mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 08:12:17 +09:00
1. JS/CSS 파일 제거 문법 추가
: Context.class.php에 unloadCSSFile, unloadJsFile 추가 (파일명과 옵션이 일치해야 제거됨) : templateHandler에 <!--%unload(..)--> 추가 2. optmized된 JS/CSS 통합 파일을 제일 먼저 불러오도록 순서 변경 git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4580 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
2f44b9c980
commit
81ac933a7a
3 changed files with 97 additions and 4 deletions
|
|
@ -121,6 +121,9 @@
|
|||
// import xml filter/ css/ js/ 언어파일 <!--%import("filename"[,optimized=true|false][,media="media"][,targetie="lt IE 6|IE 7|gte IE 8|..."])--> (media는 css에만 적용)
|
||||
$buff = preg_replace_callback('!<\!--%import\(\"([^\"]*?)\"(,optimized\=(true|false))?(,media\=\"([^\"]*)\")?(,targetie=\"([^\"]*)\")?\)-->!is', array($this, '_compileImportCode'), $buff);
|
||||
|
||||
// unload css/ js <!--%unload("filename"[,optimized=true|false][,media="media"][,targetie="lt IE 6|IE 7|gte IE 8|..."])--> (media는 css에만 적용)
|
||||
$buff = preg_replace_callback('!<\!--%unload\(\"([^\"]*?)\"(,optimized\=(true|false))?(,media\=\"([^\"]*)\")?(,targetie=\"([^\"]*)\")?\)-->!is', array($this, '_compileUnloadCode'), $buff);
|
||||
|
||||
// 파일에 쓰기 전에 직접 호출되는 것을 방지
|
||||
$buff = sprintf('%s%s%s','<?php if(!defined("__ZBXE__")) exit();?>',"\n",$buff);
|
||||
|
||||
|
|
@ -350,6 +353,55 @@
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief <!--%filename-->의 확장자를 봐서 css/ js 파일을 제거하도록 수정
|
||||
**/
|
||||
function _compileUnloadCode($matches) {
|
||||
// 현재 tpl 파일의 위치를 구해서 $base_path에 저장하여 적용하려는 xml file을 찾음
|
||||
//$base_path = dirname($this->tpl_file).'/';
|
||||
$base_path = $this->tpl_path;
|
||||
$given_file = trim($matches[1]);
|
||||
if(!$given_file) return;
|
||||
if(isset($matches[3]))
|
||||
$optimized = strtolower(trim($matches[3]));
|
||||
if(!$optimized) $optimized = 'true';
|
||||
if(isset($matches[5]))
|
||||
$media = trim($matches[5]);
|
||||
if(!$media) $media = 'all';
|
||||
if(isset($matches[7]))
|
||||
$targetie = trim($matches[7]);
|
||||
if(!$targetie) $targetie = '';
|
||||
else $optimized = 'false';
|
||||
|
||||
$filename = sprintf("%s%s",$base_path, $given_file);
|
||||
|
||||
// path와 파일이름을 구함
|
||||
$tmp_arr = explode("/",$filename);
|
||||
$filename = array_pop($tmp_arr);
|
||||
|
||||
$base_path = implode("/",$tmp_arr)."/";
|
||||
|
||||
// 확장자를 구함
|
||||
$tmp_arr = explode(".",$filename);
|
||||
$ext = strtolower(array_pop($tmp_arr));
|
||||
|
||||
// 확장자에 따라서 파일 import를 별도로
|
||||
switch($ext) {
|
||||
// css file
|
||||
case 'css' :
|
||||
$meta_file = sprintf('%s%s', $base_path, $filename);
|
||||
$output = sprintf('<?php Context::unloadCSSFile("%s%s", %s, "%s", "%s"); ?>', $base_path, $filename, $optimized, $media, $targetie);
|
||||
break;
|
||||
// js file
|
||||
case 'js' :
|
||||
$meta_file = sprintf('%s%s', $base_path, $filename);
|
||||
$output = sprintf('<?php Context::unloadJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
|
||||
break;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief $tpl_file로 compiled_tpl_file이름을 return
|
||||
**/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue