From e14d7f8015201a35dc49db37b8507c3de8060f8b Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 8 Mar 2007 07:47:45 +0000 Subject: [PATCH] git-svn-id: http://xe-core.googlecode.com/svn/trunk@337 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- config/config.inc.php | 2 +- layouts/sample_layout/layout.html | 1 - modules/layout/layout.controller.php | 40 +++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/config/config.inc.php b/config/config.inc.php index b3e18ff9e..b245bef4b 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -18,7 +18,7 @@ /** * @brief debug mode = true 일때 files/_debug_message.php 에 디버그 내용이 쌓임 **/ - define('__DEBUG__', true); + define('__DEBUG__', false); if(__DEBUG__) { // php5이상이면 error handling을 handleError() 로 set diff --git a/layouts/sample_layout/layout.html b/layouts/sample_layout/layout.html index c06834b0a..6faec191d 100644 --- a/layouts/sample_layout/layout.html +++ b/layouts/sample_layout/layout.html @@ -1,5 +1,4 @@ - diff --git a/modules/layout/layout.controller.php b/modules/layout/layout.controller.php index 08df777ec..ffa126dd8 100644 --- a/modules/layout/layout.controller.php +++ b/modules/layout/layout.controller.php @@ -219,8 +219,9 @@ $output = $oDB->executeQuery("layout.getLayoutMenuList", $args); if(!$output->toBool()) return; - // xml 파일의 이름을 지정 + // 캐시 파일의 이름을 지정 $xml_file = sprintf("./files/cache/layout/%s_%s.xml", $layout_srl, $menu_id); + $php_file = sprintf("./files/cache/layout/%s_%s.php", $layout_srl, $menu_id); // 구해온 데이터가 없다면 노드데이터가 없는 xml 파일만 생성 $list = $output->data; @@ -243,10 +244,12 @@ $tree[$parent_srl][$menu_srl] = $node; } - // 파일 생성 - $xml_buff = "".$this->getXmlTree($tree[0], $tree).""; + $xml_buff = sprintf('%s', $this->getXmlTree($tree[0], $tree)); + $php_buff = sprintf('', $menu_id, $this->getPhpCacheCode($tree[0], $tree)); + debugPrint($php_buff); FileHandler::writeFile($xml_file, $xml_buff); + FileHandler::writeFile($php_file, $php_buff); return $xml_file; } @@ -280,5 +283,36 @@ } return $buff; } + + /** + * @brief array로 정렬된 노드들을 php code로 변경하여 return + * 레이아웃에서 메뉴를 tpl에 사용시 xml데이터를 사용할 수도 있지만 별도의 javascript 사용이 필요하기에 + * php로 된 캐시파일을 만들어서 db이용없이 바로 메뉴 정보를 구할 수 있도록 한다 + * 이 캐시는 ModuleHandler::displayContent() 에서 include하여 Context::set() 한다 + **/ + function getPhpCacheCode($source_node, $tree) { + if(!$source_node) return; + foreach($source_node as $menu_srl => $node) { + $child_buff = ""; + + if($menu_srl&&$tree[$menu_srl]) $child_buff = $this->getPhpCacheCode($tree[$menu_srl], $tree); + + $attribute = sprintf( + '"node_srl"=>"%s","text"=>"%s","url"=>"%s","open_window"=>"%s","normal_btn"=>"%s","hover_btn"=>"%s","active_btn"=>"%s","group_srls"=>array(%s),%s', + $node->menu_srl, + str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->name), + str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->url), + $node->open_window, + str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->normal_btn), + str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->hover_btn), + str_replace(array('&','"','<','>'),array('&','"','<','>'),$node->active_btn), + $node->group_srls, + $child_buff + ); + + $buff .= sprintf('%s=>array(%s),'."\n", $node->menu_srl, $attribute); + } + return $buff; + } } ?>