AutoSuggest
in package
implements
ActionInterface
Uses
BackwardCompatibility
Suggests members, membergroups, or SMF versions in reply to AJAX requests.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Properties
- $search : string
- $search_param : array<string|int, mixed>
- $suggest_type : string
- $suggest_types : array<string|int, mixed>
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- AutoSuggest_Search_Member() : void
- Backward compatibility wrapper for the member suggestion type.
- AutoSuggest_Search_MemberGroups() : void
- Backward compatibility wrapper for the membergroups suggestion type.
- AutoSuggest_Search_SMFVersions() : void
- Backward compatibility wrapper for the versions suggestion type.
- AutoSuggestHandler() : mixed
- Backward compatibility wrapper that either calls self::checkRegistered() or self::call(), depending on whether the parameter is set or not.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- checkRegistered() : bool
- Checks whether the given suggestion type is supported.
- execute() : void
- Dispatcher to whichever method is necessary.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- load() : object
- Static wrapper for constructor.
- member() : array<string|int, mixed>
- Search for a member by real_name.
- membergroups() : array<string|int, mixed>
- Search for a membergroup by name.
- versions() : array<string|int, mixed>
- Provides a list of possible SMF versions to use in emulation.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- sanitizeSearch() : void
- Sanitizes the search string.
Properties
$search
public
string
$search
The string to search for when finding suggestions. This should be set by the constructor.
$search_param
public
array<string|int, mixed>
$search_param
= []
Optional search parameters. This should be set by the constructor.
$suggest_type
public
string
$suggest_type
The requested type of suggestion. This should be set by the constructor.
$suggest_types
public
static array<string|int, mixed>
$suggest_types
= ['member' => 'member', 'membergroups' => 'membergroups', 'versions' => 'versions']
Available suggestion types.
$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' => ['AutoSuggestHandler' => 'AutoSuggestHandler', 'AutoSuggest_Search_Member' => 'AutoSuggest_Search_Member', 'AutoSuggest_Search_MemberGroups' => 'AutoSuggest_Search_MemberGroups', 'AutoSuggest_Search_SMFVersions' => 'AutoSuggest_Search_SMFVersions']]
BackwardCompatibility settings for this class.
Methods
AutoSuggest_Search_Member()
Backward compatibility wrapper for the member suggestion type.
public
static AutoSuggest_Search_Member() : void
AutoSuggest_Search_MemberGroups()
Backward compatibility wrapper for the membergroups suggestion type.
public
static AutoSuggest_Search_MemberGroups() : void
AutoSuggest_Search_SMFVersions()
Backward compatibility wrapper for the versions suggestion type.
public
static AutoSuggest_Search_SMFVersions() : void
AutoSuggestHandler()
Backward compatibility wrapper that either calls self::checkRegistered() or self::call(), depending on whether the parameter is set or not.
public
static AutoSuggestHandler([mixed $suggest_type = null ]) : mixed
Parameters
- $suggest_type : mixed = null
-
Either a suggestion type, or null.
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
checkRegistered()
Checks whether the given suggestion type is supported.
public
static checkRegistered(string $suggest_type) : bool
Parameters
- $suggest_type : string
-
The suggestion type we are interested in.
Return values
boolexecute()
Dispatcher to whichever method is necessary.
public
execute() : void
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.
member()
Search for a member by real_name.
public
member() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of information for displaying the suggestions.
membergroups()
Search for a membergroup by name.
public
membergroups() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of information for displaying the suggestions.
versions()
Provides a list of possible SMF versions to use in emulation.
public
versions() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of data for displaying the suggestions.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
sanitizeSearch()
Sanitizes the search string.
protected
sanitizeSearch() : void