123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778 |
- <?php
- namespace Manage\Src\Lib;
- use Dever;
- class Input
- {
- public static function __callStatic($name, $param = array())
- {
- $method = '_' . $name;
- $result = call_user_func_array(array(__CLASS__, $method), $param);
- if ($result && is_string($result) && $name != 'pageLeft') {
- if (layadmin()) {
- if (strstr($result, '<select')) {
- $result = str_replace('form-control', 'form-control layui-input layui-select', $result);
- $result = str_replace('<select', '<select lay-ignore ', $result);
- } elseif (strstr($result, 'radio')) {
- $result = str_replace('form-control', 'form-control layui-radio', $result);
- } elseif (strstr($result, 'checkbox')) {
- $result = str_replace('form-control', 'form-control layui-checkbox', $result);
- } else {
- $result = str_replace('form-control', 'form-control layui-input', $result);
- }
-
- if (isset($param[1]) && !$param[1]) {
- $result = '<div class="layui-inline"><div class="layui-input-inline">'.$result.'</div></div>';
- } else {
- $result = '<div>'.$result.'</div>';
- }
- } else {
- if (isset($param[1])) {
- $result = '<div style="display:inline;margin-right: 10px;">'.$result.'</div>';
- } else {
- $result = '<div>'.$result.'</div>';
- }
- }
-
- }
- return $result;
- }
- /**
- * 地图
- *
- * @return string
- */
- public static function _map($param)
- {
- $url = Dever::url('map', 'manage');
- $html = self::text($param);
- $id = $param['name'] . '_value';
- $iframe_id = $id . '_map';
- $html .= '<iframe id="'.$iframe_id.'" src="'.$url.'" style="margin-top:10px;display: block;" width="800" height="500" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" onload="mapLoad()"></iframe>';
- $html .= '<script>$(function()
- {
- $("#'.$id.'").blur(function()
- {
- layui.layer.msg("搜索中...");
- $("#'.$iframe_id.'")[0].contentWindow.search($(this).val());
- });
- });
- function _mapLoad(){
- if ($("#'.$id.'").val()) {
- $("#'.$iframe_id.'")[0].contentWindow.showMaker($("#'.$id.'").val());
- }
- }
- function _closeMsg() {
- layui.layer.closeAll();
- }
- function _setMap(x, y, z) {
- var val = $("#'.$id.'").val();
- if (val) {
- var temp = val.split(",");
- val = temp[0];
- }
- $("#'.$id.'").val(val + "," + x + "," + y + "," + z);
- }</script>';
- return $html;
- }
- /**
- * desc
- *
- * @return string
- */
- public static function _modal($modal, $desc)
- {
- return '<a href="javascript:;" onclick="showAlert($(this).next().html());initLayui();">' . $modal . '</a><div style="display:none;">' . $desc . '</div>';
- }
- /**
- * desc
- *
- * @return string
- */
- public static function _desc($desc)
- {
- return '';
- return $desc;
- }
- /**
- * hr 分割线
- *
- * @return string
- */
- public static function _hr($param)
- {
- if (layadmin()) {
-
- $col = '';
- if (isset($param['right'])) {
- $col = '</div><div class="layui-col-md6">';
- }
- $html = '</div></div></div>'.$col.'<div class="layui-card"><div class="layui-card-header">[' . $param['name'] . ']</div><div class="layui-card-body"><div>';
- return $html;
- }
- return '<div class="dever_form_hr ' . (isset($param['class']) ? $param['class'] : '') . '" ' . (isset($param['attr']) ? $param['attr'] : '') . '>' . $param['name'] . '</div>';
- }
- /**
- * cue
- *
- * @return string
- */
- public static function _cue($param)
- {
- $param['cue'] = isset($param['cue']) ? $param['cue'] : '';
- if (strpos($param['name'], '-') !== false) {
- $temp = explode('-', $param['name']);
- $param['name'] = $temp[0];
- $param['cue'] = $temp[1];
- } elseif (strpos($param['name'], '(') !== false) {
- $temp = explode('(', $param['name']);
- $param['name'] = $temp[0];
- $param['cue'] = str_replace(')', '', $temp[1]);
- } elseif (strpos($param['name'], '(') !== false) {
- $temp = explode('(', $param['name']);
- $param['name'] = $temp[0];
- $param['cue'] = str_replace(')', '', $temp[1]);
- }
- return $param;
- }
- /**
- * pageLeft
- *
- * @return string
- */
- public static function _pageLeft($param)
- {
- $param = self::cue($param);
- if ($param['cue']) {
- $param['cue'] = '<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[' . $param['cue'] . ']</span>';
- }
- $class = '';
- if (layadmin()) {
- //$class = 'layui-form-label';
- }
- $html = '<div><label style="font-size:14px;font-weight:bold;" class="'.$class.'">' . $param['name'] . $param['cue'] . '</label></div>';
- return $html;
- }
- /**
- * textarea
- *
- * @return string
- */
- public static function _textarea($param)
- {
- return '<textarea style="height:100px;" update_type="value" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" >' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
- return '<textarea style="height:100px;" update_type="value" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
- }
- /**
- * image
- *
- * @return string
- */
- public static function _image($param)
- {
- if (isset($param['value']) && $param['value']) {
- $pic = 'src="' . $param['value'] . '"';
- } elseif (isset($param['places'])) {
- $pic = 'src="http://placehold.it/' . $param['place'] . '"';
- } else {
- $pic = 'src="" style=display:none;';
- }
- return '<input type="button" style="width:10%;" class="form-control image_upload" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="选择文件"/>
- <div style="margin:10px;">
- <img ' . $pic . ' onclick="picDel($(this), \'' . $param['name'] . '_' . $param['index'] . '\', 1);" class="update_value" update_type="src" id="show_' . $param['name'] . '_' . $param['index'] . '" width="150" /></div>
- <input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">';
- }
- /**
- * images
- *
- * @return string
- */
- public static function _images($param)
- {
- $pic = '';
- if (isset($param['value'])) {
- $temp = explode(',', $param['value']);
- foreach ($temp as $k => $v) {
- $pic .= '<a href="javascript:;" title="点此删除" onclick="picDel($(this), \'' . $param['name'] . '_' . $param['index'] . '\')"><img src="' . $v . '" id="show_' . $param['name'] . '_' . $param['index'] . '_' . $k . '" width="150" style="margin-left:5px;" alt="点此删除"/></a>';
- }
- }
- return '<input type="button" style="width:10%;" class="form-control image_upload" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="选择文件"/>
- <div style="margin:10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $pic . '</div>
- <input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">';
- }
- /**
- * upload
- *
- * @return string
- */
- public static function _upload($param)
- {
- return '<input type="button" style="width:10%;" class="form-control image_upload" t="file" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="选择文件"/>
- <div style="margin-top:10px;"><input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">
- </div>';
- //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
- }
- /**
- * upload
- *
- * @return string
- */
- public static function _uploads($param)
- {
- $file = '';
- if (isset($param['value']) && $param['value']) {
- $temp = explode(',', $param['value']);
- foreach ($temp as $k => $v) {
- $upload = Dever::load('upload/file-check', array('option_key' => md5($v)));
- $file .= '<li><a href="' . $v . '" rel="box" title="点此下载" >' . $upload['source_name'] . '</a> <a href="javascript:;" style="color:red;" title="点此删除" onclick="fileDel($(this), \'' . $param['name'] . '_' . $param['index'] . '\')">[删除]</a></li>';
- }
- }
- return '<input type="button" style="width:10%;" class="form-control image_upload" t="file" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" value="选择文件"/>
- <ul style="margin:10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $file . '</ul>
- <input type="hidden" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">';
- //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
- }
- /**
- * editor
- *
- * @return string
- */
- public static function _editor($param)
- {
- return '<textarea style="width:100%;display: inline" update_type="value" class=" update_value editor" id="' . $param['name'] . '_editor" key="' . (isset($param['key']) ? $param['key'] : 1) . '" name="' . $param['name'] . '" rows="18" cols="100" >' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
- }
- /**
- * markdown
- *
- * @return string
- */
- public static function _markdown($param)
- {
- return '<textarea style="height:300px;" update_type="value" key="' . (isset($param['key']) ? $param['key'] : 1) . '" class="maze-note update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" >' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
- }
- /**
- * selector
- *
- * @return string
- */
- public static function _selector($param, $type = '')
- {
- $html = '';
- if (isset($param['key']) && strpos($param['key'], '.css') !== false) {
- $param['key'] = '<link rel="stylesheet" href="' . $param['key'] . '"/>';
- }
- if (isset($param['option'])) {
- foreach ($param['option'] as $k => $v) {
- $check = '';
- if ((isset($param['value']) && $param['value'] == $k) || (empty($param['value']) && isset($param['default']) && $param['default'] == $k)) {
- $check = 'checked';
- }
- if (is_array($v)) {
- $value = $v['name'];
- } else {
- $value = $v;
- }
- $html .= '<a href="javascript:;" onclick="selector($(this))" class="' . $param['name'] . '_selector selector" data-check="' . $check . '" data-name="' . $param['name'] . '" data-value="' . $k . '">' . $value . '</a> ';
- }
- $html .= self::hidden($param);
- }
- return '<div class="am-btn-group" >' . $html . '</div>';
- }
- /**
- * radio
- *
- * @return string
- */
- public static function _radio($param, $type = '')
- {
- $html = '';
- if (isset($param['option'])) {
- if (isset($param['option']['state']) && $param['option']['state'] >= 1) {
- if (isset($param['value'])) {
- $param['value'] = explode(',', $param['value']);
- } else {
- $param['value'] = array();
- }
- # 处理比较复杂的多维数组
- unset($param['option']['state']);
- $j = -1;
- foreach ($param['option'] as $k => $v) {
- $check = '';
- if (isset($param['update_parent'])) {
- $input_type = $param['update_parent'];
- } else {
- $input_type = $param['update'];
- }
- //{check}
- $html .= '<input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '"/> -----【' . $v['name'] . '】----- <br />';
- $span = array('', '');
- if (isset($v['child']) && $v['child']) {
- //$i = 1;
-
- $html .= '<ul style="list-style:none;margin:0px;display:;" class="">';
- foreach ($v['child'] as $ki => $vi) {
- if (!is_array($vi)) {
- $temp = $vi;
- $vi = array();
- $vi['name'] = $temp;
- $vi['id'] = $ki;
- }
- if (isset($v['url'])) {
- $span = array('<span class="edit" data-url="' . Dever::url($v['url'] . '?id=' . $vi['id']) . '">', '</span>');
- }
- $check = '';
- $disabled = 'disabled="true"';
- if (isset($param['value']) && in_array($ki, $param['value'])) {
- $check = 'checked';
- $disabled = '';
- $j++;
- } elseif (isset($param['default']) && is_array($param['default']) && (in_array($k . '_' . $ki, $param['default']))) {
- $check = 'checked';
- $disabled = '';
- $j++;
- }
- $input = $input_value = '';
- if (isset($param['update_input'])) {
- if (isset($param['update_input_data']) && isset($param['update_input_data'][$j])) {
- $input_value = $param['update_input_data'][$j];
- if ($disabled) {
- $input_value = '';
- }
- } else {
- $input_value = isset($param['update_input_default']) ? $param['update_input_default'] : '';
- }
- if ($param['update_input']) {
- $input = '[' . $param['update_input'] . ']';
- }
- $input = $input . ': <input class="form-control" name="' . $param['name'] . '_input[]" type="text" value="' . $input_value . '" style="width:20%;margin:5px;display:inline" placeholder="' . $param['update_input'] . '" ' . $disabled . '/>';
- }
- $html .= '<li><input update_type="checked" class="update_value checkbox-checkall-' . $param['name'] . '-'. $k . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $param['update'] . '" name="' . $param['name'] . '[]" value="' . $ki . '" ' . $check . '/> ' . $span[0] . $vi['name'] . $span[1] . ' ' . $input . '</li>';
- //++$i;
- }
- $html .= '</ul>';
- }
- $html .= '<br />';
- }
- } else {
- $js = '';
- if (isset($param['control']) && is_string($param['control'])) {
- //print_r($param);die;
- $js = ' show_id="' . $param['control'] . '" onclick="inputShow($(this), \'' . $param['control'] . '\', \'input\')"';
- } elseif (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $js = $param['bind'][0] . '="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
- $js .= ' onload="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
- }
- $param['parent'] = isset($param['parent']) ? $param['parent'] : '0';
- $param['parent'] .= '_' . $param['name'];
- if ($param['update'] == 'checkbox' && empty($param['checkall'])) {
- $html .= '<input update_type="checked" class="checkbox-checkall ' . $param['name'] . ' update_value" type="' . $param['update'] . '" name="temp_' . $param['name'] . '[]" value="' . $param['parent'] . '"/> 全选 ';
- }
- foreach ($param['option'] as $k => $v) {
- $check = '';
- if (is_array($v)) {
- $value = $v['name'];
- isset($v['id']) && $k = $v['id'];
- } else {
- $value = $v;
- }
- if (isset($param['bit'][$k])) {
- if (isset($param['value']) && ($param['value'] & $k) > 0) {
- $check = 'checked';
- }
- } elseif (isset($param['value'])) {
- if (is_string($param['value']) && strpos(',' . $param['value'] . ',', ',' . $k . ',') !== false) {
- $check = 'checked';
- } elseif (is_array($param['value']) && in_array($k, $param['value'])) {
- $check = 'checked';
- }
- } elseif (isset($param['default'])) {
- if (is_string($param['default']) && strpos(',' . $param['default'], ',' . $k) !== false) {
- $check = 'checked';
- } elseif (is_array($param['default']) && in_array($k, $param['default'])) {
- $check = 'checked';
- }
- }
- $cjs = $js;
- if (isset($param['control']) && is_string($param['control']) && $param['control'] != $param['name']) {
- $cjs = str_replace('update_', '', str_replace($param['control'], $param['name'], $js));
- }
- $html .= '<input update_type="checked" class="autoload checkbox-checkall-' . $param['parent'] . ' ' . $param['name'] . ' update_value ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $param['update'] . '" name="' . $param['name'] . '[]" value="' . $k . '" ' . $check . ' ' . $cjs . '/> ' . $value . ' ';
- if (isset($param['bind'])) {
- //$html .= '<script>$(document).ready(function(){$(".checkbox-checkall-'.$param['parent'].'").click();})</script>';
- }
- }
- }
- }
- return '<div class="am-btn-group" >' . $html . '</div>';
- }
- /**
- * group
- *
- * @return string
- */
- public static function _group($param, $class = '', $hidden = '', $change = '')
- {
- $html = $class ? '<div class="' . $class . '">' : '';
- $html .= $hidden . '<select class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" ' . $change . '>';
- if (isset($param['option'])) {
- foreach ($param['option'] as $k => $v) {
- if ($v['id'] <= 0) {
- $html .= '<option value="0" selected>' . $v['name'] . '</option>';
- } else {
- $html .= '<optgroup label="' . $v['name'] . '">';
- if (isset($v['child'])) {
- foreach ($v['child'] as $k1 => $v1) {
- $selected = '';
- if ((isset($param['value']) && $param['value'] == $v1['id']) || (empty($param['value']) && isset($param['default']) && $param['default'] == $v1['id'])) {
- $selected = 'selected';
- }
- $html .= '<option value="' . $v1['id'] . '" ' . $selected . '>' . $v1['name'] . '</option>';
- }
- }
- $html .= '</optgroup>';
- }
- }
- }
- $html .= '</select>';
- $html .= $class ? '</div>' : '';
- return $html;
- }
- /**
- * linkage select 多级联动
- *
- * @return string
- */
- public static function _linkage($param, $class = '', $hidden = '', $change = '')
- {
- $div = 'div';
- $w = 'width:20%;';
- if ($class == 'span') {
- $div = 'span';
- $w = '';
- }
- if (!isset($param['search_state'])) {
- $param['search_state'] = false;
- }
- # 当前级别
- $level = 1;
- # 传入的参数
- $level_param = '';
- if (isset($param['linkage'])) {
- $level_param = $param['linkage'];
- }
-
- $id = 'dever-linkage-' . $param['name'];
- $html = '<' . $div . ' class="' . $class . '" id="' . $id . '" >';
- # 默认值
- if (isset($param['value']) && is_array($param['value'])) {
- $param['value'] = implode(',', $param['value']);
- }
- $html .= '<script>function _linkage_' . $param['name'] . '(level){select_linkage(level, "' . $id . '","' . $param['option'] . '", "' . $param['name'] . '", "' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '", "' . (isset($param['valid']) ? $param['valid'] : '') . '", "' . $w . '", false, "'.$param['search_state'].'", "'.$level_param.'")};';
- $html .= '$(document).ready(function(){linkage_' . $param['name'] . '(' . $level . ')});</script>';
- $html .= '</' . $div . '>';
- return $html;
- }
- /**
- * select
- *
- * @return string
- */
- public static function _select($param, $class = '', $hidden = '', $change = '')
- {
- $html = $class ? '<div class="' . $class . '">' : '';
- $child_class = '';
- if (isset($param['child'])) {
- $child_param['name'] = 'update_' . $param['child_name'];
- isset($param['value']) && $param['value'] = $param['value'];
- isset($param['child_value']) && $child_param['value'] = $param['child_value'];
- $change = 'style="width:45%" id="' . $param['name'] . '" data-child="' . $child_param['name'] . '_child" ';
- $child_class = ' change';
- //$param['name'] .= '_parent';
- }
- if (isset($param['control']) && is_string($param['control'])) {
- //print_r($param);die;
- $change = ' show_id="' . $param['control'] . '" onchange="inputShow($(this), \'' . $param['control'] . '\')"';
- } elseif (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $change = $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- $child_class .= ' change';
- }
- $html .= $hidden . '<select class="update_value form-control ' . $child_class . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" ' . $change . '>';
- if (isset($param['option'])) {
- if (isset($param['lang']) && $param['lang']) {
- $html .= '<option value="0" selected>' . $param['lang'] . '</option>';
- }
- foreach ($param['option'] as $k => $v) {
- if (is_array($v)) {
- $value = $v['name'];
- isset($v['id']) && $k = $v['id'];
- } else {
- $value = $v;
- }
- $check = '';
- if ((isset($param['value']) && $param['value'] == $k) || (isset($param['bit'][$k]) && isset($param['value']) && ($param['value'] & $k) > 0) || (empty($param['value']) && isset($param['default']) && $param['default'] == $k)) {
- $check = 'selected';
- }
- $parent = '';
- if (isset($param['parent']) && $param['parent'] && isset($v[$param['parent']])) {
- $parent = $v[$param['parent']];
- }
- if (is_array($v)) {
- $value = isset($v['name']) ? $v['name'] : $v['lang'];
- } else {
- $value = $v;
- }
- $html .= '<option parent="'.$parent.'" value="' . $k . '" ' . $check . '>' . $value . '</option>';
- }
- }
- $html .= '</select>';
- if (isset($param['child'])) {
- $child = $child_param['name'];
- $hidden = self::hidden(array('name' => $child, 'class' => $child . '_child_value'));
- foreach ($param['child'] as $k => $v) {
- $child_param['name'] = 'child-' . $k;
- $child_param['option'] = $v;
- $html .= self::select($child_param, $child . '_child ' . $child . '_child_' . $k . '" parent="' . $k . '" style="display:none;margin-top: -35px;margin-left: 47%;"', $hidden);
- }
- }
- $html .= $class ? '</div>' : '';
- return $html;
- }
- /**
- * radio
- *
- * @return string
- */
- public static function _checkbox($param)
- {
- return self::radio($param);
- }
- /**
- * text
- *
- * @return string
- */
- public static function _text($param, $class = '')
- {
- if ($class) {
- return '<div class="">' . self::text($param, false) . '</div>';
- } else {
- $auto = $input = '';
- $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
- if (isset($param['autocomplete'])) {
- if (empty($param['autocomplete'][1])) {
- $param['autocomplete'][1] = 'value';
- }
- if ($param['autocomplete'][1] == 'id') {
- $input = self::hidden(array('name' => $param['name'], 'value' => $value));
- $input = '<script>var autocomplete_value = [];</script>';
- if (isset($param['autocomplete'][2]) && $value) {
- # 重新定义value
- $value = Dever::load($param['autocomplete'][2], $value);
- if (is_array($value)) {
-
- $html = '<div style="margin-top: 10px;width: 60%;overflow: auto;max-height: 500px;"><table id="'.$param['name'].'_value_show" class="table table-small-font table-bordered">';
- foreach ($value as $k => $v) {
- $link = '';
- $attr = '';
- $pic = '';
- if (isset($v['pic']) && $v['pic']) {
- $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a> ';
- }
- if (isset($v['link']) && $v['link']) {
- $link = $v['link'];
- $attr = ' target="_blank"';
- }
- $html .= '<tr><td width="90%"><input type="checkbox" checked name="'.$param['name'].'[]" value="'.$v['id'].'"/> '.$pic.'<a href="'.$link.'" '.$attr.' title="'.$v['value'].'">'.$v['value'].'</td><td width="10%"><a href="javascript:;" onclick="autocomplete_del($(this), \''.$param['name'].'_value\', \''.$v['id'].'\')">[删除]</a></td></tr><script>autocomplete_value.push('.$v['id'].');</script>';
- }
- $html .= '</table></div>';
- $input .= $html;
- $value = '';
- }
- }
- $param['name'] = $param['name'] . '_temp';
- }
- $auto = 'complete="' . Dever::url($param['autocomplete'][0]) . '" complete_callback="' . $param['autocomplete'][1] . '" ';
- }
- if (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $auto .= $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- $auto .= ' onload="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- }
- if (isset($param['autocomplete'][3])) {
- $auto .= ' complete_cate="' . $param['autocomplete'][3] . '" ';
- }
- return '<input ' . $auto . ' type="' . (isset($param['update']) ? $param['update'] : 'text') . '" class="autoload_text update_value ' . (isset($param['class']) ? $param['class'] : 'form-control') . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" value="' . $value . '" name="' . $param['name'] . '" id="' . $param['name'] . '_value" autocomplete="new'.time().'" placeholder="' . (isset($param['placeholder']) ? $param['placeholder'] : '') . '"/>' . $input;
- }
- }
- /**
- * color
- *
- * @return string
- */
- public static function _color($param)
- {
- $param['class'] = 'dever-color form-control';
- $param['update'] = 'text';
- $param['default'] = '#000000';
- return self::text($param, '');
- }
- /**
- * password
- *
- * @return string
- */
- public static function _password($param)
- {
- $param['value'] = '';
- return self::text($param);
- }
- /**
- * hidden
- *
- * @return string
- */
- public static function _hidden($param)
- {
- $param['update'] = 'hidden';
- return self::text($param, '');
- }
- /**
- * time
- *
- * @return string
- */
- public static function _time($param)
- {
- return '<input type="text" value="' . ((isset($param['value']) && $param['value'] > 0) ? date('Y-m-d', $param['value']) : ((isset($param['default']) && $param['default'] > 0) ? date('Y-m-d', $param['default']) : '')) . '" placeholder="' . (isset($param['lang']) ? $param['lang'] : '') . '" name="' . $param['name'] . '" class="manage_time update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" autocomplete="off"/>';
- }
- /**
- * date
- *
- * @return string
- */
- public static function _date($param)
- {
- return '<input type="text" value="' . ((isset($param['value']) && $param['value'] > 0) ? date('Y-m-d H:i:s', $param['value']) : ((isset($param['default']) && $param['default'] > 0) ? date('Y-m-d H:i:s', $param['default']) : '')) . '" placeholder="' . (isset($param['lang']) ? $param['lang'] : '') . '" name="' . $param['name'] . '" class="manage_date update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" autocomplete="off"/>';
- }
- /**
- * div
- *
- * @return string
- */
- public static function _node($param, $type = 'div')
- {
- $result = array('', '');
- foreach ($param as $k => $v) {
- $result[0] .= '<' . $type . ' ' . $v . '>';
- $result[1] .= '</' . $type . '>';
- }
- return $result;
- }
- }
|