diff options
author | friendica <info@friendica.com> | 2013-04-16 20:16:44 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-04-16 20:16:44 -0700 |
commit | f72d3512242d13fbba69b77a739319a9cd58627c (patch) | |
tree | d59c8904fda78b04ee19e42343d8c7ca56c67a5f /include/text.php | |
parent | 3e7e0a3c43ddb742a6518a3b38b89e3d9675eae5 (diff) | |
parent | 23f897b8aedac8a99aa81ac7799ec67ca196d407 (diff) | |
download | volse-hubzilla-f72d3512242d13fbba69b77a739319a9cd58627c.tar.gz volse-hubzilla-f72d3512242d13fbba69b77a739319a9cd58627c.tar.bz2 volse-hubzilla-f72d3512242d13fbba69b77a739319a9cd58627c.zip |
Merge branch 'master' into photothread
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/include/text.php b/include/text.php index a8d91fade..c7210010c 100644 --- a/include/text.php +++ b/include/text.php @@ -1108,6 +1108,7 @@ function prepare_text($text,$content_type = 'text/bbcode') { $s = bbcode($text); else $s = smilies(bbcode($text)); + $s = zidify_links($s); break; } @@ -1116,6 +1117,42 @@ function prepare_text($text,$content_type = 'text/bbcode') { /** + * zidify_callback() and zidify_links() work together to turn any HTML a tags with class="zrl" into zid links + * These will typically be generated by a bbcode '[zrl]' tag. This is done inside prepare_text() rather than bbcode() + * because the latter is used for general purpose conversions and the former is used only when preparing text for + * immediate display. + * + * Issues: Currently the order of HTML parameters in the text is somewhat rigid and inflexible. + * We assume it looks like <a class="zrl" href="xxxxxxxxxx"> and will not work if zrl and href appear in a different order. + */ + + +function zidify_callback($match) { + if (feature_enabled(local_user(),'sendzid')) { + $replace = '<a' . $match[1] . ' href="' . zid($match[2]) . '"';} + + else { + $replace = '<a' . $match[1] . 'class="zrl"' . $match[2] . ' href="' . zid($match[3]) . '"';} + + $x = str_replace($match[0],$replace,$match[0]); + return $x; +} + +function zidify_links($s) { + if (feature_enabled(local_user(),'sendzid')) { + $s = preg_replace_callback('/\<a(.*?)href\=\"(.*?)\"/ism','zidify_callback',$s);} + else { + $s = preg_replace_callback('/\<a(.*?)class\=\"zrl\"(.*?)href\=\"(.*?)\"/ism','zidify_callback',$s);} + + return $s; +} + + + + + + +/** * return atom link elements for all of our hubs */ @@ -1633,7 +1670,7 @@ function normalise_openid($s) { function undo_post_tagging($s) { $matches = null; - $cnt = preg_match_all('/([@#])\[url=(.*?)\](.*?)\[\/url\]/ism',$s,$matches,PREG_SET_ORDER); + $cnt = preg_match_all('/([@#])\[zrl=(.*?)\](.*?)\[\/zrl\]/ism',$s,$matches,PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s); |