Recent
in package
implements
ActionInterface
Uses
BackwardCompatibility
Finds and retrieves information about recently posted messages.
Table of Contents
Interfaces
- ActionInterface
- Interface for all action classes.
Constants
Properties
- $action_url : string
- $cat_name : string
- $messages : array<string|int, mixed>
- $obj : object
- $permission_boards : array<string|int, mixed>
- $query_parameters : array<string|int, mixed>
- $query_this_board : string
- $total_posts : int
- $backcompat : array<string|int, mixed>
Methods
- call() : void
- Convenience method to load() and execute() an instance of this class.
- execute() : void
- Find the ten most recent posts.
- exportStatic() : void
- Provides a way to export a class's public static properties and methods to global namespace.
- getLastPost() : array<string|int, mixed>
- Get the latest post made on the forum.
- load() : object
- Static wrapper for constructor.
- __construct() : mixed
- Constructor. Protected to force instantiation via self::load().
- buildQuickButtons() : mixed
- Last but not least, the quickbuttons.
- doPermissions() : void
- Figure our what the current user can do with each message.
- getBoards() : mixed
- Figures out what boards we want to get messages from.
- getCatName() : mixed
- Gets the category name, if applicable.
- getMessages() : mixed
- Populates Utils::$context['posts'] with formatted messages.
- getMsgIds() : mixed
- Populates $this->messages with the IDs of some recent messages.
- setPaginationAndLinks() : mixed
- Constructs page index, sets the linktree, next/prev/up links, etc.
Constants
PAGES
public
mixed
PAGES
= 10
PER_PAGE
public
mixed
PER_PAGE
= 10
Properties
$action_url
protected
string
$action_url
Base URL for this action.
$cat_name
protected
string
$cat_name
Name of the category we are in, if applicable.
$messages
protected
array<string|int, mixed>
$messages
= []
IDs of some recent messages.
$obj
protected
static object
$obj
An instance of this class. This is used by the load() method to prevent mulitple instantiations.
$permission_boards
protected
array<string|int, mixed>
$permission_boards
= ['own' => [], 'any' => []]
Boards that we need to check for some own/any permissions.
$query_parameters
protected
array<string|int, mixed>
$query_parameters
= []
Parameters for the main query.
$query_this_board
protected
string
$query_this_board
SQL statement indicating the boards to look in.
$total_posts
protected
int
$total_posts
= 0
How many recent messages we found.
$backcompat
private
static array<string|int, mixed>
$backcompat
= ['func_names' => ['call' => 'RecentPosts', 'getLastPost' => 'getLastPost']]
BackwardCompatibility settings for this class.
Methods
call()
Convenience method to load() and execute() an instance of this class.
public
static call() : void
execute()
Find the ten most recent posts.
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.
getLastPost()
Get the latest post made on the forum.
public
static getLastPost() : array<string|int, mixed>
Respects approved, recycled, and board permissions. Not used by SMF itself, but kept around in case mods need it.
Return values
array<string|int, mixed> —An array of information about the last post that you can see
load()
Static wrapper for constructor.
public
static load() : object
Return values
object —An instance of this class.
__construct()
Constructor. Protected to force instantiation via self::load().
protected
__construct() : mixed
buildQuickButtons()
Last but not least, the quickbuttons.
protected
buildQuickButtons() : mixed
doPermissions()
Figure our what the current user can do with each message.
protected
doPermissions() : void
getBoards()
Figures out what boards we want to get messages from.
protected
getBoards() : mixed
Sets $this->query_this_board and $this->query_parameters.
Tags
getCatName()
Gets the category name, if applicable.
protected
getCatName() : mixed
getMessages()
Populates Utils::$context['posts'] with formatted messages.
protected
getMessages() : mixed
getMsgIds()
Populates $this->messages with the IDs of some recent messages.
protected
getMsgIds() : mixed
setPaginationAndLinks()
Constructs page index, sets the linktree, next/prev/up links, etc.
protected
setPaginationAndLinks() : mixed