'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); } } $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); $html = '_htmlAttribs($hiddenAttribs) . $this->getClosingBracket() . $this->textarea($textareaName, $value, $params, $attribs); return $html; } /** * Generates the list of required modules to include, if any is needed. * * @param array $plugins plugins to include * @return array */ protected function _getRequiredModules(array $plugins) { $modules = array(); foreach ($plugins as $commandName) { if (isset($this->_pluginsModules[$commandName])) { $pluginName = $this->_pluginsModules[$commandName]; $modules[] = 'dijit._editor.plugins.' . $pluginName; } } return array_unique($modules); } /** * Normalize editor element name * * @param string $name * @return string */ protected function _normalizeEditorName($name) { if ('[]' == substr($name, -2)) { $name = substr($name, 0, strlen($name) - 2); $name .= '[Editor][]'; } else { $name .= '[Editor]'; } return $name; } /** * Create onSubmit binding for element * * @param string $hiddenId * @param string $editorId * @return void */ protected function _createEditorOnSubmit($hiddenId, $editorId) { $this->dojo->onLoadCaptureStart(); echo <<dojo->onLoadCaptureEnd(); } }