From 5f8990b91e848e8960dbb7134d5d2b1a9916d917 Mon Sep 17 00:00:00 2001
From: Ilmari Karonen
Date: Sat, 15 Nov 2008 01:18:59 +0000
Subject: [PATCH] make the layout of the namespace checkboxes in
powerSearchBox() look nicer
---
includes/specials/SpecialSearch.php | 41 ++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php
index f9d08f968d..46e64e5e2e 100644
--- a/includes/specials/SpecialSearch.php
+++ b/includes/specials/SpecialSearch.php
@@ -588,15 +588,38 @@ class SpecialSearch {
function powerSearchBox( $term ) {
global $wgScript;
- $namespaces = '';
- foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
+ $namespaces = SearchEngine::searchableNamespaces();
+
+ // group namespaces into rows according to subject; try not to make too
+ // many assumptions about namespace numbering
+ $rows = array();
+ foreach( $namespaces as $ns => $name ) {
+ $subj = Namespace::getSubject( $ns );
+ if( !array_key_exists( $subj, $rows ) ) {
+ $rows[$subj] = "";
+ }
$name = str_replace( '_', ' ', $name );
if( '' == $name ) {
$name = wfMsg( 'blanknamespace' );
}
- $namespaces .= Xml::openElement( 'span', array( 'style' => 'white-space: nowrap' ) ) .
+ $rows[$subj] .= Xml::openElement( 'td', array( 'style' => 'white-space: nowrap' ) ) .
Xml::checkLabel( $name, "ns{$ns}", "mw-search-ns{$ns}", in_array( $ns, $this->namespaces ) ) .
- Xml::closeElement( 'span' ) . "\n";
+ Xml::closeElement( 'td' ) . "\n";
+ }
+ $rows = array_values( $rows );
+ $numRows = count( $rows );
+
+ // lay out namespaces in multiple floating two-column tables so they'll
+ // be arranged nicely while still accommodating different screen widths
+ $rowsPerTable = 3; // seems to look nice
+
+ $tables = "";
+ for( $i = 0; $i < $numRows; $i += $rowsPerTable ) {
+ $tables .= Xml::openElement( 'table', array( 'style' => 'float: left; margin: 0 1em 1em 0' ) );
+ for( $j = $i; $j < $i + $rowsPerTable && $j < $numRows; $j++ ) {
+ $tables .= Xml::openElement( 'tr' ) . "\n" . $rows[$j] . Xml::closeElement( 'tr' );
+ }
+ $tables .= Xml::closeElement( 'table' ) . "\n";
}
$redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
@@ -607,15 +630,15 @@ class SpecialSearch {
$out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
Xml::fieldset( wfMsg( 'powersearch-legend' ),
- Xml::hidden( 'title', $searchTitle->getPrefixedText() ) .
+ Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n" .
"" .
wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
- "
" .
- $namespaces .
- "
" .
+ "
\n" .
+ $tables .
+ "
\n" .
"" .
$redirect . " " . $redirectLabel .
- "
" .
+ "\n" .
wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
" " .
$searchField .
--
2.20.1