Пример #1
0
 protected function getNamespaceFromRequest()
 {
     $user = $this->wg->User;
     $searchableNamespaces = SearchEngine::searchableNamespaces();
     $namespaces = array();
     foreach ($searchableNamespaces as $i => $name) {
         if ($this->getVal('ns' . $i, false)) {
             $namespaces[] = $i;
         }
     }
     if (empty($namespaces)) {
         if ($user->getGlobalPreference('searchAllNamespaces')) {
             $namespaces = array_keys($searchableNamespaces);
         } else {
             // this is mostly needed for unit testing
             $defaultProfile = !empty($this->wg->DefaultSearchProfile) ? $this->wg->DefaultSearchProfile : 'default';
             switch ($defaultProfile) {
                 case SEARCH_PROFILE_ADVANCED:
                     //There is no Config::setQuery call so it will always return default...
                 //There is no Config::setQuery call so it will always return default...
                 case SEARCH_PROFILE_DEFAULT:
                     $namespaces = \SearchEngine::defaultNamespaces();
                     break;
                 case SEARCH_PROFILE_IMAGES:
                     $namespaces = array(NS_FILE);
                     break;
                 case SEARCH_PROFILE_USERS:
                     $namespaces = array(NS_USER);
                     break;
                 case SEARCH_PROFILE_ALL:
                     $namespaces = \SearchEngine::searchableNamespaces();
                     break;
             }
         }
     }
     return $namespaces;
 }
Пример #2
0
 protected function getSearchProfiles()
 {
     // Builds list of Search Types (profiles)
     $nsAllSet = array_keys(SearchEngine::searchableNamespaces());
     $profiles = array('default' => array('message' => 'searchprofile-articles', 'tooltip' => 'searchprofile-articles-tooltip', 'namespaces' => SearchEngine::defaultNamespaces(), 'namespace-messages' => SearchEngine::namespacesAsText(SearchEngine::defaultNamespaces())), 'images' => array('message' => 'searchprofile-images', 'tooltip' => 'searchprofile-images-tooltip', 'namespaces' => array(NS_FILE)), 'help' => array('message' => 'searchprofile-project', 'tooltip' => 'searchprofile-project-tooltip', 'namespaces' => SearchEngine::helpNamespaces(), 'namespace-messages' => SearchEngine::namespacesAsText(SearchEngine::helpNamespaces())), 'all' => array('message' => 'searchprofile-everything', 'tooltip' => 'searchprofile-everything-tooltip', 'namespaces' => $nsAllSet), 'advanced' => array('message' => 'searchprofile-advanced', 'tooltip' => 'searchprofile-advanced-tooltip', 'namespaces' => $this->namespaces, 'parameters' => array('advanced' => 1)));
     wfRunHooks('SpecialSearchProfiles', array(&$profiles));
     foreach ($profiles as &$data) {
         sort($data['namespaces']);
     }
     return $profiles;
 }
Пример #3
0
 function powerSearchBox($term)
 {
     $namespaces = '';
     foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
         $checked = in_array($ns, $this->namespaces) ? ' checked="checked"' : '';
         $name = str_replace('_', ' ', $name);
         if ('' == $name) {
             $name = wfMsg('blanknamespace');
         }
         $namespaces .= " <label><input type='checkbox' value=\"1\" name=\"" . "ns{$ns}\"{$checked} />{$name}</label>\n";
     }
     $checked = $this->searchRedirects ? ' checked="checked"' : '';
     $redirect = "<input type='checkbox' value='1' name=\"redirs\"{$checked} />\n";
     $searchField = "<input type='text' name=\"search\" value=\"" . htmlspecialchars($term) . "\" width=\"80\" />\n";
     $searchButton = '<input type="submit" name="searchx" value="' . htmlspecialchars(wfMsg('powersearch')) . "\" />\n";
     $ret = wfMsg('powersearchtext', $namespaces, $redirect, $searchField, '', '', '', '', '', $searchButton);
     $title = Title::makeTitle(NS_SPECIAL, 'Search');
     $action = $title->escapeLocalURL();
     return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " . "action=\"{$action}\">\n{$ret}\n</form>\n";
 }
