X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fhtml2bbcode.php;h=1deab951958ac3a6750ac956a2289af6be3581e5;hb=71a5de40f105234aa8082844d7839c3e0e49e905;hp=bde761f2fc6bb2db1f7b6540c5eecba876454b9c;hpb=5899ae9017c351b9987868871605f3f2324c62c0;p=friendica.git
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index bde761f2fc..1deab95195 100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
@@ -1,70 +1,327 @@
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',
- '/\(.*?)\<\/span\>/is',
- '/\(.*?)\<\/blockquote\>/is',
- '/\