\n\n";
$str = "";
$tree->init($datas);
$string .= $tree->get_tree($top_id, $str, $menu_id);
$string .= '';
return $string;
}
//模型字段管理的一些初始参数
public static function getFieldsInfo($arg)
{
$info=array(
'types' => array(
'text'=>'单行文本',
'textarea'=>'多行文本',
'editor'=>'编辑器',
'cat_id'=>'栏目',
'title'=>'标题',
'box'=>'选项',
'image'=>'图片',
'images'=>'多图片',
'number'=>'数字',
'datetime'=>'日期和时间',
'pos_id'=>'推荐位',
'keywords'=>'关键词',
'author'=>'作者',
'copy_from'=>'来源',
'group_id'=>'用户组',
'is_link'=>'转向链接',
'template'=>'模板',
'pages'=>'分页选择',
'type_id'=>'类别',
'read_price'=>'金额、金币、积分',
'linkmenu'=>'联动菜单',
'downfiles'=>'多文件上传',
'map'=>'地图',
'omnipotent'=>'万能字段',
'sysconfig'=>'系统参数',
'ext_type'=>'扩展配置',
),
//不允许添加的字段类型,这些字段讲不会在字段添加处显示
'not_allow_fields' => array('cat_id','type_id','title','keywords','pos_id','template','user_name'),
//允许添加但必须唯一的字段
'unique_fields' => array('pages','read_price','author','copy_from','is_link'),
//禁止被禁用的字段列表
'forbid_fields' => array('cat_id','title','url','template','user_name','create_time','update_time','list_order','status','ext_type'),
//禁止被删除的字段列表
'forbid_delete' => array('cat_id','type_id','title','thumb','keywords','description','is_position','url','status','template','user_name','list_order','update_time','create_time','ext_type'),
//可以追加 JS和CSS 的字段
'att_css_js' => array('text','textarea','box','number')
);
return $info[$arg];
}
/**
* 下拉选择框
*/
public static function select($array = array(), $id = 0, $default_option = '请选择' , $property = 'class=\'\'' )
{
$string = '';
return $string;
}
/**
* 单选框
*
* @param $array 选项 二维数组
* @param $id 默认选中值
* @param $property 属性
* @param $inlayui 使用 layui 样式
*/
public static function radio($array = array(), $id = 0, $property = '',$inlayui=0)
{
$string = '';
foreach($array as $key=>$value) {
$checked = trim($id)==trim($key) ? 'checked' : '';
if($inlayui==1)
{
$string .= '';
}
else
{
$string .= '
';
$string .= '
';
$string .= '
';
}
}
return $string;
}
/**
* 复选框
*
* @param $array 选项 二维数组
* @param $id 默认选中值,多个用 '逗号'分割
* @param $property 属性
* @param $inlayui 使用 layui 样式
*/
public static function checkbox($array = array(), $id = '', $property = '',$inlayui=0)
{
$string = '';
$id = trim($id);
if($id != '') $id = strpos($id, ',') ? explode(',', $id) : array($id);
$i = 1;
foreach($array as $key=>$value) {
$key = trim($key);
$checked = ($id && in_array($key, $id)) ? 'checked' : '';
if($inlayui==1)
{
$string .= '';
}
else
{
$string .= '';
$string .= '
';
$string .= '
';
}
$i++;
}
return $string;
}
public static function switchbox($options = array(), $id = '', $property = '',$fieldname)
{
$string = '';
$checked = $id ? 'checked' : '';
$string .='';
$string .= '';
$string .= '';
$string .= '
';
return $string;
}
//获得日期输入控件(依赖layui)
public static function dateForm($name,$value,$array)
{
$name = $array['name']?$array['name']:$name;
$dateFmt = $array['dateFmt'];
$minDate = $array['minDate'];
$maxDate = $array['maxDate'];
$vel = $array['vel'];
$velName = $array['velName'];
$readOnly = $array['readOnly']==1?"readonly":'';
$id = $array['id']?$array['id']:$array['defaultId'];
$string = '';
return $string;
}
//详情页模板选择
public static function select_template($themename, $device, $module, $id = '', $str = '', $pre = '') {
$themePath = Yii::$app->params['themePath'];
$templatedir = $themePath.$themename.DIRECTORY_SEPARATOR.$device.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR;
$config_path = $themePath.$themename.DIRECTORY_SEPARATOR.'config.php';
$localdir = 'themes|'.$themename.'|'.$device.'|views|'.$module;
$templates = glob($templatedir.$pre.'*.php');
if(empty($templates)) return '没有可用模板';
$files = @array_map('basename', $templates);
$names = array();
if(file_exists($config_path)) {
$names = include $config_path;
}
$templates = array();
if(is_array($files)) {
foreach($files as $file) {
$key = substr($file, 0, -4);
$templates[$key] = isset($names['file_explain'][$localdir][$file]) && !empty($names['file_explain'][$localdir][$file]) ? $names['file_explain'][$localdir][$file].'('.$file.')' : $file;
}
}
ksort($templates);
return self::select($templates, $id, '', $str);
}
}
?>