예제 #1
0
 /**
  * Constructor
  *
  * @param array $cfg Array of core configuration
  * @param array $common Array of common configuration
  * @param Framework $facula The framework itself
  */
 public function __construct(array &$cfg, array $common, Framework $facula)
 {
     $cp = new ConfigParser($cfg, static::$defaultSetting);
     // General settings
     $this->configs = array('Cache' => $cp->get('CacheTemplate'), 'Compress' => $cp->get('CompressOutput'), 'Renew' => $cp->get('ForceRenew'), 'CacheTTL' => $cp->get('CacheMaxLifeTime'), 'Charset' => strtoupper($cp->get('Charset', isset($common['Charset']) ? $common['Charset'] : null)), 'AspTags' => Ini::has('asp_tags') ? Ini::getBool('asp_tags') : false, 'CacheBegin' => $common['BootTime'], 'BootTime' => $common['BootTime'], 'BootVersion' => $common['BootVersion']);
     // Use custom render
     if (!$cp->isEmpty('Render')) {
         if (!class_exists($cp->get('Render'))) {
             new Error('RENDER_CLASS_NOTFOUND', array($cp->get('Render')), 'ERROR');
             return;
         }
         if (!class_implements($cp->get('Render'), static::$operatorsImpl['Render'])) {
             new Error('RENDER_INTERFACE_INVALID', array($cp->get('Render'), static::$operatorsImpl['Render']), 'ERROR');
             return;
         }
         $this->configs['Render'] = $cp->get('Render');
     }
     // Use custom compiler
     if (!$cp->isEmpty('Compiler')) {
         if (!class_exists($cp->get('Compiler'))) {
             new Error('COMPILER_CLASS_NOTFOUND', array($cp->get('Compiler')), 'ERROR');
             return;
         }
         if (!class_implements($cp->get('Compiler'), static::$operatorsImpl['Compiler'])) {
             new Error('COMPILER_INTERFACE_INVALID', array($cp->get('Compiler'), static::$operatorsImpl['Compiler']), 'ERROR');
             return;
         }
         $this->configs['Compiler'] = $cp->get('Compiler');
     }
     // TemplatePool
     if (!$cp->isEmpty('TemplatePool') && is_dir($cp->get('TemplatePool'))) {
         $this->configs['TplPool'] = PathParser::get($cp->get('TemplatePool'));
     } else {
         new Error('PATH_TEMPLATEPOOL_NOTFOUND', array(), 'ERROR');
         return;
     }
     // CompiledTemplate
     if (!$cp->isEmpty('CompiledTemplate') && is_dir($cp->get('CompiledTemplate'))) {
         $this->configs['Compiled'] = PathParser::get($cp->get('CompiledTemplate'));
     } else {
         new Error('PATH_COMPILEDTEMPLATE_NOTFOUND', array(), 'ERROR');
         return;
     }
     // Check if cache path has set
     if ($this->configs['Cache']) {
         if (!$cp->isEmpty('CachePath') && is_dir($cp->get('CachePath'))) {
             $this->configs['Cached'] = PathParser::get($cp->get('CachePath'));
         } else {
             new Error('PATH_CACHEDTEMPLATE_NOTFOUND', array(), 'ERROR');
             return;
         }
     }
     $this->pool['SupportedLanguages'] = array();
     if ($this->loadFileMap() && isset(static::$fileMap['Lang'])) {
         $this->pool['SupportedLanguages'] = array_keys(static::$fileMap['Lang']);
     }
     $this->assigned['RootURL'] = $facula->request->getClientInfo('rootURL');
     $this->assigned['HostURIFormatted'] = $facula->request->getClientInfo('hostURIFormatted');
     $this->assigned['AbsRootURL'] = $facula->request->getClientInfo('absRootURL');
     $this->assigned['AbsRootFormatted'] = $facula->request->getClientInfo('absRootFormatted');
     $this->assigned['_BOOT_VERSION'] = $this->configs['BootVersion'];
     $this->assigned['_BOOT_TIME'] = $this->configs['BootTime'];
 }