Skip to content

Commit

Permalink
PM support
Browse files Browse the repository at this point in the history
  • Loading branch information
martec committed Oct 5, 2014
1 parent 44ccb81 commit 4b66359
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 21 deletions.
Binary file added images/rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions inc/languages/english/admin/config_quickadveditor.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

$l['quickadveditor_plug_desc'] = 'Advanced editor in quick reply';
$l['quickadveditor_sett_desc'] = 'Settings related to the Quick Advanced Editor.';
$l['quickadveditor_qurp_heigh_title'] = 'Height of the editor in quick reply';
$l['quickadveditor_qurp_heigh_desc'] = 'Set the height of the editor in quick reply (value in px).';
$l['quickadveditor_qued_heigh_title'] = 'Height of the editor in quick edit';
$l['quickadveditor_qued_heigh_desc'] = 'Set the height of the editor in quick edit (value in px).';
$l['quickadveditor_smile_title'] = 'Show Smile Box in Quick Reply';
$l['quickadveditor_smile_desc'] = 'Set to no if you do not want to show the smile box in quick reply.';
$l['quickadveditor_qedit_title'] = 'Show SCEditor in Quick Edit';
Expand All @@ -12,8 +16,8 @@
$l['quickadveditor_canonical_desc'] = 'Set to no if you do not want enable canonical link feature, this feature required by Auto Save Draft. If you use canonical link feature of google seo plugin, you can disable this feature.';
$l['quickadveditor_save_title'] = 'Language for save action';
$l['quickadveditor_save_desc'] = 'Define the phrase that appears when the message is saved.';
$l['quickadveditor_restor_title'] = 'Language for restore action';
$l['quickadveditor_restor_desc'] = 'Define the phrase that appears when the message is restored.';
$l['quickadveditor_restor_title'] = 'Language for restore button';
$l['quickadveditor_restor_desc'] = 'Define the phrase that appears to restore button.';
$l['quickadveditor_save_default'] = 'Auto Save: Message Saved.';
$l['quickadveditor_restor_default'] = 'Auto Save: Message Restored.';
$l['quickadveditor_restor_default'] = 'Restore';
?>
200 changes: 182 additions & 18 deletions inc/plugins/quickadveditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function quickadveditor_info ()
"website" => "",
"author" => "martec",
"authorsite" => "",
"version" => "5.1.1",
"version" => "5.5.0",
"guid" => "",
"compatibility" => "18*"
);
Expand All @@ -39,13 +39,33 @@ function quickadveditor_install()
'isdefault' => '0'
));

$db->insert_query('settings', array(
'name' => 'quickadveditor_qurp_heigh',
'title' => $lang->quickadveditor_qurp_heigh_title,
'description' => $lang->quickadveditor_qurp_heigh_desc,
'optionscode' => 'text',
'value' => '280',
'disporder' => '1',
'gid' => $groupid
));

$db->insert_query('settings', array(
'name' => 'quickadveditor_qued_heigh',
'title' => $lang->quickadveditor_qued_heigh_title,
'description' => $lang->quickadveditor_qued_heigh_desc,
'optionscode' => 'text',
'value' => '300',
'disporder' => '2',
'gid' => $groupid
));

$db->insert_query('settings', array(
'name' => 'quickadveditor_smile',
'title' => $lang->quickadveditor_smile_title,
'description' => $lang->quickadveditor_smile_desc,
'optionscode' => 'onoff',
'value' => '0',
'disporder' => '1',
'disporder' => '3',
'gid' => $groupid
));

Expand All @@ -55,7 +75,7 @@ function quickadveditor_install()
'description' => $lang->quickadveditor_qedit_desc,
'optionscode' => 'onoff',
'value' => '1',
'disporder' => '2',
'disporder' => '4',
'gid' => $groupid
));

Expand All @@ -65,7 +85,7 @@ function quickadveditor_install()
'description' => $lang->quickadveditor_autosave_desc,
'optionscode' => 'onoff',
'value' => '1',
'disporder' => '3',
'disporder' => '5',
'gid' => $groupid
));

Expand All @@ -75,7 +95,7 @@ function quickadveditor_install()
'description' => $lang->quickadveditor_canonical_desc,
'optionscode' => 'onoff',
'value' => '1',
'disporder' => '4',
'disporder' => '6',
'gid' => $groupid
));

