]> git.sur5r.net Git - contagged/blobdiff - inc/smarty/plugins/modifier.http.php
Handle URL field RFC conform
[contagged] / inc / smarty / plugins / modifier.http.php
index a3fffbce9b8573f61bd2a62f5f73ddf783f1b2b0..ecb52e76b0f9df53b79f7fdc2c25b22e4d4579e2 100644 (file)
@@ -10,9 +10,7 @@
  * Smarty plugin
  *
  * Type:     modifier
- * Name:     noteparser
  * Date:     2007-06-19
- * Purpose:  Add the http:// protocol if missing
  * Example:  {$foo|http}
  * @author   Andreas Gohr <gohr@cosmocode.de>
  * @param string
 function smarty_modifier_http($string){
     if(!$string) return '';
 
-    if(!preg_match('#^\w+://#',$string)){
-        $string = 'http://'.$string;
+    list($url,$name) = explode(' ',$string,2);
+
+
+    if(!preg_match('#^\w+://#',$url)){
+        $url = 'http://'.$url;
     }
 
-    return $string;
+    if(!$name) $name = $url;
+
+    return '<a href="'.htmlspecialchars($url).'" target="_blank">'.htmlspecialchars($name).'</a>';
 }
 
 /* vim: set expandtab: */