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
This commit is contained in:
mensonge 2008-04-18 10:29:09 +00:00
parent 74fb49098e
commit 81478ceba0
2 changed files with 12 additions and 1 deletions

View file

@ -92,6 +92,17 @@ function createURL($page = '', $ending = '') {
return $root . $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) { function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '', $db = NULL) {
if(defined('HAS_DIED')) if(defined('HAS_DIED'))
die(T_('message_die() was called multiple times.')); die(T_('message_die() was called multiple times.'));

View file

@ -171,7 +171,7 @@ window.onload = playerLoad;
} }
echo '<div class="description">'. filter($row['bDescription']) ."</div>\n"; echo '<div class="description">'. filter($row['bDescription']) ."</div>\n";
if(!isset($hash)) { 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"; echo '<div class="meta">'. date($GLOBALS['shortdate'], strtotime($row['bDatetime'])) . $cats . $copy . $edit ."</div>\n";