当前位置: 首页>>代码示例>>PHP>>正文


PHP pagination::getPagination方法代码示例

本文整理汇总了PHP中pagination::getPagination方法的典型用法代码示例。如果您正苦于以下问题:PHP pagination::getPagination方法的具体用法?PHP pagination::getPagination怎么用?PHP pagination::getPagination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pagination的用法示例。


在下文中一共展示了pagination::getPagination方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getComments


//.........这里部分代码省略.........
                     } else {
                         $comment = $this->insertComment($this->module, $this->module_id, $this->objUser->grab('id'), $_POST['comment']);
                         if (!mysql_affected_rows()) {
                             msg('FAIL', 'Error: Your comment wasnt posted, please try again.', '_ERROR');
                         }
                         unset($_SESSION[$module]);
                     }
                     $dontShow = true;
                 }
                 break;
             case 'ajPostComment':
                 if (HTTP_AJAX && HTTP_POST) {
                     if (doArgs('comment_' . $this->module_id, false, $_SESSION[$this->module]) != $_POST['sessid']) {
                         die('1 <script>console.log(' . json_encode(array('comment_' . $this->module_id, $_SESSION[$this->module], $_POST['sessid'], $_POST)) . ');</script>');
                     } else {
                         $comment = $this->insertComment($this->module, $this->module_id, $this->objUser->grab('id'), $_POST['comment']);
                         if (!mysql_affected_rows()) {
                             die('0');
                         }
                         echo $this->getLastComment($comment);
                     }
                     exit;
                 }
                 break;
             case 'deleteComment':
                 $id = doArgs('id', 0, $_GET, 'is_number');
                 $comment = $this->objSQL->getLine('SELECT * FROM `$Pcomments` WHERE id = "%d"', array($id));
                 if (!$comment) {
                     msg('FAIL', 'Error: Comment not found.', '_ERROR');
                     break;
                 }
                 //check if user has perms
                 if (User::$IS_ADMIN || User::$IS_MOD || User::$IS_ONLINE && ($this->objUser->grab('id') == $comments['author'] || $this->objUser->grab('id') == $this->author_id)) {
                     //do teh the delete
                     $log = 'Comments System: ' . $this->objUser->profile($this->objUser->grab('id'), RAW) . ' deleted comment from <a href="' . $this->aURL[1] . '">this</a>.';
                     $delete = $this->objSQL->deleteRow('comments', array('id = "%d"', $id), $log);
                     if (!$delete) {
                         msg('FAIL', 'Error: The comment was not deleted.', '_ERROR');
                     } else {
                         msg('INFO', 'The comment was successfully deleted.', '_ERROR');
                     }
                 }
                 break;
             case 'ajDelComment':
                 if (HTTP_AJAX && HTTP_POST) {
                     $id = doArgs('id', 0, $_GET, 'is_number');
                     $comment = $this->objSQL->getLine('SELECT * FROM `$Pcomments` WHERE id = "%d"', array($id));
                     if (!$comment) {
                         die('-1');
                     }
                     //check if user has perms
                     if (User::$IS_ADMIN || User::$IS_MOD || User::$IS_ONLINE && ($this->objUser->grab('id') == $comments['author'] || $this->objUser->grab('id') == $this->author_id)) {
                         //do teh the delete
                         $log = 'Comments System: ' . $this->objUser->profile($this->objUser->grab('id'), RAW) . ' deleted comment from <a href="' . $this->aURL[1] . '">this</a>.';
                         $delete = $this->objSQL->deleteRow('comments', array('id = "%d"', $id), $log);
                         die(!$delete ? '0' : '1');
                     }
                 } else {
                     die('-1');
                 }
                 die('0');
                 break;
         }
         //make sure the submit form only shows when we want it to
         if (!$dontShow) {
             $this->makeSubmitForm();
         }
     }
     //get a comments count for this module and id
     $commentsCount = $this->getCount();
     $comPagination = new pagination('commentsPage', $this->perPage, $commentsCount);
     //check to see if we have a positive number
     if ($commentsCount) {
         //now lets actually grab the comments
         $commentsData = $this->objSQL->getTable('SELECT * FROM `$Pcomments`
                     WHERE module="%s" AND module_id="%d"
                     ORDER BY timestamp ASC
                     LIMIT %s', array($this->module, $this->module_id, $comPagination->getSqlLimit()));
         if (!$commentsData) {
             //something went wrong
             msg('INFO', 'Error loading comments.', '_ERROR');
         } else {
             $this->objTPL->assign_var('COM_PAGINATION', $comPagination->getPagination());
             $i = 0;
             //assign the comments to the template
             foreach ($commentsData as $comments) {
                 $this->objTPL->assign_block_vars('comment', array('ID' => $comments['id'], 'cID' => 'comment-' . $comments['id'], 'ROW' => $i % 2 ? 'row_color2' : 'row_color1', 'ALT_ROW' => $i % 2 ? 'row_color1' : 'row_color2', 'AUTHOR' => $this->objUser->profile($comments['author']), 'POSTED' => $this->objTime->mk_time($comments['timestamp']), 'POST' => contentParse($comments['comment'])));
                 if (User::$IS_ADMIN || User::$IS_MOD || User::$IS_ONLINE && ($this->objUser->grab('id') == $comments['author'] || $this->objUser->grab('id') == $this->author_id)) {
                     $this->objTPL->assign_block_vars('comment.functions', array('URL' => $this->aURL[0] . '?mode=deleteComment&id=' . $comments['id']));
                 }
                 $i++;
             }
         }
     } else {
         //we have no comments so output a msg box saying so
         msg('INFO', 'No Comments.', '_ERROR');
     }
     //and then output the comments to the parent template
     $this->objTPL->assign_var_from_handle($tplVar, 'comments');
 }
