PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/xoops_trust_path/vendor/htmlpurifier/library/HTMLPurifier/HTMLModule/Xcore.php

https://github.com/nouphet/momoxo
PHP | 143 lines | 91 code | 33 blank | 19 comment | 1 complexity | c16d5d026d46e64684a099be56350260 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * XHTML 1.1 Legacy module defines elements that were previously
  4. * deprecated.
  5. *
  6. * @note Not all Legacy elements have been implemented yet, which
  7. * is a bit of a reverse problem as compared to browsers! In
  8. * addition, this Legacy module may implement a bit more than
  9. * mandated by XHTML 1.1.
  10. *
  11. * This module can be used in combination with TransformToStrict in order
  12. * to transform as many deprecated elements as possible, but retain
  13. * questionably deprecated elements that do not have good alternatives
  14. * as well as transform elements that don't have an implementation.
  15. * See docs/ref-strictness.txt for more details.
  16. */
  17. class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
  18. {
  19. public $name = 'Xcore';
  20. public function setup($config) {
  21. $this->addElement('basefont', 'Inline', 'Empty', false, array(
  22. 'color' => 'Color',
  23. 'face' => 'Text', // extremely broad, we should
  24. 'size' => 'Text', // tighten it
  25. 'id' => 'ID'
  26. ));
  27. $this->addElement('center', 'Block', 'Flow', 'Common');
  28. $this->addElement('dir', 'Block', 'Required: li', 'Common', array(
  29. 'compact' => 'Bool#compact'
  30. ));
  31. $this->addElement('font', 'Inline', 'Inline', array('Core', 'I18N'), array(
  32. 'color' => 'Color',
  33. 'face' => 'Text', // extremely broad, we should
  34. 'size' => 'Text', // tighten it
  35. ));
  36. $this->addElement('menu', 'Block', 'Required: li', 'Common', array(
  37. 'compact' => 'Bool#compact'
  38. ));
  39. $s = $this->addElement('s', 'Inline', 'Inline', 'Common');
  40. $s->formatting = true;
  41. $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common');
  42. $strike->formatting = true;
  43. $u = $this->addElement('u', 'Inline', 'Inline', 'Common');
  44. $u->formatting = true;
  45. // setup modifications to old elements
  46. $align = 'Enum#left,right,center,justify';
  47. $address = $this->addBlankElement('address');
  48. $address->content_model = 'Inline | #PCDATA | p';
  49. $address->content_model_type = 'optional';
  50. $address->child = false;
  51. $blockquote = $this->addBlankElement('blockquote');
  52. $blockquote->content_model = 'Flow | #PCDATA';
  53. $blockquote->content_model_type = 'optional';
  54. $blockquote->child = false;
  55. $br = $this->addBlankElement('br');
  56. $br->attr['clear'] = 'Enum#left,all,right,none';
  57. $caption = $this->addBlankElement('caption');
  58. $caption->attr['align'] = 'Enum#top,bottom,left,right';
  59. $div = $this->addBlankElement('div');
  60. $div->attr['align'] = $align;
  61. $dl = $this->addBlankElement('dl');
  62. $dl->attr['compact'] = 'Bool#compact';
  63. for ($i = 1; $i <= 6; $i++) {
  64. $h = $this->addBlankElement("h$i");
  65. $h->attr['align'] = $align;
  66. }
  67. $hr = $this->addBlankElement('hr');
  68. $hr->attr['align'] = $align;
  69. $hr->attr['noshade'] = 'Bool#noshade';
  70. $hr->attr['size'] = 'Pixels';
  71. $hr->attr['width'] = 'Length';
  72. $img = $this->addBlankElement('img');
  73. $img->attr['align'] = 'Enum#top,middle,bottom,left,right';
  74. $img->attr['border'] = 'Pixels';
  75. $img->attr['hspace'] = 'Pixels';
  76. $img->attr['vspace'] = 'Pixels';
  77. // figure out this integer business
  78. $li = $this->addBlankElement('li');
  79. $li->attr['value'] = new HTMLPurifier_AttrDef_Integer();
  80. $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle';
  81. $ol = $this->addBlankElement('ol');
  82. $ol->attr['compact'] = 'Bool#compact';
  83. $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
  84. $ol->attr['type'] = 'Enum#s:1,i,I,a,A';
  85. $p = $this->addBlankElement('p');
  86. $p->attr['align'] = $align;
  87. $pre = $this->addBlankElement('pre');
  88. $pre->attr['width'] = 'Number';
  89. // script omitted
  90. $table = $this->addBlankElement('table');
  91. $table->attr['align'] = 'Enum#left,center,right';
  92. $table->attr['bgcolor'] = 'Color';
  93. $tr = $this->addBlankElement('tr');
  94. $tr->attr['bgcolor'] = 'Color';
  95. $th = $this->addBlankElement('th');
  96. $th->attr['bgcolor'] = 'Color';
  97. $th->attr['height'] = 'Length';
  98. $th->attr['nowrap'] = 'Bool#nowrap';
  99. $th->attr['width'] = 'Length';
  100. $td = $this->addBlankElement('td');
  101. $td->attr['bgcolor'] = 'Color';
  102. $td->attr['height'] = 'Length';
  103. $td->attr['nowrap'] = 'Bool#nowrap';
  104. $td->attr['width'] = 'Length';
  105. $ul = $this->addBlankElement('ul');
  106. $ul->attr['compact'] = 'Bool#compact';
  107. $ul->attr['type'] = 'Enum#square,disc,circle';
  108. }
  109. }
  110. // vim: et sw=4 sts=4