Example #1
0
/**
 *
 */
function wfSpecialAllmessages()
{
    global $wgOut, $wgAllMessagesEn, $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
    wfLoadAllExtensions();
    $first = true;
    $sortedArray = array_merge($wgAllMessagesEn, $wgMessageCache->mExtensionMessages);
    ksort($sortedArray);
    $messages = array();
    $wgMessageCache->disableTransform();
    foreach ($sortedArray as $key => $value) {
        $messages[$key]['enmsg'] = is_array($value) ? $value['en'] : $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);
}
Example #2
0
 /**
  * Loads all or main part of cacheable messages from the database
  */
 function loadFromDB()
 {
     global $wgAllMessagesEn, $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
     foreach ($wgAllMessagesEn 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
     wfLoadAllExtensions();
     # 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);
 }
Example #3
0
 function loadAllMessages($lang = false)
 {
     global $wgExtensionMessagesFiles;
     $key = $lang === false ? '*' : $lang;
     if (isset($this->mAllMessagesLoaded[$key])) {
         return;
     }
     $this->mAllMessagesLoaded[$key] = true;
     # Some extensions will load their messages when you load their class file
     wfLoadAllExtensions();
     # Others will respond to this hook
     wfRunHooks('LoadAllMessages');
     # Some register their messages in $wgExtensionMessagesFiles
     foreach ($wgExtensionMessagesFiles as $name => $file) {
         wfLoadExtensionMessages($name, $lang);
     }
     # Still others will respond to neither, they are EVIL. We sometimes need to know!
 }
Example #4
0
 static function loadAllMessages()
 {
     # Some extensions will load their messages when you load their class file
     wfLoadAllExtensions();
     # Others will respond to this hook
     wfRunHooks('LoadAllMessages');
     # Still others will respond to neither, they are EVIL. We sometimes need to know!
 }
Example #5
0
 function loadAllMessages()
 {
     global $wgExtensionMessagesFiles;
     if ($this->mAllMessagesLoaded) {
         return;
     }
     $this->mAllMessagesLoaded = true;
     # Some extensions will load their messages when you load their class file
     wfLoadAllExtensions();
     # Others will respond to this hook
     wfRunHooks('LoadAllMessages');
     # Some register their messages in $wgExtensionMessagesFiles
     foreach ($wgExtensionMessagesFiles as $name => $file) {
         if ($file) {
             $this->loadMessagesFile($file);
             $wgExtensionMessagesFiles[$name] = false;
         }
     }
     # Still others will respond to neither, they are EVIL. We sometimes need to know!
 }