menu의 버튼이미지를 직접 업로드 가능하도록 하고 menu의 값중 link라는 값을 사용시 등록된 이미지 정보를 그대로 사용할수 있도록 수정. 메뉴들의 재컴파일 필요

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3579 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-01-23 11:58:39 +00:00
parent 8578efa48f
commit bdbeea29df
14 changed files with 258 additions and 25 deletions

View file

@ -15,5 +15,8 @@
<action name="procMenuAdminDeleteItem" type="controller" standalone="true" />
<action name="procMenuAdminMakeXmlFile" type="controller" standalone="true" />
<action name="procMenuAdminMoveItem" type="controller" standalone="true" />
<action name="procMenuAdminUploadButton" type="controller" standalone="true" />
<action name="procMenuAdminDeleteButton" type="controller" standalone="true" />
</actions>
</module>

View file

@ -48,4 +48,6 @@
$lang->about_menu_group_srls = 'If you select a group, only the group members can see the menu. (if xml file is directly opened, it will be shown.)';
$lang->about_menu = "Menu module will help you to create a complete site through the convenient menu management which arranges created modules and links to layouts without any manual works..\nMenu is not a site manager, but it just has information which can link to modules and layouts so you can express different types of menu.";
$lang->alert_image_only = "이미지 파일만 등록가능합니다.";
?>

View file

@ -48,4 +48,6 @@
$lang->about_menu_group_srls = 'Si tu selecciona el grupo, sólo los usuarios del grupo pueden ver el menú. (Si el archivo xml es abierto directamente, lo mostrará.)';
$lang->about_menu = "Módulo del menú te ayudara a crear un sitio completo a través de un conveniente manejo del menú que ordena los módulos creados y conecta con el diseño sin ningún otro trabajo.\nEl menú no es un manejador del sitio, sino que permite conectar los módulos con el diseño y a través del diseño puede expresar variados estilos del menú.";
$lang->alert_image_only = "이미지 파일만 등록가능합니다.";
?>

View file

@ -48,4 +48,6 @@
$lang->about_menu_group_srls = 'グループを選択すると該当するグループのユーザにのみメニューが表示されますXMLファイルを直接開くと情報が表示されます。';
$lang->about_menu = "メニューモジュルは、生成されたモジュールを、便利なメニュー管理機能で、整理したりレイアウトをリンクしたりして煩わしい作業なしでサイトを構築できるようにします。メニューは、サイトを管理するというより、モジュールとレイアウトをリンクして様々なメニューを表示させる情報のみ保持します。";
$lang->alert_image_only = "이미지 파일만 등록가능합니다.";
?>

View file

@ -48,4 +48,6 @@
$lang->about_menu_group_srls = '그룹을 선택하시면 해당 그룹의 사용자만 메뉴가 보이게 됩니다. (xml파일을 직접 열람하면 노출이 됩니다)';
$lang->about_menu = "메뉴모듈은 생성된 모듈을 편리한 메뉴관리기를 통해 정리하고 레이아웃과 연결하여 별도의 수작업 없이 완성된 사이트를 구축하도록 도와줍니다..\n메뉴는 사이트를 관리하기 보다는 모듈과 레이아웃을 연결해 주며 레이아웃을 통해서 여러가지 형태의 메뉴를 표시할 수 있도록 하는 정보만 가지고 있습니다.";
$lang->alert_image_only = "이미지 파일만 등록가능합니다.";
?>

View file

@ -48,4 +48,6 @@
$lang->about_menu_group_srls = 'Если Вы выберите группу, то только ее члены могут видеть это меню. (если XML файл открыт напрямую, оно будет показано.)';
$lang->about_menu = "Модуль меню поможет Вам создать полноценный сайт посредством удобного менеджмента меню, которое расставляет созданные модули и ссылки в лейауты без всякой ручной работы.\nМеню не является менеджером сайта, но оно содержит информацию, которая может связываться с модулями и лейаутами так, что Вы можете выразить различные виды меню.";
$lang->alert_image_only = "이미지 파일만 등록가능합니다.";
?>

View file

@ -48,4 +48,6 @@
$lang->about_menu_group_srls = '如选择用户组,只有所属组用户才能看到此菜单。 —xml文件中不能隐藏';
$lang->about_menu = "菜单模块可以通过菜单管理器整理已生成的模块并同布局相连接来轻松建设一个完整的网站。\n菜单模块虽然具有连接模块和布局并通过布局来显示多种形态菜单的信息,但它不具备管理网站的功能。";
?>
$lang->alert_image_only = "이미지 파일만 등록가능합니다.";
?>

