本文整理汇总了PHP中Context::getI18n方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getI18n方法的具体用法?PHP Context::getI18n怎么用?PHP Context::getI18n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::getI18n方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forward403unless
/**
* Forward the user with HTTP status code 403 and an (optional) message
* based on a boolean check
*
* @param boolean $condition
* @param string $message [optional] The message
*/
public function forward403unless($condition, $message = null)
{
if (!$condition) {
$message = $message === null ? Context::getI18n()->__("You are not allowed to access this page") : htmlentities($message);
if (Context::getUser()->isGuest()) {
Context::setMessage('login_message_err', $message);
Context::setMessage('login_force_redirect', true);
Context::setMessage('login_referer', Context::getRouting()->generate(Context::getRouting()->getCurrentRouteName(), Context::getRequest()->getParameters()));
$this->forward(Context::getRouting()->generate('login_page'), 403);
} else {
$this->getResponse()->setHttpStatus(403);
$this->getResponse()->setTemplate('main/forbidden');
}
}
}
示例2: getI18n
/**
* Return the i18n object
*
* @return \thebuggenie\core\framework\I18n
*/
protected function getI18n()
{
return Context::getI18n();
}
示例3: getPredefinedBreadcrumbLinks
public function getPredefinedBreadcrumbLinks($type, $project = null)
{
$i18n = Context::getI18n();
$links = array();
switch ($type) {
case 'main_links':
$links[] = array('url' => Context::getRouting()->generate('home'), 'title' => $i18n->__('Frontpage'));
$links[] = array('url' => Context::getRouting()->generate('dashboard'), 'title' => $i18n->__('Personal dashboard'));
$links[] = array('title' => $i18n->__('Issues'));
if (Context::getUser()->hasPageAccess('teamlist')) {
$links[] = array('url' => make_url('team_list'), 'title' => $i18n->__('Teams'));
}
if (Context::getUser()->hasPageAccess('clientlist')) {
$links[] = array('url' => make_url('client_list'), 'title' => $i18n->__('Clients'));
}
$links = Event::createNew('core', 'breadcrumb_main_links', null, array(), $links)->trigger()->getReturnList();
if (Context::getUser()->canAccessConfigurationPage()) {
$links[] = array('url' => make_url('configure'), 'title' => $i18n->__('Configure %sitename', array('%sitename' => Settings::getSiteHeaderName())));
}
$links[] = array('url' => Context::getRouting()->generate('about'), 'title' => $i18n->__('About %sitename', array('%sitename' => Settings::getSiteHeaderName())));
$links[] = array('url' => Context::getRouting()->generate('account'), 'title' => $i18n->__('Account details'));
$root_projects = array_merge(\thebuggenie\core\entities\Project::getAllRootProjects(true), \thebuggenie\core\entities\Project::getAllRootProjects(false));
$first = true;
foreach ($root_projects as $project) {
if (!$project->hasAccess()) {
continue;
}
if ($first) {
$first = false;
$links[] = array('separator' => true);
}
$links[] = array('url' => Context::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $project->getName());
}
break;
case 'project_summary':
$links['project_dashboard'] = array('url' => Context::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $i18n->__('Dashboard'));
$links['project_releases'] = array('url' => Context::getRouting()->generate('project_releases', array('project_key' => $project->getKey())), 'title' => $i18n->__('Releases'));
$links['project_roadmap'] = array('url' => Context::getRouting()->generate('project_roadmap', array('project_key' => $project->getKey())), 'title' => $i18n->__('Roadmap'));
$links['project_team'] = array('url' => Context::getRouting()->generate('project_team', array('project_key' => $project->getKey())), 'title' => $i18n->__('Team overview'));
$links['project_statistics'] = array('url' => Context::getRouting()->generate('project_statistics', array('project_key' => $project->getKey())), 'title' => $i18n->__('Statistics'));
$links['project_timeline'] = array('url' => Context::getRouting()->generate('project_timeline', array('project_key' => $project->getKey())), 'title' => $i18n->__('Timeline'));
$links['project_issues'] = array('url' => Context::getRouting()->generate('project_issues', array('project_key' => $project->getKey())), 'title' => $i18n->__('Issues'));
$links = Event::createNew('core', 'breadcrumb_project_links', null, array(), $links)->trigger()->getReturnList();
$links['project_release_center'] = array('url' => Context::getRouting()->generate('project_release_center', array('project_key' => $project->getKey())), 'title' => $i18n->__('Release center'));
$links['project_settings'] = array('url' => Context::getRouting()->generate('project_settings', array('project_key' => $project->getKey())), 'title' => $i18n->__('Settings'));
break;
case 'client_list':
foreach (\thebuggenie\core\entities\Client::getAll() as $client) {
if ($client->hasAccess()) {
$links[] = array('url' => Context::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName());
}
}
break;
case 'team_list':
foreach (\thebuggenie\core\entities\Team::getAll() as $team) {
if ($team->hasAccess()) {
$links[] = array('url' => Context::getRouting()->generate('team_dashboard', array('team_id' => $team->getID())), 'title' => $team->getName());
}
}
break;
case 'configure':
$config_sections = Settings::getConfigSections($i18n);
foreach ($config_sections as $key => $sections) {
foreach ($sections as $section) {
if ($key == Settings::CONFIGURATION_SECTION_MODULES) {
$url = is_array($section['route']) ? make_url($section['route'][0], $section['route'][1]) : make_url($section['route']);
$links[] = array('url' => $url, 'title' => $section['description']);
} else {
$links[] = array('url' => make_url($section['route']), 'title' => $section['description']);
}
}
}
break;
}
return $links;
}
示例4: getPredefinedBreadcrumbLinks
public function getPredefinedBreadcrumbLinks($type, $project = null)
{
$i18n = Context::getI18n();
$links = array();
switch ($type) {
case 'main_links':
$links[] = array('url' => Context::getRouting()->generate('home'), 'title' => $i18n->__('Frontpage'));
$links[] = array('url' => Context::getRouting()->generate('dashboard'), 'title' => $i18n->__('Personal dashboard'));
$links[] = array('title' => $i18n->__('Issues'));
$links[] = array('title' => $i18n->__('Teams'));
$links[] = array('title' => $i18n->__('Clients'));
$links = Event::createNew('core', 'breadcrumb_main_links', null, array(), $links)->trigger()->getReturnList();
if (Context::getUser()->canAccessConfigurationPage()) {
$links[] = array('url' => make_url('configure'), 'title' => $i18n->__('Configure %sitename', array('%sitename' => Settings::getSiteHeaderName())));
}
$links[] = array('url' => Context::getRouting()->generate('about'), 'title' => $i18n->__('About %sitename', array('%sitename' => Settings::getSiteHeaderName())));
$links[] = array('url' => Context::getRouting()->generate('account'), 'title' => $i18n->__('Account details'));
break;
case 'project_summary':
$links['project_dashboard'] = array('url' => Context::getRouting()->generate('project_dashboard', array('project_key' => $project->getKey())), 'title' => $i18n->__('Dashboard'));
$links['project_releases'] = array('url' => Context::getRouting()->generate('project_release_center', array('project_key' => $project->getKey())), 'title' => $i18n->__('Releases'));
$links['project_roadmap'] = array('url' => Context::getRouting()->generate('project_roadmap', array('project_key' => $project->getKey())), 'title' => $i18n->__('Roadmap'));
$links['project_team'] = array('url' => Context::getRouting()->generate('project_team', array('project_key' => $project->getKey())), 'title' => $i18n->__('Team overview'));
$links['project_statistics'] = array('url' => Context::getRouting()->generate('project_statistics', array('project_key' => $project->getKey())), 'title' => $i18n->__('Statistics'));
$links['project_timeline'] = array('url' => Context::getRouting()->generate('project_timeline', array('project_key' => $project->getKey())), 'title' => $i18n->__('Timeline'));
$links['project_issues'] = array('url' => Context::getRouting()->generate('project_issues', array('project_key' => $project->getKey())), 'title' => $i18n->__('Issues'));
$links = Event::createNew('core', 'breadcrumb_project_links', null, array(), $links)->trigger()->getReturnList();
$links['project_release_center'] = array('url' => Context::getRouting()->generate('project_release_center', array('project_key' => $project->getKey())), 'title' => $i18n->__('Release center'));
$links['project_settings'] = array('url' => Context::getRouting()->generate('project_settings', array('project_key' => $project->getKey())), 'title' => $i18n->__('Settings'));
break;
case 'client_list':
foreach (\thebuggenie\core\entities\Client::getAll() as $client) {
if ($client->hasAccess()) {
$links[] = array('url' => Context::getRouting()->generate('client_dashboard', array('client_id' => $client->getID())), 'title' => $client->getName());
}
}
break;
case 'team_list':
foreach (\thebuggenie\core\entities\Team::getAll() as $team) {
if ($team->hasAccess()) {
$links[] = array('url' => Context::getRouting()->generate('team_dashboard', array('team_id' => $team->getID())), 'title' => $team->getName());
}
}
break;
}
return $links;
}
示例5: forward403unless
/**
* Forward the user with HTTP status code 403 and an (optional) message
* based on a boolean check
*
* @param boolean $condition
* @param string $message [optional] The message
*/
public function forward403unless($condition, $message = null)
{
if (!$condition) {
$message = $message === null ? Context::getI18n()->__("You are either not allowed to access this page or don't have access to perform this action") : $message;
if (Context::getUser()->isGuest()) {
Context::setMessage('login_message_err', htmlentities($message));
Context::setMessage('login_force_redirect', true);
Context::setMessage('login_referer', Context::getRouting()->generate(Context::getRouting()->getCurrentRouteName(), Context::getRequest()->getParameters()));
$this->forward(Context::getRouting()->generate('login_page'), Response::HTTP_STATUS_FORBIDDEN);
} elseif (Context::getRequest()->isAjaxCall()) {
$this->getResponse()->setHttpStatus(Response::HTTP_STATUS_FORBIDDEN);
throw new \Exception($message);
} else {
throw new \thebuggenie\core\framework\exceptions\ActionNotAllowedException($message);
}
}
}