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
*
*
* 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)
),
);
);
}
}

Loading…
Cancel
Save