git-svn-id: http://xe-core.googlecode.com/svn/trunk@1318 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-04-25 03:09:50 +00:00
parent 19b9fd314f
commit e1ecee7484
12 changed files with 147 additions and 16 deletions

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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 파일 지정
**/

View file

@ -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;