public static function clearCache($rt_shop_category = null) { $cache = sfContext::getInstance()->getViewCacheManager(); if ($cache) { rtGlobalCacheToolkit::clearCache(); $cache->remove('rtShopCategory/index'); $file_cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'frontend')); $file_cache->removePattern('**/rtShopCategory/_navigation/*'); $cache->remove('@sf_cache_partial?module=rtShopCategory&action=_navigation&sf_cache_key=*'); $cache->remove('@sf_cache_partial?module=rtShopCategory&action=_navigation&sf_cache_key=40cd750bba9870f18aada2478b24840a'); $cache->remove('rtShopCategory/_navigation?module=rtShopCategory&action=*&sf_cache_key=*'); // '/1_mysite_com/all/rtShopCategory/index/page/1'; if (!is_null($rt_shop_category)) { if ($rt_shop_category->getNode()->isRoot()) { $cache->remove('rtShopCategory/index?page=*'); } $cache->remove(sprintf('rtShopCategory/show?id=%s&slug=%s', $rt_shop_category->getId(), $rt_shop_category->getSlug())); // show page $cache->remove(sprintf('rtShopCategory/show?id=%s&slug=%s&page=*', $rt_shop_category->getId(), $rt_shop_category->getSlug())); // show page $cache->remove(sprintf('rtShopCategory/show?id=%s&slug=%s&page=*&show_more=', $rt_shop_category->getId(), $rt_shop_category->getSlug())); // show page $cache->remove('@sf_cache_partial?module=rtShopCategory&action=_shop_category&sf_cache_key=' . $rt_shop_category->getId()); // show page partial. } } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (!class_exists('DbFinder')) { throw new Exception('sfCombine expects DbFinder to call combined asset file'); } // initialize database manager $databaseManager = new sfDatabaseManager($this->configuration); $flag = true; if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); if (!ini_get('apc.enable_cli')) { $this->logSection('combine', 'Check apc.enabled_cli in your ini file', null, 'ERROR'); $flag = false; } } else { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . '/combiners')); } if ($flag) { $results = DbFinder::from('sfCombine')->find(); foreach ($results as $result) { $cache->remove($result->getAssetsKey()); } $this->logSection('combine', 'Cleanup cache complete', null, 'INFO'); $nbAssets = DbFinder::from('sfCombine')->delete(); $this->logSection('combine', sprintf('Cleanup database complete (%d rows deleted)', $nbAssets), null, 'INFO'); } }
public function doSave($con = null) { parent::doSave($con); $enabled_ids = $this->getValue('enabled_modules'); $all_dependencies = sfConfig::get('app_pm_module_enabler_dependencies', array()); foreach ($this->getObject()->getpmModules() as $pm_module) { $pm_module->setIsEnabled(in_array($pm_module->getId(), $enabled_ids) || $pm_module->getName() == 'pmconfiguration' ? true : false); $pm_module->save(); } foreach ($all_dependencies as $pm_module_name => $dependency) { $pm_module = pmModulePeer::retrieveByName($pm_module_name); if ($pm_module->getIsEnabled()) { $dependencies = isset($all_dependencies[$pm_module_name]) ? $all_dependencies[$pm_module_name] : array(); // save all module dependencies foreach ($dependencies as $dependency) { $dependency = pmModulePeer::retrieveByName($dependency); $dependency->setIsEnabled(true); $dependency->save(); } } } // clear cache $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir'))); $cache->clean(); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // initialize database manager $databaseManager = new sfDatabaseManager($this->configuration); $flag = true; if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); if (!ini_get('apc.enable_cli')) { $this->logSection('combine', 'Check apc.enable_cli in your ini file', null, 'ERROR'); $flag = false; } } else { $cache = new sfFileCache(array('cache_dir' => sfCombineUtility::getCacheDir())); } if ($flag) { if (!class_exists('sfCombine')) { $this->logSection('combine', 'Call the task `doctrine:build-model`', null, 'ERROR'); return false; } $results = Doctrine::getTable('sfCombine')->findAll(); foreach ($results as $result) { $cache->remove($result->getAssetKey()); } $this->logSection('combine', 'Cleanup cache complete', null, 'INFO'); $deleted = Doctrine::getTable('sfCombine')->deleteAll(); $this->logSection('combine', sprintf('Cleanup database complete (%d rows deleted)', $deleted), null, 'INFO'); } }
/** * Remove cache (with cached i18n app dicts) * * @param array $params Object params * @return void */ public function removeCache(array $params) { if ($params['dictionary_id']) { if ($dict = Doctrine::getTable('DinLanguageDictionary')->find($params['dictionary_id'])) { $driver = new sfFileCache(array('lifetime' => 157680000, 'cache_dir' => sfConfig::get('sf_cache_dir') . '/' . $dict->getApplication() . '/*/i18n/' . $dict->getName())); $driver->removePattern('*'); } } parent::removeCache($params); }
public function execute($filterChain) { // Create a function cache object for the QubitSettings method call $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_app_cache_dir') . '/settings')); // Get settings (from cache if exists) if ($cache->has('settings')) { $settings = unserialize($cache->get('settings')); } else { $settings = QubitSetting::getSettingsArray(); $cache->set('settings', serialize($settings)); } // Overwrite/populate settings into sfConfig object sfConfig::add($settings); // Execute next filter $filterChain->execute(); }
protected function serve() { //get an instance of the file cache object. We grab the web root then get the name of the cache folder //we don't want to use sf_cache_dir because that is application and environment specific //we don't want to a path relative to sf_web_dir because the sf_root_dir can be changed, better to start from there $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . "/" . sfCombineFilter::PACK_CACHE_FOLDER)); //Next we see if we can pull the file from the cache. if ($cache->has($this->cacheFileName)) { //Ok! We have a cached copy of the file! $this->data = $cache->get($this->cacheFileName); $this->mimeType = 'text/' . $this->type; $this->size = strlen($this->data); } else { //cached copy wasn't found, return 404 $this->forward404('Cache file not found!!! ' . $this->cacheFileName); } }
protected function serve($file_info) { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . 'cache')); if ($file_info->getIsCached() && $cache->has($file_info->getId(), 'uploaded_files')) { $file_data = new FileData(); $file_data->setBinaryData($cache->get($file_info->getId(), 'uploaded_files')); } else { $file_data = $file_info->getFileData(); $cache->set($file_info->getId(), 'uploaded_files', fread($file_data->getBinaryData(), $file_info->getSize())); $file_info->setIsCached(true); $file_info->save(); } sfConfig::set('sf_web_debug', false); // $this->getResponse()->addHttpMeta('content-type', $file_info->getMime()); // $this->getResponse()->addHttpMeta('content-length', $file_info->getSize()); return $file_data; }
/** * Saves some data in a cache file. * * This function handles generating the cached php code for the array. * * @param string The cache id * @param string The name of the cache namespace * @param array The array to put in cache * * @return boolean true if no problem * * @see sfCache */ public function set($id, $namespace = self::DEFAULT_NAMESPACE, $array) { $data = array(); $data[] = '<?php'; $data[] = '// auto-generated by sfArrayCache'; $data[] = '// date: ' . date('Y-m-d H:i:s'); $data[] = ''; $data[] = 'return ' . var_export($array, true) . ';'; return parent::set($id, $namespace, implode("\n", $data)); }
public static function clearCache($rt_site_page = null) { $cache = sfContext::getInstance()->getViewCacheManager(); if ($cache) { rtGlobalCacheToolkit::clearCache(); $cache->remove('rtSitePage/index'); $file_cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'frontend')); $file_cache->removePattern('**/rtSitePage/_navigation/*'); $cache->remove('@sf_cache_partial?module=rtSitePage&action=_navigation&sf_cache_key=*'); $cache->remove('@sf_cache_partial?module=rtSitePage&action=_navigation&sf_cache_key=40cd750bba9870f18aada2478b24840a'); $cache->remove('rtSitePage/_navigation?module=rtSitePage&action=*&sf_cache_key=*'); if (!is_null($rt_site_page)) { $cache->remove(sprintf('rtSitePage/show?slug=%s', $rt_site_page->getSlug())); // show page $cache->remove(sprintf('rtSitePage/show?id=%s&slug=%s', $rt_site_page->getId(), $rt_site_page->getSlug())); // show page $cache->remove('@sf_cache_partial?module=rtSitePage&action=_site_page&sf_cache_key=' . $rt_site_page->getId()); // show page partial. } } }
/** * Clear the cache */ public static function emptyCache() { try { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir'))); $cache->clean(); self::clearAll(); } catch (Exception $e) { } }
/** * Writes a cache file. * * @param string An absolute filesystem path to a configuration file * @param string An absolute filesystem path to the cache file that will be written * @param string Data to be written to the cache file * * @throws sfCacheException If the cache file cannot be written */ protected function writeCacheFile($config, $cache, &$data) { $fileCache = new sfFileCache(dirname($cache)); $fileCache->initialize(array('lifeTime' => 86400 * 365 * 10, 'automaticCleaningFactor' => 0)); $fileCache->setWriteControl(true); $fileCache->setSuffix(''); if (!$fileCache->set(basename($cache), '', $data)) { $fileCache->remove(basename($cache), ''); throw new sfConfigurationException(sprintf('Unable to write config cache for "%s".', $config)); } }
/* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; require_once dirname(__FILE__) . '/sfCacheDriverTests.class.php'; $t = new lime_test(36, new lime_output_color()); // setup sfConfig::set('sf_logging_enabled', false); $temp = tempnam('/tmp/cachedir', 'tmp'); unlink($temp); mkdir($temp); $cache = new sfFileCache($temp); sfCacheDriverTests::launch($t, $cache); // teardown sfToolkit::clearDirectory($temp); rmdir($temp); $temp = tempnam('/tmp/cachedir', 'tmp'); unlink($temp); mkdir($temp); // Create a file cache using initialize() method $cache = new sfFileCache(); $cache->initialize(array('cacheDir' => $temp)); sfCacheDriverTests::launch($t, $cache); // teardown sfToolkit::clearDirectory($temp); rmdir($temp);
/** * Writes a cache file. * * @param string An absolute filesystem path to a configuration file * @param string An absolute filesystem path to the cache file that will be written * @param string Data to be written to the cache file * * @throws sfCacheException If the cache file cannot be written */ protected function writeCacheFile($config, $cache, &$data) { $fileCache = new sfFileCache(dirname($cache)); $fileCache->setSuffix(''); $fileCache->set(basename($cache), '', $data); }
/** * Returns the cache last modification time. * * @return int The last modification time */ public function lastModified($id, $namespace = self::DEFAULT_NAMESPACE) { list($path, $file) = $this->getFileName($id, $namespace); try { $std = self::$mem[$this->bucket]->get($path . $file); if ($std instanceof Stdclass) { return $std->lastModified; } else { throw new Exception("Returned an invalid object type"); } } catch (Exception $e) { parent::lastModified($id, $namespace); } }
public function initialize($options = array()) { $options = array_merge($options, array('cache_dir' => self::getCacheDir())); parent::initialize($options); }
/** * Method to generate the final output of the collated files. It adds each * minified chunk to a file cache * * @param bool $minify (Optional) Whether to minify output * @param array $minifySkipSuffixes (Optional) if minify is allowed a * suffix of file endings to skip * (basically extensions like .min.js) * @param array $minifySkip (Optional) An array of filenames that * should not be minified * @return string */ protected function _generateOutput($minify = false, $minifySkipSuffixes = array(), $minifySkip = array()) { $minifiable = $this->_groupMinifableFiles($minify, $minifySkipSuffixes, $minifySkip, $this->getConfigOption('group_files', true)); $cache = false; if ($this->getConfigOption('cache_minified_files', false)) { $cache = new sfFileCache(array('cache_dir' => $this->getCacheDir())); } $output = ''; $fileNameComments = $this->getConfigOption('filename_comments', false); foreach ($minifiable as $files) { if ($fileNameComments) { if ($output) { $output .= PHP_EOL; } $output .= $this->_addFilenameComments($files['files']); } if (!$files['minify']) { $output .= $files['contents'] . PHP_EOL; } else { $minifiedContents = false; if ($cache) { $key = sha1($files['contents']); if ($cache->has($key)) { $minifedContents = $cache->get($key); } } if ($minifiedContents === false) { $minifiedContents = $this->minify($files['contents']); } $output .= $minifiedContents . PHP_EOL; if ($cache) { if (!$cache->has($key)) { $cache->set($key, $minifiedContents); } } } } return $output; }
protected function refreshSettings() { // clear the file cache containing the settings $fileCache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_app_cache_dir') . '/settings')); $fileCache->clean(); }
/** * Remove cache (with cached i18n app dicts) * * @param array $params Object params * @return void */ public function removeCache(array $params) { if ($params['application'] && $params['name']) { $driver = new sfFileCache(array('lifetime' => 157680000, 'cache_dir' => sfConfig::get('sf_cache_dir') . '/' . $params['application'] . '/*/i18n/' . $params['name'])); $driver->removePattern('*'); } }
/** * Take a db hash and convert it into an array of files * * @see getFiles */ public static function getFilesByKey($key, $separator = ' ') { $base64 = false; // try get base64 from cache if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); $base64 = $cache->get($key); } if (!$base64) { $cache = new sfFileCache(array('cache_dir' => sfCombineUtility::getCacheDir())); $base64 = $cache->get($key); } // check db if (!$base64 && class_exists('sfCombine')) { $combine = Doctrine::getTable('sfCombine')->find($key); $base64 = $combine ? $combine->getFiles() : false; } return self::getFilesByBase64($base64, $separator); }
/** * SyncRepositoryTask::execute() * * @param array $arguments * @param array $options * @return */ protected function execute($arguments = array(), $options = array()) { // ログファイルの設定 $file_logger = new sfFileLogger($this->dispatcher, array('file' => $this->configuration->getRootDir() . '/log/' . $this->getName() . '.log')); $this->dispatcher->connect('application.log', array($file_logger, 'listenToLogEvent')); // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); // 更新フラグのあるリポジトリの最初の1件を取得する。 $repository = RepositoryTable::getInstance()->findOneByForceUpdate(1); if (!$repository) { return false; } // 更新フラグを消しておく。 $repository->setForceUpdate(0); $repository->save(); // リポジトリを同期する。 $this->log(sprintf('リポジトリ %s の同期を開始します', $repository->getRepositoryName())); // リポジトリキャッシュルートディレクトリ $cache_root = sfConfig::get('sf_root_dir') . '/../data/repos/'; $dir_root = $cache_root . $repository->getCacheKey(); $do_clone = false; if ($repository->getForceClone()) { // 一旦このディレクトリ配下をすべて削除する sfToolkit::clearDirectory($dir_root_repo); // 強制clone $do_clone = true; } else { if (!is_dir($dir_root)) { // ディレクトリがない。 mkdir($dir_root, 0777, true); // このディレクトリ配下にcloneを取得する。 $do_clone = true; } else { // リポジトリは取得済か? $dir_root_repo = $dir_root . DIRECTORY_SEPARATOR . $repository->getRepositoryName(); try { $git = new myVersionControl_Git($dir_root_repo); $git->setGitCommandPath('git'); // pullする。 $this->log('リポジトリをpullしています'); $pullMessage = $git->getCommand('pull')->execute(); if (preg_match('/up\\-to\\-date/i', $pullMessage)) { $this->log('更新はありません'); return; } } catch (Exception $e) { // 一旦このディレクトリ配下をすべて削除する sfToolkit::clearDirectory($dir_root_repo); // cloneする $do_clone = true; } } } if ($do_clone) { $this->log('リポジトリをcloneしています'); $git = new myVersionControl_Git($dir_root); $git->setGitCommandPath('git'); $git->createClone($repository->getRepository()); // リポジトリ $dir_root_repo = $dir_root . DIRECTORY_SEPARATOR . $repository->getRepositoryName(); try { $git = new myVersionControl_Git($dir_root_repo); $git->setGitCommandPath('git'); } catch (Exception $e) { // 一旦このディレクトリ配下をすべて削除する sfToolkit::clearDirectory($dir_root_repo); return; } } // このリポジトリの対象ファイルリストを取得する。 $files = sfFinder::type('file')->prune('.git')->discard('.git')->relative()->in($search_dir = $dir_root . DIRECTORY_SEPARATOR . $repository->getRepositoryName() . $repository->getSubdirectory()); $page_path_root = $repository->getBindPath(); // --------------------------------------------- // ファイル別に処理 $new_commit_found = false; foreach ($files as $file) { $this->log(sprintf('ファイル:%s', $file)); $info = pathinfo($file); $file_path = $search_dir . DIRECTORY_SEPARATOR . $file; // ファイルの更新タイムスタンプが新しいものだけ処理する if (filemtime($file_path) < time() - 86400) { $this->log('更新なし'); continue; } // このファイルが対象かどうかチェックする。 if (!PageTable::needProcess($file)) { $this->log('ページ取り込み対象外'); // 画像データなら、パブリックディレクトリにコピーする。 if (preg_match('/^(png|jpg|gif)$/', $info['extension'])) { $target_path = $repository->getImagePublicPath($file); $target_dir = dirname($target_path); if (!is_dir($target_dir)) { mkdir($target_dir, 0777, true); } $this->log('ファイルをパブリックディレクトリにコピーします。'); copy($file_path, $target_path); chmod($target_path, 0666); } continue; } // 各ページに対応するURLパスを求める。 if ('.' !== $info['dirname']) { $page_path = strtolower($page_path_root . '/' . $info['dirname'] . '/' . $info['filename']); } else { $page_path = strtolower($page_path_root . '/' . $info['filename']); } // ページに対応するレコードを取得する。 $page = Doctrine_Core::getTable('Page')->findOneByPath($page_path); if (!$page) { $page = new Page(); $page->setPath($page_path); $page->setRepository($repository); } echo $file; // ページごとにコミット履歴を取得する。 $commits = $git->getCommits('master', $file_path); foreach ($commits as $commit) { // 既存ページの場合はコミットがすでに取り込み済かチェックする。 $commit_record = null; if (!$page->isNew()) { $commit_record = Doctrine_Core::getTable('Commit')->findOneByCommitKeyAndPageId($commit->__toString(), $page->getId()); } if (!$commit_record) { // コミットを登録する。 $new_commit_found = true; $this->log(sprintf('コミット %s を取得しています', $commit)); $commit_record = new Commit(); $commit_record->setAuthorHandle($commit->getAuthorHandle()); $commit_record->setAuthorEmail($commit->getAuthorEmail()); $commit_record->setCommitterHandle($commit->getCommitterHandle()); $commit_record->setCommitterEmail($commit->getCommitterEmail()); $commit_record->setCommittedAt(date('Y/m/d H:i:s', $commit->getCommittedAt())); $commit_record->setCommitKey($commit); $commit_record->setPage($page); $commit_record->save(); $commit_record->free(); unset($commit_record); } } // 新規のコミットが無い場合は、処理をスキップする。 if (!$new_commit_found) { continue; } $new_commit_found = true; $page->setContentType($type = PageTable::checkType($file)); $content = file_get_contents($file_path); if ('UTF-8' !== ($encoding = mb_detect_encoding($content))) { $content = mb_convert_encoding($content, 'UTF-8', $encoding); } $page->setContentRaw($content); // ページのレンダリングモードに合わせてレンダリングする。 $page->setContentRendered($rendered = PageTable::renderContent($content, $type)); // DOMパース用に、特殊文字を置換する。 $html = mb_convert_encoding($rendered, 'HTML-ENTITIES', 'ASCII, JIS, UTF-8, EUC-JP, SJIS'); // レンダリング結果をパースする。 $dom = new DomDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); // タイトルを探す。 $domElements = $xpath->query('//title | //h1'); if (count($domElements)) { $page->setTitle($domElements->item(0)->nodeValue); } // 見出しをパースする $domElements = $xpath->query('//h1 | //h2 | //h3'); $indexes = array(); $now_h1 = array(); $now_h2 = array(); foreach ($domElements as $domElement) { switch ($domElement->nodeName) { case 'h1': $indexes[] = array('type' => 'h1', 'text' => $domElement->nodeValue, 'id' => $domElement->getAttribute('id'), 'children' => array()); $now_h1 =& $indexes[count($indexes) - 1]['children']; break; case 'h2': $now_h1[] = array('type' => 'h2', 'text' => $domElement->nodeValue, 'id' => $domElement->getAttribute('id'), 'children' => array()); $now_h2 =& $now_h1[count($now_h1) - 1]['children']; break; case 'h3': $now_h2[] = array('type' => 'h3', 'text' => $domElement->nodeValue, 'id' => $domElement->getAttribute('id'), 'children' => array()); break; default: break; } } $page->setIndexJson(json_encode($indexes)); // 保存する。 $page->save(); $page->free(); unset($page); } // 新しいコミットがあった場合、キャッシュを削除する。 if ($new_commit_found) { $frontend_cache_dir = sfConfig::get('sf_cache_dir') . '/frontend/prod/template'; $cache = new sfFileCache(array('cache_dir' => $frontend_cache_dir)); $cache->clean(); } $this->log(sprintf('リポジトリ %s の同期が完了しました', $repository->getRepositoryName())); }
/** * @see sfFileCache::set() */ public function set($key, $data, $lifetime = null) { return parent::set($key, serialize($data), $lifetime); }
public function execute($request) { $this->form = new sfForm(); $this->culture = $this->context->user->getCulture(); $this->globalForm = new SettingsGlobalForm(); $this->siteInformationForm = new SettingsSiteInformationForm(); $this->defaultTemplateForm = new SettingsDefaultTemplateForm(); $this->uiLabelForm = new SettingsGenericForm(array(), array('settings' => QubitSetting::getByScope('ui_label'), 'scope' => 'ui_label', 'fieldsRequired' => false)); $this->oaiRepositoryForm = new SettingsOaiRepositoryForm(); $this->initializeDefaultPageElementsForm(); // Handle POST data (form submit) if ($request->isMethod('post')) { // Clean cache $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_app_cache_dir') . '/settings')); $cache->clean(); // Global settings form submission if (null !== $request->global_settings) { // Hack to populate "version" field so it displays // if validation fails. By default, their values are not included in // $request->parameterHolder (and thus are not bound) because their // <input> field is disabled. $version = null !== ($setting = QubitSetting::getSettingByName('version')) ? $setting->getValue(array('sourceCulture' => true)) : null; $this->globalForm->bind(array_merge($request->global_settings, array('version' => $version))); if ($this->globalForm->isValid()) { // Do update and redirect to avoid repeat submit wackiness $this->updateGlobalSettings(); $this->redirect('settings/list'); } } // Handle site information form submission if (null !== $request->site_information) { $this->siteInformationForm->bind($request->site_information); if ($this->siteInformationForm->isValid()) { // Do update and redirect to avoid repeat submit wackiness $this->updateSiteInformationSettings(); $this->redirect('settings/list'); } } // Handle default template form submission if (null !== $request->default_template) { $this->defaultTemplateForm->bind($request->default_template); if ($this->defaultTemplateForm->isValid()) { // Do update and redirect to avoid repeat submit wackiness $this->updateDefaultTemplateSettings($this->defaultTemplateForm); $this->redirect('settings/list'); } } // Handle default template form submission if (null !== $request->ui_label) { $this->uiLabelForm->bind($request->ui_label); if ($this->uiLabelForm->isValid()) { // Do update and redirect to avoid repeat submit wackiness $this->updateUiLabelSettings($this->uiLabelForm); $this->redirect('settings/list'); } } // Handle OAI Repository form submission if (null !== $request->oai_repository) { $this->oaiRepositoryForm->bind($request->oai_repository); if ($this->oaiRepositoryForm->isValid()) { // Do update and redirect to avoid repeat submit wackiness $this->updateOaiRepositorySettings($this->oaiRepositoryForm); $this->redirect('settings/list'); } } if (null !== ($languageCode = $request->languageCode)) { try { format_language($languageCode, $languageCode); } catch (Exception $e) { $this->redirect(array('module' => 'settings', 'action' => 'list')); } $setting = new QubitSetting(); $setting->name = $languageCode; $setting->scope = 'i18n_languages'; $setting->value = $languageCode; $setting->deleteable = true; $setting->editable = true; $setting->getCurrentSettingI18n()->setCulture('en'); $setting->sourceCulture = 'en'; $setting->save(); } } // Populate forms $this->populateGlobalForm(); $this->populateSiteInformationForm(); $this->populateDefaultTemplateForm($this->defaultTemplateForm); $this->populateUiLabelForm($this->uiLabelForm); $this->populateOaiRepositoryForm($this->oaiRepositoryForm); // Last symfony 1.0 forms holdout $this->i18nLanguages = QubitSetting::getByScope('i18n_languages'); $this->form->setValidator('languageCode', new sfValidatorI18nChoiceLanguage()); $this->form->setWidget('languageCode', new sfWidgetFormI18nChoiceLanguage(array('add_empty' => true, 'culture' => $this->context->user->getCulture()))); // make vars available to template $this->availableLanguages = self::$availableLanguges; }
/** * Üríti a cache objektumot * * @return bool */ public function clear() { return $this->cache->deleteAll(); }
/** * will not unserialize result */ public function _get($key, $default = null) { return parent::get($key, $default); }
protected function execute($arguments = array(), $options = array()) { $frontend_cache_dir = sfConfig::get('sf_cache_dir') . '/frontend/prod/template'; $cache = new sfFileCache(array('cache_dir' => $frontend_cache_dir)); $cache->clean(); }
/** * @see sfCache */ public function removePattern($pattern) { if (!$pattern instanceof sfRoute) { return parent::removePattern($pattern); } $paths = $this->getGlobPatterns($pattern); foreach ($paths as $path) { $files = glob($path, GLOB_BRACE); foreach ($files as $file) { @unlink($file); } } }
/** * Returns a key which combined all assets file * * @return string md5 */ function _get_key($files) { $content = base64_encode(serialize($files)); $key = md5($content . sfConfig::get('app_sfCombinePlugin_asset_version', '')); if (!class_exists('DbFinder')) { throw new Exception('sfCombine expects DbFinder to call combined asset file'); } if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); // FIXME: APCCache "has" method doesn't work $checkFunction = apc_fetch($key); } else { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . '/combiners')); $checkFunction = $cache->has($key); } // Checks if key exists if (false === $checkFunction) { $keyExists = DbFinder::from('sfCombine')->where('AssetsKey', $key)->count(); if (!$keyExists) { $combine = new sfCombine(); $combine->setAssetsKey($key); $combine->setFiles($content); $combine->save(); } $cache->set($key, true); } return $key; }