]> git.mxchange.org Git - friendica.git/blobdiff - include/html2bbcode.php
Merge remote-tracking branch 'upstream/develop' into 1501-central-item-storage
[friendica.git] / include / html2bbcode.php
index b38da6b0a410f47546278cea35cd7e6ebd7385e9..650bbdcae8c07d1071a6724463b4ef0f227809df 100644 (file)
@@ -16,7 +16,7 @@ function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb)
 
 function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
 {
-       $savestart = str_replace('$', '%', $startbb);
+       $savestart = str_replace('$', '\x01', $startbb);
        $replace = false;
 
        $xpath = new DomXPath($doc);
@@ -37,7 +37,7 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
 
                foreach ($attributes as $attribute => $value) {
 
-                       $startbb = str_replace('%'.++$i, '$1', $startbb);
+                       $startbb = str_replace('\x01'.++$i, '$1', $startbb);
 
                        if (strpos('*'.$startbb, '$1') > 0) {
 
@@ -76,13 +76,14 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
        return($replace);
 }
 
+if(!function_exists('deletenode')) {
 function deletenode(&$doc, $node)
 {
        $xpath = new DomXPath($doc);
        $list = $xpath->query("//".$node);
        foreach ($list as $child)
                $child->parentNode->removeChild($child);
-}
+}}
 
 function html2bbcode($message)
 {
@@ -167,6 +168,7 @@ function html2bbcode($message)
        // Test
        //node2bbcode($doc, 'span', array('class'=>'/([\w ]+)/'), '[class=$1]', '[/class]');
        node2bbcode($doc, 'span', array('class'=>'type-link'), '[class=type-link]', '[/class]');
+       node2bbcode($doc, 'span', array('class'=>'type-video'), '[class=type-video]', '[/class]');
 
        node2bbcode($doc, 'strong', array(), '[b]', '[/b]');
        node2bbcode($doc, 'em', array(), '[i]', '[/i]');
@@ -212,6 +214,7 @@ function html2bbcode($message)
        node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
        node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
 
+       node2bbcode($doc, 'a', array('href'=>'/mailto:(.+)/'), '[mail=$1]', '[/mail]');
        node2bbcode($doc, 'a', array('href'=>'/(.+)/'), '[url=$1]', '[/url]');
 
        node2bbcode($doc, 'img', array('src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'), '[img=$2x$3]$1', '[/img]');