댓글을 관리자가 정한 수만큼 페이징을 하여 보여주도록 기능 추가. 모듈의 업데이트 필요

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3757 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-02-22 19:42:50 +00:00
parent d122c1a0b4
commit 21dcd2d191
37 changed files with 490 additions and 45 deletions

View file

@ -456,7 +456,7 @@
if(!count($_REQUEST)) return; if(!count($_REQUEST)) return;
foreach($_REQUEST as $key => $val) { foreach($_REQUEST as $key => $val) {
if($key == "page" || substr($key,-3)=="srl") $val = (int)$val; if($key == "page" || $key == "cpage" || substr($key,-3)=="srl") $val = (int)$val;
if(is_array($val)) { if(is_array($val)) {
for($i=0;$i<count($val);$i++) { for($i=0;$i<count($val);$i++) {
if(get_magic_quotes_gpc()) $val[$i] = stripslashes($val[$i]); if(get_magic_quotes_gpc()) $val[$i] = stripslashes($val[$i]);

View file

@ -445,7 +445,7 @@
if(!is_array($tables)) $tables = array($tables); if(!is_array($tables)) $tables = array($tables);
foreach($tables as $alias => $table) { foreach($tables as $alias => $table) {
$table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table) ; $table_filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table) ;
if(file_exists($table_filename) && filemtime($table_filename) > $cache_mtime) return false; if(!file_exists($table_filename) || filemtime($table_filename) > $cache_mtime) return false;
} }
$count = (int)FileHandler::readFile($cache_filename); $count = (int)FileHandler::readFile($cache_filename);
@ -480,7 +480,11 @@
if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path); if(!is_dir($this->count_cache_path)) return FileHandler::makeDir($this->count_cache_path);
if(!is_array($tables)) $tables = array($tables); if(!is_array($tables)) $tables = array($tables);
foreach($tables as $alias => $table) FileHandler::writeFile( sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table), '' ); foreach($tables as $alias => $table) {
$filename = sprintf('%s/cache.%s%s', $this->count_cache_path, $this->prefix, $table);
@unlink($filename);
FileHandler::writeFile( $filename, '' );
}
return true; return true;
} }

View file

@ -85,5 +85,19 @@
{@ $idx++} {@ $idx++}
<!--@end--> <!--@end-->
</div>
<!-- 댓글 페이지 네비게이션 -->
<div class="commentPageNavigation">
<a href="{getUrl('cpage',1)}" class="goToFirst"><img src="./images/common/bottomGotoFirst.gif" alt="{$lang->first_page}" width="7" height="5" /></a>
<!--@while($page_no = $comment_page_navigation->getNextPage())-->
<!--@if($cpage == $page_no)-->
<span class="current">{$page_no}</span>
<!--@else-->
<a href="{getUrl('cpage',$page_no)}#comment">{$page_no}</a>
<!--@end-->
<!--@end-->
<a href="{getUrl('cpage',$comment_page_navigation->last_page)}" class="goToLast"><img src="./images/common/bottomGotoLast.gif" alt="{$lang->last_page}" width="7" height="5" /></a>
</div> </div>
<!--@end--> <!--@end-->

View file

