DatabaseMssql class and related changes
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 100011c..8035e98 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  */
 
@@ -119,7 +119,41 @@ class SpecialSearch {
                wfProfileIn( __METHOD__ );
 
                $sk = $wgUser->getSkin();
-
+               
+               $beginSearchForm = Xml::openElement(
+                       'form',
+                       array(
+                               'id' => ( $this->searchAdvanced ? 'powersearch' : 'search' ),
+                               'method' => 'get',
+                               'action' => $wgScript
+                       )
+               );
+               $mwSearchTopTable =
+                       Xml::openElement( 'table', array( 'id' => 'mw-search-top-table', 'border' => 0, 'cellpadding' => 0, 'cellspacing' => 0 ) ) .
+                       Xml::openElement( 'tr' ) .
+                       Xml::openElement( 'td' ) . "\n" .
+                       $this->shortDialog( $term ) .
+                       Xml::closeElement( 'td' ) .
+                       Xml::closeElement( 'tr' ) .
+                       Xml::closeElement( 'table' );
+               
+               // moved to check for empty or null search string before running query
+               // to prevent NULL fulltext search error in SQL Server
+               $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
+               if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
+                       $wgOut->addHTML( $beginSearchForm );
+                       $wgOut->addHTML( $mwSearchTopTable );
+                       $wgOut->addHTML( $this->searchFocus() );
+                       $wgOut->addHTML( $this->formHeader( $term, 0, 0 ) );
+                       if ( $this->searchAdvanced ) {
+                               $wgOut->addHTML( $this->powerSearchBox( $term ) );
+                       }
+                       $wgOut->addHTML( Xml::closeElement( 'form' ) );
+                       // Empty query -- straight view of search form
+                       wfProfileOut( __METHOD__ );
+                       return;
+               }
+               
                $this->searchEngine = SearchEngine::create();
                $search =& $this->searchEngine;
                $search->setLimitOffset( $this->limit, $this->offset );
@@ -194,23 +228,10 @@ class SpecialSearch {
                }
                // start rendering the page
                $wgOut->addHtml(
-                       Xml::openElement(
-                               'form',
-                               array(
-                                       'id' => ( $this->searchAdvanced ? 'powersearch' : 'search' ),
-                                       'method' => 'get',
-                                       'action' => $wgScript
-                               )
-                       )
+                       $beginSearchForm
                );
                $wgOut->addHtml(
-                       Xml::openElement( 'table', array( 'id'=>'mw-search-top-table', 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) .
-                       Xml::openElement( 'tr' ) .
-                       Xml::openElement( 'td' ) . "\n" .
-                       $this->shortDialog( $term ) .
-                       Xml::closeElement('td') .
-                       Xml::closeElement('tr') .
-                       Xml::closeElement('table')
+                       $mwSearchTopTable
                );
 
                // Sometimes the search engine knows there are too many hits
@@ -220,19 +241,6 @@ class SpecialSearch {
                        return;
                }
 
-               $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':';
-               if( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
-                       $wgOut->addHTML( $this->searchFocus() );
-                       $wgOut->addHTML( $this->formHeader($term, 0, 0));
-                       if( $this->searchAdvanced ) {
-                               $wgOut->addHTML( $this->powerSearchBox( $term ) );
-                       } 
-                       $wgOut->addHTML( '</form>' );
-                       // Empty query -- straight view of search form
-                       wfProfileOut( __METHOD__ );
-                       return;
-               }
-
                // Get number of results
                $titleMatchesNum = $titleMatches ? $titleMatches->numRows() : 0;
                $textMatchesNum = $textMatches ? $textMatches->numRows() : 0;
@@ -368,6 +376,9 @@ class SpecialSearch {
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                // add javascript specific to special:search
                $wgOut->addScriptFile( 'search.js' );
+
+               // Bug #16886: Sister projects box moves down the first extract on IE7  
+               $wgOut->addStyle( 'common/IE70Fixes.css', 'screen', 'IE 7' );
        }
 
        /**
@@ -440,7 +451,7 @@ class SpecialSearch {
         * @param $terms Array: terms to highlight
         */
        protected function showHit( $result, $terms ) {
-               global $wgContLang, $wgLang, $wgUser;
+               global $wgLang, $wgUser;
                wfProfileIn( __METHOD__ );
 
                if( $result->isBrokenTitle() ) {
@@ -608,7 +619,7 @@ class SpecialSearch {
                }
 
                wfProfileOut( __METHOD__ );
-               return "<li>{$link} {$redirect} {$section} {$extract}\n" .
+               return "<li><div class='mw-search-result-heading'>{$link} {$redirect} {$section}</div> {$extract}\n" .
                        "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
                        "</li>\n";
 
@@ -664,7 +675,6 @@ class SpecialSearch {
         */
        protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) {
                wfProfileIn( __METHOD__ );
-               global $wgContLang, $wgLang;
 
                if( $result->isBrokenTitle() ) {
                        wfProfileOut( __METHOD__ );
@@ -742,8 +752,6 @@ class SpecialSearch {
         * @return String: HTML form
         */
        protected function powerSearchBox( $term ) {
-               global $wgScript, $wgContLang;
-               
                // Groups namespaces into rows according to subject
                $rows = array();
                foreach( SearchEngine::searchableNamespaces() as $namespace => $name ) {
@@ -891,7 +899,7 @@ class SpecialSearch {
        }
 
        protected function formHeader( $term, $resultsShown, $totalNum ) {
-               global $wgContLang, $wgLang;
+               global $wgLang;
                
                $out = Xml::openElement('div', array( 'class' =>  'mw-search-formheader' ) );