Documentation

Display
in package
implements ActionInterface, Routable uses ActionRouter, ActionTrait

This class loads the posts in a topic so they can be displayed.

It uses the main sub template of the Display template. It requires a topic, and can go to the previous or next topic from it. It jumps to the correct post depending on a number/time/msg passed. It depends on the messages_per_page, defaultMaxMessages and enableAllMessages settings. It is accessed by ?topic=id_topic.START.

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

$can_show_all  : bool
$obj  : static
$firstIndex  : int
$messages  : array<string|int, mixed>
$posters  : array<string|int, mixed>
$virtual_msg  : int

Methods

buildRoute()  : array<string|int, mixed>
Builds a routing path based on URL query parameters.
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
Does the heavy lifting to show the posts in this topic.
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.
prepareDisplayContext()  : array<string|int, mixed>|bool
Callback for the message display.
__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
Builds the user and moderator button arrays.
checkMovedMergedRedirect()  : void
Is this a moved or merged topic that we are redirecting to?
checkPrevNextRedirect()  : void
Redirect to the previous or next topic, if requested in the URL params.
getMessagesAndPosters()  : void
Populates $this->messages and $this->posters with IDs of each post and poster in this topic.
getNotificationMode()  : void
Get notification preferences and mode.
getWhoViewing()  : void
Let's get nosey, who is viewing this topic?
incrementNumViews()  : void
Add 1 to the number of views of this topic (except for robots).
initDisplayContext()  : void
Initializes Msg::get() and loads attachments and likes.
loadEditor()  : void
Loads the editor for the quick reply.
loadEvents()  : void
Loads info about any calendar events that are linked to this topic.
loadPoll()  : void
Loads the poll linked to this topic, if applicable.
markRead()  : void
parseActionRoute()  : array<string|int, mixed>
Parses a route for an action to get URL query parameters.
preventPrefetch()  : void
Blocks browser attempts to prefetch the topic display.
setModerators()  : void
Prepares contextual info about the moderators of this board.
setOldTopicWarning()  : void
Warn the user against replying to old topics.
setPaginationAndLinks()  : void
Constructs page index, sets next/prev/up links, etc.
setRobotNoIndex()  : void
Tells search engines not to index pages they shouldn't.
setStart()  : void
If $_REQUEST['start'] is not a number, figures out the correct numerical value and sets $_REQUEST['start'] to that value.
setUnapprovedPostsMessage()  : void
Sets the unapproved posts message.
setupTemplate()  : void
Loads the template and sets some related contextual info.
setupVerification()  : void
Sets up anti-spam verification stuff, if needed.

Properties

$can_show_all

public bool $can_show_all = false

Whether all posts in the topic can be viewed on a single page.

$obj

protected static static $obj

An instance of this class. This is used by the load() method to prevent multiple instantiations.

$firstIndex

private int $firstIndex

Index of the first message.

$messages

private array<string|int, mixed> $messages = []

ID numbers of messages in this topic.

$posters

private array<string|int, mixed> $posters = []

ID numbers of the authors of the $messages.

$virtual_msg

private int $virtual_msg

Requested message in $_REQUEST['start']. Might or might not be set.

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.

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
bool

canShowDebuggingInfo()

Determines whether debugging info should be shown.

public canShowDebuggingInfo() : bool
Return values
bool

canShowInMaintenanceMode()

Determines whether this action allows access in maintenance mode.

public canShowInMaintenanceMode() : bool
Return values
bool

True if access is allowed, false otherwise.

execute()

Does the heavy lifting to show the posts in this topic.

public execute() : void
  • Handles any redirects we might need to do.
  • Loads topic info.
  • Loads permissions.
  • Prepares stuff for the templates.
  • Sets up anti-spam verification and old topic warnings.
  • Gets the list of users viewing the topic.
  • Loads events and polls attached to the topic.
  • Loads IDs of the posts and posters.
  • Initializes the generator for displaying single posts.
  • Marks posts, topics, and boards as read (if they should be).
  • Loads the editor and builds the button arrays.

isAgreementAction()

Determines whether this action can be accessed without accepting the registration agreement and privacy policy.

public isAgreementAction() : bool
Return values
bool

isRestrictedGuestAccessAllowed()

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
bool

load()

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

prepareDisplayContext()

Callback for the message display.

public prepareDisplayContext() : array<string|int, mixed>|bool

This function internally relies on Msg::get(). Therefore, in order for this function to return any data, you must first initialize the Msg::$getter generator like this: Msg::$getter = Msg::get($message_ids);

Return values
array<string|int, mixed>|bool

Contextual data for a post, or false on failure.

__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()

Builds the user and moderator button arrays.

protected buildButtons() : void

checkMovedMergedRedirect()

Is this a moved or merged topic that we are redirecting to?

protected checkMovedMergedRedirect() : void

checkPrevNextRedirect()

Redirect to the previous or next topic, if requested in the URL params.

protected checkPrevNextRedirect() : void

getMessagesAndPosters()

Populates $this->messages and $this->posters with IDs of each post and poster in this topic.

protected getMessagesAndPosters() : void

getNotificationMode()

Get notification preferences and mode.

protected getNotificationMode() : void

getWhoViewing()

Let's get nosey, who is viewing this topic?

protected getWhoViewing() : void

incrementNumViews()

Add 1 to the number of views of this topic (except for robots).

protected incrementNumViews() : void

initDisplayContext()

Initializes Msg::get() and loads attachments and likes.

protected initDisplayContext() : void

loadEditor()

Loads the editor for the quick reply.

protected loadEditor() : void

loadEvents()

Loads info about any calendar events that are linked to this topic.

protected loadEvents() : void

loadPoll()

Loads the poll linked to this topic, if applicable.

protected loadPoll() : void

markRead()

protected markRead() : 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 topic display.

protected preventPrefetch() : void

setModerators()

Prepares contextual info about the moderators of this board.

protected setModerators() : void

setOldTopicWarning()

Warn the user against replying to old topics.

protected setOldTopicWarning() : void

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

setStart()

If $_REQUEST['start'] is not a number, figures out the correct numerical value and sets $_REQUEST['start'] to that value.

protected setStart() : void

setUnapprovedPostsMessage()

Sets the unapproved posts message.

protected setUnapprovedPostsMessage() : void

setupTemplate()

Loads the template and sets some related contextual info.

protected setupTemplate() : void

setupVerification()

Sets up anti-spam verification stuff, if needed.

protected setupVerification() : void

        
On this page

Search results