@ -8,7 +8,7 @@
.boardList td .replyAndTrackback { font:.8em Tahoma; color:#007ed5; cursor:default; position:relative; top:-.2em;} .boardList td .replyAndTrackback { font:.8em Tahoma; color:#007ed5; cursor:default; position:relative; top:-.2em;}
.boardList td.recommend { font:bold .8em Tahoma; color:#007ed5; text-align:center;} .boardList td.recommend { font:bold .8em Tahoma; color:#007ed5; text-align:center;}
.pageNavigation .current { margin-left:-4px; font:bold .8em Tahoma; color:#007ed5; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; } .pageNavigation .current, .commentPageNavigation .current { margin-left:-4px; font:bold .8em Tahoma; color:#007ed5; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; }
.boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #1187d8;} .boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #1187d8;}
.boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #1187d8; overflow:hidden;} .boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #1187d8; overflow:hidden;}

View file

@ -8,7 +8,7 @@
.boardList td .replyAndTrackback { font:.8em Tahoma; color:#9ab09f; cursor:default; position:relative; top:-.2em;} .boardList td .replyAndTrackback { font:.8em Tahoma; color:#9ab09f; cursor:default; position:relative; top:-.2em;}
.boardList td.recommend { font:bold .8em Tahoma; color:#9ab09f; text-align:center;} .boardList td.recommend { font:bold .8em Tahoma; color:#9ab09f; text-align:center;}
.pageNavigation .current { margin-left:-4px; font:bold .8em Tahoma; color:#9ab09f; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; } .pageNavigation .current , .commentPageNavigation .current{ margin-left:-4px; font:bold .8em Tahoma; color:#9ab09f; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; }
.boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #9ab09f;} .boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #9ab09f;}
.boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #9ab09f; overflow:hidden;} .boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #9ab09f; overflow:hidden;}

View file

@ -128,6 +128,16 @@ Jeong, Chan Myeong 070601~070630
.pageNavigation a.goToFirst img, .pageNavigation a.goToFirst img,
.pageNavigation a.goToLast img { vertical-align:middle;} .pageNavigation a.goToLast img { vertical-align:middle;}
/* comment pageNavigation */
.commentPageNavigation { overflow:hidden; margin:5px 0 10px 0; text-align:center; font:bold .8em Tahoma; }
.commentPageNavigation a, .commentPageNavigation a:visited, .commentPageNavigation a:active { margin-left:-4px; font:bold .8em Tahoma; color:#676767; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; }
.commentPageNavigation a:hover { text-decoration:none; }
.commentPageNavigation a.goToFirst,
.commentPageNavigation a.goToLast { border:none; border-right:1px solid #ffffff; border-left:1px solid #ffffff; z-index:99; padding:1px 5px 3px 4px;}
.commentPageNavigation a.goToFirst img,
.commentPageNavigation a.goToLast img { vertical-align:middle;}
.buttonBox { float:right; margin:1.2em 0 0 0; } .buttonBox { float:right; margin:1.2em 0 0 0; }
/* boardRead */ /* boardRead */

View file

@ -8,7 +8,7 @@
.boardList td .replyAndTrackback { font:.8em Tahoma; color:#27a939; cursor:default; position:relative; top:-.2em;} .boardList td .replyAndTrackback { font:.8em Tahoma; color:#27a939; cursor:default; position:relative; top:-.2em;}
.boardList td.recommend { font:bold .8em Tahoma; color:#27a939; text-align:center;} .boardList td.recommend { font:bold .8em Tahoma; color:#27a939; text-align:center;}
.pageNavigation .current { margin-left:-4px; font:bold .8em Tahoma; color:#27a939; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; } .pageNavigation .current , .commentPageNavigation .current{ margin-left:-4px; font:bold .8em Tahoma; color:#27a939; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; }
.boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #8dc63f;} .boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #8dc63f;}
.boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #8dc63f; overflow:hidden;} .boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #8dc63f; overflow:hidden;}

View file

@ -8,7 +8,7 @@
.boardList td .replyAndTrackback { font:.8em Tahoma; color:#f70795; cursor:default; position:relative; top:-.2em;} .boardList td .replyAndTrackback { font:.8em Tahoma; color:#f70795; cursor:default; position:relative; top:-.2em;}
.boardList td.recommend { font:bold .8em Tahoma; color:#f70795; text-align:center;} .boardList td.recommend { font:bold .8em Tahoma; color:#f70795; text-align:center;}
.pageNavigation .current { margin-left:-4px; font:bold .8em Tahoma; color:#f70795; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; } .pageNavigation .current , .commentPageNavigation .current{ margin-left:-4px; font:bold .8em Tahoma; color:#f70795; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; }
.boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #f70795;} .boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #f70795;}
.boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #f70795; overflow:hidden;} .boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #f70795; overflow:hidden;}

View file

@ -8,7 +8,7 @@
.boardList td .replyAndTrackback { font:.8em Tahoma; color:#ed1f29; cursor:default; position:relative; top:-.2em;} .boardList td .replyAndTrackback { font:.8em Tahoma; color:#ed1f29; cursor:default; position:relative; top:-.2em;}
.boardList td.recommend { font:bold .8em Tahoma; color:#ec2127; text-align:center;} .boardList td.recommend { font:bold .8em Tahoma; color:#ec2127; text-align:center;}
.pageNavigation .current { margin-left:-4px; font:bold .8em Tahoma; color:#ff6600; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; } .pageNavigation .current , .commentPageNavigation .current{ margin-left:-4px; font:bold .8em Tahoma; color:#ff6600; display:inline-block; padding:1px 5px 2px 4px; border-left:1px solid #dedfde; border-right:1px solid #CCCCCC; text-decoration:none; line-height:1em; }
.boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #ed2228;} .boardRead { position:relative; _width:100%; margin:1em 0 0 0; padding: 0 0 .6em 0; border-bottom:3px solid #ed2228;}
.boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #ee202a; overflow:hidden;} .boardRead .readHeader { width:100%; padding-bottom:.5em; margin-bottom:1em; border-bottom:3px solid #ee202a; overflow:hidden;}

View file

@ -89,5 +89,18 @@
</div> </div>
<!--@end--> <!--@end-->
<!-- 댓글 페이지 네비게이션 -->
<div class="pageNavigation">
<a href="{getUrl('cpage',1)}" class="goToFirst"><img src="./images/common/bottomGotoFirst.gif" alt="{$lang->first_page}" width="7" height="5" /></a>
<!--@while($page_no = $comment_page_navigation->getNextPage())-->
<!--@if($cpage == $page_no)-->
<span class="current">{$page_no}</span>
<!--@else-->
<a href="{getUrl('cpage',$page_no)}#comment">{$page_no}</a>
<!--@end-->
<!--@end-->
<a href="{getUrl('cpage',$comment_page_navigation->last_page)}" class="goToLast"><img src="./images/common/bottomGotoLast.gif" alt="{$lang->last_page}" width="7" height="5" /></a>
</div>
</div> </div>
<!--@end--> <!--@end-->

View file

@ -84,5 +84,18 @@
</div> </div>
<!--@end--> <!--@end-->
<!-- 댓글 페이지 네비게이션 -->
<div class="pageNavigation">
<a href="{getUrl('cpage',1)}" class="goToFirst"><img src="./images/common/bottomGotoFirst.gif" alt="{$lang->first_page}" width="7" height="5" /></a>
<!--@while($page_no = $comment_page_navigation->getNextPage())-->
<!--@if($cpage == $page_no)-->
<span class="current">{$page_no}</span>
<!--@else-->
<a href="{getUrl('cpage',$page_no)}#comment">{$page_no}</a>
<!--@end-->
<!--@end-->
<a href="{getUrl('cpage',$comment_page_navigation->last_page)}" class="goToLast"><img src="./images/common/bottomGotoLast.gif" alt="{$lang->last_page}" width="7" height="5" /></a>
</div>
</div> </div>
<!--@end--> <!--@end-->

View file

@ -62,8 +62,47 @@
function deleteModuleComments($module_srl) { function deleteModuleComments($module_srl) {
$args->module_srl = $module_srl; $args->module_srl = $module_srl;
$output = executeQuery('comment.deleteModuleComments', $args); $output = executeQuery('comment.deleteModuleComments', $args);
if(!$output->toBool()) return $output;
$output = executeQuery('comment.deleteModuleCommentsList', $args);
return $output; return $output;
} }
/**
* @brief 댓글의 모듈별 추가 확장 폼을 저장
**/
function procCommentAdminInsertModuleConfig() {
// 기존 설정을 가져옴
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('comment');
// 대상을 구함
$module_srl = Context::get('target_module_srl');
// 여러개의 모듈 일괄 설정일 경우
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
else $module_srl = array($module_srl);
$comment_config = null;
$comment_config->comment_count = (int)Context::get('comment_count');
if(!$comment_config->comment_count) $comment_config->comment_count = 50;
for($i=0;$i<count($module_srl);$i++) {
$srl = trim($module_srl[$i]);
if(!$srl) continue;
$config->module_config[$srl] = $comment_config;
}
// module Controller 객체 생성하여 입력
$oModuleController = &getController('module');
$output = $oModuleController->insertModuleConfig('comment',$config);
$this->setError(-1);
$this->setMessage('success_updated');
}
} }
?> ?>

View file

@ -24,6 +24,9 @@
// 2007. 10. 17 모듈이 삭제될때 등록된 댓글도 모두 삭제하는 트리거 추가 // 2007. 10. 17 모듈이 삭제될때 등록된 댓글도 모두 삭제하는 트리거 추가
$oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after'); $oModuleController->insertTrigger('module.deleteModule', 'comment', 'controller', 'triggerDeleteModuleComments', 'after');
// 2008. 02. 22 모듈의 추가 설정에서 댓글 추가 설정 추가
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
return new Object(); return new Object();
} }
@ -46,6 +49,9 @@
if(!$oModuleModel->getActionForward('dispCommentAdminDeclared')) return true; if(!$oModuleModel->getActionForward('dispCommentAdminDeclared')) return true;
// 2008. 02. 22 모듈의 추가 설정에서 댓글 추가 설정 추가
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before')) return true;
return false; return false;
} }
@ -78,6 +84,10 @@
if(!$oModuleModel->getActionForward('dispCommentAdminDeclared')) if(!$oModuleModel->getActionForward('dispCommentAdminDeclared'))
$oModuleController->insertActionForward('comment', 'view', 'dispCommentAdminDeclared'); $oModuleController->insertActionForward('comment', 'view', 'dispCommentAdminDeclared');
// 2008. 02. 22 모듈의 추가 설정에서 댓글 추가 설정 추가
if(!$oModuleModel->getTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before'))
$oModuleController->insertTrigger('module.dispAdditionSetup', 'comment', 'view', 'triggerDispCommentAdditionSetup', 'before');
return new Object(0, 'success_updated'); return new Object(0, 'success_updated');
} }

View file

@ -118,11 +118,11 @@
// 내용에서 제로보드XE만의 태그를 삭제 // 내용에서 제로보드XE만의 태그를 삭제
$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content); $obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
$obj->regdate = date("YmdHis");
// 세션에서 최고 관리자가 아니면 iframe, script 제거 // 세션에서 최고 관리자가 아니면 iframe, script 제거
if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
if(!$obj->notify_message) $obj->notify_message = 'N'; if(!$obj->notify_message) $obj->notify_message = 'N';
if(!$obj->is_secret) $obj->is_secret = 'N'; if(!$obj->is_secret) $obj->is_secret = 'N';
@ -130,15 +130,48 @@
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$oDB->begin(); $oDB->begin();
// 댓글을 입력 // 댓글 목록 부분을 먼저 입력
$output = executeQuery('comment.insertComment', $obj); $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(!$obj->parent_srl) {
$list_args->head = $list_args->arrange = $obj->comment_srl;
$list_args->depth = 0;
// 부모댓글이 있으면 부모글의 정보를 구해옴
} else {
// 부모댓글의 정보를 구함
$parent_args->comment_srl = $obj->parent_srl;
$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
// 부모댓글이 존재하지 않으면 return
if(!$parent_output->toBool() || !$parent_output->data) return;
$parent = $parent_output->data;
$list_args->head = $parent->head;
$list_args->depth = $parent->depth+1;
if($list_args->depth<2) $list_args->arrange = $obj->comment_srl;
else {
$list_args->arrange = $parent->arrange;
$output = executeQuery('comment.updateCommentListArrange', $list_args);
if(!$output->toBool()) return $output;
}
}
$output = executeQuery('comment.insertCommentList', $list_args);
if(!$output->toBool()) return $output;
// 댓글 본문을 입력
$output = executeQuery('comment.insertComment', $obj);
if(!$output->toBool()) { if(!$output->toBool()) {
$oDB->rollback(); $oDB->rollback();
return $output; return $output;
} }
// 입력에 이상이 없으면 해당 글의 댓글 수를 올림
if(!$manual_inserted) { if(!$manual_inserted) {
// comment model객체 생성 // comment model객체 생성
$oCommentModel = &getModel('comment'); $oCommentModel = &getModel('comment');
@ -156,6 +189,7 @@
$this->addGrant($obj->comment_srl); $this->addGrant($obj->comment_srl);
} }
// trigger 호출 (after) // trigger 호출 (after)
if($output->toBool()) { if($output->toBool()) {
$trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj); $trigger_output = ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
@ -301,6 +335,8 @@
return $output; return $output;
} }
$output = executeQuery('comment.deleteCommentList', $args);
// 댓글 수를 구해서 업데이트 // 댓글 수를 구해서 업데이트
$comment_count = $oCommentModel->getCommentCount($document_srl); $comment_count = $oCommentModel->getCommentCount($document_srl);
@ -341,9 +377,14 @@
$oDocument = $oDocumentModel->getDocument($document_srl); $oDocument = $oDocumentModel->getDocument($document_srl);
if(!$oDocument->isExists() || !$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted'); if(!$oDocument->isExists() || !$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
// 삭제 // 댓글 본문 삭제
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$output = executeQuery('comment.deleteComments', $args); $output = executeQuery('comment.deleteComments', $args);
if(!$output->toBool()) return $output;
// 댓글 목록 삭제
$output = executeQuery('comment.deleteCommentsList', $args);
return $output; return $output;
} }

View file

@ -158,13 +158,62 @@
/** /**
* @brief document_srl에 해당하는 문서의 댓글 목록을 가져옴 * @brief document_srl에 해당하는 문서의 댓글 목록을 가져옴
**/ **/
function getCommentList($document_srl, $is_admin = false) { function getCommentList($document_srl, $page = 1, $is_admin = false) {
// 해당 문서의 모듈에 해당하는 댓글 수를 구함
$oDocumentModel = &getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl);
// 문서가 존재하지 않으면 return~
if(!$oDocument->isExists()) return;
// 댓글수가 없으면 return~
if($oDocument->getCommentCount()<1) return;
// 정해진 댓글수에 따른 댓글 목록 구함
$module_srl = $oDocument->get('module_srl');
$comment_config = $this->getCommentConfig($module_srl);
$comment_count = $comment_config->comment_count;
if(!$comment_count) $comment_count = 50;
if(!$page) !$page = 1;
// 정해진 수에 따라 목록을 구해옴
$args->document_srl = $document_srl;
$args->list_count = $comment_count;
$args->page = $page;
$args->page_count = 10;
$output = executeQueryArray('comment.getCommentPageList', $args);
// 쿼리 결과에서 오류가 생기면 그냥 return
if(!$output->toBool()) return;
// 만약 구해온 결과값이 저장된 댓글수와 다르다면 기존의 데이터로 판단하고 댓글 목록 테이블에 데이터 입력
if(!$output->data) {
$this->fixCommentList($oDocument->get('module_srl'), $document_srl);
$output = executeQueryArray('comment.getCommentPageList', $args);
if(!$output->toBool()) return;
}
return $output;
}
/**
* @brief document_srl에 해당하는 댓글 목록을 갱신
* 정식버전 이전에 사용되던 데이터를 위한 처리
**/
function fixCommentList($module_srl, $document_srl) {
// 일괄 작업이라서 lock 파일을 생성하여 중복 작업이 되지 않도록 한다
$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, '');
// 목록을 구함
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$args->list_order = 'list_order'; $args->list_order = 'list_order';
$output = executeQuery('comment.getCommentList', $args); $output = executeQuery('comment.getCommentList', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
$source_list= $output->data; $source_list = $output->data;
if(!is_array($source_list)) $source_list = array($source_list); if(!is_array($source_list)) $source_list = array($source_list);
// 댓글를 계층형 구조로 정렬 // 댓글를 계층형 구조로 정렬
@ -172,26 +221,18 @@
$root = NULL; $root = NULL;
$list = NULL; $list = NULL;
$comment_list = array();
// 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음 // 로그인 사용자의 경우 로그인 정보를 일단 구해 놓음
$logged_info = Context::get('logged_info'); $logged_info = Context::get('logged_info');
// loop를 돌면서 코멘트의 계층 구조 만듬 // loop를 돌면서 코멘트의 계층 구조 만듬
for($i=$comment_count-1;$i>=0;$i--) { for($i=$comment_count-1;$i>=0;$i--) {
$comment_srl = $source_list[$i]->comment_srl; $comment_srl = $source_list[$i]->comment_srl;
$parent_srl = $source_list[$i]->parent_srl; $parent_srl = $source_list[$i]->parent_srl;
$member_srl = $source_list[$i]->member_srl;
// OL/LI 태그를 위한 치환 처리
//$source_list[$i]->content = preg_replace('!<(ol|ul|blockquote)>!is','<\\1 style="margin-left:40px;">',$source_list[$i]->content);
// url에 대해서 정규표현식으로 치환
$source_list[$i]->content = preg_replace('!([^>^"^\'^=])(http|https|ftp|mms):\/\/([^ ^<^"^\']*)!is','$1<a href="$2://$3" onclick="window.open(this.href);return false;">$2://$3</a>',' '.$source_list[$i]->content);
if(!$comment_srl) continue; 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]; $list[$comment_srl] = $source_list[$i];
@ -201,35 +242,48 @@
$root->child[] = &$list[$comment_srl]; $root->child[] = &$list[$comment_srl];
} }
} }
$this->_arrangeComment($comment_list, $root->child, 0); $this->_arrangeComment($comment_list, $root->child, 0, null);
return $comment_list;
// 구해진 값을 db에 입력함
if(count($comment_list)) {
foreach($comment_list as $comment_srl => $item) {
$comment_args = null;
$comment_args->comment_srl = $comment_srl;
$comment_args->document_srl = $document_srl;
$comment_args->head = $item->head;
$comment_args->arrange = $item->arrange;
$comment_args->module_srl = $module_srl;
$comment_args->regdate = $item->regdate;
$comment_args->depth = $item->depth;
executeQuery('comment.insertCommentList', $comment_args);
}
}
// 성공시 lock파일 제거
@unlink($lock_file);
} }
/** /**
* @brief 댓글을 계층형으로 재배치 * @brief 댓글을 계층형으로 재배치
**/ **/
function _arrangeComment(&$comment_list, $list, $depth, $set_grant = false) { function _arrangeComment(&$comment_list, $list, $depth, $parent = null) {
if(!count($list)) return; if(!count($list)) return;
foreach($list as $key => $val) { foreach($list as $key => $val) {
$oCommentItem = new commentItem();
if($parent) $val->head = $parent->head;
else $val->head = $val->comment_srl;
$val->arrange = count($comment_list)+1;
if($val->child) { if($val->child) {
$tmp = $val; $val->depth = $depth;
$tmp->depth = $depth; $comment_list[$val->comment_srl] = $val;
$oCommentItem->setAttribute($tmp); $this->_arrangeComment($comment_list,$val->child,$depth+1, $val);
unset($val->child);
$comment_list[$tmp->comment_srl] = $oCommentItem;
if($set_grant) $oCommentItem->setAccessible();
$this->_arrangeComment($comment_list,$val->child,$depth+1, $oCommentItem->isGranted());
} else { } else {
$val->depth = $depth; $val->depth = $depth;
$oCommentItem->setAttribute($val); $comment_list[$val->comment_srl] = $val;
if($set_grant) $oCommentItem->setAccessible();
$comment_list[$val->comment_srl] = $oCommentItem;
} }
} }
} }
@ -297,5 +351,25 @@
return $output; return $output;
} }
/**
* @brief 모듈별 댓글 설정을 return
**/
function getCommentConfig($module_srl) {
if(!$GLOBLAS['__comment_module_config__']) {
// 선택된 모듈의 trackback설정을 가져옴
$oModuleModel = &getModel('module');
$GLOBLAS['__comment_module_config__'] = $oModuleModel->getModuleConfig('comment');
}
$comment_config = $GLOBLAS['__comment_module_config__']->module_config[$module_srl];
if(!is_object($comment_config)) $comment_config = null;
if(!isset($comment_config->comment_count)) $comment_count->comment_count = 50;
return $comment_config;
}
} }
?> ?>

