/** * Add tracking JS to all pages for all users that are not members of excluded * groups (the group listed in $wgQuantcastTrackingExcludedGroups). * * @param $skin Object: Skin object * @param $text String: bottomScripts text * @return Boolean: true */ function wfAddQuantcastTrackingCode( $skin, &$text ) { global $wgUser, $wgQuantcastTrackingExcludedGroups; $groups = $wgUser->getEffectiveGroups(); if ( !in_array( $wgQuantcastTrackingExcludedGroups, $groups ) ) { $message = trim( wfMsgForContent( 'quantcast-tracking-number' ) ); // We have a custom tracking code, use it! if( !wfEmptyMsg( 'quantcast-tracking-number', $message ) ) { $trackingCode = $message; } else { // use ShoutWiki's default code $trackingCode = wfMsgForContent( 'shoutwiki-quantcast-tracking-number' ); } $safeCode = htmlspecialchars( $trackingCode, ENT_QUOTES ); $text .= "\t\t" . '<!-- Start Quantcast tag --> <script type="text/javascript">/*<![CDATA[*/ _qoptions = { qacct: "' . $safeCode . '" }; /*]]>*/</script> <script type="text/javascript" src="http://edge.quantserve.com/quant.js"></script> <noscript> <img src="http://pixel.quantserve.com/pixel/' . $safeCode . '.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast" /> </noscript> <!-- End Quantcast tag -->' . "\n\n"; } return true; }
/** * */ function makePhp($messages) { global $wgLang; $txt = "\n\n\$messages = array(\n"; foreach ($messages as $key => $m) { if ($wgLang->getCode() != 'en' and $m['msg'] == $m['enmsg']) { //if (strstr($m['msg'],"\n")) { // $txt.='/* '; // $comment=' */'; //} else { // $txt .= '#'; // $comment = ''; //} continue; } elseif (wfEmptyMsg($key, $m['msg'])) { $m['msg'] = ''; $comment = ' #empty'; } else { $comment = ''; } $txt .= "'{$key}' => '" . preg_replace("/(?<!\\\\)'/", "\\'", $m['msg']) . "',{$comment}\n"; } $txt .= ');'; return $txt; }
/** * @param OutputPage $out * @param string $text * @return bool */ function wfArticleMetaDescription(&$out, &$text) { global $wgTitle; wfProfileIn(__METHOD__); $sMessage = null; $sMainPage = wfMsgForContent('Mainpage'); if (strpos($sMainPage, ':') !== false) { $sTitle = $wgTitle->getFullText(); } else { $sTitle = $wgTitle->getText(); } if (strcmp($sTitle, $sMainPage) == 0) { // we're on Main Page, check MediaWiki:Description message $sMessage = wfMsg("Description"); } if ($sMessage == null || wfEmptyMsg("Description", $sMessage)) { $DESC_LENGTH = 100; $articleId = $wgTitle->getArticleID(); $articleService = new ArticleService($articleId); $description = $articleService->getTextSnippet($DESC_LENGTH); } else { // MediaWiki:Description message found, use it $description = $sMessage; } if (!empty($description)) { $out->addMeta('description', htmlspecialchars($description)); } wfProfileOut(__METHOD__); return true; }
function wfWhitelistPages() { global $wgWhitelistRead, $wgGroupPermissions; $message = wfMsgForContent( 'public read whitelist' ); // If MediaWiki:Public read whitelist is empty, bail out if ( wfEmptyMsg( 'public read whitelist', $message ) ) { return; } // If anonymous users can read the wiki, then it's not a private one // and we don't need this feature for non-private wikis if ( $wgGroupPermissions['*']['read'] ) { return; } // $wgWhitelistRead is *false* by default instead of being an empty array if ( $wgWhitelistRead === false ) { $wgWhitelistRead = array(); } // Explode along newlines $whitelistedPages = explode( "\n", trim( $message ) ); // Merge with current list $wgWhitelistRead = array_merge( $wgWhitelistRead, $whitelistedPages ); }
function constructCreateForm() { global $wgOut, $wgScript; global $wgUserProperties, $wgActivityModes; $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post'))); $wgOut->addHTML(Xml::element('h2', null, wfMsg('nss-create-account-header')) . "\n"); $wgOut->addHTML("<table border=\"1\" id=\"newuser\">\n"); $props = array_merge(array('username', 'email'), $wgUserProperties); foreach ($props as $i) { $msg = 'am-' . $i; $wgOut->addHTML("\t<tr><th>" . (wfEmptyMsg($msg, wfMsg($msg)) ? $i : wfMsgHtml($msg)) . "</th><td>" . Xml::input("am-" . str_replace(' ', '_', $i), 40) . "</td></tr>\n"); } global $wgActivityModes; $select = new XmlSelect("am-active"); $select->setDefault('active'); $select->setAttribute('width', '100%'); foreach ($wgActivityModes as $key) { $select->addOption($key); } $wgOut->addHTML("\t<tr><th>" . wfMsgHtml('am-active') . "</th><td>" . $select->getHTML() . "</td></tr>\n"); $wgOut->addHTML("</table>\n"); $wgOut->addHTML("<div id=\"newaccount-submit\">\n" . Html::Hidden('action', 'create') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n"); $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL(), 'method' => 'post'))); $wgOut->addHTML("<div id=\"newaccount-raw\">\n" . Xml::textarea('nss-create-account-raw', '') . "\n" . Html::Hidden('action', 'create-raw') . Xml::checkLabel(wfMsg('nss-no-mail'), 'nss-no-mail', 'nss-no-mail') . "<br />\n" . Xml::element('input', array('type' => 'submit', 'value' => wfMsg('nss-create-account'))) . "</div>\n</form>\n"); }
public function getSummary() { if ($this->summary === false) { if ($this->messageId) { $id = $this->messageId; if (is_array($id)) { $id = array_shift($id); } if (substr($id, 0, 3) == 'mw-') { $id = substr($id, 3); } if (isset(self::$messagesMap[$id])) { $id = self::$messagesMap[$id]; } $messageId = $id . '-notice'; $message = wfMsg($messageId); if (!wfEmptyMsg($messageId, $message)) { $this->summary = wfMsgExt($messageId, array('parseinline')); } } if ($this->summary === false) { $this->summary = $this->getHtmlSnippet(); } } return (string) $this->summary; }
/** * Send the message if the UserBoard class exists (duh!) and the welcome * message has some content. * * @param $user User: the new User object being created * @param $byEmail Boolean: true if the account was created by e-mail * @return Boolean: true */ function wfSendUserBoardMessageOnRegistration($user, $byEmail) { if (class_exists('UserBoard') && $user instanceof User) { $message = trim(wfMsgForContent('user-board-welcome-message')); // If the welcome message is empty, short-circuit right away. if (wfEmptyMsg('user-board-welcome-message', $message)) { return true; } // Just quit if we're in read-only mode if (wfReadOnly()) { return true; } $dbr = wfGetDB(DB_SLAVE); // Get all users who are in the 'sysop' group and aren't blocked from // the database $res = $dbr->select(array('user_groups', 'ipblocks'), array('ug_group', 'ug_user'), array('ug_group' => 'sysop', 'ipb_user' => null), __METHOD__, array(), array('ipblocks' => array('LEFT JOIN', 'ipb_user = ug_user'))); $adminUids = array(); foreach ($res as $row) { $adminUids[] = $row->ug_user; } // Pick one UID from the array of admin user IDs $random = array_rand(array_flip($adminUids), 1); $sender = User::newFromId($random); $senderUid = $sender->getId(); $senderName = $sender->getName(); // Send the message $b = new UserBoard(); $b->sendBoardMessage($senderUid, $senderName, $user->getId(), $user->getName(), wfMsgForContent('user-board-welcome-message', $senderName)); } return true; }
function efGPManagerCustomToolboxAppend(&$skin) { global $wgOut, $wgUser; $tb = explode("\n", wfMsg('toolbox_append')); $new = array(); foreach ($tb as &$nt) { if (strpos($nt, '*') === 0) { $nt = trim($nt, '*'); $parts = explode('|', $nt); foreach ($parts as &$part) { $part = trim($part); } $href = wfMsgForContent($parts[0]); $text = wfMsgForContent($parts[1]); $perm = array_key_exists(2, $parts) ? $parts[2] : 'read'; if (!$wgUser->isAllowed($perm)) { continue; } if (wfEmptyMsg($parts[0], $href)) { $href = $parts[0]; } if (wfEmptyMsg($parts[1], $text)) { $text = $parts[1]; } $id = Sanitizer::escapeId($parts[1], 'noninitial'); $new[] = array($href, $text, $id); } } foreach ($new as $t) { echo '<li id="t-' . $t[2] . '"><a href="' . htmlspecialchars($t[0]) . '">' . $t[1] . '</a></li>'; } return true; }
function doTagRow($tag, $hitcount) { static $sk = null, $doneTags = array(); if (!$sk) { global $wgUser; $sk = $wgUser->getSkin(); } if (in_array($tag, $doneTags)) { return ''; } $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsg('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $disp); $desc = wfMsgExt("tag-{$tag}-description", 'parseinline'); $desc = wfEmptyMsg("tag-{$tag}-description", $desc) ? '' : $desc; $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsg('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $desc); $hitcount = wfMsg('tags-hitcount', $hitcount); $hitcount = $sk->link(SpecialPage::getTitleFor('RecentChanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
/** * Gets a message from the NS_MEDIAWIKI namespace */ protected function getMsg($msgId) { $msgText = wfMsgExt($msgId); if (wfEmptyMsg($msgId, $msgText)) { return null; } return $msgText; }
static function tagDescription($tag) { $msg = wfMsgExt("tag-{$tag}", 'parseinline'); if (wfEmptyMsg("tag-{$tag}", $msg)) { return htmlspecialchars($tag); } return $msg; }
/** * Show a message asking the user to enter a captcha on edit * The result will be treated as wiki text * * @param $action Action being performed * @return string */ function getMessage($action) { $name = 'recaptcha-' . $action; $text = wfMsg($name); # Obtain a more tailored message, if possible, otherwise, fall back to # the default for edits return wfEmptyMsg($name, $text) ? wfMsg('recaptcha-edit') : $text; }
/** * GETS a message from the MediaWiki namespace */ protected function getMessage(&$key) { $source = wfMsgGetKey($key, true, true, false); if (wfEmptyMsg($key, $source)) { return null; } return $source; }
/** * Gets a message from the NS_MEDIAWIKI namespace */ protected function getMsg($msgId) { $msgText = wfMsgExt($msgId, array('parseinline')); if (wfEmptyMsg($msgId, $msgText)) { return null; } return $msgText; }
/** * Show a message asking the user to enter a captcha on edit * The result will be treated as wiki text * * @param string $action Action being performed * * @return string */ public function getMessage($action) { // Possible keys for easy grepping: captcha-edit, captcha-addurl, captcha-createaccount, captcha-create $name = 'captcha-' . $action; $text = wfMessage($name)->escaped(); # Obtain a more tailored message, if possible, otherwise, fall back to # the default for edits return wfEmptyMsg($name, $text) ? wfMessage('captcha-edit')->escaped() : $text; }
function WidgetTipsGetTips() { // use content language (thx to Uberfuzzy) $tips = wfMsgForContent('tips'); if (wfEmptyMsg('tips', $tips)) { return false; } else { return $tips != '' ? explode("\n\n", trim($tips)) : false; } }
function wfMetaKeywordInput($type) { global $wgContLang, $wgMemc, $wgDBname; $params = wfMsgForContentNoTrans("meta{$type}"); $opts = array(0); if (!wfEmptyMsg("meta{$type}", $params)) { $opts = wfMetaKeywordParse($params); } return $opts; }
/** * Get message for ConfirmEdit - FancyCaptcha (code come from FancyCaptcha::getMessage()). */ function onGetConfirmEditMessage($captcha, &$message) { if (!$captcha instanceof FancyCaptcha) { return true; } $name = 'fancycaptcha-createaccount'; $text = wfMsgExt($name, array('parseinline')); $message = wfEmptyMsg($name, $text) ? wfMsgExt('fancycaptcha-edit', array('parseinline')) : $text; return true; }
/** * constructor */ function wfSpecialStatistics() { global $wgOut, $wgLang, $wgRequest; $fname = 'wfSpecialStatistics'; $action = $wgRequest->getVal('action'); $dbr = wfGetDB(DB_SLAVE); $views = SiteStats::views(); $edits = SiteStats::edits(); $good = SiteStats::articles(); $images = SiteStats::images(); $total = SiteStats::pages(); $users = SiteStats::users(); $admins = $dbr->selectField('user_groups', 'COUNT(*)', array('ug_group' => 'sysop'), $fname); $numJobs = $dbr->estimateRowCount('job'); if ($action == 'raw') { $wgOut->disable(); header('Pragma: nocache'); echo "total={$total};good={$good};views={$views};edits={$edits};users={$users};admins={$admins};images={$images};jobs={$numJobs}\n"; return; } else { $text = '==' . wfMsg('sitestats') . "==\n"; $text .= wfMsgExt('sitestatstext', array('parsemag'), $wgLang->formatNum($total), $wgLang->formatNum($good), $wgLang->formatNum($views), $wgLang->formatNum($edits), $wgLang->formatNum(sprintf('%.2f', $total ? $edits / $total : 0)), $wgLang->formatNum(sprintf('%.2f', $edits ? $views / $edits : 0)), $wgLang->formatNum($numJobs), $wgLang->formatNum($images)); $text .= "\n==" . wfMsg('userstats') . "==\n"; $text .= wfMsgExt('userstatstext', array('parsemag'), $wgLang->formatNum($users), $wgLang->formatNum($admins), '[[' . wfMsgForContent('grouppage-sysop') . ']]', $wgLang->formatNum(sprintf('%.2f', $admins / $users * 100)), User::makeGroupLinkWiki('sysop')); $wgOut->addWikiText($text); global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang; if (!$wgDisableCounters && !$wgMiserMode) { $page = $dbr->tableName('page'); $sql = "SELECT page_namespace, page_title, page_counter FROM {$page} WHERE page_is_redirect = 0 AND page_counter > 0 ORDER BY page_counter DESC"; $sql = $dbr->limitResult($sql, 10, 0); $res = $dbr->query($sql, $fname); if ($res) { $wgOut->addHtml('<h2>' . wfMsgHtml('statistics-mostpopular') . '</h2>'); $skin = $wgUser->getSkin(); $wgOut->addHtml('<ol>'); while ($row = $dbr->fetchObject($res)) { // BizzWiki begin {{ if (!$wgUser->isAllowed('browse', $row->page_namespace)) { continue; } // BizzWiki end }} $link = $skin->makeKnownLinkObj(Title::makeTitleSafe($row->page_namespace, $row->page_title)); $dirmark = $wgContLang->getDirMark(); $wgOut->addHtml('<li>' . $link . $dirmark . ' [' . $wgLang->formatNum($row->page_counter) . ']</li>'); } $wgOut->addHtml('</ol>'); $dbr->freeResult($res); } } $footer = wfMsg('statistics-footer'); if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') { $wgOut->addWikiText($footer); } } }
/** * @param $siteNotice String: existing site notice (if any) to manipulate or * append to * @return Boolean: true */ function wfGlobalNotice(&$siteNotice) { global $wgLang, $wgUser; // It is possible that there is a global notice (for example, for all // French-speaking users) *and* a forced global notice (for everyone, // informing them of planned server maintenance etc.) // // We append whatever we have to this variable and if right before // returning this variable is non-empty, we wrap the local site-notice in // a div with id="localSiteNotice" because users may want to hide global // notices (or forced global notices...that'd be quite dumb though) // // Come to think of it...on ShoutWiki, the $siteNotice variable will never // be empty because SendToAFriend hooks into SiteNoticeAfter hook, too, and // appends its HTML to it. $ourSiteNotice = ''; // "Forced" globalnotice -- a site-wide notice shown for *all* users, // no matter what their language is // Used only for things like server migration notices etc. // // So, once again I find it that MediaWiki sucks. Adding 'parse' to the // options array adds <p> tags around the message, EVEN IF THE MESSAGE IS // EMPTY! This causes wfEmptyMsg() to think that the message has some // content, when in fact it doesn't. $forcedNotice = wfMsgExt('forced-globalnotice', array('language' => 'en')); if (!wfEmptyMsg('forced-globalnotice', $forcedNotice)) { $ourSiteNotice .= '<div style="text-align: center;" id="forcedGlobalNotice">' . wfMsgExt('forced-globalnotice', array('parse', 'language' => 'en')) . '</div>'; } // Global notice, depending on the user's language // This can be used to show language-specific stuff to users with a certain // interface language (i.e. "We need more French translators! Pouvez-vous nous aider ?") $globalNotice = wfMsgExt('globalnotice', array('language' => $wgLang->getCode())); if (!wfEmptyMsg('globalnotice', $globalNotice)) { // Give the global notice its own ID and center it $ourSiteNotice .= '<div style="text-align: center;" id="globalNotice">' . wfMsgExt('globalnotice', array('parse', 'language' => $wgLang->getCode())) . '</div>'; } // Group-specific global notices foreach (array('sysop', 'bureaucrat', 'bot', 'rollback') as $group) { $messageName = 'globalnotice-' . $group; $globalNoticeForGroup = wfMsgExt($messageName, array('language' => $wgLang->getCode())); $isMember = in_array($group, $wgUser->getEffectiveGroups()); if (!wfEmptyMsg($messageName, $globalNoticeForGroup) && $isMember) { // Give the global notice its own ID and center it $ourSiteNotice .= '<div style="text-align: center;" id="globalNoticeForGroup">' . wfMsgExt($messageName, array('parse', 'language' => $wgLang->getCode())) . '</div>'; } } // If we have something to display, wrap the local sitenotice in a pretty // div and copy $ourSiteNotice to $siteNotice if (!empty($ourSiteNotice)) { $ourSiteNotice .= '<!-- end GlobalNotice --><div id="localSiteNotice">' . $siteNotice . '</div>'; $siteNotice = $ourSiteNotice; } return true; }
/** * @param $key * @param $useDB * @param $langCode * @param $transform * @return bool */ function wfFakeAnswersMessaging(&$key, &$useDB, &$langCode, &$transform) { $mask = "-answers2"; if (!preg_match("/{$mask}\$/", $key, $matches)) { $key2 = "{$key}{$mask}"; $msg2 = wfMsgGetKey($key2, $useDB, $langCode, $transform); if (!wfEmptyMsg($key2, $msg2)) { $key = $key2; } } return true; }
/** * Show the special page */ public function execute($par) { global $wgOut, $wgImplicitGroups, $wgMessageCache; global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups; global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; $wgMessageCache->loadAllMessages(); $this->setHeaders(); $this->outputHeader(); $wgOut->addHTML(Xml::openElement('table', array('class' => 'wikitable mw-listgrouprights-table')) . '<tr>' . Xml::element('th', null, wfMsg('listgrouprights-group')) . Xml::element('th', null, wfMsg('listgrouprights-rights')) . '</tr>'); foreach ($wgGroupPermissions as $group => $permissions) { $groupname = $group == '*' ? 'all' : $group; // Replace * with a more descriptive groupname $msg = wfMsg('group-' . $groupname); if (wfEmptyMsg('group-' . $groupname, $msg) || $msg == '') { $groupnameLocalized = $groupname; } else { $groupnameLocalized = $msg; } $msg = wfMsgForContent('grouppage-' . $groupname); if (wfEmptyMsg('grouppage-' . $groupname, $msg) || $msg == '') { $grouppageLocalized = MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname; } else { $grouppageLocalized = $msg; } if ($group == '*') { // Do not make a link for the generic * group $grouppage = htmlspecialchars($groupnameLocalized); } else { $grouppage = $this->skin->link(Title::newFromText($grouppageLocalized), htmlspecialchars($groupnameLocalized)); } if ($group === 'user') { // Link to Special:listusers for implicit group 'user' $grouplink = '<br />' . $this->skin->link(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), array(), array(), array('known', 'noclasses')); } elseif (!in_array($group, $wgImplicitGroups)) { $grouplink = '<br />' . $this->skin->link(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), array(), array('group' => $group), array('known', 'noclasses')); } else { // No link to Special:listusers for other implicit groups as they are unlistable $grouplink = ''; } $revoke = isset($wgRevokePermissions[$group]) ? $wgRevokePermissions[$group] : array(); $addgroups = isset($wgAddGroups[$group]) ? $wgAddGroups[$group] : array(); $removegroups = isset($wgRemoveGroups[$group]) ? $wgRemoveGroups[$group] : array(); $addgroupsSelf = isset($wgGroupsAddToSelf[$group]) ? $wgGroupsAddToSelf[$group] : array(); $removegroupsSelf = isset($wgGroupsRemoveFromSelf[$group]) ? $wgGroupsRemoveFromSelf[$group] : array(); $wgOut->addHTML('<tr> <td>' . $grouppage . $grouplink . '</td> <td>' . self::formatPermissions($permissions, $revoke, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf) . '</td> </tr>'); } $wgOut->addHTML(Xml::closeElement('table') . "\n<br /><hr />\n"); $wgOut->wrapWikiMsg("<div class=\"mw-listgrouprights-key\">\n\$1\n</div>", 'listgrouprights-key'); }
static function getCreateplate($category) { global $wgEnableAnswers; if (!empty($wgEnableAnswers)) { return Answers::getUnansweredCategory(); } $categoryKey = 'newpagelayout-' . $category; $categoryCreateplate = wfMsgForContent($categoryKey); if (!wfEmptyMsg($categoryKey, $categoryCreateplate)) { return $categoryCreateplate; } return wfMsgForContent('newpagelayout'); }
public function execute() { global $wgMessageCache; $params = $this->extractRequestParams(); if (!is_null($params['lang'])) { global $wgLang; $wgLang = Language::factory($params['lang']); } //Determine which messages should we print $messages_target = array(); if ($params['messages'] == '*') { $wgMessageCache->loadAllMessages(); $message_names = array_keys(array_merge(Language::getMessagesFor('en'), $wgMessageCache->getExtensionMessagesFor('en'))); sort($message_names); $messages_target = $message_names; } else { $messages_target = explode('|', $params['messages']); } //Filter messages if (isset($params['filter'])) { $messages_filtered = array(); foreach ($messages_target as $message) { if (strpos($message, $params['filter']) !== false) { //!== is used because filter can be at the beginnig of the string $messages_filtered[] = $message; } } $messages_target = $messages_filtered; } //Get all requested messages $messages = array(); foreach ($messages_target as $message) { $messages[$message] = wfMsg($message); } //Print the result $result = $this->getResult(); $messages_out = array(); foreach ($messages as $name => $value) { $message = array(); $message['name'] = $name; if (wfEmptyMsg($name, $value)) { $message['missing'] = ''; } else { $result->setContent($message, $value); } $messages_out[] = $message; } $result->setIndexedTagName($messages_out, 'message'); $result->addValue('query', $this->getModuleName(), $messages_out); }
function view() { global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; $diff = $wgRequest->getVal('diff'); $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getOption('diffonly')); if ($this->mTitle->getNamespace() != NS_IMAGE || isset($diff) && $diffOnly) { return Article::view(); } if ($wgShowEXIF && $this->img->exists()) { // FIXME: bad interface, see note on MediaHandler::formatMetadata(). $formattedMetadata = $this->img->formatMetadata(); $showmeta = $formattedMetadata !== false; } else { $showmeta = false; } if ($this->img->exists()) { $wgOut->addHTML($this->showTOC($showmeta)); } $this->openShowImage(); # No need to display noarticletext, we use our own message, output in openShowImage() if ($this->getID()) { Article::view(); } else { # Just need to set the right headers $wgOut->setArticleFlag(true); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setPageTitle($this->mTitle->getPrefixedText()); $this->viewUpdates(); } # Show shared description, if needed if ($this->mExtraDescription) { $fol = wfMsgNoTrans('shareddescriptionfollows'); if ($fol != '-' && !wfEmptyMsg('shareddescriptionfollows', $fol)) { $wgOut->addWikiText($fol); } $wgOut->addHTML('<div id="shared-image-desc">' . $this->mExtraDescription . '</div>'); } $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); if ($showmeta) { global $wgStylePath, $wgStyleVersion; $expand = htmlspecialchars(wfEscapeJsString(wfMsg('metadata-expand'))); $collapse = htmlspecialchars(wfEscapeJsString(wfMsg('metadata-collapse'))); $wgOut->addHTML(Xml::element('h2', array('id' => 'metadata'), wfMsg('metadata')) . "\n"); $wgOut->addWikiText($this->makeMetadataTable($formattedMetadata)); $wgOut->addHTML("<script type=\"text/javascript\" src=\"{$wgStylePath}/common/metadata.js?{$wgStyleVersion}\"></script>\n" . "<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '{$expand}', '{$collapse}');</script>\n"); } }
protected function getContent($title) { if ($title->getNamespace() === NS_MEDIAWIKI) { $dbkey = $title->getDBkey(); return wfEmptyMsg($dbkey) ? '' : wfMsgExt($dbkey, 'content'); } if (!$title->isCssJsSubpage()) { return null; } $revision = Revision::newFromTitle($title); if (!$revision) { return null; } return $revision->getRawText(); }
/** * Produce a (possibly random) signature. * @return String */ static function fetchSignature() { $signatures = wfMsgForContent('newusermessage-signatures'); $signature = ''; if (!wfEmptyMsg('newusermessage-signatures', $signatures)) { $pattern = '/^\\* ?(.*?)$/m'; $signatureList = array(); preg_match_all($pattern, $signatures, $signatureList, PREG_SET_ORDER); if (count($signatureList) > 0) { $rand = rand(0, count($signatureList) - 1); $signature = $signatureList[$rand][1]; } } return $signature; }
function wfLoadGadgetsStructured($forceNewText = NULL) { global $wgContLang; global $wgMemc, $wgDBname; static $gadgets = NULL; if ($gadgets !== NULL && $forceNewText !== NULL) { return $gadgets; } $key = "{$wgDBname}:gadgets-definition"; if ($forceNewText == NULL) { //cached? $gadgets = $wgMemc->get($key); if ($gadgets !== NULL) { return $gadgets; } $g = wfMsgForContentNoTrans("gadgets-definition"); if (wfEmptyMsg("gadgets-definition", $g)) { $gadgets = false; return $gadgets; } } else { $g = $forceNewText; } $g = preg_replace('/<!--.*-->/s', '', $g); $g = preg_split('/(\\r\\n|\\r|\\n)+/', $g); $gadgets = array(); $section = ''; foreach ($g as $line) { if (preg_match('/^==+ *([^*:\\s|]+?)\\s*==+\\s*$/', $line, $m)) { $section = $m[1]; } else { if (preg_match('/^\\*+ *([a-zA-Z](?:[-_:.\\w\\d ]*[a-zA-Z0-9])?)\\s*((\\|[^|]*)+)\\s*$/', $line, $m)) { //NOTE: the gadget name is used as part of the name of a form field, // and must follow the rules defined in http://www.w3.org/TR/html4/types.html#type-cdata // Also, title-normalization applies. $name = str_replace(' ', '_', $m[1]); $code = preg_split('/\\s*\\|\\s*/', $m[2], -1, PREG_SPLIT_NO_EMPTY); if ($code) { $gadgets[$section][$name] = $code; } } } } //cache for a while. gets purged automatically when MediaWiki:Gadgets-definition is edited $wgMemc->set($key, $gadgets, 900); wfDebug("wfLoadGadgetsStructured: MediaWiki:Gadgets-definition parsed, cache entry {$key} updated\n"); return $gadgets; }
/** * Show the special page */ public function execute($par) { global $wgOut, $wgImplicitGroups, $wgMessageCache; global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups; $wgMessageCache->loadAllMessages(); $this->setHeaders(); $this->outputHeader(); $wgOut->addHTML(Xml::openElement('table', array('class' => 'mw-listgrouprights-table')) . '<tr>' . Xml::element('th', null, wfMsg('listgrouprights-group')) . Xml::element('th', null, wfMsg('listgrouprights-rights')) . '</tr>'); foreach ($wgGroupPermissions as $group => $permissions) { $groupname = $group == '*' ? 'all' : htmlspecialchars($group); // Replace * with a more descriptive groupname $msg = wfMsg('group-' . $groupname); if (wfEmptyMsg('group-' . $groupname, $msg) || $msg == '') { $groupnameLocalized = $groupname; } else { $groupnameLocalized = $msg; } $msg = wfMsgForContent('grouppage-' . $groupname); if (wfEmptyMsg('grouppage-' . $groupname, $msg) || $msg == '') { $grouppageLocalized = MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname; } else { $grouppageLocalized = $msg; } if ($group == '*') { // Do not make a link for the generic * group $grouppage = $groupnameLocalized; } else { $grouppage = $this->skin->makeLink($grouppageLocalized, $groupnameLocalized); } if ($group === 'user') { // Link to Special:listusers for implicit group 'user' $grouplink = '<br />' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), ''); } elseif (!in_array($group, $wgImplicitGroups)) { $grouplink = '<br />' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), 'group=' . $group); } else { // No link to Special:listusers for other implicit groups as they are unlistable $grouplink = ''; } $addgroups = isset($wgAddGroups[$group]) ? $wgAddGroups[$group] : array(); $removegroups = isset($wgRemoveGroups[$group]) ? $wgRemoveGroups[$group] : array(); $wgOut->addHTML('<tr> <td>' . $grouppage . $grouplink . '</td> <td>' . self::formatPermissions($permissions, $addgroups, $removegroups) . '</td> </tr>'); } $wgOut->addHTML(Xml::closeElement('table') . "\n"); }
/** * Show the special page * * @param mixed $par (not used) */ function wfSpecialStatistics($par = '') { global $wgOut, $wgLang, $wgRequest; $dbr = wfGetDB(DB_SLAVE); $views = SiteStats::views(); $edits = SiteStats::edits(); $good = SiteStats::articles(); $images = SiteStats::images(); $total = SiteStats::pages(); $users = SiteStats::users(); $admins = SiteStats::admins(); $numJobs = SiteStats::jobs(); if ($wgRequest->getVal('action') == 'raw') { $wgOut->disable(); header('Pragma: nocache'); echo "total={$total};good={$good};views={$views};edits={$edits};users={$users};admins={$admins};images={$images};jobs={$numJobs}\n"; return; } else { $text = "__NOTOC__\n"; $text .= '==' . wfMsg('sitestats') . "==\n"; $text .= wfMsgExt('sitestatstext', array('parsemag'), $wgLang->formatNum($total), $wgLang->formatNum($good), $wgLang->formatNum($views), $wgLang->formatNum($edits), $wgLang->formatNum(sprintf('%.2f', $total ? $edits / $total : 0)), $wgLang->formatNum(sprintf('%.2f', $edits ? $views / $edits : 0)), $wgLang->formatNum($numJobs), $wgLang->formatNum($images)) . "\n"; $text .= "==" . wfMsg('userstats') . "==\n"; $text .= wfMsgExt('userstatstext', array('parsemag'), $wgLang->formatNum($users), $wgLang->formatNum($admins), '[[' . wfMsgForContent('grouppage-sysop') . ']]', $wgLang->formatNum(sprintf('%.2f', $admins / $users * 100)), User::makeGroupLinkWiki('sysop')) . "\n"; global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang; if (!$wgDisableCounters && !$wgMiserMode) { $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_counter'), array('page_is_redirect' => 0, 'page_counter > 0'), __METHOD__, array('ORDER BY' => 'page_counter DESC', 'LIMIT' => 10)); if ($res->numRows() > 0) { $text .= "==" . wfMsg('statistics-mostpopular') . "==\n"; while ($row = $res->fetchObject()) { $title = Title::makeTitleSafe($row->page_namespace, $row->page_title); if ($title instanceof Title) { $text .= '* [[:' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum($row->page_counter) . ")\n"; } } $res->free(); } } $footer = wfMsg('statistics-footer'); if (!wfEmptyMsg('statistics-footer', $footer) && $footer != '') { $text .= "\n" . $footer; } $wgOut->addWikiText($text); } }