From 245bb3ac0a67cbefa63a02b30e102a7a69ed59b4 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Thu, 10 Feb 2011 01:59:39 -0400 Subject: [PATCH] ISLANDORA-171 Make tabs modular. --- ContentModel.inc | 6 +++--- ObjectHelper.inc | 7 ++++--- fedora_repository.module | 24 ++++++++++++++++++++---- formClass.inc | 10 +++++----- plugins/ShowStreamsInFieldSets.inc | 15 ++++++--------- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/ContentModel.inc b/ContentModel.inc index a28c7ff9..6234120b 100644 --- a/ContentModel.inc +++ b/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); } } } diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 5c70d2cc..c008ac69 100644 --- a/ObjectHelper.inc +++ b/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; } /* diff --git a/fedora_repository.module b/fedora_repository.module index a4171e4f..6ded3f2f 100644 --- a/fedora_repository.module +++ b/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 . ''; + return tabs_render($cmodels_tabs) . ''; } function fedora_repository_urlencode_string($str) { diff --git a/formClass.inc b/formClass.inc index 72ecac17..3ffaffff 100644 --- a/formClass.inc +++ b/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); } + } } diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index 1607349c..69f2bcd6 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/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('

View Document
', '/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' => "