本文整理汇总了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));
}
示例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();
}
示例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);
}
示例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);
}
}
示例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());
}
示例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;
}
示例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));
}
}
}
示例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);
}
示例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));
}
示例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();
}