本文整理汇总了PHP中Language::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getCode方法的具体用法?PHP Language::getCode怎么用?PHP Language::getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::getCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLanguage
/**
* Test the Language class.
*
* @return void
* @access public
*/
public function testLanguage()
{
$l = new Language();
$this->assertEquals($l->getLanguage('eng'), 'English');
$this->assertEquals($l->getLanguage('??'), 'Unknown');
$this->assertEquals($l->getCode('English'), 'eng');
$this->assertEquals($l->getCode('???'), false);
}
示例2: GetURI
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
{
$languageObj = new Language($p_languageId);
if (!$languageObj->exists()) {
return new PEAR_Error(getGS('Language does not exist.'));
}
$uri = $GLOBALS['Campsite']['SUBDIR'] . '/' . $languageObj->getCode() . '/';
if (!is_null($p_issueNo) && is_null($p_articleNo)) {
$issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
if (!$issueObj->exists()) {
return new PEAR_Error(getGS('Issue does not exist.'));
}
$uri .= $issueObj->getUrlName() . '/';
}
if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
$sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
if (!$sectionObj->exists()) {
return new PEAR_Error(getGS('Section does not exist.'));
}
$uri .= $sectionObj->getUrlName() . '/';
}
if (!is_null($p_articleNo)) {
$articleObj = new Article($p_languageId, $p_articleNo);
if (!$articleObj->exists()) {
return new PEAR_Error(getGS('Article does not exist.'));
}
$issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
$sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
$uri .= $issueObj->getUrlName() . '/';
$uri .= $sectionObj->getUrlName() . '/';
$uri .= $articleObj->getUrlName() . '/';
}
return $uri;
}
示例3: GetURI
public static function GetURI($p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null)
{
$translator = \Zend_Registry::get('container')->getService('translator');
$languageObj = new Language($p_languageId);
if (!$languageObj->exists()) {
return new PEAR_Error($translator->trans('Language does not exist.'));
}
$uri = '/' . $languageObj->getCode() . '/';
if (!is_null($p_issueNo) && is_null($p_articleNo)) {
$issueObj = new Issue($p_publicationId, $p_languageId, $p_issueNo);
if (!$issueObj->exists()) {
return new PEAR_Error($translator->trans('Issue does not exist.'));
}
$uri .= $issueObj->getUrlName() . '/';
}
if (!is_null($p_sectionNo) && is_null($p_articleNo)) {
$sectionObj = new Section($p_publicationId, $p_issueNo, $p_languageId, $p_sectionNo);
if (!$sectionObj->exists()) {
return new PEAR_Error($translator->trans('Section does not exist.'));
}
$uri .= $sectionObj->getUrlName() . '/';
}
if (!is_null($p_articleNo)) {
$articleObj = new Article($p_languageId, $p_articleNo);
if (!$articleObj->exists()) {
return new PEAR_Error($translator->trans('Article does not exist.'));
}
$issueObj = new Issue($p_publicationId, $p_languageId, $articleObj->getIssueNumber());
$sectionObj = new Section($p_publicationId, $articleObj->getIssueNumber(), $p_languageId, $articleObj->getSectionNumber());
$uri .= $issueObj->getUrlName() . '/';
$uri .= $sectionObj->getUrlName() . '/';
$uri .= $articleObj->getUrlName() . '/';
}
return $uri;
}
示例4: getFirstLetterData
/**
* @since 1.16.3
* @return array
*/
public function getFirstLetterData()
{
if ($this->firstLetterData === null) {
$cache = ObjectCache::getLocalServerInstance(CACHE_ANYTHING);
$cacheKey = $cache->makeKey('first-letters', $this->locale, $this->digitTransformLanguage->getCode(), self::getICUVersion(), self::FIRST_LETTER_VERSION);
$this->firstLetterData = $cache->getWithSetCallback($cacheKey, $cache::TTL_WEEK, function () {
return $this->fetchFirstLetterData();
});
}
return $this->firstLetterData;
}
示例5:
function __construct($page, $conds, $langObj = null)
{
parent::__construct($page->getContext());
$this->mIndexField = 'am_title';
$this->mPage = $page;
$this->mConds = $conds;
// FIXME: Why does this need to be set to DIR_DESCENDING to produce ascending ordering?
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
$this->mLimitsShown = [20, 50, 100, 250, 500, 5000];
global $wgContLang;
$this->talk = $this->msg('talkpagelinktext')->escaped();
$this->lang = $langObj ? $langObj : $wgContLang;
$this->langcode = $this->lang->getCode();
$this->foreign = !$this->lang->equals($wgContLang);
$request = $this->getRequest();
$this->filter = $request->getVal('filter', 'all');
if ($this->filter === 'all') {
$this->custom = null;
// So won't match in either case
} else {
$this->custom = $this->filter === 'unmodified';
}
$prefix = $this->getLanguage()->ucfirst($request->getVal('prefix', ''));
$prefix = $prefix !== '' ? Title::makeTitleSafe(NS_MEDIAWIKI, $request->getVal('prefix', null)) : null;
if ($prefix !== null) {
$this->displayPrefix = $prefix->getDBkey();
$this->prefix = '/^' . preg_quote($this->displayPrefix, '/') . '/i';
} else {
$this->displayPrefix = false;
$this->prefix = false;
}
// The suffix that may be needed for message names if we're in a
// different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
if ($this->foreign) {
$this->suffix = '/' . $this->langcode;
} else {
$this->suffix = '';
}
}
示例6: inLanguage
/**
* Request the message in any language that is supported.
* As a side effect interface message status is unconditionally
* turned off.
* @param $lang Mixed: language code or Language object.
* @return Message: $this
*/
public function inLanguage($lang)
{
if ($lang instanceof Language || $lang instanceof StubUserLang) {
$this->language = $lang;
} elseif (is_string($lang)) {
if ($this->language->getCode() != $lang) {
$this->language = Language::factory($lang);
}
} else {
$type = gettype($lang);
throw new MWException(__METHOD__ . " must be " . "passed a String or Language object; {$type} given");
}
$this->interface = false;
return $this;
}
示例7: getGroupDescription
/**
* Gets the description of a group. This is a bit slow thing to do for
* thousand+ groups, so some caching is involved.
* @param $group MessageGroup
* @return string Plain text
*/
public function getGroupDescription(MessageGroup $group)
{
$code = $this->lang->getCode();
$cache = wfGetCache(CACHE_ANYTHING);
$key = wfMemckey("translate-groupdesc-{$code}-" . $group->getId());
$desc = $cache->get($key);
if (is_string($desc)) {
return $desc;
}
$realFunction = array('MessageCache', 'singleton');
if (is_callable($realFunction)) {
$mc = MessageCache::singleton();
} else {
global $wgMessageCache;
$mc = $wgMessageCache;
}
$desc = $mc->transform($group->getDescription(), true, $this->lang);
$cache->set($key, $desc);
return $desc;
}
示例8: RemoteLanguageManager
function RemoteLanguageManager()
{
$version = str_replace('.', '_', VERSION);
$language_xml = @file_get_contents('http://update.atutor.ca/languages/' . $version . '/languages.xml');
if ($language_xml === FALSE) {
// fix for bug #2896
$language_xml = @file_get_contents('http://update.atutor.ca/languages/1_5_3/languages.xml');
}
if ($language_xml !== FALSE) {
$languageParser = new LanguagesParser();
$languageParser->parse($language_xml);
$this->numLanguages = $languageParser->getNumLanguages();
for ($i = 0; $i < $this->numLanguages; $i++) {
$thisLanguage = new Language($languageParser->getLanguage($i));
$this->availableLanguages[$thisLanguage->getCode()][$thisLanguage->getCharacterSet()] = $thisLanguage;
}
} else {
$this->numLanguages = 0;
$this->availableLanguages = array();
}
}
示例9: array
function __construct($page, $conds, $langObj = null)
{
parent::__construct();
$this->mIndexField = 'am_title';
$this->mPage = $page;
$this->mConds = $conds;
$this->mDefaultDirection = true;
// always sort ascending
$this->mLimitsShown = array(20, 50, 100, 250, 500, 5000);
global $wgLang, $wgContLang, $wgRequest;
$this->talk = htmlspecialchars(wfMsg('talkpagelinktext'));
$this->lang = $langObj ? $langObj : $wgContLang;
$this->langcode = $this->lang->getCode();
$this->foreign = $this->langcode != $wgContLang->getCode();
$request = $wgRequest;
$this->filter = $request->getVal('filter', 'all');
if ($this->filter === 'all') {
$this->custom = null;
// So won't match in either case
} else {
$this->custom = $this->filter == 'unmodified';
}
$prefix = $wgLang->ucfirst($wgRequest->getVal('prefix', ''));
$prefix = $prefix != '' ? Title::makeTitleSafe(NS_MEDIAWIKI, $wgRequest->getVal('prefix', null)) : null;
if ($prefix !== null) {
$this->displayPrefix = $prefix->getDBkey();
$this->prefix = '/^' . preg_quote($this->displayPrefix) . '/i';
} else {
$this->displayPrefix = false;
$this->prefix = false;
}
// The suffix that may be needed for message names if we're in a
// different language (eg [[MediaWiki:Foo/fr]]: $suffix = '/fr'
if ($this->foreign) {
$this->suffix = '/' . $this->langcode;
} else {
$this->suffix = '';
}
}
示例10: getURL
/**
* Returns a URL to the feed
*
* @param $format string Feed format, 'rss' or 'atom'
* @return String
*/
public function getURL($format)
{
global $wgContLang;
$options = array('action' => 'featuredfeed', 'feed' => $this->name, 'feedformat' => $format);
if ($this->options['inUserLanguage'] && $this->language->getCode() != $wgContLang->getCode()) {
$options['language'] = $this->language->getCode();
}
return wfScript('api') . '?' . wfArrayToCGI($options);
}
示例11: copyToAll
<fieldset class="plain" style="margin-top: 13px">
<input type="submit" name="Save" value="<?php
echo $translator->trans('Save');
?>
" class="save-button" />
</fieldset>
</form>
</div>
<?php
// Load tinymce once for all textareas
if (count($loadAsRichtext) > 0) {
$languageSelectedObj = new Language((int) camp_session_get('LoginLanguageId', 0));
$editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageSelectedObj->getCode();
$editorOptions = array('max_chars' => $captionLimit, 'toolbar_length' => 15);
editor_load_tinymce($loadAsRichtext, $g_user, $editorLanguage, $editorOptions);
}
?>
<script type="text/javascript">
/**
* Copy field value to all fields of that name.
*
* @param string field
* @param int imageId
*
* @return void
*/
function copyToAll(field, imageId)
示例12: array
$f_language_id = Input::Get('Language', 'int', 0);
if (!Input::IsValid()) {
camp_html_display_error($translator->trans('Invalid input: $1', array('$1' => Input::GetErrorString())), $_SERVER['REQUEST_URI']);
exit;
}
$publicationObj = new Publication($f_publication_id);
$issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
$newSectionNumber = Section::GetUnusedSectionNumber($f_publication_id, $f_issue_number);
$topArray = array('Pub' => $publicationObj, 'Issue' => $issueObj);
camp_html_content_top($translator->trans('Add new section', array(), 'sections'), $topArray, true, true, array($translator->trans("Sections") => "/{$ADMIN}/sections/?Pub={$f_publication_id}&Issue={$f_issue_number}&Language={$f_language_id}"));
$controller->view->headTitle($translator->trans('Add new section', array(), 'sections') . ' - Newscoop Admin', 'SET');
$languageObj = new Language($f_language_id);
if (!is_object($languageObj)) {
$languageObj = new Language(1);
}
$editorLanguage = camp_session_get('TOL_Language', $languageObj->getCode());
editor_load_tinymce('f_description', $g_user, 0, $editorLanguage, 'section');
?>
<p>
<form name="section_add" method="POST" action="/<?php
echo $ADMIN;
?>
/sections/do_add.php" onsubmit="return <?php
camp_html_fvalidate();
?>
;">
<?php
echo SecurityToken::FormParameter();
?>
<table border="0" cellspacing="0" cellpadding="0" class="box_table">
<tr>
示例13: putGS
?>
"><span></span>x</a>
<a class="edit" title="<?php
putGS('Edit');
?>
"><?php
putGS('Edit');
?>
</a>
<span class="open" title="<?php
putGS('Click to edit');
?>
">
<span><?php
echo $topicLanguage->getCode();
?>
</span>
<strong><?php
echo htmlspecialchars($topicName);
?>
</strong>
</span>
<form method="post" action="/<?php
echo $ADMIN;
?>
/topics/do_edit.php" onsubmit="return validate(this);">
<?php
echo SecurityToken::FormParameter();
?>
示例14: onTitleGetLangVariants
/**
* Purge a limited set of language variants on Chinese wikis
*
* See BAC-1278 / BAC-698 for details
*
* @param Language $contLang
* @param array $variants
* @return bool
* @author macbre
*/
static function onTitleGetLangVariants(Language $contLang, array &$variants)
{
switch ($contLang->getCode()) {
case 'zh':
// skin displays links to these variants only
$variants = ['zh-hans', 'zh-hant'];
break;
}
return true;
}
示例15: processItem
/**
* Process item
* @param Article $article
* @return array
*/
public function processItem($article)
{
global $g_user, $Campsite;
$translator = \Zend_Registry::get('container')->getService('translator');
$editorService = \Zend_Registry::get('container')->getService('newscoop.editor');
$articleLink = $editorService->getLink($article);
$articleLinkParams = $editorService->getLinkParameters($article);
$articleLinkParamsTranslate = $articleLinkParams . '&f_action=translate&f_action_workflow=' . $article->getWorkflowStatus() . '&f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
$previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $editorService->getLinkParameters($article);
$htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . $translator->trans('Preview') . '">' . $translator->trans('Preview') . '</a>';
$translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
$htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . $translator->trans('Translate') . '">' . $translator->trans('Translate') . '</a>';
$lockInfo = '';
$lockHighlight = false;
$timeDiff = camp_time_diff_str($article->getLockTime());
if ($article->isLocked() && $timeDiff['days'] <= 0) {
$lockUser = new User($article->getLockedByUser());
if ($timeDiff['hours'] > 0) {
$lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['hours'], '$4' => $timeDiff['minutes']), 'articles');
} else {
$lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['minutes']), 'articles');
}
if ($article->getLockedByUser() != $g_user->getUserId()) {
$lockHighlight = true;
}
}
$tmpUser = new User($article->getCreatorId());
$tmpArticleType = new ArticleType($article->getType());
$tmpAuthor = new Author();
$articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
foreach ((array) $articleAuthors as $author) {
if (strtolower($author->getAuthorType()->getName()) == 'author') {
$tmpAuthor = $author;
break;
}
}
if (!$tmpAuthor->exists() && isset($articleAuthors[0])) {
$tmpAuthor = $articleAuthors[0];
}
$onFrontPage = $article->onFrontPage() ? $translator->trans('Yes') : $translator->trans('No');
$onSectionPage = $article->onSectionPage() ? $translator->trans('Yes') : $translator->trans('No');
$imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true);
$topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true);
$commentsNo = '';
if ($article->commentsEnabled()) {
global $controller;
$repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
$filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId());
$params = array('sFilter' => $filter);
$commentsNo = $repositoryComments->getCount($params);
} else {
$commentsNo = 'No';
}
// get language code
$language = new Language($article->getLanguageId());
return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, $translator->trans('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != null ? $translator->trans('Yes') : $translator->trans('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
}