本文整理汇总了PHP中Locales::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Locales::getLocale方法的具体用法?PHP Locales::getLocale怎么用?PHP Locales::getLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locales
的用法示例。
在下文中一共展示了Locales::getLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Reload the REST information.
* This is only a empty placeholder. The child class can override it.
*
* @author David Pauli <contact@david-pauli.de>
* @since 0.0.0
* @since 0.0.1 Use HTTPRequestMethod enum.
* @since 0.1.0 Use a default Locale.
* @since 0.1.1 Unstatic every attributes.
*/
private function load()
{
// if the REST path empty -> this is the not the implementation or can't get something else
if (InputValidator::isEmpty(self::RESTPATH) || !RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
return;
}
$content = RESTClient::sendWithLocalization(self::RESTPATH, Locales::getLocale());
// if respond is empty
if (InputValidator::isEmpty($content)) {
return;
}
// reset values
$this->resetValues();
if (!InputValidator::isEmptyArrayKey($content, "name")) {
$this->NAME = $content["name"];
}
if (!InputValidator::isEmptyArrayKey($content, "navigationCaption")) {
$this->NAVIGATIONCAPTION = $content["navigationCaption"];
}
if (!InputValidator::isEmptyArrayKey($content, "description")) {
$this->DESCRIPTION = $content["description"];
}
// update timestamp when make the next request
$timestamp = (int) (microtime(true) * 1000);
$this->NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME;
}
示例2: elseif
/**
* Loads the current locale. It works so that it tries to fetch the parameter "lang" from the
* request. If it's not available, then it will try to look for it in the session. If it is not
* there either, it will try to guess the most prefered language according to what the User Agent
* included in the HTTP_ACCEPT_LANGUAGE string sent with the request. If none matches available
* languages we have to use the value of "default_locale" and display the default language.
*
* @private
* @return Returns a reference to a Locale object
*/
function &_loadLocale()
{
$requestLocale =& $this->_request->getValue("lang");
$localeCode = "";
$serverVars =& HttpVars::getServer();
// check if there's something in the request...
// if not, check the session or at least try to
// guess the apropriate languege from the http_accept_lnaguage string
if ($requestLocale) {
// check if it's a valid one
if (Locales::isValidLocale($requestLocale)) {
$localeCode = $requestLocale;
}
} else {
$sessionLocale =& SessionManager::getSessionValue("summaryLang");
if ($sessionLocale) {
$localeCode = $sessionLocale;
} elseif ($this->_config->getValue("use_http_accept_language_detection", HTTP_ACCEPT_LANGUAGE_DETECTION) == 1) {
$localeCode =& $this->_matchHttpAcceptLanguages($serverVars['HTTP_ACCEPT_LANGUAGE']);
}
}
// check if the locale code is correct
// and as a valid resort, use the default one if the locale ist not valid or 'false'
if ($localeCode === false || !Locales::isValidLocale($localeCode)) {
$localeCode = $this->_config->getValue("default_locale");
}
// now put whatever locale value back to the session
SessionManager::setSessionValue("summaryLang", $localeCode);
// load the correct locale
$locale =& Locales::getLocale($localeCode);
return $locale;
}
示例3: perform
/**
* Performs the action.
*/
function perform()
{
// fetch the articles for the given blog
$articles = new Articles();
$blogSettings = $this->_blogInfo->getSettings();
$localeCode = $blogSettings->getValue("locale");
// fetch the default profile as chosen by the administrator
$defaultProfile = $this->_config->getValue("default_rss_profile");
if ($defaultProfile == "" || $defaultProfile == null) {
$defaultProfile = DEFAULT_PROFILE;
}
// fetch the profile
// if the profile specified by the user is not valid, then we will
// use the default profile as configured
$profile = $this->_request->getValue("profile");
if ($profile == "") {
$profile = $defaultProfile;
}
// fetch the category, or set it to '0' otherwise, which will mean
// fetch all the most recent posts from any category
$categoryId = $this->_request->getValue("categoryId");
if (!is_numeric($categoryId)) {
$categoryId = 0;
}
// check if the template is available
$this->_view = new RssView($this->_blogInfo, $profile, array("profile" => $profile, "categoryId" => $categoryId));
// do nothing if the view was already cached
if ($this->_view->isCached()) {
return true;
}
// create an instance of a locale object
$locale = Locales::getLocale($localeCode);
// fetch the posts, though we are going to fetch the same amount in both branches
$amount = $blogSettings->getValue("recent_posts_max", 15);
$t = new Timestamp();
if ($blogSettings->getValue('show_future_posts_in_calendar')) {
$blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0);
} else {
$today = $t->getTimestamp();
$blogArticles = $articles->getBlogArticles($this->_blogInfo->getId(), -1, $amount, $categoryId, POST_STATUS_PUBLISHED, 0, $today);
}
$pm =& PluginManager::getPluginManager();
$pm->setBlogInfo($this->_blogInfo);
$pm->setUserInfo($this->_userInfo);
$result = $pm->notifyEvent(EVENT_POSTS_LOADED, array('articles' => &$blogArticles));
$articles = array();
foreach ($blogArticles as $article) {
$postText = $article->getIntroText();
$postExtendedText = $article->getExtendedText();
$pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postText));
$pm->notifyEvent(EVENT_TEXT_FILTER, array("text" => &$postExtendedText));
$article->setIntroText($postText);
$article->setExtendedText($postExtendedText);
array_push($articles, $article);
}
$this->_view->setValue("locale", $locale);
$this->_view->setValue("posts", $articles);
$this->setCommonData();
return true;
}
示例4: getDateFormatted
/**
* shortuct for formatting the date in the same way that it is expected by
* the "date picker" javascript calendar
*
*�@return a string
*/
function getDateFormatted()
{
include_once PLOG_CLASS_PATH . "class/locale/locales.class.php";
$locale = Locales::getLocale("en_UK");
$dateFormatted = $locale->formatDate($this->getDateObject(), "%d/%m/%Y %H:%M");
return $dateFormatted;
}
示例5: AdminArticleCommentsListView
function AdminArticleCommentsListView($blogInfo, $params = array())
{
$this->AdminTemplatedView($blogInfo, "editcomments");
$blogSettings = $blogInfo->getSettings();
$this->_locale =& Locales::getLocale($blogSettings->getValue("locale"), "en_UK");
$this->_setParameters($params);
$this->_page = $this->getCurrentPageFromRequest();
}
示例6: _getLocale
/**
* @private
*/
function _getLocale()
{
// load the Locale object from the view context or initialize it now
if ($this->_params->keyExists("locale")) {
$this->_locale = $this->_params->getValue("locale");
} else {
$config =& Config::getConfig();
$this->_locale =& Locales::getLocale($config->getValue("default_locale"));
}
}
示例7: perform
/**
* Carries out the specified action
*/
function perform()
{
$this->_view = new AdminHelpView($this->_blogInfo);
$blogSettings = $this->_blogInfo->getSettings();
$locale =& Locales::getLocale($blogSettings->getValue("locale"));
$this->_view->setValue("help", $locale->tr($this->_helpId));
$this->setCommonData();
// better to return true if everything fine
return true;
}
示例8: sendUncachedOutput
function sendUncachedOutput()
{
//$templateService = new TemplateService();
//$template = $templateService->Template( $this->_profile, "summary/rss" );
$config =& Config::getConfig();
$this->_locale =& Locales::getLocale($config->getValue("default_locale"));
$this->_params->setValue("version", new Version());
$this->_params->setValue("locale", $this->_locale);
$this->_template->assign($this->_params->getAsArray());
print $this->_template->fetch($this->_viewId);
}
示例9: AdminLoginAction
/**
* Constructor. If nothing else, it also has to call the constructor of the parent
* class, BlogAction with the same parameters
*/
function AdminLoginAction($actionInfo, $request)
{
$this->Action($actionInfo, $request);
$this->_config =& Config::getConfig();
$this->_locale =& Locales::getLocale($this->_config->getValue("default_locale"));
// data validation
$this->registerFieldValidator("userName", new StringValidator());
$this->registerFieldValidator("userPassword", new StringValidator());
$view = new AdminDefaultView();
$view->setErrorMessage($this->_locale->tr("error_incorrect_username_or_password"));
$this->setValidationErrorView($view);
}
示例10: renderBodyTemplate
function renderBodyTemplate($templateid, $templateFolder)
{
// create a new template service
$ts = new TemplateService();
$messageTemplate = $ts->Template($templateid, $templateFolder);
$messageTemplate->assign("username", $this->username);
$messageTemplate->assign("activeCode", $this->activeCode);
$messageTemplate->assign("activeLink", $this->activeLink);
// FIXME: use which locale?
$locale =& Locales::getLocale();
$messageTemplate->assign("locale", $locale);
// render and return the contents
return $messageTemplate->fetch();
}
示例11: load
/**
* Reload the REST information.
*
* @author David Pauli <contact@david-pauli.de>
* @since 0.0.0
* @since 0.0.1 Use HTTPRequestMethod enum.
* @since 0.1.0 Use a default Locale.
*/
private static function load()
{
// if request method is blocked
if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
return;
}
$content = RESTClient::sendWithLocalization(self::$RESTPATH, Locales::getLocale());
// if respond is empty
if (InputValidator::isEmpty($content)) {
return;
}
// reset values
self::resetValues();
if (!InputValidator::isEmptyArrayKey($content, "name")) {
self::$NAME = $content["name"];
}
if (!InputValidator::isEmptyArrayKey($content, "title")) {
self::$TITLE = $content["title"];
}
if (!InputValidator::isEmptyArrayKey($content, "navigationCaption")) {
self::$NAVIGATIONCAPTION = $content["navigationCaption"];
}
if (!InputValidator::isEmptyArrayKey($content, "shortDescription")) {
self::$SHORTDESCRIPTION = $content["shortDescription"];
}
if (!InputValidator::isEmptyArrayKey($content, "description")) {
self::$DESCRIPTION = $content["description"];
}
if (!InputValidator::isEmptyArrayKey($content, "company")) {
self::$COMPANY = $content["company"];
}
if (!InputValidator::isEmptyArrayKey($content, "contactPerson")) {
self::$CONTACTPERSON = $content["contactPerson"];
}
if (!InputValidator::isEmptyArrayKey($content, "contactPersonJobTitle")) {
self::$CONTACTPERSONJOBTITLE = $content["contactPersonJobTitle"];
}
if (!InputValidator::isEmptyArrayKey($content, "address")) {
self::$ADDRESS = $content["address"];
}
if (!InputValidator::isEmptyArrayKey($content, "phone")) {
self::$PHONE = $content["phone"];
}
if (!InputValidator::isEmptyArrayKey($content, "email")) {
self::$EMAIL = $content["email"];
}
// update timestamp when make the next request
$timestamp = (int) (microtime(true) * 1000);
self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::NEXT_RESPONSE_WAIT_TIME;
}
示例12: render
/**
* Renders the view. It simply gets all the parameters we've been adding to it
* and puts them in the context of the template renderer so that they can be accessed
* as normal parameters from within the template
*/
function render()
{
parent::render();
// to find the template we need, we can use the TemplateService
$ts = new TemplateService();
$template = $ts->AdminTemplate(ADMINLOGIN_TEMPLATE);
// load the default locale
$config =& Config::getConfig();
$locale =& Locales::getLocale($config->getValue("default_locale"));
$this->setValue("locale", $locale);
// assign all the values
$template->assign($this->_params->getAsArray());
// and send the results
print $template->fetch();
}
示例13: MenuRenderer
/**
* Initializes the renderer
*
* @param menu A vaid Menu object
* @param blogInfo A reference to a BlogInfo object containing information of the blog for whom
* we are going to render this menu tree.
* @param userInfo A reference to a UserInfo object containing information of the user for whom
* we are going to render this menu tree, because we need to know which options he/she is allowed
* to see and which not.
*/
function MenuRenderer($menu, $blogInfo, $userInfo)
{
$this->Object();
$this->_menu = $menu;
$this->_blogInfo = $blogInfo;
$this->_userInfo = $userInfo;
$config =& Config::getConfig();
// load the right locale
if ($blogInfo != null) {
$this->_locale =& $blogInfo->getLocale();
} else {
$localeCode = $config->getValue("default_locale");
$this->_locale =& Locales::getLocale($localeCode);
}
}
示例14: perform
function perform()
{
// fetch the validated data
$this->_blogName = Textfilter::filterAllHTML($this->_request->getValue("blogName"));
$this->_ownerId = $this->_request->getValue("blogOwner");
$this->_blogProperties = $this->_request->getValue("properties");
// check that the user really exists
$users = new Users();
$userInfo = $users->getUserInfoFromId($this->_ownerId);
if (!$userInfo) {
$this->_view = new AdminCreateBlogView($this->_blogInfo);
$this->_form->setFieldValidationStatus("blogOwner", false);
$this->setCommonData(true);
return false;
}
// now that we have validated the data, we can proceed to create the user, making
// sure that it doesn't already exists
$blogs = new Blogs();
$blog = new BlogInfo($this->_blogName, $this->_ownerId, "", "");
$blog->setProperties($this->_blogProperties);
$this->notifyEvent(EVENT_PRE_BLOG_ADD, array("blog" => &$blog));
$newBlogId = $blogs->addBlog($blog);
if (!$newBlogId) {
$this->_view = new AdminCreateBlogView($this->_blogInfo);
$this->_form->setFieldValidationStatus("blogName", false);
$this->setCommonData();
return false;
}
// add a default category and a default post
$articleCategories = new ArticleCategories();
$articleCategory = new ArticleCategory("General", "", $newBlogId, true);
$catId = $articleCategories->addArticleCategory($articleCategory);
$config =& Config::getConfig();
$locale =& Locales::getLocale($config->getValue("default_locale"));
$articleTopic = $locale->tr("register_default_article_topic");
$articleText = $locale->tr("register_default_article_text");
$article = new Article($articleTopic, $articleText, array($catId), $this->_ownerId, $newBlogId, POST_STATUS_PUBLISHED, 0, array(), "welcome");
$t = new Timestamp();
$article->setDateObject($t);
$articles = new Articles();
$articles->addArticle($article);
// and inform everyone that everything went ok
$this->notifyEvent(EVENT_POST_BLOG_ADD, array("blog" => &$blog));
$this->_view = new AdminSiteBlogsListView($this->_blogInfo);
$this->_view->setSuccessMessage($this->_locale->pr("blog_added_ok", $blog->getBlog()));
$this->setCommonData();
return true;
}
示例15: render
/**
* Renders the view. It simply gets all the parameters we've been adding to it
* and puts them in the context of the template renderer so that they can be accessed
* as normal parameters from within the template
*/
function render()
{
// set the view character set based on the default locale
$config =& Config::getConfig();
$locale =& Locales::getLocale($config->getValue("default_locale"));
$this->setCharset($locale->getCharset());
parent::render();
// to find the template we need, we can use the TemplateService
$ts = new TemplateService();
$template = $ts->AdminTemplate("dashboard");
$this->setValue("locale", $locale);
// assign all the values
$template->assign($this->_params->getAsArray());
// and send the results
print $template->fetch();
}