本文整理匯總了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;
}