private function createFeedItem($row) { global $wgOut; $thread = Thread::newFromRow($row); $linker = new Linker(); $titleStr = $thread->subject(); $completeText = $thread->root()->getContent(); $completeText = $wgOut->parse($completeText); $threadTitle = clone $thread->topmostThread()->title(); $threadTitle->setFragment('#' . $thread->getAnchorName()); $titleUrl = $threadTitle->getFullURL(); $timestamp = $thread->created(); $user = $thread->author()->getName(); // Grab the title for the superthread, if one exists. $stTitle = null; if ($thread->hasSuperThread()) { $stTitle = clone $thread->topmostThread()->title(); $stTitle->setFragment('#' . $thread->superthread()->getAnchorName()); } // Prefix content with a quick description $userLink = $linker->userLink($thread->author()->getId(), $user); $talkpageLink = $linker->link($thread->getTitle()); $superthreadLink = $linker->link($stTitle); $description = wfMsgExt($thread->hasSuperThread() ? 'lqt-feed-reply-intro' : 'lqt-feed-new-thread-intro', array('parse', 'replaceafter'), array($talkpageLink, $userLink, $superthreadLink)); $completeText = $description . $completeText; return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user); }
function wfSajaxSearch($term) { global $wgContLang, $wgOut; $limit = 16; $l = new Linker(); $term = str_replace(' ', '_', $wgContLang->ucfirst($wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term))))); if (strlen(str_replace('_', '', $term)) < 3) { return; } $db =& wfGetDB(DB_SLAVE); $res = $db->select('page', 'page_title', array('page_namespace' => 0, "page_title LIKE '" . $db->strencode($term) . "%'"), "wfSajaxSearch", array('LIMIT' => $limit + 1)); $r = ""; $i = 0; while (($row = $db->fetchObject($res)) && ++$i <= $limit) { $nt = Title::newFromDBkey($row->page_title); $r .= '<li>' . $l->makeKnownLinkObj($nt) . "</li>\n"; } if ($i > $limit) { $more = '<i>' . $l->makeKnownLink($wgContLang->specialPage("Allpages"), wfMsg('moredotdotdot'), "namespace=0&from=" . wfUrlEncode($term)) . '</i>'; } else { $more = ''; } $subtitlemsg = Title::newFromText($term) ? 'searchsubtitle' : 'searchsubtitleinvalid'; $subtitle = $wgOut->parse(wfMsg($subtitlemsg, wfEscapeWikiText($term))); #FIXME: parser is missing mTitle ! $term = htmlspecialchars($term); $html = '<div style="float:right; border:solid 1px black;background:gainsboro;padding:2px;"><a onclick="Searching_Hide_Results();">' . wfMsg('hideresults') . '</a></div>' . '<h1 class="firstHeading">' . wfMsg('search') . '</h1><div id="contentSub">' . $subtitle . '</div><ul><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchcontaining', $term), "search={$term}&fulltext=Search") . '</li><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchnamed', $term), "search={$term}&go=Go") . "</li></ul><h2>" . wfMsg('articletitles', $term) . "</h2>" . '<ul>' . $r . '</ul>' . $more; $response = new AjaxResponse($html); $response->setCacheDuration(30 * 60); return $response; }
function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) { // From CategoryViewer::addPage global $wgContLang; $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $sortkey ) ); // Customization global $wgPeopleCategories; $name = $title->getText(); if( in_array( $this->title->getText(), $wgPeopleCategories ) && strpos( $name, ' ' ) ) { $first = substr( $name, 0, strrpos( $name, ' ' ) ); $last = substr( $name, strrpos( $name, ' ' ) + 1 ); $name = $last . ', ' . $first; } if( $title->getNamespace() !== NS_MAIN ) { $name = $title->getNsText() . ':' . $name; } $linker = new Linker; if( $isRedirect ) { $this->articles[] = '<span class="redirect-in-category">' . $linker->link( $title, $name ) . '</span>'; } else { $this->articles[] = $linker->link( $title, $name ); } }
/** * a StaffLog::formatRow hook * * Formats a log entry to be displayed on Special:StaffLog */ public static function formatLog($type, $result, $time, $linker, &$out) { if ('spamwiki' == $type) { $l = new Linker(); $out = "{$time} {$type} - user {$l->userLink($result->slog_user, $result->slog_user_name)} {$result->slog_comment}."; } return true; }
/** * Function generates Contribution Scores tables in HTML format (not wikiText) * * @param $days int Days in the past to run report for * @param $limit int Maximum number of users to return (default 50) * @param $title Title (default null) * @param $options array of options (default none; nosort/notools) * @return Html Table representing the requested Contribution Scores. */ function genContributionScoreTable($days, $limit, $title = null, $options = 'none') { global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName; $opts = explode(',', strtolower($options)); $dbr = wfGetDB(DB_SLAVE); $userTable = $dbr->tableName('user'); $userGroupTable = $dbr->tableName('user_groups'); $revTable = $dbr->tableName('revision'); $ipBlocksTable = $dbr->tableName('ipblocks'); $sqlWhere = ""; $nextPrefix = "WHERE"; if ($days > 0) { $date = time() - 60 * 60 * 24 * $days; $dateString = $dbr->timestamp($date); $sqlWhere .= " {$nextPrefix} rev_timestamp > '{$dateString}'"; $nextPrefix = "AND"; } if ($wgContribScoreIgnoreBlockedUsers) { $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)"; $nextPrefix = "AND"; } if ($wgContribScoreIgnoreBots) { $sqlWhere .= " {$nextPrefix} rev_user NOT IN (SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')"; } $sqlMostPages = "SELECT rev_user,\n\t\t\t\t\t\t COUNT(DISTINCT rev_page) AS page_count,\n\t\t\t\t\t\t COUNT(rev_id) AS rev_count\n\t\t\t\t\t\t FROM {$revTable}\n\t\t\t\t\t\t {$sqlWhere}\n\t\t\t\t\t\t GROUP BY rev_user\n\t\t\t\t\t\t ORDER BY page_count DESC\n\t\t\t\t\t\t LIMIT {$limit}"; $sqlMostRevs = "SELECT rev_user,\n\t\t\t\t\t\t COUNT(DISTINCT rev_page) AS page_count,\n\t\t\t\t\t\t COUNT(rev_id) AS rev_count\n\t\t\t\t\t\t FROM {$revTable}\n\t\t\t\t\t\t {$sqlWhere}\n\t\t\t\t\t\t GROUP BY rev_user\n\t\t\t\t\t\t ORDER BY rev_count DESC\n\t\t\t\t\t\t LIMIT {$limit}"; $sql = "SELECT user_id, " . "user_name, " . "user_real_name, " . "page_count, " . "rev_count, " . "page_count+SQRT(rev_count-page_count)*2 AS wiki_rank " . "FROM {$userTable} u JOIN (({$sqlMostPages}) UNION ({$sqlMostRevs})) s ON (user_id=rev_user) " . "ORDER BY wiki_rank DESC " . "LIMIT {$limit}"; $res = $dbr->query($sql); $sortable = in_array('nosort', $opts) ? '' : ' sortable'; $output = "<table class=\"wikitable contributionscores plainlinks{$sortable}\" >\n" . "<tr class='header'>\n" . Html::element('th', array(), $this->msg('contributionscores-score')->text()) . Html::element('th', array(), $this->msg('contributionscores-pages')->text()) . Html::element('th', array(), $this->msg('contributionscores-changes')->text()) . Html::element('th', array(), $this->msg('contributionscores-username')->text()); $altrow = ''; $lang = $this->getLanguage(); foreach ($res as $row) { // Use real name if option used and real name present. if ($wgContribScoresUseRealName && $row->user_real_name !== '') { $userLink = Linker::userLink($row->user_id, $row->user_name, $row->user_real_name); } else { $userLink = Linker::userLink($row->user_id, $row->user_name); } $output .= Html::closeElement('tr'); $output .= "<tr class='{$altrow}'>\n<td class='content'>" . $lang->formatNum(round($row->wiki_rank, 0)) . "\n</td><td class='content'>" . $lang->formatNum($row->page_count) . "\n</td><td class='content'>" . $lang->formatNum($row->rev_count) . "\n</td><td class='content'>" . $userLink; # Option to not display user tools if (!in_array('notools', $opts)) { $output .= Linker::userToolLinks($row->user_id, $row->user_name); } $output .= Html::closeElement('td') . "\n"; if ($altrow == '' && empty($sortable)) { $altrow = 'odd '; } else { $altrow = ''; } } $output .= Html::closeElement('tr'); $output .= Html::closeElement('table'); $dbr->freeResult($res); if (!empty($title)) { $output = Html::rawElement('table', array('style' => 'border-spacing: 0; padding: 0', 'class' => 'contributionscores-wrapper', 'lang' => htmlspecialchars($lang->getCode()), 'dir' => $lang->getDir()), "\n" . "<tr>\n" . "<td style='padding: 0px;'>{$title}</td>\n" . "</tr>\n" . "<tr>\n" . "<td style='padding: 0px;'>{$output}</td>\n" . "</tr>\n"); } return $output; }
/** * (non-PHPdoc) * @see EPPager::getFormattedValue() */ protected function getFormattedValue($name, $value) { switch ($name) { case 'id': $value = Linker::linkKnown(SpecialPage::getTitleFor('Student', $value), htmlspecialchars($this->getLanguage()->formatNum($value, true))); break; case 'user_id': $user = User::newFromId($value); $name = $user->getRealName() === '' ? $user->getName() : $user->getRealName(); $value = Linker::userLink($value, $name) . Linker::userToolLinks($value, $name); break; case 'first_enroll': case 'last_active': $value = htmlspecialchars($this->getLanguage()->date($value)); break; case 'active_enroll': $value = wfMsgHtml($value === '1' ? 'epstudentpager-yes' : 'epstudentpager-no'); break; case '_courses_current': $value = $this->getLanguage()->pipeList(array_map(function (EPCourse $course) { return $course->getLink(); }, $this->currentObject->getCoursesWithState('current', 'name'))); break; } return $value; }
function formatRow($row) { $time = htmlspecialchars($this->getLanguage()->userDate($row->log_timestamp, $this->getUser())); $paramsSerialized = unserialize($row->log_params); $paramsOldFormat = null; // If the params aren't serialized, it's an older log format if ($paramsSerialized === false) { $paramsOldFormat = explode("\n", $row->log_params); } $targetName = $paramsSerialized === false ? $paramsOldFormat[0] : $paramsSerialized['4::target']; $logPageId = (int) $row->log_page; $currentTitle = $logPageId && $logPageId !== 0 ? Title::newFromID($logPageId) : null; $targetTitleObj = Title::newFromText($targetName); // Make sure the target is NS_MAIN if ($targetTitleObj->getNamespace() !== NS_MAIN) { return false; } $originalNameDisplay = ''; if ($currentTitle && $targetName !== $currentTitle->getFullText()) { $originalNameDisplay = ' ' . $this->msg('newarticles-original-title')->params($targetName); } $pageLink = Linker::link($originalNameDisplay ? $currentTitle : $targetTitleObj); $articleTypeDisplay = ''; if (isset($row->pp_value) && $row->pp_value === 'portal') { $pageLink = Html::rawElement('strong', [], $pageLink); $articleTypeReadable = WRArticleType::getReadableArticleTypeFromCode($row->pp_value); $articleTypeDisplay = $this->msg('newarticles-articletype')->params($articleTypeReadable)->text(); $articleTypeDisplay = ' ' . $articleTypeDisplay; } $formattedRow = Html::rawElement('li', [], "{$time}: {$pageLink}{$articleTypeDisplay}{$originalNameDisplay}") . "\n"; return $formattedRow; }
static function formatLogEntry($type, $action, $title, $sk, $parameters) { $msg = "lqt-log-action-{$action}"; switch ($action) { case 'merge': if ($parameters[0]) { $msg = 'lqt-log-action-merge-across'; } else { $msg = 'lqt-log-action-merge-down'; } break; case 'move': $smt = new SpecialMoveThread(); $rightsCheck = $smt->checkUserRights($parameters[1] instanceof Title ? $parameters[1] : Title::newFromText($parameters[1]), $parameters[0] instanceof Title ? $parameters[0] : Title::newFromText($parameters[0])); if ($rightsCheck === true) { $parameters[] = Message::rawParam(Linker::link(SpecialPage::getTitleFor('MoveThread', $title), wfMessage('revertmove')->text(), array(), array('dest' => $parameters[0]))); } else { $parameters[] = ''; } break; default: // Give grep a chance to find the usages: // lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit, // lqt-log-action-resort, lqt-log-action-signatureedit $msg = "lqt-log-action-{$action}"; break; } array_unshift($parameters, $title->getPrefixedText()); $html = wfMessage($msg, $parameters); if ($sk === null) { return StringUtils::delimiterReplace('<', '>', '', $html->inContentLanguage()->parse()); } return $html->parse(); }
/** * @param $skin Skin * @param $result * @return string */ function formatResult($skin, $result) { $title = Title::makeTitleSafe($result->namespace, $result->title); $count = $this->msg('ncategories')->numParams($result->value)->escaped(); $link = Linker::link($title); return $this->getLanguage()->specialList($link, $count); }
function formatValue($name, $value) { global $wgContLang; switch ($name) { case 'article_title': $articleId = $this->mCurrentRow->article_id; $title = Title::newFromID($articleId); return $title ? Linker::link($title) : '(unknown, id: ' . $articleId . ')'; break; case 'page_ns': return ($value != 0 ? $wgContLang->getNsText($value) : $this->mainNamespaceText) . " [{$value}]"; break; case 'average_time': case 'minimum_time': case 'maximum_time': return $value . " s"; break; case 'wikitext_size': case 'html_size': return sprintf("%.1f kb", $value / 1000); break; default: return $value; } }
/** * @param Skin $skin * @param object $result Result row * @return string */ function formatResult($skin, $result) { $title = Title::makeTitle(NS_TEMPLATE, $result->title); $pageLink = Linker::linkKnown($title, null, array(), array('redirect' => 'no')); $wlhLink = Linker::linkKnown(SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText()), $this->msg('unusedtemplateswlh')->escaped()); return $this->getLanguage()->specialList($pageLink, $wlhLink); }
function doTagRow($tag, $hitcount) { static $doneTags = array(); if (in_array($tag, $doneTags)) { return ''; } $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); $newRow .= Xml::tags('td', null, $desc); $hitcount = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcount = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
public function formatRow($row) { $title = Title::makeTitle($row->page_namespace, $row->page_title); // Link to page $link = Linker::link($title); // Helpful utility links $utilLinks = array(); $utilLinks[] = Linker::link($title, wfMsgHtml('stablepages-config'), array(), array('action' => 'protect'), 'known'); $utilLinks[] = Linker::link($title, wfMsgHtml('history'), array(), array('action' => 'history'), 'known'); $utilLinks[] = Linker::link(SpecialPage::getTitleFor('Log', 'stable'), wfMsgHtml('stable-logpage'), array(), array('page' => $title->getPrefixedText()), 'known'); // Autoreview/review restriction level $restr = ''; if ($row->fpc_level != '') { $restr = 'autoreview=' . htmlspecialchars($row->fpc_level); $restr = "[{$restr}]"; } // When these configuration settings expire if ($row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry)) { $expiry_description = " (" . wfMsgForContent('protect-expiring', $this->getLang()->timeanddate($row->fpc_expiry), $this->getLang()->date($row->fpc_expiry), $this->getLang()->time($row->fpc_expiry)) . ")"; } else { $expiry_description = ""; } $utilLinks = $this->getLang()->pipeList($utilLinks); return "<li>{$link} ({$utilLinks}) {$restr}<i>{$expiry_description}</i></li>"; }
/** * @return string A HTML <li> element representing this revision, showing * change tags and everything */ public function getHTML() { $date = htmlspecialchars($this->list->getLanguage()->userTimeAndDate($this->row->log_timestamp, $this->list->getUser())); $title = Title::makeTitle($this->row->log_namespace, $this->row->log_title); $formatter = LogFormatter::newFromRow($this->row); $formatter->setContext($this->list->getContext()); $formatter->setAudience(LogFormatter::FOR_THIS_USER); // Log link for this page $loglink = Linker::link(SpecialPage::getTitleFor('Log'), $this->list->msg('log')->escaped(), array(), array('page' => $title->getPrefixedText())); $loglink = $this->list->msg('parentheses')->rawParams($loglink)->escaped(); // User links and action text $action = $formatter->getActionText(); // Comment $comment = $this->list->getLanguage()->getDirMark() . $formatter->getComment(); if (LogEventsList::isDeleted($this->row, LogPage::DELETED_COMMENT)) { $comment = '<span class="history-deleted">' . $comment . '</span>'; } $content = "{$loglink} {$date} {$action} {$comment}"; $attribs = array(); $tags = $this->getTags(); if ($tags) { list($tagSummary, $classes) = ChangeTags::formatSummaryRow($tags, 'edittags', $this->list->getContext()); $content .= " {$tagSummary}"; $attribs['class'] = implode(' ', $classes); } return Xml::tags('li', $attribs, $content); }
function getButtons() { $buttons = ''; if ($this->mShowSubmit) { $attribs = array(); if (isset($this->mSubmitID)) { $attribs['id'] = $this->mSubmitID; } if (isset($this->mSubmitName)) { $attribs['name'] = $this->mSubmitName; } if (isset($this->mSubmitTooltip)) { $attribs += Linker::tooltipAndAccesskeyAttribs($this->mSubmitTooltip); } $attribs['class'] = array('mw-htmlform-submit', 'mw-ui-button mw-ui-big mw-ui-block', $this->mSubmitModifierClass); $buttons .= Xml::submitButton($this->getSubmitText(), $attribs) . "\n"; } if ($this->mShowReset) { $buttons .= Html::element('input', array('type' => 'reset', 'value' => $this->msg('htmlform-reset')->text(), 'class' => 'mw-ui-button mw-ui-big mw-ui-block')) . "\n"; } foreach ($this->mButtons as $button) { $attrs = array('type' => 'submit', 'name' => $button['name'], 'value' => $button['value']); if ($button['attribs']) { $attrs += $button['attribs']; } if (isset($button['id'])) { $attrs['id'] = $button['id']; } $attrs['class'] = isset($attrs['class']) ? (array) $attrs['class'] : array(); $attrs['class'][] = 'mw-ui-button mw-ui-big mw-ui-block'; $buttons .= Html::element('input', $attrs) . "\n"; } $html = Html::rawElement('div', array('class' => 'mw-htmlform-submit-buttons'), "\n{$buttons}") . "\n"; return $html; }
public function formatRow($row) { $title = Title::newFromRow($row); # Link to page $link = Linker::link($title); # Link to page configuration $config = Linker::linkKnown(SpecialPage::getTitleFor('Stabilization'), wfMsgHtml('configuredpages-config'), array(), 'page=' . $title->getPrefixedUrl()); # Show which version is the default (stable or draft) if (intval($row->fpc_override)) { $default = wfMsgHtml('configuredpages-def-stable'); } else { $default = wfMsgHtml('configuredpages-def-draft'); } # Autoreview/review restriction level $restr = ''; if ($row->fpc_level != '') { $restr = 'autoreview=' . htmlspecialchars($row->fpc_level); $restr = "[{$restr}]"; } # When these configuration settings expire if ($row->fpc_expiry != 'infinity' && strlen($row->fpc_expiry)) { $expiry_description = " (" . wfMsgForContent('protect-expiring', $this->getLang()->timeanddate($row->fpc_expiry), $this->getLang()->date($row->fpc_expiry), $this->getLang()->time($row->fpc_expiry)) . ")"; } else { $expiry_description = ""; } return "<li>{$link} ({$config}) <b>[{$default}]</b> " . "{$restr}<i>{$expiry_description}</i></li>"; }
private function createFeedItem($row) { $thread = Thread::newFromRow($row); $titleStr = $thread->subject(); $completeText = $thread->root()->getContent(); $completeText = $this->getOutput()->parse($completeText); $threadTitle = clone $thread->topmostThread()->title(); $threadTitle->setFragment('#' . $thread->getAnchorName()); $titleUrl = $threadTitle->getFullURL(); $timestamp = $thread->created(); $user = $thread->author()->getName(); // Prefix content with a quick description $userLink = Linker::userLink($thread->author()->getId(), $user); $talkpageLink = Linker::link($thread->getTitle()); if ($thread->hasSuperThread()) { $stTitle = clone $thread->topmostThread()->title(); $stTitle->setFragment('#' . $thread->superthread()->getAnchorName()); $superthreadLink = Linker::link($stTitle); $description = wfMessage('lqt-feed-reply-intro')->rawParams($talkpageLink, $userLink, $superthreadLink)->params($user)->parseAsBlock(); } else { // Third param is unused $description = wfMessage('lqt-feed-new-thread-intro')->rawParams($talkpageLink, $userLink, '')->params($user)->parseAsBlock(); } $completeText = $description . $completeText; return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user); }
public static function getLinkFor($identifierValue, $action = 'view', $html = null, $customAttribs = array(), $query = array()) { if ($action !== 'view') { $query['action'] = $action; } return Linker::linkKnown(self::getTitleFor($identifierValue, $action), is_null($html) ? htmlspecialchars($identifierValue) : $html, $customAttribs, $query); }
/** * Returns HTML of license link or empty string * For example: * "<a title="Wikipedia:Copyright" href="/index.php/Wikipedia:Copyright">CC BY</a>" * * @param string $context The context in which the license link appears, e.g. footer, * editor, talk, or upload. * @param array $attribs An associative array of extra HTML attributes to add to the link * @return string */ public static function getLicense($context, $attribs = array()) { $config = MobileContext::singleton()->getConfig(); $rightsPage = $config->get('RightsPage'); $rightsUrl = $config->get('RightsUrl'); $rightsText = $config->get('RightsText'); // Construct the link to the licensing terms if ($rightsText) { // Use shorter text for some common licensing strings. See Installer.i18n.php // for the currently offered strings. Unfortunately, there is no good way to // comprehensively support localized licensing strings since the license (as // stored in LocalSettings.php) is just freeform text, not an i18n key. $commonLicenses = array('Creative Commons Attribution-Share Alike 3.0' => 'CC BY-SA 3.0', 'Creative Commons Attribution Share Alike' => 'CC BY-SA', 'Creative Commons Attribution 3.0' => 'CC BY 3.0', 'Creative Commons Attribution 2.5' => 'CC BY 2.5', 'Creative Commons Attribution' => 'CC BY', 'Creative Commons Attribution Non-Commercial Share Alike' => 'CC BY-NC-SA', 'Creative Commons Zero (Public Domain)' => 'CC0 (Public Domain)', 'GNU Free Documentation License 1.3 or later' => 'GFDL 1.3 or later'); if (isset($commonLicenses[$rightsText])) { $rightsText = $commonLicenses[$rightsText]; } if ($rightsPage) { $title = Title::newFromText($rightsPage); $link = Linker::linkKnown($title, $rightsText, $attribs); } elseif ($rightsUrl) { $link = Linker::makeExternalLink($rightsUrl, $rightsText, true, '', $attribs); } else { $link = $rightsText; } } else { $link = ''; } // Allow other extensions (for example, WikimediaMessages) to override $msg = 'mobile-frontend-copyright'; Hooks::run('MobileLicenseLink', array(&$link, $context, $attribs, &$msg)); return array('msg' => $msg, 'link' => $link, 'plural' => self::getPluralLicenseInfo($link)); }
/** * Callback function to output a restriction * * @param object $row Database row * @return string */ function formatRow($row) { wfProfileIn(__METHOD__); static $infinity = null; if (is_null($infinity)) { $infinity = wfGetDB(DB_SLAVE)->getInfinity(); } $title = Title::makeTitleSafe($row->pt_namespace, $row->pt_title); if (!$title) { wfProfileOut(__METHOD__); return Html::rawElement('li', array(), Html::element('span', array('class' => 'mw-invalidtitle'), Linker::getInvalidTitleDescription($this->getContext(), $row->pt_namespace, $row->pt_title))) . "\n"; } $link = Linker::link($title); $description_items = array(); $protType = $this->msg('restriction-level-' . $row->pt_create_perm)->escaped(); $description_items[] = $protType; $lang = $this->getLanguage(); $expiry = strlen($row->pt_expiry) ? $lang->formatExpiry($row->pt_expiry, TS_MW) : $infinity; if ($expiry != $infinity) { $user = $this->getUser(); $description_items[] = $this->msg('protect-expiring-local', $lang->userTimeAndDate($expiry, $user), $lang->userDate($expiry, $user), $lang->userTime($expiry, $user))->escaped(); } wfProfileOut(__METHOD__); // @todo i18n: This should use a comma separator instead of a hard coded comma, right? return '<li>' . $lang->specialList($link, implode($description_items, ', ')) . "</li>\n"; }
/** * @param Skin $skin * @param object $result Result row * @return string */ function formatResult($skin, $result) { global $wgContLang; $nt = Title::makeTitle($result->namespace, $result->title); $text = htmlspecialchars($wgContLang->convert($nt->getText())); if (!$this->isCached()) { // We can assume the freshest data $plink = Linker::link($nt, $text, array(), array(), array('broken')); $nlinks = $this->msg('nmembers')->numParams($result->value)->escaped(); } else { $plink = Linker::link($nt, $text); $currentValue = isset($this->currentCategoryCounts[$result->title]) ? $this->currentCategoryCounts[$result->title] : 0; $cachedValue = intval($result->value); // T76910 // If the category has been created or emptied since the list was refreshed, strike it if ($nt->isKnown() || $currentValue === 0) { $plink = "<del>{$plink}</del>"; } // Show the current number of category entries if it changed if ($currentValue !== $cachedValue) { $nlinks = $this->msg('nmemberschanged')->numParams($cachedValue, $currentValue)->escaped(); } else { $nlinks = $this->msg('nmembers')->numParams($cachedValue)->escaped(); } } return $this->getLanguage()->specialList($plink, $nlinks); }
/** * The category list template. Used by article pages on view and edit save. */ public function categories() { wfProfileIn(__METHOD__); $categories = $this->request->getVal('categories', array()); $data = array(); // Because $out->getCategoryLinks doesn't maintain the order of the stored category data, // we have to build this information ourselves manually. This is essentially the same // code from $out->addCategoryLinks() but it results in a different data format. foreach ($categories as $category) { // Support category name or category data object $name = is_array($category) ? $category['name'] : $category; $originalName = $name; $title = Title::makeTitleSafe(NS_CATEGORY, $name); if ($title != null) { $this->wg->ContLang->findVariantLink($name, $title, true); if ($name != $originalName && array_key_exists($name, $data)) { continue; } $text = $this->wg->ContLang->convertHtml($title->getText()); $data[$name] = array('link' => Linker::link($title, $text), 'name' => $text, 'type' => CategoryHelper::getCategoryType($originalName)); } else { \Wikia\Logger\WikiaLogger::instance()->warning("Unsafe category provided", ['name' => $name]); } } $this->response->setVal('categories', $data); wfProfileOut(__METHOD__); }
/** * Main execution point * * @param null|string $code Confirmation code passed to the page */ function execute( $code ) { $this->setHeaders(); $this->checkReadOnly(); $this->checkPermissions(); // This could also let someone check the current email address, so // require both permissions. if ( !$this->getUser()->isAllowed( 'viewmyprivateinfo' ) ) { throw new PermissionsError( 'viewmyprivateinfo' ); } if ( $code === null || $code === '' ) { if ( $this->getUser()->isLoggedIn() ) { if ( Sanitizer::validateEmail( $this->getUser()->getEmail() ) ) { $this->showRequestForm(); } else { $this->getOutput()->addWikiMsg( 'confirmemail_noemail' ); } } else { $llink = Linker::linkKnown( SpecialPage::getTitleFor( 'Userlogin' ), $this->msg( 'loginreqlink' )->escaped(), array(), array( 'returnto' => $this->getTitle()->getPrefixedText() ) ); $this->getOutput()->addHTML( $this->msg( 'confirmemail_needlogin' )->rawParams( $llink )->parse() ); } } else { $this->attemptConfirm( $code ); } }
/** * @return array */ protected function getMessageParameters() { $entry = $this->entry->getParameters(); $params = parent::getMessageParameters(); $filter_title = SpecialPage::getTitleFor('AbuseFilter', $entry['filter']); $filter_caption = $this->msg('abusefilter-log-detailedentry-local')->params($entry['filter']); $log_title = SpecialPage::getTitleFor('AbuseLog', $entry['log']); $log_caption = $this->msg('abusefilter-log-detailslink'); $params[4] = $entry['action']; if ($this->plaintext) { $params[3] = '[[' . $filter_title->getPrefixedText() . '|' . $filter_caption . ']]'; $params[8] = '[[' . $log_title->getPrefixedText() . '|' . $log_caption . ']]'; } else { $params[3] = Message::rawParam(Linker::link($filter_title, htmlspecialchars($filter_caption))); $params[8] = Message::rawParam(Linker::link($log_title, htmlspecialchars($log_caption))); } $actions_taken = $entry['actions']; if (!strlen(trim($actions_taken))) { $actions_taken = $this->msg('abusefilter-log-noactions'); } else { $actions = explode(',', $actions_taken); $displayActions = array(); foreach ($actions as $action) { $displayActions[] = AbuseFilter::getActionDisplay($action); } $actions_taken = $this->context->getLanguage()->commaList($displayActions); } $params[5] = $actions_taken; // Bad things happen if the numbers are not in correct order ksort($params); return $params; }
function doTagRow($tag, $hitcount) { $user = $this->getUser(); $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); if ($user->isAllowed('editinterface')) { $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); } $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); if ($user->isAllowed('editinterface')) { $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); } $newRow .= Xml::tags('td', null, $desc); $active = isset($this->definedTags[$tag]) ? 'tags-active-yes' : 'tags-active-no'; $active = $this->msg($active)->escaped(); $newRow .= Xml::tags('td', null, $active); $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcountLink = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, array(), array('tagfilter' => $tag)); // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters $newRow .= Xml::tags('td', array('data-sort-value' => $hitcount), $hitcountLink); return Xml::tags('tr', null, $newRow) . "\n"; }
function deleteForm($query, $reason) { $title = $this->getTitle(); $output = $this->getOutput(); $pages = $this->getPages($query); $count = count($pages); if ($count == 0) { $output->addWikiText($this->msg('nukedpl-nopages', $query)->text()); return $this->queryForm(); } $output->addWikiText($this->msg('nukedpl-list', $count, $query)->text()); $output->addHTML(Xml::element('form', array('action' => $title->getLocalURL('action=delete'), 'method' => 'post'), null)); $output->addHTML(Xml::element('input', array('type' => 'submit', 'value' => $this->msg('nukedpl-nuke')->text()))); $output->addHTML('<div>' . $this->msg('deletecomment')->escaped() . '</div>'); $output->addHTML(Xml::element('input', array('name' => 'reason', 'value' => $reason, 'size' => 60))); $output->addHTML('<ol>'); foreach ($pages as $page) { $page = Title::newFromText($page); if ($page and $page->isKnown()) { $output->addHTML('<li>'); $output->addHTML(Xml::element('input', array('type' => 'checkbox', 'name' => 'ids[]', 'value' => $page->getArticleID(), 'checked' => 'checked'))); $output->addHTML(Linker::makeKnownLinkObj($page)); $output->addHTML('</li>'); } } $output->addHTML('</ol>'); $output->addHTML(Xml::element('input', array('type' => 'submit', 'value' => $this->msg('nukedpl-nuke')->text()))); $output->addHTML('</form>'); }
public function execute($params = false) { $sEditLinkText = wfMessage('bs-widget-edit')->text(); $oTitle = Title::makeTitle(NS_USER, RequestContext::getMain()->getUser()->getName() . '/Widgetbar'); $sEditLink = Linker::link($oTitle, Html::rawElement('span', array(), $sEditLinkText), array('id' => 'bs-widgetbar-edit', 'class' => 'icon-pencil clearfix'), array('action' => 'edit', 'preload' => '')); $aOut = array(); $aOut[] = '<div id="bs-widget-container" >'; $aOut[] = ' <div class="icon-plus" id="bs-widget-tab" title="' . wfMessage('bs-widget-container-tooltip')->text() . '" tabindex="100">[+/-]</div>'; $aOut[] = ' <div id="bs-flyout">'; $aOut[] = ' <h4 id="bs-flyout-heading">' . wfMessage('bs-widget-flyout-heading')->text() . '</h4>'; $aOut[] = ' <div id="bs-flyout-content">'; $aOut[] = ' <div id="bs-flyout-content-widgets">'; $aOut[] = ' <h4 id="bs-flyout-content-widgets-header">' . wfMessage("bs-widget-flyout-heading")->plain() . $sEditLink . '</h4>'; foreach ($this->_mWidgets as $oWidgetView) { if ($oWidgetView instanceof ViewWidget) { $aOut[] = $oWidgetView->execute(); } else { wfDebug(__METHOD__ . ': Invalid widget.'); } } $aOut[] = ' </div>'; $aOut[] = ' </div>'; $aOut[] = ' </div>'; $aOut[] = '</div>'; return implode("\n", $aOut); }
/** * Make a link placeholder. The text returned can be later resolved to a real link with * replaceLinkHolders(). This is done for two reasons: firstly to avoid further * parsing of interwiki links, and secondly to allow all existence checks and * article length checks (for stub links) to be bundled into a single query. * */ function makeHolder($nt, $text = '', $query = '', $trail = '', $prefix = '') { wfProfileIn(__METHOD__); if (!is_object($nt)) { # Fail gracefully $retVal = "<!-- ERROR -->{$prefix}{$text}{$trail}"; } else { # Separate the link trail from the rest of the link list($inside, $trail) = Linker::splitTrail($trail); $entry = array('title' => $nt, 'text' => $prefix . $text . $inside, 'pdbk' => $nt->getPrefixedDBkey()); if ($query !== '') { $entry['query'] = $query; } if ($nt->isExternal()) { // Use a globally unique ID to keep the objects mergable $key = $this->parent->nextLinkID(); $this->interwikis[$key] = $entry; $retVal = "<!--IWLINK {$key}-->{$trail}"; } else { $key = $this->parent->nextLinkID(); $ns = $nt->getNamespace(); $this->internals[$ns][$key] = $entry; $retVal = "<!--LINK {$ns}:{$key}-->{$trail}"; } $this->size++; } wfProfileOut(__METHOD__); return $retVal; }
public function getActionLinks() { if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden || $this->entry->getSubtype() !== 'move' || !$this->context->getUser()->isAllowed( 'move' ) ) { return ''; } $params = $this->extractParameters(); $destTitle = Title::newFromText( $params[3] ); if ( !$destTitle ) { return ''; } $revert = Linker::linkKnown( SpecialPage::getTitleFor( 'Movepage' ), $this->msg( 'revertmove' )->escaped(), array(), array( 'wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(), 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(), 'wpMovetalk' => 0 ) ); return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); }
function execute($category) { global $wgUser, $wgRequest, $wgOut, $wgPageSchemasHandlerClasses; if (!$wgUser->isAllowed('generatepages')) { $wgOut->permissionRequired('generatepages'); return; } $this->setHeaders(); $param = $wgRequest->getText('param'); if (!empty($param) && !empty($category)) { // Generate the pages! $this->generatePages($param, $wgRequest->getArray('page')); $text = Html::element('p', null, wfMessage('ps-generatepages-success')->parse()); $wgOut->addHTML($text); return true; } if ($category == "") { // No category listed. // TODO - show an error message. return true; } // Standard "generate pages" form, with category name set. // Check for a valid category, with a page schema defined. $pageSchemaObj = new PSSchema($category); if (!$pageSchemaObj->isPSDefined()) { $text = Html::element('p', null, wfMessage('ps-generatepages-noschema')->parse()); $wgOut->addHTML($text); return true; } $text = Html::element('p', null, wfMessage('ps-generatepages-desc')->parse()) . "\n"; $text .= '<form method="post">'; $text .= Html::input('param', $category, 'hidden') . "\n"; $text .= '<div id="ps_check_all_check_none"> <input type="button" id="ps_check_all" value="' . wfMessage('powersearch-toggleall')->parse() . '" /> <input type="button" id="ps_check_none" value="' . wfMessage('powersearch-togglenone')->parse() . '" /> </div><br/>'; $wgOut->addModules('ext.pageschemas.generatepages'); // This hook will set an array of strings, with each value // as a title of a page to be created. $pageList = array(); foreach ($wgPageSchemasHandlerClasses as $psHandlerClass) { $pagesFromHandler = call_user_func(array($psHandlerClass, "getPagesToGenerate"), $pageSchemaObj); foreach ($pagesFromHandler as $page) { $pageList[] = $page; } } foreach ($pageList as $page) { if (!$page instanceof Title) { continue; } $pageName = PageSchemas::titleString($page); $text .= Html::input('page[]', $pageName, 'checkbox', array('checked' => true)); $text .= "\n" . Linker::link($page) . "<br />\n"; } $text .= "<br />\n"; $text .= Html::input(null, wfMessage('generatepages')->parse(), 'submit'); $text .= "\n</form>"; $wgOut->addHTML($text); return true; }