commentHandler Class Reference

List of all members.

Public Member Functions

 commentHandler ($comments, $commentsOwner, $commentLevel, $editLevel)
 addComment ()
 editComment ()
 deleteComment ()
 cleanComments ($comments)
 replyto ($comments, $depth="", $commentlink, $newcommentid)
 numberOfComments ()
 countComments ($comments)
 getComment ($whatcomment, $comments)
 renderComments ()
 renderCommentsActual ($comments, &$listid, $commentlink="", $depth="")
 renderCommentsAdder ()
 renderCommentsDelete ()
 renderCommentEditor ()

Public Attributes

 $commentsOwner
 Who owns that which is being edited? Used to check commenting and editing allowance levels against.
 $commentLevel
 The access level for editing the comments.
 $editLevel
 The access level for editing the comments data.
 $comments
 The array containing blog data. Just let commentHandler handle this - black box stuff, no need to know what's inside ;).
 $thisPageURL
 This can be set by the user, in case thisPageURL() doesn't return enough information (such as sub-items in a blog entry or gallery items or...).
 $commentsChanged = false
 This starts false, and will be set to true if the comments have changed (edited, hidden/shown, added, removed...).
 $lastCommenter
 The person who made a comment (set if commentsChanged == true).
 $lastComment
 The last comment.
 $allowNesting = true
 Do we allow nesting the comments?


Detailed Description

Class to hangle recursive comments. Use instructions as follows:

$commenthandler = new commentHandler($yourCommentsArray, $yourCommentsOwner, $commentingAllowanceLevel, $editingAllowanceLevel); // This is where you input the comments data (to start it off, simply pass an empty array) $commenthandler->renderComments(); // Put this where you wish to show the actual comments $commenthandler->renderCommentsAdder(); // Put this where you wish to show the form for adding a new comment if ($commenthandler->commentsChanged) { // If the comments have changed... You don't actually have to check, but it's good for efficiency $yourCommentsArray = $commenthandler->comments; // Remember to save your comments again, commentHandler does not do that for you! file_put_contents($commentfilename, array_export($yourCommentsArray, "yourCommentsArray")); // Use for example array_export for saving it to file }

Definition at line 28 of file comment_handler.php.


Member Function Documentation

commentHandler::commentHandler ( comments,
commentsOwner,
commentLevel,
editLevel 
)

Constructor for the comments handler. Use the comments handler as described in the class documentation

Parameters:
comments Comments data array. If you have no array to begin with, simply pass an empty array.
commentsOwner String comtaining the user id of the parent data
commentLevel Integer containing an allowance level relative to commentsOwner for who is allowed to comment
editLevel Integer containing an allowance level relative to commentsOwner for who is allowed to edit the comments
Returns:
void

Definition at line 52 of file comment_handler.php.

References $commentLevel, $comments, $commentsOwner, $editLevel, addComment(), array_merge_n(), cleanComments(), commentLevel, deleteComment(), editComment(), editLevel, and thisPageURL().

Here is the call graph for this function:

commentHandler::addComment (  ) 

Internal function used for adding a new comment

Returns:
array The new comments data array, ready for merging

Definition at line 111 of file comment_handler.php.

References array_merge_2().

Referenced by commentHandler().

Here is the call graph for this function:

commentHandler::editComment (  ) 

Internal function used for editing an existing comment

Returns:
array The new comments data array, ready for merging

Definition at line 136 of file comment_handler.php.

References array_merge_2().

Referenced by commentHandler().

Here is the call graph for this function:

commentHandler::deleteComment (  ) 

Internal function used for deleting an existing comment

Returns:
array The new comments data array, ready for merging

Definition at line 163 of file comment_handler.php.

References array_merge_2().

Referenced by commentHandler().

Here is the call graph for this function:

commentHandler::cleanComments ( comments  ) 

Internal function used for cleaning up comments data

Parameters:
comments Uncleaned comments data array
Returns:
array Cleaned up comments data array

Definition at line 193 of file comment_handler.php.

References $comments.

Referenced by commentHandler().

commentHandler::replyto ( comments,
depth = "",
commentlink,
newcommentid 
)

Internal function used for creating the replyto targets

Definition at line 217 of file comment_handler.php.

References $comments, $i, and parse_profilelinks().

