PHP Class PromotedContentModule, vanilla

- Posted by a certain role - Reached bestof status - Latest from a certain category
Since: 2.0.17.9
Author: Tim Gunter ([email protected])
Inheritance: extends Gdn_Module
Mostra file Open project: vanilla/vanilla Class Usage Examples

Public Properties

Property Type Description
$BodyLimit How many chars of Body to return.
$ContentType What type of content to fetch. One of: all, discussions, comments.
$Expiry How long do we cache in seconds.
$Group How often should we encapsulate content in groups. Groups of: n.
$Limit How much content should be fetched.
$Properties Whitelist of accepted parameters.
$Selection Parameters for the selector method.
$Selector How should we choose the content? - role Author's Role - rank Author's Rank - category Content's Category - score Content's Score - promoted
$TitleLimit How many chars of Title to return.

Public Methods

Method Description
__construct ( )
assetTarget ( ) : string Default asset target for this module.
getData ( ) Get data based on class properties.
load ( array $Parameters = [] ) Set class properties.
showComments ( ) : boolean Whether to display promoted comments.
showDiscussions ( ) : boolean Whether to display promoted discussions.
toString ( ) : string Render.
validate ( array $Parameters = [] ) : string | true Validate data to be used as class properties.

Protected Methods

Method Description
condense ( array &$Content, array $Limit ) Condense an interleaved content list down to the required size
joinCategory ( array &$Comments ) Attach CategoryID to Comments
processContent ( Array &$content ) Pre-process content into a uniform format for output
security ( array &$Content ) Strip out content that this user is not allowed to see
securityFilter ( $ContentItem ) : boolean Determine if we have permission to view this content.
selectByCategory ( array | integer $Parameters ) : array | false Select content based on its CategoryID.
selectByPromoted ( array $Parameters ) : array | false Selected content that passed the Promoted threshold.
selectByRank ( array | integer $Parameters ) : array | false Select content based on author RankID.
selectByRole ( array | integer $Parameters ) : array | false Select content based on author RoleID.
selectByScore ( array | integer $Parameters ) : array | false Select content based on its Score.
union ( string $Field, array $Sections ) : array Interleave two or more result arrays by a common field

Method Details

__construct() public method

public __construct ( )

assetTarget() public method

Default asset target for this module.
public assetTarget ( ) : string
return string

condense() protected method

Condense an interleaved content list down to the required size
protected condense ( array &$Content, array $Limit )
$Content array
$Limit array

getData() public method

Get data based on class properties.
public getData ( )

joinCategory() protected method

Attach CategoryID to Comments
protected joinCategory ( array &$Comments )
$Comments array

load() public method

Set class properties.
public load ( array $Parameters = [] )
$Parameters array Use lowercase key names that map to class properties.

processContent() protected method

Pre-process content into a uniform format for output
protected processContent ( Array &$content )
$content Array By reference

security() protected method

Strip out content that this user is not allowed to see
protected security ( array &$Content )
$Content array Content array, by reference

securityFilter() protected method

Determine if we have permission to view this content.
protected securityFilter ( $ContentItem ) : boolean
$ContentItem
return boolean

selectByCategory() protected method

Select content based on its CategoryID.
protected selectByCategory ( array | integer $Parameters ) : array | false
$Parameters array | integer
return array | false

selectByPromoted() protected method

This uses the Reactions caching system & options.
protected selectByPromoted ( array $Parameters ) : array | false
$Parameters array Not used.
return array | false $Content

selectByRank() protected method

Select content based on author RankID.
protected selectByRank ( array | integer $Parameters ) : array | false
$Parameters array | integer
return array | false

selectByRole() protected method

Select content based on author RoleID.
protected selectByRole ( array | integer $Parameters ) : array | false
$Parameters array | integer
return array | false

selectByScore() protected method

Select content based on its Score.
protected selectByScore ( array | integer $Parameters ) : array | false
$Parameters array | integer
return array | false

showComments() public method

Whether to display promoted comments.
public showComments ( ) : boolean
return boolean

showDiscussions() public method

Whether to display promoted discussions.
public showDiscussions ( ) : boolean
return boolean

toString() public method

Render.
public toString ( ) : string
return string

union() protected method

Interleave two or more result arrays by a common field
protected union ( string $Field, array $Sections ) : array
$Field string
$Sections array Array of result arrays
return array

validate() public method

Validate data to be used as class properties.
public validate ( array $Parameters = [] ) : string | true
$Parameters array .
return string | true True on success or string (message) on error.

Property Details

$BodyLimit public_oe property

How many chars of Body to return.
public $BodyLimit

$ContentType public_oe property

What type of content to fetch. One of: all, discussions, comments.
public $ContentType

$Expiry public_oe property

How long do we cache in seconds.
public $Expiry

$Group public_oe property

How often should we encapsulate content in groups. Groups of: n.
public $Group

$Limit public_oe property

How much content should be fetched.
public $Limit

$Properties public_oe property

Whitelist of accepted parameters.
public $Properties

$Selection public_oe property

Parameters for the selector method.
public $Selection

$Selector public_oe property

How should we choose the content? - role Author's Role - rank Author's Rank - category Content's Category - score Content's Score - promoted
public $Selector

$TitleLimit public_oe property

How many chars of Title to return.
public $TitleLimit