Author: Richtermeister
Date: 2010-02-26 21:59:12 +0100 (Fri, 26 Feb 2010)
New Revision: 28316
Removed:
plugins/sfFCKEditorPlugin/lib/helper/
Modified:
plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php
Log:
sfFCKEditorPlugin - simplifying widget, removing reliance of obsolete editor
helper classes. moving height/width into attributes array.
Modified: plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php
===================================================================
--- plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php
2010-02-26 18:05:33 UTC (rev 28315)
+++ plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php
2010-02-26 20:59:12 UTC (rev 28316)
@@ -7,65 +7,64 @@
* @subpackage widget
* @version SVN: $Id$
*/
-class sfWidgetFormFCKEditor extends sfWidgetForm
+class sfWidgetFormFCKEditor extends sfWidgetFormTextarea
{
-
- /**
- * Constructor.
- *
- * Available options:
- *
- * * config: Sets custom path to the FCKEditor configuration file
- * * tool: Sets the FCKEditor toolbar style
- * * rows: number of rows
- * * width: editor width
- * * height: editor height
- *
- * @param array $options An array of options
- * @param array $attributes Attributes not supported. FCK editor rendering
can be influenced by options.
- *
- * @see sfWidget
- * @see sfWidgetForm
- */
- public function __construct($options = array(), $attributes = array())
+ protected function configure($options = array(), $attributes = array())
{
- if (!empty($attributes)) {
- throw new Exception('Attributes not supported.');
- }
-
$this->addOption('config', null);
- $this->addOption('rows', null);
- $this->addOption('width', null);
- $this->addOption('height', null);
- $this->addOption('tool', null);
-
- parent::__construct($options, $attributes);
+ $this->addOption('tool', 'Default');
}
-
- /**
- * Render the widget
- *
- * @param string $name The element name
- * @param string $value The value displayed in this widget
- * @param array $attributes Attributes not supported. FCK editor
rendering can be influenced by options.
- * @param array $errors An array of errors for the field
- *
- * @return string An HTML tag string
- *
- * @see sfWidgetForm
- */
+
public function render($name, $value = null, $attributes = array(), $errors
= array())
{
- if (!empty($attributes)) {
- throw new Exception('Attributes not supported.');
+ $php_file = sfConfig::get('sf_rich_text_fck_js_dir',
"js/fckeditor").DIRECTORY_SEPARATOR.'fckeditor.php';
+
+ if
(!is_readable(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file))
+ {
+ throw new sfConfigurationException('You must install FCKEditor to use
this helper (see rich_text_fck_js_dir settings).');
}
-
- $editor = new sfRichTextEditorFCK();
- $options = $this->getOptions();
- $editor->initialize($name, $value, $options);
-
- return $editor->toHTML();
+ // FCKEditor.php class is written with backward compatibility of PHP4.
+ // This reportings are to turn off errors with public properties and
already declared constructor
+ $error_reporting = error_reporting(E_ALL);
+
+ require_once(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file);
+
+ // turn error reporting back to your settings
+ error_reporting($error_reporting);
+
+ $fckeditor = new FCKeditor($name);
+ $fckeditor->BasePath =
sfContext::getInstance()->getRequest()->getRelativeUrlRoot().'/'.sfConfig::get('sf_rich_text_fck_js_dir').'/';
+ $fckeditor->Value = $value;
+
+ if (isset($attributes["width"]))
+ {
+ $fckeditor->Width = $attributes['width'];
+ }
+ elseif (isset($attributes['cols']))
+ {
+ $fckeditor->Width = (string)((int) $attributes['cols'] * 10).'px';
+ }
+
+ if (isset($attributes['height']))
+ {
+ $fckeditor->Height = $attributes['height'];
+ }
+ elseif (isset($attributes['rows']))
+ {
+ $fckeditor->Height = (string)((int) $attributes['rows'] * 10).'px';
+ }
+
+ if ($tool = $this -> getOption("tool"))
+ {
+ $fckeditor->ToolbarSet = $tool;
+ }
+
+ if ($config = $this -> getOption('config'))
+ {
+ $fckeditor->Config['CustomConfigurationsPath'] =
javascript_path($options['config']); //suspect
+ }
+
+ return $fckeditor->CreateHtml();
}
-
-}
+}
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.