mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-26 05:42:13 +09:00
게시글의 카테고리를 다중 depth를 지원하게 하고 게시판 모듈에서 이 다중 depth를 적용하도록 기본 스킨 수정. 게시글 분류 위젯 추가
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3549 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
e539a5e8a2
commit
3a12a24a1f
38 changed files with 475 additions and 112 deletions
|
|
@ -730,7 +730,7 @@
|
|||
**/
|
||||
function makeCategoryFile($module_srl) {
|
||||
// 캐시 파일 생성시 필요한 정보가 없으면 그냥 return
|
||||
if(!$module_srl) return;
|
||||
if(!$module_srl) return false;
|
||||
|
||||
// 모듈 정보를 가져옴 (mid를 구하기 위해)
|
||||
$oModuleModel = &getModel('module');
|
||||
|
|
@ -743,9 +743,22 @@
|
|||
$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
|
||||
$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
|
||||
|
||||
// DB에서 module_srl 에 해당하는 카테고리 목록을 listorder순으로 구해옴
|
||||
$oDocumentModel = &getModel('document');
|
||||
$list = $oDocumentModel->getCategoryList($module_srl);
|
||||
// 카테고리 목록을 구함
|
||||
$args->module_srl = $module_srl;
|
||||
$args->sort_index = 'list_order';
|
||||
$output = executeQuery('document.getCategoryList', $args);
|
||||
|
||||
$category_list = $output->data;
|
||||
|
||||
if(!$category_list) return false;
|
||||
if(!is_array($category_list)) $category_list = array($category_list);
|
||||
|
||||
$category_count = count($category_list);
|
||||
for($i=0;$i<$category_count;$i++) {
|
||||
$category_srl = $category_list[$i]->category_srl;
|
||||
if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
|
||||
$list[$category_srl] = $category_list[$i];
|
||||
}
|
||||
|
||||
// 구해온 데이터가 없다면 노드데이터가 없는 xml 파일만 생성
|
||||
if(!$list) {
|
||||
|
|
@ -780,7 +793,7 @@
|
|||
$xml_buff = sprintf('<?php %s 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"); @session_start(); ?><root>%s</root>', $php_script, $this->getXmlTree($tree[0], $tree));
|
||||
|
||||
// php 캐시 파일 생성
|
||||
$php_output = $this->getPhpCacheCode($tree[0], $tree);
|
||||
$php_output = $this->getPhpCacheCode($tree[0], $tree, 0);
|
||||
$php_buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); %s; $menu->list = array(%s); ?>', $php_output['category_title_str'], $php_output['buff']);
|
||||
|
||||
// 파일 저장
|
||||
|
|
@ -807,13 +820,18 @@
|
|||
$title = str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->title);
|
||||
$expand = $node->expand;
|
||||
$group_srls = $node->group_srls;
|
||||
$mid = $node->mid;
|
||||
$module_srl = $node->module_srl;
|
||||
|
||||
// node->group_srls값이 있으면
|
||||
if($group_srls) $group_check_code = sprintf('($_SESSION["is_admin"]==true||(is_array($_SESSION["group_srls"])&&count(array_intersect($_SESSION["group_srls"], array(%s)))))',$group_srls);
|
||||
else $group_check_code = "true";
|
||||
|
||||
$attribute = sprintf(
|
||||
'node_srl="%s" text="<?php echo (%s?"%s":"")?>" url="%s" expand="%s" document_count="%d" ',
|
||||
'mid="%s" module_srl="%d" node_srl="%d" category_srl = "%d" text="<?php echo (%s?"%s":"")?>" url="%s" expand="%s" document_count="%d" ',
|
||||
$mid,
|
||||
$module_srl,
|
||||
$category_srl,
|
||||
$category_srl,
|
||||
$group_check_code,
|
||||
$title,
|
||||
|
|
@ -838,7 +856,9 @@
|
|||
$output = array("buff"=>"", "category_srl_list"=>array());
|
||||
if(!$source_node) return $output;
|
||||
|
||||
// 루프를 돌면서 1차 배열로 정리하고 include할 수 있는 php script 코드를 생성
|
||||
foreach($source_node as $category_srl => $node) {
|
||||
|
||||
// 자식 노드가 있으면 자식 노드의 데이터를 먼저 얻어옴
|
||||
if($category_srl&&$tree[$category_srl]) $child_output = $this->getPhpCacheCode($tree[$category_srl], $tree);
|
||||
else $child_output = array("buff"=>"", "category_srl_list"=>array());
|
||||
|
|
@ -861,15 +881,18 @@
|
|||
|
||||
// 속성을 생성한다 ( category_srl_list를 이용해서 선택된 메뉴의 노드에 속하는지를 검사한다. 꽁수지만 빠르고 강력하다고 생각;;)
|
||||
$attribute = sprintf(
|
||||
'"node_srl"=>"%s","category_srl"=>"%s","parent_srl"=>"%s","text"=>%s?$_category_title[%d]:"","selected"=>(in_array(Context::get("category"),array(%s))?1:0),"expand"=>"%s", "list"=>array(%s)',
|
||||
'"mid" => "%s", "module_srl" => "%d","node_srl"=>"%s","category_srl"=>"%s","parent_srl"=>"%s","text"=>$_category_title[%d],"selected"=>(in_array(Context::get("category"),array(%s))?1:0),"expand"=>"%s", "list"=>array(%s),"document_count"=>"%d","grant"=>%s?true:false',
|
||||
$node->mid,
|
||||
$node->module_srl,
|
||||
$node->category_srl,
|
||||
$node->category_srl,
|
||||
$node->parent_srl,
|
||||
$group_check_code,
|
||||
$node->category_srl,
|
||||
$selected,
|
||||
$expand,
|
||||
$child_buff
|
||||
$child_buff,
|
||||
$node->document_count,
|
||||
$group_check_code
|
||||
);
|
||||
|
||||
// buff 데이터를 생성한다
|
||||
|
|
|
|||
|
|
@ -565,8 +565,11 @@
|
|||
* @brief 에디터 html을 구해서 return
|
||||
**/
|
||||
function getEditor() {
|
||||
$module_srl = $this->get('module_srl');
|
||||
if(!$module_srl) $module_srl = Context::get('module_srl');
|
||||
|
||||
$oEditorModel = &getModel('editor');
|
||||
return $oEditorModel->getModuleEditor('document', $this->get('module_srl'), $this->document_srl, 'document_srl', 'content');
|
||||
return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -406,23 +406,86 @@
|
|||
|
||||
/**
|
||||
* @brief 특정 모듈의 카테고리 목록을 가져옴
|
||||
* 속도나 여러가지 상황을 고려해서 카테고리 목록은 php로 생성된 script를 include하여 사용하는 것을 원칙으로 함
|
||||
**/
|
||||
function getCategoryList($module_srl) {
|
||||
// 한 페이지에서 여러번 호출될 경우를 대비해서 static var로 보관 (php4때문에 다른 방법으로 구현)
|
||||
if(isset($this->category_list[$module_srl])) return $this->category_list[$module_srl];
|
||||
|
||||
// php 캐싱된 파일의 유무를 체크하여 처리
|
||||
$args->module_srl = $module_srl;
|
||||
$args->sort_index = 'list_order';
|
||||
$output = executeQuery('document.getCategoryList', $args);
|
||||
|
||||
$category_list = $output->data;
|
||||
// 대상 모듈의 카테고리 파일을 불러옴
|
||||
$filename = sprintf("./files/cache/document_category/%s.php", $module_srl);
|
||||
|
||||
if(!$category_list) return NULL;
|
||||
if(!is_array($category_list)) $category_list = array($category_list);
|
||||
|
||||
$category_count = count($category_list);
|
||||
for($i=0;$i<$category_count;$i++) {
|
||||
$category_srl = $category_list[$i]->category_srl;
|
||||
$list[$category_srl] = $category_list[$i];
|
||||
// 대상 파일이 없으면 카테고리 캐시 파일을 재생성
|
||||
if(!file_exists($filename)) {
|
||||
$oDocumentController = &getController('document');
|
||||
if(!$oDocumentController->makeCategoryFile($module_srl)) return array();
|
||||
}
|
||||
return $list;
|
||||
|
||||
@include($filename);
|
||||
|
||||
// 카테고리의 정리
|
||||
$document_category = array();
|
||||
$this->_arrangeCategory($document_category, $menu->list, 0);
|
||||
|
||||
return $document_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 카테고리를 1차 배열 형식으로 변경하는 내부 method
|
||||
**/
|
||||
function _arrangeCategory(&$document_category, $list, $depth) {
|
||||
$idx = 0;
|
||||
$list_order = array();
|
||||
foreach($list as $key => $val) {
|
||||
$obj = null;
|
||||
$obj->mid = $val['mid'];
|
||||
$obj->module_srl = $val['module_srl'];
|
||||
$obj->category_srl = $val['category_srl'];
|
||||
$obj->parent_srl = $val['parent_srl'];
|
||||
$obj->title = $obj->text = $val['text'];
|
||||
$obj->expand = $val['expand']=='Y'?true:false;
|
||||
$obj->document_count = $val['document_count'];
|
||||
$obj->depth = $depth;
|
||||
$obj->child_count = 0;
|
||||
$obj->childs = array();
|
||||
$obj->grant = $val['grant'];
|
||||
|
||||
if(Context::get('mid') == $obj->mid && Context::get('category') == $obj->category_srl) $selected = true;
|
||||
else $selected = false;
|
||||
|
||||
$obj->selected = $selected;
|
||||
|
||||
$list_order[$idx++] = $obj->category_srl;
|
||||
|
||||
// 부모 카테고리가 있으면 자식노드들의 데이터를 적용
|
||||
if($obj->parent_srl) {
|
||||
|
||||
$parent_srl = $obj->parent_srl;
|
||||
$document_count = $obj->document_count;
|
||||
$expand = $obj->expand;
|
||||
if($selected) $expand = true;
|
||||
|
||||
while($parent_srl) {
|
||||
$document_category[$parent_srl]->document_count += $document_count;
|
||||
$document_category[$parent_srl]->childs[] = $obj->category_srl;
|
||||
$document_category[$parent_srl]->child_count = count($document_category[$parent_srl]->childs);
|
||||
if($expand) $document_category[$parent_srl]->expand = $expand;
|
||||
|
||||
$parent_srl = $document_category[$parent_srl]->parent_srl;
|
||||
}
|
||||
}
|
||||
|
||||
$document_category[$key] = $obj;
|
||||
|
||||
if(count($val['list'])) $this->_arrangeCategory($document_category, $val['list'], $depth+1);
|
||||
}
|
||||
$document_category[$list_order[0]]->first = true;
|
||||
$document_category[$list_order[count($list_order)-1]]->last = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -513,7 +576,7 @@
|
|||
|
||||
$output = '';
|
||||
foreach($categories as $category_srl => $category) {
|
||||
$output .= sprintf("%d,%s\n",$category_srl, $category->title);
|
||||
$output .= sprintf("%d,%d,%s\n",$category_srl, $category->depth,$category->title);
|
||||
}
|
||||
$this->add('categories', $output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,12 +60,19 @@ function completeGetCategoryFromModules(ret_obj, response_tags) {
|
|||
var category_list = categories.split("\n");
|
||||
for(var i=0;i<category_list.length;i++) {
|
||||
var item = category_list[i];
|
||||
|
||||
var pos = item.indexOf(',');
|
||||
var category_srl = item.substr(0,pos);
|
||||
|
||||
var item = item.substr(pos+1, item.length);
|
||||
var pos = item.indexOf(',');
|
||||
var depth = item.substr(0,pos);
|
||||
|
||||
var category_title = item.substr(pos+1,item.length);
|
||||
if(!category_srl || !category_title) continue;
|
||||
|
||||
var opt = new Option(category_title, category_srl, false, false);
|
||||
if(depth>0) opt.style.paddingLeft = (depth*15)+'px';
|
||||
obj.options[obj.options.length] = opt;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue