XOOPS  2.6.0
Editor.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
12 namespace Xoops\Form;
13 
25 class Editor extends TextArea
26 {
30  public $editor;
31 
45  public function __construct($caption, $name, $configs = null, $nohtml = false, $OnFailure = '')
46  {
47  // Backward compatibility: $name -> editor name; $configs['name'] -> textarea field name
48  if (!isset($configs['editor'])) {
49  $configs['editor'] = $name;
50  $name = $configs['name'];
51  // New: $name -> textarea field name;
52  // $configs['editor'] -> editor name;
53  // $configs['name'] -> textarea field name
54  } else {
55  $configs['name'] = $name;
56  }
57  parent::__construct($caption, $name);
58  $editor_handler = \XoopsEditorHandler::getInstance();
59  $this->editor = $editor_handler->get($configs['editor'], $configs, $nohtml, $OnFailure);
60  }
61 
69  public function renderValidationJS()
70  {
71  if ($this->editor instanceof \XoopsEditor && $this->isRequired()) {
72  if (method_exists($this->editor, 'renderValidationJS')) {
73  $this->editor->setName($this->getName());
74  $this->editor->setCaption($this->getCaption());
75  $this->editor->setRequired($this->isRequired());
76  $ret = $this->editor->renderValidationJS();
77  return $ret;
78  } else {
79  parent::renderValidationJS();
80  }
81  }
82  return false;
83  }
84 
90  public function render()
91  {
92  if ($this->editor instanceof \XoopsEditor) {
93  return $this->editor->render();
94  }
95  return '';
96  }
97 }
$configs
Definition: config.php:27
__construct($caption, $name, $configs=null, $nohtml=false, $OnFailure= '')
Definition: Editor.php:45