| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974 | <?php// +----------------------------------------------------------------------// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]// +----------------------------------------------------------------------// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.// +----------------------------------------------------------------------// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )// +---------------------------------------------------------------------// | Author: Dean <zxxjjforever@163.com>// +----------------------------------------------------------------------use cmf\view\Filter;use cmf\view\Index;use huo\model\menu\AdminMenuModel;use huolib\tool\StrUtils;function view_edit($url) {    return Index::edit($url);}function view_delete($url) {    return Index::delete($url);}function view_img($url, $width = '40') {    $url = cmf_get_image_preview_url($url);    return Index::img($url, $width);}function view_btn_ajax($url, $class = 'btn btn-xs btn-yellow js-ajax-dialog-btn') {    return Index::linkDialog($url);}function view_btn($url) {    return Index::img($url);}function view_copy($url, $class = '') {    return Index::copy($url, $class);}function filter_button() {    return Filter::button(['title' => lang('search'), 'type' => 'search']);}function filter_button_clear($url = '') {    return Filter::button(['title' => lang('clear'), 'type' => 'clear', 'uri' => $url]);}function button_export() {    return Index::exportData();}/** * 输出文本框 * * @param string $name        字段名称 * @param string $value       字段值 * @param string $placeholder 字段提示 * * @return:string */function filter_text($name, $value = '', $placeholder = '') {    return Filter::text($name, $value, $placeholder);}/** * 设置游戏实名认证状态 * * @param int $auth_status 实名认证状态1为关闭,2为开启强制,3为开启不强制 * * @return: */function select_identify($auth_status) {    return \huoIdentify\view\Index::selectIdentify($auth_status);}/** * 列表编辑操作 * * @param string|int $id_or_url 传入ID或者链接 * * @param bool       $new_frame 是否弹框 * @param int        $width     弹框宽度 * @param int        $height    弹框高度 * * @return string */function action_edit($id_or_url, $new_frame = false, $width = 800, $height = 500) {    if (is_numeric($id_or_url)) {        $_url = url('edit', ['id' => $id_or_url]);        $_auth_url = request()->module().'/'.request()->controller().'/edit';    } else {        $_url = $id_or_url;        $_auth_url = $id_or_url;        $name = explode('/', $id_or_url);        if (isset($name[3])) {            $_auth_url = $name[1].'/'.$name[2].'/'.$name[3];        }    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_auth_url);    if (false == $_auth) {        return '';    }    if ($new_frame) {        return \cmf\view\Index::linkOpenIframeDialog(            $_url, lang('EDIT'), '<span class="text-info"><i class="fa fa-pencil"></i></span>', $width, $height,            'btn-xs btn-link', lang('EDIT')        );    } else {        return \cmf\view\Index::edit($_url);    }}/** * 列表页新增入口 * * @param string $lang_key   语言KEY * @param string $add_or_url 新增 * * @param bool   $new_frame  是否弹框 * @param int    $width      弹框宽度 * @param int    $height     弹框高度 * * @return string */function action_add($lang_key, $add_or_url = '', $new_frame = true, $width = 800, $height = 500) {    if (empty($add_or_url) || 'add' == $add_or_url) {        $_url = url('add');        $_auth_url = request()->module().'/'.request()->controller().'/add';    } else {        $_url = $add_or_url;        $_auth_url = $add_or_url;    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_auth_url);    if (false == $_auth) {        return '';    }    if (empty($lang_key)) {        $_lang = lang('ADD');    } else {        $_lang = lang($lang_key);    }    if (true == $_auth) {        if (true == $new_frame) {            return \cmf\view\Index::linkOpenIframeDialog(                $_url, $_lang, '<i class="fa fa-plus"></i>'.$_lang, $width, $height, 'btn-success', $_lang            );        } else {            return '<a class="btn btn-success" href="'.$_url.'"><i class="fa fa-plus"></i> '.$_lang.'</a>';        }    }    return '';}/** * 列表删除操作 * * @param string|int $id_or_url 传入ID或者链接 * * @return string */function action_delete($id_or_url) {    if (is_numeric($id_or_url)) {        $_url = url('delete', ['id' => $id_or_url]);        $_auth_url = request()->module().'/'.request()->controller().'/delete';    } else {        $_url = $id_or_url;        $_auth_url = $id_or_url;    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_auth_url);    if (false == $_auth) {        return '';    }    return \cmf\view\Index::delete($_url);}/** * 列表状态操作 * * @param        $id_or_url * @param  int   $current_value      目前值 * @param  int   $value              目标值 * @param string $lang_key           变化的值 * @param string $current_status_str 目前状态名称 * @param string $name               字段 * @param string $func               函数 * * @return string */function action_status(    $id_or_url, $current_value, $value, $lang_key, $current_status_str, $name = 'status', $func = 'setStatus') {    if (is_numeric($id_or_url)) {        $_url = url($func, ['id' => $id_or_url, $name => $value, 'field' => $name]);    } else {        $_url = $id_or_url;    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    switch ($current_value) {        case 1:            $_class = 'btn-default';            break;        case 2:            $_class = 'btn-success';            break;        case 3:            $_class = 'btn-primary';            break;        default:            $_class = 'btn-info';            break;    }    $_lang_key = $lang_key;    $_target_status_str = lang($_lang_key);    return \cmf\view\Index::link(        $_url, '', '', 'btn btn-xs '.$_class.' js-ajax-dialog-btn',        lang('CONFIRM').$_target_status_str.'?', $current_status_str, ''    );}function view_param($param, $title = '') {    if (empty($param)) {        return '';    }    if (false == is_string($param)) {        $param = json_encode($param);    }    $_title = $title;    if (empty($title)) {        $_title = mb_substr($param, 0, 50);        if (strlen($_title) > 50) {            $_title .= '...';        }    }    $_html        = <<<EOF            <div class="action-buttons">                {$title}                <a href="javascript:;" data-toggle="tooltip" title='{$_title}' onclick="showParam(this)">                    <span class="text-success"><i class="fa fa-file-text"></i></span>                    <div class="content" style="display: none">{$param}</div>                </a>            </div>EOF;    return $_html;}function view_sort($id, $list_order, $width = 100) {    $_max_int = CommonConst::CONST_MAX_INT;    $_html        = <<<EOF  <input name='list_orders[{$id}]'   class="input input-order mr5" type='text' size='10'  onkeyup="clearNoNum(this,0,$_max_int;)"  onafterpaste="clearNoNum(this,0,$_max_int)"  style="width: {$width}px;text-align: center;"  value='{$list_order}'>EOF;    return $_html;}function view_time($ts = 0, $format = 'Y-m-d H:i') {    if (empty($ts)) {        return '';    }    return date($format, $ts);}function date_search(    $time_range, $func = 'index', $time_range_arr= ['today',   'yesterday',   'seven_days',   'this_week',   'last_week',   'this_month',   'last_month',   'thirty_days']) {    $_time_range_arr = $time_range_arr;    $_html = '';    foreach ($_time_range_arr as $_v) {        $_btn = 'btn-default';        if ($time_range == $_v) {            $_btn = 'btn-success';        }        $_html .= '<a class="btn '.$_btn.'" href="'.url($func, ['time_range' => $_v]).'">'.lang(strtoupper($_v)).'</a>';    }    return $_html;}/** * 打开链接 * * @param $url * * @return string */function view_link($url) {    if (empty($url)) {        return '';    }    $_html = cmf\view\Index::link($url, $url, 'chain', 'btn-xs btn-link', '', '', 'info', '', 'view_window');    return $_html;}/** * 列表中游戏列表 * * @param string $url       请求地址 * @param bool   $new_frame 是否Frame打开 * @param string $lang_key * * @param int    $width * @param int    $height * * @return string */function view_game($url, $new_frame = true, $lang_key = 'GAME_LIST', $width = 1000, $height = 600) {    if (empty($url)) {        return '';    }    if ($new_frame) {        $_html = Index::linkOpenIframeDialog(            $url, lang($lang_key), '<span class="text-info"><i class="fa fa-gamepad"></i></span>', $width, $height,            'btn-xs btn-link', lang($lang_key)        );    } else {        $_html = cmf\view\Index::link($url, lang($lang_key), 'gamepad', '', lang($lang_key), '', 'info');    }    return $_html;}/** * 列表中渠道列表 * * @param string $url       请求地址 * @param bool   $new_frame 是否Frame打开 * @param string $lang_key * * @param int    $width * @param int    $height * * @return string */function view_channel($url, $new_frame = true, $lang_key = 'CHANNEL_LIST', $width = 1000, $height = 600) {    if (empty($url)) {        return '';    }    if ($new_frame) {        $_html = Index::linkOpenIframeDialog(            $url, lang($lang_key), '<span class="text-info"><i class="fa fa-sitemap"></i></span>', $width, $height,            'btn-xs btn-link', lang($lang_key)        );    } else {        $_html = cmf\view\Index::link($url, lang($lang_key), 'fa-sitemap', '', lang($lang_key), '', 'info');    }    return $_html;}/** * 输出订单号文本框 * * @param string $value       字段值 * @param string $placeholder 字段提示 * * @return:string */function filter_text_order_id($value = '', $placeholder = '') {    $_placeholder = empty($placeholder) ? lang('MSG_ORDER_ID_INPUT') : $placeholder;    return Filter::text('order_id', $value, $_placeholder);}/** * 输出玩家账号文本框 * * @param string $value       字段值 * @param string $placeholder 字段提示 * * @return:string */function filter_text_username($value = '', $placeholder = '') {    $_placeholder = empty($placeholder) ? lang('MSG_INPUT_ACCOUNT') : $placeholder;    return Filter::text('username', $value, $_placeholder);}/** * 输出玩家注册手机号文本框 * * @param string $value       字段值 * @param string $placeholder 字段提示 * * @return string */function filter_text_reg_mobile($value = '', $placeholder = '') {    $_placeholder = empty($placeholder) ? lang('MSG_MEMBER_REG_MOBILE_INPUT') : $placeholder;    return Filter::text('reg_mobile', $value, $_placeholder);}/** * @param string $info  提示信息 * @param string $place 显示位置 默认底部 * * @return string */function view_tips($info, $place = 'bottom') {    return '<i class="iconfont tips icon-i" style="color: #a9a9a9;font-size: 10px;margin-right: 8px;" title="'.$info           .'" data-toggle="tooltip" data-placement="'.$place.'"></i>';}/** * 跳转详情操作 * * @param string|int $id_or_url 传入ID或者链接 * * @param string     $id_key * * @param bool       $new_frame * @param int        $width * @param int        $height * * @return string */function action_detail($id_or_url, $id_key = 'id', $new_frame = false, $width = 1000, $height = 800) {    if (substr_count($id_or_url, '/') < 3) {        $_url = url('detail', [$id_key => $id_or_url]);    } else {        $_url = $id_or_url;    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    if ($new_frame) {        return Index::linkOpenIframeDialog(            $_url, lang('DETAIL'), '<span class="text-info"><i class="fa fa-eye"></i></span>', $width, $height,            'btn-xs btn-link', lang('EDIT')        );    } else {        return action_link($_url, 'DETAIL', 'eye');    }}/** * 跳转链接操作 * * @param string $link     链接 * @param string $lang_key 显示文字语言KEY * @param string $icon     图标 * * @return: string */function action_link($link, $lang_key, $icon = '') {    $_url = $link;    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    $_title = lang($lang_key);    return Index::link($_url, $_title, $icon);}/** * 确认操作(二次确认操作,用于更改数据状态等操作) * * @param string $link         链接 * @param string $lang_key     显示文字语言KEY * @param string $msg_lang_key 提示文字语言KEY * @param string $type         类型,默认是btn * @param string $class        ICON下面为图标样式,BUTTON下为按钮样式 * * @return string */function action_confirm($link, $lang_key, $msg_lang_key, $type = 'btn', $class = '') {    $_url = $link;    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    $_title = lang($lang_key);    $_msg = lang($msg_lang_key);    switch ($type) {        /*图标类型*/        case 'icon':            $_class = empty($class) ? 'edit' : $class;            $_class = 'fa-'.$_class;            $_html                = <<<EOF                  <a href="{$_url}"                   title="{$_title}"                   data-toggle="tooltip"                   data-original-title="{$_title}"                   class="js-ajax-dialog-btn"                   data-msg="{$_msg}?">                    <span class="text-danger"><i class="fa {$_class}"></i></span>                </a>EOF;            break;        /*按钮类型*/        case 'btn':        case 'button':            $_class = empty($class) ? 'default' : $class;            $_class = 'btn-'.$_class;            $_html                = <<<EOF                 <a href="{$_url}"                   title="{$_title}"                   data-toggle="tooltip"                   data-original-title="{$_title}"                   class="btn btn-xs {$_class} js-ajax-dialog-btn"                   data-msg="{$_msg}?">                    {$_title}                </a>EOF;            break;        default:            $_html = '';            break;    }    return $_html;}/** * 弹框操作 * * @param string $link     链接 * @param string $lang_key 显示文字语言KEY * @param string $type     类型,默认是btn * @param string $class    ICON下面为图标样式,BUTTON下为按钮样式 * @param int    $width * @param int    $height * @param string $dialog_lang_key * * @return string :string */function action_dialog(    $link, $lang_key, $type = 'btn', $class = '', $width = 800,    $height = 400, $dialog_lang_key = '') {    $_url = $link;    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    $_title = lang($lang_key);    $dialog_title = !empty($dialog_lang_key) ? lang($dialog_lang_key) : $_title;    switch ($type) {        /*图标类型*/        case 'icon':            $_class = empty($class) ? 'edit' : $class;            $_class = 'fa-'.$_class;            $_html                = <<<EOF            <a title="{$dialog_title}" data-toggle="tooltip" data-original-title="{$dialog_title}" href="javascript:openIframeDialog('{$link}','{$_title}',{width:'{$width}px',height:'{$height}px'});">                <span class="text-info">                    <i class="fa {$_class}"></i>                </span>            </a>EOF;            break;        /*按钮类型*/        case 'btn':        case 'button':            $_class = empty($class) ? 'default' : $class;            $_class = 'btn-'.$_class;            $_html = Index::linkOpenIframeDialog(                $_url, $dialog_title, $_title, $width, $height, $_class, $_title            );            break;        default:            $_html = '';            break;    }    return $_html;}/*** * 列表审核操作 * * @param        $id * @param        $value * @param        $lang_key * @param string $name * @param string $func * @param string $original_title_key * @param string $id_name * @param string $fa * @param string $class * * @return string */function action_check(    $id, $value, $lang_key, $name = 'status', $func = 'setStatus', $original_title_key = '', $id_name = 'id',    $fa = 'check', $class = '') {    $_auth_url = request()->module().'/'.request()->controller().'/'.$func;    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_auth_url);    if (false == $_auth) {        return '';    }    $_url = url($_auth_url, [$id_name => $id, $name => $value]);    $_lang_key = $lang_key;    $_target_status_str = lang($_lang_key);    $_original_title = '';    if (!empty($original_title_key)) {        $_original_title = lang($original_title_key);    }    return Index::link(        $_url, $_original_title, '', $class.' js-ajax-dialog-btn',        lang('CONFIRM').$_target_status_str.'?', '<span class="text-info"><i class="fa fa-'.$fa.'"></i></span>',        ''    );}/** * 列表删除操作 * * @param string|int $id_or_url 传入ID或者链接 * * @param bool       $new_frame 是否弹框 * @param int        $width     弹框宽度 * @param int        $height    弹框高度 * * @return string */function action_add_sub($id_or_url, $new_frame = false, $width = 800, $height = 500) {    if (is_numeric($id_or_url)) {        $_url = url('add', ['id' => $id_or_url]);    } else {        $_url = $id_or_url;    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    if ($new_frame) {        return Index::linkOpenIframeDialog(            $_url, lang('ADD'), '<span class="text-info"><i class="fa fa-plus"></i></span>', $width, $height,            'btn-xs btn-link', lang('ADD')        );    } else {        return Index::edit($_url, lang('ADD'));    }}/** * 输入数字限制 * * @param string $name     名称 * @param int    $value    默认值 * @param int    $min      最小值 * @param int    $max      最大值 * @param string $style    样式 * @param string $required 是否必须 * * @return string */function input_num(    $name, $value = 0, $min = 0, $max = CommonConst::CONST_MAX_INT, $style = '', $required = '', $placeholder = '') {    $_html = '<input class="input form-control" name="'.$name.'" id="'.$name.'"                     style="'.$style.'" '.$required.'                     onkeyup="clearNoNum(this,'.$min.','.$max.')"                     onafterpaste="clearNoNum(this,'.$min.','.$max.')"                     placeholder="'.$placeholder.'"                     value="'.$value.'">';    return $_html;}/** * 输入数字与逗号 * * @param string $name  名称 * @param int    $value 默认值 * * @return string */function input_num_comma($name, $value = 0) {    $_html = '<input class="input form-control" type="text" name="'.$name.'" id="'.$name.'"                     onkeyup="this.value=this.value.replace(/[^\d,]/g,\'\')"                     onafterpaste="this.value=this.value.replace(/[^\d,]/g,\'\')"                     value="'.$value.'" >';    return $_html;}/** * 输入数字与点号 * * @param string $name  名称 * @param int    $value 默认值 * * @return string */function input_num_dot($name, $value = 0) {    $_html = '<input class="input form-control" type="text" name="'.$name.'" id="'.$name.'"                     onkeyup="this.value=this.value.replace(/[^\d.]/g,\'\')"                     onafterpaste="this.value=this.value.replace(/[^\d.]/g,\'\')"                     value="'.$value.'" >';    return $_html;}/** * 调用上传图片 * * @param string $value 图片值 * @param string $name  图片名 * @param string $id    图片ID * * @return string */function upload_image($value = '', $name = 'image', $id = 'thumb') {    $_static_site = STATICSITE;    if (empty($value)) {        $_img = "<img src='".STATICSITE."/admin/assets/images/default-thumbnail.png' id='".$id                ."-preview' width='135' style='cursor: hand'/>";    } else {        $_img = "<img src='".cmf_get_image_preview_url($value)."' id='".$id                ."-preview' width='135' style='cursor: hand'/>";    }    $_lang_image_upload = lang('IMAGE_UPLOAD');    $_lang_image_cancel = lang('IMAGE_CANCEL');    $_html        = <<<  EOT    <input type="hidden" name="$name" id="$id" value="$value">    <a href="javascript:uploadOneImage('{$_lang_image_upload}','#$id');">        {$_img}    </a>    <input type="button" class="btn btn-sm btn-cancel-thumbnail"           onclick="$('#{$id}-preview').attr('src','{$_static_site}/admin/assets/images/default-thumbnail.png');$('#{$id}').val('');return false;"           value="{$_lang_image_cancel}">EOT;    return $_html;}function action_url(    $id_or_url, $new_frame = false, $logo = 'eye', $tip = 'edit', $info = 'info', $width = 800, $height = 500) {    if (is_numeric($id_or_url)) {        $_url = url('edit', ['id' => $id_or_url]);        $_auth_url = request()->module().'/'.request()->controller().'/edit';    } else {        $_url = $id_or_url;        $_auth_url = $id_or_url;        $name = explode('/', $id_or_url);        if (isset($name[3])) {            $_auth_url = $name[1].'/'.$name[2].'/'.$name[3];        }    }    $_auth = cmf_auth_check(cmf_get_current_admin_id(), $_auth_url);    if (false == $_auth) {        return '';    }    if ($new_frame) {        return \cmf\view\Index::linkOpenIframeDialog(            $_url, $tip, '<span class="text-info"><i class="fa fa-pencil"></i></span>', $width, $height,            'btn-xs btn-link', $tip        );    } else {        //return \cmf\view\Index::edit($_url);        return cmf\view\Index::link($_url, $tip, $logo, '', $tip, '', $info);    }}/** * 设置菜单 * * @param int    $parent_id * @param string $default_action * @param int    $new_frame 是否返回上级页面 * * @return string */function setting_menu($parent_id, $default_action = '', $new_frame = 1) {    $_default_action = $default_action;    if (empty($_default_action)) {        $_default_action = request()->action();    }    $_menu_model = new AdminMenuModel();    $_menu_data = $_menu_model->adminMenu($parent_id);    $_txt = '';    if (count($_menu_data) > 0) {        $_txt = '<ul class="nav nav-tabs">';        foreach ($_menu_data as $_menu) {            $_name = $_menu['app'];            $_controller = ucwords($_menu['controller']);            $_action = $_menu['action'];            //附带参数            if ($_menu['param']) {                $_params = "?".htmlspecialchars_decode($_menu['param']).'&new_frame='.$new_frame;            } else {                $_params = '?new_frame='.$new_frame;            }            $_url = url("{$_name}/{$_controller}/{$_action}{$_params}");            $_lang = strtoupper($_name.'_'.$_controller.'_'.$_action);            $_class = '';            if (strtolower($_default_action) == strtolower($_action)) {                $_class = 'active';            }            $_txt .= "<li class='{$_class}'> <a href='{$_url}'>".lang($_lang)."</a></li>";        }        $_txt .= "</ul>";    }    return $_txt;}function button($lang_key, $id, $class) {    return Filter::button(['title' => lang($lang_key), 'type' => $id, 'class' => $class]);}/** * 列表状态标识 * * @param int    $current_value      目前值 * @param string $current_status_str 目前状态名称 * * @return string */function btn_status($current_value, $current_status_str) {    switch ($current_value) {        case 1:            $_class = 'btn-default';            break;        case 2:            $_class = 'btn-success';            break;        case 3:            $_class = 'btn-primary';            break;        default:            $_class = 'btn-info';            break;    }    return Index::link(        '#', '', '', 'btn btn-xs '.$_class,        '', $current_status_str, ''    );}function get_btn($value) {    switch ($value) {        case 1:            $_class = 'danger';            break;        case 2:            $_class = 'success';            break;        case 3:            $_class = 'primary';            break;        case 4:            $_class = 'warning';            break;        default:            $_class = 'default';            break;    }    return $_class;}function get_btn1($value) {    switch ($value) {        case 1:            $_class = 'info';            break;        case 2:            $_class = 'success';            break;        case 3:            $_class = 'primary';            break;        case 4:            $_class = 'warning';            break;        default:            $_class = 'default';            break;    }    return $_class;}/** * 列表删除操作 * * @param int|string $id_or_url          ID或者地址 * @param int        $current_value      目前值 * @param int        $value              目标值 * @param string     $lang_key           变化的值 * @param string     $current_status_str 目前状态名称 * @param string     $name               字段 * @param string     $func               函数 * * @return string */function action_switch(    $id_or_url, $current_value, $value, $lang_key, $current_status_str, $name = 'status', $func = 'setStatus') {    if (is_numeric($id_or_url)) {        $_url = url($func, ['id' => $id_or_url, $name => $value, 'field' => $name]);    } else {        $_url = $id_or_url;    }    $_auth = cmf_auth_check_url(cmf_get_current_admin_id(), $_url);    if (false == $_auth) {        return '';    }    switch ($current_value) {        case 1:            $_class = 'btn-success';            break;        case 2:            $_class = 'btn-default';            break;        case 3:            $_class = 'btn-primary';            break;        default:            $_class = 'btn-info';            break;    }    $_lang_key = $lang_key;    $_target_status_str = lang($_lang_key);    return Index::link(        $_url, '', '', 'btn btn-xs '.$_class.' js-ajax-dialog-btn',        lang('CONFIRM').$_target_status_str.'?', $current_status_str, ''    );}/** * @param int    $user_id 用户ID * @param string $url     访问的URL * * @return bool */function cmf_auth_check_url($user_id, $url) {    if (1 == $user_id) {        return true;    }    $_name = StrUtils::getRoute($url);    return cmf_auth_check($user_id, $_name);}
 |