当前位置: 首页>>代码示例>>PHP>>正文


PHP MessageCache::singleton方法代码示例

本文整理汇总了PHP中MessageCache::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageCache::singleton方法的具体用法?PHP MessageCache::singleton怎么用?PHP MessageCache::singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageCache的用法示例。


在下文中一共展示了MessageCache::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initMessagesHref

 /** Build $this->messages array */
 private function initMessagesHref()
 {
     # List of default messages for the sidebar:
     $URL_messages = array('mainpage', 'portal-url', 'currentevents-url', 'recentchanges-url', 'randompage-url', 'helppage');
     foreach ($URL_messages as $m) {
         $titleName = MessageCache::singleton()->get($m);
         $title = Title::newFromText($titleName);
         $this->messages[$m]['href'] = $title->getLocalURL();
     }
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:11,代码来源:SideBarTest.php

示例2: setUp

 protected function setUp()
 {
     global $wgLanguageCode, $wgContLang;
     if ($wgLanguageCode != $wgContLang->getCode()) {
         throw new MWException("Error in MediaWikiLangTestCase::setUp(): " . "\$wgLanguageCode ('{$wgLanguageCode}') is different from " . "\$wgContLang->getCode() (" . $wgContLang->getCode() . ")");
     }
     parent::setUp();
     $this->setUserLang('en');
     // For mainpage to be 'Main Page'
     $this->setContentLang('en');
     MessageCache::singleton()->disable();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:MediaWikiLangTestCase.php

示例3: setUp

 public function setUp()
 {
     global $wgLanguageCode, $wgLang, $wgContLang;
     self::$oldLang = $wgLang;
     self::$oldContLang = $wgContLang;
     if ($wgLanguageCode != $wgContLang->getCode()) {
         throw new MWException("Error in MediaWikiLangTestCase::setUp(): " . "\$wgLanguageCode ('{$wgLanguageCode}') is different from " . "\$wgContLang->getCode() (" . $wgContLang->getCode() . ")");
     }
     $wgLanguageCode = 'en';
     # For mainpage to be 'Main Page'
     $wgContLang = $wgLang = Language::factory($wgLanguageCode);
     MessageCache::singleton()->disable();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:MediaWikiLangTestCase.php

示例4: setUp

 public function setUp()
 {
     global $wgLanguageCode, $wgLang, $wgContLang;
     self::$oldLang = $wgLang;
     self::$oldContLang = $wgContLang;
     if ($wgLanguageCode != $wgContLang->getCode()) {
         die("nooo!");
     }
     $wgLanguageCode = 'en';
     # For mainpage to be 'Main Page'
     $wgContLang = $wgLang = Language::factory($wgLanguageCode);
     MessageCache::singleton()->disable();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:13,代码来源:MediaWikiLangTestCase.php

示例5: setUp

 protected function setUp()
 {
     global $wgLanguageCode, $wgContLang;
     parent::setUp();
     if ($wgLanguageCode != $wgContLang->getCode()) {
         throw new MWException("Error in MediaWikiLangTestCase::setUp(): " . "\$wgLanguageCode ('{$wgLanguageCode}') is different from " . "\$wgContLang->getCode() (" . $wgContLang->getCode() . ")");
     }
     $langCode = 'en';
     # For mainpage to be 'Main Page'
     $langObj = Language::factory($langCode);
     $this->setMwGlobals(array('wgLanguageCode' => $langCode, 'wgLang' => $langObj, 'wgContLang' => $langObj));
     MessageCache::singleton()->disable();
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:13,代码来源:MediaWikiLangTestCase.php

示例6: setUp

 protected function setUp()
 {
     global $wgLanguageCode, $wgContLang;
     parent::setUp();
     if ($wgLanguageCode != $wgContLang->getCode()) {
         throw new MWException("Error in MediaWikiLangTestCase::setUp(): " . "\$wgLanguageCode ('{$wgLanguageCode}') is different from " . "\$wgContLang->getCode() (" . $wgContLang->getCode() . ")");
     }
     // HACK: Call getLanguage() so the real $wgContLang is cached as the user language
     // rather than our fake one. This is to avoid breaking other, unrelated tests.
     RequestContext::getMain()->getLanguage();
     $langCode = 'en';
     # For mainpage to be 'Main Page'
     $langObj = Language::factory($langCode);
     $this->setMwGlobals(array('wgLanguageCode' => $langCode, 'wgLang' => $langObj, 'wgContLang' => $langObj));
     MessageCache::singleton()->disable();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:16,代码来源:MediaWikiLangTestCase.php

示例7: onMessageCacheGet

 /**
  * From WikimediaMessages
  *
  * @return bool
  */
 public static function onMessageCacheGet(&$lcKey)
 {
     global $wgLanguageCode;
     static $keys = array('centralauth-groupname');
     if (in_array($lcKey, $keys, true)) {
         $prefixedKey = "miraheze-{$lcKey}";
         // MessageCache uses ucfirst if ord( key ) is < 128, which is true of all
         // of the above.  Revisit if non-ASCII keys are used.
         $ucKey = ucfirst($lcKey);
         $cache = MessageCache::singleton();
         if ($cache->getMsgFromNamespace($ucKey, $wgLanguageCode) === false) {
             $lcKey = $prefixedKey;
         }
     }
     return true;
 }
开发者ID:reviforks,项目名称:MirahezeMagic,代码行数:21,代码来源:MirahezeMagic.hooks.php

示例8: onMessageCacheGet

 /**
  * When core requests certain messages, change the key to a Kol-Zchut version.
  *
  * @note Don't make this a closure, it causes the Database Dumps to fail.
  *   See https://bugs.php.net/bug.php?id=52144
  *
  * @param String &$lcKey message key to check and possibly convert
  *
  * @return bool
  */
 public static function onMessageCacheGet(&$lcKey)
 {
     global $wgLanguageCode;
     static $keys = array('aboutpage', 'aboutsite', 'copyright', 'copyrightwarning', 'deletereason-dropdown', 'edithelppage', 'hidetoc', 'showtoc', 'lastmodifiedat', 'lastmodifiedatby', 'login', 'logouttext', 'nav-login-createaccount', 'userlogin', 'userloginnocreate', 'logout', 'userlogout', 'notloggedin', 'nologin', 'gotaccountlink', 'createaccounterror', 'signupstart', 'noarticletext', 'noarticletext-nopermission', 'protect-dropdown', 'siteuser', 'siteusers', 'tagline', 'tooltip-p-logo', 'tooltip-n-mainpage', 'tooltip-n-mainpage-description', "accesskey-p-logo", "accesskey-n-mainpage", 'enotif_body_intro_deleted', 'enotif_body_intro_created', 'enotif_body_intro_moved', 'enotif_body_intro_restored', 'enotif_body_intro_changed', 'enotif_lastvisited', 'enotif_lastdiff', 'enotif_body', 'search-nonefound', 'upload', 'userpage', 'helena-disclaimers', 'wr-langlinks-label');
     if (in_array($lcKey, $keys, true)) {
         $prefixedKey = "kz-{$lcKey}";
         // MessageCache uses ucfirst if ord( key ) is < 128, which is true of all
         // of the above.  Revisit if non-ASCII keys are used.
         $ucKey = ucfirst($lcKey);
         $cache = MessageCache::singleton();
         if ($cache->getMsgFromNamespace($ucKey, $wgLanguageCode) === false) {
             $lcKey = $prefixedKey;
         }
     }
     return true;
 }
开发者ID:kolzchut,项目名称:mediawiki-extensions-WRMessages,代码行数:26,代码来源:WRMessages.hooks.php

示例9: getContent

 /**
  * @param $title Title
  * @return null|string
  */
 protected function getContent($title)
 {
     if ($title->getNamespace() === NS_MEDIAWIKI) {
         // The first "true" is to use the database, the second is to use the content langue
         // and the last one is to specify the message key already contains the language in it ("/de", etc.)
         $text = MessageCache::singleton()->get($title->getDBkey(), true, true, true);
         return $text === false ? '' : $text;
     }
     if (!$title->isCssJsSubpage() && !$title->isCssOrJsPage()) {
         return null;
     }
     $revision = Revision::newFromTitle($title, false, Revision::READ_NORMAL);
     if (!$revision) {
         return null;
     }
     return $revision->getRawText();
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:21,代码来源:ResourceLoaderWikiModule.php

示例10: initMessagesHref

 /** Build $this->messages array */
 private function initMessagesHref()
 {
     # List of default messages for the sidebar. The sidebar doesn't care at
     # all whether they are full URLs, interwiki links or local titles.
     $URL_messages = array('mainpage', 'portal-url', 'currentevents-url', 'recentchanges-url', 'randompage-url', 'helppage');
     # We're assuming that isValidURI works as advertised: it's also
     # tested separately, in tests/phpunit/includes/HttpTest.php.
     foreach ($URL_messages as $m) {
         $titleName = MessageCache::singleton()->get($m);
         if (Http::isValidURI($titleName)) {
             $this->messages[$m]['href'] = $titleName;
         } else {
             $title = Title::newFromText($titleName);
             $this->messages[$m]['href'] = $title->getLocalURL();
         }
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:18,代码来源:SideBarTest.php

示例11: testFullKeyBehaviour

 /**
  * There's a fallback case where the message key is given as fully qualified -- this
  * should ignore the passed $lang and use the language from the key
  *
  * @dataProvider provideMessagesForFullKeys
  */
 public function testFullKeyBehaviour($message, $lang, $expectedContent)
 {
     $result = MessageCache::singleton()->get($message, true, $lang, true);
     $this->assertEquals($expectedContent, $result, "Full key message fallback failed.");
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:11,代码来源:MessageCacheTest.php

示例12: composeCommonMailtext

 /**
  * Generate the generic "this page has been changed" e-mail text.
  */
 private function composeCommonMailtext()
 {
     global $wgPasswordSender, $wgNoReplyAddress;
     global $wgEnotifFromEditor, $wgEnotifRevealEditorAddress;
     global $wgEnotifImpersonal, $wgEnotifUseRealName;
     $this->composed_common = true;
     # You as the WikiAdmin and Sysops can make use of plenty of
     # named variables when composing your notification emails while
     # simply editing the Meta pages
     $keys = array();
     $postTransformKeys = array();
     $pageTitleUrl = $this->title->getCanonicalURL();
     $pageTitle = $this->title->getPrefixedText();
     if ($this->oldid) {
         // Always show a link to the diff which triggered the mail. See bug 32210.
         $keys['$NEWPAGE'] = "\n\n" . wfMessage('enotif_lastdiff', $this->title->getCanonicalURL(array('diff' => 'next', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         if (!$wgEnotifImpersonal) {
             // For personal mail, also show a link to the diff of all changes
             // since last visited.
             $keys['$NEWPAGE'] .= "\n\n" . wfMessage('enotif_lastvisited', $this->title->getCanonicalURL(array('diff' => '0', 'oldid' => $this->oldid)))->inContentLanguage()->text();
         }
         $keys['$OLDID'] = $this->oldid;
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('changed')->inContentLanguage()->text();
     } else {
         # clear $OLDID placeholder in the message template
         $keys['$OLDID'] = '';
         $keys['$NEWPAGE'] = '';
         // Deprecated since MediaWiki 1.21, not used by default. Kept for backwards-compatibility.
         $keys['$CHANGEDORCREATED'] = wfMessage('created')->inContentLanguage()->text();
     }
     $keys['$PAGETITLE'] = $this->title->getPrefixedText();
     $keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL();
     $keys['$PAGEMINOREDIT'] = $this->minorEdit ? wfMessage('minoredit')->inContentLanguage()->text() : '';
     $keys['$UNWATCHURL'] = $this->title->getCanonicalURL('action=unwatch');
     if ($this->editor->isAnon()) {
         # real anon (user:xxx.xxx.xxx.xxx)
         $keys['$PAGEEDITOR'] = wfMessage('enotif_anon_editor', $this->editor->getName())->inContentLanguage()->text();
         $keys['$PAGEEDITOR_EMAIL'] = wfMessage('noemailtitle')->inContentLanguage()->text();
     } else {
         $keys['$PAGEEDITOR'] = $wgEnotifUseRealName && $this->editor->getRealName() !== '' ? $this->editor->getRealName() : $this->editor->getName();
         $emailPage = SpecialPage::getSafeTitleFor('Emailuser', $this->editor->getName());
         $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalURL();
     }
     $keys['$PAGEEDITOR_WIKI'] = $this->editor->getUserPage()->getCanonicalURL();
     $keys['$HELPPAGE'] = wfExpandUrl(Skin::makeInternalOrExternalUrl(wfMessage('helppage')->inContentLanguage()->text()));
     # Replace this after transforming the message, bug 35019
     $postTransformKeys['$PAGESUMMARY'] = $this->summary == '' ? ' - ' : $this->summary;
     // Now build message's subject and body
     // Messages:
     // enotif_subject_deleted, enotif_subject_created, enotif_subject_moved,
     // enotif_subject_restored, enotif_subject_changed
     $this->subject = wfMessage('enotif_subject_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'])->text();
     // Messages:
     // enotif_body_intro_deleted, enotif_body_intro_created, enotif_body_intro_moved,
     // enotif_body_intro_restored, enotif_body_intro_changed
     $keys['$PAGEINTRO'] = wfMessage('enotif_body_intro_' . $this->pageStatus)->inContentLanguage()->params($pageTitle, $keys['$PAGEEDITOR'], $pageTitleUrl)->text();
     $body = wfMessage('enotif_body')->inContentLanguage()->plain();
     $body = strtr($body, $keys);
     $body = MessageCache::singleton()->transform($body, false, null, $this->title);
     $this->body = wordwrap(strtr($body, $postTransformKeys), 72);
     # Reveal the page editor's address as REPLY-TO address only if
     # the user has not opted-out and the option is enabled at the
     # global configuration level.
     $adminAddress = new MailAddress($wgPasswordSender, wfMessage('emailsender')->inContentLanguage()->text());
     if ($wgEnotifRevealEditorAddress && $this->editor->getEmail() != '' && $this->editor->getOption('enotifrevealaddr')) {
         $editorAddress = MailAddress::newFromUser($this->editor);
         if ($wgEnotifFromEditor) {
             $this->from = $editorAddress;
         } else {
             $this->from = $adminAddress;
             $this->replyto = $editorAddress;
         }
     } else {
         $this->from = $adminAddress;
         $this->replyto = new MailAddress($wgNoReplyAddress);
     }
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:81,代码来源:EmailNotification.php

示例13: addToSidebarPlain

 /**
  * Add content from plain text
  * @since 1.17
  * @param $bar array
  * @param $text string
  * @return Array
  */
 function addToSidebarPlain(&$bar, $text)
 {
     $lines = explode("\n", $text);
     $heading = '';
     foreach ($lines as $line) {
         if (strpos($line, '*') !== 0) {
             continue;
         }
         $line = rtrim($line, "\r");
         // for Windows compat
         if (strpos($line, '**') !== 0) {
             $heading = trim($line, '* ');
             if (!array_key_exists($heading, $bar)) {
                 $bar[$heading] = array();
             }
         } else {
             $line = trim($line, '* ');
             if (strpos($line, '|') !== false) {
                 // sanity check
                 $line = MessageCache::singleton()->transform($line, false, null, $this->getTitle());
                 $line = array_map('trim', explode('|', $line, 2));
                 if (count($line) !== 2) {
                     // Second sanity check, could be hit by people doing
                     // funky stuff with parserfuncs... (bug 33321)
                     continue;
                 }
                 $extraAttribs = array();
                 $msgLink = $this->msg($line[0])->inContentLanguage();
                 if ($msgLink->exists()) {
                     $link = $msgLink->text();
                     if ($link == '-') {
                         continue;
                     }
                 } else {
                     $link = $line[0];
                 }
                 $msgText = $this->msg($line[1]);
                 if ($msgText->exists()) {
                     $text = $msgText->text();
                 } else {
                     $text = $line[1];
                 }
                 if (preg_match('/^(?i:' . wfUrlProtocols() . ')/', $link)) {
                     $href = $link;
                     // Parser::getExternalLinkAttribs won't work here because of the Namespace things
                     global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
                     if ($wgNoFollowLinks && !wfMatchesDomainList($href, $wgNoFollowDomainExceptions)) {
                         $extraAttribs['rel'] = 'nofollow';
                     }
                     global $wgExternalLinkTarget;
                     if ($wgExternalLinkTarget) {
                         $extraAttribs['target'] = $wgExternalLinkTarget;
                     }
                 } else {
                     $title = Title::newFromText($link);
                     if ($title) {
                         $title = $title->fixSpecialName();
                         $href = $title->getLinkURL();
                     } else {
                         $href = 'INVALID-TITLE';
                     }
                 }
                 $bar[$heading][] = array_merge(array('text' => $text, 'href' => $href, 'id' => 'n-' . Sanitizer::escapeId(strtr($line[1], ' ', '-'), 'noninitial'), 'active' => false), $extraAttribs);
             } else {
                 continue;
             }
         }
     }
     return $bar;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:77,代码来源:Skin.php

示例14: getPageLanguage

 /**
  * Get the language in which the content of this page is written.
  * Defaults to $wgContLang, but in certain cases it can be e.g.
  * $wgLang (such as special pages, which are in the user language).
  *
  * @since 1.18
  * @return object Language
  */
 public function getPageLanguage()
 {
     global $wgLang;
     if ($this->getNamespace() == NS_SPECIAL) {
         // special pages are in the user language
         return $wgLang;
     } elseif ($this->isRedirect()) {
         // the arrow on a redirect page is aligned according to the user language
         return $wgLang;
     } elseif ($this->isCssOrJsPage()) {
         // css/js should always be LTR and is, in fact, English
         return wfGetLangObj('en');
     } elseif ($this->getNamespace() == NS_MEDIAWIKI) {
         // Parse mediawiki messages with correct target language
         list(, $lang) = MessageCache::singleton()->figureMessage($this->getText());
         return wfGetLangObj($lang);
     }
     global $wgContLang;
     // If nothing special, it should be in the wiki content language
     $pageLang = $wgContLang;
     // Hook at the end because we don't want to override the above stuff
     wfRunHooks('PageContentLanguage', array($this, &$pageLang, $wgLang));
     return wfGetLangObj($pageLang);
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:32,代码来源:Title.php

示例15: getPageLanguage

 /**
  * Get the language in which the content of the given page is written.
  *
  * This default implementation just returns $wgContLang (except for pages
  * in the MediaWiki namespace)
  *
  * Note that the pages language is not cacheable, since it may in some
  * cases depend on user settings.
  *
  * Also note that the page language may or may not depend on the actual content of the page,
  * that is, this method may load the content in order to determine the language.
  *
  * @since 1.21
  *
  * @param Title $title The page to determine the language for.
  * @param Content $content The page's content, if you have it handy, to avoid reloading it.
  *
  * @return Language The page's language
  */
 public function getPageLanguage(Title $title, Content $content = null)
 {
     global $wgContLang, $wgLang;
     $pageLang = $wgContLang;
     if ($title->getNamespace() == NS_MEDIAWIKI) {
         // Parse mediawiki messages with correct target language
         list(, $lang) = MessageCache::singleton()->figureMessage($title->getText());
         $pageLang = wfGetLangObj($lang);
     }
     wfRunHooks('PageContentLanguage', array($title, &$pageLang, $wgLang));
     return wfGetLangObj($pageLang);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:31,代码来源:ContentHandler.php


注:本文中的MessageCache::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。