Browse Source

refactored to themed list, cleaned out non-functional code

pull/653/head
ajstanley 8 years ago
parent
commit
b5181b8653
  1. 60
      islandora.module
  2. 23
      theme/theme.inc

60
islandora.module

@ -22,7 +22,6 @@
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
// Common datastreams.
define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
@ -459,7 +458,8 @@ function islandora_theme() {
'variables' => array(
'object' => NULL,
'content' => NULL,
'islandora_content' => NULL),
'islandora_content' => NULL,
),
),
// Render a bunch of objects as either a grid or a list.
'islandora_objects' => array(
@ -562,6 +562,12 @@ function islandora_theme() {
'file' => 'includes/solution_packs.inc',
'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 +925,21 @@ function islandora_object_manage_access_callback($perms, $object = NULL) {
*/
function islandora_manage_overview_object(AbstractObject $object) {
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);
foreach ($hooks as $hook) {
$temp = module_invoke_all($hook, $object);
islandora_as_renderable_array($temp);
if (!empty($temp)) {
arsort($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);
islandora_as_renderable_array($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.
*
@ -1819,7 +1806,6 @@ function islandora_islandora_object_purged($pid) {
islandora_conditionally_clear_cache();
}
/**
* Implements hook_islandora_datastream_purged().
*/
@ -2174,27 +2160,7 @@ function islandora_islandora_get_breadcrumb_query_predicates(AbstractObject $obj
/**
* Implements hook_islandora_overview_object().
*/
function islandora_islandora_overview_object(AbstractObject $object) {
$cmodels = $object->models;
$rows = array();
foreach ($cmodels as $cmodel) {
if ($cmodel != 'fedora-system:FedoraObject-3.0') {
$o = islandora_object_load($cmodel);
if (is_object($o)) {
$rows[] = array(l($o->label, "islandora/object/{$o->id}"));
}
else {
$rows[] = array(t("@cmodel - (This content model is not in this Islandora repository.)", array('@cmodel' => $cmodel)));
}
}
}
$header = format_plural(count($rows), 'Content Model', 'Content Models');
$table = array(
'#type' => 'markup',
'#theme' => 'table',
'#header' => array($header),
'#rows' => $rows,
'#empty' => t('No Islandora content model associated with this object.'),
);
return array('cmodels' => $table);
function islandora_create_manage_overview(AbstractObject $object) {
$output = theme('islandora_object_overview', array('islandora_object' => $object));
return array('cmodels' => $output);
}

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();
}
/**
* 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