MessageIndex
in package
implements
ActionInterface
Uses
BackwardCompatibility
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.
Properties
- $sort_default : string
- $sort_methods : array<string|int, mixed>
- $ascending : bool
- $ascending_is_default : bool
- $obj : object
- $sort_by : string
- $sort_column : string
- $backcompat : array<string|int, mixed>
Methods
- buildTopicContext() : mixed
- Processes information about topics.
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Shows the list of topics in this board, along with any child boards.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- getBoardList() : array<string|int, mixed>
- Buils and returns the list of available boards for a user.
- load() : object
- Static wrapper for constructor.
- __construct() : mixed
- Prepares to show the message index.
- 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.
- preventPrefetch() : void
- Blocks browser attempts to prefetch the message index.
- setModerators() : void
- Prepares contextual info about the modertors 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 object
$obj
An instance of this class.
$sort_by
protected
string
$sort_by
Selected sort method.
$sort_column
protected
string
$sort_column
Selected sort column.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'MessageIndex', 'getBoardList' => 'getBoardList', 'buildTopicContext' => 'buildTopicContext']]
BackwardCompatibility settings for this class.
Methods
buildTopicContext()
Processes information about topics.
public
static buildTopicContext(array<string|int, mixed> $row) : mixed
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
execute()
Shows the list of topics in this board, along with any child boards.
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.
getBoardList()
Buils 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.
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
__construct()
Prepares to show the message index.
protected
__construct() : mixed
Protected to force instantiation via self::load().
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
preventPrefetch()
Blocks browser attempts to prefetch the message index.
protected
preventPrefetch() : void
setModerators()
Prepares contextual info about the modertors 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