r43517 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43516‎ | r43517 | r43518 >
Date:01:18, 15 November 2008
Author:vyznev
Status:ok (Comments)
Tags:
Comment:
make the layout of the namespace checkboxes in powerSearchBox() look nicer
Modified paths:
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -588,17 +588,40 @@
589589 function powerSearchBox( $term ) {
590590 global $wgScript;
591591
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+ }
594602 $name = str_replace( '_', ' ', $name );
595603 if( '' == $name ) {
596604 $name = wfMsg( 'blanknamespace' );
597605 }
598 - $namespaces .= Xml::openElement( 'span', array( 'style' => 'white-space: nowrap' ) ) .
 606+ $rows[$subj] .= Xml::openElement( 'td', array( 'style' => 'white-space: nowrap' ) ) .
599607 Xml::checkLabel( $name, "ns{$ns}", "mw-search-ns{$ns}", in_array( $ns, $this->namespaces ) ) .
600 - Xml::closeElement( 'span' ) . "\n";
 608+ Xml::closeElement( 'td' ) . "\n";
601609 }
 610+ $rows = array_values( $rows );
 611+ $numRows = count( $rows );
602612
 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+
603626 $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
604627 $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' );
605628 $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) );
@@ -607,15 +630,15 @@
608631
609632 $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
610633 Xml::fieldset( wfMsg( 'powersearch-legend' ),
611 - Xml::hidden( 'title', $searchTitle->getPrefixedText() ) .
 634+ Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n" .
612635 "<p>" .
613636 wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
614 - "<br />" .
615 - $namespaces .
616 - "</p>" .
 637+ "</p>\n" .
 638+ $tables .
 639+ "<hr style=\"clear: left;\" />\n" .
617640 "<p>" .
618641 $redirect . " " . $redirectLabel .
619 - "</p>" .
 642+ "</p>\n" .
620643 wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
621644 "&nbsp;" .
622645 $searchField .

Follow-up revisions

RevisionCommit summaryAuthorDate
r43561minor fix for r43517: float tables to the right on RTL wikisvyznev18:12, 15 November 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   19:41, 17 November 2008

Lookin' sweet!

Status & tagging log