Added HTML Purifier 4.8.0 library using standard location

This commit is contained in:
Manuel Cillero 2017-08-02 16:01:02 +02:00
parent 05c7e47866
commit 570dc80359
371 changed files with 31752 additions and 40 deletions

View file

@ -65,18 +65,18 @@ function htmlpurifier_requirements($phase) {
if (function_exists('libraries_get_path')) {
$library_path = libraries_get_path('htmlpurifier');
$using_libraries = true;
if (!file_exists("$library_path/library/HTMLPurifier.auto.php")) {
$library_path = dirname(__FILE__);
if (!file_exists("$library_path/htmlpurifier/HTMLPurifier.auto.php")) {
$library_path = 'sites/all/libraries';
$complain_loc = true;
$using_libraries = false;
}
} else {
$library_path = dirname(__FILE__);
$library_path = 'sites/all/libraries';
$using_libraries = false;
}
$s = DIRECTORY_SEPARATOR;
if (!file_exists("$library_path/library/HTMLPurifier.auto.php")) {
if (!file_exists("$library_path/htmlpurifier/HTMLPurifier.auto.php")) {
$requirements['htmlpurifier_library'] = array (
'title' => $t('HTML Purifier library'),
'severity' => REQUIREMENT_ERROR,
@ -85,7 +85,7 @@ function htmlpurifier_requirements($phase) {
of the library folder in the HTML Purifier tarball or zip
to this folder or ensure HTMLPurifier.auto.php exists.
You can download HTML Purifier at
<a href=\"http://htmlpurifier.org/download.html\">htmlpurifier.org</a>.", array('@path' => "$library_path{$s}library")
<a href=\"http://htmlpurifier.org/download.html\">htmlpurifier.org</a>.", array('@path' => "$library_path{$s}htmlpurifier")
),
);
return $requirements;
@ -105,9 +105,9 @@ function htmlpurifier_requirements($phase) {
new HTML Purifier tarball unzips to (you'll be reminded in an
update notification).",
array(
'@oldpath' => dirname(__FILE__) . '/library',
'@newpath' => libraries_get_path('htmlpurifier') . '/library',
'@somefile' => libraries_get_path('htmlpurifier') . '/library/HTMLPurifier.auto.php',
'@oldpath' => dirname(__FILE__) . '/htmlpurifier',
'@newpath' => libraries_get_path('htmlpurifier') . '/htmlpurifier',
'@somefile' => libraries_get_path('htmlpurifier') . '/htmlpurifier/HTMLPurifier.auto.php',
)),
);
}
@ -121,7 +121,7 @@ function htmlpurifier_requirements($phase) {
if (!$ours || version_compare($ours, $req_version, '<')) {
// Can't use _htmlpurifier_load(), since it assumes a later
// version
require_once "$library_path/library/HTMLPurifier.auto.php";
require_once "$library_path/htmlpurifier/HTMLPurifier.auto.php";
if (defined('HTMLPurifier::VERSION')) {
$version = HTMLPurifier::VERSION;
} else {
@ -181,13 +181,13 @@ function htmlpurifier_requirements($phase) {
array('%path' => libraries_get_path('htmlpurifier')));
} else {
$how_to_update = $t('To update, replace
<code>%path/library/</code> with the <code>library/</code>
<code>%path/htmlpurifier/</code> with the <code>library/</code>
directory from the downloaded archive. ',
array('%path' => dirname(__FILE__)));
}
$warning = $t('If you do not perform this operation correctly,
your Drupal installation will stop working. Ensure that
<code>%path/library/HTMLPurifier.auto.php</code> exists after
<code>%path/htmlpurifier/HTMLPurifier.auto.php</code> exists after
the upgrade.',
array('%path' => $library_path));
$requirements['htmlpurifier_version'] = array(
@ -205,7 +205,7 @@ function htmlpurifier_requirements($phase) {
);
}
}
return $requirements;
}
@ -232,7 +232,7 @@ function htmlpurifier_update_6200() {
}
variable_set("htmlpurifier_config_$format", $config_data);
}
return array();
}

View file

