Revision: 51243
Author:   rainman
Date:     2009-05-31 16:46:52 +0000 (Sun, 31 May 2009)

Log Message:
-----------
New search option:
* 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)

Modified Paths:
--------------
    trunk/phase3/includes/DefaultSettings.php
    trunk/phase3/includes/Preferences.php
    trunk/phase3/includes/SearchEngine.php
    trunk/phase3/languages/messages/MessagesEn.php
    trunk/phase3/maintenance/language/messages.inc

Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php   2009-05-31 16:41:58 UTC (rev 
51242)
+++ trunk/phase3/includes/DefaultSettings.php   2009-05-31 16:46:52 UTC (rev 
51243)
@@ -1998,6 +1998,13 @@
 $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
  *
  * This message can contain wiki text, and can also be set through the

Modified: trunk/phase3/includes/Preferences.php
===================================================================
--- trunk/phase3/includes/Preferences.php       2009-05-31 16:41:58 UTC (rev 
51242)
+++ trunk/phase3/includes/Preferences.php       2009-05-31 16:46:52 UTC (rev 
51243)
@@ -833,8 +833,15 @@
                                                '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 @@
                                        'section' => 
'searchoptions/advancedsearchoptions',
                                        'prefix' => 'searchNs',
                                );
+               
+
+               
        }
        
        static function miscPreferences( $user, &$defaultPreferences ) {

Modified: trunk/phase3/includes/SearchEngine.php
===================================================================
--- trunk/phase3/includes/SearchEngine.php      2009-05-31 16:41:58 UTC (rev 
51242)
+++ trunk/phase3/includes/SearchEngine.php      2009-05-31 16:46:52 UTC (rev 
51243)
@@ -241,6 +241,18 @@
         * @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();
                

Modified: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php      2009-05-31 16:41:58 UTC 
(rev 51242)
+++ trunk/phase3/languages/messages/MessagesEn.php      2009-05-31 16:46:52 UTC 
(rev 51243)
@@ -1476,6 +1476,7 @@
 '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 @@
 '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',

Modified: trunk/phase3/maintenance/language/messages.inc
===================================================================
--- trunk/phase3/maintenance/language/messages.inc      2009-05-31 16:41:58 UTC 
(rev 51242)
+++ trunk/phase3/maintenance/language/messages.inc      2009-05-31 16:46:52 UTC 
(rev 51243)
@@ -826,6 +826,7 @@
                'search-external',
                'searchdisabled',
                'googlesearch',
+               'searcheverything-enable',
        ),
        'opensearch' => array(
                'opensearch-desc',



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to