Index: trunk/phase3/includes/specials/SpecialSearch.php |
— | — | @@ -588,17 +588,40 @@ |
589 | 589 | function powerSearchBox( $term ) { |
590 | 590 | global $wgScript; |
591 | 591 | |
592 | | - $namespaces = ''; |
593 | | - foreach( SearchEngine::searchableNamespaces() as $ns => $name ) { |
| 592 | + $namespaces = SearchEngine::searchableNamespaces(); |
| 593 | + |
| 594 | + // group namespaces into rows according to subject; try not to make too |
| 595 | + // many assumptions about namespace numbering |
| 596 | + $rows = array(); |
| 597 | + foreach( $namespaces as $ns => $name ) { |
| 598 | + $subj = Namespace::getSubject( $ns ); |
| 599 | + if( !array_key_exists( $subj, $rows ) ) { |
| 600 | + $rows[$subj] = ""; |
| 601 | + } |
594 | 602 | $name = str_replace( '_', ' ', $name ); |
595 | 603 | if( '' == $name ) { |
596 | 604 | $name = wfMsg( 'blanknamespace' ); |
597 | 605 | } |
598 | | - $namespaces .= Xml::openElement( 'span', array( 'style' => 'white-space: nowrap' ) ) . |
| 606 | + $rows[$subj] .= Xml::openElement( 'td', array( 'style' => 'white-space: nowrap' ) ) . |
599 | 607 | Xml::checkLabel( $name, "ns{$ns}", "mw-search-ns{$ns}", in_array( $ns, $this->namespaces ) ) . |
600 | | - Xml::closeElement( 'span' ) . "\n"; |
| 608 | + Xml::closeElement( 'td' ) . "\n"; |
601 | 609 | } |
| 610 | + $rows = array_values( $rows ); |
| 611 | + $numRows = count( $rows ); |
602 | 612 | |
| 613 | + // lay out namespaces in multiple floating two-column tables so they'll |
| 614 | + // be arranged nicely while still accommodating different screen widths |
| 615 | + $rowsPerTable = 3; // seems to look nice |
| 616 | + |
| 617 | + $tables = ""; |
| 618 | + for( $i = 0; $i < $numRows; $i += $rowsPerTable ) { |
| 619 | + $tables .= Xml::openElement( 'table', array( 'style' => 'float: left; margin: 0 1em 1em 0' ) ); |
| 620 | + for( $j = $i; $j < $i + $rowsPerTable && $j < $numRows; $j++ ) { |
| 621 | + $tables .= Xml::openElement( 'tr' ) . "\n" . $rows[$j] . Xml::closeElement( 'tr' ); |
| 622 | + } |
| 623 | + $tables .= Xml::closeElement( 'table' ) . "\n"; |
| 624 | + } |
| 625 | + |
603 | 626 | $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) ); |
604 | 627 | $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' ); |
605 | 628 | $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) ); |
— | — | @@ -607,15 +630,15 @@ |
608 | 631 | |
609 | 632 | $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) . |
610 | 633 | Xml::fieldset( wfMsg( 'powersearch-legend' ), |
611 | | - Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . |
| 634 | + Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n" . |
612 | 635 | "<p>" . |
613 | 636 | wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) . |
614 | | - "<br />" . |
615 | | - $namespaces . |
616 | | - "</p>" . |
| 637 | + "</p>\n" . |
| 638 | + $tables . |
| 639 | + "<hr style=\"clear: left;\" />\n" . |
617 | 640 | "<p>" . |
618 | 641 | $redirect . " " . $redirectLabel . |
619 | | - "</p>" . |
| 642 | + "</p>\n" . |
620 | 643 | wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) . |
621 | 644 | " " . |
622 | 645 | $searchField . |