public function lists($model = null, $page = 0)
 {
     is_array($model) || ($model = $this->getModel($this->model_name));
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $fields = $list_data['fields'];
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $list_data['list_data'] = $this->get_data($map);
     foreach ($list_data['list_data'] as &$v) {
         $v['type'] = get_name_by_status($v['type'], 'type', $model['id']);
     }
     $this->assign($list_data);
     //dump($list_data);
     $this->display();
 }
 function getInfo($id, $update = false, $data = array())
 {
     $key = 'Award_getInfo_' . $id;
     $info = S($key);
     if ($info === false || $update) {
         $info = (array) (empty($data) ? $this->find($id) : $data);
         if (count($info) != 0) {
             $model = getModelByName($this->tableName);
             $info['img_url'] = get_cover_url($info['img'], 100, 100);
             $info['type_name'] = get_name_by_status($info['award_type'], 'award_type', $model['id']);
             if ($info['award_type'] == 0) {
                 //             		$info['price']=$info['score'].'积分';
                 $info['award_title'] = $info['score'] . '积分';
             } else {
                 if ($info['award_type'] == 1) {
                     //             		$info['price'] = $info['price']==0?'未报价':$info['price'];
                     $info['award_title'] = $info['price'] == 0 ? '' : '价值 ' . intval($info['price']) . '元';
                 } else {
                     if ($info['award_type'] == 2) {
                         $coupon = D('Addons://Coupon/Coupon')->getInfo($info['coupon_id']);
                         $info['award_title'] = $coupon['title'];
                         $info['coupon_num'] = $coupon['num'];
                     } else {
                         if ($info['award_type'] == 3) {
                             $coupon = D('Addons://ShopCoupon/Coupon')->getInfo($info['coupon_id']);
                             $info['coupon_num'] = $coupon['num'];
                             $info['award_title'] = $coupon['title'];
                         } else {
                             if ($info['award_type'] == 4) {
                                 $info['award_title'] = '返现金额 ' . $info['money'] . '元';
                             }
                         }
                     }
                 }
             }
         }
         S($key, $info, 86400);
     }
     return $info;
 }
 public function special_lists($model = null, $page = 0)
 {
     $menu_id = I('menu_id');
     is_array($model) || ($model = $this->getModel($this->model_name));
     //if (!$menu_id) {
     //获取已发布个性菜单列表
     $menulists = D('CustomMenuType')->get_menu_show(1);
     //dump($menulists );
     //判断是否存在发布的默认菜单
     if (!$menulists) {
         $this->redirect('addon/CustomMenu/CustomMenuType/menu_lists', array('type' => 1));
     }
     //获取最新发布的个性菜单,展示出来
     if (!$menu_id) {
         $menu_id = D('CustomMenuType')->get_menu_show(2);
     }
     //dump($menu_id );
     $this->assign('menulists', $menulists);
     //}
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $fields = $list_data['fields'];
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $list_data['list_data'] = $this->get_data($menu_id, $map);
     foreach ($list_data['list_data'] as &$v) {
         $v['type'] = get_name_by_status($v['type'], 'type', $model['id']);
     }
     $this->assign($list_data);
     //获取分组列表
     $auth_group = D('CustomMenuType')->get_group_lists();
     $this->assign('auth_group', $auth_group);
     //获取菜单详情
     $menu_info = D('CustomMenuType')->get_menu_info($menu_id);
     //dump($menu_info);
     $this->assign('menu_info', $menu_info);
     $this->display();
 }
