MediaWiki  1.23.2
SpecialSearch Class Reference

implements Special:Search - Run text & title search and display the output More...

Inheritance diagram for SpecialSearch:
Collaboration diagram for SpecialSearch:

Public Member Functions

 __construct ()
 
 execute ( $par)
 Entry point. More...
 
 getNamespaces ()
 Current namespaces. More...
 
 getProfile ()
 Current search profile. More...
 
 getSearchEngine ()
 
 goResult ( $term)
 If an exact title match can be found, jump straight ahead to it. More...
 
 load ()
 Set up basic search parameters from the request and user settings. More...
 
 setExtraParam ( $key, $value)
 Users of hook SpecialSearchSetupEngine can use this to add more params to links to not lose selection when user navigates search results. More...
 
 showResults ( $term)
 
- Public Member Functions inherited from SpecialPage
 __construct ( $name='', $restriction='', $listed=true, $function=false, $file='default', $includable=false)
 Default constructor for special pages Derivative classes should call this from their constructor Note that if the user does not have the required level, an error message will be displayed by the default execute() method, without the global function ever being called. More...
 
 checkPermissions ()
 Checks if userCanExecute, and if not throws a PermissionsError. More...
 
 checkReadOnly ()
 If the wiki is currently in readonly mode, throws a ReadOnlyError. More...
 
 displayRestrictionError ()
 Output an error message telling the user what access level they have to have. More...
 
 getContext ()
 Gets the context this SpecialPage is executed in. More...
 
 getDescription ()
 Returns the name that goes in the <h1> in the special page itself, and also the name that will be listed in Special:Specialpages. More...
 
 getFile ()
 Get the file which will be included by SpecialPage::execute() if your extension is still stuck in the past and hasn't overridden the execute() method. More...
 
 getFinalGroupName ()
 Get the group that the special page belongs in on Special:SpecialPage Use this method, instead of getGroupName to allow customization of the group name from the wiki side. More...
 
 getFullTitle ()
 Return the full title, including $par. More...
 
 getLang ()
 Shortcut to get user's language. More...
 
 getLanguage ()
 Shortcut to get user's language. More...
 
 getLocalName ()
 Get the localised name of the special page. More...
 
 getName ()
 Get the name of this Special Page. More...
 
 getOutput ()
 Get the OutputPage being used for this instance. More...
 
 getPageTitle ( $subpage=false)
 Get a self-referential title object. More...
 
 getRequest ()
 Get the WebRequest being used for this instance. More...
 
 getRestriction ()
 Get the permission that a user must have to execute this page. More...
 
 getSkin ()
 Shortcut to get the skin being used for this instance. More...
 
 getTitle ( $subpage=false)
 Get a self-referential title object. More...
 
 getUser ()
 Shortcut to get the User executing this instance. More...
 
 including ( $x=null)
 Whether the special page is being evaluated via transclusion. More...
 
 isCached ()
 Is this page cached? Expensive pages are cached or disabled in miser mode. More...
 
 isExpensive ()
 Is this page expensive (for some definition of expensive)? Expensive pages are disabled or cached in miser mode. More...
 
 isIncludable ()
 Whether it's allowed to transclude the special page via {{Special:Foo/params}}. More...
 
 isListed ()
 Whether this special page is listed in Special:SpecialPages. More...
 
 isRestricted ()
 Can be overridden by subclasses with more complicated permissions schemes. More...
 
 listed ( $x=null)
 Get or set whether this special page is listed in Special:SpecialPages. More...
 
 msg ()
 Wrapper around wfMessage that sets the current context. More...
 
 outputHeader ( $summaryMessageKey='')
 Outputs a summary message on top of special pages Per default the message key is the canonical name of the special page May be overridden, i.e. More...
 
 requireLogin ( $reasonMsg=null, $titleMsg=null)
 If the user is not logged in, throws UserNotLoggedIn error. More...
 
 run ( $subPage)
 Entry point. More...
 
 setContext ( $context)
 Sets the context this SpecialPage is executed in. More...
 
 setHeaders ()
 Sets headers - this should be called from the execute() method of all derived classes! More...
 
 setListed ( $listed)
 Set whether this page is listed in Special:Specialpages, at run-time. More...
 
 userCanExecute (User $user)
 Checks if the given user (identified by an object) can execute this special page (as defined by $mRestriction). More...
 

Public Attributes

string $fulltext
 
