mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 07:12:15 +09:00
Merge branch 'develop' into pr/session-class
This commit is contained in:
commit
a1618c236f
60 changed files with 1564 additions and 195 deletions
|
|
@ -37,10 +37,11 @@ class Limit
|
|||
* constructor
|
||||
* @param int $list_count
|
||||
* @param int $page
|
||||
* @param int $page_count
|
||||
* @param int $page_count
|
||||
* @param int $offset
|
||||
* @return void
|
||||
*/
|
||||
function __construct($list_count, $page = NULL, $page_count = NULL)
|
||||
function __construct($list_count, $page = NULL, $page_count = NULL, $offset = NULL)
|
||||
{
|
||||
$this->list_count = $list_count;
|
||||
if($page)
|
||||
|
|
@ -50,6 +51,10 @@ class Limit
|
|||
$this->start = ($page_value - 1) * $list_count_value;
|
||||
$this->page_count = $page_count;
|
||||
$this->page = $page;
|
||||
}
|
||||
elseif($offset)
|
||||
{
|
||||
$this->start = $offset->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +86,7 @@ class Limit
|
|||
|
||||
function toString()
|
||||
{
|
||||
if($this->page)
|
||||
if($this->page || $this->start)
|
||||
{
|
||||
return $this->start . ' , ' . $this->list_count->getValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class FrontEndFileHandler extends Handler
|
|||
if(!is_array($args))
|
||||
{
|
||||
$args = array($args);
|
||||
}
|
||||
}
|
||||
$args[0] = preg_replace(array_keys(HTMLDisplayHandler::$replacements), array_values(HTMLDisplayHandler::$replacements), $args[0]);
|
||||
$isCommon = preg_match(HTMLDisplayHandler::$reservedCSS, $args[0]) || preg_match(HTMLDisplayHandler::$reservedJS, $args[0]);
|
||||
if($args[3] > -1500000 && $isCommon)
|
||||
|
|
@ -155,7 +155,8 @@ class FrontEndFileHandler extends Handler
|
|||
return $existsInfo[$existsKey];
|
||||
}
|
||||
|
||||
$pathInfo = pathinfo($fileName);
|
||||
$pathInfo = pathinfo($fileName);
|
||||
|
||||
$file = new stdClass();
|
||||
$file->fileName = $pathInfo['basename'];
|
||||
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
|
||||
|
|
@ -172,7 +173,11 @@ class FrontEndFileHandler extends Handler
|
|||
$file->fileNameNoExt = $pathInfo['filename'];
|
||||
$file->isMinified = false;
|
||||
}
|
||||
$file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false;
|
||||
$file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false;
|
||||
if ($file->isExternalURL && !$file->fileExtension)
|
||||
{
|
||||
$file->fileExtension = preg_match('/[\.\/](css|js)\b/', $fileName, $matches) ? $matches[1] : null;
|
||||
}
|
||||
$file->isCachedScript = !$file->isExternalURL && strpos($file->filePath, 'files/cache/') !== false;
|
||||
$file->isCommon = $isCommon;
|
||||
$file->keyName = $file->fileNameNoExt . '.' . $file->fileExtension;
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ class ModuleHandler extends Handler
|
|||
}
|
||||
|
||||
// redirect, if site start module
|
||||
if(isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1)
|
||||
if(Context::getRequestMethod() === 'GET' && isset($_GET['mid']) && $_GET['mid'] === $site_module_info->mid && count($_GET) === 1)
|
||||
{
|
||||
Context::setCacheControl(0);
|
||||
header('location: ' . getNotEncodedSiteUrl($site_module_info->domain), true, 301);
|
||||
|
|
|
|||
|
|
@ -11,11 +11,9 @@
|
|||
*/
|
||||
class TemplateHandler
|
||||
{
|
||||
private $compiled_path = 'files/cache/template_compiled/'; ///< path of compiled caches files
|
||||
private $path = NULL; ///< target directory
|
||||
private $filename = NULL; ///< target filename
|
||||
private $file = NULL; ///< target file (fullpath)
|
||||
private $xe_path = NULL; ///< XpressEngine base path
|
||||
private $web_path = NULL; ///< tpl file web path
|
||||
private $compiled_file = NULL; ///< tpl file web path
|
||||
private $config = NULL;
|
||||
|
|
@ -29,9 +27,8 @@ class TemplateHandler
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->xe_path = rtrim(preg_replace('/([^\.^\/]+)\.php$/i', '', $_SERVER['SCRIPT_NAME']), '/');
|
||||
$this->compiled_path = _XE_PATH_ . $this->compiled_path;
|
||||
$this->config = new stdClass();
|
||||
$this->config = new stdClass;
|
||||
$this->handler_mtime = filemtime(__FILE__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,16 +90,12 @@ class TemplateHandler
|
|||
$this->filename = $tpl_filename;
|
||||
$this->file = $tpl_file;
|
||||
|
||||
$this->web_path = $this->xe_path . '/' . ltrim(preg_replace('@^' . preg_quote(_XE_PATH_, '@') . '|\./@', '', $this->path), '/');
|
||||
// set absolute URL of template path
|
||||
$this->web_path = \RX_BASEURL . ltrim(preg_replace('@^' . preg_quote(\RX_BASEDIR, '@') . '|\./@', '', $this->path), '/');
|
||||
|
||||
// get compiled file name
|
||||
$hash = md5($this->file . __XE_VERSION__);
|
||||
$this->compiled_file = "{$this->compiled_path}{$hash}.compiled.php";
|
||||
|
||||
// compare various file's modified time for check changed
|
||||
$this->handler_mtime = filemtime(__FILE__);
|
||||
|
||||
$skip = array('');
|
||||
// set compiled file name
|
||||
$converted_path = str_replace(array('\\', '..'), array('/', 'dotdot'), ltrim($this->file, './'));
|
||||
$this->compiled_file = \RX_BASEDIR . 'files/cache/template/' . $converted_path . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,7 +116,9 @@ class TemplateHandler
|
|||
// if target file does not exist exit
|
||||
if(!$this->file || !file_exists($this->file))
|
||||
{
|
||||
return "Err : '{$this->file}' template file does not exists.";
|
||||
$error_message = "Template not found: ${tpl_path}${tpl_filename}" . ($tpl_file ? " (${tpl_file})" : '');
|
||||
trigger_error($error_message, \E_USER_WARNING);
|
||||
return escape($error_message);
|
||||
}
|
||||
|
||||
// for backward compatibility
|
||||
|
|
@ -132,8 +127,7 @@ class TemplateHandler
|
|||
self::$rootTpl = $this->file;
|
||||
}
|
||||
|
||||
$source_template_mtime = filemtime($this->file);
|
||||
$latest_mtime = $source_template_mtime > $this->handler_mtime ? $source_template_mtime : $this->handler_mtime;
|
||||
$latest_mtime = max(filemtime($this->file), $this->handler_mtime);
|
||||
|
||||
// make compiled file
|
||||
if(!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime)
|
||||
|
|
@ -184,8 +178,9 @@ class TemplateHandler
|
|||
// if target file does not exist exit
|
||||
if(!$this->file || !file_exists($this->file))
|
||||
{
|
||||
Context::close();
|
||||
exit("Cannot find the template file: '{$this->file}'");
|
||||
$error_message = "Template not found: ${tpl_path}${tpl_filename}";
|
||||
trigger_error($error_message, \E_USER_WARNING);
|
||||
return escape($error_message);
|
||||
}
|
||||
|
||||
return $this->parse();
|
||||
|
|
@ -232,7 +227,7 @@ class TemplateHandler
|
|||
$buff = $this->_parseInline($buff);
|
||||
|
||||
// include, unload/load, import
|
||||
$buff = preg_replace_callback('/{(@[\s\S]+?|(?=\$\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?)|config)(?(2)\(["\']([^"\']+)["\'])(.*?)(?(2)\)--|\/)>|<!--(@[a-z@]*)([\s\S]*?)-->(\s*)/', array($this, '_parseResource'), $buff);
|
||||
$buff = preg_replace_callback('/{(@[\s\S]+?|(?=[\$\\\\]\w+|_{1,2}[A-Z]+|[!\(+-]|\w+(?:\(|::)|\d+|[\'"].*?[\'"]).+?)}|<(!--[#%])?(include|import|(un)?load(?(4)|(?:_js_plugin)?)|config)(?(2)\(["\']([^"\']+)["\'])(.*?)(?(2)\)--|\/)>|<!--(@[a-z@]*)([\s\S]*?)-->(\s*)/', array($this, '_parseResource'), $buff);
|
||||
|
||||
// remove block which is a virtual tag
|
||||
$buff = preg_replace('@</?block\s*>@is', '', $buff);
|
||||
|
|
@ -805,7 +800,7 @@ class TemplateHandler
|
|||
}
|
||||
}
|
||||
|
||||
$path = preg_replace('/^' . preg_quote(_XE_PATH_, '/') . '/', '', $path);
|
||||
$path = preg_replace('/^' . preg_quote(\RX_BASEDIR, '/') . '/', '', $path);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
|
@ -821,7 +816,17 @@ class TemplateHandler
|
|||
{
|
||||
return '';
|
||||
}
|
||||
return preg_replace('@(?<!::|\\\\|(?<!eval\()\')\$([a-z]|_[a-z0-9])@i', '\$__Context->$1', $php);
|
||||
|
||||
return preg_replace_callback('@(?<!::|\\\\|(?<!eval\()\')\$([a-z_][a-z0-9_]*)@i', function($matches) {
|
||||
if (preg_match('/^(?:GLOBALS|_SERVER|_COOKIE|_GET|_POST|_REQUEST|__Context)$/', $matches[1]))
|
||||
{
|
||||
return '$' . $matches[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return '$__Context->' . $matches[1];
|
||||
}
|
||||
}, $php);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ class LimitTag
|
|||
*/
|
||||
var $list_count;
|
||||
|
||||
/**
|
||||
* QueryArgument object
|
||||
* @var QueryArgument
|
||||
*/
|
||||
var $offset;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param object $index
|
||||
|
|
@ -58,6 +64,12 @@ class LimitTag
|
|||
$index->list_count->attrs->default = 0;
|
||||
$this->list_count = new QueryArgument($index->list_count);
|
||||
$this->arguments[] = $this->list_count;
|
||||
|
||||
if(isset($index->offset) && isset($index->offset->attrs))
|
||||
{
|
||||
$this->offset = new QueryArgument($index->offset);
|
||||
$this->arguments[] = $this->offset;
|
||||
}
|
||||
}
|
||||
|
||||
function toString()
|
||||
|
|
@ -66,6 +78,10 @@ class LimitTag
|
|||
{
|
||||
return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
|
||||
}
|
||||
elseif($this->offset)
|
||||
{
|
||||
return sprintf('new Limit(${\'%s_argument\'}, NULL, NULL, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->offset->getArgumentName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue