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

7
ObjectHelper.inc

@ -564,15 +564,16 @@ class ObjectHelper {
if (!isset($sxml)) { if (!isset($sxml)) {
return $pids; return $pids;
} }
$cmodels = array();
foreach ($sxml->xpath('//@uri') as $uri) { foreach ($sxml->xpath('//@uri') as $uri) {
if (strpos($uri, 'fedora-system') != FALSE && $include_fedora_system_content_models == FALSE) { if (strpos($uri, 'fedora-system') != FALSE && $include_fedora_system_content_models == FALSE) {
continue; 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. * if there is no query datastream falls back to the query shipped with the module.
* @return String * @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', 'ObjectHelper');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
global $user; global $user;
@ -801,24 +801,40 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU
// $limit=20; // $limit=20;
//} //}
module_load_include('inc', 'fedora_repository', 'ContentModel');
$breadcrumbs = array(); $breadcrumbs = array();
$objectHelper->getBreadcrumbs($pid, $breadcrumbs); $objectHelper->getBreadcrumbs($pid, $breadcrumbs);
drupal_set_breadcrumb(array_reverse($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->getRelatedObjects($pid, $limit, $offset, NULL); //updated so we can do paging in query not in xslt
//$results = $collectionClass->getRelatedItems($pid, NULL); //$results = $collectionClass->getRelatedItems($pid, NULL);
$content_models = $objectHelper->get_content_models_list($pid); $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) { 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
//$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); //$content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber);
//the below is for islandlives we should be able to do this in the xslt though //the below is for islandlives we should be able to do this in the xslt though
//$css=$path.'/stylesheets/container-large.css'; //$css=$path.'/stylesheets/container-large.css';
//drupal_add_css($css); //drupal_add_css($css);
return $content . '</div>'; return tabs_render($cmodels_tabs) . '</div>';
} }
function fedora_repository_urlencode_string($str) { function fedora_repository_urlencode_string($str) {

10
formClass.inc

@ -614,12 +614,12 @@ class formClass {
if (!empty($content_models)) { if (!empty($content_models)) {
foreach ($content_models as $content_model) { foreach ($content_models as $content_model) {
if (($cm = ContentModel::loadFromModel($content_model)) !== FALSE) {
$newElements = $cm->listDatastreams(); $newElements = $content_model->listDatastreams();
if (!empty($newElements)) { if (!empty($newElements)) {
$available_dsids = array_merge($available_dsids, $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'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
$tabset = array(); $tabset = array();
$tabset['my_tabset'] = array( $tabset['first_tab'] = array(
'#type' => 'tabset',
);
$tabset['my_tabset']['first_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Description'), '#title' => t('Description'),
); );
$tabset['my_tabset']['first_tab']['tabset'] = array( $tabset['first_tab']['tabs'] = array(
'#type' => 'tabset', '#type' => 'tabset',
); );
$objectHelper = new ObjectHelper(); $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)); $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); $ds_list = $objectHelper->getFormattedDatastreamList($this->pid, NULL, $item);
$tabset['my_tabset']['first_tab']['tabset']['view'] = array( $tabset['first_tab']['tabs']['view'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('View'), '#title' => t('View'),
'#content' => $dl_link . $dc_html . $ds_list, '#content' => $dl_link . $dc_html . $ds_list,
@ -94,14 +91,14 @@ class ShowStreamsInFieldSets {
if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) { if (fedora_repository_access(OBJECTHELPER :: $EDIT_FEDORA_METADATA, $this->pid, $user)) {
$editform = drupal_get_form('fedora_repository_edit_qdc_form', $this->pid, 'DC'); $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', '#type' => 'tabpage',
'#title' => t('Edit'), '#title' => t('Edit'),
'#content' => $editform, '#content' => $editform,
); );
} }
$tabset['my_tabset']['second_tab'] = array( $tabset['second_tab'] = array(
'#type' => 'tabpage', '#type' => 'tabpage',
'#title' => t('Read Online'), '#title' => t('Read Online'),
'#content' => "<iframe src=\"http://docs.google.com/viewer?url=". $base_url . '/fedora/repository/'. '#content' => "<iframe src=\"http://docs.google.com/viewer?url=". $base_url . '/fedora/repository/'.
@ -109,7 +106,7 @@ class ShowStreamsInFieldSets {
); );
// Render the tabset. // Render the tabset.
return tabs_render($tabset); return $tabset;
} }

Loading…
Cancel
Save