ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTinyMCE.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/RTE/classes/class.ilRTE.php';
5 
15 class ilTinyMCE extends ilRTE
16 {
17  protected $mode = 'textareas';
18  protected $version = ''; // set default version here
19 
20  protected static $renderedToGlobalTemplate = false;
21 
25  protected $styleselect = false;
26 
31  protected $remove_img_context_menu_item = false;
32 
36  public function __construct($a_version = '')
37  {
38  parent::__construct($a_version);
39 
40  $this->plugins = array(
41  'link',
42  'emoticons',
43  'hr',
44  'table',
45  'save',
46  'insertdatetime',
47  'preview',
48  'searchreplace',
49  'print',
50  'paste',
51  'directionality',
52  'fullscreen',
53  'nonbreaking',
54  'noneditable',
55  'anchor',
56  'lists',
57  'code',
58  'charmap'
59  );
60  $this->contextMenuItems = array('cut','copy','paste', 'link','unlink','ilimgupload','imagetools','table');
61 
62  $this->setStyleSelect(false);
64  }
65 
66 
67  public function getPlugins()
68  {
69  return $this->plugins;
70  }
71 
75  protected function addInternalTinyMCEImageManager()
76  {
77  if (!$this->client_init->readVariable('tinymce', 'use_advanced_img_mng')) {
78  parent::addPlugin('ilimgupload');
79  parent::addButton('ilimgupload');
80  parent::removePlugin('ibrowser');
81  parent::removePlugin('image');
82 
83  $this->disableButtons(array(
84  'ibrowser',
85  'image'
86  ));
87 
88  $this->setRemoveImgContextMenuItem(true);
89  } else {
90  parent::addPlugin('ibrowser');
91  parent::removePlugin('ilimgupload');
92  $this->disableButtons('ilimgupload');
93 
94  $this->setRemoveImgContextMenuItem(false);
95  }
96  }
97 
101  protected function handleImagePluginsBeforeRendering(array $tags)
102  {
103  if (!in_array('img', $tags)) {
104  $this->setRemoveImgContextMenuItem(true);
105  parent::removePlugin('ilimgupload');
106  parent::removePlugin('ibrowser');
107  parent::removePlugin('image');
108  $this->disableButtons(array(
109  'ibrowser',
110  'image',
111  'ilimgupload'
112  ));
113  }
114  }
115 
119  protected function handleIliasImageManagerAdded()
120  {
122  }
123 
124  protected function handleIliasImageManagerRemoved()
125  {
126  if (!$this->client_init->readVariable('tinymce', 'use_advanced_img_mng')) {
127  parent::removePlugin('ilimgupload');
128  $this->disableButtons('ilimgupload');
129  } else {
130  parent::removePlugin('ibrowser');
131  $this->disableButtons('ibrowser');
132  }
133  }
134 
138  public function addPlugin($a_plugin_name)
139  {
140  if (self::ILIAS_IMG_MANAGER_PLUGIN == $a_plugin_name) {
142  } else {
143  parent::addPlugin($a_plugin_name);
144  }
145  }
146 
150  public function removePlugin($a_plugin_name)
151  {
152  if (self::ILIAS_IMG_MANAGER_PLUGIN == $a_plugin_name) {
154  } else {
155  parent::removePlugin($a_plugin_name);
156  }
157  }
158 
162  public function addRTESupport($obj_id, $obj_type, $a_module = "", $allowFormElements = false, $cfg_template = null, $hide_switch = false)
163  {
164  global $DIC;
165  $lng = $DIC['lng'];
166  if ($this->browser->isMobile()) {
168  } else {
170  }
171 
172  include_once "./Services/UICore/classes/class.ilTemplate.php";
174  $tpl = new ilTemplate(($cfg_template === null ? "tpl.tinymce.js" : $cfg_template), true, true, "Services/RTE");
176  $tags = ilObjAdvancedEditing::_getUsedHTMLTags($a_module);
177  $this->handleImagePluginsBeforeRendering($tags);
178  if ($allowFormElements) {
179  $tpl->touchBlock("formelements");
180  }
181  if ($this->getInitialWidth() !== null && $tpl->blockExists('initial_width')) {
182  $tpl->setCurrentBlock("initial_width");
183  $tpl->setVariable('INITIAL_WIDTH', $this->getInitialWidth());
184  $tpl->parseCurrentBlock();
185  }
186  $tpl->setCurrentBlock("tinymce");
187  include_once "./Services/Object/classes/class.ilObject.php";
188  $tpl->setVariable("OBJ_ID", $obj_id);
189  $tpl->setVariable("OBJ_TYPE", $obj_type);
190  $tpl->setVariable("CLIENT_ID", CLIENT_ID);
191  $tpl->setVariable("SESSION_ID", $_COOKIE[session_name()]);
192  $tpl->setVariable("BLOCKFORMATS", $this->_buildAdvancedBlockformatsFromHTMLTags($tags));
193  $tpl->setVariable("VALID_ELEMENTS", $this->_getValidElementsFromHTMLTags($tags));
194  $tpl->setVariable("TXT_MAX_SIZE", ilUtil::getFileSizeInfo());
195  // allowed extentions for uploaded image files
196  $tinyMCE_valid_imgs = array('gif', 'jpg', 'jpeg', 'png');
197  $tpl->setVariable(
198  "TXT_ALLOWED_FILE_EXTENSIONS",
199  $lng->txt("file_allowed_suffixes") . " " .
200  implode(', ', array_map(function ($value) {
201  return "." . $value;
203  );
204 
205  $buttons_1 = $this->_buildAdvancedButtonsFromHTMLTags(1, $tags);
206  $buttons_2 = $this->_buildAdvancedButtonsFromHTMLTags(2, $tags)
207  . ',' . $this->_buildAdvancedTableButtonsFromHTMLTags($tags)
208  . ($this->getStyleSelect() ? ',styleselect' : '');
209  $buttons_3 = $this->_buildAdvancedButtonsFromHTMLTags(3, $tags);
210  $tpl->setVariable('BUTTONS_1', self::removeRedundantSeparators($buttons_1));
211  $tpl->setVariable('BUTTONS_2', self::removeRedundantSeparators($buttons_2));
212  $tpl->setVariable('BUTTONS_3', self::removeRedundantSeparators($buttons_3));
213 
214  $tpl->setVariable('CONTEXT_MENU_ITEMS', join(" ", $this->contextMenuItems));
215 
216  $tpl->setVariable("ADDITIONAL_PLUGINS", join(" ", $this->plugins));
217  include_once "./Services/Utilities/classes/class.ilUtil.php";
218  //$tpl->setVariable("STYLESHEET_LOCATION", $this->getContentCSS());
219  $tpl->setVariable("STYLESHEET_LOCATION", ilUtil::getNewContentStyleSheetLocation() . "," . ilUtil::getStyleSheetLocation("output", "delos.css"));
220  $tpl->setVariable("LANG", $this->_getEditorLanguage());
221 
222  if ($this->getRTERootBlockElement() !== null) {
223  $tpl->setVariable('FORCED_ROOT_BLOCK', $this->getRTERootBlockElement());
224  }
225 
226  $tpl->parseCurrentBlock();
227 
228  if (!self::$renderedToGlobalTemplate) {
229  $this->tpl->addJavaScript("node_modules/tinymce/tinymce.js");
230  $this->tpl->addOnLoadCode($tpl->get());
231  self::$renderedToGlobalTemplate = true;
232  }
233  }
234  }
235 
240  {
241  if ($this->getRemoveImgContextMenuItem() && $tpl->blockExists('remove_img_context_menu_item')) {
242  $tpl->touchBlock('remove_img_context_menu_item');
243  }
244  }
245  //https://github.com/ILIAS-eLearning/ILIAS/pull/3088#issuecomment-805830050
252  public function addContextmenuItem(string $item = "")
253  {
254  if (!empty($item)) {
255  array_push($this->contextMenuItems, $item);
256  }
257  }
258 
264  public function removeAllContextMenuItems()
265  {
266  $this->contextMenuItems = array();
267  }
268 
272  public function addCustomRTESupport($obj_id, $obj_type, array $tags)
273  {
274  $this->handleImagePluginsBeforeRendering($tags);
275  include_once "./Services/UICore/classes/class.ilTemplate.php";
276  $tpl = new ilTemplate("tpl.tinymce.js", true, true, "Services/RTE");
278  $tpl->setCurrentBlock("tinymce");
279  include_once "./Services/Object/classes/class.ilObject.php";
280  $tpl->setVariable("OBJ_ID", $obj_id);
281  $tpl->setVariable("OBJ_TYPE", $obj_type);
282  $tpl->setVariable("CLIENT_ID", CLIENT_ID);
283  $tpl->setVariable("SESSION_ID", $_COOKIE[session_name()]);
284  $tpl->setVariable("BLOCKFORMATS", $this->_buildAdvancedBlockformatsFromHTMLTags($tags));
285  $tpl->setVariable("VALID_ELEMENTS", $this->_getValidElementsFromHTMLTags($tags));
286  $tpl->setVariable("TXT_MAX_SIZE", ilUtil::getFileSizeInfo());
287 
288  $this->disableButtons('charmap');
289  $buttons_1 = $this->_buildAdvancedButtonsFromHTMLTags(1, $tags);
290  $buttons_2 = $this->_buildAdvancedButtonsFromHTMLTags(2, $tags)
291  . ',' . $this->_buildAdvancedTableButtonsFromHTMLTags($tags)
292  . ($this->getStyleSelect() ? ',styleselect' : '');
293  $buttons_3 = $this->_buildAdvancedButtonsFromHTMLTags(3, $tags);
294  $tpl->setVariable('BUTTONS_1', self::removeRedundantSeparators($buttons_1));
295  $tpl->setVariable('BUTTONS_2', self::removeRedundantSeparators($buttons_2));
296  $tpl->setVariable('BUTTONS_3', self::removeRedundantSeparators($buttons_3));
297 
298  $tpl->setVariable('CONTEXT_MENU_ITEMS', join(" ", $this->contextMenuItems));
299 
300  $tpl->setVariable("ADDITIONAL_PLUGINS", join(" ", $this->plugins));
301  include_once "./Services/Utilities/classes/class.ilUtil.php";
302  //$tpl->setVariable("STYLESHEET_LOCATION", $this->getContentCSS());
303  $tpl->setVariable("STYLESHEET_LOCATION", ilUtil::getNewContentStyleSheetLocation());
304  $tpl->setVariable("LANG", $this->_getEditorLanguage());
305 
306  if ($this->getRTERootBlockElement() !== null) {
307  $tpl->setVariable('FORCED_ROOT_BLOCK', $this->getRTERootBlockElement());
308  }
309 
310  $tpl->parseCurrentBlock();
311 
312  if (!self::$renderedToGlobalTemplate) {
313  $this->tpl->addJavaScript("node_modules/tinymce/tinymce.js");
314  $this->tpl->addOnLoadCode($tpl->get());
315  self::$renderedToGlobalTemplate = true;
316  }
317  }
318 
322  public function addUserTextEditor($editor_selector)
323  {
324  $validtags = array("strong","em","p", "br", "div", "span");
325  $buttontags = array("strong","em");
326  include_once "./Services/UICore/classes/class.ilTemplate.php";
327  $template = new ilTemplate("tpl.usereditor.js", true, true, "Services/RTE");
328  $this->handleImgContextMenuItem($template);
329  $template->setCurrentBlock("tinymce");
330  include_once "./Services/Object/classes/class.ilObject.php";
331  $template->setVariable("SELECTOR", $editor_selector);
332  $template->setVariable("BLOCKFORMATS", "");
333  $template->setVariable("VALID_ELEMENTS", $this->_getValidElementsFromHTMLTags($validtags));
334  if ($this->getStyleSelect()) {
335  $template->setVariable("STYLE_SELECT", ",styleselect");
336  }
337  $template->setVariable("BUTTONS", $this->getButtonsForUserTextEditor($buttontags) . " backcolor removeformat");
338  include_once "./Services/Utilities/classes/class.ilUtil.php";
339  //$template->setVariable("STYLESHEET_LOCATION", $this->getContentCSS());
340  $template->setVariable("STYLESHEET_LOCATION", ilUtil::getNewContentStyleSheetLocation() . "," . ilUtil::getStyleSheetLocation("output", "delos.css"));
341  $template->setVariable("LANG", $this->_getEditorLanguage());
342  $template->parseCurrentBlock();
343 
344  $this->tpl->addJavaScript("node_modules/tinymce/tinymce.js");
345  $this->tpl->addOnLoadCode($template->get());
346  }
347 
352  protected function getButtonsForUserTextEditor(array $buttontags)
353  {
354  $btns = $this->_buildButtonsFromHTMLTags($buttontags);
355 
356  $btns = explode(' ', $btns);
357 
358  $btns[] = 'undo';
359  $btns[] = 'redo';
360 
361  return implode(' ', $btns);
362  }
363 
369  protected function setStyleSelect($a_styleselect)
370  {
371  $this->styleselect = $a_styleselect;
372  }
373 
379  public function getStyleSelect()
380  {
381  return $this->styleselect;
382  }
383 
388  public function _buildAdvancedBlockformatsFromHTMLTags(array $a_html_tags)
389  {
390  $blockformats = array();
391 
392  if (in_array("p", $a_html_tags)) {
393  array_push($blockformats, "p");
394  }
395  if (in_array("div", $a_html_tags)) {
396  array_push($blockformats, "div");
397  }
398  if (in_array("pre", $a_html_tags)) {
399  array_push($blockformats, "pre");
400  }
401  if (in_array("code", $a_html_tags)) {
402  array_push($blockformats, "code");
403  }
404  if (in_array("h1", $a_html_tags)) {
405  array_push($blockformats, "h1");
406  }
407  if (in_array("h2", $a_html_tags)) {
408  array_push($blockformats, "h2");
409  }
410  if (in_array("h3", $a_html_tags)) {
411  array_push($blockformats, "h3");
412  }
413  if (in_array("h4", $a_html_tags)) {
414  array_push($blockformats, "h4");
415  }
416  if (in_array("h5", $a_html_tags)) {
417  array_push($blockformats, "h5");
418  }
419  if (in_array("h6", $a_html_tags)) {
420  array_push($blockformats, "h6");
421  }
422  if (count($blockformats)) {
423  return join(",", $blockformats);
424  } else {
425  return "";
426  }
427  }
428 
434  public function _buildAdvancedButtonsFromHTMLTags($a_buttons_section, array $a_html_tags)
435  {
436  $theme_advanced_buttons = array();
437 
438  if ($a_buttons_section == 1) {
439  if (in_array("strong", $a_html_tags)) {
440  array_push($theme_advanced_buttons, "bold");
441  }
442  if (in_array("em", $a_html_tags)) {
443  array_push($theme_advanced_buttons, "italic");
444  }
445  if (in_array("u", $a_html_tags)) {
446  array_push($theme_advanced_buttons, "underline");
447  }
448  if (in_array("strike", $a_html_tags)) {
449  array_push($theme_advanced_buttons, "strikethrough");
450  }
451  if (count($theme_advanced_buttons)) {
452  array_push($theme_advanced_buttons, "|");
453  }
454  if (in_array("p", $a_html_tags)) {
455  array_push($theme_advanced_buttons, "alignleft");
456  array_push($theme_advanced_buttons, "aligncenter");
457  array_push($theme_advanced_buttons, "alignright");
458  array_push($theme_advanced_buttons, "alignjustify");
459  array_push($theme_advanced_buttons, "|");
460  }
461  if (strlen(ilTinyMCE::_buildAdvancedBlockformatsFromHTMLTags($a_html_tags))) {
462  array_push($theme_advanced_buttons, "formatselect");
463  }
464  if (in_array("hr", $a_html_tags)) {
465  array_push($theme_advanced_buttons, "hr");
466  }
467  array_push($theme_advanced_buttons, "removeformat");
468  array_push($theme_advanced_buttons, "|");
469  if (in_array("sub", $a_html_tags)) {
470  array_push($theme_advanced_buttons, "subscript");
471  }
472  if (in_array("sup", $a_html_tags)) {
473  array_push($theme_advanced_buttons, "superscript");
474  }
475  if (in_array("font", $a_html_tags)) {
476  array_push($theme_advanced_buttons, "fontselect");
477  array_push($theme_advanced_buttons, "fontsizeselect");
478  }
479  array_push($theme_advanced_buttons, "charmap");
480  if ((in_array("ol", $a_html_tags)) && (in_array("li", $a_html_tags))) {
481  array_push($theme_advanced_buttons, "bullist");
482  }
483  if ((in_array("ul", $a_html_tags)) && (in_array("li", $a_html_tags))) {
484  array_push($theme_advanced_buttons, "numlist");
485  }
486  array_push($theme_advanced_buttons, "|");
487  if (in_array("cite", $a_html_tags)) {
488  array_push($theme_advanced_buttons, "blockquote");
489  }
490  if (in_array("abbr", $a_html_tags)) {
491  array_push($theme_advanced_buttons, "abbr");
492  }
493  if (in_array("acronym", $a_html_tags)) {
494  array_push($theme_advanced_buttons, "acronym");
495  }
496  if (in_array("del", $a_html_tags)) {
497  array_push($theme_advanced_buttons, "del");
498  }
499  if (in_array("ins", $a_html_tags)) {
500  array_push($theme_advanced_buttons, "ins");
501  }
502  if (in_array("blockquote", $a_html_tags)) {
503  array_push($theme_advanced_buttons, "indent");
504  array_push($theme_advanced_buttons, "outdent");
505  }
506  if (in_array("img", $a_html_tags)) {
507  //array_push($theme_advanced_buttons, "advimage");
508  array_push($theme_advanced_buttons, "image");
509  array_push($theme_advanced_buttons, "ibrowser");
510  array_push($theme_advanced_buttons, "ilimgupload");
511  }
512  if (in_array("a", $a_html_tags)) {
513  array_push($theme_advanced_buttons, "link");
514  array_push($theme_advanced_buttons, "unlink");
515  array_push($theme_advanced_buttons, "anchor");
516  }
517  array_push($theme_advanced_buttons, "|");
518  array_push($theme_advanced_buttons, "undo");
519  array_push($theme_advanced_buttons, "redo");
520 
521  if (is_array($this->buttons) && count($this->buttons)) {
522  array_push($theme_advanced_buttons, "|");
523  foreach ($this->buttons as $button) {
524  array_push($theme_advanced_buttons, $button);
525  }
526  }
527 
528  array_push($theme_advanced_buttons, "code");
529  array_push($theme_advanced_buttons, "fullscreen");
530 
531  // Changed in elba2 branch, adopted change for 4.2.x due to manits bug #8147
532  array_push($theme_advanced_buttons, "pasteword");
533  } elseif ($a_buttons_section == 2) {
534  array_push($theme_advanced_buttons, "cut");
535  array_push($theme_advanced_buttons, "copy");
536  array_push($theme_advanced_buttons, "paste");
537  array_push($theme_advanced_buttons, "pastetext");
538  // Changed in elba2 branch, adopted change for 4.2.x due to manits bug #8147
539  //array_push($theme_advanced_buttons, "pasteword");
540  } elseif ($a_buttons_section == 3) {
541  }
542 
543  $remove_buttons = $this->getDisabledButtons();
544  if (is_array($remove_buttons)) {
545  foreach ($remove_buttons as $buttontext) {
546  if (($res = array_search($buttontext, $theme_advanced_buttons)) !== false) {
547  unset($theme_advanced_buttons[$res]);
548  }
549  }
550  }
551 
552  return join(" ", $theme_advanced_buttons);
553  }
554 
559  protected function _buildButtonsFromHTMLTags(array $a_html_tags)
560  {
561  $theme_advanced_buttons = array();
562  if (in_array("strong", $a_html_tags)) {
563  array_push($theme_advanced_buttons, "bold");
564  }
565  if (in_array("em", $a_html_tags)) {
566  array_push($theme_advanced_buttons, "italic");
567  }
568  if (in_array("u", $a_html_tags)) {
569  array_push($theme_advanced_buttons, "underline");
570  }
571  if (in_array("strike", $a_html_tags)) {
572  array_push($theme_advanced_buttons, "strikethrough");
573  }
574  if (in_array("p", $a_html_tags)) {
575  array_push($theme_advanced_buttons, "alignleft");
576  array_push($theme_advanced_buttons, "aligncenter");
577  array_push($theme_advanced_buttons, "alignright");
578  array_push($theme_advanced_buttons, "alignjustify");
579  }
580  if (strlen(ilTinyMCE::_buildAdvancedBlockformatsFromHTMLTags($a_html_tags))) {
581  array_push($theme_advanced_buttons, "formatselect");
582  }
583  if (in_array("hr", $a_html_tags)) {
584  array_push($theme_advanced_buttons, "hr");
585  }
586  if (in_array("sub", $a_html_tags)) {
587  array_push($theme_advanced_buttons, "subscript");
588  }
589  if (in_array("sup", $a_html_tags)) {
590  array_push($theme_advanced_buttons, "superscript");
591  }
592  if (in_array("font", $a_html_tags)) {
593  array_push($theme_advanced_buttons, "fontselect");
594  array_push($theme_advanced_buttons, "fontsizeselect");
595  }
596  if ((in_array("ol", $a_html_tags)) && (in_array("li", $a_html_tags))) {
597  array_push($theme_advanced_buttons, "bullist");
598  }
599  if ((in_array("ul", $a_html_tags)) && (in_array("li", $a_html_tags))) {
600  array_push($theme_advanced_buttons, "numlist");
601  }
602  if (in_array("cite", $a_html_tags)) {
603  array_push($theme_advanced_buttons, "blockquote");
604  }
605  if (in_array("abbr", $a_html_tags)) {
606  array_push($theme_advanced_buttons, "abbr");
607  }
608  if (in_array("acronym", $a_html_tags)) {
609  array_push($theme_advanced_buttons, "acronym");
610  }
611  if (in_array("del", $a_html_tags)) {
612  array_push($theme_advanced_buttons, "del");
613  }
614  if (in_array("ins", $a_html_tags)) {
615  array_push($theme_advanced_buttons, "ins");
616  }
617  if (in_array("blockquote", $a_html_tags)) {
618  array_push($theme_advanced_buttons, "indent");
619  array_push($theme_advanced_buttons, "outdent");
620  }
621  if (in_array("img", $a_html_tags)) {
622  //array_push($theme_advanced_buttons, "advimage");
623  array_push($theme_advanced_buttons, "image");
624  array_push($theme_advanced_buttons, "ibrowser");
625  array_push($theme_advanced_buttons, "ilimgupload");
626  }
627  if (in_array("a", $a_html_tags)) {
628  array_push($theme_advanced_buttons, "link");
629  array_push($theme_advanced_buttons, "unlink");
630  array_push($theme_advanced_buttons, "anchor");
631  }
632 
633  $remove_buttons = $this->getDisabledButtons();
634  if (is_array($remove_buttons)) {
635  foreach ($remove_buttons as $buttontext) {
636  if (($res = array_search($buttontext, $theme_advanced_buttons)) !== false) {
637  unset($theme_advanced_buttons[$res]);
638  }
639  }
640  }
641 
642  return join(" ", $theme_advanced_buttons);
643  }
644 
649  public function _buildAdvancedTableButtonsFromHTMLTags(array $a_html_tags)
650  {
651  $theme_advanced_buttons = array();
652  if (in_array("table", $a_html_tags) && in_array("tr", $a_html_tags) && in_array("td", $a_html_tags)) {
653  array_push($theme_advanced_buttons, "table");
654  }
655 
656  $remove_buttons = $this->getDisabledButtons();
657  if (is_array($remove_buttons)) {
658  foreach ($remove_buttons as $buttontext) {
659  if (($res = array_search($buttontext, $theme_advanced_buttons)) !== false) {
660  unset($theme_advanced_buttons[$res]);
661  }
662  }
663  }
664 
665  return join(",", $theme_advanced_buttons);
666  }
667 
668  protected function _getEditorLanguage()
669  {
670  $lang = $this->user->getLanguage();
671  $langtiny = $lang;
672  //Language files in tinymce and ILIAS have different nomenclatures: adjust the differences
673  switch ($lang) {
674  case "hu":
675  $langtiny = "hu_HU";
676  break;
677  case "zh":
678  $langtiny = "zh_CN";
679  break;
680  case "he":
681  $langtiny = "he_IL";
682  break;
683 
684  default:
685  //do nothing
686  }
687  if (file_exists("./node_modules/tinymce/langs/$langtiny.js")) {
688  return "$langtiny";
689  } else {
690  return "en";
691  }
692  }
693 
698  public function _getValidElementsFromHTMLTags(array $a_html_tags)
699  {
700  $valid_elements = array();
701  foreach ($a_html_tags as $tag) {
702  switch ($tag) {
703  case "a":
704  array_push($valid_elements, "a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name"
705  . "|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
706  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev"
707  . "|shape<circle?default?poly?rect|style|tabindex|title|target|type]");
708  break;
709  case "abbr":
710  array_push($valid_elements, "abbr[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
711  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
712  . "|title]");
713  break;
714  case "acronym":
715  array_push($valid_elements, "acronym[class|dir<ltr?rtl|id|id|lang|onclick|ondblclick|onkeydown|onkeypress"
716  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
717  . "|title]");
718  break;
719  case "address":
720  array_push($valid_elements, "address[class|align|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
721  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
722  . "|onmouseup|style|title]");
723  break;
724  case "applet":
725  array_push($valid_elements, "applet[align<bottom?left?middle?right?top|alt|archive|class|code|codebase"
726  . "|height|hspace|id|name|object|style|title|vspace|width]");
727  break;
728  case "area":
729  array_push($valid_elements, "area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref"
730  . "|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
731  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup"
732  . "|shape<circle?default?poly?rect|style|tabindex|title|target]");
733  break;
734  case "base":
735  array_push($valid_elements, "base[href|target]");
736  break;
737  case "basefont":
738  array_push($valid_elements, "basefont[color|face|id|size]");
739  break;
740  case "bdo":
741  array_push($valid_elements, "bdo[class|dir<ltr?rtl|id|lang|style|title]");
742  break;
743  case "big":
744  array_push($valid_elements, "big[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
745  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
746  . "|title]");
747  break;
748  case "blockquote":
749  array_push($valid_elements, "blockquote[dir|style|cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick"
750  . "|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
751  . "|onmouseover|onmouseup|style|title]");
752  break;
753  case "body":
754  array_push($valid_elements, "body[alink|background|bgcolor|class|dir<ltr?rtl|id|lang|link|onclick"
755  . "|ondblclick|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove"
756  . "|onmouseout|onmouseover|onmouseup|onunload|style|title|text|vlink]");
757  break;
758  case "br":
759  array_push($valid_elements, "br[class|clear<all?left?none?right|id|style|title]");
760  break;
761  case "button":
762  array_push($valid_elements, "button[accesskey|class|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur"
763  . "|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown"
764  . "|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex|title|type"
765  . "|value]");
766  break;
767  case "caption":
768  array_push($valid_elements, "caption[align<bottom?left?right?top|class|dir<ltr?rtl|id|lang|onclick"
769  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
770  . "|onmouseout|onmouseover|onmouseup|style|title]");
771  break;
772  case "center":
773  array_push($valid_elements, "center[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
774  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
775  . "|title]");
776  break;
777  case "cite":
778  array_push($valid_elements, "cite[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
779  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
780  . "|title]");
781  break;
782  case "code":
783  array_push($valid_elements, "code[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
784  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
785  . "|title]");
786  break;
787  case "col":
788  array_push($valid_elements, "col[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
789  . "|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
790  . "|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title"
791  . "|valign<baseline?bottom?middle?top|width]");
792  break;
793  case "colgroup":
794  array_push($valid_elements, "colgroup[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl"
795  . "|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
796  . "|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title"
797  . "|valign<baseline?bottom?middle?top|width]");
798  break;
799  case "dd":
800  array_push($valid_elements, "dd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
801  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]");
802  break;
803  case "del":
804  array_push($valid_elements, "del[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
805  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
806  . "|onmouseup|style|title]");
807  break;
808  case "dfn":
809  array_push($valid_elements, "dfn[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
810  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
811  . "|title]");
812  break;
813  case "dir":
814  array_push($valid_elements, "dir[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
815  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
816  . "|onmouseup|style|title]");
817  break;
818  case "div":
819  array_push($valid_elements, "div[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
820  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
821  . "|onmouseout|onmouseover|onmouseup|style|title]");
822  break;
823  case "dl":
824  array_push($valid_elements, "dl[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
825  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
826  . "|onmouseup|style|title]");
827  break;
828  case "dt":
829  array_push($valid_elements, "dt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
830  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]");
831  break;
832  case "em":
833  array_push($valid_elements, "em/i[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
834  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
835  . "|title]");
836  break;
837  case "fieldset":
838  array_push($valid_elements, "fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
839  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
840  . "|title]");
841  break;
842  case "font":
843  array_push($valid_elements, "font[class|color|dir<ltr?rtl|face|id|lang|size|style|title]");
844  break;
845  case "form":
846  array_push($valid_elements, "form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang"
847  . "|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
848  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit"
849  . "|style|title|target]");
850  break;
851  case "frame":
852  array_push($valid_elements, "frame[class|frameborder|id|longdesc|marginheight|marginwidth|name"
853  . "|noresize<noresize|scrolling<auto?no?yes|src|style|title]");
854  break;
855  case "frameset":
856  array_push($valid_elements, "frameset[class|cols|id|onload|onunload|rows|style|title]");
857  break;
858  case "h1":
859  array_push($valid_elements, "h1[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
860  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
861  . "|onmouseout|onmouseover|onmouseup|style|title]");
862  break;
863  case "h2":
864  array_push($valid_elements, "h2[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
865  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
866  . "|onmouseout|onmouseover|onmouseup|style|title]");
867  break;
868  case "h3":
869  array_push($valid_elements, "h3[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
870  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
871  . "|onmouseout|onmouseover|onmouseup|style|title]");
872  break;
873  case "h4":
874  array_push($valid_elements, "h4[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
875  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
876  . "|onmouseout|onmouseover|onmouseup|style|title]");
877  break;
878  case "h5":
879  array_push($valid_elements, "h5[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
880  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
881  . "|onmouseout|onmouseover|onmouseup|style|title]");
882  break;
883  case "h6":
884  array_push($valid_elements, "h6[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
885  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
886  . "|onmouseout|onmouseover|onmouseup|style|title]");
887  break;
888  case "head":
889  array_push($valid_elements, "head[dir<ltr?rtl|lang|profile]");
890  break;
891  case "hr":
892  array_push($valid_elements, "hr[align<center?left?right|class|dir<ltr?rtl|id|lang|noshade<noshade|onclick"
893  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
894  . "|onmouseout|onmouseover|onmouseup|size|style|title|width]");
895  break;
896  case "html":
897  array_push($valid_elements, "html[dir<ltr?rtl|lang|version]");
898  break;
899  case "iframe":
900  array_push($valid_elements, "iframe[align<bottom?left?middle?right?top|class|frameborder|height|id"
901  . "|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style"
902  . "|title|width]");
903  break;
904  case "img":
905  array_push($valid_elements, "img[align<bottom?left?middle?right?top|alt|border|class|dir<ltr?rtl|height"
906  . "|hspace|id|ismap<ismap|lang|longdesc|name|onclick|ondblclick|onkeydown"
907  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
908  . "|onmouseup|src|style|title|usemap|vspace|width]");
909  break;
910  case "input":
911  array_push($valid_elements, "input[accept|accesskey|align<bottom?left?middle?right?top|alt"
912  . "|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang"
913  . "|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress"
914  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect"
915  . "|readonly<readonly|size|src|style|tabindex|title"
916  . "|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text"
917  . "|usemap|value]");
918  break;
919  case "ins":
920  array_push($valid_elements, "ins[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
921  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
922  . "|onmouseup|style|title]");
923  break;
924  case "isindex":
925  array_push($valid_elements, "isindex[class|dir<ltr?rtl|id|lang|prompt|style|title]");
926  break;
927  case "kbd":
928  array_push($valid_elements, "kbd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
929  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
930  . "|title]");
931  break;
932  case "label":
933  array_push($valid_elements, "label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick"
934  . "|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
935  . "|onmouseover|onmouseup|style|title]");
936  break;
937  case "legend":
938  array_push($valid_elements, "legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang"
939  . "|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
940  . "|onmouseout|onmouseover|onmouseup|style|title]");
941  break;
942  case "li":
943  array_push($valid_elements, "li[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
944  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type"
945  . "|value]");
946  break;
947  case "link":
948  array_push($valid_elements, "link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick"
949  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
950  . "|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type]");
951  break;
952  case "map":
953  array_push($valid_elements, "map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress"
954  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
955  . "|title]");
956  break;
957  case "menu":
958  array_push($valid_elements, "menu[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
959  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
960  . "|onmouseup|style|title]");
961  break;
962  case "meta":
963  array_push($valid_elements, "meta[content|dir<ltr?rtl|http-equiv|lang|name|scheme]");
964  break;
965  case "noframes":
966  array_push($valid_elements, "noframes[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
967  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
968  . "|title]");
969  break;
970  case "noscript":
971  array_push($valid_elements, "noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
972  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
973  . "|title]");
974  break;
975  case "object":
976  array_push($valid_elements, "object[align<bottom?left?middle?right?top|archive|border|class|classid"
977  . "|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name"
978  . "|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
979  . "|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap"
980  . "|vspace|width]");
981  break;
982  case "ol":
983  array_push($valid_elements, "ol[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
984  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
985  . "|onmouseup|start|style|title|type]");
986  break;
987  case "optgroup":
988  array_push($valid_elements, "optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick"
989  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
990  . "|onmouseout|onmouseover|onmouseup|style|title]");
991  break;
992  case "option":
993  array_push($valid_elements, "option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick"
994  . "|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
995  . "|onmouseover|onmouseup|selected<selected|style|title|value]");
996  break;
997  case "p":
998  array_push($valid_elements, "p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick"
999  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
1000  . "|onmouseout|onmouseover|onmouseup|style|title]");
1001  break;
1002  case "param":
1003  array_push($valid_elements, "param[id|name|type|value|valuetype<DATA?OBJECT?REF]");
1004  break;
1005  case "pre":
1006  case "listing":
1007  case "plaintext":
1008  case "xmp":
1009  array_push($valid_elements, "pre/listing/plaintext/xmp[align|class|dir<ltr?rtl|id|lang|onclick|ondblclick"
1010  . "|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout"
1011  . "|onmouseover|onmouseup|style|title|width]");
1012  break;
1013  case "q":
1014  array_push($valid_elements, "q[cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1015  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1016  . "|title]");
1017  break;
1018  case "s":
1019  array_push($valid_elements, "s[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
1020  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]");
1021  break;
1022  case "samp":
1023  array_push($valid_elements, "samp[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1024  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1025  . "|title]");
1026  break;
1027  case "script":
1028  array_push($valid_elements, "script[charset|defer|language|src|type]");
1029  break;
1030  case "select":
1031  array_push($valid_elements, "select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name"
1032  . "|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
1033  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style"
1034  . "|tabindex|title]");
1035  break;
1036  case "small":
1037  array_push($valid_elements, "small[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1038  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1039  . "|title]");
1040  break;
1041  case "span":
1042  array_push($valid_elements, "span[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
1043  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
1044  . "|onmouseup|style|title]");
1045  break;
1046  case "strike":
1047  array_push($valid_elements, "strike[class|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
1048  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
1049  . "|onmouseup|style|title]");
1050  break;
1051  case "strong":
1052  array_push($valid_elements, "strong/b[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1053  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1054  . "|title]");
1055  break;
1056  case "style":
1057  array_push($valid_elements, "style[dir<ltr?rtl|lang|media|title|type]");
1058  break;
1059  case "sub":
1060  array_push($valid_elements, "sub[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1061  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1062  . "|title]");
1063  break;
1064  case "sup":
1065  array_push($valid_elements, "sup[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1066  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1067  . "|title]");
1068  break;
1069  case "table":
1070  array_push($valid_elements, "table[align<center?left?right|bgcolor|border|cellpadding|cellspacing|class"
1071  . "|dir<ltr?rtl|frame|height|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1072  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rules"
1073  . "|style|summary|title|width]");
1074  break;
1075  case "tbody":
1076  array_push($valid_elements, "tbody[align<center?char?justify?left?right|char|class|charoff|dir<ltr?rtl|id"
1077  . "|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
1078  . "|onmousemove|onmouseout|onmouseover|onmouseup|style|title"
1079  . "|valign<baseline?bottom?middle?top]");
1080  break;
1081  case "td":
1082  array_push($valid_elements, "td[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
1083  . "|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick"
1084  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
1085  . "|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup"
1086  . "|style|title|valign<baseline?bottom?middle?top|width]");
1087  break;
1088  case "textarea":
1089  array_push($valid_elements, "textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name"
1090  . "|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup"
1091  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect"
1092  . "|readonly<readonly|rows|style|tabindex|title]");
1093  break;
1094  case "tfoot":
1095  array_push($valid_elements, "tfoot[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
1096  . "|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
1097  . "|onmousemove|onmouseout|onmouseover|onmouseup|style|title"
1098  . "|valign<baseline?bottom?middle?top]");
1099  break;
1100  case "th":
1101  array_push($valid_elements, "th[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
1102  . "|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick"
1103  . "|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
1104  . "|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup"
1105  . "|style|title|valign<baseline?bottom?middle?top|width]");
1106  break;
1107  case "thead":
1108  array_push($valid_elements, "thead[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id"
1109  . "|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown"
1110  . "|onmousemove|onmouseout|onmouseover|onmouseup|style|title"
1111  . "|valign<baseline?bottom?middle?top]");
1112  break;
1113  case "title":
1114  array_push($valid_elements, "title[dir<ltr?rtl|lang]");
1115  break;
1116  case "tr":
1117  array_push($valid_elements, "tr[abbr|align<center?char?justify?left?right|bgcolor|char|charoff|class"
1118  . "|rowspan|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1119  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1120  . "|title|valign<baseline?bottom?middle?top]");
1121  break;
1122  case "tt":
1123  array_push($valid_elements, "tt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
1124  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]");
1125  break;
1126  case "u":
1127  array_push($valid_elements, "u[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
1128  . "|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]");
1129 
1130  // Bugfix #5945: Necessary because TinyMCE does not use the "u"
1131  // html element but <span style="text-decoration: underline">E</span>
1132  array_push($valid_elements, "span[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
1133  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
1134  . "|onmouseup|style|title]");
1135  break;
1136  case "ul":
1137  array_push($valid_elements, "ul[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown"
1138  . "|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover"
1139  . "|onmouseup|style|title|type]");
1140  break;
1141  case "var":
1142  array_push($valid_elements, "var[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress"
1143  . "|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style"
1144  . "|title]");
1145  break;
1146  }
1147  }
1148  return join(",", $valid_elements);
1149  }
1150 
1156  public static function removeRedundantSeparators($a_string)
1157  {
1158  while (strpos($a_string, '| |') !== false) {
1159  $a_string = str_replace('| |', '|', $a_string);
1160  }
1161 
1162  while (strpos($a_string, ',,') !== false) {
1163  $a_string = str_replace(',,', ',', $a_string);
1164  }
1165  while (strpos($a_string, 'separator') !== false) {
1166  $a_string = str_replace('separator', '|', $a_string);
1167  }
1168  while (strpos($a_string, ',') !== false) {
1169  $a_string = str_replace(',', ' ', $a_string);
1170  }
1171 
1172  if ($a_string[0] == ',') {
1173  $a_string = (string) substr($a_string, 1);
1174  }
1175 
1176  if (strlen($a_string) && $a_string[strlen($a_string) - 1] == ',') {
1177  $a_string = substr($a_string, 0, strlen($a_string) - 1);
1178  }
1179  //image uploader button keeps appearing twice: remove the duplicates
1180  if (strlen($a_string) && substr_count($a_string, 'ilimgupload') > 1) {
1181  $arr = explode('ilimgupload', $a_string, 2);
1182  $a_string = $arr[0];
1183  if (count($arr) > 1) {
1184  $a_string = $a_string . ' ilimgupload ' . str_replace('ilimgupload', '', $arr[1]);
1185  }
1186  }
1187 
1188 
1189  return $a_string;
1190  }
1191 
1196  {
1197  $this->remove_img_context_menu_item = $remove_img_context_menu_item;
1198  }
1199 
1204  {
1206  }
1207 }
addUserTextEditor($editor_selector)
{}
_buildAdvancedButtonsFromHTMLTags($a_buttons_section, array $a_html_tags)
removeAllContextMenuItems()
removeAllContextMenuItems
handleImagePluginsBeforeRendering(array $tags)
setStyleSelect($a_styleselect)
Set Enable Style Selecttion.
getStyleSelect()
Get Enable Style Selecttion.
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$tinyMCE_valid_imgs
Definition: imgupload.php:41
disableButtons($a_button)
Sets buttons which should be disabled in the RTE.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
static getNewContentStyleSheetLocation($mode="output")
get full style sheet file name (path inclusive) of current user
addCustomRTESupport($obj_id, $obj_type, array $tags)
{}
removePlugin($a_plugin_name)
{}
static getFileSizeInfo()
_buildButtonsFromHTMLTags(array $a_html_tags)
static _setRichTextEditorUserState($a_state)
Sets the state of the rich text editor visibility for the current user.
getInitialWidth()
user()
Definition: user.php:4
static removeRedundantSeparators($a_string)
Removes redundant seperators and removes ,, and , at the first or last position of the string...
__construct($a_version='')
{}
handleIliasImageManagerAdded()
Rich Text Editor base class This class provides access methods to a Rich Text Editor (RTE) integrated...
Definition: class.ilRTE.php:12
Tiny MCE editor class.
foreach($_POST as $key=> $value) $res
touchBlock($block)
overwrites ITX::touchBlock.
_buildAdvancedTableButtonsFromHTMLTags(array $a_html_tags)
const CLIENT_ID
Definition: constants.php:39
global $DIC
Definition: goto.php:24
addPlugin($a_plugin_name)
{}
addRTESupport($obj_id, $obj_type, $a_module="", $allowFormElements=false, $cfg_template=null, $hide_switch=false)
{}
$lang
Definition: xapiexit.php:8
blockExists($a_blockname)
check if block exists in actual template private
addInternalTinyMCEImageManager()
getRTERootBlockElement()
Getter for the RTE root block element.
__construct(Container $dic, ilPlugin $plugin)
static _getRichTextEditorUserState()
Gets the state of the rich text editor visibility for the current user.
getButtonsForUserTextEditor(array $buttontags)
handleImgContextMenuItem(ilTemplate $tpl)
getDisabledButtons($as_array=true)
Returns the disabled RTE buttons.
getRemoveImgContextMenuItem()
handleIliasImageManagerRemoved()
$_COOKIE[session_name()]
Definition: xapitoken.php:37
static $renderedToGlobalTemplate
_buildAdvancedBlockformatsFromHTMLTags(array $a_html_tags)
_getValidElementsFromHTMLTags(array $a_html_tags)
addContextmenuItem(string $item="")
addContextmenuItem
$remove_img_context_menu_item
setRemoveImgContextMenuItem($remove_img_context_menu_item)