Example #1
0
 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());
 }
Example #2
0
 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);
 }
Example #3
0
 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');
 }
Example #4
0
 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);
 }
Example #5
0
 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');
 }
 /** 
  * 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());
 }
Example #7
0
 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');
 }
Example #8
0
 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);
 }
Example #9
0
 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);
     }
 }
Example #10
0
 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);
 }
Example #11
0
 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);
 }
Example #12
0
 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);
 }
Example #13
0
 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);
     }
 }
Example #14
0
<?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>
Example #15
0
 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*/
 }
Example #16
0
 /* Extract Pagination Paramaters */
 $rowsPerPage = isset($_GET['pp']) ? $_GET['pp'] : 10;
 // get rows per page, default = 10
 $rowsReturned = sqlsrv_num_rows($archivecourses);
 if ($rowsReturned === false) {
     die(print_r(sqlsrv_errors(), true));
 } elseif ($rowsReturned == 0) {
     echo "No rows returned.";
     exit;
 } else {
     /* Calculate number of pages. */
     $numOfPages = ceil($rowsReturned / $rowsPerPage);
 }
 /* Echo results to the page */
 $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
 $page = Pagination::getPage($archivecourses, $pageNum, $rowsPerPage);
 foreach ($page as $row) {
     $courseID = $row[5];
     $teacherID = $row[6];
     echo "<tr><td>{$row['0']}</td>\n                  <td>{$row['1']}</td>\n                  <td><form method=\"POST\" action=\"/Admin/Archive/Teachers/ViewTeacher/\">\n                          <input hidden type=\"text\" name=\"teacherID\" value=\"{$teacherID}\">\n                          <button class=\"btn btn-primary\">{$row['2']}</button>\n                      </form>\n                  </td>\n                  <td>{$row['3']}</td>\n                  <td>{$row['4']}</td>\n                  <td><form method=\"POST\" action=\"/Admin/Archive/Courses/ViewCourse/\">\n                          <input hidden type=\"text\" name=\"courseID\" value=\"{$courseID}\">\n                          <button class=\"btn btn-primary\">View Course</button>\n                      </form>\n                  </td>\n              </tr>";
 }
 echo "</tbody></table><br />";
 $modulator = 3;
 Pagination::pageLinks($numOfPages, $pageNum, $rowsPerPage, $rowsReturned, $modulator);
 ?>
                                     
                             </div>
                         </div>
                         
                     </div>
                 </div>
