mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-23 05:09:56 +09:00
Wiki에 계층보기 기능 추가 (글쓰기 권한이 있는 사용자가 문서들을 tree구조로 바꿀 수 있도록 함)
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6637 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
c40d10f686
commit
461144c955
22 changed files with 431 additions and 4 deletions
|
|
@ -12,6 +12,77 @@
|
|||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 계층구조 추출
|
||||
* document_category테이블을 이용해서 위키 문서의 계층 구조도를 그림
|
||||
* document_category테이블에 등록되어 있지 않은 경우 depth = 0 으로 하여 신규 생성
|
||||
**/
|
||||
function getWikiTreeList() {
|
||||
header("Content-Type: text/xml; charset=UTF-8");
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
$cache_file = sprintf('%sfiles/cache/wiki/%d.xml', _XE_PATH_,$this->module_srl);
|
||||
if(!file_exists($cache_file)) FileHandler::writeFile($cache_file, $this->loadWikiTreeList($this->module_srl));
|
||||
|
||||
print FileHandler::readFile($cache_file);
|
||||
Context::close();
|
||||
exit();
|
||||
}
|
||||
|
||||
function loadWikiTreeList($module_srl) {
|
||||
// 문서 목록
|
||||
$list = array();
|
||||
|
||||
// 목록을 구함
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQueryArray('wiki.getTreeList', $args);
|
||||
|
||||
// 구해온 데이터가 없다면 빈 XML파일 return
|
||||
if($output->data) {
|
||||
// 데이트를 이용하여 XML 문서로 생성
|
||||
foreach($output->data as $node) {
|
||||
$tree[(int)$node->parent_srl][$node->document_srl] = $node;
|
||||
}
|
||||
|
||||
// XML 데이터를 생성
|
||||
$xml_doc = '<root>'.$this->getXmlTree($tree[0], $tree).'</root>';
|
||||
} else {
|
||||
$xml_doc = '<root></root>';
|
||||
}
|
||||
return $xml_doc;
|
||||
}
|
||||
|
||||
function getXmlTree($source_node, $tree) {
|
||||
if(!$source_node) return;
|
||||
|
||||
foreach($source_node as $document_srl => $node) {
|
||||
$child_buff = "";
|
||||
|
||||
// 자식 노드의 데이터 가져옴
|
||||
if($document_srl && $tree[$document_srl]) $child_buff = $this->getXmlTree($tree[$document_srl], $tree);
|
||||
|
||||
// 변수 정리
|
||||
$parent_srl = $node->parent_srl;
|
||||
|
||||
$title = $node->title;
|
||||
$attribute = sprintf(
|
||||
'node_srl="%d" parent_srl="%d" title="%s" ',
|
||||
$document_srl,
|
||||
$parent_srl,
|
||||
$title
|
||||
);
|
||||
|
||||
if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
|
||||
else $buff .= sprintf('<node %s />', $attribute);
|
||||
}
|
||||
return $buff;
|
||||
}
|
||||
|
||||
|
||||
function getContributors($document_srl) {
|
||||
$oDocumentModel = &getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue