Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / EntityLookup.php
blobf950cc223152c56fef465cc0cecb05020aa05f74
1 <?php
3 /**
4 * Object that provides entity lookup table from entity name to character
5 */
6 class HTMLPurifier_EntityLookup {
8 /**
9 * Assoc array of entity name to character represented.
10 * @public
12 var $table;
14 /**
15 * Sets up the entity lookup table from the serialized file contents.
16 * @note The serialized contents are versioned, but were generated
17 * using the maintenance script generate_entity_file.php
18 * @warning This is not in constructor to help enforce the Singleton
20 function setup($file = false) {
21 if (!$file) {
22 $file = dirname(__FILE__) . '/EntityLookup/entities.ser';
24 $this->table = unserialize(file_get_contents($file));
27 /**
28 * Retrieves sole instance of the object.
29 * @static
30 * @param Optional prototype of custom lookup table to overload with.
32 function instance($prototype = false) {
33 // no references, since PHP doesn't copy unless modified
34 static $instance = null;
35 if ($prototype) {
36 $instance = $prototype;
37 } elseif (!$instance) {
38 $instance = new HTMLPurifier_EntityLookup();
39 $instance->setup();
41 return $instance;