* Introduced $wgPagePropsHaveSortkey as a backwards-compatibility switch,
for using the old schema of the page_props table, in case the respective
schema update was not applied.
+* $wgSearchEverythingOnlyLoggedIn was removed as the 'searcheverything'
+ user option was removed. Use $wgNamespacesToBeSearchedDefault instead or
+ if you used to have $wgDefaultUserOptions['searcheverything'] = 1.
=== New features in 1.24 ===
* Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
* New methods setVolatile and isVolatile are added to PPFrame, so that
extensions such as Cite.php can mark that their output is volatile and
shouldn't be cached.
+* (bug 52817) Advanced search options are now saved on the search page itself, rather
+ than in a dedicated pane in the preferences panel.
=== Bug fixes in 1.24 ===
* (bug 49116) Footer copyright notice is now always displayed in user language
NS_MAIN => true,
);
-/**
- * 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;
-
/**
* Disable the internal MySQL-based search, to allow it to be
* implemented by an extension instead.
* @param array $defaultPreferences
*/
static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgContLang;
-
- $defaultPreferences['searcheverything'] = array(
- 'type' => 'toggle',
- 'label-message' => 'searcheverything-enable',
- 'section' => 'searchoptions/advancedsearchoptions',
- );
-
- $nsOptions = $wgContLang->getFormattedNamespaces();
- $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
- foreach ( $nsOptions as $ns => $name ) {
- if ( $ns < 0 ) {
- unset( $nsOptions[$ns] );
+ foreach ( MWNamespace::getValidNamespaces() as $n ) {
+ if ( $n >= 0 ) {
+ $defaultPreferences[ 'searchNs' . $n ] = array(
+ 'type' => 'api',
+ );
}
}
-
- $defaultPreferences['searchnamespaces'] = array(
- 'type' => 'multiselect',
- 'label-message' => 'defaultns',
- 'options' => array_flip( $nsOptions ),
- 'section' => 'searchoptions/advancedsearchoptions',
- 'prefix' => 'searchNs',
- );
}
/**
/**
* Set the given option for a user.
*
+ * You need to call saveSettings() to actually write to the database.
+ *
* @param string $oname The option to set
* @param mixed $val New value to set
*/
}
/**
- * @todo document
+ * Saves the non-default options for this user, as previously set e.g. via
+ * setOption(), in the database's "user_properties" (preferences) table.
+ * Usually used via saveSettings().
*/
protected function saveOptions() {
$this->loadOptions();
* @return array
*/
public static function userNamespaces( $user ) {
- global $wgSearchEverythingOnlyLoggedIn;
-
- $searchableNamespaces = SearchEngine::searchableNamespaces();
-
- // get search everything preference, that can be set to be read for logged-in users
- // it overrides other options
- if ( !$wgSearchEverythingOnlyLoggedIn || $user->isLoggedIn() ) {
- if ( $user->getOption( 'searcheverything' ) ) {
- return array_keys( $searchableNamespaces );
- }
- }
-
$arr = array();
- foreach ( $searchableNamespaces as $ns => $name ) {
+ foreach ( SearchEngine::searchableNamespaces() as $ns => $name ) {
if ( $user->getOption( 'searchNs' . $ns ) ) {
$arr[] = $ns;
}
$search = $this->getSearchEngine();
$search->setLimitOffset( $this->limit, $this->offset );
$search->setNamespaces( $this->namespaces );
+ $this->saveNamespaces();
$search->prefix = $this->mPrefix;
$term = $search->transformSearchTerm( $term );
return $opt + $this->extraParams;
}
+ /**
+ * Save namespace preferences when we're supposed to
+ *
+ * @return bool Whether we wrote something
+ */
+ protected function saveNamespaces() {
+ $user = $this->getUser();
+ $request = $this->getRequest();
+
+ if ( $user->isLoggedIn() &&
+ !is_null( $request->getVal( 'nsRemember' ) ) &&
+ $user->matchEditToken( $request->getVal( 'nsToken' ) )
+ ) {
+ // Reset namespace preferences: namespaces are not searched
+ // when they're not mentioned in the URL parameters.
+ foreach ( MWNamespace::getValidNamespaces() as $n ) {
+ if ( $n >= 0 ) {
+ $user->setOption( 'searchNs' . $n, false );
+ }
+ }
+ // The request parameters include all the namespaces we just searched.
+ // Even if they're the same as an existing profile, they're not eaten.
+ foreach ( $this->namespaces as $n ) {
+ $user->setOption( 'searchNs' . $n, true );
+ }
+
+ $user->saveSettings();
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Show whole set of results
*
$hidden .= Html::hidden( $key, $value );
}
+ # Stuff to feed saveNamespaces()
+ $remember = '';
+ $user = $this->getUser();
+ if ( $user->isLoggedIn() ) {
+ $remember .= Html::hidden( 'nsToken', $user->getEditToken() ) .
+ Xml::checkLabel(
+ wfMessage( 'powersearch-remember' )->text(),
+ 'nsRemember',
+ 'mw-search-powersearch-remember',
+ false
+ );
+ }
+
// Return final output
return Xml::openElement(
'fieldset',
Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
implode( Xml::element( 'div', array( 'class' => 'divider' ), '', false ), $showSections ) .
$hidden .
+ Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
+ $remember .
Xml::closeElement( 'fieldset' );
}
"search-interwiki-custom": "",
"search-interwiki-more": "(more)",
"search-relatedarticle": "Related",
- "searcheverything-enable": "Search in all namespaces",
"searchrelated": "related",
"searchall": "all",
"showingresults": "Showing below up to {{PLURAL:$1|<strong>1</strong> result|<strong>$1</strong> results}} starting with #<strong>$2</strong>.",
"powersearch-togglelabel": "Check:",
"powersearch-toggleall": "All",
"powersearch-togglenone": "None",
+ "powersearch-remember": "Remember selection for future searches",
"search-external": "External search",
"searchdisabled": "{{SITENAME}} search is disabled.\nYou can search via Google in the meantime.\nNote that their indexes of {{SITENAME}} content may be out of date.",
"googlesearch": "<form method=\"get\" action=\"//www.google.com/search\" id=\"googlesearch\">\n\t<input type=\"hidden\" name=\"domains\" value=\"{{SERVER}}\" />\n\t<input type=\"hidden\" name=\"num\" value=\"50\" />\n\t<input type=\"hidden\" name=\"ie\" value=\"$2\" />\n\t<input type=\"hidden\" name=\"oe\" value=\"$2\" />\n\n\t<input type=\"text\" name=\"q\" size=\"31\" maxlength=\"255\" value=\"$1\" />\n\t<input type=\"submit\" name=\"btnG\" value=\"$3\" />\n <div>\n\t<input type=\"radio\" name=\"sitesearch\" id=\"gwiki\" value=\"{{SERVER}}\" checked=\"checked\" /><label for=\"gwiki\">{{SITENAME}}</label>\n\t<input type=\"radio\" name=\"sitesearch\" id=\"gWWW\" value=\"\" /><label for=\"gWWW\">WWW</label>\n </div>\n</form>",
"allowemail": "Enable email from other users",
"prefs-searchoptions": "Search",
"prefs-namespaces": "Namespaces",
- "defaultns": "Otherwise search in these namespaces:",
"default": "default",
"prefs-files": "Files",
"prefs-custom-css": "Custom CSS",
"powersearch-togglelabel": "Used in [{{canonicalurl:Special:Search|advanced=1}} Advanced search]. Synonym: \"Select\" as verb.\n{{Identical|Check}}",
"powersearch-toggleall": "\"All\" refers to namespaces. It is used in Advanced search: {{canonicalurl:Special:Search|advanced=1}}\n{{Identical|All}}",
"powersearch-togglenone": "\"None\" refers to namespaces. It is used in Advanced search: {{canonicalurl:Special:Search|advanced=1}}\n{{Identical|None}}",
+ "powersearch-remember": "Label for a checkbox to save namespace choice for advanced search to user preferences.",
"search-external": "Legend of the fieldset for the input form when the internal search is disabled. Inside the fieldset [[MediaWiki:Searchdisabled]] and [[MediaWiki:Googlesearch]] is shown.",
"searchdisabled": "{{doc-singularthey}}\nIn this sentence, \"their indexes\" refers to \"Google's indexes\".\n\nShown on [[Special:Search]] when the internal search is disabled.",
"googlesearch": "{{notranslate}}\nShown when [[mw:Manual:$wgDisableTextSearch|$wgDisableTextSearch]] is set to true and no [[mw:Manual:$wgSearchForwardUrl|$wgSearchForwardUrl]] is set.\n\nParameters:\n* $1 - the search term\n* $2 - \"UTF-8\" (hard-coded)\n* $3 - the message {{msg-mw|Searchbutton}}",