From e6eb7a75d21224a316dc4090156c9e4deca872c3 Mon Sep 17 00:00:00 2001 From: flyskyko Date: Fri, 12 Aug 2011 09:24:54 +0000 Subject: [PATCH] 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 --- classes/context/Context.class.php | 124 +++++----- classes/display/HTMLDisplayHandler.php | 49 ++-- .../FrontEndFileHandler.class.php | 224 ++++++++++++++++++ classes/template/TemplateHandler.class.php | 92 +++---- classes/xml/XmlJsFilter.class.php | 14 +- common/tpl/common_layout.html | 6 +- modules/admin/admin.admin.view.php | 25 +- modules/admin/lang/en.lang.php | 2 + modules/admin/lang/es.lang.php | 2 + modules/admin/lang/fr.lang.php | 2 + modules/admin/lang/jp.lang.php | 2 + modules/admin/lang/ko.lang.php | 2 + modules/admin/lang/ru.lang.php | 2 + modules/admin/lang/tr.lang.php | 2 + modules/admin/lang/vi.lang.php | 2 + modules/admin/lang/zh-CN.lang.php | 2 + modules/admin/lang/zh-TW.lang.php | 2 + modules/admin/tpl/config.html | 13 +- modules/install/install.admin.controller.php | 8 +- 19 files changed, 412 insertions(+), 163 deletions(-) create mode 100644 classes/frontendfile/FrontEndFileHandler.class.php diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 07cbdb8be..1b54dc41d 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -24,8 +24,7 @@ class Context { 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 $js_files_map = array(); ///< hash map of javascript files. The file name is used as a key - var $css_files_map = array(); ///< hash map of css files. The file name is used as a key + var $oFrontEndFileHandler; var $html_header = NULL; ///< script codes in .. var $body_class = array(); ///< classnames of @@ -57,6 +56,14 @@ class Context { return $theInstance; } + /** + * @brief cunstructor + **/ + function Context() + { + $this->oFrontEndFileHandler = new FrontEndFileHandler(); + } + /** * @brief initialization, it sets DB information, request arguments and so on. * @return none @@ -987,6 +994,7 @@ class Context { /** * @brief normalize file path * @return normalized file path + * @deprecated */ function normalizeFilePath($file) { if(strpos($file,'://')===false && $file{0}!='/' && $file{0}!='.') $file = './'.$file; @@ -996,6 +1004,9 @@ class Context { return $file; } + /** + * @deprecated + **/ function getAbsFileUrl($file) { $file = Context::normalizeFilePath($file); if(strpos($file,'./')===0) $file = dirname($_SERVER['SCRIPT_NAME']).'/'.substr($file,2); @@ -1004,37 +1015,54 @@ class Context { 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 + * @deprecated **/ function addJsFile($file, $optimized = false, $targetie = '',$index=0, $type='head') { is_a($this,'Context')?$self=&$this:$self=&Context::getInstance(); - - $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; + $self->oFrontEndFileHandler->loadFile(array($file, $type, $targetie, $index)); } /** * @brief Remove the js file + * @deprecated **/ function unloadJsFile($file, $optimized = false, $targetie = '') { is_a($this,'Context')?$self=&$this:$self=&Context::getInstance(); - - $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; - } - } + $self->oFrontEndFileHandler->unloadFile($file, $targetie); } /** @@ -1042,7 +1070,7 @@ class Context { **/ function unloadAllJsFiles() { 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') { is_a($this,'Context')?$self=&$this:$self=&Context::getInstance(); - - 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; + return $self->oFrontEndFileHandler->getJsFileList($type); } /** * @brief Add CSS file + * @deprecated **/ function addCSSFile($file, $optimized=false, $media='all', $targetie='',$index=0) { is_a($this,'Context')?$self=&$this:$self=&Context::getInstance(); - - 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; + $self->oFrontEndFileHandler->loadFile(array($file, $media, $targetie, $index)); } /** * @brief Remove css file + * @deprecated **/ function unloadCSSFile($file, $optimized = false, $media = 'all', $targetie = '') { is_a($this,'Context')?$self=&$this:$self=&Context::getInstance(); - - $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; - } - } + $self->oFrontEndFileHandler->unloadFile($file, $targetie, $media); } /** @@ -1126,7 +1129,7 @@ class Context { **/ function unloadAllCSSFiles() { 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() { is_a($this,'Context')?$self=&$this:$self=&Context::getInstance(); - - 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; + return $self->oFrontEndFileHandler->getCssFileList(); } /** @@ -1168,8 +1162,8 @@ class Context { if(!$filename) continue; if(substr($filename,0,2)=='./') $filename = substr($filename,2); - if(preg_match('/\.js$/i', $filename)) $self->addJsFile($plugin_path.$filename, false, '', 0, 'body'); - elseif(preg_match('/\.css$/i', $filename)) $self->addCSSFile($plugin_path.$filename, false, 'all', '', 0); + if(preg_match('/\.js$/i', $filename)) $self->loadFile(array($plugin_path.$filename, 'body', '', 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'); diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index 6a120d993..9b94cdf3f 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -5,7 +5,7 @@ class HTMLDisplayHandler { * @brief Produce HTML compliant content given a module object.\n * @param[in] $oModule the module object **/ - function toDoc(&$oModule) + function toDoc(&$oModule) { $oTemplate = &TemplateHandler::getInstance(); @@ -14,7 +14,7 @@ class HTMLDisplayHandler { $skin = $oModule->origin_module_info->skin; else $skin = $oModule->module_config->skin; - + if ($skin){ $theme_skin = explode('.', $skin); if (count($theme_skin) == 2) @@ -58,7 +58,7 @@ class HTMLDisplayHandler { // search if the changes CSS exists in the admin layout edit window $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_file) $layout_file = "default_layout"; @@ -76,7 +76,7 @@ class HTMLDisplayHandler { function prepareToPrint(&$output) { if(Context::getResponseMethod() != 'HTML') return; - + if(__DEBUG__==3) $start = getMicroTime(); // move in body to the header @@ -146,13 +146,12 @@ class HTMLDisplayHandler { } /** - * @brief add given .css or .js file names in widget code to Context + * @brief add given .css or .js file names in widget code to Context * @param[in] $oModule the module object **/ function _transMeta($matches) { if($matches[1]) return ''; - if(substr($matches[2],'-4')=='.css') Context::addCSSFile($matches[2]); - elseif(substr($matches[2],'-3')=='.js') Context::addJSFile($matches[2]); + Context::loadFile($matches[2]); } function _loadJSCSS() @@ -162,31 +161,31 @@ class HTMLDisplayHandler { // add common JS/CSS files if(__DEBUG__) { - $oContext->addJsFile('./common/js/jquery.js', false, '', -100000); - $oContext->addJsFile('./common/js/x.js', false, '', -100000); - $oContext->addJsFile('./common/js/common.js', false, '', -100000); - $oContext->addJsFile('./common/js/js_app.js', false, '', -100000); - $oContext->addJsFile('./common/js/xml_handler.js', false, '', -100000); - $oContext->addJsFile('./common/js/xml_js_filter.js', false, '', -100000); - $oContext->addCSSFile('./common/css/default.css', false, 'all', '', -100000); - $oContext->addCSSFile('./common/css/button.css', false, 'all', '', -100000); + $oContext->loadFile(array('./common/js/jquery.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/x.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/common.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/js_app.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/css/default.css', 'all', '', -100000)); + $oContext->loadFile(array('./common/css/button.css', 'all', '', -100000)); } else { - $oContext->addJsFile('./common/js/jquery.min.js', false, '', -100000); - $oContext->addJsFile('./common/js/x.min.js', false, '', -100000); - $oContext->addJsFile('./common/js/xe.min.js', false, '', -100000); - $oContext->addCSSFile('./common/css/xe.min.css', false, 'all', '', -100000); + $oContext->loadFile(array('./common/js/jquery.min.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/x.min.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/js/xe.min.js', 'head', '', -100000)); + $oContext->loadFile(array('./common/css/xe.min.css', 'all', '', -100000)); } // for admin page, add admin css if(Context::get('module')=='admin' || strpos(Context::get('act'),'Admin')>0){ if(__DEBUG__) { - $oContext->addCSSFile('./modules/admin/tpl/css/admin.css', false, 'all', '', 100000); - $oContext->addCSSFile("./modules/admin/tpl/css/admin_{$lang_type}.css", false, 'all', '', 100000); - $oContext->addJsFile('./modules/admin/tpl/js/admin.js'); + $oContext->loadFile(array('./modules/admin/tpl/css/admin.css', 'all', '', 100000)); + $oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.css", 'all', '', 100000)); + $oContext->loadFile('./modules/admin/tpl/js/admin.js'); } else { - $oContext->addCSSFile('./modules/admin/tpl/css/admin.min.css', false, 'all', '', 100000); - $oContext->addCSSFile("./modules/admin/tpl/css/admin_{$lang_type}.min.css", false, 'all', '',10000); - $oContext->addJsFile('./modules/admin/tpl/js/admin.js'); + $oContext->loadFile(array('./modules/admin/tpl/css/admin.min.css', 'all', '', 100000)); + $oContext->loadFile(array("./modules/admin/tpl/css/admin_{$lang_type}.min.css", 'all', '',10000)); + $oContext->loadFile('./modules/admin/tpl/js/admin.js'); } } } diff --git a/classes/frontendfile/FrontEndFileHandler.class.php b/classes/frontendfile/FrontEndFileHandler.class.php new file mode 100644 index 000000000..0f9a73c20 --- /dev/null +++ b/classes/frontendfile/FrontEndFileHandler.class.php @@ -0,0 +1,224 @@ +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('@/\./|(?_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; + } + } \ No newline at end of file diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index e8f759808..fa07c9e02 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -2,19 +2,19 @@ /** * @class TemplateHandler * @author NHN (developers@xpressengine.com) - * @brief template compiler + * @brief template compiler * @version 0.1 - * @remarks It compiles template file by using regular expression into php - * code, and XE caches compiled code for further uses + * @remarks It compiles template file by using regular expression into php + * code, and XE caches compiled code for further uses **/ class TemplateHandler extends Handler { var $compiled_path = './files/cache/template_compiled/'; ///< path of compiled caches files - var $path = null; ///< target directory + var $path = null; ///< target directory var $filename = null; ///< target filename - var $file = null; ///< target file (fullpath) + var $file = null; ///< target file (fullpath) var $xe_path = null; ///< XpressEngine base path var $web_path = null; ///< tpl file web path var $compiled_file = null; ///< tpl file web path @@ -42,11 +42,11 @@ * @brief set variables for template compile **/ function init($tpl_path, $tpl_filename, $tpl_file) { - // verify arguments + // verify arguments if(substr($tpl_path,-1)!='/') $tpl_path .= '/'; if(!file_exists($tpl_path.$tpl_filename)&&file_exists($tpl_path.$tpl_filename.'.html')) $tpl_filename .= '.html'; - // create tpl_file variable + // create tpl_file variable if(!$tpl_file) $tpl_file = $tpl_path.$tpl_filename; // set template file infos. @@ -69,11 +69,11 @@ } /** - * @brief compiles specified tpl file and execution result in Context into resultant content + * @brief compiles specified tpl file and execution result in Context into resultant content * @param[in] $tpl_path path of the directory containing target template file * @param[in] $tpl_filename target template file's name - * @param[in] $tpl_file if specified use it as template file's full path - * @return Returns compiled result in case of success, NULL otherwise + * @param[in] $tpl_file if specified use it as template file's full path + * @return Returns compiled result in case of success, NULL otherwise */ function compile($tpl_path, $tpl_filename, $tpl_file = '') { // store the starting time for debug information @@ -136,16 +136,16 @@ } /** - * @brief compile a template file specified in $tpl_file and + * @brief compile a template file specified in $tpl_file and * @pre files specified by $tpl_file exists. * @param[in] $tpl_file path of tpl file * @param[in] $compiled_tpl_file if specified, write compiled result into the file - * @return compiled result in case of success or NULL in case of error + * @return compiled result in case of success or NULL in case of error **/ function parse() { if(!file_exists($this->file)) return; - // read tpl file + // read tpl file $buff = FileHandler::readFile($this->file); // replace value of src in img/input/script tag @@ -172,10 +172,10 @@ // replace include $buff = preg_replace_callback('!<\!--#include\(([^\)]*?)\)-->!is', array($this, '_compileIncludeToCode'), $buff); - // replace + // replace $buff = preg_replace_callback('!<\!--@(.*?)-->!is', array($this, '_compileFuncToCode'), $buff); - // remove comments + // remove comments $buff = preg_replace('!(\n?)( *?)<\!--//(.*?)-->!is', '', $buff); // import xml filter/ css/ js/ files (media is applied to only css) @@ -245,7 +245,7 @@ } /** - * @brief fetch using ob_* function + * @brief fetch using ob_* function * @param[in] $compiled_tpl_file path of compiled template file * @param[in] $buff if buff is not null, eval it instead of including compiled template file * @param[in] $tpl_path set context's tpl path @@ -271,7 +271,7 @@ * @param[in] $matches match * @return changed result **/ - function _replacePath($matches) + function _replacePath($matches) { preg_match_all('/src="([^"]*?)"/is', $matches[0], $m); for($i=0,$c=count($m[0]);$i<$c;$i++) { @@ -279,7 +279,7 @@ if(substr($path,0,1)=='/' || substr($path,0,1)=='{' || strpos($path,'://')!==false) continue; if(substr($path,0,2)=='./') $path = substr($path,2); $target = $this->web_path.$path; - while(strpos($target,'/../')!==false) + while(strpos($target,'/../')!==false) { $target = preg_replace('/\/([^\/]+)\/\.\.\//','/',$target); } @@ -358,7 +358,7 @@ } } - if(substr(trim($tag),-2)!='/>') + if(substr(trim($tag),-2)!='/>') { while(false !== $close_pos = strpos($next, ''; $tag_tail .= ''; } - } + } if(!preg_match('/ cond="([^"]+)"/is',$tag)) { print "Invalid XpressEngine Template Syntax
"; @@ -435,11 +435,11 @@ } $tag = preg_replace('/ cond="([^"]+)"/is','', $tag); - if(substr(trim($tag),-2)=='/>') + if(substr(trim($tag),-2)=='/>') { $buff = $pre.$tag_head.$tag.$tag_tail.$next; - } - else + } + else { while(false !== $close_pos = strpos($next, 'path; $target = $attrs['target']; - if(!preg_match('/^(http|https)/i',$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; @@ -567,19 +567,19 @@ // css file case 'css' : if($type == 'unload') { - $output = ''; + $output = ''; } else { $meta_file = $source_filename; - $output = ''; + $output = ''; } break; // js file case 'js' : if($type == 'unload') { - $output = ''; + $output = ''; } else { $meta_file = $source_filename; - $output = ''; + $output = ''; } break; } @@ -658,7 +658,7 @@ $filename = array_pop($tmp_arr); $path = implode('/', $tmp_arr).'/'; - // try to include + // try to include $output = sprintf( '" with appropriate php code + * @brief replace xe specific code, "" with appropriate php code * @param[in] $matches match * @return Returns modified result or NULL in case of error **/ @@ -846,19 +846,19 @@ // css file case 'css' : if(preg_match('/^(http|\/)/i',$source_filename)) { - $output = sprintf('', $source_filename, 'false', $media, $targetie, $index); + $output = sprintf('', $source_filename, $media, $targetie, $index); } else { $meta_file = $base_path.$filename; - $output = sprintf('', $base_path, $filename, $optimized, $media, $targetie, $index); + $output = sprintf('', $base_path, $filename, $media, $targetie, $index); } break; // js file case 'js' : if(preg_match('/^(http|\/)/i',$source_filename)) { - $output = sprintf('', $source_filename, 'false', $targetie, $index, $type); + $output = sprintf('', $source_filename, $type, $targetie, $index); } else { $meta_file = $base_path.$filename; - $output = sprintf('', $base_path, $filename, $optimized, $targetie, $index, $type); + $output = sprintf('', $base_path, $filename, $type, $targetie, $index); } break; } @@ -869,7 +869,7 @@ } /** - * @brief import javascript plugin + * @brief import javascript plugin * @param[in] $matches match * @return result loading the plugin * @remarks javascript plugin works as optimized = false @@ -881,12 +881,12 @@ } /** - * @brief remove loading part of css/ js file + * @brief remove loading part of css/ js file * @param[in] $matches match * @return removed result **/ function _compileUnloadCode($matches) { - // find xml file + // find xml file $base_path = $this->path; $given_file = trim($matches[1]); if(!$given_file) return; @@ -915,17 +915,17 @@ // css file case 'css' : if(preg_match('/^(http|https|\/)/i',$source_filename)) { - $output = sprintf('', $source_filename, 'false', $media, $targetie); + $output = sprintf('', $source_filename, $targetie, $media); } else { - $output = sprintf('', $base_path, $filename, $optimized, $media, $targetie); + $output = sprintf('', $base_path, $filename, $targetie, $media); } break; // js file case 'js' : if(preg_match('/^(http|https|\/)/i',$source_filename)) { - $output = sprintf('', $source_filename, 'false', $targetie); + $output = sprintf('', $source_filename, $targetie); } else { - $output = sprintf('', $base_path, $filename, $optimized, $targetie); + $output = sprintf('', $base_path, $filename, $targetie); } break; } diff --git a/classes/xml/XmlJsFilter.class.php b/classes/xml/XmlJsFilter.class.php index 7e8ae0122..bdd9e8625 100644 --- a/classes/xml/XmlJsFilter.class.php +++ b/classes/xml/XmlJsFilter.class.php @@ -6,8 +6,8 @@ * @version 0.2 * * it convert xml code into js file and save the result as a cache file - * @code - * { + * @code + * { * *
<-- code to validate data in the form * @@ -42,7 +42,7 @@ * tag = key : name of variable that will contain the result of the execution * } **/ - + class XmlJsFilter extends XmlParser { var $version = '0.2.5'; var $compiled_path = './files/cache/js_filter_compiled/'; // / directory path for compiled cache file @@ -66,7 +66,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, false, '',null,'body'); + Context::loadFile(array($this->js_file, 'body', '',null)); } /** @@ -90,7 +90,7 @@ $module = $attrs->module; $act = $attrs->act; $extend_filter = $attrs->extend_filter; - + $field_node = $xml_obj->filter->form->node; if($field_node && !is_array($field_node)) $field_node = array($field_node); @@ -181,7 +181,7 @@ // Check extend_filter_item $rule_types = array('homepage'=>'homepage', 'email_address'=>'email'); - + for($i=0;$i<$extend_filter_count;$i++) { $filter_item = $extend_filter_list[$i]; $target = trim($filter_item->name); @@ -265,7 +265,7 @@ $confirm_msg = ''; if ($confirm_msg_code) $confirm_msg = $lang->{$confirm_msg_code}; - + $jsdoc = array(); $jsdoc[] = "function {$filter_name}(form){ return legacy_filter('{$filter_name}', form, '{$module}', '{$act}', {$callback_func}, [".implode(',', $responses)."], '".addslashes($confirm_msg)."', {".implode(',', $rename_params)."}) };"; $jsdoc[] = '(function($){'; diff --git a/common/tpl/common_layout.html b/common/tpl/common_layout.html index 4e2c0e77c..3c54c3fa1 100644 --- a/common/tpl/common_layout.html +++ b/common/tpl/common_layout.html @@ -32,7 +32,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -90,7 +90,7 @@ - + diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index c1d6c985c..466135581 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -20,14 +20,14 @@ $logged_info = $oMemberModel->getLoggedInfo(); if($logged_info->is_admin!='Y') return $this->stop("msg_is_not_administrator"); - // change into administration layout + // change into administration layout $this->setTemplatePath($this->module_path.'tpl'); $this->setLayoutPath($this->getTemplatePath()); $this->setLayoutFile('layout.html'); $this->makeGnbUrl(); - // Retrieve the list of installed modules + // Retrieve the list of installed modules $db_info = Context::getDBInfo(); @@ -41,6 +41,7 @@ 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_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->https_port) Context::set('https_port', $db_info->https_port); @@ -117,7 +118,7 @@ if($val->category == 'statistics') $val->category = 'accessory'; if($val->module == 'admin' || !$val->admin_index_act) continue; - // get action information + // get action information $action_spec = $oModuleModel->getModuleActionXml($val->module); $actions = array(); if($action_spec->default_index_act) $actions[] = $action_spec->default_index_act; @@ -131,14 +132,14 @@ $obj->index_act = $val->admin_index_act; if(in_array(Context::get('act'), $actions)) $obj->selected = true; - // Packages + // Packages if($val->category == 'package') { if($package_idx == 0) $obj->position = "first"; else $obj->position = "mid"; $package_modules[] = $obj; $package_idx ++; if($obj->selected) Context::set('package_selected',true); - // Modules + // Modules } else { $installed_modules[] = $obj; } @@ -194,7 +195,7 @@ Context::set('download_link', $buff->zbxe_news->attrs->download_link); } - // DB Information + // DB Information $db_info = Context::getDBInfo(); Context::set('selected_lang', $db_info->lang_type); @@ -302,7 +303,7 @@ $output = executeQuery("admin.getDocumentCount", $args); $status->document->total = $output->data->count; - // Comment Status + // Comment Status $output = executeQueryArray("admin.getCommentStatus", $args); if($output->data) { foreach($output->data as $var) { @@ -316,7 +317,7 @@ $output = executeQuery("admin.getCommentCount", $args); $status->comment->total = $output->data->count; - // Trackback Status + // Trackback Status $output = executeQueryArray("admin.getTrackbackStatus", $args); if($output->data) { foreach($output->data as $var) { @@ -330,7 +331,7 @@ $output = executeQuery("admin.getTrackbackCount", $args); $status->trackback->total = $output->data->count; - // Attached files Status + // Attached files Status $output = executeQueryArray("admin.getFileStatus", $args); if($output->data) { foreach($output->data as $var) { @@ -400,7 +401,7 @@ Context::set('lang_selected', Context::loadLangSelected()); Context::set('use_mobile_view', $db_info->use_mobile_view=="Y"?'Y':'N'); - + $ftp_info = Context::getFTPInfo(); Context::set('ftp_info', $ftp_info); @@ -441,7 +442,7 @@ Context::addHtmlFooter($img); FileHandler::removeDir($path); - FileHandler::writeFile($path.__ZBXE_VERSION__,'1'); + FileHandler::writeFile($path.__ZBXE_VERSION__,'1'); } else if($_SESSION['enviroment_gather']=='Y' && !file_exists($path.__ZBXE_VERSION__)) { $oAdminAdminModel = &getAdminModel('admin'); @@ -450,7 +451,7 @@ Context::addHtmlFooter($img); FileHandler::removeDir($path); - FileHandler::writeFile($path.__ZBXE_VERSION__,'1'); + FileHandler::writeFile($path.__ZBXE_VERSION__,'1'); unset($_SESSION['enviroment_gather']); } } diff --git a/modules/admin/lang/en.lang.php b/modules/admin/lang/en.lang.php index ee4c5a05f..cb40344fd 100644 --- a/modules/admin/lang/en.lang.php +++ b/modules/admin/lang/en.lang.php @@ -107,4 +107,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/es.lang.php b/modules/admin/lang/es.lang.php index 57f7229e5..59fe98018 100644 --- a/modules/admin/lang/es.lang.php +++ b/modules/admin/lang/es.lang.php @@ -107,4 +107,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/fr.lang.php b/modules/admin/lang/fr.lang.php index 81b3d9c21..a6be1b6bb 100644 --- a/modules/admin/lang/fr.lang.php +++ b/modules/admin/lang/fr.lang.php @@ -106,4 +106,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/jp.lang.php b/modules/admin/lang/jp.lang.php index ca8879d90..81f699b87 100644 --- a/modules/admin/lang/jp.lang.php +++ b/modules/admin/lang/jp.lang.php @@ -105,4 +105,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/ko.lang.php b/modules/admin/lang/ko.lang.php index 15bd2ebe4..4c62933bd 100644 --- a/modules/admin/lang/ko.lang.php +++ b/modules/admin/lang/ko.lang.php @@ -97,4 +97,6 @@ $lang->status = '상태'; $lang->find_site = '사이트 찾기'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/ru.lang.php b/modules/admin/lang/ru.lang.php index 5f475da9e..f06e733a7 100644 --- a/modules/admin/lang/ru.lang.php +++ b/modules/admin/lang/ru.lang.php @@ -105,4 +105,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/tr.lang.php b/modules/admin/lang/tr.lang.php index d05d6ca83..b3ed75768 100644 --- a/modules/admin/lang/tr.lang.php +++ b/modules/admin/lang/tr.lang.php @@ -106,4 +106,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/vi.lang.php b/modules/admin/lang/vi.lang.php index 1a26785a7..71fb95b83 100644 --- a/modules/admin/lang/vi.lang.php +++ b/modules/admin/lang/vi.lang.php @@ -108,4 +108,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/zh-CN.lang.php b/modules/admin/lang/zh-CN.lang.php index 5397e8bf2..1c960b544 100644 --- a/modules/admin/lang/zh-CN.lang.php +++ b/modules/admin/lang/zh-CN.lang.php @@ -106,4 +106,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/lang/zh-TW.lang.php b/modules/admin/lang/zh-TW.lang.php index 16c11692e..b2d45601a 100644 --- a/modules/admin/lang/zh-TW.lang.php +++ b/modules/admin/lang/zh-TW.lang.php @@ -106,4 +106,6 @@ $lang->find_site = 'Find Site'; $lang->action = '실행'; $lang->select_module_id = '모듈 아이디를 선택하세요.'; +$lang->use_cdn = 'CDN 사용'; +$lang->about_cdn = 'XE core의 css, js 파일을 CDN으로부터 제공받으려면 체크하세요.'; ?> \ No newline at end of file diff --git a/modules/admin/tpl/config.html b/modules/admin/tpl/config.html index 780c13fd7..05baaf4ff 100644 --- a/modules/admin/tpl/config.html +++ b/modules/admin/tpl/config.html @@ -38,6 +38,13 @@

{$lang->about_rewrite}

+ +
{$lang->use_cdn}
+ + checked="checked" /> +

{$lang->about_cdn}

+ +
{$lang->use_sso}
@@ -110,7 +117,7 @@
{$lang->server_ports}
- HTTP : , + HTTP : , HTTPS:

{$lang->about_server_ports}

@@ -146,7 +153,7 @@
- +
@@ -165,7 +172,7 @@
{$lang->msg_ftp_installed_ftp_realpath}

{$lang->msg_ftp_installed_realpath}:
{_XE_PATH_}
- + diff --git a/modules/install/install.admin.controller.php b/modules/install/install.admin.controller.php index 16d7f3ef7..9c26c43e0 100644 --- a/modules/install/install.admin.controller.php +++ b/modules/install/install.admin.controller.php @@ -51,6 +51,9 @@ $use_sso = Context::get('use_sso'); 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'); $qmail_compatibility = Context::get('qmail_compatibility'); @@ -80,6 +83,7 @@ $db_info->use_rewrite = $use_rewrite; $db_info->use_sso = $use_sso; $db_info->use_ssl = $use_ssl; + $db_info->use_cdn = $use_cdn; $db_info->use_html5 = $use_html5; $db_info->use_mobile_view = $use_mobile_view; if($http_port) $db_info->http_port = (int) $http_port; @@ -124,7 +128,7 @@ } function procInstallAdminRemoveFTPInfo() { - $ftp_config_file = Context::getFTPConfigFile(); + $ftp_config_file = Context::getFTPConfigFile(); if(file_exists($ftp_config_file)) unlink($ftp_config_file); if($_SESSION['ftp_password']) unset($_SESSION['ftp_password']); $this->setMessage('success_deleted'); @@ -149,7 +153,7 @@ if(ini_get('safe_mode')) { $ftp_info->ftp_password = Context::get('ftp_password'); } - + $buff = ' $val) { if(!$val) continue;