mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@17 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
0d1a4ce1ce
commit
5efaa4d880
2 changed files with 311 additions and 286 deletions
|
|
@ -1,20 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @file : classes/page/PageHandler.class.php
|
||||
* @author : zero <zero@nzeo.com>
|
||||
* @desc : 페이지 처리
|
||||
* @class PageHandler
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief 페이지 네비게이션 담당
|
||||
*
|
||||
* 전체갯수, 전체페이지, 현재페이지, 페이지당 목록의 수를 넘겨주면 \n
|
||||
* 페이지 네비게이션에 필요한 variables와 method를 구현\n
|
||||
**/
|
||||
|
||||
class PageHandler {
|
||||
|
||||
var $total_count = 0;
|
||||
var $total_page = 0;
|
||||
var $cur_page = 0;
|
||||
var $page_count = 10;
|
||||
var $first_page = 1;
|
||||
var $last_page = 1;
|
||||
var $point = 0;
|
||||
var $total_count = 0; ///< 전체 item의 갯수
|
||||
var $total_page = 0; ///< 전체 페이지 수
|
||||
var $cur_page = 0; ///< 현 페이지
|
||||
var $page_count = 10; ///< 한번에 보일 페이지의 수
|
||||
var $first_page = 1; ///< 첫 페이지
|
||||
var $last_page = 1; ///< 마지막 페이지
|
||||
var $point = 0; ///< getNextPage() 호출시 증가하는 값
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
**/
|
||||
function PageHandler($total_count, $total_page, $cur_page, $page_count = 10) {
|
||||
$this->total_count = $total_count;
|
||||
$this->total_page = $total_page;
|
||||
|
|
@ -31,12 +37,13 @@
|
|||
$this->last_page = $last_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 다음 페이지 요청
|
||||
**/
|
||||
function getNextPage() {
|
||||
$page = $this->first_page+$this->point++;
|
||||
if($page > $this->last_page) $page = 0;
|
||||
return $page;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* @file : classes/template/TemplateHandler.class.php
|
||||
* @author : zero <zero@nzeo.com>
|
||||
* @desc : 템플릿 컴파일
|
||||
* @class TemplateHandler
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief 템플릿 컴파일러
|
||||
* @version 0.1
|
||||
*
|
||||
* 정규표현식을 이용하여 템플릿 파일을 컴파일하여 php코드로 변경하고\n
|
||||
* 이 파일을 caching하여 사용할 수 있도록 하는 템플릿 컴파일러\n
|
||||
**/
|
||||
|
||||
class TemplateHandler {
|
||||
|
||||
var $compiled_path = './files/template_compiled/';
|
||||
var $compiled_path = './files/template_compiled/'; ///< 컴파일된 캐쉬 파일이 놓일 위치
|
||||
|
||||
var $tpl_path = '';
|
||||
var $tpl_file = '';
|
||||
var $tpl_path = ''; ///< 컴파일 대상 경로
|
||||
var $tpl_file = ''; ///< 컴파일 대상 파일
|
||||
|
||||
// public string compile($tpl_path, $tpl_filename)/*{{{*/
|
||||
/**
|
||||
* @brief 주어진 tpl파일의 컴파일
|
||||
**/
|
||||
function compile($tpl_path, $tpl_filename) {
|
||||
$this->tpl_path = $tpl_path;
|
||||
|
||||
|
|
@ -47,20 +53,22 @@
|
|||
|
||||
// 컴파일된 파일을 실행
|
||||
return $output;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _compile($tpl_file, $compiled_tpl_file)/*{{{*/
|
||||
// tpl_file이 컴파일이 되어 있는 것이 있는지 체크
|
||||
/**
|
||||
* @brief tpl_file이 컴파일이 되어 있는 것이 있는지 체크
|
||||
**/
|
||||
function _compile($tpl_file, $compiled_tpl_file) {
|
||||
if(!file_exists($compiled_tpl_file)) return $this->_compileTplFile($tpl_file, $compiled_tpl_file);
|
||||
|
||||
$source_ftime = filectime($tpl_file);
|
||||
$target_ftime = filectime($compiled_tpl_file);
|
||||
if($source_ftime>$target_ftime) return $this->_compileTplFile($tpl_file, $compiled_tpl_file);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private void _compileTplFile($tpl_file, $compiled_tpl_file)/*{{{*/
|
||||
// tpl_file을 compile
|
||||
/**
|
||||
* @brief tpl_file을 compile
|
||||
**/
|
||||
function _compileTplFile($tpl_file, $compiled_tpl_file) {
|
||||
|
||||
// tpl 파일을 읽음
|
||||
|
|
@ -92,17 +100,19 @@
|
|||
FileHandler::writeFile($compiled_tpl_file, $buff);
|
||||
|
||||
return $buff;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _compileVarToContext($matches)/*{{{*/
|
||||
// {$와 } 안의 $... 변수를 Context::get(...) 으로 변경
|
||||
/**
|
||||
* @brief {$와 } 안의 $... 변수를 Context::get(...) 으로 변경
|
||||
**/
|
||||
function _compileVarToContext($matches) {
|
||||
$str = trim(substr($matches[0],1,strlen($matches[0])-2));
|
||||
return '<?php print('.preg_replace('/\$([a-zA-Z0-9\_\-\>]+)/i','$__Context->\\1', $str).');?>';
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _compileImgPath($matches)/*{{{*/
|
||||
// {$와 } 안의 $... 변수를 Context::get(...) 으로 변경
|
||||
/**
|
||||
* @brief {$와 } 안의 $... 변수를 Context::get(...) 으로 변경
|
||||
**/
|
||||
function _compileImgPath($matches) {
|
||||
$str1 = $matches[0];
|
||||
$str2 = $matches[1];
|
||||
|
|
@ -111,19 +121,22 @@
|
|||
|
||||
$path = '<?=$this->tpl_path?>'.substr($path,2);
|
||||
return str_replace($str2, $path, $str1);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _compileVarToFunc($matches)/*{{{*/
|
||||
// {@와 } 안의 @... 함수를 print func(..)로 변경
|
||||
/**
|
||||
* @brief {@와 } 안의 @... 함수를 print func(..)로 변경
|
||||
**/
|
||||
function _compileVarToFunc($matches) {
|
||||
return '<?php print('.preg_replace('/\$([a-zA-Z0-9\_\-\>]+)/i','$__Context->\\1', trim($matches[1])).');?>';
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _compileFuncToCode($matches)/*{{{*/
|
||||
// <!--@, --> 사이의 구문을 php코드로 변경
|
||||
/**
|
||||
* @brief <!--@, --> 사이의 구문을 php코드로 변경
|
||||
**/
|
||||
function _compileFuncToCode($matches) {
|
||||
$code = trim($matches[1]);
|
||||
if(!$code) return;
|
||||
|
||||
switch(strtolower($code)) {
|
||||
case 'else' :
|
||||
$output = '}else{';
|
||||
|
|
@ -149,10 +162,11 @@
|
|||
}
|
||||
|
||||
return sprintf('<?php %s %s ?>', $prefix, $output);
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _compileIncludeToCode($matches)/*{{{*/
|
||||
// <!--#include $path-->를 변환
|
||||
/**
|
||||
* @brief <!--#include $path-->를 변환
|
||||
**/
|
||||
function _compileIncludeToCode($matches) {
|
||||
// include하려는 대상문자열에 변수가 있으면 변수 처리
|
||||
$arg = str_replace(array('"','\''), '', $matches[1]);
|
||||
|
|
@ -200,10 +214,11 @@
|
|||
"\n"
|
||||
);
|
||||
return $output;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _compileImportCode($matches)/*{{{*/
|
||||
// <!--%filename-->의 확장자를 봐서 js filter/ css/ js 파일을 include하도록 수정
|
||||
/**
|
||||
* @brief <!--%filename-->의 확장자를 봐서 js filter/ css/ js 파일을 include하도록 수정
|
||||
**/
|
||||
function _compileImportCode($matches) {
|
||||
// 현재 tpl 파일의 위치를 구해서 $base_path에 저장하여 적용하려는 xml file을 찾음
|
||||
$base_path = dirname($this->tpl_file).'/';
|
||||
|
|
@ -252,16 +267,18 @@
|
|||
}
|
||||
|
||||
return $output;
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _getComliedFileName($tpl_file) /*{{{*/
|
||||
// $tpl_file로 compiled_tpl_file이름을 return
|
||||
/**
|
||||
* @brief $tpl_file로 compiled_tpl_file이름을 return
|
||||
**/
|
||||
function _getCompiledFileName($tpl_file) {
|
||||
return sprintf('%s%s.compiled.php',$this->compiled_path, md5($tpl_file));
|
||||
}/*}}}*/
|
||||
}
|
||||
|
||||
// private string _fetch($compiled_tpl_file)/*{{{*/
|
||||
// ob_* 함수를 이용하여 fetch...
|
||||
/**
|
||||
* @brief ob_* 함수를 이용하여 fetch...
|
||||
**/
|
||||
function _fetch($compiled_tpl_file, $buff = NULL) {
|
||||
$__Context = &$GLOBALS['__Context__'];
|
||||
|
||||
|
|
@ -269,6 +286,7 @@
|
|||
|
||||
// ob_start를 시킨후 컴파일된 tpl파일을 include하고 결과를 return
|
||||
ob_start();
|
||||
|
||||
// tpl파일을 compile하지 못할 경우 $buff로 넘어온 값을 eval시킴 (미설치시에나..)
|
||||
if($buff) {
|
||||
$eval_str = "?>".$buff;
|
||||
|
|
@ -276,11 +294,11 @@
|
|||
} else {
|
||||
@include $compiled_tpl_file;
|
||||
}
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $output;
|
||||
}/*}}}*/
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue