当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Translate::clearCache方法代码示例

本文整理汇总了PHP中Zend_Translate::clearCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate::clearCache方法的具体用法?PHP Zend_Translate::clearCache怎么用?PHP Zend_Translate::clearCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Translate的用法示例。


在下文中一共展示了Zend_Translate::clearCache方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cleartranslationcacheAction

 /**
  * Clears the translation cache
  *
  * @return void
  */
 public function cleartranslationcacheAction()
 {
     if (Zend_Translate::hasCache()) {
         Zend_Translate::clearCache();
     }
     $this->_redirect($_SERVER['HTTP_REFERER'], array('code' => 302));
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:12,代码来源:DebugController.php

示例2: updateTransAction

 public function updateTransAction()
 {
     foreach ($this->getRequest()->getParam('trans') as $lang => $trans) {
         $toReplace = array();
         $toReplace[$this->getRequest()->getParam('text')] = $trans;
         $this->getDi()->translationTable->replaceTranslation($toReplace, $lang);
     }
     Zend_Translate::hasCache() && Zend_Translate::clearCache();
 }
开发者ID:grlf,项目名称:eyedock,代码行数:9,代码来源:AdminTransLocalController.php

示例3: editAction

 public function editAction()
 {
     try {
         $model = $this->getModel();
         $dataForm = $this->getForm();
         $form = new Zend_Form();
         $form->addSubForm($dataForm, 'data');
         $form->addElement('submit', $this->view->translate('Save'));
         if ($this->_request->isPost()) {
             $postData = $this->_request->getPost('data');
             if ($dataForm->isValid($postData)) {
                 $this->view->messages = array();
                 $model->fromArray($postData);
                 $stored = $model->store();
                 if (!$stored) {
                     $dataForm->populate($postData);
                     $this->view->messages[] = array('level' => 'failure', 'message' => $this->view->translate('setup_message_write-failed'));
                 } else {
                     $this->view->messages[] = array('level' => 'notice', 'message' => $this->view->translate('setup_message_write-success'));
                     Zend_Translate::clearCache();
                 }
             } else {
                 $this->view->messages[] = array('level' => 'failure', 'message' => 'Es ist ein Fehler aufgetreten. Bitte überprüfen Sie Ihre Eingaben.');
             }
         } else {
             $formData = $model->toArray();
             $dataForm->populate($formData);
         }
         $this->view->form = $form;
     } catch (Setup_Model_FileNotReadableException $exc) {
         $this->_redirectTo('error', array('failure' => $this->view->translate('setup_message_error_read-access', $exc->getMessage())));
     } catch (Setup_Model_FileNotWriteableException $exc) {
         $this->_redirectTo('error', array('failure' => $this->view->translate('setup_message_error_write-access', $exc->getMessage())));
     } catch (Setup_Model_FileNotFoundException $exc) {
         $this->_redirectTo('error', array('failure' => $this->view->translate('setup_message_error_filenotfound', $exc->getMessage())));
     }
     $this->render('edit', null, true);
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:38,代码来源:SetupAbstract.php

示例4: clearAction

 public function clearAction()
 {
     $request = $this->getRequest();
     $cacheType = $request->getParam('cachetype');
     $cacheType = $this->_helper->IdConvert->hexToStr($cacheType);
     $this->_helper->layout()->disableLayout();
     try {
         if ($cacheType != '') {
             $cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache($cacheType);
             $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
             //Zend_Cache::CLEANING_MODE_MATCHING_TAG,array('filecache'));
             $this->_helper->messenger("success", 'Cache ' . $cacheType . ' was successfully cleared.');
             $this->_helper->redirector('index');
         } else {
             $standardcache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('standardcache');
             $standardcache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('standardcache'));
             $rolecache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('rolecache');
             $rolecache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('rolecache'));
             $dictcache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('dictcache');
             $dictcache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('dictcache'));
             $requestcache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('requestcache');
             $requestcache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('requestcache'));
             $longcache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('longcache');
             $longcache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('longcache'));
             $metadata = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('metadata');
             $metadata->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('metadata'));
             $filecache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('filecache');
             $filecache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('filecache'));
             $this->_helper->messenger("success", 'Cache was successfully cleared.');
             $this->_helper->redirector('index');
         }
         Zend_Translate::clearCache();
     } catch (Logic_Cache_Exception $e) {
         $this->_helper->messenger('error', MSG_ERROR, $e);
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:36,代码来源:CacheController.php

示例5: testTestingCacheHandling

 public function testTestingCacheHandling()
 {
     require_once 'Zend/Cache.php';
     $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => dirname(__FILE__) . '/_files/'));
     Zend_Translate::setCache($cache);
     $cache = Zend_Translate::getCache();
     $this->assertTrue($cache instanceof Zend_Cache_Core);
     $this->assertTrue(Zend_Translate::hasCache());
     $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1 (en)'), 'en');
     $adapter = $lang->getAdapter();
     $this->assertTrue($adapter instanceof Zend_Translate_Adapter_Array);
     $adaptercache = $adapter->getCache();
     $this->assertTrue($adaptercache instanceof Zend_Cache_Core);
     Zend_Translate::clearCache();
     $this->assertTrue(Zend_Translate::hasCache());
     Zend_Translate::removeCache();
     $this->assertFalse(Zend_Translate::hasCache());
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:18,代码来源:TranslateTest.php

