Changeset 845 in ExiteCMS for trunk/includes/core_functions.php
- Timestamp:
- 09/28/07 00:02:59 (5 years ago)
- File:
-
- 1 edited
-
trunk/includes/core_functions.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core_functions.php
r843 r845 268 268 269 269 // Trim a line of text to a preferred length 270 function trimlink($text, $length ) {270 function trimlink($text, $length, $filler="...") { 271 271 $dec = array("\"", "'", "\\", '\"', "\'", "<", ">"); 272 272 $enc = array(""", "'", "\", """, "'", "<", ">"); 273 273 $text = str_replace($enc, $dec, $text); 274 if (strlen($text) > $length) $text = substr($text, 0, ($length-3)). "...";274 if (strlen($text) > $length) $text = substr($text, 0, ($length-3)).$filler; 275 275 $text = str_replace($dec, $enc, $text); 276 276 return $text; 277 } 278 279 // Trim a URI to a preferred length by cutting out the middle (preserve the hostname if possible) 280 function shortenlink($text, $length, $filler="...") { 281 282 $dec = array("\"", "'", "\\", '\"', "\'", "<", ">"); 283 $enc = array(""", "'", "\", """, "'", "<", ">"); 284 $returner = str_replace($enc, $dec, $text); 285 if (strlen($returner) > $length) { 286 $url = preg_match("=[^/]/[^/]=",$returner,$treffer,PREG_OFFSET_CAPTURE); 287 $cutpos = $treffer[0][1]+2; 288 $part[0] = substr($returner,0,$cutpos); 289 $part[1] = substr($returner,$cutpos); 290 $strlen1 = $cutpos; 291 if ($strlen1 > $length) { 292 $returner = substr($returner,0,$length-3).$filler; 293 } else { 294 $strlen2 = strlen($part[1]); 295 $cutpos = $strlen2-($length-3-$strlen1); 296 $returner = $part[0].$filler.substr($part[1],$cutpos); 297 } 298 } 299 $returner = str_replace($dec, $enc, $returner); 300 return $returner; 277 301 } 278 302 … … 490 514 $text = preg_replace('#\[url=([\r\n]*)(http://|ftp://|https://|ftps://)([^\'\";]*?)\](.*?)([\r\n]*)\[/url\]#si', '<a href=\'\2\3\' target=\'_blank\'>\4</a>', $text); 491 515 $text = preg_replace('#\[url=([\r\n]*)([^\s\'\";\+]*?)\](.*?)([\r\n]*)\[/url\]#si', '<a href=\'http://\2\' target=\'_blank\'>\3</a>', $text); 492 516 493 517 $text = preg_replace('#\[mail\]([\r\n]*)([^\s\'\";:\+]*?)([\r\n]*)\[/mail\]#si', '<a href=\'mailto:\2\'>\2</a>', $text); 494 518 $text = preg_replace('#\[mail=([\r\n]*)([^\s\'\";:\+]*?)\](.*?)([\r\n]*)\[/mail\]#si', '<a href=\'mailto:\2\'>\2</a>', $text);
Note: See TracChangeset
for help on using the changeset viewer.
