2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A WYSIWYG editor field, powered by tinymce.
|
|
|
|
* tinymce editor fields are created from <textarea> tags which are then converted with javascript.
|
|
|
|
* The {@link Requirements} system is used to ensure that all necessary javascript is included.
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
2008-02-04 02:31:55 +01:00
|
|
|
* Caution: Only works within the CMS with a global tinymce-menubar, see {@link CMSMain}
|
|
|
|
*
|
2008-01-09 05:18:36 +01:00
|
|
|
* @subpackage fields-formattedinput
|
2008-10-16 15:00:30 +02:00
|
|
|
* @deprecated 2.3 It's not clear that this field works properly. Just use {@link HtmlEditorField}.
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class HtmlOneLineField extends TextField {
|
|
|
|
/**
|
|
|
|
* Returns the a <textarea> field with tinymce="true" set on it
|
|
|
|
*/
|
|
|
|
function Field() {
|
|
|
|
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
|
ENHANCEMENT Introduced constants for system paths like /sapphire in preparation for a more flexible directory reorganisation. Instead of hardcoding your path, please use the following constants: BASE_PATH, BASE_URL, SAPPHIRE_DIR, SAPPHIRE_PATH, CMS_DIR, CMS_PATH, THIRDPARTY_DIR, THIRDPARTY_PATH, ASSETS_DIR, ASSETS_PATH, THEMES_DIR, THEMES_PATH
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63175 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-09-28 15:12:20 +02:00
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/tiny_mce_improvements.js");
|
2007-07-19 12:40:28 +02:00
|
|
|
|
|
|
|
// Don't allow unclosed tags - they will break the whole application ;-)
|
|
|
|
$cleanVal = $this->value;
|
|
|
|
$lPos = strrpos($cleanVal,'<');
|
|
|
|
$rPos = strrpos($cleanVal,'>');
|
|
|
|
if(($lPos > $rPos) || ($rPos === false && $lPos !== false)) $cleanVal .= '>';
|
|
|
|
|
|
|
|
return "<textarea class=\"htmleditor\" tinymce_oneline=\"true\" id=\"" . $this->id() . "\" name=\"{$this->name}\" rows=\"1\">$cleanVal</textarea>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|