| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
class sfRichTextEditorFCK extends sfRichTextEditor |
|---|
| 24 |
{ |
|---|
| 25 |
|
|---|
| 26 |
* Returns the rich text editor as HTML. |
|---|
| 27 |
* |
|---|
| 28 |
* @return string Rich text editor HTML representation |
|---|
| 29 |
*/ |
|---|
| 30 |
public function toHTML() |
|---|
| 31 |
{ |
|---|
| 32 |
$options = $this->options; |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
// in advance of building the tag |
|---|
| 36 |
$id = _get_option($options, 'id', $this->name); |
|---|
| 37 |
|
|---|
| 38 |
$php_file = sfConfig::get('sf_rich_text_fck_js_dir').DIRECTORY_SEPARATOR.'fckeditor.php'; |
|---|
| 39 |
|
|---|
| 40 |
if (!is_readable(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file)) |
|---|
| 41 |
{ |
|---|
| 42 |
throw new sfConfigurationException('You must install FCKEditor to use this helper (see rich_text_fck_js_dir settings).'); |
|---|
| 43 |
} |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
// This reportings are to turn off errors with public properties and already declared constructor |
|---|
| 47 |
$error_reporting = error_reporting(E_ALL); |
|---|
| 48 |
|
|---|
| 49 |
require_once(sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$php_file); |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
error_reporting($error_reporting); |
|---|
| 53 |
|
|---|
| 54 |
$fckeditor = new FCKeditor($this->name); |
|---|
| 55 |
$fckeditor->BasePath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot().'/'.sfConfig::get('sf_rich_text_fck_js_dir').'/'; |
|---|
| 56 |
$fckeditor->Value = $this->content; |
|---|
| 57 |
|
|---|
| 58 |
if (isset($options['width'])) |
|---|
| 59 |
{ |
|---|
| 60 |
$fckeditor->Width = $options['width']; |
|---|
| 61 |
} |
|---|
| 62 |
elseif (isset($options['cols'])) |
|---|
| 63 |
{ |
|---|
| 64 |
$fckeditor->Width = (string)((int) $options['cols'] * 10).'px'; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
if (isset($options['height'])) |
|---|
| 68 |
{ |
|---|
| 69 |
$fckeditor->Height = $options['height']; |
|---|
| 70 |
} |
|---|
| 71 |
elseif (isset($options['rows'])) |
|---|
| 72 |
{ |
|---|
| 73 |
$fckeditor->Height = (string)((int) $options['rows'] * 10).'px'; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
if (isset($options['tool'])) |
|---|
| 77 |
{ |
|---|
| 78 |
$fckeditor->ToolbarSet = $options['tool']; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
if (isset($options['config'])) |
|---|
| 82 |
{ |
|---|
| 83 |
$fckeditor->Config['CustomConfigurationsPath'] = javascript_path($options['config']); |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
$content = $fckeditor->CreateHtml(); |
|---|
| 87 |
|
|---|
| 88 |
if (sfConfig::get('sf_compat_10')) |
|---|
| 89 |
{ |
|---|
| 90 |
|
|---|
| 91 |
// fields need to be of type text to be picked up by fillin. they are hidden by inline css anyway: |
|---|
| 92 |
// <input type="hidden" id="name" name="name" style="display:none" value="<p>default</p>"> |
|---|
| 93 |
$content = str_replace('type="hidden"','type="text"',$content); |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
return $content; |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|