本文整理汇总了PHP中Pagination::getPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Pagination::getPage方法的具体用法?PHP Pagination::getPage怎么用?PHP Pagination::getPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagination
的用法示例。
在下文中一共展示了Pagination::getPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$type = MailBox::$IN;
if (isset($this->params['type'])) {
$type = $this->params['type'];
}
try {
$mailBox = new MailBox(User::getInstance(), $type);
} catch (MailBoxNullException $e) {
$this->error(ECode::$MAIL_NOBOX);
}
$this->notice = '邮件-' . $mailBox->desc;
$p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
App::import('vendor', "inc/pagination");
try {
$pagination = new Pagination($mailBox, 10);
$mails = $pagination->getPage($p);
} catch (MailDataNullException $e) {
$this->error(ECode::$MAIL_NOMAIL);
}
$info = false;
if ($mailBox->getTotalNum() > 0) {
App::import('Sanitize');
foreach ($mails as $v) {
$info[] = array("read" => $v->isRead(), "num" => $v->num, "sender" => $v->OWNER, "title" => Sanitize::html($v->TITLE), "time" => date("Y-m-d H:i:s", $v->POSTTIME), "size" => $v->EFFSIZE);
}
}
$this->set("type", $type);
$this->set("info", $info);
$this->set("totalNum", $mailBox->getTotalNum());
$this->set("curPage", $pagination->getCurPage());
$this->set("totalPage", $pagination->getTotalPage());
}
示例2: index
public function index()
{
if (!isset($this->params['type'])) {
$this->error(ECode::$REFER_NONE);
}
$type = $this->params['type'];
try {
$refer = new Refer(User::getInstance(), $type);
} catch (ReferNullException $e) {
$this->error(ECode::$REFER_NONE);
}
$count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.mail");
if (($count = intval($count)) <= 0) {
$count = Configure::read('pagination.mail');
}
if ($count > Configure::read('plugins.api.page_item_limit')) {
$count = Configure::read('pagination.mail');
}
$page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
$page = intval($page);
$pagination = new Pagination($refer, $count);
$articles = $pagination->getPage($page);
$wrapper = Wrapper::getInstance();
$info = array();
foreach ($articles as $v) {
$info[] = $wrapper->refer($v);
}
$data['description'] = $refer->getDesc();
$data['pagination'] = $wrapper->page($pagination);
$data['article'] = $info;
$this->set('data', $data);
}
示例3: threads
public function threads()
{
if (!isset($this->params['id'])) {
$this->error(ECode::$ARTICLE_NONE);
}
$id = $this->params['id'];
App::import('vendor', array("model/threads", "inc/pagination"));
try {
$threads = Threads::getInstance($id, $this->_board);
} catch (ThreadsNullException $e) {
$this->error(ECode::$ARTICLE_NONE);
}
$count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.article");
if (($count = intval($count)) <= 0) {
$count = Configure::read("pagination.article");
}
if ($count > Configure::read('plugins.api.page_item_limit')) {
$count = Configure::read("pagination.article");
}
$page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
$page = intval($page);
$pagination = new Pagination($threads, $count);
$articles = $pagination->getPage($page);
$wrapper = Wrapper::getInstance();
$info = array();
foreach ($articles as $v) {
$info[] = $wrapper->article($v, array('content' => true));
}
$data = $wrapper->article($threads, array('threads' => true));
$data['pagination'] = $wrapper->page($pagination);
$data['article'] = $info;
$this->set('data', $data);
$this->set('root', 'threads');
}
示例4: index
public function index()
{
$this->js[] = "forum.refer.js";
$this->css[] = "mail.css";
$type = Refer::$AT;
$pageBar = "";
if (isset($this->params['type'])) {
$type = $this->params['type'];
}
try {
$refer = new Refer(User::getInstance(), $type);
} catch (ReferNullException $e) {
$this->error(ECode::$REFER_NONE);
}
$p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
App::import('vendor', "inc/pagination");
try {
$pagination = new Pagination($refer, Configure::read("pagination.mail"));
$articles = $pagination->getPage($p);
} catch (Exception $e) {
$this->error(ECode::$REFER_NONE);
}
if ($refer->getTotalNum() > 0) {
$info = array();
App::import('Sanitize');
foreach ($articles as $v) {
$info[] = array("index" => $v['INDEX'], "id" => $v['ID'], "board" => $v['BOARD'], "user" => $v['USER'], "title" => Sanitize::html($v['TITLE']), "time" => date("Y-m-d H:i:s", $v['TIME']), "read" => $v['FLAG'] === Refer::$FLAG_READ);
}
$this->set("info", $info);
}
$link = "{$this->base}/refer/{$type}?p=%page%";
$this->set("pageBar", $pagination->getPageBar($p, $link));
$this->set("pagination", $pagination);
$this->set("type", $type);
}
示例5: box
public function box()
{
if (!isset($this->params['type'])) {
$this->error(ECode::$MAIL_NOBOX);
}
$type = $this->params['type'];
try {
$mailBox = new MailBox(User::getInstance(), $type);
} catch (MailBoxNullException $e) {
$this->error(ECode::$MAIL_NOBOX);
}
$count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.mail");
if (($count = intval($count)) <= 0) {
$count = Configure::read('pagination.mail');
}
if ($count > Configure::read('plugins.api.page_item_limit')) {
$count = Configure::read('pagination.mail');
}
$page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
$page = intval($page);
$pagination = new Pagination($mailBox, $count);
$mails = $pagination->getPage($page);
$wrapper = Wrapper::getInstance();
$info = array();
foreach ($mails as $v) {
$info[] = $wrapper->mail($v);
}
$data['description'] = $mailBox->desc;
$data['pagination'] = $wrapper->page($pagination);
$data['mail'] = $info;
$this->set('data', $data);
$this->set('root', 'mailbox');
}
示例6: index
/**
* Call class Pagination to show number of pages
* Count all existing threads
*/
public function index()
{
$paginate = new Pagination();
$page = $paginate->getPage(Thread::count());
$pagination_links = $paginate->rangeRows($page['pagenum'], $page['last_page']);
$threads = Thread::getAll($pagination_links['max']);
$this->set(get_defined_vars());
}
示例7: threads
public function threads()
{
if (!isset($this->params['id'])) {
$this->error(ECode::$ARTICLE_NONE);
}
$id = $this->params['id'];
App::import('vendor', array("model/threads", "inc/pagination"));
try {
$threads = Threads::getInstance($id, $this->_board);
} catch (ThreadsNullException $e) {
$this->error(ECode::$ARTICLE_NONE);
}
//filter author
$auF = $au = false;
if (isset($this->params['url']['au'])) {
$tmp = $threads->getRecord(1, $threads->getTotalNum());
$auF = array();
$au = trim($this->params['url']['au']);
foreach ($tmp as $v) {
if ($v->OWNER == $au) {
$auF[] = $v;
}
}
$auF = new ArrayPageableAdapter($auF);
}
$count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.article");
if (($count = intval($count)) <= 0) {
$count = Configure::read("pagination.article");
}
if ($count > Configure::read('plugins.api.page_item_limit')) {
$count = Configure::read("pagination.article");
}
$page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
$page = intval($page);
$pagination = new Pagination(false !== $au ? $auF : $threads, $count);
$articles = $pagination->getPage($page);
$wrapper = Wrapper::getInstance();
$info = array();
foreach ($articles as $v) {
$info[] = $wrapper->article($v, array('content' => true));
}
$data = $wrapper->article($threads, array('threads' => true));
$data['pagination'] = $wrapper->page($pagination);
$data['article'] = $info;
$this->set('data', $data);
$this->set('root', 'threads');
}
示例8: index
public function index()
{
$this->js[] = "forum.adv.js";
$this->css[] = "adv.css";
$p = 1;
if (isset($this->params['url']['p'])) {
$p = $this->params['url']['p'];
}
$adv = new Adv();
$adv->type = $this->_type;
$search = array();
if (isset($this->params['url']['remark']) && trim($this->params['url']['remark']) != '') {
$search['remark'] = $adv->search = trim($this->params['url']['remark']);
}
if (isset($this->params['url']['sTime']) && trim($this->params['url']['sTime']) != '') {
$search['sTime'] = $adv->search_start = trim($this->params['url']['sTime']);
}
if (isset($this->params['url']['eTime']) && trim($this->params['url']['eTime']) != '') {
$search['eTime'] = $adv->search_end = trim($this->params['url']['eTime']);
}
App::import('vendor', "inc/pagination");
$page = new Pagination($adv, 30);
$res = $page->getPage($p);
$ret['page'] = $page->getCurPage();
$ret['total'] = $adv->getTotalNum();
$ret['aPath'] = Configure::read("adv.path");
foreach ($res as $v) {
$ret['info'][] = $v;
}
$this->set($ret);
$this->set($search);
$this->set("dir", Configure::read('adv.path'));
$this->set("type", $this->_type == 1 || $this->_type == 2 ? true : false);
$this->set("advType", $this->_type);
$this->set("hasPrivilege", isset($res[0]['privilege']) && '1' == $res[0]['privilege']);
$query = '';
foreach ($search as $k => $v) {
$query .= '&' . $k . '=' . $v;
}
$this->set("pageBar", $page->getPageBar($p, "?p=%page%" . $query));
$this->set("pagination", $page);
}
示例9: index
public function index()
{
$u = User::getInstance();
try {
App::import('Sanitize');
$p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
$this->notice = "°æÃæ-{$this->_board->DESC}({$this->_board->NAME})";
$page = new Pagination($this->_board, Configure::read("pagination.threads"));
$threads = $page->getPage($p);
$info = false;
$curTime = strtotime(date("Y-m-d", time()));
$pageArticle = Configure::read("pagination.article");
if ($this->_board->getMode() === Board::$THREAD) {
foreach ($threads as $v) {
$pages = ceil($v->articleNum / $pageArticle);
$last = $v->LAST;
$postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME);
$replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME);
$info[] = array("tag" => $v->isTop() ? "top" : ($v->isM() || $v->isG() ? "m" : false), "title" => Sanitize::html($v->TITLE), "poster" => $v->isSubject() ? $v->OWNER : "ÔÌûÒÑɾ³ý", "postTime" => $postTime, "gid" => $v->ID, "last" => $last->OWNER, "replyTime" => $replyTime, "num" => $v->articleNum - 1, "page" => $pages);
}
$threads = true;
} else {
foreach ($threads as $v) {
$postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME);
$info[] = array("tag" => $v->isTop() ? "top" : ($v->isM() || $v->isG() ? "m" : false), "title" => Sanitize::html($v->TITLE), "poster" => $v->OWNER, "postTime" => $postTime, "gid" => $v->ID, "subject" => $v->isSubject(), "top" => $v->isTop(), "m" => $v->isM(), "pos" => $v->getPos());
}
$threads = false;
}
$this->set("threads", $threads);
$this->set("info", $info);
$this->set("totalPage", $page->getTotalPage());
$this->set("curPage", $page->getCurPage());
$this->set("bName", $this->_board->NAME);
$this->set("canPost", $this->_board->hasPostPerm($u) ? 1 : 0);
$this->set("mode", $this->_board->getMode());
$this->set("sort", $this->_board->isSortMode());
$this->set("isBM", $u->isBM($this->_board));
$this->set("isAdmin", $u->isAdmin());
} catch (BoardNullException $e) {
$this->error(Board::$BOARD_NONE);
}
}
示例10: index
public function index()
{
$wrapper = Wrapper::getInstance();
$data = array();
$data = $wrapper->board($this->_board, array('status' => true));
App::import('vendor', 'inc/pagination');
$count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.threads");
$page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
if (($count = intval($count)) <= 0) {
$count = Configure::read("pagination.threads");
}
if ($count > Configure::read('plugins.api.page_item_limit')) {
$count = Configure::read("pagination.article");
}
$page = intval($page);
$pagination = new Pagination($this->_board, $count);
$articles = $pagination->getPage($page);
$data['pagination'] = $wrapper->page($pagination);
foreach ($articles as $v) {
$data['article'][] = $wrapper->article($v, array('threads' => $this->_board->getMode() == Board::$THREAD));
}
$this->set('data', $data);
}
示例11: index
public function index()
{
$this->js[] = "forum.mail.js";
$this->css[] = "mail.css";
$type = MailBox::$IN;
$pageBar = "";
if (isset($this->params['type'])) {
$type = $this->params['type'];
}
try {
$mailBox = new MailBox(User::getInstance(), $type);
} catch (MailBoxNullException $e) {
$this->error(ECode::$MAIL_NOBOX);
}
$p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
App::import('vendor', "inc/pagination");
try {
$pagination = new Pagination($mailBox, Configure::read("pagination.mail"));
$mails = $pagination->getPage($p);
} catch (MailDataNullException $e) {
$this->error(ECode::$MAIL_NOMAIL);
}
if ($mailBox->getTotalNum() > 0) {
$info = array();
App::import('Sanitize');
foreach ($mails as $v) {
$info[] = array("tag" => $this->_getTag($v), "read" => $v->isRead(), "num" => $v->num, "sender" => $v->OWNER, "title" => Sanitize::html($v->TITLE), "time" => date("Y-m-d H:i:s", $v->POSTTIME), "size" => $v->EFFSIZE);
}
$this->set("info", $info);
}
$link = "{$this->base}/mail/{$type}?p=%page%";
$this->set("pageBar", $pagination->getPageBar($p, $link));
$this->set("pagination", $pagination);
$this->set("type", $type);
$this->set("desc", $mailBox->desc);
}
示例12: index
public function index()
{
$this->js[] = "forum.friend.js";
$this->css[] = "mail.css";
$p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
try {
$f = new Friend(User::getInstance());
App::import("vendor", "inc/pagination");
$pagination = new Pagination($f, Configure::read("pagination.friend"));
$friends = $pagination->getPage($p);
} catch (FriendNullException $e) {
$this->error();
}
if ($f->getTotalNum() > 0) {
$info = array();
foreach ($friends as $v) {
$info[] = array("fid" => $v->userid, "desc" => $v->exp);
}
$this->set("friends", $info);
}
$link = "{$this->base}/friend?p=%page%";
$this->set("pageBar", $pagination->getPageBar($p, $link));
$this->set("pagination", $pagination);
}
示例13: tmpl
public function tmpl()
{
$article = $this->_postInit();
App::import("vendor", "model/template");
App::import('Sanitize');
$this->js[] = "forum.tmpl.js";
$this->css[] = "post.css";
$this->_getNotice();
$this->notice[] = array("url" => "", "text" => "模版发文");
if (isset($this->params['url']['tmplid'])) {
//template question
$id = trim($this->params['url']['tmplid']);
try {
$t = Template::getInstance($id, $this->_board);
} catch (TemplateNullException $e) {
$this->error(ECode::$TMPL_ERROR);
}
$info = array();
try {
foreach (range(0, $t->CONT_NUM - 1) as $i) {
$q = $t->getQ($i);
$info[$i] = array("text" => Sanitize::html($q['TEXT']), "len" => $q['LENGTH']);
}
} catch (TemplateQNullException $e) {
$this->error();
}
$this->set("tmplId", $id);
$this->set("bName", $this->_board->NAME);
$this->set("info", $info);
$this->set("num", $t->NUM);
$this->set("tmplTitle", Sanitize::html($t->TITLE));
$this->set("title", $t->TITLE_TMPL);
$this->render("tmpl_que");
} else {
//template list
try {
$page = new Pagination(Template::getTemplates($this->_board));
} catch (TemplateNullException $e) {
$this->error(ECode::$TMPL_ERROR);
}
$info = $page->getPage(1);
foreach ($info as &$v) {
$v = array("name" => Sanitize::html($v->TITLE), "num" => $v->CONT_NUM);
}
$this->set("info", $info);
$this->set("bName", $this->_board->NAME);
}
}
示例14: Pagination
<?php
require_once 'config.php';
require_once DIR_TOOLS . 'connect_db.php';
require_once DIR_INCLUDES . 'pagination.php';
$pagination = new Pagination($pdo, IMAGES_PER_PAGE);
$current_page = isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1;
$page_items = $pagination->getPage($current_page);
$total_pages = $pagination->totalPages();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Image Gallery</title>
<link href="assets/css/main.css" rel="stylesheet" type="text/css" media="screen">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="assets/javascript/main.js"></script>
<script>
console.log("Current Page: <?php
echo $current_page;
?>
");
</script>
</head>
<body>
示例15: index
public function index()
{
$this->css[] = "xwidget.css";
$this->css['plugin']['vote'][] = "vote.css";
$this->js['plugin']['vote'][] = "vote.js";
$this->cache(false);
@($category = $this->params['url']['c']);
$u = User::getInstance();
$time = time();
$yes = $time - 86400;
$search = '';
if (isset($this->params['url']['s'])) {
$search = trim(rawurldecode($this->params['url']['s']));
$search = nforum_iconv('utf-8', $this->encoding, $search);
if ('' != $search) {
App::import('Sanitize');
$this->set('search', Sanitize::html($search));
$search = addslashes($search);
$search = " and (uid like '%{$search}%' or subject like '%{$search}%' or `desc` like '%{$search}%')";
}
}
switch ($category) {
case 'hot':
$title = "热门投票";
$sql = "select * from pl_vote where status=1 and end>{$yes} {$search} order by num desc, vid desc";
break;
case 'list':
@($user = $this->params['url']['u']);
if ($u->userid != $user) {
try {
$user = User::getInstance($user);
} catch (UserNullException $e) {
$this->error(ECode::$USER_NOID);
}
} else {
$user = $u;
}
$title = $user->userid == $u->userid ? "我的投票" : "{$user->userid}的投票";
$this->set("vote_user", $user->userid);
$sql = "select * from pl_vote where status=1 and uid='{$user->userid}' {$search} order by vid desc";
break;
case 'all':
$title = "全部投票";
$sql = "select * from pl_vote where status=1 {$search} order by vid desc";
break;
case 'join':
$this->requestLogin();
$title = "我参与的投票";
$sql = "select * from pl_vote where status=1 and vid in (select vid from pl_vote_result where uid='{$u->userid}') {$search} order by vid desc";
break;
case 'del':
if (!$u->isAdmin()) {
$this->error('你无权查看此类投票');
}
$title = "已删除的投票";
$sql = "select * from pl_vote where status=0 {$search} order by vid desc";
break;
default:
$title = "最新投票";
$category = "new";
$sql = "select * from pl_vote where status=1 and end>{$yes} {$search} order by vid desc";
}
$list = new VoteList($sql);
App::import("vendor", "inc/pagination");
$page = new Pagination($list, 10);
$p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
$res = $page->getPage($p);
if (count($res) == 0) {
$info = false;
} else {
$info = array();
App::import('Sanitize');
foreach ($res as $v) {
$info[] = array("vid" => $v->vid, "title" => Sanitize::html($v->subject), "start" => date("Y-m-d H:i:s", $v->start), "end" => date("Y-m-d", $v->end), "num" => $v->num, "isEnd" => $v->isEnd(), "isDel" => $v->isDeleted(), "admin" => $u->userid === $v->uid || $u->isAdmin(), "uid" => $v->uid);
}
}
$query = $this->params['url'];
unset($query['url']);
unset($query['p']);
unset($query['ext']);
foreach ($query as $k => &$v) {
$v = $k . '=' . rawurlencode($v);
}
$query[] = "p=%page%";
$link = "{$this->base}/vote?" . join("&", $query);
$pageBar = $page->getPageBar($p, $link);
$this->set("pageBar", $pageBar);
$this->set("totalNum", $list->getTotalNum());
$this->set("info", $info);
$this->set("category", $category);
$this->set("voteTitle", $title);
$this->notice[] = array("url" => "", "text" => $title);
/* right rank*/
$week = nforum_cache_read("vote_week");
$month = nforum_cache_read("vote_month");
$year = nforum_cache_read("vote_year");
$this->set("week", $week);
$this->set("month", $month);
$this->set("year", $year);
/* right rank end*/
//.........这里部分代码省略.........