Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Show options for the log list |
64 | | - * @param $type String |
| 64 | + * @param $types string or Array |
65 | 65 | * @param $user String |
66 | 66 | * @param $page String |
67 | 67 | * @param $pattern String |
— | — | @@ -69,32 +69,38 @@ |
70 | 70 | * @param $filter: array |
71 | 71 | * @param $tagFilter: array? |
72 | 72 | */ |
73 | | - public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '', |
74 | | - $month = '', $filter = null, $tagFilter='' ) |
| 73 | + public function showOptions( $types=array(), $user='', $page='', $pattern='', $year='', |
| 74 | + $month = '', $filter = null, $tagFilter='' ) |
75 | 75 | { |
76 | 76 | global $wgScript, $wgMiserMode; |
77 | 77 | $action = htmlspecialchars( $wgScript ); |
78 | 78 | $title = SpecialPage::getTitleFor( 'Log' ); |
79 | 79 | $special = htmlspecialchars( $title->getPrefixedDBkey() ); |
| 80 | + // For B/C, we take strings, but make sure they are converted... |
| 81 | + $types = ($types === '') ? array() : (array)$types; |
80 | 82 | |
81 | 83 | $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter ); |
82 | 84 | |
83 | 85 | $this->out->addHTML( "<form action=\"$action\" method=\"get\"><fieldset>" . |
84 | 86 | Xml::element( 'legend', array(), wfMsg( 'log' ) ) . |
85 | 87 | Xml::hidden( 'title', $special ) . "\n" . |
86 | | - $this->getTypeMenu( $type ) . "\n" . |
| 88 | + $this->getTypeMenu( $types ) . "\n" . |
87 | 89 | $this->getUserInput( $user ) . "\n" . |
88 | 90 | $this->getTitleInput( $page ) . "\n" . |
89 | 91 | ( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) . |
90 | 92 | "<p>" . Xml::dateMenu( $year, $month ) . "\n" . |
91 | 93 | ( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" . |
92 | | - ( $filter ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) . "\n" . |
| 94 | + ( $filter ? "</p><p>".$this->getFilterLinks( $filter )."\n" : "" ) . "\n" . |
93 | 95 | Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" . |
94 | 96 | "</fieldset></form>" |
95 | 97 | ); |
96 | 98 | } |
97 | 99 | |
98 | | - private function getFilterLinks( $logType, $filter ) { |
| 100 | + /** |
| 101 | + * @param $filter Array |
| 102 | + * @return String: Formatted HTML |
| 103 | + */ |
| 104 | + private function getFilterLinks( $filter ) { |
99 | 105 | global $wgTitle, $wgLang; |
100 | 106 | // show/hide links |
101 | 107 | $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); |
— | — | @@ -128,10 +134,10 @@ |
129 | 135 | } |
130 | 136 | |
131 | 137 | /** |
132 | | - * @param $queryType String |
| 138 | + * @param $queryTypes Array |
133 | 139 | * @return String: Formatted HTML |
134 | 140 | */ |
135 | | - private function getTypeMenu( $queryType ) { |
| 141 | + private function getTypeMenu( $queryTypes ) { |
136 | 142 | global $wgLogRestrictions, $wgUser; |
137 | 143 | |
138 | 144 | $html = "<select name='type'>\n"; |
— | — | @@ -148,6 +154,8 @@ |
149 | 155 | // Second pass to sort by name |
150 | 156 | ksort($typesByName); |
151 | 157 | |
| 158 | + // Note the query type |
| 159 | + $queryType = count($queryTypes) == 1 ? $queryTypes[0] : ''; |
152 | 160 | // Third pass generates sorted XHTML content |
153 | 161 | foreach( $typesByName as $text => $type ) { |
154 | 162 | $selected = ($type == $queryType); |
— | — | @@ -427,17 +435,17 @@ |
428 | 436 | /** |
429 | 437 | * Quick function to show a short log extract |
430 | 438 | * @param $out OutputPage |
431 | | - * @param $type String |
| 439 | + * @param $types String or Array |
432 | 440 | * @param $page String |
433 | 441 | * @param $user String |
434 | 442 | * @param $lim Integer |
435 | 443 | * @param $conds Array |
436 | 444 | */ |
437 | | - public static function showLogExtract( $out, $type='', $page='', $user='', $lim=0, $conds=array() ) { |
| 445 | + public static function showLogExtract( $out, $types=array(), $page='', $user='', $lim=0, $conds=array() ) { |
438 | 446 | global $wgUser; |
439 | 447 | # Insert list of top 50 or so items |
440 | 448 | $loglist = new LogEventsList( $wgUser->getSkin(), $out, 0 ); |
441 | | - $pager = new LogPager( $loglist, $type, $user, $page, '', $conds ); |
| 449 | + $pager = new LogPager( $loglist, $types, $user, $page, '', $conds ); |
442 | 450 | if( $lim > 0 ) $pager->mLimit = $lim; |
443 | 451 | $logBody = $pager->getBody(); |
444 | 452 | if( $logBody ) { |
— | — | @@ -482,13 +490,14 @@ |
483 | 491 | * @ingroup Pager |
484 | 492 | */ |
485 | 493 | class LogPager extends ReverseChronologicalPager { |
486 | | - private $type = '', $user = '', $title = '', $pattern = ''; |
| 494 | + private $types = array(), $user = '', $title = '', $pattern = ''; |
| 495 | + private $typeCGI = ''; |
487 | 496 | public $mLogEventsList; |
488 | 497 | |
489 | 498 | /** |
490 | 499 | * constructor |
491 | 500 | * @param $list LogEventsList |
492 | | - * @param $type String |
| 501 | + * @param $types String or Array |
493 | 502 | * @param $user String |
494 | 503 | * @param $title String |
495 | 504 | * @param $pattern String |
— | — | @@ -496,7 +505,7 @@ |
497 | 506 | * @param $year Integer |
498 | 507 | * @param $month Integer |
499 | 508 | */ |
500 | | - public function __construct( $list, $type = '', $user = '', $title = '', $pattern = '', |
| 509 | + public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '', |
501 | 510 | $conds = array(), $year = false, $month = false, $tagFilter = '' ) |
502 | 511 | { |
503 | 512 | parent::__construct(); |
— | — | @@ -504,7 +513,7 @@ |
505 | 514 | |
506 | 515 | $this->mLogEventsList = $list; |
507 | 516 | |
508 | | - $this->limitType( $type ); // also excludes hidden types |
| 517 | + $this->limitType( $types ); // also excludes hidden types |
509 | 518 | $this->limitUser( $user ); |
510 | 519 | $this->limitTitle( $title, $pattern ); |
511 | 520 | $this->getDateCond( $year, $month ); |
— | — | @@ -513,17 +522,18 @@ |
514 | 523 | |
515 | 524 | public function getDefaultQuery() { |
516 | 525 | $query = parent::getDefaultQuery(); |
517 | | - $query['type'] = $this->type; |
| 526 | + $query['type'] = $this->typeCGI; // arrays won't work here |
518 | 527 | $query['user'] = $this->user; |
519 | 528 | $query['month'] = $this->mMonth; |
520 | 529 | $query['year'] = $this->mYear; |
521 | 530 | return $query; |
522 | 531 | } |
523 | 532 | |
| 533 | + // Call ONLY after calling $this->limitType() already! |
524 | 534 | public function getFilterParams() { |
525 | 535 | global $wgFilterLogTypes, $wgUser, $wgRequest; |
526 | 536 | $filters = array(); |
527 | | - if( $this->type ) { |
| 537 | + if( count($this->types) ) { |
528 | 538 | return $filters; |
529 | 539 | } |
530 | 540 | foreach( $wgFilterLogTypes as $type => $default ) { |
— | — | @@ -560,9 +570,11 @@ |
561 | 571 | if( $hideLogs !== false ) { |
562 | 572 | $this->mConds[] = $hideLogs; |
563 | 573 | } |
564 | | - if( count($types) > 0 ) { |
565 | | - $this->type = $types; |
| 574 | + if( count($types) ) { |
| 575 | + $this->types = $types; |
566 | 576 | $this->mConds['log_type'] = $types; |
| 577 | + // Set typeCGI; used in url param for paging |
| 578 | + if( count($types) == 1 ) $this->typeCGI = $types[0]; |
567 | 579 | } |
568 | 580 | } |
569 | 581 | |
— | — | @@ -642,7 +654,7 @@ |
643 | 655 | # Don't use the wrong logging index |
644 | 656 | if( $this->title || $this->pattern || $this->user ) { |
645 | 657 | $index = array( 'USE INDEX' => array( 'logging' => array('page_time','user_time') ) ); |
646 | | - } else if( $this->type ) { |
| 658 | + } else if( $this->types ) { |
647 | 659 | $index = array( 'USE INDEX' => array( 'logging' => 'type_time' ) ); |
648 | 660 | } else { |
649 | 661 | $index = array( 'USE INDEX' => array( 'logging' => 'times' ) ); |
— | — | @@ -688,7 +700,7 @@ |
689 | 701 | } |
690 | 702 | |
691 | 703 | public function getType() { |
692 | | - return $this->type; |
| 704 | + return $this->types; |
693 | 705 | } |
694 | 706 | |
695 | 707 | public function getUser() { |