View file

@ -0,0 +1,48 @@
<?php
/**
* @class commentView
* @author zero (zero@nzeo.com)
* @brief comment 모듈의 view 클래스
**/
class commentView extends comment {
/**
* @brief 초기화
**/
function init() {
}
/**
* @brief 모듈의 추가 설정에서 댓글 설정을 하는 form 추가
**/
function triggerDispCommentAdditionSetup(&$obj) {
$current_module_srl = Context::get('module_srl');
$current_module_srls = Context::get('module_srls');
if(!$current_module_srl && !$current_module_srls) {
// 선택된 모듈의 정보를 가져옴
$current_module_info = Context::get('current_module_info');
$current_module_srl = $current_module_info->module_srl;
if(!$current_module_srl) return new Object();
}
// 댓글 설정을 구함
$oCommentModel = &getModel('comment');
$comment_config = $oCommentModel->getCommentConfig($current_module_srl);
Context::set('comment_config', $comment_config);
// 그룹 목록을 구함
$oMemberModel = &getModel('member');
$group_list = $oMemberModel->getGroups();
Context::set('group_list', $group_list);
// 템플릿 파일 지정
$oTemplate = &TemplateHandler::getInstance();
$tpl = $oTemplate->compile($this->module_path.'tpl', 'comment_module_config');
$obj .= $tpl;
return new Object();
}
}
?>

