No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

printDefinition.php 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. require_once 'common.php'; // load library
  3. require_once 'HTMLPurifier/Printer/HTMLDefinition.php';
  4. require_once 'HTMLPurifier/Printer/CSSDefinition.php';
  5. require_once 'HTMLPurifier/Printer/ConfigForm.php';
  6. $config = HTMLPurifier_Config::loadArrayFromForm($_GET, 'config', 'HTML');
  7. // you can do custom configuration!
  8. if (file_exists('printDefinition.settings.php')) {
  9. include 'printDefinition.settings.php';
  10. }
  11. $gen_config = HTMLPurifier_Config::createDefault();
  12. $printer_html_definition = new HTMLPurifier_Printer_HTMLDefinition();
  13. $printer_html_definition->prepareGenerator($gen_config);
  14. $printer_css_definition = new HTMLPurifier_Printer_CSSDefinition();
  15. $printer_css_definition->prepareGenerator($gen_config);
  16. $printer_config_form = new HTMLPurifier_Printer_ConfigForm(
  17. 'config',
  18. 'http://htmlpurifier.org/live/configdoc/plain.html#%s'
  19. );
  20. echo '<?xml version="1.0" encoding="UTF-8" ?>';
  21. ?>
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  23. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  24. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  25. <head>
  26. <title>HTML Purifier Printer Smoketest</title>
  27. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  28. <style type="text/css">
  29. .hp-config {margin-left:auto; margin-right:auto;}
  30. .HTMLPurifier_Printer table {border-collapse:collapse;
  31. border:1px solid #000; width:600px;
  32. margin:1em auto;font-family:sans-serif;font-size:75%;}
  33. .HTMLPurifier_Printer td, .HTMLPurifier_Printer th {padding:3px;
  34. border:1px solid #000;background:#CCC; vertical-align: baseline;}
  35. .HTMLPurifier_Printer th {text-align:left;background:#CCF;width:20%;}
  36. .HTMLPurifier_Printer caption {font-size:1.5em; font-weight:bold;}
  37. .HTMLPurifier_Printer .heavy {background:#99C;text-align:center;}
  38. .HTMLPurifier_Printer .unsafe {background:#C99;}
  39. dt {font-weight:bold;}
  40. </style>
  41. <link rel="stylesheet" href="../library/HTMLPurifier/Printer/ConfigForm.css" type="text/css" />
  42. <script defer="defer" type="text/javascript" src="../library/HTMLPurifier/Printer/ConfigForm.js"></script>
  43. </head>
  44. <body>
  45. <h1>HTML Purifier Printer Smoketest</h1>
  46. <p>HTML Purifier claims to have a robust yet permissive whitelist: this
  47. page will allow you to see precisely what HTML Purifier's internal
  48. whitelist is. You can
  49. also twiddle with the configuration settings to see how a directive
  50. influences the internal workings of the definition objects.</p>
  51. <h2>Modify configuration</h2>
  52. <p>You can specify an array by typing in a comma-separated
  53. list of items, HTML Purifier will take care of the rest (including
  54. transformation into a real array list or a lookup table).</p>
  55. <form method="get" action="" name="hp-configform">
  56. <?php
  57. echo $printer_config_form->render($config, 'HTML');
  58. ?>
  59. <p>* Some configuration directives make a distinction between an empty
  60. variable and a null variable. A whitelist, for example, will take an
  61. empty array as meaning <em>no</em> allowed elements, while checking
  62. Null/Disabled will mean that user whitelisting functionality is disabled.</p>
  63. </form>
  64. <h2>Definitions</h2>
  65. <dl>
  66. <dt>Parent of Fragment</dt>
  67. <dd>HTML that HTML Purifier does not live in a void: when it's
  68. output, it has to be placed in another element by means of
  69. something like <code>&lt;element&gt; &lt;?php echo $html
  70. ?&gt; &lt;/element&gt;</code>. The parent in this example
  71. is <code>element</code>.</dd>
  72. <dt>Strict mode</dt>
  73. <dd>Whether or not HTML Purifier's output is Transitional or
  74. Strict compliant. Non-strict mode still actually a little strict
  75. and converts many deprecated elements.</dd>
  76. <dt>#PCDATA</dt>
  77. <dd>Literally <strong>Parsed Character Data</strong>, it is regular
  78. text. Tags like <code>ul</code> don't allow text in them, so
  79. #PCDATA is missing.</dd>
  80. <dt>Tag transform</dt>
  81. <dd>A tag transform will change one tag to another. Example: <code>font</code>
  82. turns into a <code>span</code> tag with appropriate CSS.</dd>
  83. <dt>Attr Transform</dt>
  84. <dd>An attribute transform changes a group of attributes based on one
  85. another. Currently, only <code>lang</code> and <code>xml:lang</code>
  86. use this hook, to synchronize each other's values. Pre/Post indicates
  87. whether or not the transform is done before/after validation.</dd>
  88. <dt>Excludes</dt>
  89. <dd>Tags that an element excludes are excluded for all descendants of
  90. that element, and not just the children of them.</dd>
  91. <dt>Name(Param1, Param2)</dt>
  92. <dd>Represents an internal data-structure. You'll have to check out
  93. the corresponding classes in HTML Purifier to find out more.</dd>
  94. </dl>
  95. <h2>HTMLDefinition</h2>
  96. <?php echo $printer_html_definition->render($config) ?>
  97. <h2>CSSDefinition</h2>
  98. <?php echo $printer_css_definition->render($config) ?>
  99. </body>
  100. </html>
  101. <?php
  102. // vim: et sw=4 sts=4