Added HTML Purifier 4.8.0 library using standard location
This commit is contained in:
parent
05c7e47866
commit
570dc80359
371 changed files with 31752 additions and 40 deletions
|
@ -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! ;-)
|
||||
|
|
Reference in a new issue