Пример #4
0
 function showFullDialog($term)
 {
     global $wgContLang, $wgLuceneSearchExactCase;
     $namespaces = '';
     foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
         $checked = in_array($ns, $this->namespaces) ? ' checked="checked"' : '';
         $name = str_replace('_', ' ', $name);
         if ('' == $name) {
             $name = wfMsg('blanknamespace');
         }
         $namespaces .= " <label><input type='checkbox' value=\"1\" name=\"" . "ns{$ns}\"{$checked} />{$name}</label>\n";
     }
     $searchField = "<input type='text' name=\"search\" value=\"" . htmlspecialchars($term) . "\" size=\"16\" />\n";
     $searchButton = '<input type="submit" name="fulltext" value="' . htmlspecialchars(wfMsg('powersearch')) . "\" />\n";
     if ($wgLuceneSearchExactCase) {
         $exactSearch = '<input type="submit" name="fulltext" value="' . htmlspecialchars(wfMsg('searchexactcase')) . "\" />\n";
     } else {
         $exactSearch = "";
     }
     $redirect = '';
     # What's this for?
     $ret = wfMsg('lucenepowersearchtext', $namespaces, $redirect, $searchField, '', '', '', '', '', $searchButton, $exactSearch);
     $title = Title::makeTitle(NS_SPECIAL, 'Search');
     $action = $title->escapeLocalURL();
     return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " . "action=\"{$action}\">\n{$ret}\n</form>\n";
 }
Пример #5
0
 /**
  * Combine the language default options with any site-specific options
  * and add the default language variants.
  *
  * @return Array of String options
  */
 public static function getDefaultOptions()
 {
     global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
     $defOpt = $wgDefaultUserOptions;
     # default language setting
     $variant = $wgContLang->getDefaultVariant();
     $defOpt['variant'] = $variant;
     $defOpt['language'] = $variant;
     foreach (SearchEngine::searchableNamespaces() as $nsnum => $nsname) {
         $defOpt['searchNs' . $nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
     }
     $defOpt['skin'] = $wgDefaultSkin;
     // FIXME: Ideally we'd cache the results of this function so the hook is only run once,
     // but that breaks the parser tests because they rely on being able to change $wgContLang
     // mid-request and see that change reflected in the return value of this function.
     // Which is insane and would never happen during normal MW operation, but is also not
     // likely to get fixed unless and until we context-ify everything.
     // See also https://www.mediawiki.org/wiki/Special:Code/MediaWiki/101488#c25275
     wfRunHooks('UserGetDefaultOptions', array(&$defOpt));
     return $defOpt;
 }
Пример #6
0
	/**
	 * @return array
	 */
	protected function getSearchProfiles() {
		// Builds list of Search Types (profiles)
		$nsAllSet = array_keys( SearchEngine::searchableNamespaces() );

		$profiles = array(
			'default' => array(
				'message' => 'searchprofile-articles',
				'tooltip' => 'searchprofile-articles-tooltip',
				'namespaces' => SearchEngine::defaultNamespaces(),
				'namespace-messages' => SearchEngine::namespacesAsText(
					SearchEngine::defaultNamespaces()
				),
			),
			'images' => array(
				'message' => 'searchprofile-images',
				'tooltip' => 'searchprofile-images-tooltip',
				'namespaces' => array( NS_FILE ),
			),
			'help' => array(
				'message' => 'searchprofile-project',
				'tooltip' => 'searchprofile-project-tooltip',
				'namespaces' => SearchEngine::helpNamespaces(),
				'namespace-messages' => SearchEngine::namespacesAsText(
					SearchEngine::helpNamespaces()
				),
			),
			'all' => array(
				'message' => 'searchprofile-everything',
				'tooltip' => 'searchprofile-everything-tooltip',
				'namespaces' => $nsAllSet,
			),
			'advanced' => array(
				'message' => 'searchprofile-advanced',
				'tooltip' => 'searchprofile-advanced-tooltip',
				'namespaces' => self::NAMESPACES_CURRENT,
			)
		);

		wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );

		foreach ( $profiles as &$data ) {
			if ( !is_array( $data['namespaces'] ) ) {
				continue;
			}
			sort( $data['namespaces'] );
		}

		return $profiles;
	}
