merge sandbox to trunk for 1.4.4.2

git-svn-id: http://xe-core.googlecode.com/svn/trunk@7944 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ngleader 2010-11-30 07:01:36 +00:00
parent 9139515e57
commit f59deeb270
131 changed files with 11605 additions and 4218 deletions

View file

@ -135,6 +135,9 @@
// set authentication information in Context and session
if(Context::isInstalled()) {
$oModuleModel = &getModel('module');
$oModuleModel->loadModuleExtends();
$oMemberModel = &getModel('member');
$oMemberController = &getController('member');
@ -215,8 +218,6 @@
if(file_exists($db_config_file)) @include($db_config_file);
if(!$db_info->time_zone) $db_info->time_zone = date("O");
if(!$db_info->use_optimizer || $db_info->use_optimizer != 'N') $db_info->use_optimizer = 'Y';
else $db_info->use_optimizer = 'N';
if(!$db_info->qmail_compatibility || $db_info->qmail_compatibility != 'Y') $db_info->qmail_compatibility = 'N';
else $db_info->qmail_compatibility = 'Y';
if(!$db_info->use_ssl) $db_info->use_ssl = 'none';
@ -1157,15 +1158,16 @@
/**
* @brief js file을 추가
**/
function addJsFile($file, $optimized = true, $targetie = '',$index=null) {
function addJsFile($file, $optimized = false, $targetie = '',$index=null, $type="head") {
$oContext = &Context::getInstance();
return $oContext->_addJsFile($file, $optimized, $targetie,$index);
return $oContext->_addJsFile($file, $targetie,$index,$type);
}
/**
* @brief js file을 추가
**/
function _addJsFile($file, $optimized = true, $targetie = '',$index=null) {
function _addJsFile($file, $targetie = '',$index=null,$type="head") {
if($type != 'body') $type = 'head';
if(strpos($file,'://')===false && $file{0}!='/' && $file{0}!='.') $file = './'.$file;
$file = preg_replace('@/\./|(?<!:)\/\/@', '/', $file);
while(strpos($file,'/../')) $file = preg_replace('/\/([^\/]+)\/\.\.\//s','/',$file,1);
@ -1174,23 +1176,23 @@
if(is_null($index)) $index=count($this->js_files);
for($i=$index;array_key_exists($i,$this->js_files);$i++);
$this->js_files[$i] = array('file' => $file, 'optimized' => $optimized, 'targetie' => $targetie);
$this->js_files[$i] = array('file' => $file, 'targetie' => $targetie, 'type'=> $type);
}
/**
* @brief js file을 제거
**/
function unloadJsFile($file, $optimized = true, $targetie = '') {
function unloadJsFile($file, $optimized = false, $targetie = '') {
$oContext = &Context::getInstance();
return $oContext->_unloadJsFile($file, $optimized, $targetie);
return $oContext->_unloadJsFile($file, $targetie);
}
/**
* @brief js file을 제거
**/
function _unloadJsFile($file, $optimized, $targetie) {
function _unloadJsFile($file, $targetie) {
foreach($this->js_files as $key => $val) {
if(realpath($val['file'])==realpath($file) && $val['optimized'] == $optimized && $val['targetie'] == $targetie) {
if(realpath($val['file'])==realpath($file) && $val['targetie'] == $targetie) {
unset($this->js_files[$key]);
return;
}
@ -1229,6 +1231,7 @@
{
if(in_array($files[$i]['file'], $filenames))
unset($files[$i]);
$filenames[] = $files[$i]['file'];
}
@ -1238,32 +1241,37 @@
/**
* @brief js file 목록을 return
**/
function getJsFile() {
function getJsFile($type='head') {
$oContext = &Context::getInstance();
return $oContext->_getJsFile();
return $oContext->_getJsFile($type);
}
/**
* @brief js file 목록을 return
**/
function _getJsFile() {
require_once(_XE_PATH_."classes/optimizer/Optimizer.class.php");
$oOptimizer = new Optimizer();
return $oOptimizer->getOptimizedFiles($this->_getUniqueFileList($this->js_files), "js");
function _getJsFile($type) {
$_files = array();
$files = $this->_getUniqueFileList($this->js_files);
foreach($files as $k => $v)
{
if($v['type'] == $type) $_files[] = $v;
}
return $_files;
}
/**
* @brief CSS file 추가
**/
function addCSSFile($file, $optimized = true, $media = 'all', $targetie = '',$index = null) {
function addCSSFile($file, $optimized = false, $media = 'all', $targetie = '',$index = null) {
$oContext = &Context::getInstance();
return $oContext->_addCSSFile($file, $optimized, $media, $targetie,$index);
return $oContext->_addCSSFile($file, $media, $targetie,$index);
}
/**
* @brief CSS file 추가
**/
function _addCSSFile($file, $optimized = true, $media = 'all', $targetie = '', $index = null) {
function _addCSSFile($file, $media = 'all', $targetie = '', $index = null) {
if(strpos($file,'://')===false && substr($file,0,1)!='/' && substr($file,0,1)!='.') $file = './'.$file;
$file = str_replace(array('/./','//'),'/',$file);
while(strpos($file,'/../')) $file = preg_replace('/\/([^\/]+)\/\.\.\//s','/',$file,1);
@ -1274,23 +1282,23 @@
for($i=$index;array_key_exists($i,$this->css_files);$i++);
//if(preg_match('/^http:\/\//i',$file)) $file = str_replace(realpath("."), ".", realpath($file));
$this->css_files[$i] = array('file' => $file, 'optimized' => $optimized, 'media' => $media, 'targetie' => $targetie);
$this->css_files[$i] = array('file' => $file, 'media' => $media, 'targetie' => $targetie);
}
/**
* @brief css file을 제거
**/
function unloadCSSFile($file, $optimized = true, $media = 'all', $targetie = '') {
function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '') {
$oContext = &Context::getInstance();
return $oContext->_unloadCSSFile($file, $optimized, $media, $targetie);
return $oContext->_unloadCSSFile($file, $media, $targetie);
}
/**
* @brief css file을 제거
**/
function _unloadCSSFile($file, $optimized, $media, $targetie) {
function _unloadCSSFile($file, $media, $targetie) {
foreach($this->css_files as $key => $val) {
if(realpath($val['file'])==realpath($file) && $val['optimized'] == $optimized && $val['media'] == $media && $val['targetie'] == $targetie) {
if(realpath($val['file'])==realpath($file) && $val['media'] == $media && $val['targetie'] == $targetie) {
unset($this->css_files[$key]);
return;
}
@ -1321,9 +1329,8 @@
* @brief CSS file 목록 return
**/
function _getCSSFile() {
require_once(_XE_PATH_."classes/optimizer/Optimizer.class.php");
$oOptimizer = new Optimizer();
return $oOptimizer->getOptimizedFiles($this->_getUniqueFileList($this->css_files), "css");
$files = $this->_getUniqueFileList($this->css_files);
return $files;
}
/**
@ -1351,8 +1358,8 @@
$filename = trim($list[$i]);
if(!$filename) continue;
if(substr($filename,0,2)=='./') $filename = substr($filename,2);
if(preg_match('/\.js$/i',$filename)) $this->_addJsFile($plugin_path.$filename, true, '', null);
elseif(preg_match('/\.css$/i',$filename)) $this->_addCSSFile($plugin_path.$filename, true, 'all','', null);
if(preg_match('/\.js$/i',$filename)) $this->_addJsFile($plugin_path.$filename, '', null, 'body');
elseif(preg_match('/\.css$/i',$filename)) $this->_addCSSFile($plugin_path.$filename, 'all','', null);
}
if(is_dir($plugin_path.'lang')) $this->_loadLang($plugin_path.'lang');

View file

@ -286,7 +286,7 @@
else $cache_time = -1;
// if there is no cache file or is not new, find original xml query file and parse it
if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_.'classes/db/DB.class.php')) {
if($cache_time < filemtime($xml_file) || $cache_time < filemtime(_XE_PATH_.'classes/db/DB.class.php') || $cache_time < filemtime(_XE_PATH_.'classes/xml/XmlQueryParser.class.php')) {
require_once(_XE_PATH_.'classes/xml/XmlQueryParser.class.php');
$oParser = new XmlQueryParser();
$oParser->parse($query_id, $xml_file, $cache_file);
@ -404,34 +404,72 @@
* @remarks if $type is not 'number', call addQuotes() and wrap with ' '
**/
function getConditionValue($name, $value, $operation, $type, $column_type) {
if($type == 'number') {
if(!in_array($operation,array('in','notin','between')) && $type == 'number') {
if(is_array($value)){
$value = join(',',$value);
}
if(strpos($value, ',') === false && strpos($value, '(') === false) return (int)$value;
return $value;
}
if(strpos($name, '.') !== false && strpos($value, '.') !== false) {
if(!is_array($value) && strpos($name, '.') !== false && strpos($value, '.') !== false) {
list($table_name, $column_name) = explode('.', $value);
if($column_type[$column_name]) return $value;
}
$value = preg_replace('/(^\'|\'$){1}/', '', $value);
switch($operation) {
case 'like_prefix' :
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
$value = $value.'%';
break;
case 'like_tail' :
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
$value = '%'.$value;
break;
case 'like' :
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
$value = '%'.$value.'%';
break;
case 'notin' :
return "'".$value."'";
if(is_array($value))
{
$value = $this->addQuotesArray($value);
if($type=='number') return join(',',$value);
else return "'". join("','",$value)."'";
}
else
{
return $value;
}
break;
case 'in' :
return "'".$value."'";
if(is_array($value))
{
$value = $this->addQuotesArray($value);
if($type=='number') return join(',',$value);
else return "'". join("','",$value)."'";
}
else
{
return $value;
}
break;
case 'between' :
if(!is_array($value)) $value = array($value);
$value = $this->addQuotesArray($value);
if($type!='number')
{
foreach($value as $k=>$v)
{
$value[$k] = "'".$v."'";
}
}
return $value;
break;
default:
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
}
return "'".$this->addQuotes($value)."'";
@ -461,6 +499,11 @@
if(!isset($value)) return;
if($value === '') return;
if(!in_array(gettype($value), array('string', 'integer'))) return;
break;
case 'between' :
if(!is_array($value)) return;
if(count($value)!=2) return;
}
switch($operation) {
@ -499,6 +542,9 @@
case 'null' :
return $name.' is null';
break;
case 'between' :
return $name.' between ' . $value[0] . ' and ' . $value[1];
break;
}
}
@ -624,5 +670,22 @@
$query = sprintf("drop table %s%s", $this->prefix, $table_name);
$this->_query($query);
}
function addQuotesArray($arr)
{
if(is_array($arr))
{
foreach($arr as $k => $v)
{
$arr[$k] = $this->addQuotes($v);
}
}
else
{
$arr = $this->addQuotes($arr);
}
return $arr;
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -403,7 +403,7 @@
foreach($val['condition'] as $v) {
if(!isset($v['value'])) continue;
if($v['value'] === '') continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double'))) continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
$name = $v['column'];
$operation = $v['operation'];
@ -437,9 +437,20 @@
foreach($output->columns as $key => $val) {
$name = $val['name'];
$value = $val['value'];
if($output->column_type[$name]!='number') {
$value = "'".$this->addQuotes($value)."'";
if(!$value) $value = 'null';
if(!is_null($value)){
$value = "'" . $this->addQuotes($value) ."'";
}else{
if($val['notnull']=='notnull') {
$value = "''";
} else {
//$value = 'null';
$value = "''";
}
}
} elseif(!$value || is_numeric($value)) $value = (int)$value;
$column_list[] = '`'.$name.'`';

View file

@ -412,7 +412,7 @@
foreach($val['condition'] as $v) {
if(!isset($v['value'])) continue;
if($v['value'] === '') continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double'))) continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
$name = $v['column'];
$operation = $v['operation'];
@ -443,13 +443,24 @@
$table_list[] = '`'.$this->prefix.$val.'`';
}
// 컬럼 정리
// 컬럼 정리
foreach($output->columns as $key => $val) {
$name = $val['name'];
$value = $val['value'];
if($output->column_type[$name]!='number') {
$value = "'".$this->addQuotes($value)."'";
if(!$value) $value = 'null';
if(!is_null($value)){
$value = "'" . $this->addQuotes($value) ."'";
}else{
if($val['notnull']=='notnull') {
$value = "''";
} else {
//$value = 'null';
$value = "''";
}
}
} elseif(!$value || is_numeric($value)) $value = (int)$value;
$column_list[] = '`'.$name.'`';

View file

@ -144,10 +144,11 @@
// 쿼리 문 실행
$result = mysqli_query($this->fd,$query);
// 오류 체크
$error = mysqli_error($this->fd);
if($error) $this->setError(mysqli_errno($this->fd), $error);
if($error){
$this->setError(mysqli_errno($this->fd), $error);
}
// 쿼리 실행 종료를 알림
$this->actFinish();
@ -392,7 +393,7 @@
foreach($val['condition'] as $v) {
if(!isset($v['value'])) continue;
if($v['value'] === '') continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double'))) continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
$name = $v['column'];
$operation = $v['operation'];
@ -422,23 +423,33 @@
$table_list[] = '`'.$this->prefix.$val.'`';
}
// 컬럼 정리
// 컬럼 정리
foreach($output->columns as $key => $val) {
$name = $val['name'];
$value = $val['value'];
if($output->column_type[$name]!='number') {
$value = "'".$this->addQuotes($value)."'";
if(!$value) $value = 'null';
if(!is_null($value)){
$value = "'" . $this->addQuotes($value) ."'";
}else{
if($val['notnull']=='notnull') {
$value = "''";
} else {
//$value = 'null';
$value = "''";
}
}
} elseif(!$value || is_numeric($value)) $value = (int)$value;
$column_list[] = '`'.$name.'`';
$value_list[] = $value;
}
$query = sprintf("insert into %s (%s) values (%s)", implode(',',$table_list), implode(',',$column_list), implode(',', $value_list));
$query = sprintf("insert into %s (%s) values (%s);", implode(',',$table_list), implode(',',$column_list), implode(',', $value_list));
return $this->_query($query);
}
}
/**
* @brief updateAct 처리

View file

@ -528,7 +528,7 @@ class DBPostgresql extends DB
continue;
if ($v['value'] === '')
continue;
if (!in_array(gettype($v['value']), array('string', 'integer', 'double')))
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
continue;
$name = $v['column'];

View file

@ -414,7 +414,7 @@
foreach($val['condition'] as $v) {
if(!isset($v['value'])) continue;
if($v['value'] === '') continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double'))) continue;
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
$name = $v['column'];
$operation = $v['operation'];

View file

@ -136,21 +136,20 @@ class HTMLDisplayHandler {
{
$oContext =& Context::getInstance();
// add common JS/CSS files
$oContext->_addJsFile("./common/js/jquery.js", true, '', -100000);
//$oContext->_addJsFile("./common/js/jquery-1.4.2-full.js", true, '', -100000);
$oContext->_addJsFile("./common/js/x.js", true, '', -100000);
$oContext->_addJsFile("./common/js/common.js", true, '', -100000);
$oContext->_addJsFile("./common/js/js_app.js", true, '', -100000);
$oContext->_addJsFile("./common/js/xml_handler.js", true, '', -100000);
$oContext->_addJsFile("./common/js/xml_js_filter.js", true, '', -100000);
$oContext->_addCSSFile("./common/css/default.css", true, 'all', '', -100000);
$oContext->_addCSSFile("./common/css/button.css", true, 'all', '', -100000);
$oContext->_addJsFile("./common/js/jquery.js", '', -100000);
$oContext->_addJsFile("./common/js/x.js", '', -100000);
$oContext->_addJsFile("./common/js/common.js", '', -100000);
$oContext->_addJsFile("./common/js/js_app.js", '', -100000);
$oContext->_addJsFile("./common/js/xml_handler.js", '', -100000);
$oContext->_addJsFile("./common/js/xml_js_filter.js", '', -100000);
$oContext->_addCSSFile("./common/css/default.css", 'all', '', -100000);
$oContext->_addCSSFile("./common/css/button.css", 'all', '', -100000);
// for admin page, add admin css
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
$oContext->_addCSSFile("./modules/admin/tpl/css/font.css", true, 'all', '',10000);
$oContext->_addCSSFile("./modules/admin/tpl/css/pagination.css", true, 'all', '', 100001);
$oContext->_addCSSFile("./modules/admin/tpl/css/admin.css", true, 'all', '', 100002);
$oContext->_addCSSFile("./modules/admin/tpl/css/font.css", 'all', '',10000);
$oContext->_addCSSFile("./modules/admin/tpl/css/pagination.css", 'all', '', 100001);
$oContext->_addCSSFile("./modules/admin/tpl/css/admin.css", 'all', '', 100002);
}
}
}

View file

@ -141,7 +141,7 @@
$value = $this->_getTypeValue($this->type, $this->value);
switch($this->type) {
case 'homepage' :
return ($value)?sprintf('<a href="%s" onclick="window.open(this.href); return false;">%s</a>', $value, $value):"";
return ($value)?(sprintf('<a href="%s" onclick="window.open(this.href); return false;">%s</a>', $value, strlen($value)>60?substr($value,0,40).'...'.substr($value,-10):$value)):"";
case 'email_address' :
return ($value)?sprintf('<a href="mailto:%s">%s</a>', $value, $value):"";
break;
@ -177,11 +177,14 @@
* @brief type에 따른 form을 리턴
**/
function getFormHTML() {
static $id_num = 1000;
$type = $this->type;
$name = $this->name;
$value = $this->_getTypeValue($this->type, $this->value);
$default = $this->_getTypeValue($this->type, $this->default);
$column_name = 'extra_vars'.$this->idx;
$tmp_id = $column_name.'-'.$id_num++;
$buff = '';
switch($type) {
@ -214,7 +217,11 @@
foreach($default as $v) {
if($value && in_array($v, $value)) $checked = ' checked="checked"';
else $checked = '';
$buff .='<li><input type="checkbox" name="'.$column_name.'" value="'.htmlspecialchars($v).'" '.$checked.' />'.$v.'</li>';
// Temporary ID for labeling
$tmp_id = $column_name.'-'.$id_num++;
$buff .='<li><input type="checkbox" name="'.$column_name.'" id="'.$tmp_id.'" value="'.htmlspecialchars($v).'" '.$checked.' /><label for="'.$tmp_id.'">'.$v.'</label></li>';
}
$buff .= '</ul>';
break;
@ -236,7 +243,11 @@
foreach($default as $v) {
if($value && in_array($v,$value)) $checked = ' checked="checked"';
else $checked = '';
$buff .= '<li><input type="radio" name="'.$column_name.'" '.$checked.' value="'.$v.'" class="radio" />'.$v.'</li>';
// Temporary ID for labeling
$tmp_id = $column_name.'-'.$id_num++;
$buff .= '<li><input type="radio" name="'.$column_name.'" id="'.$tmp_id.'" '.$checked.' value="'.$v.'" class="radio" /><label for="'.$tmp_id.'">'.$v.'</label></li>';
}
$buff .= '</ul>';
break;

View file

@ -70,9 +70,7 @@
* @return true: OK, false: redirected
**/
function init() {
$oModuleModel = &getModel('module');
$oModuleModel->loadModuleExtends();
$oModuleModel = &getModel('module');
$site_module_info = Context::get('site_module_info');
if(!$this->document_srl && $this->mid && $this->entry) {
@ -283,6 +281,7 @@
if($this->module == "admin" && $type == "view")
{
$oMemberModel = &getModel('member');
$logged_info = $oMemberModel->getLoggedInfo();
if($logged_info->is_admin=='Y') {
$orig_module->loadSideBar();
@ -426,22 +425,19 @@
* @remarks if there exists a module instance created before, returns it.
**/
function &getModuleInstance($module, $type = 'view', $kind = '') {
$parent_module = $module;
if(__DEBUG__==3) $start_time = getMicroTime();
if($kind != 'admin') $kind = 'svc';
if(is_array($GLOBALS['__MODULE_EXTEND__'])) {
$extend_module = $GLOBALS['__MODULE_EXTEND__'][$module.'.'.($kind=='svc'?'':'admin').'.'.$type];
if($extend_module && file_exists(FileHandler::getRealPath(ModuleHandler::getModulePath($extend_module)))) {
$module = $extend_module;
}else{
unset($extend_module);
}
$key = $module.'.'.($kind!='admin'?'':'admin').'.'.$type;
if(is_array($GLOBALS['__MODULE_EXTEND__']) && array_key_exists($key, $GLOBALS['__MODULE_EXTEND__'])) {
$module = $extend_module = $GLOBALS['__MODULE_EXTEND__'][$key];
}else{
unset($parent_module);
}
$class_path = ModuleHandler::getModulePath($module);
if(!is_dir(_XE_PATH_.$class_path)) return NULL;
if(!is_dir(FileHandler::getRealPath($class_path))) return NULL;
// if there is no instance of the module in global variable, create a new one
if(!$GLOBALS['_loaded_module'][$module][$type][$kind]) {
@ -457,49 +453,51 @@
case 'controller' :
if($kind == 'admin') {
$instance_name = sprintf("%sAdmin%s",$module,"Controller");
$class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type);
$class_file = sprintf('%s%s.admin.%s.php', $class_path, $module, $type);
} else {
$instance_name = sprintf("%s%s",$module,"Controller");
$class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type);
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
}
break;
case 'model' :
if($kind == 'admin') {
$instance_name = sprintf("%sAdmin%s",$module,"Model");
$class_file = sprintf('%s%s%s.admin.%s.php', _XE_PATH_, $class_path, $module, $type);
$class_file = sprintf('%s%s.admin.%s.php', $class_path, $module, $type);
} else {
$instance_name = sprintf("%s%s",$module,"Model");
$class_file = sprintf('%s%s%s.%s.php', _XE_PATH_, $class_path, $module, $type);
$class_file = sprintf('%s%s.%s.php', $class_path, $module, $type);
}
break;
case 'api' :
$instance_name = sprintf("%s%s",$module,"API");
$class_file = sprintf('%s%s%s.api.php', _XE_PATH_, $class_path, $module);
$class_file = sprintf('%s%s.api.php', $class_path, $module);
break;
case 'wap' :
$instance_name = sprintf("%s%s",$module,"WAP");
$class_file = sprintf('%s%s%s.wap.php', _XE_PATH_, $class_path, $module);
$class_file = sprintf('%s%s.wap.php', $class_path, $module);
break;
case 'mobile' :
$instance_name = sprintf("%s%s",$module,"Mobile");
$class_file = sprintf("%s%s%s.mobile.php", _XE_PATH_, $class_path, $module);
$class_file = sprintf("%s%s.mobile.php", $class_path, $module);
break;
case 'class' :
$instance_name = $module;
$class_file = sprintf('%s%s%s.class.php', _XE_PATH_, $class_path, $module);
$class_file = sprintf('%s%s.class.php', $class_path, $module);
break;
default :
$type = 'view';
if($kind == 'admin') {
$instance_name = sprintf("%sAdmin%s",$module,"View");
$class_file = sprintf('%s%s%s.admin.view.php', _XE_PATH_, $class_path, $module, $type);
$class_file = sprintf('%s%s.admin.view.php', $class_path, $module, $type);
} else {
$instance_name = sprintf("%s%s",$module,"View");
$class_file = sprintf('%s%s%s.view.php', _XE_PATH_, $class_path, $module, $type);
$class_file = sprintf('%s%s.view.php', $class_path, $module, $type);
}
break;
}
$class_file = FileHandler::getRealPath($class_file);
// Get the name of the class file
if(!file_exists($class_file)) return NULL;

View file

@ -244,6 +244,14 @@
// stop_proc==true이면 그냥 패스
if($this->stop_proc) return false;
// trigger call
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'before', $this);
if(!$triggerOutput->toBool()) {
$this->setError($triggerOutput->getError());
$this->setMessage($triggerOutput->getMessage());
return false;
}
// addon 실행(called_position 를 before_module_proc로 하여 호출)
$called_position = 'before_module_proc';
$oAddonController = &getController('addon');
@ -266,8 +274,15 @@
else {
return false;
}
// trigger call
$triggerOutput = ModuleHandler::triggerCall('moduleObject.proc', 'after', $this);
if(!$triggerOutput->toBool()) {
$this->setError($triggerOutput->getError());
$this->setMessage($triggerOutput->getMessage());
return false;
}
// addon 실행(called_position 를 after_module_proc로 하여 호출)
$called_position = 'after_module_proc';
$oAddonController = &getController('addon');

View file

@ -1,109 +0,0 @@
<?php
/**
* @class Optimizer
* @author NHN (developers@xpressengine.com)
* @brief class designed to be used to merge mutiple JS/CSS files into one file to shorten time taken for transmission.
*
**/
class Optimizer {
var $cache_path = "./files/cache/optimized/";
var $script_file = "./common/script.php?l=%s&amp;t=.%s";
/**
* @brief Constructor which check if a directory, 'optimized' exists in designated path. If not create a new one
**/
function Optimizer() {
if(!is_dir($this->cache_path)) {
FileHandler::makeDir($this->cache_path);
}
}
/**
* @brief file that removes 'optimized' in a given array
* @param[in] $files an array to be modified
**/
function _getOptimizedRemoved($files) {
foreach($files as $key => $val) unset($files[$key]['optimized']);
return $files;
}
/**
* @brief method that optimizes a given file and returns a resultant file
* @param[in] source_files an array of source files to be optimized
* @param[in] type a type of source file, either js or css.
* @return Returns a optimized file
**/
function getOptimizedFiles($source_files, $type = "js") {
if(!is_array($source_files) || !count($source_files)) return;
// 관리자 설정시 설정이 되어 있지 않으면 패스
// 캐시 디렉토리가 없으면 실행하지 않음
$db_info = Context::getDBInfo();
if($db_info->use_optimizer == 'N' || !is_dir($this->cache_path)) return $this->_getOptimizedRemoved($source_files);
if(!count($source_files)) return;
$files = array();
$hash = "";
foreach($source_files as $key => $file) {
if($file['file'][0] == '/'){
if(!file_exists($file['file'])){
if(file_exists($_SERVER['DOCUMENT_ROOT'] . $file['file'])){
if($file['optimized']) $source_files[$key]['file'] = $file['file'] = $_SERVER['DOCUMENT_ROOT'].$file['file'];
}else{
continue;
}
}
} else if(!$file || !$file['file'] || !file_exists($file['file'])) continue;
$file['file'] = $source_files[$key]['file'] = str_replace("\\","/",$file['file']);
if(empty($file['optimized']) || preg_match('/^https?:\/\//i', $file['file']) ) $files[] = $file;
else{
$targets[] = $file;
$hash .= $file['file'];
}
}
if(!count($targets)) return $this->_getOptimizedRemoved($files);
$list_file_hash = md5($hash);
$oCacheHandler = &CacheHandler::getInstance('template');
if($oCacheHandler->isSupport()){
if(!$oCacheHandler->isValid($list_file_hash)){
$buff = array();
foreach($targets as $file) $buff[] = $file['file'];
$oCacheHandler->put($list_file_hash, $buff);
}
}else{
$list_file = FileHandler::getRealPath($this->cache_path . $list_file_hash . '.info.php');
if(!file_exists($list_file)){
$str = '<?php $f=array();';
foreach($targets as $file) $str .= '$f[]="'. $file['file'] . '";';
$str .= ' return $f; ?>';
FileHandler::writeFile($list_file, $str);
}
}
array_unshift($files, array('file' => sprintf($this->script_file, $list_file_hash, $type) , 'media' => 'all'));
$files = $this->_getOptimizedRemoved($files);
if(!count($files)) return $files;
$url_info = parse_url(Context::getRequestUri());
$abpath = $url_info['path'];
foreach($files as $key => $val) {
$file = $val['file'];
if($file{0} == '/' || strpos($file,'://')!==false) continue;
if(substr($file,0,2)=='./') $file = substr($file,2);
$file = $abpath.$file;
while(strpos($file,'/../')!==false) {
$file = preg_replace('/\/([^\/]+)\/\.\.\//','/',$file);
}
$files[$key]['file'] = $file;
}
return $files;
}
}
?>

View file

@ -179,7 +179,7 @@
$buff = preg_replace('!(\n?)( *?)<\!--//(.*?)-->!is', '', $buff);
// import xml filter/ css/ js/ files <!--%import("filename"[,optimized=true|false][,media="media"][,targetie="lt IE 6|IE 7|gte IE 8|..."])--> (media is applied to only css)
$buff = preg_replace_callback('!<\!--%import\(\"([^\"]*?)\"(,optimized\=(true|false))?(,media\=\"([^\"]*)\")?(,targetie=\"([^\"]*)\")?\)-->!is', array($this, '_compileImportCode'), $buff);
$buff = preg_replace_callback('!<\!--%import\(\"([^\"]*?)\"(,optimized\=(true|false))?(,media\=\"([^\"]*)\")?(,targetie=\"([^\"]*)\")?(,index=\"([^\"]*)\")?(,type=\"([^\"]*)\")?\)-->!is', array($this, '_compileImportCode'), $buff);
// unload css/ js <!--%unload("filename"[,optimized=true|false][,media="media"][,targetie="lt IE 6|IE 7|gte IE 8|..."])--> (media is applied to only css)
$buff = preg_replace_callback('!<\!--%unload\(\"([^\"]*?)\"(,optimized\=(true|false))?(,media\=\"([^\"]*)\")?(,targetie=\"([^\"]*)\")?\)-->!is', array($this, '_compileUnloadCode'), $buff);
@ -318,7 +318,7 @@
$tmp_buff = substr($next, 0, $close_pos+strlen('</'.$tag_name.'>'));
$tag .= $tmp_buff;
$next = substr($next, strlen($tmp_buff));
if(false === strpos($tmp_buff, '<'.$tag_name)) break;
if(substr_count($tag, '<'.$tag_name) == substr_count($tag,'</'.$tag_name)) break;
}
}
@ -351,7 +351,10 @@
$next = substr($buff,$pos);
$pre_pos = strrpos($pre, '<');
$next_pos = strpos($next, '<');
preg_match('/<(\/|[a-z])/i',$next,$m);
if(!$m[0]) return $buff;
$next_pos = strpos($next, $m[0]);
$tag = substr($pre, $pre_pos). substr($next, 0, $next_pos);
$pre = substr($pre, 0, $pre_pos);
@ -387,7 +390,8 @@
$tmp_buff = substr($next, 0, $close_pos+strlen('</'.$tag_name.'>'));
$tag .= $tmp_buff;
$next = substr($next, strlen($tmp_buff));
if(false === strpos($tmp_buff, '<'.$tag_name)) break;
if(substr_count($tag, '<'.$tag_name) == substr_count($tag,'</'.$tag_name)) break;
}
$buff = $pre.$tag_head.$tag.$tag_tail.$next;
}
@ -407,7 +411,7 @@
}
$target = $m[1];
if(substr($target,0,1)=='/')
if(substr($target,0,1)=='/')
{
$target = substr($target,1);
$pos = strrpos('/',$target);
@ -452,9 +456,14 @@
$base_path = $this->path;
$target = $attrs['target'];
if(substr($target,0,2)=='./') $target = substr($target,2);
if(!substr($target,0,1)!='/') $target = $web_path.$target;
if(!preg_match('/^(http|https)/i',$target))
{
if(substr($target,0,2)=='./') $target = substr($target,2);
if(!substr($target,0,1)!='/') $target = $web_path.$target;
}
if(!$attrs['index']) $attrs['index'] = 'null';
if($attrs['type']!='body') $attrs['type'] = 'head';
// if target ends with lang, load language pack
if(substr($target, -4)=='lang') {
@ -464,7 +473,8 @@
// otherwise try to load xml, css, js file
} else {
if(substr($target,0,1)!='/') $source_filename = $base_path.$target;
if(preg_match('/^(http|https)/i',$target)) $source_filename = $target;
else if(substr($target,0,1)!='/') $source_filename = $base_path.$target;
else $source_filename = $target;
// get filename and path
@ -490,7 +500,7 @@
'?>%s',
"\n",
"\n",
$base_path,
$this->path,
$filename,
"\n",
"\n",
@ -499,15 +509,15 @@
break;
// css file
case 'css' :
if(!preg_match('/^(http|\/)/i',$source_filename)) $source_filename = $base_path.$filename;
if(!preg_match('/^(http|https|\/)/i',$source_filename)) $source_filename = $this->path.$filename;
if($type == 'unload') $output = '<?php Context::unloadCSSFile("'.$source_filename.'"); ?>';
else $output = '<?php Context::addCSSFile("'.$source_filename.'"); ?>';
else $output = '<?php Context::addCSSFile("'.$source_filename.'",false,"'.$attrs['media'].'","'.$attrs['targetie'].'",'.$attrs['index'].'); ?>';
break;
// js file
case 'js' :
if(!preg_match('/^(http|\/)/i',$source_filename)) $source_filename = $base_path.$filename;
if(!preg_match('/^(http|https|\/)/i',$source_filename)) $source_filename = $this->path.$filename;
if($type == 'unload') $output = '<?php Context::unloadJsFile("'.$source_filename.'"); ?>';
else $output = '<?php Context::addJsFile("'.$source_filename.'"); ?>';
else $output = '<?php Context::addJsFile("'.$source_filename.'",false,"'.$attrs['targetie'].'",'.$attrs['index'].',"'.$attrs['type'].'"); ?>';
break;
}
}
@ -721,6 +731,11 @@
if(!$targetie) $targetie = '';
else $optimized = 'false';
if(isset($matches[9])) $index = intval($matches[9]);
if(!$index) $index = 'null';
if(isset($matches[11])) $type = strtolower(trim($matches[11]));
if($type!='body') $type = 'head';
// if given_file ends with lang, load language pack
if(substr($given_file, -4)=='lang') {
if(substr($given_file,0,2)=='./') $given_file = substr($given_file, 2);
@ -729,7 +744,8 @@
// otherwise try to load xml, css, js file
} else {
if(substr($given_file,0,1)!='/') $source_filename = sprintf("%s%s",$base_path, $given_file);
if(preg_match('/^(http|https):/i',$given_file)) $source_filename = $given_file;
elseif(substr($given_file,0,1)!='/') $source_filename = sprintf("%s%s",$base_path, $given_file);
else $source_filename = $given_file;
// get filename and path
@ -765,19 +781,19 @@
// css file
case 'css' :
if(preg_match('/^(http|\/)/i',$source_filename)) {
$output = sprintf('<?php Context::addCSSFile("%s", %s, "%s", "%s"); ?>', $source_filename, 'false', $media, $targetie);
$output = sprintf('<?php Context::addCSSFile("%s", %s, "%s", "%s", %s); ?>', $source_filename, 'false', $media, $targetie, $index);
} else {
$meta_file = sprintf('%s%s', $base_path, $filename);
$output = sprintf('<?php Context::addCSSFile("%s%s", %s, "%s", "%s"); ?>', $base_path, $filename, $optimized, $media, $targetie);
$output = sprintf('<?php Context::addCSSFile("%s%s", %s, "%s", "%s", %s); ?>', $base_path, $filename, $optimized, $media, $targetie, $index);
}
break;
// js file
case 'js' :
if(preg_match('/^(http|\/)/i',$source_filename)) {
$output = sprintf('<?php Context::addJsFile("%s", %s, "%s"); ?>', $source_filename, 'false', $targetie);
$output = sprintf('<?php Context::addJsFile("%s", %s, "%s", %s,"%s"); ?>', $source_filename, 'false', $targetie, $index, $type);
} else {
$meta_file = sprintf('%s%s', $base_path, $filename);
$output = sprintf('<?php Context::addJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
$output = sprintf('<?php Context::addJsFile("%s%s", %s, "%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie, $index, $type);
}
break;
}
@ -833,19 +849,17 @@
switch($ext) {
// css file
case 'css' :
if(preg_match('/^(http|\/)/i',$source_filename)) {
if(preg_match('/^(http|https|\/)/i',$source_filename)) {
$output = sprintf('<?php Context::unloadCSSFile("%s", %s, "%s", "%s"); ?>', $source_filename, 'false', $media, $targetie);
} else {
$meta_file = sprintf('%s%s', $base_path, $filename);
$output = sprintf('<?php Context::unloadCSSFile("%s%s", %s, "%s", "%s"); ?>', $base_path, $filename, $optimized, $media, $targetie);
}
break;
// js file
case 'js' :
if(preg_match('/^(http|\/)/i',$source_filename)) {
if(preg_match('/^(http|https|\/)/i',$source_filename)) {
$output = sprintf('<?php Context::unloadJsFile("%s", %s, "%s"); ?>', $source_filename, 'false', $targetie);
} else {
$meta_file = sprintf('%s%s', $base_path, $filename);
$output = sprintf('<?php Context::unloadJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
}
break;

View file

@ -65,7 +65,7 @@
if(!file_exists($this->xml_file)) return;
if(!file_exists($this->js_file)) $this->_compile();
else if(filemtime($this->xml_file)>filemtime($this->js_file)) $this->_compile();
Context::addJsFile($this->js_file);
Context::addJsFile($this->js_file, false, '',null,'body');
}
/**

View file

@ -173,6 +173,17 @@
$buff .= ' );'."\n";
}
// args 변수 확인
$arg_list = $this->getArguments();
if($arg_list)
{
foreach($arg_list as $arg)
{
$pre_buff .= 'if(is_object($args->'.$arg.')){ $args->'.$arg.' = array_values(get_method_vars($args->'.$arg.')); }'. "\n";
$pre_buff .= 'if(is_array($args->'.$arg.') && count($args->'.$arg.')==0){ unset($args->'.$arg.'); };'."\n";
}
}
// order 정리
if($output->order) {
$buff .= '$output->order = array(';
@ -446,6 +457,8 @@
if($v->notnull) $this->notnull_list[] = $v->var;
if($v->default) $buff .= sprintf('array("column"=>"%s", "value"=>$args->%s?$args->%s:%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->var, $v->default, $v->pipe, $v->operation, "\n");
else $buff .= sprintf('array("column"=>"%s", "value"=>$args->%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
$this->addArguments($v->var);
} else {
$buff .= sprintf('array("column"=>"%s", "value"=>"%s","pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
}
@ -459,6 +472,15 @@
return $buff;
}
function addArguments($args_name)
{
$this->args[] = $args_name;
}
function getArguments()
{
return $this->args;
}
/**
* @brief returns predefined default values correspoding to given parameters