本文整理汇总了PHP中MessageCache类的典型用法代码示例。如果您正苦于以下问题:PHP MessageCache类的具体用法?PHP MessageCache怎么用?PHP MessageCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MessageCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
global $wgOut, $wgUser, $wgMessageCache;
$wgOut = $this;
$wgUser = new User(2);
$wgMessageCache = new MessageCache();
$wgMessageCache->addMessages(array('rdf' => 'Rdf', 'rdf-inpage' => "Embedded In-page Turtle", 'rdf-dcmes' => "Dublin Core Metadata Element Set", 'rdf-cc' => "Creative Commons", 'rdf-image' => "Embedded images", 'rdf-linksfrom' => "Links from the page", 'rdf-links' => "All links", 'rdf-history' => "Historical versions", 'rdf-interwiki' => "Interwiki links", 'rdf-categories' => "Categories", 'rdf-target' => "Target page", 'rdf-modelnames' => "Model(s)", 'rdf-format' => "Output format", 'rdf-output-xml' => "XML", 'rdf-output-turtle' => "Turtle", 'rdf-output-ntriples' => "NTriples", 'rdf-instructions' => "Select the target page and RDF models you're interested in."));
MwRdf::$ModelMakers = array('MwRdf_CreativeCommons_Modeler', 'MwRdf_LinksFrom_Modeler', 'MwRdf_LinksTo_Modeler', 'MwRdf_InPage_Modeler', 'MwRdf_DCmes_Modeler', 'MwRdf_History_Modeler', 'MwRdf_Image_Modeler', 'MwRdf_Categories_Modeler', 'MwRdf_Interwiki_Modeler');
MwRdf::ShowForm();
}
示例2: 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();
}
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例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;
}
示例8: 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();
}
示例9: 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;
}
示例10: 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();
}
示例11: 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();
}
}
}
示例12: wfSpecialAllmessages
/**
*
*/
function wfSpecialAllmessages()
{
global $wgOut, $wgRequest, $wgMessageCache, $wgTitle;
global $wgUseDatabaseMessages;
# The page isn't much use if the MediaWiki namespace is not being used
if (!$wgUseDatabaseMessages) {
$wgOut->addWikiText(wfMsg('allmessagesnotsupportedDB'));
return;
}
$fname = "wfSpecialAllMessages";
wfProfileIn($fname);
wfProfileIn("{$fname}-setup");
$ot = $wgRequest->getText('ot');
$navText = wfMsg('allmessagestext');
# Make sure all extension messages are available
MessageCache::loadAllMessages();
$first = true;
$sortedArray = array_merge(Language::getMessagesFor('en'), $wgMessageCache->getExtensionMessagesFor('en'));
ksort($sortedArray);
$messages = array();
$wgMessageCache->disableTransform();
foreach ($sortedArray as $key => $value) {
$messages[$key]['enmsg'] = $value;
$messages[$key]['statmsg'] = wfMsgNoDb($key);
$messages[$key]['msg'] = wfMsg($key);
}
$wgMessageCache->enableTransform();
wfProfileOut("{$fname}-setup");
wfProfileIn("{$fname}-output");
if ($ot == 'php') {
$navText .= makePhp($messages);
$wgOut->addHTML('PHP | <a href="' . $wgTitle->escapeLocalUrl('ot=html') . '">HTML</a><pre>' . htmlspecialchars($navText) . '</pre>');
} else {
$wgOut->addHTML('<a href="' . $wgTitle->escapeLocalUrl('ot=php') . '">PHP</a> | HTML');
$wgOut->addWikiText($navText);
$wgOut->addHTML(makeHTMLText($messages));
}
wfProfileOut("{$fname}-output");
wfProfileOut($fname);
}
示例13: setupGlobals
/**
* Set up the global variables for a consistent environment for each test.
* Ideally this should replace the global configuration entirely.
* @param array $opts
* @param string $config
* @return RequestContext
*/
protected function setupGlobals($opts = array(), $config = '')
{
global $wgFileBackends;
# Find out values for some special options.
$lang = self::getOptionValue('language', $opts, 'en');
$variant = self::getOptionValue('variant', $opts, false);
$maxtoclevel = self::getOptionValue('wgMaxTocLevel', $opts, 999);
$linkHolderBatchSize = self::getOptionValue('wgLinkHolderBatchSize', $opts, 1000);
$uploadDir = $this->getUploadDir();
if ($this->getCliArg('use-filebackend')) {
if (self::$backendToUse) {
$backend = self::$backendToUse;
} else {
$name = $this->getCliArg('use-filebackend');
$useConfig = array();
foreach ($wgFileBackends as $conf) {
if ($conf['name'] == $name) {
$useConfig = $conf;
}
}
$useConfig['name'] = 'local-backend';
// swap name
unset($useConfig['lockManager']);
unset($useConfig['fileJournal']);
$class = $useConfig['class'];
self::$backendToUse = new $class($useConfig);
$backend = self::$backendToUse;
}
} else {
# Replace with a mock. We do not care about generating real
# files on the filesystem, just need to expose the file
# informations.
$backend = new MockFileBackend(array('name' => 'local-backend', 'wikiId' => wfWikiId()));
}
$settings = array('wgLocalFileRepo' => array('class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => $backend), 'wgEnableUploads' => self::getOptionValue('wgEnableUploads', $opts, true), 'wgLanguageCode' => $lang, 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'unittest_' : 'ut_', 'wgRawHtml' => self::getOptionValue('wgRawHtml', $opts, false), 'wgNamespacesWithSubpages' => array(NS_MAIN => isset($opts['subpage'])), 'wgAllowExternalImages' => self::getOptionValue('wgAllowExternalImages', $opts, true), 'wgThumbLimits' => array(self::getOptionValue('thumbsize', $opts, 180)), 'wgMaxTocLevel' => $maxtoclevel, 'wgUseTeX' => isset($opts['math']) || isset($opts['texvc']), 'wgMathDirectory' => $uploadDir . '/math', 'wgDefaultLanguageVariant' => $variant, 'wgLinkHolderBatchSize' => $linkHolderBatchSize, 'wgUseTidy' => isset($opts['tidy']));
if ($config) {
$configLines = explode("\n", $config);
foreach ($configLines as $line) {
list($var, $value) = explode('=', $line, 2);
$settings[$var] = eval("return {$value};");
// ???
}
}
$this->savedGlobals = array();
/** @since 1.20 */
Hooks::run('ParserTestGlobals', array(&$settings));
$langObj = Language::factory($lang);
$settings['wgContLang'] = $langObj;
$settings['wgLang'] = $langObj;
$context = new RequestContext();
$settings['wgOut'] = $context->getOutput();
$settings['wgUser'] = $context->getUser();
$settings['wgRequest'] = $context->getRequest();
// We (re)set $wgThumbLimits to a single-element array above.
$context->getUser()->setOption('thumbsize', 0);
foreach ($settings as $var => $val) {
if (array_key_exists($var, $GLOBALS)) {
$this->savedGlobals[$var] = $GLOBALS[$var];
}
$GLOBALS[$var] = $val;
}
MWTidy::destroySingleton();
MagicWord::clearCache();
# The entries saved into RepoGroup cache with previous globals will be wrong.
RepoGroup::destroySingleton();
FileBackendGroup::destroySingleton();
# Create dummy files in storage
$this->setupUploads();
# Publish the articles after we have the final language set
$this->publishTestArticles();
MessageCache::destroyInstance();
return $context;
}
示例14: onArticleDelete
/**
* Clears caches when article is deleted
*
* @param Title $title
*/
public static function onArticleDelete(Title $title)
{
global $wgContLang;
// Update existence markers on article/talk tabs...
$other = $title->getOtherPage();
$other->purgeSquid();
$title->touchLinks();
$title->purgeSquid();
MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle($title);
// File cache
HTMLFileCache::clearFileCache($title);
InfoAction::invalidateCache($title);
// Messages
if ($title->getNamespace() == NS_MEDIAWIKI) {
MessageCache::singleton()->replace($title->getDBkey(), false);
if ($wgContLang->hasVariants()) {
$wgContLang->updateConversionTable($title);
}
}
// Images
if ($title->getNamespace() == NS_FILE) {
DeferredUpdates::addUpdate(new HTMLCacheUpdate($title, 'imagelinks'));
}
// User talk pages
if ($title->getNamespace() == NS_USER_TALK) {
$user = User::newFromName($title->getText(), false);
if ($user) {
$user->setNewtalk(false);
}
}
// Image redirects
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($title);
}
示例15: wfEmptyMsg
/**
* Since wfMsg() and co suck, they don't return false if the message key they
* looked up didn't exist but instead the key wrapped in <>'s, this function checks for the
* nonexistence of messages by checking the MessageCache::get() result directly.
*
* @deprecated since 1.18. Use Message::isDisabled().
*
* @param string $key The message key looked up
* @return bool True if the message *doesn't* exist.
*/
function wfEmptyMsg($key)
{
wfDeprecated(__METHOD__, '1.21');
return MessageCache::singleton()->get($key, true, false) === false;
}