Quantcast
Channel: MyBB Community Forums - Tutorials
Viewing all articles
Browse latest Browse all 685

[1.8] How add sceditor in quick reply and quick edit

$
0
0
Ps. This only work with latest version of mybb 1.8 Beta 2 of Github
https://github.com/mybb/mybb/archive/feature.zip

Ps2. If need modification in final version of mybb 1.8 to this work, i will update this tutorial, don´t worry.
Ps3. Plz, not request to me or send PM asking how to add buttons in the editor. I'll just ignore it.

With Smilies box:

1 - Create quickadveditor.php in notepad++

PHP Code:
<?php 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Plugin info
function quickadveditor_info ()
{
    return array(
        
"name"            => "Quick Advanced Editor",
        
"description"    => "Advanced editor in quick reply",
        
"website"        => "",
        
"author"        => "martec",
        
"authorsite"    => "",
        
"version"        => "1.0",
        
"guid"             => "1.0",
        
"compatibility" => "1*"
    
);
}

function 
quickadveditor_activate()
{
    include_once 
MYBB_ROOT."inc/adminfunctions_templates.php";

    
find_replace_templatesets(
        
'showthread_quickreply',
        
'#' preg_quote('</textarea>') . '#i',
        
'</textarea>{$codebuttons}'
    
);

    
find_replace_templatesets(
        
'showthread_quickreply',
        
'#' preg_quote('<span class="smalltext">{$lang->message_note}<br />') . '#i',
        
'<span class="smalltext">{$lang->message_note}<br />{$smilieinserter}'
    
);
}

function 
quickadveditor_deactivate()
{
    include_once 
MYBB_ROOT."inc/adminfunctions_templates.php";

    
find_replace_templatesets(
        
'showthread_quickreply',
        
'#' preg_quote('</textarea>{$codebuttons}') . '#i',
        
'</textarea>'
    
);

    
find_replace_templatesets(
        
'showthread_quickreply',
        
'#' preg_quote('<span class="smalltext">{$lang->message_note}<br />{$smilieinserter}') . '#i',
        
'<span class="smalltext">{$lang->message_note}<br />'
    
);
}

$plugins->add_hook("showthread_start""codebuttons");     

function 
codebuttons () {

    global 
$smilieinserter$codebuttons;

    
$codebuttons build_mycode_inserter();
    
$smilieinserter build_clickable_smilies();

}    

?>

2 - upload quickadveditor.php to root/inc/plugins and activate.

3 - Go to codebuttons template in ACP

3.1 - Find

PHP Code:
plugins"bbcode"

3.2 - Add after

PHP Code:
height250

3.3 - Find

PHP Code:
    {$sourcemode}
}); 

3.4 - Add after

PHP Code:
/**********************************
 * Thread compatibility functions *
 **********************************/
if(typeof Thread !== 'undefined')
{
    var 
quickReplyFunc Thread.quickReply;
    
// update the textarea to the editors value before the Thread class
    // uses it for quickReply, ect.
    
Thread.quickReply = function(e) {
        var 
editor jQuery('#message, #signature').data('sceditor');

        if(
editor)
            
editor.updateOriginal();

        return 
quickReplyFunc.call(thise);
}; 

Without Smilies box:

1 - Create quickadveditor.php in notepad++

PHP Code:
<?php 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Plugin info
function quickadveditor_info ()
{
    return array(
        
"name"            => "Quick Advanced Editor",
        
"description"    => "Advanced editor in quick reply",
        
"website"        => "",
        
"author"        => "martec",
        
"authorsite"    => "",
        
"version"        => "1.0",
        
"guid"             => "1.0",
        
"compatibility" => "1*"
    
);
}

function 
quickadveditor_activate()
{
    include_once 
MYBB_ROOT."inc/adminfunctions_templates.php";

    
find_replace_templatesets(
        
'showthread_quickreply',
        
'#' preg_quote('</textarea>') . '#i',
        
'</textarea>{$codebuttons}'
    
);
}

function 
quickadveditor_deactivate()
{
    include_once 
MYBB_ROOT."inc/adminfunctions_templates.php";

    
find_replace_templatesets(
        
'showthread_quickreply',
        
'#' preg_quote('</textarea>{$codebuttons}') . '#i',
        
'</textarea>'
    
);
}

$plugins->add_hook("showthread_start""codebuttons");     

function 
codebuttons () {

    global 
$codebuttons;

    
$codebuttons build_mycode_inserter();

}    

?>

2 - upload quickadveditor.php to root/inc/plugins and activate.

3.1 - Find

PHP Code:
plugins"bbcode"

3.2 - Add after

PHP Code:
height250

3.3 - Find

PHP Code:
    {$sourcemode}
}); 

