Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. /**
  20. * @type string
  21. */
  22. public $name = 'Legacy';
  23. /**
  24. * @param HTMLPurifier_Config $config
  25. */
  26. public function setup($config)
  27. {
  28. $this->addElement(
  29. 'basefont',
  30. 'Inline',
  31. 'Empty',
  32. null,
  33. array(
  34. 'color' => 'Color',
  35. 'face' => 'Text', // extremely broad, we should
  36. 'size' => 'Text', // tighten it
  37. 'id' => 'ID'
  38. )
  39. );
  40. $this->addElement('center', 'Block', 'Flow', 'Common');
  41. $this->addElement(
  42. 'dir',
  43. 'Block',
  44. 'Required: li',
  45. 'Common',
  46. array(
  47. 'compact' => 'Bool#compact'
  48. )
  49. );
  50. $this->addElement(
  51. 'font',
  52. 'Inline',
  53. 'Inline',
  54. array('Core', 'I18N'),
  55. array(
  56. 'color' => 'Color',
  57. 'face' => 'Text', // extremely broad, we should
  58. 'size' => 'Text', // tighten it
  59. )
  60. );
  61. $this->addElement(
  62. 'menu',
  63. 'Block',
  64. 'Required: li',
  65. 'Common',
  66. array(
  67. 'compact' => 'Bool#compact'
  68. )
  69. );
  70. $s = $this->addElement('s', 'Inline', 'Inline', 'Common');
  71. $s->formatting = true;
  72. $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common');
  73. $strike->formatting = true;
  74. $u = $this->addElement('u', 'Inline', 'Inline', 'Common');
  75. $u->formatting = true;
  76. // setup modifications to old elements
  77. $align = 'Enum#left,right,center,justify';
  78. $address = $this->addBlankElement('address');
  79. $address->content_model = 'Inline | #PCDATA | p';
  80. $address->content_model_type = 'optional';
  81. $address->child = false;
  82. $blockquote = $this->addBlankElement('blockquote');
  83. $blockquote->content_model = 'Flow | #PCDATA';
  84. $blockquote->content_model_type = 'optional';
  85. $blockquote->child = false;
  86. $br = $this->addBlankElement('br');
  87. $br->attr['clear'] = 'Enum#left,all,right,none';
  88. $caption = $this->addBlankElement('caption');
  89. $caption->attr['align'] = 'Enum#top,bottom,left,right';
  90. $div = $this->addBlankElement('div');
  91. $div->attr['align'] = $align;
  92. $dl = $this->addBlankElement('dl');
  93. $dl->attr['compact'] = 'Bool#compact';
  94. for ($i = 1; $i <= 6; $i++) {
  95. $h = $this->addBlankElement("h$i");
  96. $h->attr['align'] = $align;
  97. }
  98. $hr = $this->addBlankElement('hr');
  99. $hr->attr['align'] = $align;
  100. $hr->attr['noshade'] = 'Bool#noshade';
  101. $hr->attr['size'] = 'Pixels';
  102. $hr->attr['width'] = 'Length';
  103. $img = $this->addBlankElement('img');
  104. $img->attr['align'] = 'IAlign';
  105. $img->attr['border'] = 'Pixels';
  106. $img->attr['hspace'] = 'Pixels';
  107. $img->attr['vspace'] = 'Pixels';
  108. // figure out this integer business
  109. $li = $this->addBlankElement('li');
  110. $li->attr['value'] = new HTMLPurifier_AttrDef_Integer();
  111. $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle';
  112. $ol = $this->addBlankElement('ol');
  113. $ol->attr['compact'] = 'Bool#compact';
  114. $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer();
  115. $ol->attr['type'] = 'Enum#s:1,i,I,a,A';
  116. $p = $this->addBlankElement('p');
  117. $p->attr['align'] = $align;
  118. $pre = $this->addBlankElement('pre');
  119. $pre->attr['width'] = 'Number';
  120. // script omitted
  121. $table = $this->addBlankElement('table');
  122. $table->attr['align'] = 'Enum#left,center,right';
  123. $table->attr['bgcolor'] = 'Color';
  124. $tr = $this->addBlankElement('tr');
  125. $tr->attr['bgcolor'] = 'Color';
  126. $th = $this->addBlankElement('th');
  127. $th->attr['bgcolor'] = 'Color';
  128. $th->attr['height'] = 'Length';
  129. $th->attr['nowrap'] = 'Bool#nowrap';
  130. $th->attr['width'] = 'Length';
  131. $td = $this->addBlankElement('td');
  132. $td->attr['bgcolor'] = 'Color';
  133. $td->attr['height'] = 'Length';
  134. $td->attr['nowrap'] = 'Bool#nowrap';
  135. $td->attr['width'] = 'Length';
  136. $ul = $this->addBlankElement('ul');
  137. $ul->attr['compact'] = 'Bool#compact';
  138. $ul->attr['type'] = 'Enum#square,disc,circle';
  139. // "safe" modifications to "unsafe" elements
  140. // WARNING: If you want to add support for an unsafe, legacy
  141. // attribute, make a new TrustedLegacy module with the trusted
  142. // bit set appropriately
  143. $form = $this->addBlankElement('form');
  144. $form->content_model = 'Flow | #PCDATA';
  145. $form->content_model_type = 'optional';
  146. $form->attr['target'] = 'FrameTarget';
  147. $input = $this->addBlankElement('input');
  148. $input->attr['align'] = 'IAlign';
  149. $legend = $this->addBlankElement('legend');
  150. $legend->attr['align'] = 'LAlign';
  151. }
  152. }
  153. // vim: et sw=4 sts=4