diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Dojo/View/Helper/Editor.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Dojo/View/Helper/Editor.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,187 @@ + 'LinkDialog', + 'insertImage' => 'LinkDialog', + 'fontName' => 'FontChoice', + 'fontSize' => 'FontChoice', + 'formatBlock' => 'FontChoice', + 'foreColor' => 'TextColor', + 'hiliteColor' => 'TextColor' + ); + + /** + * JSON-encoded parameters + * @var array + */ + protected $_jsonParams = array('captureEvents', 'events', 'plugins'); + + /** + * dijit.Editor + * + * @param string $id + * @param string $value + * @param array $params + * @param array $attribs + * @return string + */ + public function editor($id, $value = null, $params = array(), $attribs = array()) + { + if (isset($params['plugins'])) { + foreach ($this->_getRequiredModules($params['plugins']) as $module) { + $this->dojo->requireModule($module); + } + } + + // Previous versions allowed specifying "degrade" to allow using a + // textarea instead of a div -- but this is insecure. Removing the + // parameter if set to prevent its injection in the dijit. + if (isset($params['degrade'])) { + unset($params['degrade']); + } + + $hiddenName = $id; + if (array_key_exists('id', $attribs)) { + $hiddenId = $attribs['id']; + } else { + $hiddenId = $hiddenName; + } + $hiddenId = $this->_normalizeId($hiddenId); + + $textareaName = $this->_normalizeEditorName($hiddenName); + $textareaId = $hiddenId . '-Editor'; + + $hiddenAttribs = array( + 'id' => $hiddenId, + 'name' => $hiddenName, + 'value' => $value, + 'type' => 'hidden', + ); + $attribs['id'] = $textareaId; + + $this->_createGetParentFormFunction(); + $this->_createEditorOnSubmit($hiddenId, $textareaId); + + $attribs = $this->_prepareDijit($attribs, $params, 'textarea'); + + $html = '_htmlAttribs($hiddenAttribs) . $this->getClosingBracket(); + $html .= '_htmlAttribs($attribs) . '>' + . $value + . "\n"; + + // Embed a textarea in a