本文整理汇总了PHP中MessageCache::loadAllMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageCache::loadAllMessages方法的具体用法?PHP MessageCache::loadAllMessages怎么用?PHP MessageCache::loadAllMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageCache
的用法示例。
在下文中一共展示了MessageCache::loadAllMessages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: getGroupPage
/**
* Get the title of a page describing a particular group
*
* @param $group Name of the group
* @return mixed
*/
static function getGroupPage($group)
{
MessageCache::loadAllMessages();
$page = wfMsgForContent('grouppage-' . $group);
if (!wfEmptyMsg('grouppage-' . $group, $page)) {
$title = Title::newFromText($page);
if (is_object($title)) {
return $title;
}
}
return false;
}
示例3: loadFromDB
/**
* Loads all or main part of cacheable messages from the database
*/
function loadFromDB()
{
global $wgLang;
$fname = 'MessageCache::loadFromDB';
$dbr =& wfGetDB(DB_SLAVE);
if (!$dbr) {
throw new MWException('Invalid database object');
}
$conditions = array('page_is_redirect' => 0, 'page_namespace' => NS_MEDIAWIKI);
$res = $dbr->select(array('page', 'revision', 'text'), array('page_title', 'old_text', 'old_flags'), 'page_is_redirect=0 AND page_namespace=' . NS_MEDIAWIKI . ' AND page_latest=rev_id AND rev_text_id=old_id', $fname);
$this->mCache = array();
for ($row = $dbr->fetchObject($res); $row; $row = $dbr->fetchObject($res)) {
$this->mCache[$row->page_title] = Revision::getRevisionText($row);
}
# Negative caching
# Go through the language array and the extension array and make a note of
# any keys missing from the cache
$allMessages = Language::getMessagesFor('en');
foreach ($allMessages as $key => $value) {
$uckey = $wgLang->ucfirst($key);
if (!array_key_exists($uckey, $this->mCache)) {
$this->mCache[$uckey] = false;
}
}
# Make sure all extension messages are available
MessageCache::loadAllMessages();
# Add them to the cache
foreach ($this->mExtensionMessages as $key => $value) {
$uckey = $wgLang->ucfirst($key);
if (!array_key_exists($uckey, $this->mCache) && (isset($this->mExtensionMessages[$key][$wgLang->getCode()]) || isset($this->mExtensionMessages[$key]['en']))) {
$this->mCache[$uckey] = false;
}
}
$dbr->freeResult($res);
}