X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLogEventsList.php;h=820793a9ef8aa9643d7ec5ce13da277288034f8f;hb=9cb3299aee7acc5ba824427146e9f4c77e325ede;hp=3739304d11b9d37c6c1ce9d2934196c7ba7a0cdc;hpb=38ca12aa82343574c319ccc0ac1b0783188618f0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 3739304d11..820793a9ef 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -1,24 +1,31 @@ , 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; private $skin; private $out; @@ -39,8 +46,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' ) ); } @@ -49,17 +56,22 @@ class LogEventsList { /** * Set page title and show header for this log type - * @param $type String + * @param $type Array */ public function showHeader( $type ) { - if( LogPage::isLogType( $type ) ) { - $this->out->setPageTitle( LogPage::logName( $type ) ); - $this->out->addHTML( LogPage::logHeader( $type ) ); + // If only one log type is used, then show a special message... + $headerType = (count($type) == 1) ? $type[0] : ''; + if( LogPage::isLogType( $headerType ) ) { + $this->out->setPageTitle( LogPage::logName( $headerType ) ); + $this->out->addHTML( LogPage::logHeader( $headerType ) ); + } else { + $this->out->addHTML( wfMsgExt('alllogstext',array('parseinline')) ); } } /** * Show options for the log list + * * @param $types string or Array * @param $user String * @param $page String @@ -73,29 +85,54 @@ class LogEventsList { $month = '', $filter = null, $tagFilter='' ) { global $wgScript, $wgMiserMode; - $action = htmlspecialchars( $wgScript ); + + $action = $wgScript; $title = SpecialPage::getTitleFor( 'Log' ); - $special = htmlspecialchars( $title->getPrefixedDBkey() ); + $special = $title->getPrefixedDBkey(); + // For B/C, we take strings, but make sure they are converted... $types = ($types === '') ? array() : (array)$types; $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); - $this->out->addHTML( "
" . - Xml::element( 'legend', array(), wfMsg( 'log' ) ) . - Xml::hidden( 'title', $special ) . "\n" . - $this->getTypeMenu( $types ) . "\n" . - $this->getUserInput( $user ) . "\n" . - $this->getTitleInput( $page ) . "\n" . - ( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) . - "

" . Xml::dateMenu( $year, $month ) . "\n" . - ( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" . - ( $filter ? "

".$this->getFilterLinks( $filter )."\n" : "" ) . "\n" . - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "

\n" . - "
" - ); + $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 ) ); + } + + // 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 @@ -108,18 +145,29 @@ class LogEventsList { $links = array(); $hiddens = ''; // keep track for "go" button foreach( $filter as $type => $val ) { + // Should the below assignment be outside the foreach? + // Then it would have to be copied. Not certain what is more expensive. + $query = $this->getDefaultQuery(); + $queryKey = "hide_{$type}_log"; + $hideVal = 1 - intval($val); - // FIXME: use link() here. Needs changes in getDefaultQuery() - $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal], - wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() ) + $query[$queryKey] = $hideVal; + + $link = $this->skin->link( + $wgTitle, + $messages[$hideVal], + array(), + $query, + array( 'known', 'noclasses' ) ); + $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() { if ( !isset( $this->mDefaultQuery ) ) { $this->mDefaultQuery = $_GET; @@ -149,16 +197,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]) ) { @@ -179,7 +235,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 ) . + ''; } /** @@ -187,7 +245,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 ) . + ''; } /** @@ -199,6 +259,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 "