Example #17
0
 public function index()
 {
     $this->notice = "版面-{$this->_board->DESC}({$this->_board->NAME})";
     App::import('Sanitize');
     App::import('vendor', array("inc/pagination", "inc/astro"));
     try {
         $gid = $this->params['gid'];
         $threads = Threads::getInstance($gid, $this->_board);
     } catch (ThreadsNullException $e) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     //article jump
     if (isset($this->params['url']['s'])) {
         $article = $threads->getArticleById(intval($this->params['url']['s']));
         if (null !== $article) {
             $pos = $article->getPos();
             $page = ceil(($pos + 1) / Configure::read("pagination.article"));
             $this->redirect("{$this->_mbase}/article/{$this->_board->NAME}/{$gid}?p={$page}#a{$pos}");
         }
         $this->redirect("{$this->_mbase}/article/{$this->_board->NAME}/{$gid}");
     }
     //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);
     }
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     $pagination = new Pagination(false !== $au ? $auF : $threads, Configure::read("pagination.article"));
     $articles = $pagination->getPage($p);
     $u = User::getInstance();
     $bm = $u->isBM($this->_board) || $u->isAdmin();
     $info = array();
     foreach ($articles as $v) {
         $content = $v->getPlant();
         $content = preg_replace("/&nbsp;/", " ", $content);
         $content = preg_replace("/  /", "&nbsp;&nbsp;", $content);
         preg_match("|※ 修改:·([\\S]+) .*?FROM:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $m);
         preg_match("|※ 来源:.*FROM:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $f);
         $m = empty($m) ? "" : "<br />修改:{$m[1]} FROM {$m[2]}";
         $f = empty($f) ? "" : "<br />FROM {$f[1]}";
         $s = ($pos = strpos($content, "<br/><br/>")) === false ? 0 : $pos + 10;
         $e = ($pos = strpos($content, "<br/>--<br/>")) === false ? strlen($content) : $pos + 7;
         $content = preg_replace(array("'^(<br/>)+'", "|(<br/>)+--\$|"), array("", "<br>--"), substr($content, $s, $e - $s)) . $m . $f;
         $content = $v->parseAtt($content, 'middle');
         if (Configure::read("ubb.parse")) {
             $content = XUBB::parse($content);
         }
         $info[] = array("id" => $v->ID, "op" => $v->OWNER == $u->userid || $bm ? 1 : 0, "time" => date("Y-m-d H:i:s", $v->POSTTIME), "pos" => $v->getPos(), "poster" => $v->OWNER, "content" => $content, "subject" => $v->isSubject());
     }
     $this->set("bName", $this->_board->NAME);
     $this->set("anony", $this->_board->isAnony());
     $this->set("canPost", $this->_board->hasPostPerm($u));
     $this->set("info", $info);
     $this->set("gid", $threads->GROUPID);
     $this->set("title", Sanitize::html($threads->TITLE));
     $this->set("curPage", $pagination->getCurPage());
     $this->set("totalPage", $pagination->getTotalPage());
     $this->set("au", $au);
     //for the quick reply, raw encode the space
     $this->set("reid", $threads->ID);
     if (!strncmp($threads->TITLE, "Re: ", 4)) {
         $reTitle = $threads->TITLE;
     } else {
         $reTitle = "Re: " . $threads->TITLE;
     }
     $this->set("reTitle", rawurlencode($reTitle));
 }
Example #18
0
 public function threads()
 {
     App::import('vendor', array('model/board', 'model/threads', 'inc/pagination'));
     $day = 7;
     $title1 = $title2 = $title3 = $author = '';
     if (isset($this->params['url']['title1'])) {
         $title1 = trim($this->params['url']['title1']);
     }
     if (isset($this->params['url']['title2'])) {
         $title2 = trim($this->params['url']['title2']);
     }
     if (isset($this->params['url']['titlen'])) {
         $title3 = trim($this->params['url']['titlen']);
     }
     if (isset($this->params['url']['author'])) {
         $author = trim($this->params['url']['author']);
     }
     if (isset($this->params['url']['day'])) {
         $day = intval($this->params['url']['day']);
     }
     $m = isset($this->params['url']['m']) && $this->params['url']['m'] == '1';
     $a = isset($this->params['url']['a']) && $this->params['url']['a'] == '1';
     $return = Configure::read('search.max');
     $res = array();
     if (!isset($this->params['url']['boards'])) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     $boards = $this->params['url']['boards'];
     foreach (explode('|', $boards) as $b) {
         try {
             $brd = Board::getInstance($b);
             $res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return));
         } catch (BoardNullException $e) {
         }
     }
     $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.threads");
     if (($count = intval($count)) <= 0) {
         $count = Configure::read("pagination.threads");
     }
     if ($count > Configure::read('plugins.api.page_item_limit')) {
         $count = Configure::read("pagination.threads");
     }
     $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
     $page = intval($page);
     $pagination = new Pagination(new ArrayPageableAdapter($res), $count);
     $articles = $pagination->getPage($page);
     $wrapper = Wrapper::getInstance();
     $data = array();
     $data['pagination'] = $wrapper->page($pagination);
     foreach ($articles as $v) {
         $data['threads'][] = $wrapper->article($v, array('threads' => true));
     }
     $this->set('data', $data);
 }
Example #19
0
 public function online()
 {
     $this->requestLogin();
     $this->css[] = "mail.css";
     $this->notice[] = array("url" => "/online", "text" => "在线用户");
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     try {
         App::import("vendor", "inc/pagination");
         $f = Forum::getOnlineUser();
         $pagination = new Pagination($f, Configure::read("pagination.friend"));
         $users = $pagination->getPage($p);
     } catch (FriendNullException $e) {
         $this->error();
     }
     if ($f->getTotalNum() > 0) {
         $info = array();
         foreach ($users as $v) {
             $info[] = array("fid" => $v->userid, "from" => $v->userfrom, "mode" => $v->mode, "idle" => sprintf('%02d:%02d', intval($v->idle / 60), $v->idle % 60));
         }
         $this->set("friends", $info);
     }
     $link = "{$this->base}/online?p=%page%";
     $this->set("pageBar", $pagination->getPageBar($p, $link));
     $this->set("pagination", $pagination);
 }
