Browse Source

Merge pull request #653 from ajstanley/7.x

Add content model to object overview
pull/657/head
Rosemary Le Faive 8 years ago committed by GitHub
parent
commit
c98f29cec6
  1. 47
      islandora.module
  2. 11
      theme/islandora-object-overview.tpl.php
  3. 23
      theme/theme.inc

47
islandora.module

@ -459,7 +459,8 @@ function islandora_theme() {
'variables' => array( 'variables' => array(
'object' => NULL, 'object' => NULL,
'content' => NULL, 'content' => NULL,
'islandora_content' => NULL), 'islandora_content' => NULL,
),
), ),
// Render a bunch of objects as either a grid or a list. // Render a bunch of objects as either a grid or a list.
'islandora_objects' => array( 'islandora_objects' => array(
@ -562,6 +563,12 @@ function islandora_theme() {
'file' => 'includes/solution_packs.inc', 'file' => 'includes/solution_packs.inc',
'render element' => 'form', 'render element' => 'form',
), ),
// Overview for manage tab.
'islandora_object_overview' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-object-overview',
'variables' => array('islandora_object' => NULL),
),
); );
} }
@ -919,40 +926,21 @@ function islandora_object_manage_access_callback($perms, $object = NULL) {
*/ */
function islandora_manage_overview_object(AbstractObject $object) { function islandora_manage_overview_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/utilities'); module_load_include('inc', 'islandora', 'includes/utilities');
$output = array(); $output = islandora_create_manage_overview($object);
$hooks = islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models); $hooks = islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models);
foreach ($hooks as $hook) { foreach ($hooks as $hook) {
$temp = module_invoke_all($hook, $object); $temp = module_invoke_all($hook, $object);
islandora_as_renderable_array($temp); islandora_as_renderable_array($temp);
if (!empty($temp)) { if (!empty($temp)) {
arsort($temp);
$output = array_merge_recursive($output, $temp); $output = array_merge_recursive($output, $temp);
} }
} }
if (empty($output)) {
// Add in the default, if we did not get any results.
$output = islandora_default_islandora_manage_overview_object($object);
}
arsort($output);
drupal_alter($hooks, $object, $output); drupal_alter($hooks, $object, $output);
islandora_as_renderable_array($output); islandora_as_renderable_array($output);
return $output; return $output;
} }
/**
* Renders the default manage object page for the given object.
*
* @param AbstractObject $object
* The object used to render the manage object page.
*
* @return array
* The default rendering of the object manage page, indexed at
* 'Default Edit output'.
*/
function islandora_default_islandora_manage_overview_object(AbstractObject $object) {
$output = theme('islandora_default_overview', array('islandora_object' => $object));
return array('Default overview output' => array('#markup' => $output));
}
/** /**
* Renders the given objects manage page. * Renders the given objects manage page.
* *
@ -1819,7 +1807,6 @@ function islandora_islandora_object_purged($pid) {
islandora_conditionally_clear_cache(); islandora_conditionally_clear_cache();
} }
/** /**
* Implements hook_islandora_datastream_purged(). * Implements hook_islandora_datastream_purged().
*/ */
@ -2170,3 +2157,17 @@ function islandora_islandora_get_breadcrumb_query_predicates(AbstractObject $obj
'fedora-rels-ext:isMemberOf', 'fedora-rels-ext:isMemberOf',
); );
} }
/**
* Provides information for the object manage page.
*
* @param AbstractObject $object
* The object being managed.
*
* @return array
* themed output
*/
function islandora_create_manage_overview(AbstractObject $object) {
$output = theme('islandora_object_overview', array('islandora_object' => $object));
return array('cmodels' => $output);
}

11
theme/islandora-object-overview.tpl.php

@ -0,0 +1,11 @@
<?php
/**
* @file
* The default islandora object overview.
*/
?>
<div class="islandora-object-overview">
<p class = 'islandora_overview_header'><?php print $header; ?></p>
<p class = 'islandora_overview_list'><?php print $list; ?></p>
</div>

23
theme/theme.inc

@ -647,3 +647,26 @@ function islandora_preprocess_islandora_dublin_core_description(array &$variable
} }
$variables['dc_array'] = isset($dc_object) ? $dc_object->asArray() : array(); $variables['dc_array'] = isset($dc_object) ? $dc_object->asArray() : array();
} }
/**
* Implements hook_preprocess().
*/
function islandora_preprocess_islandora_object_overview(array &$variables) {
$object = $variables['islandora_object'];
$cmodels = $object->models;
$links = array();
foreach ($cmodels as $cmodel) {
if ($cmodel != 'fedora-system:FedoraObject-3.0') {
$o = islandora_object_load($cmodel);
if (is_object($o)) {
$links[] = array(l($o->label, "islandora/object/{$o->id}"));
}
else {
$links[] = array(t("@cmodel - (This content model is not in this Islandora repository.)", array('@cmodel' => $cmodel)));
}
}
}
$pluralized_identifier = format_plural(count($links), 'Islandora content model', 'Islandora content models');
$variables['header'] = t("This object's behavior is defined by the @identifier", array("@identifier" => $pluralized_identifier));
$variables['list'] = theme('item_list', array('items' => $links));
}

Loading…
Cancel
Save