View file

@ -10,5 +10,6 @@
<action name="procCommentDeclare" type="controller" standalone="true" /> <action name="procCommentDeclare" type="controller" standalone="true" />
<action name="procCommentAdminDeleteChecked" type="controller" standalone="true" /> <action name="procCommentAdminDeleteChecked" type="controller" standalone="true" />
<action name="procCommentAdminCancelDeclare" type="controller" standalone="true" /> <action name="procCommentAdminCancelDeclare" type="controller" standalone="true" />
<action name="procCommentAdminInsertModuleConfig" type="controller" standalone="true" />
</actions> </actions>
</module> </module>

View file

@ -10,6 +10,9 @@
$lang->comment_list = 'Comments List'; $lang->comment_list = 'Comments List';
$lang->cmd_delete_checked_comment = 'Delete selected item'; $lang->cmd_delete_checked_comment = 'Delete selected item';
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = 'Please select an article to delete'; $lang->msg_cart_is_null = 'Please select an article to delete';
$lang->msg_checked_comment_is_deleted = '%d comment(s) is(are) successfully deleted.'; $lang->msg_checked_comment_is_deleted = '%d comment(s) is(are) successfully deleted.';

View file

@ -10,6 +10,9 @@
$lang->comment_list = 'Comentarios Lista'; $lang->comment_list = 'Comentarios Lista';
$lang->cmd_delete_checked_comment = 'Eliminar lo seleccionado' ; $lang->cmd_delete_checked_comment = 'Eliminar lo seleccionado' ;
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = 'Selecciona el commentario que desea eliminar'; $lang->msg_cart_is_null = 'Selecciona el commentario que desea eliminar';
$lang->msg_checked_comment_is_deleted = '%d comentario eliminado correctamente.'; $lang->msg_checked_comment_is_deleted = '%d comentario eliminado correctamente.';

