PHP Class CommentArray, ProcessWire

Maintains an array of multiple Comment instances. Serves as the value referenced when a FieldtypeComment field is reference from a Page. ProcessWire 2.x Copyright (C) 2015 by Ryan Cramer This file licensed under Mozilla Public License v2.0 http://mozilla.org/MPL/2.0/ https://processwire.com
Inheritance: extends PaginatedArray, implements WirePaginatable
Afficher le fichier Open project: ryancramerdesign/ProcessWire Class Usage Examples

Protected Properties

Свойство Type Description
$field Field object associated with this CommentArray
$numLimit integer May vary from count() when on the last page of a result set. As a result, paging routines should refer to their own itemsPerPage rather than count(). Applicable for paginated result sets. This number is not enforced for adding items to this CommentArray.
$numStart integer If this CommentArray is a partial representation of a larger set, this will contain the starting result number if previous results preceded it.
$numTotal integer Total number of comments, including those here and others that aren't, but may be here in pagination.
$page Page that owns these comments, required to use the renderForm() or getCommentForm() methods.

Méthodes publiques

Méthode Description
getCommentForm ( array $options = [] ) : CommentForm Return instance of CommentForm object
getCommentList ( array $options = [] ) Return instance of CommentList object
getField ( ) Get the Field that these comments are on
getLimit ( ) : integer Get the imposed limit on number of comments.
getPage ( ) Get the page that these comments are on
getTotal ( ) : integer Get the total number of comments
isIdentical ( WireArray $items, boolean | integer $strict = true ) : boolean Is the given CommentArray identical to this one?
isValidItem ( $item ) Per the WireArray interface, is the item a Comment
makeNew ( )
render ( array $options = [] ) : string Provides the default rendering of a comment list, which may or may not be what you want
renderAll ( array $options = [] ) : string Render all comments and a comments form below it
renderForm ( array $options = [] ) : string Provides the default rendering of a comment form, which may or may not be what you want
renderStars ( boolean $showCount = false, array $options = [] ) : string Render combined star rating for all comments in this CommentsArray
setField ( Field $field ) Set the Field that these comments are on
setPage ( Page $page ) Set the page that these comments are on
stars ( boolean $allowPartial = true, boolean $getCount = false ) : integer | float | false | array Get an average of all star ratings for all comments in this CommentsArray

Method Details

getCommentForm() public méthode

Return instance of CommentForm object
public getCommentForm ( array $options = [] ) : CommentForm
$options array
Résultat CommentForm

getCommentList() public méthode

Return instance of CommentList object
public getCommentList ( array $options = [] )
$options array

getField() public méthode

Get the Field that these comments are on
public getField ( )

getLimit() public méthode

If no limit set, then return number of comments currently here. Used for pagination.
public getLimit ( ) : integer
Résultat integer

getPage() public méthode

Get the page that these comments are on
public getPage ( )

getTotal() public méthode

Used for pagination.
public getTotal ( ) : integer
Résultat integer

isIdentical() public méthode

Is the given CommentArray identical to this one?
public isIdentical ( WireArray $items, boolean | integer $strict = true ) : boolean
$items WireArray
$strict boolean | integer
Résultat boolean

isValidItem() public méthode

Per the WireArray interface, is the item a Comment
public isValidItem ( $item )

makeNew() public méthode

public makeNew ( )

render() public méthode

Provides the default rendering of a comment list, which may or may not be what you want
See also: CommentList class and override it to serve your needs
public render ( array $options = [] ) : string
$options array
Résultat string

renderAll() public méthode

Render all comments and a comments form below it
public renderAll ( array $options = [] ) : string
$options array
Résultat string

renderForm() public méthode

Provides the default rendering of a comment form, which may or may not be what you want
See also: CommentForm class and override it to serve your needs
public renderForm ( array $options = [] ) : string
$options array
Résultat string

renderStars() public méthode

Render combined star rating for all comments in this CommentsArray
public renderStars ( boolean $showCount = false, array $options = [] ) : string
$showCount boolean Specify true to include how many ratings the average is based on
$options array Overrides of stars and/or count, see $defaults in method
Résultat string

setField() public méthode

Set the Field that these comments are on
public setField ( Field $field )
$field Field

setPage() public méthode

Set the page that these comments are on
public setPage ( Page $page )
$page Page

stars() public méthode

Get an average of all star ratings for all comments in this CommentsArray
public stars ( boolean $allowPartial = true, boolean $getCount = false ) : integer | float | false | array
$allowPartial boolean Allow partial stars? If true, returns a float. If false, returns int.
$getCount boolean If true, this method returns an array(stars, count) where count is number of ratings.
Résultat integer | float | false | array Returns false for stars value if no ratings yet.

Property Details

$field protected_oe property

Field object associated with this CommentArray
protected $field

$numLimit protected_oe property

May vary from count() when on the last page of a result set. As a result, paging routines should refer to their own itemsPerPage rather than count(). Applicable for paginated result sets. This number is not enforced for adding items to this CommentArray.
protected int $numLimit
Résultat integer

$numStart protected_oe property

If this CommentArray is a partial representation of a larger set, this will contain the starting result number if previous results preceded it.
protected int $numStart
Résultat integer

$numTotal protected_oe property

Total number of comments, including those here and others that aren't, but may be here in pagination.
protected int $numTotal
Résultat integer

$page protected_oe property

Page that owns these comments, required to use the renderForm() or getCommentForm() methods.
protected $page