/** * @param $row * @param $isListItem bool * @return String */ function formatRow($row, $isListItem = true) { $user = $this->getUser(); $lang = $this->getLanguage(); $actionLinks = array(); $title = Title::makeTitle($row->afl_namespace, $row->afl_title); $diffLink = false; if (self::isHidden($row) && !$this->canSeeHidden()) { return ''; } if (!$row->afl_wiki) { $pageLink = Linker::link($title); if ($row->afl_rev_id) { $diffLink = Linker::link($title, wfMessage('abusefilter-log-diff')->parse(), array(), array('diff' => 'prev', 'oldid' => $row->afl_rev_id)); } } else { $pageLink = WikiMap::makeForeignLink($row->afl_wiki, $row->afl_title); if ($row->afl_rev_id) { $diffUrl = WikiMap::getForeignURL($row->afl_wiki, $row->afl_title); $diffUrl = wfAppendQuery($diffUrl, array('diff' => 'prev', 'oldid' => $row->afl_rev_id)); $diffLink = Linker::makeExternalLink($diffUrl, wfMessage('abusefilter-log-diff')->parse()); } } if (!$row->afl_wiki) { // Local user $userLink = Linker::userLink($row->afl_user, $row->afl_user_text) . Linker::userToolLinks($row->afl_user, $row->afl_user_text, true); } else { $userLink = WikiMap::foreignUserLink($row->afl_wiki, $row->afl_user_text); $userLink .= ' (' . WikiMap::getWikiName($row->afl_wiki) . ')'; } $timestamp = $lang->timeanddate($row->afl_timestamp, true); $actions_taken = $row->afl_actions; if (!strlen(trim($actions_taken))) { $actions_taken = $this->msg('abusefilter-log-noactions')->text(); } else { $actions = explode(',', $actions_taken); $displayActions = array(); foreach ($actions as $action) { $displayActions[] = AbuseFilter::getActionDisplay($action); } $actions_taken = $lang->commaList($displayActions); } $globalIndex = AbuseFilter::decodeGlobalName($row->afl_filter); if ($globalIndex) { // Pull global filter description $parsed_comments = $this->getOutput()->parseInline(AbuseFilter::getGlobalFilterDescription($globalIndex)); $filter_hidden = null; } else { $parsed_comments = $this->getOutput()->parseInline($row->af_public_comments); $filter_hidden = $row->af_hidden; } if (self::canSeeDetails($row->afl_filter, $filter_hidden)) { if ($isListItem) { $detailsLink = Linker::linkKnown($this->getPageTitle($row->afl_id), $this->msg('abusefilter-log-detailslink')->escaped()); $actionLinks[] = $detailsLink; } $examineTitle = SpecialPage::getTitleFor('AbuseFilter', 'examine/log/' . $row->afl_id); $examineLink = Linker::link($examineTitle, $this->msg('abusefilter-changeslist-examine')->parse(), array()); $actionLinks[] = $examineLink; if ($diffLink) { $actionLinks[] = $diffLink; } if ($user->isAllowed('abusefilter-hide-log')) { $hideLink = Linker::link($this->getPageTitle(), $this->msg('abusefilter-log-hidelink')->text(), array(), array('hide' => $row->afl_id)); $actionLinks[] = $hideLink; } if ($globalIndex) { global $wgAbuseFilterCentralDB; $globalURL = WikiMap::getForeignURL($wgAbuseFilterCentralDB, 'Special:AbuseFilter/' . $globalIndex); $linkText = wfMessage('abusefilter-log-detailedentry-global')->numParams($globalIndex)->escaped(); $filterLink = Linker::makeExternalLink($globalURL, $linkText); } else { $title = SpecialPage::getTitleFor('AbuseFilter', $row->afl_filter); $linkText = wfMessage('abusefilter-log-detailedentry-local')->numParams($row->afl_filter)->escaped(); $filterLink = Linker::link($title, $linkText); } $description = $this->msg('abusefilter-log-detailedentry-meta')->rawParams($timestamp, $userLink, $filterLink, $row->afl_action, $pageLink, $actions_taken, $parsed_comments, $lang->pipeList($actionLinks), $row->afl_user_text)->parse(); } else { if ($diffLink) { $msg = 'abusefilter-log-entry-withdiff'; } else { $msg = 'abusefilter-log-entry'; } $description = $this->msg($msg)->rawParams($timestamp, $userLink, $row->afl_action, $pageLink, $actions_taken, $parsed_comments, $diffLink)->parse(); } if (self::isHidden($row) === true) { $description .= ' ' . $this->msg('abusefilter-log-hidden')->parse(); $class = 'afl-hidden'; } elseif (self::isHidden($row) === 'implicit') { $description .= ' ' . $this->msg('abusefilter-log-hidden-implicit')->parse(); } if ($isListItem) { return Xml::tags('li', isset($class) ? array('class' => $class) : null, $description); } else { return Xml::tags('span', isset($class) ? array('class' => $class) : null, $description); } }
function formatRow($row, $li = true) { global $wgLang, $wgUser; # One-time setup static $sk = null; $actionLinks = array(); if (is_null($sk)) { $sk = $wgUser->getSkin(); } $title = Title::makeTitle($row->afl_namespace, $row->afl_title); if (!$row->afl_wiki) { $pageLink = $sk->link($title); } else { $pageLink = WikiMap::makeForeignLink($row->afl_wiki, $row->afl_title); } if (!$row->afl_wiki) { // Local user $user = $sk->userLink($row->afl_user, $row->afl_user_text) . $sk->userToolLinks($row->afl_user, $row->afl_user_text); } else { $user = WikiMap::foreignUserLink($row->afl_wiki, $row->afl_user_text); $user .= ' (' . WikiMap::getWikiName($row->afl_wiki) . ')'; } $timestamp = $wgLang->timeanddate($row->afl_timestamp, true); $actions_taken = $row->afl_actions; if (!strlen(trim($actions_taken))) { $actions_taken = wfMsg('abusefilter-log-noactions'); } else { $actions = explode(',', $actions_taken); $displayActions = array(); foreach ($actions as $action) { $displayActions[] = AbuseFilter::getActionDisplay($action); } $actions_taken = $wgLang->commaList($displayActions); } $globalIndex = AbuseFilter::decodeGlobalName($row->afl_filter); global $wgOut; if ($globalIndex) { // Pull global filter description $parsed_comments = $wgOut->parseInline(AbuseFilter::getGlobalFilterDescription($globalIndex)); } else { $parsed_comments = $wgOut->parseInline($row->af_public_comments); } if (self::canSeeDetails()) { $examineTitle = SpecialPage::getTitleFor('AbuseFilter', 'examine/log/' . $row->afl_id); $detailsLink = $sk->makeKnownLinkObj($this->getTitle($row->afl_id), wfMsg('abusefilter-log-detailslink')); $examineLink = $sk->link($examineTitle, wfMsgExt('abusefilter-changeslist-examine', 'parseinline'), array()); $actionLinks[] = $detailsLink; $actionLinks[] = $examineLink; if ($wgUser->isAllowed('abusefilter-hide-log')) { $hideLink = $sk->link($this->getTitle(), wfMsg('abusefilter-log-hidelink'), array(), array('hide' => $row->afl_id)); $actionLinks[] = $hideLink; } if ($globalIndex) { global $wgAbuseFilterCentralDB; $globalURL = WikiMap::getForeignURL($wgAbuseFilterCentralDB, 'Special:AbuseFilter/' . $globalIndex); $linkText = wfMsgExt('abusefilter-log-detailedentry-global', 'parseinline', array($globalIndex)); $filterLink = $sk->makeExternalLink($globalURL, $linkText); } else { $title = SpecialPage::getTitleFor('AbuseFilter', $row->afl_filter); $linkText = wfMsgExt('abusefilter-log-detailedentry-local', 'parseinline', array($row->afl_filter)); $filterLink = $sk->link($title, $linkText); } $description = wfMsgExt('abusefilter-log-detailedentry-meta', array('parseinline', 'replaceafter'), array($timestamp, $user, $filterLink, $row->afl_action, $pageLink, $actions_taken, $parsed_comments, $wgLang->pipeList($actionLinks))); } else { $description = wfMsgExt('abusefilter-log-entry', array('parseinline', 'replaceafter'), array($timestamp, $user, $row->afl_action, $sk->link($title), $actions_taken, $parsed_comments)); } if ($row->afl_deleted) { $description .= ' ' . wfMsgExt('abusefilter-log-hidden', 'parseinline'); } return $li ? Xml::tags('li', null, $description) : $description; }