recreate 1.5.0

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8252 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2011-04-01 05:42:43 +00:00
commit 9802eaa60a
5 changed files with 90 additions and 85 deletions

View file

@ -750,7 +750,7 @@ class Context {
if(is_array($args_list) && $args_list[0]=='') array_shift($args_list);
} else {
// Otherwise, make GET variables into array
$get_vars = $_GET;
$get_vars = get_object_vars($self->get_vars);
}
// arrange args_list
@ -909,11 +909,12 @@ class Context {
}
/**
* @brief key/val로 context vars 세팅
* @brief set a context value with a key
**/
function set($key, $val, $set_to_get_vars = false) {
function set($key, $val, $set_to_get_vars=0) {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
$self->context->{$key} = $val;
if($set_to_get_vars === false) return;
if($set_to_get_vars || $self->get_vars->{$key}) $self->get_vars->{$key} = $val;
}
@ -993,14 +994,15 @@ class Context {
/**
* @brief js file을 추가
**/
function addJsFile($file, $optimized = false, $targetie = '',$index=null, $type='head') {
function addJsFile($file, $optimized = false, $targetie = '',$index=0, $type='head') {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
$avail_types = array('head', 'body');
if(!in_array($type, $avail_types)) $type = $avail_types[0];
$file = $self->normalizeFilePath($file);
$key = $self->normalizeFilePath($file)."\t".$targetie;
$map = &$self->js_files_map;
// Is this file already registered?
if (!is_array($map[$type])) $map[$type] = array();
if (!isset($map[$type][$key]) || (int)$map[$type][$key] > (int)$index) $map[$type][$key] = (int)$index+count($map[$type])/1000-1;
@ -1014,10 +1016,10 @@ class Context {
$realfile = realpath($file);
foreach($self->js_files as $key=>$val) {
if(realpath($val['file'])==$realfile && $val['targetie'] == $targetie) {
unset($self->js_files[$key]);
unset($self->js_files_map[$val['file']]);
foreach($self->js_files_map as $key=>$val) {
list($_file, $_targetie) = explode("\t", $key);
if(realpath($_file)==$realfile && $_targetie == $targetie) {
unset($self->js_files_map[$key]);
return;
}
}
@ -1028,7 +1030,6 @@ class Context {
**/
function unloadAllJsFiles() {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
$self->js_files = array();
$self->js_files_map = array();
}
@ -1063,11 +1064,16 @@ class Context {
function getJsFile($type='head') {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
ksort($self->js_files);
if(!is_array($self->js_files_map[$type])) $self->js_files_map[$type] = array();
$ret = array();
foreach($self->js_files as $key=>$val) {
if($val['type'] == $type) $ret[] = $val;
$ret = array();
$map = &$self->js_files_map[$type];
asort($self->js_files_map[$type]);
foreach($map as $key=>$val) {
list($file, $targetie) = explode("\t", $key);
$ret[] = array('file'=>$file, 'targetie'=>$targetie);
}
return $ret;
@ -1076,10 +1082,11 @@ class Context {
/**
* @brief CSS file 추가
**/
function addCSSFile($file, $optimized = false, $media = 'all', $targetie = '',$index = null) {
function addCSSFile($file, $optimized=false, $media='all', $targetie='',$index=0) {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
$file = $self->normalizeFilePath($file);
$key = $self->normalizeFilePath($file)."\t".$targetie."\t".$media;
$map = &$self->css_files_map;
if (!isset($map[$key]) || (int)$map[$key] > (int)$index) $map[$key] = (int)$index+count($map)/100-1;
}
@ -1092,10 +1099,10 @@ class Context {
$realfile = realpath($file);
foreach($self->css_files as $key => $val) {
if(realpath($val['file'])==$realfile && $val['media'] == $media && $val['targetie'] == $targetie) {
unset($self->css_files[$key]);
unset($self->css_files_map[$val['file']]);
foreach($self->css_files_map as $key => $val) {
list($_file, $_targetie, $_media) = explode("\t", $key);
if(realpath($_file)==$realfile && $_media==$media && $_targetie==$targetie) {
unset($self->css_files_map[$key]);
return;
}
}
@ -1106,7 +1113,6 @@ class Context {
**/
function unloadAllCSSFiles() {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
$self->css_files = array();
$self->css_files_map = array();
}
@ -1115,8 +1121,16 @@ class Context {
**/
function getCSSFile() {
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
ksort($self->css_files);
return array_values($self->css_files);
asort($self->css_files_map);
$ret = array();
foreach($self->css_files_map as $key=>$val) {
list($_file, $_targetie, $_media) = explode("\t", $key);
$ret[] = array('file'=>$_file, 'media'=>$_media, 'targetie'=>$_targetie);
}
return $ret;
}
/**
@ -1141,8 +1155,8 @@ class Context {
if(!$filename) continue;
if(substr($filename,0,2)=='./') $filename = substr($filename,2);
if(preg_match('/\.js$/i', $filename)) $self->addJsFile($plugin_path.$filename, false, '', null, 'body');
elseif(preg_match('/\.css$/i', $filename)) $self->addCSSFile($plugin_path.$filename, false, 'all', '', null);
if(preg_match('/\.js$/i', $filename)) $self->addJsFile($plugin_path.$filename, false, '', 0, 'body');
elseif(preg_match('/\.css$/i', $filename)) $self->addCSSFile($plugin_path.$filename, false, 'all', '', 0);
}
if(is_dir($plugin_path.'lang')) $self->loadLang($plugin_path.'lang');
@ -1287,4 +1301,4 @@ class Context {
return $path;
}
}
?>
?>

View file

@ -80,10 +80,6 @@
$this->cache_file = _XE_PATH_.$this->cache_file;
}
function create() {
return new DB;
}
/**
* @brief returns list of supported db
* @return list of supported db

View file

@ -21,7 +21,7 @@ class HTMLDisplayHandler {
if(Context::get('layout') != 'none') {
if(__DEBUG__==3) $start = getMicroTime();
Context::set('content', $output);
Context::set('content', $output, false);
$layout_path = $oModule->getLayoutPath();
$layout_file = $oModule->getLayoutFile();

View file

@ -459,12 +459,12 @@
* @param[in] $thumbnail_type thumbnail type(crop, ratio)
* @return true: success, false: failed
**/
function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop', $engine = 'gd') {
function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop') {
$source_file = FileHandler::getRealPath($source_file);
$target_file = FileHandler::getRealPath($target_file);
if(!is_readable($source_file)) return false;
if(!$resize_width) $resize_width = 100;
if(!file_exists($source_file)) return;
if(!$resize_width) $resize_width = 100;
if(!$resize_height) $resize_height = $resize_width;
// retrieve source image's information
@ -472,42 +472,48 @@
if(!FileHandler::checkMemoryLoadImage($imageInfo)) return false;
list($width, $height, $type, $attrs) = $imageInfo;
if($width<1 || $height<1) return false;
$types = array(1=>'gif', 'jpg', 'png', 'bmp');
$type = $types[$type]?$types[$type]:'';
if($width<1 || $height<1) return;
if (!$type) return false;
switch($type) {
case '1' :
$type = 'gif';
break;
case '2' :
$type = 'jpg';
break;
case '3' :
$type = 'png';
break;
case '6' :
$type = 'bmp';
break;
default :
return;
break;
}
// calculate target size
$w_ratio = min($resize_width / $width, 1);
$h_ratio = min($resize_height / $height, 1);
$ratio = ($thumbnail_type=='ratio')?min($w_ratio, $h_ratio):max($w_ratio, $h_ratio);
$thumb_w = (int)($ratio * $width);
$thumb_h = (int)($ratio * $height);
// if original image is larger than specified size to resize, calculate the ratio
if($resize_width > 0 && $width >= $resize_width) $width_per = $resize_width / $width;
else $width_per = 1;
if($resize_height>0 && $height >= $resize_height) $height_per = $resize_height / $height;
else $height_per = 1;
if($thumbnail_type == 'ratio') {
if($width_per>$height_per) $per = $height_per;
else $per = $width_per;
$resize_width = $width * $per;
$resize_height = $height * $per;
} else {
if($width_per < $height_per) $per = $height_per;
else $per = $width_per;
}
if(!$per) $per = 1;
// get type of target file
$target_type = strtolower($target_type?$target_type:$type);
// get image processing engine
$engines = array('gd', 'imagick', 'gmagick');
$engine = strtolower($engine);
if(!in_array($engine, $engines)) $engine = 'gd';
if($engine == 'gd') {
// thumbnail image resource
$thumb = null;
if(function_exists('imagecreatetruecolor')) $thumb = imagecreatetruecolor($resize_width, $resize_height);
elseif(function_exists('imagecreate')) $thumb = imagecreate($resize_width, $resize_height);
if (!$thumb) return false;
} elseif($engine == 'imagick' && class_exists('Imagick')) {
} elseif($engine == 'gd' && class_exists('Gmagick')) {
}
//
// 여기까지 했음!
//
if(!$target_type) $target_type = $type;
$target_type = strtolower($target_type);
// create temporary image with target size
if(function_exists('imagecreatetruecolor')) $thumb = imagecreatetruecolor($resize_width, $resize_height);
@ -597,7 +603,6 @@
return true;
}
/**
* @brief reads ini file, and puts result into array
* @param[in] $filename path of the ini file
@ -669,4 +674,4 @@
return (is_readable($filename) && !!filesize($filename));
}
}
?>
?>

View file

@ -34,22 +34,12 @@
}
// Set variables from request arguments
if(!$module) $this->module = Context::get('module');
else $this->module = $module;
if(!$act) $this->act = Context::get('act');
else $this->act = $act;
if(!$mid) $this->mid = Context::get('mid');
else $this->mid = $mid;
if(!$document_srl) $this->document_srl = (int)Context::get('document_srl');
else $this->document_srl = (int)$document_srl;
if(!$module_srl) $this->module_srl = (int)Context::get('module_srl');
else $this->module_srl = (int)$module_srl;
$this->entry = Context::convertEncodingStr(Context::get('entry'));
$this->module = $module?$module:Context::get('module');
$this->act = $act?$act:Context::get('act');
$this->mid = $mid?$mid:Context::get('mid');
$this->document_srl = $document_srl?(int)$document_srl:(int)Context::get('document_srl');
$this->module_srl = $module_srl?(int)$module_srl:(int)Context::get('module_srl');
$this->entry = Context::convertEncodingStr(Context::get('entry'));
// Validate variables to prevent XSS
if($this->module && !preg_match("/^([a-z0-9\_\-]+)$/i",$this->module)) die(Context::getLang("msg_invalid_request"));