Fix warnings in widget editor and support default values in info.xml

This commit is contained in:
Kijin Sung 2025-06-17 18:45:16 +09:00
parent 18b0e28a76
commit 34840508f7
6 changed files with 68 additions and 44 deletions

View file

@ -37,15 +37,15 @@
</div> </div>
</div> </div>
{@$suggestion_id = 0} {@ $group = ''; $not_first = false; $suggestion_id = 0; }
<block loop="$widget_info->extra_var => $id, $var"> <block loop="$widget_info->extra_var => $id, $var">
{@$suggestion_id++} {@ $suggestion_id++; }
<block cond="!$not_first && !$var->group"><section class="extra_vars section"></block> <block cond="!$not_first && !$var->group"><section class="extra_vars section"></block>
<block cond="$group != $var->group"> <block cond="$group != $var->group">
<block cond="$not_first"></section></block> <block cond="$not_first"></section></block>
<section class="extra_vars section"> <section class="extra_vars section">
<h1>{$var->group}</h1> <h1>{$var->group}</h1>
{@$group = $var->group} {@ $group = $var->group; }
</block> </block>
{@$not_first = true} {@$not_first = true}
@ -53,21 +53,21 @@
<label class="x_control-label" for="{$id}"|cond="$var->type != 'radio' && $var->type != 'checkbox'">{$var->name}</label> <label class="x_control-label" for="{$id}"|cond="$var->type != 'radio' && $var->type != 'checkbox'">{$var->name}</label>
<div class="x_controls"> <div class="x_controls">
<block cond="$var->type == 'text'"> <block cond="$var->type == 'text'">
<input type="text" name="{$id}" /> <input type="text" name="{$id}" value="{$var->default}" />
</block> </block>
<block cond="$var->type == 'color'"> <block cond="$var->type == 'color'">
<input type="text" name="{$id}" value="" id="{$id}" class="rx-spectrum" style="width:178px" /> <input type="text" name="{$id}" value="" id="{$id}" class="rx-spectrum" style="width:178px" />
</block> </block>
<block cond="$var->type == 'textarea'"> <block cond="$var->type == 'textarea'">
<textarea cond="$var->type == 'textarea'" name="{$id}" id="{$id}" rows="8" cols="42"></textarea> <textarea cond="$var->type == 'textarea'" name="{$id}" id="{$id}" rows="8" cols="42">{$var->default}</textarea>
</block> </block>
<block cond="$var->type == 'select'"> <block cond="$var->type == 'select'">
<select name="{$id}" id="{$id}"> <select name="{$id}" id="{$id}">
<option loop="$var->options => $key, $val" value="{$key}">{$val}</option> <option loop="$var->options => $key, $val" value="{$key}" selected="selected"|cond="$var->default !== '' && $key == $var->default">{$val}</option>
</select> </select>
</block> </block>
<block cond="$var->type == 'select-multi-order'"> <block cond="$var->type == 'select-multi-order'">
<!--@if($var->init_options && is_array($var->init_options))--> <!--@if(isset($var->init_options) && is_array($var->init_options))-->
{@$inits = array_keys($var->init_options)} {@$inits = array_keys($var->init_options)}
<input type="hidden" name="{$id}" value="{implode(',', $inits)}" /> <input type="hidden" name="{$id}" value="{implode(',', $inits)}" />
<!--@else--> <!--@else-->
@ -76,7 +76,7 @@
<div style="display:inline-block;padding-top:3px"> <div style="display:inline-block;padding-top:3px">
<label>{$lang->display_no}</label> <label>{$lang->display_no}</label>
<select class="multiorder_show" size="8" multiple="multiple" style="vertical-align:top;margin-bottom:5px"> <select class="multiorder_show" size="8" multiple="multiple" style="vertical-align:top;margin-bottom:5px">
<option loop="$var->options => $key, $val" cond="!$var->init_options[$key]" value="{$key}" default="true"|cond="$var->default_options[$key]">{$val}</option> <option loop="$var->options => $key, $val" cond="empty($var->init_options[$key])" value="{$key}" default="true"|cond="!empty($var->default_options[$key])">{$val}</option>
</select> </select>
<br> <br>
<button type="button" class="x_btn multiorder_add" style="vertical-align:top">{$lang->cmd_insert}</button> <button type="button" class="x_btn multiorder_add" style="vertical-align:top">{$lang->cmd_insert}</button>
@ -84,7 +84,7 @@
<div style="display:inline-block;padding-top:3px"> <div style="display:inline-block;padding-top:3px">
<label>{$lang->display_yes}</label> <label>{$lang->display_yes}</label>
<select class="multiorder_selected" size="8" multiple="multiple" style="vertical-align:top;margin-bottom:5px"> <select class="multiorder_selected" size="8" multiple="multiple" style="vertical-align:top;margin-bottom:5px">
<option loop="$var->options => $key, $val" cond="$var->init_options[$key]" value="{$key}" default="true"|cond="$var->default_options[$key]">{$val}</option> <option loop="$var->options => $key, $val" cond="!empty($var->init_options[$key])" value="{$key}" default="true"|cond="!empty($var->default_options[$key])">{$val}</option>
</select> </select>
<br> <br>
<button type="button" class="x_btn multiorder_up" style="margin:0 -5px 0 0;border-radius:2px 0 0 2px">{$lang->cmd_move_up}</button> <button type="button" class="x_btn multiorder_up" style="margin:0 -5px 0 0;border-radius:2px 0 0 2px">{$lang->cmd_move_up}</button>

View file

@ -21,7 +21,7 @@
</div> </div>
<div id="content" class="x_modal-body"> <div id="content" class="x_modal-body">
<p>{$widget_info->description} {$lang->about_widget_code_in_page}</p> <p>{$widget_info->description} {$lang->about_widget_code_in_page}</p>
<form cond="$type=='faceoff'" class="x_form-horizontal"> <form cond="isset($type) && $type === 'faceoff'" class="x_form-horizontal">
<input type="hidden" name="module" value="widget" /> <input type="hidden" name="module" value="widget" />
<input type="hidden" name="type" value="faceoff" /> <input type="hidden" name="type" value="faceoff" />
<input type="hidden" name="act" value="dispWidgetGenerateCodeInPage" /> <input type="hidden" name="act" value="dispWidgetGenerateCodeInPage" />

View file

@ -28,9 +28,9 @@
</div> </div>
<div class="x_modal-body x_form-horizontal"> <div class="x_modal-body x_form-horizontal">
<a href="{getUrl('widgetstyle','none')}" class="widgetStyle"><img src="images/widgetstyle_none.gif" title="{$lang->notuse}" /></a> <a href="{getUrl('widgetstyle','none')}" class="widgetStyle"><img src="images/widgetstyle_none.gif" title="{$lang->notuse}" /></a>
<a loop="$widgetStyle_list => $key, $widgetStyle" cond="$widgetStyle->preview" href="{getUrl('widgetstyle',$widgetStyle->widgetStyle)}" class="widgetStyle <!--@if($widgetStyle->widgetStyle==$widgetstyle)-->selected<!--@end-->"><img src="{getUrl()}{$widgetStyle->preview}" title="{$widgetStyle->title}" /><span>{$widgetStyle->title}</span></a> <a loop="$widgetStyle_list => $key, $widgetStyle" cond="$widgetStyle->preview" href="{getUrl('widgetstyle',$widgetStyle->widgetStyle)}" class="widgetStyle <!--@if($widgetStyle->widgetStyle == ($widgetstyle ?? ''))-->selected<!--@end-->"><img src="{getUrl()}{$widgetStyle->preview}" title="{$widgetStyle->title}" /><span>{$widgetStyle->title}</span></a>
<block cond="$widgetstyle_info"> <block cond="$widgetstyle_info">
<h2>{$widgetstyle_info->title} ver {$widgetstyle_info->version}</h2> <h2>{$widgetstyle_info->title} ver {$widgetstyle_info->version}</h2>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label">{$lang->description}</label> <label class="x_control-label">{$lang->description}</label>
@ -52,45 +52,46 @@
{zdate($widgetstyle_info->date,'Y-m-d')} {zdate($widgetstyle_info->date,'Y-m-d')}
</div> </div>
</div> </div>
{@ $group = ''; $not_first = false; $suggestion_id = 0; }
<block loop="$widgetstyle_info->extra_var => $id, $var"> <block loop="$widgetstyle_info->extra_var => $id, $var">
{@$suggestion_id++} {@ $suggestion_id++; }
<block cond="!$not_first && !$var->group"><section class="section"></block> <block cond="!$not_first && !$var->group"><section class="section"></block>
<block cond="$group != $var->group"> <block cond="$group != $var->group">
<block cond="$not_first"></section></block> <block cond="$not_first"></section></block>
<h1>{$var->group}</h1> <h1>{$var->group}</h1>
<section class="section"> <section class="section">
{@$group = $var->group} {@ $group = $var->group; }
</block> </block>
{@$not_first = true} {@ $not_first = true; }
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label" for="{$id}"|cond="$var->type!='text'&&$var->type!='textarea'" for="lang_{$id}"|cond="$var->type=='text'||$var->type=='textarea'">{$var->name}</label> <label class="x_control-label" for="{$id}"|cond="$var->type!='text'&&$var->type!='textarea'" for="lang_{$id}"|cond="$var->type=='text'||$var->type=='textarea'">{$var->name}</label>
<div class="x_controls extra_vars"> <div class="x_controls extra_vars">
<div cond="$var->type == 'text'"> <div cond="$var->type == 'text'">
<input type="text" name="{$id}" value="" class="lang_code" /> <input type="text" name="{$id}" value="{$var->default}" class="lang_code" />
</div> </div>
<input cond="$var->type == 'color'" type="text" name="{$id}" class="rx-spectrum" /> <input cond="$var->type == 'color'" type="text" name="{$id}" value="{$var->default}" class="rx-spectrum" />
<div cond="$var->type == 'textarea'"> <div cond="$var->type == 'textarea'">
<textarea name="{$id}" rows="8" cols="42" class="lang_code"></textarea> <textarea name="{$id}" rows="8" cols="42" class="lang_code">{$var->default}</textarea>
</div> </div>
<select cond="$var->type == 'select'" name="{$id}"> <select cond="$var->type == 'select'" name="{$id}">
<option loop="$var->options => $key, $val" value="{$key}">{$val}</option> <option loop="$var->options ?? [] => $key, $val" value="{$key}" selected="selected"|cond="$var->default !== '' && $key == $var->default">{$val}</option>
</select> </select>
<block cond="$var->type == 'filebox'"> <block cond="$var->type == 'filebox'">
<input type="hidden" name="{$id}" /> <input type="hidden" name="{$id}" />
<a href="#modalFilebox" class="modalAnchor filebox">{$lang->cmd_select}</a> <a href="#modalFilebox" class="modalAnchor filebox">{$lang->cmd_select}</a>
{@$use_filebox = TRUE} {@$use_filebox = TRUE}
</block> </block>
<label loop="$var->options => $key, $val" cond="$var->type == 'radio'"> <label loop="$var->options ?? [] => $key, $val" cond="$var->type == 'radio'">
<input type="radio" name="{$id}" id="{$id}_{$key}" value="{$key}" > {$val} <input type="radio" name="{$id}" id="{$id}_{$key}" value="{$key}" > {$val}
</label> </label>
<label loop="$var->options => $key, $val" cond="$var->type == 'checkbox'"> <label loop="$var->options ?? [] => $key, $val" cond="$var->type == 'checkbox'">
<input type="checkbox" name="{$id}" id="{$id}_{$key}" value="{$key}" > {$val} <input type="checkbox" name="{$id}" id="{$id}_{$key}" value="{$key}" > {$val}
</label> </label>
<span class="x_help-block">{$var->description}</span> <span class="x_help-block">{$var->description}</span>

