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

This commit is contained in:
zero 2007-06-29 08:50:38 +00:00
parent 5d31f4cba5
commit 3eaea3f33a
106 changed files with 351 additions and 253 deletions

View file

@ -781,6 +781,9 @@
function transContent($content) {
// 위젯 코드 변경
$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'_transWidget'), $content);
// 메타 파일 변경
$content = preg_replace_callback('!<\!\-\-Meta:([^\-]*?)\-\->!is', array($this,'_transMeta'), $content);
// 에디터 컴포넌트를 찾아서 결과 코드로 변환
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'_transEditorComponent'), $content);
@ -811,6 +814,14 @@
return sprintf('<%s%s%s>', $matches[1], strtolower($matches[2]), $matches[3]);
}
/**
* @brief <!--Meta:파일이름.(css|js)--> 변경
**/
function _transMeta($matches) {
if(eregi('\.css$', $matches[1])) $this->addCSSFile($matches[1]);
elseif(eregi('\.js$', $matches[1])) $this->addJSFile($matches[1]);
}
/**
* @brief <body>내의 <style태그를 header로 이동
**/
@ -871,6 +882,14 @@
if(!$vars->widget) return "";
// 캐시 체크
$widget_sequence = $vars->widget_sequence;
$widget_cache = $vars->widget_cache;
if($widget_cache && $widget_sequence) {
$output = WidgetHandler::getCache($widget_sequence, $widget_cache);
if($output) return $output;
}
// 위젯의 이름을 구함
$widget = $vars->widget;
unset($vars->widget);

View file

@ -288,15 +288,18 @@
break;
// css file
case 'css' :
$meta_file = sprintf('%s%s', $base_path, $filename);
$output = sprintf('<?php Context::addCSSFile("%s%s"); ?>', $base_path, $filename);
break;
// js file
case 'js' :
$meta_file = sprintf('%s%s', $base_path, $filename);
$output = sprintf('<?php Context::addJsFile("%s%s"); ?>', $base_path, $filename);
break;
}
}
$output = '<!--Meta:'.$meta_file.'-->'.$output;
return $output;
}

View file

@ -9,6 +9,28 @@
var $widget_path = '';
/**
* @brief 위젯 캐시 처리
**/
function getCache($sequence, $cache) {
if(!$sequence || !$cache) return;
$cache_path = './files/cache/widget_cache/';
if(!is_dir($cache_path)) {
FileHandler::makeDir($cache_path);
return;
}
$cache_file = sprintf('%s%d.%s.cache', $cache_path, $sequence, Context::getLangType());
if(!file_exists($cache_file)) return;
$filectime = filectime($cache_file);
if($filectime + $cache*60 < time()) return;
$output = FileHandler::readFile($cache_file);
return $output;
}
/**
* @brief 위젯을 찾아서 실행하고 결과를 출력
* <div widget='위젯'...></div> 태그 사용 templateHandler에서 WidgetHandler::execute() 실행하는 코드로 대체하게 된다
@ -32,6 +54,13 @@
if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
if($args->widget_sequence && $args->widget_cache) {
$cache_path = './files/cache/widget_cache/';
$cache_file = sprintf('%s%d.%s.cache', $cache_path, $args->widget_sequence, Context::getLangType());
FileHandler::writeFile($cache_file, $output);
}
return $output;
}