Exemplo n.º 1
0
 public function generateApplicationMessages($dirs)
 {
     $catalogues = array();
     $files = sfFinder::type('file')->follow_link()->name('*.xml')->maxdepth(1)->in($dirs);
     foreach ($files as $file) {
         $name = basename($file);
         if (empty($catalogues[$name])) {
             $catalogues[$name] = array();
         }
         $messageSource = sfMessageSource::factory('OpenPNE');
         $data = $messageSource->loadData($file);
         $catalogues[$name] = array_merge($data, $catalogues[$name]);
     }
     $cacheDir = sfConfig::get('sf_app_cache_dir') . DIRECTORY_SEPARATOR . 'i18n';
     foreach ($catalogues as $filename => $catalogue) {
         $path = $cacheDir . DIRECTORY_SEPARATOR . $filename . '.php';
         opToolkit::writeCacheFile($path, '<?php return ' . var_export($catalogue, true) . ';');
     }
 }
 protected function setOpenPNEConfiguration()
 {
     $opConfigCachePath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'OpenPNE.yml.php';
     if (is_readable($opConfigCachePath)) {
         $config = (array) (include $opConfigCachePath);
     } else {
         $path = OPENPNE3_CONFIG_DIR . '/OpenPNE.yml';
         $config = sfYaml::load($path . '.sample');
         if (is_readable($path)) {
             $config = array_merge($config, sfYaml::load($path));
         }
         if (isset($config['base_url'])) {
             $config['base_url'] = preg_replace('/\\/$/', '', $config['base_url']);
         }
         opToolkit::writeCacheFile($opConfigCachePath, '<?php return ' . var_export($config, true) . ';');
     }
     $this->configureSessionStorage($config['session_storage']['name'], (array) $config['session_storage']['options']);
     unset($config['session_storage']);
     foreach ($config as $key => $value) {
         sfConfig::set('op_' . $key, $value);
     }
 }
 public function globEnablePlugin($pattern, $isControllerPath = false)
 {
     if ($this->isDebug()) {
         return $this->globPlugins($pattern, false, $isControllerPath);
     }
     $cacheKey = md5(serialize($pattern));
     $cacheHead = substr($cacheKey, 0, 2);
     $cacheDir = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR;
     $cacheFile = $cacheDir . 'glob_enable_plugin_path' . DIRECTORY_SEPARATOR . $cacheHead . '.php';
     $cacheProperty = 'globEnablePluginList';
     if ($isControllerPath) {
         $cacheFile = $cacheDir . 'glob_enable_plugin_path_controller' . DIRECTORY_SEPARATOR . $cacheHead . '.php';
         $cacheProperty = 'globEnablePluginControllerList';
     }
     $_prop =& $this->{$cacheProperty};
     if (empty($_prop[$cacheHead])) {
         if (is_readable($cacheFile)) {
             $_prop[$cacheHead] = (include $cacheFile);
         }
     }
     if (isset($_prop[$cacheHead][$cacheKey])) {
         return $_prop[$cacheHead][$cacheKey];
     }
     $_prop[$cacheHead][$cacheKey] = $this->globPlugins($pattern, false, $isControllerPath);
     opToolkit::writeCacheFile($cacheFile, "<?php\nreturn " . var_export($_prop[$cacheHead], true) . ';');
     return $_prop[$cacheHead][$cacheKey];
 }