PHP Class Habari\Comment

Includes an instance of the CommentInfo class; for holding inforecords about the comment If the Comment object describes an existing user; use the internal info object to get, set, unset and test for existence (isset) of info records $this->info = new CommentInfo ( 1 ); // Info records of comment with id = 1 $this->info->browser_ua= "Netscape 2.0"; // set info record with name "browser_ua" to value "Netscape 2.0" $info_value= $this->info->browser_ua; // get value of info record with name "browser_ua" into variable $info_value if ( isset ($this->info->browser_ua) ) // test for existence of "browser_ua" unset ( $this->info->browser_ua ); // delete "browser_ua" info record
Inheritance: extends QueryRecord, implements IsContent
Exibir arquivo Open project: habari/system Class Usage Examples

Public Properties

Property Type Description
$comment_status_actions
$comment_status_list static variables to hold comment status and comment type values
$comment_type_list

Public Methods

Method Description
__construct ( array $paramarray = [] ) Constructor for the Comment class.
__get ( string $name ) : mixed Overrides QueryRecord __get to implement custom object properties
__isset ( string $name ) : boolean Overrides QueryRecord __isset to implement custom object properties
__set ( string $name, mixed $value ) : mixed Overrides QueryRecord __set to implement custom object properties
__static ( ) Register plugin hooks
add_status ( string $status, boolean $internal = false ) : integer Register a new comment status
add_type ( string $type ) : integer Register a new comment type
content_type ( ) : string Return the content type of this object
create ( array $paramarray ) : Comment Creates a comment and saves it
css_class ( string | array $append = [] ) : string Returns a list of CSS classes for the comment
default_fields ( ) : array Returns the defined database columns for a comment
delete ( ) : boolean Deletes this comment
filter_comment_status_display_4 ( string $status ) : string How to display the built-in comment statuses.
filter_comment_type_display_4 ( string $type, string $foruse ) : string How to display the built-in comment types.
get ( integer $id ) : array static function get Returns a single comment, by ID
get_access ( User $user = null ) : Bitmask Returns an access Bitmask for the given user on this comment. Read access is determined by the associated post. Update/delete is determined by the comment management tokens.
insert ( ) : integer | boolean Saves a new comment to the comments table
list_comment_statuses ( boolean $refresh = false ) : array Obtain an associative array of comment statuses
list_comment_types ( boolean $refresh = false ) : array Obtain an associative array of comment types
remove_status ( integer | string $status, null | integer | string $newstatus = null ) Remove a comment type from the database
remove_type ( integer | string $type, boolean $delete = false ) Remove a comment type from the database
status ( string | integer $name ) : integer | boolean Obtain the integer value of the specified comment status, or false
status_action ( integer | string $status ) : string Obtain the action name of the comment status
status_name ( integer | string $status ) : string Obtain the friendly name of a comment status
type ( integer | string $name ) : mixed Obtain the integer value of the specified comment type, or false
type_name ( $type ) : string Obtain the friendly name of a comment type, or null
update ( ) : boolean Updates an existing comment in the comments table

Private Methods

Method Description
get_editlink ( ) : string Returns a URL for the ->editlink property of this class.
get_info ( ) : CommentInfo Gets the info object for this comment, which contains data from the commentinfo table related to this comment.
get_post ( boolean $use_cache = true ) : Post Obtain the Post object for the post of this comment

Method Details

__construct() public method

Constructor for the Comment class.
public __construct ( array $paramarray = [] )
$paramarray array an associative array of initial Post field values.

__get() public method

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

__isset() public method

Overrides QueryRecord __isset to implement custom object properties
public __isset ( string $name ) : boolean
$name string Name of property to return
return boolean true if var is set and not NULL, false otherwise

__set() public method

Overrides QueryRecord __set to implement custom object properties
public __set ( string $name, mixed $value ) : mixed
$name string Name of property to set
$value mixed Value of the property
return mixed The set field value

__static() public static method

Register plugin hooks
public static __static ( )

add_status() public static method

Register a new comment status
public static add_status ( string $status, boolean $internal = false ) : integer
$status string The name of the new comment status
$internal boolean True if the status is one that was added by core
return integer The id of the new comment type

