위젯 검출 정규 표현식을 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2892 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-11-01 10:28:42 +00:00
parent f9896fe51a
commit 90aa62a6ac
993 changed files with 9190 additions and 10457 deletions

View file

@ -74,18 +74,18 @@
else $this->lang_type = $this->db_info->lang_type;
// 등록된 기본 언어파일 찾기
$lang_files = FileHandler::readDir('./common/lang');
$langs = file('./common/lang/lang.info');
$accept_lang = strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach($lang_files as $key => $val) {
list($lang_prefix) = explode('.',$val);
$lang_supported[] = $lang_prefix;
foreach($langs as $val) {
list($lang_prefix, $lang_text) = explode(',',$val);
$lang_supported[$lang_prefix] = $lang_text;
if(!$this->lang_type && ereg($lang_prefix, strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']))) {
$this->lang_type = $lang_prefix;
setcookie('lang_type', $this->lang_type, time()+60*60*24*365, '/');
}
}
if(!in_array($this->lang_type, $lang_supported)) $this->lang_type = $this->db_info->lang_type;
if(!in_array($this->lang_type, array_keys($lang_supported))) $this->lang_type = $this->db_info->lang_type;
if(!$this->lang_type) $this->lang_type = "en";
Context::set('lang_supported', $lang_supported);
@ -282,6 +282,7 @@
function setLangType($lang_type = 'ko') {
$oContext = &Context::getInstance();
$oContext->_setLangType($lang_type);
$_SESSION['lang_type'] = $lang_type;
}
/**

View file

@ -534,8 +534,8 @@
foreach($output->columns as $key => $val) {
$name = $val['name'];
$alias = $val['alias'];
if($name == '*') {
$column_list[] = '*';
if(substr($name,-1) == '*') {
$column_list[] = $name;
} elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
if($alias) $column_list[] = sprintf('"%s" as "%s"', $name, $alias);
else $column_list[] = sprintf('"%s"',$name);

View file

@ -484,8 +484,8 @@
foreach($output->columns as $key => $val) {
$name = $val['name'];
$alias = $val['alias'];
if($name == '*') {
$column_list[] = '*';
if(substr($name,-1) == '*') {
$column_list[] = $name;
} elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
if($alias) $column_list[] = sprintf('`%s` as `%s`', $name, $alias);
else $column_list[] = sprintf('`%s`',$name);

View file

@ -493,8 +493,8 @@
foreach($output->columns as $key => $val) {
$name = $val['name'];
$alias = $val['alias'];
if($name == '*') {
$column_list[] = '*';
if(substr($name,-1) == '*') {
$column_list[] = $name;
} elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
if($alias) $column_list[] = sprintf('`%s` as `%s`', $name, $alias);
else $column_list[] = sprintf('`%s`',$name);

View file

@ -505,8 +505,8 @@
foreach($output->columns as $key => $val) {
$name = $val['name'];
$alias = $val['alias'];
if($name == '*') {
$column_list[] = '*';
if(substr($name,-1) == '*') {
$column_list[] = $name;
} elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
if($alias) $column_list[] = sprintf('%s as %s', $name, $alias);
else $column_list[] = sprintf('%s',$name);

View file

@ -546,8 +546,8 @@
foreach($output->columns as $key => $val) {
$name = $val['name'];
$alias = $val['alias'];
if($name == '*') {
$column_list[] = '*';
if(substr($name,-1) == '*') {
$column_list[] = $name;
} elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
if($alias) $column_list[] = sprintf('%s as %s', $name, $alias);
else $column_list[] = sprintf('%s',$name);

View file

@ -32,7 +32,7 @@
// 요청방식에 따라 출력을 별도로
if(Context::getResponseMethod()!="XMLRPC") {
Context::set('content', $content);
// 레이아웃을 컴파일
@ -92,6 +92,10 @@
$content = preg_replace('!(href|src)=("|\'){0,1}(commons|modules|widgets|layouts|addons|files)!is', '\\1=\\2'.$path.'\\3', $content);
$content = preg_replace('!(href|src)=("|\'){0,1}\.\/([a-zA-Z0-9\_^\/]+)\/!is', '\\1=\\2'.$path.'\\3/', $content);
// 출력하기 전에 trigger 호출 (after)
ModuleHandler::triggerCall('display', 'after', $content);
if($this->gz_enabled) print ob_gzhandler($content, 5);
else print $content;
}

View file

@ -209,6 +209,23 @@
break;
}
// 이미지 정보가 정해진 크기보다 크면 크기를 바꿈 (%를 구해서 처리)
if($resize_width > 0 && $width >= $resize_width) $width_per = $resize_width / $width;
else $width_per = $width / $resize_width;
if($resize_height>0 && $height >= $resize_height) $height_per = $resize_height / $height;
else $height_per = $height / $resize_height;
if($thumbnail_type == 'ratio') {
$per = $width_per;
$resize_height = $height * $per;
} else {
if($width_per < $height_per) $per = $height_per;
else $per = $width_per;
}
if(!$per) $per = 1;
// 타겟 파일의 type을 구함
if(!$target_type) $target_type = $type;
$target_type = strtolower($target_type);
@ -220,24 +237,6 @@
$white = @imagecolorallocate($thumb, 255,255,255);
@imagefilledrectangle($thumb,0,0,$resize_width-1,$resize_height-1,$white);
// 이미지 정보가 정해진 크기보다 크면 크기를 바꿈 (%를 구해서 처리)
if($resize_width > 0 && $width >= $resize_width) $width_per = $resize_width / $width;
else $width_per = $width / $resize_width;
if($resize_height>0 && $height >= $resize_height) $height_per = $resize_height / $height;
else $height_per = $height / $resize_height;
if($thumbnail_type == 'ratio') {
if($width_per > $height_per) $per = $height_per;
else $per = $width_per;
} else {
if($width_per < $height_per) $per = $height_per;
else $per = $width_per;
}
if(!$per) $per = 1;
// 원본 이미지의 타입으로 임시 이미지 생성
switch($type) {
case 'gif' :
@ -269,8 +268,13 @@
$new_width = (int)($width * $per);
$new_height = (int)($height * $per);
$x = (int)($resize_width/2 - $new_width/2);
$y = (int)($resize_height/2 - $new_height/2);
if($thumbnail_type == 'crop') {
$x = (int)($resize_width/2 - $new_width/2);
$y = (int)($resize_height/2 - $new_height/2);
} else {
$x = 0;
$y = 0;
}
if($source) {
if(function_exists('imagecopyresampled')) @imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);

View file

@ -107,6 +107,13 @@
// mid값이 있을 경우 mid값을 세팅
if($this->mid) Context::set('mid', $this->mid, true);
// 현재 모듈의 정보를 세팅
Context::set('current_module_info', $module_info);
// 실제 동작을 하기 전에 trigger 호출
$output = ModuleHandler::triggerCall('display', 'before', $content);
if(!$output->toBool()) die($output->getMessage());
}
/**
@ -336,5 +343,45 @@
// 객체 리턴
return $GLOBALS['_loaded_module'][$module][$type][$kind];
}
/**
* @brief trigger_name, called_position을 주고 trigger 호출
**/
function triggerCall($trigger_name, $called_position, &$obj) {
// 설치가 안되어 있다면 trigger call을 하지 않고 바로 return
if(!Context::isInstalled()) return new Object();
$oModuleModel = &getModel('module');
$cache_dir = sprintf("./files/cache/triggers/");
if(!is_dir($cache_dir)) FileHandler::makeDir($cache_dir);
$cache_file = sprintf("%s%s.%s", $cache_dir, $trigger_name, $called_position);
if(!@file_exists($cache_file)) {
$triggers = $oModuleModel->getTriggers($trigger_name, $called_position);
FileHandler::writeFile($cache_file, serialize($triggers));
} else {
$buff = FileHandler::readFile($cache_file);
$triggers = unserialize($buff);
}
if(!$triggers || !count($triggers)) return new Object();
foreach($triggers as $item) {
$module = $item->module;
$type = $item->type;
$called_method = $item->called_method;
$oModule = null;
$oModule = &getModule($module, $type);
if(!$oModule || !method_exists($oModule, $called_method)) continue;
$output = $oModule->{$called_method}($obj);
if(!$output->toBool()) return $output;
}
return new Object();
}
}
?>

View file

@ -96,10 +96,13 @@
// css 일경우 background:url() 변경
if($type == "css") $str = $this->replaceCssPath($file, $str);
$content_buff .= $str."\r\n";
$content_buff .= $str."\n";
}
if($type == "css") $content_buff = '@charset "utf-8";'."\n".$content_buff;
if($type!="css" && Context::isGzEnabled()) $content_buff = ob_gzhandler($content_buff, 5);
$content_file = eregi_replace("\.php$","",$filename);
$content_filename = str_replace($this->cache_path, '', $content_file);
@ -142,6 +145,8 @@ EndOfBuff;
$str = preg_replace('!\/([^\/]*)\/\.\.\/!is','/', $str);
$str = preg_replace('!@charset([^;]*?);!is','',$str);
return $str;
}

View file

@ -41,6 +41,9 @@
if(!is_dir(sprintf('./widgets/%s/',$widget))) return;
$cache_path = './files/cache/widget_cache/';
if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
// $widget의 객체를 받음
$oWidget = WidgetHandler::getObject($widget);