From d8eeb2154d46b2979076302f0d920ecedeadd0fb Mon Sep 17 00:00:00 2001 From: ovclas Date: Wed, 20 Jun 2012 06:17:28 +0000 Subject: [PATCH] add phpDoc comment in comment module git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10783 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/comment/comment.admin.controller.php | 70 +++++--- modules/comment/comment.admin.view.php | 36 ++-- modules/comment/comment.class.php | 43 +++-- modules/comment/comment.controller.php | 179 ++++++++++++------- modules/comment/comment.item.php | 74 ++++++-- modules/comment/comment.model.php | 177 +++++++++++------- modules/comment/comment.view.php | 30 ++-- 7 files changed, 390 insertions(+), 219 deletions(-) diff --git a/modules/comment/comment.admin.controller.php b/modules/comment/comment.admin.controller.php index 067a00c7d..e53047040 100644 --- a/modules/comment/comment.admin.controller.php +++ b/modules/comment/comment.admin.controller.php @@ -1,21 +1,24 @@ module_srl = $module_srl; $output = executeQuery('comment.deleteModuleComments', $args); @@ -310,9 +328,10 @@ } /** - * @brief restore comment from trash module, called by trash module + * Restore comment from trash module, called by trash module * this method is passived - **/ + * @return object + */ function restoreTrash($originObject) { if(is_array($originObject)) $originObject = (object)$originObject; @@ -336,10 +355,11 @@ return $output; } - /** - * @brief empty comment in trash, called by trash module + /** + * Empty comment in trash, called by trash module * this method is passived - **/ + * @return object + */ function emptyTrash($originObject) { $originObject = unserialize($originObject); diff --git a/modules/comment/comment.admin.view.php b/modules/comment/comment.admin.view.php index 16d64b6bd..16c266f62 100644 --- a/modules/comment/comment.admin.view.php +++ b/modules/comment/comment.admin.view.php @@ -1,21 +1,24 @@ page = Context::get('page'); // /< Page @@ -61,9 +64,10 @@ $this->setTemplateFile('comment_list'); } - /** - * @brief show the blacklist of comments in the admin page - **/ + /** + * Show the blacklist of comments in the admin page + * @return void + */ function dispCommentAdminDeclared() { // option to get a blacklist $args->page = Context::get('page'); // /< Page diff --git a/modules/comment/comment.class.php b/modules/comment/comment.class.php index 6fa2ab9e7..7ad0a0737 100644 --- a/modules/comment/comment.class.php +++ b/modules/comment/comment.class.php @@ -1,17 +1,19 @@ updateVotedCount($comment_srl, $point); } - /** - * @brief action to handle recommendation votes on comments (Down) - **/ + /** + * Action to handle recommendation votes on comments (Down) + * @return Object + */ function procCommentVoteDown() { if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); @@ -57,9 +61,10 @@ return $this->updateVotedCount($comment_srl, $point); } - /** - * @brief action to be called when a comment posting is reported - **/ + /** + * Action to be called when a comment posting is reported + * @return void|Object + */ function procCommentDeclare() { if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request'); @@ -69,9 +74,10 @@ return $this->declaredComment($comment_srl); } - /** - * @brief trigger to delete its comments together with document deleted - **/ + /** + * Trigger to delete its comments together with document deleted + * @return Object + */ function triggerDeleteDocumentComments(&$obj) { $document_srl = $obj->document_srl; if(!$document_srl) return new Object(); @@ -79,9 +85,10 @@ return $this->deleteComments($document_srl, true); } - /** - * @brief trigger to delete corresponding comments when deleting a module - **/ + /** + * Trigger to delete corresponding comments when deleting a module + * @return object + */ function triggerDeleteModuleComments(&$obj) { $module_srl = $obj->module_srl; if(!$module_srl) return new Object(); @@ -90,18 +97,20 @@ return $oCommentController->deleteModuleComments($module_srl); } - /** - * @brief Authorization of the comments - * available only in the current connection of the session value - **/ + /** + * Authorization of the comments + * available only in the current connection of the session value + * @return void + */ function addGrant($comment_srl) { $_SESSION['own_comment'][$comment_srl] = true; } /** - *@brief Check if module is using comment validation system - * @param number $document_srl - * @return boolean + * Check if module is using comment validation system + * @param int $document_srl + * @param int $module_srl + * @return bool */ function isModuleUsingPublishValidation($document_srl=null, $module_srl=null) { @@ -116,9 +125,12 @@ return $use_validation; } - /** - * @brief Enter comments - **/ + /** + * Enter comments + * @param object $obj + * @param bool $manual_inserted + * @return object + */ function insertComment($obj, $manual_inserted = false) { // check if comment's module is using comment validation and set the publish status to 0 (false) @@ -314,9 +326,10 @@ } /** - * @brief Send email to module's admins after a new comment was interted successfully - * if Comments Approval System is used - * @param type $obj + * Send email to module's admins after a new comment was interted successfully + * if Comments Approval System is used + * @param object $obj + * @return void */ function sendEmailToAdminAfterInsertComment($obj) { @@ -434,9 +447,12 @@ } - /** - * @brief fix the comment - **/ + /** + * Fix the comment + * @param object $obj + * @param bool $is_admin + * @return object + */ function updateComment($obj, $is_admin = false) { $obj->__isupdate = true; // call a trigger (before) @@ -517,9 +533,13 @@ return $output; } - /** - * @brief Delete comment - **/ + /** + * Delete comment + * @param int $comment_srl + * @param bool $is_admin + * @param bool $isMoveToTrash + * @return object + */ function deleteComment($comment_srl, $is_admin = false, $isMoveToTrash = false) { // create the comment model object $oCommentModel = &getModel('comment'); @@ -588,8 +608,9 @@ } /** - * @brief remove all comment relation log - **/ + * Remove all comment relation log + * @return Object + */ function deleteCommentLog() { $this->_deleteDeclaredComments($args); @@ -597,9 +618,11 @@ return new Object(0, 'success'); } - /** - * @brief remove all comments of the article - **/ + /** + * Remove all comments of the article + * @param int $document_srl + * @return object + */ function deleteComments($document_srl) { // create the document model object $oDocumentModel = &getModel('document'); @@ -649,10 +672,10 @@ } /** - * @brief delete declared comment, log - * @param $commentSrls : srls string (ex: 1, 2,56, 88) + * delete declared comment, log + * @param array|string $commentSrls : srls string (ex: 1, 2,56, 88) * @return void - **/ + */ function _deleteDeclaredComments($commentSrls) { executeQuery('comment.deleteDeclaredComments', $commentSrls); @@ -660,18 +683,21 @@ } /** - * @brief delete voted comment log - * @param $commentSrls : srls string (ex: 1, 2,56, 88) + * delete voted comment log + * @param array|string $commentSrls : srls string (ex: 1, 2,56, 88) * @return void - **/ + */ function _deleteVotedComments($commentSrls) { executeQuery('comment.deleteCommentVotedLog', $commentSrls); } - /** - * @brief Increase vote-up counts of the comment - **/ + /** + * Increase vote-up counts of the comment + * @param int $comment_srl + * @param int $point + * @return Object + */ function updateVotedCount($comment_srl, $point = 1) { if($point > 0) { $failed_voted = 'failed_voted'; @@ -734,9 +760,11 @@ return new Object(0, $success_message); } - /** - * @brief report a blamed comment - **/ + /** + * Report a blamed comment + * @param $comment_srl + * @return void + */ function declaredComment($comment_srl) { // Fail if session information already has a reported document if($_SESSION['declared_comment'][$comment_srl]) return new Object(-1, 'failed_declared'); @@ -788,9 +816,14 @@ $this->setMessage('success_declared'); } - /** - * @brief method to add a pop-up menu when clicking for displaying child comments - **/ + /** + * Method to add a pop-up menu when clicking for displaying child comments + * @param string $url + * @param string $str + * @param strgin $icon + * @param strgin $target + * @return void + */ function addCommentPopupMenu($url, $str, $icon = '', $target = 'self') { $comment_popup_menu_list = Context::get('comment_popup_menu_list'); if(!is_array($comment_popup_menu_list)) $comment_popup_menu_list = array(); @@ -804,9 +837,10 @@ Context::set('comment_popup_menu_list', $comment_popup_menu_list); } - /** - * @brief save the comment extension form for each module - **/ + /** + * Save the comment extension form for each module + * @return void + */ function procCommentInsertModuleConfig() { $module_srl = Context::get('target_module_srl'); if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); @@ -839,6 +873,12 @@ } } + /** + * Comment module config setting + * @param int $srl + * @param object $comment_config + * @return Object + */ function setCommentModuleConfig($srl, $comment_config){ $oModuleController = &getController('module'); $oModuleController->insertModulePartConfig('comment',$srl,$comment_config); @@ -846,8 +886,9 @@ } /** - * @brief get comment all list - **/ + * Get comment all list + * @return void + */ function procCommentGetList() { if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php index a599d473a..d93dfcb25 100644 --- a/modules/comment/comment.item.php +++ b/modules/comment/comment.item.php @@ -1,15 +1,30 @@ comment_srl = $comment_srl; $this->columnList = $columnList; @@ -21,6 +36,10 @@ $this->_loadFromDB(); } + /** + * Load comment data from DB and set to commentItem object + * @return void + */ function _loadFromDB() { if(!$this->comment_srl) return; @@ -30,6 +49,10 @@ $this->setAttribute($output->data); } + /** + * Comment attribute set to Object object + * @return void + */ function setAttribute($attribute) { if(!$attribute->comment_srl) { $this->comment_srl = null; @@ -101,6 +124,10 @@ return $this->get('notify_message')=='Y' ? true : false; } + /** + * Notify to comment owner + * @return void + */ function notify($type, $content) { // return if not useNotify if(!$this->useNotify()) return; @@ -158,6 +185,10 @@ return htmlspecialchars($this->get('nick_name')); } + /** + * Return content with htmlspecialchars + * @return string + */ function getContentText($strlen = 0) { if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); @@ -168,6 +199,10 @@ return htmlspecialchars($content); } + /** + * Return content after filter + * @return string + */ function getContent($add_popup_menu = true, $add_content_info = true, $add_xe_content_class = true) { if($this->isSecret() && !$this->isAccessible()) return Context::getLang('msg_is_secret'); @@ -203,6 +238,10 @@ return $content; } + /** + * Return summary content + * @return string + */ function getSummary($str_size = 50, $tail = '...') { $content = $this->getContent(false, false); // for newline, insert a blank. @@ -279,9 +318,10 @@ return $file_list; } - /** - * @brief return the editor html - **/ + /** + * Return the editor html + * @return string + */ function getEditor() { $module_srl = $this->get('module_srl'); if(!$module_srl) $module_srl = Context::get('module_srl'); @@ -289,9 +329,10 @@ return $oEditorModel->getModuleEditor('comment', $module_srl, $this->comment_srl, 'comment_srl', 'content'); } - /** - * @brief return author's profile image - **/ + /** + * Return author's profile image + * @return object + */ function getProfileImage() { if(!$this->isExists() || !$this->get('member_srl')) return; $oMemberModel = &getModel('member'); @@ -301,9 +342,10 @@ return $profile_info->src; } - /** - * @brief return author's signiture - **/ + /** + * Return author's signiture + * @return string + */ function getSignature() { // pass if the posting not exists. if(!$this->isExists() || !$this->get('member_srl')) return; diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 579a7bd9d..6ad9e36b6 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -1,23 +1,25 @@ comment_srl = $comment_srl; $output = executeQuery('comment.getChildCommentCount', $args); return (int)$output->data->count; } - /** - * @brief get the comment - **/ + /** + * Get the comment + * @param int $comment_srl + * @param bool $is_admin + * @param array $columnList + * @return commentItem + */ function getComment($comment_srl=0, $is_admin = false, $columnList = array()) { $oComment = new commentItem($comment_srl, $columnList); if($is_admin) $oComment->setGrant(); @@ -112,9 +121,12 @@ return $oComment; } - /** - * @brief get the multiple comments(not paginating) - **/ + /** + * Get the comment list(not paginating) + * @param string|array $comment_srl_list + * @param array $columnList + * @return array + */ function getComments($comment_srl_list, $columnList = array()) { if(is_array($comment_srl_list)) $comment_srls = implode(',',$comment_srl_list); // fetch from a database @@ -138,9 +150,11 @@ return $result; } - /** - * @brief get the total number of comments in corresponding with document_srl. - **/ + /** + * Get the total number of comments in corresponding with document_srl. + * @param int $document_srl + * @return int + */ function getCommentCount($document_srl) { $args->document_srl = $document_srl; @@ -165,9 +179,12 @@ return (int)$total_count; } - /** - * @brief get the total number of comments in corresponding with document_srl. - **/ + /** + * Get the total number of comments in corresponding with document_srl. + * @param string $date + * @param array $moduleSrlList + * @return int + */ function getCommentCountByDate($date = '', $moduleSrlList = array()) { if($date) $args->regDate = date('Ymd', strtotime($date)); if(count($moduleSrlList)>0) $args->module_srl = $moduleSrlList; @@ -178,9 +195,12 @@ return $output->data->count; } - /** - * @brief get the total number of comments in corresponding with module_srl. - **/ + /** + * Get the total number of comments in corresponding with module_srl. + * @param int $module_srl + * @param bool $published + * @return int + */ function getCommentAllCount($module_srl,$published=null) { $args->module_srl = $module_srl; @@ -211,6 +231,10 @@ return (int)$total_count; } + /** + * Get the module info without duplication + * @return array + */ function getDistinctModules() { $output = executeQuery('comment.getDistinctModules'); @@ -228,10 +252,13 @@ return $result; } - /** - * @brief get the comment in corresponding with mid. - * TODO add commentItems to cache too - **/ + /** + * Get the comment in corresponding with mid. + * @todo add commentItems to cache too + * @param object $obj + * @param array $columnList + * @return array + */ function getNewestCommentList($obj, $columnList = array()) { if($obj->mid) { $oModuleModel = &getModel('module'); @@ -283,9 +310,14 @@ return $result; } - /** - * @brief get a comment list of the doc in corresponding woth document_srl. - **/ + /** + * Get a comment list of the doc in corresponding woth document_srl. + * @param int $document_srl + * @param int $page + * @param bool $is_admin + * @param int $count + * @return object + */ function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0) { if(!isset($document_srl)) return; // cache controll @@ -348,10 +380,13 @@ return $output; } - /** - * @brief update a list of comments in corresponding with document_srl - * take care of previously used data than GA version - **/ + /** + * Update a list of comments in corresponding with document_srl + * Take care of previously used data than GA version + * @param int $module_srl + * @param int $document_srl + * @return void + */ function fixCommentList($module_srl, $document_srl) { // create a lock file to prevent repeated work when performing a batch job $lock_file = "./files/cache/tmp/lock.".$document_srl; @@ -407,9 +442,14 @@ FileHandler::removeFile($lock_file); } - /** - * @brief relocate comments in the hierarchical structure - **/ + /** + * Relocate comments in the hierarchical structure + * @param array $comment_list + * @param array $list + * @param int $depth + * @param object $parent + * @return void + */ function _arrangeComment(&$comment_list, $list, $depth, $parent = null) { if(!count($list)) return; foreach($list as $key => $val) { @@ -430,9 +470,12 @@ } } - /** - * @brief get all the comments in time decending order(for administrators) - **/ + /** + * Get all the comments in time decending order(for administrators) + * @param object $obj + * @param array $columnList + * @return object + */ function getTotalCommentList($obj, $columnList = array()) { $query_id = 'comment.getTotalCommentList'; // Variables @@ -526,9 +569,11 @@ return $output; } - /** - * @brief get all the comment count in time decending order(for administrators) - **/ + /** + * Get all the comment count in time decending order(for administrators) + * @param object $obj + * @return int + */ function getTotalCommentCount($obj) { $query_id = 'comment.getTotalCommentCountByGroupStatus'; // Variables @@ -588,9 +633,11 @@ return $output->data; } - /** - * @brief return a configuration of comments for each module - **/ + /** + * Return a configuration of comments for each module + * @param int $module_srl + * @return object + */ function getCommentConfig($module_srl) { $oModuleModel = &getModel('module'); $comment_config = $oModuleModel->getModulePartConfig('comment', $module_srl); @@ -598,6 +645,10 @@ return $comment_config; } + /** + * Return a list of voting member + * @return void + */ function getCommentVotedMemberList() { $comment_srl = Context::get('comment_srl'); @@ -636,6 +687,10 @@ $this->add('voted_member_list',$output->data); } + /** + * Return a secret status by secret field + * @return array + */ function getSecretNameList() { global $lang; diff --git a/modules/comment/comment.view.php b/modules/comment/comment.view.php index 93f3fef20..14209d7a9 100644 --- a/modules/comment/comment.view.php +++ b/modules/comment/comment.view.php @@ -1,21 +1,25 @@