X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fhtml2bbcode.php;h=189ba91f19c847e673844367c10c9a02054da19b;hb=48209f0ecd1e61cabfbf1eb5454197974807e441;hp=65cbcec41f66835acca21810cfe64200d43b87dd;hpb=fa1f2ce8f38962b97c4a6a327c5f50e238eabb9b;p=friendica.git
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 65cbcec41f..189ba91f19 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -1,68 +1,307 @@
query("//".$oldnode);
+ foreach ($list as $oldNode) {
+
+ $attr = array();
+ if ($oldNode->attributes->length)
+ foreach ($oldNode->attributes as $attribute)
+ $attr[$attribute->name] = $attribute->value;
+
+ $replace = true;
+
+ $startbb = $savestart;
+
+ $i = 0;
+
+ foreach ($attributes as $attribute => $value) {
+
+ $startbb = str_replace('\x01'.++$i, '$1', $startbb);
+
+ if (strpos('*'.$startbb, '$1') > 0) {
+
+ if ($replace and (@$attr[$attribute] != '')) {
+
+ $startbb = preg_replace($value, $startbb, $attr[$attribute], -1, $count);
+
+ // If nothing could be changed
+ if ($count == 0)
+ $replace = false;
+ } else
+ $replace = false;
+ } else {
+ if (@$attr[$attribute] != $value)
+ $replace = false;
+ }
+ }
+
+ if ($replace) {
+ $StartCode = $oldNode->ownerDocument->createTextNode($startbb);
+ $EndCode = $oldNode->ownerDocument->createTextNode($endbb);
+
+ $oldNode->parentNode->insertBefore($StartCode, $oldNode);
+
+ if ($oldNode->hasChildNodes()) {
+ foreach ($oldNode->childNodes as $child) {
+ $newNode = $child->cloneNode(true);
+ $oldNode->parentNode->insertBefore($newNode, $oldNode);
+ }
+ }
-function html2bbcode($s) {
-
- // Tags to Find
-
- $htmltags = array(
- '/\n/is',
- '/\
(.*?)\<\/pre\>/is',
- '/\/is',
- '/\<\/p\>/is',
- '/\(.*?)\<\/b\>/is',
- '/\(.*?)\<\/i\>/is',
- '/\(.*?)\<\/u\>/is',
- '/\(.*?)\<\/ul\>/is',
- '/\- (.*?)\<\/li\>/is',
- '/\
/is',
- '/\(.*?)\<\/div\>/is',
- '/\
/is',
- '/\
(.*?)\<\/strong\>/is',
- '/\(.*?)\<\/a\>/is',
- '/\(.*?)\<\/code\>/is',
- '/\(.*?)\<\/span\>/is',
- '/\(.*?)\<\/blockquote\>/is',
- '/\