Browse Source

ISLANDORA-171 Make tabs modular.

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
245bb3ac0a
  1. 6
      ContentModel.inc
  2. 7
      ObjectHelper.inc
  3. 24
      fedora_repository.module
  4. 10
      formClass.inc
  5. 15
      plugins/ShowStreamsInFieldSets.inc

6
ContentModel.inc

@ -37,9 +37,9 @@ class ContentModel extends XMLDatastream {
$content_models = $objectHelper->get_content_models_list($pid);
foreach ($content_models as $content_model) {
if ($content_model != 'fedora-system:FedoraObject-3.0') {
$ret = self::loadFromModel($content_model);
$ret = $content_model;
break;
}
}
}
}
return $ret;
@ -1467,7 +1467,7 @@ class ContentModel extends XMLDatastream {
self::$errors[] = 'Execute Form Handler: method \''. $className .'->'. $methodName .'\' does not exist.';
}
else {
$output .= $class->$methodName($page_number);
$output = $class->$methodName($page_number);
}
}
}

7
ObjectHelper.inc

@ -564,15 +564,16 @@ class ObjectHelper {
if (!isset($sxml)) {
return $pids;
}
$cmodels = array();
foreach ($sxml->xpath('//@uri') as $uri) {
if (strpos($uri, 'fedora-system') != FALSE && $include_fedora_system_content_models == FALSE) {
continue;
}
$pids[] = substr(strstr($uri, '/'), 1);
$cmodel_pid = substr(strstr($uri, '/'), 1);
$cmodels[] = ContentModel::loadFromModel($cmodel_pid);
}
return $pids;
return $cmodels;
}
/*

24
fedora_repository.module

@ -751,7 +751,7 @@ function makeObject($pid, $dsID) {
* if there is no query datastream falls back to the query shipped with the module.
* @return String
*/
function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $pageNumber = NULL, $limit = NULL) {
function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NULL, $page_number = NULL, $limit = NULL) {
module_load_include('inc', 'fedora_repository', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
global $user;
@ -801,24 +801,40 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
// $limit=20;
//}
module_load_include('inc', 'fedora_repository', 'ContentModel');
$breadcrumbs = array();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($breadcrumbs));
$offset = $limit * $pageNumber;
$offset = $limit * $page_number;
//$results = $collectionClass->getRelatedObjects($pid, $limit, $offset, NULL); //updated so we can do paging in query not in xslt
//$results = $collectionClass->getRelatedItems($pid, NULL);
$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 .= $objectHelper->createExtraFieldsets($pid, $content_model, $pageNumber);
//$content_model_fieldsets = $objectHelper->createExtraFieldsets($pid, $content_model, $pageNumber);
$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['tabset'][$content_model->pid] = array(
'#type' => 'tabpage',
'#title' => $cmodel->name,
'#content' => $content_model_fieldset,
);
}
}
//$content .= $objectHelper
//$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber);
//the below is for islandlives we should be able to do this in the xslt though
//$css=$path.'/stylesheets/container-large.css';
//drupal_add_css($css);
return $content . '</div>';
return tabs_render($cmodels_tabs) . '</div>';
}
function fedora_repository_urlencode_string($str) {

10
formClass.inc

@ -614,12 +614,12 @@ class formClass {
if (!empty($content_models)) {
foreach ($content_models as $content_model) {
if (($cm = ContentModel::loadFromModel($content_model)) !== FALSE) {
$newElements = $cm->listDatastreams();
if (!empty($newElements)) {
$available_dsids = array_merge($available_dsids, $newElements);
}
$newElements = $content_model->listDatastreams();
if (!empty($newElements)) {
$available_dsids = array_merge($available_dsids, $newElements);
}
}
}

15
plugins/ShowStreamsInFieldSets.inc

@ -62,15 +62,12 @@ class ShowStreamsInFieldSets {
module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$tabset = array();
$tabset['my_tabset'] = array(
'#type' => 'tabset',
);
$tabset['my_tabset']['first_tab'] = array(
$tabset['first_tab'] = array(
'#type' => 'tabpage',
'#title' => t('Description'),
);
$tabset['my_tabset']['first_tab']['tabset'] = array(
$tabset['first_tab']['tabs'] = array(
'#type' => 'tabset',
);
$objectHelper = new ObjectHelper();
@ -86,7 +83,7 @@ class ShowStreamsInFieldSets {
$dl_link = l('<div style="float:left; padding: 10px"><img src="'.$tn_url.'"><br />View Document</div>', '/fedora/repository/'.$this->pid.'/OBJ', array('html' => TRUE));
$ds_list = $objectHelper->getFormattedDatastreamList($this->pid, NULL, $item);
$tabset['my_tabset']['first_tab']['tabset']['view'] = array(
$tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage',
'#title' => t('View'),
'#content' => $dl_link . $dc_html . $ds_list,
@ -94,14 +91,14 @@ class ShowStreamsInFieldSets {
if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) {
$editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC');
$tabset['my_tabset']['first_tab']['tabset']['edit'] = array(
$tabset['first_tab']['tabs']['edit'] = array(
'#type' => 'tabpage',
'#title' => t('Edit'),
'#content' => $editform,
);
}
$tabset['my_tabset']['second_tab'] = array(
$tabset['second_tab'] = array(
'#type' => 'tabpage',
'#title' => t('Read Online'),
'#content' => "<iframe src=\"http://docs.google.com/viewer?url=". $base_url . '/fedora/repository/'.
@ -109,7 +106,7 @@ class ShowStreamsInFieldSets {
);
// Render the tabset.
return tabs_render($tabset);
return $tabset;
}

Loading…
Cancel
Save