From 937ef030475826a4ceebaec203a189e8b140de34 Mon Sep 17 00:00:00 2001 From: Achim Ennenbach Date: Thu, 9 Aug 2018 14:05:06 +0200 Subject: [PATCH 1/3] fixes #3317 added bbcode template "forum" Fixed issue with bbcode youtube to display the mediamanager only if the current user is an admin. Otherwise it will just add the plain bbcode string "[youtube]dkhkj[/youtube]" to the textarea. --- .../shortcodes/batch/bbcode_shortcodes.php | 19 ++++++++++++++----- e107_core/templates/bbcode_template.php | 8 ++++++++ e107_handlers/bbcode_handler.php | 4 +++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/e107_core/shortcodes/batch/bbcode_shortcodes.php b/e107_core/shortcodes/batch/bbcode_shortcodes.php index 74778802c..a3bf00d63 100644 --- a/e107_core/shortcodes/batch/bbcode_shortcodes.php +++ b/e107_core/shortcodes/batch/bbcode_shortcodes.php @@ -131,8 +131,17 @@ class bbcode_shortcodes extends e_shortcode { list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. } - - $text = ""; + + if (ADMIN) + { + $text = ""; + } + else + { + $data = "[youtube=tiny | small | medium | big | huge | width,height]6kYjxJmk0wc[/youtube]"; + $event = $this->getEvent('addtext',$data,LANHELP_48); + $text = ""; + } $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48); $text .= ""; @@ -152,7 +161,7 @@ class bbcode_shortcodes extends e_shortcode } - $text = ""; + $text = ""; $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48); $text .= ""; @@ -211,7 +220,7 @@ class bbcode_shortcodes extends e_shortcode { list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. } - $text = ""; + $text = ""; $text .= $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o'); // $text .= ""; @@ -229,7 +238,7 @@ class bbcode_shortcodes extends e_shortcode { list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. } - $text = ""; + $text = ""; $text .= $this->button(e_IMAGE_ABS."bbcode/prefile.png", 'file'); // $text .= ""; diff --git a/e107_core/templates/bbcode_template.php b/e107_core/templates/bbcode_template.php index d1e7666a7..16cf357d2 100644 --- a/e107_core/templates/bbcode_template.php +++ b/e107_core/templates/bbcode_template.php @@ -50,6 +50,14 @@ $BBCODE_TEMPLATE_SUBMITNEWS = " "; +$BBCODE_TEMPLATE_FORUM = " +
+ {BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=format}{BB=left}{BB=center}{BB=right}{BB=justify} + {BB=list}{BB=fontcol}{BB=fontsize}{BB=emotes}{BB=youtube} +
+"; + + // -------- Admin Templates ---------------------- $BBCODE_TEMPLATE_ADMIN = " diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 199f82a9d..cd5ef5c3f 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -547,6 +547,7 @@ class e_bbcode $BBCODE_TEMPLATE_ADMIN = ''; $BBCODE_TEMPLATE_COMMENT = ''; $BBCODE_TEMPLATE_SIGNATURE = ''; + $BBCODE_TEMPLATE_FORUM = ''; require(e107::coreTemplatePath('bbcode')); //correct way to load a core template. @@ -574,7 +575,8 @@ class e_bbcode $temp['maintenance']= $BBCODE_TEMPLATE_ADMIN; $temp['comment'] = $BBCODE_TEMPLATE_COMMENT; $temp['signature'] = $BBCODE_TEMPLATE_SIGNATURE; - + $temp['forum'] = $BBCODE_TEMPLATE_FORUM; + if(isset($temp[$template])) { $BBCODE_TEMPLATE = $temp[$template]; From fe7bb66b7660a5f8e14ea061dcc7d3285a06754f Mon Sep 17 00:00:00 2001 From: Achim Ennenbach Date: Thu, 9 Aug 2018 19:18:36 +0200 Subject: [PATCH 2/3] fixes #3317 ADMIN_AREA is sometimes not defined when the method is called --- e107_handlers/bbcode_handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index cd5ef5c3f..77d7096f9 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -586,7 +586,7 @@ class e_bbcode $BBCODE_TEMPLATE = $template; $template = 'comment'; } - elseif(ADMIN_AREA) + elseif(deftrue('ADMIN_AREA')) { $BBCODE_TEMPLATE = $BBCODE_TEMPLATE_ADMIN; } From c1bec2b6d75445354028a858f98f0c51f5c69a41 Mon Sep 17 00:00:00 2001 From: Achim Ennenbach Date: Fri, 10 Aug 2018 11:49:58 +0200 Subject: [PATCH 3/3] fixes #3317 moved the forum template from core to plugin --- e107_core/templates/bbcode_template.php | 8 -------- e107_handlers/bbcode_handler.php | 16 ++++++++++++++-- .../forum/templates/bbcode_template.php | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 e107_plugins/forum/templates/bbcode_template.php diff --git a/e107_core/templates/bbcode_template.php b/e107_core/templates/bbcode_template.php index 16cf357d2..d1e7666a7 100644 --- a/e107_core/templates/bbcode_template.php +++ b/e107_core/templates/bbcode_template.php @@ -50,14 +50,6 @@ $BBCODE_TEMPLATE_SUBMITNEWS = " "; -$BBCODE_TEMPLATE_FORUM = " -
- {BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=format}{BB=left}{BB=center}{BB=right}{BB=justify} - {BB=list}{BB=fontcol}{BB=fontsize}{BB=emotes}{BB=youtube} -
-"; - - // -------- Admin Templates ---------------------- $BBCODE_TEMPLATE_ADMIN = " diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 77d7096f9..033f4b391 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -547,7 +547,6 @@ class e_bbcode $BBCODE_TEMPLATE_ADMIN = ''; $BBCODE_TEMPLATE_COMMENT = ''; $BBCODE_TEMPLATE_SIGNATURE = ''; - $BBCODE_TEMPLATE_FORUM = ''; require(e107::coreTemplatePath('bbcode')); //correct way to load a core template. @@ -575,7 +574,20 @@ class e_bbcode $temp['maintenance']= $BBCODE_TEMPLATE_ADMIN; $temp['comment'] = $BBCODE_TEMPLATE_COMMENT; $temp['signature'] = $BBCODE_TEMPLATE_SIGNATURE; - $temp['forum'] = $BBCODE_TEMPLATE_FORUM; + + if(!isset($temp[$template])) + { + // if template not yet defined, assume that $template is the name of a plugin + // and load the specific bbcode template from the plugin + // see forum plugin "templates/bbcode_template.php" for an example of the definition + $tpl = e107::getTemplate($template, 'bbcode', $template); + if (!empty($tpl)) + { + // If the plugin has a template defined for bbcode, add it to the list + $temp[$template] = $tpl; + } + unset($tpl); + } if(isset($temp[$template])) { diff --git a/e107_plugins/forum/templates/bbcode_template.php b/e107_plugins/forum/templates/bbcode_template.php new file mode 100644 index 000000000..53f9b2ac9 --- /dev/null +++ b/e107_plugins/forum/templates/bbcode_template.php @@ -0,0 +1,19 @@ + + {BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=format}{BB=left}{BB=center}{BB=right}{BB=justify} + {BB=list}{BB=fontcol}{BB=fontsize}{BB=emotes}{BB=youtube} +
+";