mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 08:42:15 +09:00
#14 별도의 외부 페이지(opage) 모듈을 만들어서 외부 html/php 문서나 외부 html문서등을 내부에서 사용할 수 있는 모듈 제작
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2600 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7f90125627
commit
dc24001d46
21 changed files with 984 additions and 4 deletions
92
modules/opage/opage.view.php
Normal file
92
modules/opage/opage.view.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* @class opageView
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief opage 모듈의 view 클래스
|
||||
**/
|
||||
|
||||
class opageView extends opage {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
// 템플릿 경로 구함 (opage의 경우 tpl에 관리자용 템플릿 모아놓음)
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 일반 요청시 출력
|
||||
**/
|
||||
function dispOpageIndex() {
|
||||
// 권한 체크
|
||||
if(!$this->grant->view) return $this->stop('msg_not_permitted');
|
||||
|
||||
// opage controller 생성
|
||||
$oOpageController = &getController('opage');
|
||||
|
||||
// 외부 페이지 모듈의 정보를 구함
|
||||
$oOpageModel = &getModel('opage');
|
||||
$module_info = $oOpageModel->getOpage($this->module_srl);
|
||||
Context::set('module_info', $module_info);
|
||||
|
||||
// 외부 페이지에서 명시된 외부 페이지 경로/ 캐싱 간격을 를 구함
|
||||
$path = $module_info->path;
|
||||
$caching_interval = $module_info->caching_interval;
|
||||
|
||||
// 캐시 파일 지정
|
||||
$cache_file = sprintf("./files/cache/opage/%d.cache", $module_info->module_srl);
|
||||
|
||||
// 캐시 검사
|
||||
if($caching_interval > 0 && file_exists($cache_file) && filemtime($cache_file) + $caching_interval*60 > time()) {
|
||||
|
||||
$content = FileHandler::readFile($cache_file);
|
||||
|
||||
} else {
|
||||
|
||||
// 경로에 http://가 있는 경우와 없는 경우를 비교
|
||||
if(eregi("^http:\/\/",$path)) {
|
||||
FileHandler::getRemoteFile($path, $cache_file);
|
||||
$content = FileHandler::readFile($cache_file);
|
||||
|
||||
// 서버 내부에 있는 경우
|
||||
} elseif(file_exists($path)) {
|
||||
ob_start();
|
||||
@include($path);
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
FileHandler::writeFile($cache_file, $content);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 외부 서버의 페이지 일 경우 이미지, css, javascript등의 url을 변경
|
||||
if(eregi("^http:\/\/",$path)) {
|
||||
$content = $oOpageController->replaceSrc($content, $path);
|
||||
}
|
||||
|
||||
// 해당 문서를 utf-8로 변경
|
||||
$buff->content = $content;
|
||||
$buff = Context::convertEncoding($buff);
|
||||
$content = $buff->content;
|
||||
|
||||
// title 추출
|
||||
$title = $oOpageController->getTitle($content);
|
||||
if($title) Context::setBrowserTitle($title);
|
||||
|
||||
// header script 추출
|
||||
$head_script = $oOpageController->getHeadScript($content);
|
||||
if($head_script) Context::addHtmlHeader($head_script);
|
||||
|
||||
// body 내용 추출
|
||||
$body_script = $oOpageController->getBodyScript($content);
|
||||
if(!$body_script) $body_script = $content;
|
||||
|
||||
Context::set('opage_content', $body_script);
|
||||
|
||||
// 결과 출력 템플릿 지정
|
||||
$this->setTemplateFile('content');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue