forked from ezyang/htmlpurifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Phorum] Refactor settings.php into different files.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1298 48356398-32a2-884e-a903-53898d9a118a
- Loading branch information
Edward Z. Yang
committed
Jun 29, 2007
1 parent
88d0147
commit 63f5414
Showing
7 changed files
with
263 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/** | ||
* Initializes the appropriate configuration from either a PHP file | ||
* or a module configuration value | ||
* @return Instance of HTMLPurifier_Config | ||
*/ | ||
function phorum_htmlpurifier_get_config() { | ||
global $PHORUM; | ||
$config_exists = phorum_htmlpurifier_config_file_exists(); | ||
if ($config_exists || !isset($PHORUM['mod_htmlpurifier']['config'])) { | ||
$config = HTMLPurifier_Config::createDefault(); | ||
include(dirname(__FILE__) . '/config.default.php'); | ||
if ($config_exists) { | ||
include(dirname(__FILE__) . '/config.php'); | ||
} | ||
unset($PHORUM['mod_htmlpurifier']['config']); // unnecessary | ||
} else { | ||
$config = HTMLPurifier_Config::create($PHORUM['mod_htmlpurifier']['config']); | ||
} | ||
return $config; | ||
} | ||
|
||
function phorum_htmlpurifier_config_file_exists() { | ||
return file_exists(dirname(__FILE__) . '/config.php'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
function phorum_htmlpurifier_show_form() { | ||
if (phorum_htmlpurifier_config_file_exists()) { | ||
phorum_htmlpurifier_show_config_info(); | ||
return; | ||
} | ||
|
||
global $PHORUM; | ||
|
||
$config = phorum_htmlpurifier_get_config(); | ||
|
||
$frm = new PhorumInputForm ("", "post", "Save"); | ||
$frm->hidden("module", "modsettings"); | ||
$frm->hidden("mod", "htmlpurifier"); // this is the directory name that the Settings file lives in | ||
|
||
if (!empty($error)){ | ||
echo "$error<br />"; | ||
} | ||
|
||
$frm->addbreak("Edit settings for the HTML Purifier module"); | ||
|
||
$frm->addMessage('<p>Click on directive links to read what each option does | ||
(links do not open in new windows).</p> | ||
<p>For more flexibility (for instance, you want to edit the full | ||
range of configuration directives), you can create a <tt>config.php</tt> | ||
file in your <tt>mods/htmlpurifier/</tt> directory. Doing so will, | ||
however, make the web configuration interface unavailable.</p>'); | ||
|
||
require_once 'HTMLPurifier/Printer/ConfigForm.php'; | ||
$htmlpurifier_form = new HTMLPurifier_Printer_ConfigForm('config', 'http://htmlpurifier.org/live/configdoc/plain.html#%s'); | ||
$htmlpurifier_form->setTextareaDimensions(23, 7); // widen a little, since we have space | ||
|
||
$frm->addMessage($htmlpurifier_form->render( | ||
$config, $PHORUM['mod_htmlpurifier']['directives'], false)); | ||
|
||
$frm->addMessage("<strong>Warning: Changing HTML Purifier's configuration will invalidate | ||
the cache. Expect to see a flurry of database activity after you change | ||
any of these settings.</strong>"); | ||
|
||
$frm->addrow('Reset to defaults:', $frm->checkbox("reset", "1", "", false)); | ||
|
||
// hack to include extra styling | ||
echo '<style type="text/css">' . $htmlpurifier_form->getCSS() . ' | ||
.hp-config {margin-left:auto;margin-right:auto;} | ||
</style>'; | ||
$js = $htmlpurifier_form->getJavaScript(); | ||
echo '<script type="text/javascript">'."<!--\n$js\n//-->".'</script>'; | ||
|
||
$frm->show(); | ||
} | ||
|
||
function phorum_htmlpurifier_show_config_info() { | ||
global $PHORUM; | ||
|
||
// update mod_htmlpurifier for housekeeping | ||
phorum_htmlpurifier_commit_settings(); | ||
|
||
// politely tell user how to edit settings manually | ||
?> | ||
<div class="input-form-td-break">How to edit settings for HTML Purifier module</div> | ||
<p> | ||
A <tt>config.php</tt> file exists in your <tt>mods/htmlpurifier/</tt> | ||
directory. This file contains your custom configuration: in order to | ||
change it, please navigate to that file and edit it accordingly. | ||
</p> | ||
<p> | ||
To use the web interface, delete <tt>config.php</tt> (or rename it to | ||
<tt>config.php.bak</tt>). | ||
</p> | ||
<p> | ||
<strong>Warning: Changing HTML Purifier's configuration will invalidate | ||
the cache. Expect to see a flurry of database activity after you change | ||
any of these settings.</strong> | ||
</p> | ||
<?php | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
function phorum_htmlpurifier_show_migrate_sigs_form() { | ||
|
||
$frm = new PhorumInputForm ('', "post", "Migrate"); | ||
$frm->hidden("module", "modsettings"); | ||
$frm->hidden("mod", "htmlpurifier"); | ||
$frm->hidden("migrate-sigs", "1"); | ||
$frm->addbreak("Migrate user signatures to HTML"); | ||
$frm->addMessage('This operation will migrate your users signatures | ||
to HTML. <strong>This process is irreversible and must only be performed once.</strong> | ||
Type in yes in the confirmation field to migrate.'); | ||
if (!file_exists(dirname(__FILE__) . '/../migrate.php')) { | ||
$frm->addMessage('Migration file does not exist, cannot migrate signatures. | ||
Please check <tt>migrate.bbcode.php</tt> on how to create an appropriate file.'); | ||
} else { | ||
$frm->addrow('Confirm:', $frm->text_box("confirmation", "")); | ||
} | ||
$frm->show(); | ||
} | ||
|
Oops, something went wrong.