Пример #7
0
 /**
  * Combine the language default options with any site-specific options
  * and add the default language variants.
  *
  * @return Array of String options
  */
 public static function getDefaultOptions()
 {
     global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
     $defOpt = $wgDefaultUserOptions;
     # default language setting
     $variant = $wgContLang->getDefaultVariant();
     $defOpt['variant'] = $variant;
     $defOpt['language'] = $variant;
     foreach (SearchEngine::searchableNamespaces() as $nsnum => $nsname) {
         $defOpt['searchNs' . $nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
     }
     $defOpt['skin'] = $wgDefaultSkin;
     wfRunHooks('UserGetDefaultOptions', array(&$defOpt));
     return $defOpt;
 }
Пример #8
0
 /**
  * Extract default namespaces to search from the given user's
  * settings, returning a list of index numbers.
  *
  * @param $user User
  * @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) {
         if ($user->getOption('searchNs' . $ns)) {
             $arr[] = $ns;
         }
     }
     return $arr;
 }
Пример #9
0
 /**
  * Returns searchable namespaces from MediaWiki.
  * @return array
  */
 public function getSearchableNamespacesFromSearchEngine()
 {
     return \SearchEngine::searchableNamespaces();
 }
Пример #10
0
 function shortDialog($term)
 {
     global $wgScript;
     $out = Xml::openElement('form', array('id' => 'search', 'method' => 'get', 'action' => $wgScript));
     $searchTitle = SpecialPage::getTitleFor('Search');
     $out .= Xml::hidden('title', $searchTitle->getPrefixedText());
     $out .= Xml::input('search', 50, $term, array('type' => 'text', 'id' => 'searchText')) . ' ';
     foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
         if (in_array($ns, $this->namespaces)) {
             $out .= Xml::hidden("ns{$ns}", '1');
         }
     }
     $out .= Xml::submitButton(wfMsg('searchbutton'), array('name' => 'fulltext'));
     $out .= Xml::closeElement('form');
     return $out;
 }
Пример #11
0
 static function customiseSearchProfiles(&$profiles)
 {
     $namespaces = array(NS_LQT_THREAD, NS_LQT_SUMMARY);
     // Add odd namespaces
     foreach (SearchEngine::searchableNamespaces() as $ns => $nsName) {
         if ($ns % 2 == 1) {
             $namespaces[] = $ns;
         }
     }
     $insert = array('threads' => array('message' => 'searchprofile-threads', 'tooltip' => 'searchprofile-threads-tooltip', 'namespaces' => $namespaces, 'namespace-messages' => SearchEngine::namespacesAsText($namespaces)));
     // Insert translations before 'all'
     $index = array_search('all', array_keys($profiles));
     // Or just at the end if all is not found
     if ($index === false) {
         wfWarn('"all" not found in search profiles');
         $index = count($profiles);
     }
     $profiles = array_merge(array_slice($profiles, 0, $index), $insert, array_slice($profiles, $index));
     return true;
 }
Пример #12
0
 /**
  * Uses search profiles to determine the active tab in the view
  * @return string
  */
 public function getActiveTab()
 {
     if ($this->getAdvanced()) {
         return 'advanced';
     }
     $searchableNamespaces = array_keys(SearchEngine::searchableNamespaces());
     $nsVals = $this->getNamespaces();
     if (empty($nsVals)) {
         return $this->wg->User->getOption('searchAllNamespaces') ? 'all' : 'default';
     }
     foreach ($this->getSearchProfiles() as $name => $profile) {
         if (!count(array_diff($nsVals, $profile['namespaces'])) && !count(array_diff($profile['namespaces'], $nsVals))) {
             return $name;
         }
     }
     return 'advanced';
 }
Пример #13
0
 static function customiseSearchProfiles(&$profiles)
 {
     $namespaces = array(NS_LQT_THREAD, NS_LQT_SUMMARY);
     // Add odd namespaces
     foreach (SearchEngine::searchableNamespaces() as $ns => $nsName) {
         if ($ns % 2 == 1) {
             $namespaces[] = $ns;
         }
     }
     $insert = array('threads' => array('message' => 'searchprofile-threads', 'tooltip' => 'searchprofile-threads-tooltip', 'namespaces' => $namespaces, 'namespace-messages' => SearchEngine::namespacesAsText($namespaces)));
     $profiles = wfArrayInsertAfter($profiles, $insert, 'help');
     return true;
 }
