}
$wgOut->setArticleRelated( false );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
+ // add javascript specific to special:search
+ $wgOut->addScriptFile( 'search.js' );
}
/**
$out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
$prev = $result->getInterwikiPrefix();
}
- // FIXME: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
+ // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
$out .= "</ul></div>\n";
// convert the whole thing to desired language variant
$namespaces = SearchEngine::searchableNamespaces();
$tables = $this->namespaceTables( $namespaces );
-
+
+ // include redirects in the search
$redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
$redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' );
- $searchField = Xml::inputLabel( wfMsg('powersearch-field'), 'search', 'powerSearchText', 50, $term,
- array( 'type' => 'text') );
- $searchButton = Xml::submitButton( wfMsg( 'powersearch' ) ) . "\n";
- $searchTitle = SpecialPage::getTitleFor( 'Search' );
$redirectText = '';
// show redirects check only if backend supports it
if( $this->searchEngine->acceptListRedirects() ) {
- $redirectText = "<p>". $redirect . " " . $redirectLabel ."</p>";
+ $redirectText = "<td id='powersearch-rediropt'>". $redirect . " " . $redirectLabel ."</td>";
}
+
+
+ $searchField = Xml::inputLabel( wfMsg( 'powersearch-field' ), 'search', 'powerSearchText', 50, $term,
+ array( 'type' => 'text') );
+
+ // toggle for turning on and off all checkboxes
+ $selectOptionsLabel = Xml::label( wfMsg( 'powersearch-togglelabel' ), 'mw-search-togglelabel' );
+ $selectAllButton = Xml::submitButton( wfMsg( 'powersearch-toggleall' ), array( 'id' => 'mw-search-toggleall', 'onclick' => 'mwToggleSearchCheckboxes(this);return false;' ) );
+ $selectNoneButton = Xml::submitButton( wfMsg( 'powersearch-togglenone' ), array( 'id' => 'mw-search-togglenone', 'onclick' => 'mwToggleSearchCheckboxes(this);return false;' ) );
+ $selectOptionsText = "<td id='mw-search-togglebox'>" . $selectOptionsLabel . $selectAllButton . $selectNoneButton . "</td>";
+
+ $searchButton = Xml::submitButton( wfMsg( 'powersearch' ) ) . "\n";
+ $searchTitle = SpecialPage::getTitleFor( 'Search' );
+
+ $optionsText = "<div id='mw-search-redirbox'><table id='mw-search-redirtable'><tr>" . $redirectText . $selectOptionsText . "</tr></table></div>";
$out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n" .
'<input type="hidden" name="advanced" value="'.$this->searchAdvanced."\"/>\n".
$tables .
"<hr style=\"clear: both;\" />\n".
- $redirectText ."\n".
- "<div style=\"padding-top:2px;padding-bottom:2px;\">".
+ $optionsText . "\n".
+ "<div style=\"padding-top:4px;padding-bottom:2px;text-align:center;\">".
$searchField .
" " .
Xml::hidden( 'fulltext', 'Advanced search' ) . "\n" .
if( $this->active == 'default' ) {
$out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );
} else {
- $out .= $this->makeSearchLink( $bareterm, SearchEngine::defaultNamespaces(), $m, $tt );
+ $out .= $this->makeSearchLink( $bareterm, SearchEngine::defaultNamespaces(), $m, $tt);
}
$out .= $sep;
$out .= Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . "\n";
$out .= Xml::hidden( 'fulltext', 'Search' );
$out .= Xml::submitButton( wfMsg( 'searchbutton' ) );
- //$out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')';
$out .= Xml::closeElement( 'form' );
- // Add prefix link for single-namespace searches
- $t = Title::newFromText( $term );
- /*if( $t != null && count($this->namespaces) === 1 ) {
- $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
- }*/
return $out . $this->didYouMeanHtml;
}
$stParams = wfArrayToCGI( array( 'search' => $term, 'fulltext' => wfMsg( 'search' ) ), $opt );
return Xml::element( 'a',
- array( 'href'=> $st->getLocalURL( $stParams ), 'title' => $tooltip ),
+ array( 'href'=> $st->getLocalURL( $stParams ), 'title' => $tooltip,
+ 'onmousedown' => 'mwSearchHeaderClick(this);',
+ 'onkeydown' => 'mwSearchHeaderClick(this);'),
$label );
}
--- /dev/null
+// JS specific to Special:Search
+
+// change the search link to what user entered
+function mwSearchHeaderClick(obj){
+ var searchbox = document.getElementById("searchText");
+ if( searchbox == null )
+ searchbox = document.getElementById("powerSearchText");
+ if( searchbox == null)
+ return; // should always have either normal or advanced search
+
+ var searchterm = searchbox.value;
+ var parts = obj.href.split("search=");
+ var lastpart = '';
+ if( parts[1].indexOf('&') >= 0 )
+ lastpart = parts[1].substring( parts[1].indexOf('&') )
+ obj.href = parts[0] + "search=" + encodeURIComponent(searchterm) + lastpart;
+}
+
+function mwToggleSearchCheckboxes( btn ) {
+ if( !document.getElementById ) return;
+
+ var nsInputs = document.getElementById( 'powersearch' ).getElementsByTagName( 'input' );
+ var isChecked = false;
+
+ for ( var i = 0; i < nsInputs.length; i++ ) {
+ var pattern = /^ns/;
+ if ( ( nsInputs[i].type == 'checkbox' ) && ( pattern.test( nsInputs[i].name ) ) ) {
+ switch ( btn.value ) {
+ case "None":
+ if ( nsInputs[i].checked ) {
+ nsInputs[i].checked = false;
+ }
+ break;
+ case "All":
+ if ( !nsInputs[i].checked ) {
+ nsInputs[i].checked = true;
+ }
+ break;
+ }
+ }
+ }
+}