1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

Removed TinyMce from every page load. e_footer.php introduced and e107::wysiwyg() toggle method.

This commit is contained in:
Cameron
2015-01-29 11:26:56 -08:00
parent 6621247583
commit 86c1bd3353
11 changed files with 89 additions and 221 deletions

View File

@@ -70,18 +70,6 @@ if (!defined('ADMIN_WIDTH')) //BC Only
// Wysiwyg JS support on or off.
// your code should run off e_WYSIWYG
if (e107::getPref('wysiwyg', false) ) // posts bbcode by default.
{
define("e_WYSIWYG", TRUE);
}
else
{
define("e_WYSIWYG", FALSE);
}
/** /**
* Automate DB system messages DEPRECATED * Automate DB system messages DEPRECATED
* NOTE: default value of $output parameter will be changed to false (no output by default) in the future * NOTE: default value of $output parameter will be changed to false (no output by default) in the future

View File

@@ -275,7 +275,7 @@ if (function_exists('theme_foot'))
// //
// F any included JS footer scripts // F any included JS footer scripts
// DEPRECATED - use e107::getJs()->footerFile('{e_PLUGIN}myplug/js/my.js', $zone = 2) // DEPRECATED - use e107::js('footer', '{e_PLUGIN}myplug/js/my.js', $zone = 2)
// //
global $footer_js; global $footer_js;
if (isset($footer_js) && is_array($footer_js)) if (isset($footer_js) && is_array($footer_js))
@@ -288,6 +288,32 @@ if (isset($footer_js) && is_array($footer_js))
} }
} }
// Load e_footer.php files.
if (is_array($pref['e_footer_list']))
{
// ob_start();
foreach($pref['e_footer_list'] as $val)
{
$fname = e_PLUGIN.$val."/e_footer.php"; // Do not place inside a function - BC $pref required. .
if(is_readable($fname))
{
$ret = ($e107_debug || isset($_E107['debug'])) ? include_once($fname) : @include_once($fname);
}
}
// $e_footer_ouput = ob_get_contents(); // Don't use.
// ob_end_clean();
unset($ret);
}
// [JSManager] Load JS Footer Includes by priority // [JSManager] Load JS Footer Includes by priority
e107::getJs()->renderJs('footer', true); e107::getJs()->renderJs('footer', true);

View File

@@ -33,7 +33,7 @@ e107::js('core', 'plupload/plupload.full.js', 'jquery', 2);
e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery');
e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2);
e107::js('core', 'core/mediaManager.js',"jquery",5); e107::js('core', 'core/mediaManager.js',"jquery",5);
e107::wysiwyg(true);
/* /*
* CLOSE - GO TO MAIN SCREEN * CLOSE - GO TO MAIN SCREEN
*/ */

View File