Пример #14
0
 /**
  * @group Slow
  * @slowExecutionTime 0.09002 ms
  * @covers Wikia\Search\MediaWikiService::getSearchableNamespacesFromSearchEngine
  */
 public function testGetSearchableNamespacesFromSearchEngine()
 {
     $this->assertEquals(\SearchEngine::searchableNamespaces(), (new MediaWikiService())->getSearchableNamespacesFromSearchEngine());
 }
Пример #15
0
 /**
  * Extract default namespaces to search from the given user's
  * settings, returning a list of index numbers.
  *
  * @param user $user
  * @return array
  */
 public static function userNamespaces($user)
 {
     $arr = array();
     foreach (SearchEngine::searchableNamespaces() as $ns => $name) {
         if ($user->getOption('searchNs' . $ns)) {
             $arr[] = $ns;
         }
     }
     return $arr;
 }
Пример #16
0
 /**
  * Extract default namespaces to search from the given user's
  * settings, returning a list of index numbers.
  *
  * @param $user User
  * @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();
     $arr = array_intersect($arr, array_keys($searchableNamespaces));
     // Filter
     return $arr;
 }
Пример #17
0
 /**
  * Combine the language default options with any site-specific options
  * and add the default language variants.
  *
  * @return \type{\arrayof{\string}} Array of options
  */
 static function getDefaultOptions()
 {
     global $wgNamespacesToBeSearchedDefault;
     /**
      * Site defaults will override the global/language defaults
      */
     global $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
     $defOpt = $wgDefaultUserOptions + $wgContLang->getDefaultUserOptionOverrides();
     /**
      * default language setting
      */
     $variant = $wgContLang->getPreferredVariant(false);
     $defOpt['variant'] = $variant;
     $defOpt['language'] = $variant;
     foreach (SearchEngine::searchableNamespaces() as $nsnum => $nsname) {
         $defOpt['searchNs' . $nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
     }
     $defOpt['skin'] = $wgDefaultSkin;
     return $defOpt;
 }
 protected function shortDialog($term)
 {
     $searchTitle = SpecialPage::getTitleFor('Search');
     $searchable = SearchEngine::searchableNamespaces();
     $out = Html::hidden('title', $searchTitle->getPrefixedText()) . "\n";
     // Keep redirect setting
     $out .= Html::hidden("redirs", (int) $this->searchRedirects) . "\n";
     // Term box
     $out .= Html::input('search', $term, 'search', array('id' => $this->searchAdvanced ? 'powerSearchText' : 'searchText', 'size' => '50', 'autofocus')) . "\n";
     $out .= Html::hidden('fulltext', 'Search') . "\n";
     $out .= Xml::submitButton(wfMsg('searchbutton')) . "\n";
     return $out . $this->didYouMeanHtml;
 }
Пример #19
0
 /**
  * Check if we are searching all the namespaces on this wiki
  *
  * @return boolean
  */
 function searchingEverything()
 {
     return $this->namespaces == array_keys(SearchEngine::searchableNamespaces());
 }
	function showForm( $warning_msg = null ) {
		global $wgOut;
		$wgOut->addHTML(
			Xml::openElement( 'form', array( 'id' => 'powersearch', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post' ) ) . "\n" .
			self::hiddenField( 'title', $this->getTitle()->getPrefixedText() ) .
			self::hiddenField( 'continue', 1 )
		);
		if ( is_null( $warning_msg ) ) {
			$wgOut->addWikiMsg( 'replacetext_docu' );
		} else {
			$wgOut->wrapWikiMsg( "<div class=\"errorbox\">\n$1\n</div><br clear=\"both\" />", $warning_msg );
		}
		$wgOut->addHTML( '<table><tr><td style="vertical-align: top;">' );
		$wgOut->addWikiMsg( 'replacetext_originaltext' );
		$wgOut->addHTML( '</td><td>' );
		// 'width: auto' style is needed to override MediaWiki's
		// normal 'width: 100%', which causes the textarea to get
		// zero width in IE
		$wgOut->addHTML( Xml::textarea( 'target', $this->target, 50, 2, array( 'style' => 'width: auto;' ) ) );
		$wgOut->addHTML( '</td></tr><tr><td style="vertical-align: top;">' );
		$wgOut->addWikiMsg( 'replacetext_replacementtext' );
		$wgOut->addHTML( '</td><td>' );
		$wgOut->addHTML( Xml::textarea( 'replacement', $this->replacement, 50, 2, array( 'style' => 'width: auto;' ) ) );
		$wgOut->addHTML( '</td></tr></table>' );
		$wgOut->addHTML( Xml::tags( 'p', null,
				Xml::checkLabel( wfMsg( 'replacetext_useregex' ), 'use_regex', 'use_regex' ) ) . "\n" .
			Xml::element( 'p', array( 'style' => 'font-style: italic' ),
				wfMsg( 'replacetext_regexdocu' ) )
		);

		// The interface is heavily based on the one in Special:Search.
		$search_label = wfMsg( 'powersearch-ns' );
		$namespaces = SearchEngine::searchableNamespaces();
		$tables = $this->namespaceTables( $namespaces );
		$wgOut->addHTML(
			"<div class=\"mw-search-formheader\"></div>\n" .
			"<fieldset id=\"mw-searchoptions\">\n" . 
			Xml::tags( 'h4', null, wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) )
		);
		// The ability to select/unselect groups of namespaces in the
		// search interface exists only in some skins, like Vector -
		// check for the presence of the 'powersearch-togglelabel'
		// message to see if we can use this functionality here.
		if ( !wfEmptyMsg( 'powersearch-togglelabel', wfMsg( 'powersearch-togglelabel' ) ) ) {
			$wgOut->addHTML(
				Xml::tags(
					'div',
					array( 'id' => 'mw-search-togglebox' ),
					Xml::label( wfMsg( 'powersearch-togglelabel' ), 'mw-search-togglelabel' ) .
					Xml::element(
						'input',
						array(
							'type'=>'button',
							'id' => 'mw-search-toggleall',
							// 'onclick' value needed for MW 1.16
							'onclick' => 'mwToggleSearchCheckboxes("all");',
							'value' => wfMsg( 'powersearch-toggleall' )
						)
					) .
					Xml::element(
						'input',
						array(
							'type'=>'button',
							'id' => 'mw-search-togglenone',
							// 'onclick' value needed for MW 1.16
							'onclick' => 'mwToggleSearchCheckboxes("none");',
							'value' => wfMsg( 'powersearch-togglenone' )
						)
					)
				)
			);
		} // end if
		$wgOut->addHTML(
			Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
			"$tables\n</fieldset>"
		);
		//FIXME: raw html messages
		$optional_filters_label = wfMsg( 'replacetext_optionalfilters' );
		$category_search_label = wfMsg( 'replacetext_categorysearch' );
		$prefix_search_label = wfMsg( 'replacetext_prefixsearch' );
		$wgOut->addHTML(
			"<fieldset id=\"mw-searchoptions\">\n" . 
			Xml::tags( 'h4', null, wfMsgExt( 'replacetext_optionalfilters', array( 'parseinline' ) ) ) .
			Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
			"<p>$category_search_label\n" .
			Xml::input( 'category', 20, $this->category, array( 'type' => 'text' ) ) . '</p>' .
			"<p>$prefix_search_label\n" .
			Xml::input( 'prefix', 20, $this->prefix, array( 'type' => 'text' ) ) . '</p>' .
			"</fieldset>\n" .
			"<p>\n" .
			Xml::checkLabel( wfMsg( 'replacetext_editpages' ), 'edit_pages', 'edit_pages', true ) . '<br />' .
			Xml::checkLabel( wfMsg( 'replacetext_movepages' ), 'move_pages', 'move_pages' ) .
			"</p>\n" .
			Xml::submitButton( wfMsg( 'replacetext_continue' ) ) .
			Xml::closeElement( 'form' )
		);
		// Add Javascript specific to Special:Search
		if ( method_exists( $wgOut, 'addModules' ) ) {
			$wgOut->addModules( 'mediawiki.special.search' );
		} else {
			$wgOut->addScriptFile( 'search.js' );
		}
	}
Пример #21
0
function lockdownSearchEngineReplacePrefixesComplete($searchEngine, $query, $parsed)
{
    global $wgUser, $wgNamespacePermissionLockdown;
    if ($searchEngine->namespaces === null) {
        #null means all namespaces.
        $searchEngine->namespaces = array_keys(SearchEngine::searchableNamespaces());
        #Use the namespaces... filtered
        return true;
    }
    $ugroups = $wgUser->getEffectiveGroups(true);
    foreach ($searchEngine->namespaces as $key => $ns) {
        $groups = @$wgNamespacePermissionLockdown[$ns]['read'];
        if ($groups === null) {
            $groups = @$wgNamespacePermissionLockdown['*']['read'];
        }
        if ($groups === null) {
            $groups = @$wgNamespacePermissionLockdown[$ns]['*'];
        }
        if ($groups === null) {
            continue;
        }
        if (!$groups || !array_intersect($ugroups, $groups)) {
            unset($searchEngine->namespaces[$key]);
        }
    }
    if (count($searchEngine->namespaces) == 0) {
        $searchEngine->namespaces = array_keys(SearchEngine::searchableNamespaces());
    }
    return true;
}
Пример #22
0
 /**
  * Combine the language default options with any site-specific options
  * and add the default language variants.
  *
  * @return array Array of String options
  */
 public static function getDefaultOptions()
 {
     global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
     static $defOpt = null;
     if (!defined('MW_PHPUNIT_TEST') && $defOpt !== null) {
         // Disabling this for the unit tests, as they rely on being able to change $wgContLang
         // mid-request and see that change reflected in the return value of this function.
         // Which is insane and would never happen during normal MW operation
         return $defOpt;
     }
     $defOpt = $wgDefaultUserOptions;
     // Default language setting
     $defOpt['language'] = $wgContLang->getCode();
     foreach (LanguageConverter::$languagesWithVariants as $langCode) {
         $defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-{$langCode}"] = $langCode;
     }
     foreach (SearchEngine::searchableNamespaces() as $nsnum => $nsname) {
         $defOpt['searchNs' . $nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
     }
     $defOpt['skin'] = Skin::normalizeKey($wgDefaultSkin);
     Hooks::run('UserGetDefaultOptions', array(&$defOpt));
     return $defOpt;
 }
Пример #23
0
 function showForm($warning_msg = null)
 {
     global $wgVersion;
     $out = $this->getOutput();
     $out->addHTML(Xml::openElement('form', array('id' => 'powersearch', 'action' => $this->getTitle()->getFullUrl(), 'method' => 'post')) . "\n" . $this->hiddenField('title', $this->getTitle()->getPrefixedText()) . $this->hiddenField('continue', 1));
     if (is_null($warning_msg)) {
         $out->addWikiMsg('replacetext_docu');
     } else {
         $out->wrapWikiMsg("<div class=\"errorbox\">\n\$1\n</div><br clear=\"both\" />", $warning_msg);
     }
     $out->addHTML('<table><tr><td style="vertical-align: top;">');
     $out->addWikiMsg('replacetext_originaltext');
     $out->addHTML('</td><td>');
     // 'width: auto' style is needed to override MediaWiki's
     // normal 'width: 100%', which causes the textarea to get
     // zero width in IE
     $out->addHTML(Xml::textarea('target', $this->target, 50, 2, array('style' => 'width: auto;')));
     $out->addHTML('</td></tr><tr><td style="vertical-align: top;">');
     $out->addWikiMsg('replacetext_replacementtext');
     $out->addHTML('</td><td>');
     $out->addHTML(Xml::textarea('replacement', $this->replacement, 50, 2, array('style' => 'width: auto;')));
     $out->addHTML('</td></tr></table>');
     $out->addHTML(Xml::tags('p', null, Xml::checkLabel($this->msg('replacetext_useregex')->text(), 'use_regex', 'use_regex')) . "\n" . Xml::element('p', array('style' => 'font-style: italic'), $this->msg('replacetext_regexdocu')->text()));
     // The interface is heavily based on the one in Special:Search.
     $namespaces = SearchEngine::searchableNamespaces();
     $tables = $this->namespaceTables($namespaces);
     $out->addHTML("<div class=\"mw-search-formheader\"></div>\n" . "<fieldset id=\"mw-searchoptions\">\n" . Xml::tags('h4', null, $this->msg('powersearch-ns')->parse()));
     // The ability to select/unselect groups of namespaces in the
     // search interface exists only in some skins, like Vector -
     // check for the presence of the 'powersearch-togglelabel'
     // message to see if we can use this functionality here.
     if ($this->msg('powersearch-togglelabel')->isDisabled()) {
         // do nothing
     } elseif (version_compare($wgVersion, '1.20', '>=')) {
         // In MediaWiki 1.20, this became a lot simpler after
         // the main work was passed off to Javascript
         $out->addHTML(Html::element('div', array('id' => 'mw-search-togglebox')));
     } else {
         // MW <= 1.19
         $out->addHTML(Xml::tags('div', array('id' => 'mw-search-togglebox'), Xml::label($this->msg('powersearch-togglelabel')->text(), 'mw-search-togglelabel') . Xml::element('input', array('type' => 'button', 'id' => 'mw-search-toggleall', 'onclick' => 'mwToggleSearchCheckboxes("all");', 'value' => $this->msg('powersearch-toggleall')->text())) . Xml::element('input', array('type' => 'button', 'id' => 'mw-search-togglenone', 'onclick' => 'mwToggleSearchCheckboxes("none");', 'value' => $this->msg('powersearch-togglenone')->text()))));
     }
     // end if
     $out->addHTML(Xml::element('div', array('class' => 'divider'), '', false) . "{$tables}\n</fieldset>");
     // @todo FIXME: raw html messages
     $category_search_label = $this->msg('replacetext_categorysearch')->text();
     $prefix_search_label = $this->msg('replacetext_prefixsearch')->text();
     $out->addHTML("<fieldset id=\"mw-searchoptions\">\n" . Xml::tags('h4', null, $this->msg('replacetext_optionalfilters')->parse()) . Xml::element('div', array('class' => 'divider'), '', false) . "<p>{$category_search_label}\n" . Xml::input('category', 20, $this->category, array('type' => 'text')) . '</p>' . "<p>{$prefix_search_label}\n" . Xml::input('prefix', 20, $this->prefix, array('type' => 'text')) . '</p>' . "</fieldset>\n" . "<p>\n" . Xml::checkLabel($this->msg('replacetext_editpages')->text(), 'edit_pages', 'edit_pages', true) . '<br />' . Xml::checkLabel($this->msg('replacetext_movepages')->text(), 'move_pages', 'move_pages') . "</p>\n" . Xml::submitButton($this->msg('replacetext_continue')->text()) . Xml::closeElement('form'));
     // Add Javascript specific to Special:Search
     $out->addModules('mediawiki.special.search');
 }
Пример #24
0
	/**
	 * @deprecated in 1.19
	 * @param $user User
	 * @return array
	 */
	public static function loadOldSearchNs( $user ) {
		wfDeprecated( __METHOD__, '1.19' );

		$searchableNamespaces = SearchEngine::searchableNamespaces();
		// Back compat with old format
		$arr = array();

		foreach ( $searchableNamespaces as $ns => $name ) {
			if ( $user->getOption( 'searchNs' . $ns ) ) {
				$arr[] = $ns;
			}
		}

		return $arr;
	}
 /**
  * This is how we generate the subtemplate for the advanced search box.
  * @see    SearchControllerTest::testAdvancedBox
  * @throws Exception
  */
 public function advancedBox()
 {
     $config = $this->getVal('config', false);
     if (!$config instanceof Wikia\Search\Config) {
         throw new Exception("This should not be called outside of self-request context.");
     }
     $searchEngine = new SearchEngine();
     $searchableNamespaces = $searchEngine->searchableNamespaces();
     wfRunHooks('AdvancedBoxSearchableNamespaces', array(&$searchableNamespaces));
     $this->setVal('namespaces', $config->getNamespaces());
     $this->setVal('searchableNamespaces', $searchableNamespaces);
 }