X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLogEventsList.php;h=188e23fd2e467c74ecb60e1f8b42ab289f2ff05e;hb=583e3e954eff2b08c57095aaacc34348da16b2be;hp=40204d0bdd8b82b920968d1323212bceec3738d5;hpb=18244534612a475811066e983a15c81ea54d8556;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 40204d0bdd..188e23fd2e 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -19,6 +19,7 @@ class LogEventsList { const NO_ACTION_LINK = 1; + const NO_EXTRA_USER_LINKS = 2; private $skin; private $out; @@ -39,8 +40,8 @@ class LogEventsList { // Precache various messages if( !isset( $this->message ) ) { $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink', - 'revertmove', 'undeletelink', '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 +50,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 +79,55 @@ 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 .= Xml::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,17 +140,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); - $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"; } // Build links return ''.$wgLang->pipeList( $links ) . '' . $hiddens; } - + private function getDefaultQuery() { if ( !isset( $this->mDefaultQuery ) ) { $this->mDefaultQuery = $_GET; @@ -148,16 +192,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]) ) { @@ -178,7 +230,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 ) . + ''; } /** @@ -186,7 +240,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 ) . + ''; } /** @@ -198,6 +254,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 "