View file

@ -11,6 +11,9 @@
$lang->cmd_toggle_checked_comment = '選択項目の反転'; $lang->cmd_toggle_checked_comment = '選択項目の反転';
$lang->cmd_delete_checked_comment = '選択項目削除'; $lang->cmd_delete_checked_comment = '選択項目削除';
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = '削除するコメントを選択してください。'; $lang->msg_cart_is_null = '削除するコメントを選択してください。';
$lang->msg_checked_comment_is_deleted = '%d個のコメントを削除しました。'; $lang->msg_checked_comment_is_deleted = '%d個のコメントを削除しました。';

View file

@ -11,6 +11,9 @@
$lang->cmd_toggle_checked_comment = '선택항목 반전'; $lang->cmd_toggle_checked_comment = '선택항목 반전';
$lang->cmd_delete_checked_comment = '선택항목 삭제'; $lang->cmd_delete_checked_comment = '선택항목 삭제';
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = '삭제할 글을 선택해주세요'; $lang->msg_cart_is_null = '삭제할 글을 선택해주세요';
$lang->msg_checked_comment_is_deleted = '%d개의 댓글이 삭제되었습니다'; $lang->msg_checked_comment_is_deleted = '%d개의 댓글이 삭제되었습니다';

View file

@ -10,6 +10,9 @@
$lang->comment_list = 'Список комментариев'; $lang->comment_list = 'Список комментариев';
$lang->cmd_delete_checked_comment = 'Удалить выбранный объект'; $lang->cmd_delete_checked_comment = 'Удалить выбранный объект';
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = 'Пожалуйста, выберите статью для удаления.'; $lang->msg_cart_is_null = 'Пожалуйста, выберите статью для удаления.';
$lang->msg_checked_comment_is_deleted = '%d комментарий(-ия) успешно удален(о).'; $lang->msg_checked_comment_is_deleted = '%d комментарий(-ия) успешно удален(о).';

