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
This commit is contained in:
Hamish Friedlander 2009-05-18 00:15:20 +00:00 committed by Sam Minnee
parent 5b53fda4e3
commit f4fae2a91e
3 changed files with 8 additions and 15 deletions

View File

@ -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');

View File

@ -882,6 +882,9 @@ JS;
}
public function EditForm() {
// Include JavaScript to ensure HtmlEditorField works.
HtmlEditorField::include_js();
$record = $this->currentPage();
if(!$record) return false;

View File

@ -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");
// 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');