helper.php
Table of Contents
Functions
- call_retry() : mixed
- 尝试多次运行 $times 运行次数 $usleep_time 毫秒
- array_to_tree() : mixed
- 数组转tree
- pr() : mixed
- 数组或字符输出,方便查看
- add_action() : mixed
- do_action() : mixed
- is_cli() : mixed
- is_post() : mixed
- is_json() : mixed
- array_to_object() : mixed
- object_to_array() : mixed
- get_dir() : mixed
- get_ext() : mixed
- get_name() : mixed
- create_dir_if_not_exists() : mixed
- is_local() : mixed
- get_ip() : mixed
- now() : mixed
- get_distance() : mixed
- get_deep_dir() : mixed
- price_format() : mixed
- json() : mixed
- json_error() : mixed
- json_success() : mixed
- yaml_load() : mixed
- yaml_dump() : mixed
- yaml() : mixed
- aes_encode() : mixed
- aes_decode() : mixed
- string_to_array() : mixed
- get_dates() : mixed
- get_date_china() : mixed
- timeago() : mixed
- is_ajax() : mixed
- import() : mixed
- get_reffer() : mixed
- get_root_domain() : mixed
- get_sub_domain() : mixed
- sign_by_secret() : mixed
- zip_extract() : mixed
- zip_create() : mixed
- is_json_request() : mixed
- array_to_el_select() : mixed
- echats() : mixed
- echats_reload() : mixed
- echarts() : mixed
- echarts_reload() : mixed
- set_field_allow() : mixed
- 设置允许字段
- get_field_allow() : mixed
- 获取允许字段
- get_data_allow() : mixed
- 返回允许字段值
- is_ssl() : mixed
- think_validate() : mixed
- validate() : mixed
- jump() : mixed
- set_url_use_cdn() : mixed
- 对数组添加cdn url
- push_task() : mixed
- 添加到队列 "topthink/think-queue": "^3" push_task('app\printer\job\Printer',['tt'=>11],'');
- loop_tree() : mixed
- 向上取递归 如当前分类是3,将返回 123所有的值 $arr = loop_tree("catalog",$v['catalog_id'],true); foreach($arr as $vv){ $title[] = $vv['title']; } id pid 1 0 2 1 3 2
- get_loop_tree_ids() : mixed
- 向下递归
- loop_del() : mixed
- 递归删除
- el_table_tree() : mixed
- 用于tree表格排序 因为tree给的lists字段是用于显示,在排序时得到的index是不正确的, 此时需要lists_sort字段得到正确的index 在交换排序值时才能正确保存并显示
- el_cascader() : mixed
- 用于cascader字段 public function cascader(){ $catalog = db_get($this->table,"*",[ 'ORDER'=>catalog_default_order_by(), 'status'=>1 ]); $select = el_cascader(array_to_tree($catalog)); json_success(['data'=>$select]); } $catalog = db_get("catalog",[]); $select = el_cascader(array_to_tree($catalog));
- _loop_del_tree() : mixed
- 内部实现
- _loop_tree_deep_inner() : mixed
- 内部实现
Functions
call_retry()
尝试多次运行 $times 运行次数 $usleep_time 毫秒
call_retry(mixed $func[, mixed $times = 3 ][, mixed $usleep_time = 1000 ]) : mixed
Parameters
- $func : mixed
- $times : mixed = 3
- $usleep_time : mixed = 1000
array_to_tree()
数组转tree
array_to_tree(mixed $list[, mixed $pk = 'id' ][, mixed $pid = 'pid' ][, mixed $child = 'children' ][, mixed $root = 0 ][, mixed $my_id = '' ]) : mixed
输入$list [ {id:1,pid:0,其他字段}, {id:2,pid:1,其他字段}, {id:3,pid:1,其他字段}, ] 输出 [ [ id:1, pid:0, 其他字段, children:[ {id:2,pid:1,其他字段}, {id:3,pid:1,其他字段}, ] ] ]
Parameters
- $list : mixed
- $pk : mixed = 'id'
- $pid : mixed = 'pid'
- $child : mixed = 'children'
- $root : mixed = 0
- $my_id : mixed = ''
pr()
数组或字符输出,方便查看
pr(mixed $str) : mixed
Parameters
- $str : mixed
add_action()
add_action(mixed $name, mixed $call[, mixed $level = 20 ]) : mixed
Parameters
- $name : mixed
- $call : mixed
- $level : mixed = 20
do_action()
do_action(mixed $name[, mixed &$par = null ]) : mixed
Parameters
- $name : mixed
- $par : mixed = null
is_cli()
is_cli() : mixed
is_post()
is_post() : mixed
is_json()
is_json(mixed $data[, mixed $assoc = false ]) : mixed
Parameters
- $data : mixed
- $assoc : mixed = false
array_to_object()
array_to_object(mixed $arr) : mixed
Parameters
- $arr : mixed
object_to_array()
object_to_array(mixed $obj) : mixed
Parameters
- $obj : mixed
get_dir()
get_dir(mixed $name) : mixed
Parameters
- $name : mixed
get_ext()
get_ext(mixed $name) : mixed
Parameters
- $name : mixed
get_name()
get_name(mixed $name) : mixed
Parameters
- $name : mixed
create_dir_if_not_exists()
create_dir_if_not_exists(mixed $arr) : mixed
Parameters
- $arr : mixed
is_local()
is_local() : mixed
get_ip()
get_ip([mixed $type = 0 ][, mixed $adv = false ]) : mixed
Parameters
- $type : mixed = 0
- $adv : mixed = false
now()
now() : mixed
get_distance()
get_distance(mixed $longitude1, mixed $latitude1, mixed $longitude2, mixed $latitude2[, mixed $unit = 2 ][, mixed $decimal = 2 ]) : mixed
Parameters
- $longitude1 : mixed
- $latitude1 : mixed
- $longitude2 : mixed
- $latitude2 : mixed
- $unit : mixed = 2
- $decimal : mixed = 2
get_deep_dir()
get_deep_dir(mixed $path) : mixed
Parameters
- $path : mixed
price_format()
price_format(mixed $yuan[, mixed $dot = 2 ]) : mixed
Parameters
- $yuan : mixed
- $dot : mixed = 2
json()
json([mixed $arr = [] ]) : mixed
Parameters
- $arr : mixed = []
json_error()
json_error([mixed $arr = [] ][, mixed $is_array = false ]) : mixed
Parameters
- $arr : mixed = []
- $is_array : mixed = false
json_success()
json_success([mixed $arr = [] ][, mixed $is_array = false ]) : mixed
Parameters
- $arr : mixed = []
- $is_array : mixed = false
yaml_load()
yaml_load(mixed $str) : mixed
Parameters
- $str : mixed
yaml_dump()
yaml_dump(mixed $array[, mixed $line = 3 ]) : mixed
Parameters
- $array : mixed
- $line : mixed = 3
yaml()
yaml(mixed $str) : mixed
Parameters
- $str : mixed
aes_encode()
aes_encode(mixed $data[, mixed $key = '' ][, mixed $iv = '' ][, mixed $type = 'AES-128-CBC' ][, mixed $options = '' ]) : mixed
Parameters
- $data : mixed
- $key : mixed = ''
- $iv : mixed = ''
- $type : mixed = 'AES-128-CBC'
- $options : mixed = ''
aes_decode()
aes_decode(mixed $data[, mixed $key = '' ][, mixed $iv = '' ][, mixed $type = 'AES-128-CBC' ][, mixed $options = '' ]) : mixed
Parameters
- $data : mixed
- $key : mixed = ''
- $iv : mixed = ''
- $type : mixed = 'AES-128-CBC'
- $options : mixed = ''
string_to_array()
string_to_array(mixed $name[, mixed $array = '' ]) : mixed
Parameters
- $name : mixed
- $array : mixed = ''
get_dates()
get_dates(mixed $start, mixed $end[, mixed $contain_last = true ]) : mixed
Parameters
- $start : mixed
- $end : mixed
- $contain_last : mixed = true
get_date_china()
get_date_china(mixed $date) : mixed
Parameters
- $date : mixed
timeago()
timeago(mixed $time) : mixed
Parameters
- $time : mixed
is_ajax()
is_ajax() : mixed
import()
import(mixed $file[, mixed $vars = [] ][, mixed $check_vars = false ]) : mixed
Parameters
- $file : mixed
- $vars : mixed = []
- $check_vars : mixed = false
get_reffer()
get_reffer([mixed $refer = '' ]) : mixed
Parameters
- $refer : mixed = ''
get_root_domain()
get_root_domain([mixed $host = '' ]) : mixed
Parameters
- $host : mixed = ''
get_sub_domain()
get_sub_domain([mixed $host = '' ]) : mixed
Parameters
- $host : mixed = ''
sign_by_secret()
sign_by_secret(mixed $params[, mixed $secret = '' ][, mixed $array_encode = false ]) : mixed
Parameters
- $params : mixed
- $secret : mixed = ''
- $array_encode : mixed = false
zip_extract()
zip_extract(mixed $local_file, mixed $extract_local_dir) : mixed
Parameters
- $local_file : mixed
- $extract_local_dir : mixed
zip_create()
zip_create(mixed $local_zip_file[, mixed $files = [] ]) : mixed
Parameters
- $local_zip_file : mixed
- $files : mixed = []
is_json_request()
is_json_request() : mixed
array_to_el_select()
array_to_el_select(mixed $all, mixed $v, mixed $k) : mixed
Parameters
- $all : mixed
- $v : mixed
- $k : mixed
echats()
echats(mixed $ele[, mixed $options = [] ]) : mixed
Parameters
- $ele : mixed
- $options : mixed = []
echats_reload()
echats_reload() : mixed
echarts()
echarts(mixed $ele[, mixed $options = [] ]) : mixed
Parameters
- $ele : mixed
- $options : mixed = []
echarts_reload()
echarts_reload() : mixed
set_field_allow()
设置允许字段
set_field_allow(mixed $collect, mixed $field) : mixed
Parameters
- $collect : mixed
- $field : mixed
get_field_allow()
获取允许字段
get_field_allow(mixed $collect) : mixed
Parameters
- $collect : mixed
get_data_allow()
返回允许字段值
get_data_allow(mixed $collect, mixed $input) : mixed
Parameters
- $collect : mixed
- $input : mixed
is_ssl()
is_ssl() : mixed
think_validate()
think_validate(mixed $labels, mixed $data, mixed $rules[, mixed $show_array = false ]) : mixed
Parameters
- $labels : mixed
- $data : mixed
- $rules : mixed
- $show_array : mixed = false
validate()
validate(mixed $labels, mixed $data, mixed $rules[, mixed $show_array = false ]) : mixed
Parameters
- $labels : mixed
- $data : mixed
- $rules : mixed
- $show_array : mixed = false
jump()
jump(mixed $url) : mixed
Parameters
- $url : mixed
set_url_use_cdn()
对数组添加cdn url
set_url_use_cdn(mixed &$row[, mixed $field = [] ]) : mixed
Parameters
- $row : mixed
- $field : mixed = []
push_task()
添加到队列 "topthink/think-queue": "^3" push_task('app\printer\job\Printer',['tt'=>11],'');
push_task(mixed $job[, mixed $data = '' ][, mixed $queue = '' ]) : mixed
Parameters
- $job : mixed
- $data : mixed = ''
- $queue : mixed = ''
loop_tree()
向上取递归 如当前分类是3,将返回 123所有的值 $arr = loop_tree("catalog",$v['catalog_id'],true); foreach($arr as $vv){ $title[] = $vv['title']; } id pid 1 0 2 1 3 2
loop_tree(mixed $table, mixed $id[, mixed $is_frist = true ]) : mixed
Parameters
- $table : mixed
- $id : mixed
- $is_frist : mixed = true
get_loop_tree_ids()
向下递归
get_loop_tree_ids(mixed $table, mixed $id[, mixed $where = [] ][, mixed $get_field = 'id' ]) : mixed
Parameters
- $table : mixed
- $id : mixed
- $where : mixed = []
- $get_field : mixed = 'id'
loop_del()
递归删除
loop_del(mixed $table, mixed $id[, mixed $where = [] ]) : mixed
Parameters
- $table : mixed
- $id : mixed
- $where : mixed = []
el_table_tree()
用于tree表格排序 因为tree给的lists字段是用于显示,在排序时得到的index是不正确的, 此时需要lists_sort字段得到正确的index 在交换排序值时才能正确保存并显示
el_table_tree(mixed $list, mixed $j[, mixed $is_top = false ]) : mixed
Parameters
- $list : mixed
- $j : mixed
- $is_top : mixed = false
el_cascader()
用于cascader字段 public function cascader(){ $catalog = db_get($this->table,"*",[ 'ORDER'=>catalog_default_order_by(), 'status'=>1 ]); $select = el_cascader(array_to_tree($catalog)); json_success(['data'=>$select]); } $catalog = db_get("catalog",[]); $select = el_cascader(array_to_tree($catalog));
el_cascader(mixed $select[, mixed $label = 'title' ][, mixed $value = 'id' ]) : mixed
Parameters
- $select : mixed
- $label : mixed = 'title'
- $value : mixed = 'id'
_loop_del_tree()
内部实现
_loop_del_tree(mixed $table, mixed $all) : mixed
Parameters
- $table : mixed
- $all : mixed
_loop_tree_deep_inner()
内部实现
_loop_tree_deep_inner(mixed $all, mixed $get_field[, mixed $is_frist = false ]) : mixed
Parameters
- $all : mixed
- $get_field : mixed
- $is_frist : mixed = false