22 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
56 var $htmlEditor = array();
66 var $skipPreview =
false;
92 $this->XoopsFormTextArea($caption, $name, $value, $rows, $cols);
93 $this->_hiddenText = $hiddentext;
99 if (isset($xoopsConfig[
'editor']))
100 $options[
'editor'] = $xoopsConfig[
'editor'];
103 if (! empty($this->htmlEditor) || ! empty(
$options[
'editor'])) {
104 $options[
'name'] = $this->getName();
105 $options[
'value'] = $this->getValue();
110 if (count($this->htmlEditor) == 1) {
113 $this->htmlEditor = $editor_handler->get($this->htmlEditor[0],
$options);
115 $this->htmlEditor = null;
118 list ($class,
$path) = $this->htmlEditor;
119 include_once XOOPS_ROOT_PATH .
$path;
120 if (class_exists($class)) {
121 $this->htmlEditor =
new $class(
$options);
124 $this->htmlEditor = null;
139 if ($this->htmlEditor && is_object($this->htmlEditor)) {
140 if (! isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) {
141 return $this->htmlEditor->render();
149 $ret .= $this->codeIcon() .
"<br />\n";
151 $ret .= $this->fontArray();
156 $ret .=
"<textarea id='" . $this->getName() .
"' name='" . $this->getName() .
"' title='". $this->getTitle() .
"' onselect=\"xoopsSavePosition('" . $this->getName() .
"');\" onclick=\"xoopsSavePosition('" . $this->getName() .
"');\" onkeyup=\"xoopsSavePosition('" . $this->getName() .
"');\" cols='" . $this->getCols() .
"' rows='" . $this->getRows() .
"'" . $this->getExtra() .
">" . $this->getValue() .
"</textarea><br />\n";
158 if (empty($this->skipPreview)) {
160 $this->js .= implode(
"", file(XOOPS_ROOT_PATH .
"/class/textsanitizer/image/image.js"));
162 $GLOBALS[
'xoTheme']->addScript(
'/class/textsanitizer/image/image.js', array(
'type' =>
'text/javascript'));
165 "<input " .
" id='" . $this->getName() .
"_preview_button'" .
" type='button' " .
" value='" .
_PREVIEW .
"' " .
" onclick=\"form_instantPreview('" . XOOPS_URL .
"', '" . $this->getName() .
"','" . XOOPS_URL .
"/images', " . intval($this->doHtml) .
", '" .
$GLOBALS[
'xoopsSecurity']->createToken() .
"')\"" .
" />";
166 $ret .=
"<br />" .
"<div id='" . $this->getName() .
"_hidden' style='display: block;'> " .
" <fieldset>" .
" <legend>" . $button .
"</legend>" .
" <div id='" . $this->getName() .
"_hidden_data'>" .
_XOOPS_FORM_PREVIEW_CONTENT .
"</div>" .
" </fieldset>" .
"</div>";
169 if (empty($js_loaded)) {
170 $javascript = ((
$this->js) ?
'<script language="JavaScript" type="text/javascript">' . $this->js .
'</script>' :
'') .
'<script language="JavaScript" type="text/javascript" src="' . XOOPS_URL .
'/include/formdhtmltextarea.js"></script>';
184 $textarea_id = $this->getName();
185 $code =
"<a name='moresmiley'></a>" .
"<img src='" . XOOPS_URL .
"/images/url.gif' alt='" .
_XOOPS_FORM_ALT_URL .
"' title='" .
_XOOPS_FORM_ALT_URL .
"' onclick='xoopsCodeUrl(\"{$textarea_id}\", \"" . htmlspecialchars(
_ENTERURL, ENT_QUOTES) .
"\", \"" . htmlspecialchars(
_ENTERWEBTITLE, ENT_QUOTES) .
"\");' onmouseover='style.cursor=\"hand\"'/> " .
"<img src='" . XOOPS_URL .
"/images/email.gif' alt='" .
_XOOPS_FORM_ALT_EMAIL .
"' title='" .
_XOOPS_FORM_ALT_EMAIL .
"' onclick='xoopsCodeEmail(\"{$textarea_id}\", \"" . htmlspecialchars(
_ENTEREMAIL, ENT_QUOTES) .
"\");' onmouseover='style.cursor=\"hand\"'/> " .
"<img src='" . XOOPS_URL .
"/images/imgsrc.gif' alt='" .
_XOOPS_FORM_ALT_IMG .
"' title='" .
_XOOPS_FORM_ALT_IMG .
"' onclick='xoopsCodeImg(\"{$textarea_id}\", \"" . htmlspecialchars(
_ENTERIMGURL, ENT_QUOTES) .
"\", \"" . htmlspecialchars(
_ENTERIMGPOS, ENT_QUOTES) .
"\", \"" . htmlspecialchars(
_IMGPOSRORL, ENT_QUOTES) .
"\", \"" . htmlspecialchars(
_ERRORIMGPOS, ENT_QUOTES) .
"\", \"" . htmlspecialchars(
_XOOPS_FORM_ALT_ENTERWIDTH, ENT_QUOTES) .
"\");' onmouseover='style.cursor=\"hand\"'/> " .
"<img src='" . XOOPS_URL .
"/images/image.gif' alt='" .
_XOOPS_FORM_ALT_IMAGE .
"' title='" .
_XOOPS_FORM_ALT_IMAGE .
"' onclick='openWithSelfMain(\"" . XOOPS_URL .
"/imagemanager.php?target={$textarea_id}\",\"imgmanager\",400,430);' onmouseover='style.cursor=\"hand\"'/> " .
"<img src='" . XOOPS_URL .
"/images/smiley.gif' alt='" .
_XOOPS_FORM_ALT_SMILEY .
"' title='" .
_XOOPS_FORM_ALT_SMILEY .
"' onclick='openWithSelfMain(\"" . XOOPS_URL .
"/misc.php?action=showpopups&type=smilies&target={$textarea_id}\",\"smilies\",300,475);' onmouseover='style.cursor=\"hand\"'/> ";
188 $extensions = array_filter(
$myts->config[
'extensions']);
189 foreach(array_keys($extensions) as $key) {
190 $extension =
$myts->loadExtension($key);
191 @list ($encode, $js) = $extension->encode($textarea_id);
199 $code .=
"<img src='" . XOOPS_URL .
"/images/code.gif' alt='" .
_XOOPS_FORM_ALT_CODE .
"' title='" .
_XOOPS_FORM_ALT_CODE .
"' onclick='xoopsCodeCode(\"{$textarea_id}\", \"" . htmlspecialchars(
_ENTERCODE, ENT_QUOTES) .
"\");' onmouseover='style.cursor=\"hand\"'/> " .
"<img src='" . XOOPS_URL .
"/images/quote.gif' alt='" .
_XOOPS_FORM_ALT_QUOTE .
"' title='" .
_XOOPS_FORM_ALT_QUOTE .
"' onclick='xoopsCodeQuote(\"{$textarea_id}\", \"" . htmlspecialchars(
_ENTERQUOTE, ENT_QUOTES) .
"\");' onmouseover='style.cursor=\"hand\"'/>";
202 $xoopsPreload->triggerEvent(
'core.class.xoopsform.formdhtmltextarea.codeicon', array(&$code));
213 $textarea_id = $this->getName();
214 $hiddentext = $this->_hiddenText;
216 $fontStr =
"<script type=\"text/javascript\" language=\"JavaScript\">" .
"var _editor_dialog = ''" .
"+ '<select id=\'{$textarea_id}Size\' onchange=\'xoopsSetElementAttribute(\"size\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" .
"+ '<option value=\'SIZE\'>" .
_SIZE .
"</option>'";
217 foreach(
$GLOBALS[
"formtextdhtml_sizes"] as $_val => $_name) {
218 $fontStr .=
" + '<option value=\'{$_val}\'>{$_name}</option>'";
221 $fontStr .=
" + '</select> '";
222 $fontStr .=
"+ '<select id=\'{$textarea_id}Font\' onchange=\'xoopsSetElementAttribute(\"font\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" .
"+ '<option value=\'FONT\'>" .
_FONT .
"</option>'";
223 $fontarray = ! empty(
$GLOBALS[
"formtextdhtml_fonts"]) ?
$GLOBALS[
"formtextdhtml_fonts"] : array(
"Arial" ,
"Courier" ,
"Georgia" ,
"Helvetica" ,
"Impact" ,
"Verdana" ,
"Haettenschweiler");
224 foreach($fontarray as $font) {
225 $fontStr .=
" + '<option value=\'{$font}\'>{$font}</option>'";
228 $fontStr .=
" + '</select> '";
229 $fontStr .=
"+ '<select id=\'{$textarea_id}Color\' onchange=\'xoopsSetElementAttribute(\"color\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'" .
"+ '<option value=\'COLOR\'>" .
_COLOR .
"</option>';" .
"var _color_array = new Array('00', '33', '66', '99', 'CC', 'FF');
230 for(var i = 0; i < _color_array.length; i ++) {
231 for(var j = 0; j < _color_array.length; j ++) {
232 for(var k = 0; k < _color_array.length; k ++) {
233 var _color_ele = _color_array[i] + _color_array[j] + _color_array[k];
234 _editor_dialog += '<option value=\''+_color_ele+'\' style=\'background-color:#'+_color_ele+';color:#'+_color_ele+';\'>#'+_color_ele+'</option>';
238 _editor_dialog += '</select>';";
240 $fontStr .=
"document.write(_editor_dialog); </script>";
242 $styleStr =
"<img src='" . XOOPS_URL .
"/images/bold.gif' alt='" .
_XOOPS_FORM_ALT_BOLD .
"' title='" .
_XOOPS_FORM_ALT_BOLD .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeBold(\"{$hiddentext}\", \"{$textarea_id}\");' /> ";
243 $styleStr .=
"<img src='" . XOOPS_URL .
"/images/italic.gif' alt='" .
_XOOPS_FORM_ALT_ITALIC .
"' title='" .
_XOOPS_FORM_ALT_ITALIC .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeItalic(\"{$hiddentext}\", \"{$textarea_id}\");' /> ";
244 $styleStr .=
"<img src='" . XOOPS_URL .
"/images/underline.gif' alt='" .
_XOOPS_FORM_ALT_UNDERLINE .
"' title='" .
_XOOPS_FORM_ALT_UNDERLINE .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeUnderline(\"{$hiddentext}\", \"{$textarea_id}\");'/> ";
245 $styleStr .=
"<img src='" . XOOPS_URL .
"/images/linethrough.gif' alt='" .
_XOOPS_FORM_ALT_LINETHROUGH .
"' title='" .
_XOOPS_FORM_ALT_LINETHROUGH .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeLineThrough(\"{$hiddentext}\", \"{$textarea_id}\");' /></a> ";
247 $alignStr =
"<img src='" . XOOPS_URL .
"/images/alignleft.gif' alt='" .
_XOOPS_FORM_ALT_LEFT .
"' title='" .
_XOOPS_FORM_ALT_LEFT .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeLeft(\"{$hiddentext}\", \"{$textarea_id}\");' /> ";
248 $alignStr .=
"<img src='" . XOOPS_URL .
"/images/aligncenter.gif' alt='" .
_XOOPS_FORM_ALT_CENTER .
"' title='" .
_XOOPS_FORM_ALT_CENTER .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeCenter(\"{$hiddentext}\", \"{$textarea_id}\");' /> ";
249 $alignStr .=
"<img src='" . XOOPS_URL .
"/images/alignright.gif' alt='" .
_XOOPS_FORM_ALT_RIGHT .
"' title='" .
_XOOPS_FORM_ALT_RIGHT .
"' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeRight(\"{$hiddentext}\", \"{$textarea_id}\");' /> ";
250 $fontStr = $fontStr .
"<br />\n{$styleStr} {$alignStr} \n";
259 function renderValidationJS()
261 if ($this->htmlEditor && is_object($this->htmlEditor) && method_exists($this->htmlEditor,
'renderValidationJS')) {
262 if (! isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) {
263 return $this->htmlEditor->renderValidationJS();
266 return parent::renderValidationJS();