@ -201,28 +201,28 @@ function _htmlpurifier_add_css( &$field, $nid ) {
// -- INTERNAL FUNCTIONS ---------------------------------------------------- //
/**
* Processes HTML according to a format and returns purified HTML. Makes a
* Processes HTML according to a format and returns purified HTML. Makes a
* cache pass if possible.
*
*
* @param string $text
* Text to purify
* @param int $format
* Input format corresponding to HTML Purifier's configuration.
* @param boolean $cache
* Whether or not to check the cache.
*
*
* @note
* We ignore $delta because the only difference it makes is in the configuration
* screen.
*/
function _htmlpurifier_process($text, $format, $cache = TRUE) {
if ($cache) {
$cid = $format . ':' . md5($text);
$old = cache_get($cid, 'cache_htmlpurifier');
if ($old) return $old->data;
}
_htmlpurifier_load();
$config = _htmlpurifier_get_config($format);
@ -249,9 +249,9 @@ function _htmlpurifier_process($text, $format, $cache = TRUE) {
$ret = '<!-- HTML Purifier Cache #' . $cid . ' -->' . $ret;
}
}
if ($cache) cache_set($cid, $ret, 'cache_htmlpurifier', CACHE_PERMANENT);
return $ret;
}
@ -265,15 +265,15 @@ function _htmlpurifier_load() {
}
$done = true;
$module_path = drupal_get_path('module', 'htmlpurifier');
$library_path = $module_path;
$library_path = 'sites/all/libraries';
if (function_exists('libraries_get_path')) {
$library_path = libraries_get_path('htmlpurifier');
// This may happen if the user has HTML Purifier installed under the
// old configuration, but also installed libraries and forgot to
// move it over. There is code for emitting errors in
// htmlpurifier.install when this is the case.
if (!file_exists("$library_path/library/HTMLPurifier.auto.php")) {
$library_path = $module_path;
if (!file_exists("$library_path/htmlpurifier/HTMLPurifier.auto.php")) {
$library_path = 'sites/all/libraries';
}
}
@ -285,7 +285,7 @@ function _htmlpurifier_load() {
exit;
}
require_once "$library_path/library/HTMLPurifier.auto.php";
require_once "$library_path/htmlpurifier/HTMLPurifier.auto.php";
require_once "$module_path/HTMLPurifier_DefinitionCache_Drupal.php";
$factory = HTMLPurifier_DefinitionCacheFactory::instance();
@ -303,28 +303,28 @@ function _htmlpurifier_load() {
* Instance of HTMLPurifier_Config.
*/
function _htmlpurifier_get_config($format) {
$config = HTMLPurifier_Config::createDefault();
$config->set('AutoFormat.AutoParagraph', TRUE);
$config->set('AutoFormat.Linkify', TRUE);
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); // Probably
$config->set('Core.AggressivelyFixLt', TRUE);
$config->set('Cache.DefinitionImpl', 'Drupal');
// Filter HTML doesn't allow external images, so neither will we...
// for now. This can be configured off.
$config->set('URI.DisableExternalResources', TRUE);
if (!empty($_SERVER['SERVER_NAME'])) {
// SERVER_NAME is more reliable than HTTP_HOST
$config->set('URI.Host', $_SERVER['SERVER_NAME']);
}
if (defined('LANGUAGE_RTL') && $GLOBALS['language']->direction === LANGUAGE_RTL) {
$config->set('Attr.DefaultTextDir', 'rtl');
}
if ($config_function = _htmlpurifier_config_load($format)) {
$config_function($config);
} else {
@ -338,9 +338,9 @@ function _htmlpurifier_get_config($format) {
// {FALSE, TRUE, FALSE} = {no index, everything is allowed, don't do mq fix}
$config->mergeArrayFromForm($config_data, FALSE, TRUE, FALSE);
}
return $config;
}
function _htmlpurifier_load_csstidY() {
@ -366,7 +366,7 @@ function _htmlpurifier_load_csstidY() {
/**
* Returns the name of the configuration function for $format, or FALSE if none
* exists. Function name will be htmlpurifier_config_N.
*
*
* @param int $format
* Integer format to check function for.
* @return
@ -395,16 +395,16 @@ function _htmlpurifier_config_load($format) {
*/
function _htmlpurifier_settings($delta, $format) {
_htmlpurifier_load();
// Dry run, testing for errors:
_htmlpurifier_process('', $format, FALSE);
$module_path = drupal_get_path('module', 'htmlpurifier');
drupal_add_css("$module_path/config-form.css");
// Makes all configuration links open in new windows; can safe lots of grief!
drupal_add_js('$(function(){$(".hp-config a").click(function(){window.open(this.href);return false;});});', 'inline');
drupal_add_js(HTMLPurifier_Printer_ConfigForm::getJavaScript(), 'inline');
$form = array();
$form['dashboard'] = array(
@ -466,14 +466,14 @@ function _htmlpurifier_settings($delta, $format) {
'#description' => t('If enabled, HTML Purifier will tell filter that its output is cacheable. This is not usually necessary, because HTML Purifier maintains its own cache, but may be helpful if you have later filters that need to be cached. Warning: this applies to ALL filters, not just this one'),
);
}
$intro =
'<div class="form-item"><h3>'.
$title.
'</h3><div class="description">'.
t('Please click on a directive name for more information on what it does before enabling or changing anything! Changes will not apply to old entries until you clear the cache (see the dashboard)').
'</div></div>';
$config = _htmlpurifier_get_config($format);
$config_form = new HTMLPurifier_Printer_ConfigForm(
"htmlpurifier_config_$format", 'http://htmlpurifier.org/live/configdoc/plain.html#%s'
@ -483,14 +483,14 @@ function _htmlpurifier_settings($delta, $format) {
'#after_build' => array('_htmlpurifier_config_hack'),
);
}
return $form;
}
/**
* Fills out the form state with extra post data originating from the
* HTML Purifier configuration form. This is an #after_build hook function.
*
*
* @warning
* If someone ever gets the smart idea of changing the parameters to
* this function, I'm SOL! ;-)