From f4fae2a91e3223809b0b6090345775cc6b4fb9e8 Mon Sep 17 00:00:00 2001 From: Hamish Friedlander Date: Mon, 18 May 2009 00:15:20 +0000 Subject: [PATCH] BUGFIX: Add JavaScript for HtmlEditorField on every CMS page, to avoid issue where loading form with HtmlEditorField via ajax doesn't work because scripts are stripped out. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@77031 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 10 ++-------- code/LeftAndMain.php | 3 +++ code/ReportAdmin.php | 10 +++------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/code/CMSMain.php b/code/CMSMain.php index 8b508a6e..1ae160c1 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -108,15 +108,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $spellcheckSpec = array(); foreach($spellcheckLangs as $lang => $title) $spellcheckSpec[] = "{$title}={$lang}"; + // Set custom options for TinyMCE specific to CMSMain HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', '+' . implode(',', $spellcheckSpec)); - - // @todo Do we need this - I'm pretty sure not, since HtmlEditorField#Field() will include it on being called. - // The only time you might need it is if you are creating an textarea.htmlfield yourself, in which case bad things are going to happen now we've moved configuration - // We don't want this showing up in every ajax-response, it should always be present in a CMS-environment - if(!Director::is_ajax()) { - Requirements::javascript(MCE_ROOT . "tiny_mce_src.js"); - } - + Requirements::javascript(CMS_DIR . '/javascript/CMSMain.js'); Requirements::javascript(CMS_DIR . '/javascript/CMSMain_left.js'); Requirements::javascript(CMS_DIR . '/javascript/CMSMain_right.js'); diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index bf583529..6ff894f9 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -882,6 +882,9 @@ JS; } public function EditForm() { + // Include JavaScript to ensure HtmlEditorField works. + HtmlEditorField::include_js(); + $record = $this->currentPage(); if(!$record) return false; diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index cc34ccca..741e0fa1 100755 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -29,13 +29,9 @@ class ReportAdmin extends LeftAndMain { Requirements::css(CMS_DIR . '/css/ReportAdmin.css'); - // We don't want this showing up in every ajax-response, it should - // always be present in a CMS environment - if(!Director::is_ajax()) { - Requirements::javascript(MCE_ROOT . "tiny_mce_src.js"); - HtmlEditorConfig::get('cms')->setOption('ContentCSS', project() . '/css/editor.css'); - HtmlEditorConfig::get('cms')->setOption('Lang', i18n::get_tinymce_lang()); - } + // Set custom options for TinyMCE specific to ReportAdmin + HtmlEditorConfig::get('cms')->setOption('ContentCSS', project() . '/css/editor.css'); + HtmlEditorConfig::get('cms')->setOption('Lang', i18n::get_tinymce_lang()); // Always block the HtmlEditorField.js otherwise it will be sent with an ajax request Requirements::block(SAPPHIRE_DIR . '/javascript/HtmlEditorField.js');