int $offset
 
const NAMESPACES_CURRENT = 'sense'
 

Protected Member Functions

 formHeader ( $term, $resultsShown, $totalNum)
 
 getGroupName ()
 Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'. More...
 
 getProfileForm ( $profile, $term)
 
 getSearchProfiles ()
 
 makeSearchLink ( $term, $namespaces, $label, $tooltip, $params=array())
 Make a search link with some target namespaces. More...
 
 powerSearch (&$request)
 Extract "power search" namespace settings from the request object, returning a list of index numbers to search. More...
 
 powerSearchBox ( $term, $opts)
 Generates the power search box at [[Special:Search]]. More...
 
 powerSearchOptions ()
 Reconstruct the 'power search' options for links. More...
 
 setupPage ( $term)
 
 shortDialog ( $term)
 
 showCreateLink ( $title, $num, $titleMatches, $textMatches)
 
 showHit ( $result, $terms)
 Format a single hit result. More...
 
 showInterwiki ( $matches, $query)
 Show results from other wikis. More...
 
 showInterwikiHit ( $result, $lastInterwiki, $query, $customCaptions)
 Show single interwiki link. More...
 
 showMatches (&$matches)
 Show whole set of results. More...
 
 startsWithAll ( $term)
 Check if query starts with all: prefix. More...
 
 startsWithImage ( $term)
 Check if query starts with image: prefix. More...
 
- Protected Member Functions inherited from SpecialPage
 addFeedLinks ( $params)
 Adds RSS/atom links. More...
 
 afterExecute ( $subPage)
 Gets called after. More...
 
 beforeExecute ( $subPage)
 Gets called before. More...
 
 getRobotPolicy ()
 Return the robot policy. More...
 

Protected Attributes

string $didYouMeanHtml
 
Array $extraParams = array()
 For links *. More...
 
int $limit
 
String $mPrefix
 No idea, apparently used by some other classes *. More...
 
array $namespaces
 
null string $profile
 Current search profile. More...
 
SearchEngine $searchEngine
 Search engine *. More...
 
String $searchEngineType
 Search engine type, if not default *. More...
 
- Protected Attributes inherited from SpecialPage
IContextSource $mContext
 Current request context. More...
 
 $mIncludable
 
 $mIncluding
 
 $mName
 

Additional Inherited Members

- Static Public Member Functions inherited from SpecialPage
static getSafeTitleFor ( $name, $subpage=false)
 Get a localised Title object for a page name with a possibly unvalidated subpage. More...
 
static getTitleFor ( $name, $subpage=false, $fragment='')
 Get a localised Title object for a specified special page name. More...
 

Detailed Description

implements Special:Search - Run text & title search and display the output

Definition at line 30 of file SpecialSearch.php.

Constructor & Destructor Documentation

◆ __construct()

SpecialSearch::__construct ( )

Definition at line 62 of file SpecialSearch.php.

Member Function Documentation

◆ execute()

SpecialSearch::execute (   $par)

Entry point.

Parameters
string$paror null

Reimplemented from SpecialPage.

Definition at line 71 of file SpecialSearch.php.

References $out, array(), SpecialPage\getOutput(), SpecialPage\getRequest(), goResult(), load(), SpecialPage\outputHeader(), SpecialPage\setHeaders(), and showResults().

◆ formHeader()

SpecialSearch::formHeader (   $term,
  $resultsShown,
  $totalNum 
)
protected

◆ getGroupName()

SpecialSearch::getGroupName ( )
protected

Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-group-*' for valid names This method defaults to group 'other'.

Returns
string
Since
1.21

Reimplemented from SpecialPage.

Definition at line 1207 of file SpecialSearch.php.

◆ getNamespaces()

SpecialSearch::getNamespaces ( )

Current namespaces.

Returns
array

Definition at line 1190 of file SpecialSearch.php.

References $namespaces.

◆ getProfile()

SpecialSearch::getProfile ( )

Current search profile.

Returns
null|string

Definition at line 1182 of file SpecialSearch.php.

References $profile.

◆ getProfileForm()

SpecialSearch::getProfileForm (   $profile,
  $term 
)
protected
Parameters
$profile
$term
Returns
String

Definition at line 852 of file SpecialSearch.php.

References $form, $profile, $term, array(), powerSearchBox(), and wfRunHooks().

Referenced by showResults().

◆ getSearchEngine()

