Skip to content

Commit

Permalink
Closes #3330 #3318
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Jul 28, 2018
1 parent 3701765 commit e5af746
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 37 deletions.
23 changes: 1 addition & 22 deletions e107_handlers/e107_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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');
Expand Down
37 changes: 27 additions & 10 deletions e107_handlers/form_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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']))
Expand All @@ -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}";
}
Expand All @@ -2372,14 +2389,14 @@ function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'lar
$options['other'] = " ".$height;
}


$counter = vartrue($options['counter'],false);

$ret = "<div class='bbarea {$size}'>
<div class='field-spacer'><!-- --></div>\n";


if(e107::wysiwyg() === true)
if(e107::wysiwyg() === true && $wysiwyg !== false)
{
$eParseList = e107::getConfig()->get('e_parse_list');

Expand Down
11 changes: 7 additions & 4 deletions e107_plugins/forum/forum_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion e107_plugins/forum/shortcodes/batch/post_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}

Expand Down

1 comment on commit e5af746

@Jimmi08
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arunshekher Great work. Only note: Rich Text Editor - this was confusing label for me. If I get this right, maybe label "The same as post" or "Post editor" would be better.

Please sign in to comment.