aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
authorAndrew Manning <andrew@reticu.li>2016-11-27 14:48:06 -0700
committerAndrew Manning <andrew@reticu.li>2016-11-27 14:48:06 -0700
commit369dc295b12bc3fc4cc2ab50727bea277a44d91c (patch)
tree1467f730f7b6a61160d5142fe02537adca1e0905 /include/bbcode.php
parent7470b1180e884104b690b39dce90143c72c096a3 (diff)
downloadvolse-hubzilla-369dc295b12bc3fc4cc2ab50727bea277a44d91c.tar.gz
volse-hubzilla-369dc295b12bc3fc4cc2ab50727bea277a44d91c.tar.bz2
volse-hubzilla-369dc295b12bc3fc4cc2ab50727bea277a44d91c.zip
Add some identity-aware parsing to HTML content using parseIdentityAwareHTML()
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 21bc6de77..d6bc53d12 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -529,7 +529,46 @@ function bb_fixtable_lf($match) {
}
+function parseIdentityAwareHTML($Text) {
+
+ // process [observer] tags before we do anything else because we might
+ // be stripping away stuff that then doesn't need to be worked on anymore
+
+ $observer = App::get_observer();
+ if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) {
+ if ($observer) {
+ $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text);
+ $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text);
+ $Text = preg_replace_callback("/\[rpost(=(.*?))?\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text);
+ } else {
+ $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text);
+ $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text);
+ $Text = preg_replace("/\[rpost(=.*?)?\](.*?)\[\/rpost\]/ism", '', $Text);
+ }
+ }
+ // replace [observer.baseurl]
+ if ($observer) {
+ $s1 = '<span class="bb_observer" title="' . t('Different viewers will see this text differently') . '">';
+ $s2 = '</span>';
+ $obsBaseURL = $observer['xchan_connurl'];
+ $obsBaseURL = preg_replace("/\/poco\/.*$/", '', $obsBaseURL);
+ $Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text);
+ $Text = str_replace('[observer.url]',$observer['xchan_url'], $Text);
+ $Text = str_replace('[observer.name]',$s1 . $observer['xchan_name'] . $s2, $Text);
+ $Text = str_replace('[observer.address]',$s1 . $observer['xchan_addr'] . $s2, $Text);
+ $Text = str_replace('[observer.webname]', substr($observer['xchan_addr'],0,strpos($observer['xchan_addr'],'@')), $Text);
+ $Text = str_replace('[observer.photo]',$s1 . '[zmg]'.$observer['xchan_photo_l'].'[/zmg]' . $s2, $Text);
+ } else {
+ $Text = str_replace('[observer.baseurl]', '', $Text);
+ $Text = str_replace('[observer.url]','', $Text);
+ $Text = str_replace('[observer.name]','', $Text);
+ $Text = str_replace('[observer.address]','', $Text);
+ $Text = str_replace('[observer.webname]','',$Text);
+ $Text = str_replace('[observer.photo]','', $Text);
+ }
+ return $Text;
+}
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica/Redmatrix/Hubzilla - Mike Macgirvin