mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
issue 106 Add support for CDN
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8764 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
52b3ae8d4f
commit
e6eb7a75d2
19 changed files with 412 additions and 163 deletions
|
|
@ -24,8 +24,7 @@ class Context {
|
||||||
var $ftp_info = NULL; ///< FTP info.
|
var $ftp_info = NULL; ///< FTP info.
|
||||||
|
|
||||||
var $ssl_actions = array(); ///< list of actions to be sent via ssl (it is used by javascript xml handler for ajax)
|
var $ssl_actions = array(); ///< list of actions to be sent via ssl (it is used by javascript xml handler for ajax)
|
||||||
var $js_files_map = array(); ///< hash map of javascript files. The file name is used as a key
|
var $oFrontEndFileHandler;
|
||||||
var $css_files_map = array(); ///< hash map of css files. The file name is used as a key
|
|
||||||
|
|
||||||
var $html_header = NULL; ///< script codes in <head>..</head>
|
var $html_header = NULL; ///< script codes in <head>..</head>
|
||||||
var $body_class = array(); ///< classnames of <body>
|
var $body_class = array(); ///< classnames of <body>
|
||||||
|
|
@ -57,6 +56,14 @@ class Context {
|
||||||
return $theInstance;
|
return $theInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief cunstructor
|
||||||
|
**/
|
||||||
|
function Context()
|
||||||
|
{
|
||||||
|
$this->oFrontEndFileHandler = new FrontEndFileHandler();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief initialization, it sets DB information, request arguments and so on.
|
* @brief initialization, it sets DB information, request arguments and so on.
|
||||||
* @return none
|
* @return none
|
||||||
|
|
@ -987,6 +994,7 @@ class Context {
|
||||||
/**
|
/**
|
||||||
* @brief normalize file path
|
* @brief normalize file path
|
||||||
* @return normalized file path
|
* @return normalized file path
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
function normalizeFilePath($file) {
|
function normalizeFilePath($file) {
|
||||||
if(strpos($file,'://')===false && $file{0}!='/' && $file{0}!='.') $file = './'.$file;
|
if(strpos($file,'://')===false && $file{0}!='/' && $file{0}!='.') $file = './'.$file;
|
||||||
|
|
@ -996,6 +1004,9 @@ class Context {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
**/
|
||||||
function getAbsFileUrl($file) {
|
function getAbsFileUrl($file) {
|
||||||
$file = Context::normalizeFilePath($file);
|
$file = Context::normalizeFilePath($file);
|
||||||
if(strpos($file,'./')===0) $file = dirname($_SERVER['SCRIPT_NAME']).'/'.substr($file,2);
|
if(strpos($file,'./')===0) $file = dirname($_SERVER['SCRIPT_NAME']).'/'.substr($file,2);
|
||||||
|
|
@ -1004,37 +1015,54 @@ class Context {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief load front end file
|
||||||
|
* @params $args array
|
||||||
|
* case js
|
||||||
|
* $args[0]: file name
|
||||||
|
* $args[1]: type (head | body)
|
||||||
|
* $args[2]: target IE
|
||||||
|
* $args[3]: index
|
||||||
|
* case css
|
||||||
|
* $args[0]: file name
|
||||||
|
* $args[1]: media
|
||||||
|
* $args[2]: target IE
|
||||||
|
* $args[3]: index
|
||||||
|
**/
|
||||||
|
function loadFile($args, $cdnPath = '')
|
||||||
|
{
|
||||||
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->loadFile($args, $cdnPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unloadFile($file, $targetIe = '', $media = 'all')
|
||||||
|
{
|
||||||
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->unloadFile($file, $targetIe, $media);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unloadAllFiles($type = 'all')
|
||||||
|
{
|
||||||
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->unloadAllFiles($type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add the js file
|
* @brief Add the js file
|
||||||
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
function addJsFile($file, $optimized = false, $targetie = '',$index=0, $type='head') {
|
function addJsFile($file, $optimized = false, $targetie = '',$index=0, $type='head') {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->loadFile(array($file, $type, $targetie, $index));
|
||||||
$avail_types = array('head', 'body');
|
|
||||||
if(!in_array($type, $avail_types)) $type = $avail_types[0];
|
|
||||||
|
|
||||||
$key = Context::getAbsFileUrl($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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove the js file
|
* @brief Remove the js file
|
||||||
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
function unloadJsFile($file, $optimized = false, $targetie = '') {
|
function unloadJsFile($file, $optimized = false, $targetie = '') {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->unloadFile($file, $targetie);
|
||||||
$remove_key = Context::getAbsFileUrl($file)."\t$targetie";
|
|
||||||
|
|
||||||
foreach($self->js_files_map as $key=>$val) {
|
|
||||||
if($key === $remove_key) {
|
|
||||||
unset($self->js_files_map[$key]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1042,7 +1070,7 @@ class Context {
|
||||||
**/
|
**/
|
||||||
function unloadAllJsFiles() {
|
function unloadAllJsFiles() {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
$self->js_files_map = array();
|
$self->oFrontEndFileHandler->unloadAllJsFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1075,50 +1103,25 @@ class Context {
|
||||||
**/
|
**/
|
||||||
function getJsFile($type='head') {
|
function getJsFile($type='head') {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
return $self->oFrontEndFileHandler->getJsFileList($type);
|
||||||
if(!is_array($self->js_files_map[$type])) $self->js_files_map[$type] = array();
|
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add CSS file
|
* @brief Add CSS file
|
||||||
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
function addCSSFile($file, $optimized=false, $media='all', $targetie='',$index=0) {
|
function addCSSFile($file, $optimized=false, $media='all', $targetie='',$index=0) {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->loadFile(array($file, $media, $targetie, $index));
|
||||||
if(!$media) $media = 'all';
|
|
||||||
|
|
||||||
$key = Context::getAbsFileUrl($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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove css file
|
* @brief Remove css file
|
||||||
|
* @deprecated
|
||||||
**/
|
**/
|
||||||
function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '') {
|
function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '') {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
$self->oFrontEndFileHandler->unloadFile($file, $targetie, $media);
|
||||||
$remove_key = Context::getAbsFileUrl($file)."\t$targetie\t$media";
|
|
||||||
|
|
||||||
foreach($self->css_files_map as $key => $val) {
|
|
||||||
if($key === $remove_key) {
|
|
||||||
unset($self->css_files_map[$key]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1126,7 +1129,7 @@ class Context {
|
||||||
**/
|
**/
|
||||||
function unloadAllCSSFiles() {
|
function unloadAllCSSFiles() {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
$self->css_files_map = array();
|
$self->oFrontEndFileHandler->unloadAllCssFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1134,16 +1137,7 @@ class Context {
|
||||||
**/
|
**/
|
||||||
function getCSSFile() {
|
function getCSSFile() {
|
||||||
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
is_a($this,'Context')?$self=&$this:$self=&Context::getInstance();
|
||||||
|
return $self->oFrontEndFileHandler->getCssFileList();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1168,8 +1162,8 @@ class Context {
|
||||||
if(!$filename) continue;
|
if(!$filename) continue;
|
||||||
|
|
||||||
if(substr($filename,0,2)=='./') $filename = substr($filename,2);
|
if(substr($filename,0,2)=='./') $filename = substr($filename,2);
|
||||||
if(preg_match('/\.js$/i', $filename)) $self->addJsFile($plugin_path.$filename, false, '', 0, 'body');
|
if(preg_match('/\.js$/i', $filename)) $self->loadFile(array($plugin_path.$filename, 'body', '', 0));
|
||||||
elseif(preg_match('/\.css$/i', $filename)) $self->addCSSFile($plugin_path.$filename, false, 'all', '', 0);
|
elseif(preg_match('/\.css$/i', $filename)) $self->loadFile(array($plugin_path.$filename, 'all', '', 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_dir($plugin_path.'lang')) $self->loadLang($plugin_path.'lang');
|
if(is_dir($plugin_path.'lang')) $self->loadLang($plugin_path.'lang');
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class HTMLDisplayHandler {
|
||||||
// search if the changes CSS exists in the admin layout edit window
|
// search if the changes CSS exists in the admin layout edit window
|
||||||
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
|
$edited_layout_css = $oLayoutModel->getUserLayoutCss($layout_srl);
|
||||||
|
|
||||||
if(file_exists($edited_layout_css)) Context::addCSSFile($edited_layout_css,true,'all','',100);
|
if(file_exists($edited_layout_css)) Context::loadFile(array($edited_layout_css,'all','',100));
|
||||||
}
|
}
|
||||||
if(!$layout_path) $layout_path = "./common/tpl";
|
if(!$layout_path) $layout_path = "./common/tpl";
|
||||||
if(!$layout_file) $layout_file = "default_layout";
|
if(!$layout_file) $layout_file = "default_layout";
|
||||||
|
|
@ -151,8 +151,7 @@ class HTMLDisplayHandler {
|
||||||
**/
|
**/
|
||||||
function _transMeta($matches) {
|
function _transMeta($matches) {
|
||||||
if($matches[1]) return '';
|
if($matches[1]) return '';
|
||||||
if(substr($matches[2],'-4')=='.css') Context::addCSSFile($matches[2]);
|
Context::loadFile($matches[2]);
|
||||||
elseif(substr($matches[2],'-3')=='.js') Context::addJSFile($matches[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _loadJSCSS()
|
function _loadJSCSS()
|
||||||
|
|
@ -162,31 +161,31 @@ class HTMLDisplayHandler {
|
||||||
|
|
||||||
// add common JS/CSS files
|
// add common JS/CSS files
|
||||||
if(__DEBUG__) {
|
if(__DEBUG__) {
|
||||||
$oContext->addJsFile('./common/js/jquery.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/jquery.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/x.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/x.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/common.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/js_app.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/xml_handler.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/xml_js_filter.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$oContext->addCSSFile('./common/css/default.css', false, 'all', '', -100000);
|
$oContext->loadFile(array('./common/css/default.css', 'all', '', -100000));
|
||||||
$oContext->addCSSFile('./common/css/button.css', false, 'all', '', -100000);
|
$oContext->loadFile(array('./common/css/button.css', 'all', '', -100000));
|
||||||
} else {
|
} else {
|
||||||
$oContext->addJsFile('./common/js/jquery.min.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/jquery.min.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/x.min.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000));
|
||||||
$oContext->addJsFile('./common/js/xe.min.js', false, '', -100000);
|
$oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000));
|
||||||
$oContext->addCSSFile('./common/css/xe.min.css', false, 'all', '', -100000);
|
$oContext->loadFile(array('./common/css/xe.min.css', 'all', '', -100000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// for admin page, add admin css
|
// for admin page, add admin css
|
||||||
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
|
if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){
|
||||||
if(__DEBUG__) {
|
if(__DEBUG__) {
|
||||||
$oContext->addCSSFile('./modules/admin/tpl/css/admin.css', false, 'all', '', 100000);
|
$oContext->loadFile(array('./modules/admin/tpl/css/admin.css', 'all', '', 100000));
|
||||||
$oContext->addCSSFile("./modules/admin/tpl/css/admin_{$lang_type}.css", false, 'all', '', 100000);
|
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", 'all', '', 100000));
|
||||||
$oContext->addJsFile('./modules/admin/tpl/js/admin.js');
|
$oContext->loadFile('./modules/admin/tpl/js/admin.js');
|
||||||
} else {
|
} else {
|
||||||
$oContext->addCSSFile('./modules/admin/tpl/css/admin.min.css', false, 'all', '', 100000);
|
$oContext->loadFile(array('./modules/admin/tpl/css/admin.min.css', 'all', '', 100000));
|
||||||
$oContext->addCSSFile("./modules/admin/tpl/css/admin_{$lang_type}.min.css", false, 'all', '',10000);
|
$oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.min.css", 'all', '',10000));
|
||||||
$oContext->addJsFile('./modules/admin/tpl/js/admin.js');
|
$oContext->loadFile('./modules/admin/tpl/js/admin.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
224
classes/frontendfile/FrontEndFileHandler.class.php
Normal file
224
classes/frontendfile/FrontEndFileHandler.class.php
Normal file
|
|
@ -0,0 +1,224 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @class FrontEndFileHandler
|
||||||
|
* @author NHN (developer@xpressengine.com)
|
||||||
|
**/
|
||||||
|
|
||||||
|
class FrontEndFileHandler extends Handler
|
||||||
|
{
|
||||||
|
var $cssMap = array();
|
||||||
|
var $jsHeadMap = array();
|
||||||
|
var $jsBodyMap = array();
|
||||||
|
var $cssMapIndex = array();
|
||||||
|
var $jsHeadMapIndex = array();
|
||||||
|
var $jsBodyMapIndex = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief load front end file
|
||||||
|
* @params $args array
|
||||||
|
* case js
|
||||||
|
* $args[0]: file name
|
||||||
|
* $args[1]: type (head | body)
|
||||||
|
* $args[2]: target IE
|
||||||
|
* $args[3]: index
|
||||||
|
* case css
|
||||||
|
* $args[0]: file name
|
||||||
|
* $args[1]: media
|
||||||
|
* $args[2]: target IE
|
||||||
|
* $args[3]: index
|
||||||
|
**/
|
||||||
|
function loadFile($args, $cdnPath = '')
|
||||||
|
{
|
||||||
|
if (!is_array($args)) $args = array($args);
|
||||||
|
|
||||||
|
$pathInfo = pathinfo($args[0]);
|
||||||
|
$file->fileName = $pathInfo['basename'];
|
||||||
|
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
|
||||||
|
$file->fileExtension = strtolower($pathInfo['extension']);
|
||||||
|
$file->cdnPath = $cdnPath;
|
||||||
|
|
||||||
|
$availableExtension = array('css', 'js');
|
||||||
|
if (!in_array($file->fileExtension, $availableExtension)) return;
|
||||||
|
|
||||||
|
$file->targetIe = $args[2];
|
||||||
|
$file->index = (int)$args[3];
|
||||||
|
|
||||||
|
if ($file->fileExtension == 'css')
|
||||||
|
{
|
||||||
|
$file->media = $args[1];
|
||||||
|
$map = &$this->cssMap;
|
||||||
|
$mapIndex = &$this->cssMapIndex;
|
||||||
|
$key = $file->filePath . $file->fileName . "\t" . $file->targetIe . "\t" . $file->media;
|
||||||
|
}
|
||||||
|
else if ($file->fileExtension == 'js')
|
||||||
|
{
|
||||||
|
$type = $args[1];
|
||||||
|
if ($type == 'body')
|
||||||
|
{
|
||||||
|
$map = &$this->jsBodyMap;
|
||||||
|
$mapIndex = &$this->jsBodyMapIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$map = &$this->jsHeadMap;
|
||||||
|
$mapIndex = &$this->jsHeadMapIndex;
|
||||||
|
}
|
||||||
|
$key = $file->filePath . $file->fileName . "\t" . $file->targetIe;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($map[$key]) || $map[$key]->index > $file->index)
|
||||||
|
{
|
||||||
|
$file->index = ((int)$file->index + count($map));
|
||||||
|
$map[$key] = $file;
|
||||||
|
$mapIndex[$key] = $file->index;
|
||||||
|
}
|
||||||
|
debugPrint($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unloadFile($fileName, $targetIe = '', $media = 'all')
|
||||||
|
{
|
||||||
|
$pathInfo = pathinfo($fileName);
|
||||||
|
$fileName = $pathInfo['basename'];
|
||||||
|
$filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
|
||||||
|
$fileExtension = strtolower($pathInfo['extension']);
|
||||||
|
$key = $filePath . $fileName . "\t" . $targetIe;
|
||||||
|
|
||||||
|
if ($fileExtension == 'css')
|
||||||
|
{
|
||||||
|
$key .= "\t" . $media;
|
||||||
|
unset($this->cssMap[$key]);
|
||||||
|
unset($this->cssMapIndex[$key]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($this->jsHeadMap[$key]);
|
||||||
|
unset($this->jsBodyMap[$key]);
|
||||||
|
unset($this->jsHeadMapIndex[$key]);
|
||||||
|
unset($this->jsBodyMapIndex[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function unloadAllFiles($type = 'all')
|
||||||
|
{
|
||||||
|
if ($type == 'css' || $type == 'all')
|
||||||
|
{
|
||||||
|
$cssMap = array();
|
||||||
|
$cssMapIndex = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type == 'js' || $type == 'all')
|
||||||
|
{
|
||||||
|
$jsHeadMap = array();
|
||||||
|
$jsBodyMap = array();
|
||||||
|
$jsHeadMapIndex = array();
|
||||||
|
$jsBodyMapIndex = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCssFileList()
|
||||||
|
{
|
||||||
|
$map = &$this->cssMap;
|
||||||
|
$mapIndex = &$this->cssMapIndex;
|
||||||
|
|
||||||
|
$this->_sortMap($map, $mapIndex);
|
||||||
|
|
||||||
|
$dbInfo = Context::get('db_info');
|
||||||
|
$useCdn = $dbInfo->use_cdn;
|
||||||
|
$result = array();
|
||||||
|
foreach($map as $file)
|
||||||
|
{
|
||||||
|
if ($useCdn == 'Y' && $file->cdnPath)
|
||||||
|
{
|
||||||
|
$fullFilePath = __XE_CDN__ . $file->cdnPath . '/' . $file->fileName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fullFilePath = $file->filePath . '/' . $file->fileName;
|
||||||
|
}
|
||||||
|
$result[] = array('file' => $fullFilePath, 'media' => $file->media, 'targetie' => $file->targetIe);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getJsFileList($type = 'head')
|
||||||
|
{
|
||||||
|
if ($type == 'head')
|
||||||
|
{
|
||||||
|
$map = &$this->jsHeadMap;
|
||||||
|
$mapIndex = &$this->jsHeadMapIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$map = &$this->jsBodyMap;
|
||||||
|
$mapIndex = &$this->jsBodyMapIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_sortMap($map, $mapIndex);
|
||||||
|
|
||||||
|
$dbInfo = Context::get('db_info');
|
||||||
|
$useCdn = $dbInfo->use_cdn;
|
||||||
|
$result = array();
|
||||||
|
foreach($map as $file)
|
||||||
|
{
|
||||||
|
if ($useCdn == 'Y' && $file->cdnPath)
|
||||||
|
{
|
||||||
|
$fullFilePath = __XE_CDN__ . $file->cdnPath . '/' . $file->fileName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fullFilePath = $file->filePath . '/' . $file->fileName;
|
||||||
|
}
|
||||||
|
$result[] = array('file' => $fullFilePath, 'targetie' => $file->targetIe);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _sortMap(&$map, &$index)
|
||||||
|
{
|
||||||
|
|
||||||
|
asort($index);
|
||||||
|
|
||||||
|
$sortedMap = array();
|
||||||
|
foreach($index as $key => $val)
|
||||||
|
{
|
||||||
|
$sortedMap[$key] = $map[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = $sortedMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _normalizeFilePath($path)
|
||||||
|
{
|
||||||
|
if (strpos($path, '://') === false && $path{0} != '/' && $path{0} != '.')
|
||||||
|
{
|
||||||
|
$path = './' . $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = preg_replace('@/\./|(?<!:)\/\/@', '/', $path);
|
||||||
|
|
||||||
|
while(strpos($path, '/../'))
|
||||||
|
{
|
||||||
|
$path = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $path, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _getAbsFileUrl($path)
|
||||||
|
{
|
||||||
|
$path = $this->_normalizeFilePath($path);
|
||||||
|
|
||||||
|
if(strpos($path, './') === 0)
|
||||||
|
{
|
||||||
|
$path = dirname($_SERVER['SCRIPT_NAME']) . '/' . substr($path, 2);
|
||||||
|
}
|
||||||
|
else if(strpos($file, '../') === 0)
|
||||||
|
{
|
||||||
|
$file = $this->_normalizeFilePath(dirname($_SERVER['SCRIPT_NAME']) . "/{$path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -567,19 +567,19 @@
|
||||||
// css file
|
// css file
|
||||||
case 'css' :
|
case 'css' :
|
||||||
if($type == 'unload') {
|
if($type == 'unload') {
|
||||||
$output = '<?php Context::unloadCSSFile("'.$source_filename.'"); ?>';
|
$output = '<?php Context::unloadFile("'.$source_filename.'","'.$attrs['targetie'].'","'.$attrs['media'].'"); ?>';
|
||||||
} else {
|
} else {
|
||||||
$meta_file = $source_filename;
|
$meta_file = $source_filename;
|
||||||
$output = '<?php Context::addCSSFile("'.$source_filename.'",false,"'.$attrs['media'].'","'.$attrs['targetie'].'",'.$attrs['index'].'); ?>';
|
$output = '<?php Context::loadFile(array("'.$source_filename.'","'.$attrs['media'].'","'.$attrs['targetie'].'","'.$attrs['index'].'"), "'.$attrs['cdn'].'"); ?>';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// js file
|
// js file
|
||||||
case 'js' :
|
case 'js' :
|
||||||
if($type == 'unload') {
|
if($type == 'unload') {
|
||||||
$output = '<?php Context::unloadJsFile("'.$source_filename.'"); ?>';
|
$output = '<?php Context::unloadFile("'.$source_filename.'","'.$attrs['targetie'].'","'.$attrs['media'].'"); ?>';
|
||||||
} else {
|
} else {
|
||||||
$meta_file = $source_filename;
|
$meta_file = $source_filename;
|
||||||
$output = '<?php Context::addJsFile("'.$source_filename.'",false,"'.$attrs['targetie'].'",'.$attrs['index'].',"'.$attrs['type'].'"); ?>';
|
$output = '<?php Context::loadFile(array("'.$source_filename.'","'.$attrs['type'].'","'.$attrs['targetie'].'","'.$attrs['index'].'"), "'.$attrs['cdn'].'"); ?>';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -846,19 +846,19 @@
|
||||||
// css file
|
// css file
|
||||||
case 'css' :
|
case 'css' :
|
||||||
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
||||||
$output = sprintf('<?php Context::addCSSFile("%s", %s, "%s", "%s", %s); ?>', $source_filename, 'false', $media, $targetie, $index);
|
$output = sprintf('<?php Context::loadFile(array("%s", "%s", "%s", "%s")); ?>', $source_filename, $media, $targetie, $index);
|
||||||
} else {
|
} else {
|
||||||
$meta_file = $base_path.$filename;
|
$meta_file = $base_path.$filename;
|
||||||
$output = sprintf('<?php Context::addCSSFile("%s%s", %s, "%s", "%s", %s); ?>', $base_path, $filename, $optimized, $media, $targetie, $index);
|
$output = sprintf('<?php Context::loadFile(array("%s%s", "%s", "%s", "%s")); ?>', $base_path, $filename, $media, $targetie, $index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// js file
|
// js file
|
||||||
case 'js' :
|
case 'js' :
|
||||||
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
||||||
$output = sprintf('<?php Context::addJsFile("%s", %s, "%s", %s,"%s"); ?>', $source_filename, 'false', $targetie, $index, $type);
|
$output = sprintf('<?php Context::loadFile(array("%s", "%s", "%s","%s")); ?>', $source_filename, $type, $targetie, $index);
|
||||||
} else {
|
} else {
|
||||||
$meta_file = $base_path.$filename;
|
$meta_file = $base_path.$filename;
|
||||||
$output = sprintf('<?php Context::addJsFile("%s%s", %s, "%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie, $index, $type);
|
$output = sprintf('<?php Context::loadFile(array("%s%s", "%s", "%s", "%s")); ?>', $base_path, $filename, $type, $targetie, $index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -915,17 +915,17 @@
|
||||||
// css file
|
// css file
|
||||||
case 'css' :
|
case 'css' :
|
||||||
if(preg_match('/^(http|https|\/)/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);
|
$output = sprintf('<?php Context::unloadFile("%s", "%s", "%s"); ?>', $source_filename, $targetie, $media);
|
||||||
} else {
|
} else {
|
||||||
$output = sprintf('<?php Context::unloadCSSFile("%s%s", %s, "%s", "%s"); ?>', $base_path, $filename, $optimized, $media, $targetie);
|
$output = sprintf('<?php Context::unloadFile("%s%s", "%s", "%s"); ?>', $base_path, $filename, $targetie, $media);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// js file
|
// js file
|
||||||
case 'js' :
|
case 'js' :
|
||||||
if(preg_match('/^(http|https|\/)/i',$source_filename)) {
|
if(preg_match('/^(http|https|\/)/i',$source_filename)) {
|
||||||
$output = sprintf('<?php Context::unloadJsFile("%s", %s, "%s"); ?>', $source_filename, 'false', $targetie);
|
$output = sprintf('<?php Context::unloadFile("%s", "%s"); ?>', $source_filename, $targetie);
|
||||||
} else {
|
} else {
|
||||||
$output = sprintf('<?php Context::unloadJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
|
$output = sprintf('<?php Context::unloadFile("%s%s", "%s"); ?>', $base_path, $filename, $targetie);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
if(!file_exists($this->xml_file)) return;
|
if(!file_exists($this->xml_file)) return;
|
||||||
if(!file_exists($this->js_file)) $this->_compile();
|
if(!file_exists($this->js_file)) $this->_compile();
|
||||||
else if(filemtime($this->xml_file)>filemtime($this->js_file)) $this->_compile();
|
else if(filemtime($this->xml_file)>filemtime($this->js_file)) $this->_compile();
|
||||||
Context::addJsFile($this->js_file, false, '',null,'body');
|
Context::loadFile(array($this->js_file, 'body', '',null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
<!--@if($css_file['targetie'])-->
|
<!--@if($css_file['targetie'])-->
|
||||||
<!--[if {$css_file['targetie']}]>
|
<!--[if {$css_file['targetie']}]>
|
||||||
<!--@end-->
|
<!--@end-->
|
||||||
<link rel="stylesheet" href="{$css_file['file']}?{__ZBXE_VERSION__}" type="text/css" charset="UTF-8" media="{$css_file['media']}" />
|
<link rel="stylesheet" href="{$css_file['file']}" type="text/css" charset="UTF-8" media="{$css_file['media']}" />
|
||||||
<!--@if($css_file['targetie'])-->
|
<!--@if($css_file['targetie'])-->
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<!--@end-->
|
<!--@end-->
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<!--@if($js_file['targetie'])-->
|
<!--@if($js_file['targetie'])-->
|
||||||
<!--[if {$js_file['targetie']}]>
|
<!--[if {$js_file['targetie']}]>
|
||||||
<!--@end-->
|
<!--@end-->
|
||||||
<script type="text/javascript" src="{$js_file['file']}?{__ZBXE_VERSION__}"></script>
|
<script type="text/javascript" src="{$js_file['file']}"></script>
|
||||||
<!--@if($js_file['targetie'])-->
|
<!--@if($js_file['targetie'])-->
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<!--@end-->
|
<!--@end-->
|
||||||
|
|
@ -90,7 +90,7 @@
|
||||||
<!--@if($js_file['targetie'])-->
|
<!--@if($js_file['targetie'])-->
|
||||||
<!--[if {$js_file['targetie']}]>
|
<!--[if {$js_file['targetie']}]>
|
||||||
<!--@end-->
|
<!--@end-->
|
||||||
<script type="text/javascript" src="{$js_file['file']}?{__ZBXE_VERSION__}"></script>
|
<script type="text/javascript" src="{$js_file['file']}"></script>
|
||||||
<!--@if($js_file['targetie'])-->
|
<!--@if($js_file['targetie'])-->
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<!--@end-->
|
<!--@end-->
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
Context::set('use_db_session', $db_info->use_db_session=='N'?'N':'Y');
|
Context::set('use_db_session', $db_info->use_db_session=='N'?'N':'Y');
|
||||||
Context::set('use_mobile_view', $db_info->use_mobile_view =='Y'?'Y':'N');
|
Context::set('use_mobile_view', $db_info->use_mobile_view =='Y'?'Y':'N');
|
||||||
Context::set('use_ssl', $db_info->use_ssl?$db_info->use_ssl:"none");
|
Context::set('use_ssl', $db_info->use_ssl?$db_info->use_ssl:"none");
|
||||||
|
Context::set('use_cdn', $db_info->use_cdn?$db_info->use_cdn:"none");
|
||||||
if($db_info->http_port) Context::set('http_port', $db_info->http_port);
|
if($db_info->http_port) Context::set('http_port', $db_info->http_port);
|
||||||
if($db_info->https_port) Context::set('https_port', $db_info->https_port);
|
if($db_info->https_port) Context::set('https_port', $db_info->https_port);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,4 +107,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -107,4 +107,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -106,4 +106,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -105,4 +105,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -97,4 +97,6 @@ $lang->status = '상태';
|
||||||
$lang->find_site = '사이트 찾기';
|
$lang->find_site = '사이트 찾기';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -105,4 +105,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -106,4 +106,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -108,4 +108,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -106,4 +106,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -106,4 +106,6 @@ $lang->find_site = 'Find Site';
|
||||||
$lang->action = '실행';
|
$lang->action = '실행';
|
||||||
|
|
||||||
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
$lang->select_module_id = '모듈 아이디를 선택하세요.';
|
||||||
|
$lang->use_cdn = 'CDN 사용';
|
||||||
|
$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.';
|
||||||
?>
|
?>
|
||||||
|
|
@ -38,6 +38,13 @@
|
||||||
<p>{$lang->about_rewrite}</p>
|
<p>{$lang->about_rewrite}</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><div>{$lang->use_cdn}</div></th>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" name="use_cdn" value="Y" <!--@if($use_cdn=='Y')-->checked="checked"<!--@end--> />
|
||||||
|
<p>{$lang->about_cdn}</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><div>{$lang->use_sso}</div></th>
|
<th><div>{$lang->use_sso}</div></th>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@
|
||||||
$use_sso = Context::get('use_sso');
|
$use_sso = Context::get('use_sso');
|
||||||
if($use_sso !='Y') $use_sso = 'N';
|
if($use_sso !='Y') $use_sso = 'N';
|
||||||
|
|
||||||
|
$use_cdn = Context::get('use_cdn');
|
||||||
|
if($use_cdn != 'Y') $use_cdn = 'N';
|
||||||
|
|
||||||
$time_zone = Context::get('time_zone');
|
$time_zone = Context::get('time_zone');
|
||||||
|
|
||||||
$qmail_compatibility = Context::get('qmail_compatibility');
|
$qmail_compatibility = Context::get('qmail_compatibility');
|
||||||
|
|
@ -80,6 +83,7 @@
|
||||||
$db_info->use_rewrite = $use_rewrite;
|
$db_info->use_rewrite = $use_rewrite;
|
||||||
$db_info->use_sso = $use_sso;
|
$db_info->use_sso = $use_sso;
|
||||||
$db_info->use_ssl = $use_ssl;
|
$db_info->use_ssl = $use_ssl;
|
||||||
|
$db_info->use_cdn = $use_cdn;
|
||||||
$db_info->use_html5 = $use_html5;
|
$db_info->use_html5 = $use_html5;
|
||||||
$db_info->use_mobile_view = $use_mobile_view;
|
$db_info->use_mobile_view = $use_mobile_view;
|
||||||
if($http_port) $db_info->http_port = (int) $http_port;
|
if($http_port) $db_info->http_port = (int) $http_port;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue