diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-08-03 20:53:51 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-08-03 20:53:51 -0400 |
commit | 05a9f0aa1473e155c7f0ac27ef733bf174e49abd (patch) | |
tree | ed34c31b6e1e4f38e6c43846079026ef962e348a /include | |
parent | 64810405ef4ce33646031b16efcfb038fcdb2ded (diff) | |
download | volse-hubzilla-05a9f0aa1473e155c7f0ac27ef733bf174e49abd.tar.gz volse-hubzilla-05a9f0aa1473e155c7f0ac27ef733bf174e49abd.tar.bz2 volse-hubzilla-05a9f0aa1473e155c7f0ac27ef733bf174e49abd.zip |
Convert select bbcode tags including [observer], [baseurl], [sitename]
Diffstat (limited to 'include')
-rw-r--r-- | include/wiki.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/wiki.php b/include/wiki.php index 424b2d9a0..494ff835e 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -505,6 +505,39 @@ function wiki_generate_toc($s) { return $s; } +/** + * Converts a select set of bbcode tags. Much of the code is copied from include/bbcode.php + * @param string $s + * @return string + */ +function wiki_bbcode($s) { + + $s = str_replace(array('[baseurl]', '[sitename]'), array(z_root(), get_config('system', 'sitename')), $s); + + $observer = App::get_observer(); + 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); + $s = str_replace('[observer.baseurl]', $obsBaseURL, $s); + $s = str_replace('[observer.url]', $observer['xchan_url'], $s); + $s = str_replace('[observer.name]', $s1 . $observer['xchan_name'] . $s2, $s); + $s = str_replace('[observer.address]', $s1 . $observer['xchan_addr'] . $s2, $s); + $s = str_replace('[observer.webname]', substr($observer['xchan_addr'], 0, strpos($observer['xchan_addr'], '@')), $s); + $s = str_replace('[observer.photo]', '', $s); + } else { + $s = str_replace('[observer.baseurl]', '', $s); + $s = str_replace('[observer.url]', '', $s); + $s = str_replace('[observer.name]', '', $s); + $s = str_replace('[observer.address]', '', $s); + $s = str_replace('[observer.webname]', '', $s); + $s = str_replace('[observer.photo]', '', $s); + } + + return $s; +} + // This function is derived from // http://stackoverflow.com/questions/32068537/generate-table-of-contents-from-markdown-in-php function wiki_toc($content) { |