View file

@ -11,6 +11,9 @@
$lang->cmd_toggle_checked_comment = '反选'; $lang->cmd_toggle_checked_comment = '反选';
$lang->cmd_delete_checked_comment = '删除所选'; $lang->cmd_delete_checked_comment = '删除所选';
$lang->comment_count = '댓글 수';
$lang->about_comment_count = '댓글을 정해진 수 만큼만 표시하고 그 이상일 경우 목록으로 이동할 수 있게 합니다.';
$lang->msg_cart_is_null = '请选择要删除的评论。'; $lang->msg_cart_is_null = '请选择要删除的评论。';
$lang->msg_checked_comment_is_deleted = '已删除%d个评论。'; $lang->msg_checked_comment_is_deleted = '已删除%d个评论。';

View file

@ -0,0 +1,8 @@
<query id="deleteCommentList" action="delete">
<tables>
<table name="comments_list" />
</tables>
<conditions>
<condition operation="equal" column="comment_srl" var="comment_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,8 @@
<query id="deleteCommentsList" action="delete">
<tables>
<table name="comments_list" />
</tables>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,8 @@
<query id="deleteModuleCommentsList" action="delete">
<tables>
<table name="comments_list" />
</tables>
<conditions>
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -3,7 +3,9 @@
<table name="comments" /> <table name="comments" />
</tables> </tables>
<columns> <columns>
<column name="*" /> <column name="comment_srl" />
<column name="parent_srl" />
<column name="regdate" />
</columns> </columns>
<conditions> <conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" /> <condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />

View file

@ -0,0 +1,11 @@
<query id="getCommentListItem" action="select">
<tables>
<table name="comments_list" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="equal" column="comment_srl" var="comment_srl" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,21 @@
<query id="getCommentPageList" action="select">
<tables>
<table name="comments" alias="comments" />
<table name="comments_list" alias="comments_list" />
</tables>
<columns>
<column name="comments.*" />
<column name="depth" alias="depth" />
</columns>
<conditions>
<condition operation="equal" column="comments_list.document_srl" var="document_srl" notnull="notnull" pipe="and" />
<condition operation="equal" column="comments_list.comment_srl" var="comments.comment_srl" filter="number" pipe="and" />
</conditions>
<navigation>
<index var="sort_index" default="head" order="asc" />
<index var="sort_index" default="arrange" order="asc" />
<list_count var="list_count" default="list_count" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
</query>

View file

@ -0,0 +1,14 @@
<query id="insertCommentList" action="insert">
<tables>
<table name="comments_list" />
</tables>
<columns>
<column name="comment_srl" var="comment_srl" notnull="notnull" />
<column name="document_srl" var="document_srl" filter="number" notnull="notnull" />
<column name="head" var="head" filter="number" />
<column name="arrange" var="arrange" filter="number" />
<column name="module_srl" var="module_srl" filter="number" notnull="notnull" />
<column name="regdate" var="regdate" />
<column name="depth" var="depth" filter="number" />
</columns>
</query>