SpecialSearch::getSearchEngine ( )
Since
1.18
Returns
SearchEngine

Definition at line 1169 of file SpecialSearch.php.

References $searchEngine, and SearchEngine\create().

Referenced by showResults().

◆ getSearchProfiles()

SpecialSearch::getSearchProfiles ( )
protected

◆ goResult()

SpecialSearch::goResult (   $term)

If an exact title match can be found, jump straight ahead to it.

Parameters
$termString

Definition at line 159 of file SpecialSearch.php.

References $term, $title, array(), SearchEngine\getNearMatch(), SpecialPage\getOutput(), global, Title\newFromText(), setupPage(), showResults(), wfDebugLog(), and wfRunHooks().

Referenced by execute().

◆ load()

SpecialSearch::load ( )

Set up basic search parameters from the request and user settings.

See also
tests/phpunit/includes/specials/SpecialSearchTest.php

Definition at line 107 of file SpecialSearch.php.

References $profile, $user, as, SpecialPage\getRequest(), getSearchProfiles(), SpecialPage\getUser(), list, namespaces, of, powerSearch(), and SearchEngine\userNamespaces().

Referenced by execute().

◆ makeSearchLink()

SpecialSearch::makeSearchLink (   $term,
  $namespaces,
  $label,
  $tooltip,
  $params = array() 
)
protected

Make a search link with some target namespaces.

Parameters
$termString
array$namespacesignored
string$labellink's text
string$tooltiplink's tooltip
array$paramsquery string parameters
Returns
String: HTML fragment

Definition at line 1105 of file SpecialSearch.php.

References $n, $namespaces, $params, $term, array(), as, Xml\element(), SpecialPage\getPageTitle(), SpecialPage\msg(), and text.

Referenced by formHeader().

◆ powerSearch()

SpecialSearch::powerSearch ( $request)
protected

Extract "power search" namespace settings from the request object, returning a list of index numbers to search.

Parameters
$requestWebRequest
Returns
Array

Definition at line 484 of file SpecialSearch.php.

References $name, array(), as, and SearchEngine\searchableNamespaces().

Referenced by load().

◆ powerSearchBox()

SpecialSearch::powerSearchBox (   $term,
  $opts 
)
protected

Generates the power search box at [[Special:Search]].

Parameters
string$termsearch term
$optsarray
Returns
String: HTML form

Definition at line 874 of file SpecialSearch.php.

References $name, $term, $value, $wgContLang, array(), as, Xml\checkLabel(), Xml\closeElement(), Xml\element(), Html\element(), MWNamespace\getSubject(), global, Html\hidden(), SpecialPage\msg(), namespaces, Xml\openElement(), SearchEngine\searchableNamespaces(), Xml\tags(), text, and wfRunHooks().

Referenced by getProfileForm().

◆ powerSearchOptions()

SpecialSearch::powerSearchOptions ( )
protected

Reconstruct the 'power search' options for links.

Returns
Array

Definition at line 500 of file SpecialSearch.php.

References $extraParams, $n, $profile, array(), as, and namespaces.

Referenced by showHit(), and showResults().

◆ setExtraParam()

SpecialSearch::setExtraParam (   $key,
  $value 
)

Users of hook SpecialSearchSetupEngine can use this to add more params to links to not lose selection when user navigates search results.

Since
1.18
Parameters
$key
$value

Definition at line 1203 of file SpecialSearch.php.

References $value.

◆ setupPage()

SpecialSearch::setupPage (   $term)
protected
Parameters
$termstring

Definition at line 462 of file SpecialSearch.php.

References $out, $term, SpecialPage\getOutput(), SpecialPage\msg(), and text.

Referenced by goResult(), and showResults().

◆ shortDialog()

SpecialSearch::shortDialog (   $term)
protected
Parameters
$termstring
Returns
string

Definition at line 1076 of file SpecialSearch.php.

References $didYouMeanHtml, $out, $term, array(), SpecialPage\getPageTitle(), Html\hidden(), Html\input(), SpecialPage\msg(), Xml\submitButton(), and text.

Referenced by showResults().

◆ showCreateLink()

SpecialSearch::showCreateLink (   $title,
  $num,
  $titleMatches,
  $textMatches 
)
protected
Parameters
$titleTitle
int$numThe number of search results found
$titleMatchesnull|SearchResultSet results from title search
$textMatchesnull|SearchResultSet results from text search

