diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index cd77a54d8..34dd72f1d 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -188,7 +188,8 @@ } $tmp_arr[$i] = implode(".",$tmp2_arr); } - $arg = implode("/",$tmp_arr); + if(is_array($tmp_arg)) $arg = implode("/",$tmp_arr); + else $args = $tmp_arr; if(substr($arg,0,2)=='./') $arg = substr($arg,2); // 1단계로 해당 tpl 내의 파일을 체크 diff --git a/modules/pagemaker/pagemaker.class.php b/modules/pagemaker/pagemaker.class.php index 32fb0a91a..54921258f 100644 --- a/modules/pagemaker/pagemaker.class.php +++ b/modules/pagemaker/pagemaker.class.php @@ -1,16 +1,29 @@ document_srl; - if(!$document_srl) return new Object(-1,'msg_invalid_document'); - - // document model 객체 생성 - $oDocumentModel = &getModel('document'); - - // 원본글을 가져옴 - $document = $oDocumentModel->getDocument($document_srl); - - if($document_srl != $document->document_srl) return new Object(-1,'msg_invalid_document'); - if($document->lock_comment=='Y') return new Object(-1,'msg_invalid_request'); - - $oDB = &DB::getInstance(); - - $obj->comment_srl = $oDB->getNextSequence(); - $obj->list_order = $obj->comment_srl * -1; - if($obj->password) $obj->password = md5($obj->password); - - // 로그인 된 회원일 경우 회원의 정보를 입력 - if(Context::get('is_logged')) { - $logged_info = Context::get('logged_info'); - $obj->member_srl = $logged_info->member_srl; - $obj->user_name = $logged_info->user_name; - $obj->nick_name = $logged_info->nick_name; - $obj->email_address = $logged_info->email_address; - $obj->homepage = $logged_info->homepage; - } - - // 댓글을 입력 - $output = $oDB->executeQuery('comment.insertComment', $obj); - - // 입력에 이상이 없으면 해당 글의 댓글 수를 올림 - if(!$output->toBool()) return $output; - - // comment model객체 생성 - $oCommentModel = &getModel('comment'); - - // 해당 글의 전체 댓글 수를 구해옴 - $comment_count = $oCommentModel->getCommentCount($document_srl); - - // document의 controller 객체 생성 - $oDocumentController = &getController('document'); - - // 해당글의 댓글 수를 업데이트 - $output = $oDocumentController->updateCommentCount($document_srl, $comment_count); - - // 댓글의 권한을 부여 - $this->addGrant($obj->comment_srl); - - $output->add('comment_srl', $obj->comment_srl); - return $output; - } - - /** - * @brief 댓글 수정 - **/ - function updateComment($obj, $is_admin = false) { - // comment model 객체 생성 - $oCommentModel = &getModel('comment'); - - // 원본 데이터를 가져옴 - $source_obj = $oCommentModel->getComment($obj->comment_srl); - - // 권한이 있는지 확인 - if(!$is_admin && !$source_obj->is_granted) return new Object(-1, 'msg_not_permitted'); - - $oDB = &DB::getInstance(); - - if($obj->password) $obj->password = md5($obj->password); - - // 로그인 되어 있고 작성자와 수정자가 동일하면 수정자의 정보를 세팅 - if(Context::get('is_logged')) { - $logged_info = Context::get('logged_info'); - if($source_obj->member_srl == $logged_info->member_srl) { - $obj->member_srl = $logged_info->member_srl; - $obj->user_name = $logged_info->user_name; - $obj->nick_name = $logged_info->nick_name; - $obj->email_address = $logged_info->email_address; - $obj->homepage = $logged_info->homepage; - } - } - - // 로그인한 유저가 작성한 글인데 user_name이 없을 경우 - if($source_obj->member_srl && !$obj->user_name) { - $obj->member_srl = $source_obj->member_srl; - $obj->user_name = $source_obj->user_name; - $obj->nick_name = $source_obj->nick_name; - $obj->email_address = $source_obj->email_address; - $obj->homepage = $source_obj->homepage; - } - - // 업데이트 - $output = $oDB->executeQuery('comment.updateComment', $obj); - - $output->add('comment_srl', $obj->comment_srl); - return $output; - } - - /** - * @brief 댓글 삭제 - **/ - function deleteComment($comment_srl, $is_admin = false) { - // comment model 객체 생성 - $oCommentModel = &getModel('comment'); - - // 기존 댓글이 있는지 확인 - $comment = $oCommentModel->getComment($comment_srl); - if($comment->comment_srl != $comment_srl) return new Object(-1, 'msg_invalid_request'); - $document_srl = $comment->document_srl; - - // 해당 댓글에 child가 있는지 확인 - $child_count = $oCommentModel->getChildCommentCount($comment_srl); - if($child_count>0) return new Object(-1, 'fail_to_delete_have_children'); - - // 권한이 있는지 확인 - if(!$is_admin && !$comment->is_granted) return new Object(-1, 'msg_not_permitted'); - - // 삭제 - $oDB = &DB::getInstance(); - - $args->comment_srl = $comment_srl; - $output = $oDB->executeQuery('comment.deleteComment', $args); - if(!$output->toBool()) return new Object(-1, 'msg_error_occured'); - - // 댓글 수를 구해서 업데이트 - $comment_count = $oCommentModel->getCommentCount($document_srl); - - // document의 controller 객체 생성 - $oDocumentController = &getController('document'); - - // 해당글의 댓글 수를 업데이트 - $output = $oDocumentController->updateCommentCount($document_srl, $comment_count); - - $output->add('document_srl', $document_srl); - return $output; - } - - /** - * @brief 특정 글의 모든 댓글 삭제 - **/ - function deleteComments($document_srl) { - // document model객체 생성 - $oDocumentModel = &getModel('document'); - - // 권한이 있는지 확인 - if(!$oDocumentModel->isGranted($document_srl)) return new Object(-1, 'msg_not_permitted'); - - // 삭제 - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('comment.deleteComments', $args); - return $output; - } - - /** - * @brief 특정 모듈의 모든 댓글 삭제 - **/ - function deleteModuleComments($module_srl) { - $oDB = &DB::getInstance(); - $args->module_srl = $module_srl; - $output = $oDB->executeQuery('comment.deleteModuleComments', $args); - return $output; - } - - /** - * @brief 관리자 페이지에서 선택된 댓글들을 삭제 - **/ - function procDeleteChecked() { - // 선택된 글이 없으면 오류 표시 - $cart = Context::get('cart'); - if(!$cart) return $this->stop('msg_cart_is_null'); - $comment_srl_list= explode('|@|', $cart); - $comment_count = count($comment_srl_list); - if(!$comment_count) return $this->stop('msg_cart_is_null'); - - // 글삭제 - for($i=0;$i<$comment_count;$i++) { - $comment_srl = trim($comment_srl_list[$i]); - if(!$comment_srl) continue; - - $this->deleteComment($comment_srl, true); - } - - $this->setMessage( sprintf(Context::getLang('msg_checked_comment_is_deleted'), $comment_count) ); - } } ?> diff --git a/modules/pagemaker/pagemaker.model.php b/modules/pagemaker/pagemaker.model.php index 54d8fe1c2..ae34677ac 100644 --- a/modules/pagemaker/pagemaker.model.php +++ b/modules/pagemaker/pagemaker.model.php @@ -1,11 +1,11 @@ comment_srl = $comment_srl; - $output = $oDB->executeQuery('comment.getChildCommentCount', $args); - return (int)$output->data->count; - } - - /** - * @brief 댓글 가져오기 - **/ - function getComment($comment_srl, $is_admin = false) { - // DB에서 가져옴 - $oDB = &DB::getInstance(); - $args->comment_srl = $comment_srl; - $output = $oDB->executeQuery('comment.getComment', $args); - $comment = $output->data; - - // 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음 - $logged_info = Context::get('logged_info'); - - if($is_admin || $this->isGranted($comment_srl) || $comment->member_srl == $logged_info->member_srl) $comment->is_granted = true; - return $comment; - } - - /** - * @brief 여러개의 댓글들을 가져옴 (페이징 아님) - **/ - function getComments($comment_srl_list) { - if(is_array($comment_srl_list)) $comment_srls = implode(',',$comment_srl_list); - - $oDB = &DB::getInstance(); - $args->comment_srls = $comment_srls; - $output = $oDB->executeQuery('comment.getComments', $args); - return $output->data; - } - - /** - * @brief document_srl 에 해당하는 댓글의 전체 갯수를 가져옴 - **/ - function getCommentCount($document_srl) { - $oDB = &DB::getInstance(); - $args->document_srl = $document_srl; - $output = $oDB->executeQuery('comment.getCommentCount', $args); - $total_count = $output->data->count; - return (int)$total_count; - } - - /** - * @brief document_srl에 해당하는 문서의 댓글 목록을 가져옴 - **/ - function getCommentList($document_srl, $is_admin = false) { - $oDB = &DB::getInstance(); - - $args->document_srl = $document_srl; - $args->list_order = 'list_order'; - $output = $oDB->executeQuery('comment.getCommentList', $args); - if(!$output->toBool()) return $output; - - $source_list= $output->data; - if(!is_array($source_list)) $source_list = array($source_list); - - // 댓글를 계층형 구조로 정렬 - $comment_count = count($source_list); - - $root = NULL; - $list = NULL; - - // 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음 - $logged_info = Context::get('logged_info'); - - for($i=$comment_count-1;$i>=0;$i--) { - $comment_srl = $source_list[$i]->comment_srl; - $parent_srl = $source_list[$i]->parent_srl; - $member_srl = $source_list[$i]->member_srl; - if(!$comment_srl) continue; - - if($is_admin || $this->isGranted($comment_srl) || $member_srl == $logged_info->member_srl) $source_list[$i]->is_granted = true; - - $list[$comment_srl] = $source_list[$i]; - - if($parent_srl) { - $list[$parent_srl]->child[] = &$list[$comment_srl]; - } else { - $root->child[] = &$list[$comment_srl]; - } - } - $this->_arrangeComment($comment_list, $root->child, 0); - return $comment_list; - } - - /** - * @brief 댓글을 계층형으로 재배치 - **/ - function _arrangeComment(&$comment_list, $list, $depth) { - if(!count($list)) return; - foreach($list as $key => $val) { - if($val->child) { - $tmp = $val; - $tmp->depth = $depth; - $comment_list[$tmp->comment_srl] = $tmp; - $this->_arrangeComment($comment_list,$val->child,$depth+1); - } else { - $val->depth = $depth; - $comment_list[$val->comment_srl] = $val; - } - } - } - - /** - * @brief 모든 댓글를 시간 역순으로 가져옴 (관리자용) - **/ - function getTotalCommentList($obj) { - - // DB 객체 생성 - $oDB = &DB::getInstance(); - - $query_id = 'comment.getTotalCommentList'; - - // 변수 설정 - $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; - - // 검색 옵션 정리 - $search_target = trim(Context::get('search_target')); - $search_keyword = trim(Context::get('search_keyword')); - if($search_target && $search_keyword) { - switch($search_target) { - case 'content' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); - $args->s_content = $search_keyword; - break; - case 'user_id' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); - $args->s_user_id = $search_keyword; - $query_id = 'comment.getTotalCommentListWithinMember'; - $args->sort_index = 'comments.list_order'; - break; - case 'user_name' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); - $args->s_user_name = $search_keyword; - break; - case 'nick_name' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); - $args->s_nick_name = $search_keyword; - break; - case 'email_address' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); - $args->s_email_address = $search_keyword; - break; - case 'homepage' : - if($search_keyword) $search_keyword = str_replace(' ','%',$search_keyword); - $args->s_homepage = $search_keyword; - break; - case 'regdate' : - $args->s_regdate = $search_keyword; - break; - case 'last_update' : - $args->s_last_upate = $search_keyword; - break; - case 'ipaddress' : - $args->s_ipaddress= $search_keyword; - break; - } - } - - // comment.getTotalCommentList 쿼리 실행 - $output = $oDB->executeQuery($query_id, $args); - - // 결과가 없거나 오류 발생시 그냥 return - if(!$output->toBool()||!count($output->data)) return $output; - - return $output; - } } ?> diff --git a/modules/pagemaker/pagemaker.view.php b/modules/pagemaker/pagemaker.view.php index 06830649c..196099007 100644 --- a/modules/pagemaker/pagemaker.view.php +++ b/modules/pagemaker/pagemaker.view.php @@ -1,11 +1,11 @@ page = Context::get('page'); ///< 페이지 - $args->list_count = 50; ///< 한페이지에 보여줄 글 수 - $args->page_count = 10; ///< 페이지 네비게이션에 나타날 페이지의 수 - - $args->sort_index = 'list_order'; ///< 소팅 값 - - // 목록 구함, comment->getCommentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다) - $oCommentModel = &getModel('comment'); - $output = $oCommentModel->getTotalCommentList($args); - - // 목록의 loop를 돌면서 mid를 구하기 위한 module_srl값을 구함 - $comment_count = count($output->data); - if($comment_count) { - foreach($output->data as $key => $val) { - $module_srl = $val->module_srl; - if(!in_array($module_srl, $module_srl_list)) $module_srl_list[] = $module_srl; - } - if(count($module_srl_list)) { - $oDB = &DB::getInstance(); - $args->module_srls = implode(',',$module_srl_list); - $mid_output = $oDB->executeQuery('module.getModuleInfoByModuleSrl', $args); - if($mid_output->data && !is_array($mid_output->data)) $mid_output->data = array($mid_output->data); - for($i=0;$idata);$i++) { - $mid_info = $mid_output->data[$i]; - $module_list[$mid_info->module_srl] = $mid_info; - } - } - } - - // 템플릿에 쓰기 위해서 comment_model::getTotalCommentList() 의 return object에 있는 값들을 세팅 - 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); - Context::set('module_list', $module_list); - - // 템플릿 지정 - $this->setTemplatePath($this->module_path.'tpl.admin'); - $this->setTemplateFile('comment_list'); } }