From 86c1bd3353cd3276249d10264e5e4bf895be466f Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 29 Jan 2015 11:26:56 -0800 Subject: [PATCH] Removed TinyMce from every page load. e_footer.php introduced and e107::wysiwyg() toggle method. --- e107_admin/boot.php | 12 -- e107_admin/footer.php | 28 ++- e107_admin/image.php | 2 +- .../shortcodes/batch/bbcode_shortcodes.php | 29 +-- e107_core/templates/footer_default.php | 23 +++ e107_core/templates/header_default.php | 10 +- e107_handlers/e107_class.php | 20 ++ e107_handlers/form_handler.php | 3 + e107_handlers/plugin_class.php | 9 +- .../shortcodes/batch/post_shortcodes.php | 2 +- e107_plugins/tinymce4/e_meta.php | 172 ------------------ 11 files changed, 89 insertions(+), 221 deletions(-) diff --git a/e107_admin/boot.php b/e107_admin/boot.php index e5a8d5657..3f216f5c0 100644 --- a/e107_admin/boot.php +++ b/e107_admin/boot.php @@ -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 * NOTE: default value of $output parameter will be changed to false (no output by default) in the future diff --git a/e107_admin/footer.php b/e107_admin/footer.php index d71bbc423..0d7ca70c0 100644 --- a/e107_admin/footer.php +++ b/e107_admin/footer.php @@ -275,7 +275,7 @@ if (function_exists('theme_foot')) // // 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; 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 e107::getJs()->renderJs('footer', true); diff --git a/e107_admin/image.php b/e107_admin/image.php index bc15ac955..2a6d8d186 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -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::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); e107::js('core', 'core/mediaManager.js',"jquery",5); - +e107::wysiwyg(true); /* * CLOSE - GO TO MAIN SCREEN */ diff --git a/e107_core/shortcodes/batch/bbcode_shortcodes.php b/e107_core/shortcodes/batch/bbcode_shortcodes.php index 18cd75943..491f3b7c4 100644 --- a/e107_core/shortcodes/batch/bbcode_shortcodes.php +++ b/e107_core/shortcodes/batch/bbcode_shortcodes.php @@ -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. } - $text = ""; + $text = ""; $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48); $text .= ""; @@ -152,7 +152,7 @@ class bbcode_shortcodes extends e_shortcode } - $text = ""; + $text = ""; $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48); $text .= ""; @@ -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. } - $text = ""; + $text = ""; $text .= $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o'); // $text .= ""; @@ -297,7 +297,7 @@ class bbcode_shortcodes extends e_shortcode $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')) { @@ -498,7 +498,7 @@ class bbcode_shortcodes extends e_shortcode //FIXME - cachevars/getcachedvars! 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(); $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'" : ""; $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); @@ -609,7 +596,7 @@ class bbcode_shortcodes extends e_shortcode } else { - $pre = "','\\n',($_helptxt))."\" onclick=\"{$_onclick_func}('".$_onclick_var."')\" ".($bbcode_helpactive ? "onmouseout=\"{$bbcode_help}(''{$bbcode_tag})\" onmouseover=\"{$bbcode_help}('".$_helptxt."'{$bbcode_tag})\"" : "" )." />"; + $pre = "','\\n',($_helptxt))."\" onclick=\"{$_onclick_func}('".$_onclick_var."')\" ".($bbcode_helpactive ? "onmouseout=\"{$bbcode_help}(''{$bbcode_tag})\" onmouseover=\"{$bbcode_help}('".$_helptxt."'{$bbcode_tag})\"" : "" )." >"; $post = "\n"; // btn-small bbcode bbcode_buttons } @@ -656,7 +643,7 @@ class bbcode_shortcodes extends e_shortcode function sc_bb_preimagedir($parm) { - // if(defsettrue('e_WYSIWYG')) { return; } + // global $bbcode_imagedir; // $bbcode_imagedir = $parm; // return; diff --git a/e107_core/templates/footer_default.php b/e107_core/templates/footer_default.php index 18ee31421..dd578da1a 100644 --- a/e107_core/templates/footer_default.php +++ b/e107_core/templates/footer_default.php @@ -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 e107::getJs()->renderJs('footer', true); diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index c28234d35..a0479a815 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -148,15 +148,7 @@ echo e107::getUrl()->response()->renderMeta()."\n"; echo "".(defined('e_PAGETITLE') ? e_PAGETITLE.' - ' : (defined('PAGE_NAME') ? PAGE_NAME.' - ' : "")).SITENAME."\n\n"; -// Wysiwyg JS support on or off. -if (varset($pref['wysiwyg'],FALSE)) -{ - define("e_WYSIWYG",TRUE); -} -else -{ - define("e_WYSIWYG",FALSE); -} + diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index a10c08935..39ff0baf8 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -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); + } + + } /** diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 9e089c392..3f8b488f5 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1218,6 +1218,9 @@ class e_form $_SESSION['media_category'] = $mediaCat; // used by TinyMce. + e107::wysiwyg(true); // bbarea loaded, so activate wysiwyg (if enabled in preferences) + + return $ret; // Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 48a663eb0..95c537dc0 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -36,8 +36,8 @@ class e107plugin 'e_meta', 'e_emailprint', 'e_frontpage', - 'e_latest', // @TODO Move inside e_dashboard as latest() - 'e_status', // @TODO Move inside e_dashboard as status() + 'e_latest', // @Deprecated - see e_dashboard + 'e_status', //@Deprecated - see e_dashboard 'e_search', 'e_shortcode', 'e_module', @@ -46,13 +46,14 @@ class e107plugin 'e_sql', 'e_dashboard', // Admin Front-Page addon. // '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_tagwords', 'e_url', // simple mod-rewrite. 'e_mailout', - 'e_sitelink', + 'e_sitelink', // sitelinks generator. 'e_tohtml', 'e_featurebox', 'e_related', diff --git a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php index 19c62fbd7..348865505 100644 --- a/e107_plugins/forum/shortcodes/batch/post_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/post_shortcodes.php @@ -87,7 +87,7 @@ class plugin_forum_post_shortcodes extends e_shortcode return e107::getForm()->bbarea('post',$post,'forum'); - $rows = (e_WYSIWYG) ? 15 : 10; + $rows = (e107::wysiwyg()==true) ? 15 : 10; $ret = "\n
\n"; // if(!e_WYSIWYG) { diff --git a/e107_plugins/tinymce4/e_meta.php b/e107_plugins/tinymce4/e_meta.php index 843e7ed5b..6c43193ec 100644 --- a/e107_plugins/tinymce4/e_meta.php +++ b/e107_plugins/tinymce4/e_meta.php @@ -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('
"; - // $insert .= "Switch to bbcode<\/a>"; - - if(e_PAGE == 'mailout.php') - { - $insert .= "  ".LAN_MAILOUT_16."<\/a>"; - $insert .= "".LAN_MAILOUT_14."<\/a>"; - $insert .= "".LAN_MAILOUT_17."<\/a>"; - $insert .= "".LAN_MAILOUT_18."<\/a>"; - } - - $insert .= "
');"; - - define("SWITCH_TO_BB",$insert); - - } - else - { - define("SWITCH_TO_BB",""); - } - -// print_a($_POST); - - //
Toggle WYSIWYG
- - - 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 = '\'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"); - - -} - ?> \ No newline at end of file