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; }
function formatValue($name, $value) { global $wgOut, $wgLang; static $sk = null; if (empty($sk)) { global $wgUser; $sk = $wgUser->getSkin(); } $row = $this->mCurrentRow; $formatted = ''; switch ($name) { case 'afh_timestamp': $title = SpecialPage::getTitleFor('AbuseFilter', 'history/' . $row->afh_filter . '/item/' . $row->afh_id); $formatted = $sk->link($title, $wgLang->timeanddate($row->afh_timestamp, true)); break; case 'afh_user_text': $formatted = $sk->userLink($row->afh_user, $row->afh_user_text) . ' ' . $sk->userToolLinks($row->afh_user, $row->afh_user_text); break; case 'afh_public_comments': $formatted = $wgOut->parse($value); 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_filter': $title = $this->mPage->getTitle(strval($value)); $formatted = $sk->link($title, $value); break; case 'afh_id': $title = $this->mPage->getTitle('history/' . $row->afh_filter . "/diff/prev/{$value}"); $formatted = $sk->link($title, wfMsgExt('abusefilter-history-diff', 'parseinline')); 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; }
function formatDiff() { $oldVersion = $this->mOldVersion; $newVersion = $this->mNewVersion; // headings $oldLink = $this->formatVersionLink($oldVersion['meta']['modified'], $oldVersion['meta']['history_id']); $newLink = $this->formatVersionLink($newVersion['meta']['modified'], $newVersion['meta']['history_id']); $sk = $this->mSkin; $oldUserLink = $sk->userLink($oldVersion['meta']['modified_by'], $oldVersion['meta']['modified_by_text']); $newUserLink = $sk->userLink($newVersion['meta']['modified_by'], $newVersion['meta']['modified_by_text']); $headings = ''; $headings .= Xml::tags('th', null, wfMsgExt('abusefilter-diff-item', 'parseinline')); $headings .= Xml::tags('th', null, wfMsgExt('abusefilter-diff-version', array('parseinline', 'replaceafter'), array($oldLink, $oldUserLink, $newVersion['meta']['modified_by_text']))); $headings .= Xml::tags('th', null, wfMsgExt('abusefilter-diff-version', array('parseinline', 'replaceafter'), array($newLink, $newUserLink))); $headings = Xml::tags('tr', null, $headings); // Basic info $info = ''; $info .= $this->getHeaderRow('abusefilter-diff-info'); $info .= $this->getSimpleRow('abusefilter-edit-description', $oldVersion['info']['description'], $newVersion['info']['description'], 'wikitext'); $info .= $this->getSimpleRow('abusefilter-edit-flags', AbuseFilter::formatFlags($oldVersion['info']['flags']), AbuseFilter::formatFlags($newVersion['info']['flags'])); $info .= $this->getMultiLineRow('abusefilter-edit-notes', $oldVersion['info']['notes'], $newVersion['info']['notes']); // Pattern $info .= $this->getHeaderRow('abusefilter-diff-pattern'); $info .= $this->getMultiLineRow('abusefilter-edit-rules', $oldVersion['pattern'], $newVersion['pattern'], 'text'); // Actions $oldActions = $this->stringifyActions($oldVersion['actions']); $newActions = $this->stringifyActions($newVersion['actions']); $info .= $this->getHeaderRow('abusefilter-edit-consequences'); $info .= $this->getMultiLineRow('abusefilter-edit-consequences', $oldActions, $newActions); $html = "<table class='mw-abusefilter-diff'>\n\t\t<thead>{$headings}</thead>\n\t\t<tbody>{$info}</tbody>\n</table>"; $html = Xml::tags('h2', null, wfMsgExt('abusefilter-diff-title', 'parseinline')) . $html; return $html; }
/** * @return string */ function formatDiff() { $oldVersion = $this->mOldVersion; $newVersion = $this->mNewVersion; // headings $oldLink = $this->formatVersionLink($oldVersion['meta']['modified'], $oldVersion['meta']['history_id']); $newLink = $this->formatVersionLink($newVersion['meta']['modified'], $newVersion['meta']['history_id']); $oldUserLink = Linker::userLink($oldVersion['meta']['modified_by'], $oldVersion['meta']['modified_by_text']); $newUserLink = Linker::userLink($newVersion['meta']['modified_by'], $newVersion['meta']['modified_by_text']); $headings = ''; $headings .= Xml::tags('th', null, $this->msg('abusefilter-diff-item')->parse()); $headings .= Xml::tags('th', null, $this->msg('abusefilter-diff-version')->rawParams($oldLink, $oldUserLink)->params($newVersion['meta']['modified_by_text'])->parse()); $headings .= Xml::tags('th', null, $this->msg('abusefilter-diff-version')->rawParams($newLink, $newUserLink)->params($newVersion['meta']['modified_by_text'])->parse()); $headings = Xml::tags('tr', null, $headings); // Basic info $info = ''; $info .= $this->getHeaderRow('abusefilter-diff-info'); $info .= $this->getDiffRow('abusefilter-edit-description', $oldVersion['info']['description'], $newVersion['info']['description']); global $wgAbuseFilterValidGroups; if (count($wgAbuseFilterValidGroups) > 1 || $oldVersion['info']['group'] != $newVersion['info']['group']) { $info .= $this->getDiffRow('abusefilter-edit-group', AbuseFilter::nameGroup($oldVersion['info']['group']), AbuseFilter::nameGroup($newVersion['info']['group'])); } $info .= $this->getDiffRow('abusefilter-edit-flags', AbuseFilter::formatFlags($oldVersion['info']['flags']), AbuseFilter::formatFlags($newVersion['info']['flags'])); $info .= $this->getDiffRow('abusefilter-edit-notes', $oldVersion['info']['notes'], $newVersion['info']['notes']); // Pattern $info .= $this->getHeaderRow('abusefilter-diff-pattern'); $info .= $this->getDiffRow('abusefilter-edit-rules', $oldVersion['pattern'], $newVersion['pattern'], 'text'); // Actions $oldActions = $this->stringifyActions($oldVersion['actions']); $newActions = $this->stringifyActions($newVersion['actions']); $info .= $this->getHeaderRow('abusefilter-edit-consequences'); $info .= $this->getDiffRow('abusefilter-edit-consequences', $oldActions, $newActions); $html = "<table class='wikitable'>\n\t\t\t<thead>{$headings}</thead>\n\t\t\t<tbody>{$info}</tbody>\n\t\t</table>"; $html = Xml::tags('h2', null, $this->msg('abusefilter-diff-title')->parse()) . $html; return $html; }