/** * Show the special page * * @param string $par Parameter passed to the page or null */ public function execute($par) { $request = $this->getRequest(); $out = $this->getOutput(); $this->setHeaders(); if (!$this->getConfig()->get('UseDatabaseMessages')) { $out->addWikiMsg('allmessagesnotsupportedDB'); return; } $this->outputHeader('allmessagestext'); $out->addModuleStyles('mediawiki.special'); $this->table = new AllmessagesTablePager($this, array(), wfGetLangObj($request->getVal('lang', $par))); $this->langcode = $this->table->lang->getCode(); $out->addHTML($this->table->buildForm()); $out->addParserOutputContent($this->table->getFullOutput()); }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { $request = $this->getRequest(); $out = $this->getOutput(); $this->setHeaders(); global $wgUseDatabaseMessages; if (!$wgUseDatabaseMessages) { $out->addWikiMsg('allmessagesnotsupportedDB'); return; } else { $this->outputHeader('allmessagestext'); } $out->addModuleStyles('mediawiki.special'); $this->table = new AllmessagesTablePager($this, array(), wfGetLangObj($request->getVal('lang', $par))); $this->langcode = $this->table->lang->getCode(); $out->addHTML($this->table->buildForm() . $this->table->getNavigationBar() . $this->table->getBody() . $this->table->getNavigationBar()); }
/** * @param string|bool $langCode See --lang-code option. */ protected function fetchMessageInfo($langCode, array &$messageInfo) { global $wgContLang; if ($langCode) { $this->output("\n... fetching message info for language: {$langCode}"); $nonContLang = true; } else { $this->output("\n... fetching message info for content language"); $langCode = $wgContLang->getCode(); $nonContLang = false; } /* Based on SpecialAllmessages::reallyDoQuery #filter=modified */ $l10nCache = Language::getLocalisationCache(); $messageNames = $l10nCache->getSubitemList('en', 'messages'); // Normalise message names for NS_MEDIAWIKI page_title $messageNames = array_map(array($wgContLang, 'ucfirst'), $messageNames); $statuses = AllmessagesTablePager::getCustomisedStatuses($messageNames, $langCode, $nonContLang); // getCustomisedStatuses is stripping the sub page from the page titles, add it back $titleSuffix = $nonContLang ? "/{$langCode}" : ''; foreach ($messageNames as $key) { $customised = isset($statuses['pages'][$key]); if ($customised) { $actual = wfMessage($key)->inLanguage($langCode)->plain(); $default = wfMessage($key)->inLanguage($langCode)->useDatabase(false)->plain(); $messageInfo['relevantPages']++; if ($default !== '' && $default !== '-' && $actual === $default) { $hasTalk = isset($statuses['talks'][$key]); $messageInfo['results'][] = array('title' => $key . $titleSuffix, 'hasTalk' => $hasTalk); $messageInfo['equalPages']++; if ($hasTalk) { $messageInfo['equalPagesTalks']++; } } } } }
public function execute() { $params = $this->extractRequestParams(); if (is_null($params['lang'])) { $langObj = $this->getLanguage(); } elseif (!Language::isValidCode($params['lang'])) { $this->dieUsage('Invalid language code for parameter lang', 'invalidlang'); } else { $langObj = Language::factory($params['lang']); } if ($params['enableparser']) { if (!is_null($params['title'])) { $title = Title::newFromText($params['title']); if (!$title || $title->isExternal()) { $this->dieUsageMsg(array('invalidtitle', $params['title'])); } } else { $title = Title::newFromText('API'); } } $prop = array_flip((array) $params['prop']); // Determine which messages should we print if (in_array('*', $params['messages'])) { $message_names = Language::getMessageKeysFor($langObj->getCode()); if ($params['includelocal']) { global $wgLanguageCode; $message_names = array_unique(array_merge($message_names, MessageCache::singleton()->getAllMessageKeys($wgLanguageCode))); } sort($message_names); $messages_target = $message_names; } else { $messages_target = $params['messages']; } // Filter messages that have the specified prefix // Because we sorted the message array earlier, they will appear in a clump: if (isset($params['prefix'])) { $skip = false; $messages_filtered = array(); foreach ($messages_target as $message) { // === 0: must be at beginning of string (position 0) if (strpos($message, $params['prefix']) === 0) { if (!$skip) { $skip = true; } $messages_filtered[] = $message; } elseif ($skip) { break; } } $messages_target = $messages_filtered; } // Filter messages that contain specified string if (isset($params['filter'])) { $messages_filtered = array(); foreach ($messages_target as $message) { // !== is used because filter can be at the beginning of the string if (strpos($message, $params['filter']) !== false) { $messages_filtered[] = $message; } } $messages_target = $messages_filtered; } // Whether we have any sort of message customisation filtering $customiseFilterEnabled = $params['customised'] !== 'all'; if ($customiseFilterEnabled) { global $wgContLang; $lang = $langObj->getCode(); $customisedMessages = AllmessagesTablePager::getCustomisedStatuses(array_map(array($langObj, 'ucfirst'), $messages_target), $lang, $lang != $wgContLang->getCode()); $customised = $params['customised'] === 'modified'; } // Get all requested messages and print the result $skip = !is_null($params['from']); $useto = !is_null($params['to']); $result = $this->getResult(); foreach ($messages_target as $message) { // Skip all messages up to $params['from'] if ($skip && $message === $params['from']) { $skip = false; } if ($useto && $message > $params['to']) { break; } if (!$skip) { $a = array('name' => $message); $args = array(); if (isset($params['args']) && count($params['args']) != 0) { $args = $params['args']; } if ($customiseFilterEnabled) { $messageIsCustomised = isset($customisedMessages['pages'][$langObj->ucfirst($message)]); if ($customised === $messageIsCustomised) { if ($customised) { $a['customised'] = ''; } } else { continue; } } $msg = wfMessage($message, $args)->inLanguage($langObj); if (!$msg->exists()) { $a['missing'] = ''; } else { // Check if the parser is enabled: if ($params['enableparser']) { $msgString = $msg->title($title)->text(); } else { $msgString = $msg->plain(); } if (!$params['nocontent']) { ApiResult::setContent($a, $msgString); } if (isset($prop['default'])) { $default = wfMessage($message)->inLanguage($langObj)->useDatabase(false); if (!$default->exists()) { $a['defaultmissing'] = ''; } elseif ($default->plain() != $msgString) { $a['default'] = $default->plain(); } } } $fit = $result->addValue(array('query', $this->getModuleName()), null, $a); if (!$fit) { $this->setContinueEnumParameter('from', $message); break; } } } $result->setIndexedTagName_internal(array('query', $this->getModuleName()), 'message'); }