ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
string$classClass to load
Returns
bool

Definition at line 38 of file Bootstrap.php.

References getPath().

Referenced by __autoload().

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

◆ getPath()

static HTMLPurifier_Bootstrap::getPath (   $class)
static

Returns the path for a specific class.

Parameters
string$classClass path to get
Returns
string

Definition at line 58 of file Bootstrap.php.

References $code.

Referenced by autoload().

59  {
60  if (strncmp('HTMLPurifier', $class, 12) !== 0) {
61  return false;
62  }
63  // Custom implementations
64  if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) {
65  $code = str_replace('_', '-', substr($class, 22));
66  $file = 'HTMLPurifier/Language/classes/' . $code . '.php';
67  } else {
68  $file = str_replace('_', '/', $class) . '.php';
69  }
70  if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) {
71  return false;
72  }
73  return $file;
74  }
$code
Definition: example_050.php:99
+ 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 79 of file Bootstrap.php.

References $compat.

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

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