]> git.sur5r.net Git - contagged/blob - inc/smarty/plugins/modifier.http.php
support non-http URLs in labeledURI fields (e.g. xmpp or mailto)
[contagged] / inc / smarty / plugins / modifier.http.php
1 <?php
2 /**
3  * Smarty plugin
4  * @package Smarty
5  * @subpackage plugins
6  */
7
8
9 /**
10  * Smarty plugin
11  *
12  * Type:     modifier
13  * Date:     2007-06-19
14  * Example:  {$foo|http}
15  * @author   Andreas Gohr <gohr@cosmocode.de>
16  * @param string
17  * @return string
18  */
19 function smarty_modifier_http($string){
20     if(!$string) return '';
21
22     list($url,$name) = explode(' ',$string,2);
23
24
25     if(!parse_url($url, PHP_URL_SCHEME)) {
26         $url = 'http://' . $url;
27     }
28
29     if(!$name) $name = $url;
30
31     return '<a href="'.htmlspecialchars($url).'" target="_blank">'.htmlspecialchars($name).'</a>';
32 }
33
34 /* vim: set expandtab: */
35
36 ?>