widget module(not completed)

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8987 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2011-09-02 06:14:53 +00:00
parent 6285e0b316
commit 1f6fe648a8
11 changed files with 555 additions and 69 deletions

View file

@ -7,9 +7,12 @@
<action name="dispWidgetGenerateCode" type="view" standalone="true" />
<action name="dispWidgetGenerateCodeInPage" type="view" standalone="true" />
<action name="dispWidgetStyleGenerateCodeInPage" type="view" standalone="true" />
<action name="dispWidgetAdminDownloadedList" type="view" standalone="true" admin_index="true" />
<action name="dispWidgetAdminDownloadedList" type="view" standalone="true" admin_index="true" menu_name="installedWidget" menu_index="true" />
<action name="dispWidgetAdminAddContent" type="view" standalone="true" />
<action name="procWidgetGenerateCode" type="controller" standalone="true" />
<action name="dispWidgetAdminGenerateCode" type="view" menu_name="installedWidget" />
<action name="procWidgetGenerateCode" type="controller" standalone="true" />
<action name="procWidgetStyleExtraImageUpload" type="controller" standalone="true" />
<action name="procWidgetStyleGenerateCodeInPage" type="controller" standalone="true" />
<action name="procWidgetAddContent" type="controller" standalone="true" />
@ -25,7 +28,7 @@
<menus>
<menu name="installedWidget">
<title xml:lang="en">Installed Widget</title>
<title xml:lang="ko">위젯</title>
<title xml:lang="ko">설치된 위젯</title>
<title xml:lang="zh-CN">Installed Widget</title>
<title xml:lang="jp">Installed Widget</title>
<title xml:lang="es">Installed Widget</title>

View file

@ -617,4 +617,8 @@ Sin la necesidad de utilizar los módulos de página o del diseño de XE, Usted
<value xml:lang="tr"><![CDATA[Y Konum]]></value>
<value xml:lang="vi"><![CDATA[Vị trí Y]]></value>
</item>
</lang>
<item name="installed_widget">
<value xml:lang="ko"><![CDATA[설치된 위젯]]></value>
<value xml:lang="en"><![CDATA[Installed Widget]]></value>
</item>
</lang>

View file

@ -1,44 +1,38 @@
<h3 class="xeAdmin">{$lang->widget} <span class="gray">{$lang->cmd_management}</span></h3>
<include target="header.html" />
<!-- 설명 -->
<div class="infoText">{nl2br($lang->about_widget)}</div>
<!-- 위젯의 목록 -->
<table cellspacing="0" class="crossTable">
<thead>
<tr>
<th scope="col"><div>{$lang->widget_name}<div></th>
<th scope="col"><div>{$lang->version}<div></th>
<th scope="col"><div>{$lang->author}<div></th>
<th scope="col"><div>{$lang->date}<div></th>
<th scope="col"><div>{$lang->path}<div></th>
<th scope="col"><div>{$lang->cmd_generate_code}<div></th>
</tr>
</thead>
<tbody>
<!--@foreach($widget_list as $key => $val)-->
<tr class="row{$cycle_idx}">
<th scope="row" rowspan="2">
<div>
<a href="{getUrl('','module','widget','act','dispWidgetInfo','selected_widget',$val->widget)}" onclick="popopen(this.href,'widget_info');return false">{$val->title}</a><br />
({$val->widget})
</div>
</th>
<td class="number center">{$val->version}</td>
<td class="nowrap">
<!--@foreach($val->author as $author)-->
<!--@if($author->homepage)--><a href="{$author->homepage}" onclick="window.open(this.href);return false;"><!--@end-->{$author->name}<!--@if($author->homepage)--></a><!--@end-->
<!--@endforeach-->
</td>
<td class="date nowrap center">{zdate($val->date, 'Y-m-d')}</td>
<td class="number">{$val->path}</td>
<td class="center"><a href="{getUrl('','module','widget','act','dispWidgetGenerateCode','selected_widget',$val->widget)}" onclick="popopen(this.href,'widget_code_generate');return false">{$lang->cmd_generate_code}</a></td>
</tr>
<tr>
<td colspan="5" class="left">
{nl2br(trim($val->description))}&nbsp;
</td>
</tr>
<!--@end-->
</tbody>
</table>
<div class="table even easyList">
<table width="100%" border="1" cellspacing="0">
<caption>All({$tCount})</caption>
<thead>
<tr>
<th scope="col" class="title">{$lang->widget_name}</th>
<th scope="col">{$lang->version}</th>
<th scope="col">{$lang->author}</th>
<th scope="col">{$lang->path}</th>
<th scope="col">{$lang->cmd_generate_code}</th>
<th scope="col">{$lang->cmd_delete}</th>
</tr>
</thead>
<tbody>
<tr loop="$widget_list => $widget">
<td class="title">
<p><strong>{$widget->title}</strong></p>
<p>{$widget->description}</p>
<p cond="$widget->need_update == 'Y'" class="update">
{$lang->msg_avail_update} <a href="{$widget->update_url}&amp;return_url={urlencode(getRequestUriByServerEnviroment())}">{$lang->msg_do_you_like_update}</a>
</p>
</td>
<td>{$widget->version}</td>
<td>
<block loop="$widget->author => $author">
<a cond="$author->homepage" href="{$author->homepage}" target="_blank">{$author->name}</a>
<block cond="!$author->homepage">{$author->name}</block>
</block>
</td>
<td>{$widget->path}</td>
<td><a href="{getUrl('act', 'dispWidgetAdminGenerateCode', 'selected_widget', $widget->widget)}">{$lang->cmd_generate_code}</a></td>
<td><a cond="$widget->remove_url" href="{$widget->remove_url}&amp;return_url={urlencode(getRequestUriByServerEnviroment())}">{$lang->cmd_delete}</a></td>
</tr>
</tbody>
</table>
</div>

