Dojo editor view helper customized for use with p4cms content.
More...
List of all members.
Public Member Functions |
| editor ($id, $value=null, $params=array(), $attribs=array()) |
| Extend default editor generation to include onChange proxying of content to hidden text area (normally it is only proxied onSubmit).
|
Static Public Member Functions |
static | clearPluginRegistry () |
| Clears all registered plugins and their related options.
|
static | registerPlugin ($shortName, $options) |
| Add a plugin to the registry.
|
Protected Member Functions |
| _createEditorOnSubmit ($hiddenId, $editorId) |
| Extend parent to remove dependency on zend.findParentForm; no other functional change.
|
| _getRequiredModules (array $plugins) |
| Generates the list of required modules to include, if any is needed.
|
Protected Attributes |
| $_dijit = 'p4cms.content.Editor' |
| $_jsonParams = array('captureEvents', 'events', 'plugins', 'extraPlugins') |
| $_module = 'p4cms.content.Editor' |
| $_pluginsModules |
Static Protected Attributes |
static | $_pluginRegistry = array() |
Detailed Description
Dojo editor view helper customized for use with p4cms content.
- Registers additional plugin modules.
- Provides a static 'plugin registry'.
- Adds support for specifying extra plugins.
- Enhances onchange to proxy to an arbitrary element.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Member Function Documentation
Content_View_Helper_Editor::_createEditorOnSubmit |
( |
$ |
hiddenId, |
|
|
$ |
editorId |
|
) |
| [protected] |
Extend parent to remove dependency on zend.findParentForm; no other functional change.
- Parameters:
-
string | $hiddenId | The hidden Dojo form ID |
string | $editorId | The editor Dojo form ID |
- Returns:
- void
{
$this->dojo->onLoadCaptureStart();
echo <<<EOJ
function() {
var form = dojo.byId('$hiddenId');
while (form.nodeName.toLowerCase() != 'form') {
form = form.parentNode;
}
dojo.connect(form, 'submit', function(e) {
var value = dijit.byId('$editorId').getValue(false);
if(dojo.isFF) {
value = value.replace(/<br _moz_editor_bogus_node="TRUE" \/>/, '');
}
dojo.byId('$hiddenId').value = value;
});
}
EOJ;
$this->dojo->onLoadCaptureEnd();
}
Content_View_Helper_Editor::_getRequiredModules |
( |
array $ |
plugins | ) |
[protected] |
Generates the list of required modules to include, if any is needed.
- Parameters:
-
array | $plugins | plugins to include |
- Returns:
- array
{
$modules = array();
foreach ($plugins as $commandName) {
if (isset($this->_pluginsModules[$commandName])) {
$modules[] = $this->_pluginsModules[$commandName];
} elseif (isset(static::$_pluginRegistry[$commandName])
&& isset(static::$_pluginRegistry[$commandName]['plugin'])
) {
$modules[] = static::$_pluginRegistry[$commandName]['plugin'];
} else {
if (strpos($commandName, '.') !== false) {
$modules[] = $commandName;
}
}
}
return array_unique($modules);
}
static Content_View_Helper_Editor::clearPluginRegistry |
( |
| ) |
[static] |
Clears all registered plugins and their related options.
{
static::$_pluginRegistry = array();
}
Content_View_Helper_Editor::editor |
( |
$ |
id, |
|
|
$ |
value = null , |
|
|
$ |
params = array() , |
|
|
$ |
attribs = array() |
|
) |
| |
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.
- Parameters:
-
string | $id | Zend provides no documentation for this param. |
string | $value | Zend provides no documentation for this param. |
array | $params | Zend provides no documentation for this param. |
array | $attribs | Zend provides no documentation for this param. |
- Returns:
- string
{
if (!isset($params['plugins']) || empty($params['plugins'])) {
if (!isset($params['extraPlugins']) || !is_array($params['extraPlugins'])) {
$params['extraPlugins'] = array();
}
foreach (static::$_pluginRegistry as $shortName => $options) {
if (!isset($options['default'])) {
continue;
}
if (in_array($shortName, $params['extraPlugins'])) {
continue;
}
if (isset($options['plugin'])
&& in_array($options['plugin'], $params['extraPlugins'])) {
continue;
}
$params['extraPlugins'][] = $shortName;
}
}
if (isset($params['extraPlugins'])) {
foreach ($this->_getRequiredModules($params['extraPlugins']) as $module) {
$this->dojo->requireModule($module);
}
}
$hiddenName = $id;
if (array_key_exists('id', $attribs)) {
$hiddenId = $attribs['id'];
} else {
$hiddenId = $hiddenName;
}
$hiddenId = $this->_normalizeId($hiddenId);
$attribs['proxyId'] = $hiddenId;
$html = parent::editor($id, $value, $params, $attribs);
$start = strpos($html, '<noscript>');
while ($start !== false) {
$end = strpos($html, '</noscript>', $start);
if ($end === false) {
break;
}
$html = substr_replace($html, "", $start, $end - $start + 11);
$start = strpos($html, '<noscript>', $start);
}
return $html;
}
static Content_View_Helper_Editor::registerPlugin |
( |
$ |
shortName, |
|
|
$ |
options |
|
) |
| [static] |
Add a plugin to the registry.
Options expects an array that contains one or more of the below settings: 'plugin' => plugin class name, e.g. 'dijit._editor.plugins.ViewSource' 'default' => true/false the plugin will be enabled by default if true
- Parameters:
-
string | $shortName | The user friendly plugin name, e.g. 'viewsource' |
array | $options | The array of option(s), see above for details |
{
if (!is_array($options)) {
throw new InvalidArgumentException('Expected options to be an array');
}
if (!is_string($shortName)) {
throw new InvalidArgumentException('Expected shortName to be a string');
}
static::$_pluginRegistry[$shortName] = $options;
}
Member Data Documentation
Content_View_Helper_Editor::$_dijit = 'p4cms.content.Editor' [protected] |
Content_View_Helper_Editor::$_jsonParams = array('captureEvents', 'events', 'plugins', 'extraPlugins') [protected] |
Content_View_Helper_Editor::$_module = 'p4cms.content.Editor' [protected] |
Content_View_Helper_Editor::$_pluginRegistry = array() [static, protected] |
Content_View_Helper_Editor::$_pluginsModules [protected] |
The documentation for this class was generated from the following file: