X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FLogEventsList.php;h=a18d84923e11c40c2eaa0cac9b2516d63bd7e141;hb=41ac01dfc839b4f1c32a354fe37ed064b8a31585;hp=d6178abc5a7e8ebfb977c7f66611f217735e5e63;hpb=19e33229155ce1dc44ee0b4ea515e56454e24466;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index d6178abc5a..a18d84923e 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -1,29 +1,53 @@ , 2008 Aaron Schulz -# http://www.mediawiki.org/ -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# http://www.gnu.org/copyleft/gpl.html +/** + * Contain classes to list log entries + * + * Copyright © 2004 Brion Vibber , 2008 Aaron Schulz + * http://www.mediawiki.org/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + */ class LogEventsList { const NO_ACTION_LINK = 1; + const NO_EXTRA_USER_LINKS = 2; + /** + * @var Skin + */ private $skin; + + /** + * @var OutputPage + */ private $out; public $flags; + /** + * @var Array + */ + protected $message; + + /** + * @var Array + */ + protected $mDefaultQuery; + public function __construct( $skin, $out, $flags = 0 ) { $this->skin = $skin; $this->out = $out; @@ -39,8 +63,8 @@ class LogEventsList { // Precache various messages if( !isset( $this->message ) ) { $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink', - 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'rev-delundel', 'hist', 'diff', - 'pipe-separator' ); + 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'hist', 'diff', + 'pipe-separator', 'revdel-restore-deleted', 'revdel-restore-visible' ); foreach( $messages as $msg ) { $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); } @@ -64,6 +88,7 @@ class LogEventsList { /** * Show options for the log list + * * @param $types string or Array * @param $user String * @param $page String @@ -73,64 +98,63 @@ class LogEventsList { * @param $filter: array * @param $tagFilter: array? */ - public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='', - $month = '', $filter = null, $tagFilter='' ) - { + public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='', + $month = '', $filter = null, $tagFilter='' ) { global $wgScript, $wgMiserMode; - + $action = $wgScript; $title = SpecialPage::getTitleFor( 'Log' ); $special = $title->getPrefixedDBkey(); - + // For B/C, we take strings, but make sure they are converted... $types = ($types === '') ? array() : (array)$types; $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); - - $html = ''; - $html .= Xml::hidden( 'title', $special ); - + + $html = Html::hidden( 'title', $special ); + // Basic selectors $html .= $this->getTypeMenu( $types ) . "\n"; $html .= $this->getUserInput( $user ) . "\n"; $html .= $this->getTitleInput( $page ) . "\n"; + $html .= $this->getExtraInputs( $types ) . "\n"; // Title pattern, if allowed if (!$wgMiserMode) { $html .= $this->getTitlePattern( $pattern ) . "\n"; } - + // date menu $html .= Xml::tags( 'p', null, Xml::dateMenu( $year, $month ) ); - + // Tag filter if ($tagSelector) { - $html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) ); + $html .= Xml::tags( 'p', null, implode( ' ', $tagSelector ) ); } - + // Filter links if ($filter) { $html .= Xml::tags( 'p', null, $this->getFilterLinks( $filter ) ); } - + // Submit button $html .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ); - + // Fieldset $html = Xml::fieldset( wfMsg( 'log' ), $html ); - + // Form wrapping $html = Xml::tags( 'form', array( 'action' => $action, 'method' => 'get' ), $html ); $this->out->addHTML( $html ); } - + /** * @param $filter Array * @return String: Formatted HTML */ private function getFilterLinks( $filter ) { - global $wgTitle, $wgLang; + global $wgLang; // show/hide links $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); // Option value -> message mapping @@ -145,8 +169,8 @@ class LogEventsList { $hideVal = 1 - intval($val); $query[$queryKey] = $hideVal; - $link = $this->skin->link( - $wgTitle, + $link = Linker::link( + $this->getDisplayTitle(), $messages[$hideVal], array(), $query, @@ -154,15 +178,17 @@ class LogEventsList { ); $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link ); - $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n"; + $hiddens .= Html::hidden( "hide_{$type}_log", $val ) . "\n"; } // Build links return ''.$wgLang->pipeList( $links ) . '' . $hiddens; } - + private function getDefaultQuery() { + global $wgRequest; + if ( !isset( $this->mDefaultQuery ) ) { - $this->mDefaultQuery = $_GET; + $this->mDefaultQuery = $wgRequest->getQueryValues(); unset( $this->mDefaultQuery['title'] ); unset( $this->mDefaultQuery['dir'] ); unset( $this->mDefaultQuery['offset'] ); @@ -174,6 +200,16 @@ class LogEventsList { return $this->mDefaultQuery; } + /** + * Get the Title object of the page the links should point to. + * This is NOT the Title of the page the entries should be restricted to. + * + * @return Title object + */ + public function getDisplayTitle() { + return $this->out->getTitle(); + } + /** * @param $queryTypes Array * @return String: Formatted HTML @@ -189,16 +225,24 @@ class LogEventsList { // First pass to load the log names foreach( $validTypes as $type ) { $text = LogPage::logName( $type ); - $typesByName[$text] = $type; + $typesByName[$type] = $text; } // Second pass to sort by name - ksort($typesByName); + asort($typesByName); // Note the query type $queryType = count($queryTypes) == 1 ? $queryTypes[0] : ''; + + // Always put "All public logs" on top + if ( isset( $typesByName[''] ) ) { + $all = $typesByName['']; + unset( $typesByName[''] ); + $typesByName = array( '' => $all ) + $typesByName; + } + // Third pass generates sorted XHTML content - foreach( $typesByName as $text => $type ) { + foreach( $typesByName as $type => $text ) { $selected = ($type == $queryType); // Restricted types if ( isset($wgLogRestrictions[$type]) ) { @@ -219,7 +263,9 @@ class LogEventsList { * @return String: Formatted HTML */ private function getUserInput( $user ) { - return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user ); + return '' . + Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user ) . + ''; } /** @@ -227,7 +273,9 @@ class LogEventsList { * @return String: Formatted HTML */ private function getTitleInput( $title ) { - return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title ); + return '' . + Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title ) . + ''; } /** @@ -239,6 +287,20 @@ class LogEventsList { ''; } + private function getExtraInputs( $types ) { + global $wgRequest; + $offender = $wgRequest->getVal('offender'); + $user = User::newFromName( $offender, false ); + if( !$user || ($user->getId() == 0 && !IP::isIPAddress($offender) ) ) { + $offender = ''; // Blank field if invalid + } + if( count($types) == 1 && $types[0] == 'suppress' ) { + return Xml::inputLabel( wfMsg('revdelete-offender'), 'offender', + 'mw-log-offender', 20, $offender ); + } + return ''; + } + public function beginLogEventsList() { return "