Browse Source

Use hook_islandora_tabs() to add ALL the tabs.

...  Including those provided by islandora proper.
pull/126/head
Adam Vessey 13 years ago committed by Adam Vessey
parent
commit
f51cdfe115
  1. 109
      fedora_repository.module

109
fedora_repository.module

@ -951,6 +951,63 @@ function makeObject($pid, $dsID) {
$objectHelper->makeObject($pid, $dsID);
}
/**
* Implementation of hook_islandora_tabs().
*
* @param $content_models array
* An array of ContentModel objects to which the current Fedora Object
* subscribes.
* @param $pid string
* A string containing the Fedora PID of the current Fedora Object.
* @param $page_number integer
* An integer for which page we should start on in the loaded object.
* @return array
* An array containing a tabset (an array of tabpages), renderable with
* drupal_render().
*/
function fedora_repository_islandora_tabs($content_models, $pid, $page_number) {
$cmodels_tabs = array(
'#type' => 'tabset',
);
foreach ($content_models as $content_model) {
$content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number);
// Each content model may return either a tabpage array or plain HTML. If
// it is HTML, stick it in a tabpage.
if (is_array($content_model_fieldset)) {
$cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset);
}
else {
$cmodels_tabs[$content_model->pid] = array(
'#type' => 'tabpage',
'#title' => $content_model->name,
'#content' => $content_model_fieldset,
);
}
}
// Add a 'manage object' tab for all objects, where detailed list of content is shown.
// XXX: Perhaps this should be extracted into its own object?
module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent');
$obj = new FedoraObjectDetailedContent($pid);
//can disable showing the object details tab in admin UI
if (variable_get('fedora_repository_show_object_details_tab', TRUE)) {
$object_details = $obj->showFieldSets();
if ($object_details['fedora_object_details']['#selected'] == TRUE) {
foreach (element_children($cmodels_tabs) as $key) {
$cmodels_tabs[$key]['#selected'] = FALSE;
}
}
}
else {
$object_details = array();
}
return array_merge($cmodels_tabs, $object_details);
}
/**
* Sends an ITQL query to the Fedora Resource index (can only communicate with Kowari or mulgara)
* Reads the pid and datastream id as url parameters. Queries the collection object for the query
@ -984,7 +1041,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
$pid = variable_get('fedora_repository_pid', 'islandora:root');
}
$item = new fedora_item($pid);
$item = new Fedora_Item($pid);
if (!$item->exists()) {
drupal_not_found();
exit();
@ -1023,57 +1080,19 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
return makeObject($pid, $dsId);
}
$content = '<div id="content-fedora">';
module_load_include('inc', 'fedora_repository', 'CollectionClass');
$collectionClass = new CollectionClass();
module_load_include('inc', 'fedora_repository', 'ContentModel');
module_load_include('inc', 'fedora_repository', 'plugins/FedoraObjectDetailedContent');
$breadcrumbs = array();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
$offset = $limit * $page_number;
$content_models = $objectHelper->get_content_models_list($pid);
// Each content model may return either a tabset array or plain HTML. If it's HTML, stick it in a tab.
$cmodels_tabs = array(
'#type' => 'tabset',
);
foreach ($content_models as $content_model) {
$content_model_fieldset = $content_model->displayExtraFieldset($pid, $page_number);
if (is_array($content_model_fieldset)) {
$cmodels_tabs = array_merge($cmodels_tabs, $content_model_fieldset);
}
else {
$cmodels_tabs[$content_model->pid] = array(
'#type' => 'tabpage',
'#title' => $content_model->name,
'#content' => $content_model_fieldset,
);
}
}
// Add a 'manage object' tab for all objects, where detailed list of content is shown.
$obj = new FedoraObjectDetailedContent($pid);
//can disable showing the object details tab in admin UI
if (variable_get('fedora_repository_show_object_details_tab', TRUE)) {
$object_details = $obj->showFieldSets();
if ($object_details['fedora_object_details']['#selected'] == TRUE) {
foreach ($cmodels_tabs as &$cmodel_tab) {
if (is_array($cmodel_tab)) {
$cmodel_tab['#selected'] = FALSE;
}
}
}
}
else {
$object_details = array();
}
$hook_tabs = module_invoke_all('islandora_tabs', $content_models, $pid, $page_number);
$cmodels_tabs = array_merge($cmodels_tabs, $object_details, $hook_tabs);
$cmodels_tabs = array(
'#type' => 'tabset',
);
$cmodels_tabs = array_merge($cmodels_tabs, $hook_tabs);
return tabs_render($cmodels_tabs);
}

Loading…
Cancel
Save