示例6: saveAction

 public function saveAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNeverRender();
     if (!$this->_request->isPost() || !$this->getRequest()->isXmlHttpRequest()) {
         throw new Ot_Exception_Access('You can not access this method directly');
     }
     $path = realpath(APPLICATION_PATH . '/../overrides/languages');
     if (!is_writable($path)) {
         $retData = array('rc' => '0', 'msg' => $this->view->translate('msg-error-langDirNotWritable'));
         echo Zend_Json::encode($retData);
         return;
     }
     $postFilter = Zend_Registry::get('postFilter');
     $overrides = array();
     $removals = array();
     foreach ($postFilter->getEscaped() as $key => $value) {
         if (preg_match('/^[^#]*#[a-z]*$/i', $key)) {
             $removals[] = preg_replace('/#.*$/i', '', $key);
         } else {
             if ($value != '') {
                 $overrides[$key] = $value;
             }
         }
     }
     ini_set('auto_detect_line_endings', TRUE);
     $newData = array();
     $translate = Zend_Registry::get('Zend_Translate');
     $filename = $path . '/' . $translate->getLocale() . '.csv';
     if (is_file($filename)) {
         $handle = fopen($filename, 'r+');
         while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
             if (isset($overrides[$data[0]])) {
                 $data[1] = $overrides[$data[0]];
                 $newData[] = $data;
                 unset($overrides[$data[0]]);
             } elseif (!in_array($data[0], $removals)) {
                 $newData[] = $data;
             }
         }
         rewind($handle);
         ftruncate($handle, 0);
     } else {
         $handle = fopen($filename, 'w+');
     }
     foreach ($overrides as $key => $value) {
         $newData[] = array($key, $value);
     }
     foreach ($newData as $d) {
         $ret = fputcsv($handle, $d, ";");
         if ($ret === false) {
             $retData = array('rc' => '0', 'msg' => $this->view->translate('msg-error-writingLangFile'));
             echo Zend_Json::encode($retData);
             return;
         }
     }
     ini_set('auto_detect_line_endings', FALSE);
     Zend_Translate::clearCache();
     $logOptions = array('attributeName' => 'translation', 'attributeId' => $translate->getLocale());
     $this->_helper->log(Zend_Log::INFO, 'Language override file modified', $logOptions);
     $retData = array('rc' => '1', 'msg' => $this->view->translate('msg-info-savedLang'));
     echo Zend_Json::encode($retData);
     return;
 }
开发者ID:ncsuwebdev,项目名称:otframework,代码行数:64,代码来源:TranslateController.php

