本文整理汇总了PHP中Axis_Locale::setLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Axis_Locale::setLocale方法的具体用法?PHP Axis_Locale::setLocale怎么用?PHP Axis_Locale::setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axis_Locale
的用法示例。
在下文中一共展示了Axis_Locale::setLocale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatchLoopStartup
/**
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
if (Axis_Area::isFrontend() && null !== $request->getParam('locale')) {
$locale = $request->getParam('locale');
} elseif (isset(Axis::session()->locale)) {
$locale = Axis::session()->locale;
} else {
$locale = Axis_Locale::getDefaultLocale();
}
Axis_Locale::setLocale($locale);
}
示例2: changeAction
public function changeAction()
{
$locale = $this->_getParam('lang');
$redirectUrl = $lastUrl = $this->_getBackUrl();
if ($locale) {
$langUrl = Axis_Locale::getLanguageUrl();
if (0 === strpos($redirectUrl, $this->view->secureUrl)) {
$urlPrefix = $this->view->secureUrl . $langUrl;
} else {
$urlPrefix = $this->view->baseUrl . $langUrl;
}
$redirectUrl = substr($lastUrl, strpos($lastUrl, $urlPrefix) + strlen($urlPrefix));
Axis_Locale::setLocale($locale);
}
$this->_redirect($redirectUrl);
}
示例3: _initLocale
protected function _initLocale()
{
$session = Axis::session('install');
$timezone = Axis_Locale::DEFAULT_TIMEZONE;
$locale = Axis_Locale::DEFAULT_LOCALE;
if (is_array($session->locale)) {
$timezone = current($session->locale['timezone']);
}
if ($session->current_locale) {
$locale = $session->current_locale;
}
Axis_Locale::setLocale($locale);
Axis_Locale::setTimezone($timezone);
}
示例4: changeAction
/**
* Change the locale
*
*/
public function changeAction()
{
$locale = $this->_getParam('new_locale');
if ($locale) {
Axis_Locale::setLocale($locale);
}
$this->_redirect($this->_getBackUrl());
}
示例5: createAction
public function createAction()
{
$filename = $this->_getParam('filename');
$alpha = new Zend_Filter_Alnum();
$filename = $alpha->filter($filename);
$filename .= '.xml';
$siteId = $this->_getParam('site_id');
$menu = new Zend_Navigation();
$gmDate = gmdate('Y-m-d');
$oldLocale = Axis_Locale::getLocale();
$locales = Axis::single('locale/language')->select(array('id', 'locale'))->fetchPairs();
foreach ($locales as $languageId => &$_locale) {
Axis_Locale::setLocale($_locale);
$_locale = Axis_Locale::getLanguageUrl();
}
Axis_Locale::setLocale($oldLocale);
$categories = Axis::single('catalog/category')->select('*')->addName()->addKeyWord()->order('cc.lft')->addSiteFilter($siteId)->addDisabledFilter()->fetchAll();
$config = Axis::config()->sitemap;
$changefreq = $config->categories->frequency;
$priority = $config->categories->priority;
$_container = $menu;
$lvl = 0;
foreach ($categories as $_category) {
if (!isset($locales[$_category['language_id']])) {
continue;
}
$uri = $this->view->hurl(array('cat' => array('value' => $_category['id'], 'seo' => $_category['key_word']), 'locale' => $locales[$_category['language_id']], 'controller' => 'catalog', 'action' => 'view'), false, true);
$page = new Zend_Navigation_Page_Uri(array('label' => $_category['name'], 'title' => $_category['name'], 'uri' => $uri, 'order' => $_category['lft'], 'visible' => 'enabled' === $_category['status'] ? true : false, 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority, 'id' => $_category['id'] . $_category['language_id']));
$lvl = $lvl - $_category['lvl'] + 1;
for ($i = 0; $i < $lvl; $i++) {
$_container = $_container->getParent();
}
$lvl = $_category['lvl'];
$_container->addPage($page);
$_container = $page;
}
$products = Axis::single('catalog/product_category')->select()->distinct()->from('catalog_product_category', array())->joinLeft('catalog_product', 'cp.id = cpc.product_id', array('id'))->addName()->addKeyWord()->addActiveFilter()->addDateAvailableFilter()->addSiteFilter($siteId)->columns(array('category_id' => 'cc.id'))->fetchAll();
$changefreq = $config->products->frequency;
$priority = $config->products->priority;
foreach ($products as $_product) {
if (!isset($locales[$_product['language_id']])) {
continue;
}
$uri = $this->view->hurl(array('cat' => array('value' => $_product['id'], 'seo' => $_product['key_word']), 'locale' => $locales[$_product['language_id']], 'controller' => 'catalog', 'action' => 'view'), false, true);
$page = new Zend_Navigation_Page_Uri(array('label' => $_product['name'], 'title' => $_product['name'], 'uri' => $uri, 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority));
$_container = $menu->findBy('id', $_product['category_id'] . $_product['language_id']);
if (null !== $_container) {
$_container->addPage($page);
}
}
$categories = Axis::single('cms/category')->select(array('id', 'parent_id'))->addCategoryContentTable()->columns(array('ccc.link', 'ccc.title', 'ccc.language_id'))->addActiveFilter()->addSiteFilter($siteId)->where('ccc.link IS NOT NULL')->fetchAll();
$changefreq = $config->cms->frequency;
$priority = $config->cms->priority;
foreach ($categories as $_category) {
if (!isset($locales[$_category['language_id']])) {
continue;
}
$title = empty($_category['title']) ? $_category['link'] : $_category['title'];
$page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_category', 'params' => array('cat' => $_category['link'], 'locale' => $locales[$_category['language_id']]), 'id' => 'cms' . $_category['id'] . $_category['language_id'], 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority));
$_container = $menu->findBy('id', 'cms' . $_category['parent_id'] . $_category['language_id']);
if (null === $_container) {
$_container = $menu;
}
$_container->addPage($page);
}
$pages = array();
if ($config->cms->showPages && !empty($categories)) {
$pages = Axis::single('cms/page')->select(array('id', 'name'))->join(array('cpca' => 'cms_page_category'), 'cp.id = cpca.cms_page_id', 'cms_category_id')->join('cms_page_content', 'cp.id = cpc.cms_page_id', array('link', 'title', 'language_id'))->where('cp.is_active = 1')->where('cpca.cms_category_id IN (?)', array_keys($categories))->fetchAll();
foreach ($pages as $_page) {
$title = empty($_page['title']) ? $_page['link'] : $_page['title'];
$page = new Zend_Navigation_Page_Mvc(array('label' => $title, 'title' => $title, 'route' => 'cms_page', 'params' => array('page' => $_page['link'], 'locale' => $locales[$_page['language_id']]), 'lastmod' => $gmDate, 'changefreq' => $changefreq, 'priority' => $priority));
$_container = $menu->findBy('id', 'cms' . $_page['cms_category_id'] . $_page['language_id']);
if (null !== $_container) {
$_container->addPage($page);
}
}
}
$content = $this->view->navigation()->sitemap($menu)->setUseSitemapValidators(false)->render();
$this->getResponse()->clearAllHeaders()->setHeader('Content-Description', 'File Transfer', true)->setHeader('Content-Type', 'application/octet-stream', true)->setHeader('Content-Disposition', 'attachment; filename=' . $filename, true)->setHeader('Content-Transfer-Encoding', 'binary', true)->setHeader('Expires', '0', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Pragma', 'public', true);
$this->getResponse()->setBody($content);
}
示例6: changeAction
/**
* Change the locale
*
*/
public function changeAction()
{
$locale = $this->_getParam('new_locale');
if ($locale) {
Axis_Locale::setLocale($locale);
}
$this->_redirect($this->getRequest()->getServer('HTTP_REFERER'));
}
示例7: setLocale
/**
* Set the locale to be used for email template and subject
* Locale will be automatically switched back after calling the send method
*
* @param string $locale Locale code
*/
public function setLocale($locale)
{
$this->_locale = Axis_Locale::getLocale()->toString();
Axis_Locale::setLocale($locale);
}