Search2
in package
implements
ActionInterface
Uses
BackwardCompatibility
Shows the search form.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $messages : array<string|int, mixed>
- $num_results : int
- $posters : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Performs the search and shows the results.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- load() : object
- Static wrapper for constructor.
- prepareSearchContext() : array<string|int, mixed>
- Callback to return messages - saves memory.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- checkLoadAverage() : void
- Aborts search if the load average is too high right now.
- errorCheck() : bool
- Checks for errors and shows the initial search page if there were.
- getPosters() : mixed
- Populates $this->posters with IDs of authors of the posts we will show.
- initSearchContext() : mixed
- Initializes stuff we need to display the search results.
- preventPrefetch() : void
- Blocks browser attempts to prefetch the topic display.
- redirectToMemberSearch() : void
- If comming from the quick search box and trying to search on members, redirect to the right place for that.
- setupTemplate() : void
- Loads the template and sets some related contextual info.
- setupVerification() : void
- Sets up anti-spam verification stuff, if needed.
- spamCheck() : void
- Block spam attempts, but without driving guests completely crazy.
- spellCheck() : mixed
- If spellchecking is enabled, check for typos in the search terms.
Properties
$messages
public
array<string|int, mixed>
$messages
= []
ID numbers of messages in the search results.
$num_results
public
int
$num_results
= 0
The number of results found.
$posters
public
array<string|int, mixed>
$posters
= []
ID numbers of the authors of the $messages.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'PlushSearch2']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Performs the search and shows the results.
public
execute() : void
Tags
exportStatic()
Provides a way to export a class's public static properties and methods to global namespace.
public
static exportStatic() : void
To do so:
- Use this trait in the class.
- At the END of the class's file, call its exportStatic() method.
Although it might not seem that way at first glance, this approach conforms to section 2.3 of PSR 1, since executing this method is simply a dynamic means of declaring functions when the file is included; it has no other side effects.
Regarding the $backcompat items:
A class's static properties are not exported to global variables unless explicitly included in $backcompat['prop_names']. Likewise, a class's static methods are not exported as global functions unless explicitly included in $backcompat['func_names'].
$backcompat['prop_names'] is a simple array where the keys are the names of one or more of a class's static properties, and the values are the names of global variables. In each case, the global variable will be set to a reference to the static property. Static properties that are not named in this array will not be exported.
$backcompat['func_names'] is a simple array where the keys are the names of one or more of a class's static methods, and the values are the names that should be used for global functions that will encapsulate those methods. Methods that are not named in this array will not be exported.
Adding non-static properties or methods to the $backcompat arrays will produce runtime errors. It is the responsibility of the developer to make sure not to do this.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
prepareSearchContext()
Callback to return messages - saves memory.
public
prepareSearchContext([bool $reset = false ]) : array<string|int, mixed>
What it does:
- callback function for the results sub template.
- loads the necessary contextual data to show a search result.
Parameters
- $reset : bool = false
-
Whether to reset the counter
Return values
array<string|int, mixed> —An array of contextual info related to this search
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
checkLoadAverage()
Aborts search if the load average is too high right now.
protected
checkLoadAverage() : void
errorCheck()
Checks for errors and shows the initial search page if there were.
protected
errorCheck() : bool
Return values
boolgetPosters()
Populates $this->posters with IDs of authors of the posts we will show.
protected
getPosters() : mixed
initSearchContext()
Initializes stuff we need to display the search results.
protected
initSearchContext() : mixed
preventPrefetch()
Blocks browser attempts to prefetch the topic display.
protected
preventPrefetch() : void
redirectToMemberSearch()
If comming from the quick search box and trying to search on members, redirect to the right place for that.
protected
redirectToMemberSearch() : void
setupTemplate()
Loads the template and sets some related contextual info.
protected
setupTemplate() : void
setupVerification()
Sets up anti-spam verification stuff, if needed.
protected
setupVerification() : void
spamCheck()
Block spam attempts, but without driving guests completely crazy.
protected
spamCheck() : void
spellCheck()
If spellchecking is enabled, check for typos in the search terms.
protected
spellCheck() : mixed