View file

@ -0,0 +1,4 @@
<h1 class="h1">{$lang->installed_widget}</h1>
<div cond="$XE_VALIDATOR_MESSAGE" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>

View file

@ -0,0 +1,57 @@
function doDisplaySkinColorset()
{
var skin = jQuery('select[name=skin]').val();
if(!skin) {
doHideSkinColorset();
return;
}
var params = new Array();
params["selected_widget"] = jQuery('input[name=selected_widget]').val();
params["skin"] = skin;
params["colorset"] = jQuery('select[name=colorset]').val();
var response_tags = new Array("error","message","colorset_list");
exec_xml("widget", "procWidgetGetColorsetList", params, completeGetSkinColorset, response_tags, params);
}
function completeGetSkinColorset(ret_obj)
{
var sel = jQuery("select[name=colorset]").get(0);
var length = sel.options.length;
var selected_colorset = jQuery('select[name=colorset]').val();
for(var i=0;i<length;i++) sel.remove(0);
if(!ret_obj["colorset_list"]) return;
var colorset_list = ret_obj["colorset_list"].split("\n");
var selected_index = 0;
for(var i=0;i<colorset_list.length;i++) {
var tmp = colorset_list[i].split("|@|");
if(selected_colorset && selected_colorset==tmp[0]) selected_index = i;
var opt = new Option(tmp[1], tmp[0], false, false);
sel.options.add(opt);
}
sel.selectedIndex = selected_index;
doShowSkinColorset();
}
function doHideSkinColorset()
{
jQuery('select[name=colorset]').parents('li').hide();
}
function doShowSkinColorset()
{
jQuery('select[name=colorset]').parents('li').show();
}
jQuery(document).ready(function($){
$('select[name=skin]').next('span').children().bind('click', function(e){
doDisplaySkinColorset();
});
doHideSkinColorset();
});

View file