示例7: include_by_locale

 /**
  * Includes all available language files for a certain defined locale.
  *
  * @param string $locale All resources from any module in locale $locale will be loaded
  * @param Boolean $clean Clean old caches?
  */
 public static function include_by_locale($locale, $clean = false)
 {
     if ($clean) {
         Zend_Translate::clearCache();
     }
     // Get list of module => path pairs, and then just the names
     $modules = SS_ClassLoader::instance()->getManifest()->getModules();
     $moduleNames = array_keys($modules);
     // Remove the "project" module from the list - we'll add it back specially later if needed
     global $project;
     if (($idx = array_search($project, $moduleNames)) !== false) {
         array_splice($moduleNames, $idx, 1);
     }
     // Get the order from the config syste,
     $order = Config::inst()->get('i18n', 'module_priority');
     // Find all modules that don't have their order specified by the config system
     $unspecified = array_diff($moduleNames, $order);
     // If the placeholder "other_modules" exists in the order array, replace it by the unspecified modules
     if (($idx = array_search('other_modules', $order)) !== false) {
         array_splice($order, $idx, 1, $unspecified);
     } else {
         array_splice($order, 0, 0, $unspecified);
     }
     // Put the project module back in at the begining if it wasn't specified by the config system
     if (!in_array($project, $order)) {
         array_unshift($order, $project);
     }
     $sortedModules = array();
     foreach ($order as $module) {
         if (isset($modules[$module])) {
             $sortedModules[$module] = $modules[$module];
         }
     }
     $sortedModules = array_reverse($sortedModules, true);
     // Loop in reverse order, meaning the translator with the highest priority goes first
     $translators = array_reverse(self::get_translators(), true);
     foreach ($translators as $priority => $translators) {
         foreach ($translators as $name => $translator) {
             $adapter = $translator->getAdapter();
             // Load translations from modules
             foreach ($sortedModules as $module) {
                 $filename = $adapter->getFilenameForLocale($locale);
                 $filepath = "{$module}/lang/" . $filename;
                 if ($filename && !file_exists($filepath)) {
                     continue;
                 }
                 $adapter->addTranslation(array('content' => $filepath, 'locale' => $locale));
             }
             // Load translations from themes
             // TODO Replace with theme listing once implemented in TemplateManifest
             $themesBase = Director::baseFolder() . '/themes';
             if (is_dir($themesBase)) {
                 foreach (scandir($themesBase) as $theme) {
                     if (strpos($theme, Config::inst()->get('SSViewer', 'theme')) === 0 && file_exists("{$themesBase}/{$theme}/lang/")) {
                         $filename = $adapter->getFilenameForLocale($locale);
                         $filepath = "{$themesBase}/{$theme}/lang/" . $filename;
                         if ($filename && !file_exists($filepath)) {
                             continue;
                         }
                         $adapter->addTranslation(array('content' => $filepath, 'locale' => $locale));
                     }
                 }
             }
             // Add empty translations to ensure the locales are "registered" with isAvailable(),
             // and the next invocation of include_by_locale() doesn't cause a new reparse.
             $adapter->addTranslation(array('content' => array($locale => $locale), 'locale' => $locale, 'usetranslateadapter' => true));
         }
     }
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:75,代码来源:i18n.php

示例8: saveAction

 function saveAction()
 {
     $trans = $this->getRequest()->getParam('trans', array());
     $translationData = $this->grid->getDataSource()->getTDataSource()->getTranslationData($this->getLanguage(), TranslationDataSource_Abstract::FETCH_MODE_ALL);
     $toReplace = array();
     foreach ($trans as $k => $v) {
         $k = base64_decode($k);
         if ($v != $translationData[$k]) {
             $toReplace[$k] = $v;
         }
     }
     if (count($toReplace)) {
         $this->getDi()->translationTable->replaceTranslation($toReplace, $this->language);
         if (Zend_Translate::hasCache()) {
             Zend_Translate::clearCache();
         }
     }
     $_POST['trans'] = $_GET['trans'] = null;
     $this->grid->getRequest()->setParam('trans', null);
     $this->grid->getCompleteRequest()->setParam('trans', null);
     $this->getRequest()->setParam('trans', null);
     $url = $this->makeUrl(null, 'index', null, $this->getRequest()->toArray());
     $this->isAjax() ? $this->redirectAjax($url, ___('Redirect')) : $this->redirectLocation($url);
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:24,代码来源:AdminTransGlobalController.php

示例9: deleteCache

 /**
  * delete translated data from cache (APC)
  */
 private function deleteCache()
 {
     $frontendOptions = array('automatic_serialization' => true);
     $cache = Zend_Cache::factory('Core', 'Apc', $frontendOptions, array());
     Zend_Translate::setCache($cache);
     Zend_Translate::clearCache();
     $this->_redirect('/locale/translate-messages/index/' . $this->_getParam('page', 1));
 }
开发者ID:zelimirus,项目名称:yard,代码行数:11,代码来源:TranslateMessagesController.php

示例10: testSetCacheFromCacheManager

 /**
  * @group ZF-10034
  */
 public function testSetCacheFromCacheManager()
 {
     $configCache = array('translate' => array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 120, 'automatic_serialization' => true)), 'backend' => array('name' => 'Black Hole')));
     $this->bootstrap->registerPluginResource('cachemanager', $configCache);
     $options = $this->_translationOptions;
     $options['cache'] = 'translate';
     $resource = new Zend_Application_Resource_Translate($options);
     $resource->setBootstrap($this->bootstrap);
     $resource->init();
     $this->assertType('Zend_Cache_Core', Zend_Translate::getCache());
     Zend_Translate::clearCache();
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:15,代码来源:TranslateTest.php


注:本文中的Zend_Translate::clearCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。