MessageIndex
in package
implements
ActionInterface, Routable
uses
ActionRouter, ActionTrait
This class shows the list of topics in a board.
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
- $sort_default : string
- $sort_methods : array<string|int, mixed>
- $ascending : bool
- $ascending_is_default : bool
- $obj : static
- $sort_by : string
- $sort_column : string
Methods
- buildRoute() : array<string|int, mixed>
- Builds a routing path based on URL query parameters.
- buildTopicContext() : void
- Processes information about topics.
- 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 topics in this board, along with any child boards.
- getBoardList() : array<string|int, mixed>
- Builds and returns the list of available boards for a user.
- 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.
- buildButtons() : void
- Build the message index button array.
- buildChildBoardIndex() : void
- Gets the child boards of this board, if applicable.
- buildQuickMod() : void
- Figures out which quick moderation actions the current user can perform.
- buildTopicList() : void
- The heart of the message index. Builds the list of topics to display.
- checkRedirect() : void
- Redirects to the target URL for this board, if applicable.
- getWhoViewing() : void
- Nosey, nosey - who's viewing this board?
- markViewed() : void
- Mark current and parent boards as seen.
- parseActionRoute() : array<string|int, mixed>
- Parses a route for an action to get URL query parameters.
- preventPrefetch() : void
- Blocks browser attempts to prefetch the message index.
- setModerators() : void
- Prepares contextual info about the moderators of this board.
- setPaginationAndLinks() : void
- Constructs page index, sets next/prev/up links, etc.
- setRobotNoIndex() : void
- Tells search engines not to index pages they shouldn't.
- setSortMethod() : void
- Determines how to sort the topics.
- setUnapprovedPostsMessage() : void
- Sets the unapproved posts message.
- setupTemplate() : void
- Loads the template and sets some related contextual info.
Properties
$sort_default
public
string
$sort_default
= 'last_post'
Default sort method. Must be a key in $this->sort_methods.
$sort_methods
public
array<string|int, mixed>
$sort_methods
= ['subject' => ['column' => 'mf.subject', 'joins' => 'JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)', 'asc_default' => true], 'starter' => ['column' => 'COALESCE(memf.real_name, mf.poster_name)', 'joins' => 'JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' . "\n\t\t\t" . 'LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)', 'asc_default' => true], 'last_poster' => ['column' => 'COALESCE(meml.real_name, ml.poster_name)', 'joins' => 'JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' . "\n\t\t\t" . 'LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)', 'asc_default' => true], 'replies' => ['column' => 't.num_replies', 'joins' => '', 'asc_default' => true], 'views' => ['column' => 't.num_views', 'joins' => '', 'asc_default' => true], 'first_post' => ['column' => 't.id_topic', 'joins' => '', 'asc_default' => false], 'last_post' => ['column' => 't.id_last_msg', 'joins' => '', 'asc_default' => false]]
Default sort methods.
$ascending
protected
bool
$ascending
Whether to sort in ascending order or not.
$ascending_is_default
protected
bool
$ascending_is_default
= false
Whether the $ascending value is the default for this sort method. Assume false until proven otherwise.
$obj
protected
static static
$obj
An instance of this class. This is used by the load() method to prevent multiple instantiations.
$sort_by
protected
string
$sort_by
Selected sort method.
$sort_column
protected
string
$sort_column
Selected sort column.
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.
buildTopicContext()
Processes information about topics.
public
static buildTopicContext(array<string|int, mixed> $row) : void
Populates Utils:$context['topics'] with the results.
This is static so that it can be called by SMF\Actions\Unread, etc.
Parameters
- $row : array<string|int, mixed>
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 topics in this board, along with any child boards.
public
execute() : void
getBoardList()
Builds and returns the list of available boards for a user.
public
static getBoardList([array<string|int, mixed> $boardListOptions = [] ]) : array<string|int, mixed>
Parameters
- $boardListOptions : array<string|int, mixed> = []
-
An array of options for the board list.
Return values
array<string|int, mixed> —An array of board info.
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.
buildButtons()
Build the message index button array.
protected
buildButtons() : void
buildChildBoardIndex()
Gets the child boards of this board, if applicable.
protected
buildChildBoardIndex() : void
buildQuickMod()
Figures out which quick moderation actions the current user can perform.
protected
buildQuickMod() : void
buildTopicList()
The heart of the message index. Builds the list of topics to display.
protected
buildTopicList() : void
checkRedirect()
Redirects to the target URL for this board, if applicable.
protected
checkRedirect() : void
getWhoViewing()
Nosey, nosey - who's viewing this board?
protected
getWhoViewing() : void
markViewed()
Mark current and parent boards as seen.
protected
markViewed() : void
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
preventPrefetch()
Blocks browser attempts to prefetch the message index.
protected
preventPrefetch() : void
setModerators()
Prepares contextual info about the moderators of this board.
protected
setModerators() : void
setPaginationAndLinks()
Constructs page index, sets next/prev/up links, etc.
protected
setPaginationAndLinks() : void
setRobotNoIndex()
Tells search engines not to index pages they shouldn't.
protected
setRobotNoIndex() : void
setSortMethod()
Determines how to sort the topics.
protected
setSortMethod() : void
setUnapprovedPostsMessage()
Sets the unapproved posts message.
protected
setUnapprovedPostsMessage() : void
setupTemplate()
Loads the template and sets some related contextual info.
protected
setupTemplate() : void