english comments added

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0_english@8278 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
mosmartin 2011-04-06 16:48:06 +00:00
parent 693e215bc1
commit 4d272994dd
219 changed files with 6407 additions and 8705 deletions

View file

@ -2,23 +2,22 @@
/**
* @class commentAdminController
* @author NHN (developers@xpressengine.com)
* @brief comment 모듈의 admin controller class
* @brief admin controller class of the comment module
**/
class commentAdminController extends comment {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 관리자 페이지에서 선택된 댓글들을 삭제
* @brief Delete the selected comment from the administrator page
**/
function procCommentAdminDeleteChecked() {
// 선택된 글이 없으면 오류 표시
// Error display if none is selected
$cart = Context::get('cart');
if(!$cart) return $this->stop('msg_cart_is_null');
$comment_srl_list= explode('|@|', $cart);
@ -28,8 +27,7 @@
$oCommentController = &getController('comment');
$deleted_count = 0;
// 글삭제
// Delete the comment posting
for($i=0;$i<$comment_count;$i++) {
$comment_srl = trim($comment_srl_list[$i]);
if(!$comment_srl) continue;
@ -44,7 +42,7 @@
}
/**
* @brief 신고대상을 취소 시킴
* @brief cancel the blacklist of abused comments reported by other users
**/
function procCommentAdminCancelDeclare() {
$comment_srl = trim(Context::get('comment_srl'));
@ -57,7 +55,7 @@
}
/**
* @brief 특정 모듈의 모든 댓글 삭제
* @brief delete all comments of the specific module
**/
function deleteModuleComments($module_srl) {
$args->module_srl = $module_srl;

View file

@ -2,59 +2,57 @@
/**
* @class commentAdminView
* @author NHN (developers@xpressengine.com)
* @brief comment 모듈의 admin view 클래스
* @brief admin view class of the comment module
**/
class commentAdminView extends comment {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 목록 출력 (관리자용)
* @brief Display the list(for administrators)
**/
function dispCommentAdminList() {
// 목록을 구하기 위한 옵션
$args->page = Context::get('page'); ///< 페이지
$args->list_count = 30; ///< 한페이지에 보여줄 글 수
$args->page_count = 10; ///< 페이지 네비게이션에 나타날 페이지의 수
// option to get a list
$args->page = Context::get('page'); // /< Page
$args->list_count = 30; // / the number of postings to appear on a single page
$args->page_count = 10; // / the number of pages to appear on the page navigation
$args->sort_index = 'list_order'; ///< 소팅 값
$args->sort_index = 'list_order'; // /< Sorting values
$args->module_srl = Context::get('module_srl');
// 목록 구함, comment->getCommentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다)
// get a list by using comment->getCommentList.
$oCommentModel = &getModel('comment');
$output = $oCommentModel->getTotalCommentList($args);
// 템플릿에 쓰기 위해서 comment_model::getTotalCommentList() 의 return object에 있는 값들을 세팅
// set values in the return object of comment_model:: getTotalCommentList() in order to use a template.
Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page);
Context::set('page', $output->page);
Context::set('comment_list', $output->data);
Context::set('page_navigation', $output->page_navigation);
// 템플릿 지정
// set the template
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('comment_list');
}
/**
* @brief 관리자 페이지의 신고 목록 보기
* @brief show the blacklist of comments in the admin page
**/
function dispCommentAdminDeclared() {
// 목록을 구하기 위한 옵션
$args->page = Context::get('page'); ///< 페이지
$args->list_count = 30; ///< 한페이지에 보여줄 글 수
$args->page_count = 10; ///< 페이지 네비게이션에 나타날 페이지의 수
// option to get a blacklist
$args->page = Context::get('page'); // /< Page
$args->list_count = 30; // /< the number of comment postings to appear on a single page
$args->page_count = 10; // /< the number of pages to appear on the page navigation
$args->sort_index = 'comment_declared.declared_count'; ///< 소팅 값
$args->order_type = 'desc'; ///< 소팅 정렬 값
$args->sort_index = 'comment_declared.declared_count'; // /< sorting values
$args->order_type = 'desc'; // /< sorted value
// 목록을 구함
// get a list
$declared_output = executeQuery('comment.getDeclaredList', $args);
if($declared_output->data && count($declared_output->data)) {
@ -68,14 +66,13 @@
$declared_output->data = $comment_list;
}
// 템플릿에 쓰기 위해서 comment_model::getCommentList() 의 return object에 있는 값들을 세팅
// set values in the return object of comment_model:: getCommentList() in order to use a template.
Context::set('total_count', $declared_output->total_count);
Context::set('total_page', $declared_output->total_page);
Context::set('page', $declared_output->page);
Context::set('comment_list', $declared_output->data);
Context::set('page_navigation', $declared_output->page_navigation);
// 템플릿 지정
// set the template
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('declared_list');
}

View file

@ -2,7 +2,7 @@
/**
* @class comment
* @author NHN (developers@xpressengine.com)
* @brief comment 모듈의 high class
* @brief comment module's high class
**/
require_once(_XE_PATH_.'modules/comment/comment.item.php');
@ -10,45 +10,37 @@
class comment extends ModuleObject {
/**
* @brief 설치시 추가 작업이 필요할시 구현
* @brief implemented if additional tasks are required when installing
**/
function moduleInstall() {
// action forward에 등록 (관리자 모드에서 사용하기 위함)
// register the action forward (for using on the admin mode)
$oModuleController = &getController('module');
// 2007. 10. 17 게시글이 삭제될때 댓글도 삭제되도록 trigger 등록
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
// 2007. 10. 17 모듈이 삭제될때 등록된 댓글도 모두 삭제하는 트리거 추가
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
// 2008. 02. 22 모듈의 추가 설정에서 댓글 추가 설정 추가
// 2008. 02. 22 add comment setting when a new module added
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
return new Object();
}
/**
* @brief 설치가 이상이 없는지 체크하는 method
* @brief method to check if installation is succeeded
**/
function checkUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
// 2007. 10. 17 게시글이 삭제될때 댓글도 삭제되도록 trigger 등록
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after')) return true;
// 2007. 10. 17 모듈이 삭제될때 등록된 댓글도 모두 삭제하는 트리거 추가
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after')) return true;
// 2007. 10. 23 댓글에도 추천/ 알림 기능을 위한 컬럼 추가
// 2007. 10. 23 add a column for recommendation votes or notification of the comments
if(!$oDB->isColumnExists("comments","voted_count")) return true;
if(!$oDB->isColumnExists("comments","notify_message")) return true;
// 2008. 02. 22 모듈의 추가 설정에서 댓글 추가 설정 추가
// 2008. 02. 22 add comment setting when a new module added
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) return true;
// 2008. 05. 14 blamed count 컬럼 추가
// 2008. 05. 14 add a column for blamed count
if(!$oDB->isColumnExists("comments", "blamed_count")) return true;
if(!$oDB->isColumnExists("comment_voted_log", "point")) return true;
@ -56,22 +48,19 @@
}
/**
* @brief 업데이트 실행
* @brief Execute update
**/
function moduleUpdate() {
$oDB = &DB::getInstance();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
// 2007. 10. 17 게시글이 삭제될때 댓글도 삭제되도록 trigger 등록
// 2007. 10. 17 add a trigger to delete comments together with posting deleted
if(!$oModuleModel->getTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after'))
$oModuleController->insertTrigger('document.deleteDocument', 'comment', 'controller', 'triggerDeleteDocumentComments', 'after');
// 2007. 10. 17 모듈이 삭제될때 등록된 댓글도 모두 삭제하는 트리거 추가
// 2007. 10. 17 add a trigger to delete all of comments together with module deleted
if(!$oModuleModel->getTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'))
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
// 2007. 10. 23 댓글에도 추천/ 알림 기능을 위한 컬럼 추가
// 2007. 10. 23 add a column for recommendation votes or notification of the comments
if(!$oDB->isColumnExists("comments","voted_count")) {
$oDB->addColumn("comments","voted_count", "number","11");
$oDB->addIndex("comments","idx_voted_count", array("voted_count"));
@ -80,12 +69,10 @@
if(!$oDB->isColumnExists("comments","notify_message")) {
$oDB->addColumn("comments","notify_message", "char","1");
}
// 2008. 02. 22 모듈의 추가 설정에서 댓글 추가 설정 추가
// 2008. 02. 22 add comment setting when a new module added
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
// 2008. 05. 14 blamed count 컬럼 추가
// 2008. 05. 14 add a column for blamed count
if(!$oDB->isColumnExists("comments", "blamed_count")) {
$oDB->addColumn('comments', 'blamed_count', 'number', 11, 0, true);
$oDB->addIndex('comments', 'idx_blamed_count', array('blamed_count'));
@ -97,7 +84,7 @@
}
/**
* @brief 캐시 파일 재생성
* @brief Regenerate cache file
**/
function recompileCache() {
}

View file

@ -2,19 +2,19 @@
/**
* @class commentController
* @author NHN (developers@xpressengine.com)
* @brief comment 모듈의 controller class
* @brief controller class of the comment module
**/
class commentController extends comment {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 댓글의 추천을 처리하는 action (Up)
* @brief action to handle recommendation votes on comments (Up)
**/
function procCommentVoteUp() {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
@ -36,7 +36,7 @@
}
/**
* @brief 댓글의 추천을 처리하는 action (Down)
* @brief action to handle recommendation votes on comments (Down)
**/
function procCommentVoteDown() {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
@ -58,7 +58,7 @@
}
/**
* @brief 댓글이 신고될 경우 호출되는 action
* @brief action to be called when a comment posting is reported
**/
function procCommentDeclare() {
if(!Context::get('is_logged')) return new Object(-1, 'msg_invalid_request');
@ -70,7 +70,7 @@
}
/**
* @brief document삭제시 해당 document의 댓글을 삭제하는 trigger
* @brief trigger to delete its comments together with document deleted
**/
function triggerDeleteDocumentComments(&$obj) {
$document_srl = $obj->document_srl;
@ -80,7 +80,7 @@
}
/**
* @brief module 삭제시 해당 댓글을 모두 삭제하는 trigger
* @brief trigger to delete corresponding comments when deleting a module
**/
function triggerDeleteModuleComments(&$obj) {
$module_srl = $obj->module_srl;
@ -91,32 +91,30 @@
}
/**
* @brief 코멘트의 권한 부여
* 세션값으로 접속상태에서만 사용 가능
* @brief Authorization of the comments
* available only in the current connection of the session value
**/
function addGrant($comment_srl) {
$_SESSION['own_comment'][$comment_srl] = true;
}
/**
* @brief 댓글 입력
* @brief Enter comments
**/
function insertComment($obj, $manual_inserted = false) {
$obj->__isupdate = false;
// trigger 호출 (before)
// call a trigger (before)
$output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj);
if(!$output->toBool()) return $output;
// document_srl에 해당하는 글이 있는지 확인
// check if a posting of the corresponding document_srl exists
$document_srl = $obj->document_srl;
if(!$document_srl) return new Object(-1,'msg_invalid_document');
// document model 객체 생성
// get a object of document model
$oDocumentModel = &getModel('document');
// even for manual_inserted if password exists, md5 it.
if($obj->password) $obj->password = md5($obj->password);
// 원본글을 가져옴
// get the original posting
if(!$manual_inserted) {
$oDocument = $oDocumentModel->getDocument($document_srl);
@ -124,8 +122,7 @@
if($oDocument->isLocked()) return new Object(-1,'msg_invalid_request');
if($obj->homepage && !preg_match('/^[a-z]+:\/\//i',$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage;
// 로그인 된 회원일 경우 회원의 정보를 입력
// input the member's information if logged-in
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
$obj->member_srl = $logged_info->member_srl;
@ -136,24 +133,20 @@
$obj->homepage = $logged_info->homepage;
}
}
// 로그인정보가 없고 사용자 이름이 없으면 오류 표시
// error display if neither of log-in info and user name exist.
if(!$logged_info->member_srl && !$obj->nick_name) return new Object(-1,'msg_invalid_request');
if(!$obj->comment_srl) $obj->comment_srl = getNextSequence();
// 순서를 정함
// determine the order
$obj->list_order = getNextSequence() * -1;
// 내용에서 XE만의 태그를 삭제
// remove XE's own tags from the contents
$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
if(Mobile::isFromMobilePhone())
{
$obj->content = nl2br(htmlspecialchars($obj->content));
}
if(!$obj->regdate) $obj->regdate = date("YmdHis");
// 세션에서 최고 관리자가 아니면 iframe, script 제거
// remove iframe and script if not a top administrator on the session.
if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
if(!$obj->notify_message) $obj->notify_message = 'N';
@ -162,38 +155,32 @@
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 댓글 목록 부분을 먼저 입력
// Enter a list of comments first
$list_args->comment_srl = $obj->comment_srl;
$list_args->document_srl = $obj->document_srl;
$list_args->module_srl = $obj->module_srl;
$list_args->regdate = $obj->regdate;
// 부모댓글이 없으면 바로 데이터를 설정
// If parent comment doesn't exist, set data directly
if(!$obj->parent_srl) {
$list_args->head = $list_args->arrange = $obj->comment_srl;
$list_args->depth = 0;
// 부모댓글이 있으면 부모글의 정보를 구해옴
// If parent comment exists, get information of the parent comment
} else {
// 부모댓글의 정보를 구함
// get information of the parent comment posting
$parent_args->comment_srl = $obj->parent_srl;
$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
// 부모댓글이 존재하지 않으면 return
// return if no parent comment exists
if(!$parent_output->toBool() || !$parent_output->data) return;
$parent = $parent_output->data;
$list_args->head = $parent->head;
$list_args->depth = $parent->depth+1;
// depth가 2단계 미만이면 별도의 update문 없이 insert만으로 쓰레드 정리
// if the depth of comments is less than 2, execute insert.
if($list_args->depth<2) {
$list_args->arrange = $obj->comment_srl;
// depth가 2단계 이상이면 반업데이트 실행
// if the depth of comments is greater than 2, execute update.
} else {
// 부모 댓글과 같은 head를 가지고 depth가 같거나 작은 댓글중 제일 위 댓글을 구함
// get the top listed comment among those in lower depth and same head with parent's.
$p_args->head = $parent->head;
$p_args->arrange = $parent->arrange;
$p_args->depth = $parent->depth;
@ -211,31 +198,23 @@
$output = executeQuery('comment.insertCommentList', $list_args);
if(!$output->toBool()) return $output;
// 댓글 본문을 입력
// insert comment
$output = executeQuery('comment.insertComment', $obj);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// comment model객체 생성
// creat the comment model object
$oCommentModel = &getModel('comment');
// 해당 글의 전체 댓글 수를 구해옴
// get the number of all comments in the posting
$comment_count = $oCommentModel->getCommentCount($document_srl);
// document의 controller 객체 생성
// create the controller object of the document
$oDocumentController = &getController('document');
// 해당글의 댓글 수를 업데이트
// Update the number of comments in the post
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, true);
// 댓글의 권한을 부여
// grant autority of the comment
$this->addGrant($obj->comment_srl);
// trigger 호출 (after)
// call a trigger(after)
if($output->toBool()) {
$trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
if(!$trigger_output->toBool()) {
@ -248,10 +227,9 @@
$oDB->commit();
if(!$manual_inserted) {
// 원본글에 알림(notify_message)가 설정되어 있으면 메세지 보냄
// send a message if notify_message option in enabled in the original article
$oDocument->notify(Context::getLang('comment'), $obj->content);
// 원본 댓글이 있고 원본 댓글에 알림(notify_message)가 있으면 메세지 보냄
// send a message if notify_message option in enabled in the original comment
if($obj->parent_srl) {
$oParent = $oCommentModel->getComment($obj->parent_srl);
if ($oParent->get('member_srl') != $oDocument->get('member_srl')) {
@ -266,18 +244,16 @@
}
/**
* @brief 댓글 수정
* @brief fix the comment
**/
function updateComment($obj, $is_admin = false) {
$obj->__isupdate = true;
// trigger 호출 (before)
// call a trigger (before)
$output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj);
if(!$output->toBool()) return $output;
// comment model 객체 생성
// create a comment model object
$oCommentModel = &getModel('comment');
// 원본 데이터를 가져옴
// get the original data
$source_obj = $oCommentModel->getComment($obj->comment_srl);
if(!$source_obj->getMemberSrl()) {
$obj->member_srl = $source_obj->get('member_srl');
@ -286,14 +262,12 @@
$obj->email_address = $source_obj->get('email_address');
$obj->homepage = $source_obj->get('homepage');
}
// 권한이 있는지 확인
// check if permission is granted
if(!$is_admin && !$source_obj->isGranted()) return new Object(-1, 'msg_not_permitted');
if($obj->password) $obj->password = md5($obj->password);
if($obj->homepage && !preg_match('/^[a-z]+:\/\//i',$obj->homepage)) $obj->homepage = 'http://'.$obj->homepage;
// 로그인 되어 있고 작성자와 수정자가 동일하면 수정자의 정보를 세팅
// set modifier's information if logged-in and posting author and modifier are matched.
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
if($source_obj->member_srl == $logged_info->member_srl) {
@ -304,8 +278,7 @@
$obj->homepage = $logged_info->homepage;
}
}
// 로그인한 유저가 작성한 글인데 nick_name이 없을 경우
// if nick_name of the logged-in author doesn't exist
if($source_obj->get('member_srl')&& !$obj->nick_name) {
$obj->member_srl = $source_obj->get('member_srl');
$obj->user_name = $source_obj->get('user_name');
@ -316,25 +289,21 @@
if(!$obj->content) $obj->content = $source_obj->get('content');
// 내용에서 XE만의 태그를 삭제
// remove XE's wn tags from contents
$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
// 세션에서 최고 관리자가 아니면 iframe, script 제거
// remove iframe and script if not a top administrator on the session
if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 업데이트
// Update
$output = executeQuery('comment.updateComment', $obj);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// trigger 호출 (after)
// call a trigger (after)
if($output->toBool()) {
$trigger_output = ModuleHandler::triggerCall('comment.updateComment', 'after', $obj);
if(!$trigger_output->toBool()) {
@ -351,34 +320,28 @@
}
/**
* @brief 댓글 삭제
* @brief Delete comment
**/
function deleteComment($comment_srl, $is_admin = false) {
// comment model 객체 생성
// create the comment model object
$oCommentModel = &getModel('comment');
// 기존 댓글이 있는지 확인
// check if comment already exists
$comment = $oCommentModel->getComment($comment_srl);
if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request');
$document_srl = $comment->document_srl;
// trigger 호출 (before)
// call a trigger (before)
$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
if(!$output->toBool()) return $output;
// 해당 댓글에 child가 있는지 확인
// check if child comment exists on the comment
$child_count = $oCommentModel->getChildCommentCount($comment_srl);
if($child_count>0) return new Object(-1, 'fail_to_delete_have_children');
// 권한이 있는지 확인
// check if permission is granted
if(!$is_admin && !$comment->isGranted()) return new Object(-1, 'msg_not_permitted');
// begin transaction
$oDB = &DB::getInstance();
$oDB->begin();
// 삭제
// Delete
$args->comment_srl = $comment_srl;
$output = executeQuery('comment.deleteComment', $args);
if(!$output->toBool()) {
@ -387,21 +350,17 @@
}
$output = executeQuery('comment.deleteCommentList', $args);
// 댓글 수를 구해서 업데이트
// update the number of comments
$comment_count = $oCommentModel->getCommentCount($document_srl);
// document의 controller 객체 생성
// create the controller object of the document
$oDocumentController = &getController('document');
// 해당글의 댓글 수를 업데이트
// update comment count of the article posting
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, null, false);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// trigger 호출 (after)
// call a trigger (after)
if($output->toBool()) {
$trigger_output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
if(!$trigger_output->toBool()) {
@ -418,45 +377,40 @@
}
/**
* @brief 특정 글의 모든 댓글 삭제
* @brief remove all comments of the article
**/
function deleteComments($document_srl) {
// document model객체 생성
// create the document model object
$oDocumentModel = &getModel('document');
$oCommentModel = &getModel('comment');
// 권한이 있는지 확인
// check if permission is granted
$oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists() || !$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
// 댓글 목록을 가져와서 일단 trigger만 실행 (일괄 삭제를 해야 하기에 최대한 처리 비용을 줄이기 위한 방법)
// get a list of comments and then execute a trigger(way to reduce the processing cost for delete all)
$args->document_srl = $document_srl;
$comments = executeQueryArray('comment.getAllComments',$args);
if($comments->data) {
foreach($comments->data as $key => $comment) {
// trigger 호출 (before)
// call a trigger (before)
$output = ModuleHandler::triggerCall('comment.deleteComment', 'before', $comment);
if(!$output->toBool()) continue;
// trigger 호출 (after)
// call a trigger (after)
$output = ModuleHandler::triggerCall('comment.deleteComment', 'after', $comment);
if(!$output->toBool()) continue;
}
}
// 댓글 본문 삭제
// delete the comment
$args->document_srl = $document_srl;
$output = executeQuery('comment.deleteComments', $args);
if(!$output->toBool()) return $output;
// 댓글 목록 삭제
// Delete a list of comments
$output = executeQuery('comment.deleteCommentsList', $args);
return $output;
}
/**
* @brief 해당 comment의 추천수 증가
* @brief Increase vote-up counts of the comment
**/
function updateVotedCount($comment_srl, $point = 1) {
if($point > 0) {
@ -467,31 +421,28 @@
$success_message = 'success_blamed';
}
// 세션 정보에 추천 정보가 있으면 중단
// invalid vote if vote info exists in the session info.
if($_SESSION['voted_comment'][$comment_srl]) return new Object(-1, $failed_voted);
$oCommentModel = &getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl, false, false);
// 글의 작성 ip와 현재 접속자의 ip가 동일하면 패스
// invalid vote if both ip addresses between author's and the current user are same.
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
$_SESSION['voted_comment'][$comment_srl] = true;
return new Object(-1, $failed_voted);
}
// comment의 작성자가 회원일때 조사
// if the comment author is a member
if($oComment->get('member_srl')) {
// create the member model object
$oMemberModel = &getModel('member');
$member_srl = $oMemberModel->getLoggedMemberSrl();
// 글쓴이와 현재 로그인 사용자의 정보가 일치하면 읽었다고 생각하고 세션 등록후 패스
// session registered if the author information matches to the current logged-in user's.
if($member_srl && $member_srl == $oComment->get('member_srl')) {
$_SESSION['voted_comment'][$comment_srl] = true;
return new Object(-1, $failed_voted);
}
}
// 로그인 사용자이면 member_srl, 비회원이면 ipaddress로 판단
// If logged-in, use the member_srl. otherwise use the ipaddress.
if($member_srl) {
$args->member_srl = $member_srl;
} else {
@ -499,14 +450,13 @@
}
$args->comment_srl = $comment_srl;
$output = executeQuery('comment.getCommentVotedLogInfo', $args);
// 로그 정보에 추천 로그가 있으면 세션 등록후 패스
// session registered if log info contains recommendation vote log.
if($output->data->count) {
$_SESSION['voted_comment'][$comment_srl] = true;
return new Object(-1, $failed_voted);
}
// 추천수 업데이트
// update the number of votes
if($point < 0) {
$args->blamed_count = $oComment->get('blamed_count') + $point;
$output = executeQuery('comment.updateBlamedCount', $args);
@ -514,54 +464,46 @@
$args->voted_count = $oComment->get('voted_count') + $point;
$output = executeQuery('comment.updateVotedCount', $args);
}
// 로그 남기기
// leave logs
$args->point = $point;
$output = executeQuery('comment.insertCommentVotedLog', $args);
// 세션 정보에 남김
// leave into session information
$_SESSION['voted_comment'][$comment_srl] = true;
// 결과 리턴
// Return the result
return new Object(0, $success_message);
}
/**
* @brief 댓글 신고
* @brief report a blamed comment
**/
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');
// 이미 신고되었는지 검사
// check if already reported
$args->comment_srl = $comment_srl;
$output = executeQuery('comment.getDeclaredComment', $args);
if(!$output->toBool()) return $output;
// 문서 원본을 가져옴
// get the original comment
$oCommentModel = &getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl, false, false);
// 글의 작성 ip와 현재 접속자의 ip가 동일하면 패스
// failed if both ip addresses between author's and the current user are same.
if($oComment->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
$_SESSION['declared_comment'][$comment_srl] = true;
return new Object(-1, 'failed_declared');
}
// comment의 작성자가 회원일때 조사
// if the comment author is a member
if($oComment->get('member_srl')) {
// member model 객체 생성
// create the member model object
$oMemberModel = &getModel('member');
$member_srl = $oMemberModel->getLoggedMemberSrl();
// 글쓴이와 현재 로그인 사용자의 정보가 일치하면 읽었다고 생각하고 세션 등록후 패스
// session registered if the author information matches to the current logged-in user's.
if($member_srl && $member_srl == $oComment->get('member_srl')) {
$_SESSION['declared_comment'][$comment_srl] = true;
return new Object(-1, 'failed_declared');
}
}
// 로그인 사용자이면 member_srl, 비회원이면 ipaddress로 판단
// If logged-in, use the member_srl. otherwise use the ipaddress.
if($member_srl) {
$args->member_srl = $member_srl;
} else {
@ -569,29 +511,25 @@
}
$args->comment_srl = $comment_srl;
$output = executeQuery('comment.getCommentDeclaredLogInfo', $args);
// 로그 정보에 신고 로그가 있으면 세션 등록후 패스
// session registered if log info contains report log.
if($output->data->count) {
$_SESSION['declared_comment'][$comment_srl] = true;
return new Object(-1, 'failed_declared');
}
// 신고글 추가
// execute insert
if($output->data->declared_count > 0) $output = executeQuery('comment.updateDeclaredComment', $args);
else $output = executeQuery('comment.insertDeclaredComment', $args);
if(!$output->toBool()) return $output;
// 로그 남기기
// leave the log
$output = executeQuery('comment.insertCommentDeclaredLog', $args);
// 세션 정보에 남김
// leave into the session information
$_SESSION['declared_comment'][$comment_srl] = true;
$this->setMessage('success_declared');
}
/**
* @brief 댓글의 댓글을.. 클릭시 나타나는 팝업 메뉴를 추가하는 method
* @brief method to add a pop-up menu when clicking for displaying child comments
**/
function addCommentPopupMenu($url, $str, $icon = '', $target = 'self') {
$comment_popup_menu_list = Context::get('comment_popup_menu_list');
@ -607,7 +545,7 @@
}
/**
* @brief 댓글의 모듈별 추가 확장 폼을 저장
* @brief save the comment extension form for each module
**/
function procCommentInsertModuleConfig() {
$module_srl = Context::get('target_module_srl');

View file

@ -2,7 +2,7 @@
/**
* @class commentItem
* @author NHN (developers@xpressengine.com)
* @brief comment 객체
* @brief comment Object
**/
class commentItem extends Object {
@ -35,8 +35,7 @@
}
$this->comment_srl = $attribute->comment_srl;
$this->adds($attribute);
// 기존 스킨의 호환을 위해 변수를 객체 자신에 재선언
// define vars on the object for backward compatibility of skins
if(count($attribute)) foreach($attribute as $key => $val) $this->{$key} = $val;
}
@ -101,28 +100,23 @@
}
function notify($type, $content) {
// useNotify가 아니면 return
// return if not useNotify
if(!$this->useNotify()) return;
// 글쓴이가 로그인 유저가 아니면 패스~
// pass if the author is not logged-in user
if(!$this->get('member_srl')) return;
// 현재 로그인한 사용자와 글을 쓴 사용자를 비교하여 동일하면 return
// return if the currently logged-in user is an author of the comment.
$logged_info = Context::get('logged_info');
if($logged_info->member_srl == $this->get('member_srl')) return;
// 원본글의 주소를 구함
// get where the comment belongs to
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
// 변수 정리
// Variables
if($type) $title = "[".$type."] ";
$title .= cut_str(strip_tags($content), 30, '...');
$content = sprintf('%s<br /><br />from : <a href="%s#comment_%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->get('document_srl')), $this->get('comment_srl'), getFullUrl('','document_srl',$this->get('document_srl')));
$receiver_srl = $this->get('member_srl');
$sender_member_srl = $logged_info->member_srl;
// 쪽지 발송
// send a message
$oCommunicationController = &getController('communication');
$oCommunicationController->sendMessage($sender_member_srl, $receiver_srl, $title, $content, false);
}
@ -177,8 +171,7 @@
$content = $this->get('content');
stripEmbedTagForAdmin($content, $this->get('member_srl'));
// 이 댓글을... 팝업메뉴를 출력할 경우
// when displaying the comment on the pop-up menu
if($add_popup_menu && Context::get('is_logged') ) {
$content = sprintf(
'%s<div class="comment_popup_menu"><a href="#popup_menu_area" class="comment_%d" onclick="return false">%s</a></div>',
@ -186,8 +179,7 @@
$this->comment_srl, Context::getLang('cmd_comment_do')
);
}
// 컨텐츠에 대한 조작이 가능한 추가 정보를 설정하였을 경우
// if additional information which can access contents is set
if($add_content_info) {
$content = sprintf(
'<!--BeforeComment(%d,%d)--><div class="comment_%d_%d xe_content">%s</div><!--AfterComment(%d,%d)-->',
@ -196,7 +188,7 @@
$content,
$this->comment_srl, $this->get('member_srl')
);
// 컨텐츠에 대한 조작이 필요하지 않더라도 xe_content라는 클래스명을 꼭 부여
// xe_content class name should be specified although content access is not necessary.
} else {
if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
}
@ -206,26 +198,19 @@
function getSummary($str_size = 50, $tail = '...') {
$content = $this->getContent(false, false);
// 줄바꿈이 있을 때, 공백문자 삽입
// for newline, insert a blank.
$content = preg_replace('!(<br[\s]*/{0,1}>[\s]*)+!is', ' ', $content);
// </p>, </div>, </li> 등의 태그를 공백 문자로 치환
// replace tags such as </p> , </div> , </li> by blanks.
$content = str_replace(array('</p>', '</div>', '</li>'), ' ', $content);
// 태그 제거
// Remove tags
$content = preg_replace('!<([^>]*?)>!is','', $content);
// < , > , " 를 치환
// replace < , >, "
$content = str_replace(array('&lt;','&gt;','&quot;','&nbsp;'), array('<','>','"',' '), $content);
// 연속된 공백문자 삭제
// delete a series of blanks
$content = preg_replace('/ ( +)/is', ' ', $content);
// 문자열을 자름
// truncate strings
$content = trim(cut_str($content, $str_size, $tail));
// >, <, "를 다시 복구
// restore >, <, , "\
$content = str_replace(array('<','>','"'),array('&lt;','&gt;','&quot;'), $content);
return $content;
@ -288,7 +273,7 @@
}
/**
* @brief 에디터 html을 구해서 return
* @brief return the editor html
**/
function getEditor() {
$module_srl = $this->get('module_srl');
@ -298,7 +283,7 @@
}
/**
* @brief 작성자의 프로필 이미지를 return
* @brief return author's profile image
**/
function getProfileImage() {
if(!$this->isExists() || !$this->get('member_srl')) return;
@ -310,17 +295,15 @@
}
/**
* @brief 작성자의 서명을 return
* @brief return author's signiture
**/
function getSignature() {
// 존재하지 않는 글이면 패스~
// pass if the posting not exists.
if(!$this->isExists() || !$this->get('member_srl')) return;
// 서명정보를 구함
// get the signiture information
$oMemberModel = &getModel('member');
$signature = $oMemberModel->getSignature($this->get('member_srl'));
// 회원모듈에서 서명 최고 높이 지정되었는지 검사
// check if max height of the signiture is specified on the member module
if(!isset($GLOBALS['__member_signature_max_height'])) {
$oModuleModel = &getModel('module');
$member_config = $oModuleModel->getModuleConfig('member');
@ -339,34 +322,27 @@
}
function getThumbnail($width = 80, $height = 0, $thumbnail_type = '') {
// 존재하지 않는 문서일 경우 return false
// return false if no doc exists
if(!$this->comment_srl) return;
// 높이 지정이 별도로 없으면 정사각형으로 생성
// If signiture height setting is omitted, create a square
if(!$height) $height = $width;
// 첨부파일이 없거나 내용중 이미지가 없으면 return false;
// return false if neigher attached file nor image;
if(!$this->hasUploadedFiles() && !preg_match("!<img!is", $this->get('content'))) return;
// 문서 모듈의 기본 설정에서 Thumbnail의 생성 방법을 구함
// get thumbail generation info on the doc module configuration.
if(!in_array($thumbnail_type, array('crop','ratio'))) $thumbnail_type = 'crop';
// 섬네일 정보 정의
// Define thumbnail information
$thumbnail_path = sprintf('files/cache/thumbnails/%s',getNumberingPath($this->comment_srl, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri().$thumbnail_file;
// 섬네일 파일이 있을 경우 파일의 크기가 0 이면 return false 아니면 경로 return
// return false if a size of existing thumbnail file is 0. otherwise return the file path
if(file_exists($thumbnail_file)) {
if(filesize($thumbnail_file)<1) return false;
else return $thumbnail_url;
}
// 대상 파일
// Target file
$source_file = null;
$is_tmp_file = false;
// 첨부된 파일중 이미지 파일이 있으면 찾음
// find an image file among attached files
if($this->hasUploadedFiles()) {
$file_list = $this->getUploadedFiles();
if(count($file_list)) {
@ -380,8 +356,7 @@
}
}
}
// 첨부된 파일이 없으면 내용중 이미지 파일을 구함
// get an image file from the doc content if no file attached.
if(!$source_file) {
$content = $this->get('content');
$target_src = null;
@ -411,11 +386,9 @@
$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
if($is_tmp_file) FileHandler::removeFile($source_file);
// 섬네일 생성 성공시 경로 return
// return the thumbnail path if successfully generated.
if($output) return $thumbnail_url;
// 차후 다시 섬네일 생성을 시도하지 않기 위해 빈 파일을 생성
// create an empty file not to attempt to generate the thumbnail afterwards
else FileHandler::writeFile($thumbnail_file, '','w');
return;

View file

@ -2,39 +2,36 @@
/**
* @class commentModel
* @author NHN (developers@xpressengine.com)
* @brief comment 모듈의 model class
* @brief model class of the comment module
**/
class commentModel extends comment {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 선택된 게시물의 팝업메뉴 표시
* @brief display the pop-up menu of the post
*
* 인쇄, 스크랩, 추천, 비추천, 신고 기능 추가
* Print, scrap, vote-up(recommen), vote-down(non-recommend), report features added
**/
function getCommentMenu() {
// 요청된 게시물 번호와 현재 로그인 정보 구함
// get the post's id number and the current login information
$comment_srl = Context::get('target_srl');
$mid = Context::get('cur_mid');
$logged_info = Context::get('logged_info');
$act = Context::get('cur_act');
// menu_list 에 "표시할글,target,url" 을 배열로 넣는다
// array values for menu_list, "comment post, target, url"
$menu_list = array();
// trigger 호출
// call a trigger
ModuleHandler::triggerCall('comment.getCommentMenu', 'before', $menu_list);
$oCommentController = &getController('comment');
// 회원이어야만 가능한 기능
// feature that only member can do
if($logged_info->member_srl) {
$oCommentModel = &getModel('comment');
@ -45,31 +42,29 @@
$oModuleModel = &getModel('module');
$comment_config = $oModuleModel->getModulePartConfig('document',$module_srl);
if($comment_config->use_vote_up!='N' && $member_srl!=$logged_info->member_srl){
// 추천 버튼 추가
// Add a vote-up button for positive feedback
$url = sprintf("doCallModuleAction('comment','procCommentVoteUp','%s')", $comment_srl);
$oCommentController->addCommentPopupMenu($url,'cmd_vote','./modules/document/tpl/icons/vote_up.gif','javascript');
}
if($comment_config->use_vote_down!='N' && $member_srl!=$logged_info->member_srl){
// 비추천 버튼 추가
// Add a vote-down button for negative feedback
$url = sprintf("doCallModuleAction('comment','procCommentVoteDown','%s')", $comment_srl);
$oCommentController->addCommentPopupMenu($url,'cmd_vote_down','./modules/document/tpl/icons/vote_down.gif','javascript');
}
// 신고 기능 추가
// Add the report feature against abused posts
$url = sprintf("doCallModuleAction('comment','procCommentDeclare','%s')", $comment_srl);
$oCommentController->addCommentPopupMenu($url,'cmd_declare','./modules/document/tpl/icons/declare.gif','javascript');
}
// trigger 호출 (after)
// call a trigger (after)
ModuleHandler::triggerCall('comment.getCommentMenu', 'after', $menu_list);
// 관리자일 경우 ip로 글 찾기
// find a comment by IP matching if an administrator.
if($logged_info->is_admin == 'Y') {
$oCommentModel = &getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl);
if($oComment->isExists()) {
// ip주소에 해당하는 글 찾기
// Find a post of the corresponding ip address
$url = getUrl('','module','admin','act','dispCommentAdminList','search_target','ipaddress','search_keyword',$oComment->get('ipaddress'));
$icon_path = './modules/member/tpl/images/icon_management.gif';
$oCommentController->addCommentPopupMenu($url,'cmd_search_by_ipaddress',$icon_path,'TraceByIpaddress');
@ -78,30 +73,28 @@
$oCommentController->addCommentPopupMenu($url,'cmd_add_ip_to_spamfilter','./modules/document/tpl/icons/declare.gif','javascript');
}
}
// 팝업메뉴의 언어 변경
// Changing a language of pop-up menu
$menus = Context::get('comment_popup_menu_list');
$menus_count = count($menus);
for($i=0;$i<$menus_count;$i++) {
$menus[$i]->str = Context::getLang($menus[$i]->str);
}
// 최종적으로 정리된 팝업메뉴 목록을 구함
// get a list of final organized pop-up menus
$this->add('menus', $menus);
}
/**
* @brief comment_srl에 권한이 있는지 체크
* @brief check if you have a permission to comment_srl
*
* 세션 정보만 이용
* use only session information
**/
function isGranted($comment_srl) {
return $_SESSION['own_comment'][$comment_srl];
}
/**
* @brief 자식 답글의 갯수 리턴
* @brief Returns the number of child comments
**/
function getChildCommentCount($comment_srl) {
$args->comment_srl = $comment_srl;
@ -110,7 +103,7 @@
}
/**
* @brief 댓글 가져오기
* @brief get the comment
**/
function getComment($comment_srl=0, $is_admin = false) {
$oComment = new commentItem($comment_srl);
@ -120,12 +113,11 @@
}
/**
* @brief 여러개의 댓글들을 가져옴 (페이징 아님)
* @brief get the multiple comments(not paginating)
**/
function getComments($comment_srl_list) {
if(is_array($comment_srl_list)) $comment_srls = implode(',',$comment_srl_list);
// DB에서 가져옴
// fetch from a database
$args->comment_srls = $comment_srls;
$output = executeQuery('comment.getComments', $args);
if(!$output->toBool()) return;
@ -147,7 +139,7 @@
}
/**
* @brief document_srl 해당하는 댓글의 전체 갯수를 가져옴
* @brief get the total number of comments in corresponding with document_srl.
**/
function getCommentCount($document_srl) {
$args->document_srl = $document_srl;
@ -158,7 +150,7 @@
/**
* @brief module_srl 해당하는 댓글의 전체 갯수를 가져옴
* @brief get the total number of comments in corresponding with module_srl.
**/
function getCommentAllCount($module_srl) {
$args->module_srl = $module_srl;
@ -170,7 +162,7 @@
/**
* @brief mid 해당하는 댓글을 가져옴
* @brief get the comment in corresponding with mid.
**/
function getNewestCommentList($obj) {
if($obj->mid) {
@ -178,8 +170,7 @@
$obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid);
unset($obj->mid);
}
// 넘어온 module_srl은 array일 수도 있기에 array인지를 체크
// check if module_srl is an arrary.
if(is_array($obj->module_srl)) $args->module_srl = implode(',', $obj->module_srl);
else $args->module_srl = $obj->module_srl;
$args->list_count = $obj->list_count;
@ -205,20 +196,17 @@
}
/**
* @brief document_srl에 해당하는 문서의 댓글 목록을 가져옴
* @brief get a comment list of the doc in corresponding woth document_srl.
**/
function getCommentList($document_srl, $page = 0, $is_admin = false, $count = 0) {
// 해당 문서의 모듈에 해당하는 댓글 수를 구함
// get the number of comments on the document module
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
// 문서가 존재하지 않으면 return~
// return if no doc exists.
if(!$oDocument->isExists()) return;
// 댓글수가 없으면 return~
// return if no comment exists
if($oDocument->getCommentCount()<1) return;
// 정해진 댓글수에 따른 댓글 목록 구함
// get a list of comments
$module_srl = $oDocument->get('module_srl');
if(!$count) {
@ -228,21 +216,17 @@
} else {
$comment_count = $count;
}
// 페이지가 없으면 제일 뒤 페이지를 구함
// get a very last page if no page exists
if(!$page) $page = (int)( ($oDocument->getCommentCount()-1) / $comment_count) + 1;
// 정해진 수에 따라 목록을 구해옴
// get a list of comments
$args->document_srl = $document_srl;
$args->list_count = $comment_count;
$args->page = $page;
$args->page_count = 10;
$output = executeQueryArray('comment.getCommentPageList', $args);
// 쿼리 결과에서 오류가 생기면 그냥 return
// return if an error occurs in the query results
if(!$output->toBool()) return;
// 만약 구해온 결과값이 저장된 댓글수와 다르다면 기존의 데이터로 판단하고 댓글 목록 테이블에 데이터 입력
// insert data into CommentPageList table if the number of results is different from stored comments
if(!$output->data) {
$this->fixCommentList($oDocument->get('module_srl'), $document_srl);
$output = executeQueryArray('comment.getCommentPageList', $args);
@ -253,16 +237,15 @@
}
/**
* @brief document_srl에 해당하는 댓글 목록을 갱신
* 정식버전 이전에 사용되던 데이터를 위한 처리
* @brief update a list of comments in corresponding with document_srl
* take care of previously used data than GA version
**/
function fixCommentList($module_srl, $document_srl) {
// 일괄 작업이라서 lock 파일을 생성하여 중복 작업이 되지 않도록 한다
// create a lock file to prevent repeated work when performing a batch job
$lock_file = "./files/cache/tmp/lock.".$document_srl;
if(file_exists($lock_file) && filemtime($lock_file)+60*60*10<time()) return;
FileHandler::writeFile($lock_file, '');
// 목록을 구함
// get a list
$args->document_srl = $document_srl;
$args->list_order = 'list_order';
$output = executeQuery('comment.getCommentList', $args);
@ -270,25 +253,20 @@
$source_list = $output->data;
if(!is_array($source_list)) $source_list = array($source_list);
// 댓글를 계층형 구조로 정렬
// Sort comments by the hierarchical structure
$comment_count = count($source_list);
$root = NULL;
$list = NULL;
$comment_list = array();
// 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음
// get the log-in information for logged-in users
$logged_info = Context::get('logged_info');
// loop를 돌면서 코멘트의 계층 구조 만듬
// generate a hierarchical structure of comments for loop
for($i=$comment_count-1;$i>=0;$i--) {
$comment_srl = $source_list[$i]->comment_srl;
$parent_srl = $source_list[$i]->parent_srl;
if(!$comment_srl) continue;
// 목록을 만듬
// generate a list
$list[$comment_srl] = $source_list[$i];
if($parent_srl) {
@ -298,8 +276,7 @@
}
}
$this->_arrangeComment($comment_list, $root->child, 0, null);
// 구해진 값을 db에 입력함
// insert values to the database
if(count($comment_list)) {
foreach($comment_list as $comment_srl => $item) {
$comment_args = null;
@ -314,13 +291,12 @@
executeQuery('comment.insertCommentList', $comment_args);
}
}
// 성공시 lock파일 제거
// remove the lock file if successful.
FileHandler::removeFile($lock_file);
}
/**
* @brief 댓글을 계층형으로 재배치
* @brief relocate comments in the hierarchical structure
**/
function _arrangeComment(&$comment_list, $list, $depth, $parent = null) {
if(!count($list)) return;
@ -343,20 +319,18 @@
}
/**
* @brief 모든 댓글를 시간 역순으로 가져옴 (관리자용)
* @brief get all the comments in time decending order(for administrators)
**/
function getTotalCommentList($obj) {
$query_id = 'comment.getTotalCommentList';
// 변수 설정
// Variables
$args->sort_index = 'list_order';
$args->page = $obj->page?$obj->page:1;
$args->list_count = $obj->list_count?$obj->list_count:20;
$args->page_count = $obj->page_count?$obj->page_count:10;
$args->s_module_srl = $obj->module_srl;
$args->exclude_module_srl = $obj->exclude_module_srl;
// 검색 옵션 정리
// Search options
$search_target = $obj->search_target?$obj->search_target:trim(Context::get('search_target'));
$search_keyword = $obj->search_keyword?$obj->search_keyword:trim(Context::get('search_keyword'));
if($search_target && $search_keyword) {
@ -401,11 +375,9 @@
break;
}
}
// comment.getTotalCommentList 쿼리 실행
// comment.getTotalCommentList query execution
$output = executeQueryArray($query_id, $args);
// 결과가 없거나 오류 발생시 그냥 return
// return when no result or error occurance
if(!$output->toBool()||!count($output->data)) return $output;
foreach($output->data as $key => $val) {
unset($_oComment);
@ -418,7 +390,7 @@
}
/**
* @brief 모듈별 댓글 설정을 return
* @brief return a configuration of comments for each module
**/
function getCommentConfig($module_srl) {
$oModuleModel = &getModel('module');

View file

@ -2,42 +2,39 @@
/**
* @class commentView
* @author NHN (developers@xpressengine.com)
* @brief comment 모듈의 view 클래스
* @brief comment module's view class
**/
class commentView extends comment {
/**
* @brief 초기화
* @brief Initialization
**/
function init() {
}
/**
* @brief 모듈의 추가 설정에서 댓글 설정을 하는 form 추가
* @brief add a form fot comment setting on the additional setting of module
**/
function triggerDispCommentAdditionSetup(&$obj) {
$current_module_srl = Context::get('module_srl');
$current_module_srls = Context::get('module_srls');
if(!$current_module_srl && !$current_module_srls) {
// 선택된 모듈의 정보를 가져옴
// get information of the selected module
$current_module_info = Context::get('current_module_info');
$current_module_srl = $current_module_info->module_srl;
if(!$current_module_srl) return new Object();
}
// 댓글 설정을 구함
// get the comment configuration
$oCommentModel = &getModel('comment');
$comment_config = $oCommentModel->getCommentConfig($current_module_srl);
Context::set('comment_config', $comment_config);
// 그룹 목록을 구함
// get a group list
$oMemberModel = &getModel('member');
$group_list = $oMemberModel->getGroups();
Context::set('group_list', $group_list);
// 템플릿 파일 지정
// Set a template file
$oTemplate = &TemplateHandler::getInstance();
$tpl = $oTemplate->compile($this->module_path.'tpl', 'comment_module_config');
$obj .= $tpl;