diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index d06d11e22..6467cada9 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -36,24 +36,26 @@ $layout_path = $oModule->getLayoutPath(); $layout_file = $oModule->getLayoutFile(); + $edited_layout_file = $oModule->getEditedLayoutFile(); + if(!$layout_path) $layout_path = './common/tpl/'; if(!$layout_file) $layout_file = 'default_layout.html'; - $zbxe_final_content = $oTemplate->compile($layout_path, $layout_file); + + $zbxe_final_content = $oTemplate->compile($layout_path, $layout_file, $edited_layout_file); + if(__DEBUG__==3) $GLOBALS['__layout_compile_elapsed__'] = getMicroTime()-$start; // 각 플러그인, 에디터 컴포넌트의 코드 변경 if(__DEBUG__==3) $start = getMicroTime(); + $oContext = &Context::getInstance(); $zbxe_final_content= $oContext->transContent($zbxe_final_content); + if(__DEBUG__==3) $GLOBALS['__trans_plugin_editor_elapsed__'] = getMicroTime()-$start; // 최종 결과를 common_layout에 넣어버림 Context::set('zbxe_final_content', $zbxe_final_content); $output = $oTemplate->compile('./common/tpl', 'common_layout'); - - // rewrite module을 위한 코드 - // $output = preg_replace("/([0-9]+)\?(.*)/",'?\\2',$output); - } else { $output = $content; } diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 43a4685e2..75387700a 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -198,7 +198,6 @@ foreach($layout_info->extra_var as $var_id => $val) { $layout_info->{$var_id} = $val->value; } - //unset($layout_info->extra_var); } // 레이아웃 정보중 menu를 Context::set @@ -214,6 +213,10 @@ $oModule->setLayoutPath($layout_info->path); $oModule->setLayoutFile('layout'); + + // 레이아웃이 수정되었을 경우 수정본을 지정 + $edited_layout = sprintf('./files/cache/layout/%d.html', $layout_info->layout_srl); + if(file_exists($edited_layout)) $oModule->setEditedLayoutFile($edited_layout); } } diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index 13f40bbc7..ce806c4f3 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -22,6 +22,7 @@ var $layout_path = ''; ///< 레이아웃 경로 var $layout_file = ''; ///< 레이아웃 파일 + var $edited_layout_file = ''; ///< 관리자 모드에서 수정된 레이아웃 파일 var $stop_proc = false; ///< action 수행중 stop()를 호출하면 ModuleObject::proc()를 수행하지 않음 @@ -210,6 +211,21 @@ return $this->template_path; } + /** + * @brief edited layout 파일 지정 + **/ + function setEditedLayoutFile($filename) { + if(substr($filename,-5)!='.html') $filename .= '.html'; + $this->edited_layout_file = $filename; + } + + /** + * @brief layout 파일 return + **/ + function getEditedLayoutFile() { + return $this->edited_layout_file; + } + /** * @brief layout 파일 지정 **/ diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index d205a6a16..8b7e41dca 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -33,22 +33,21 @@ /** * @brief 주어진 tpl파일의 컴파일 **/ - function compile($tpl_path, $tpl_filename) { - $this->tpl_path = $tpl_path; - + function compile($tpl_path, $tpl_filename, $tpl_file = '') { // 디버그를 위한 컴파일 시작 시간 저장 if(__DEBUG__==3) $start = getMicroTime(); // 변수 체크 - $this->tpl_path = ereg_replace('(\/+)$', '', $this->tpl_path).'/'; + $tpl_path = ereg_replace('(\/+)$', '', $tpl_path).'/'; if(substr($tpl_filename,-5)!='.html') $tpl_filename .= '.html'; // tpl_file 변수 생성 - $tpl_file = $this->tpl_path.$tpl_filename; + if(!$tpl_file) $tpl_file = $tpl_path.$tpl_filename; // tpl_file이 비어 있거나 해당 파일이 없으면 return if(!$tpl_file || !file_exists($tpl_file)) return; + $this->tpl_path = $tpl_path; $this->tpl_file = $tpl_file; // compiled된(or 될) 파일이름을 구함 @@ -252,7 +251,8 @@ **/ function _compileImportCode($matches) { // 현재 tpl 파일의 위치를 구해서 $base_path에 저장하여 적용하려는 xml file을 찾음 - $base_path = dirname($this->tpl_file).'/'; + //$base_path = dirname($this->tpl_file).'/'; + $base_path = $this->tpl_path; $given_file = trim($matches[1]); if(!$given_file) return; diff --git a/modules/layout/conf/module.xml b/modules/layout/conf/module.xml index 372f4ea09..1b1d88729 100644 --- a/modules/layout/conf/module.xml +++ b/modules/layout/conf/module.xml @@ -4,6 +4,7 @@ + @@ -11,5 +12,6 @@ + diff --git a/modules/layout/lang/ko.lang.php b/modules/layout/lang/ko.lang.php index e57bc8e24..f4b008c54 100644 --- a/modules/layout/lang/ko.lang.php +++ b/modules/layout/lang/ko.lang.php @@ -6,6 +6,9 @@ **/ $lang->cmd_layout_management = '레이아웃 설정'; + $lang->cmd_layout_edit = '레이아웃 편집'; + $lang->cmd_preview = '미리 보기'; + $lang->cmd_load_source = '원본 불러오기'; $lang->layout_name = '레이아웃 이름'; $lang->layout_maker = "레이아웃 제작자"; @@ -21,4 +24,8 @@ $lang->about_title = '모듈에 연결시 쉽게 구분할 수 있는 제목을 입력해주세요'; $lang->about_layout = "레이아웃 모듈은 사이트의 레이아웃을 쉽게 만들 수 있도록 도와줍니다.\n레이아웃 설정과 메뉴의 연결을 통해서 다양한 모듈이 완성된 사이트의 모습으로 보여줄 수 있도록 합니다.\n* 삭제나 수정이 불가능한 레이아웃은 블로그나 기타 모듈의 자체 레이아웃이므로 해당 모듈로 가서 설정하셔야 합니다."; + $lang->about_layout_code = + "아래 레이아웃의 코드를 직접 수정후 저장하시면 서비스에 반영이 됩니다. + 꼭 미리보기를 하신 후에 저장을 하세요. + 제로보드XE의 템플릿 문법은 [제로보드XE 템플릿] 을 참고하시면 됩니다."; ?> diff --git a/modules/layout/layout.class.php b/modules/layout/layout.class.php index b8b1349ac..eaf0b87e5 100644 --- a/modules/layout/layout.class.php +++ b/modules/layout/layout.class.php @@ -16,6 +16,7 @@ $oModuleController->insertActionForward('layout', 'view', 'dispLayoutAdminContent'); $oModuleController->insertActionForward('layout', 'view', 'dispLayoutAdminInsert'); $oModuleController->insertActionForward('layout', 'view', 'dispLayoutAdminModify'); + $oModuleController->insertActionForward('layout', 'view', 'dispLayoutAdminEdit'); $oModuleController->insertActionForward('layout', 'view', 'dispLayoutAdminDownloadedList'); $oModuleController->insertActionForward('layout', 'view', 'dispLayoutAdminInfo'); diff --git a/modules/layout/layout.controller.php b/modules/layout/layout.controller.php index ddc712483..e4d1f0d63 100644 --- a/modules/layout/layout.controller.php +++ b/modules/layout/layout.controller.php @@ -115,5 +115,19 @@ $output = executeQuery("layout.deleteLayout", $args); return $output; } + + /** + * @brief 레이아웃 코드 추가 + **/ + function procLayoutAdminCodeUpdate() { + $layout_srl = Context::get('layout_srl'); + $code = Context::get('code'); + if(!$layout_srl || !$code) return new Object(-1, 'msg_invalid_request'); + + $layout_file = sprintf('./files/cache/layout/%d.html', $layout_srl); + FileHandler::writeFile($layout_file, $code); + + $this->setMessage('success_updated'); + } } ?> diff --git a/modules/layout/layout.view.php b/modules/layout/layout.view.php index cc3c08639..2652f6b10 100644 --- a/modules/layout/layout.view.php +++ b/modules/layout/layout.view.php @@ -62,6 +62,36 @@ $this->setTemplateFile('layout_modify'); } + /** + * @brief 레이아웃 코드 편집 + **/ + function dispLayoutAdminEdit() { + // 선택된 레이아웃의 정보르 구해서 세팅 + $layout_srl = Context::get('layout_srl'); + + // 레이아웃의 정보를 가져옴 + $oLayoutModel = &getModel('layout'); + $layout_info = $oLayoutModel->getLayout($layout_srl); + + // 등록된 레이아웃이 없으면 오류 표시 + if(!$layout_info) return $this->dispLayoutAdminContent(); + Context::set('layout_info', $layout_info); + + // 레이아웃 코드 가져오기 + $layout_file = sprintf('./files/cache/layout/%d.html', $layout_info->layout_srl); + if(!file_exists($layout_file)) $layout_file = sprintf('%s%s', $layout_info->path, 'layout.html'); + + $layout_code = FileHandler::readFile($layout_file); + Context::set('layout_code', $layout_code); + + // 플러그인 목록을 세팅 + $oPluginModel = &getModel('plugin'); + $plugin_list = $oPluginModel->getDownloadedPluginList(); + Context::set('plugin_list', $plugin_list); + + $this->setTemplateFile('layout_edit'); + } + /** * @brief 레이아웃 목록을 보여줌 **/ diff --git a/modules/layout/tpl/filter/update_layout_code.xml b/modules/layout/tpl/filter/update_layout_code.xml new file mode 100644 index 000000000..10a7ffae8 --- /dev/null +++ b/modules/layout/tpl/filter/update_layout_code.xml @@ -0,0 +1,10 @@ + +
+ + + + + + + +
diff --git a/modules/layout/tpl/header.html b/modules/layout/tpl/header.html index c905d679f..679de63ce 100644 --- a/modules/layout/tpl/header.html +++ b/modules/layout/tpl/header.html @@ -1,8 +1,17 @@ + -
- style="font-weight:bold">[{$lang->layout_list}] - style="font-weight:bold">[{$lang->downloaded_list}] -
+
+ style="font-weight:bold">[{$lang->layout_list}] + style="font-weight:bold">[{$lang->downloaded_list}] +
+ + + + +
+ style="font-weight:bold">[{$lang->cmd_layout_management}] + style="font-weight:bold">[{$lang->cmd_layout_edit}] +
diff --git a/modules/layout/tpl/layout_edit.html b/modules/layout/tpl/layout_edit.html new file mode 100644 index 000000000..58074c43c --- /dev/null +++ b/modules/layout/tpl/layout_edit.html @@ -0,0 +1,37 @@ + + + + +
+ {$layout_info->title} ver {$layout_info->version} ({$layout_info->layout}) +
+ +
+ {nl2br($lang->about_layout_code)} +
+ +
+
{$lang->plugin}
+
+ + [{$plugin->title}] + +
+
+ +
+
+ + +
+ +
+
+ + + +
+ + +
+