페이지 모듈의 컨텐츠 꾸미는 부분을 위지윅으로 변경

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2957 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-11-12 12:04:01 +00:00
parent 2b1d64f477
commit 7de5dc3a0b
30 changed files with 974 additions and 229 deletions

View file

@ -836,23 +836,23 @@
**/
function transContent($content) {
// 위젯 코드 변경
$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'_transWidget'), $content);
$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content);
// 메타 파일 변경
$content = preg_replace_callback('!<\!\-\-Meta:([^\-]*?)\-\->!is', array($this,'_transMeta'), $content);
$content = preg_replace_callback('!<\!\-\-Meta:([^\-]*?)\-\->!is', array($this,'transMeta'), $content);
// 에디터 컴포넌트를 찾아서 결과 코드로 변환
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'_transEditorComponent'), $content);
$content = preg_replace_callback('!<img([^\>]*)editor_component=([^\>]*?)\>!is', array($this,'_transEditorComponent'), $content);
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'transEditorComponent'), $content);
$content = preg_replace_callback('!<img([^\>]*)editor_component=([^\>]*?)\>!is', array($this,'transEditorComponent'), $content);
// body 내의 <style ..></style>를 header로 이동
$content = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'_moveStyleToHeader'), $content);
$content = preg_replace_callback('!<style(.*?)<\/style>!is', array($this,'moveStyleToHeader'), $content);
// <br> 코드 변환
$content = preg_replace('/<br([^>\/]*)(\/>|>)/i','<br$1 />', $content);
// 몇가지 대문자 태그를 소문자로 변경
//$content = preg_replace_callback('!<(\/){0,1}([A-Z]+)([^>]*?)>!s',array($this,'_transTagToLowerCase'), $content);
//$content = preg_replace_callback('!<(\/){0,1}([A-Z]+)([^>]*?)>!s',array($this,'transTagToLowerCase'), $content);
// <img ...> 코드를 <img ... /> 코드로 변환
$content = preg_replace('/<img(.*?)(\/){0,1}>/i','<img$1 />', $content);
@ -866,14 +866,14 @@
/**
* @brief IE위지윅에디터에서 태그가 대문자로 사용되기에 이를 소문자로 치환
**/
function _transTagToLowerCase($matches) {
function transTagToLowerCase($matches) {
return sprintf('<%s%s%s>', $matches[1], strtolower($matches[2]), $matches[3]);
}
/**
* @brief <!--Meta:파일이름.(css|js)--> 변경
**/
function _transMeta($matches) {
function transMeta($matches) {
if(eregi('\.css$', $matches[1])) $this->addCSSFile($matches[1]);
elseif(eregi('\.js$', $matches[1])) $this->addJSFile($matches[1]);
}
@ -881,7 +881,7 @@
/**
* @brief <body>내의 <style태그를 header로 이동
**/
function _moveStyleToHeader($matches) {
function moveStyleToHeader($matches) {
$this->addHtmlHeader($matches[0]);
return '';
}
@ -896,7 +896,7 @@
return sprintf('%s=%s', $key, $val);
}
function _transEditorComponent($matches) {
function transEditorComponent($matches) {
// IE에서는 태그의 특성중에서 " 를 빼어 버리는 경우가 있기에 정규표현식으로 추가해줌
$buff = $matches[0];
$buff = preg_replace_callback('/([^=^"^ ]*)=([^ ^>]*)/i', array($this, _fixQuotation), $buff);
@ -924,7 +924,7 @@
/**
* @brief 위젯 코드를 실제 php코드로 변경
**/
function _transWidget($matches) {
function transWidget($matches, $include_info = false) {
// IE에서는 태그의 특성중에서 " 를 빼어 버리는 경우가 있기에 정규표현식으로 추가해줌
$buff = $matches[0];
$buff = preg_replace_callback('/([^=^"^ ]*)=([^ ^>]*)/i', array($this, _fixQuotation), $buff);
@ -941,7 +941,7 @@
// 캐시 체크
$widget_sequence = $vars->widget_sequence;
$widget_cache = $vars->widget_cache;
if($widget_cache && $widget_sequence) {
if($widget_cache && $widget_sequence && !$include_info) {
$output = WidgetHandler::getCache($widget_sequence, $widget_cache);
if($output) return $output;
}
@ -950,7 +950,7 @@
$widget = $vars->widget;
unset($vars->widget);
return WidgetHandler::execute($widget, $vars);
return WidgetHandler::execute($widget, $vars, $include_info);
}
/**

View file

@ -31,75 +31,131 @@
return $output;
}
/**
* @brief 캐시 파일 생성
**/
function writeCache($widget_sequence, $output) {
$cache_path = './files/cache/widget_cache/';
$cache_file = sprintf('%s%d.%s.cache', $cache_path, $widget_sequence, Context::getLangType());
FileHandler::writeFile($cache_file, $output);
}
/**
* @brief 위젯을 찾아서 실행하고 결과를 출력
* <div widget='위젯'...></div> 태그 사용 templateHandler에서 WidgetHandler::execute() 실행하는 코드로 대체하게 된다
*
* $include_info가 true일 경우 css 코드와 위젯핸들링을 위한 코드까지 포함하도록 한다
**/
function execute($widget, $args) {
function execute($widget, $args, $include_info = false) {
// 디버그를 위한 위젯 실행 시간 저장
if(__DEBUG__==3) $start = getMicroTime();
// widget중 widgetContent 는 page 모듈에 종속적인 위젯으로 직접 page.admin.controller.php를 호출하여 처리를 해야 함 (차후 정리 필요)
if($widget == 'widgetContent') {
$style = $args->style;
$body = base64_decode($args->body);
if($include_info) {
$oPageAdminController = &getAdminController('page');
return $oPageAdminController->transEditorContent($body, $style);
} else {
return sprintf('<div style="%s">%s</div>', $style, $body);
}
}
if(!is_dir(sprintf('./widgets/%s/',$widget))) return;
$cache_path = './files/cache/widget_cache/';
if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
$cache_path = './files/cache/widget_cache/';
if(!is_dir($cache_path)) FileHandler::makeDir($cache_path);
// $widget의 객체를 받음
$oWidget = WidgetHandler::getObject($widget);
if(!$oWidget) return;
// 위젯 실행
if($oWidget) {
$output = $oWidget->proc($args);
$html = $oWidget->proc($args);
// 위젯 output을 생성하기 위한 변수 설정
$fix_width = $args->widget_fix_width=='Y'?'Y':'N';
$width_type = strtolower($args->widget_width_type)=='%'?'%':'px';
$widget_width = (int)$args->widget_width;
$margin_top = (int)$args->widget_margin_top;
$margin_bottom = (int)$args->widget_margin_bottom;
$margin_left = (int)$args->widget_margin_left;
$margin_right = (int)$args->widget_margin_right;
$widget_position = $args->widget_position;
preg_match("/height:([^;]*);/i",$args->style, $height_match);
if($height_match[0]) $height = $height_match[0];
$style = "overflow:hidden;padding:none !important; margin:none !important;float:left;".$height;
$inner_style = sprintf("margin:%dpx %dpx %dpx %dpx !important; padding:none !important;", $margin_top, $margin_right, $margin_bottom, $margin_left);
/**
* 출력을 위해 위젯 내용을 div로 꾸밈
**/
// 위젯의 크기가 고정일 경우
if($widget_width) {
$style .= sprintf('%s:%s%s;', 'width', $widget_width, $width_type);
}
if($args->widget_fix_width == 'Y') {
$widget_width_type = strtolower($args->widget_width_type);
if(!$widget_width_type||!in_array($widget_width_type,array("px","%"))) $widget_width_type = "px";
// 서비스에 사용하기 위해 위젯 정보를 포함하지 않을 경우
if(!$include_info) {
if(!$widget_position) $output = sprintf('<div class="clear"></div><div style="%s;float:left;"><div style="%s">%s</div></div>', $style, $inner_style, $html);
else $output = sprintf('<div style="%s;"><div style="%s">%s</div></div>', $style, $inner_style, $html);
// 위젯 sequence가 있고 위젯의 캐싱을 지정하였고 위젯정보를 담지 않도록 하였을 경우 캐시 파일을 저장
if($args->widget_sequence && $args->widget_cache) WidgetHandler::writeCache($args->widget_sequence, $output);
if($widget_width_type == "px") {
$style = "overflow:hidden;";
$style .= sprintf("%s:%s%s;", "width", $args->widget_width - $args->widget_margin_right - $args->widget_margin_left, $widget_width_type);
$style .= sprintf("margin-top:%dpx;margin-bottom:%dpx;", $args->widget_margin_top, $args->widget_margin_bottom);
$inner_style = sprintf("margin-left:%dpx;margin-right:%dpx;", $args->widget_margin_left, $args->widget_margin_right);
if($args->widget_position) {
$style .= sprintf("%s:%s;", "float", $args->widget_position);
$output = sprintf('<div style="%s"><div style="%s">%s</div></div>',$style, $inner_style, $output);
} else {
$style .= "float:left;";
$output = sprintf('<div class="clear"></div><div style="%s"><div style="%s">%s</div></div>',$style, $inner_style, $output);
}
} else {
$style = sprintf("padding:0;overflow:hidden;%s:%s%s;", "width", $args->widget_width, $widget_width_type);
$output = sprintf('<div style="margin:%dpx %dpx %dpx %dpx;">%s</div>', $args->widget_margin_top, $args->widget_margin_right,$args->widget_margin_bottom,$args->widget_margin_left, $output);
if($args->widget_position) {
$style .= sprintf("%s:%s;", "float", $args->widget_position);
$output = sprintf('<div style="%s">%s</div>',$style, $output);
} else {
$style .= "float:left;";
$output = sprintf('<div class="clear"></div><div style="%s">%s</div>',$style, $output);
// 에디팅등에 사용하기 위한 목적으로 위젯 정보를 포함할 경우
} else {
// 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));
}
}
} else {
$output = sprintf('<div style="margin:%dpx %dpx %dpx %dpx;padding:0;clear:both;">%s</div>', $args->widget_margin_top, $args->widget_margin_right,$args->widget_margin_bottom,$args->widget_margin_left, $output);
// 결과물에 있는 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";
}
if(!$html) $html = '&nbsp;';
$output = sprintf(
'<div class="widgetOutput" style="%s" widget="%s" %s />'.
'<style type="text/css">%s</style>'.
'<div class="widgetSetup"></div>'.
'<div class="widgetRemove"></div>'.
'<div class="widgetResize"></div>'.
'<div class="widgetBorder">'.
'<div style="%s">'.
'%s'.
'</div><div class="clear"></div>'.
'</div>'.
'</div>',
$style, $widget, implode(' ',$attribute),
$css_header,
$inner_style,
$html
);
}
// 위젯 결과물 생성 시간을 debug 정보에 추가
if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start;
if($args->widget_sequence && $args->widget_cache) {
$cache_path = './files/cache/widget_cache/';
$cache_file = sprintf('%s%d.%s.cache', $cache_path, $args->widget_sequence, Context::getLangType());
FileHandler::writeFile($cache_file, $output);
}
// 결과 return
return $output;
}

View file

@ -49,6 +49,33 @@ String.prototype.setQuery = function(key, val) {
}
}
/**
* @breif replace outerHTML
**/
function replaceOuterHTML(obj, html) {
if(obj.outerHTML) {
obj.outerHTML = html;
} else {
var dummy = xCreateElement("div");
xInnerHtml(dummy, html);
var parent = obj.parentNode;
while(dummy.firstChild) {
parent.insertBefore(dummy.firstChild, obj);
}
parent.removeChild(obj);
}
}
/**
* @breif get outerHTML
**/
function getOuterHTML(obj) {
if(obj.outerHTML) return obj.outerHTML;
var dummy = xCreateElement("div");
dummy.insertBefore(obj, dummy.lastChild);
return xInnerHtml(dummy);
}
/**
* @brief xSleep(micro time)
**/
@ -106,7 +133,7 @@ function winopen(url, target, attribute) {
**/
function popopen(url, target) {
if(typeof(target)=="undefined") target = "_blank";
winopen(url, target, "left=10,top=10,width=10,height=10,scrollbars=no,resizable=no,toolbars=no");
winopen(url, target, "left=10,top=10,width=10,height=10,scrollbars=no,resizable=yes,toolbars=no");
}
/**
@ -740,3 +767,73 @@ function doAddDocumentCart(obj) {
exec_xml("document","procDocumentAdminAddCart", params, null);
}
/**
* base64 encoding/decoding
**/
// This code was written by Tyler Akins and has been placed in the
// public domain. It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) +
keyStr.charAt(enc3) + keyStr.charAt(enc4);
} while (i < input.length);
return output;
}
function decode64(input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
do {
enc1 = keyStr.indexOf(input.charAt(i++));
enc2 = keyStr.indexOf(input.charAt(i++));
enc3 = keyStr.indexOf(input.charAt(i++));
enc4 = keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
} while (i < input.length);
return output;
}

View file

@ -54,10 +54,10 @@ body { background:#FFFFFF url(../images/default/bgBody.gif) repeat-x left top; }
/* Site Layout - Column Left */
#columnLeft { position:relative; width:201px; float:left;}
#columnLeft .mask { width:201px; height:5px; background:#ffffff; display:block;}
#columnLeft .mask { width:201px; height:5px; background:#ffffff; display:block; clear:both;}
#lnb { border-top:1px solid #dddddd; padding:4px 5px; width:190px;}
#lnb li { padding-bottom:4px;}
#lnb li { padding-bottom:4px; list-style:none; }
#lnb li a { padding:6px 5px 6px 13px; width:170px; display:block; border:1px solid #e8e8e8; background:url(../images/default/bgLnbOff.gif) repeat-x; color:#3e3e3e; position:relative; z-index:99; text-decoration:none;}
#lnb li a:hover,
#lnb li a:focus { color:#ffffff; background:#de4332; border:1px solid #de4332;}

View file

@ -457,7 +457,7 @@
$buff = null;
foreach($buffs as $key => $val) {
$buff .= sprintf('<img src="%s%s.gif" alt="%s" title="%s" align="absmiddle"/>', $path, $val, $val, $val);
$buff .= sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="vertical-align:middle;"/>', $path, $val, $val, $val);
}
return $buff;
}

View file

@ -131,6 +131,7 @@
// 내용을 sync 맞추기 위한 content column name을 세팅한다
Context::set('editor_content_key_name', $option->content_key_name);
/**
* 에디터 컴포넌트 체크
@ -154,6 +155,9 @@
**/
Context::set('editor_height', $editor_height);
// 에디터의 초기화를 수동으로하는 것에 대한 값 체크
Context::set('editor_manual_start', $option->manual_start);
/**
* 템플릿을 미리 컴파일해서 컴파일된 소스를 하기 위해 스킨의 경로를 설정
**/

View file

@ -8,7 +8,10 @@
<script type="text/javascript">//<![CDATA[
var editor_path = "{$editor_path}";
var auto_saved_msg = "{$lang->msg_auto_saved}";
<!--@if(!$editor_manual_start)-->
xAddEventListener(window, 'load', function() { editorStart("{$editor_sequence}", "{$editor_primary_key_name}", "{$editor_content_key_name}", {$enable_resizable}, '{$editor_height}' ) } );
<!--@end-->
//]]></script>
<!-- 자동저장용 폼 -->
@ -146,17 +149,17 @@
<script type="text/javascript">//<![CDATA[
var zbxe_session_name = "{session_name()}";
var uploader_setting = { "allowed_filesize" : "{$file_config->allowed_filesize}", "allowed_filetypes" : "{$file_config->allowed_filetypes}", "allowed_filetypes_description" : "{$file_config->allowed_filetypes}" }
<!--@if(!$editor_manual_start)-->
editor_upload_init("{$editor_sequence}");
<!--@end-->
//]]></script>
<div class="fileAttach">
<div class="preview" id="preview_uploaded_{$editor_sequence}">
<img src="./images/blank.gif" alt="preview" width="100" height="100" />
</div>
<div class="preview" id="preview_uploaded_{$editor_sequence}"><img src="./images/blank.gif" alt="preview" width="100" height="100" /></div>
<!-- 파일 업로드 영역 -->
<div class="fileListArea">
<select id="uploaded_file_list_{$editor_sequence}" multiple="multiple" size="8" class="fileList" onclick="editor_preview(this, '{$editor_sequence}');"></select>
<select id="uploaded_file_list_{$editor_sequence}" multiple="multiple" size="5" class="fileList" onclick="editor_preview(this, '{$editor_sequence}');"></select>
<span class="file_attach_info" id="uploader_status_{$editor_sequence}">{$upload_status}</span>
</div>

View file

@ -103,7 +103,7 @@ function editorStart(editor_sequence, primary_key, content_key, resizable, edito
// iframe obj를 찾음
var iframe_obj = editorGetIFrame(editor_sequence);
if(!iframe_obj) return;
xWidth(iframe_obj, xWidth(iframe_obj.parentNode)-30);
iframe_obj.style.width = "100%";
// 현 에디터를 감싸고 있는 form문을 찾음
var fo_obj = editorGetForm(editor_sequence);

View file

@ -1609,11 +1609,11 @@
if(!$image_name && !$image_mark) return $matches[0];
if($image_name->width) {
$text = sprintf('<img src="%s" border="0" alt="id: %s" title="id: %s" width="%s" height="%s" align="absmiddle" style="margin-right:3px" />', Context::getRequestUri().$image_name->file, htmlspecialchars(strip_tags($matches[5])), htmlspecialchars(strip_tags($matches[5])), $image_name->width, $image_name->height);
$text = sprintf('<img src="%s" border="0" alt="id: %s" title="id: %s" width="%s" height="%s" style="vertical-align:middle;margin-right:3px" />', Context::getRequestUri().$image_name->file, htmlspecialchars(strip_tags($matches[5])), htmlspecialchars(strip_tags($matches[5])), $image_name->width, $image_name->height);
}
if($image_mark->width) {
$text = sprintf('<img src="%s" border="0" alt="id: %s" title="id : %s" width="%s" height="%s" align="absmiddle" style="margin-right:3px"/>%s', Context::getRequestUri().$image_mark->file, htmlspecialchars(strip_tags($matches[5])), htmlspecialchars(strip_tags($matches[5])), $image_mark->width, $image_mark->height, $text);
$text = sprintf('<img src="%s" border="0" alt="id: %s" title="id : %s" width="%s" height="%s" style="vertical-align:middle;margin-right:3px"/>%s', Context::getRequestUri().$image_mark->file, htmlspecialchars(strip_tags($matches[5])), htmlspecialchars(strip_tags($matches[5])), $image_mark->width, $image_mark->height, $text);
}
return sprintf('<span class="nowrap member_%d" style="cursor:pointer">%s</span>',$member_srl, $text);

View file

@ -27,10 +27,13 @@
<action name="dispPageAdminInsert" type="view" standalone="true" />
<action name="dispPageAdminDelete" type="view" standalone="true" />
<action name="dispPageAdminContentModify" type="view" standalone="true" />
<action name="dispPageAdminAddContent" type="view" standalone="true" />
<action name="procPageAdminRemoveWidgetCache" type="controller" standalone="true" />
<action name="procPageAdminInsert" type="controller" standalone="true" />
<action name="procPageAdminInsertContent" type="controller" standalone="true" />
<action name="procPageAdminDelete" type="controller" standalone="true" />
<action name="procPageAdminInsertConfig" type="controller" standalone="true" />
<action name="procPageAdminAddContent" type="controller" standalone="true" />
</actions>
</module>

View file

@ -73,6 +73,31 @@
$this->setMessage($msg_code);
}
/**
* @brief 페이지 수정 내용 저장
**/
function procPageAdminInsertContent() {
$module_srl = Context::get('module_srl');
$content = Context::get('content');
if(!$module_srl) return new Object(-1,'msg_invalid_request');
// 페이지의 원 정보를 구해옴
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
$module_info->content = $content;
// module 모듈의 controller 객체 생성
$oModuleController = &getController('module');
// 저장
$output = $oModuleController->updateModule($module_info);
if(!$output->toBool()) return $output;
$this->add("module_srl", $module_info->module_srl);
$this->add("page", Context::get('page'));
$this->setMessage($msg_code);
}
/**
* @brief 페이지 삭제
**/
@ -167,5 +192,60 @@
$this->setMessage('success_updated');
}
/**
* @brief 페이지에 에디터 컨테츠 추가하기 위한 tpl return
**/
function procPageAdminAddContent() {
$content = Context::get('content');
$tpl = $this->transEditorContent($content);
$this->add('tpl', $tpl);
}
/**
* @brief 에디터에서 생성한 컨텐츠를 페이지 수정시 사용할 있도록 코드 생성
**/
function transEditorContent($content, $style = "width:100%;float:left;") {
// 에디터의 내용을 변환하여 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(
'<div class="widgetOutput" style="%s" widget="widgetContent" />'.
'<style type="text/css">%s</style>'.
'<div class="widgetSetup"></div>'.
'<div class="widgetRemove"></div>'.
'<div class="widgetResize"></div>'.
'<div class="widgetBorder">'.
'<div>'.
'%s'.
'</div><div class="clear"></div>'.
'</div>'.
'<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'.
'</div>',
$style,
$css_header,
$content,
$code
);
return $tpl;
}
}
?>

View file

@ -149,30 +149,47 @@
* @brief 페이지 내용 수정
**/
function dispPageAdminContentModify() {
// 모듈 정보를 세팅
Context::set('module_info', $this->module_info);
// GET parameter에서 module_srl을 가져옴
$module_srl = Context::get('module_srl');
// 내용을 세팅
$content = $this->module_info->content;
// module_srl이 있으면 해당 모듈의 정보를 구해서 세팅
if($module_srl) {
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if($module_info->module_srl == $module_srl) Context::set('module_info',$module_info);
else {
unset($module_info);
unset($module_srl);
}
}
// 내용중 widget이 아닌 것들을 일단 분리
$none_widget_code = preg_replace('!<img([^\>]*)widget=([^\>]*?)\>!is', '', $content);
$oPageAdminController = &getAdminController('page');
if(trim($none_widget_code)) $none_widget_content = $oPageAdminController->transEditorContent($none_widget_code);
// module_srl이 없으면 sequence값으로 미리 구해 놓음
if(!$module_srl) $module_srl = getNextSequence();
Context::set('module_srl',$module_srl);
// 내용중 위젯을 또다시 구함 (기존 버전에서 페이지 수정해 놓은것과의 호환을 위해서)
preg_match_all('!<img([^\>]*)widget=([^\>]*?)\>!is', $content, $matches);
$content = '';
for($i=0;$i<count($matches[0]);$i++) $content .= $matches[0][$i];
$content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content);
Context::set('page_content', $none_widget_content.$content);
// 위젯 목록을 세팅
$oWidgetModel = &getModel('widget');
$widget_list = $oWidgetModel->getDownloadedWidgetList();
Context::set('widget_list', $widget_list);
// 템플릿 파일 지정
$this->setTemplateFile('page_content_modify');
}
/**
* @brief 페이지에 에디터 위젯 추가
**/
function dispPageAdminAddContent() {
$this->setLayoutFile("popup_layout");
$module_srl = Context::get('module_srl');
if(!$module_srl) return $this->stop("msg_invalid_request");
$oModuleModel = &getModel('module');
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
Context::set('module_info', $module_info);
// 에디터 모듈의 getEditor를 호출하여 세팅
$oEditorModel = &getModel('editor');
$option->primary_key_name = 'module_srl';
@ -181,23 +198,28 @@
$option->enable_autosave = false;
$option->enable_default_component = true;
$option->enable_component = true;
$option->resizable = true;
$option->height = 600;
$option->resizable = false;
$option->height = 400;
$option->manual_start = true;
$editor = $oEditorModel->getEditor($module_srl, $option);
Context::set('editor', $editor);
// 레이아웃 목록을 구해옴
$oLayoutMode = &getModel('layout');
$layout_list = $oLayoutMode->getLayoutList();
Context::set('layout_list', $layout_list);
// 내용 수정시에는 레이아웃을 보이지 않도록 세팅
Context::set('layout','none');
// 템플릿 파일 지정
$this->setTemplateFile('page_content_modify');
$this->setTemplateFile('page_add_content');
}
function transWidget($matches) {
$oContext = &Context::getInstance();
$tpl = $oContext->transWidget($matches, true);
return $tpl;
}
function transWidgetContent($matches) {
preg_match_all('/style="([^"]*)"/is', $matches[2].' ', $mat);
$style = $mat[1][0];
$oPageAdminController = &getAdminController('page');
return $oPageAdminController->transEditorContent($matches[3], $style);
}
/**
* @brief 페이지 삭제 화면 출력

View file

@ -19,6 +19,7 @@
$oModuleController->insertActionForward('page', 'view', 'dispPageAdminInfo');
$oModuleController->insertActionForward('page', 'view', 'dispPageAdminInsert');
$oModuleController->insertActionForward('page', 'view', 'dispPageAdminDelete');
$oModuleController->insertActionForward('page', 'view', 'dispPageAdminContentModify');
// page 에서 사용할 cache디렉토리 생성
FileHandler::makeDir('./files/cache/page');
@ -30,6 +31,8 @@
* @brief 설치가 이상이 없는지 체크하는 method
**/
function checkUpdate() {
$oModuleModel = &getModel('module');
if(!$oModuleModel->getActionForward('dispPageAdminContentModify')) return true;
return false;
}
@ -37,7 +40,13 @@
* @brief 업데이트 실행
**/
function moduleUpdate() {
return new Object();
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
if(!$oModuleModel->getActionForward('dispPageAdminContentModify'))
$oModuleController->insertActionForward('page', 'view', 'dispPageAdminContentModify');
return new Object(0,'success_updated');
}
/**

View file

@ -1,4 +1,4 @@
{$page_content}
<div>{$page_content}</div>
<!--@if($grant->manager)-->
<!--%import("./js/page_admin.js")-->
@ -7,6 +7,6 @@
<!--@if($grant->is_admin)-->
<a href="{getUrl('act','dispPageAdminInfo','module_srl',$module_info->module_srl)}" class="button"><span>{$lang->cmd_setup}</span></a>
<!--@end-->
<a href="{getUrl('','module','page','act','dispPageAdminContentModify','module_srl',$module_info->module_srl)}" onclick="window.open(this.href,'PageEdit','width=850,height=650,scrollbars=yes,resizable=yes,toolbars=no');return false;" class="button"><span>{$lang->cmd_page_modify}</span></a>
<a href="{getUrl('act','dispPageAdminContentModify')}" class="button"><span>{$lang->cmd_page_modify}</span></a>
</div>
<!--@end-->

View file

@ -4,3 +4,15 @@ h3 { margin:0 10px 0 10px; }
.widget_list a { margin-bottom:10px; }
.editor_box { margin:0 10px 10px 10px; }
.button_box { float:right; overflow:hidden; }
.adminLayer { margin-top:30px; border:1px solid #CCCCCC; padding:10px; overflow:hidden;}
#zonePageContent { overflow:hidden; }
.pageAddContent { width:700px; }
.widgetOutput { float:left; cursor:move; z-index:998; overflow:hidden; position:relative;}
.widgetOutput .widgetBorder { border:1px dotted #17DA29; z-index:999; }
.widgetOutput .widgetSetup { background:#FFFFFF url("../images/widget_setup.gif") no-repeat left top; width:22px; height:22px; position:absolute; top:1px; right:24px; cursor:pointer; z-index:1000;}
.widgetOutput .widgetRemove { background:#FFFFFF url("../images/widget_remove.gif") no-repeat left top; width:22px; height:22px; position:absolute; top:1px; right:1px; cursor:pointer; z-index:1000;}
.widgetOutput .widgetResize { background:transparent url("../images/btn_resize.gif") no-repeat left top; width:12px; height:12px; position:absolute; bottom:1px; right:1px; cursor:pointer; z-index:1000;}

View file

@ -0,0 +1,8 @@
<filter name="add_content" module="page" act="procPageAdminAddContent" confirm_msg_code="confirm_submit">
<form />
<response callback_func="completeAddContent">
<tag name="error" />
<tag name="message" />
<tag name="tpl" />
</response>
</filter>

View file

@ -1,19 +1,11 @@
<filter name="insert_page_content" module="page" act="procPageAdminInsert" confirm_msg_code="confirm_submit">
<filter name="insert_page_content" module="page" act="procPageAdminInsertContent" confirm_msg_code="confirm_submit">
<form>
<node target="mid" required="true" filter="alpha_number" />
<node target="browser_title" required="true" maxlength="250" />
<node target="module_srl" required="true" />
<node target="content" required="true" />
</form>
<parameter>
<param name="page_name" target="mid" />
<param name="module_srl" target="module_srl" />
<param name="module_category_srl" target="module_category_srl" />
<param name="layout_srl" target="layout_srl" />
<param name="content" target="content" />
<param name="browser_title" target="browser_title" />
<param name="is_default" target="is_default" />
<param name="view" target="view" />
<param name="manager" target="manager" />
</parameter>
<response callback_func="completeInsertPageContent">
<tag name="error" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

View file

@ -33,8 +33,6 @@ function completeInsertPageContent(ret_obj) {
var page = ret_obj['page'];
var module_srl = ret_obj['module_srl'];
alert(message);
var url = '';
if(location.href.getQuery('module')=='admin') {
url = current_url.setQuery('module_srl',module_srl).setQuery('act','dispPageAdminInfo');
@ -43,9 +41,52 @@ function completeInsertPageContent(ret_obj) {
url = current_url.setQuery('act','').setQuery('module_srl','');
}
if(opener) opener.location.reload();
location.href = url;
}
window.close();
/* 페이지 컨텐츠 저장 */
function doSubmitPageContent(fo_obj) {
var zoneObj = xGetElementById("zonePageContent");
var html = "";
var childObj = zoneObj.firstChild;
while(childObj) {
if(childObj.nodeName == "DIV" && childObj.getAttribute("widget")) {
var widget = childObj.getAttribute("widget");
if(widget == "widgetContent") {
var style = childObj.getAttribute("style");
if(typeof(style)=="object") style = style["cssText"];
var cobj = childObj.firstChild;
var code = "";
while(cobj && cobj.className != "widgetContent") { cobj = cobj.nextSibling; }
if(cobj && cobj.className == "widgetContent") {
var body = encode64(xInnerHtml(cobj));
code = '<img src="./common/tpl/images/widget_bg.jpg" class="zbxe_widget_output" widget="widgetContent" style="'+style+'" body="'+body+'" />';
}
html += code;
} else {
var attrs = "";
var code = "";
for(var i=0;i<childObj.attributes.length;i++) {
if(!childObj.attributes[i].nodeName || !childObj.attributes[i].nodeValue) continue;
var name = childObj.attributes[i].nodeName.toLowerCase();
var value = childObj.attributes[i].nodeValue.replace(/\"/ig,'&quot;');
if(!value) continue;
if(name=="style" || name=="src" || name=="widget" || name == "body" || name == "class" || name == "height") continue;
attrs += name+'="'+value+'" ';
}
var style = childObj.getAttribute("style");
if(typeof(style)=="object") style = style["cssText"];
code = '<img class="zbxe_widget_output" style="'+style+'" widget="'+widget+'" '+attrs+' />';
html += code;
}
}
childObj = childObj.nextSibling;
}
fo_obj.content.value = html;
return procFilter(fo_obj, insert_page_content);
}
/* 모듈 삭제 후 */
@ -108,3 +149,389 @@ function doUnSelectAll(obj, key) {
if(tobj.name == key) tobj.checked = false;
}
}
/* 빈 공간 추가 */
function doAddEmptyBox() {
var zoneObj = xGetElementById("zonePageContent");
var dummy = '<div class="widgetOutput" style="width:100%;height:50px;" widget="_empty" />'+
'<div class="widgetRemove"></div>'+
'<div class="widgetResize"></div>'+
'<div class="widgetBorder">'+
'<div style="%s">'+
''+
'</div>'+
'</div>'+
'</div>';
xInnerHtml(zoneObj, xInnerHtml(zoneObj)+dummy);
}
/* 컨텐츠 추가 */
function doAddContent(module_srl) {
popopen("./?module=page&act=dispPageAdminAddContent&module_srl="+module_srl, "addContent");
}
function doSyncPageContent() {
if(opener && opener.selectedWidget) {
var obj = opener.selectedWidget.firstChild;
while(obj && obj.className != "widgetContent") obj = obj.nextSibling;
if(obj && obj.className == "widgetContent") {
var content = xInnerHtml(obj);
xGetElementById("content_fo").content.value = content;
}
}
editorStart(1, "module_srl", "content", false, 400 );
editor_upload_start(1);
}
function completeAddContent(ret_obj) {
var tpl = ret_obj["tpl"];
selected_node = opener.selectedWidget;
if(selected_node && selected_node.getAttribute("widget")) {
selected_node = replaceOuterHTML(selected_node, tpl);
} else {
var obj = opener.xGetElementById('zonePageContent');
xInnerHtml(obj, xInnerHtml(obj)+tpl);
}
window.close();
return false;
}
/* 위젯 추가 */
function doAddWidget(fo) {
var sel = fo.widget_list;
var idx = sel.selectedIndex;
var val = sel.options[idx].value;
var module_srl = fo.module_srl.value;
var url = current_url.setQuery('module','widget').setQuery('act','dispWidgetGenerateCodeInPage').setQuery('selected_widget', val).setQuery('module_srl', module_srl);
popopen(url,'GenerateCodeInPage');
}
/* 페이지 수정 시작 */
function doStartPageModify() {
// widgetBorder에 height를 widgetOutput와 맞춰줌
var obj_list = xGetElementsByClassName('widgetBorder', xGetElementById('zonePageContent'));
for(var i=0;i<obj_list.length;i++) {
var obj = obj_list[i];
xHeight(obj, xHeight(obj.parentNode));
}
// 드래그와 리사이즈와 관련된 이벤트 리스너 생성
xAddEventListener(document,"click",doCheckWidget);
xAddEventListener(document,"mousedown",doCheckWidgetDrag);
}
var selectedWidget = null;
// 클릭 이벤트시 위젯의 수정/제거/이벤트 무효화 처리
function doCheckWidget(e) {
var evt = new xEvent(e); if(!evt.target) return;
var obj = evt.target;
selectedWidget = null;
// 위젯 설정
if(obj.className == 'widgetSetup') {
var p_obj = obj.parentNode;
var widget = p_obj.getAttribute("widget");
if(!widget) return;
selectedWidget = p_obj;
if(widget == 'widgetContent') {
popopen("./?module=page&act=dispPageAdminAddContent&module_srl="+xGetElementById("pageFo").module_srl.value, "addContent");
} else {
popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget,'GenerateCodeInPage');
}
return;
// 위젯 제거
} else if(obj.className == 'widgetRemove') {
var p_obj = obj.parentNode;
var widget = p_obj.getAttribute("widget");
p_obj.parentNode.removeChild(p_obj);
return;
}
// 내용 클릭 무효화
var p_obj = obj;
while(p_obj) {
if(p_obj.className == 'widgetOutput') {
evt.cancelBubble = true;
evt.returnValue = false;
xPreventDefault(e);
xStopPropagation(e);
break;
}
p_obj = p_obj.parentNode;
}
}
// 마우스 다운 이벤트 발생시 위젯의 이동을 처리
function doCheckWidgetDrag(e) {
var evt = new xEvent(e); if(!evt.target) return;
var obj = evt.target;
if(obj.className == 'widgetSetup' || obj.className == 'widgetRemove') return;
p_obj = obj;
while(p_obj) {
if(p_obj.className == 'widgetOutput' || p_obj.className == 'widgetResize') {
widgetDragEnable(p_obj, widgetDragStart, widgetDrag, widgetDragEnd);
widgetMouseDown(e);
return;
}
p_obj = p_obj.parentNode;
}
}
/* 위젯 드래그 */
// 드래그 중이라는 상황을 간직할 변수
var widgetDragManager = {obj:null, isDrag:false}
var widgetTmpObject = new Array();
var widgetDisappear = 0;
function widgetCreateTmpObject(obj) {
var id = obj.getAttribute('id');
var tmpObj = widgetTmpObject[id];
if(tmpObj) return tmpObj;
tmpObj = xCreateElement('DIV');
tmpObj.id = id + '_tmp';
tmpObj.className = obj.className;
//tmpObj.setAttribute('widget', obj.getAttribute('widget'));
tmpObj.style.overflow = 'hidden';
tmpObj.style.padding = '0px';
tmpObj.style.margin = '0px';
tmpObj.style.width = obj.style.width;
tmpObj.style.display = 'none';
tmpObj.style.position = 'absolute';
tmpObj.style.opacity = 1;
tmpObj.style.filter = 'alpha(opacity=100)';
xLeft(tmpObj, xPageX(obj));
xTop(tmpObj, xPageY(obj));
document.body.appendChild(tmpObj);
widgetTmpObject[obj.id] = tmpObj;
return tmpObj;
}
// 기생성된 임시 object를 찾아서 return, 없으면 만들어서 return
function widgetGetTmpObject(obj) {
var tmpObj = widgetTmpObject[obj.id];
if(!tmpObj) tmpObj = widgetCreateTmpObject(obj);
return tmpObj;
}
// 메뉴에 마우스 클릭이 일어난 시점에 드래그를 위한 제일 첫 동작 (해당 object에 각종 함수나 상태변수 설정)
var id_step = 0;
function widgetDragEnable(obj, funcDragStart, funcDrag, funcDragEnd) {
var id = obj.getAttribute('id');
if(!id) {
id = 'zLayer_'+id_step;
id_step++;
obj.setAttribute('id', id);
}
// 상위 object에 드래그 가능하다는 상태와 각 드래그 관련 함수를 설정
obj.draggable = true;
obj.dragStart = funcDragStart;
obj.drag = funcDrag;
obj.dragEnd = funcDragEnd;
// 드래그 가능하지 않다면 드래그 가능하도록 상태 지정하고 mousemove이벤트 등록
if (!widgetDragManager.isDrag) {
widgetDragManager.isDrag = true;
xAddEventListener(document, 'mousemove', widgetDragMouseMove, false);
}
}
// 드래그를 시작할때 호출되는 함수 (이동되는 형태를 보여주기 위한 작업을 함)
function widgetDragStart(tobj, px, py) {
if(tobj.className == 'widgetResize') return;
var obj = widgetGetTmpObject(tobj);
xInnerHtml(obj, xInnerHtml(tobj));
tobj.setAttribute('source_color', tobj.style.backgroundColor);
tobj.style.backgroundColor = "#BBBBBB";
xLeft(obj, xPageX(tobj));
xTop(obj, xPageY(tobj));
xWidth(obj, xWidth(tobj));
xHeight(obj, xHeight(tobj));
xDisplay(obj, 'block');
}
// 드래그 시작후 마우스를 이동할때 발생되는 이벤트에 의해 실행되는 함수
function widgetDrag(tobj, dx, dy) {
// 위젯 리사이즈
if(tobj.className == 'widgetResize') {
var sx = xPageX(tobj.parentNode);
var sy = xPageY(tobj.parentNode);
var new_width = tobj.xDPX - sx;
if(new_width < 20) new_width = 20;
var new_height = tobj.xDPY - sy;
if(new_height < 20) new_height = 20;
if(new_width > xWidth('zonePageContent')-2) new_width = xWidth('zonePageContent')-2;
// 위젯의 크기 조절
xWidth(tobj.nextSibling, new_width);
xHeight(tobj.nextSibling, new_height);
xWidth(tobj.parentNode, new_width);
xHeight(tobj.parentNode, new_height);
// 위젯 드래그
} else {
var obj = widgetGetTmpObject(tobj);
var zoneObj = xGetElementById('zonePageContent');
var target_obj = zoneObj.firstChild;
xLeft(obj, parseInt(xPageX(obj),10) + parseInt(dx,10));
xTop(obj, parseInt(xPageY(obj),10) + parseInt(dy,10));
while(target_obj) {
//if(target_obj.nodeName == 'DIV' && target_obj.getAttribute('widget')) {
if(target_obj.parentNode.id == "zonePageContent" && target_obj.getAttribute && target_obj.getAttribute("widget") ) {
var l = xPageX(target_obj);
var t = xPageY(target_obj);
var ll = parseInt(l,10) + parseInt(xWidth(target_obj),10);
var tt = parseInt(t,10) + parseInt(xHeight(target_obj),10);
if( tobj != target_obj && tobj.xDPX >= l && tobj.xDPX <= ll && tobj.xDPY >= t && tobj.xDPY <= tt) {
//target_obj.parentNode.insertBefore(tobj, target_obj.nextSibling);
var next1 = target_obj.nextSibling;
if(!next1) next1 = target_obj.parentNode.lastChild;
var next2 = tobj.nextSibling;
if(!next2) next2 = tobj.parentNode.lastChild;
if(next1) next1.parentNode.insertBefore(tobj, next1);
if(next2) next2.parentNode.insertBefore(target_obj, next2);
}
}
target_obj = target_obj.nextSibling;
}
}
}
// 드래그 종료 (이동되는 object가 이동할 곳에 서서히 이동되는 것처럼 보이는 효과)
function widgetDragEnd(tobj, px, py) {
var obj = widgetGetTmpObject(tobj);
widgetDisapear = widgetDisapearObject(obj, tobj);
widgetDragDisable(tobj.getAttribute('id'));
}
// 스르르 사라지게 함;;
function widgetDisapearObject(obj, tobj) {
var it = 150;
var ib = 15;
var x = parseInt(xPageX(obj),10);
var y = parseInt(xPageY(obj),10);
var ldt = (x - parseInt(xPageX(tobj),10)) / ib;
var tdt = (y - parseInt(xPageY(tobj),10)) / ib;
return setInterval(function() {
if(ib < 1) {
clearInterval(widgetDisapear);
xInnerHtml(tobj,xInnerHtml(obj));
xInnerHtml(obj,'');
xDisplay(obj, 'none');
return;
}
ib -= 5;
x-=ldt;
y-=tdt;
xLeft(obj, x);
xTop(obj, y);
}, it/ib);
}
// 마우스다운 이벤트 발생시 호출됨
function widgetMouseDown(e) {
var evt = new xEvent(e);
var obj = evt.target;
while(obj && !obj.draggable) {
obj = xParent(obj, true);
}
if(obj) {
xPreventDefault(e);
obj.xDPX = evt.pageX;
obj.xDPY = evt.pageY;
widgetDragManager.obj = obj;
xAddEventListener(document, 'mouseup', widgetMouseUp, false);
if (obj.dragStart) obj.dragStart(obj, evt.pageX, evt.pageY);
}
}
// 마우스 버튼을 놓았을때 동작될 함수 (각종 이벤트 해제 및 변수 설정 초기화)
function widgetMouseUp(e) {
if (widgetDragManager.obj) {
xPreventDefault(e);
xRemoveEventListener(document, 'mouseup', widgetMouseUp, false);
if (widgetDragManager.obj.dragEnd) {
var evt = new xEvent(e);
widgetDragManager.obj.dragEnd(widgetDragManager.obj, evt.pageX, evt.pageY);
}
widgetDragManager.obj = null;
widgetDragManager.isDrag = false;
}
}
// 드래그할때의 object이동등을 담당
function widgetDragMouseMove(e) {
var evt = new xEvent(e);
if(widgetDragManager.obj) {
xPreventDefault(e);
var obj = widgetDragManager.obj;
var dx = evt.pageX - obj.xDPX;
var dy = evt.pageY - obj.xDPY;
obj.xDPX = evt.pageX;
obj.xDPY = evt.pageY;
if (obj.drag) {
obj.drag(obj, dx, dy);
} else {
xMoveTo(obj, xLeft(obj) + dx, xTop(obj) + dy);
}
}
}
// 해당 object 에 더 이상 drag가 되지 않도록 설정
function widgetDragDisable(id) {
if (!widgetDragManager) return;
var obj = xGetElementById(id);
obj.draggable = false;
obj.dragStart = null;
obj.drag = null;
obj.dragEnd = null;
obj.style.backgroundColor = obj.getAttribute('source_color');
xRemoveEventListener(obj, 'mousedown', widgetMouseDown, false);
return;
}

View file

@ -0,0 +1,24 @@
<!--%import("filter/add_content.xml")-->
<!--%import("js/page_admin.js")-->
<!--%import("css/page.css")-->
<div class="pageAddContent"></div>
<form action="./" method="get" onsubmit="return procFilter(this, add_content);" 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}" />
<div class="editor">
{$editor}
</div>
<div class="tCenter help">
<span class="button"><input type="submit" value="{$lang->cmd_insert}" class="editor_button" accesskey="s" /></span>
<a href="#" onclick="window.close(); return false;" class="button"><span>{$lang->cmd_close}</span></a>
</div>
</form>
<script type="text/javascript">
xAddEventListener(window, 'load', doSyncPageContent);
</script>

View file

@ -3,52 +3,32 @@
<!--%import("css/page.css")-->
<div class="clear"></div>
<form action="./" method="post" onsubmit="return procFilter(this, insert_page_content)" enctype="multipart/form-data">
<input type="hidden" name="page" value="{$page}" />
<input type="hidden" name="module_srl" value="{$module_srl}" />
<input type="hidden" name="content" value="{htmlspecialchars($module_info->content)}" />
<!--@if($module_info->is_default=='Y')-->
<input type="hidden" name="is_default" value="Y" />
<!--@end-->
<input type="hidden" name="mid" value="{$module_info->mid}" />
<input type="hidden" name="module_category_srl" value="{$module_info->module_category_srl}" />
<input type="hidden" name="browser_title" value="{$module_info->browser_title}" />
<input type="hidden" name="layout_srl" value="{$module_info->layout_srl}" />
<!--@foreach($grant_list as $key => $val)-->
<input type="hidden" name="{$key}" value="<!--@if(is_array($module_info->grants[$key]))-->{implode('|@|',$module_info->grants[$key])}<!--@end-->" />
<!--@end-->
<table cellspacing="0" class="adminTable">
<caption>{$lang->page} {$lang->cmd_management}</caption>
<tr>
<td>
<!--@foreach($widget_list as $widget)-->
<a href="{getUrl('','module','widget','act','dispWidgetGenerateCodeInPage','selected_widget',$widget->widget,'module_srl',$module_srl)}" onclick="popopen(this.href,'GenerateCodeInPage');return false;" class="button"><span>{$widget->title}</span></a>
<!--@end-->
</td>
</tr>
<tr>
<th scope="row" class="button">
<span class="button"><input type="button" value="{$lang->cmd_preview}" onclick="doDocumentPreview(this); return false;" /></span>
<span class="button"><input type="submit" value="{$lang->cmd_save}" accesskey="s" /></span>
<span class="button"><input type="button" value="{$lang->cmd_close}" onclick="window.close(); return false;" /></span>
</th>
</tr>
</table>
{$editor}
<table cellspacing="0" class="adminTable">
<tr>
<th scope="row" class="button">
<span class="button"><input type="button" value="{$lang->cmd_preview}" onclick="doDocumentPreview(this); return false;" /></span>
<span class="button"><input type="submit" value="{$lang->cmd_save}" accesskey="s" /></span>
<span class="button"><input type="button" value="{$lang->cmd_close}" onclick="window.close(); return false;" /></span>
</th>
</tr>
</table>
</form>
<div id="zonePageContent">
{$page_content}
</div>
<div class="clear"></div>
<div class="adminLayer">
<form action="./" id="pageFo" onsubmit="return doSubmitPageContent(this);">
<input type="hidden" name="module_srl" value="{$module_info->module_srl}" />
<input type="hidden" name="content" value="" />
<div class="fl">
<select name="widget_list">
<!--@foreach($widget_list as $widget)-->
<option value="{$widget->widget}">{$widget->title}</option>
<!--@end-->
</select>
<span class="button"><input type="button" value="위젯 추가" onclick="doAddWidget(this.form); return false;"/></span>
<span class="button"><input type="button" value="컨텐츠 추가" onclick="doAddContent('{$module_info->module_srl}'); return false;" /></span>
</div>
<div class="fr">
<span class="button"><input type="button" value="{$lang->cmd_cancel}" onclick="location.href=current_url.setQuery('act','');return false;"/></span>
<span class="button"><input type="submit" value="{$lang->cmd_save}"/></span>
</div>
<div class="clear"></div>
</form>
</div>
<div class="clear"></div>
<script type="text/javascript">
xAddEventListener(window,"load",doStartPageModify);
</script>

View file

@ -359,7 +359,7 @@
$title = sprintf("%s:%s%s %s, %s:%s/%s", Context::getLang('point'), $point, $this->config->point_name, $per?"(".$per."%)":"", Context::getLang('level'), $level, $this->config->max_level);
$text = sprintf('<span class="nowrap member_%s" style="cursor:pointer"><img src="%s" width="%s" height="%s" alt="%s" title="%s" align="absmiddle" style="margin-right:3px"/>%s</span>', $member_srl, Context::getRequestUri().$src, $this->icon_width, $this->icon_height, $title, $title, $text);
$text = sprintf('<span class="nowrap member_%s" style="cursor:pointer"><img src="%s" width="%s" height="%s" alt="%s" title="%s" style="vertical-align:middle;margin-right:3px"/>%s</span>', $member_srl, Context::getRequestUri().$src, $this->icon_width, $this->icon_height, $title, $title, $text);
$this->member_code[$member_srl] = $text;

View file

@ -7,7 +7,7 @@
Total <strong>{number_format($total_count)}</strong>, Page <strong>{number_format($page)}</strong>/{number_format($total_page)}
</div>
<form action="./" method="get" onsubmit="return procFilter(this, delete_checked)">
<form action="./" method="get" onsubmit="return procFilter(this, delete_checked)" id="fo_list">
<input type="hidden" name="page" value="{$page}" />
<!-- 목록 -->

View file

@ -8,6 +8,7 @@
<action name="dispWidgetAdminDownloadedList" type="view" standalone="true" admin_index="true" />
<action name="procWidgetGenerateCode" type="controller" standalone="true" />
<action name="procWidgetGenerateCodeInPage" type="controller" standalone="true" />
<action name="procWidgetGetColorsetList" type="controller" standalone="true" />
</actions>
</module>

View file

@ -1,7 +1,9 @@
<filter name="generate_code_in_page" module="widget" act="procWidgetGenerateCode">
<filter name="generate_code_in_page" module="widget" act="procWidgetGenerateCodeInPage">
<response callback_func="completeGenerateCodeInPage">
<tag name="error" />
<tag name="message" />
<tag name="widget_code" />
<tag name="tpl" />
<tag name="css_header" />
</response>
</filter>

View file

@ -15,20 +15,15 @@ function completeGenerateCode(ret_obj) {
/* 생성된 코드를 에디터에 출력 */
function completeGenerateCodeInPage(ret_obj,response_tags,params,fo_obj) {
var widget_code = ret_obj["widget_code"];
var module_srl = fo_obj.module_srl.value;
if(!opener || !widget_code || !module_srl) {
if(!opener || !widget_code) {
window.close();
return;
}
// 부모창에 에디터가 있으면 에디터에 추가
if(opener.editorGetIFrame) {
var iframe_obj = opener.editorGetIFrame(1);
if(iframe_obj) {
opener.editorFocus(1);
opener.editorReplaceHTML(iframe_obj, widget_code);
opener.editorFocus(1);
}
if(selected_node && selected_node.getAttribute("widget")) {
selected_node = replaceOuterHTML(selected_node, widget_code);
} else {
var obj = opener.xGetElementById('zonePageContent');
xInnerHtml(obj, xInnerHtml(obj)+widget_code);
}
window.close();
}
@ -77,9 +72,9 @@ function completeGetSkinColorset(ret_obj, response_tags, params, fo_obj) {
/* 페이지 모듈에서 내용의 위젯을 더블클릭하여 수정하려고 할 경우 */
var selected_node = null;
function doFillWidgetVars() {
if(!opener || !opener.editorPrevNode || !opener.editorPrevNode.getAttribute("widget")) return;
if(!opener || !opener.selectedWidget || !opener.selectedWidget.getAttribute("widget")) return;
selected_node = opener.editorPrevNode;
selected_node = opener.selectedWidget;
// 스킨과 컬러셋은 기본
var skin = selected_node.getAttribute("skin");
@ -101,7 +96,7 @@ function doFillWidgetVars() {
case "text" :
case "textarea" :
var val = selected_node.getAttribute(name);
node.value = val;
if(val) node.value = val;
break;
case "checkbox" :
if(selected_node.getAttribute(name)) {
@ -144,9 +139,21 @@ function doFillWidgetVars() {
if(selected_node.style.border) border= parseInt(selected_node.style.boarder.replace(/px$/,''),10);
*/
var width_type = "px";
if(selected_node.getAttribute("widget_width_type")=="%") width_type = "%";
else fo_obj.widget_width.value = xWidth(selected_node);
var width = selected_node.style.width;
if(width) {
var width_type = width.replace(/^([0-9]+)/, '');
if(!width_type) width_type = 'px';
var width_value = width.replace(/([%|px]+)/,'');
fo_obj.widget_width.value = width_value;
if(width_type == '%') fo_obj.widget_width_type.selectedIndex = 0;
else fo_obj.widget_width_type.selectedIndex = 1;
} else {
var width_type = "px";
if(selected_node.getAttribute("widget_width_type")=="%") width_type = "%";
else fo_obj.widget_width.value = xWidth(selected_node);
}
// 컬러셋 설정
if(skin && xGetElementById("widget_colorset").options.length<1 && colorset) {

View file

@ -22,6 +22,35 @@
<th scope="row">{$lang->widget}</th>
<td>{$widget_info->title} ver {$widget_info->version}</td>
</tr>
<tr>
<th scope="row">{$lang->widget_width}</th>
<td>
<input type="text" value="50" name="widget_width" size="3" class="inputTypeText" />
<select name="widget_width_type" onchange="checkFixType(this)">
<option value="%">%</option>
<option value="px">px</option>
</select>
<p>{$lang->about_widget_width}</p>
</td>
</tr>
<tr>
<th scope="row">{$lang->widget_margin}</th>
<td>
<table cellspacing="1" class="adminTable">
<tr>
<td colspan="2" class="tCenter">{$lang->widget_margin_top} <input type="text" name="widget_margin_top" value="0" size="2" class="inputTypeText" />px</td>
</tr>
<tr>
<td class="tCenter">{$lang->widget_margin_left} <input type="text" name="widget_margin_left" value="0" size="2" class="inputTypeText"/>px</td>
<td class="tCenter">{$lang->widget_margin_right} <input type="text" name="widget_margin_right" value="0" size="2" class="inputTypeText" />px</td>
</tr>
<tr>
<td colspan="2" class="tCenter">{$lang->widget_margin_bottom} <input type="text" name="widget_margin_bottom" value="0" size="2" class="inputTypeText" />px</td>
</tr>
</table>
<p>{$lang->about_widget_margin}</p>
</td>
</tr>
<!--@if(count($skin_list))-->
<tr>
<th scope="row">{$lang->skin}</th>
@ -84,58 +113,8 @@
</td>
</tr>
<!--@end-->
<tr>
<th scope="row">{$lang->widget_margin}</th>
<td>
<table cellspacing="1" class="adminTable">
<tr>
<td colspan="2" class="tCenter">{$lang->widget_margin_top} <input type="text" name="widget_margin_top" value="0" size="2" class="inputTypeText" />px</td>
</tr>
<tr>
<td class="tCenter">{$lang->widget_margin_left} <input type="text" name="widget_margin_left" value="0" size="2" class="inputTypeText"/>px</td>
<td class="tCenter">{$lang->widget_margin_right} <input type="text" name="widget_margin_right" value="0" size="2" class="inputTypeText" />px</td>
</tr>
<tr>
<td colspan="2" class="tCenter">{$lang->widget_margin_bottom} <input type="text" name="widget_margin_bottom" value="0" size="2" class="inputTypeText" />px</td>
</tr>
</table>
<p>{$lang->about_widget_margin}</p>
</td>
</tr>
</table>
<table cellspacing="0" class="adminTable">
<col width="100" />
<col />
<tr>
<th scope="row">{$lang->widget_fix_width}</th>
<td>
<input type="checkbox" value="Y" name="widget_fix_width" /> {$lang->about_widget_fix_width}
</td>
</tr>
<tr>
<th scope="row">{$lang->widget_width}</th>
<td>
<input type="text" value="50" name="widget_width" size="3" class="inputTypeText" />
<select name="widget_width_type" onchange="checkFixType(this)">
<option value="%">%</option>
<option value="px">px</option>
</select>
<p>{$lang->about_widget_width}</p>
</td>
</tr>
<tr>
<th scope="row">{$lang->widget_position}</th>
<td>
<select name="widget_position">
<option value="">{$lang->widget_position_none}</option>
<option value="left">{$lang->widget_position_left}</option>
<option value="right">{$lang->widget_position_right}</option>
</select>
<p>{$lang->about_widget_position}</p>
</td>
</tr>
</table>
</div>
<div id="popFooter" class="tCenter gap1">
<span class="button"><input type="submit" value="{$lang->cmd_generate_code}" /></span>

View file

@ -66,6 +66,45 @@
$this->add('widget_code', $widget_code);
}
/**
* @brief 페이지 수정시 위젯 코드의 생성 요청
**/
function procWidgetGenerateCodeInPage() {
// 먼저 정상적인 widget 코드를 구함
$this->procWidgetGenerateCode();
$widget_code = $this->get('widget_code');
// 변수 정리
$vars = Context::getRequestVars();
$widget = $vars->selected_widget;
unset($vars->module);
unset($vars->body);
unset($vars->act);
unset($vars->selected_widget);
if(!$vars->widget_sequence) $vars->widget_sequence = getNextSequence();
// args 정리
$attribute = array();
if($vars) {
$vars->widget_position = "left";
$vars->widget_fix_width = "Y";
foreach($vars as $key => $val) {
if($key == 'widget_position') continue;
if(strpos($val,'|@|')>0) {
$val = str_replace('|@|',',',$val);
$vars->{$key} = $val;
}
$attribute[] = sprintf('%s="%s"', $key, str_replace('"','\"',$val));
}
}
// 결과물을 구함
$oWidgetHandler = new WidgetHandler();
$widget_code = $oWidgetHandler->execute($widget, $vars, true);
$this->add('widget_code', $widget_code);
}
/**
* @brief 선택된 위젯 - 스킨의 컬러셋을 return
**/