From 888c5cfd21ccae0575c5239aea70f18729e2ec52 Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Wed, 26 Jan 2011 16:09:18 -0400 Subject: [PATCH] Adopted PDF content model to use tabs. --- ObjectHelper.inc | 81 +----------------------------- plugins/ShowStreamsInFieldSets.inc | 32 +++++++++--- 2 files changed, 27 insertions(+), 86 deletions(-) diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 3276fc9f..81e09186 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -501,19 +501,7 @@ class ObjectHelper { return '
' . $content . '
'; } - /** - * Queries a collection object for an xslt to format how the - * collection of objects is displayed. - */ - function getXslContent($pid, $path, $canUseDefault = TRUE) { - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - $collectionClass = new CollectionClass(); - $xslContent = $collectionClass->getCollectionViewStream($pid); - if (!$xslContent && $canUseDefault) { //no xslt so we will use the default sent with the module - $xslContent = file_get_contents($path . '/xsl/sparql_to_html.xsl'); - } - return $xslContent; - } + /** * returns a stream from a fedora object given a pid and dsid @@ -755,73 +743,6 @@ class ObjectHelper { return $parent_collections_HTML; } - - function renderCollection($content, $pid, $dsId, $collection, $pageNumber = NULL) { - $path = drupal_get_path('module', 'fedora_repository'); - global $base_url; - $collection_pid = $pid; //we will be changing the pid later maybe - //module_load_include('php', ''Fedora_Repository'', 'ObjectHelper'); - $objectHelper = $this; - $parsedContent = NULL; - $contentModels = $objectHelper->get_content_models_list($pid); - $isCollection = FALSE; - //if this is a collection object store the $pid in the session as it will come in handy - //after a purge or ingest to return to the correct collection. - - $fedoraItem = NULL; - - - - $collectionName = $collection; - if (!$pageNumber) { - $pageNumber = 1; - } - - if (!isset($collectionName)) { - $collectionName = variable_get('fedora_repository_name', 'Collection'); - } - $xslContent = $this->getXslContent($pid, $path); - - //get collection list and display using xslt------------------------------------------- - $objectList = ''; - if (isset($content) && $content != FALSE) { - $input = new DomDocument(); - $input->loadXML(trim($content)); - $results = $input->getElementsByTagName('result'); - if ($results->length > 0) { - try { - $proc = new XsltProcessor(); - $proc->setParameter('', 'collectionPid', $collection_pid); - $proc->setParameter('', 'collectionTitle', $collectionName); - $proc->setParameter('', 'baseUrl', $base_url); - $proc->setParameter('', 'path', $base_url . '/' . $path); - $proc->setParameter('', 'hitPage', $pageNumber); - $proc->registerPHPFunctions(); - $xsl = new DomDocument(); - $xsl->loadXML($xslContent); - // php xsl does not seem to work with namespaces so removing it below - // I may have just been being stupid here - // $content = str_ireplace('xmlns="http://www.w3.org/2001/sw/DataAccess/rf1/result"', '', $content); - - $xsl = $proc->importStylesheet($xsl); - $newdom = $proc->transformToDoc($input); - - $objectList = $newdom->saveXML(); //is the xml transformed to html as defined in the xslt associated with the collection object - - if (!$objectList) { - throw new Exception("Invalid XML."); - } - } catch (Exception $e) { - drupal_set_message(t('!e', array('!e' => $e->getMessage())), 'error'); - return ''; - } - } - } else { - drupal_set_message(t("No Objects in this collection or bad query.")); - } - return $objectList; - } - /** * gets a list of datastreams and related function that we should use to show datastreams in their own fieldsets diff --git a/plugins/ShowStreamsInFieldSets.inc b/plugins/ShowStreamsInFieldSets.inc index ad3f2829..d2108293 100644 --- a/plugins/ShowStreamsInFieldSets.inc +++ b/plugins/ShowStreamsInFieldSets.inc @@ -57,7 +57,8 @@ class ShowStreamsInFieldSets { */ function showPDFPreview() { global $base_url; - + global $user; + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $tabset = array(); $tabset['my_tabset'] = array( @@ -66,11 +67,33 @@ class ShowStreamsInFieldSets { $tabset['my_tabset']['first_tab'] = array( '#type' => 'tabpage', '#title' => t('Description'), - '#content' => $this->showQdc(), ); + $tabset['my_tabset']['first_tab']['tabset'] = array( + '#type' => 'tabset', + ); + $objectHelper = new ObjectHelper(); + $item = new Fedora_Item($this->pid); + $dc_html = $objectHelper->getFormattedDC($item); + + $ds_list = $objectHelper->getFormattedDatastreamList($this->pid, NULL, $item); + + $tabset['my_tabset']['first_tab']['tabset']['view'] = array( + '#type' => 'tabpage', + '#title' => t('View'), + '#content' => $dc_html . $ds_list, + ); + + 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( + '#type' => 'tabpage', + '#title' => t('Edit'), + '#content' => $editform, + ); + } + $tabset['my_tabset']['second_tab'] = array( -// $collection_fieldset = array ( '#type' => 'tabpage', '#title' => t('Read Online'), '#content' => "