@ -0,0 +1,104 @@
var ModuleListManager = xe.createApp("ModuleListManager", {
values: null,
keyObj: null,
moduleNameObj: null,
moduleSrlObj: null,
selectedObj: null,
init: function(key, values){
var values = this.values = values;
var keyObj = this.keyObj = jQuery('input[name='+key+']');
var moduleNameObj = this.moduleNameObj = keyObj.parent().find('.moduleList');
var moduleSrlObj = this.moduleSrlObj = keyObj.parent().find('.moduleIdList');
var selectedObj = this.selectedObj = keyObj.parent().find('.modulelist_selected');
var thisObj = this;
keyObj.parent().find('.modulelist_add').bind('click', function(){ thisObj.cast('MODULELIST_ADD'); return false; });
keyObj.parent().find('.modulelist_del').bind('click', function(){ thisObj.cast('MODULELIST_DEL'); return false; });
keyObj.parent().find('.modulelist_up').bind('click', function(){ thisObj.cast('MODULELIST_UP'); return false; });
keyObj.parent().find('.modulelist_down').bind('click', function(){ thisObj.cast('MODULELIST_DOWN'); return false; });
},
API_MODULELIST_ADD: function(){
var module = this.moduleNameObj.children('option:selected').text();
var moduleSrl = this.moduleSrlObj.val();
var browserTitle = this.moduleSrlObj.children('option:selected').text();
if (this.addValue(moduleSrl, module, browserTitle)) this.apply();
},
API_MODULELIST_DEL: function(){
var index = this.selectedObj.get(0).selectedIndex;
if (index == -1) return;
if (this.delValue(index)) this.apply();
},
API_MODULELIST_UP: function(){
var index = this.selectedObj.get(0).selectedIndex;
if (index == -1) return;
if (this.up(index)) this.apply();
},
API_MODULELIST_DOWN: function(){
var index = this.selectedObj.get(0).selectedIndex;
if (index == -1) return;
if (this.down(index)) this.apply();
},
addValue: function(moduleSrl, module, browserTitle){
var value = {'moduleSrl': moduleSrl, 'module': module, 'browserTitle': browserTitle};
if (this.values == undefined) this.values = new Array();
for (var i in this.values){
if (this.values[i].moduleSrl == value.moduleSrl) return false;
}
this.values.push(value);
return true;
},
delValue: function(index){
this.values.splice(index, 1);
return true;
},
up: function(index){
if (index == 0) return false;
var targets = this.values.splice(index-1, 2);
for(var i in targets){
this.values.splice(index-1, 0, targets[i]);
}
return true;
},
down: function(index){
if (index == this.values.length-1) return false;
var targets = this.values.splice(index, 2);
for(var i in targets){
this.values.splice(index, 0, targets[i]);
}
return true;
},
apply: function(){
var keys = new Array();
for (var i in this.values){
keys.push(this.values[i].moduleSrl);
}
this.keyObj.val(keys.join(','));
var prevValue = this.selectedObj.val();
this.selectedObj.empty();
for (var i in this.values){
var module = this.values[i];
var html = '<option value="'+module.moduleSrl+'">'+module.browserTitle+'('+module.module+')</option>';
this.selectedObj.append(html);
}
this.selectedObj.val(prevValue);
}
});

View file