Example #4
0
 public function common_export($model = null, $order = 'id desc', $return = false)
 {
     set_time_limit(0);
     // 获取模型信息
     is_array($model) || ($model = $this->getModel($model));
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $grids = $list_data['list_grids'];
     $fields = $list_data['fields'];
     foreach ($grids as $v) {
         if ($v['title'] == '操作') {
             array_pop($grids);
         } else {
             $arr = explode('|', $v['field']);
             if (count($arr) > 1) {
                 $fun[$arr[0]] = $arr[1];
             }
             $ht[$arr[0]] = $v['title'];
         }
     }
     $dataArr[0] = $ht;
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $name = parse_name(get_table_name($model['id']), true);
     $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order($order)->select();
     if ($data) {
         foreach ($data as &$vo) {
             foreach ($vo as $name => &$vv) {
                 if (isset($fun[$name])) {
                     if ($fun[$name] == 'get_name_by_status') {
                         $vv = get_name_by_status($vv, $name, $model['id']);
                     } else {
                         $vv = call_user_func($fun[$name], $vv);
                     }
                 }
             }
             foreach ($ht as $key => $val) {
                 $newArr[$key] = empty($vo[$key]) ? ' ' : $vo[$key];
             }
             $vo = $newArr;
         }
         $dataArr = array_merge($dataArr, $data);
     }
     if ($return) {
         return $dataArr;
     } else {
         outExcel($dataArr, $map['module']);
     }
 }
 function export()
 {
     set_time_limit(0);
     // 获取模型信息
     $model = $this->model;
     // 解析列表规则
     $list_data = $this->_list_grid($model);
     $grids = $list_data['list_grids'];
     $fields = $list_data['fields'];
     foreach ($grids as $v) {
         if ($v['title'] == '操作') {
             array_pop($grids);
         } else {
             $arr = explode('|', $v['field'][0]);
             if (count($arr) > 1) {
                 $fun[$arr[0]] = $arr[1];
             }
             $ht[$arr[0]] = $v['title'];
         }
     }
     $dataArr[0] = $ht;
     // 搜索条件
     $map = $this->_search_map($model, $fields);
     $map['ask_id'] = $this->ask_id;
     $name = parse_name(get_table_name($model['id']), true);
     $data = M($name)->field(empty($fields) ? true : $fields)->where($map)->order($order)->select();
     if ($data) {
         $qdao = D('AskQuestion');
         foreach ($data as &$vv) {
             $user = get_followinfo($vv['uid']);
             $vv['nickname'] = $user['nickname'];
             $vv['times'] += 1;
             $vv['question_id'] = $qdao->getQuestionTitle($vv['question_id'], $this->ask_id);
             $vv['answer'] = implode(', ', unserialize($vv['answer']));
             $vv['is_correct'] = $vv['is_correct'] == 1 ? '是' : '否';
         }
         foreach ($data as &$vo) {
             foreach ($vo as $name => &$vv) {
                 if (isset($fun[$name])) {
                     if ($fun[$name] == 'get_name_by_status') {
                         $vv = get_name_by_status($vv, $name, $model['id']);
                     } else {
                         $vv = call_user_func($fun[$name], $vv);
                     }
                 }
             }
             foreach ($ht as $key => $val) {
                 $newArr[$key] = empty($vo[$key]) ? ' ' : $vo[$key];
             }
             $vo = $newArr;
         }
         $dataArr = array_merge($dataArr, $data);
     }
     if ($return) {
         return $dataArr;
     } else {
         outExcel($dataArr, $map['module']);
     }
 }
Example #6
0
function get_list_field($data, $grid, $model)
{
    // 获取当前字段数据
    foreach ($grid['field'] as $field) {
        $array = explode('|', $field);
        $array[0] = trim($array[0]);
        $temp = $data[$array[0]];
        // 函数支持
        if (isset($array[1])) {
            if ($array[1] == 'get_name_by_status') {
                $temp = get_name_by_status($temp, $array[0], $model['id']);
            } else {
                $temp = call_user_func($array[1], $temp);
            }
        }
        $data2[$array[0]] = $temp;
    }
    if (!empty($grid['format'])) {
        $value = preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use($data2) {
            return $data2[$match[1]];
        }, $grid['format']);
    } else {
        $value = implode(' ', $data2);
    }
    // 链接支持
    if (!empty($grid['href'])) {
        $links = explode(',', $grid['href']);
        foreach ($links as $link) {
            $array = explode('|', $link);
            $href = $array[0];
            if (preg_match('/^\\[([a-z_]+)\\]$/', $href, $matches)) {
                $val[] = $data2[$matches[1]];
            } else {
                $show = isset($array[1]) ? $array[1] : $value;
                // 增加跳转方式处理 weiphp
                $target = '_self';
                if (preg_match('/target=(\\w+)/', $href, $matches)) {
                    $target = $matches[1];
                    $href = str_replace('&' . $matches[0], '', $href);
                }
                // 替换系统特殊字符串
                $href = str_replace(array('[DELETE]', '[EDIT]', '[MODEL]'), array('del?id=[id]&model=[MODEL]', 'edit?id=[id]&model=[MODEL]', $model['id']), $href);
                // 替换数据变量
                $href = preg_replace_callback('/\\[([a-z_]+)\\]/', function ($match) use($data) {
                    return $data[$match[1]];
                }, $href);
                // 兼容多种写法
                if (strpos($href, '?') === false && strpos($href, '&') !== false) {
                    $href = preg_replace("/&/i", "?", $href, 1);
                }
                if ($show == '删除') {
                    $val[] = '<a class="confirm"   href="' . urldecode(U($href, $GLOBALS['get_param'])) . '">' . $show . '</a>';
                } else {
                    $val[] = '<a  target="' . $target . '" href="' . urldecode(U($href, $GLOBALS['get_param'])) . '">' . $show . '</a>';
                }
            }
        }
        $value = implode(' ', $val);
    }
    return $value;
}