13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Dojo |
16 * @package Zend_Dojo |
17 * @subpackage View |
17 * @subpackage View |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Editor.php 20116 2010-01-07 14:18:34Z matthew $ |
20 * @version $Id: Editor.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** Zend_Dojo_View_Helper_Dijit */ |
23 /** Zend_Dojo_View_Helper_Dijit */ |
24 require_once 'Zend/Dojo/View/Helper/Dijit.php'; |
24 require_once 'Zend/Dojo/View/Helper/Dijit.php'; |
25 |
25 |
30 * Dojo Editor dijit |
30 * Dojo Editor dijit |
31 * |
31 * |
32 * @uses Zend_Dojo_View_Helper_Textarea |
32 * @uses Zend_Dojo_View_Helper_Textarea |
33 * @package Zend_Dojo |
33 * @package Zend_Dojo |
34 * @subpackage View |
34 * @subpackage View |
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 * @license http://framework.zend.com/license/new-bsd New BSD License |
37 */ |
37 */ |
38 class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Dijit |
38 class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Dijit |
39 { |
39 { |
40 /** |
40 /** |
55 'insertImage' => 'LinkDialog', |
55 'insertImage' => 'LinkDialog', |
56 'fontName' => 'FontChoice', |
56 'fontName' => 'FontChoice', |
57 'fontSize' => 'FontChoice', |
57 'fontSize' => 'FontChoice', |
58 'formatBlock' => 'FontChoice', |
58 'formatBlock' => 'FontChoice', |
59 'foreColor' => 'TextColor', |
59 'foreColor' => 'TextColor', |
60 'hiliteColor' => 'TextColor' |
60 'hiliteColor' => 'TextColor', |
|
61 'enterKeyHandling' => 'EnterKeyHandling', |
|
62 'fullScreen' => 'FullScreen', |
|
63 'newPage' => 'NewPage', |
|
64 'print' => 'Print', |
|
65 'tabIndent' => 'TabIndent', |
|
66 'toggleDir' => 'ToggleDir', |
|
67 'viewSource' => 'ViewSource' |
61 ); |
68 ); |
62 |
69 |
63 /** |
70 /** |
64 * JSON-encoded parameters |
71 * JSON-encoded parameters |
65 * @var array |
72 * @var array |
66 */ |
73 */ |
67 protected $_jsonParams = array('captureEvents', 'events', 'plugins'); |
74 protected $_jsonParams = array('captureEvents', 'events', 'plugins', 'extraPlugins'); |
68 |
75 |
69 /** |
76 /** |
70 * dijit.Editor |
77 * dijit.Editor |
71 * |
78 * |
72 * @param string $id |
79 * @param string $id |
81 foreach ($this->_getRequiredModules($params['plugins']) as $module) { |
88 foreach ($this->_getRequiredModules($params['plugins']) as $module) { |
82 $this->dojo->requireModule($module); |
89 $this->dojo->requireModule($module); |
83 } |
90 } |
84 } |
91 } |
85 |
92 |
86 // Previous versions allowed specifying "degrade" to allow using a |
93 // Previous versions allowed specifying "degrade" to allow using a |
87 // textarea instead of a div -- but this is insecure. Removing the |
94 // textarea instead of a div -- but this is insecure. Removing the |
88 // parameter if set to prevent its injection in the dijit. |
95 // parameter if set to prevent its injection in the dijit. |
89 if (isset($params['degrade'])) { |
96 if (isset($params['degrade'])) { |
90 unset($params['degrade']); |
97 unset($params['degrade']); |
91 } |
98 } |
92 |
99 |
112 $this->_createGetParentFormFunction(); |
119 $this->_createGetParentFormFunction(); |
113 $this->_createEditorOnSubmit($hiddenId, $textareaId); |
120 $this->_createEditorOnSubmit($hiddenId, $textareaId); |
114 |
121 |
115 $attribs = $this->_prepareDijit($attribs, $params, 'textarea'); |
122 $attribs = $this->_prepareDijit($attribs, $params, 'textarea'); |
116 |
123 |
117 $html = '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket(); |
124 $html = '<div' . $this->_htmlAttribs($attribs) . '>' |
118 $html .= '<div' . $this->_htmlAttribs($attribs) . '>' |
|
119 . $value |
125 . $value |
120 . "</div>\n"; |
126 . "</div>\n"; |
121 |
127 |
122 // Embed a textarea in a <noscript> tag to allow for graceful |
128 // Embed a textarea in a <noscript> tag to allow for graceful |
123 // degradation |
129 // degradation |
124 $html .= '<noscript>' |
130 $html .= '<noscript>' |
125 . $this->view->formTextarea($hiddenId, $value, $attribs) |
131 . $this->view->formTextarea($hiddenId, $value, $attribs) |
126 . '</noscript>'; |
132 . '</noscript>'; |
127 |
133 |
|
134 $html .= '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket(); |
|
135 |
128 return $html; |
136 return $html; |
129 } |
137 } |
130 |
138 |
131 /** |
139 /** |
132 * Generates the list of required modules to include, if any is needed. |
140 * Generates the list of required modules to include, if any is needed. |
176 $this->dojo->onLoadCaptureStart(); |
184 $this->dojo->onLoadCaptureStart(); |
177 echo <<<EOJ |
185 echo <<<EOJ |
178 function() { |
186 function() { |
179 var form = zend.findParentForm(dojo.byId('$hiddenId')); |
187 var form = zend.findParentForm(dojo.byId('$hiddenId')); |
180 dojo.connect(form, 'submit', function(e) { |
188 dojo.connect(form, 'submit', function(e) { |
181 dojo.byId('$hiddenId').value = dijit.byId('$editorId').getValue(false); |
189 var value = dijit.byId('$editorId').getValue(false); |
|
190 if(dojo.isFF) { |
|
191 value = value.replace(/<br _moz_editor_bogus_node="TRUE" \/>/, ''); |
|
192 } |
|
193 dojo.byId('$hiddenId').value = value; |
182 }); |
194 }); |
183 } |
195 } |
184 EOJ; |
196 EOJ; |
185 $this->dojo->onLoadCaptureEnd(); |
197 $this->dojo->onLoadCaptureEnd(); |
186 } |
198 } |