ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
HTMLPurifier_Bootstrap Class Reference

Bootstrap class that contains meta-functionality for HTML Purifier such as the autoload function. More...

+ Collaboration diagram for HTMLPurifier_Bootstrap:

Static Public Member Functions

static autoload ($class)
 Autoload function for HTML Purifier. More...
 
static getPath ($class)
 Returns the path for a specific class. More...
 
static registerAutoload ()
 "Pre-registers" our autoloader on the SPL stack. More...
 

Detailed Description

Bootstrap class that contains meta-functionality for HTML Purifier such as the autoload function.

Note
This class may be used without any other files from HTML Purifier.

Definition at line 30 of file Bootstrap.php.

Member Function Documentation

◆ autoload()

static HTMLPurifier_Bootstrap::autoload (   $class)
static

Autoload function for HTML Purifier.

Parameters
$classClass to load

Definition at line 37 of file Bootstrap.php.

References $file, and getPath().

37  {
39  if (!$file) return false;
40  // Technically speaking, it should be ok and more efficient to
41  // just do 'require', but Antonio Parraga reports that with
42  // Zend extensions such as Zend debugger and APC, this invariant
43  // may be broken. Since we have efficient alternatives, pay
44  // the cost here and avoid the bug.
45  require_once HTMLPURIFIER_PREFIX . '/' . $file;
46  return true;
47  }
print $file
static getPath($class)
Returns the path for a specific class.
Definition: Bootstrap.php:52
+ Here is the call graph for this function:

◆ getPath()

static HTMLPurifier_Bootstrap::getPath (   $class)
static

Returns the path for a specific class.

Definition at line 52 of file Bootstrap.php.

References $file.

Referenced by autoload().

52  {
53  if (strncmp('HTMLPurifier', $class, 12) !== 0) return false;
54  // Custom implementations
55  if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) {
56  $code = str_replace('_', '-', substr($class, 22));
57  $file = 'HTMLPurifier/Language/classes/' . $code . '.php';
58  } else {
59  $file = str_replace('_', '/', $class) . '.php';
60  }
61  if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) return false;
62  return $file;
63  }
print $file
+ Here is the caller graph for this function:

◆ registerAutoload()

static HTMLPurifier_Bootstrap::registerAutoload ( )
static

"Pre-registers" our autoloader on the SPL stack.

Definition at line 68 of file Bootstrap.php.

References $compat.

68  {
69  $autoload = array('HTMLPurifier_Bootstrap', 'autoload');
70  if ( ($funcs = spl_autoload_functions()) === false ) {
71  spl_autoload_register($autoload);
72  } elseif (function_exists('spl_autoload_unregister')) {
73  if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
74  // prepend flag exists, no need for shenanigans
75  spl_autoload_register($autoload, true, true);
76  } else {
77  $buggy = version_compare(PHP_VERSION, '5.2.11', '<');
78  $compat = version_compare(PHP_VERSION, '5.1.2', '<=') &&
79  version_compare(PHP_VERSION, '5.1.0', '>=');
80  foreach ($funcs as $func) {
81  if ($buggy && is_array($func)) {
82  // :TRICKY: There are some compatibility issues and some
83  // places where we need to error out
84  $reflector = new ReflectionMethod($func[0], $func[1]);
85  if (!$reflector->isStatic()) {
86  throw new Exception('
87  HTML Purifier autoloader registrar is not compatible
88  with non-static object methods due to PHP Bug #44144;
89  Please do not use HTMLPurifier.autoload.php (or any
90  file that includes this file); instead, place the code:
91  spl_autoload_register(array(\'HTMLPurifier_Bootstrap\', \'autoload\'))
92  after your own autoloaders.
93  ');
94  }
95  // Suprisingly, spl_autoload_register supports the
96  // Class::staticMethod callback format, although call_user_func doesn't
97  if ($compat) $func = implode('::', $func);
98  }
99  spl_autoload_unregister($func);
100  }
101  spl_autoload_register($autoload);
102  foreach ($funcs as $func) spl_autoload_register($func);
103  }
104  }
105  }

The documentation for this class was generated from the following file: