/** * Clears the translation cache * * @return void */ public function cleartranslationcacheAction() { if (Zend_Translate::hasCache()) { Zend_Translate::clearCache(); } $this->_redirect($_SERVER['HTTP_REFERER'], array('code' => 302)); }
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(); }
/** * ZF-9877 */ public function testSetCacheThroughOptions() { require_once 'Zend/Cache.php'; $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => dirname(__FILE__) . '/_files/')); $translate = new Zend_Translate(array('adapter' => Zend_Translate::AN_ARRAY, 'content' => array('msg1' => 'Message 1 (en)'), 'locale' => 'en', 'cache' => $cache)); $return = Zend_Translate::getCache(); $this->assertTrue($return instanceof Zend_Cache_Core); $this->assertTrue(Zend_Translate::hasCache()); }
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()); }
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); }