BoardIndex
in package
implements
ActionInterface, Routable
uses
ActionRouter, ActionTrait
This class shows the board index.
It uses the BoardIndex template, and main sub template. It updates most of the online statistics.
Although this class is not accessed using an ?action=... URL query, it behaves like an action in every other way.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
- Routable
- Classes implementing this interface can build routes from URL query parameters and parse routes back into URL query parameters.
Properties
- $obj : static
Methods
- buildRoute() : array<string|int, mixed>
- Builds a routing path based on URL query parameters.
- cache_getLastPosts() : array<string|int, mixed>
- Callback-function for the cache for getLastPosts().
- call() : void
- Convenience method to load() and execute() an instance of this class.
- canBeLogged() : bool
- Determines whether this action can be logged in the online log.
- canShowDebuggingInfo() : bool
- Determines whether debugging info should be shown.
- canShowInMaintenanceMode() : bool
- Determines whether this action allows access in maintenance mode.
- execute() : void
- Shows the list of categories and boards, along with the info center.
- get() : array<string|int, mixed>
- Fetches a list of boards and (optional) categories including statistical information, child boards and moderators.
- getLastPosts() : array<string|int, mixed>
- Get the latest posts of a forum.
- getOutputType() : OutputTypeInterface
- Gets the output type for this action.
- isAgreementAction() : bool
- Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
- isRestrictedGuestAccessAllowed() : bool
- Determines whether this action allows access if guest access is restricted.
- isSimpleAction() : bool
- Determines whether this is a simple action.
- load() : static
- Static wrapper for constructor.
- parseRoute() : array<string|int, mixed>
- Parses a route to get URL query parameters.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- buildActionRoute() : array<string|int, mixed>
- Builds a routing path for an action based on URL query parameters.
- parseActionRoute() : array<string|int, mixed>
- Parses a route for an action to get URL query parameters.
- prepareLastPost() : array<string|int, mixed>
- Prepares formatted data about the latest post in a board.
- propagateStatsToParents() : void
- Propagates statistics (e.g. post and topic counts) to parent boards.
Properties
$obj
protected
static static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
Methods
buildRoute()
Builds a routing path based on URL query parameters.
public
static buildRoute(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
URL query parameters.
Return values
array<string|int, mixed> —Contains two elements: ['route' => [], 'params' => []]. The 'route' element contains the routing path. The 'params' element contains any $params that weren't incorporated into the route.
cache_getLastPosts()
Callback-function for the cache for getLastPosts().
public
cache_getLastPosts([int $number_posts = 5 ]) : array<string|int, mixed>
Parameters
- $number_posts : int = 5
Return values
array<string|int, mixed> —Latest posts data from cache.
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
canBeLogged()
Determines whether this action can be logged in the online log.
public
canBeLogged() : bool
Return values
boolcanShowDebuggingInfo()
Determines whether debugging info should be shown.
public
canShowDebuggingInfo() : bool
Return values
boolcanShowInMaintenanceMode()
Determines whether this action allows access in maintenance mode.
public
canShowInMaintenanceMode() : bool
Return values
bool —True if access is allowed, false otherwise.
execute()
Shows the list of categories and boards, along with the info center.
public
execute() : void
get()
Fetches a list of boards and (optional) categories including statistical information, child boards and moderators.
public
static get(array<string|int, mixed> $board_index_options) : array<string|int, mixed>
Used by both the board index (main data) and the message index (child boards).
Depending on the include_categories setting returns an associative array with categories->boards->child_boards or an associative array with boards->child_boards.
Parameters
- $board_index_options : array<string|int, mixed>
-
An array of boardindex options.
Return values
array<string|int, mixed> —An array of information for displaying the boardindex.
getLastPosts()
Get the latest posts of a forum.
public
getLastPosts([int $number_posts = 5 ]) : array<string|int, mixed>
Parameters
- $number_posts : int = 5
-
How many posts to get.
Return values
array<string|int, mixed> —Info about the posts.
getOutputType()
Gets the output type for this action.
public
getOutputType() : OutputTypeInterface
Return values
OutputTypeInterfaceisAgreementAction()
Determines whether this action can be accessed without accepting the registration agreement and privacy policy.
public
isAgreementAction() : bool
Return values
boolisRestrictedGuestAccessAllowed()
Determines whether this action allows access if guest access is restricted.
public
isRestrictedGuestAccessAllowed() : bool
Return values
bool —True if access is allowed, false otherwise.
isSimpleAction()
Determines whether this is a simple action.
public
isSimpleAction() : bool
Return values
boolload()
Static wrapper for constructor.
public
static load() : static
Return values
static —An instance of this class.
parseRoute()
Parses a route to get URL query parameters.
public
static parseRoute(array<string|int, mixed> $route[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $route : array<string|int, mixed>
-
Array of routing path components.
- $params : array<string|int, mixed> = []
-
Any existing URL query parameters.
Return values
array<string|int, mixed> —URL query parameters
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
buildActionRoute()
Builds a routing path for an action based on URL query parameters.
protected
static buildActionRoute(array<string|int, mixed> &$params) : array<string|int, mixed>
The 'action', 'area', and 'sa' parameters will be mapped to route path components in that order. The 'action' parameter is required, whereas 'area' and 'sa' are optional and will be silently skipped if not set.
The parameters are passed by reference and parameters are removed from the array when recognized. This lets wrapper methods continue parsing the remainder of the parameters without worrying about duplicate elements.
Parameters
- $params : array<string|int, mixed>
-
URL query parameters.
Return values
array<string|int, mixed> —The route path elements.
parseActionRoute()
Parses a route for an action to get URL query parameters.
protected
static parseActionRoute(array<string|int, mixed> &$route) : array<string|int, mixed>
The first element of the route path is mapped to the 'action' parameter.
For the 'admin', 'moderate', and 'profile' actions, the second element of the route is mapped to the 'area' parameter and the third element is mapped to the 'sa' parameter.
For all other actions, the second element of the route path is mapped to the 'sa' parameter.
The route passed by reference and route path elements are removed from the route when recognized. This lets wrapper methods continue parsing the remainder of the route without worrying about duplicate elements.
Parameters
- $route : array<string|int, mixed>
-
Array of routing path components.
Return values
array<string|int, mixed> —URL query parameters
prepareLastPost()
Prepares formatted data about the latest post in a board.
protected
static prepareLastPost(array<string|int, mixed> $row_board) : array<string|int, mixed>
Returned array contains at least the following keys:
- id (of the post)
- timestamp (a number that represents the time)
- time (formatted according to the user's preferences)
- topic (topic id)
- link
- href
- subject
- start (where they should go for the first unread post)
- member (which contains id, name, link, href, username)
Parameters
- $row_board : array<string|int, mixed>
-
Raw board data.
Return values
array<string|int, mixed> —Formatted post data.
propagateStatsToParents()
Propagates statistics (e.g. post and topic counts) to parent boards.
protected
static propagateStatsToParents(Board $board, array<string|int, mixed> $board_index_options) : void
Parameters
- $board : Board
-
An instance of SMF\Board.
- $board_index_options : array<string|int, mixed>
-
The options passed to BoardIndex:get().