diff --git a/CollectionClass.inc b/CollectionClass.inc index 0e518b6d..e50ca224 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) ), - ); + ); } } diff --git a/api/fedora_item.inc b/api/fedora_item.inc index d4c8aff0..7fdd211c 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -347,7 +347,10 @@ RDF; $modified = FALSE; $rels = $relsextxml->getElementsByTagNameNS($namespaceURI, $relationship); if (!empty($rels)) { - foreach ($rels as $rel) { + // 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) { // 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) ||