PHP Class Habari\Comments

Inheritance: extends ArrayObject
Exibir arquivo Open project: habari/system Class Usage Examples

Public Methods

Method Description
__get ( string $name ) : mixed Implements custom object properties
by_email ( string $email = '' ) : array selects all comments from a given email address
by_ip ( string $ip = '' ) : array selects all comments from a given IP address
by_name ( string $name = '' ) : array selects all comments from a given name
by_post_id ( integer $post_id ) : array Returns all comments for a supplied post ID
by_slug ( string $slug = '' ) : array select all comments for a given post slug
by_status ( integer $status ) : array select all comments of a given status
by_url ( string $url = '' ) : array select all comments from an author's URL
count_by_author ( integer $id, integer | string $status = 'approved' ) : integer returns the number of comments attached to posts by the specified author
count_by_email ( string $email = '', integer | string $status = 'approved' ) : integer returns the number of comments attributed ot the specified email
count_by_id ( integer $id, integer | string $status = 'approved' ) : integer returns the number of comments attached to the specified post
count_by_ip ( string $ip = '', integer | string $status = 'approved' ) : integer returns the number of comments from the specified IP address
count_by_name ( string $name = '', integer | string $status = 'approved' ) : integer returns the number of comments attributed to the specified name
count_by_slug ( string $slug = '', integer | string $status = 'approved' ) : integer returns the number of comments attached to the specified post
count_by_url ( string $url = '', integer | string $status = 'approved' ) : integer returns the number of comments attributed to the specified URL
count_total ( integer | string $status = 'approved', integer | string $type = 'comment' ) : integer returns the number of comments based on the specified status and type
delete ( ) function delete Deletes all comments in this object
delete_by_status ( integer | string $status ) delete all the comments and commentinfo for comments with this status
delete_these ( $comments ) : boolean Deletes comments from the database
filter ( Callable | array $filter ) : Comments Filter Comments using a callback function
get ( array $paramarray = [] ) : array function get Returns requested comments
moderate_these ( array | Comments $comments, integer | string $status = null ) : boolean Changes the status of comments
only ( string $field, mixed $index ) : array Returns all of the comments from the current Comments object having the specified index for the specified field $tb = $comments->only( 'trackbacks' )
search_to_get ( string $search_string ) : array Parses a search string for status, type, author, and tag keywords. Returns an associative array which can be passed to Comments::get(). If multiple authors, statuses, or types are specified, we assume an implicit OR such that (e.g.) any author that matches would be returned.

Method Details

__get() public method

Implements custom object properties
public __get ( string $name ) : mixed
$name string Name of property to return
return mixed The requested field value

by_email() public static method

selects all comments from a given email address
public static by_email ( string $email = '' ) : array
$email string an email address
return array an array of Comment objects written by that email address

by_ip() public static method

selects all comments from a given IP address
public static by_ip ( string $ip = '' ) : array
$ip string an IP address
return array an array of Comment objects written from the given IP

by_name() public static method

selects all comments from a given name
public static by_name ( string $name = '' ) : array
$name string a name
return array an array of Comment objects written by the given name

by_post_id() public static method

Returns all comments for a supplied post ID
public static by_post_id ( integer $post_id ) : array
$post_id integer The id of a post
return array an array of Comment objects for the given post

by_slug() public static method

select all comments for a given post slug
public static by_slug ( string $slug = '' ) : array
$slug string a post slug
return array array an array of Comment objects for the given post

by_status() public static method

select all comments of a given status
public static by_status ( integer $status ) : array
$status integer a status value
return array an array of Comment objects with the same status

by_url() public static method

select all comments from an author's URL
public static by_url ( string $url = '' ) : array
$url string a URL
return array array an array of Comment objects with the same URL

count_by_author() public static method

returns the number of comments attached to posts by the specified author
public static count_by_author ( integer $id, integer | string $status = 'approved' ) : integer
$id integer a user ID
$status integer | string A comment status value, or false to not filter on status(default: 'approved')
return integer a count of the comments attached to the specified post

