Beispiel #1
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;
	}
Beispiel #2
0
 /**
  * Returns text values for namespaces.
  * @param array $namespaces
  * @return array of namespace strings
  */
 public function getTextForNamespaces(array $namespaces)
 {
     return \SearchEngine::namespacesAsText($namespaces);
 }
 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 $key => &$data) {
         sort($data['namespaces']);
     }
     return $profiles;
 }
Beispiel #4
0
 protected function formHeader($term)
 {
     global $wgContLang, $wgCanonicalNamespaceNames;
     $sep = '   ';
     $out = Xml::openElement('div', array('style' => 'padding-bottom:0.5em;'));
     $bareterm = $term;
     if ($this->startsWithImage($term)) {
         $bareterm = substr($term, strpos($term, ':') + 1);
     }
     // delete all/image prefix
     $nsAllSet = array_keys(SearchEngine::searchableNamespaces());
     // search profiles headers
     $m = wfMsg('searchprofile-articles');
     $tt = wfMsg('searchprofile-articles-tooltip', implode(', ', SearchEngine::namespacesAsText(SearchEngine::defaultNamespaces())));
     if ($this->active == 'default') {
         $out .= Xml::element('strong', array('title' => $tt), $m);
     } else {
         $out .= $this->makeSearchLink($bareterm, SearchEngine::defaultNamespaces(), $m, $tt);
     }
     $out .= $sep;
     $m = wfMsg('searchprofile-images');
     $tt = wfMsg('searchprofile-images-tooltip');
     if ($this->active == 'images') {
         $out .= Xml::element('strong', array('title' => $tt), $m);
     } else {
         $imageTextForm = $wgContLang->getFormattedNsText(NS_FILE) . ':' . $bareterm;
         $out .= $this->makeSearchLink($imageTextForm, array(NS_FILE), $m, $tt);
     }
     $out .= $sep;
     /*
     $m = wfMsg( 'searchprofile-articles-and-proj' );
     $tt = wfMsg( 'searchprofile-project-tooltip', 
     	implode( ', ', SearchEngine::namespacesAsText( SearchEngine::defaultAndProjectNamespaces() ) ) );
     if( $this->active == 'withproject' ) {
     	$out .= Xml::element( 'strong', array( 'title'=>$tt ), $m );	
     } else {
     	$out .= $this->makeSearchLink( $bareterm, SearchEngine::defaultAndProjectNamespaces(), $m, $tt );
     }
     $out .= $sep;
     */
     $m = wfMsg('searchprofile-project');
     $tt = wfMsg('searchprofile-project-tooltip', implode(', ', SearchEngine::namespacesAsText(SearchEngine::projectNamespaces())));
     if ($this->active == 'project') {
         $out .= Xml::element('strong', array('title' => $tt), $m);
     } else {
         $out .= $this->makeSearchLink($bareterm, SearchEngine::projectNamespaces(), $m, $tt);
     }
     $out .= $sep;
     $m = wfMsg('searchprofile-everything');
     $tt = wfMsg('searchprofile-everything-tooltip');
     if ($this->active == 'all') {
         $out .= Xml::element('strong', array('title' => $tt), $m);
     } else {
         $out .= $this->makeSearchLink($bareterm, $nsAllSet, $m, $tt);
     }
     $out .= $sep;
     $m = wfMsg('searchprofile-advanced');
     $tt = wfMsg('searchprofile-advanced-tooltip');
     if ($this->active == 'advanced') {
         $out .= Xml::element('strong', array('title' => $tt), $m);
     } else {
         $out .= $this->makeSearchLink($bareterm, $this->namespaces, $m, $tt, array('advanced' => '1'));
     }
     $out .= Xml::closeElement('div');
     return $out;
 }
Beispiel #5
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;
 }
 /**
  * These search profiles are used to figure out what tab we're on and how we should be searching based on that
  * While kind of a view concern, moved here so it can play nicely with the namespaces value
  * @return array
  */
 public function getSearchProfiles()
 {
     // Builds list of Search Types (profiles)
     $searchEngine = F::build('SearchEngine');
     $nsAllSet = array_keys($searchEngine->searchableNamespaces());
     $profiles = array('default' => array('message' => 'wikiasearch2-tabs-articles', 'tooltip' => 'searchprofile-articles-tooltip', 'namespaces' => SearchEngine::defaultNamespaces(), 'namespace-messages' => SearchEngine::namespacesAsText(SearchEngine::defaultNamespaces())), 'images' => array('message' => 'wikiasearch2-tabs-photos-and-videos', 'tooltip' => 'searchprofile-images-tooltip', 'namespaces' => array(NS_FILE)), 'users' => array('message' => 'wikiasearch2-users', 'tooltip' => 'wikiasearch2-users-tooltip', 'namespaces' => array(NS_USER)), 'all' => array('message' => 'searchprofile-everything', 'tooltip' => 'searchprofile-everything-tooltip', 'namespaces' => $nsAllSet), 'advanced' => array('message' => 'searchprofile-advanced', 'tooltip' => 'searchprofile-advanced-tooltip', 'namespaces' => $this->getNamespaces(), 'parameters' => array('advanced' => 1)));
     wfRunHooks('SpecialSearchProfiles', array(&$profiles));
     foreach ($profiles as $key => &$data) {
         sort($data['namespaces']);
     }
     return $profiles;
 }
Beispiel #7
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;
 }
 /**
  * @group Slow
  * @slowExecutionTime 0.08619 ms
  * @covers Wikia\Search\MediaWikiService::getTextForNamespaces
  */
 public function testGetTextForNamespaces()
 {
     $this->assertEquals(\SearchEngine::namespacesAsText(array(0, 14)), (new MediaWikiService())->getTextForNamespaces(array(0, 14)));
 }