]> git.mxchange.org Git - friendica.git/commitdiff
plugin hooks for bbcode conversions
authorFriendika <info@friendika.com>
Thu, 30 Dec 2010 22:21:05 +0000 (14:21 -0800)
committerFriendika <info@friendika.com>
Thu, 30 Dec 2010 22:21:05 +0000 (14:21 -0800)
addon/README
include/bbcode.php
include/html2bbcode.php

index 451b6ed7264fcc4702a1badd9e40b9ed8f99958e..23e1b5c6fe2fd06a944eeb5367cf0852552c12b7 100644 (file)
@@ -107,6 +107,12 @@ Current hooks:
                'contacts' => contact array of entries
                'output' => the (string) generated HTML of the contact block
 
+'bbcode' - called during conversion of bbcode to html
+       $b is (string) converted text
+
+'html2bbcode' - called during conversion of html to bbcode (e.g. remote message posting)
+       $b is (string) converted text
+
 
 *** = subject to change
 
index 351510f6d29251df91ac84101a7096de0bbe82eb..7e901bd412bd00d2853b473af091489c883e267c 100644 (file)
@@ -1,10 +1,13 @@
 <?php
+
        // BBcode 2 HTML was written by WAY2WEB.net
-       // Made to work with Mistpark/Friendika - Mike Macgirvin
+       // extended to work with Mistpark/Friendika - Mike Macgirvin
 
 function bbcode($Text) {
+
        // Replace any html brackets with HTML Entities to prevent executing HTML or script
        // Don't use strip_tags here because it breaks [url] search by replacing & with amp
+
        $Text = str_replace("<", "&lt;", $Text);
        $Text = str_replace(">", "&gt;", $Text);
 
@@ -82,5 +85,7 @@ function bbcode($Text) {
         $Text = preg_replace("/\[youtube\]http:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); 
        $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
 
+       call_hooks('bbcode',$Text);
+
        return $Text;
 }
index a2e53a81b8682f8e9ebc2693e9d013d3e5b1e804..1f3d63a0da59b66591f870f5334f360da2ec8005 100644 (file)
@@ -44,6 +44,8 @@ $bbtags = array(
 // Replace $htmltags in $text with $bbtags
 $text = preg_replace ($htmltags, $bbtags, $s);
 
+call_hooks('html2bbcode', $text);
+
 // Strip all other HTML tags
 $text = strip_tags($text);
 return $text;