| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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']); |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
return $fckeditor->CreateHtml(); |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|