form.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. function phorum_htmlpurifier_show_form() {
  3. if (phorum_htmlpurifier_config_file_exists()) {
  4. phorum_htmlpurifier_show_config_info();
  5. return;
  6. }
  7. global $PHORUM;
  8. $config = phorum_htmlpurifier_get_config();
  9. $frm = new PhorumInputForm ("", "post", "Save");
  10. $frm->hidden("module", "modsettings");
  11. $frm->hidden("mod", "htmlpurifier"); // this is the directory name that the Settings file lives in
  12. if (!empty($error)){
  13. echo "$error<br />";
  14. }
  15. $frm->addbreak("Edit settings for the HTML Purifier module");
  16. $frm->addMessage('<p>The box below sets <code>$PHORUM[\'mod_htmlpurifier\'][\'wysiwyg\']</code>.
  17. When checked, contents sent for edit are now purified and the
  18. informative message is disabled. If your WYSIWYG editor is disabled for
  19. admin edits, you can safely keep this unchecked.</p>');
  20. $frm->addRow('Use WYSIWYG?', $frm->checkbox('wysiwyg', '1', '', $PHORUM['mod_htmlpurifier']['wysiwyg']));
  21. $frm->addMessage('<p>The box below sets <code>$PHORUM[\'mod_htmlpurifier\'][\'suppress_message\']</code>,
  22. which removes the big how-to use
  23. HTML Purifier message.</p>');
  24. $frm->addRow('Suppress information?', $frm->checkbox('suppress_message', '1', '', $PHORUM['mod_htmlpurifier']['suppress_message']));
  25. $frm->addMessage('<p>Click on directive links to read what each option does
  26. (links do not open in new windows).</p>
  27. <p>For more flexibility (for instance, you want to edit the full
  28. range of configuration directives), you can create a <tt>config.php</tt>
  29. file in your <tt>mods/htmlpurifier/</tt> directory. Doing so will,
  30. however, make the web configuration interface unavailable.</p>');
  31. require_once 'HTMLPurifier/Printer/ConfigForm.php';
  32. $htmlpurifier_form = new HTMLPurifier_Printer_ConfigForm('config', 'http://htmlpurifier.org/live/configdoc/plain.html#%s');
  33. $htmlpurifier_form->setTextareaDimensions(23, 7); // widen a little, since we have space
  34. $frm->addMessage($htmlpurifier_form->render(
  35. $config, $PHORUM['mod_htmlpurifier']['directives'], false));
  36. $frm->addMessage("<strong>Warning: Changing HTML Purifier's configuration will invalidate
  37. the cache. Expect to see a flurry of database activity after you change
  38. any of these settings.</strong>");
  39. $frm->addrow('Reset to defaults:', $frm->checkbox("reset", "1", "", false));
  40. // hack to include extra styling
  41. echo '<style type="text/css">' . $htmlpurifier_form->getCSS() . '
  42. .hp-config {margin-left:auto;margin-right:auto;}
  43. </style>';
  44. $js = $htmlpurifier_form->getJavaScript();
  45. echo '<script type="text/javascript">'."<!--\n$js\n//-->".'</script>';
  46. $frm->show();
  47. }
  48. function phorum_htmlpurifier_show_config_info() {
  49. global $PHORUM;
  50. // update mod_htmlpurifier for housekeeping
  51. phorum_htmlpurifier_commit_settings();
  52. // politely tell user how to edit settings manually
  53. ?>
  54. <div class="input-form-td-break">How to edit settings for HTML Purifier module</div>
  55. <p>
  56. A <tt>config.php</tt> file exists in your <tt>mods/htmlpurifier/</tt>
  57. directory. This file contains your custom configuration: in order to
  58. change it, please navigate to that file and edit it accordingly.
  59. You can also set <code>$GLOBALS['PHORUM']['mod_htmlpurifier']['wysiwyg']</code>
  60. or <code>$GLOBALS['PHORUM']['mod_htmlpurifier']['suppress_message']</code>
  61. </p>
  62. <p>
  63. To use the web interface, delete <tt>config.php</tt> (or rename it to
  64. <tt>config.php.bak</tt>).
  65. </p>
  66. <p>
  67. <strong>Warning: Changing HTML Purifier's configuration will invalidate
  68. the cache. Expect to see a flurry of database activity after you change
  69. any of these settings.</strong>
  70. </p>
  71. <?php
  72. }
  73. // vim: et sw=4 sts=4