From 81478ceba0c1bbdaa43679b72ec6d4fd603f5d17 Mon Sep 17 00:00:00 2001 From: mensonge Date: Fri, 18 Apr 2008 10:29:09 +0000 Subject: Interface design: shorten too long URLs in the displayed bookmarks git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@115 b3834d28-1941-0410-a4f8-b48e95affb8f --- functions.inc.php | 11 +++++++++++ templates/bookmarks.tpl.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/functions.inc.php b/functions.inc.php index 63b789a..35f0fed 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -92,6 +92,17 @@ function createURL($page = '', $ending = '') { return $root . $page .'/'. $ending; } +/* Shorten a string like a URL for example by cutting the middle of it */ +function shortenString($string, $maxSize=75) { + $output = ''; + if(strlen($string) > $maxSize) { + $output = substr($string, 0, $maxSize/2).'...'.substr($string, -$maxSize/2); + } else { + $output = $string; + } + return $output; +} + function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '', $db = NULL) { if(defined('HAS_DIED')) die(T_('message_die() was called multiple times.')); diff --git a/templates/bookmarks.tpl.php b/templates/bookmarks.tpl.php index 556d92e..cc4743c 100644 --- a/templates/bookmarks.tpl.php +++ b/templates/bookmarks.tpl.php @@ -171,7 +171,7 @@ window.onload = playerLoad; } echo '
'. filter($row['bDescription']) ."
\n"; if(!isset($hash)) { - echo '
'.$address.'
'; + echo '
'.shortenString($address).'
'; } echo '
'. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."
\n"; -- cgit v1.2.3-54-g00ecf