public function action_list() { $cid = Arr::get($_GET, 'cid'); $where = array(); $where['cid'] = $cid; $where['status'] = 'open'; $where['ORDER'] = 'id DESC'; $where = array_filter($where); $m_article = Model::factory('article', 'cms'); $total = $m_article->count($where); $pager = new Pager($total, 10); $list = $m_article->select($pager->offset, $pager->size, $where)->as_array(); $m_category = Model::factory('category', 'cms'); $cat_list = $m_category->getAll()->as_array('id', 'name'); foreach ($list as &$item) { $item['cat_name'] = isset($cat_list[$item['cid']]) ? $cat_list[$item['cid']] : ''; } unset($item); if (isset($_GET['get_next_page'])) { $content = View::factory('article/list_incr'); $content->list = $list; $next_page = $pager->next_page ? $pager->url($pager->next_page, array('cid' => $cid, 'get_next_page' => 'ajax')) : ''; header('Content-Type: application/json; charset=utf-8'); $ret = array('content' => (string) $content, 'next_page' => $next_page); echo json_encode($ret); exit; } $this->content = View::factory('article_list'); $this->content->list = $list; $this->content->pager = $pager->render('common/pager'); $this->content->next_page = $pager->next_page ? $pager->url($pager->next_page, array('cid' => $cid, 'get_next_page' => 'ajax')) : ''; }
/** * Тег постраничной навигации * * @param array $config конфиг * @param int $total Общее кол-во страниц * * @return string формированный блок с постраничкой */ public static function pages($config, $total) { $config['total_items'] = $total; $pages = ''; if ($total > $config['items_per_page']) { $pagination = new Pager($config); // Сформированный блок с постраничкой $pages = $pagination->render(); } return $pages; }
public function action_list() { $database = $this->curr_db; $curr_table = $this->curr_table; $model = Model::factory($curr_table, $this->curr_db); $db = Cookie::get('db'); $db = json_decode($db, true); if (!isset($db[$database][$curr_table]) || !is_array($db[$database][$curr_table])) { $columns = $model->list_columns($curr_table)->as_array(null, 'Field'); $columns = array_map(function ($n) { return $n > 7 ? 0 : 1; }, array_flip($columns)); $db[$database][$curr_table] = $columns; Cookie::set('db', json_encode($db)); } else { $columns = $db[$database][$curr_table]; } $where = array(); $field_name = Arr::get($_GET, 'field_name'); $field_value = Arr::get($_GET, 'field_value'); $op = Arr::get($_GET, 'op', '='); if (!empty($field_name)) { $where[$field_name . '|' . $op] = $field_value; } $where = array_filter($where, 'strlen'); if (isset($_GET['sort'])) { list($field, $order) = explode('|', $_GET['sort']); $fields = array_keys($columns); if (in_array($field, $fields) && in_array($order, array('asc', 'desc'))) { $where['ORDER'] = $field . ' ' . $order; } } $total = $model->count($where); $pager = new Pager($total, 10); $list = $model->select($pager->offset, $pager->size, $where); $this->content = View::factory('myadmin/list'); $this->content->columns = $columns; $this->content->list = $list; $this->content->field = isset($field) ? $field : ''; $this->content->order = isset($order) ? $order : ''; $this->content->field_name = $field_name; $this->content->field_value = $field_value; $this->content->op = $op; $this->content->pager = $pager->render('myadmin/pager'); }
public function action_view() { $key = Arr::get($_GET, 'key', ''); $total = 1; $type = $this->getType($key); if ($type == 'List') { $total = $this->_redis->lSize($key); } elseif ($type == 'ZSet') { $total = $this->_redis->zCard($key); } $pager = new Pager($total, 2); $values = $this->getValue($key, $pager->offset, $pager->size); $content = View::factory('phpredmin/view'); $content->pager = $pager->render('phpredmin/pager'); $content->type = $type; $content->values = $values; echo $content; exit; }
public function action_list() { $where = array('member_id' => $this->user['id'], 'ORDER' => 'id DESC'); $m_order = Model::factory('orders', 'admin'); $size = 5; $total = $m_order->count($where); $pager = new Pager($total, $size); $order_list = $m_order->select($pager->offset, $size, $where)->as_array(); $deliver_status_arr = array('0' => '等待发货', '1' => '已发货'); $m_order_goods = Model::factory('order_goods', 'admin'); foreach ($order_list as &$item) { $order_id = $item['id']; $item['goods_list'] = $m_order_goods->getAll(array('order_id' => $order_id)); $item['deliver_status_str'] = isset($deliver_status_arr[$item['deliver_status']]) ? $deliver_status_arr[$item['deliver_status']] : ''; } unset($item); $this->content = View::factory('order_list'); $this->content->order_list = $order_list; $this->content->pager = $pager->render('common/pager'); }
<?php /** * 发送成功列表 * @author 潘洪学 panliu888@gmail.com * @create_date 2011-10 */ include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php'; Passport::RequireLogin(); $task = new Task(); switch (strtolower($_GET['action'])) { case 'del': $task->UpdateStatus(Task::DELETE_OK, intval($_GET['id']), '已取消'); break; case 'clear': $task->update(array('status' => Task::DELETE_OK, 'msg' => '被清空'), array('uid' => Passport::GetLoginUid(), 'status' => Task::OK)); redirect('?'); break; } $pager = new Pager($task->GetCount(Task::OK), 20); $TEMPLATE['list'] = $task->GetList(Task::OK, $pager->offset()); $TEMPLATE['pager'] = $pager->render(); $TEMPLATE['title'] = '已发送'; $TEMPLATE['login_name'] = Passport::GetLoginName(); $TEMPLATE['nav']['list_ok'] = 'current'; $smarty = new Template(); echo $smarty->r('list_ok');
public function render() { return Pager::render(Page::find($this->page_id)); }
public function action_index() { if (isset($_GET['get_vehicle_count'])) { unset($_GET['get_vehicle_count']); if ($this->auto_render === false) { $year_list = $this->_getYearList(); $miles_list = $this->_getMilesList(); $view = View::factory('vehicle/list_more'); $view->year_list = $year_list; $view->miles_list = $miles_list; echo $view; exit; } } if (isset($_GET['get_vehicle_series'])) { unset($_GET['get_vehicle_series']); if ($this->auto_render === false) { $series_list = array(); if (isset($this->_filter_array['brand_id'])) { $brand_id = $this->_filter_array['brand_id']; $series_list = $this->_getSeriesList($brand_id); } $view = View::factory('vehicle/list_series'); $view->series_list = $series_list; echo $view; exit; } } $city_list = $this->_getCityList(); $page_size = 12; $page_num = $this->request->param('page', 1); //*/ $ret = $this->_getVehicleList($page_num, $page_size); $vehicle_list = $ret['list']; $total = $ret['count']; $pager = new Pager($total, $page_size, 'route'); if (!empty($ret['query'])) { $this->_getColsFromQuery($ret['query']); } /*/ $ret = $this->_getVehicleList2($page_num, $page_size); $vehicle_list = $ret['data']['vehicles']; $total = $ret['data']['count']; $pager = new Pager($total, $page_size, 'route'); if (!empty($ret['query'])) { $this->_getColsFromQuery($ret['query']); } //*/ $this->_format_list($vehicle_list); if ($this->auto_render === false) { $view = View::factory('vehicle/list_vehicle'); $view->vehicle_list = $vehicle_list; echo $view; exit; } list($brand_top_list, $brand_list) = $this->_getBrandList(); $series_list = array(); if (isset($this->_filter_array['brand_id'])) { $brand_id = $this->_filter_array['brand_id']; $series_list = $this->_getSeriesList($brand_id); } list($price_list, $custom_price) = $this->_getPriceList(); $year_list = $this->_getYearList(); $miles_list = $this->_getMilesList(); $sort_list = $this->_getSortList(); $filter_list = $this->filter_list; /*uksort($filter_list, function ($a, $b) { $sort_filter = array_flip(array('brand', 'series', 'price', 'year', 'mile')); return $sort_filter[$a] > $sort_filter[$b]; });*/ $this->content = View::factory('vehicle_list'); $this->content->city_list = $city_list; $this->content->city_info = $this->city_info; $this->content->brand_top_list = $brand_top_list; $this->content->brand_list = $brand_list; $this->content->series_list = $series_list; $this->content->price_list = $price_list; $this->content->custom_price = $custom_price; $this->content->year_list = $year_list; $this->content->miles_list = $miles_list; $this->content->sort_list = $sort_list; $this->content->filter_list = $filter_list; $this->content->vehicle_list = $vehicle_list; //var_dump($pager->url($pager->next_page));exit; $this->content->pager = $pager->render('common/pager'); $this->content->total_items = $pager->total_items; $this->content->total_pages = $pager->total_pages; $this->content->curr_page = $pager->current_page; $this->content->page_url = $this->_getUrl(array('page' => '')); }