You are here

function _htmlpurifier_load in HTML Purifier 7

Same name and namespace in other branches
  1. 5 htmlpurifier.module \_htmlpurifier_load()
  2. 6.2 htmlpurifier.module \_htmlpurifier_load()
  3. 6 htmlpurifier.module \_htmlpurifier_load()

Loads the HTML Purifier library, and performs global initialization.

4 calls to _htmlpurifier_load()
htmlpurifier_filter_info in ./htmlpurifier.module
Implements hook_filter_info().
htmlpurifier_requirements in ./htmlpurifier.install
Implements hook_requirements().
_htmlpurifier_process_text in ./htmlpurifier.module
Processes HTML according to a format and returns purified HTML. Makes a cache pass if possible.
_htmlpurifier_settings in ./htmlpurifier.module
Generates a settings form for configuring HTML Purifier.

File

./htmlpurifier.module, line 295
Implements HTML Purifier as a Drupal filter.

Code

function _htmlpurifier_load() {
  static $done = FALSE;
  if ($done) {
    return;
  }
  $done = TRUE;
  $module_path = drupal_get_path('module', 'htmlpurifier');
  $library_path = $module_path;
  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")) {

      // Check for an alternate phrasing and error about it
      if (file_exists("{$library_path}/HTMLPurifier.auto.php") && !file_exists("{$module_path}/library/HTMLPurifier.auto.php")) {
        echo "HTML Purifier was installed improperly; move contents of folder {$library_path} to {$library_path}/library";
        exit;
      }
      $library_path = $module_path;
    }
  }
  require_once "{$library_path}/library/HTMLPurifier.auto.php";
  require_once "{$module_path}/HTMLPurifier_DefinitionCache_Drupal.php";
  $factory = HTMLPurifier_DefinitionCacheFactory::instance();
  $factory
    ->register('Drupal', 'HTMLPurifier_DefinitionCache_Drupal');

  // Register the version as a variable:
  $current_version = variable_get('htmlpurifier_version_ours', FALSE);
  if ($current_version != HTMLPurifier::VERSION) {
    variable_set('htmlpurifier_version_ours', HTMLPurifier::VERSION);
  }
}