mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-18 18:02:15 +09:00
#903 support select, textarea configure at editor components config
This commit is contained in:
parent
a01757706d
commit
43fec02555
2 changed files with 91 additions and 16 deletions
|
|
@ -751,18 +751,77 @@ class editorModel extends editor
|
|||
}
|
||||
|
||||
// List extra variables (text type only for editor component)
|
||||
$extra_vars = $xml_doc->component->extra_vars->var;
|
||||
$extra_vars = $xml_doc->component->extra_vars;
|
||||
if($extra_vars)
|
||||
{
|
||||
if(!is_array($extra_vars)) $extra_vars = array($extra_vars);
|
||||
|
||||
foreach($extra_vars as $key => $val)
|
||||
$extra_var_groups = $extra_vars->group;
|
||||
if(!$extra_var_groups)
|
||||
{
|
||||
$key = $val->attrs->name;
|
||||
$extra_var = new stdClass;
|
||||
$extra_var->title = $val->title->body;
|
||||
$extra_var->description = $val->description->body;
|
||||
$component_info->extra_vars->{$key} = $extra_var;
|
||||
$extra_var_groups = $extra_vars;
|
||||
}
|
||||
if(!is_array($extra_var_groups))
|
||||
{
|
||||
$extra_var_groups = array($extra_var_groups);
|
||||
}
|
||||
|
||||
foreach($extra_var_groups as $group)
|
||||
{
|
||||
$extra_vars = $group->var;
|
||||
if(!is_array($group->var))
|
||||
{
|
||||
$extra_vars = array($group->var);
|
||||
}
|
||||
|
||||
foreach($extra_vars as $key => $val)
|
||||
{
|
||||
if(!$val)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$obj = new stdClass();
|
||||
if(!$val->attrs)
|
||||
{
|
||||
$val->attrs = new stdClass();
|
||||
}
|
||||
if(!$val->attrs->type)
|
||||
{
|
||||
$val->attrs->type = 'text';
|
||||
}
|
||||
|
||||
$obj->group = $group->title->body;
|
||||
$obj->name = $val->attrs->name;
|
||||
$obj->title = $val->title->body;
|
||||
$obj->type = $val->attrs->type;
|
||||
$obj->description = $val->description->body;
|
||||
if($obj->name)
|
||||
{
|
||||
$obj->value = $extra_vals->{$obj->name};
|
||||
}
|
||||
if(strpos($obj->value, '|@|') != FALSE)
|
||||
{
|
||||
$obj->value = explode('|@|', $obj->value);
|
||||
}
|
||||
if($obj->type == 'mid_list' && !is_array($obj->value))
|
||||
{
|
||||
$obj->value = array($obj->value);
|
||||
}
|
||||
|
||||
// 'Select'type obtained from the option list.
|
||||
if($val->options && !is_array($val->options))
|
||||
{
|
||||
$val->options = array($val->options);
|
||||
}
|
||||
|
||||
for($i = 0, $c = count($val->options); $i < $c; $i++)
|
||||
{
|
||||
$obj->options[$i] = new stdClass();
|
||||
$obj->options[$i]->title = $val->options[$i]->title->body;
|
||||
$obj->options[$i]->value = $val->options[$i]->attrs->value;
|
||||
}
|
||||
|
||||
$component_info->extra_vars->{$obj->name} = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,13 +32,29 @@
|
|||
<a href="#" onclick="winopen('{$component->link}');return false;">{$component->link}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group" loop="$component->extra_vars=>$key,$val">
|
||||
<label class="x_control-label">{$val->title}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="{$key}" value="{$val->value}" />
|
||||
<span class="x_help-block">{$val->description}</span>
|
||||
</div>
|
||||
</div>
|
||||
<block cond="count($component->extra_vars)">
|
||||
<block loop="$component->extra_vars => $id, $var">
|
||||
<block cond="$group != $var->group">
|
||||
<h2>{$var->group}</h2>
|
||||
{@$group = $var->group}
|
||||
</block>
|
||||
{@$not_first = true}
|
||||
<div class="x_control-group" cond="!$not_first && $group != $var->group"></div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="{$var->name}"|cond="$var->type != 'textarea'" for="lang_{$var->name}"|cond="$var->type == 'textarea'">{$var->title}</label>
|
||||
<div class="x_controls">
|
||||
<input cond="$var->type == 'text'" type="text" name="{$var->name}" id="{$var->name}" value="{htmlspecialchars($var->value, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)}">
|
||||
<textarea cond="$var->type == 'textarea'" name="{$var->name}" id="{$var->name}" rows="8" cols="42">{htmlspecialchars($var->value, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)}</textarea>
|
||||
<select cond="$var->type == 'select'" name="{$var->name}" id="{$var->name}">
|
||||
<option loop="$var->options => $option" value="{$option->value}" selected="selected"|cond="$var->value == $option->value">{$option->title}</option>
|
||||
</select>
|
||||
<span class="x_help-inline">{nl2br($var->description)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</block>
|
||||
</block>
|
||||
|
||||
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->grant}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue