public function lists() { $cid = I('get.cid', 0, 'intval'); $p = I('get.p', 1, 'intval'); $sort = I('post.sort', '', 'htmlspecialchars'); $by = I('post.by', '', 'htmlspecialchars'); if (!in_array($sort, array('id', 'name', 'pricespe', 'dateline'))) { $sort = 'id'; } if (!in_array($by, array('desc', 'asc'))) { $by = 'desc'; } if (S($strFid_class) == '') { $classChildren = D('Cate')->getChildren($cid); $classChildren[count($classChildren)] = $cid; S($strFid_class, implode(',', $classChildren)); //取得所有子类 } $model = D('Products'); $map['isdown'] = array('neq', 1); $map['cateid'] = array('in', S($strFid_class)); $count = $model->where($map)->count(); $list = $model->where($map)->order("{$sort} {$by}")->page($p, $this->pagesize)->select(); $cateinfo = get_cate($cid); $this->assign('sort', $sort); $this->assign('by', $by); $this->assign('cateinfo', $cateinfo); $this->assign('list', $list); $this->assign('count', $count ? $count : 0); $this->assign('totalpage', ceil($count / $this->pagesize)); $this->display($p > 1 ? 'Product-block' : 'Cate-lists'); }
public function _initialize() { if (isset($_GET['cate'])) { $cateInfo = get_cate($_GET['cate']); $this->assign('cateName', $cateInfo['name']); } }
echo U('Article/index?cate_id=' . $vo['category_id'] . '&pid=' . $vo['id']); ?> "><?php echo $vo["title"]; ?> </a></td> <td><span><?php echo get_subdocument_count($vo['id']); ?> </span></td> <td><span><?php echo get_document_type($vo['type']); ?> </span></td> <td><span><?php echo get_cate($vo['category_id']); ?> </span></td> <td><?php echo $vo["level"]; ?> </td> <td><span><?php echo time_format($vo["update_time"]); ?> </span></td> <td><?php echo $vo["view"]; ?> </td> <td><?php
public function focus() { $GLOBALS['tmpl']->assign("page_title", "关注的项目"); if (!$GLOBALS['user_info']) { app_redirect(url_wap("user#login")); } $page_size = intval($GLOBALS['m_config']['page_size']); $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $s = intval($_REQUEST['s']); if ($s == 3) { $sort_field = " d.support_amount desc "; } if ($s == 1) { $sort_field = " d.support_count desc "; } if ($s == 2) { $sort_field = " d.support_amount - d.limit_price desc "; } if ($s == 0) { $sort_field = " d.end_time asc "; } $GLOBALS['tmpl']->assign("s", $s); $f = intval($_REQUEST['f']); if ($f == 0) { $cond = " 1=1 "; } if ($f == 1) { $cond = " d.begin_time < " . NOW_TIME . " and (d.end_time = 0 or d.end_time > " . NOW_TIME . ") "; } if ($f == 2) { $cond = " d.end_time <> 0 and d.end_time < " . NOW_TIME . " and d.is_success = 1 "; } //过期成功 if ($f == 3) { $cond = " d.end_time <> 0 and d.end_time < " . NOW_TIME . " and d.is_success = 0 "; } //过期失败 $GLOBALS['tmpl']->assign("f", $f); $app_sql = " " . DB_PREFIX . "deal_focus_log as dfl left join " . DB_PREFIX . "deal as d on d.id = dfl.deal_id where dfl.user_id = " . intval($GLOBALS['user_info']['id']) . " and d.is_effect = 1 and d.is_delete = 0 and " . $cond . " "; $deal_list = $GLOBALS['db']->getAll("select d.*,dfl.id as fid from " . $app_sql . " order by " . $sort_field . " limit " . $limit); $deal_count = $GLOBALS['db']->getOne("select count(*) from " . $app_sql); foreach ($deal_list as $k => $v) { $deal_list[$k]['remain_days'] = ceil(($v['end_time'] - NOW_TIME) / (24 * 3600)); $deal_list[$k]['percent'] = round($v['support_amount'] / $v['limit_price'] * 100); $deal_list[$k]['cate'] = get_cate($v['cate_id']); //积分商城项目 if ($deal_list[$k]['is_ap'] == "1") { $deal_list[$k]['support_amount'] *= $deal_list[$k]['ap_ratio']; } } // $page = new Page($deal_count,$page_size); //初始化分页对象 // $p = $page->show(); $page = get_pages(ceil($deal_count / $page_size)); $GLOBALS['tmpl']->assign('page', $page); $GLOBALS['tmpl']->assign('deal_list', $deal_list); $GLOBALS['tmpl']->display("account_focus.html"); }
$i = 0; $__LIST__ = $list; if (count($__LIST__) == 0) { echo ""; } else { foreach ($__LIST__ as $key => $vo) { $mod = $i % 2; ++$i; ?> <tr> <td><?php echo $vo["id"]; ?> </td> <td><?php echo get_cate($vo["cid"], 'name'); ?> </td> <td><?php echo get_username($vo["uid"]); ?> </td> <td><a href="<?php echo U('Home/Index/artc', array('id' => $vo['id'])); ?> " target="_blank"><?php echo $vo["title"]; ?> </a></td> <td><?php echo getStatus($vo['status']);
public static function get_cate_name($id) { return get_cate($id, 'name'); }
public function index() { $is_ap = $_REQUEST['isap']; //判断是否是爱前进积分商城 //积分商城现判断用户合法性 if ($is_ap == 1) { $this->ap_login(); } $page_title = $is_ap == 1 ? "积分商城" : "推荐项目"; //获取页码 $p = $_REQUEST['p'] ? intval($_REQUEST['p']) : 1; $to_num = ($p - 1) * 10; $condition = " d.is_delete = 0 and d.is_effect = 1 "; if ($is_ap == 1) { $condition .= "and (d.is_ap = 1 or d.is_ap = 2) "; } else { $condition .= "and (d.is_ap = 0 or d.is_ap = 2) "; } //积分商城时需判断 $limit = $to_num . ' , 10'; /* * 增加搜索条件 * 1.cate 分类搜索 * 2.status 状态搜索 * status=1 已成功 status=2 失败 status=3 筹资中 status=4 长期项目 status=0 未开始 all 全部 3.keyword 关键字搜索 * */ if ($_REQUEST['keyword']) { //keyword $condition .= "and d.name like N'%"; $condition .= urldecode($_REQUEST['keyword']) . "%' "; $page_title = "搜索结果"; } if ($_REQUEST['cate']) { //cate $cates_condition = $_REQUEST['cate'] !== "all" ? explode(',', $_REQUEST['cate']) : ""; if ($cates_condition) { $condition .= 'and ('; for ($i = 0; $i < count($cates_condition); $i++) { $condition .= ' d.cate_id = '; $condition .= $cates_condition[$i]; if ($i < count($cates_condition) - 1) { $condition .= ' or'; } } $condition .= ")"; } $page_title = "搜索结果"; } if (isset($_REQUEST['status'])) { //status $status = $_REQUEST['status'] !== "all" ? explode(',', $_REQUEST['status']) : ""; $status_condition = ""; if (!empty($status[0])) { foreach ($status as $key => $v) { $status_condition .= $this->get_status_condition($v); //获取该状态sql语句 if ($key != count($status) - 1) { $status_condition .= ' or '; } } $condition .= ' and '; $condition .= $status_condition; $page_title = "搜索结果"; } } /*search condition END*/ // echo $condition; $result = get_deal_list($limit, $condition); $index_list = $result['list']; $deal_list = array(); $time = time(); foreach ($index_list as $k => $v) { if ($v['image'] != '') { $v['image'] = get_abs_img_root_wap(get_spec_image($v['image'], 560, 220, 1)); } if ($v['start_time'] > $time) { $tmp_start_day = ceil(($v['start_time'] - $time) / 86400); $v['show'] = "还有" . $tmp_start_day . "天开始"; $v['showtype'] = 1; } elseif ($time > $v['end_time']) { $v['show'] = "已过期"; $v['showtype'] = 2; } else { $tmp_end_day = ceil(($v['end_time'] - $time) / 86400); $v['show'] = $tmp_end_day; $v['showtype'] = 3; } $v['cate_name'] = get_cate($v['cate_id']); //如果为积分商城,则将总数*ratio后显示 if ($is_ap == 1) { $v['support_amount'] = (int) $v['support_amount'] * (int) $v['ap_ratio']; $v['limit_price'] = (int) $v['limit_price'] * (int) $v['ap_ratio']; } $deal_list[] = $v; } //获取页面分页数据 // $alldealnum = $GLOBALS['db']->getRow(" select count(id) as num from ".DB_PREFIX."deal as d where ".$condition); $allPNum = ceil($result['rs_count'] / 10); $page = get_pages($allPNum); //获取所有分类 $cates = getCateList(); // print_r($deal_list); $GLOBALS['tmpl']->assign('page', $page); //数量有待验证 $GLOBALS['tmpl']->assign('result_count', ceil($result['rs_count'])); $GLOBALS['tmpl']->assign('page_title', $page_title); $GLOBALS['tmpl']->assign('cates', $cates); $GLOBALS['tmpl']->assign('deal_list', $deal_list); if ($is_ap == 1) { $GLOBALS['tmpl']->display("ap_deals_index.html"); exit; } $GLOBALS['tmpl']->display("deals_index.html"); }