/** * @ copyright (C)2016-2099 Hnaoyun Inc. * @ author XingMeng * @ email hnxsh@foxmail.com * @ date 2017年4月14日 * 公共处理函数 */ use core\basic\Config; // 获取字符串型自动编码 function get_auto_code($string, $start = '1') { if (! $string) return $start; if (is_numeric($string)) { // 如果纯数字则直接加1 return sprintf('%0' . strlen($string) . 's', $string + 1); } else { // 非纯数字则先分拆 $reg = '/^([a-zA-Z-_]+)([0-9]+)$/'; $str = preg_replace($reg, '$1', $string); // 字母部分 $num = preg_replace($reg, '$2', $string); // 数字部分 return $str . sprintf('%0' . (strlen($string) - strlen($str)) . 's', $num + 1); } } // 获取指定分类列表 function get_type($tcode) { $type_model = model('admin.system.Type'); if (! ! $result = $type_model->getItem($tcode)) { return $result; } else { return array(); } } // 生成区域选择 function make_area_Select($tree, $selectid = null) { $list_html = ''; global $blank; foreach ($tree as $values) { // 默认选择项 if ($selectid == $values->acode) { $select = "selected='selected'"; } else { $select = ''; } // 禁用父栏目选择功能 if ($values->son) { $disabled = "disabled='disabled'"; } else { $disabled = ''; } $list_html .= "