From d2b0a11a7a065ad641743d0d44bd1e6d4eb6e9b7 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 1 May 2012 14:20:46 -0300 Subject: [PATCH] Truncate titles for regular display to 60 character +/- a word. Should make the length an actual configurable value... Shouldn't be hard, though. --- CollectionClass.inc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CollectionClass.inc b/CollectionClass.inc index 18d5a107..b027ac4c 100644 --- a/CollectionClass.inc +++ b/CollectionClass.inc @@ -687,23 +687,27 @@ class CollectionClass { $per_page = 20; //XXX: Make this configurable. $pager_name = 0; $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(); 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']}"; $tn_path = ($result['thumbnail'] ? "fedora/repository/{$result['thumbnail']}": - "$obj_path/TN"); - $thumbnail = theme('image', $tn_path, $title, $title, array(), FALSE); + "$obj_path/TN"); + + $thumbnail = theme('image', $tn_path, $truncated_title, $title, array(), FALSE); + $results[] = array( 'data' => l($thumbnail, $obj_path, array( 'html' => TRUE, 'attributes' => array( '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) {