Browse Source

Truncate titles for regular display to 60 character +/- a word.

Should make the length an actual configurable value...  Shouldn't be hard, though.
pull/126/head
Adam Vessey 13 years ago committed by Adam Vessey
parent
commit
6d6342c269
  1. 14
      CollectionClass.inc

14
CollectionClass.inc

@ -687,23 +687,27 @@ class CollectionClass {
$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;
$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);
$obj_path = "fedora/repository/{$result['object']}"; $obj_path = "fedora/repository/{$result['object']}";
$tn_path = ($result['thumbnail'] ? $tn_path = ($result['thumbnail'] ?
"fedora/repository/{$result['thumbnail']}": "fedora/repository/{$result['thumbnail']}":
"$obj_path/TN"); "$obj_path/TN");
$thumbnail = theme('image', $tn_path, $title, $title, array(), FALSE);
$thumbnail = theme('image', $tn_path, $truncated_title, $title, array(), FALSE);
$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($title, $obj_path, array('attributes' => array('class' => 'results-text'))), )) . l($truncated_title, $obj_path, array('attributes' => array('class' => 'results-text'))),
); );
} }
if (!$results) { if (!$results) {

Loading…
Cancel
Save