git-svn-id: http://xe-core.googlecode.com/svn/trunk@547 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-03-19 10:25:41 +00:00
parent e277f86f12
commit a4f427a228
3 changed files with 50 additions and 1 deletions

View file

@ -670,5 +670,49 @@
return file_exists(Context::getConfigFile()); return file_exists(Context::getConfigFile());
} }
/**
* @brief 내용의 플러그인이나 기타 기능에 대한 code를 실제 code로 변경
**/
function transContent($content) {
// 에디터 컴포넌트를 찾아서 결과 코드로 변환
$content = preg_replace_callback('!<(div|img)([^\>]*?)>(<\/div>)?!is', array($this,'_transMultimedia'), $content);
// <br> 코드 변환
$content = str_replace(array("<BR>","<br>","<Br>"),"<br />", $content);
// <img ...> 코드를 <img ... /> 코드로 변환
$content = preg_replace('!<img(.*?)(\/){0,1}>!is','<img\\1 />', $content);
return $content;
}
/**
* @brief 내용의 멀티미디어 태그를 html 태그로 변경
* <img ... class="multimedia" ..> 되어 있는 코드를 변경
**/
function _transMultimedia($matches) {
// IE에서는 태그의 특성중에서 " 를 빼어 버리는 경우가 있기에 정규표현식으로 추가해줌
$buff = $matches[0];
$buff = preg_replace('/([^=^"^ ]*)=([^"])([^=^ ]*)/i', '$1="$2$3"', $buff);
// 플러그인에서 생성된 코드 (img, div태그내에 plugin코드 존재)의 parameter를 추출
$oXmlParser = new XmlParser();
$xml_doc = $oXmlParser->parse($buff);
// plugin attribute가 없으면 return
$editor_component = $xml_doc->attrs->editor_component;
if(!$editor_component) return $matches[0];
// editor class 객체 생성하여 component 객체 받음
$oEditor = &getClass('editor');
if(!is_object($oEditor)) return $matches[0];
// component::transHTML() 을 이용하여 변환된 코드를 받음
$oComponent = &$oEditor->getComponentObject($editor_component, 0);
if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $matches[0];
return $oComponent->transHTML($xml_doc);
}
} }
?> ?>

View file

@ -27,6 +27,10 @@
// 요청방식에 따라 출력을 별도로 // 요청방식에 따라 출력을 별도로
if(Context::getResponseMethod()!="XMLRPC") { if(Context::getResponseMethod()!="XMLRPC") {
// 각 플러그인, 에디터 컴포넌트의 코드 변경
$oContext = &Context::getInstance();
$content = $oContext->transContent($content);
Context::set('content', $content); Context::set('content', $content);
// content 래핑 (common/tpl/default.html) // content 래핑 (common/tpl/default.html)
@ -34,6 +38,7 @@
$oTemplate = new TemplateHandler(); $oTemplate = new TemplateHandler();
$output = $oTemplate->compile($oModule->getLayoutPath(), $oModule->getLayoutFile()); $output = $oTemplate->compile($oModule->getLayoutPath(), $oModule->getLayoutFile());
} else { } else {
$output = $content; $output = $content;
} }

View file

@ -18,7 +18,7 @@
/** /**
* @brief debug mode = true 일때 files/_debug_message.php 디버그 내용이 쌓임 * @brief debug mode = true 일때 files/_debug_message.php 디버그 내용이 쌓임
**/ **/
define('__DEBUG__', false); define('__DEBUG__', true);
if(__DEBUG__) { if(__DEBUG__) {
// php5이상이면 error handling을 handleError() 로 set // php5이상이면 error handling을 handleError() 로 set