View file

@ -59,6 +59,10 @@
}
}
// 이미지 버튼 모두 삭제
$image_path = sprintf('./files/attach/menu_button/%s', $menu_srl);
FileHandler::removeDir($image_path);
$args->menu_srl = $menu_srl;
// 메뉴 메뉴 삭제
@ -87,8 +91,14 @@
// 메뉴 이름 체크
$lang_supported = Context::get('lang_supported');
$name_inserted = false;
foreach($lang_supported as $key => $val) {
$menu_name[$key] = $source_args->{"menu_name_".strtolower($key )};
if($menu_name[$key]) $name_inserted = true;
}
if(!$name_inserted) {
global $lang;
return new Object(-1, sprintf($lang->filter->isnull, $lang->menu_name));
}
// 변수를 다시 정리 (form문의 column과 DB column이 달라서)
@ -101,9 +111,9 @@
$args->url = trim($source_args->menu_url);
$args->open_window = $source_args->menu_open_window;
$args->expand = $source_args->menu_expand;
$args->normal_btn = $source_args->menu_normal_btn;
$args->hover_btn = $source_args->menu_hover_btn;
$args->active_btn = $source_args->menu_active_btn;
$args->normal_btn = $source_args->normal_btn;
$args->hover_btn = $source_args->hover_btn;
$args->active_btn = $source_args->active_btn;
$args->group_srls = $source_args->group_srls;
// 이미 존재하는지를 확인
@ -185,6 +195,11 @@
// XML 파일을 갱신하고 위치을 넘겨 받음
$xml_file = $this->makeXmlFile($args->menu_srl);
// 이미지 버튼 모두 삭제
if($item_info->normal_btn) @unlink($item_info->normal_btn);
if($item_info->hover_btn) @unlink($item_info->hover_btn);
if($item_info->active_btn) @unlink($item_info->active_btn);
$this->add('xml_file', $xml_file);
$this->add('menu_title', $menu_title);
$this->add('menu_item_srl', $parent_srl);
@ -250,6 +265,51 @@
$this->add('xml_file',$xml_file);
}
/**
* @brief 메뉴 이미지 버튼을 등록
**/
function procMenuAdminUploadButton() {
$menu_srl = Context::get('menu_srl');
$menu_item_srl = Context::get('menu_item_srl');
$target = Context::get('target');
$target_file = Context::get($target);
// 필수 요건이 없거나 업로드된 파일이 아니면 오류 발생
if(!$menu_srl || !$menu_item_srl || !$target_file || !is_uploaded_file($target_file['tmp_name']) || !preg_match('/\.(gif|jpeg|jpg|png)/i',$target_file['name'])) {
Context::get('error_messge', Context::getLang('msg_invalid_request'));
// 요건을 만족하고 업로드된 파일이면 지정된 위치로 이동
} else {
$tmp_arr = explode('/',$target_file['type']);
$ext = $tmp_arr[count($tmp_arr)-1];
$path = sprintf('./files/attach/menu_button/%d/', $menu_srl);
$filename = sprintf('%s%d.%s.%s', $path, $menu_item_srl, $target, $ext);
if(!is_dir($path)) FileHandler::makeDir($path);
move_uploaded_file($target_file['tmp_name'], $filename);
Context::set('filename', $filename);
}
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('menu_file_uploaded');
}
/**
* @brief 등록된 메뉴 이미지 제거
**/
function procMenuAdminDeleteButton() {
$menu_srl = Context::get('menu_srl');
$menu_item_srl = Context::get('menu_item_srl');
$target = Context::get('target');
$filename = Context::get('filename');
@unlink($filename);
$this->add('target', $target);
}
/**
* @brief 메뉴의 xml 파일을 만들고 위치를 return
**/
@ -341,16 +401,32 @@
else $href = $url;
$open_window = $node->open_window;
$expand = $node->expand;
$normal_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$node->normal_btn);
$hover_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$node->hover_btn);
$active_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$node->active_btn);
$normal_btn = $node->normal_btn;
if($normal_btn && preg_match('/^\.\/files\/attach\/menu_button/i',$normal_btn)) $normal_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$normal_btn);
else $normal_btn = '';
$hover_btn = $node->hover_btn;
if($hover_btn && preg_match('/^\.\/files\/attach\/menu_button/i',$hover_btn)) $hover_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$hover_btn);
else $hover_btn = '';
$active_btn = $node->active_btn;
if($active_btn && preg_match('/^\.\/files\/attach\/menu_button/i',$active_btn)) $active_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$active_btn);
else $active_btn = '';
$group_srls = $node->group_srls;
if($normal_btn) {
if($hover_btn) $hover_str = sprintf('onmouseover=&quot;this.src=\'%s\'&quot;', $hover_btn); else $hover_str = '';
if($active_btn) $active_str = sprintf('onmousedown=&quot;this.src=\'%s\'&quot;', $active_btn); else $active_str = '';
$link = sprintf('&lt;img src=&quot;%s&quot; onmouseout=&quot;this.src=\'%s\'&quot; alt=&quot;<?php print htmlspecialchars($_names[$_SESSION["lang_type"]]) ?>&quot; %s %s /&gt;', $normal_btn, $normal_btn, $hover_str, $active_str);
} else {
$link = '<? print $_names[$_SESSION["lang_type"]]; ?>';
}
// node->group_srls값이 있으면
if($group_srls) $group_check_code = sprintf('($_is_admin==true||(is_array($_SESSION["group_srls"])&&count(array_intersect($_SESSION["group_srls"], array(%s)))))',$group_srls);
else $group_check_code = "true";
$attribute = sprintf(
'node_srl="%s" parent_srl="%s" text="<?php if(%s) { %s }?>" url="<?php print(%s?"%s":"")?>" href="<?php print(%s?"%s":"")?>" open_window="%s" expand="%s" normal_btn="%s" hover_btn="%s" active_btn="%s" ',
'node_srl="%s" parent_srl="%s" text="<?php if(%s) { %s }?>" url="<?php print(%s?"%s":"")?>" href="<?php print(%s?"%s":"")?>" open_window="%s" expand="%s" normal_btn="%s" hover_btn="%s" active_btn="%s" link="<?php if(%s) {?>%s<?}?>"',
$menu_item_srl,
$node->parent_srl,
$group_check_code,
@ -363,7 +439,9 @@
$expand,
$normal_btn,
$hover_btn,
$active_btn
$active_btn,
$group_check_code,
$link
);
if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
@ -417,9 +495,31 @@
$child_buff = $child_output['buff'];
$expand = $node->expand;
$normal_btn = $node->normal_btn;
if($normal_btn && preg_match('/^\.\/files\/attach\/menu_button/i',$normal_btn)) $normal_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$normal_btn);
else $normal_btn = '';
$hover_btn = $node->hover_btn;
if($hover_btn && preg_match('/^\.\/files\/attach\/menu_button/i',$hover_btn)) $hover_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$hover_btn);
else $hover_btn = '';
$active_btn = $node->active_btn;
if($active_btn && preg_match('/^\.\/files\/attach\/menu_button/i',$active_btn)) $active_btn = str_replace(array('&','"','<','>'),array('&amp;','&quot;','&lt;','&gt;'),$active_btn);
else $active_btn = '';
$group_srls = $node->group_srls;
if($normal_btn) {
if($hover_btn) $hover_str = sprintf('onmouseover=\"this.src=\'%s\'\"', $hover_btn); else $hover_str = '';
if($active_btn) $active_str = sprintf('onmousedown=\"this.src=\'%s\'\"', $active_btn); else $active_str = '';
$link = sprintf('"<img src=\"%s\" onmouseout=\"this.src=\'%s\'\" alt=\"".$_menu_names[%d][$lang_type]."\" %s %s />"', $normal_btn, $normal_btn, $node->menu_item_srl, $hover_str, $active_str);
} else {
$link = sprintf('$_menu_names[%d][$lang_type]', $node->menu_item_srl);
}
// 속성을 생성한다 ( url_list를 이용해서 선택된 메뉴의 노드에 속하는지를 검사한다. 꽁수지만 빠르고 강력하다고 생각;;)
$attribute = sprintf(
'"node_srl"=>"%s","parent_srl"=>"%s","text"=>(%s?$_menu_names[%d][$lang_type]:""),"href"=>(%s?"%s":""),"url"=>(%s?"%s":""),"open_window"=>"%s","normal_btn"=>"%s","hover_btn"=>"%s","active_btn"=>"%s","selected"=>(array(%s)&&in_array(Context::get("mid"),array(%s))?1:0),"expand"=>"%s", "list"=>array(%s)',
'"node_srl"=>"%s","parent_srl"=>"%s","text"=>(%s?$_menu_names[%d][$lang_type]:""),"href"=>(%s?"%s":""),"url"=>(%s?"%s":""),"open_window"=>"%s","normal_btn"=>"%s","hover_btn"=>"%s","active_btn"=>"%s","selected"=>(array(%s)&&in_array(Context::get("mid"),array(%s))?1:0),"expand"=>"%s", "list"=>array(%s), "link"=>(%s?%s:""),',
$node->menu_item_srl,
$node->parent_srl,
$group_check_code,
@ -435,7 +535,9 @@
$selected,
$selected,
$expand,
$child_buff
$child_buff,
$group_check_code,
$link
);
// buff 데이터를 생성한다

View file

@ -1,11 +1,11 @@
<query id="getChildCategoryCount" action="select">
<query id="getChildMenuCount" action="select">
<tables>
<table name="document_categories" />
<table name="menu_item" />
</tables>
<columns>
<column name="count(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="parent_srl" var="category_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="parent_srl" var="menu_item_srl" filter="number" notnull="notnull" />
</conditions>
</query>

View file

@ -201,3 +201,81 @@ function doInsertMid(mid, menu_id) {
fo_obj.menu_url.value = mid;
window.close();
}
/* 각 메뉴의 버튼 이미지 등록 */
function doMenuUploadButton(obj) {
// 이미지인지 체크
if(!/\.(gif|jpg|jpeg|png)$/i.test(obj.value)) return alert(alertImageOnly);
// iframe 객체 생성 (있으면 있는것 이용)
if(!xGetElementById('tmp_upload_iframe')) {
if(xIE4Up) {
window.document.body.insertAdjacentHTML("afterEnd", "<iframe id='tmp_upload_iframe' name='tmp_upload_iframe' style='display:none;width:1px;height:1px;position:absolute;top:-10px;left:-10px'></iframe>");
} else {
var obj_iframe = xCreateElement('IFRAME');
obj_iframe.name = obj_iframe.id = 'tmp_upload_iframe';
obj_iframe.style.display = 'none';
obj_iframe.style.width = '1px';
obj_iframe.style.height = '1px';
obj_iframe.style.position = 'absolute';
obj_iframe.style.top = '-10px';
obj_iframe.style.left = '-10px';
window.document.body.appendChild(obj_iframe);
}
}
// 현재 form의 target을 바꾸고 이미지 등록
obj.form.target = 'tmp_upload_iframe';
// submit
obj.form.act.value = "procMenuAdminUploadButton";
obj.form.target.value = obj.name;
obj.form.submit();
obj.form.act.value = "";
obj.form.target.value = "";
}
/* 메뉴 이미지 업로드 후처리 */
function completeMenuUploadButton(target, filename) {
var column_name = target.replace(/^menu_/,'');
var fo_obj = xGetElementById("fo_menu");
var zone_obj = xGetElementById(target+'_zone');
var img_obj = xGetElementById(target+'_img');
fo_obj[column_name].value = filename;
var img = new Image();
img.src = filename;
img_obj.src = img.src;
zone_obj.style.display = "block";
}
/* 업로드된 메뉴 이미지 삭제 */
function doDeleteButton(target) {
var fo_obj = xGetElementById("fo_menu");
var col_name = target.replace(/^menu_/,'');
var params = new Array();
params['target'] = target;
params['menu_srl'] = fo_obj.menu_srl.value;
params['menu_item_srl'] = fo_obj.menu_item_srl.value;
params['filename'] = fo_obj[col_name].value;
var response_tags = new Array('error','message', 'target');
exec_xml('menu','procMenuAdminDeleteButton', params, completeDeleteButton, response_tags);
}
function completeDeleteButton(ret_obj, response_tags) {
var target = ret_obj['target'];
var column_name = target.replace(/^menu_/,'');
var fo_obj = xGetElementById("fo_menu");
var zone_obj = xGetElementById(target+'_zone');
var img_obj = xGetElementById(target+'_img');
fo_obj[column_name].value = "";
img_obj.src = "";
zone_obj.style.display = "none";
}

View file

@ -0,0 +1,10 @@
<!--@if($error_message)-->
<script type="text/javascript">
alert("{$error_message}");
</script>
<!--@else-->
<script type="text/javascript">
top.completeMenuUploadButton("{$target}", "{$filename}");
</script>
<!--@end-->

View file

@ -1,5 +1,8 @@
<input type="hidden" name="menu_item_srl" value="{$item_info->menu_item_srl}" />
<input type="hidden" name="parent_srl" value="{$item_info->parent_srl}" />
<input type="hidden" name="normal_btn" value="{$item_info->normal_btn}" />
<input type="hidden" name="hover_btn" value="{$item_info->hover_btn}" />
<input type="hidden" name="active_btn" value="{$item_info->active_btn}" />
<table cellspacing="0" class="adminTable">
<col width="80" />
@ -49,15 +52,33 @@
</tr>
<tr>
<th scope="row" colspan="2">{$lang->menu_normal_btn}</th>
<td><input type="text" name="menu_normal_btn" value="{htmlspecialchars($item_info->normal_btn)}" class="inputTypeText" /></td>
<td>
<div id="menu_normal_btn_zone" <!--@if(!$item_info->normal_btn)-->style="display:none;"<!--@end-->>
<img src="{$item_info->normal_btn}" alt="" id="menu_normal_btn_img" /><br />
<a href="#" onclick="doDeleteButton('menu_normal_btn');return false;" class="button"><span>{$lang->cmd_delete}</span></a>
</div>
<input type="file" name="menu_normal_btn" value="" class="inputTypeText" onchange="doMenuUploadButton(this); return false;"/>
</td>
</tr>
<tr>
<th scope="row" colspan="2">{$lang->menu_hover_btn}</th>
<td><input type="text" name="menu_hover_btn" value="{htmlspecialchars($item_info->hover_btn)}" class="inputTypeText" /></td>
<td>
<div id="menu_hover_btn_zone") <!--@if(!$item_info->hover_btn)-->style="display:none;"<!--@end-->>
<img src="{$item_info->hover_btn}" alt="" id="menu_hover_btn_img" /><br />
<a href="#" onclick="doDeleteButton('menu_hover_btn');return false;" class="button"><span>{$lang->cmd_delete}</span></a>
</div>
<input type="file" name="menu_hover_btn" value="" class="inputTypeText" onchange="doMenuUploadButton(this); return false;"/>
</td>
</tr>
<tr>
<th scope="row" colspan="2">{$lang->menu_active_btn}</th>
<td><input type="text" name="menu_active_btn" value="{htmlspecialchars($item_info->active_btn)}" class="inputTypeText" /></td>
<td>
<div id="menu_active_btn_zone" <!--@if(!$item_info->active_btn)-->style="display:none;"<!--@end-->>
<img src="{$item_info->active_btn}" alt="" id="menu_active_btn_img" /><br />
<a href="#" onclick="doDeleteButton('menu_active_btn');return false;" class="button"><span>{$lang->cmd_delete}</span></a>
</div>
<input type="file" name="menu_active_btn" value="" class="inputTypeText" onchange="doMenuUploadButton(this); return false;"/>
</td>
</tr>
<tr>
<th scope="row" colspan="2">{$lang->menu_group_srls}</th>

