/ */ class Content_View_Helper_Editor extends Zend_Dojo_View_Helper_Editor { protected static $_pluginRegistry = array(); protected $_pluginsModules = array( 'foreColor' => 'p4cms.content.editor.plugins.TextColor', 'hiliteColor' => 'p4cms.content.editor.plugins.TextColor', 'fontName' => 'p4cms.content.editor.plugins.FontChoice', 'fontSize' => 'p4cms.content.editor.plugins.FontChoice', 'formatBlock' => 'p4cms.content.editor.plugins.FontChoice', 'link' => 'p4cms.content.editor.plugins.Link', 'image' => 'p4cms.content.editor.plugins.Image', 'viewsource' => 'p4cms.content.editor.plugins.ViewSource', 'paste' => 'p4cms.content.editor.plugins.Paste', 'branchifyurls' => 'p4cms.content.editor.plugins.BranchifyUrls', 'prettyprint' => 'p4cms.content.editor.plugins.PrettyPrint', 'toggleDir ' => 'dijit._editor.plugins.ToggleDir', 'fullscreen' => 'dijit._editor.plugins.FullScreen', 'print' => 'dijit._editor.plugins.Print', 'newpage' => 'dijit._editor.plugins.NewPage', 'pagebreak' => 'dojox.editor.plugins.PageBreak', 'showblocknodes' => 'dojox.editor.plugins.ShowBlockNodes', 'preview' => 'dojox.editor.plugins.Preview', 'save' => 'dojox.editor.plugins.Save', '||' => 'dojox.editor.plugins.ToolbarLineBreak', 'toolbarlinebreak' => 'dojox.editor.plugins.ToolbarLineBreak', 'normalizeindentoutdent' => 'dojox.editor.plugins.NormalizeIndentOutdent', 'breadcrumb' => 'dojox.editor.plugins.Breadcrumb', 'findreplace' => 'dojox.editor.plugins.FindReplace', 'pastefromword' => 'dojox.editor.plugins.PasteFromWord', 'insertanchor' => 'dojox.editor.plugins.InsertAnchor', 'collapsibletoolbar' => 'dojox.editor.plugins.CollapsibleToolbar', 'blockquote' => 'dojox.editor.plugins.Blockquote', 'normalizestyle' => 'dojox.editor.plugins.NormalizeStyle' ); /** * @param string Dijit type */ protected $_dijit = 'p4cms.content.Editor'; /** * @var string Dijit module to load */ protected $_module = 'p4cms.content.Editor'; /** * JSON-encoded parameters * @var array */ protected $_jsonParams = array('captureEvents', 'events', 'plugins', 'extraPlugins'); /** * Extend default editor generation to include onChange proxying of content to hidden * text area (normally it is only proxied onSubmit). * * Additionally, will ensure any extraPlugins have been required in to function. * * @param string $id Zend provides no documentation for this param. * @param string $value Zend provides no documentation for this param. * @param array $params Zend provides no documentation for this param. * @param array $attribs Zend provides no documentation for this param. * @return string */ public function editor($id, $value = null, $params = array(), $attribs = array()) { // Step 0: add any 'default' plugins if user didn't specify 'plugins' setting if (!isset($params['plugins']) || empty($params['plugins'])) { // normalize extraPlugins to be present and an array if (!isset($params['extraPlugins']) || !is_array($params['extraPlugins'])) { $params['extraPlugins'] = array(); } // scan all registered plugins and add in non-present 'default' entries foreach (static::$_pluginRegistry as $shortName => $options) { if (!isset($options['default'])) { continue; } if (in_array($shortName, $params['extraPlugins'])) { continue; } // if we have a 'long name' and it is present skip if (isset($options['plugin']) && in_array($options['plugin'], $params['extraPlugins'])) { continue; } $params['extraPlugins'][] = $shortName; } } // Step 1: ensure 'extraPlugins' get required in if (isset($params['extraPlugins'])) { foreach ($this->_getRequiredModules($params['extraPlugins']) as $module) { $this->dojo->requireModule($module); } } // Step 2: adjust onChange handling $hiddenName = $id; if (array_key_exists('id', $attribs)) { $hiddenId = $attribs['id']; } else { $hiddenId = $hiddenName; } $hiddenId = $this->_normalizeId($hiddenId); $attribs['proxyId'] = $hiddenId; // return parent with the fallback textarea stripped; it blows up content panes with a dupe ID // we use substr in order to avoid the PHP pcre_backtrack_limit constraint on preg_replace $html = parent::editor($id, $value, $params, $attribs); $start = strpos($html, '', $start); // exit the loop early if there is not an end tag if ($end === false) { break; } // remove anything in the tag (including tag names). $html = substr_replace($html, "", $start, $end - $start + 11); // search for the start of the next tag $start = strpos($html, '