19declare(strict_types=1);
50 "mini" => array(
"strong",
"em",
"u",
"ol",
"li",
"ul",
"blockquote",
"a",
"p",
"span",
"br"),
51 "standard" => array(
"strong",
"em",
"u",
"ol",
"li",
"ul",
"p",
"div",
52 "i",
"b",
"code",
"sup",
"sub",
"pre",
"strike",
"gap"),
54 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
55 "h4",
"h5",
"h6",
"hr",
"li",
"ol",
"p",
56 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"u",
"ul",
58 "extended_img" => array(
59 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
60 "h4",
"h5",
"h6",
"hr",
"img",
"li",
"ol",
"p",
61 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"u",
"ul",
63 "extended_table" => array(
64 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
65 "h4",
"h5",
"h6",
"hr",
"li",
"ol",
"p",
66 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"table",
"td",
67 "tr",
"u",
"ul",
"i",
"b",
"gap"),
68 "extended_table_img" => array(
69 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
70 "h4",
"h5",
"h6",
"hr",
"img",
"li",
"ol",
"p",
71 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"table",
"td",
72 "tr",
"u",
"ul",
"i",
"b",
"gap"),
74 "a",
"blockquote",
"br",
"cite",
"code",
"div",
"em",
"h1",
"h2",
"h3",
75 "h4",
"h5",
"h6",
"hr",
"img",
"li",
"ol",
"p",
76 "pre",
"span",
"strike",
"strong",
"sub",
"sup",
"table",
"td",
77 "tr",
"u",
"ul",
"ruby",
"rbc",
"rtc",
"rb",
"rt",
"rp",
"i",
"b",
"gap"));
81 string $a_postvar =
""
85 $this->
lng = $DIC->language();
86 $this->
user = $DIC->user();
90 $this->plugins = array();
91 $this->removeplugins = array();
92 $this->buttons = array();
93 $this->rteSupport = array();
96 public function setValue(
string $a_value): void
98 $this->value = $a_value;
112 $this->cols = $a_cols;
122 $this->rows = $a_rows;
133 $this->max_num_chars = $a_number;
143 $this->min_num_chars = $a_number;
153 $this->usert = $a_usert;
154 $this->rteSupport[
'version'] =
$version;
164 $this->plugins[$a_plugin] = $a_plugin;
169 $this->removeplugins[$a_plugin] = $a_plugin;
175 $this->buttons[$a_button] = $a_button;
180 unset($this->buttons[$a_button]);
190 ?
string $cfg_template =
null,
191 bool $hide_switch =
false,
194 $this->rteSupport = array(
196 "obj_type" => $obj_type,
198 'cfg_template' => $cfg_template,
199 'hide_switch' => $hide_switch,
206 $this->rteSupport = array();
211 $this->rtetags = $a_rtetags;
216 return $this->rtetags;
225 $this->setRteTags($this->rte_tag_set[$a_set_name]);
230 return $this->rte_tag_set[$a_set_name];
236 foreach ($this->getRteTags() as $tag) {
247 $this->use_tags_for_rte_only = $a_val;
252 return $this->use_tags_for_rte_only;
257 $this->setValue($a_values[$this->getPostVar()] ??
"");
259 foreach ($this->getSubItems() as $item) {
260 $item->setValueByArray($a_values);
268 $value = $this->getInput();
269 if ($this->getRequired() && trim($value) ==
"") {
270 $this->setAlert(
$lng->txt(
"msg_input_is_required"));
274 if ($this->isCharLimited()) {
275 $chars_entered = mb_strlen($value);
277 if ($this->getMaxNumOfChars() && ($chars_entered > $this->getMaxNumOfChars())) {
278 $this->setAlert(
$lng->txt(
"msg_input_char_limit_max"));
280 } elseif ($this->getMinNumOfChars() && ($chars_entered < $this->getMinNumOfChars())) {
281 $this->setAlert(
$lng->txt(
"msg_input_char_limit_min"));
286 return $this->checkSubItemsInput();
291 $raw_post_var = (string) ($this->
raw($this->getPostVar()) ??
"");
293 if ($this->usePurifier() && $this->getPurifier()) {
294 $value = $this->getPurifier()->purify($raw_post_var);
296 $allowed = $this->getRteTagString();
297 if (isset($this->plugins[
"latex"]) && $this->plugins[
"latex"] ==
"latex" && !is_int(strpos($allowed,
"<span>"))) {
298 $allowed .=
"<span>";
300 $value = ($this->getUseRte() || !$this->getUseTagsForRteOnly())
302 : $this->
str($this->getPostVar());
305 $value = self::removeProhibitedCharacters($value);
307 # Convert newline characters
308 $value = str_replace(
"\r\n",
"\n", $value);
317 $ttpl =
new ilTemplate(
"tpl.prop_textarea.html",
true,
true,
"components/ILIAS/Form");
319 if ($this->getInfo() !==
'') {
320 $ttpl->setCurrentBlock(
'described_by_description');
321 $ttpl->setVariable(
'DESCRIBED_BY_DESCRIPTION_FIELD_ID', $this->getFieldId());
322 $ttpl->parseCurrentBlock();
326 if ($this->getUseRte() && $this->getDisabled()) {
327 $ttpl->setCurrentBlock(
"disabled_rte");
328 $ttpl->setVariable(
"DR_VAL", $this->
getValue());
330 if ($this->getUseRte()) {
331 $ttpl->touchBlock(
"rteditor");
333 $rte =
new $rtestring((
string) $this->rteSupport[
'version']);
334 $rte->setInitialWidth($this->getInitialRteWidth());
337 $rte->addPlugin(
"emoticons");
338 foreach ($this->plugins as
$plugin) {
343 foreach ($this->removeplugins as
$plugin) {
349 foreach ($this->buttons as $button) {
350 if (strlen($button)) {
351 $rte->addButton($button);
355 $rte->disableButtons($this->getDisabledButtons());
357 if ($this->getRTERootBlockElement() !==
null) {
358 $rte->setRTERootBlockElement($this->getRTERootBlockElement());
361 if (count($this->rteSupport) >= 3) {
365 $this->rteSupport[
"obj_id"],
366 $this->rteSupport[
"obj_type"],
367 $this->rteSupport[
"module"],
369 $this->rteSupport[
'cfg_template']
373 if (!array_diff($this->getRteTags(), $this->getRteTagSet(
"mini"))) {
374 $rte->removeAllPlugins();
377 $rte->addPlugin(
"paste");
379 $rte->addPlugin(
"lists");
380 $rte->addPlugin(
"link");
381 $rte->addPlugin(
"code");
383 if (method_exists($rte,
'removeAllContextMenuItems')) {
384 $rte->removeAllContextMenuItems();
388 $rte->disableButtons(array(
"anchor",
"alignleft",
"aligncenter",
389 "alignright",
"alignjustify",
"formatselect",
"removeformat",
390 "cut",
"copy",
"paste",
"pastetext"));
392 $rte->addCustomRTESupport(0,
"", $this->getRteTags());
395 $ttpl->touchBlock(
"prop_ta_w");
397 if ($this->getCols() > 5) {
398 $ttpl->setCurrentBlock(
"prop_ta_c");
399 $ttpl->setVariable(
"COLS", $this->getCols());
400 $ttpl->parseCurrentBlock();
402 $ttpl->touchBlock(
"prop_ta_w");
405 $ttpl->setCurrentBlock(
"prop_textarea");
406 $ttpl->setVariable(
"ROWS", $this->getRows());
407 $ttpl->setVariable(
"POST_VAR", $this->getPostVar());
408 $ttpl->setVariable(
"ID", $this->getFieldId());
409 if ($this->getDisabled()) {
410 $ttpl->setVariable(
'DISABLED',
'disabled="disabled" ');
414 if ($this->getRequired()) {
415 $ttpl->setVariable(
"REQUIRED",
"required=\"required\"");
418 if ($this->isCharLimited()) {
419 $ttpl->setVariable(
"MAXCHARS", $this->getMaxNumOfChars());
420 $ttpl->setVariable(
"MINCHARS", $this->getMinNumOfChars());
422 $lng->toJS(
"form_chars_remaining");
425 $ttpl->parseCurrentBlock();
427 if ($this->isCharLimited()) {
428 $ttpl->setVariable(
"FEEDBACK_MAX_LIMIT", $this->getMaxNumOfChars());
429 $ttpl->setVariable(
"FEEDBACK_ID", $this->getFieldId());
430 $ttpl->setVariable(
"CHARS_REMAINING",
$lng->txt(
"form_chars_remaining"));
433 if ($this->getDisabled()) {
436 $this->getHiddenTag($this->getPostVar(), $this->
getValue())
451 if (
null === $a_flag) {
452 return $this->usePurifier;
455 $this->usePurifier = $a_flag;
464 $this->Purifier = $Purifier;
470 return $this->Purifier;
475 $this->root_block_element = $a_root_block_element;
481 return $this->root_block_element;
491 if (is_array($a_button)) {
492 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, $a_button));
494 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, array($a_button)));
505 return implode(
',', $this->disabled_buttons);
507 return $this->disabled_buttons;
513 return $this->initial_rte_width;
518 $this->initial_rte_width = $initial_rte_width;
523 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)
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)
usePurifier(?bool $a_flag=null)
Setter/Getter for the html purifier usage.
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