@ -0,0 +1,117 @@
var MultiOrderManager = xe.createApp("MultiOrderManager", {
options: null,
values: null,
keyObj: null,
showObj: null,
selectedObj: null,
init: function(key, options, values){
var opstions = this.options = options;
var values = this.values = values;
var keyObj = this.keyObj = jQuery('input[name='+key+']');
var showObj = this.showObj = keyObj.parent().find('.multiorder_show');
var selectedObj = this.selectedObj = keyObj.parent().find('.multiorder_selected');
for (var key in options){
var option = options[key];
var html = '<option value="'+key+'">'+option.value+'</option>';
showObj.append(html);
if (option.init){
this.addValue(key);
}
}
this.apply();
var thisObj = this;
keyObj.parent().find('.multiorder_add').bind('click', function(){ thisObj.cast('MULTIORDER_ADD'); return false; });
keyObj.parent().find('.multiorder_del').bind('click', function(){ thisObj.cast('MULTIORDER_DEL'); return false; });
keyObj.parent().find('.multiorder_up').bind('click', function(){ thisObj.cast('MULTIORDER_UP'); return false; });
keyObj.parent().find('.multiorder_down').bind('click', function(){ thisObj.cast('MULTIORDER_DOWN'); return false; });
},
API_MULTIORDER_ADD: function(){
var index = this.showObj.get(0).selectedIndex;
if (index == -1) return;
if (this.addValue(index)) this.apply();
},
API_MULTIORDER_DEL: function(){
var index = this.selectedObj.get(0).selectedIndex;
if (index == -1) return;
if (this.delValue(index)) this.apply();
},
API_MULTIORDER_UP: function(){
var index = this.selectedObj.get(0).selectedIndex;
if (index == -1) return;
if (this.up(index)) this.apply();
},
API_MULTIORDER_DOWN: function(){
var index = this.selectedObj.get(0).selectedIndex;
if (index == -1) return;
if (this.down(index)) this.apply();
},
addValue: function(index){
var option = this.options[index];
if (!option) return false;
if (this.values == undefined) this.values = new Array();
for (var i in this.values){
if (this.values[i].key == option.key) return false;
}
this.values.push(option);
return true;
},
delValue: function(index){
if (this.options[index].default) return false;
this.values.splice(index, 1);
return true;
},
up: function(index){
if (index == 0) return false;
var targets = this.values.splice(index-1, 2);
for(var i in targets){
this.values.splice(index-1, 0, targets[i]);
}
return true;
},
down: function(index){
if (index == this.values.length-1) return false;
var targets = this.values.splice(index, 2);
for(var i in targets){
this.values.splice(index, 0, targets[i]);
}
return true;
},
apply: function(){
var keys = new Array();
for (var i in this.values){
keys.push(this.values[i].key);
}
this.keyObj.val(keys.join(','));
var prevValue = this.selectedObj.val();
this.selectedObj.empty();
for (var i in this.values){
var option = this.values[i];
var html = '<option value="'+option.key+'">'+option.value+'</option>';
this.selectedObj.append(html);
}
this.selectedObj.val(prevValue);
}
});

View file

