Development

/plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php

You must first sign up to be able to contribute.

root/plugins/sfFCKEditorPlugin/lib/widget/sfWidgetFormFCKEditor.class.php

Revision 28453, 2.1 kB (checked in by Richtermeister, 3 years ago)

adding default path to fckeditor

Line 
1 <?php
2
3 /**
4  * Represents a FCK Editor widget.
5  *
6  * @package    sfFCKEditorPlugin
7  * @subpackage widget
8  * @version    SVN: $Id$
9  */
10 class sfWidgetFormFCKEditor extends sfWidgetFormTextarea
11 {
12   protected function configure($options = array(), $attributes = array())
13   {
14     $this->addOption('config', null);
15     $this->addOption('tool', 'Default');
16   }
17
18   public function render($name, $value = null, $attributes = array(), $errors = array())
19   {
20     $php_file = sfConfig::get('sf_rich_text_fck_js_dir', "js/fckeditor").DIRECTORY_SEPARATOR.'fckeditor.php';
21
22     if (!is_readable(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file))
23     {
24       throw new sfConfigurationException('You must install FCKEditor to use this helper (see rich_text_fck_js_dir settings).');
25     }
26
27     // FCKEditor.php class is written with backward compatibility of PHP4.
28     // This reportings are to turn off errors with public properties and already declared constructor
29     $error_reporting = error_reporting(E_ALL);
30
31     require_once(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file);
32
33     // turn error reporting back to your settings
34     error_reporting($error_reporting);
35
36     $fckeditor           = new FCKeditor($name);
37     $fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot().'/'.sfConfig::get('sf_rich_text_fck_js_dir', "js/fckeditor").'/';
38     $fckeditor->Value    = $value;
39
40     if (isset($attributes["width"]))
41     {
42       $fckeditor->Width = $attributes['width'];
43     }
44     elseif (isset($attributes['cols']))
45     {
46       $fckeditor->Width = (string)((int) $attributes['cols'] * 10).'px';
47     }
48
49     if (isset($attributes['height']))
50     {
51       $fckeditor->Height = $attributes['height'];
52     }
53     elseif (isset($attributes['rows']))
54     {
55       $fckeditor->Height = (string)((int) $attributes['rows'] * 10).'px';
56     }
57
58     if ($tool = $this -> getOption("tool"))
59     {
60       $fckeditor->ToolbarSet = $tool;
61     }
62
63     if ($config = $this -> getOption('config'))
64     {
65       $fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']); //suspect
66     }
67
68     return $fckeditor->CreateHtml();
69   }
70 }
Note: See TracBrowser for help on using the browser.