Merged from branches/2.3

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@77032 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-05-18 00:19:47 +00:00
parent 161e7a35c7
commit 2fc1771f93
2 changed files with 14 additions and 3 deletions

View File

@ -244,6 +244,7 @@ class HtmlEditorConfig {
return "
if((typeof tinyMCE != 'undefined')) {
tinyMCE.init(" . Convert::raw2json($config) . ");
}";
}
";
}
}

View File

@ -12,6 +12,16 @@
class HtmlEditorField extends TextareaField {
protected $rows;
/**
* Includes the javascript neccesary for this field to work in the current output.
* NOTE: If you are loading a form that includes an HtmlEditorField via Ajax this function must be called in the requesting page, because
* javascript is not sent via ajax
*/
static function include_js() {
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
Requirements::customScript(HtmlEditorConfig::get_active()->generateJS(), 'htmlEditorConfig');
}
/**
* Construct a new HtmlEditor field
*/
@ -24,8 +34,8 @@ class HtmlEditorField extends TextareaField {
* Returns the a <textarea> field with tinymce="true" set on it
*/
function Field() {
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
Requirements::customScript(HtmlEditorConfig::get_active()->generateJS(), 'htmlEditorConfig');
// Make sure the nessecary javascript is included
self::include_js();
// Don't allow unclosed tags - they will break the whole application ;-)
$cleanVal = $this->value;