From e5af746153a8d9fbdaeca87c8f89115959f929e6 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 28 Jul 2018 13:41:44 -0700 Subject: [PATCH] Closes #3330 #3318 --- e107_handlers/e107_class.php | 23 +----------- e107_handlers/form_handler.php | 37 ++++++++++++++----- e107_plugins/forum/forum_admin.php | 11 ++++-- .../shortcodes/batch/post_shortcodes.php | 6 ++- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 62f0357677..1cf557151f 100755 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -3628,7 +3628,7 @@ public static function minify($js,$options=array()) /** * Set or Retrieve WYSIWYG active status. (replaces constant e_WYSIWYG) * @param bool $val if null, return current value, otherwise set value to registry - * @return bool|mixed|void + * @return bool|mixed */ public static function wysiwyg($val=null) { @@ -3638,27 +3638,6 @@ public static function wysiwyg($val=null) return false; } - - if (defined('e_CURRENT_PLUGIN') && e_CURRENT_PLUGIN != '') - { - $editor = e107::getPlugPref(e_CURRENT_PLUGIN, 'editor', 'default'); - if ($editor != 'default' && $editor != 'bbcode' && !e107::isInstalled($editor)) - { - $editor = 'default'; - } - switch ($editor) - { - case 'bbcode': - return false; - case 'tinymce4': - return true; - default: - break; - } - - } - - if(is_null($val)) { return self::getRegistry('core/e107/wysiwyg'); diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 84173e37c7..fe63a04bc7 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2302,12 +2302,15 @@ function textarea($name, $value, $rows = 10, $cols = 80, $options = array(), $co /** * Bbcode Area. Name, value, template, media-Cat, size, options array eg. counter * IMPORTANT: $$mediaCat is also used is the media-manager category identifier - * @param $name - * @param $value - * @param $template - * @param $mediaCat _common - * @param $size : small | medium | large - * @param $options array(); + * @param string $name + * @param mixed $value + * @param string $template + * @param string $mediaCat _common + * @param string $size : small | medium | large + * @param array $options array(); + * @param bool $options['wysiwyg'] when set to false will disable wysiwyg if active. + * @param string $options['class'] override class. + * @param string $options['id'] */ function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'large', $options = array()) { @@ -2349,8 +2352,22 @@ function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'lar } // auto-height support - $options['class'] = 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg e-autoheight form-control'; + $bbbar = ''; + $wysiwyg = null; + $wysiwygClass = ' e-wysiwyg'; + + if(isset($options['wysiwyg'])) + { + $wysiwyg = $options['wysiwyg']; + } + + if($wysiwyg === false) + { + $wysiwygClass = ''; + } + + $options['class'] = 'tbox bbarea '.($size ? ' '.$size : '').$wysiwygClass.' e-autoheight form-control'; if (isset($options['id']) && !empty($options['id'])) @@ -2363,7 +2380,7 @@ function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'lar } - if(e107::wysiwyg(true) === false) // bbarea loaded, so activate wysiwyg (if enabled in preferences) + if(e107::wysiwyg(true) === false || $wysiwyg === false) // bbarea loaded, so activate wysiwyg (if enabled in preferences) { $options['other'] = "onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' {$height}"; } @@ -2372,14 +2389,14 @@ function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'lar $options['other'] = " ".$height; } - + $counter = vartrue($options['counter'],false); $ret = "
\n"; - if(e107::wysiwyg() === true) + if(e107::wysiwyg() === true && $wysiwyg !== false) { $eParseList = e107::getConfig()->get('e_parse_list'); diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php index 72af5d0810..0bfe19e73c 100644 --- a/e107_plugins/forum/forum_admin.php +++ b/e107_plugins/forum/forum_admin.php @@ -229,16 +229,19 @@ public function init() $this->checkOrder(); - $this->prefs['editor']['writeParms']['optArray']['default'] = 'System editor'; + $this->prefs['editor']['writeParms']['optArray']['default'] = 'System default'; //todo LAN $this->prefs['editor']['writeParms']['optArray']['bbcode'] = 'BBCode'; + + //@ global pref should override plugins due to security considerations and allowance of posting html. + /* if (e107::isInstalled('tinymce4')) { $this->prefs['editor']['writeParms']['optArray']['tinymce4'] = 'TinyMCE'; - } + }*/ $this->prefs['quickreply']['writeParms']['optArray'] = array( - 'default' => 'Textarea', - 'wysiwyg' => 'Editor' + 'default' => 'Textarea', //todo LAN + 'wysiwyg' => 'Rich Text Editor' //TODO LAN ); if(e107::isInstalled('poll') == false) diff --git a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php index 58e918af12..98b342f256 100644 --- a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php @@ -177,7 +177,11 @@ function sc_forum_post_textarea() $text = ''; } - return e107::getForm()->bbarea('post',$text,'forum'); + $editor = $this->forum->prefs->get('editor'); + + $wysiwyg = ($editor === 'bbcode') ? false : null; + + return e107::getForm()->bbarea('post',$text,'forum','_common','large', array('wysiwyg' => $wysiwyg)); }