XOOPS Cube Legacy base repository
Revision | 03f70fc15d8a69189192646061c1760241edc08e (tree) |
---|---|
Zeit | 2013-02-04 17:24:15 |
Autor | nao-pon <hypweb@gmai...> |
Commiter | nao-pon |
support editor delegate with xoopsform dhtmltarea
ex.
php
$tarea = new XoopsFormDhtmlTextArea(, 'body' , ) ;
if (method_exists($tarea, 'setEditor')) {
$tarea->setEditor($allow_html? 'html' : 'bbcode');
}
[ja]XCL 2.2 から採用された HTML エディタ仕様に対応した
XoopsFormDhtmlTextArea です。Smarty テンプレートを利用しないフォームでも
HTML エディタの切り替えが可能になります。[/ja]
@@ -64,6 +64,13 @@ class XoopsFormDhtmlTextArea extends XoopsFormTextArea | ||
64 | 64 | * @access private |
65 | 65 | */ |
66 | 66 | var $_hiddenText; |
67 | + | |
68 | + /** | |
69 | + * Editor type | |
70 | + * @var string | |
71 | + * @access private | |
72 | + */ | |
73 | + private $_editor; | |
67 | 74 | |
68 | 75 | /** |
69 | 76 | * Constructor |
@@ -89,6 +96,33 @@ class XoopsFormDhtmlTextArea extends XoopsFormTextArea | ||
89 | 96 | function render() |
90 | 97 | { |
91 | 98 | $root =& XCube_Root::getSingleton(); |
99 | + | |
100 | + if ($this->_editor) { | |
101 | + $params['name'] = trim($this->getName(false)); | |
102 | + $params['class'] = trim($this->getClass()); | |
103 | + $params['cols'] = $this->getCols(); | |
104 | + $params['rows'] = $this->getRows(); | |
105 | + $params['value'] = $this->getValue(); | |
106 | + $params['id'] = $this->getId(); | |
107 | + $params['editor'] = $this->getEditor(); | |
108 | + | |
109 | + $html = ''; | |
110 | + switch ($params['editor']) { | |
111 | + case 'html': | |
112 | + XCube_DelegateUtils::call('Site.TextareaEditor.HTML.Show', new XCube_Ref($html), $params); | |
113 | + break; | |
114 | + case 'none': | |
115 | + XCube_DelegateUtils::call('Site.TextareaEditor.None.Show', new XCube_Ref($html), $params); | |
116 | + break; | |
117 | + case 'bbcode': | |
118 | + default: | |
119 | + XCube_DelegateUtils::call('Site.TextareaEditor.BBCode.Show', new XCube_Ref($html), $params); | |
120 | + break; | |
121 | + } | |
122 | + | |
123 | + return $html; | |
124 | + } | |
125 | + | |
92 | 126 | $renderSystem =& $root->getRenderSystem(XOOPSFORM_DEPENDENCE_RENDER_SYSTEM); |
93 | 127 | |
94 | 128 | $renderTarget =& $renderSystem->createRenderTarget('main'); |
@@ -129,5 +163,24 @@ class XoopsFormDhtmlTextArea extends XoopsFormTextArea | ||
129 | 163 | |
130 | 164 | return $renderTarget->getResult(); |
131 | 165 | } |
166 | + | |
167 | + /** | |
168 | + * set editor mode for XCL 2.2 | |
169 | + * | |
170 | + * @param string editor type | |
171 | + */ | |
172 | + function setEditor($editor) { | |
173 | + $this->_editor = strtolower($editor); | |
174 | + } | |
175 | + | |
176 | + /** | |
177 | + * get the "editor" value | |
178 | + * | |
179 | + * @return string editor type | |
180 | + */ | |
181 | + function getEditor() { | |
182 | + return $this->_editor; | |
183 | + } | |
184 | + | |
132 | 185 | } |
133 | 186 | ?> |