diff options
author | Hubzilla <hubzilla@hz.macgirvin.com> | 2017-01-20 13:36:37 -0800 |
---|---|---|
committer | Hubzilla <hubzilla@hz.macgirvin.com> | 2017-01-20 13:36:37 -0800 |
commit | 0368b6730fcb16ec66a0cb2bdc692ce85d26d633 (patch) | |
tree | 80436c924d30cb5be4eb9cbf42fef10007a3bc49 | |
parent | ece1dd1d7edc800085def93e50efc25a3dda55a7 (diff) | |
download | volse-hubzilla-0368b6730fcb16ec66a0cb2bdc692ce85d26d633.tar.gz volse-hubzilla-0368b6730fcb16ec66a0cb2bdc692ce85d26d633.tar.bz2 volse-hubzilla-0368b6730fcb16ec66a0cb2bdc692ce85d26d633.zip |
language aware content
-rw-r--r-- | Zotlabs/Render/Comanche.php | 2 | ||||
-rw-r--r-- | include/bbcode.php | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 8e36f52c2..048921670 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -108,6 +108,8 @@ class Comanche { return $_SERVER['REQUEST_URI']; elseif($x[0] === 'observer') { if(count($x) > 1) { + if($x[1] == 'language') + return \App::$language; $y = \App::get_observer(); if(! $y) return false; diff --git a/include/bbcode.php b/include/bbcode.php index 00d22d26d..8b78034f2 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -473,11 +473,26 @@ function bb_sanitize_style($input) { return '<span style="' . $css_string_san . '">' . $input[2] . '</span>'; } +function oblanguage_callback($matches) { + if(strlen($matches[1]) == 2) { + $compare = strtolower(substr(\App::$language,0,2)); + } + else { + $compare = strtolower(\App::$language); + } + + if($compare === strtolower($matches[1])) + return $matches[2]; + + return ''; +} + function bb_observer($Text) { $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); @@ -561,6 +576,9 @@ function parseIdentityAwareHTML($Text) { $observer = App::get_observer(); if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { + + $Text = preg_replace_callback("/\[observer\.language\=(.*?)\](.*?)\[\/observer\]/ism",'oblanguage_callback', $Text); + if ($observer) { $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); @@ -643,6 +661,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) $observer = App::get_observer(); if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { + $Text = preg_replace_callback("/\[observer\.language\=(.*?)\](.*?)\[\/observer\]/ism",'oblanguage_callback', $Text); + if ($observer) { $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); |