View file

@ -600,25 +600,30 @@ class WidgetController extends Widget
{ {
foreach($args as $key => $val) foreach($args as $key => $val)
{ {
$val = (string)$val;
if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue; if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue;
if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val);
$attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
} }
} }
$oWidgetController = getController('widget'); $widget_content_header = vsprintf(
'<div class="rhymix_content xe_content widgetOutput ' . ($args->css_class ?? '') . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>'.
$widget_content_header = sprintf(
'<div class="rhymix_content xe_content widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>'.
'<div class="widgetResize"></div>'. '<div class="widgetResize"></div>'.
'<div class="widgetResizeLeft"></div>'. '<div class="widgetResizeLeft"></div>'.
'<div class="widgetBorder">'. '<div class="widgetBorder">'.
'<div style="%s">',$args->widgetstyle, '<div style="%s">',
[
$args->widgetstyle ?? '',
$style, $style,
$args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, $args->widget_padding_left,
$args->widget_padding_right,
$args->widget_padding_top,
$args->widget_padding_bottom,
$args->document_srl, $args->document_srl,
implode(' ',$attribute), implode(' ', $attribute),
$inner_style); $inner_style,
]);
$widget_content_body = $body; $widget_content_body = $body;
$widget_content_footer = sprintf('</div>'. $widget_content_footer = sprintf('</div>'.
@ -642,11 +647,21 @@ class WidgetController extends Widget
} }
} }
$widget_content_header = sprintf( $widget_content_header = vsprintf(
'<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >'. '<div class="widgetOutput ' . ($args->css_class ?? '') . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >'.
'<div class="widgetBoxResize"></div>'. '<div class="widgetBoxResize"></div>'.
'<div class="widgetBoxResizeLeft"></div>'. '<div class="widgetBoxResizeLeft"></div>'.
'<div class="widgetBoxBorder"><div class="nullWidget" style="%s">',$args->widgetstyle,$style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,implode(' ',$attribute),$inner_style); '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">',
[
$args->widgetstyle ?? '',
$style,
$widget_padding_top,
$widget_padding_right,
$widget_padding_bottom,
$widget_padding_left,
implode(' ', $attribute),
$inner_style,
]);
$widget_content_body = $widgetbox_content; $widget_content_body = $widgetbox_content;
@ -667,12 +682,20 @@ class WidgetController extends Widget
} }
} }
$widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'. $widget_content_header = vsprintf('<div class="widgetOutput ' . ($args->css_class ?? '') . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'.
'<div class="widgetResize"></div>'. '<div class="widgetResize"></div>'.
'<div class="widgetResizeLeft"></div>'. '<div class="widgetResizeLeft"></div>'.
'<div class="widgetBorder">',$args->widgetstyle,$style, '<div class="widgetBorder">',
$widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, [
$widget, implode(' ',$attribute)); $args->widgetstyle ?? '',
$style,
$widget_padding_top,
$widget_padding_right,
$widget_padding_bottom,
$widget_padding_left,
$widget,
implode(' ', $attribute),
]);
$widget_content_body = sprintf('<div style="%s">%s</div>',$inner_style, $widget_content); $widget_content_body = sprintf('<div style="%s">%s</div>',$inner_style, $widget_content);

