From 2b471e48a6a99f0efac1399515b013b345e1fd85 Mon Sep 17 00:00:00 2001 From: jonathangreen Date: Wed, 20 Jun 2012 14:42:57 -0300 Subject: [PATCH 1/8] 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 000000000..1ffd74082 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nbproject diff --git a/ObjectHelper.inc b/ObjectHelper.inc index 27e2f746d..d34e64c37 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 a4f337e9e..33860ab8a 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 06d840de0..5184cf78a 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 2/8] 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 33860ab8a..7e50c81c0 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 3/8] 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 7e50c81c0..3037a8787 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 4/8] 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 a4f337e9e..747eb2042 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); From 8c3da4569a6f271dd5713cb435621358fa40ece8 Mon Sep 17 00:00:00 2001 From: William Panting Date: Fri, 22 Jun 2012 16:18:45 -0300 Subject: [PATCH 5/8] ISLANDORA-581 On content model trigered tabs we use module_exists to verify if a module is present and enabled before calling code. We also use module_load_include instead of including directly. --- ContentModel.inc | 143 +++++++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 66 deletions(-) diff --git a/ContentModel.inc b/ContentModel.inc index be362c705..52ebdf09f 100644 --- a/ContentModel.inc +++ b/ContentModel.inc @@ -1,11 +1,11 @@ getAttribute('class'); - $methodName = ($method->getAttribute('method')); - if (!class_exists($className)) { - self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.'; - } - else { - $class = new $className($pid); - if (!method_exists($class, $methodName)) { - self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.'; + + $file_extension = pathinfo($method->getAttribute('file'), PATHINFO_EXTENSION); + $file_path_without_extension = $method->getAttribute('file'); + /* Only in PHP. This is meant to avoid file path + * concatenation issues.*/ + $file_path_without_extension = substr($file_path_without_extension, 0, strlen($file_path_without_extension) - (strlen($file_extension) + 1)); + /* Only try to execute if the module is present, this is + * necessarybecause we go outside of the expected + * 'Drupal Way' and have dynamic dependencies.*/ + if (module_exists(!empty($module) ? $module : 'fedora_repository')) { + module_load_include($file_extension, !empty($module) ? $module : 'fedora_repository', $file_path_without_extension); + $className = $method->getAttribute('class'); + $methodName = ($method->getAttribute('method')); + if (!class_exists($className)) { + self::$errors[] = 'Execute Form Handler: class \'' . $className . '\' does not exist.'; } else { - $output = $class->$methodName($page_number); + $class = new $className($pid); + if (!method_exists($class, $methodName)) { + self::$errors[] = 'Execute Form Handler: method \'' . $className . '->' . $methodName . '\' does not exist.'; + } + else { + $output = $class->$methodName($page_number); + } } } } @@ -1527,8 +1538,8 @@ class ContentModel extends XMLDatastream { } /** - * Adds an allowed mimetype to the model. - * + * Adds an allowed mimetype to the model. + * * @param String $type * @return boolean $success */ @@ -1581,7 +1592,7 @@ class ContentModel extends XMLDatastream { /** * getDisplayMethods ?? * @param type $ds - * @return type + * @return type */ public function getDisplayMethods($ds) { $ret = FALSE; @@ -1603,7 +1614,7 @@ class ContentModel extends XMLDatastream { * addDs ?? * @param type $dsid * @param type $display_in_fieldset - * @return boolean + * @return boolean */ public function addDs($dsid, $display_in_fieldset = FALSE) { $ret = FALSE; @@ -1632,7 +1643,7 @@ class ContentModel extends XMLDatastream { /** * removeDs ?? * @param type $dsid - * @return boolean + * @return boolean */ public function removeDs($dsid) { $ret = FALSE; @@ -1648,7 +1659,7 @@ class ContentModel extends XMLDatastream { /** * displayInFieldset ?? * @param type $dsid - * @return type + * @return type */ public function displayInFieldset($dsid) { $ret = FALSE; @@ -1662,7 +1673,7 @@ class ContentModel extends XMLDatastream { * setDisplayInFieldset ?? * @param type $dsid * @param type $value - * @return boolean + * @return boolean */ public function setDisplayInFieldset($dsid, $value = TRUE) { $ret = FALSE; @@ -1686,7 +1697,7 @@ class ContentModel extends XMLDatastream { * @param type $file * @param type $class * @param type $method - * @return boolean + * @return boolean */ public function setDefaultDispMeth($dsid, $module, $file, $class, $method) { $ret = FALSE; @@ -1725,7 +1736,7 @@ class ContentModel extends XMLDatastream { * @param type $file * @param type $class * @param type $method - * @return boolean + * @return boolean */ public function removeDispMeth($dsid, $module, $file, $class, $method) { $ret = FALSE; @@ -1757,7 +1768,7 @@ class ContentModel extends XMLDatastream { * @param type $class * @param type $method * @param type $default - * @return boolean + * @return boolean */ public function addDispMeth($dsid, $module, $file, $class, $method, $default = FALSE) { $ret = FALSE; @@ -1779,7 +1790,7 @@ class ContentModel extends XMLDatastream { /** * getAddDsMethod ?? * @param type $ds - * @return type + * @return type */ public function getAddDsMethod($ds) { $ret = FALSE; @@ -1801,7 +1812,7 @@ class ContentModel extends XMLDatastream { /** * getIngestRule ?? * @param type $rule_id - * @return type + * @return type */ public function getIngestRule($rule_id) { $ret = FALSE; @@ -1817,7 +1828,7 @@ class ContentModel extends XMLDatastream { * removeAppliesTo ?? * @param type $rule_id * @param type $type - * @return boolean + * @return boolean */ public function removeAppliesTo($rule_id, $type) { $ret = FALSE; @@ -1842,7 +1853,7 @@ class ContentModel extends XMLDatastream { * addAppliesTo ?? * @param type $rule_id * @param type $type - * @return boolean + * @return boolean */ public function addAppliesTo($rule_id, $type) { $ret = FALSE; @@ -1871,7 +1882,7 @@ class ContentModel extends XMLDatastream { * @param type $method * @param type $dsid * @param type $modified_files_ext - * @return boolean + * @return boolean */ public function addIngestMethod($rule_id, $module, $file, $class, $method, $dsid, $modified_files_ext) { $ret = FALSE; @@ -1898,7 +1909,7 @@ class ContentModel extends XMLDatastream { * @param type $file * @param type $class * @param type $method - * @return boolean + * @return boolean */ public function removeIngestMethod($rule_id, $module, $file, $class, $method) { $ret = FALSE; @@ -1929,7 +1940,7 @@ class ContentModel extends XMLDatastream { * @param type $method * @param type $name * @param type $value - * @return boolean + * @return boolean */ public function addIngestMethodParam($rule_id, $module, $file, $class, $method, $name, $value) { $ret = FALSE; @@ -1981,7 +1992,7 @@ class ContentModel extends XMLDatastream { * @param type $class * @param type $method * @param type $name - * @return boolean + * @return boolean */ public function removeIngestMethodParam($rule_id, $module, $file, $class, $method, $name) { $ret = FALSE; @@ -2024,7 +2035,7 @@ class ContentModel extends XMLDatastream { /** * removeIngestRule ?? * @param type $rule_id - * @return type + * @return type */ public function removeIngestRule($rule_id) { $ret = FALSE; @@ -2043,7 +2054,7 @@ class ContentModel extends XMLDatastream { * @param type $method * @param type $dsid * @param type $modified_files_ext - * @return type + * @return type */ public function addIngestRule($applies_to, $module, $file, $class, $method, $dsid, $modified_files_ext) { $ret = FALSE; @@ -2061,7 +2072,7 @@ class ContentModel extends XMLDatastream { /** * getIngestRules ?? - * @return type + * @return type */ public function getIngestRules() { $ret = FALSE; @@ -2105,7 +2116,7 @@ class ContentModel extends XMLDatastream { /** * getIngestFormAttributes ?? - * @return type + * @return type */ public function getIngestFormAttributes() { $ret = FALSE; @@ -2125,7 +2136,7 @@ class ContentModel extends XMLDatastream { * @param type $page * @param type $hide_file_chooser * @param type $redirect - * @return boolean + * @return boolean */ public function editIngestFormAttributes($dsid, $page, $hide_file_chooser = FALSE, $redirect = TRUE) { $ret = FALSE; @@ -2152,7 +2163,7 @@ class ContentModel extends XMLDatastream { /** * getIngestFormBuilderMethod - * @return type + * @return type */ public function getIngestFormBuilderMethod() { $ret = FALSE; @@ -2174,7 +2185,7 @@ class ContentModel extends XMLDatastream { * @param type $class * @param type $method * @param type $handler - * @return boolean + * @return boolean */ public function editIngestFormBuilderMethod($module, $file, $class, $method, $handler) { $ret = FALSE; @@ -2192,7 +2203,7 @@ class ContentModel extends XMLDatastream { /** * Find the form element with name $name. - * + * * @param string $name * The name of the form element to find. * @return DOMElement @@ -2263,7 +2274,7 @@ class ContentModel extends XMLDatastream { * * @param string $name * Name of the form to remove. - * + * * @return boolean * TRUE on success, FALSE otherwise. */ From 21a6fd1aee9b41058084b27998576d894f6b96fd Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Tue, 26 Jun 2012 11:08:13 -0300 Subject: [PATCH 6/8] updated getCollectionQuery to call out an alter for other modules to update the query (specifically for the xacml module, but others could alter as well) --- CollectionClass.inc | 82 ++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index 0e518b6d5..e50ca224b 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -2,10 +2,10 @@ /** * @file - * + * * Collection Class Class */ - + /** * This CLASS caches the streams so once you call a getstream once it will always return * the same stream as long as you are using the instance of this class. Cached to @@ -34,12 +34,12 @@ class CollectionClass { } public static function getCollectionQuery($pid) { - if ($query = self::getCollectionQueryFromStream($pid)) { - return $query; - } - else { - return self::getDefaultCollectionQuery($pid); + $query = self::getCollectionQueryFromStream($pid); + if (!$query) { + $query = self::getDefaultCollectionQuery($pid); } + drupal_alter("islandora_collection_query", $query, $pid); + return $query; } protected static function getCollectionQueryFromStream($pid) { @@ -684,17 +684,17 @@ class CollectionClass { * An array to be passed to drupal_render, containing a pager, an unordered * list of items, and another pager. */ - public static function assembleCollectionView($sparql_results) { - $per_page = 20; //XXX: Make this configurable. - $pager_name = 0; - $total = count($sparql_results); + public static function assembleCollectionView($sparql_results) { + $per_page = 20; //XXX: Make this configurable. + $pager_name = 0; + $total = count($sparql_results); $pager_page = self::hackPager($pager_name, $per_page, $total); - $max_title_length = 60; - - $results = array(); - foreach (array_slice($sparql_results, $per_page * $pager_page, $per_page) as $result) { + $max_title_length = 60; + + $results = array(); + foreach (array_slice($sparql_results, $per_page * $pager_page, $per_page) as $result) { $title = $result['title']; - $truncated_title = truncate_utf8($title, $max_title_length, TRUE, TRUE, 5); + $truncated_title = truncate_utf8($title, $max_title_length, TRUE, TRUE, 5); $obj_path = "fedora/repository/{$result['object']}"; //Get a thumbnail @@ -703,28 +703,28 @@ class CollectionClass { "$obj_path/TN"); $thumbnail = _fedora_repository_render_image($tn_path); - - $results[] = array( - 'data' => l($thumbnail, $obj_path, array( - 'html' => TRUE, - 'attributes' => array( - 'class' => 'results-image', - ), - )) . l($truncated_title, $obj_path, array('attributes' => array('class' => 'results-text'))), - ); - } - if (!$results) { - drupal_set_message(t("No objects in this collection (or bad query).")); - } - else { - $first = $per_page * $pager_page; - $last = (($total - $first) > $per_page)? - ($first + $per_page): - $total; - $results_range_text = t('Results @first to @last of @total', array( - '@first' => $first + 1, - '@last' => $last, - '@total' => $total, + + $results[] = array( + 'data' => l($thumbnail, $obj_path, array( + 'html' => TRUE, + 'attributes' => array( + 'class' => 'results-image', + ), + )) . l($truncated_title, $obj_path, array('attributes' => array('class' => 'results-text'))), + ); + } + if (!$results) { + drupal_set_message(t("No objects in this collection (or bad query).")); + } + else { + $first = $per_page * $pager_page; + $last = (($total - $first) > $per_page)? + ($first + $per_page): + $total; + $results_range_text = t('Results @first to @last of @total', array( + '@first' => $first + 1, + '@last' => $last, + '@total' => $total, )); return array( @@ -734,15 +734,15 @@ class CollectionClass { ), array( '#type' => 'markup', - '#value' => theme('item_list', $results, $result_range_text, 'ul', array( - 'class' => 'islandora-collection-results-list', + '#value' => theme('item_list', $results, $result_range_text, 'ul', array( + 'class' => 'islandora-collection-results-list', )) ), array( '#type' => 'markup', '#value' => theme('pager', array(), $per_page, $pager_name) ), - ); + ); } } From 845c33964a534c32c248d0276c0623139ebe0e90 Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Tue, 26 Jun 2012 11:19:24 -0300 Subject: [PATCH 7/8] updated purge_datastream to iterate backwards through the rels elements instead of forward so it can correctly remove all of them --- api/fedora_item.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index d4c8aff04..a41529aaf 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -347,7 +347,9 @@ RDF; $modified = FALSE; $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); if (!empty($rels)) { - foreach ($rels as $rel) { + for ($i = $rels->length; $i>0; $i--) { + $rel = $rels->item($i-1); +// foreach ($rels as $rel) { if ( //If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. empty($object) || (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) || From 530d5a3aca407b1e30308824dd3b7f142925390c Mon Sep 17 00:00:00 2001 From: Jason MacWilliams Date: Tue, 26 Jun 2012 12:01:00 -0300 Subject: [PATCH 8/8] added notes to reverse iterator in purge_relationships --- api/fedora_item.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index a41529aaf..7fdd211c6 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -347,9 +347,10 @@ RDF; $modified = FALSE; $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); if (!empty($rels)) { + // iterate backwards so if we delete something our pointer doesn't get out of sync for ($i = $rels->length; $i>0; $i--) { $rel = $rels->item($i-1); -// foreach ($rels as $rel) { +// foreach ($rels as $rel) { // moving forward like this caused iteration errors when something was deleted if ( //If either no object is specified, or the object matches (in either the literal or URI case), remove this node from it's parent, and mark as changed. empty($object) || (($literal_value == RELS_TYPE_URI) && $rel->getAttributeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource') == $object) ||