@@ -132,7 +132,7 @@ class bbcode_shortcodes extends e_shortcode
list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
} }
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Youtube video via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=video' >"; $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Youtube video via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=video' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48); $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
$text .= "</a>"; $text .= "</a>";
@@ -152,7 +152,7 @@ class bbcode_shortcodes extends e_shortcode
} }
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Glyphicon via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=glyph' >"; $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Glyphicon via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=glyph' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48); $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
$text .= "</a>"; $text .= "</a>";
@@ -211,7 +211,7 @@ class bbcode_shortcodes extends e_shortcode
{ {
list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
} }
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert an Image from the Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=img' >"; $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert an Image from the Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=img' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o'); $text .= $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o');
// $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/preimage.png' title='".LANHELP_45."' alt='' />"; // $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/preimage.png' title='".LANHELP_45."' alt='' />";
@@ -297,7 +297,7 @@ class bbcode_shortcodes extends e_shortcode
$pref = e107::getPref(); $pref = e107::getPref();
if ($pref['comments_emoticons'] && $pref['smiley_activate'] && !defsettrue('e_WYSIWYG')) if ($pref['comments_emoticons'] && $pref['smiley_activate'] && !e107::wysiwyg())
{ {
if(deftrue('BOOTSTRAP')) if(deftrue('BOOTSTRAP'))
{ {
@@ -498,7 +498,7 @@ class bbcode_shortcodes extends e_shortcode
//FIXME - cachevars/getcachedvars! //FIXME - cachevars/getcachedvars!
global $pref, $eplug_bb, $bbcode_func, $bbcode_help, $bbcode_helpactive, $bbcode_helptag, $register_bb; global $pref, $eplug_bb, $bbcode_func, $bbcode_help, $bbcode_helpactive, $bbcode_helptag, $register_bb;
// if(defsettrue('e_WYSIWYG')){ return; }
$eplug_bb = $this->var['eplug_bb'] ? $this->var['eplug_bb'] : array(); $eplug_bb = $this->var['eplug_bb'] ? $this->var['eplug_bb'] : array();
$bbcode_func = ($this->var['trigger']) ? $this->var['trigger'] : "addtext"; $bbcode_func = ($this->var['trigger']) ? $this->var['trigger'] : "addtext";
@@ -508,20 +508,7 @@ class bbcode_shortcodes extends e_shortcode
$bbcode_tag = ($bbcode_helptag != 'helpb') ? ",'$bbcode_helptag'" : ""; $bbcode_tag = ($bbcode_helptag != 'helpb') ? ",'$bbcode_helptag'" : "";
$rand = rand(1000,9999); $rand = rand(1000,9999);
// $imagedir_display = str_replace('../','',$bbcode_imagedir);
/*
if($parm == 'emotes')
{
if ($pref['comments_emoticons'] && $pref['smiley_activate'] && !defsettrue('e_WYSIWYG'))
{
$bbcode['emotes'] = array("expandit","emoticon_selector_".$rand, LANHELP_44, "emotes.png", "Emoticon_Select", "emoticon_selector_".$rand);
}
else
{ // If emotes disabled, don't return anything (without this we return an empty image reference)
return '';
}
}
*/
// Format: $bbcode['UNIQUE_NAME'] = array(ONCLICK_FUNC, ONCLICK_VAR, HELPTEXT, ICON, INCLUDE_FUNC, INCLUDE_FUNCTION_VAR); // Format: $bbcode['UNIQUE_NAME'] = array(ONCLICK_FUNC, ONCLICK_VAR, HELPTEXT, ICON, INCLUDE_FUNC, INCLUDE_FUNCTION_VAR);
@@ -609,7 +596,7 @@ class bbcode_shortcodes extends e_shortcode
} }
else else
{ {
$pre = "<a class='btn ".vartrue($bbcode[$parm][7], 'e-pointer')."' title=\"".str_replace('<br />','\\n',($_helptxt))."\" onclick=\"{$_onclick_func}('".$_onclick_var."')\" ".($bbcode_helpactive ? "onmouseout=\"{$bbcode_help}(''{$bbcode_tag})\" onmouseover=\"{$bbcode_help}('".$_helptxt."'{$bbcode_tag})\"" : "" )." />"; $pre = "<a class='btn ".vartrue($bbcode[$parm][7], 'e-pointer')."' title=\"".str_replace('<br />','\\n',($_helptxt))."\" onclick=\"{$_onclick_func}('".$_onclick_var."')\" ".($bbcode_helpactive ? "onmouseout=\"{$bbcode_help}(''{$bbcode_tag})\" onmouseover=\"{$bbcode_help}('".$_helptxt."'{$bbcode_tag})\"" : "" )." >";
$post = "</a>\n"; // btn-small bbcode bbcode_buttons $post = "</a>\n"; // btn-small bbcode bbcode_buttons
} }
@@ -656,7 +643,7 @@ class bbcode_shortcodes extends e_shortcode
function sc_bb_preimagedir($parm) function sc_bb_preimagedir($parm)
{ {
// if(defsettrue('e_WYSIWYG')) { return; }
// global $bbcode_imagedir; // global $bbcode_imagedir;
// $bbcode_imagedir = $parm; // $bbcode_imagedir = $parm;
// return; // return;

View File

@@ -277,6 +277,29 @@ if (isset($footer_js) && is_array($footer_js))
} }
} }
// Load e_footer.php files.
if (is_array($pref['e_footer_list']))
{
ob_start();
foreach($pref['e_footer_list'] as $val)
{
$fname = e_PLUGIN.$val."/e_footer.php"; // Do not place inside a function - BC $pref required. .
if(is_readable($fname))
{
$ret = ($e107_debug || isset($_E107['debug'])) ? include_once($fname) : @include_once($fname);
}
}
$e_footer_ouput = ob_get_contents(); // Don't use.
ob_end_clean();
unset($ret);
}
// [JSManager] Load JS Footer Includes by priority // [JSManager] Load JS Footer Includes by priority
e107::getJs()->renderJs('footer', true); e107::getJs()->renderJs('footer', true);

