loadPageConfigurationFromPhp() публичный Метод

public loadPageConfigurationFromPhp ( $config, $configPath, $configPagePath )
Пример #1
0
 /**
  * Collects configuration for a page.
  * @param TXmlElement additional configuration specified in the application configuration
  * @return TPageConfiguration
  */
 protected function loadPageConfig($config)
 {
     $application = $this->getApplication();
     $pagePath = $this->getRequestedPagePath();
     if (($cache = $application->getCache()) === null) {
         $pageConfig = new TPageConfiguration($pagePath);
         if ($config !== null) {
             if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
                 $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
             } else {
                 $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
             }
         }
         $pageConfig->loadFromFiles($this->getBasePath());
     } else {
         $configCached = true;
         $currentTimestamp = array();
         $arr = $cache->get(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath);
         if (is_array($arr)) {
             list($pageConfig, $timestamps) = $arr;
             if ($application->getMode() !== TApplicationMode::Performance) {
                 foreach ($timestamps as $fileName => $timestamp) {
                     if ($fileName === 0) {
                         $appConfigFile = $application->getConfigurationFile();
                         $currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
                         if ($currentTimestamp[0] > $timestamp || $timestamp > 0 && !$currentTimestamp[0]) {
                             $configCached = false;
                         }
                     } else {
                         $currentTimestamp[$fileName] = @filemtime($fileName);
                         if ($currentTimestamp[$fileName] > $timestamp || $timestamp > 0 && !$currentTimestamp[$fileName]) {
                             $configCached = false;
                         }
                     }
                 }
             }
         } else {
             $configCached = false;
             $paths = explode('.', $pagePath);
             $configPath = $this->getBasePath();
             $fileName = $this->getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP ? self::CONFIG_FILE_PHP : self::CONFIG_FILE_XML;
             foreach ($paths as $path) {
                 $configFile = $configPath . DIRECTORY_SEPARATOR . $fileName;
                 $currentTimestamp[$configFile] = @filemtime($configFile);
                 $configPath .= DIRECTORY_SEPARATOR . $path;
             }
             $appConfigFile = $application->getConfigurationFile();
             $currentTimestamp[0] = $appConfigFile === null ? 0 : @filemtime($appConfigFile);
         }
         if (!$configCached) {
             $pageConfig = new TPageConfiguration($pagePath);
             if ($config !== null) {
                 if ($application->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) {
                     $pageConfig->loadPageConfigurationFromPhp($config, $application->getBasePath(), '');
                 } else {
                     $pageConfig->loadPageConfigurationFromXml($config, $application->getBasePath(), '');
                 }
             }
             $pageConfig->loadFromFiles($this->getBasePath());
             $cache->set(self::CONFIG_CACHE_PREFIX . $this->getID() . $pagePath, array($pageConfig, $currentTimestamp));
         }
     }
     return $pageConfig;
 }