本文整理汇总了PHP中Ak::lang方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::lang方法的具体用法?PHP Ak::lang怎么用?PHP Ak::lang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::lang方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentLocale
public function getCurrentLocale()
{
static $current_locale;
if (empty($current_locale)) {
$current_locale = Ak::lang();
$available_locales = $this->getAvailableLocales();
if (!in_array($current_locale, $available_locales)) {
$current_locale = array_shift($available_locales);
}
}
return $current_locale;
}
示例2: rescueActionInPublic
/**
* Attempts to render a static error page based on the
* <tt>$this->getStatusCode</tt> thrown, or just return headers if no such file
* exists. At first, it will try to render a localized static page.
* For example, if a 500 error is being handled Rails and locale is :da,
* it will first attempt to render the file at <tt>public/500.da.html</tt>
* then attempt to render <tt>public/500.html</tt>. If none of them exist,
* the body of the response will be left empty.
*/
public function rescueActionInPublic($Exception)
{
$status = $this->getStatusCode($Exception);
$locale_path = AkConfig::getDir('public') . '/' . $status . '_' . Ak::lang() . '.html';
$path = AkConfig::getDir('public') . '/' . $status . '.html';
if (file_exists($locale_path)) {
$this->render($status, file_get_contents($locale_path));
} elseif (file_exists($path)) {
$this->render($status, file_get_contents($path));
} else {
$this->render($status, '');
}
}
示例3: get_doc_contents
public function get_doc_contents($doc_name)
{
$doc_file = $this->_getdocPath($doc_name, Ak::lang());
if (file_exists($doc_file)) {
return file_get_contents($doc_file);
}
$doc_file = $this->_getTodoDocPath($doc_name, Ak::lang());
if (file_exists($doc_file)) {
$this->is_todo = true;
return file_get_contents($doc_file);
}
$doc_file = $this->_getdocPath($doc_name, 'en');
return @file_get_contents($doc_file);
}
示例4: get_doc_contents
public function get_doc_contents($doc_name)
{
$doc_file = $this->_getdocPath($doc_name, Ak::lang());
return file_exists($doc_file) ? file_get_contents($doc_file) : @file_get_contents($this->_getdocPath($doc_name, 'en'));
}
示例5: expire
function expire()
{
$this->expireAction(array('controller' => 'action_caching', 'action' => 'index', 'lang' => Ak::lang()));
$this->expireAction(array('controller' => 'action_caching', 'action' => 'skip'));
$this->renderNothing(200);
}
示例6: encoding
function encoding()
{
static $encoding;
if (empty($encoding)) {
// This will force system language settings
Ak::t('Akelos');
$encoding = Ak::locale('charset', Ak::lang());
$encoding = empty($encoding) ? 'UTF-8' : $encoding;
}
return $encoding;
}
示例7: _getLocaleForRequest
function _getLocaleForRequest(&$Request)
{
$lang = $this->getNavigationLanguage();
if ($url_locale = $this->getLangFromUrl($Request)) {
$lang = $this->getLocaleFromAlias($url_locale);
}
if (!$this->_canUseLocaleOnCurrentRequest($lang, $Request)) {
$lang = array_shift($this->getPublicLocales());
} elseif (empty($lang)) {
$lang = array_shift($this->getPublicLocales());
}
// This way we store on get_url_locale and on lang the value of $lang on
// a static variable for accessing it application wide
empty($url_locale) ? null : Ak::get_url_locale($url_locale);
Ak::lang($lang);
return $lang;
}
示例8: test_normalized_action_paths
public function test_normalized_action_paths()
{
$this->assertTrue(true,'Need to test that /page is the same cache as /page/index');
$this->_flushCache('xinc.eu');
$cache_this_xinc = date('Y-m-d, H:i:s', time()+30);
$this->get('http://xinc.eu/action_caching/',array(),array(),array('cache_this'=>$cache_this_xinc));
$xinc_cached_normalized = $this->_getActionCache('/'.Ak::lang().'/action_caching/index',array('host'=>'xinc.eu'));
$this->assertTextMatch($cache_this_xinc);
$this->assertEqual($cache_this_xinc,$xinc_cached_normalized);
$this->get('http://xinc.eu/action_caching/index',array(),array(),array('cache_this'=>$cache_this_xinc));
$this->assertTextMatch($cache_this_xinc);
}
示例9: get_language
function get_language()
{
$this->renderText(Ak::lang());
}
示例10: test_update_sweeper_except
public function test_update_sweeper_except()
{
$this->post('http://www.example.com/cache_sweeper2/create', array('first_name' => 'Max', 'last_name' => 'Mustermann'));
$this->assertResponse(302);
$url = $this->getHeader('Location');
$parts = parse_url($url);
$this->showUrl = 'http://www.example.com' . $parts['path'];
$params = preg_split('/\\//', rtrim($this->showUrl, '/'));
$this->userId = $params[count($params) - 1];
$this->_assertCacheNotExists('/' . Ak::lang() . '/cache_sweeper2/show/' . $this->userId, array('host' => 'www.example.com'));
$this->get($this->showUrl);
$this->_assertCacheExists('/' . Ak::lang() . '/cache_sweeper2/show/' . $this->userId, array('host' => 'www.example.com'));
/**
* delete does not call the sweeper, so cache should still exist
*/
$this->post('http://www.example.com/cache_sweeper2/delete/' . $this->userId);
$this->get('http://www.example.com/page_caching/');
$this->_assertCacheExists('/' . Ak::lang() . '/cache_sweeper2/show/' . $this->userId, array('host' => 'www.example.com'));
/**
* but user does not exist anymore
*/
$this->post('http://www.example.com/cache_sweeper2/update/' . $this->userId, array());
$this->assertResponse(404);
}
示例11: _pathFor
function _pathFor($options = array(), $normalize = true)
{
$options = empty($options)?$this->_controller->Request->_route_params:$options;
$options['controller'] = !isset($options['controller']) ? (isset($this->_controller->params['controller']) ?
$this->_controller->params['controller']:null):
$options['controller'];
$options['action'] = !isset($options['action']) ?
(isset($this->_controller->params['action']) ? $this->_controller->params['action'] : null ) :
$options['action'];
$options['id'] = isset($options['id']) ? $options['id']: false;
$options['lang'] = isset($options['lang']) ? $options['lang'] : Ak::lang();
$options['skip_relative_url_root']=true;
$url = $this->_controller->rewrite($this->_controller->rewriteOptions($options));
$parts = parse_url($url);
$path = isset($parts['path'])?$parts['path']:'';
if ($normalize && (!isset($options['action']) || (isset($options['action']) && $options['action']==AK_DEFAULT_ACTION && !strstr($path,'/'.AK_DEFAULT_ACTION)))) {
$path = rtrim($path,'/');
$parts = preg_split('/\/+/',$path);
if(!empty($options['format']) && preg_match('/(\.'.$options['format'].')$/',$parts[count($parts)-1],$matches)) {
$parts[count($parts)-1] = str_replace($matches[1],'',$parts[count($parts)-1]);
}
$parts[] = AK_DEFAULT_ACTION;
$path = implode('/', $parts);
}
$path = rtrim($path,'/');
if(!empty($options['module'])) {
$path.='?module='.$options['module'];
}
return $path;
}
示例12: _getDefaultLocale
function _getDefaultLocale()
{
return Ak::lang();
}
示例13: getDefaultLocale
public function getDefaultLocale()
{
return Ak::lang();
}
示例14: checkForRoutedRequests
public function checkForRoutedRequests(AkRouter &$Router)
{
$this->parameters_from_url = $params = $Router->match($this);
if (!isset($params['controller']) || !$this->isValidControllerName($params['controller'])) {
throw new NoMatchingRouteException('No route matches "' . $this->getPath() . '" with {:method=>:' . $this->getMethod() . '}');
}
if (empty($params['action'])) {
$params['action'] = 'index';
}
if (!$this->isValidActionName($params['action'])) {
throw new NoMatchingRouteException('No action was specified.');
}
if (!empty($params['module'])) {
if (!$this->isValidModuleName($params['module'])) {
throw new DispatchException('Invalid module ' . $params['module'] . '.');
}
} else {
unset($this->_request['module']);
}
isset($params['module']) ? $this->module = $params['module'] : null;
$this->controller = $params['controller'];
$this->action = $params['action'];
if (isset($params['lang'])) {
AkLocaleManager::rememberNavigationLanguage($params['lang']);
Ak::lang($params['lang']);
}
$this->_request = array_merge($this->_request, $params);
}
示例15: checkForRoutedRequests
function checkForRoutedRequests(AkRouter &$Router)
{
$this->parameters_from_url = $params = $Router->match($this);
if (!isset($params['controller']) || !$this->isValidControllerName($params['controller'])) {
throw new DispatchException('No controller was specified.');
}
if (!isset($params['action']) || !$this->isValidActionName($params['action'])) {
throw new DispatchException('No action was specified.');
}
if (isset($params['module']) && !$this->isValidModuleName($params['module'])) {
throw new DispatchException('Invalid module.');
}
isset($params['module']) ? $this->module = $params['module'] : null;
$this->controller = $params['controller'];
$this->action = $params['action'];
if (isset($params['lang'])) {
AkLocaleManager::rememberNavigationLanguage($params['lang']);
Ak::lang($params['lang']);
}
$this->_request = array_merge($this->_request, $params);
}