19declare(strict_types=1);
48 "mini" => array(
"strong",
"em",
"u",
"ol",
"li",
"ul",
"blockquote",
"a",
"p",
"span",
"br"),
49 "standard" => array(
"strong",
"em",
"u",
"ol",
"li",
"ul",
"p",
"div",
50 "i",
"b",
"code",
"sup",
"sub",
"pre",
"strike",
"gap"),
52 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
53 "h4",
"h5",
"h6",
"hr",
"li",
"ol",
"p",
54 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"u",
"ul",
56 "extended_img" => array(
57 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
58 "h4",
"h5",
"h6",
"hr",
"img",
"li",
"ol",
"p",
59 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"u",
"ul",
61 "extended_table" => array(
62 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
63 "h4",
"h5",
"h6",
"hr",
"li",
"ol",
"p",
64 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"table",
"td",
65 "tr",
"u",
"ul",
"i",
"b",
"gap"),
66 "extended_table_img" => array(
67 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
68 "h4",
"h5",
"h6",
"hr",
"img",
"li",
"ol",
"p",
69 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"table",
"td",
70 "tr",
"u",
"ul",
"i",
"b",
"gap"),
72 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
73 "h4",
"h5",
"h6",
"hr",
"img",
"li",
"ol",
"p",
74 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"table",
"td",
75 "tr",
"u",
"ul",
"ruby",
"rbc",
"rtc",
"rb",
"rt",
"rp",
"i",
"b",
"gap"));
79 string $a_postvar =
""
83 $this->
lng = $DIC->language();
87 $this->plugins = array();
88 $this->removeplugins = array();
89 $this->buttons = array();
90 $this->rteSupport = array();
93 public function setValue(
string $a_value): void
95 $this->value = $a_value;
109 $this->cols = $a_cols;
119 $this->rows = $a_rows;
130 $this->max_num_chars = $a_number;
140 $this->min_num_chars = $a_number;
150 $this->usert = $a_usert;
151 $this->rteSupport[
'version'] =
$version;
161 $this->plugins[$a_plugin] = $a_plugin;
166 $this->removeplugins[$a_plugin] = $a_plugin;
172 $this->buttons[$a_button] = $a_button;
177 unset($this->buttons[$a_button]);
187 ?
string $cfg_template =
null,
188 bool $hide_switch =
false,
191 $this->rteSupport = array(
193 "obj_type" => $obj_type,
195 'cfg_template' => $cfg_template,
196 'hide_switch' => $hide_switch,
203 $this->rteSupport = array();
208 $this->rtetags = $a_rtetags;
213 return $this->rtetags;
222 $this->setRteTags($this->rte_tag_set[$a_set_name]);
227 return $this->rte_tag_set[$a_set_name];
233 foreach ($this->getRteTags() as $tag) {
244 $this->use_tags_for_rte_only = $a_val;
249 return $this->use_tags_for_rte_only;
254 $this->setValue($a_values[$this->getPostVar()] ??
"");
256 foreach ($this->getSubItems() as $item) {
257 $item->setValueByArray($a_values);
265 $value = $this->getInput();
266 if ($this->getRequired() && trim($value) ==
"") {
267 $this->setAlert(
$lng->txt(
"msg_input_is_required"));
271 if ($this->isCharLimited()) {
273 $ascii_whitespaces = chr(194) . chr(160);
274 $ascii_breaklines = chr(13) . chr(10);
276 $to_replace = array($ascii_whitespaces, $ascii_breaklines,
"<",
">",
"&");
277 $replace_to = array(
' ',
'',
"_",
"_",
"_");
279 #20630 mbstring extension is mandatory for 5.4
280 $chars_entered = mb_strlen(strip_tags(str_replace($to_replace, $replace_to, $value)));
282 if ($this->getMaxNumOfChars() && ($chars_entered > $this->getMaxNumOfChars())) {
283 $this->setAlert(
$lng->txt(
"msg_input_char_limit_max"));
285 } elseif ($this->getMinNumOfChars() && ($chars_entered < $this->getMinNumOfChars())) {
286 $this->setAlert(
$lng->txt(
"msg_input_char_limit_min"));
291 return $this->checkSubItemsInput();
296 if ($this->usePurifier() && $this->getPurifier()) {
297 $value = $this->getPurifier()->purify($this->
raw($this->getPostVar()));
299 $allowed = $this->getRteTagString();
300 if (isset($this->plugins[
"latex"]) && $this->plugins[
"latex"] ==
"latex" && !is_int(strpos($allowed,
"<span>"))) {
301 $allowed .=
"<span>";
303 $value = ($this->getUseRte() || !$this->getUseTagsForRteOnly())
305 : $this->
str($this->getPostVar());
308 $value = self::removeProhibitedCharacters($value);
316 $ttpl =
new ilTemplate(
"tpl.prop_textarea.html",
true,
true,
"Services/Form");
318 if ($this->getInfo() !==
'') {
319 $ttpl->setCurrentBlock(
'described_by_description');
320 $ttpl->setVariable(
'DESCRIBED_BY_DESCRIPTION_FIELD_ID', $this->getFieldId());
321 $ttpl->parseCurrentBlock();
325 if ($this->getUseRte() && $this->getDisabled()) {
326 $ttpl->setCurrentBlock(
"disabled_rte");
327 $ttpl->setVariable(
"DR_VAL", $this->
getValue());
329 if ($this->getUseRte()) {
331 $rte =
new $rtestring((
string) $this->rteSupport[
'version']);
332 $rte->setInitialWidth($this->getInitialRteWidth());
335 $rte->addPlugin(
"emoticons");
336 foreach ($this->plugins as
$plugin) {
341 foreach ($this->removeplugins as
$plugin) {
347 foreach ($this->buttons as $button) {
348 if (strlen($button)) {
349 $rte->addButton($button);
353 $rte->disableButtons($this->getDisabledButtons());
355 if ($this->getRTERootBlockElement() !==
null) {
356 $rte->setRTERootBlockElement($this->getRTERootBlockElement());
359 if (count($this->rteSupport) >= 3) {
360 $rte->addRTESupport($this->rteSupport[
"obj_id"], $this->rteSupport[
"obj_type"], $this->rteSupport[
"module"],
false, $this->rteSupport[
'cfg_template'], $this->rteSupport[
'hide_switch']);
363 if (!array_diff($this->getRteTags(), $this->getRteTagSet(
"mini"))) {
364 $rte->removeAllPlugins();
367 $rte->addPlugin(
"paste");
369 $rte->addPlugin(
"lists");
370 $rte->addPlugin(
"link");
371 $rte->addPlugin(
"code");
373 if (method_exists($rte,
'removeAllContextMenuItems')) {
374 $rte->removeAllContextMenuItems();
378 $rte->disableButtons(array(
"anchor",
"alignleft",
"aligncenter",
379 "alignright",
"alignjustify",
"formatselect",
"removeformat",
380 "cut",
"copy",
"paste",
"pastetext"));
382 $rte->addCustomRTESupport(0,
"", $this->getRteTags());
385 $ttpl->touchBlock(
"prop_ta_w");
387 $ttpl->touchBlock(
"no_rteditor");
389 if ($this->getCols() > 5) {
390 $ttpl->setCurrentBlock(
"prop_ta_c");
391 $ttpl->setVariable(
"COLS", $this->getCols());
392 $ttpl->parseCurrentBlock();
394 $ttpl->touchBlock(
"prop_ta_w");
397 $ttpl->setCurrentBlock(
"prop_textarea");
398 $ttpl->setVariable(
"ROWS", $this->getRows());
399 $ttpl->setVariable(
"POST_VAR", $this->getPostVar());
400 $ttpl->setVariable(
"ID", $this->getFieldId());
401 if ($this->getDisabled()) {
402 $ttpl->setVariable(
'DISABLED',
'disabled="disabled" ');
406 if ($this->getRequired()) {
407 $ttpl->setVariable(
"REQUIRED",
"required=\"required\"");
410 if ($this->isCharLimited()) {
411 $ttpl->setVariable(
"MAXCHARS", $this->getMaxNumOfChars());
412 $ttpl->setVariable(
"MINCHARS", $this->getMinNumOfChars());
414 $lng->toJS(
"form_chars_remaining");
417 $ttpl->parseCurrentBlock();
419 if ($this->isCharLimited()) {
420 $ttpl->setVariable(
"FEEDBACK_MAX_LIMIT", $this->getMaxNumOfChars());
421 $ttpl->setVariable(
"FEEDBACK_ID", $this->getFieldId());
422 $ttpl->setVariable(
"CHARS_REMAINING",
$lng->txt(
"form_chars_remaining"));
425 if ($this->getDisabled()) {
428 $this->getHiddenTag($this->getPostVar(), $this->
getValue())
443 if (
null === $a_flag) {
444 return $this->usePurifier;
447 $this->usePurifier = $a_flag;
456 $this->Purifier = $Purifier;
462 return $this->Purifier;
467 $this->root_block_element = $a_root_block_element;
473 return $this->root_block_element;
483 if (is_array($a_button)) {
484 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, $a_button));
486 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, array($a_button)));
497 return implode(
',', $this->disabled_buttons);
499 return $this->disabled_buttons;
505 return $this->initial_rte_width;
510 $this->initial_rte_width = $initial_rte_width;
515 if ($this->getMaxNumOfChars() || $this->getMinNumOfChars()) {
setVariable($variable, $value='')
Sets a variable value.
static _getRTEClassname()
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a text area property in a property form.
removeButton(string $a_button)
removePlugin(string $a_plugin)
disableButtons($a_button)
Sets buttons which should be disabled in TinyMCE.
setUseTagsForRteOnly(bool $a_val)
Set use tags for RTE only (default is true)
addButton(string $a_button)
setPurifier(ilHtmlPurifierInterface $Purifier)
Setter for the html purifier.
__construct(string $a_title="", string $a_postvar="")
getRteTagSet($a_set_name)
insert(ilTemplate $a_tpl)
usePurifier(bool $a_flag=null)
Setter/Getter for the html purifier usage.
setValue(string $a_value)
setRTESupport(int $obj_id, string $obj_type, string $module, ?string $cfg_template=null, bool $hide_switch=false, ?string $version=null)
Set RTE support for a special module.
setMinNumOfChars(int $a_number)
bool $use_tags_for_rte_only
getDisabledButtons(bool $as_array=true)
setRteTagSet(string $a_set_name)
setMaxNumOfChars(int $a_number)
setValueByArray(array $a_values)
ilHtmlPurifierInterface $Purifier
setInitialRteWidth(int $initial_rte_width)
addPlugin(string $a_plugin)
checkInput()
Check input, strip slashes etc.
string $root_block_element
setUseRte(bool $a_usert, string $version='')
setRTERootBlockElement(?string $a_root_block_element)
setRteTags(array $a_rtetags)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
Interface for html sanitizing functionality.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc