mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
위젯 핸들링 하는 부분을 수정하여 페이지 수정시 위젯을 추가하게 되면 해당 페이지를 다시 읽어 플래시파일등의 추가 및 css의 오류가 없도록 수정
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3603 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
de2a43eb43
commit
95cfcf7f83
10 changed files with 209 additions and 215 deletions
|
|
@ -13,20 +13,29 @@
|
|||
* @brief 위젯 캐시 처리
|
||||
**/
|
||||
function getCache($sequence, $cache) {
|
||||
// 위젯 캐시는 캐시 번호와 캐시 시간이 없으면 캐시하지 않는 것으로 처리함
|
||||
if(!$sequence || !$cache) return;
|
||||
|
||||
// 캐시 디렉토리가 없으면 생성하고 return
|
||||
$cache_path = './files/cache/widget_cache/';
|
||||
if(!is_dir($cache_path)) {
|
||||
FileHandler::makeDir($cache_path);
|
||||
return;
|
||||
}
|
||||
|
||||
// 캐시파일명을 구해서 해당 파일이 없으면 return
|
||||
$cache_file = sprintf('%s%d.%s.cache', $cache_path, $sequence, Context::getLangType());
|
||||
if(!file_exists($cache_file)) return;
|
||||
|
||||
$filemtime= filemtime($cache_file);
|
||||
$filemtime = filemtime($cache_file);
|
||||
|
||||
// 만약 캐시파일이 widgetHandler보다 이전에 생성된 파일이면 새로 캐시해야 함
|
||||
if($filemtime < filemtime('./classes/widget/WidgetHandler.class.php')) return;
|
||||
|
||||
// 캐시 파일의 수정일이 캐시시간보다 크면 새로 만들기 위해서 return
|
||||
if($filemtime + $cache*60 < time()) return;
|
||||
|
||||
// 캐시 파일 내용을 읽어서 return
|
||||
$output = FileHandler::readFile($cache_file);
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -42,130 +51,170 @@
|
|||
|
||||
/**
|
||||
* @brief 위젯을 찾아서 실행하고 결과를 출력
|
||||
* <div widget='위젯'...></div> 태그 사용 templateHandler에서 WidgetHandler::execute()를 실행하는 코드로 대체하게 된다
|
||||
* 태그 사용 templateHandler에서 WidgetHandler::execute()를 실행하는 코드로 대체하게 된다
|
||||
*
|
||||
* $include_info가 true일 경우 css 코드와 위젯핸들링을 위한 코드까지 포함하도록 한다
|
||||
* $include_info가 true일 경우 페이지 수정시 위젯 핸들링을 위한 코드까지 포함함
|
||||
**/
|
||||
function execute($widget, $args, $include_info = false) {
|
||||
// 디버그를 위한 위젯 실행 시간 저장
|
||||
if(__DEBUG__==3) $start = getMicroTime();
|
||||
|
||||
$args->style = preg_replace('/background\-image: url\(none\)/is','', $args->style);
|
||||
|
||||
// widget중 widgetContent 는 page 모듈에 종속적인 위젯으로 직접 page.admin.controller.php를 호출하여 처리를 해야 함 (차후 정리 필요)
|
||||
if($widget == 'widgetContent') {
|
||||
$style = $args->style;
|
||||
$body = base64_decode($args->body);
|
||||
$widget_padding_left = $args->widget_padding_left;
|
||||
$widget_padding_right = $args->widget_padding_right;
|
||||
$widget_padding_top = $args->widget_padding_top;
|
||||
$widget_padding_bottom = $args->widget_padding_bottom;
|
||||
if($include_info) {
|
||||
$oWidgetController = &getController('widget');
|
||||
$tpl = $oWidgetController->transEditorContent($body, $args);
|
||||
} else {
|
||||
$tpl = sprintf('<div style="overflow:hidden;%s"><div style="padding:%s %s %s %s;">%s</div></div>', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $body);
|
||||
// args값에서 urldecode를 해줌
|
||||
$object_vars = get_object_vars($args);
|
||||
if(count($object_vars)) {
|
||||
foreach($object_vars as $key => $val) {
|
||||
if(in_array($key, array('body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right'))) continue;
|
||||
$args->{$key} = urldecode($val);
|
||||
}
|
||||
return $tpl;
|
||||
// widget Box일 경우 간단히 변경만 시도함
|
||||
} else if($widget == 'widgetBox') {
|
||||
$style = $args->style;
|
||||
$widget_padding_left = $args->widget_padding_left;
|
||||
$widget_padding_right = $args->widget_padding_right;
|
||||
$widget_padding_top = $args->widget_padding_top;
|
||||
$widget_padding_bottom = $args->widget_padding_bottom;
|
||||
if($include_info) {
|
||||
$tpl = sprintf('<div class="widgetOutput" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s"><div class="widgetBoxCopy"></div><div class="widgetBoxSize"></div><div class="widgetBoxRemove"></div><div class="widgetBoxResize"></div><div class="widgetBoxResizeLeft"></div><div class="widgetBoxBorder"><div class="nullWidget" style="padding:%s %s %s %s;">', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left);
|
||||
} else {
|
||||
$tpl = sprintf('<div style="overflow:hidden;%s;"><div style="padding:%s %s %s %s;"><div>%s', $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $body);
|
||||
}
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
// 설치된 위젯들에 대한 처리
|
||||
if(!is_dir(sprintf('./widgets/%s/',$widget))) return;
|
||||
|
||||
$cache_path = './files/cache/widget_cache/';
|
||||
if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
|
||||
|
||||
// $widget의 객체를 받음
|
||||
$oWidget = WidgetHandler::getObject($widget);
|
||||
if(!$oWidget) return;
|
||||
|
||||
// 위젯 output을 생성하기 위한 변수 설정
|
||||
$widget_padding_top = $args->widget_padding_top;
|
||||
$widget_padding_bottom = $args->widget_padding_bottom;
|
||||
$widget_padding_left = $args->widget_padding_left;
|
||||
$widget_padding_right = $args->widget_padding_right;
|
||||
|
||||
$inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important; padding:none !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left);
|
||||
|
||||
/**
|
||||
* 출력을 위해 위젯 내용을 div로 꾸밈
|
||||
* 위젯이 widgetContent/ widgetBox가 아니라면 내용을 구함
|
||||
**/
|
||||
// 서비스에 사용하기 위해 위젯 정보를 포함하지 않을 경우
|
||||
if(!$include_info) {
|
||||
if($widget != 'widgetContent' && $widget != 'widgetBox') {
|
||||
if(!is_dir(sprintf('./widgets/%s/',$widget))) return;
|
||||
|
||||
// 위젯 실행
|
||||
$html = $oWidget->proc($args);
|
||||
$output = sprintf('<div style="overflow:hidden;%s;"><div style="%s">%s</div></div>', $args->style, $inner_style, $html);
|
||||
// 위젯의 내용을 담을 변수
|
||||
$widget_content = '';
|
||||
|
||||
// 위젯 sequence가 있고 위젯의 캐싱을 지정하였고 위젯정보를 담지 않도록 하였을 경우 캐시 파일을 저장
|
||||
if($args->widget_sequence && $args->widget_cache) WidgetHandler::writeCache($args->widget_sequence, $output);
|
||||
// 캐시된 코드가 있는지 확인
|
||||
$widget_sequence = $args->widget_sequence;
|
||||
$widget_cache = $args->widget_cache;
|
||||
if($widget_cache && $widget_sequence) $widget_content = WidgetHandler::getCache($widget_sequence, $widget_cache);
|
||||
|
||||
// 에디팅등에 사용하기 위한 목적으로 위젯 정보를 포함할 경우
|
||||
} else {
|
||||
// 위젯 실행
|
||||
//if($args->widget_sequence && $args->widget_cache) $html = WidgetHandler::getCache($args->widget_sequence, $args->widget_cache);
|
||||
//if(!$html) $html = $oWidget->proc($args);
|
||||
$html = $oWidget->proc($args);
|
||||
// 캐시된 코드가 없을 경우 코드 생성
|
||||
if(!$widget_content) {
|
||||
$oWidget = WidgetHandler::getObject($widget);
|
||||
if(!$oWidget) return;
|
||||
|
||||
// args 정리
|
||||
$attribute = array();
|
||||
if($args) {
|
||||
foreach($args as $key => $val) {
|
||||
if($key == 'class' || $key == 'style') continue;
|
||||
if(strpos($val,'|@|')>0) {
|
||||
$val = str_replace('|@|',',',$val);
|
||||
}
|
||||
$attribute[] = sprintf('%s="%s"', $key, str_replace('"','\"',$val));
|
||||
$widget_content = $oWidget->proc($args);
|
||||
|
||||
if(!is_string($widget_content)) {
|
||||
if(is_object($widget_content) && (is_a($widget_content, 'Object')||is_subclass_of($widget_content, 'Object'))) {
|
||||
$widget_content = $widget_content->getMessage();
|
||||
} else $widget_content = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 결과물에 있는 css Meta 목록을 구해와서 해당 css를 아예 읽어버림
|
||||
require_once("./classes/optimizer/Optimizer.class.php");
|
||||
$oOptimizer = new Optimizer();
|
||||
preg_match_all('!<\!\-\-Meta:([^\-]*?)\-\->!is', $html, $matches);
|
||||
$css_header = null;
|
||||
for($i=0;$i<count($matches[1]);$i++) {
|
||||
$css_file = $matches[1][$i];
|
||||
$buff = FileHandler::readFile($css_file);
|
||||
$css_header .= $oOptimizer->replaceCssPath($css_file, $buff)."\n";
|
||||
// 위젯의 캐시값과 위젯 sequence가 있을 경우 캐시 파일에 저장
|
||||
if($widget_cache && $widget_sequence) WidgetHandler::writeCache($widget_sequence, $widget_content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자가 지정한 위젯의 style을 구함
|
||||
**/
|
||||
// 가끔 잘못된 코드인 background-image:url(none)이 들어 있을 수가 있는데 이럴 경우 none에 대한 url을 요청하므로 무조건 제거함
|
||||
$style = preg_replace('/background\-image: url\(none\)/is','', $args->style);
|
||||
|
||||
// 내부 여백을 둔 것을 구해서 style문으로 미리 변경해 놓음
|
||||
$widget_padding_left = $args->widget_padding_left;
|
||||
$widget_padding_right = $args->widget_padding_right;
|
||||
$widget_padding_top = $args->widget_padding_top;
|
||||
$widget_padding_bottom = $args->widget_padding_bottom;
|
||||
$inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important; padding:none !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left);
|
||||
|
||||
/**
|
||||
* 위젯 출력물을 구함
|
||||
**/
|
||||
// 일반 페이지 호출일 경우 지정된 스타일만 꾸면서 바로 return 함
|
||||
if(!$include_info) {
|
||||
switch($widget) {
|
||||
// 내용 직접 추가일 경우
|
||||
case 'widgetContent' :
|
||||
$body = base64_decode($args->body);
|
||||
$output = sprintf('<div style="overflow:hidden;%s"><div style="%s">%s</div></div>', $style, $inner_style, $body);
|
||||
break;
|
||||
|
||||
// 위젯 박스일 경우
|
||||
case 'widgetBox' :
|
||||
$output = sprintf('<div style="overflow:hidden;%s;"><div style="%s"><div>', $style, $inner_style);
|
||||
break;
|
||||
|
||||
// 일반 위젯일 경우
|
||||
default :
|
||||
$output = sprintf('<div style="overflow:hidden;%s;"><div style="%s">%s</div></div>', $style, $inner_style, $widget_content);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!$html) $html = ' ';
|
||||
$output = sprintf(
|
||||
'<div class="widgetClass"><style type="text/css">%s</style></div>'.
|
||||
'<div class="widgetOutput" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'.
|
||||
'<div class="widgetSetup"></div>'.
|
||||
'<div class="widgetCopy"></div>'.
|
||||
'<div class="widgetSize"></div>'.
|
||||
'<div class="widgetRemove"></div>'.
|
||||
'<div class="widgetResize"></div>'.
|
||||
'<div class="widgetResizeLeft"></div>'.
|
||||
'<div class="widgetBorder">'.
|
||||
'<div style="%s">'.
|
||||
'%s'.
|
||||
'</div><div class="clear"></div>'.
|
||||
'</div>'.
|
||||
'</div>',
|
||||
$css_header,
|
||||
$args->style,
|
||||
$widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,
|
||||
$widget, implode(' ',$attribute),
|
||||
$inner_style,
|
||||
$html
|
||||
);
|
||||
// 페이지 수정시에 호출되었을 경우 위젯 핸들링을 위한 코드 추가
|
||||
} else {
|
||||
switch($widget) {
|
||||
// 내용 직접 추가일 경우
|
||||
case 'widgetContent' :
|
||||
$body = base64_decode($args->body);
|
||||
$oWidgetController = &getController('widget');
|
||||
|
||||
$output = sprintf(
|
||||
'<div class="widgetOutput" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent">'.
|
||||
'<div class="widgetSetup"></div>'.
|
||||
'<div class="widgetCopy"></div>'.
|
||||
'<div class="widgetSize"></div>'.
|
||||
'<div class="widgetRemove"></div>'.
|
||||
'<div class="widgetResize"></div>'.
|
||||
'<div class="widgetResizeLeft"></div>'.
|
||||
'<div class="widgetBorder">'.
|
||||
'<div style="%s">'.
|
||||
'%s'.
|
||||
'</div><div class="clear"></div>'.
|
||||
'</div>'.
|
||||
'<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'.
|
||||
'</div>',
|
||||
$style,
|
||||
$args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom,
|
||||
$inner_style,
|
||||
$body,
|
||||
base64_encode($body)
|
||||
);
|
||||
break;
|
||||
|
||||
// 위젯 박스일 경우
|
||||
case 'widgetBox' :
|
||||
$output = sprintf(
|
||||
'<div class="widgetOutput" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s">'.
|
||||
'<div class="widgetBoxCopy"></div>'.
|
||||
'<div class="widgetBoxSize"></div>'.
|
||||
'<div class="widgetBoxRemove"></div>'.
|
||||
'<div class="widgetBoxResize"></div>'.
|
||||
'<div class="widgetBoxResizeLeft"></div>'.
|
||||
'<div class="widgetBoxBorder">'.
|
||||
'<div class="nullWidget" style="%s">',
|
||||
$style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, $inner_style);
|
||||
break;
|
||||
|
||||
// 일반 위젯일 경우
|
||||
default :
|
||||
// args 정리
|
||||
$attribute = array();
|
||||
if($args) {
|
||||
foreach($args as $key => $val) {
|
||||
if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget'))) continue;
|
||||
if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
|
||||
$attribute[] = sprintf('%s="%s"', $key, str_replace('"','\"',$val));
|
||||
}
|
||||
}
|
||||
|
||||
$output = sprintf(
|
||||
'<div class="widgetOutput" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'.
|
||||
'<div class="widgetSetup"></div>'.
|
||||
'<div class="widgetCopy"></div>'.
|
||||
'<div class="widgetSize"></div>'.
|
||||
'<div class="widgetRemove"></div>'.
|
||||
'<div class="widgetResize"></div>'.
|
||||
'<div class="widgetResizeLeft"></div>'.
|
||||
'<div class="widgetBorder">'.
|
||||
'<div style="%s">'.
|
||||
'%s'.
|
||||
'</div><div class="clear"></div>'.
|
||||
'</div>'.
|
||||
'</div>',
|
||||
$style,
|
||||
$widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,
|
||||
$widget, implode(' ',$attribute),
|
||||
$inner_style,
|
||||
$widget_content
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 위젯 결과물 생성 시간을 debug 정보에 추가
|
||||
|
|
|
|||
|
|
@ -98,10 +98,11 @@
|
|||
$oFileController->setFilesValid($module_info->module_srl);
|
||||
|
||||
// 캐시파일 재생성
|
||||
$this->procPageAdminRemoveWidgetCache();
|
||||
//$this->procPageAdminRemoveWidgetCache();
|
||||
|
||||
$this->add("module_srl", $module_info->module_srl);
|
||||
$this->add("page", Context::get('page'));
|
||||
$this->add("mid", $module_info->mid);
|
||||
$this->setMessage($msg_code);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,9 @@
|
|||
Context::set('module_info', $this->module_info);
|
||||
|
||||
// 내용을 세팅
|
||||
$content = $this->module_info->content;
|
||||
$content = Context::get('content');
|
||||
if(!$content) $content = $this->module_info->content;
|
||||
Context::set('content', $content);
|
||||
|
||||
// 내용중 위젯들을 변환
|
||||
$oWidgetController = &getController('widget');
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
<response callback_func="completeInsertPageContent">
|
||||
<tag name="error" />
|
||||
<tag name="message" />
|
||||
<tag name="mid" />
|
||||
<tag name="module_srl" />
|
||||
<tag name="page" />
|
||||
</response>
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ function completeInsertPageContent(ret_obj) {
|
|||
|
||||
var page = ret_obj['page'];
|
||||
var module_srl = ret_obj['module_srl'];
|
||||
var mid = ret_obj['mid'];
|
||||
|
||||
location.href = current_url.setQuery('act','');
|
||||
location.href = current_url.setQuery('mid',mid).setQuery('act','');
|
||||
}
|
||||
|
||||
/* 수정한 페이지 컨텐츠를 저장 */
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
<!--%import("filter/insert_page_content.xml")-->
|
||||
<!--%import("js/page_admin.js")-->
|
||||
<!--%import("css/page.css")-->
|
||||
|
||||
<!--%import("../../widget/tpl/js/widget.js")-->
|
||||
<!--%import("../../widget/tpl/css/widget.css")-->
|
||||
<!--#include("../../widget/tpl/widget_layer.html")-->
|
||||
|
||||
<div class="clear"></div>
|
||||
<div id="zonePageContent">{$page_content}</div>
|
||||
<div class="clear"></div>
|
||||
<div class="adminLayer">
|
||||
<form action="./" id="pageFo" onsubmit="return doSubmitPageContent(this);">
|
||||
<form action="./" method="post" id="pageFo" onsubmit="return doSubmitPageContent(this);">
|
||||
<input type="hidden" name="module" value="page" />
|
||||
<input type="hidden" name="act" value="dispPageAdminContentModify" />
|
||||
<input type="hidden" name="module_srl" value="{$module_info->module_srl}" />
|
||||
<input type="hidden" name="content" value="" />
|
||||
<input type="hidden" name="content" value="{htmlspecialchars($content)}" />
|
||||
|
||||
<div class="tCenter">
|
||||
<select name="widget_list">
|
||||
|
|
@ -19,9 +26,10 @@
|
|||
<span class="button"><input type="button" value="{$lang->cmd_content_insert}" onclick="doAddContent('{$module_info->module_srl}'); return false;" /></span>
|
||||
<span class="button"><input type="button" value="{$lang->cmd_box_widget_insert}" onclick="doAddWidgetBox(); return false;" /></span>
|
||||
</div>
|
||||
|
||||
<div class="tRight">
|
||||
<span class="button"><input type="button" value="{$lang->cmd_remove_all_widgets}" onclick="removeAllWidget();return false;"/></span>
|
||||
<span class="button"><input type="button" value="{$lang->cmd_back}" onclick="location.href=current_url.setQuery('act','');return false;"/></span>
|
||||
<span class="button"><input type="button" value="{$lang->cmd_back}" onclick="location.href=current_url.setQuery('mid','{$module_info->mid}').setQuery('act','');return false;"/></span>
|
||||
<span class="button"><input type="submit" value="{$lang->cmd_save}"/></span>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
<!--%import("filter/add_content.xml")-->
|
||||
<!--%import("js/widget.js")-->
|
||||
<!--%import("css/widget.css")-->
|
||||
|
||||
<div class="pageAddContent"></div>
|
||||
<form action="./" method="get" onsubmit="return procFilter(this, add_content);" id="content_fo">
|
||||
<form action="./" method="get" onsubmit="return completeAddContent(this); return false;" id="content_fo">
|
||||
<input type="hidden" name="content" value="" />
|
||||
<input type="hidden" name="mid" value="{$module_info->mid}" />
|
||||
<input type="hidden" name="module_srl" value="{$module_srl}" />
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ function getPadding(obj, direct) {
|
|||
}
|
||||
|
||||
|
||||
/* 위젯 배치 시작을 함 */
|
||||
/* 위젯 핸들링 시작 */
|
||||
var zonePageObj = null;
|
||||
var zoneModuleSrl = 0;
|
||||
function doStartPageModify(zoneID, module_srl) {
|
||||
|
|
@ -155,8 +155,7 @@ function getWidgetCode(childObj, widget) {
|
|||
var value = childObj.attributes[i].nodeValue;
|
||||
if(!value) continue;
|
||||
|
||||
if(value && typeof(value)=="string") value = value.replace(/\"/ig,'"');
|
||||
attrs += name+'="'+value+'" ';
|
||||
attrs += name+'="'+escape(value)+'" ';
|
||||
}
|
||||
var style = childObj.getAttribute("style");
|
||||
return '<img class="zbxe_widget_output" style="'+getStyle(childObj)+'" widget="'+widget+'" '+attrs+' />';
|
||||
|
|
@ -196,11 +195,28 @@ function doSyncPageContent() {
|
|||
}
|
||||
|
||||
// 부모창에 위젯을 추가
|
||||
function completeAddContent(ret_obj) {
|
||||
var tpl = ret_obj["tpl"];
|
||||
function completeAddContent(fo_obj) {
|
||||
var editor_sequence = fo_obj.getAttribute('editor_sequence');
|
||||
var content = editorGetContent(editor_sequence);
|
||||
|
||||
var tpl = ''+
|
||||
'<div class="widgetOutput" style="'+fo_obj.style.value+'" widget_padding_left="'+fo_obj.widget_padding_left.value+'" widget_padding_right="'+fo_obj.widget_padding_right.value+'" widget_padding_top="'+fo_obj.widget_padding_top.value+'" widget_padding_bottom="'+fo_obj.widget_padding_bottom.value+'" widget="widgetContent">'+
|
||||
'<div class="widgetSetup"></div>'+
|
||||
'<div class="widgetCopy"></div>'+
|
||||
'<div class="widgetSize"></div>'+
|
||||
'<div class="widgetRemove"></div>'+
|
||||
'<div class="widgetResize"></div>'+
|
||||
'<div class="widgetResizeLeft"></div>'+
|
||||
'<div class="widgetBorder">'+
|
||||
'<div style="padding:'+fo_obj.widget_padding_top.value+'px '+fo_obj.widget_padding_right.value+'px'+fo_obj.widget_padding_bottom.value+'px'+fo_obj.widget_padding_left.value+'px">'+
|
||||
content+
|
||||
'</div><div class="clear"></div>'+
|
||||
'</div>'+
|
||||
'<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">'+Base64.encode(content)+'</div>'+
|
||||
'</div>';
|
||||
|
||||
opener.doAddWidgetCode(tpl);
|
||||
window.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 박스 위젯 추가 */
|
||||
|
|
@ -259,6 +275,7 @@ function doAddWidgetCode(widget_code) {
|
|||
var nodes = dummy.childNodes;
|
||||
|
||||
var zoneObj = xGetElementById('zonePageContent');
|
||||
zoneObj.style.visibility = 'hidden';
|
||||
|
||||
if(selectedWidget && selectedWidget.getAttribute("widget")) {
|
||||
while ( nodes.length ) {
|
||||
|
|
@ -273,7 +290,13 @@ function doAddWidgetCode(widget_code) {
|
|||
}
|
||||
}
|
||||
|
||||
doFitBorderSize();
|
||||
// 위젯 추가후 페이지 리로딩
|
||||
var tpl = getWidgetContent();
|
||||
|
||||
var fo_obj = xGetElementById('pageFo');
|
||||
fo_obj.content.value = tpl;
|
||||
|
||||
fo_obj.submit();
|
||||
}
|
||||
|
||||
// 클릭 이벤트시 위젯의 수정/제거/이벤트 무효화 처리
|
||||
|
|
|
|||
|
|
@ -102,7 +102,10 @@ function doFillWidgetVars() {
|
|||
case "text" :
|
||||
case "textarea" :
|
||||
var val = selected_node.getAttribute(name);
|
||||
if(val) node.value = val;
|
||||
if(!val) continue;
|
||||
var unescaped_val = unescape(val);
|
||||
if(!unescaped_val) node.value = val;
|
||||
else node.value = unescaped_val;
|
||||
break;
|
||||
case "checkbox" :
|
||||
if(selected_node.getAttribute(name)) {
|
||||
|
|
|
|||
|
|
@ -130,34 +130,12 @@
|
|||
$this->add('colorset_list', $colorsets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 직접 내용 입력된 위젯의 처리
|
||||
**/
|
||||
function procWidgetAddContent() {
|
||||
$content = Context::get('content');
|
||||
$args = Context::getRequestVars('style','widget_padding_left','widget_padding_right','widget_padding_bottom','widget_padding_top');
|
||||
|
||||
$tpl = $this->transEditorContent($content, $args);
|
||||
|
||||
$this->add('tpl', $tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @breif 특정 content의 위젯 태그들을 변환하여 return
|
||||
**/
|
||||
function transWidgetCode($content, $include_info = false) {
|
||||
$this->include_info = $include_info;
|
||||
|
||||
// 내용중 widget이 아닌 것들을 일단 분리
|
||||
/*
|
||||
$none_widget_code = preg_replace('!<img([^\>]*)widget=([^\>]*?)\>!is', '', $content);
|
||||
$oPageAdminController = &getAdminController('page');
|
||||
if(trim($none_widget_code)) {
|
||||
$args->style = "float:left;overflow:hidden;padding:none;padding:none";
|
||||
$args->widget_padding_left = $args->widget_padding_top = $args->widget_padding_right = $args->widget_padding_bottom = 0;
|
||||
$none_widget_content = $oPageAdminController->transEditorContent($none_widget_code, $args);
|
||||
}
|
||||
*/
|
||||
$this->include_info = $include_info;
|
||||
|
||||
// 내용중 위젯을 또다시 구함 (기존 버전에서 페이지 수정해 놓은것과의 호환을 위해서)
|
||||
$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content);
|
||||
|
|
@ -165,17 +143,6 @@
|
|||
// 박스 위젯을 다시 구함
|
||||
$content = preg_replace_callback('!<div([^\>]*)widget=([^\>]*?)\><div><div>!is', array($this,'transWidgetBox'), $content);
|
||||
|
||||
// include_info, 즉 위젯의 수정일 경우 css와 js파일을 추가해 주고 위젯 수정용 레이어도 추가함
|
||||
if($this->include_info) {
|
||||
Context::addJsFile("./modules/widget/tpl/js/widget.js");
|
||||
Context::addCSSFile("./modules/widget/tpl/css/widget.css");
|
||||
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
$tpl = $oTemplate->compile($this->module_path.'tpl', 'widget_layer');
|
||||
$content .= $tpl;
|
||||
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
|
@ -183,10 +150,7 @@
|
|||
* @brief 위젯 코드를 실제 php코드로 변경
|
||||
**/
|
||||
function transWidget($matches) {
|
||||
$oContext = &Context::getInstance();
|
||||
$buff = trim($matches[0]);
|
||||
$buff = preg_replace_callback('/([^=^"^ ]*)=([^ ^>]*)/i', array($oContext, _fixQuotation), $buff);
|
||||
$buff = str_replace("&","&",$buff);
|
||||
|
||||
$oXmlParser = new XmlParser();
|
||||
$xml_doc = $oXmlParser->parse(trim($buff));
|
||||
|
|
@ -196,14 +160,6 @@
|
|||
|
||||
if(!$vars->widget) return "";
|
||||
|
||||
// 캐시 체크
|
||||
$widget_sequence = $vars->widget_sequence;
|
||||
$widget_cache = $vars->widget_cache;
|
||||
if($widget_cache && $widget_sequence && !$this->include_info) {
|
||||
$output = WidgetHandler::getCache($widget_sequence, $widget_cache);
|
||||
if($output) return $output;
|
||||
}
|
||||
|
||||
// 위젯의 이름을 구함
|
||||
$widget = $vars->widget;
|
||||
unset($vars->widget);
|
||||
|
|
@ -229,54 +185,5 @@
|
|||
return WidgetHandler::execute($widget, $vars, $this->include_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터에서 생성한 컨텐츠를 페이지 수정시 사용할 수 있도록 코드 생성
|
||||
**/
|
||||
function transEditorContent($content, $args = null) {
|
||||
// 에디터의 내용을 변환하여 visual한 영역과 원본 소스를 가지고 있는 code로 분리
|
||||
$code = $content;
|
||||
|
||||
$oContext = &Context::getInstance();
|
||||
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($oContext,'transEditorComponent'), $content);
|
||||
$content = preg_replace_callback('!<img([^\>]*)editor_component=([^\>]*?)\>!is', array($oContext,'transEditorComponent'), $content);
|
||||
|
||||
// 결과물에 있는 css Meta 목록을 구해와서 해당 css를 아예 읽어버림
|
||||
require_once("./classes/optimizer/Optimizer.class.php");
|
||||
$oOptimizer = new Optimizer();
|
||||
preg_match_all('!<\!\-\-Meta:([^\-]*?)\-\->!is', $content, $matches);
|
||||
$css_header = null;
|
||||
for($i=0;$i<count($matches[1]);$i++) {
|
||||
$css_file = $matches[1][$i];
|
||||
$buff = FileHandler::readFile($css_file);
|
||||
$css_header .= $oOptimizer->replaceCssPath($css_file, $buff)."\n";
|
||||
}
|
||||
|
||||
$tpl = sprintf(
|
||||
'<style type="text/css">%s</style>'.
|
||||
'<div class="widgetOutput" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent">'.
|
||||
'<div class="widgetSetup"></div>'.
|
||||
'<div class="widgetCopy"></div>'.
|
||||
'<div class="widgetSize"></div>'.
|
||||
'<div class="widgetRemove"></div>'.
|
||||
'<div class="widgetResize"></div>'.
|
||||
'<div class="widgetResizeLeft"></div>'.
|
||||
'<div class="widgetBorder">'.
|
||||
'<div style="padding:%s %s %s %s;">'.
|
||||
'%s'.
|
||||
'</div><div class="clear"></div>'.
|
||||
'</div>'.
|
||||
'<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'.
|
||||
'</div>',
|
||||
$css_header,
|
||||
$args->style,
|
||||
$args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom,
|
||||
$args->widget_padding_top, $args->widget_padding_right, $args->widget_padding_bottom, $args->widget_padding_left,
|
||||
$content,
|
||||
base64_encode($code)
|
||||
);
|
||||
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue