| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 10 require_once('limb/wact/src/compiler/filter/WactFilterDictionary.class.php'); 11 require_once 'limb/wact/src/compiler/property/WactPropertyDictionary.class.php'; 12 require_once 'limb/wact/src/compiler/tag_node/WactTagDictionary.class.php'; 13 require_once 'limb/wact/src/compiler/WactCompiler.class.php'; 14 15 /** 16 * class WactDictionaryHolder. 17 * 18 * @package wact 19 * @version $Id: WactDictionaryHolder.class.php 5945 2007-06-06 08:31:43Z pachanga $ 20 */ 21 class WactDictionaryHolder 22 { 23 protected $dictionaries; 24 protected $config; 25 protected static $instance = null; 26 27 function __construct($config) 28 { 29 $this->config = $config; 30 } 31 32 static function initialize($config) 33 { 34 if(isset(self :: $instance)) 35 return self :: $instance; 36 37 self :: $instance = new WactDictionaryHolder($config); 38 self :: $instance->initializeAllDictionaries(); 39 40 return self :: $instance; 41 } 42 43 // for testing purpose 44 static function resetInstance() 45 { 46 self :: $instance = null; 47 } 48 49 static function instance() 50 { 51 if(!isset(self :: $instance)) 52 throw new WactException('WactDictionaryHolder not initialized yet!'); 53 54 return self :: $instance; 55 } 56 57 function initializeAllDictionaries() 58 { 59 $this->initializeWactFilterDictionary(); 60 $this->initializePropertyDictionary(); 61 $this->initializeTagDictionary(); 62 } 63 64 function initializeWactFilterDictionary() 65 { 66 $this->_initializeDictionary('filter', 'WactFilterDictionary', 'filter'); 67 } 68 69 function initializePropertyDictionary() 70 { 71 $this->_initializeDictionary('property', 'WactPropertyDictionary', 'prop'); 72 } 73 74 function initializeTagDictionary() 75 { 76 $this->_initializeDictionary('tag', 'WactTagDictionary', 'tag'); 77 } 78 79 function getDictionary($name) 80 { 81 if(isset($this->dictionaries[$name])) 82 return $this->dictionaries[$name]; 83 84 throw new WactException('Dictionary "' . $name . '" is not initialized yet!'); 85 } 86 87 function getFilterDictionary() 88 { 89 return $this->getDictionary('filter'); 90 } 91 92 function getTagDictionary() 93 { 94 return $this->getDictionary('tag'); 95 } 96 97 function getPropertyDictionary() 98 { 99 return $this->getDictionary('property'); 100 } 101 102 protected function _initializeDictionary($name, $dictionary_class, $type) 103 { 104 $dictionary = null; 105 $cache_file = $this->config->getCacheDir() . "/{$dictionary_class}.cache"; 106 107 if(!$this->config->isForceScan() && file_exists($cache_file)) 108 { 109 $dictionary = unserialize(file_get_contents($cache_file)); 110 $this->dictionaries[$name] = $dictionary; 111 } 112 113 if(!is_object($dictionary)) 114 { 115 // For testing purposes 116 if(isset($GLOBALS[$name.'_wact_dictionary'])) 117 { 118 $dictionary = $GLOBALS[$name.'_wact_dictionary']; 119 $dictionary->setConfig($this->config); 120 } 121 else 122 $dictionary = new $dictionary_class($this->config); 123 124 $this->dictionaries[$name] = $dictionary; 125 $dictionary->buildDictionary('.' . $type . '.php'); 126 127 WactCompiler :: writeFile($cache_file, serialize($dictionary)); 128 } 129 130 // For testing purposes 131 $GLOBALS[$name.'_wact_dictionary'] = $dictionary; 132 133 return $dictionary; 134 } 135 } 136 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Sep 6 04:46:52 2008 | Cross-referenced by PHPXref 0.7 |