add_type() public static method

Register a new comment type
public static add_type ( string $type ) : integer
$type string The name of the new comment type
return integer The id of the new comment type

content_type() public method

Return the content type of this object
See also: IsContent
public content_type ( ) : string
return string The content type of this object

create() static public method

Creates a comment and saves it
static public create ( array $paramarray ) : Comment
$paramarray array An associative array of comment fields $return Comment The comment object that was created
return Comment The new comment

css_class() public method

Returns a list of CSS classes for the comment
public css_class ( string | array $append = [] ) : string
$append string | array Additional classes that should be added to the ones generated
return string The resultant classes

default_fields() public static method

Returns the defined database columns for a comment
public static default_fields ( ) : array
return array The requested array

delete() public method

Deletes this comment
public delete ( ) : boolean
return boolean True on success, false if not

filter_comment_status_display_4() public static method

How to display the built-in comment statuses.
public static filter_comment_status_display_4 ( string $status ) : string
$status string The name of the status we want to translate
return string The translated status name. This is always lowercase. It is up to the caller to uppercase it.

filter_comment_type_display_4() public static method

How to display the built-in comment types.
public static filter_comment_type_display_4 ( string $type, string $foruse ) : string
$type string The type of comment
$foruse string Can be 'singular' or 'plural'
return string The translated type name. This is always lowercase. It is up to the caller to uppercase it

get() static public method

$post = Post::get( 10 );
static public get ( integer $id ) : array
$id integer An ID
return array A single Comment object

get_access() public method

Returns an access Bitmask for the given user on this comment. Read access is determined by the associated post. Update/delete is determined by the comment management tokens.
public get_access ( User $user = null ) : Bitmask
$user User The user mask to fetch
return Bitmask

insert() public method

Saves a new comment to the comments table
public insert ( ) : integer | boolean
return integer | boolean The inserted record id on success, false if not

list_comment_statuses() public static method

Obtain an associative array of comment statuses
public static list_comment_statuses ( boolean $refresh = false ) : array
$refresh boolean Whether to force a refresh of the cached values
return array An array mapping comment statuses names to interger values

list_comment_types() public static method

Obtain an associative array of comment types
public static list_comment_types ( boolean $refresh = false ) : array
$refresh boolean Whether to force a refresh of the cached values
return array An array mapping comment type names to integer values

remove_status() public static method

Remove a comment type from the database
public static remove_status ( integer | string $status, null | integer | string $newstatus = null )
$status integer | string The type of the comment
$newstatus null | integer | string If provided, the new status to change all of the comments with the deleted status to

remove_type() public static method

Remove a comment type from the database
public static remove_type ( integer | string $type, boolean $delete = false )
$type integer | string The type of the comment
$delete boolean If true, delete the type and all comments of that type instead of deactivating it

status() public static method

Obtain the integer value of the specified comment status, or false
public static status ( string | integer $name ) : integer | boolean
$name string | integer A comment status name or value
return integer | boolean The valid integer status value or false if there was no match

status_action() public static method

Obtain the action name of the comment status
public static status_action ( integer | string $status ) : string
$status integer | string A comment status value, or name
return string A string of the status action, or null

status_name() public static method

Obtain the friendly name of a comment status
public static status_name ( integer | string $status ) : string
$status integer | string A comment status value or name
return string The status name, or null

type() public static method

Obtain the integer value of the specified comment type, or false
public static type ( integer | string $name ) : mixed
$name integer | string a comment type name or number
return mixed an integer or boolean false

type_name() public static method

Obtain the friendly name of a comment type, or null
public static type_name ( $type ) : string
return string A string of the comment type, or emptystring

update() public method

Updates an existing comment in the comments table
public update ( ) : boolean
return boolean True on success, false if not

Property Details

$comment_status_actions static_oe public_oe property

static public $comment_status_actions

$comment_status_list static_oe public_oe property

static variables to hold comment status and comment type values
static public $comment_status_list

$comment_type_list static_oe public_oe property

static public $comment_type_list