开发者ID:richard-clifford,项目名称:cmsv1,代码行数:101,代码来源:class.comments.php

示例2: viewThread

 /**
  * Allows a user to view a thread
  *
  * @version 2.0
  * @since   1.0.0
  * @author  xLink
  *
  * @param   int         $id
  */
 public function viewThread($id)
 {
     $vars = $this->objPage->getVar('tplVars');
     $this->objTPL->set_filenames(array('body' => 'modules/forum/template/forum_thread.tpl'));
     //grab the thread
     $thread = $this->objSQL->getLine('SELECT t.*, COUNT(DISTINCT p.id) as posts
             FROM `$Pforum_threads` t
             LEFT JOIN `$Pforum_posts` p
                 ON p.thread_id = t.id
             WHERE t.id = %d', array($id));
     //make sure it exists
     if (is_empty($thread['id'])) {
         $this->throwHTTP(404);
         return;
     }
     //grab the cat
     $cat = $this->getForumInfo($thread['cat_id']);
     $cat = $cat[0];
     //grab the auth and make sure they /can/ see it
     $threadAuth = $this->auth[$thread['cat_id']];
     if (!$threadAuth['auth_view'] || !$threadAuth['auth_read']) {
         $this->objPage->setTitle(langVar('B_FORUM') . ' > ' . langVar('P_PERMISSION_DENIED'));
         hmsgDie('INFO', langVar('L_AUTH_MSG', $threadAuth['auth_read_type']));
         return;
     }
     //sort out the breadcrumbs & page title
     $threadTitle = secureMe($thread['subject']);
     $threadUrl = $this->generateThreadURL($thread);
     $page_name = array(langVar('B_FORUM'), $cat['title'], !is_empty($threadTitle) ? $threadTitle : langVar('F_VIEWF'));
     $this->objPage->setTitle(implode(' > ', $page_name));
     $this->getSubCrumbs($thread['cat_id']);
     $this->objPage->addPagecrumb(array(array('url' => $threadUrl, 'name' => $threadTitle)));
     //update views
     if (!isset($_SESSION['site']['forum']['view'][$thread['tid']])) {
         $this->objSQL->query('UPDATE `$Pforum_threads` SET views = (views+1) WHERE id = %d LIMIT 1', array($id));
         $_SESSION['site']['forum']['view'][$thread['tid']] = 1;
     }
     //if the user is online
     if (User::$IS_ONLINE) {
         //do thread tracker part of the tour
         $tracker = doArgs('forum_tracker', false, $_SESSION['user']);
         $tracking_threads = array();
         if (!is_empty($tracker)) {
             $tracking_threads = unserialize($tracker);
         }
         //find the thread row in the array or create a new one
         if (!is_empty($tracking_threads)) {
             foreach ($tracking_threads as $k => $v) {
                 if ($tracking_threads[$k]['id'] == $id) {
                     $tracking_threads[$k][$id]['read'] = true;
                     $tracking_threads[$k][$id]['last_poster'] = time();
                 }
             }
         } else {
             $tracking_threads[$id]['read'] = true;
             $tracking_threads[$id]['last_poster'] = time();
         }
         //now update the user row
         unset($update);
         $_SESSION['user']['forum_tracker'] = $update['forum_tracker'] = serialize($tracking_threads);
         $this->objUser->updateUserSettings($this->objUser->grab('id'), $update);
         unset($update);
         //update the users watch status
         $this->objSQL->updateRow('forum_watch', array('seen' => 1), array('user_id ="%d" AND thread_id ="%d"', $this->objUser->grab('id'), $id));
         // && read notification if needed
         $this->objNotify->clearNotifications($id, true);
     }
     //setup a new pagination obj
     $objPagination = new pagination('page', 10, $thread['posts']);
     //see if the user wants us to jump to the last page
     if (doArgs('mode', false, $_GET) == 'last_page') {
         $objPagination->goLastPage();
     }
     //check for guest restrictions
     $limit = $objPagination->getSqlLimit();
     if (!User::$IS_ONLINE && $this->config('forum', 'guest_restriction')) {
         $this->objTPL->assign_block_vars('error', array('ERROR' => langVar('L_VIEW_GUEST')));
         $limit = '1;';
     }
     //grab the thread posts
     $posts = $this->objSQL->getTable('SELECT * FROM `$Pforum_posts` WHERE thread_id = %d ORDER by timestamp, id ASC LIMIT %s', array($id, $limit));
     //assign some vars to the tpl
     $this->objTPL->assign_vars(array('THREAD_TITLE' => $threadTitle, 'PAGINATION' => $objPagination->getPagination(true), 'JUMPBOX' => $this->objForm->start('jump' . randcode(2)) . $this->buildJumpBox('jumpbox', $this->buildJumpBoxArray(), $thread['cat_id'], false) . $this->objForm->finish(), 'JUMPBOX2' => $this->objForm->start('jump' . randcode(2)) . $this->buildJumpBox('jumpbox2', $this->buildJumpBoxArray(), $thread['cat_id'], false) . $this->objForm->finish()));
     //setup the watch thread trigger
     $watchThread = $this->objSQL->getInfo('forum_watch', array('user_id ="%s" AND thread_id ="%s"', $this->objUser->grab('id'), $id));
     $this->objTPL->assign_var('WATCH', USER::$IS_ONLINE ? '<a href="' . $threadUrl . '?mode=' . ($watchThread ? 'unwatch' : 'watch') . '">' . langVar($watchThread ? 'L_UNWATCH_THREAD' : 'L_WATCH_THREAD') . '</a>' : null);
     //check if the thread is currently locked
     if ($thread['locked'] == 0) {
         $quick_reply = doArgs('forum_quickreply', false, $_SESSION['user']);
         //test if we get to output quick reply
         if ($quick_reply && ($threadAuth['auth_reply'] || $threadAuth['auth_mod'] || User::$IS_MOD)) {
//.........这里部分代码省略.........
开发者ID:richard-clifford,项目名称:cmsv1,代码行数:101,代码来源:class.forum.php


注:本文中的pagination::getPagination方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。