/** *取一个分类的扩展属性(在前台输出搜索筛选时有用) */ function get_goods_cate_attr($cat_id = null) { if (empty($cat_id)) { return false; } $rearr = array(); $row = M('GoodsCat')->field('goods_type_id')->find($cat_id); if (!empty($row)) { $tema = M('GoodsTypeAttr')->where("goods_type_id={$row['goods_type_id']}")->order('sort asc ,id desc')->select(); foreach ($tema as $val) { $extra = $val['extra']; if (!empty($extra)) { $extra = extra_to_array($extra); } $rearr[] = array('name' => $val['name'], 'title' => $val['title'], 'extra' => $extra); } return $rearr; } }
public function __construct() { parent::__construct(); import('Ainiku.AssetsManager'); $this->assets = \Ainiku\AssetsManager::getInstance(); //设置资源路径 $this->assets->addSourcePath(array(__ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/css', __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/js', __ROOT__ . '/Public/Static/css', __ROOT__ . '/Public/Static/js', __ROOT__ . '/Public/Plugin/css', __ROOT__ . '/Public/Plugin/js')); /*//注册css文件 $assets->registercss('reset,common,index,404'); //注册js文件 $assets->registerjs('jquery-1.9.1.min,ajax,functions'); echo ($assets->registerend()); dump($assets);*/ //查询黑名单 $ip = get_client_ip(); $iplist = C('IP_BLACKLIST'); $iplist = extra_to_array($iplist); if (!empty($iplist)) { if (in_array($ip, $iplist)) { die('ip is access denied!'); } } }
/** *取表单模型数据数组 *@param $model_id 模型id或标识 *@param $field 模型的字段值 *@param $attr 字段的属性值 如 title note name field extra type......等 常用的有extra文章属性标记返回的是一个数组 * **/ function get_model_attr($model_id = null, $field = null, $attr = null) { $skey = $model_id . '_' . $field . '_' . $attr; $relist = F('_modelform/' . $skey); if (empty($relist) || APP_DEBUG) { $list = array(); if (empty($model_id)) { return null; } $data = get_model($model_id); if (empty($data)) { return null; } $model_id = $data['model_id']; $list = M('ModelAttr')->where("model_id={$model_id}")->order('sort asc')->select(); $refield = null; foreach ($list as $key => $val) { if (!empty($val['extra'])) { $redata = parse_string_function($val['extra']); if ($redata === false) { //如果是数组格式就转化成数组 $list[$key]['extra'] = extra_to_array($val['extra']); } else { $list[$key]['extra'] = $redata; } } if (!empty($field) and $val['field'] === $field) { if (empty($attr)) { $relist = $list[$key]; F('_modelform/' . $skey, $relist); return $list[$key]; } else { $relist = $list[$key][$attr]; F('_modelform/' . $skey, $relist); return $list[$key][$attr]; } } } $relist = $list; F('_modelform/' . $skey, $list); } return $relist; }
/** *取产品类型表单模型数据数组 */ function get_goods_type_model($goods_type_id = null) { if (empty($goods_type_id)) { return null; } $map['status'] = 1; if (is_numeric($goods_type_id)) { $map['goods_type_id'] = $goods_type_id; } $list = M('GoodsTypeAttribute')->where($map)->order('sort asc')->select(); $refield = null; foreach ($list as $key => $val) { $namef = $val['name'] . '____' . $val['goods_type_attribute_id']; $list[$key]['name'] = $namef; $list[$key]['field'] = $namef; if (!empty($val['extra'])) { if ($val['extranote'] === '1' || $val['extranote'] == 'func') { $func = $val['extra']; $list[$key]['extra'] = $func(); } else { $list[$key]['extra'] = extra_to_array($val['extra']); } } } return $list; }
<?php return array(array('field' => 'name', 'type' => 'text', 'name' => 'name', 'title' => '配置标识', 'note' => '用于C函数调用,只能使用英文且不能重复', 'extra' => null, 'is_show' => 3), array('field' => 'title', 'type' => 'text', 'name' => 'title', 'title' => '配置标题', 'note' => '用于显示的配置标题', 'extra' => array(), 'is_show' => 3), array('field' => 'sort', 'type' => 'number', 'name' => 'sort', 'title' => '排序', 'note' => '用于分组显示的顺序', 'extra' => array(), 'is_show' => 3, 'value' => 99), array('field' => 'type', 'type' => 'select', 'name' => 'type', 'title' => '配置类型', 'note' => '系统会根据不同的类型解析配置值', 'extra' => get_form_type(), 'is_show' => 3), array('field' => 'group', 'type' => 'select', 'name' => 'group', 'title' => '配置分组', 'note' => '默认的是添加到默认分组', 'extra' => extra_to_array(C('CONFIG_GROUP')), 'is_show' => 3), array('field' => 'value', 'name' => 'value', 'type' => 'textarea', 'title' => '配置值', 'note' => '配置值', 'extra' => null, 'is_show' => 3), array('field' => 'extra', 'name' => 'extra', 'type' => 'textarea', 'title' => '配置项', 'note' => '如果是枚举值则要设置此项', 'extra' => null, 'is_show' => 3), array('field' => 'note', 'name' => 'note', 'type' => 'textarea', 'title' => '说明', 'note' => '配置详细说明', 'extra' => null, 'is_show' => 3), array('field' => 'no_del', 'name' => 'no_del', 'type' => 'radio', 'title' => '只有在开发模式下才能删除', 'note' => '关闭开发模式后此配置项不显示', 'extra' => array(0 => '否', 1 => '是'), 'is_show' => 3), array('field' => 'is_show', 'name' => 'is_show', 'type' => 'radio', 'title' => '什么时候显示', 'note' => '关闭开发模式后在网站设置中是否显示', 'extra' => array(0 => '隐藏', 1 => '添加时显示', 2 => '编辑时显示', 3 => '添加编辑时都显示'), 'value' => 3, 'is_show' => 3));
/** * 配置分组 * @author 枫叶 <*****@*****.**> */ function group($id = null) { $this->meta_title = '网站配置'; $id = $id ? $id : 1; $grouplist = extra_to_array(C('CONFIG_GROUP')); $this->assign('group', $grouplist); $this->assign('id', $id); //循环每个分组的模型 $data = null; if (APP_DEBUG) { $data = M('Config')->where("`group`={$id}")->order('sort asc,config_id desc')->select(); } else { $data = M('Config')->where("`group`={$id} and no_del=1")->order('sort asc,config_id desc')->select(); } //处理extra数据 //进入单个分组中后对每个进行处理 foreach ($data as $k => $v) { $nme = isset($v['name']) ? $v['name'] : ''; $data[$k]['data'] = $v['value']; $data[$k]['field'] = 'config__' . $nme . ''; $data[$k]['name'] = 'config__' . $nme . ''; $data[$k]['note'] = $v['note'] . '。标识:' . $nme; $data[$k]['is_show'] = 3; $redata = parse_string_function($v['extra']); if ($redata === false) { if (!empty($v['extra']) && $v['type'] != 'custom') { $data[$k]['extra'] = extra_to_array($v['extra']); } } else { $data[$k]['extra'] = $redata; } } // dump($data); // die(); $this->assign('data', $data); $this->display(); }