Definition at line 425 of file SpecialSearch.php.

References $params, $title, array(), SpecialPage\getOutput(), wfEscapeWikiText(), and wfRunHooks().

Referenced by showResults().

◆ showHit()

SpecialSearch::showHit (   $result,
  $terms 
)
protected

◆ showInterwiki()

SpecialSearch::showInterwiki (   $matches,
  $query 
)
protected

Show results from other wikis.

Parameters
$matchesSearchResultSet|array
$queryString
Returns
string

Definition at line 728 of file SpecialSearch.php.

References $line, $matches, $out, $profile, $query, $wgContLang, array(), as, global, SpecialPage\msg(), showInterwikiHit(), and text.

Referenced by showResults().

◆ showInterwikiHit()

SpecialSearch::showInterwikiHit (   $result,
  $lastInterwiki,
  $query,
  $customCaptions 
)
protected

Show single interwiki link.

Parameters
$resultSearchResult
$lastInterwikiString
$queryString
array$customCaptionsiw prefix -> caption
Returns
string

Definition at line 780 of file SpecialSearch.php.

References $link, $out, $profile, $query, $title, array(), Linker\linkKnown(), SpecialPage\msg(), Title\newFromText(), text, and wfParseUrl().

Referenced by showInterwiki().

◆ showMatches()

SpecialSearch::showMatches ( $matches)
protected

Show whole set of results.

Parameters
$matchesSearchResultSet
Returns
string

Definition at line 520 of file SpecialSearch.php.

References $matches, $out, $profile, $wgContLang, global, and showHit().

Referenced by showResults().

◆ showResults()

◆ startsWithAll()

SpecialSearch::startsWithAll (   $term)
protected

Check if query starts with all: prefix.

Parameters
string$termthe string to check
Returns
Boolean

Definition at line 1152 of file SpecialSearch.php.

References $term, and SpecialPage\msg().

◆ startsWithImage()

SpecialSearch::startsWithImage (   $term)
protected

Check if query starts with image: prefix.

Parameters
string$termthe string to check
Returns
Boolean

Definition at line 1135 of file SpecialSearch.php.

References $term, $wgContLang, global, and NS_FILE.

Referenced by formHeader().

Member Data Documentation

◆ $didYouMeanHtml

string SpecialSearch::$didYouMeanHtml
protected

Definition at line 58 of file SpecialSearch.php.

Referenced by shortDialog().

◆ $extraParams

Array SpecialSearch::$extraParams = array()
protected

For links *.

Definition at line 44 of file SpecialSearch.php.

Referenced by powerSearchOptions().

◆ $fulltext

string SpecialSearch::$fulltext

Definition at line 58 of file SpecialSearch.php.

Referenced by showResults().

◆ $limit

int SpecialSearch::$limit
protected

Definition at line 50 of file SpecialSearch.php.

◆ $mPrefix

String SpecialSearch::$mPrefix
protected

No idea, apparently used by some other classes *.

Definition at line 46 of file SpecialSearch.php.

Referenced by showResults().

◆ $namespaces

array SpecialSearch::$namespaces
protected

Definition at line 54 of file SpecialSearch.php.

Referenced by getNamespaces(), and makeSearchLink().

◆ $offset

int SpecialSearch::$offset

Definition at line 50 of file SpecialSearch.php.

◆ $profile

null string SpecialSearch::$profile
protected

Current search profile.

Search profile is just a name that identifies the active search tab on the search page (content, help, discussions...) For users tt replaces the set of enabled namespaces from the query string when applicable. Extensions can add new profiles with hooks with custom search options just for that profile.

Definition at line 38 of file SpecialSearch.php.

Referenced by formHeader(), getProfile(), getProfileForm(), load(), powerSearchOptions(), showHit(), showInterwiki(), showInterwikiHit(), showMatches(), and showResults().

◆ $searchEngine

SearchEngine SpecialSearch::$searchEngine
protected

Search engine *.

Definition at line 40 of file SpecialSearch.php.

Referenced by getSearchEngine().

◆ $searchEngineType

String SpecialSearch::$searchEngineType
protected

Search engine type, if not default *.

Definition at line 42 of file SpecialSearch.php.

◆ NAMESPACES_CURRENT

const SpecialSearch::NAMESPACES_CURRENT = 'sense'

Definition at line 60 of file SpecialSearch.php.


The documentation for this class was generated from the following file: