mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
#17143608 외부페이지에서 css, js에 대해서 상대 또는 절대경로로 import 문법을 이용시에 ./files/cache/opage/경로 라는 이상한 path가 설정되는 것을 수정.
수정된 방법은 대상 외부페이지 파일의 위치로 import 구문의 경로를 바꾸어서 직접 호출되도록 수정하는 방법을 사용. git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6323 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
2fab7c2b7e
commit
ca413d3c90
3 changed files with 51 additions and 32 deletions
|
|
@ -101,7 +101,7 @@
|
|||
$output = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'moveStyleToHeader'), $output);
|
||||
|
||||
// 메타 파일 변경 (캐싱기능등으로 인해 위젯등에서 <!--Meta:경로--> 태그를 content에 넣는 경우가 있음
|
||||
$output = preg_replace_callback('/<!--Meta:([a-z0-9\_\/\.]+)-->/is', array($this,'transMeta'), $output);
|
||||
$output = preg_replace_callback('/<!--Meta:([a-z0-9\_\/\.\@]+)-->/is', array($this,'transMeta'), $output);
|
||||
|
||||
// rewrite module 사용시 생기는 상대경로에 대한 처리를 함
|
||||
if(Context::isAllowRewrite()) {
|
||||
|
|
|
|||
|
|
@ -312,18 +312,14 @@
|
|||
**/
|
||||
function _compileImportCode($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(isset($matches[3])) $optimized = strtolower(trim($matches[3]));
|
||||
if(!$optimized) $optimized = 'true';
|
||||
if(isset($matches[5]))
|
||||
$media = trim($matches[5]);
|
||||
if(isset($matches[5])) $media = trim($matches[5]);
|
||||
if(!$media) $media = 'all';
|
||||
if(isset($matches[7]))
|
||||
$targetie = trim($matches[7]);
|
||||
if(isset($matches[7])) $targetie = trim($matches[7]);
|
||||
if(!$targetie) $targetie = '';
|
||||
else $optimized = 'false';
|
||||
|
||||
|
|
@ -335,10 +331,11 @@
|
|||
|
||||
// load lang이 아니라면 xml, css, js파일을 읽도록 시도
|
||||
} else {
|
||||
$filename = sprintf("%s%s",$base_path, $given_file);
|
||||
if(substr($given_file,0,1)!='/') $source_filename = sprintf("%s%s",$base_path, $given_file);
|
||||
else $source_filename = $given_file;
|
||||
|
||||
// path와 파일이름을 구함
|
||||
$tmp_arr = explode("/",$filename);
|
||||
$tmp_arr = explode("/",$source_filename);
|
||||
$filename = array_pop($tmp_arr);
|
||||
|
||||
$base_path = implode("/",$tmp_arr)."/";
|
||||
|
|
@ -369,18 +366,26 @@
|
|||
break;
|
||||
// css file
|
||||
case 'css' :
|
||||
$meta_file = sprintf('%s%s', $base_path, $filename);
|
||||
$output = sprintf('<?php Context::addCSSFile("%s%s", %s, "%s", "%s"); ?>', $base_path, $filename, $optimized, $media, $targetie);
|
||||
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
||||
$output = sprintf('<?php Context::addCSSFile("%s", %s, "%s", "%s"); ?>', $source_filename, 'false', $media, $targetie);
|
||||
} else {
|
||||
$meta_file = sprintf('%s%s', $base_path, $filename);
|
||||
$output = sprintf('<?php Context::addCSSFile("%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::addJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
|
||||
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
||||
$output = sprintf('<?php Context::addJsFile("%s", %s, "%s"); ?>', $source_filename, 'false', $targetie);
|
||||
} else {
|
||||
$meta_file = sprintf('%s%s', $base_path, $filename);
|
||||
$output = sprintf('<?php Context::addJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$output = '<!--Meta:'.$meta_file.'-->'.$output;
|
||||
if($meta_file) $output = '<!--Meta:'.$meta_file.'-->'.$output;
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
@ -399,25 +404,22 @@
|
|||
**/
|
||||
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(isset($matches[3])) $optimized = strtolower(trim($matches[3]));
|
||||
if(!$optimized) $optimized = 'true';
|
||||
if(isset($matches[5]))
|
||||
$media = trim($matches[5]);
|
||||
if(isset($matches[5])) $media = trim($matches[5]);
|
||||
if(!$media) $media = 'all';
|
||||
if(isset($matches[7]))
|
||||
$targetie = trim($matches[7]);
|
||||
if(isset($matches[7])) $targetie = trim($matches[7]);
|
||||
if(!$targetie) $targetie = '';
|
||||
else $optimized = 'false';
|
||||
|
||||
$filename = sprintf("%s%s",$base_path, $given_file);
|
||||
if(substr($given_file,0,1)!='/') $source_filename = sprintf("%s%s",$base_path, $given_file);
|
||||
else $source_filename = $given_file;
|
||||
|
||||
// path와 파일이름을 구함
|
||||
$tmp_arr = explode("/",$filename);
|
||||
$tmp_arr = explode("/",$source_filename);
|
||||
$filename = array_pop($tmp_arr);
|
||||
|
||||
$base_path = implode("/",$tmp_arr)."/";
|
||||
|
|
@ -430,13 +432,21 @@
|
|||
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);
|
||||
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
||||
$output = sprintf('<?php Context::unloadCSSFile("%s", %s, "%s", "%s"); ?>', $source_filename, 'false', $media, $targetie);
|
||||
} else {
|
||||
$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);
|
||||
if(preg_match('/^(http|\/)/i',$source_filename)) {
|
||||
$output = sprintf('<?php Context::unloadJsFile("%s", %s, "%s"); ?>', $source_filename, 'false', $targetie);
|
||||
} else {
|
||||
$meta_file = sprintf('%s%s', $base_path, $filename);
|
||||
$output = sprintf('<?php Context::unloadJsFile("%s%s", %s, "%s"); ?>', $base_path, $filename, $optimized, $targetie);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@
|
|||
$path_info = pathinfo($path);
|
||||
$this->path = realpath($path_info['dirname']).'/';
|
||||
$content = preg_replace_callback('/(src=|href=|url\()("|\')?([^"\'\)]+)("|\'\))?/is',array($this,'_replacePath'),$content);
|
||||
$content = preg_replace_callback('/(<!--%import\()(\")([^"]+)(\")/is',array($this,'_replacePath'),$content);
|
||||
|
||||
FileHandler::writeFile($cache_file, $content);
|
||||
|
||||
|
|
@ -138,11 +139,19 @@
|
|||
|
||||
function _replacePath($matches) {
|
||||
$val = trim($matches[3]);
|
||||
if(preg_match('/^(http|\/|\.\.)/i',$val)) return $matches[0];
|
||||
if(substr($val,0,2)=='./') $val = substr($val,2);
|
||||
|
||||
$p = str_replace(_XE_PATH_,'',$this->path);
|
||||
return sprintf("%s%s%s%s",$matches[1],$matches[2],getUrl('').$val,$matches[4]);
|
||||
// http 또는 / 로 시작하는 경로라면 그냥 pass
|
||||
if(preg_match('/^(http|\/)/i',$val)) return $matches[0];
|
||||
|
||||
// .. 와 같은 경우 대상 경로를 구함
|
||||
elseif(preg_match('/^(\.\.)/i',$val)) {
|
||||
$p = '/'.str_replace(_XE_PATH_,'',$this->path);
|
||||
return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]);
|
||||
}
|
||||
|
||||
if(substr($val,0,2)=='./') $val = substr($val,2);
|
||||
$p = '/'.str_replace(_XE_PATH_,'',$this->path);
|
||||
return sprintf("%s%s%s%s",$matches[1],$matches[2],$p.$val,$matches[4]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue