View source
<?php
function htmlpurifier_schema() {
$schema['cache_htmlpurifier'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_htmlpurifier']['description'] = t(<<<DESCRIPTION
Cache table for the HTML Purifier module just like cache_filter, except that
cached text is stored permanently until flushed or manually invalidated.
This helps prevent recurrent cache slams on pages with lots of segments of HTML.
DESCRIPTION
);
return $schema;
}
function htmlpurifier_install() {
_htmlpurifier_version_check();
drupal_install_schema('htmlpurifier');
}
function htmlpurifier_uninstall() {
drupal_uninstall_schema('htmlpurifier');
db_query("DELETE FROM {variable} WHERE name LIKE 'htmlpurifier%%'");
}
function _htmlpurifier_version_check() {
static $req_version = '3.1.0';
$module_path = dirname(__FILE__);
$s = DIRECTORY_SEPARATOR;
if (!file_exists("{$module_path}/library/HTMLPurifier.auto.php")) {
echo "<strong>Fatal error:</strong> Could not find HTML Purifier\n installation in {$module_path}{$s}library. Please copy contents\n of the library folder in the HTML Purifier tarball or zip\n to this folder or ensure HTMLPurifier.auto.php exists.\n You can download HTML Purifier at\n <a href=\"http://htmlpurifier.org/download.html\">htmlpurifier.org</a>.\n After you have done so, reload this page.";
exit;
}
require_once "{$module_path}/library/HTMLPurifier.auto.php";
if (!defined('HTMLPurifier::VERSION') || version_compare($old = HTMLPurifier::VERSION, $req_version, '<')) {
echo "<strong>Fatal error:</strong> HTML Purifier {$old} is not compatible\n with this module: HTML Purifier <strong>{$req_version}</strong> or later is required.\n If the required version is a dev version, you will need to\n <a href=\"http://htmlpurifier.org/download.html#Subversion\">check\n code out of Subversion</a> or\n <a href=\"http://htmlpurifier.org/download.html#NightlyBuilds\">download a nightly</a>\n to use this module. Once you have done so, reload this page.";
exit;
}
return true;
}
function htmlpurifier_update_6200() {
_htmlpurifier_version_check();
$formats = filter_formats();
foreach ($formats as $format => $info) {
$filters = filter_list_format($format);
if (!isset($filters['htmlpurifier/0'])) {
continue;
}
$config_data = array(
'URI.DisableExternalResources' => variable_get("htmlpurifier_externalresources_{$format}", TRUE),
'Attr.EnableID' => variable_get("htmlpurifier_enableattrid_{$format}", FALSE),
'AutoFormat.Linkify' => variable_get("htmlpurifier_linkify_{$format}", TRUE),
'AutoFormat.AutoParagraph' => variable_get("htmlpurifier_autoparagraph_{$format}", TRUE),
'Null_HTML.Allowed' => !variable_get("htmlpurifier_allowedhtml_enabled_{$format}", FALSE),
'HTML.Allowed' => variable_get("htmlpurifier_allowedhtml_{$format}", ''),
'Filter.YouTube' => variable_get("htmlpurifier_preserveyoutube_{$format}", FALSE),
);
if (defined('HTMLPurifier::VERSION') && version_compare(HTMLPurifier::VERSION, '3.1.0-dev', '>=')) {
$config_data['HTML.ForbiddenElements'] = variable_get("htmlpurifier_forbiddenelements_{$format}", '');
$config_data['HTML.ForbiddenAttributes'] = variable_get("htmlpurifier_forbiddenattributes_{$format}", '');
}
variable_set("htmlpurifier_config_{$format}", $config_data);
}
return array();
}
function htmlpurifier_update_6201() {
_htmlpurifier_version_check();
}