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
|
|
|
|
14
|
|
|
use Xoops\Html\Button as HtmlButton; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* DhtmlTextArea - A textarea with xoopsish formatting and smilie buttons |
18
|
|
|
* |
19
|
|
|
* @category Xoops\Form\DhtmlTextArea |
20
|
|
|
* @package Xoops\Form |
21
|
|
|
* @author Kazumi Ono <[email protected]> |
22
|
|
|
* @author Taiwen Jiang <[email protected]> |
23
|
|
|
* @author Vinod <[email protected]> |
24
|
|
|
* @copyright 2001-2016 XOOPS Project (https://xoops.org) |
25
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
26
|
|
|
*/ |
27
|
|
|
class DhtmlTextArea extends \XoopsEditor |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Extended HTML editor |
31
|
|
|
* |
32
|
|
|
* <p>If an extended HTML editor is set, the renderer will be replaced by the specified editor, |
33
|
|
|
* usually a visual or WYSIWYG editor.</p> |
34
|
|
|
* |
35
|
|
|
* <ul>Developer and user guide: |
36
|
|
|
* <li> |
37
|
|
|
* <ul>For run-time settings per call |
38
|
|
|
* <li>To use an editor pre-configured by {@link XoopsEditor}, e.g. 'fckeditor': <code>$options['editor'] = 'fckeditor';</code></li> |
39
|
|
|
* <li>To use a custom editor, e.g. 'MyEditor' class located in "/modules/myeditor/myeditor.php": <code>$options['editor'] = array('MyEditor', XOOPS_ROOT_PATH . "/modules/myeditor/myeditor.php");</code></li> |
40
|
|
|
* </ul> |
41
|
|
|
* </li> |
42
|
|
|
* <li> |
43
|
|
|
* <ul>For pre-configured settings, which will force to use a editor if no specific editor is set for call |
44
|
|
|
* <li> |
45
|
|
|
* <ul>Set up custom configs: in XOOPS_VAR_PATH . '/configs/xoopsconfig.php' set a editor as default, e.g. |
46
|
|
|
* <li>a pre-configured editor 'fckeditor': <code>return array('editor' => 'fckeditor');</code></li> |
47
|
|
|
* <li>a custom editor 'MyEditor' class located in "/modules/myeditor/myeditor.php": <code>return array('editor' => array('MyEditor', XOOPS_ROOT_PATH . "/modules/myeditor/myeditor.php");</code></li> |
48
|
|
|
* </ul> |
49
|
|
|
* </li> |
50
|
|
|
* <li>To disable the default editor, in XOOPS_VAR_PATH . '/configs/xoopsconfig.php': <code>return array();</code></li> |
51
|
|
|
* <li>To disable the default editor for a specific call: <code>$options['editor'] = 'dhtmltextarea';</code></li> |
52
|
|
|
* </ul> |
53
|
|
|
* </li> |
54
|
|
|
* </ul> |
55
|
|
|
*/ |
56
|
|
|
/** |
57
|
|
|
* @var \XoopsEditor |
58
|
|
|
*/ |
59
|
|
|
public $htmlEditor; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Hidden text |
63
|
|
|
* |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
private $hiddenText; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var bool |
70
|
|
|
*/ |
71
|
|
|
public $skipPreview = false; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var bool |
75
|
|
|
*/ |
76
|
|
|
public $doHtml = false; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var string |
80
|
|
|
*/ |
81
|
|
|
public $js = ''; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @var array |
85
|
|
|
*/ |
86
|
|
|
public $configs = array(); |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Constructor |
90
|
|
|
* |
91
|
|
|
* @param string $caption Caption |
92
|
|
|
* @param string $name name attribute |
93
|
|
|
* @param string $value Initial text |
94
|
|
|
* @param integer $rows Number of rows |
95
|
|
|
* @param integer $cols Number of columns |
96
|
|
|
* @param string $hiddentext Identifier for hidden Text |
97
|
|
|
* @param array $options Extra options |
98
|
|
|
*/ |
99
|
6 |
|
public function __construct( |
100
|
|
|
$caption, |
101
|
|
|
$name, |
102
|
|
|
$value = "", |
103
|
|
|
$rows = 5, |
104
|
|
|
$cols = 50, |
105
|
|
|
$hiddentext = "xoopsHiddenText", |
106
|
|
|
$options = array() |
107
|
|
|
) { |
108
|
6 |
|
static $inLoop = 0; |
109
|
|
|
|
110
|
6 |
|
++$inLoop; |
111
|
|
|
// Second loop, invalid, return directly |
112
|
6 |
|
if ($inLoop > 2) { |
113
|
|
|
return; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
// Else, initialize |
117
|
6 |
|
parent::__construct($caption, $name, $value, $rows, $cols); |
118
|
6 |
|
$this->hiddenText = $hiddentext; |
119
|
|
|
|
120
|
6 |
|
if ($inLoop > 1) { |
121
|
|
|
return; |
122
|
|
|
} |
123
|
|
|
|
124
|
6 |
|
$xoops = \Xoops::getInstance(); |
125
|
6 |
|
if (!isset($options['editor'])) { |
126
|
6 |
|
if ($editor = $xoops->getConfig('editor')) { |
127
|
|
|
$options['editor'] = $editor; |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
131
|
6 |
|
if (!empty($this->htmlEditor) || !empty($options['editor'])) { |
132
|
|
|
$options['name'] = $this->getName(); |
133
|
|
|
$options['value'] = $this->getValue(); |
134
|
|
|
if (!empty($options['editor'])) { |
135
|
|
|
$this->htmlEditor = is_array($options['editor']) ? $options['editor'] : array($options['editor']); |
|
|
|
|
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
if (count($this->htmlEditor) == 1) { |
139
|
|
|
$editor_handler = \XoopsEditorHandler::getInstance(); |
140
|
|
|
$this->htmlEditor = $editor_handler->get($this->htmlEditor[0], $options); |
141
|
|
|
if ($inLoop > 1) { |
142
|
|
|
$this->htmlEditor = null; |
143
|
|
|
} |
144
|
|
|
} else { |
145
|
|
|
list ($class, $path) = $this->htmlEditor; |
146
|
|
|
include_once \XoopsBaseConfig::get('root-path') . $path; |
147
|
|
|
if (class_exists($class)) { |
148
|
|
|
$this->htmlEditor = new $class($options); |
149
|
|
|
} |
150
|
|
|
if ($inLoop > 1) { |
151
|
|
|
$this->htmlEditor = null; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
156
|
6 |
|
$inLoop = 0; |
157
|
6 |
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* defaultRender |
161
|
|
|
* |
162
|
|
|
* @return string rendered form element |
163
|
|
|
*/ |
164
|
1 |
|
public function defaultRender() |
165
|
|
|
{ |
166
|
1 |
|
if ($this->htmlEditor && is_object($this->htmlEditor)) { |
167
|
|
|
if (!isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) { |
168
|
|
|
return $this->htmlEditor->render(); |
169
|
|
|
} |
170
|
|
|
} |
171
|
1 |
|
static $js_loaded; |
172
|
|
|
|
173
|
1 |
|
$xoops = \Xoops::getInstance(); |
174
|
|
|
|
175
|
1 |
|
$extra = ($this->getExtra() != '' ? " " . $this->getExtra() : ''); |
176
|
1 |
|
$ret = ""; |
177
|
|
|
// actions |
178
|
1 |
|
$ret .= $this->xoopsCodeControls() . "<br />\n"; |
179
|
|
|
// fonts |
180
|
1 |
|
$ret .= $this->typographyControls(); |
181
|
|
|
|
182
|
|
|
// the textarea box |
183
|
|
|
|
184
|
1 |
|
$this->suppressRender(['value']); |
185
|
1 |
|
$attributes = $this->renderAttributeString(); |
186
|
|
|
|
187
|
1 |
|
$ret .= '<textarea ' . $attributes . $extra . '>' . $this->getValue() . "</textarea>\n"; |
188
|
|
|
|
189
|
1 |
|
if (empty($this->skipPreview)) { |
190
|
1 |
|
if (!$xoops->theme()) { |
191
|
|
|
$this->js .= implode("", file($xoops->path('media/xoops/image.js'))); |
|
|
|
|
192
|
|
|
} else { |
193
|
1 |
|
$xoops->theme()->addScript('media/xoops/image.js', array('type' => 'text/javascript')); |
194
|
|
|
} |
195
|
1 |
|
$button = "<input id='" . $this->getName() . "_preview_button' " . "type='button' " . "class='btn btn-sm btn-default' value='" . \XoopsLocale::A_PREVIEW . "' " . "onclick=\"form_instantPreview('" . XOOPS_URL . "', '" . $this->getName() . "','" . XOOPS_URL . "/images', " . (int)($this->doHtml) . ", '" . $xoops->security()->createToken() . "')\"" . " />"; |
196
|
1 |
|
$ret .= "<br />" . "<div id='" . $this->getName() . "_hidden' style='display: block;'> " . "<fieldset>" . "<legend>" . $button . "</legend>" . "<div id='" . $this->getName() . "_hidden_data'>" . \XoopsLocale::CLICK_PREVIEW_TO_SEE_CONTENT . "</div>" . "</fieldset>" . "</div>"; |
197
|
|
|
} |
198
|
|
|
// Load javascript |
199
|
1 |
|
if (empty($js_loaded)) { |
200
|
1 |
|
$javascript = (($this->js) |
201
|
1 |
|
? '<script type="text/javascript">' . $this->js . '</script>' |
202
|
1 |
|
: '') . '<script type="text/javascript" src="' . \XoopsBaseConfig::get('url') . '/include/formdhtmltextarea.js"></script>'; |
203
|
1 |
|
$ret = $javascript . $ret; |
204
|
1 |
|
$js_loaded = true; |
205
|
|
|
} |
206
|
1 |
|
return $ret; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* xoopsCodeControls |
211
|
|
|
* |
212
|
|
|
* @return string |
213
|
|
|
*/ |
214
|
2 |
|
public function xoopsCodeControls() |
215
|
|
|
{ |
216
|
2 |
|
$textarea_id = $this->getName(); |
217
|
2 |
|
$myts = \Xoops\Core\Text\Sanitizer::getInstance(); |
218
|
|
|
|
219
|
2 |
|
$code = ''; |
220
|
2 |
|
$code .= '<div class="row"><div class="col-md-12">'; |
221
|
|
|
|
222
|
2 |
|
$urlText = htmlspecialchars(\XoopsLocale::ENTER_LINK_URL, ENT_COMPAT); |
223
|
2 |
|
$titleText = htmlspecialchars(\XoopsLocale::ENTER_WEBSITE_TITLE, ENT_COMPAT); |
224
|
2 |
|
$urlButton = new HtmlButton(); |
225
|
2 |
|
$urlButton->set('type', 'button') |
226
|
2 |
|
->set('class', 'btn btn-default btn-sm') |
227
|
2 |
|
->set('alt', \XoopsLocale::URL) |
228
|
2 |
|
->set('title', \XoopsLocale::URL) |
229
|
2 |
|
->set('onclick', "xoopsCodeUrl(\"{$textarea_id}\", \"{$urlText}\", \"{$titleText}\")") |
230
|
2 |
|
->set('onmouseover', "style.cursor='hand'") |
231
|
2 |
|
->set('value', '<span class="fa fa-fw fa-link" aria-hidden="true"></span>'); |
232
|
2 |
|
$code .= $urlButton->render(); |
233
|
|
|
|
234
|
2 |
|
$emailText = htmlspecialchars(\XoopsLocale::ENTER_EMAIL, ENT_COMPAT); |
235
|
2 |
|
$emailButton = new HtmlButton(); |
236
|
2 |
|
$emailButton->set('type', 'button') |
237
|
2 |
|
->set('class', 'btn btn-default btn-sm') |
238
|
2 |
|
->set('alt', \XoopsLocale::EMAIL) |
239
|
2 |
|
->set('title', \XoopsLocale::EMAIL) |
240
|
2 |
|
->set('onclick', "xoopsCodeEmail(\"{$textarea_id}\", \"{$emailText}\")") |
241
|
2 |
|
->set('onmouseover', "style.cursor='hand'") |
242
|
2 |
|
->set('value', '<span class="fa fa-fw fa-envelope-o" aria-hidden="true"></span>'); |
243
|
2 |
|
$code .= $emailButton->render(); |
244
|
|
|
|
245
|
2 |
|
$imgUrlText = htmlspecialchars(\XoopsLocale::ENTER_IMAGE_URL, ENT_COMPAT); |
246
|
2 |
|
$imgPosText = htmlspecialchars(\XoopsLocale::ENTER_IMAGE_POSITION, ENT_COMPAT); |
247
|
2 |
|
$imgPosDescText = htmlspecialchars(\XoopsLocale::IMAGE_POSITION_DESCRIPTION, ENT_COMPAT); |
248
|
2 |
|
$imgEPosText = htmlspecialchars(\XoopsLocale::E_ENTER_IMAGE_POSITION, ENT_COMPAT); |
249
|
2 |
|
$imgWidthText = htmlspecialchars(\XoopsLocale::WIDTH, ENT_COMPAT); |
250
|
2 |
|
$imageButton = new HtmlButton(); |
251
|
2 |
|
$imageButton->set('type', 'button') |
252
|
2 |
|
->set('class', 'btn btn-default btn-sm') |
253
|
2 |
|
->set('alt', \XoopsLocale::IMAGES) |
254
|
2 |
|
->set('title', \XoopsLocale::IMAGES) |
255
|
2 |
|
->set('onclick', "xoopsCodeImg(\"{$textarea_id}\", \"{$imgUrlText}\", \"{$imgPosText}\", \"{$imgPosDescText}\", \"{$imgEPosText}\", \"{$imgWidthText}\")") |
256
|
2 |
|
->set('onmouseover', "style.cursor='hand'") |
257
|
2 |
|
->set('value', '<span class="fa fa-fw fa-file-image-o" aria-hidden="true"></span>'); |
258
|
2 |
|
$code .= $imageButton->render(); |
259
|
|
|
|
260
|
2 |
|
$extensions = array_filter($myts->listExtensions()); |
261
|
2 |
|
foreach ($extensions as $extension) { |
262
|
2 |
|
list ($button, $js) = $myts->getDhtmlEditorSupport($extension, $textarea_id); |
263
|
2 |
|
if (!empty($button)) { |
264
|
2 |
|
$code .= $button; |
265
|
|
|
} |
266
|
2 |
|
if (!empty($js)) { |
267
|
2 |
|
$this->js .= $js; |
268
|
|
|
} |
269
|
|
|
} |
270
|
|
|
|
271
|
2 |
|
$codeText = htmlspecialchars(\XoopsLocale::ENTER_CODE, ENT_COMPAT); |
272
|
2 |
|
$codeButton = new HtmlButton(); |
273
|
2 |
|
$codeButton->set('type', 'button') |
274
|
2 |
|
->set('class', 'btn btn-default btn-sm') |
275
|
2 |
|
->set('alt', \XoopsLocale::SOURCE_CODE) |
276
|
2 |
|
->set('title', \XoopsLocale::SOURCE_CODE) |
277
|
2 |
|
->set('onclick', "xoopsCodeCode(\"{$textarea_id}\", \"{$codeText}\")") |
278
|
2 |
|
->set('onmouseover', "style.cursor='hand'") |
279
|
2 |
|
->set('value', '<span class="fa fa-fw fa-code" aria-hidden="true"></span>'); |
280
|
2 |
|
$code .= $codeButton->render(); |
281
|
|
|
|
282
|
2 |
|
$quoteText = htmlspecialchars(\XoopsLocale::ENTER_QUOTE, ENT_COMPAT); |
283
|
2 |
|
$quoteButton = new HtmlButton(); |
284
|
2 |
|
$quoteButton->set('type', 'button') |
285
|
2 |
|
->set('class', 'btn btn-default btn-sm') |
286
|
2 |
|
->set('alt', \XoopsLocale::QUOTE) |
287
|
2 |
|
->set('title', \XoopsLocale::QUOTE) |
288
|
2 |
|
->set('onclick', "xoopsCodeQuote(\"{$textarea_id}\", \"{$quoteText}\")") |
289
|
2 |
|
->set('onmouseover', "style.cursor='hand'") |
290
|
2 |
|
->set('value', '<span class="fa fa-fw fa-quote-right" aria-hidden="true"></span>'); |
291
|
2 |
|
$code .= $quoteButton->render(); |
292
|
|
|
|
293
|
2 |
|
$response = \Xoops::getInstance()->service('emoji')->renderEmojiSelector($this->getName()); |
294
|
2 |
|
if ($response->isSuccess()) { |
295
|
|
|
$emojiSelector = $response->getValue(); |
296
|
|
|
$code .= $emojiSelector; |
297
|
|
|
} |
298
|
|
|
|
299
|
2 |
|
$code .= "</div></div>"; |
300
|
|
|
|
301
|
2 |
|
return $code; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* Render typography controls for editor (font, size, color) |
306
|
|
|
* |
307
|
|
|
* @return string rendered typography controls |
308
|
|
|
*/ |
309
|
1 |
|
public function typographyControls() |
310
|
|
|
{ |
311
|
1 |
|
$textarea_id = $this->getName(); |
312
|
1 |
|
$hiddentext = $this->hiddenText; |
313
|
|
|
|
314
|
1 |
|
$fontarray = \XoopsLocale::getFonts(); |
315
|
|
|
|
316
|
|
|
$colorArray = array( |
317
|
1 |
|
'Black' => '000000', |
318
|
|
|
'Blue' => '38AAFF', |
319
|
|
|
'Brown' => '987857', |
320
|
|
|
'Green' => '79D271', |
321
|
|
|
'Grey' => '888888', |
322
|
|
|
'Orange' => 'FFA700', |
323
|
|
|
'Paper' => 'E0E0E0', |
324
|
|
|
'Purple' => '363E98', |
325
|
|
|
'Red' => 'FF211E', |
326
|
|
|
'White' => 'FEFEFE', |
327
|
|
|
'Yellow' => 'FFD628', |
328
|
|
|
); |
329
|
|
|
|
330
|
1 |
|
$fontStr = '<div class="row"><div class="col-md-12"><div class="btn-group" role="toolbar">'; |
331
|
|
|
$fontStr .= '<div class="btn-group">' |
332
|
1 |
|
. '<button type="button" class="btn btn-default btn-sm dropdown-toggle" title="'. \XoopsLocale::SIZE .'"' |
333
|
1 |
|
. ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
334
|
1 |
|
. '<span class = "glyphicon glyphicon-text-height"></span><span class="caret"></span></button>' |
335
|
1 |
|
. '<ul class="dropdown-menu">'; |
336
|
1 |
|
$localeFontSizes = \XoopsLocale::getFontSizes(); |
337
|
1 |
|
foreach ($localeFontSizes as $value => $name) { |
338
|
1 |
|
$fontStr .= '<li><a href="javascript:xoopsSetElementAttribute(\'size\', \'' . $value . '\', \'' |
339
|
1 |
|
. $textarea_id . '\', \'' . $hiddentext . '\');">' . $name . '</a></li>'; |
340
|
|
|
} |
341
|
1 |
|
$fontStr .= '</ul></div>'; |
342
|
|
|
|
343
|
|
|
$fontStr .= '<div class="btn-group">' |
344
|
1 |
|
. '<button type="button" class="btn btn-default btn-sm dropdown-toggle" title="'. \XoopsLocale::FONT .'"' |
345
|
1 |
|
. ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
346
|
1 |
|
. '<span class = "glyphicon glyphicon-font"></span><span class="caret"></span></button>' |
347
|
1 |
|
. '<ul class="dropdown-menu">'; |
348
|
|
|
//. _FONT . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
349
|
1 |
|
foreach ($fontarray as $font) { |
350
|
1 |
|
$fontStr .= '<li><a href="javascript:xoopsSetElementAttribute(\'font\', \'' . $font . '\', \'' |
351
|
1 |
|
. $textarea_id . '\', \'' . $hiddentext . '\');">' . $font . '</a></li>'; |
352
|
|
|
} |
353
|
1 |
|
$fontStr .= '</ul></div>'; |
354
|
|
|
|
355
|
|
|
$fontStr .= '<div class="btn-group">' |
356
|
1 |
|
. '<button type="button" class="btn btn-default btn-sm dropdown-toggle" title="'. \XoopsLocale::COLOR .'"' |
357
|
1 |
|
. ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
358
|
1 |
|
. '<span class = "glyphicon glyphicon-text-color"></span><span class="caret"></span></button>' |
359
|
1 |
|
. '<ul class="dropdown-menu">'; |
360
|
|
|
//. _COLOR . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
361
|
1 |
|
foreach ($colorArray as $color => $hex) { |
362
|
1 |
|
$fontStr .= '<li><a href="javascript:xoopsSetElementAttribute(\'color\', \'' . $hex . '\', \'' |
363
|
1 |
|
. $textarea_id . '\', \'' . $hiddentext . '\');">' |
364
|
1 |
|
. '<span style="color:#' . $hex . ';">' . $color .'</span></a></li>'; |
365
|
|
|
} |
366
|
1 |
|
$fontStr .= '</ul></div>'; |
367
|
1 |
|
$fontStr .= '</div>'; |
368
|
|
|
|
369
|
|
|
//$styleStr = "<div class='row'><div class='col-md-12'>"; |
370
|
1 |
|
$styleStr = "<div class='btn-group' role='group'>"; |
371
|
1 |
|
$styleStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeBold(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::BOLD . "' aria-label='Left Align'><span class='fa fa-bold' aria-hidden='true'></span></button>"; |
372
|
1 |
|
$styleStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeItalic(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::ITALIC . "' aria-label='Left Align'><span class='fa fa-italic' aria-hidden='true'></span></button>"; |
373
|
1 |
|
$styleStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeUnderline(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::UNDERLINE . "' aria-label='Left Align'>" . '<span class="fa fa-underline"></span></button>'; |
374
|
1 |
|
$styleStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeLineThrough(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::LINE_THROUGH . "' aria-label='Left Align'>" . '<span class="fa fa-strikethrough"></span></button>'; |
375
|
1 |
|
$styleStr .= "</div>"; |
376
|
|
|
|
377
|
1 |
|
$alignStr = "<div class='btn-group' role='group'>"; |
378
|
1 |
|
$alignStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeLeft(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::LEFT . "' aria-label='Left Align'><span class='fa fa-align-left' aria-hidden='true'></span></button>"; |
379
|
1 |
|
$alignStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeCenter(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::CENTER . "' aria-label='Left Align'><span class='fa fa-align-center' aria-hidden='true'></span></button>"; |
380
|
1 |
|
$alignStr .= "<button type='button' class='btn btn-default btn-sm' onclick='xoopsMakeRight(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . \XoopsLocale::RIGHT . "' aria-label='Left Align'><span class='fa fa-align-right' aria-hidden='true'></span></button>"; |
381
|
1 |
|
$alignStr .= "</div>"; |
382
|
|
|
|
383
|
1 |
|
$fontStr .= " {$styleStr} {$alignStr} \n"; |
384
|
|
|
|
385
|
|
|
$fontStr .= "<button type='button' class='btn btn-default btn-sm' onclick=\"XoopsCheckLength('" |
386
|
1 |
|
. $this->getName() . "', '" . @$this->configs['maxlength'] . "', '" |
387
|
1 |
|
. \XoopsLocale::F_CURRENT_TEXT_LENGTH . "', '" . \XoopsLocale::MAXIMUM_LENGTH . "');\" title='" |
388
|
1 |
|
. \XoopsLocale::CHECK_TEXT_LENGTH . "'><span class='fa fa-check-square-o' aria-hidden='true'></span></button>"; |
389
|
1 |
|
$fontStr .= "</div></div>"; |
390
|
|
|
|
391
|
1 |
|
return $fontStr; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* fontArray |
396
|
|
|
* |
397
|
|
|
* @return string |
398
|
|
|
*/ |
399
|
1 |
|
public function fontArray() |
400
|
|
|
{ |
401
|
1 |
|
$textarea_id = $this->getName(); |
402
|
1 |
|
$hiddentext = $this->hiddenText; |
403
|
|
|
|
404
|
1 |
|
$fontStr = "<script type=\"text/javascript\" language=\"JavaScript\">"; |
405
|
1 |
|
$fontStr .= "var _editor_dialog = ''" . "+ '<select class=\"span2\" id=\'{$textarea_id}Size\' onchange=\'xoopsSetElementAttribute(\"size\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'"; |
406
|
1 |
|
$fontStr .= "+ '<option value=\'SIZE\'>" . \XoopsLocale::SIZE . "</option>'"; |
407
|
1 |
|
$localeFontSizes = \XoopsLocale::getFontSizes(); |
408
|
1 |
|
foreach ($localeFontSizes as $_val => $_name) { |
409
|
1 |
|
$fontStr .= " + '<option value=\'{$_val}\'>{$_name}</option>'"; |
410
|
|
|
} |
411
|
1 |
|
$fontStr .= " + '</select> '"; |
412
|
1 |
|
$fontStr .= "+ '<select class=\"span2\" id=\'{$textarea_id}Font\' onchange=\'xoopsSetElementAttribute(\"font\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'"; |
413
|
1 |
|
$fontStr .= "+ '<option value=\'FONT\'>" . \XoopsLocale::FONT . "</option>'"; |
414
|
1 |
|
$localeFonts = \XoopsLocale::getFonts(); |
415
|
1 |
|
$fontarray = !empty($localeFonts) ? $localeFonts : |
416
|
1 |
|
array("Arial", "Courier", "Georgia", "Helvetica", "Impact", "Verdana", "Haettenschweiler"); |
417
|
1 |
|
foreach ($fontarray as $font) { |
418
|
1 |
|
$fontStr .= " + '<option value=\'{$font}\'>{$font}</option>'"; |
419
|
|
|
} |
420
|
1 |
|
$fontStr .= " + '</select> '"; |
421
|
1 |
|
$fontStr .= "+ '<select class=\"span2\" id=\'{$textarea_id}Color\' onchange=\'xoopsSetElementAttribute(\"color\", this.options[this.selectedIndex].value, \"{$textarea_id}\", \"{$hiddentext}\");\'>'"; |
422
|
1 |
|
$fontStr .= "+ '<option value=\'COLOR\'>" . \XoopsLocale::COLOR . "</option>';"; |
423
|
1 |
|
$fontStr .= "var _color_array = new Array('00', '33', '66', '99', 'CC', 'FF'); |
424
|
|
|
for(var i = 0; i < _color_array.length; i ++) { |
425
|
|
|
for(var j = 0; j < _color_array.length; j ++) { |
426
|
|
|
for(var k = 0; k < _color_array.length; k ++) { |
427
|
|
|
var _color_ele = _color_array[i] + _color_array[j] + _color_array[k]; |
428
|
|
|
_editor_dialog += '<option value=\''+_color_ele+'\' style=\'background-color:#'+_color_ele+';color:#'+_color_ele+';\'>#'+_color_ele+'</option>'; |
429
|
|
|
} |
430
|
|
|
} |
431
|
|
|
} |
432
|
|
|
_editor_dialog += '</select>';"; |
433
|
|
|
|
434
|
1 |
|
$fontStr .= "document.write(_editor_dialog); </script>"; |
435
|
|
|
|
436
|
1 |
|
$styleStr = "<img src='" . \XoopsBaseConfig::get('url') . "/images/bold.gif' alt='" . \XoopsLocale::BOLD . "' title='" . \XoopsLocale::BOLD . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeBold(\"{$hiddentext}\", \"{$textarea_id}\");' /> "; |
437
|
1 |
|
$styleStr .= "<img src='" . \XoopsBaseConfig::get('url') . "/images/italic.gif' alt='" . \XoopsLocale::ITALIC . "' title='" . \XoopsLocale::ITALIC . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeItalic(\"{$hiddentext}\", \"{$textarea_id}\");' /> "; |
438
|
1 |
|
$styleStr .= "<img src='" . \XoopsBaseConfig::get('url') . "/images/underline.gif' alt='" . \XoopsLocale::UNDERLINE . "' title='" . \XoopsLocale::UNDERLINE . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeUnderline(\"{$hiddentext}\", \"{$textarea_id}\");'/> "; |
439
|
1 |
|
$styleStr .= "<img src='" . \XoopsBaseConfig::get('url') . "/images/linethrough.gif' alt='" . \XoopsLocale::LINE_THROUGH . "' title='" . \XoopsLocale::LINE_THROUGH . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeLineThrough(\"{$hiddentext}\", \"{$textarea_id}\");' /> "; |
440
|
|
|
|
441
|
1 |
|
$alignStr = "<img src='" . \XoopsBaseConfig::get('url') . "/images/alignleft.gif' alt='" . \XoopsLocale::LEFT . "' title='" . \XoopsLocale::LEFT . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeLeft(\"{$hiddentext}\", \"{$textarea_id}\");' /> "; |
442
|
1 |
|
$alignStr .= "<img src='" . \XoopsBaseConfig::get('url') . "/images/aligncenter.gif' alt='" . \XoopsLocale::CENTER . "' title='" . \XoopsLocale::CENTER . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeCenter(\"{$hiddentext}\", \"{$textarea_id}\");' /> "; |
443
|
1 |
|
$alignStr .= "<img src='" . \XoopsBaseConfig::get('url') . "/images/alignright.gif' alt='" . \XoopsLocale::RIGHT . "' title='" . \XoopsLocale::RIGHT . "' onmouseover='style.cursor=\"hand\"' onclick='xoopsMakeRight(\"{$hiddentext}\", \"{$textarea_id}\");' /> "; |
444
|
1 |
|
$fontStr = $fontStr . "<br />\n{$styleStr} {$alignStr} \n"; |
445
|
1 |
|
return $fontStr; |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* renderValidationJS |
450
|
|
|
* |
451
|
|
|
* @return bool|string |
452
|
|
|
*/ |
453
|
1 |
|
public function renderValidationJS() |
454
|
|
|
{ |
455
|
1 |
|
if ($this->htmlEditor && is_object($this->htmlEditor) && method_exists($this->htmlEditor, 'renderValidationJS')) { |
456
|
|
|
if (!isset($this->htmlEditor->isEnabled) || $this->htmlEditor->isEnabled) { |
457
|
|
|
return $this->htmlEditor->renderValidationJS(); |
458
|
|
|
} |
459
|
|
|
} |
460
|
1 |
|
return parent::renderValidationJS(); |
461
|
|
|
} |
462
|
|
|
} |
463
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..