mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +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
|
|
@ -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