审查视图

public/themes/admin_simpleboot3/admin/theme/functions.html 9.5 KB
景龙 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
<php>
    if (!function_exists('_parse_vars')) {
        function _parse_vars($vars,$inputName,$level=1,$widget='',$file_id=''){

</php>
<foreach name="vars" item="var" key="varName">
    <fieldset>
        <div class="form-group">
            <present name="var.title">
                <label class="control-label">
                    {$var.title}
                    <notempty name="var.rule.require">
                        <span class="form-required">*</span>
                    </notempty>
                </label>
            </present>
            <switch name="var.type">
                <case value="text">
                    <div class="controls">
                        <present name="var.dataSource">
                            <input type="text" name="{$inputName}[{$varName}_text_]" class="form-control"
                                   onclick="doSelectData(this)"
                                   data-source="{:base64_encode(json_encode($var['dataSource']))}"
                                   data-title="请选择{$var.title}"
                                   value="{$vars[$varName]['valueText']|default=''}">
                            <input type="hidden" name="{$inputName}[{$varName}]" class="form-control"
                                   value="{$vars[$varName]['value']}">
                            <else/>
                            <input type="text" name="{$inputName}[{$varName}]" class="form-control"
                                   value="{$vars[$varName]['value']}">
                        </present>
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="textarea">
                    <div class="controls">
                        <textarea name="{$inputName}[{$varName}]"
                                  class="form-control">{$vars[$varName]['value']}</textarea>
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="date">
                    <div class="controls">
                        <input type="text" name="{$inputName}[{$varName}]" class="form-control js-bootstrap-date"
                               value="{$vars[$varName]['value']}">
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="datetime">
                    <div class="controls">
                        <input type="text" name="{$inputName}[{$varName}]" class="form-control js-bootstrap-datetime"
                               value="{$vars[$varName]['value']}">
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="image">
                    <div class="controls">
                        <input type="hidden" name="{$inputName}[{$varName}]" class="form-control"
                               value="{$vars[$varName]['value']}" id="js-{$widget}{$varName}-input">
                        <div>
                            <a href="javascript:uploadOneImage('图片上传','#js-{$widget}{$varName}-input');">
                                <if condition="empty($vars[$varName]['value'])">
                                    <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                         id="js-{$widget}{$varName}-input-preview"
                                         width="135" style="cursor: pointer"/>
                                    <else/>
                                    <img src="{:cmf_get_image_preview_url($vars[$varName]['value'])}"
                                         id="js-{$widget}{$varName}-input-preview"
                                         width="135" style="cursor: pointer"/>
                                </if>
                            </a>
                            <if condition="!empty($vars[$varName]['value'])">
                                <br>
                                <button id="js-{$widget}{$varName}-button-remove" defaultImage="__TMPL__/public/assets/images/default-thumbnail.png" class="removeImage btn btn-sm" type="button" onclick="removeImage('{$widget}{$varName}')">取消图片</button>
                            </if>
                        </div>
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="number">
                    <div class="controls">
                        <input type="number" name="{$inputName}[{$varName}]" class="form-control"
                               value="{$vars[$varName]['value']}">
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="location">
                    <div class="controls">
                        <input type="text" name="{$inputName}[{$varName}_text_]" class="form-control"
                               onclick="doSelectLocation(this)"
                               data-title="请选择{$var.title}"
                               value="{$vars[$varName]['valueText']|default=''}">
                        <input type="hidden" name="{$inputName}[{$varName}]" class="form-control"
                               value="{$vars[$varName]['value']}">
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="file">
                    <div class="controls">
                        <div class="input-group">
                            <input type="text" name="{$inputName}[{$varName}]" class="form-control"
                                   value="{$vars[$varName]['value']}" id="js-{$widget}{$varName}-input-file">
                            <span class="input-group-addon"> <a href="javascript:uploadOne('图片上传','#js-{$widget}{$varName}-input-file','file');">上传</a></span>
                        </div>
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="color">
                    <div class="controls">
                        <input type="text" name="{$inputName}[{$varName}]" class="form-control js-color"
                               value="{$vars[$varName]['value']}" id="js-color-{$widget}{$varName}">
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>

                <case value="array">
                    <div class="controls">
                        <php>
                            $arrayValueText=is_array($var['value'])&&count($var['value'])>0?count($var['value']).'条数据,点击添加更多...':'';
                        </php>
                        <textarea class="form-control" placeholder="点击添加数据"
                                  onclick="doEditArrayData(this)"
                                  data-var="{$varName}"
                                  data-widget="{$widget}"
                                  data-title="编辑{$var.title}"
                                    data-file_id="{$file_id}">{$arrayValueText}</textarea>
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="select">
                    <div class="controls">
                        <php>
                            $value= $vars[$varName]['value'];
                            $options = $vars[$varName]['options'];
                        </php>
                        <select name="{$inputName}[{$varName}]" class="form-control">
                            <foreach name="options" item="optionItem" key="optionKey">
                                <php>$optionSelected=$optionKey==$value?"selected":"";</php>
                                <option value="{$optionKey}" {$optionSelected}>{$optionItem}
                                </option>
                            </foreach>
                        </select>
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
                <case value="slide">
                    <div class="controls">
                        <input type="text" name="{$inputName}[{$varName}]" class="form-control"
                               value="{$vars[$varName]['value']}">
                        <present name="var.tip">
                            <p class="help-block">{$var.tip}</p>
                        </present>
                    </div>
                </case>
            </switch>
        </div>
    </fieldset>
</foreach>

<php>
        }
    }
</php>