diff --git a/css/islandora.base.css b/css/islandora.base.css index 0a8b3662..585ad756 100644 --- a/css/islandora.base.css +++ b/css/islandora.base.css @@ -32,14 +32,14 @@ dl.islandora-inline-metadata { .islandora-inline-metadata dt { margin-right: -1px; - width: 15.625%; - font-weight: normal; + width: 20.625%; font-weight: bold; padding-right: 0; + word-wrap: normal; } .islandora-inline-metadata dd { - width: 84.375%; + width: 79.375%; padding-left: 40px; } diff --git a/css/islandora.theme.css b/css/islandora.theme.css index e299b9db..29f14e66 100644 --- a/css/islandora.theme.css +++ b/css/islandora.theme.css @@ -13,19 +13,24 @@ dl.islandora-object-tn { float: left; width: 20.8333%; padding: 0 10px 0 0; - margin: 0; + margin: 1.5em 0; } dl.islandora-object-fields { float: right; width:79.1666%; - border-top:3px solid #ddd; + border-top:0px solid #ddd; + margin: 1.5em 0; } .islandora-object-fields dt { font-weight: bold; } +.islandora-object-fields dt.first { + border-top:0; +} + .islandora-object-fields dt, .islandora-object-fields dd { padding:6px 2% 4px; diff --git a/includes/datastream.inc b/includes/datastream.inc index 2c7e58b2..8ac9e9de 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -24,7 +24,9 @@ function islandora_datastream_as_attachment($object_id, $dsid) { return""; } header('Content-type: ' . $fedora_object[$dsid]->mimetype); - header('Content-length: ' . $fedora_object[$dsid]->size); + if($fedora_object[$dsid]->controlGroup == 'M' || $fedora_object[$dsid]->controlGroup == 'X') { + header('Content-length: ' . $fedora_object[$dsid]->size); + } header("Cache-control: private"); $method = arg(5); if (isset($method) && $method == 'download') { @@ -34,6 +36,29 @@ function islandora_datastream_as_attachment($object_id, $dsid) { exit(); } +function islandora_get_datastream_parents($islandora_object) { + $parent_collections = array(); + $repository = $islandora_object->repository; + $collections1 = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOfCollection'); + $collections2 = $islandora_object->relationships->get(FEDORA_RELS_EXT_URI, 'isMemberOf'); + $collections = array_merge($collections1, $collections2); + + foreach($collections as $collection) { + try { + $pid = $collection['object']['value']; + $object = $repository->getObject($collection['object']['value']); + $parent_collections[$pid] = array(); + $parent_collections[$pid]['object'] = $object; + $parent_collections[$pid]['url'] = 'islandora/object/' . $object->id; + $parent_collections[$pid]['label'] = $object->label; + $parent_collections[$pid]['label_link'] = l($parent_collections[$pid]['label'], $parent_collections[$pid]['url']); + } + catch (RepositoryException $e) {} + } + + return $parent_collections; +} + /** * * @param array $arr @@ -280,8 +305,8 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) { $form['add_fieldset'] = array( '#type' => 'fieldset', '#title' => 'Add a datastream', - '#collapsible' => TRUE, - '#collapsed' => TRUE, + '#collapsible' => FALSE, + '#collapsed' => FALSE, ); $form['add_fieldset']['add_datastream_label'] = array( '#value' => t('

Add Datastream:

'), @@ -339,3 +364,24 @@ function islandora_add_datastream_form($form, &$form_state, $object_id) { } return $form; } + +function islandora_datastream_get_human_readable_size($ds) { + module_load_include('inc', 'islandora', 'includes/utilities'); + + // we return - if we don't have a size + if($ds->controlGroup == 'M' || $ds->controlGroup == 'X') { + return islandora_convert_bytes_to_human_readable($ds->size); + } + else { + return '-'; + } +} + +function islandora_datastream_get_url($ds, $type = 'download') { + if($ds->controlGroup == 'R') { + return $ds->url; + } + else { + return "islandora/object/{$ds->parent->id}/datastream/{$ds->id}/$type"; + } +} \ No newline at end of file diff --git a/includes/object_properties.inc b/includes/object_properties.inc index 34a7b67e..97dd20a4 100644 --- a/includes/object_properties.inc +++ b/includes/object_properties.inc @@ -1,8 +1,17 @@ owner){ - $params['ownerId'] = check_plain($owner); - $submit = TRUE; - } - if(isset($state) && $state != $islandora_object->state){ - $params['state'] = check_plain($state); - $submit = TRUE; + if (isset($owner) && $owner != $islandora_object->owner) { + try { + $islandora_object->owner = $owner; + drupal_set_message(t('Successfully updated owner %s', array('%s' => $owner))); + } catch (Exception $e) { + form_set_error('object_owner',t('Error updating owner %s', array('%s'=> $e->getMessage()))); + } } - if(isset($label) && $label != $islandora_object->label){ - $params['label'] = check_plain($label); - $submit = TRUE; + if (isset($state) && $state != $islandora_object->state) { + try { + $islandora_object->state = $state; + drupal_set_message(t('Successfully updated state %s', array('%s' => $state))); + } catch (Exception $e) { + form_set_error('object_state',t('Error updating state %s', array('%s'=> $e->getMessage()))); + } } - if($submit){ - $islandora_object->modifyObject($params); + if (isset($label) && $label != $islandora_object->label) { + try { + $islandora_object->label = $label; + drupal_set_message(t('Successfully updated label %s', array('%s' => check_plain($label)))); + } catch (Exception $e) { + form_set_error(t('Error updating label %s', array('%s' => $e->getMessage()))); + } } } @@ -45,10 +61,11 @@ function islandora_edit_properties_form_submit($form, &$form_state){ * an object id * @return array */ -function islandora_edit_properties_form ($form, &$form_state, $object_id){ +function islandora_edit_properties_form($form, &$form_state, $object_id) { $form = array(); $islandora_object = islandora_get_object($object_id); - if(!isset($islandora_object)){ + drupal_set_title($islandora_object->label); + if (!isset($islandora_object)) { return NULL; } $form['pid'] = array( @@ -76,7 +93,7 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){ '#required' => TRUE, '#description' => t('The items state one of active, inactive or deleted'), '#type' => 'select', - '#options' => array ('A' => 'Active', 'I' => 'Inactive', 'D'=>'Deleted'), + '#options' => array('A' => 'Active', 'I' => 'Inactive', 'D' => 'Deleted'), ); $form['submit'] = array( '#type' => 'submit', @@ -84,4 +101,5 @@ function islandora_edit_properties_form ($form, &$form_state, $object_id){ ); return $form; } + ?> diff --git a/includes/utilities.inc b/includes/utilities.inc new file mode 100644 index 00000000..edb49780 --- /dev/null +++ b/includes/utilities.inc @@ -0,0 +1,48 @@ += 0) && ($bytes < $kilobyte)) { + return $bytes . ' B'; + + } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { + return round($bytes / $kilobyte, $precision) . ' KB'; + + } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { + return round($bytes / $megabyte, $precision) . ' MB'; + + } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { + return round($bytes / $gigabyte, $precision) . ' GB'; + + } elseif ($bytes >= $terabyte) { + return round($bytes / $terabyte, $precision) . ' TB'; + } else { + return $bytes . ' B'; + } +} + +function islandora_control_group_to_human_readable($control_group) { + switch($control_group) { + case 'M': + return 'Managed'; + case 'X': + return 'Inline XML'; + case 'R': + return 'Redirect'; + case 'E': + return 'Externally Referenced'; + default: + return $control_group; + } +} \ No newline at end of file diff --git a/islandora-object-edit.tpl.php b/islandora-object-edit.tpl.php index f06d8f64..409c9781 100644 --- a/islandora-object-edit.tpl.php +++ b/islandora-object-edit.tpl.php @@ -44,17 +44,8 @@ //dsm($object); drupal_set_title($islandora_object->label); -$islandora_datastreams = $variables['islandora_datastreams']; -print($islandora_object->label . ' ' . $islandora_object->id); -print ('

datastreams

'); -foreach ($islandora_datastreams as $dsid => $ds) { - print (l($ds['label'],$ds['view_url'])); - print (' ' . l('download', $ds['download_url'])); - print (' ' . l('delete', $ds['delete_url'])); - print ('
'); +//print($islandora_object->label . ' ' . $islandora_object->id); -} -print (drupal_render($variables['add_datastream_form'])); -print (l(t('Edit Metadata'),$variables['islandora_editmetadata_url'])); +print ($variables['datastream_table']); ?> diff --git a/islandora-object.tpl.php b/islandora-object.tpl.php index 06b11cab..4a50d07f 100644 --- a/islandora-object.tpl.php +++ b/islandora-object.tpl.php @@ -27,15 +27,46 @@ * this is a template for objects that do not have a module to registered to build their display. * * islandora_object is a fedora tuque Object - * $object->label - * $object->id + * $object->label - The label for this object. + * $object->id - The identifier of the object. + * $object->state - The state of this object. + * $object->createdDate - The date the object was ingested. + * $object->lastModifiedDate - The date teh object was last mofified. + * * to get the contents of a datastream - * $object['dsid']->content + * $object['dsid']->content + * + * to test if a datastream exists isset($object['dsid']) + * + * to iterate over datastreams: + * foreach($object as $ds) { + * $ds->label, etc + * } + * + * each $ds in the above loop has the following properties: + * $ds->label - The label for this datastream. + * $ds->id - The identifier of the datastream. + * $ds->controlGroup - The control group of the datastream. This + * property is read-only. This will return one of: "X", "M", "R", or "E". + * $ds->versionable - This defines if the datastream will be versioned + * or not. This is boolean. + * $ds->state - The state of the datastream. This will be one + * of: "A", "I", "D". + * $ds->mimetype - The mimetype of the datastrem. + * $ds->format - The format of the datastream + * $ds->size - The size of the datastream + * $ds->checksum - The checksum of the datastream + * $ds->checksumType - The type of checksum for the datastream. + * $ds->createdDate->format("Y-m-d") - The created date with an option to use a format of your choice + * $ds->content - The content of the datastream + * $ds->url - The URL. This is only valid for R and E datastreams. * * $dublin_core is a Dublin_Core object * which is an array of elements, such as dc.title * and each element has an array of values. dc.title can have none, one or many titles * this is the case for all dc elements. + * + * * * we can get a list of datastreams by doing * foreach ($object as $ds){ @@ -44,30 +75,7 @@ * */ -//dsm($object); drupal_set_title($islandora_object->label); -// $dublin_core = $variables['islandora_dublin_core']; -// print($islandora_object->label . ' ' . $islandora_object->id); -// print ('

datastreams

'); -// foreach ($islandora_object as $ds) { -// print $ds->label . '
'; -// //do something -// } -// print('

Dublin Core

'); - -// foreach ($dublin_core as $element) { -// if (!empty($element)) { -// // print($element); -// foreach ($element as $key => $value) { -// foreach($value as $v){ -// if(!empty($v)){ -// print ''.($key).': ';print($v).'
'; -// } -// } -// } -// } -// } - ?>

Details

@@ -87,7 +95,36 @@ drupal_set_title($islandora_object->label);
- + +
Collections
+
+ $value): ?> +
+ +
+ diff --git a/islandora.module b/islandora.module index 521101bc..15813359 100644 --- a/islandora.module +++ b/islandora.module @@ -108,16 +108,6 @@ function islandora_menu() { 'access arguments' => array(FEDORA_VIEW), ); - - $items['islandora/object/%/add'] = array( - 'title' => 'Add to an object', - 'file' => 'includes/datastream.inc', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('islandora_add_datastream_form',2), - 'type' => MENU_NORMAL_ITEM, - 'access arguments' => array(FEDORA_ADD_DS) - ); - $items['islandora/object/%/view'] = array( 'title' => 'View', @@ -146,9 +136,9 @@ function islandora_menu() { $items['islandora/object/%/manage/datastreams'] = array( 'title' => 'Datastreams', - 'page callback' => 'islandora_edit_object', + //'page callback' => 'islandora_edit_object', 'page arguments' => array(2), - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_DEFAULT_LOCAL_TASK, 'access arguments' => array(FEDORA_PURGE), 'weight' => -10, ); @@ -157,13 +147,12 @@ function islandora_menu() { 'title' => 'Properties', 'page callback' => 'drupal_get_form', 'file' => 'includes/object_properties.inc', - 'page arguments' => array('islandora_edit_properties_form',2), + 'page arguments' => array('islandora_edit_properties_form', 2), 'type' => MENU_LOCAL_TASK, 'access arguments' => array(FEDORA_MODIFY_STATE), 'weight' => -5, ); - $items['islandora/object/%/delete'] = array( 'title' => 'Purge object', 'page callback' => 'islandora_purge_object', @@ -172,6 +161,26 @@ function islandora_menu() { 'access arguments' => array(FEDORA_PURGE), ); + $items['islandora/object/%/manage/datastreams/add'] = array( + 'title' => 'Add a datastream', + 'file' => 'includes/datastream.inc', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('islandora_add_datastream_form', 2), + 'type' => MENU_NORMAL_ITEM, + 'access arguments' => array(FEDORA_ADD_DS) + ); + + + // $items['islandora/object/%/add'] = array( + // 'title' => 'Add to an object', + // 'file' => 'includes/datastream.inc', + // 'page callback' => 'drupal_get_form', + // 'page arguments' => array('islandora_add_datastream_form',2), + // 'type' => MENU_NORMAL_ITEM, + // 'access arguments' => array(FEDORA_ADD_DS) + // ); + + $items['islandora/object/%/datastream/%'] = array( 'title' => 'View datastream', 'page callback' => 'islandora_datastream_as_attachment', @@ -223,6 +232,23 @@ function islandora_admin_paths_alter(&$paths) { $paths['*/manage*'] = TRUE; } +/** + * Implements hook_menu_local_tasks_alter(). + */ +function islandora_menu_local_tasks_alter(&$data, $router_item, $root_path) { + // Add action link 'islandora/object/%/manage/datastreams'. + if ($root_path == 'islandora/object/%/manage') { + $object_id = $router_item['page_arguments'][0]; + $item = menu_get_item("islandora/object/$object_id/manage/datastreams/add"); + if ($item['access']) { + $data['actions']['output'][] = array( + '#theme' => 'menu_local_action', + '#link' => $item, + ); + } + } +} + /** * determines whether we can see the object or not * checks PID namespace permissions, and user permissions @@ -353,7 +379,7 @@ function islandora_edit_object($object_id) { function islandora_edit_properties($object_id) { $object = islandora_get_object($object_id); if (isset($object)) { - module_load_include('inc','islandora','includes/object_properties'); + module_load_include('inc', 'islandora', 'includes/object_properties'); $form = drupal_get_form('islandora_edit_properties_form', $object); drupal_set_title($object->label); return drupal_render($form); @@ -567,8 +593,31 @@ function islandora_permission() { * @param array $variables */ function islandora_preprocess_islandora_default(&$variables) { + drupal_add_js('misc/form.js'); + drupal_add_js('misc/collapse.js'); $islandora_object = $variables['islandora_object']; module_load_include('inc', 'islandora', 'includes/islandora_dublin_core'); + module_load_include('inc', 'islandora', 'includes/utilities'); + module_load_include('inc', 'islandora', 'includes/datastream'); + + $variables['parent_collections'] = islandora_get_datastream_parents($islandora_object); + + $datastreams = array(); + foreach ($islandora_object as $ds) { + $pid = $islandora_object->id; + $id = $ds->id; + $label = $ds->label; + $download_path = islandora_datastream_get_url($ds, 'download'); + $datastreams[$id]['id'] = $id; + $datastreams[$id]['label'] = $label; + $datastreams[$id]['label_link'] = l($label, $download_path); + $datastreams[$id]['download_url'] = $download_path; + $datastreams[$id]['mimetype'] = $ds->mimetype; + $datastreams[$id]['size'] = islandora_datastream_get_human_readable_size($ds); + $datastreams[$id]['created_date'] = $ds->createdDate->format("Y-m-d"); + $datastreams[$id]['class'] = strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $id)); + } + $variables['datastreams'] = $datastreams; try { $dc = $islandora_object['DC']->content; //$dc_xml = simplexml_load_string($dc); @@ -615,13 +664,32 @@ function islandora_preprocess_islandora_default_edit(&$variables) { global $base_url; $datastreams = array(); $variables['islandora_editmetadata_url'] = $base_url . '/islandora/edit_form/' . $islandora_object->id; - module_load_include('inc','islandora','includes/datastream'); - $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); + module_load_include('inc', 'islandora', 'includes/datastream'); + module_load_include('inc', 'islandora', 'includes/utilities'); + // $variables['add_datastream_form'] = drupal_get_form('islandora_add_datastream_form', $islandora_object->id); + $header = array( + array('data' => t('ID')), + array('data' => t('Label')), + array('data' => t('Type')), + array('data' => t('Mime type')), + array('data' => t('Size')), + array('data' => t('Operations'), 'colspan' => '2'), + //array('data' => t('Delete')), + ); + $table_attributes = array('class' => array('manage-datastreams')); + $rows = array(); foreach ($islandora_object as $ds) { - $datastreams['download_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/download'; - $datastreams['view_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/view'; - $datastreams['delete_url'] = $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete'; - $datastreams['label'] = $ds->label; - $variables['islandora_datastreams'][$ds->id] = $datastreams; + $rows[] = array( + array('class' => 'datastream-id', 'data' => l($ds->id, islandora_datastream_get_url($ds, 'view'))), + array('class' => 'datastream-label', 'data' => $ds->label), + array('class' => 'datastream-control', 'data' => islandora_control_group_to_human_readable($ds->controlGroup)), + array('class' => 'datastream-mime', 'data' => $ds->mimeType), + array('class' => 'datastream-size', 'data' => islandora_datastream_get_human_readable_size($ds)), + array('class' => 'datastream-download', 'data' => l(t('download'), islandora_datastream_get_url($ds, 'download'))), + array('class' => 'datastream-delete', 'data' => l(t('delete'), $base_url . '/islandora/object/' . $islandora_object->id . '/datastream/' . $ds->id . '/delete')), + ); } + $caption = $islandora_object->label . ' - ' . $islandora_object->id; + $table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes); + $variables['datastream_table'] = theme_table($table); } \ No newline at end of file diff --git a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc index 6bef9d51..4054cfc8 100644 --- a/islandora_basic_collection/admin/islandora_basic_collection.admin.inc +++ b/islandora_basic_collection/admin/islandora_basic_collection.admin.inc @@ -14,11 +14,18 @@ function islandora_basic_collection_admin() { $form['islandora_basic_collection_use_for_default_tab'] = array( '#type' => 'checkbox', '#title' => t('Provide the view for the default tab'), - '#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', 'TRUE'), + '#default_value' => variable_get('islandora_basic_collection_use_for_default_tab', TRUE), '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content on a view tab you may have multiple modules configured to provide content for the default tab.'), '#weight' => -10 ); + $form['islandora_basic_collection_page_size'] = array( + '#type' => 'textfield', + '#title' => t('The default number of objects to show for a collection'), + '#default_value' => variable_get('islandora_basic_collection_page_size', '10'), + '#description' => t('The default number of object to show in a collection view.'), + '#weight' => -10 + ); return system_settings_form($form); -} \ No newline at end of file +} diff --git a/islandora_basic_collection/css/islandora_basic_collection.admin.css b/islandora_basic_collection/css/islandora_basic_collection.admin.css index ab1e4e86..714b8ba9 100644 --- a/islandora_basic_collection/css/islandora_basic_collection.admin.css +++ b/islandora_basic_collection/css/islandora_basic_collection.admin.css @@ -4,6 +4,3 @@ Description: Purpose of the stylesheet follows. */ - - - diff --git a/islandora_basic_collection/css/islandora_basic_collection.theme.css b/islandora_basic_collection/css/islandora_basic_collection.theme.css index e00d319c..80dc3c4d 100644 --- a/islandora_basic_collection/css/islandora_basic_collection.theme.css +++ b/islandora_basic_collection/css/islandora_basic_collection.theme.css @@ -38,3 +38,9 @@ dl.islandora-basic-collection-object margin: 0; padding: 0; } + +/* to be moved to admin when it is added */ +#islandora-collection-deletion-form table th.select-all, +#islandora-collection-migrate-form table th.select-all { + width: 20px; +} diff --git a/islandora_basic_collection/islandora-basic-collection-grid.tpl.php b/islandora_basic_collection/islandora-basic-collection-grid.tpl.php new file mode 100644 index 00000000..05b3d807 --- /dev/null +++ b/islandora_basic_collection/islandora-basic-collection-grid.tpl.php @@ -0,0 +1,37 @@ +. + */ +?> + + +
+
+ + $value): ?> +
+
+
+
+ + +
+
\ No newline at end of file diff --git a/islandora_basic_collection/islandora-basic-collection.tpl.php b/islandora_basic_collection/islandora-basic-collection.tpl.php index da5de757..92c9ec5f 100644 --- a/islandora_basic_collection/islandora-basic-collection.tpl.php +++ b/islandora_basic_collection/islandora-basic-collection.tpl.php @@ -25,11 +25,13 @@
+ $value): ?>
+
\ No newline at end of file diff --git a/islandora_basic_collection/islandora_basic_collection.module b/islandora_basic_collection/islandora_basic_collection.module index ecebc374..b8c14825 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -176,6 +176,11 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) { //an example template would be named islandora-basic-image--islandora-27.tpl.phps 'variables' => array('islandora_object' => NULL), ), + 'islandora_basic_collection_grid' => array( + 'template' => 'islandora-basic-collection-grid', + 'pattern' => 'islandora_basic_collection_grid__', + 'variables' => array('islandora_object' => NULL), + ), 'islandora_basic_collection_management_form_table' => array( 'arguments' => array('element' => NULL), 'file' => 'includes/CollectionManagerTable.inc', @@ -210,21 +215,35 @@ function islandora_basic_collection_islandora_get_types() { * @return string * themed html */ -function islandora_basic_collection_islandora_view_object($object, $user, $page_number, $page_size) { +function islandora_basic_collection_islandora_view_object($object, $user) { //global $user; $cmodel_list = islandora_basic_collection_islandora_get_types(); $models = $object->models; foreach ($object->models as $model) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { - $output = theme('islandora_basic_collection', array('islandora_object' => $object)); - return array('' => $output); + $display = (empty($_GET['display'])) ? 'list' : $_GET['display']; + if($display == 'grid'){ + $output = theme('islandora_basic_collection_grid', array('islandora_object' => $object)); + } else { + $output = theme('islandora_basic_collection', array('islandora_object' => $object)); + } + return array('Collection View' => $output); } } return NULL; } /** - * + * list view preprocess + * currently just calls normal view preprocess as variables are the same + * @param type $variables + */ +function islandora_basic_collection_preprocess_islandora_basic_collection_grid(&$variables){ + islandora_basic_collection_preprocess_islandora_basic_collection($variables); +} + +/** + * * @global type $base_url * @param array $variables * an array of variables that will be passed to the theme function @@ -242,7 +261,14 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } catch (Exception $e) { drupal_set_message(t('Error retrieving object %s %t', array('%s' => $islandora_object->id, '%t' => $e->getMessage())), 'error'); } - $variables['islandora_associated_objects'] = islandora_basic_collection_get_objects($islandora_object); + $page_number = (empty($_GET['page'])) ? 0 : $_GET['page']; + $page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize']; + $results = islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size); + $total_count = count($results); + pager_default_initialize($total_count, $page_size); + + $pager = theme('pager', array('quantity' => $total_count)); + $variables['pager'] = $pager; $variables['islandora_dublin_core'] = $dc_object; $variables['islandora_object_label'] = $islandora_object->label; $variables['theme_hook_suggestions'][] = 'islandora_basic_collection__' . str_replace(':', '_', $islandora_object->id); @@ -260,8 +286,11 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } $associated_objects_array = array(); - foreach ($variables['islandora_associated_objects'] as $key => $value) { - $pid = $variables['islandora_associated_objects'][$key]['object']['value']; + $start = $page_size * ($page_number); + $end = min($start + $page_size, $total_count); + + for ($i = $start; $i < $end; $i++) { + $pid = $results[$i]['object']['value']; $fc_object = islandora_basic_collection_get_object($pid); if (!isset($fc_object)) { continue; //null object so don't show in collection view; @@ -276,7 +305,7 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } $object_url = 'islandora/object/' . $pid; $thumbnail_img = ''; - $title = $variables['islandora_associated_objects'][$key]['title']['value']; + $title = $results[$i]['title']['value']; $associated_objects_array[$pid]['pid'] = $pid; $associated_objects_array[$pid]['path'] = $object_url; $associated_objects_array[$pid]['title'] = $title; @@ -307,7 +336,7 @@ function islandora_basic_collection_get_object($object_id) { return $fedora_object; } -function islandora_basic_collection_get_objects($object) { +function islandora_basic_collection_get_objects($object, $page_number = 1, $page_size = 5) { $query = 'select $object $title $content from <#ri> where ($object $title and $object $content @@ -316,8 +345,6 @@ function islandora_basic_collection_get_objects($object) { and $object ) minus $content order by $title'; - $page_number = (empty($_GET['page'])) ? '1' : $_GET['page']; - $page_size = (empty($_GET['pagesize'])) ? '10' : $_GET['pagesize']; module_load_include('inc', 'islandora', 'RestConnection'); $query_array = array('query' => $query, 'type' => 'itql', 'pid' => $object->id, 'page_size' => $page_size, 'page_number' => $page_number); drupal_alter('islandora_basic_collection_query', $query_array); diff --git a/islandora_basic_image/admin/islandora_basic_image.admin.inc b/islandora_basic_image/admin/islandora_basic_image.admin.inc index d31dbef0..2e6652f3 100644 --- a/islandora_basic_image/admin/islandora_basic_image.admin.inc +++ b/islandora_basic_image/admin/islandora_basic_image.admin.inc @@ -5,7 +5,7 @@ function islandora_basic_image_admin() { $form['islandora_basic_image_use_for_default_tab'] = array( '#type' => 'checkbox', '#title' => t('Provide the view for the default tab'), - '#default_value' => variable_get('islandora_basic_image_use_for_default_tab', 'TRUE'), + '#default_value' => variable_get('islandora_basic_image_use_for_default_tab', TRUE), '#description' => t('Should this module provide the view for the default view tab. If you are seeing unexpected content on a view tab you may have multiple modules configured to provide content for the default tab.'), '#weight' => -10 diff --git a/islandora_basic_image/css/islandora_basic_image.theme.css b/islandora_basic_image/css/islandora_basic_image.theme.css index e7b31c4d..93a8db89 100644 --- a/islandora_basic_image/css/islandora_basic_image.theme.css +++ b/islandora_basic_image/css/islandora_basic_image.theme.css @@ -56,6 +56,7 @@ body.two-sidebars .islandora-basic-image-sidebar { width: 60%; padding: 0 20px 0 0; float: left; /* LTR */ + margin-top: 1em; } body.no-sidebars .islandora-basic-image-sidebar { diff --git a/islandora_basic_image/islandora-basic-image.tpl.php b/islandora_basic_image/islandora-basic-image.tpl.php index a1a61da5..44228a7c 100644 --- a/islandora_basic_image/islandora-basic-image.tpl.php +++ b/islandora_basic_image/islandora-basic-image.tpl.php @@ -31,6 +31,14 @@

+
+

In Collections

+
    + $value): ?> +
  • + +
+