View file

@ -5,6 +5,10 @@
<!--%import("css/menu.css")-->
<!--%import("js/menu_admin.js")-->
<script type="text/javascript">
var alertImageOnly = "{$lang->alert_image_only}";
</script>
<div class="menuManagement">
<!-- 메뉴 이동을 위해 임시로 사용하는 form -->
@ -65,11 +69,14 @@
<p class="gap1"><input type="checkbox" id="menu_enable_move" class="checkbox" /> <label for="menu_enable_move">{$lang->cmd_enable_move_menu}</label></p>
<div class="gap1">
<form id="fo_menu" action="./" method="get" onsubmit="return procFilter(this, insert_menu_item)" class="clear">
<form id="fo_menu" action="./" method="post" onsubmit="return procFilter(this, insert_menu_item)" class="clear" enctype="multipart/form-data">
<input type="hidden" name="title" value="{$menu_info->title}" />
<input type="hidden" name="menu_srl" value="{$menu_info->menu_srl}" />
<input type="hidden" name="xml_file" value="{$menu_info->xml_file}" />
<input type="hidden" name="php_file" value="{$menu_info->php_file}" />
<input type="hidden" name="module" value="menu" />
<input type="hidden" name="act" value="" />
<input type="hidden" name="target" value="" />
<div id="category_list">
<div id="menu_zone_menu"></div>