form.php 3.8 KB

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