count_by_email() public static method

returns the number of comments attributed ot the specified email
public static count_by_email ( string $email = '', integer | string $status = 'approved' ) : integer
$email string an email address
$status integer | string A comment status value, or false to not filter on status (default: 'approved')
return integer a count of the comments from the specified email

count_by_id() public static method

returns the number of comments attached to the specified post
public static count_by_id ( integer $id, integer | string $status = 'approved' ) : integer
$id integer a post ID
$status integer | string A comment status value, or false to not filter on status(default: 'approved')
return integer a count of the comments attached to the specified post

count_by_ip() public static method

returns the number of comments from the specified IP address
public static count_by_ip ( string $ip = '', integer | string $status = 'approved' ) : integer
$ip string an IP address
$status integer | string A comment status value, or false to not filter on status (default: 'approved')
return integer a count of the comments from the specified IP address

count_by_name() public static method

returns the number of comments attributed to the specified name
public static count_by_name ( string $name = '', integer | string $status = 'approved' ) : integer
$name string a commenter's name
$status integer | string A comment status value, or false to not filter on status (default: 'approved')
return integer a count of the comments from the specified name

count_by_slug() public static method

returns the number of comments attached to the specified post
public static count_by_slug ( string $slug = '', integer | string $status = 'approved' ) : integer
$slug string a post slug
$status integer | string A comment status value, or false to not filter on status (default: 'approved')
return integer a count of the comments attached to the specified post

count_by_url() public static method

returns the number of comments attributed to the specified URL
public static count_by_url ( string $url = '', integer | string $status = 'approved' ) : integer
$url string a URL
$status integer | string a comment status value, or false to not filter on status (default: 'approved')
return integer a count of the comments from the specified URL

count_total() public static method

returns the number of comments based on the specified status and type
public static count_total ( integer | string $status = 'approved', integer | string $type = 'comment' ) : integer
$status integer | string A comment status value, or false to not filter on status (default: 'approved')
$type integer | string A comment type value, or false to not filter on type (default: 'comment')
return integer a count of the comments based on the specified status and type

delete() public method

function delete Deletes all comments in this object
public delete ( )

delete_by_status() public static method

delete all the comments and commentinfo for comments with this status
public static delete_by_status ( integer | string $status )
$status integer | string a comment status ID or name

delete_these() public static method

Deletes comments from the database
public static delete_these ( $comments ) : boolean
return boolean True on success, false on failure

filter() public method

Filter Comments using a callback function
public filter ( Callable | array $filter ) : Comments
$filter Callable | array A callback function that returns true if the item passed in should be kept
return Comments The filtered comments

get() public static method

function get Returns requested comments
public static get ( array $paramarray = [] ) : array
$paramarray array An associated array of parameters, or a querystring
return array An array of Comment objects, one for each query result $comments = comments::get( array ( "author" => "skippy" ) ); $comments = comments::get( array ( "slug" => "first-post", "status" => "1", "orderby" => "date ASC" ) );

moderate_these() public static method

Changes the status of comments
public static moderate_these ( array | Comments $comments, integer | string $status = null ) : boolean
$comments array | Comments Comments to be moderated
$status integer | string The new status for the provided array of comments, "unapproved" if not provided
return boolean True if all the comments were successfully changed

only() public method

Returns all of the comments from the current Comments object having the specified index for the specified field $tb = $comments->only( 'trackbacks' )
public only ( string $field, mixed $index ) : array
$field string The field on the comment that is being filtered
$index mixed The value of the field that qualifies a comment
return array an array of Comment objects of the specified type

search_to_get() public static method

Parses a search string for status, type, author, and tag keywords. Returns an associative array which can be passed to Comments::get(). If multiple authors, statuses, or types are specified, we assume an implicit OR such that (e.g.) any author that matches would be returned.
public static search_to_get ( string $search_string ) : array
$search_string string The search string
return array An associative array which can be passed to Comments::get()