New search option:
authorRobert Stojnić <rainman@users.mediawiki.org>
Sun, 31 May 2009 16:46:52 +0000 (16:46 +0000)
committerRobert Stojnić <rainman@users.mediawiki.org>
Sun, 31 May 2009 16:46:52 +0000 (16:46 +0000)
* new option to search all namespaces: searcheverything
* add a switch ($wgSearchEverythingOnlyLoggedIn) to limit this option only to logged-in users, this way one
  can set different default values of this option for logged-in and logged-out (disabled by default)

includes/DefaultSettings.php
includes/Preferences.php
includes/SearchEngine.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 4d5b9a7..5a49bfc 100644 (file)
@@ -1997,6 +1997,13 @@ $wgNamespacesToBeSearchedHelp = array(
 
 $wgUseOldSearchUI = true; // temp testing variable
 
+/**
+ * If set to true the 'searcheverything' preference will be effective only for logged-in users.
+ * Useful for big wikis to maintain different search profiles for anonymous and logged-in users.
+ *
+ */
+$wgSearchEverythingOnlyLoggedIn = false;
+
 /**
  * Site notice shown at the top of each page
  *
index 116a52c..c659144 100644 (file)
@@ -833,7 +833,14 @@ class Preferences {
                                                'label-message' => 'mwsuggest-disable',
                                                'section' => 'searchoptions/display',
                                        );
-               }               
+               }
+               
+               $defaultPreferences['searcheverything'] =
+                               array(
+                                       'type' => 'toggle',
+                                       'label-message' => 'searcheverything-enable',
+                                       'section' => 'searchoptions/advancedsearchoptions',
+                               );
                
                // Searchable namespaces back-compat with old format
                $searchableNamespaces = SearchEngine::searchableNamespaces();
@@ -857,6 +864,9 @@ class Preferences {
                                        'section' => 'searchoptions/advancedsearchoptions',
                                        'prefix' => 'searchNs',
                                );
+               
+
+               
        }
        
        static function miscPreferences( $user, &$defaultPreferences ) {
index 3a4daca..daec7ca 100644 (file)
@@ -241,6 +241,18 @@ class SearchEngine {
         * @return Array
         */
        public static function userNamespaces( $user ) {
+               global $wgSearchEverythingOnlyLoggedIn;
+               
+               // get search everything preference, that can be set to be read for logged-in users
+               $searcheverything = false;
+               if( ( $wgSearchEverythingOnlyLoggedIn && $user->isLoggedIn() )
+                   || !$wgSearchEverythingOnlyLoggedIn )
+                       $searcheverything = $user->getOption('searcheverything');
+               
+               // searcheverything overrides other options 
+               if( $searcheverything )
+                       return array_keys(SearchEngine::searchableNamespaces());
+               
                $arr = Preferences::loadOldSearchNs( $user );
                $searchableNamespaces = SearchEngine::searchableNamespaces();
                
index 2657b80..416eb2a 100644 (file)
@@ -1476,6 +1476,7 @@ You can [[:\$1|create this page]].",
 'search-mwsuggest-disabled'        => 'no suggestions',
 'search-relatedarticle'            => 'Related',
 'mwsuggest-disable'                => 'Disable AJAX suggestions',
+'searcheverything-enable'          => 'Search in all namespaces', 
 'searchrelated'                    => 'related',
 'searchall'                        => 'all',
 'showingresults'                   => "Showing below up to {{PLURAL:$1|'''1''' result|'''$1''' results}} starting with #'''$2'''.",
@@ -1583,7 +1584,7 @@ Note that their indexes of {{SITENAME}} content may be out of date.',
 'allowemail'                    => 'Enable e-mail from other users',
 'prefs-searchoptions'           => 'Search options',
 'prefs-namespaces'              => 'Namespaces',
-'defaultns'                     => 'Search in these namespaces by default:',
+'defaultns'                     => 'Otherwise search in these namespaces:',
 'default'                       => 'default',
 'prefs-files'                   => 'Files',
 'prefs-custom-css'              => 'Custom CSS',
index 0b6b38c..3cd96a1 100644 (file)
@@ -826,6 +826,7 @@ $wgMessageStructure = array(
                'search-external',
                'searchdisabled',
                'googlesearch',
+               'searcheverything-enable',
        ),
        'opensearch' => array(
                'opensearch-desc',