/** * */ 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); }
/** * 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; }
/** * 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); }