ImComment

Kind: global class
Summary: Manage the comment structure of a topic. It can load and save the comments from/to a file or a database.
To use it, you must include x5engine.php in your code.

This class is available only in the Professional, Evolution and Compact editions.

new ImComment()

Build a new ImComment object.

.loadFromXML($file) ⇒ Void

Load the comments from an xml file

Kind: instance method of ImComment

Param Type Description
$file String The source file path

~~.loadFromOldFile($file) ⇒ Void~~

Deprecated

Get the comments from a v8 comments file.
Use loadFromXML instead

Kind: instance method of ImComment
See: loadFromXML

Param Type Description
$file String The source file path

.saveToXML($file) ⇒ Boolean

Save the comments in a xml file

Kind: instance method of ImComment
Returns: Boolean - True if the file was saved correctly

Param Type Description
$file String The destination file path

.saveToDb($host, $user, $password, $db, $table, $postid) ⇒ Boolean

Save the comments in a DB.
Available only in the Professional Edition

Kind: instance method of ImComment
Returns: Boolean - True if the comment was saved correctly

Param Type Description
$host String The host name
$user String The user name
$password String The user password
$db String The db name
$table String The db table
$postid String The post id

.loadFromDb($host, $user, $password, $db, $table, $postid) ⇒ Boolean

Load the comments from a DB. This method is available only in the Professional edition.

Kind: instance method of ImComment
Returns: Boolean - True if the data was loaded correctly. False instead.

Param Type Description
$host String The host name
$user String The user name
$password String The user password
$db String The db name
$table String The db table
$postid String The post id

.add($comment) ⇒ Void

Add a comment to a file

Kind: instance method of ImComment

Param Type Description
$comment Array the array of data to store

.sort($orderby, $sort) ⇒ Void

Sort the array

Kind: instance method of ImComment

Param Type Description
$orderby String Field to compare when ordering the array
$sort String Sort by ascending (asc) or descending (desc) order

.getAll($orderby, $sort, $approvedOnly) ⇒ Array

Get all the comments loaded in this class

Kind: instance method of ImComment
Returns: Array - An array of associative arrays containing the comments data

Param Type Description
$orderby String Field to compare when ordering the array
$sort String Sort by ascending (asc) or descending (desc) order
$approvedOnly Boolean Show only approved comments

.getPage($pageNumber, $commentsPerPage, $orderby, $sort, $approvedOnly) ⇒ Array

Get the comments in the specified page when there is the specified number of comments in every page.
This is useful for pagination.

Kind: instance method of ImComment
Returns: Array - The list of comments in the page

Param Type Description
$pageNumber Number The number of page to show (0 based)
$commentsPerPage Number Number of comments shown in each page
$orderby String Field to compare when ordering the array
$sort String Sort by ascending (asc) or descending (desc) order
$approvedOnly Boolean Show only approved comments

.get($n) ⇒ Array

Get the comment number n

Kind: instance method of ImComment
Returns: Array - The comment's data or an empty array if the comment is not found

Param Type Description
$n Number The comment's number

.getPagesNumber($commentsPerPage, $approvedOnly) ⇒ Number

Get the pages number given the number of comments per page

Kind: instance method of ImComment
Returns: Number - The number of pages

Param Type Description
$commentsPerPage Number Number of comments in every page
$approvedOnly Boolean Show only approved comments

.edit($n, $comment) ⇒ Boolean

Edit the comment number $n with the data contained in the parameter $comment

Kind: instance method of ImComment
Returns: Boolean - True if the comment was correctly edited. False instead.

Param Type Description
$n Number Comment number
$comment Array Comment data

.delete($n) ⇒ Void

Delete the comment at $n

Kind: instance method of ImComment

Param Type Description
$n Number The index of the comment

Clean the data from XSS

Kind: instance method of ImComment

Param Type Description
$str String The string to parse
$allow_links Boolean true to allow links

.lastError() ⇒ Number

Provide the last error

Kind: instance method of ImComment