@ -1,26 +1,194 @@
<!--%import("filter/generate_code.xml")-->
<!--%import("js/widget_admin.js")-->
<!--%import("css/widget.css")-->
<!--%import("../../admin/tpl/css/admin.css")-->
<include cond="$in_admin" target="header.html" />
<load target="js/generate_code.js" />
<load target="js/multi_order.js" />
<load target="js/module_list.js" />
<!--%load_js_plugin("ui.colorpicker")-->
<form action="./" method="get" onsubmit="return procFilter(this, generate_code);" id="fo_widget">
<div id="popHeader" class="wide">
<h3 class="xeAdmin">{$lang->cmd_generate_code}</h3>
</div>
<h2 class="h2">{$widget_info->title}</h2>
<p>{$widget_info->description}</p>
<div id="popBody">
{@ $_caption = $lang->about_widget_code}
<!--#include("widget_generate_code.include.html")-->
<h3 class="xeAdmin">{$lang->widget_code}</h3>
<table cellspacing="0" class="rowTable">
<tr>
<td class="wide"><textarea readonly="true" id="widget_code" class="inputTypeTextArea fullWidth"></textarea></td>
</tr>
</table>
</div>
<form class="form" action="./" method="post">
<input type="hidden" name="selected_widget" value="{$widget_info->widget}" />
<div id="popFooter">
<span class="button black strong"><input type="submit" value="{$lang->cmd_generate_code}" /></span>
</div>
<h3 class="h3">{$lang->cmd_generate_code}</h3>
<p>{$lang->about_widget_code}</p>
<ul>
<li>
<p class="q"><label for="skin">{$lang->skin}</label></p>
<a class="a">
<select name="skin" id="skin">
<option value=""></option>
<option loop="$skin_list => $skin_name, $skin" value="{$skin_name}">{$skin->title} ({$skin_name})</option>
</select>
<span class="btn small"><input type="button" value="{$lang->cmd_select}" /></span>
</a>
</li>
<li>
<p class="q"><label for="colorset">{$lang->colorset}</label></p>
<p class="a">
<select name="colorset">
</select>
</p>
</li>
<li>
<p class="q"><label for="widget_cache">{$lang->widget_cache}</label></p>
<p class="a">
<input type="text" name="widget_cache" id="widget_cache" value="0" size="2" style="width: auto;" /> {$lang->unit_min}
</p>
<p class="desc">{$lang->about_widget_cache}</p>
</li>
</ul>
{@$suggestion_id = 0}
<block loop="$widget_info->extra_var => $id, $var">
{@$suggestion_id++}
<block cond="!$not_first && !$var->group"><ul></block>
<block cond="$group != $var->group">
<block cond="$not_first"></ul></block>
<h3 class="h3">{$var->group}</h3>
<ul>
{@$group = $var->group}
</block>
{@$not_first = true}
<li class="modulefinder"|cond="$var->type == 'mid' || $var->type == 'module_srl_list'">
<p class="q"><label for="{$id}">{$var->name}</label></p>
<div class="a">
<input cond="$var->type == 'text'" type="text" name="{$id}" value="" id="{$id}" />
<input cond="$var->type == 'color'" type="text" name="{$id}" value="" id="{$id}" class="color-indicator" />
<textarea cond="$var->type == 'textarea'" name="{$id}" id="{$id}"></textarea>
<select cond="$var->type == 'select'" name="{$id}" id="{$id}">
<option loop="$var->options => $key, $val" value="{$key}">{$val}</option>
</select>
<block cond="$var->type == 'select-multi-order'">
<input type="hidden" name="{$id}" value="" />
<div style="float:left; margin-left: 30px;">
<select class="multiorder_show" size="8" style="width: 100px;"></select>
</div>
<div style="float:left;margin-left:30px;">
<a class="multiorder_add" href="#">{$lang->cmd_insert}</a>
<br/><br/>
<a class="multiorder_del" href="#">{$lang->cmd_delete}</a>
</div>
<div style="float:left;margin-left:30px;">
<select class="multiorder_selected" size="8" style="width: 100px;"></select>
</div>
<div style="float:left;margin-left:30px;">
<a class="multiorder_up" href="#">{$lang->cmd_move_up}</a>
<br/><br/>
<a class="multiorder_down" href="#">{$lang->cmd_move_down}</a>
</div>
<script type="text/javascript">
var options = [
<block loop="$var->options => $key, $val">
{
<block cond="$var->init_options[$key]">
'init': true,
</block>
<block cond="!$var->init_options[$key]">
'init': false,
</block>
<block cond="$var->default_options[$key]">
'default': true,
</block>
<block cond="!$var->default_options[$key]">
'default': false,
</block>
'key': '{$key}',
'value': '{$val}'
},
</block>
];
new MultiOrderManager('{$id}', options);
</script>
</block>
<block cond="$var->type == 'mid_list'">
{@debugPrint($mid_list)}
<fieldset loop="$mid_list => $module_category_srl, $modules" style="border: 1px solid #ccc; margin: 0; padding: 4px 7px 9px 7px;">
<legend cond="$modules->title">{$modules->title}</legend>
<legend cond="!$modules->title">{$lang->none_category}</legend>
<div loop="$modules->list => $key, $val">
<input type="checkbox" value="{$key}" name="{$id}" id="chk_mid_list_{$key}" />
<label for="chk_mid_list_{$key}">{$key} ({$val->browser_title})</label>
</div>
</fieldset>
</block>
<block cond="$var->type == 'member_group'">
<block loop="$group_list => $key, $val">
<input type="checkbox" value="{$key}" name="{$id}" id="chk_member_gruop_{$id}_{$key}" />
<label for="chk_member_gruop_{$id}_{$key}">{$val->title}</label>
</block>
</block>
<block cond="$var->type == 'module_srl_list'">
<input type="hidden" name="{$id}" value="" />
<div style="float:left; margin-left: 30px;">
<div class="a">
<input type="text" /> <a href="#suggestion_{$suggestion_id}" class="tgAnchor findsite">사이트찾기</a>
<div id="suggestion_{$suggestion_id}" class="tgContent suggestion">
<ul>
</ul>
</div>
</div>
<p class="a"><select class="moduleList" style="width: 290px;"></select></p>
<p class="a"><select class="moduleIdList" style="width: 290px;"></select></p>
</div>
<div style="float:left;margin-left:30px;">
<a class="modulelist_add" href="#">{$lang->cmd_insert}</a>
<br/><br/>
<a class="modulelist_del" href="#">{$lang->cmd_delete}</a>
</div>
<div style="float:left;margin-left:30px;">
<select class="modulelist_selected" size="8" style="width: 200px;"></select>
</div>
<div style="float:left;margin-left:30px;">
<a class="modulelist_up" href="#">{$lang->cmd_move_up}</a>
<br/><br/>
<a class="modulelist_down" href="#">{$lang->cmd_move_down}</a>
</div>
<script type="text/javascript">
new ModuleListManager('{$id}');
</script>
</block>
<block cond="$var->type == 'mid'">
<div class="a">
<input type="text" /> <a href="#suggestion_{$suggestion_id}" class="tgAnchor findsite">사이트찾기</a>
<div id="suggestion_{$suggestion_id}" class="tgContent suggestion">
<ul>
</ul>
</div>
</div>
<p class="a"><select class="moduleList" style="width: 290px;"></select></p>
<p class="a"><select name="{$id}" class="moduleIdList" style="width: 290px;"></select></p>
</block>
<block cond="$var->type == 'filebox'">
<div id="filebox_preview_{$id}" style="width:100px;height:100px;display:none" ></div>
<input type="hidden" name="{$id}" value="" />
<span class="button black"><button type="button" onclick="XE.filebox.open(jQuery('[name={$id}]', '#fo_widget').get(0), '{$var->filter}')">{$lang->cmd_select}</button></span>
<span id="filebox_cancel_{$id}" class="button red" style="display:none" ><button type="button" onclick="XE.filebox.cancel('{$id}')">{$lang->cmd_delete}</button></span>
<script type="text/javascript">//<![CDATA[
XE.filebox.init('{$id}');
//]]></script>
</block>
<select cond="$var->type == 'menu'">
<option value="">-</option>
<option loop="$menu_list => $key, $val" value="{$val->menu_srl}">{$val->title}</option>
</select>
</div>
<p class="desc" style="clear: both;">{$var->description}</p>
</li>
</block>
</ul>
</form>

