X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2FLogEventsList.php;h=29a54c6f314d927628b72d89acbfeb66a1c6ec6f;hb=c4a604a984f26bb2b044bf7d152bd7b9c535f97c;hp=28b0ea4f1a41bea61624c4d347d5ff84d7030073;hpb=7c7951f78fac944934a18bf34b1e12cd8ec3c850;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 28b0ea4f1a..29a54c6f31 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -24,7 +24,7 @@ class LogEventsList { private $out; public $flags; - function __construct( $skin, $out, $flags = 0 ) { + public function __construct( $skin, $out, $flags = 0 ) { $this->skin = $skin; $this->out = $out; $this->flags = $flags; @@ -38,74 +38,168 @@ class LogEventsList { private function preCacheMessages() { // Precache various messages if( !isset( $this->message ) ) { - $messages = 'revertmerge protect_change unblocklink revertmove undeletelink revdel-restore rev-delundel hist'; - foreach( explode(' ', $messages ) as $msg ) { - $this->message[$msg] = wfMsgExt( $msg, array( 'escape') ); + $messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink', + 'revertmove', 'undeletelink', 'undeleteviewlink', 'revdel-restore', 'rev-delundel', 'hist', 'diff', + 'pipe-separator' ); + foreach( $messages as $msg ) { + $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); } } } /** * Set page title and show header for this log type - * @param string $type + * @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 string $type, - * @param string $user, - * @param string $page, - * @param string $pattern - * @param int $year - * @parm int $month + * @param $types string or Array + * @param $user String + * @param $page String + * @param $pattern String + * @param $year Integer: year + * @param $month Integer: month + * @param $filter: array + * @param $tagFilter: array? */ - public function showOptions( $type='', $user='', $page='', $pattern='', $year='', $month='' ) { + public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='', + $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 ); + + $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( "
" . - Xml::element( 'legend', array(), wfMsg( 'log' ) ) . - Xml::hidden( 'title', $special ) . "\n" . - $this->getTypeMenu( $type ) . "\n" . - $this->getUserInput( $user ) . "\n" . - $this->getTitleInput( $page ) . "\n" . - ( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) . - "

" . $this->getDateMenu( $year, $month ) . "\n" . - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "

\n" . - "
" ); + $this->out->addHTML( $html ); + } + + /** + * @param $filter Array + * @return String: Formatted HTML + */ + private function getFilterLinks( $filter ) { + global $wgTitle, $wgLang; + // show/hide links + $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); + // Option value -> message mapping + $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); + $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; + unset( $this->mDefaultQuery['title'] ); + unset( $this->mDefaultQuery['dir'] ); + unset( $this->mDefaultQuery['offset'] ); + unset( $this->mDefaultQuery['limit'] ); + unset( $this->mDefaultQuery['order'] ); + unset( $this->mDefaultQuery['month'] ); + unset( $this->mDefaultQuery['year'] ); + } + return $this->mDefaultQuery; } /** - * @return string Formatted HTML - * @param string $queryType + * @param $queryTypes Array + * @return String: Formatted HTML */ - private function getTypeMenu( $queryType ) { + private function getTypeMenu( $queryTypes ) { global $wgLogRestrictions, $wgUser; $html = "