1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

choose editor in forum and quick reply

New prefs for forum: editor & quickreply
editor makes it possible to choose between bbcode or tinymce (if installed and html enabled)
quickreply gives the option to choose between the standard textarea or the choosen editor (from pref editor)
This commit is contained in:
Achim Ennenbach 2018-07-25 22:48:14 +02:00
parent 526bc06ba0
commit 26022e4507
6 changed files with 96 additions and 17 deletions

View File

@ -3627,17 +3627,38 @@ class e107
/**
* Set or Retrieve WYSIWYG active status. (replaces constant e_WYSIWYG)
* @param null $val
* @param bool $val if null, return current value, otherwise set value to registry
* @return bool|mixed|void
*/
public static function wysiwyg($val=null)
{
// Check the general wysiwyg setting
if (self::getPref('wysiwyg',false) != true)
{
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');

View File

@ -2271,9 +2271,16 @@ class e_form
// auto-height support
$options['class'] = 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg e-autoheight form-control';
$bbbar = '';
$help_tagid = $this->name2id($name)."--preview";
if (isset($options['id']) && !empty($options['id']))
{
$help_tagid = $this->name2id($options['id'])."--preview";
}
else
{
$help_tagid = $this->name2id($name)."--preview";
}
if(e107::wysiwyg(true) === false) // bbarea loaded, so activate wysiwyg (if enabled in preferences)

View File

@ -183,6 +183,9 @@ if(!deftrue('OLD_FORUMADMIN'))
'popular' => array('title' => FORLAN_55, 'type'=>'number', 'data' => 'int','help'=>FORLAN_56),
'postspage' => array('title' => FORLAN_57, 'type'=>'number', 'data' => 'int','help'=>FORLAN_58),
'threadspage' => array('title' => FORLAN_186, 'type'=>'number', 'data' => 'int','help'=>FORLAN_187),
'editor' => array('title' => 'Post editor', 'type' => 'dropdown', 'data' => 'str', 'readParms' => array(), 'writeParms' => array('optArray' => array(), 'defaultValue' => 'default'), 'help' => 'Which editor should be used to create/edit posts?'),
'quickreply' => array('title' => 'Quick replay editor', 'type' => 'dropdown', 'data' => 'str', 'readParms' => array(), 'writeParms' => array('optArray' => array(), 'defaultValue' => 'default'), 'help' => '')
);
public $forumParents = array();
@ -225,6 +228,19 @@ if(!deftrue('OLD_FORUMADMIN'))
$this->checkOrder();
$this->prefs['editor']['writeParms']['optArray']['default'] = 'System editor';
$this->prefs['editor']['writeParms']['optArray']['bbcode'] = 'BBCode';
if (e107::isInstalled('tinymce4'))
{
$this->prefs['editor']['writeParms']['optArray']['tinymce4'] = 'TinyMCE';
}
$this->prefs['quickreply']['writeParms']['optArray'] = array(
'default' => 'Textarea',
'wysiwyg' => 'Editor'
);
if(e107::isInstalled('poll') == false)
{
$this->prefs['poll']['writeParms']['post'] = " <span class='label label-important label-danger'>".FORLAN_215."</span>";

View File

@ -27,7 +27,14 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
var action = $this.attr('data-forum-action');
var thread = $this.attr('data-forum-thread');
var post = $this.attr('data-forum-post');
var text = $('#forum-quickreply-text').val();
if (typeof tinymce == 'undefined')
{
var text = $('#forum-quickreply-text').val();
}
else
{
var text = tinymce.get('forum-quickreply-text').getContent();
}
var insert = $this.attr('data-forum-insert');
var token = $this.attr('data-token');
var script = $this.attr("src");
@ -109,7 +116,14 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
e107.attachBehaviors();
}
$('#forum-quickreply-text').val('');
if (typeof tinymce == 'undefined')
{
$('#forum-quickreply-text').val('');
}
else
{
tinymce.get('forum-quickreply-text').setContent('');
}
return;
}

View File

@ -1196,17 +1196,38 @@
$urlParms = array('f' => 'rp', 'id' => $this->var['thread_id'], 'post' => $this->var['thread_id']);
$url = e107::url('forum', 'post', null, array('query' => $urlParms));; // ."?f=rp&amp;id=".$thread->threadInfo['thread_id']."&amp;post=".$thread->threadInfo['thread_id'];
return "
<form action='" . $url . "' method='post'>
<div class='form-group'>
<textarea cols='80' placeholder='" . LAN_FORUM_2007 . "' rows='4' id='forum-quickreply-text' class='tbox input-xxlarge form-control' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
</div>
<div class='center text-center form-group'>
<input type='submit' data-token='" . e_TOKEN . "' data-forum-insert='" . $ajaxInsert . "' data-forum-post='" . $this->var['thread_forum_id'] . "' data-forum-thread='" . $this->var['thread_id'] . "' data-forum-action='quickreply' name='reply' value='" . LAN_FORUM_2006 . "' class='btn btn-success button' />
<input type='hidden' name='thread_id' value='" . $this->var['thread_id'] . "' />
</div>
$qr = e107::getPlugPref('forum', 'quickreply', 'default');
if ($qr == 'default')
{
</form>";
return "
<form action='" . $url . "' method='post'>
<div class='form-group'>
<textarea cols='80' placeholder='" . LAN_FORUM_2007 . "' rows='4' id='forum-quickreply-text' class='tbox input-xxlarge form-control' name='post' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'></textarea>
</div>
<div class='center text-center form-group'>
<input type='submit' data-token='" . e_TOKEN . "' data-forum-insert='" . $ajaxInsert . "' data-forum-post='" . $this->var['thread_forum_id'] . "' data-forum-thread='" . $this->var['thread_id'] . "' data-forum-action='quickreply' name='reply' value='" . LAN_FORUM_2006 . "' class='btn btn-success button' />
<input type='hidden' name='thread_id' value='" . $this->var['thread_id'] . "' />
</div>
</form>";
}
else
{
$text = "
<form action='" . $url . "' method='post'>
<div class='form-group'>" .
e107::getForm()->bbarea('post','','forum', '_common', 'small', array('id' => 'forum-quickreply-text')) .
"</div>
<div class='center text-center form-group'>
<input type='submit' data-token='" . e_TOKEN . "' data-forum-insert='" . $ajaxInsert . "' data-forum-post='" . $this->var['thread_forum_id'] . "' data-forum-thread='" . $this->var['thread_id'] . "' data-forum-action='quickreply' name='reply' value='" . LAN_FORUM_2006 . "' class='btn btn-success button' />
<input type='hidden' name='thread_id' value='" . $this->var['thread_id'] . "' />
</div>
</form>";
return $text;
}
if(E107_DEBUG_LEVEL > 0)
{

View File

@ -402,7 +402,7 @@ $FORUM_VIEWTOPIC_TEMPLATE['end'] = "</ul>
</div>
</div>
<div class='row'>
<div class='col-xs-12 col-md-6 col-md-offset-3'>
<div class='col-xs-12 col-md-8 col-md-offset-2'>
{QUICKREPLY}
</div>
</div>