diff --git a/layouts/joomla/tinymce/textarea.php b/layouts/joomla/tinymce/textarea.php index 0c969b423a03e..c116c3a2f4118 100644 --- a/layouts/joomla/tinymce/textarea.php +++ b/layouts/joomla/tinymce/textarea.php @@ -19,6 +19,7 @@ rows="rows; ?>" style="width: width; ?>; height: height; ?>;" class="class) ? 'mce_editable' : $data->class; ?>" + readonly ? ' readonly disabled' : ''; ?> > content; ?> \ No newline at end of file diff --git a/libraries/cms/editor/editor.php b/libraries/cms/editor/editor.php index 5f0ce39beb95d..cdc9150be784e 100644 --- a/libraries/cms/editor/editor.php +++ b/libraries/cms/editor/editor.php @@ -315,6 +315,9 @@ public function display($name, $html, $width, $height, $col, $row, $buttons = tr $args['row'] = $row; $args['buttons'] = $buttons; $args['id'] = $id ?: $name; + $args['asset'] = $asset; + $args['author'] = $author; + $args['params'] = $params; $args['event'] = 'onDisplay'; $results[] = $this->_editor->update($args); diff --git a/libraries/cms/form/field/editor.php b/libraries/cms/form/field/editor.php index 486a9beb5f982..ab3287f7d6f16 100644 --- a/libraries/cms/form/field/editor.php +++ b/libraries/cms/form/field/editor.php @@ -241,11 +241,12 @@ protected function getInput() { // Get an editor object. $editor = $this->getEditor(); + $readonly = $this->readonly || $this->disabled; return $editor->display( $this->name, htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), $this->width, $this->height, $this->columns, $this->rows, $this->buttons ? (is_array($this->buttons) ? array_merge($this->buttons, $this->hide) : $this->hide) : false, $this->id, $this->asset, - $this->form->getValue($this->authorField), array('syntax' => (string) $this->element['syntax']) + $this->form->getValue($this->authorField), array('syntax' => (string) $this->element['syntax'], 'readonly' => $readonly) ); } diff --git a/plugins/editors/codemirror/codemirror.php b/plugins/editors/codemirror/codemirror.php index 4cc1e3a4391bb..4073e85110ade 100644 --- a/plugins/editors/codemirror/codemirror.php +++ b/plugins/editors/codemirror/codemirror.php @@ -196,6 +196,12 @@ public function onDisplay( // Options for the CodeMirror constructor. $options = new stdClass; + // Is field readonly? + if (!empty($params['readonly'])) + { + $options->readOnly = 'nocursor'; + } + // Should we focus on the editor on load? $options->autofocus = (boolean) $this->params->get('autoFocus', true); diff --git a/plugins/editors/none/none.php b/plugins/editors/none/none.php index 9b520321de03a..81dfb59cef494 100644 --- a/plugins/editors/none/none.php +++ b/plugins/editors/none/none.php @@ -122,9 +122,11 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $height .= 'px'; } + $readonly = !empty($params['readonly']) ? ' readonly disabled' : ''; + $editor = '
' . '' + . '" style="width: ' . $width . '; height: ' . $height . ';"' . $readonly . '>' . $content . '' . $this->_displayButtons($id, $buttons, $asset, $author) . '
'; diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 2581e2a34a2a6..882930a818408 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -130,10 +130,12 @@ public function onGetInsertMethod($name) * @param string $id An optional ID for the textarea. If not supplied the name is used. * @param string $asset The object asset * @param object $author The author. + * @param array $params Associative array of editor parameters. * * @return string */ - public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null) + public function onDisplay( + $name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array()) { $app = JFactory::getApplication(); @@ -188,6 +190,9 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $textarea->height = $height; $textarea->content = $content; + // Set editor to readonly mode + $textarea->readonly = !empty($params['readonly']); + // Render Editor markup $editor = '
'; $editor .= JLayoutHelper::render('joomla.tinymce.textarea', $textarea); @@ -204,6 +209,12 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons JHtml::_('script', 'editors/tinymce/tiny-close.min.js', array('version' => 'auto', 'relative' => true), array('defer' => 'defer')); } + // Set editor to readonly mode + if (!empty($params['readonly'])) + { + $options['tinyMCE'][$fieldName]['readonly'] = 1; + } + $options['tinyMCE'][$fieldName]['joomlaMergeDefaults'] = true; $options['tinyMCE'][$fieldName]['joomlaExtButtons'] = $btns;