3.4 - Add after

PHP Code:
/**********************************
 * Thread compatibility functions *
 **********************************/
if(typeof Thread !== 'undefined')
{
    var 
quickReplyFunc Thread.quickReply;
    
// update the textarea to the editors value before the Thread class
    // uses it for quickReply, ect.
    
Thread.quickReply = function(e) {
        var 
editor jQuery('#message, #signature').data('sceditor');

        if(
editor)
            
editor.updateOriginal();

        return 
quickReplyFunc.call(thise);
}; 



Bonus: Add sceditor in quick edit


Dependence: Plugin quickadveditor.php activated.

Ps. If you will use this with tutorial imgur upload button and/or spoiler button made by me plz, performing the procedure below before other tutorials.

1 - Go to codebuttons template in ACP

Replace all:

PHP Code:
<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/sceditor/editor_themes/{$theme['editortheme']}type="text/css" media="all" />
<
link rel="stylesheet" href="{$mybb->asset_url}/jscripts/sceditor/editor_themes/extrabuttons.css" type="text/css" media="all" />
<
script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/jquery.sceditor.bbcode.min.js"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/bbcodes_sceditor.js"></script>
<script type="text/javascript">
var partialmode = {$mybb->settings['partialmode']},
opt_editor = {
        plugins: "bbcode",
        height: 250,
        style: "{$mybb->asset_url}/jscripts/sceditor/jquery.sceditor.mybb.css?v=3.0",
        rtl: {$lang->settings['rtl']},
        locale: "mybblang",
        emoticonsEnabled: {$emoticons_enabled},
        emoticons: {
            // Emoticons to be included in the dropdown
            dropdown: {
                {$dropdownsmilies}
            },
            // Emoticons to be included in the more section
            more: {
                {$moresmilies}
            }
        },
        emoticonsCompat: true,
        toolbar: "{$basic1}{$align}{$font}{$size}{$color}{$removeformat}{$basic2}image,imgur,{$ema​il}{$link}|video{$emoticon}|{$list}{$code}quote|maximize,source",
};
{$editor_language}
$(function() {
    $("#{$bind}").sceditor(opt_editor);

    MyBBEditor = $("#{$bind}").sceditor("instance");
    {$sourcemode}
});

($.fn.on || $.fn.live).call($(document), 'focus', 'textarea[name*="value"]', function () {
    $(this).sceditor(opt_editor);

    MyBBEditor = $('textarea[name*="value"]').sceditor("instance");
    {$sourcemode}
});
  
/**********************************
 * Thread compatibility functions *
 **********************************/
if(typeof Thread !== 'undefined')
{
    var quickReplyFunc = Thread.quickReply;
    // update the textarea to the editors value before the Thread class
    // uses it for quickReply, ect.
    Thread.quickReply = function(e) {
        var editor = jQuery('#message, #signature').data('sceditor');

        if(editor)
            editor.updateOriginal();

        return quickReplyFunc.call(this, e);
};
</script> 

Viewing all articles
Browse latest Browse all 685

Trending Articles