Example #20
0
 public function mode()
 {
     $this->js[] = "forum.board.js";
     $this->css[] = "board.css";
     $this->_getNotice();
     switch ($this->params['mode']) {
         case BOARD::$NORMAL:
             $tmp = '经典模式';
             break;
         case BOARD::$DIGEST:
             $tmp = '文摘模式';
             break;
         case BOARD::$MARK:
             $tmp = '保留模式';
             break;
         case BOARD::$DELETED:
             $tmp = '回收模式';
             break;
         case BOARD::$JUNK:
             $tmp = '纸篓模式';
             break;
         case BOARD::$ORIGIN:
             $tmp = '原作模式';
             break;
         default:
             $tmp = '主题模式';
     }
     $this->notice[] = array("url" => "", "text" => $tmp);
     $this->cache(false);
     App::import('Sanitize');
     $pageBar = "";
     $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1;
     $pagination = new Pagination($this->_board, Configure::read("pagination.threads"));
     $articles = $pagination->getPage($p);
     $u = User::getInstance();
     if ($bm = $u->isBM($this->_board) || $u->isAdmin()) {
         $this->js[] = "forum.manage.js";
     }
     $info = false;
     $curTime = strtotime(date("Y-m-d", time()));
     $sort = $this->_board->isSortMode();
     foreach ($articles as $v) {
         $postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . "&emsp;";
         $info[] = array("tag" => $this->_getTag($v), "title" => Sanitize::html($v->TITLE), "poster" => $v->OWNER, "postTime" => $postTime, "id" => $sort ? $v->ID : $v->getPos(), "gid" => $v->GROUPID, "att" => $v->hasAttach());
     }
     $this->title = Configure::read('site.name') . '-' . $this->_board->DESC;
     $this->set("info", $info);
     $link = "{$this->base}/board/{$this->_board->NAME}/mode/{$this->params['mode']}?p=%page%";
     $this->set("pageBar", $pagination->getPageBar($p, $link));
     $this->set("pagination", $pagination);
     $bms = split(" ", $this->_board->BM);
     foreach ($bms as &$v) {
         if (preg_match("/[^0-9a-zA-Z]/", $v)) {
             $v = array($v, false);
         } else {
             $v = array($v, true);
         }
     }
     $this->set("todayNum", $this->_board->getTodayNum());
     $this->set("curNum", $this->_board->CURRENTUSERS);
     if (isset($this->_board->MAXONLINE)) {
         $this->set("maxNum", $this->_board->MAXONLINE);
         $this->set("maxTime", date("Y-m-d H:i:s", $this->_board->MAXTIME));
     }
     $this->set("bms", $bms);
     $this->set("bName", $this->_board->NAME);
     $this->set("bm", $u->isBM($this->_board));
     $this->set("tmpl", $this->_board->isTmplPost());
     $this->set("hasVote", count($this->_board->getVotes()) != 0);
     $this->set("mode", (int) $this->params['mode']);
     //for default search day
     $this->set("searchDay", Configure::read("search.day"));
     //for elite path
     $this->set("elitePath", urlencode($this->_board->getElitePath()));
     $this->jsr[] = "window.user_post=" . ($this->_board->hasPostPerm($u) && !$this->_board->isDeny($u) ? "true" : "false") . ";";
 }