View file

@ -0,0 +1,13 @@
<query id="updateCommentListArrange" action="update">
<tables>
<table name="comments_list" />
</tables>
<columns>
<column name="arrange" default="plus(1)" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="head" var="head" filter="number" notnull="notnull" pipe="and" />
<condition operation="excess" column="arrange" var="arrange" filter="number" notnull="notnull" pipe="and" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="updateCommentListModule" action="update">
<tables>
<table name="comments_list" />
</tables>
<columns>
<column name="module_srl" var="module_srl" filter="number" default="0" />
</columns>
<conditions>
<condition operation="in" column="document_srl" var="document_srls" notnull="notnull" />
</conditions>
</query>

View file

@ -0,0 +1,9 @@
<table name="comments_list">
<column name="comment_srl" type="number" size="11" notnull="notnull" primary_key="primary_key" />
<column name="document_srl" type="number" size="11" default="0" notnull="notnull" index="idx_list" />
<column name="head" type="number" size="11" default="0" notnull="notnull" index="idx_list" />
<column name="arrange" type="number" size="11" default="0" notnull="notnull" index="idx_list" />
<column name="module_srl" type="number" size="11" default="0" notnull="notnull" index="idx_date" />
<column name="regdate" type="date" index="idx_date" />
<column name="depth" type="number" size="11" default="0" notnull="notnull" />
</table>

View file

@ -0,0 +1,27 @@
<!--%import("filter/insert_comment_module_config.xml")-->
<form action="./" method="post" onsubmit="return procFilter(this, insert_comment_module_config)">
<input type="hidden" name="target_module_srl" value="{$module_info->module_srl?$module_info->module_srl:$module_srls}" />
<table cellspacing="0" class="adminTable">
<col width="150" />
<col />
<caption>{$lang->comment}</caption>
<tr>
<th rowspan="2">{$lang->comment_count}</th>
<td>
<input type="text" name="comment_count" value="{$comment_config->comment_count}" class="inputTypeText w80" />
</td>
</tr>
<tr>
<td>{$lang->about_comment_count}</td>
<tr>
<th class="button" colspan="2">
<span class="button"><input type="submit" value="{$lang->cmd_save}"/></span>
</th>
</tr>
</table>
</form>
<div class="gap1"></div>

View file

@ -0,0 +1,7 @@
<filter name="insert_comment_module_config" module="comment" act="procCommentAdminInsertModuleConfig" confirm_msg_code="confirm_submit">
<form />
<response>
<tag name="error" />
<tag name="message" />
</response>
</filter>

View file

@ -207,6 +207,12 @@
return $output; return $output;
} }
$output = executeQuery('comment.updateCommentListModule', $args);
if(!$output->toBool()) {
$oDB->rollback();
return $output;
}
// 엮인글의 이동 // 엮인글의 이동
$output = executeQuery('trackback.updateTrackbackModule', $args); $output = executeQuery('trackback.updateTrackbackModule', $args);
if(!$output->toBool()) { if(!$output->toBool()) {

View file

@ -375,9 +375,24 @@
if(!$this->allowComment() || !$this->getCommentCount()) return; if(!$this->allowComment() || !$this->getCommentCount()) return;
if(!$this->isGranted() && $this->isSecret()) return; if(!$this->isGranted() && $this->isSecret()) return;
$cpage = Context::get('cpage');
if(!$cpage) $cpage = 1;
$oCommentModel = &getModel('comment'); $oCommentModel = &getModel('comment');
$output = $oCommentModel->getCommentList($this->document_srl, $is_admin); $output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
return $output; if(!$output->toBool() || !count($output->data)) return;
$oCommentModel = &getModel('comment');
foreach($output->data as $key => $val) {
$oCommentItem = new commentItem();
$oCommentItem->setAttribute($val);
$comment_list[$val->comment_srl] = $oCommentItem;
}
Context::set('comment_page_navigation', $output->page_navigation);
Context::set('cpage', $output->page_navigation->cur_page);
return $comment_list;
} }
function getTrackbackCount() { function getTrackbackCount() {