mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@18 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5efaa4d880
commit
9aa4e0dc3f
3 changed files with 594 additions and 543 deletions
|
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @file : classes/xml/XmlJSFilter.class.php
|
||||
* @author : zero <zero@nzeo.com>
|
||||
* @desc : filter xml문서를 해석하여 js파일로 만듬
|
||||
* @class XmlJsFilter
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief filter xml문서를 해석하여 js파일로 만듬
|
||||
*
|
||||
* filter xml은 tpl 파일과 같은 위치에 있어야 함
|
||||
* <filter id='js function 이름'>
|
||||
* <field> <-- 폼 항목의 체크
|
||||
|
|
@ -36,28 +37,32 @@
|
|||
**/
|
||||
|
||||
class XmlJsFilter {
|
||||
var $compiled_path = './files/js_filter_compiled/';
|
||||
var $xml_file = NULL;
|
||||
var $js_file = NULL;
|
||||
var $compiled_path = './files/js_filter_compiled/'; ///< 컴파일된 캐시 파일이 놓일 위치
|
||||
var $xml_file = NULL; ///< 대상 xml 파일
|
||||
var $js_file = NULL; ///< 컴파일된 js 파일
|
||||
|
||||
// public void XmlJsFilter($path, $xml_file)/*{{{*/
|
||||
/**
|
||||
* @brief constructor
|
||||
**/
|
||||
function XmlJsFilter($path, $xml_file) {
|
||||
$this->xml_file = sprintf("%s%s",$path, $xml_file);
|
||||
$this->js_file = $this->_getCompiledFileName($this->xml_file);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// public void compile()/*{{{*/
|
||||
// 원 xml파일과 compiled된js파일의 시간 비교 및 유무 비교등을 처리
|
||||
/**
|
||||
* @brief 원 xml파일과 compiled된js파일의 시간 비교 및 유무 비교등을 처리
|
||||
**/
|
||||
function compile() {
|
||||
if(!file_exists($this->xml_file)) return;
|
||||
if(!file_exists($this->js_file)) $this->_compile();
|
||||
if(filectime($this->xml_file)>filectime($this->js_file)) $this->_compile();
|
||||
$this->_compile();
|
||||
Context::addJsFile($this->js_file);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _compile()/*{{{*/
|
||||
// 실제 xml_file을 컴파일하여 js_file을 생성
|
||||
/**
|
||||
* @brief 실제 xml_file을 컴파일하여 js_file을 생성
|
||||
**/
|
||||
function _compile() {
|
||||
global $lang;
|
||||
|
||||
|
|
@ -147,12 +152,13 @@
|
|||
|
||||
// js파일 생성
|
||||
FileHandler::writeFile($this->js_file, $js_doc);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getCompiledFileName($xml_file) /*{{{*/
|
||||
// $xml_file로 compiled_xml_file이름을 return
|
||||
/**
|
||||
* @brief $xml_file로 compiled_xml_file이름을 return
|
||||
**/
|
||||
function _getCompiledFileName($xml_file) {
|
||||
return sprintf('%s%s.%s.compiled.js',$this->compiled_path, md5($xml_file),Context::getLangType());
|
||||
}/*}}}*/
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,20 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @file : classes/xml/XmlParser.class.php
|
||||
* @author : zero <zero@nzeo.com>
|
||||
* @desc : xmlrpc를 해석하여 object로 return 하는 simple xml parser
|
||||
* @class XmlParser
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief xmlrpc를 해석하여 object로 return 하는 simple xml parser
|
||||
*
|
||||
* xml 데이터의 attribute중에 xml:lang=""이 있을 경우 지정된 lang\n
|
||||
* 값에 해당하는 것만 남기는 트릭이 적용됨.\n
|
||||
* 무슨 문제를 일으킬지는 현재 모르나 잘 동작하고 있음\n
|
||||
**/
|
||||
|
||||
class XmlParser {
|
||||
|
||||
var $oParser = NULL;
|
||||
var $oParser = NULL; ///< xml parser
|
||||
|
||||
var $input = NULL;
|
||||
var $output = array();
|
||||
var $input = NULL; ///< input xml
|
||||
var $output = array(); ///< output object
|
||||
|
||||
var $lang = "en";
|
||||
var $lang = "en"; ///< 기본 언어타입
|
||||
|
||||
// public object loadXmlFile($filename)/*{{{*/
|
||||
/**
|
||||
* @brief xml 파일을 로딩하여 parsing 처리 후 return
|
||||
**/
|
||||
function loadXmlFile($filename) {
|
||||
if(!file_exists($filename)) return;
|
||||
|
||||
|
|
@ -22,9 +28,11 @@
|
|||
|
||||
$oXmlParser = new XmlParser();
|
||||
return $oXmlParser->parse($buff);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// public void parse($input)/*{{{*/
|
||||
/**
|
||||
* @brief xml 파싱
|
||||
**/
|
||||
function parse($input = '') {
|
||||
$this->lang = Context::getLangType();
|
||||
|
||||
|
|
@ -60,23 +68,29 @@
|
|||
|
||||
if(!count($this->output)) return;
|
||||
return array_shift($this->output);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _tagOpen($parser, $node_name, $attrs)/*{{{*/
|
||||
/**
|
||||
* @brief 태그 오픈
|
||||
**/
|
||||
function _tagOpen($parser, $node_name, $attrs) {
|
||||
$obj->node_name = strtolower($node_name);
|
||||
$obj->attrs = $this->_arrToObj($attrs);
|
||||
|
||||
array_push($this->output, $obj);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _tagBody($parser, $body)/*{{{*/
|
||||
/**
|
||||
* @brief body 내용
|
||||
**/
|
||||
function _tagBody($parser, $body) {
|
||||
if(!trim($body)) return;
|
||||
$this->output[count($this->output)-1]->body .= $body;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _tagClosed($parser, $node_name)/*{{{*/
|
||||
/**
|
||||
* @brief 태그 닫음
|
||||
**/
|
||||
function _tagClosed($parser, $node_name) {
|
||||
$node_name = strtolower($node_name);
|
||||
$cur_obj = array_pop($this->output);
|
||||
|
|
@ -96,9 +110,11 @@
|
|||
} else {
|
||||
$parent_obj->{$node_name} = $cur_obj;
|
||||
}
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _arrToObj($arr)/*{{{*/
|
||||
/**
|
||||
* @brief 파싱한 결과를 object vars에 담기 위한 method
|
||||
**/
|
||||
function _arrToObj($arr) {
|
||||
if(!count($arr)) return;
|
||||
foreach($arr as $key => $val) {
|
||||
|
|
@ -106,6 +122,6 @@
|
|||
$output->{$key} = $val;
|
||||
}
|
||||
return $output;
|
||||
}/*}}}*/
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @file : classes/db/DB.class.php
|
||||
* @author : zero <zero@nzeo.com>
|
||||
* @desc : query xml을 파싱하여 결과를 return
|
||||
* @class XmlQueryParser
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief query xml을 파싱하여 결과를 return
|
||||
* @version 0.1
|
||||
*
|
||||
* @todo subquery나 union등의 확장 쿼리에 대한 지원이 필요
|
||||
**/
|
||||
|
||||
class XmlQueryParser {
|
||||
|
||||
// 조건문에서 조건을 등호로 표시하는 변수
|
||||
/**
|
||||
* @brief 조건문에서 조건을 등호로 표시하는 변수
|
||||
**/
|
||||
var $cond_operation = array(
|
||||
'equal' => '=',
|
||||
'more' => '>=',
|
||||
|
|
@ -19,8 +24,9 @@
|
|||
'null' => 'is null',
|
||||
);
|
||||
|
||||
// private string parse($query_id, $xml_file, $cache_file)/*{{{*/
|
||||
// 쿼리 파일을 찾아서 파싱하고 cacheing한다
|
||||
/**
|
||||
* @brief 쿼리 파일을 찾아서 파싱하고 cacheing한다
|
||||
**/
|
||||
function parse($query_id, $xml_file, $cache_file) {
|
||||
// query xml 파일을 찾아서 파싱, 결과가 없으면 return
|
||||
$buff = FileHandler::readFile($xml_file);
|
||||
|
|
@ -80,9 +86,11 @@
|
|||
|
||||
// 저장
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getDefaultCode($name, $value)/*{{{*/
|
||||
/**
|
||||
* @brief column, condition등의 key에 default 값을 세팅
|
||||
**/
|
||||
function _getDefaultCode($name, $value) {
|
||||
if(!$value) return;
|
||||
if(substr($value, -1)!=')') return sprintf('if(!$args->%s) $args->%s = \'%s\';'."\n", $name, $name, $value);
|
||||
|
|
@ -119,14 +127,18 @@
|
|||
$output = sprintf('if(!$args->%s) $args->%s = %s;'."\n", $name, $name, $val);
|
||||
if($pass_quotes) $output .= sprintf('$pass_quotes[] = \'%s\';'."\n",$name);
|
||||
return $output;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getFilterCode($key, $type, $minlength, $maxlength, $var='column')/*{{{*/
|
||||
/**
|
||||
* @brief 필터 체크
|
||||
**/
|
||||
function _getFilterCode($key, $type, $minlength, $maxlength, $var='column', $notnull='') {
|
||||
if(!$type||!$minlength||!$maxlength) return;
|
||||
if(!$notnull) $notnull_code = sprintf('if($%s->%s) ', $var, $key);
|
||||
|
||||
return
|
||||
sprintf('unset($output); %s$output = $this->_checkFilter(\'%s\', $%s->%s, \'%s\', \'%d\', \'%d\'); if(!$output->toBool()) return $output;'."\n",
|
||||
sprintf(
|
||||
'unset($output); %s$output = $this->_checkFilter(\'%s\', $%s->%s, \'%s\', \'%d\', \'%d\'); if(!$output->toBool()) return $output;'."\n",
|
||||
$notnull_code,
|
||||
$key,
|
||||
$var,
|
||||
|
|
@ -135,21 +147,26 @@
|
|||
(int)$minlength,
|
||||
(int)$maxlength
|
||||
);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getNotNullCode($name)/*{{{*/
|
||||
/**
|
||||
* @brief not null 체크된 항목에 대한 처리
|
||||
**/
|
||||
function _getNotNullCode($name, $var='column') {
|
||||
return
|
||||
sprintf('if(!$%s->%s) return new Output(-1, sprintf($lang->filter->isnull, $lang->%s?$lang->%s:\'%s\'));'."\n",
|
||||
sprintf(
|
||||
'if(!$%s->%s) return new Output(-1, sprintf($lang->filter->isnull, $lang->%s?$lang->%s:\'%s\'));'."\n",
|
||||
$var,
|
||||
$name,
|
||||
$name,
|
||||
$name,
|
||||
$name
|
||||
);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getTablesScript($xml_obj) /*{{{*/
|
||||
/**
|
||||
* @brief 대상 테이블에 대한 처리
|
||||
**/
|
||||
function _getTablesScript($xml_obj) {
|
||||
$obj_tables = $xml_obj->query->tables->table;
|
||||
if(!is_array($obj_tables)) $obj_tables = array('', $obj_tables);
|
||||
|
|
@ -162,9 +179,11 @@
|
|||
$table_list[] = sprintf('\'%s\'=>\'%s\'', $name, $alias);
|
||||
}
|
||||
return implode(",",$table_list);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getColumnsScript($xml_obj, &$default_script, &$notnull_script, &$filter_script, $action)/*{{{*/
|
||||
/**
|
||||
* @brief 컬럼 처리
|
||||
**/
|
||||
function _getColumnsScript($xml_obj, &$default_script, &$notnull_script, &$filter_script, $action) {
|
||||
$obj_columns = $xml_obj->query->columns->column;
|
||||
if(!is_array($obj_columns)) $obj_columns = array('', $obj_columns);
|
||||
|
|
@ -194,9 +213,11 @@
|
|||
}
|
||||
if(is_array($invert_columns)) $column_script .= sprintf('$invert_columns = array(%s);'."\n", implode(',',$invert_columns));
|
||||
return $column_script;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getConditionScript($xml_obj, &$default_script, &$notnull_script, &$filter_script)/*{{{*/
|
||||
/**
|
||||
* @brief 조건절 처리
|
||||
**/
|
||||
function _getConditionScript($xml_obj, &$default_script, &$notnull_script, &$filter_script) {
|
||||
$cond_idx = 0;
|
||||
|
||||
|
|
@ -216,10 +237,11 @@
|
|||
|
||||
$condition_script .= '$condition = $this->_combineCondition($cond_group, $group_pipe);'."\n";
|
||||
return $condition_script;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getConditionQuery($cond_idx, $obj, $group_pipe, &$notnull_script, &$filter_script) /*{{{*/
|
||||
// 조건문의 쿼리를 만들어 줌
|
||||
/**
|
||||
* @brief 조건문의 쿼리를 만들어 줌
|
||||
**/
|
||||
function _getConditionQuery($cond_idx, $obj, $group_pipe, &$notnull_script, &$filter_script) {
|
||||
if(!is_array($obj)) $obj = array('', $obj);
|
||||
|
||||
|
|
@ -274,6 +296,7 @@
|
|||
else $buff = sprintf('sprintf("%s %s \'%%s\' ", $this->addQuotes($args->%s))', $column, $operation, $var?$var:$column);
|
||||
break;
|
||||
}
|
||||
|
||||
$buff = sprintf('$cond_group[%d][][\'%s\'] = %s;'."\n",$cond_idx, $pipe, $buff);
|
||||
|
||||
if(!$notnull && $var) $buff = sprintf('if($args->%s) ', $var).$buff;
|
||||
|
|
@ -284,9 +307,11 @@
|
|||
}
|
||||
$condition_script .= sprintf('$group_pipe[%d] = \'%s\';'."\n", $cond_idx, $group_pipe);
|
||||
return $condition_script;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getGroupScript($xml_obj)/*{{{*/
|
||||
/**
|
||||
* @brief group by 쿼리 처리
|
||||
**/
|
||||
function _getGroupScript($xml_obj) {
|
||||
$group_list = $xml_obj->query->groups->group;
|
||||
if(!$group_list) return;
|
||||
|
|
@ -297,12 +322,15 @@
|
|||
if(!$column) continue;
|
||||
$group_column_list[] = $column;
|
||||
}
|
||||
|
||||
if(count($group_column_list)) {
|
||||
return ' group by '.implode(" , ", $group_column_list);
|
||||
}
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getNavigationScript($xml_obj) /*{{{*/
|
||||
/**
|
||||
* @brief page navigation 처리
|
||||
**/
|
||||
function _getNavigationScript($xml_obj) {
|
||||
$obj_navigation = $xml_obj->query->navigation;
|
||||
if(!$obj_navigation) return;
|
||||
|
|
@ -334,7 +362,8 @@
|
|||
$page_var = $obj_page->var;
|
||||
$page_default = $obj_page->default;
|
||||
if($page_var) $navigation_script .= sprintf('$navigation->page = $args->%s?$args->%s%s;'."\n", $page_var, $page_var, $page_default?':'.$page_default:'');
|
||||
|
||||
return $navigation_script;
|
||||
}/*}}}*/
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue