diff --git a/common/lang/ko.lang.php b/common/lang/ko.lang.php index 4c29b8ba6..48e70f3a9 100644 --- a/common/lang/ko.lang.php +++ b/common/lang/ko.lang.php @@ -79,6 +79,7 @@ $lang->target = "대상"; $lang->total_count = "전체개수"; $lang->ipaddress = "IP 주소"; + $lang->path = "경로"; $lang->document_url = '게시글 주소'; $lang->trackback_url = '엮인글 주소'; @@ -152,4 +153,20 @@ $lang->confirm_logout = '로그아웃하시겠습니까?'; $lang->confirm_vote = '추천하시겠습니까?'; $lang->confirm_delete = '삭제하시겠습니까?'; + + $lang->column_type = '형식'; + $lang->column_type_list['text'] = '한줄 입력칸 (text)'; + $lang->column_type_list['homepage'] = '홈페이지 형식 (url)'; + $lang->column_type_list['email_address'] = '이메일 형식 (email)'; + $lang->column_type_list['tel'] = '전화번호 형식 (phone)'; + $lang->column_type_list['textarea'] = '여러줄 입력칸 (textarea)'; + $lang->column_type_list['checkbox'] = '다중 선택 (checkbox)'; + $lang->column_type_list['select'] = '단일 선택 (select)'; + $lang->column_type_list['kr_zip'] = '한국주소 (zip)'; + //$lang->column_type_list['jp_zip'] = '일본주소 (zip)'; + $lang->column_name = '입력항목 이름'; + $lang->column_title = '입력항목 제목'; + $lang->default_value = '기본 값'; + $lang->is_active = '활성'; + $lang->is_required = '필수항목'; ?> diff --git a/layouts/sample_layout/conf/info.xml b/layouts/sample_layout/conf/info.xml index 82c5ada52..89ba67d20 100644 --- a/layouts/sample_layout/conf/info.xml +++ b/layouts/sample_layout/conf/info.xml @@ -11,16 +11,39 @@ sample layout - - + + + 상단 제목 + top title + text + + + 간단한 내용 + memo + textarea + + + 컬러셋 + colorset + select + + red + blue + green + rightred + + + + + 주메뉴 main menu 2 - - + + 하단 메뉴 bottom menu 1 - - + + diff --git a/modules/admin/admin.view.php b/modules/admin/admin.view.php index fdffb5511..7dee74dc1 100644 --- a/modules/admin/admin.view.php +++ b/modules/admin/admin.view.php @@ -90,7 +90,7 @@ **/ function dispLayoutList() { $oLayoutView = &getView('layout'); - $oLayoutView->dispLayoutList(); + $oLayoutView->dispDownloadedLayoutList(); $this->setTemplatePath($oLayoutView->getTemplatePath()); $this->setTemplateFile($oLayoutView->getTemplateFile()); diff --git a/modules/layout/conf/module.xml b/modules/layout/conf/module.xml index 09f34d472..dc72b0881 100644 --- a/modules/layout/conf/module.xml +++ b/modules/layout/conf/module.xml @@ -2,7 +2,6 @@ - diff --git a/modules/layout/layout.controller.php b/modules/layout/layout.controller.php index 7044022ff..5bf5959d4 100644 --- a/modules/layout/layout.controller.php +++ b/modules/layout/layout.controller.php @@ -15,6 +15,7 @@ /** * @brief 레이아웃 신규 생성 + * 레이아웃의 신규 생성은 제목만 받아서 layouts테이블에 입력함 **/ function procInsertLayout() { $oDB = &DB::getInstance(); @@ -30,7 +31,38 @@ } /** - * @brief 레이아웃 메뉴 추가 + * @brief 레이아웃 삭제 + * 삭제시 메뉴 xml 캐시 파일도 삭제 + **/ + function procDeleteLayout() { + $layout_srl = Context::get('layout_srl'); + + // 캐시 파일 삭제 + $cache_list = FileHandler::readDir("./files/cache/layout","",false,true); + if(count($cache_list)) { + foreach($cache_list as $cache_file) { + $pos = strpos($cache_file, $layout_srl.'_'); + if($pos>0) unlink($cache_file); + } + } + + // DB에서 삭제 + $oDB = &DB::getInstance(); + + // 레이아웃 메뉴 삭제 + $args->layout_srl = $layout_srl; + $output = $oDB->executeQuery("layout.deleteLayoutMenus", $args); + if(!$output->toBool()) return $output; + + // 레이아웃 삭제 + $output = $oDB->executeQuery("layout.deleteLayout", $args); + if(!$output->toBool()) return $output; + + $this->setMessage('success_deleted'); + } + + /** + * @brief 레이아웃에 메뉴 추가 **/ function procInsertLayoutMenu() { // 입력할 변수 정리 @@ -74,14 +106,7 @@ // 해당 메뉴의 정보를 구함 $layout_info = $oLayoutModel->getLayoutInfoXml($layout); - $navigations = $layout_info->navigations; - if(count($navigations)) { - foreach($navigations as $key => $val) { - if($args->menu_id == $val->id) { - $menu_title = $val->name; - } - } - } + $menu_title = $layout_info->menu->{$args->menu_id}->name; // XML 파일을 갱신하고 위치을 넘겨 받음 $xml_file = $this->makeXmlFile($args->layout_srl, $args->menu_id); @@ -92,35 +117,6 @@ $this->add('menu_title', $menu_title); } - /** - * @brief 레이아웃 삭제 - **/ - function procDeleteLayout() { - $layout_srl = Context::get('layout_srl'); - - // 캐시 파일 삭제 - $cache_list = FileHandler::readDir("./files/cache/layout","",false,true); - if(count($cache_list)) { - foreach($cache_list as $cache_file) { - $pos = strpos($cache_file, $layout_srl.'_'); - if($pos>0) unlink($cache_file); - } - } - - // DB에서 삭제 - $oDB = &DB::getInstance(); - - // 레이아웃 메뉴 삭제 - $args->layout_srl = $layout_srl; - $output = $oDB->executeQuery("layout.deleteLayoutMenus", $args); - if(!$output->toBool()) return $output; - - // 레이아웃 삭제 - $output = $oDB->executeQuery("layout.deleteLayout", $args); - if(!$output->toBool()) return $output; - - $this->setMessage('success_deleted'); - } /** * @brief 레이아웃 메뉴 삭제 @@ -137,10 +133,9 @@ $oDB = &DB::getInstance(); - // 자식 노드가 있는지 체크 + // 자식 노드가 있는지 체크하여 있으면 삭제 못한다는 에러 출력 $output = $oDB->executeQuery('layout.getChildMenuCount', $args); if(!$output->toBool()) return $output; - if($output->data->count>0) return new Object(-1, msg_cannot_delete_for_child); // DB에서 삭제 @@ -149,14 +144,7 @@ // 해당 메뉴의 정보를 구함 $layout_info = $oLayoutModel->getLayoutInfoXml($args->layout); - $navigations = $layout_info->navigations; - if(count($navigations)) { - foreach($navigations as $key => $val) { - if($args->menu_id == $val->id) { - $menu_title = $val->name; - } - } - } + $menu_title = $layout_info->menu->{$args->menu_id}->name; // XML 파일을 갱신하고 위치을 넘겨 받음 $xml_file = $this->makeXmlFile($args->layout_srl, $args->menu_id); @@ -169,6 +157,9 @@ /** * @brief xml 파일을 갱신 + * 관리자페이지에서 메뉴 구성 후 간혹 xml파일이 재생성 안되는 경우가 있는데\n + * 이럴 경우 관리자의 수동 갱신 기능을 구현해줌\n + * 개발 중간의 문제인 것 같고 현재는 문제가 생기지 않으나 굳이 없앨 필요 없는 기능 **/ function procMakeXmlFile() { // 입력값을 체크 @@ -179,14 +170,7 @@ // 해당 메뉴의 정보를 구함 $oLayoutModel = &getModel('layout'); $layout_info = $oLayoutModel->getLayoutInfoXml($layout); - $navigations = $layout_info->navigations; - if(count($navigations)) { - foreach($navigations as $key => $val) { - if($menu_id == $val->id) { - $menu_title = $val->name; - } - } - } + $menu_title = $layout_info->menu->{$menu_id}->name; // xml파일 재생성 $xml_file = $this->makeXmlFile($layout_srl, $menu_id); @@ -201,6 +185,7 @@ * @brief 메뉴의 xml 파일을 만들고 위치를 return **/ function makeXmlFile($layout_srl, $menu_id) { + // xml파일 생성시 필요한 정보가 없으면 그냥 return if(!$layout_srl || !$menu_id) return; // DB에서 layout_srl에 해당하는 메뉴 목록을 listorder순으로 구해옴 @@ -213,13 +198,15 @@ // xml 파일의 이름을 지정 $xml_file = sprintf("./files/cache/layout/%s_%s.xml", $layout_srl, $menu_id); - // 구해온 데이터가 없다면 걍 return + // 구해온 데이터가 없다면 노드데이터가 없는 xml 파일만 생성 $list = $output->data; if(!$list) { $xml_buff = ""; FileHandler::writeFile($xml_file, $xml_buff); return $xml_file; } + + // 구해온 데이터가 하나라면 array로 바꾸어줌 if(!is_array($list)) $list = array($list); // 루프를 돌면서 tree 구성 @@ -232,13 +219,17 @@ $tree[$parent_srl][$menu_srl] = $node; } + // 파일 생성 $xml_buff = "".$this->getXmlTree($tree[0], $tree).""; FileHandler::writeFile($xml_file, $xml_buff); + return $xml_file; } /** * @brief array로 정렬된 노드들을 parent_srl을 참조하면서 recursive하게 돌면서 xml 데이터 생성 + * 메뉴 xml파일은 node라는 tag가 중첩으로 사용되며 이 xml doc으로 관리자 페이지에서 메뉴를 구성해줌\n + * (tree_menu.js 에서 xml파일을 바로 읽고 tree menu를 구현) **/ function getXmlTree($source_node, $tree) { if(!$source_node) return; diff --git a/modules/layout/layout.model.php b/modules/layout/layout.model.php index b71954f5a..3cb37d4f4 100644 --- a/modules/layout/layout.model.php +++ b/modules/layout/layout.model.php @@ -2,6 +2,7 @@ /** * @class layoutModel * @author zero (zero@nzeo.com) + * @version 0.1 * @brief layout 모듈의 Model class **/ @@ -15,6 +16,7 @@ /** * @brief DB 에 생성된 레이아웃의 목록을 구함 + * 생성되었다는 것은 DB에 등록이 되었다는 것을 의미 **/ function getLayoutList() { $oDB = &DB::getInstance(); @@ -27,6 +29,7 @@ /** * @brief DB 에 생성된 한개의 레이아웃 정보를 구함 + * 생성된 레이아웃의 DB정보를 return **/ function getLayout($layout_srl) { $oDB = &DB::getInstance(); @@ -39,6 +42,7 @@ /** * @brief 레이아웃의 경로를 구함 + * 기본으로는 ./layouts에 있지만 웹관리기능으로 다운로드시 ./files/layouts에 존재함 **/ function getLayoutPath($layout_name) { $class_path = sprintf('./files/layouts/%s/', $layout_name); @@ -52,6 +56,7 @@ /** * @brief 레이아웃의 종류와 정보를 구함 + * 다운로드되어 있는 레이아웃의 종류 (생성과 다른 의미) **/ function getDownloadedLayoutList() { // 다운받은 레이아웃과 설치된 레이아웃의 목록을 구함 @@ -61,27 +66,22 @@ $searched_count = count($searched_list); if(!$searched_count) return; + // 찾아진 레이아웃 목록을 loop돌면서 필요한 정보를 간추려 return for($i=0;$i<$searched_count;$i++) { // 레이아웃의 이름 - $layout_name = $searched_list[$i]; - - // 레이아웃의 경로 (files/layouts가 우선) - $path = $this->getLayoutPath($layout_name); + $layout = $searched_list[$i]; // 해당 레이아웃의 정보를 구함 - $info = $this->getLayoutInfoXml($layout_name); - unset($obj); + $layout_info = $this->getLayoutInfoXml($layout); - $info->layout = $layout_name; - $info->path = $path; - - $list[] = $info; + $list[] = $layout_info; } return $list; } /** * @brief 모듈의 conf/info.xml 을 읽어서 정보를 구함 + * 이것 역시 캐싱을 통해서 xml parsing 시간을 줄인다.. **/ function getLayoutInfoXml($layout, $layout_srl = 0) { // 요청된 모듈의 경로를 구한다. 없으면 return @@ -92,60 +92,61 @@ $xml_file = sprintf("%sconf/info.xml", $layout_path); if(!file_exists($xml_file)) return; + // cache 파일을 비교하여 문제 없으면 include하고 $layout_info 변수를 return + $cache_file = sprintf('./files/cache/layout/%s.cache.php', $layout); + if(file_exists($cache_file)&&filectime($cache_file)>filectime($xml_file)) { + include $cache_file; + return $layout_info; + } + + // cache 파일이 없으면 xml parsing하고 변수화 한 후에 캐시 파일에 쓰고 변수 바로 return $oXmlParser = new XmlParser(); $tmp_xml_obj = $oXmlParser->loadXmlFile($xml_file); $xml_obj = $tmp_xml_obj->layout; - if(!$xml_obj) return; - $info->title = $xml_obj->title->body; + $buff = ''; + + // 레이아웃의 제목, 버전 + $buff .= sprintf('$layout_info->layout = "%s";', $layout); + $buff .= sprintf('$layout_info->path = "%s";', $layout_path); + $buff .= sprintf('$layout_info->title = "%s";', $xml_obj->title->body); + $buff .= sprintf('$layout_info->version = "%s";', $xml_obj->attrs->version); // 작성자 정보 - $layout_info->title = $xml_obj->title->body; - $layout_info->version = $xml_obj->attrs->version; - $layout_info->author->name = $xml_obj->author->name->body; - $layout_info->author->email_address = $xml_obj->author->attrs->email_address; - $layout_info->author->homepage = $xml_obj->author->attrs->link; - $layout_info->author->date = $xml_obj->author->attrs->date; - $layout_info->author->description = $xml_obj->author->description->body; + $buff .= sprintf('$layout_info->author->name = "%s";', $xml_obj->author->name->body); + $buff .= sprintf('$layout_info->author->email_address = "%s";', $xml_obj->author->attrs->email_address); + $buff .= sprintf('$layout_info->author->homepage = "%s";', $xml_obj->author->attrs->link); + $buff .= sprintf('$layout_info->author->date = "%s";', $xml_obj->author->attrs->date); + $buff .= sprintf('$layout_info->author->description = "%s";', $xml_obj->author->description->body); - // history - if(!is_array($xml_obj->history->author)) $history[] = $xml_obj->history->author; - else $history = $xml_obj->history->author; + // 추가 변수 (템플릿에서 사용할 제작자 정의 변수) - foreach($history as $item) { - unset($obj); - $obj->name = $item->name->body; - $obj->email_address = $item->attrs->email_address; - $obj->homepage = $item->attrs->link; - $obj->date = $item->attrs->date; - $obj->description = $item->description->body; - $layout_info->history[] = $obj; + // 메뉴 + if(!is_array($xml_obj->menus->menu)) $menus[] = $xml_obj->menus->menu; + else $menus = $xml_obj->menus->menu; + + $menu_count = count($menus); + $buff .= sprintf('$layout_info->menu_count = "%s";', count($menus)); + for($i=0;$i<$menu_count;$i++) { + $id = $menus[$i]->attrs->id; + + $buff .= sprintf('$layout_info->menu->{%s}->id = "%s";',$id, $menus[$i]->attrs->id); + $buff .= sprintf('$layout_info->menu->{%s}->name = "%s";',$id, $menus[$i]->name->body); + $buff .= sprintf('$layout_info->menu->{%s}->maxdepth = "%s";',$id, $menus[$i]->maxdepth->body); + $buff .= sprintf('$layout_info->menu->{%s}->xml_file = "./files/cache/layout/".$layout_srl."_%s.xml";',$id, $id); } - // navigations - if(!is_array($xml_obj->navigations->navigation)) $navigations[] = $xml_obj->navigations->navigation; - else $navigations = $xml_obj->navigations->navigation; - - unset($item); - foreach($navigations as $item) { - unset($obj); - $obj->id = $item->attrs->id; - $obj->name = $item->name->body; - $obj->maxdepth = $item->maxdepth->body; - $obj->xml_file = sprintf("./files/cache/layout/%s_%s.xml", $layout_srl, $obj->id); - if($layout_srl && !file_exists($obj->xml_file)) { - $buff = ""; - FileHandler::writeFile($obj->xml_file, $buff); - } - $layout_info->navigations[] = $obj; - } + $buff = ''; + FileHandler::writeFile($cache_file, $buff); + if(file_exists($cache_file)) include $cache_file; return $layout_info; } /** * @brief 특정 menu_srl의 정보를 return + * 이 정보중에 group_srls의 경우는 , 로 연결되어 들어가며 사용시에는 explode를 통해 array로 변환 시킴 **/ function getLayoutMenuInfo($menu_srl) { $oDB = &DB::getInstance(); @@ -162,6 +163,7 @@ /** * @brief 특정 menu_srl의 정보를 이용하여 템플릿을 구한후 return + * 관리자 페이지에서 특정 메뉴의 정보를 추가하기 위해 서버에서 tpl을 컴파일 한후 컴파일 된 html을 직접 return **/ function getMenuTplInfo() { // 해당 메뉴의 정보를 가져오기 위한 변수 설정 @@ -185,10 +187,13 @@ $menu_info->menu_srl = $oDB->getNextSequence(); $menu_info->parent_srl = $parent_srl; $menu_info->parent_menu_name = $parent_info->name; + + // root에 메뉴 추가하거나 기존 메뉴의 수정일 경우 } else { // menu_srl 이 있으면 해당 메뉴의 정보를 가져온다 if($menu_srl) $menu_info = $this->getLayoutMenuInfo($menu_srl); + // 찾아진 값이 없다면 신규 메뉴 추가로 보고 menu_srl값만 구해줌 if(!$menu_info->menu_srl) { $oDB = &DB::getInstance(); $menu_info->menu_srl = $oDB->getNextSequence(); diff --git a/modules/layout/layout.view.php b/modules/layout/layout.view.php index 506bd5582..170ba2aa6 100644 --- a/modules/layout/layout.view.php +++ b/modules/layout/layout.view.php @@ -26,7 +26,8 @@ } /** - * @brief 레이아웃 등록 페이지 step 1 + * @brief 레이아웃 등록 페이지 + * 1차적으로 레이아웃만 선택한 후 DB 에 빈 값을 넣고 그 후 상세 값 설정하는 단계를 거침 **/ function dispInsertLayout() { // 레이아웃 목록을 세팅 @@ -38,7 +39,7 @@ } /** - * @brief 레이아웃 등록 페이지 step 2 + * @brief 레이아웃 세부 정보 입력 **/ function dispLayoutInfo() { // 선택된 레이아웃의 정보르 구해서 세팅 @@ -55,39 +56,26 @@ // xml 정보를 가져옴 $layout = $layout_info->layout; $layout_info = $oLayoutModel->getLayoutInfoXml($layout, $layout_srl); + + // 기본 layout_info에 세부 정보를 입력할 layout_srl, layout_title을 추가 $layout_info->layout_srl = $layout_srl; $layout_info->layout_title = $layout_title; - $layout_info->layout = $layout; Context::set('layout_info', $layout_info); $this->setTemplateFile('layout_info'); } - /** - * @brief 레이아웃 메뉴의 개별 정보 출력 - **/ - function dispLayoutMenuInfo() { - // 팝업이기 때문에 팝업용 레이아웃을 지정 - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile('popup_layout'); - - // menu_srl에 해당하는 값을 가져옴 - - // 템플릿 지정 - $this->setTemplateFile('layout_menu_info'); - } - /** * @brief 레이아웃 목록을 보여줌 **/ - function dispLayoutList() { + function dispDownloadedLayoutList() { // 레이아웃 목록을 세팅 $oLayoutModel = &getModel('layout'); $layout_list = $oLayoutModel->getDownloadedLayoutList(); Context::set('layout_list', $layout_list); - $this->setTemplateFile('layout_list'); + $this->setTemplateFile('downloaded_layout_list'); } diff --git a/modules/layout/tpl.admin/layout_list.html b/modules/layout/tpl.admin/downloaded_layout_list.html similarity index 93% rename from modules/layout/tpl.admin/layout_list.html rename to modules/layout/tpl.admin/downloaded_layout_list.html index 6a1eadee9..298c075d5 100644 --- a/modules/layout/tpl.admin/layout_list.html +++ b/modules/layout/tpl.admin/downloaded_layout_list.html @@ -11,7 +11,7 @@ {$lang->author} {$lang->menu_count} {$lang->date} - {$lang->date} + {$lang->path} {$lang->cmd_make} @@ -22,7 +22,7 @@ {$val->version} {$val->author->name} - {count($val->navigations)} + {$val->menu_count} {$val->author->date} {$val->path} {$lang->cmd_make} diff --git a/modules/layout/tpl.admin/layout_info.html b/modules/layout/tpl.admin/layout_info.html index 47a87849b..bc810a484 100644 --- a/modules/layout/tpl.admin/layout_info.html +++ b/modules/layout/tpl.admin/layout_info.html @@ -18,6 +18,10 @@ {$lang->layout_name} {$layout_info->title} ver {$layout_info->version} ({$layout_info->layout}) + + {$lang->path} + {$layout_info->path} + {$lang->author} {$layout_info->author->name} @@ -44,37 +48,37 @@ {$lang->menu_management} {nl2br($lang->about_menu_management)} - + - {$val->name}
- ({$val->maxdepth} {$lang->depth}) + {$menu->name}
+ ({$menu->maxdepth} {$lang->depth}) -
+ - +
- +
- - - - + + + +
-
diff --git a/modules/member/lang/ko.lang.php b/modules/member/lang/ko.lang.php index 34e362d0c..4c93c58bf 100644 --- a/modules/member/lang/ko.lang.php +++ b/modules/member/lang/ko.lang.php @@ -33,22 +33,6 @@ $lang->redirect_url = '회원 가입후 이동할 페이지'; $lang->agreement = '회원 가입 약관'; - $lang->column_type = '형식'; - $lang->column_type_list['text'] = '한줄 입력칸 (text)'; - $lang->column_type_list['homepage'] = '홈페이지 형식 (url)'; - $lang->column_type_list['email_address'] = '이메일 형식 (email)'; - $lang->column_type_list['tel'] = '전화번호 형식 (phone)'; - $lang->column_type_list['textarea'] = '여러줄 입력칸 (textarea)'; - $lang->column_type_list['checkbox'] = '다중 선택 (checkbox)'; - $lang->column_type_list['select'] = '단일 선택 (select)'; - $lang->column_type_list['kr_zip'] = '한국주소 (zip)'; - //$lang->column_type_list['jp_zip'] = '일본주소 (zip)'; - $lang->column_name = '입력항목 이름'; - $lang->column_title = '입력항목 제목'; - $lang->default_value = '기본 값'; - $lang->is_active = '활성'; - $lang->is_required = '필수항목'; - $lang->msg_new_member = '회원 추가'; $lang->msg_update_member = '회원 정보 수정'; $lang->msg_group_is_null = '등록된 그룹이 없습니다';