Expand All @@ -85,7 +105,7 @@ function quickadveditor_install()
'description' => $lang->quickadveditor_save_desc,
'optionscode' => 'text',
'value' => $lang->quickadveditor_save_default,
'disporder' => '5',
'disporder' => '7',
'gid' => $groupid
));

Expand All @@ -95,7 +115,7 @@ function quickadveditor_install()
'description' => $lang->quickadveditor_restor_desc,
'optionscode' => 'text',
'value' => $lang->quickadveditor_restor_default,
'disporder' => '6',
'disporder' => '8',
'gid' => $groupid
));

Expand Down Expand Up @@ -230,13 +250,13 @@ function quickadveditor_activate()
setTimeout(function() {
restitem = localStorage.getItem(link_can + \'quickreply\');
if (restitem) {
if(!\$(\'#autosave\').length) {
\$(\'<div/>\', { id: \'autosave\', class: \'bottom-right\' }).appendTo(\'body\');
}
setTimeout(function() {
\$(\'#autosave\').jGrowl(\'{\$mybb->settings[\'quickadveditor_restor_lang\']}\', { life: 500 });
},200);
MyBBEditor.val(restitem);
var restorebut = [
\'<a class=\"sceditor-button\" title=\"{\$mybb->settings[\'quickadveditor_restor_lang\']}\" onclick=\"MyBBEditor.insert(restitem);\">\',
\'<div style=\"background-image: url(images/rest.png); opacity: 1; cursor: pointer;\">{\$mybb->settings[\'quickadveditor_restor_lang\']}</div>\',
\'</a>\'
];
\$(restorebut.join(\'\')).appendTo(\'.sceditor-group:last\');
}
},600);
MyBBEditor.blur(function(e) {
Expand Down Expand Up @@ -276,18 +296,125 @@ function quickadveditor_activate()
);
$db->insert_query("templates", $template);

$template2 = array(
"tid" => NULL,
"title" => "codebutquick_pm",
"template" => "<link rel=\"stylesheet\" href=\"{\$mybb->asset_url}/jscripts/sceditor/editor_themes/{\$theme[\'editortheme\']}\" 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\",
style: \"{\$mybb->asset_url}/jscripts/sceditor/jquery.sceditor.mybb.css\",
rtl: {\$lang->settings[\'rtl\']},
locale: \"mybblang\",
enablePasteFiltering: true,
emoticonsEnabled: {\$emoticons_enabled},
emoticons: {
// Emoticons to be included in the dropdown
dropdown: {
{\$dropdownsmilies}
},
// Emoticons to be included in the more section
more: {
{\$moresmilies}
},
// Emoticons that are not shown in the dropdown but will still be converted. Can be used for things like aliases
hidden: {
{\$hiddensmilies}
}
},
emoticonsCompat: true,
toolbar: \"{\$basic1}{\$align}{\$font}{\$size}{\$color}{\$removeformat}{\$basic2}image,{\$email}{\$link}|video{\$emoticon}|{\$list}{\$code}quote|maximize,source\",
};
{\$editor_language}
(\$.fn.on || \$.fn.live).call(\$(document), \'click\', \'input[accesskey*=\"s\"]\', function () {
MyBBEditor.updateOriginal();
localStorage.removeItem(location.href + \'quickreply\');
});
(\$.fn.on || \$.fn.live).call(\$(document), \'click\', \'input[name*=\"preview\"]\', function () {
MyBBEditor.updateOriginal();
});
\$(document).ready(function() {
\$(\'#message\').height({\$mybb->settings[\'quickadveditor_qurp_heigh\']}+\'px\');
\$(\'#message\').sceditor(opt_editor);
MyBBEditor = $(\'#message\').sceditor(\'instance\');
{\$sourcemode}
if({\$mybb->settings[\'quickadveditor_autosave\']}!=0) {
setInterval(function() {
if (MyBBEditor) {
if (MyBBEditor.val() != localStorage.getItem(location.href + \'quickreply\')) {
if (MyBBEditor.val()) {
if(!\$(\'#autosave\').length) {
\$(\'<div/>\', { id: \'autosave\', class: \'bottom-right\' }).appendTo(\'body\');
}
setTimeout(function() {
\$(\'#autosave\').jGrowl(\'{\$mybb->settings[\'quickadveditor_save_lang\']}\', { life: 500 });
},200);
localStorage.setItem(location.href + \'quickreply\', MyBBEditor.val());
}
else {
localStorage.removeItem(location.href + \'quickreply\');
}
}
}
},15000);
setTimeout(function() {
restitem = localStorage.getItem(location.href + \'quickreply\');
if (restitem) {
var restorebut = [
\'<a class=\"sceditor-button\" title=\"{\$mybb->settings[\'quickadveditor_restor_lang\']}\" onclick=\"MyBBEditor.insert(restitem);\">\',
\'<div style=\"background-image: url(images/rest.png); opacity: 1; cursor: pointer;\">{\$mybb->settings[\'quickadveditor_restor_lang\']}</div>\',
\'</a>\'
];
\$(restorebut.join(\'\')).appendTo(\'.sceditor-group:last\');
}
},600);
MyBBEditor.blur(function(e) {
if (MyBBEditor.val()) {
localStorage.setItem(location.href + \'quickreply\', MyBBEditor.val())
}
else {
localStorage.removeItem(location.href + \'quickreply\');
}
});
}
});
</script>",
"sid" => "-1"
);
$db->insert_query("templates", $template2);

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

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

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

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

find_replace_templatesets(
'showthread',
'#' . preg_quote('<body>') . '#i',
Expand All @@ -309,19 +436,32 @@ function quickadveditor_deactivate()
include_once MYBB_ROOT."inc/adminfunctions_templates.php";

$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='codebutquick'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='codebutquick_pm'");

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

find_replace_templatesets(
'private_quickreply',
'#' . preg_quote('</textarea>{$codebutquick}') . '#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 />'
);

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

find_replace_templatesets(
'showthread',
'#' . preg_quote('<body>
Expand All @@ -348,10 +488,18 @@ function advedt_cache_codebutquick()

if (THIS_SCRIPT == 'showthread.php') {
if($mybb->settings['quickadveditor_smile'] != 0) {
$templatelist .= 'codebutquick,smilieinsert,smilieinsert_smilie,smilieinsert_getmore';
$templatelist .= 'codebutquick,smilieinsert,smilieinsert_smilie,smilieinsert_getmore';
}
else {
$templatelist .= 'codebutquick';
$templatelist .= 'codebutquick';
}
}
if (THIS_SCRIPT == 'private.php') {
if($mybb->settings['quickadveditor_smile'] != 0) {
$templatelist .= 'codebutquick_pm,smilieinsert,smilieinsert_smilie,smilieinsert_getmore';
}
else {
$templatelist .= 'codebutquick_pm';
}
}
}
Expand Down Expand Up @@ -577,14 +725,18 @@ function mycode_inserter_quick_lite($smilies = true)
$sourcemode = "MyBBEditor.sourceMode(true);";
}

eval("\$codeinsertquick = \"".$templates->get("codebutquick")."\";");
if (!strpos($_SERVER['PHP_SELF'],'private.php')) {
eval("\$codeinsertquick = \"".$templates->get("codebutquick")."\";");
}
else {
eval("\$codeinsertquick = \"".$templates->get("codebutquick_pm")."\";");
}
}

return $codeinsertquick;
}

$plugins->add_hook("showthread_start", "codebuttonsquick_lite");

function codebuttonsquick_lite () {

global $smilieinserter, $codebutquick, $codebutquickedt, $mybb;
Expand All @@ -599,6 +751,18 @@ function codebuttonsquick_lite () {
}
}

$plugins->add_hook("private_start", "codebuttonsquick_lite_pm");
function codebuttonsquick_lite_pm () {

global $smilieinserter, $codebutquick, $mybb;

$codebutquick = mycode_inserter_quick_lite();
$smilieinserter = '';
if($mybb->settings['quickadveditor_smile'] != 0) {
$smilieinserter = build_clickable_smilies();
}
}

$plugins->add_hook('postbit', 'canonical_postbit');

function canonical_lite($link)
Expand Down

0 comments on commit 4b66359

Please sign in to comment.