Referenced by renderCommentsAdder().

Here is the call graph for this function:

commentHandler::numberOfComments (  ) 

Function which returns the number of comments in the current instance

Returns:
int Number of comments

Definition at line 238 of file comment_handler.php.

References countComments().

Here is the call graph for this function:

commentHandler::countComments ( comments  ) 

Internal function used above for counting the comments (the numberOfComments function is a dummy function created to make the API a little prettier)

Parameters:
comments Input a comments data array
Returns:
int Number of comments in the comments data array

Definition at line 250 of file comment_handler.php.

References $comments.

Referenced by numberOfComments().

commentHandler::getComment ( whatcomment,
comments 
)

Internal function used to get a single comment's data

Parameters:
whatcomment Which comment do you want to grab?
comments A comments data structure to get the comment from
Returns:
array An array containing the single comment

Definition at line 273 of file comment_handler.php.

References $comments.

Referenced by renderCommentEditor().

commentHandler::renderComments (  ) 

renderComments renders the comments

Returns:
string The rendered comments

Definition at line 290 of file comment_handler.php.

References renderCommentsActual().

Here is the call graph for this function:

commentHandler::renderCommentsActual ( comments,
&$  listid,
commentlink = "",
depth = "" 
)

The actual comments rendering function. The renderComments function is a dummy function that makes the API a little more pleasant

Parameters:
$comments The comments data
$commentlink The link... Just pass "" to this - used internally for recursion
$depth How deep are we? Just pass "" to this - used internally for recursion
$listid The comment index. Pass a variable $listid = 0 to this - used internally for recursion, for javascript replyto links
Returns:
string The rendered comments

Definition at line 308 of file comment_handler.php.

References $comments, $i, commentLevel, editLevel, formatTime(), i18n(), parse_page_data(), parse_profilelinks(), renderCommentEditor(), renderCommentsDelete(), and thisPageURL().

Referenced by renderComments().

Here is the call graph for this function:

commentHandler::renderCommentsAdder (  ) 

commentHandler::renderCommentsDelete (  ) 

Internal function used for showing the inline comment deletion comfirmation dialog

Returns:
string The dialog

Definition at line 441 of file comment_handler.php.

References i18n(), renderQuestionBox(), and thisPageURL().

Referenced by renderCommentsActual().

Here is the call graph for this function:

commentHandler::renderCommentEditor (  ) 

Internal function used for showing the inline comment editing dialog

Returns:
string The dialog

Definition at line 460 of file comment_handler.php.

References $formatting_toolbar, getComment(), i18n(), and thisPageURL().

Referenced by renderCommentsActual().

Here is the call graph for this function:


Member Data Documentation

commentHandler::$commentsOwner

Who owns that which is being edited? Used to check commenting and editing allowance levels against.

Definition at line 30 of file comment_handler.php.

Referenced by commentHandler().

commentHandler::$commentLevel

The access level for editing the comments.

Definition at line 31 of file comment_handler.php.

Referenced by commentHandler().

commentHandler::$editLevel

The access level for editing the comments data.

Definition at line 32 of file comment_handler.php.

Referenced by commentHandler().

commentHandler::$comments

The array containing blog data. Just let commentHandler handle this - black box stuff, no need to know what's inside ;).

Definition at line 33 of file comment_handler.php.

Referenced by cleanComments(), commentHandler(), countComments(), getComment(), renderCommentsActual(), and replyto().

commentHandler::$thisPageURL

This can be set by the user, in case thisPageURL() doesn't return enough information (such as sub-items in a blog entry or gallery items or...).

Definition at line 34 of file comment_handler.php.

commentHandler::$commentsChanged = false

This starts false, and will be set to true if the comments have changed (edited, hidden/shown, added, removed...).

Definition at line 36 of file comment_handler.php.

commentHandler::$lastCommenter

The person who made a comment (set if commentsChanged == true).

Definition at line 37 of file comment_handler.php.

commentHandler::$lastComment

The last comment.

Definition at line 38 of file comment_handler.php.

commentHandler::$allowNesting = true

Do we allow nesting the comments?

Definition at line 40 of file comment_handler.php.


The documentation for this class was generated from the following file:

Generated on Sun Oct 26 20:33:14 2008 for The Travelsized Content Management System by  doxygen 1.5.5