Example #21
0
 public function article()
 {
     $this->js[] = "forum.board.js";
     $this->css[] = "board.css";
     $this->notice[] = array("url" => "", "text" => "ËÑË÷½á¹û");
     App::import('Sanitize');
     $day = $title1 = $title2 = $title3 = $author = $t = "";
     if (isset($this->params['url']['t1'])) {
         $title1 = trim(rawurldecode($this->params['url']['t1']));
     }
     if (isset($this->params['url']['t2'])) {
         $title2 = trim(rawurldecode($this->params['url']['t2']));
     }
     if (isset($this->params['url']['tn'])) {
         $title3 = trim(rawurldecode($this->params['url']['tn']));
     }
     if (isset($this->params['url']['au'])) {
         $author = trim($this->params['url']['au']);
     }
     if (isset($this->params['url']['d'])) {
         $day = intval($this->params['url']['d']);
     }
     $title1 = nforum_iconv('utf-8', $this->encoding, $title1);
     $title2 = nforum_iconv('utf-8', $this->encoding, $title2);
     $title3 = nforum_iconv('utf-8', $this->encoding, $title3);
     $m = isset($this->params['url']['m']);
     $a = isset($this->params['url']['a']);
     $full = isset($this->params['url']['f']);
     $site = Configure::read('search.site');
     $return = Configure::read("search.max");
     $res = array();
     $u = User::getInstance();
     if ($title1 == '' && $title3 == '' && $author == '' && !$m && !$a) {
         $res = array();
     } else {
         if ($full && $site && $u->isAdmin()) {
             App::import('vendor', 'model/section');
             $secs = array_keys(Configure::read("section"));
             foreach ($secs as $v) {
                 $sec = Section::getInstance($v, Section::$ALL);
                 foreach ($sec->getList() as $brd) {
                     if (!$brd->isNormal()) {
                         continue;
                     }
                     $res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return));
                 }
             }
         } else {
             $b = @$this->params['url']['b'];
             try {
                 $brd = Board::getInstance($b);
             } catch (BoardNullException $e) {
                 $this->error(ECode::$BOARD_NONE);
             }
             $res = Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return);
         }
     }
     $p = 1;
     if (isset($this->params['url']['p'])) {
         $p = $this->params['url']['p'];
     }
     App::import("vendor", "inc/pagination");
     $page = new Pagination(new ArrayPageableAdapter($res), Configure::read("pagination.search"));
     $threads = $page->getPage($p);
     $info = false;
     $curTime = strtotime(date("Y-m-d", time()));
     $pageArticle = Configure::read("pagination.article");
     foreach ($threads as $v) {
         $tabs = ceil($v->articleNum / $pageArticle);
         $last = $v->LAST;
         $postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . "&emsp;";
         $replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME) . "&emsp;";
         $info[] = array("title" => Sanitize::html($v->TITLE), "poster" => $v->isSubject() ? $v->OWNER : "Ô­ÌûÒÑɾ³ý", "postTime" => $postTime, "gid" => $v->ID, "last" => $last->OWNER, "replyTime" => $replyTime, "page" => $tabs, "bName" => $v->getBoard()->NAME, "num" => $v->articleNum - 1);
     }
     $this->set("info", $info);
     $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}/s/article?" . join("&", $query);
     $this->set("pageBar", $page->getPageBar($p, $link));
     $this->set("pagination", $page);
 }
Example #22
0
            $worksheets = sqlsrv_query($con, $worksheetsSQL, $params, $options);
            if (!$worksheets) {
                die(print_r(sqlsrv_errors(), true));
            }
            $rowsPerPage = 10;
            $rowsReturned = sqlsrv_num_rows($worksheets);
            if ($rowsReturned === false) {
                die(print_r(sqlsrv_errors(), true));
            } elseif ($rowsReturned == 0) {
                echo "No rows returned.";
                exit;
            } else {
                $numOfPages = ceil($rowsReturned / $rowsPerPage);
            }
            $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
            $page = Pagination::getPage($worksheets, $pageNum, $rowsPerPage);
            foreach ($page as $row) {
                $worksheetID = $row[0];
                echo "<tr>  \n                        <td>{$row['1']}</td>\n                        <td><form method=\"POST\" action=\"ViewWorksheet\">\n                                <input hidden type=\"text\" name=\"worksheetID\" value=\"{$worksheetID}\">\n                                <button class=\"btn btn-primary\">Worksheet Page</button>\n                            </form>\n                        </td>\n                        <td><form method=\"POST\" action=\"ViewWorksheet/AnnotationEditor/\">\n                                <input hidden type=\"text\" name=\"worksheetID\" value=\"{$worksheetID}\">\n                                <button class=\"btn btn-primary\">Annotation Editor</button>\n                            </form>\n                        </td>\n                      </tr>";
            }
            ?>
            
            
            
                                            </tbody>
                                        </table>

                                    </div>
                                </div>
                            </div>
                        </div>
