function stringifyActions($actions) { $lines = array(); ksort($actions); foreach ($actions as $action => $parameters) { $lines[] = AbuseFilter::formatAction($action, $parameters); } if (!count($lines)) { $lines[] = ''; } return $lines; }
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; }