Browse Source

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)

pull/140/head
Jason MacWilliams 13 years ago
parent
commit
21a6fd1aee
  1. 82
      CollectionClass.inc

82
CollectionClass.inc

@ -2,10 +2,10 @@
/** /**
* @file * @file
* *
* Collection Class Class * Collection Class Class
*/ */
/** /**
* This CLASS caches the streams so once you call a getstream once it will always return * 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 * 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) { public static function getCollectionQuery($pid) {
if ($query = self::getCollectionQueryFromStream($pid)) { $query = self::getCollectionQueryFromStream($pid);
return $query; if (!$query) {
} $query = self::getDefaultCollectionQuery($pid);
else {
return self::getDefaultCollectionQuery($pid);
} }
drupal_alter("islandora_collection_query", $query, $pid);
return $query;
} }
protected static function getCollectionQueryFromStream($pid) { protected static function getCollectionQueryFromStream($pid) {
@ -684,17 +684,17 @@ class CollectionClass {
* An array to be passed to drupal_render, containing a pager, an unordered * An array to be passed to drupal_render, containing a pager, an unordered
* list of items, and another pager. * list of items, and another pager.
*/ */
public static function assembleCollectionView($sparql_results) { public static function assembleCollectionView($sparql_results) {
$per_page = 20; //XXX: Make this configurable. $per_page = 20; //XXX: Make this configurable.
$pager_name = 0; $pager_name = 0;
$total = count($sparql_results); $total = count($sparql_results);
$pager_page = self::hackPager($pager_name, $per_page, $total); $pager_page = self::hackPager($pager_name, $per_page, $total);
$max_title_length = 60; $max_title_length = 60;
$results = array(); $results = array();
foreach (array_slice($sparql_results, $per_page * $pager_page, $per_page) as $result) { foreach (array_slice($sparql_results, $per_page * $pager_page, $per_page) as $result) {
$title = $result['title']; $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']}"; $obj_path = "fedora/repository/{$result['object']}";
//Get a thumbnail //Get a thumbnail
@ -703,28 +703,28 @@ class CollectionClass {
"$obj_path/TN"); "$obj_path/TN");
$thumbnail = _fedora_repository_render_image($tn_path); $thumbnail = _fedora_repository_render_image($tn_path);
$results[] = array( $results[] = array(
'data' => l($thumbnail, $obj_path, array( 'data' => l($thumbnail, $obj_path, array(
'html' => TRUE, 'html' => TRUE,
'attributes' => array( 'attributes' => array(
'class' => 'results-image', 'class' => 'results-image',
), ),
)) . l($truncated_title, $obj_path, array('attributes' => array('class' => 'results-text'))), )) . l($truncated_title, $obj_path, array('attributes' => array('class' => 'results-text'))),
); );
} }
if (!$results) { if (!$results) {
drupal_set_message(t("No objects in this collection (or bad query).")); drupal_set_message(t("No objects in this collection (or bad query)."));
} }
else { else {
$first = $per_page * $pager_page; $first = $per_page * $pager_page;
$last = (($total - $first) > $per_page)? $last = (($total - $first) > $per_page)?
($first + $per_page): ($first + $per_page):
$total; $total;
$results_range_text = t('Results @first to @last of @total', array( $results_range_text = t('Results @first to @last of @total', array(
'@first' => $first + 1, '@first' => $first + 1,
'@last' => $last, '@last' => $last,
'@total' => $total, '@total' => $total,
)); ));
return array( return array(
@ -734,15 +734,15 @@ class CollectionClass {
), ),
array( array(
'#type' => 'markup', '#type' => 'markup',
'#value' => theme('item_list', $results, $result_range_text, 'ul', array( '#value' => theme('item_list', $results, $result_range_text, 'ul', array(
'class' => 'islandora-collection-results-list', 'class' => 'islandora-collection-results-list',
)) ))
), ),
array( array(
'#type' => 'markup', '#type' => 'markup',
'#value' => theme('pager', array(), $per_page, $pager_name) '#value' => theme('pager', array(), $per_page, $pager_name)
), ),
); );
} }
} }

Loading…
Cancel
Save