BoardIndex
in package
implements
ActionInterface
Uses
BackwardCompatibility
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.
Properties
- $obj : object
- $backcompat : array<string|int, mixed>
Methods
- cache_getLastPosts() : mixed
- Callback-function for the cache for getLastPosts().
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Shows the list of categories and boards, along with the info center.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- 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.
- load() : object
- Static wrapper for constructor.
- __construct() : mixed
- Prepares to show the board index.
- 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 object
$obj
An instance of this class.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['load' => 'BoardIndex', 'call' => 'call', 'get' => 'getBoardIndex']]
BackwardCompatibility settings for this class.
Methods
cache_getLastPosts()
Callback-function for the cache for getLastPosts().
public
cache_getLastPosts([int $number_posts = 5 ]) : mixed
Parameters
- $number_posts : int = 5
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Shows the list of categories and boards, along with the info center.
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.
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.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
__construct()
Prepares to show the board index.
protected
__construct() : mixed
Protected to force instantiation via self::load().
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(object $board, array<string|int, mixed> $board_index_options) : void
Parameters
- $board : object
-
An instance of SMF\Board.
- $board_index_options : array<string|int, mixed>
-
The options passed to BoardIndex:get().