X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fhtml2bbcode.php;h=189ba91f19c847e673844367c10c9a02054da19b;hb=e6463c8af6af247c9555bf2677a6aa75a4721d62;hp=6af8df824e76bbf35552e881b81aaa2c783364c5;hpb=25c2640c17244aeb53020df83455a14ae245e831;p=friendica.git
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 6af8df824e..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',
- '/\