1: <?php
2: /**
3: * XOOPS form element
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
14: * @package kernel
15: * @subpackage form
16: * @since 2.3.0
17: * @author Taiwen Jiang <phppp@users.sourceforge.net>
18: */
19:
20: defined('XOOPS_ROOT_PATH') || exit('Restricted access');
21:
22: xoops_load('XoopsFormElementTray');
23:
24: /**
25: * XoopsFormSelectEditor
26: */
27: class XoopsFormSelectEditor extends XoopsFormElementTray
28: {
29: public $allowed_editors = array();
30: public $form;
31: public $value;
32: public $name;
33: public $nohtml;
34:
35: /**
36: * Constructor
37: *
38: * @param string $form the form calling the editor selection
39: * @param string $name editor name
40: * @param string $value Pre-selected text value
41: * @param bool $nohtml
42: * @param array $allowed_editors
43: *
44: */
45:
46: public function __construct($form, $name = 'editor', $value = null, $nohtml = false, $allowed_editors = array())
47: {
48: parent::__construct(_SELECT);
49: $this->allowed_editors = $allowed_editors;
50: $this->form = $form;
51: $this->name = $name;
52: $this->value = $value;
53: $this->nohtml = $nohtml;
54: }
55:
56: /**
57: * XoopsFormSelectEditor::render()
58: *
59: * @return string
60: */
61: public function render()
62: {
63: xoops_load('XoopsEditorHandler');
64: $editor_handler = XoopsEditorHandler::getInstance();
65: $editor_handler->allowed_editors = $this->allowed_editors;
66: $option_select = new XoopsFormSelect('', $this->name, $this->value);
67: $extra = 'onchange="if (this.options[this.selectedIndex].value.length > 0) {
68: window.document.forms.' . $this->form->getName() . '.submit();
69: }"';
70: $option_select->setExtra($extra);
71: $option_select->addOptionArray($editor_handler->getList($this->nohtml));
72: $this->addElement($option_select);
73:
74: return parent::render();
75: }
76: }
77: