本文整理汇总了PHP中parse_config_attr函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_config_attr函数的具体用法?PHP parse_config_attr怎么用?PHP parse_config_attr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_config_attr函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detail
function detail()
{
$this->assign('add_button', false);
$this->assign('search_button', false);
$this->assign('del_button', false);
$this->assign('check_all', false);
$model = $this->getModel('survey_answer');
// 解析列表规则
$fields[] = 'question';
$fields[] = 'answer';
$girds['field'] = 'question';
$girds['title'] = '问题';
$list_data['list_grids']['question'] = $girds;
$girds['field'] = 'answer';
$girds['title'] = '回答内容';
$list_data['list_grids']['answer'] = $girds;
$list_data['fields'] = $fields;
$this->assign($list_data);
$map['survey_id'] = intval($_REQUEST['survey_id']);
$questions = M('survey_question')->where($map)->select();
foreach ($questions as $q) {
$title[$q['id']] = $q['title'];
$type[$q['id']] = $q['type'];
$extra[$q['id']] = parse_config_attr($q['extra']);
}
$map['uid'] = intval($_REQUEST['uid']);
$answers = M('survey_answer')->where($map)->select();
foreach ($answers as $a) {
$qid = $a['question_id'];
$data['question'] = $title[$qid];
$value = unserialize($a['answer']);
switch ($type[$qid]) {
case 'radio':
$data['answer'] = $extra[$qid][$value];
break;
case 'checkbox':
foreach ($value as $v) {
$data['answer'][] = $extra[$qid][$v];
}
$data['answer'] = implode(',', $data['answer']);
break;
default:
$data['answer'] = $value;
}
$list[] = $data;
unset($data);
}
$this->assign('list_data', $list);
$this->display(T('lists'));
}
示例2: survey
function survey()
{
$id = I('get.id', 0, 'intval');
$num = I('num', 1, 'intval');
$token = get_token();
$survey = D('Survey')->getSurveyInfo($id);
$list = D('SurveyQuestion')->getQuestionInfo($id);
if (IS_POST) {
$follow_id = $this->mid;
$question_id = I('post.question_id', 0, 'intval');
$answer = D('SurveyAnswer')->getAnswerInfo($id, $question_id, $follow_id);
$data['cTime'] = time();
$data['answer'] = serialize($_POST['answer']);
if ($answer) {
D('SurveyAnswer')->updateAnswer($id, $question_id, $follow_id, $data);
} else {
$data['survey_id'] = $id;
$data['token'] = $token;
$data['question_id'] = $question_id;
$data['uid'] = $follow_id;
$data['openid'] = get_openid();
M('survey_answer')->add($data);
D('SurveyAnswer')->getAnswerInfo($id, $question_id, $follow_id, true);
}
$num = $num + 1;
}
$question_id = I('post.next_id', 0, 'intval');
if ($question_id == '-1') {
redirect(U('finish', 'survey_id=' . $id));
}
if (empty($question_id)) {
$question = $list[0];
$next_id = isset($list[1]['id']) ? $list[1]['id'] : '-1';
} else {
foreach ($list as $k => $vo) {
if ($vo['id'] == $question_id) {
$question = $vo;
$next_id = isset($list[$k + 1]['id']) ? $list[$k + 1]['id'] : '-1';
}
}
}
$extra = parse_config_attr($question['extra']);
$this->assign('survey', $survey);
$this->assign('question', $question);
$this->assign('next_id', $next_id);
$this->assign('extra', $extra);
$this->assign('num', $num);
$this->display();
}
示例3: U
?>
</p><?php
}
?>
<div class="tab-content">
<!-- 表单 -->
<?php
$post_url || ($post_url = U('edit?model=' . $model['id'], $get_param));
?>
<form id="form" action="<?php
echo $post_url;
?>
" method="post" class="form-horizontal form-center">
<!-- 基础文档模型 -->
<?php
$_result = parse_config_attr($model['field_group']);
if (is_array($_result)) {
$i = 0;
$__LIST__ = $_result;
if (count($__LIST__) == 0) {
echo "";
} else {
foreach ($__LIST__ as $key => $group) {
$mod = $i % 2;
++$i;
?>
<div id="tab<?php
echo $key;
?>
" class="tab-pane <?php
if ($key == "1") {
示例4: test
function test()
{
$map['test_id'] = intval($_REQUEST['test_id']);
$map['token'] = get_token();
$test = M('test')->where($map)->find();
$now = time();
$start = intval($test['start_time']);
$end = intval($test['end_time']);
if ($start > 0 && $now < $start || $end > 0 && $now > $end) {
redirect(U('show', 'test_id=' . $map['test_id']));
}
$list = M('test_question')->where($map)->order('sort asc, id asc')->select();
foreach ($list as $vo) {
$question_list[$vo['id']] = $vo;
}
if (IS_POST) {
$map['uid'] = $this->mid;
$map['question_id'] = I('post.question_id', 0, 'intval');
$answer = M('test_answer')->where($map)->find();
$data['cTime'] = time();
$data['answer'] = serialize($_POST['answer']);
$data['score'] = intval($_POST['score']);
if ($answer) {
M('test_answer')->where($map)->save($data);
} else {
$data['test_id'] = $map['test_id'];
$data['token'] = $map['token'];
$data['question_id'] = $map['question_id'];
$data['uid'] = $map['uid'];
$data['openid'] = get_openid();
M('test_answer')->add($data);
}
}
$question_id = I('post.next_id', 0, 'intval');
if ($question_id == '-1') {
redirect(U('finish', 'test_id=' . $map['test_id']));
}
if (empty($question_id)) {
$question = $list[0];
$next_id = isset($list[1]['id']) ? $list[1]['id'] : '-1';
} else {
foreach ($list as $k => $vo) {
if ($vo['id'] == $question_id) {
$question = $vo;
$next_id = isset($list[$k + 1]['id']) ? $list[$k + 1]['id'] : '-1';
}
}
}
$extra = parse_config_attr($question['extra']);
foreach ($extra as $k => $vo) {
$score = 0;
$n_id = 0;
preg_match('/\\[\\+([^\\]]*)\\]+/', $vo, $matches);
if (isset($matches[1])) {
$score = intval($matches[1]);
$vo = str_replace($matches[0], '', $vo);
}
unset($matches);
preg_match('/\\[@([^\\]]*)\\]+/', $vo, $matches);
if (isset($matches[1])) {
$n_id = intval($matches[1]);
$vo = str_replace($matches[0], '', $vo);
}
$extraArr[$k]['title'] = $vo;
$extraArr[$k]['score'] = $score;
$extraArr[$k]['next_id'] = $n_id != 0 && isset($question_list[$n_id]) ? $n_id : $next_id;
}
// dump ( $extraArr );
$this->assign('test', $test);
$this->assign('question', $question);
$this->assign('next_id', $next_id);
$this->assign('extra', $extraArr);
$this->display();
}
示例5: parse_config_attr
]"><?php
echo $config["value"];
?>
</textarea>
</label><?php
break;
?>
<?php
case "4":
?>
<select name="config[<?php
echo $config["name"];
?>
]">
<?php
$_result = parse_config_attr($config['extra']);
if (is_array($_result)) {
$i = 0;
$__LIST__ = $_result;
if (count($__LIST__) == 0) {
echo "";
} else {
foreach ($__LIST__ as $key => $vo) {
$mod = $i % 2;
++$i;
?>
<option value="<?php
echo $key;
?>
" <?php
if ($config["value"] == $key) {
示例6: exam
function exam()
{
$map['exam_id'] = intval($_REQUEST['exam_id']);
$map['token'] = get_token();
$exam = M('exam')->where($map)->find();
$now = time();
$start = intval($exam['start_time']);
$end = intval($exam['end_time']);
if ($start > 0 && $now < $start || $end > 0 && $now > $end) {
redirect(U('show', 'exam_id=' . $map['exam_id']));
}
$list = M('exam_question')->where($map)->order('sort asc, id asc')->select();
foreach ($list as $vo) {
$question_list[$vo['id']] = $vo;
}
if (IS_POST) {
$map['uid'] = $this->mid;
$map['question_id'] = I('post.question_id', 0, 'intval');
$answer = M('exam_answer')->where($map)->find();
$data['cTime'] = time();
$data['answer'] = serialize($_POST['answer']);
$data['score'] = $this->_getScore($question_list[$map['question_id']], $_POST['answer']);
if ($answer) {
M('exam_answer')->where($map)->save($data);
} else {
$data['exam_id'] = $map['exam_id'];
$data['token'] = $map['token'];
$data['question_id'] = $map['question_id'];
$data['uid'] = $map['uid'];
$data['openid'] = get_openid();
M('exam_answer')->add($data);
}
}
$question_id = I('post.next_id', 0, 'intval');
if ($question_id == '-1') {
redirect(U('finish', 'exam_id=' . $map['exam_id']));
}
if (empty($question_id)) {
$question = $list[0];
$next_id = isset($list[1]['id']) ? $list[1]['id'] : '-1';
} else {
foreach ($list as $k => $vo) {
if ($vo['id'] == $question_id) {
$question = $vo;
$next_id = isset($list[$k + 1]['id']) ? $list[$k + 1]['id'] : '-1';
}
}
}
$extra = parse_config_attr($question['extra']);
$this->assign('exam', $exam);
$this->assign('question', $question);
$this->assign('next_id', $next_id);
$this->assign('extra', $extra);
$this->display();
}
示例7: lists
public function lists()
{
// 解析列表规则
$fields[] = 'openid';
$fields[] = 'cTime';
$fields[] = 'reserve_id';
$girds['field'] = 'uid';
$girds['title'] = '用户';
$list_data['list_grids'][] = $girds;
$girds['field'] = 'cTime|time_format';
$girds['title'] = '增加时间';
$list_data['list_grids'][] = $girds;
$map['reserve_id'] = $this->reserve_id;
$attribute = M('reserve_attribute')->where($map)->order('sort asc, id asc')->select();
foreach ($attribute as &$fd) {
$fd['name'] = 'field_' . $fd['id'];
}
foreach ($attribute as $vo) {
$girds['field'] = $fields[] = $vo['name'];
$girds['title'] = $vo['title'];
$list_data['list_grids'][] = $girds;
$attr[$vo['name']]['type'] = $vo['type'];
if ($vo['type'] == 'radio' || $vo['type'] == 'checkbox' || $vo['type'] == 'select') {
$extra = parse_config_attr($vo['extra']);
if (is_array($extra) && !empty($extra)) {
$attr[$vo['name']]['extra'] = $extra;
}
} elseif ($vo['type'] == 'cascade' || $vo['type'] == 'dynamic_select') {
$attr[$vo['name']]['extra'] = $vo['extra'];
}
}
$fields[] = 'id';
$girds['field'][0] = 'id';
$girds['title'] = '操作';
$girds['href'] = '[EDIT]&reserve_id=[reserve_id]&id=[id]|编辑,[DELETE]&reserve_id=[reserve_id]&id=[id]| 删除';
$list_data['list_grids'][] = $girds;
$list_data['fields'] = $fields;
$param['reserve_id'] = $this->reserve_id;
$param['model'] = $this->model['id'];
$add_url = U('add', $param);
$this->assign('add_url', $add_url);
// 搜索条件
$map = $this->_search_map($this->model, $fields);
$page = I('p', 1, 'intval');
$row = 20;
$name = parse_name(get_table_name($this->model['id']), true);
$list = M($name)->where($map)->order('id DESC')->selectPage();
$list_data = array_merge($list_data, $list);
foreach ($list_data['list_data'] as &$vo) {
$value = unserialize($vo['value']);
foreach ($value as $n => &$d) {
$type = $attr[$n]['type'];
$extra = $attr[$n]['extra'];
if ($type == 'radio' || $type == 'select') {
if ($extra) {
$extArr = explode(' ', $extra[0]);
$d = $extArr[$d];
}
} elseif ($type == 'checkbox') {
$extArr = explode(' ', $extra[0]);
foreach ($d as &$v) {
if (isset($extArr[$v])) {
$v = $extArr[$v];
}
}
$d = implode(', ', $d);
} elseif ($type == 'datetime') {
$d = time_format($d);
} elseif ($type == 'picture') {
$d = get_cover_url($d);
} elseif ($type == 'cascade') {
$d = getCascadeTitle($d, $extra);
}
}
unset($vo['value']);
$vo = array_merge($vo, $value);
$vo['uid'] = get_nickname($vo['uid']);
}
$this->assign($list_data);
// dump ( $list_data );
$this->display();
}
示例8: get_name_by_status
/**
* 获取状态值对应的标题
*
* @author weiphp
*/
function get_name_by_status($val, $name, $model_id)
{
static $_name = array();
if (!isset($_name[$model_id])) {
$_name[$model_id] = array();
$map['extra'] = array('EXP', '!=""');
$map['model_id'] = $model_id;
$list = M('attribute')->where($map)->select();
foreach ($list as $attr) {
if (empty($attr['extra'])) {
continue;
}
$extra = parse_config_attr($attr['extra']);
if (is_array($extra) && !empty($extra)) {
$_name[$model_id][$attr['name']]['value'] = $extra;
$_name[$model_id][$attr['name']]['type'] = $attr['type'];
}
}
}
if ($_name[$model_id][$name]['type'] == 'checkbox') {
$valArr = explode(',', $val);
foreach ($valArr as $v) {
$res[] = empty($_name[$model_id][$name]['value'][$v]) ? $v : $_name[$model_id][$name]['value'][$v];
}
return implode(', ', $res);
} else {
return empty($_name[$model_id][$name]['value'][$val]) ? $val : $_name[$model_id][$name]['value'][$val];
}
}
示例9: survey
function survey()
{
$map['id'] = intval($_REQUEST['survey_id']);
$map['token'] = get_token();
$survey = M('survey')->where($map)->find();
$map['survey_id'] = $map['id'];
unset($map['id']);
$list = M('survey_question')->where($map)->order('sort asc, id asc')->select();
if (IS_POST) {
$map['uid'] = $this->mid;
$map['question_id'] = I('post.question_id', 0, 'intval');
$answer = M('survey_answer')->where($map)->find();
$data['cTime'] = time();
$data['answer'] = serialize($_POST['answer']);
if ($answer) {
M('survey_answer')->where($map)->save($data);
} else {
$data['survey_id'] = $map['survey_id'];
$data['token'] = $map['token'];
$data['question_id'] = $map['question_id'];
$data['uid'] = $map['uid'];
$data['openid'] = get_openid();
M('survey_answer')->add($data);
}
}
$question_id = I('post.next_id', 0, 'intval');
if ($question_id == '-1') {
redirect(U('finish', 'survey_id=' . $map['survey_id']));
}
if (empty($question_id)) {
$question = $list[0];
$next_id = isset($list[1]['id']) ? $list[1]['id'] : '-1';
} else {
foreach ($list as $k => $vo) {
if ($vo['id'] == $question_id) {
$question = $vo;
$next_id = isset($list[$k + 1]['id']) ? $list[$k + 1]['id'] : '-1';
}
}
}
$extra = parse_config_attr($question['extra']);
$this->assign('survey', $survey);
$this->assign('question', $question);
$this->assign('next_id', $next_id);
$this->assign('extra', $extra);
$this->display();
}
示例10: ask
function ask()
{
$param['ask_id'] = $ask_id = intval($_REQUEST['ask_id']);
$ask = D('Ask')->getAskInfo($ask_id);
$question_list = D('AskQuestion')->getQuestionsByAskid($ask_id);
$answer = D('AskAnswer')->myLastAnswer($ask_id);
$last_question = $question_list[$answer['question_id']];
$times = 0;
// 次数
if ($answer['is_correct'] && $last_question['is_last'] || $answer['question_id'] && !$last_question) {
// 重新开始进入
reset($question_list);
$question = current($question_list);
$times = $answer['times'] + 1;
} elseif ($answer) {
$times = intval($answer['times']);
$param['time_left'] = $last_question['wait_time'] - (NOW_TIME - $answer['cTime']);
if ($answer['is_correct']) {
// 上次已经回答正确
if (NOW_TIME - $answer['cTime'] > $last_question['wait_time']) {
// 已经到时间了,显示下一题
$flat = false;
foreach ($question_list as $qid => $v) {
if ($flat) {
$question = $v;
$flat = false;
break;
}
if ($qid == $answer['question_id']) {
$flat = true;
}
}
} else {
// 还没到时间,显示等待界面
redirect(U('wait', $param));
}
} else {
// 上次已经回答不对时
if ($param['time_left'] > 0) {
// 不到时间还不能重新回答
redirect(U('fail', $param));
// dump("aaaa");
} else {
// 可重新回答
$question = $last_question;
}
}
} else {
// 第一次进入
reset($question_list);
$question = current($question_list);
}
// 概率进入
$wait = session('percent_wait_' . $this->mid);
if ($wait) {
$time_left = $wait['wait'] - (NOW_TIME - $wait['time']);
if ($time_left > 0) {
redirect(U('percent', $param));
} else {
session('percent_wait_' . $this->mid, null);
}
}
$percent = intval($question['percent']);
if ($percent < 100) {
$rand = rand(1, 100);
if ($percent < $rand) {
// 未抢中
$wait = array('time' => NOW_TIME, 'wait' => $question['wait_time']);
session('percent_wait_' . $this->mid, $wait);
redirect(U('percent', $param));
}
}
// dump ( $question );
$extra = parse_config_attr($question['extra']);
$this->assign('ask', $ask);
$this->assign('question', $question);
$this->assign('extra', $extra);
$this->assign('times', $times);
$this->display();
}