View File

@@ -148,15 +148,7 @@ echo e107::getUrl()->response()->renderMeta()."\n";
echo "<title>".(defined('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n"; echo "<title>".(defined('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."</title>\n\n";
// Wysiwyg JS support on or off.
if (varset($pref['wysiwyg'],FALSE))
{
define("e_WYSIWYG",TRUE);
}
else
{
define("e_WYSIWYG",FALSE);
}

View File

@@ -2599,6 +2599,26 @@ class e107
} }
/**
* Set or Retrieve WYSIWYG active status. (replaces constant e_WYSIWYG)
*/
public static function wysiwyg($val=null)
{
if (self::getPref('core','wysiwyg',false) != true)
{
return false;
}
if(is_null($val))
{
return self::getRegistry('core/e107/wysiwyg');
}
else
{
return self::setRegistry('core/e107/wysiwyg',$val);
}
}
/** /**

View File

@@ -1218,6 +1218,9 @@ class e_form
$_SESSION['media_category'] = $mediaCat; // used by TinyMce. $_SESSION['media_category'] = $mediaCat; // used by TinyMce.
e107::wysiwyg(true); // bbarea loaded, so activate wysiwyg (if enabled in preferences)
return $ret; return $ret;
// Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler // Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler

View File

@@ -36,8 +36,8 @@ class e107plugin
'e_meta', 'e_meta',
'e_emailprint', 'e_emailprint',
'e_frontpage', 'e_frontpage',
'e_latest', // @TODO Move inside e_dashboard as latest() 'e_latest', // @Deprecated - see e_dashboard
'e_status', // @TODO Move inside e_dashboard as status() 'e_status', //@Deprecated - see e_dashboard
'e_search', 'e_search',
'e_shortcode', 'e_shortcode',
'e_module', 'e_module',
@@ -46,13 +46,14 @@ class e107plugin
'e_sql', 'e_sql',
'e_dashboard', // Admin Front-Page addon. 'e_dashboard', // Admin Front-Page addon.
// 'e_userprofile', @deprecated @see e_user // 'e_userprofile', @deprecated @see e_user
'e_header', 'e_header', // loaded in header prior to javascript manager.
'e_footer', // Loaded in footer prior to javascript manager.
// 'e_userinfo', @deprecated @see e_user // 'e_userinfo', @deprecated @see e_user
'e_tagwords', 'e_tagwords',
'e_url', // simple mod-rewrite. 'e_url', // simple mod-rewrite.
'e_mailout', 'e_mailout',
'e_sitelink', 'e_sitelink', // sitelinks generator.
'e_tohtml', 'e_tohtml',
'e_featurebox', 'e_featurebox',
'e_related', 'e_related',

View File

@@ -87,7 +87,7 @@ class plugin_forum_post_shortcodes extends e_shortcode
return e107::getForm()->bbarea('post',$post,'forum'); return e107::getForm()->bbarea('post',$post,'forum');
$rows = (e_WYSIWYG) ? 15 : 10; $rows = (e107::wysiwyg()==true) ? 15 : 10;
$ret = "<textarea class='e-wysiwyg tbox' id='post' name='post' cols='70' rows='{$rows}' style='width:95%' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$post</textarea>\n<br />\n"; $ret = "<textarea class='e-wysiwyg tbox' id='post' name='post' cols='70' rows='{$rows}' style='width:95%' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>$post</textarea>\n<br />\n";
// if(!e_WYSIWYG) // if(!e_WYSIWYG)
{ {

View File

@@ -19,177 +19,5 @@ e107::css('inline','
'); ');
$pref = e107::getPref();
if((e_WYSIWYG && check_class($pref['post_html'])) || strpos(e_SELF,"tinymce4/admin_config.php") )
{
if(e_PAGE != 'image.php')
{
//e107::js('tinymce','tiny_mce.js','jquery');
//e107::js('tinymce','wysiwyg.php','jquery',5);
e107::js('url', "//tinymce.cachefly.net/4.0/tinymce.min.js");
e107::js('tinymce4','wysiwyg.php','jquery',5);
// e107::js('inline', "
// tinymce.init({selector:'.e-wysiwyg'});
// ");
}
else
{
// e107::js('tinymce','tiny_mce_popup.js','jquery');
}
if(ADMIN)
{
$insert = "$('#'+id).after('<div>";
// $insert .= "<a href=\"#\" id=\"' + id + '\" class=\"e-wysiwyg-toggle btn btn-inverse btn-mini\">Switch to bbcode<\/a>";
if(e_PAGE == 'mailout.php')
{
$insert .= "&nbsp;&nbsp;<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|USERNAME|\" >".LAN_MAILOUT_16."<\/a>";
$insert .= "<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|DISPLAYNAME|\" >".LAN_MAILOUT_14."<\/a>";
$insert .= "<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|SIGNUP_LINK|\" >".LAN_MAILOUT_17."<\/a>";
$insert .= "<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|USERID|\" >".LAN_MAILOUT_18."<\/a>";
}
$insert .= "</div>');";
define("SWITCH_TO_BB",$insert);
}
else
{
define("SWITCH_TO_BB","");
}
// print_a($_POST);
// <div><a href='#' class='e-wysiwyg-switch' onclick=\"tinyMCE.execCommand('mceToggleEditor',false,'".$tinyMceID."');expandit('".$toggleID."');\">Toggle WYSIWYG</a></div>
e107::js('inline',"
$(function() {
$('.e-wysiwyg').each(function() {
var id = $(this).attr('id'); // 'e-wysiwyg';
".SWITCH_TO_BB."
// alert(id);
$('#bbcode-panel-'+id+'--preview').hide();
});
$('.tinyInsert').click(function() {
var val = $(this).attr('data-value');
top.tinymce.activeEditor.execCommand('mceInsertContent',0,val);
return false;
});
/*
$('img.tinyInsertEmote').live('click',function() {
var src = $(this).attr('src');
alert(src);
// var html = '<img src=\''+src +'\' alt=\'emote\' />';
tinyMCE.execCommand('mceInsertRawHTML',false, 'hi there');
;
$('.mceContentBody', window.top.document).tinymce().execCommand('mceInsertContent',false,src);
// tinyMCE.selectedInstance.execCommand('mceInsertContent',0,src);
$('#uiModal').modal('hide');
return true;
});*/
// When new tab is added - convert textarea to TinyMce.
$('.e-tabs-add').on('click',function(){
alert('New Page Added'); // added for delay - quick and dirty work-around. XXX fixme
var idt = $(this).attr('data-target'); // eg. news-body
var ct = parseInt($('#e-tab-count').val());
var id = idt + '-' + ct;
$('#bbcode-panel-'+id+'--preview').hide();
".SWITCH_TO_BB."
top.tinymce.activeEditor.execCommand('mceAddControl', false, id);
});
$('a.e-wysiwyg-toggle').toggle(function(){
var id = $(this).attr('id'); // eg. news-body
$('#bbcode-panel-'+id+'--preview').show();
$(this).text('Switch to wysiwyg');
tinymce.activeEditor.execCommand('mceRemoveControl', false, id);
}, function () {
var id = $(this).attr('id');
$('#bbcode-panel-'+id+'--preview').hide();
$(this).text('Switch to bbcode');
tinymce.activeEditor.execCommand('mceAddControl', false, id);
});
$('.e-dialog-save').live('click', function(){
// var html = $('#html_holder').val();
var s = $('#bbcode_holder').val();
var p = $.ajax({
type: 'POST',
url: '".e_PLUGIN_ABS. "tinymce4/plugins/e107/parser.php', // parse bbcode value
data: { content: s, mode: 'tohtml' },
async : false,
dataType: 'html',
success: function(html) {
return html;
}
}).responseText;
html = p;
// alert(html);
if(html === undefined)
{
return;
}
// tinyMCE.execCommand('mceInsertContent',false,html);
top.tinymce.activeEditor.execCommand('mceInsertRawHTML',false,html);
top.tinymce.activeEditor.windowManager.close();
});
// $('.e-dialog-close').click(function(){
// top.tinymce.activeEditor.windowManager.close();
// });
});
","jquery");
}
?> ?>