diff options
author | zotlabs <mike@macgirvin.com> | 2018-08-12 15:10:19 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-08-12 15:10:19 -0700 |
commit | 2d29095348eb8ab73bac7c22b4f87bfed7ea06c0 (patch) | |
tree | 0385828542ba0b8c930b10b8cac503777b696e45 /include | |
parent | ac03b4ccd74e52d8f1c78ad6393e8d90171516ce (diff) | |
parent | 759a18685b75e631d5884d610cc3a6fe483b821d (diff) | |
download | volse-hubzilla-2d29095348eb8ab73bac7c22b4f87bfed7ea06c0.tar.gz volse-hubzilla-2d29095348eb8ab73bac7c22b4f87bfed7ea06c0.tar.bz2 volse-hubzilla-2d29095348eb8ab73bac7c22b4f87bfed7ea06c0.zip |
Merge branch 'dev' of https://framagit.org/hubzilla/core into xdev_merge
Diffstat (limited to 'include')
-rw-r--r-- | include/markdown.php | 42 | ||||
-rw-r--r-- | include/nav.php | 2 |
2 files changed, 41 insertions, 3 deletions
diff --git a/include/markdown.php b/include/markdown.php index de9862801..058b79909 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -74,8 +74,11 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { // Convert everything that looks like a link to a link if($use_zrl) { - $s = str_replace(['[img', '/img]'], ['[zmg', '/zmg]'], $s); - $s = preg_replace("/([^\]\=\{]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[zrl=$2$3]$2$3[/zrl]',$s); + if (strpos($s,'[/img]') !== false) { + $s = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'use_zrl_cb_img', $s); + $s = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'use_zrl_cb_img_x', $s); + } + $s = preg_replace_callback("/([^\]\=\{]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", 'use_zrl_cb_link',$s); } else { $s = preg_replace("/([^\]\=\{]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]',$s); @@ -96,6 +99,41 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { return $s; } +function use_zrl_cb_link($match) { + $res = ''; + $is_zid = is_matrix_url(trim($match[0])); + + if($is_zid) + $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]'; + else + $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]'; + + return $res; +} + +function use_zrl_cb_img($match) { + $res = ''; + $is_zid = is_matrix_url(trim($match[1])); + + if($is_zid) + $res = '[zmg]' . $match[1] . '[/zmg]'; + else + $res = $match[0]; + + return $res; +} + +function use_zrl_cb_img_x($match) { + $res = ''; + $is_zid = is_matrix_url(trim($match[3])); + + if($is_zid) + $res = '[zmg=' . $match[1] . 'x' . $match[2] . ']' . $match[3] . '[/zmg]'; + else + $res = $match[0]; + + return $res; +} /** * @brief diff --git a/include/nav.php b/include/nav.php index 05d2d199f..56fe9b901 100644 --- a/include/nav.php +++ b/include/nav.php @@ -175,7 +175,7 @@ function nav($template = 'default') { $search_form_action = 'network'; break; case 'channel': - $search_form_action = 'channel'; + $search_form_action = 'channel/' . App::$profile['channel_address']; break; default: $search_form_action = 'search'; |