View file

@ -21,11 +21,29 @@
// Set widget list
$oWidgetModel = &getModel('widget');
$widget_list = $oWidgetModel->getDownloadedWidgetList();
$security = new Security($widget_list);
$widget_list = $security->encodeHTML('..', '..author..');
foreach($widget_list as $no => $widget)
{
$widget_list[$no]->description = nl2br(trim($widget->description));
}
Context::set('widget_list', $widget_list);
Context::set('tCount', count($widget_list));
$this->setTemplateFile('downloaded_widget_list');
}
function dispWidgetAdminGenerateCode()
{
$oView = &getView('widget');
Context::set('in_admin', true);
$this->setTemplateFile('widget_generate_code');
return $oView->dispWidgetGenerateCode();
}
/**
* @brief For information on direct entry widget popup kkuhim
**/

View file

@ -49,6 +49,8 @@
* Download a widget with type (generation and other means)
**/
function getDownloadedWidgetList() {
$oAutoinstallModel = &getModel('autoinstall');
// 've Downloaded the widget and the widget's list of installed Wanted
$searched_list = FileHandler::readDir('./widgets');
$searched_count = count($searched_list);
@ -61,6 +63,20 @@
// Wanted information on the Widget
$widget_info = $this->getWidgetInfo($widget);
// get easyinstall remove url
$packageSrl = $oAutoinstallModel->getPackageSrlByPath($widget_info->path);
$widget_info->remove_url = $oAutoinstallModel->getRemoveUrlByPackageSrl($packageSrl);
// get easyinstall need update
$package = $oAutoinstallModel->getInstalledPackages($packageSrl);
$widget_info->need_update = $package[$packageSrl]->need_update;
// get easyinstall update url
if ($widget_info->need_update == 'Y')
{
$widget_info->update_url = $oAutoinstallModel->getUpdateUrlByPackageSrl($packageSrl);
}
$list[] = $widget_info;
}
return $list;

View file

@ -97,6 +97,7 @@
$this->setLayoutFile('popup_layout');
// Set a template file
$this->setTemplateFile('widget_generate_code');
debugPrint($widget_info);
}
/**
@ -127,7 +128,7 @@
if($widgetstyle && $widgetstyle_info){
Context::set('widgetstyle_info',$widgetstyle_info);
}
$this->dispWidgetGenerateCode();
$this->setLayoutFile('popup_layout');
$this->setTemplateFile('widget_style_generate_code_in_page');