Development

/branches/1.2/lib/helper/sfRichTextEditorFCK.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/helper/sfRichTextEditorFCK.class.php

Revision 17860, 3.0 kB (checked in by FabianLange, 6 years ago)

[1.1, 1.2, 1.3] wrapped fill-in fix for FCK Texteditor in sf_10_compat check (closes #732)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  * sfRichTextEditorFCK implements the FCK rich text editor.
13  *
14  * <b>Options:</b>
15  *  - tool   - Sets the FCKEditor toolbar style
16  *  - config - Sets custom path to the FCKEditor configuration file
17  *
18  * @package    symfony
19  * @subpackage helper
20  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
21  * @version    SVN: $Id$
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     // we need to know the id for things the rich text editor
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     // FCKEditor.php class is written with backward compatibility of PHP4.
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     // turn error reporting back to your settings
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       // fix for http://trac.symfony-project.com/ticket/732
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="&lt;p&gt;default&lt;/p&gt;">
93       $content = str_replace('type="hidden"','type="text"',$content);
94     }
95
96     return $content;
97   }
98 }
99
Note: See TracBrowser for help on using the browser.