本文整理汇总了PHP中parse_field_attr函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_field_attr函数的具体用法?PHP parse_field_attr怎么用?PHP parse_field_attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_field_attr函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean_hide_attr
?>
"></label><?php
echo clean_hide_attr($vo);
?>
<![endif]-->
</div><?php
}
}
} else {
echo "";
}
break;
?>
<?php
case "checkbox":
$_result = parse_field_attr($field['extra']);
if (is_array($_result)) {
$i = 0;
$__LIST__ = $_result;
if (count($__LIST__) == 0) {
echo "";
} else {
foreach ($__LIST__ as $key => $vo) {
$mod = $i % 2;
++$i;
?>
<div class="check-item">
<input type="checkbox" class="regular-checkbox toggle-data" value="<?php
echo $key;
?>
" id="<?php
示例2: index
/**
* 分类文档列表页
* @param integer $cate_id 分类id
* @param integer $model_id 模型id
* @param integer $position 推荐标志
* @param integer $group_id 分组id
*/
public function index($cate_id = null, $model_id = null, $position = null, $group_id = null)
{
//获取左边菜单
$this->getMenu();
if ($cate_id === null) {
$cate_id = $this->cate_id;
}
if (!empty($cate_id)) {
$pid = I('pid', 0);
// 获取列表绑定的模型
if ($pid == 0) {
$models = get_category($cate_id, 'model');
// 获取分组定义
$groups = get_category($cate_id, 'groups');
if ($groups) {
$groups = parse_field_attr($groups);
}
} else {
// 子文档列表
$models = get_category($cate_id, 'model_sub');
}
if (is_null($model_id) && !is_numeric($models)) {
// 绑定多个模型 取基础模型的列表定义
$model = D('Model')->getByName('document');
} else {
$model_id = $model_id ?: $models;
//获取模型信息
$model = D('Model')->getById($model_id);
if (empty($model['list_grid'])) {
$model['list_grid'] = D('Model')->getFieldByName('document', 'list_grid');
}
}
$this->assign('model', explode(',', $models));
} else {
// 获取基础模型信息
$model = D('Model')->getByName('document');
$model_id = null;
$cate_id = 0;
$this->assign('model', null);
}
//解析列表规则
$fields = array();
$grids = preg_split('/[;\\r\\n]+/s', trim($model['list_grid']));
foreach ($grids as &$value) {
// 字段:标题:链接
$val = explode(':', $value);
// 支持多个字段显示
$field = explode(',', $val[0]);
$value = array('field' => $field, 'title' => $val[1]);
if (isset($val[2])) {
// 链接信息
$value['href'] = $val[2];
// 搜索链接信息中的字段信息
preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use(&$fields) {
$fields[] = $match[1];
}, $value['href']);
}
if (strpos($val[1], '|')) {
// 显示格式定义
list($value['title'], $value['format']) = explode('|', $val[1]);
}
foreach ($field as $val) {
$array = explode('|', $val);
$fields[] = $array[0];
}
}
// 文档模型列表始终要获取的数据字段 用于其他用途
$fields[] = 'category_id';
$fields[] = 'model_id';
$fields[] = 'pid';
// 过滤重复字段信息
$fields = array_unique($fields);
// 列表查询
$list = $this->getDocumentList($cate_id, $model_id, $position, $fields, $group_id);
// 列表显示处理
$list = $this->parseDocumentList($list, $model_id);
$this->assign('model_id', $model_id);
$this->assign('group_id', $group_id);
$this->assign('position', $position);
$this->assign('groups', $groups);
$this->assign('list', $list);
$this->assign('list_grids', $grids);
$this->assign('model_list', $model);
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
$this->display();
}
示例3: parse_field_attr
</div>
</div>
<div class="form-item cf">
<label class="item-label">表单显示分组<span class="check-tips">(用于表单显示的分组,以及设置该模型表单排序的显示)</span></label>
<div class="controls">
<input type="text" class="text input-large" name="field_group" value="<?php
echo $info["field_group"];
?>
">
</div>
</div>
<div class="form-item cf">
<label class="item-label">表单显示排序<span class="check-tips">(直接拖动进行排序)</span></label>
<?php
$_result = parse_field_attr($info['field_group']);
if (is_array($_result)) {
$i = 0;
$__LIST__ = $_result;
if (count($__LIST__) == 0) {
echo "";
} else {
foreach ($__LIST__ as $key => $vo) {
$mod = $i % 2;
++$i;
?>
<div class="form-item cf edit_sort edit_sort_l form_field_sort">
<span><?php
echo $vo;
?>
</span>
示例4: parseDocumentList
/**
* 处理文档列表显示
* @param array $list 列表数据
* @param integer $model_id 模型id
*/
protected function parseDocumentList($list, $model_id = null)
{
$model_id = $model_id ? $model_id : 1;
$attrList = get_model_attribute($model_id, false, 'id,name,type,extra');
// 对列表数据进行显示处理
if (is_array($list)) {
foreach ($list as $k => $data) {
foreach ($data as $key => $val) {
if (isset($attrList[$key])) {
$extra = $attrList[$key]['extra'];
$type = $attrList[$key]['type'];
if ('select' == $type || 'checkbox' == $type || 'radio' == $type || 'bool' == $type) {
// 枚举/多选/单选/布尔型
$options = parse_field_attr($extra);
if ($options && array_key_exists($val, $options)) {
$data[$key] = $options[$val];
}
} elseif ('date' == $type) {
// 日期型
$data[$key] = date('Y-m-d', $val);
} elseif ('datetime' == $type) {
// 时间型
$data[$key] = date('Y-m-d H:i', $val);
}
}
}
$data['model_id'] = $model_id;
$list[$k] = $data;
}
}
return $list;
}
示例5: index
/**
* 分类文档列表页
* @param integer $cate_id 分类id
* @param integer $model_id 模型id
* @param integer $position 推荐标志
* @param integer $group_id 分组id
*/
public function index()
{
$cate_id = I('cate_id');
$model_id = I('model_id', null);
$position = I('position', null);
$group_id = I('group_id', null);
//获取面包屑信息
$nav = get_parent_category($cate_id);
$this->assign('rightNav', $nav);
if ($cate_id === null) {
$cate_id = $this->cate_id;
}
if (!empty($cate_id)) {
$pid = I('pid', 0);
// 获取列表绑定的模型
if ($pid == 0) {
$models = get_category($cate_id, 'model');
// 获取分组定义
$groups = get_category($cate_id, 'groups');
if ($groups) {
$groups = parse_field_attr($groups);
}
} else {
// 子文档列表
$models = get_category($cate_id, 'model_sub');
}
if (is_null($model_id) && !is_numeric($models)) {
// 绑定多个模型 取基础模型的列表定义
$model = M('Model')->getByName('document');
} else {
$model_id = $model_id ?: $models;
//获取模型信息
$model = M('Model')->getById($model_id);
if (empty($model['list_grid'])) {
$model['list_grid'] = M('Model')->getFieldByName('document', 'list_grid');
}
}
$this->assign('model', explode(',', $models));
} else {
$site_id = $this->site_id;
$cates = M("Category")->where("site_id = {$site_id}")->getField('id', true);
// 获取基础模型信息
$model = M('Model')->getByName('document');
$model_id = null;
if (empty($cates)) {
$cate_id = array('in', array(null));
} else {
$cate_id = array('in', $cates);
}
$this->assign('model', null);
}
if ($model['name'] == 'single') {
$document_id = M('Document')->where("category_id={$cate_id}")->getField('id');
$data = array();
if ($document_id) {
// 获取详细数据
$Document = D('Document');
$data = $Document->detail($document_id);
} else {
$data['pid'] = 0;
$data['category_id'] = $cate_id;
$data['model_id'] = $model_id;
}
$this->assign('data', $data);
$this->assign('model_id', $data['model_id']);
$this->assign('model', $model);
//获取表单字段排序
$fields = get_model_attribute($model['id']);
$this->assign('fields', $fields);
//获取当前分类的文档类型
$this->assign('type_list', get_type_bycate($data['category_id']));
$this->meta_title = '编辑内容';
$this->display('Profile/Article/edit');
} else {
//解析列表规则
$fields = array();
$grids = preg_split('/[;\\r\\n]+/s', trim($model['list_grid']));
foreach ($grids as &$value) {
// 字段:标题:链接
$val = explode(':', $value);
// 支持多个字段显示
$field = explode(',', $val[0]);
$value = array('field' => $field, 'title' => $val[1]);
if (isset($val[2])) {
// 链接信息
$value['href'] = $val[2];
// 搜索链接信息中的字段信息
preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use(&$fields) {
$fields[] = $match[1];
}, $value['href']);
}
if (strpos($val[1], '|')) {
// 显示格式定义
//.........这里部分代码省略.........
示例6: edit
/**
* 编辑页面初始化
* @author huajie <banhuajie@163.com>
*/
public function edit()
{
$id = I('get.id', '');
if (empty($id)) {
$this->error('参数不能为空!');
}
/*获取一条记录的详细数据*/
$Model = M('Model');
$data = $Model->field(true)->find($id);
if (!$data) {
$this->error($Model->getError());
}
/* 获取模型排序字段 */
$fields = json_decode($data['field_sort'], true);
if (empty($fields)) {
//未排序
$base_fields = M('Attribute')->where(array('model_id' => $data['id'], 'is_show' => 1))->field('id,name,title')->select();
//是否继承了其他模型
$extend_fields = array();
if ($data['extend'] != 0) {
$extend_fields = M('Attribute')->where(array('model_id' => $data['extend'], 'is_show' => 1))->field('id,name,title')->select();
}
$fields = array_merge($base_fields, $extend_fields);
//默认分组设为1
foreach ($fields as $key => $value) {
$fields[$key]['group'] = 1;
}
} else {
//已排序
//查询字段数据
$fields_list = array();
foreach ($fields as $key => $value) {
foreach ($value as $k => $v) {
$info = M('Attribute')->where(array('id' => $v))->field('id,name,title,is_show')->find();
if (!empty($info)) {
$info['group'] = $key;
$fields_list[] = $info;
}
}
}
//检查字段分组规则是否被修改
$keys = array_keys($fields);
$group = array_keys(parse_field_attr($data['field_group']));
foreach ($keys as $value) {
if (!in_array($value, $group)) {
//重置字段分组
foreach ($fields_list as $k => $v) {
$fields_list[$k]['group'] = 1;
}
}
}
$fields = $fields_list;
}
//获取所有的模型
$models = M('Model')->where(array('extend' => 0))->field('id,title')->select();
$this->assign('models', $models);
$this->assign('fields', $fields);
$this->assign('info', $data);
$this->meta_title = '编辑模型';
$this->display();
}
示例7: parseDataList
/**
* 处理模型数据列表显示
* @param array $list 列表数据
* @param integer $model_id 模型id
*/
protected function parseDataList($list, $model_id = null)
{
$attrList = get_model_attribute($model_id ? $model_id : 1, false, 'id,name,type,extra');
// 对列表数据进行显示处理
if (is_array($list)) {
foreach ($list as $k => $data) {
foreach ($data as $key => $val) {
if (isset($attrList[$key])) {
$extra = $attrList[$key]['extra'];
$type = $attrList[$key]['type'];
if ('select' == $type || 'checkbox' == $type || 'radio' == $type || 'bool' == $type) {
// 枚举/多选/单选/布尔型
$options = parse_field_attr($extra);
if ($options && array_key_exists($val, $options)) {
$data[$key] = $options[$val];
}
} elseif ('date' == $type) {
// 日期型
$data[$key] = date('Y-m-d', $val);
} elseif ('datetime' == $type) {
// 时间型
$data[$key] = date('Y-m-d H:i', $val);
}
}
if ($key == 'product') {
$info = M('Document')->field('title')->find($val);
if ($info !== false && $info['title']) {
$data[$key] = $info['title'];
}
}
if ($key == 'manage' || $key == 'user' || $key == 'uid') {
$info = M('Member')->field('nickname')->find($val);
if ($info !== false && $info['nickname']) {
$data[$key] = $info['nickname'];
}
}
}
$list[$k] = $data;
}
}
return $list;
}