|
|
@@ -48,6 +48,19 @@ class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Textarea
|
|
|
protected $_module = 'dijit.Editor';
|
|
|
|
|
|
/**
|
|
|
+ * @var array Maps non-core plugin to module basename
|
|
|
+ */
|
|
|
+ protected $_pluginsModules = array(
|
|
|
+ 'createLink' => 'LinkDialog',
|
|
|
+ 'insertImage' => 'LinkDialog',
|
|
|
+ 'fontName' => 'FontChoice',
|
|
|
+ 'fontSize' => 'FontChoice',
|
|
|
+ 'formatBlock' => 'FontChoice',
|
|
|
+ 'foreColor' => 'TextColor',
|
|
|
+ 'hiliteColor' => 'TextColor'
|
|
|
+ );
|
|
|
+
|
|
|
+ /**
|
|
|
* JSON-encoded parameters
|
|
|
* @var array
|
|
|
*/
|
|
|
@@ -64,6 +77,12 @@ class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Textarea
|
|
|
*/
|
|
|
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'];
|
|
|
@@ -93,6 +112,25 @@ class Zend_Dojo_View_Helper_Editor extends Zend_Dojo_View_Helper_Textarea
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 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
|