Example #23
0
 public function category()
 {
     $category = $this->params['id'];
     $params = array();
     $time = time();
     $yes = $time - 86400;
     $u = User::getInstance();
     switch ($category) {
         case 'hot':
             $sql = "select * from pl_vote where status=1 and end>? order by num desc, vid desc";
             $params = array($yes);
             break;
         case 'me':
         case 'list':
             if ($category === 'me') {
                 $user = $u->userid;
             } else {
                 @($user = trim($this->params['url']['u']));
             }
             $sql = "select * from pl_vote where status=1 and uid=? order by vid desc";
             $params = array($user);
             break;
         case 'all':
             $sql = "select * from pl_vote where status=1 order by vid desc";
             break;
         case 'join':
             $this->requestLogin();
             $sql = "select * from pl_vote where status=1 and vid in (select vid from pl_vote_result where uid=?) order by vid desc";
             $params = array($u->userid);
             break;
         case 'delete':
             if (!$u->isAdmin()) {
                 $this->error('你无权查看此类投票');
             }
             $sql = "select * from pl_vote where status=0 order by vid desc";
             break;
         case 'new':
             $category = "new";
             $sql = "select * from pl_vote where status=1 and end>? order by vid desc";
             $params = array($yes);
             break;
         default:
             $this->error('错误的类别');
     }
     $list = new VoteList($sql, $params);
     App::import('vendor', 'inc/pagination');
     $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : 10;
     $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
     if (($count = intval($count)) <= 0) {
         $count = 10;
     }
     if ($count > Configure::read('plugins.api.page_item_limit')) {
         $count = Configure::read('plugins.api.page_item_limit');
     }
     $page = intval($page);
     $pagination = new Pagination($list, $count);
     $votes = $pagination->getPage($page);
     $wrapper = Wrapper::getInstance();
     $data = array();
     $data['pagination'] = $wrapper->page($pagination);
     $data['votes'] = array();
     foreach ($votes as $v) {
         $data['votes'][] = $wrapper->vote($v);
     }
     $this->set('data', $data);
     $this->set('root', 'list');
 }
Example #24
0
 /* Extract Pagination Paramaters */
 $rowsPerPage = isset($_GET['pp']) ? $_GET['pp'] : 10;
 // get rows per page, default = 50
 $rowsReturned = sqlsrv_num_rows($stmt);
 if ($rowsReturned === false) {
     die(print_r(sqlsrv_errors(), true));
 } elseif ($rowsReturned == 0) {
     echo "No rows returned.";
     exit;
 } else {
     /* Calculate number of pages. */
     $numOfPages = ceil($rowsReturned / $rowsPerPage);
 }
 /* Echo results to the page */
 $pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;
 $page = Pagination::getPage($stmt, $pageNum, $rowsPerPage);
 foreach ($page as $row) {
     $studentPageLink = "ViewStudent/?studentID={$row['3']}";
     echo "<tr><td>{$row['0']}</td><td>{$row['1']}</td><td>{$row['2']}</td><td><a href='{$studentPageLink}'>Student's Page</a></td><td>{$row['4']}</td></tr>";
 }
 echo "</tbody></table><br />";
 $modulator = 4;
 Pagination::pageLinks($numOfPages, $pageNum, $rowsPerPage, $rowsReturned, $modulator);
 ?>
                                     
                             </div>
                         </div>
                         
                     </div>
                 </div>
             </div>
Example #25
0
    public $pages;
    public function __construct($data, $resultsPerPage)
    {
        $this->totalPages = ceil(count($data) / $resultsPerPage);
        $j = 0;
        while (count($data) > 0) {
            if (isset($this->pages[$j][$resultsPerPage - 1])) {
                $j++;
            }
            //echo "$data=".$data;
            $this->pages[$j][] = array_shift($data);
        }
    }
    public function getPage($strona)
    {
        $html = PAGINATION_OPENING_TAG;
        foreach ($this->pages[$strona] as $page) {
            $html .= PAGINATION_PAGE_OPENING_TAG . $page . PAGINATION_PAGE_CLOSING_TAG;
        }
        $html .= PAGINATION_PAGE_CLOSING_TAG;
        return $html;
    }
}
$dane = array();
for ($i = 0; $i < 10; $i++) {
    $dane[] = $i;
}
$pagi = new Pagination($dane, 5);
//var_dump($pagi->pages);
echo $pagi->getPage(1);