aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-04-18 10:29:09 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-04-18 10:29:09 +0000
commit81478ceba0c1bbdaa43679b72ec6d4fd603f5d17 (patch)
tree70f2d5ca67d97301645f3981e135a0f3138a3223
parent74fb49098eb52b8f42110713caa3892572305cf3 (diff)
downloadsemanticscuttle-81478ceba0c1bbdaa43679b72ec6d4fd603f5d17.tar.gz
semanticscuttle-81478ceba0c1bbdaa43679b72ec6d4fd603f5d17.tar.bz2
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
-rw-r--r--functions.inc.php11
-rw-r--r--templates/bookmarks.tpl.php2
2 files changed, 12 insertions, 1 deletions
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 '<div class="description">'. filter($row['bDescription']) ."</div>\n";
if(!isset($hash)) {
- echo '<div class="address">'.$address.'</div>';
+ echo '<div class="address">'.shortenString($address).'</div>';
}
echo '<div class="meta">'. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."</div>\n";