Wiki에 계층보기 기능 추가 (글쓰기 권한이 있는 사용자가 문서들을 tree구조로 바꿀 수 있도록 함)

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6637 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2009-06-22 09:16:53 +00:00
parent c40d10f686
commit 461144c955
22 changed files with 431 additions and 4 deletions

View file

@ -152,6 +152,103 @@
$this->add('document_srl', $output->get('document_srl'));
$this->setMessage('success_deleted');
}
function procWikiMoveTree() {
// 권한 체크
if(!$this->grant->write_document) return new Object(-1, 'msg_not_permitted');
// request argument 추출
$args = Context::gets('parent_srl','target_srl','source_srl');
debugPrint($args);
// 노드 정보 구함
$output = executeQuery('wiki.getTreeNode', $args);
$node = $output->data;
if(!$node->document_srl) return new Object('msg_invalid_request');
$args->module_srl = $node->module_srl;
$args->title = $node->title;
// parent_srl 이 있으면 자식으로 추가
if($args->parent_srl) {
// target이 없으면 부모의 list_order중 최소 list_order를 구함
if(!$args->target_srl) {
$list_order->parent_srl = $args->parent_srl;
$output = executeQuery('wiki.getTreeMinListorder',$list_order);
if($output->data->list_order) $args->list_order = $output->data->list_order-1;
// target이 있으면 그 target의 list_order + 1
} else {
$t_args->source_srl = $args->target_srl;
$output = executeQuery('wiki.getTreeNode', $t_args);
$target = $output->data;
// target보다 list_order가 크고 부모가 같은 node에 대해서 list_order+2를 해주고 선택된 node에 list_order+1을 해줌
$update_args->module_srl = $target->module_srl;
$update_args->parent_srl = $target->parent_srl;
$update_args->list_order = $target->list_order;
$output = executeQuery('wiki.updateTreeListOrder', $update_args);
if(!$output->toBool()) return $output;
// target을 원위치 (list_order중복 문제로 인하여 1번 더 업데이트를 시도함)
$restore_args->module_srl = $target->module_srl;
$restore_args->source_srl = $target->document_srl;
$restore_args->list_order = $target->list_order;
$output = executeQuery('wiki.updateTreeNode', $restore_args);
if(!$output->toBool()) return $output;
$args->list_order = $target->list_order+1;
}
if(!$node->is_exists) $output = executeQuery('wiki.insertTreeNode',$args);
else $output = executeQuery('wiki.updateTreeNode',$args);
if(!$output->toBool()) return $output;
if($args->list_order) {
$doc->document_srl = $args->source_srl;
$doc->list_order = $args->list_order;
$output = executeQuery('wiki.updateDocumentListOrder', $doc);
if(!$output->toBool()) return $output;
}
// parent_srl이 없고 target_srl 이 있으면 형제로 node 업데이트
} elseif($args->target_srl) {
$t_args->source_srl = $args->target_srl;
$output = executeQuery('wiki.getTreeNode', $t_args);
$target = $output->data;
// target보다 list_order가 크고 부모가 같은 node에 대해서 list_order+2를 해주고 선택된 node에 list_order+1을 해줌
$update_args->module_srl = $target->module_srl;
$update_args->parent_srl = $target->parent_srl;
$update_args->list_order = $target->list_order;
$output = executeQuery('wiki.updateTreeListOrder', $update_args);
if(!$output->toBool()) return $output;
// target을 원위치 (list_order중복 문제로 인하여 1번 더 업데이트를 시도함)
$restore_args->module_srl = $target->module_srl;
$restore_args->source_srl = $target->document_srl;
$restore_args->list_order = $target->list_order;
$output = executeQuery('wiki.updateTreeNode', $restore_args);
if(!$output->toBool()) return $output;
$args->list_order = $target->list_order+1;
// 선택된 노드의 부모 값 맞춤
$args->parent_srl = $target->parent_srl;
if(!$node->is_exists) $output = executeQuery('wiki.insertTreeNode',$args);
else $output = executeQuery('wiki.updateTreeNode',$args);
if(!$output->toBool()) return $output;
if($args->list_order) {
$doc->document_srl = $args->source_srl;
$doc->list_order = $args->list_order;
$output = executeQuery('wiki.updateDocumentListOrder', $doc);
if(!$output->toBool()) return $output;
}
}
// 캐시파일 재생성
FileHandler::removeFile(sprintf('%sfiles/cache/wiki/%d.xml', _XE_PATH_,$this->module_srl));
}
}
?>