View file

@ -155,7 +155,7 @@ class WidgetModel extends Widget
public static function getWidgetStyleInfo($widgetStyle) public static function getWidgetStyleInfo($widgetStyle)
{ {
// Check the widget style path. // Check the widget style path.
$widgetStyle = preg_replace('/[^a-zA-Z0-9-_]/', '', $widgetStyle); $widgetStyle = preg_replace('/[^a-zA-Z0-9-_]/', '', (string)$widgetStyle);
$widgetStyle_path = self::getWidgetStylePath($widgetStyle); $widgetStyle_path = self::getWidgetStylePath($widgetStyle);
if (!$widgetStyle_path) if (!$widgetStyle_path)
{ {

View file

@ -246,7 +246,7 @@
<name xml:lang="tr">UL (list)</name> <name xml:lang="tr">UL (list)</name>
</options> </options>
</var> </var>
<var id="list_count" type="text"> <var id="list_count" type="text" default="5">
<name xml:lang="ko">목록수</name> <name xml:lang="ko">목록수</name>
<name xml:lang="zh-CN">目录数</name> <name xml:lang="zh-CN">目录数</name>
<name xml:lang="jp">リスト数</name> <name xml:lang="jp">リスト数</name>
@ -266,7 +266,7 @@
<description xml:lang="zh-TW">設置要顯示的目錄數。(預設是5個)</description> <description xml:lang="zh-TW">設置要顯示的目錄數。(預設是5個)</description>
<description xml:lang="tr">Görüntülenecek yazıların sayısını ayarlayabilirsiniz. (varsayılan değer 5'tir)</description> <description xml:lang="tr">Görüntülenecek yazıların sayısını ayarlayabilirsiniz. (varsayılan değer 5'tir)</description>
</var> </var>
<var id="cols_list_count" type="text"> <var id="cols_list_count" type="text" default="5">
<name xml:lang="ko">가로 이미지 수</name> <name xml:lang="ko">가로 이미지 수</name>
<name xml:lang="jp">横並びイメージ数</name> <name xml:lang="jp">横並びイメージ数</name>
<name xml:lang="zh-CN">横向图片数</name> <name xml:lang="zh-CN">横向图片数</name>