You are here

function _htmlpurifier_version_check in HTML Purifier 5

Same name and namespace in other branches
  1. 6 htmlpurifier.install \_htmlpurifier_version_check()

Checks the version of HTML Purifier and fatally errors out if there's a problem.

2 calls to _htmlpurifier_version_check()
htmlpurifier_install in ./htmlpurifier.install
Implementation of hook_install().
htmlpurifier_update_1 in ./htmlpurifier.install

File

./htmlpurifier.install, line 46

Code

function _htmlpurifier_version_check() {

  // This version of HTML Purifier is required
  static $req_version = '2.1.0';

  // Can't use drupal_get_path, since module may not have been installed.
  $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 library 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";
  $purifier = new HTMLPurifier();
  if (version_compare($purifier->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          You can download the latest version of HTML Purifier at\n          <a href=\"http://htmlpurifier.org/download.html\">htmlpurifier.org</a>.";
    exit;
  }

  // Everything looks ok!
  return true;
}