From dbadd0ce5a791f2f3b712f23d1e69beac8ba285a Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Thu, 31 May 2012 13:20:42 -0300 Subject: [PATCH] added a wrapper template for collection objects --- islandora.module | 1 + .../islandora-basic-collection-grid.tpl.php | 4 +- ...islandora-basic-collection-wrapper.tpl.php | 32 ++++++++++++++++ .../islandora-basic-collection.tpl.php | 4 +- .../islandora_basic_collection.info | 2 +- .../islandora_basic_collection.module | 37 +++++++++++++------ 6 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 islandora_basic_collection/islandora-basic-collection-wrapper.tpl.php diff --git a/islandora.module b/islandora.module index 50cb36ba..5ee0f746 100644 --- a/islandora.module +++ b/islandora.module @@ -516,6 +516,7 @@ function islandora_view_object($object_id = NULL) { drupal_set_message(t('there was an error loading the view for islandora object %s', array('%s' => $object_id)), 'error'); return ""; } + arsort($arr); drupal_alter('islandora_display',$arr); $output = ""; foreach ($arr as $key => $value) { diff --git a/islandora_basic_collection/islandora-basic-collection-grid.tpl.php b/islandora_basic_collection/islandora-basic-collection-grid.tpl.php index 05b3d807..f56a80b4 100644 --- a/islandora_basic_collection/islandora-basic-collection-grid.tpl.php +++ b/islandora_basic_collection/islandora-basic-collection-grid.tpl.php @@ -21,17 +21,15 @@ * along with the program. If not, see . */ ?> - +
- $value): ?>
-
\ No newline at end of file diff --git a/islandora_basic_collection/islandora-basic-collection-wrapper.tpl.php b/islandora_basic_collection/islandora-basic-collection-wrapper.tpl.php new file mode 100644 index 00000000..1f9f3b3d --- /dev/null +++ b/islandora_basic_collection/islandora-basic-collection-wrapper.tpl.php @@ -0,0 +1,32 @@ +. + */ +?> +label); ?> + +
+
+ + + +
+
\ 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 92c9ec5f..d4cbf264 100644 --- a/islandora_basic_collection/islandora-basic-collection.tpl.php +++ b/islandora_basic_collection/islandora-basic-collection.tpl.php @@ -24,14 +24,12 @@ label); ?>
-
- +
$value): ?>
-
\ No newline at end of file diff --git a/islandora_basic_collection/islandora_basic_collection.info b/islandora_basic_collection/islandora_basic_collection.info index 0254df74..7663b814 100644 --- a/islandora_basic_collection/islandora_basic_collection.info +++ b/islandora_basic_collection/islandora_basic_collection.info @@ -4,4 +4,4 @@ dependencies[] = islandora package = Islandora core = 7.x stylesheets[all][] = css/islandora_basic_collection.base.css -stylesheets[all][] = css/islandora_basic_collection.theme.css +stylesheets[all][] = css/islandora_basic_collection.theme.css \ 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 4a9e8bda..aa7d2be3 100644 --- a/islandora_basic_collection/islandora_basic_collection.module +++ b/islandora_basic_collection/islandora_basic_collection.module @@ -199,6 +199,10 @@ function islandora_basic_collection_theme($existing, $type, $theme, $path) { 'islandora_basic_collection_grid' => array( 'template' => 'islandora-basic-collection-grid', 'pattern' => 'islandora_basic_collection_grid__', + 'variables' => array('islandora_object' => NULL, 'collection_results' => NULL), + ), + 'islandora_basic_collection_wrapper' => array( + 'template' => 'islandora-basic-collection-wrapper', 'variables' => array('islandora_object' => NULL), ), 'islandora_basic_collection_management_form_table' => array( @@ -241,13 +245,7 @@ function islandora_basic_collection_islandora_view_object($object, $user) { $models = $object->models; foreach ($object->models as $model) { if (isset($cmodel_list[$model][ISLANDORA_VIEW_HOOK]) && $cmodel_list[$model][ISLANDORA_VIEW_HOOK] == TRUE) { - $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)); - } + $output = theme('islandora_basic_collection_wrapper', array('islandora_object' => $object,)); return array('Collection View' => $output); } } @@ -263,6 +261,24 @@ function islandora_basic_collection_preprocess_islandora_basic_collection_grid(& islandora_basic_collection_preprocess_islandora_basic_collection($variables); } +function islandora_basic_collection_preprocess_islandora_basic_collection_wrapper(&$variables) { + $page_number = (empty($_GET['page'])) ? 0 : $_GET['page']; + $page_size = (empty($_GET['pagesize'])) ? variable_get('islandora_basic_collection_page_size', '10') : $_GET['pagesize']; + $islandora_object = $variables['islandora_object']; + $results = islandora_basic_collection_get_objects($islandora_object, $page_number, $page_size); + $total_count = count($results); + pager_default_initialize($total_count, $page_size); + $variables['collection_pager'] = theme('pager', array('quantity' => $total_count)); + $display = (empty($_GET['display'])) ? 'list' : $_GET['display']; + if ($display == 'grid') { + $collection_content = theme('islandora_basic_collection_grid', array('islandora_object' => $islandora_object, 'collection_results' => $results)); + } + else { + $collection_content = theme('islandora_basic_collection', array('islandora_object' => $islandora_object, 'collection_results' => $results)); + } + $variables['collection_content'] = $collection_content; +} + /** * * @global type $base_url @@ -284,12 +300,8 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari } $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); + $results = $variables['collection_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); @@ -335,6 +347,7 @@ function islandora_basic_collection_preprocess_islandora_basic_collection(&$vari $thumbnail_img = ''; } else { + //TODO: change this default image url $thumbnail_img = ''; } $associated_objects_array[$pid]['thumbnail'] = $thumbnail_img;