From 2371ea7869f07ab929d2fe7b60dfa1b3680726f9 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 19 Jun 2012 09:39:57 -0300 Subject: [PATCH 1/5] Use function to get query. --- CollectionClass.inc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index e1ec846e..0e518b6d 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -533,16 +533,12 @@ class CollectionClass { function showFieldSets($page_number) { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - //module_load_include('inc', 'fedora_repository', 'BatchIngest'); //Legacy code? global $base_url; global $user; $tabset = array(); - $query = NULL; + $query = self::getCollectionQuery($this->pid); $item = new Fedora_Item($this->pid); - if ($item->exists() && array_key_exists('QUERY', $item->datastreams)) { - $query = $item->get_datastream_dissemination('QUERY'); - } $results = $this->getRelatedItems($this->pid, $query); $collection_items = $this->renderCollection($results, $this->pid, NULL, NULL, $page_number); From 2b471e48a6a99f0efac1399515b013b345e1fd85 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 20 Jun 2012 14:42:57 -0300 Subject: [PATCH 2/5] Removed Useless Configuration Options There are old configuration options that predate time (are older then islandora has been in GIT) that just don't do anything anymore. We used to hide them in advanced settings. Just killed them. --- .gitignore | 1 + ObjectHelper.inc | 105 +--------------------------------- fedora_repository.module | 119 +++++++++++++++------------------------ formClass.inc | 30 ---------- 4 files changed, 46 insertions(+), 209 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1ffd7408 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nbproject diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 27e2f746..d34e64c3 100644 --- a/ObjectHelper.inc +++ b/ObjectHelper.inc @@ -19,9 +19,7 @@ class ObjectHelper { public static $INGEST_FEDORA_OBJECTS = 'ingest new fedora objects'; public static $EDIT_TAGS_DATASTREAM = 'edit tags datastream'; public static $VIEW_DETAILED_CONTENT_LIST = 'view detailed list of content'; - public static $DISPLAY_ALWAYS = 0; - public static $DISPLAY_NEVER = 1; - public static $DISPLAY_NO_MODEL_OUTPUT = 2; + // TODO: Make this into a static member constant public $availableDataStreamsText = 'Detailed list of content'; @@ -705,107 +703,6 @@ class ObjectHelper { return ($namespace_access && user_access($op, $as_user)); } - /** - * internal function - * uses an xsl to parse the sparql xml returned from the ITQL query - * @deprecated - * This is only used in the fedora/repository/collection path, - * which should probably be nuked. - * @param $content String - */ - function parseContent($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 - $objectHelper = $this; - $parsedContent = NULL; - $contentModels = $this->get_content_models_list($pid); - $isCollection = FALSE; - - $fedoraItem = NULL; - $datastreams = $this->get_formatted_datastream_list($pid, $contentModels, $fedoraItem); - - if (!empty($contentModels)) { - foreach ($contentModels as $contentModel) { - if ($contentModel == variable_get('fedora_collection_model_pid', 'islandora:collectionCModel')) { - //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. - - $_SESSION['fedora_collection'] = $pid; - $isCollection = TRUE; - } - } - } - - if ($fedoraItem !== NULL) { - $dslist = $fedoraItem->get_datastreams_list_as_array(); - if (isset($dslist['COLLECTION_POLICY'])) { - $isCollection = TRUE; - } - } - //-------------------------------------------------------------------------------- - //show the collections datastreams - if ($results->length > 0 || $isCollection == TRUE) { - // if(strlen($objectList)>22||$contentModel=='Collection'||$contentModel=='Community')//length of empty dom still equals 22 because of etc - module_load_include('inc', 'fedora_repository', 'CollectionPolicy'); - $collectionPolicyExists = $this->getMimeType($pid, CollectionPolicy::getDefaultDSID()); - if (user_access(ObjectHelper::$INGEST_FEDORA_OBJECTS) && $collectionPolicyExists) { - if (!empty($collectionPolicyExists)) { - $allow = TRUE; - if (module_exists('fedora_fesl')) { - $allow = fedora_fesl_check_roles($pid, 'write'); - } - if ($allow) { - // $ingestObject = ' array( - 'class' => 'icon', - 'title' => $ingest_text, - ))) . t('Add to this Collection'); - } - } - } - else { - $ingestObject = ' '; - } - } - - $datastreams .= $ingestObject; - - - $output .= $datastreams; - - $showDesc = FALSE; - switch (variable_get('fedora_object_display_description', ObjectHelper :: $DISPLAY_NO_MODEL_OUTPUT)) { - case ObjectHelper :: $DISPLAY_NEVER: break; - case ObjectHelper :: $DISPLAY_NO_MODEL_OUTPUT: - if (trim($datastreams) == '') { - $showDesc = TRUE; - } - break; - - case ObjectHelper :: $DISPLAY_ALWAYS: - default: - $showDesc = TRUE; - break; - } - if ($showDesc) { - //just show default dc or qdc as we could not find a content model - $metaDataText = t('Description'); - $body = $this->getQDC($pid); - $fieldset = array( - '#title' => t("!metaDataText", array('!metaDataText' => $metaDataText)), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#value' => $body - ); - $output .= theme('fieldset', $fieldset); - } - - - return $output; - } - /** * Get the query to find parent objects. * diff --git a/fedora_repository.module b/fedora_repository.module index a4f337e9..33860ab8 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -62,37 +62,6 @@ function fedora_repository_purge_object($pid = NULL, $name = NULL) { return $output; } -/** - * fedora repository collection view - * @global type $user - * @param type $pid - * @param type $collection - * @param type $pageNumber - * @return type - */ -function fedora_repository_collection_view($pid = NULL, $collection = NULL, $pageNumber = NULL) { - module_load_include('inc', 'fedora_repository', 'ObjectHelper'); - global $user; - if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { - drupal_set_message(t("You do not have access to Fedora objects within the attempted namespace or access to Fedora denied."), 'error'); - return ' '; - } - - $objectHelper = new ObjectHelper(); - if ($pid == NULL) { - $pid = variable_get('fedora_repository_pid', 'islandora:root'); - } - - $content = ''; - - module_load_include('inc', 'fedora_repository', 'CollectionClass'); - $collectionClass = new CollectionClass(); - $results = $collectionClass->getRelatedItems($pid, NULL); - $content .= $objectHelper->parseContent($results, $pid, $dsId, $collection, $pageNumber); - - return $content; -} - /** * fedora repository ingest object * @param type $collection_pid @@ -978,30 +947,30 @@ function makeObject($pid, $dsID) { function fedora_repository_islandora_tabs($content_models, $pid, $page_number) { $cmodels_tabs = array(); - foreach ($content_models as $content_model) { + 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, - ); - } - } - - //can disable showing the object details tab in admin UI + // 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, + ); + } + } + + //can disable showing the object details tab in admin UI if (variable_get('fedora_repository_show_object_details_tab', TRUE)) { - // 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'); + // 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); - + $object_details = $obj->showFieldSets(); $cmodels_tabs = array_merge($cmodels_tabs, $object_details); } @@ -1124,16 +1093,16 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU //Get the tabs from all modules... $hook_tabs = module_invoke_all('islandora_tabs', $content_models, $pid, $page_number); - $cmodels_tabs = array( - '#type' => 'tabset', + $cmodels_tabs = array( + '#type' => 'tabset', ); $cmodels_tabs += $hook_tabs; //Assemble parameters, to pass during alter - $params = array( - 'content_models' => $content_models, - 'pid' => $pid, - 'page' => $page_number, + $params = array( + 'content_models' => $content_models, + 'pid' => $pid, + 'page' => $page_number, ); //Allow returned tabs to be altered, before return. @@ -2435,21 +2404,21 @@ function fedora_repository_imagecache_default_presets() { * @return * Markup for the image, making use of imagecache_external if it is available. */ -function _fedora_repository_render_image($tn_path, $imagecache_preset = 'fedora_repository_collection_thumbnail') { - $thumbnail = NULL; - if ($thumbnail === NULL && - module_exists('imagecache_external') && - is_callable('theme_imagecache_external_image') && +function _fedora_repository_render_image($tn_path, $imagecache_preset = 'fedora_repository_collection_thumbnail') { + $thumbnail = NULL; + if ($thumbnail === NULL && + module_exists('imagecache_external') && + is_callable('theme_imagecache_external_image') && variable_get('fedora_repository_use_imagecache_external_in_collection_view', FALSE) && - imagecache_external_can_fetch($tn_path, TRUE)) { - $thumbnail = theme('imagecache_external_image', $imagecache_preset, $tn_path, $truncated_title, $title); - } - if ($thumbnail === NULL) { - $thumbnail = theme('image', $tn_path, $truncated_title, $title, array(), FALSE); - } - - return $thumbnail; -} + imagecache_external_can_fetch($tn_path, TRUE)) { + $thumbnail = theme('imagecache_external_image', $imagecache_preset, $tn_path, $truncated_title, $title); + } + if ($thumbnail === NULL) { + $thumbnail = theme('image', $tn_path, $truncated_title, $title, array(), FALSE); + } + + return $thumbnail; +} /** * Render an image, given a PID, DSID and preset. @@ -2466,11 +2435,11 @@ function _fedora_repository_render_image($tn_path, $imagecache_preset = 'fedora_ * An imagecache preset with which to render the image; defaults to * fedora_repository_collection_thumbnail, which is added in this module's * implementation of hook_imagecache_default_presets(). - */ -function fedora_repository_render_image($pid, $dsid, $imagecache_preset = 'fedora_repository_collection_thumbnail') { - $tn_path = "fedora/repository/$pid/$dsid"; - - return _fedora_repository_render_image($tn_path, $imagecache_preset); + */ +function fedora_repository_render_image($pid, $dsid, $imagecache_preset = 'fedora_repository_collection_thumbnail') { + $tn_path = "fedora/repository/$pid/$dsid"; + + return _fedora_repository_render_image($tn_path, $imagecache_preset); } /** diff --git a/formClass.inc b/formClass.inc index 06d840de..5184cf78 100644 --- a/formClass.inc +++ b/formClass.inc @@ -122,13 +122,6 @@ class formClass { 'type' => MENU_CALLBACK, 'access arguments' => array('add fedora datastreams') ); - - $items['fedora/repository/collection'] = array( - 'title' => t('Collection view'), - 'page callback' => 'fedora_collection_view', - 'type' => MENU_CALLBACK, - 'access argruments' => array('view fedora collection'), - ); //new for mnpl****************************************** $items['fedora/repository/mnpl_advanced_search'] = array( @@ -347,21 +340,6 @@ class formClass { '#collapsible' => TRUE, '#collapsed' => TRUE, ); - $form['advanced']['fedora_object_display_title'] = array( - '#type' => 'select', - '#title' => t('Display Object Title Behaviour'), - '#default_value' => variable_get('fedora_object_display_title', ObjectHelper::$DISPLAY_ALWAYS), - '#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')), - '#description' => t('Determines when to display the object (or collection) title when viewing an object/collection page.'), - ); - - $form['advanced']['fedora_object_display_description'] = array( - '#type' => 'select', - '#title' => t('Display Object Description Behaviour'), - '#default_value' => variable_get('fedora_object_display_description', ObjectHelper::$DISPLAY_ALWAYS), - '#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')), - '#description' => t('Determines when to display the default object (or collection) description fieldset when viewing an object/collection page.'), - ); $form['advanced']['fedora_object_restrict_datastreams'] = array( '#type' => 'checkbox', @@ -384,14 +362,6 @@ class formClass { '@xsl' => 'sparql_to_html.xsl', )), ); - - $form['advanced']['fedora_collection_display_list'] = array( - '#type' => 'select', - '#title' => t('Display Collection List Behaviour'), - '#default_value' => variable_get('fedora_collection_display_list', ObjectHelper::$DISPLAY_ALWAYS), - '#options' => array(ObjectHelper::$DISPLAY_ALWAYS => t('Always'), ObjectHelper::$DISPLAY_NEVER => t('Never'), ObjectHelper::$DISPLAY_NO_MODEL_OUTPUT => t('Only if no Content Model display output.')), - '#description' => t('Determines when to display the list of objects when viewing a collection page.'), - ); $form['advanced']['fedora_control_group_control_during_ingest'] = array( '#type' => 'checkbox', From d5549e9a3373c56fc90e3eb5cbc07998e010e13e Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 20 Jun 2012 14:50:37 -0300 Subject: [PATCH 3/5] Fixed Namespaces Message --- fedora_repository.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.module b/fedora_repository.module index 33860ab8..7e50c81c 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1060,7 +1060,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU } if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed @here", array('@here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed @here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); } drupal_access_denied(); exit; From a3c66723f16786c124d51cf4fd709c7223458523 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 20 Jun 2012 14:51:30 -0300 Subject: [PATCH 4/5] Fixed Namespaces Message (for real this time) --- fedora_repository.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fedora_repository.module b/fedora_repository.module index 7e50c81c..3037a878 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -1060,7 +1060,7 @@ function fedora_repository_get_items($pid = NULL, $dsId = NULL, $collection = NU } if (!fedora_repository_access(OBJECTHELPER::$OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { if (user_access('access administration pages')) { - drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed @here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); + drupal_set_message(t("PIDs may be added to allowed namespaces, or all namespace restrictions removed !here", array('!here' => l('here', 'admin/settings/fedora_repository'))), 'warning'); } drupal_access_denied(); exit; From 0b8ef2ecd990281d565dd637e0468920c722d863 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Wed, 20 Jun 2012 20:37:48 +0200 Subject: [PATCH 5/5] Fixed where I missed avoiding the page cache for datastreams. --- fedora_repository.module | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fedora_repository.module b/fedora_repository.module index a4f337e9..747eb204 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -948,7 +948,7 @@ function makeObject($pid, $dsID) { drupal_set_message(t("No pid or dsid given to create an object with.")); return ' '; } - global $user; + global $user, $conf; if (!fedora_repository_access(OBJECTHELPER :: $OBJECT_HELPER_VIEW_FEDORA, $pid, $user)) { drupal_access_denied(); return; @@ -956,6 +956,9 @@ function makeObject($pid, $dsID) { return ' '; } + //Disable the page cache, so entire datastreams do not get thrown into the page cache. + $conf['cache'] = CACHE_DISABLED; + module_load_include('inc', 'fedora_repository', 'ObjectHelper'); $objectHelper = new ObjectHelper(); $objectHelper->makeObject($pid, $dsID);