function show() { $show = $this->loadData(); $out = $this->getOutput(); $links = array(); if ($this->mFilter) { $links['abusefilter-history-backedit'] = $this->getTitle($this->mFilter); $links['abusefilter-diff-backhistory'] = $this->getTitle('history/' . $this->mFilter); } foreach ($links as $msg => $title) { $links[$msg] = Linker::link($title, $this->msg($msg)->escaped()); } $backlinks = $this->getLanguage()->pipeList($links); $out->addHTML(Xml::tags('p', null, $backlinks)); if ($show) { $out->addHTML($this->formatDiff()); // Next and previous change links $links = array(); if (AbuseFilter::getFirstFilterChange($this->mFilter) != $this->mOldVersion['meta']['history_id']) { // Create a "previous change" link if this isn't the first change of the given filter $links[] = Linker::link($this->getTitle('history/' . $this->mFilter . '/diff/prev/' . $this->mOldVersion['meta']['history_id']), $this->getLanguage()->getArrow('backwards') . ' ' . $this->msg('abusefilter-diff-prev')->escaped()); } if (!is_null($this->mNextHistoryId)) { // Create a "next change" link if this isn't the last change of the given filter $links[] = Linker::link($this->getTitle('history/' . $this->mFilter . '/diff/prev/' . $this->mNextHistoryId), $this->msg('abusefilter-diff-next')->escaped() . ' ' . $this->getLanguage()->getArrow('forwards')); } if (count($links) > 0) { $backlinks = $this->getLanguage()->pipeList($links); $out->addHTML(Xml::tags('p', null, $backlinks)); } } }
function formatValue($name, $value) { $lang = $this->getLanguage(); $row = $this->mCurrentRow; switch ($name) { case 'afh_filter': $formatted = $lang->formatNum($row->afh_filter); break; case 'afh_timestamp': $title = SpecialPage::getTitleFor('AbuseFilter', 'history/' . $row->afh_filter . '/item/' . $row->afh_id); $formatted = Linker::link($title, $lang->timeanddate($row->afh_timestamp, true)); break; case 'afh_user_text': $formatted = Linker::userLink($row->afh_user, $row->afh_user_text) . ' ' . Linker::userToolLinks($row->afh_user, $row->afh_user_text); break; case 'afh_public_comments': $formatted = htmlspecialchars($value, ENT_QUOTES, 'UTF-8', false); break; case 'afh_flags': $formatted = AbuseFilter::formatFlags($value); break; case 'afh_actions': $actions = unserialize($value); $display_actions = ''; foreach ($actions as $action => $parameters) { $displayAction = AbuseFilter::formatAction($action, $parameters); $display_actions .= Xml::tags('li', null, $displayAction); } $display_actions = Xml::tags('ul', null, $display_actions); $formatted = $display_actions; break; case 'afh_id': $formatted = ''; if (AbuseFilter::getFirstFilterChange($row->afh_filter) != $value) { // Set a link to a diff with the previous version if this isn't the first edit to the filter $title = $this->mPage->getTitle('history/' . $row->afh_filter . "/diff/prev/{$value}"); $formatted = Linker::link($title, $this->msg('abusefilter-history-diff')->parse()); } break; default: $formatted = "Unable to format {$name}"; break; } $mappings = array_flip(AbuseFilter::$history_mappings) + array('afh_actions' => 'actions', 'afh_id' => 'id'); $changed = explode(',', $row->afh_changed_fields); $fieldChanged = false; if ($name == 'afh_flags') { // This is a bit freaky, but it works. // Basically, returns true if any of those filters are in the $changed array. $filters = array('af_enabled', 'af_hidden', 'af_deleted', 'af_global'); if (count(array_diff($filters, $changed)) < count($filters)) { $fieldChanged = true; } } elseif (in_array($mappings[$name], $changed)) { $fieldChanged = true; } if ($fieldChanged) { $formatted = Xml::tags('div', array('class' => 'mw-abusefilter-history-changed'), $formatted); } return $formatted; }