public function viewAllCategories() { $session = new SessionHelper(); $formval = new FormHelper(); // Pagination support if (isset($_GET['p']) && $_GET['p'] != 0) { $page = $formval->testInput($_GET['p']); } else { $page = 1; } $per_page = 5; // Amount of categories per page $total_count = CategoryModel::countCategories(); // Total amount of categories $pagination = new PaginationHelper($page, $per_page, $total_count); // Instance used for data on page $user = new User(); if ($this->_authCheck()) { if ($this->role <= 2) { // Data used on view $data = CategoryModel::getAllCategoriesPerPage($pagination->offset(), $pagination->per_page); $page_title = 'All Categories'; include BASE_URI . 'app/view/user/template/header.php'; include BASE_URI . 'app/view/user/categories.php'; include BASE_URI . 'app/view/user/template/footer.php'; } else { // Not an admin $session->setMessage('No Access', 3); $this->viewDashboard(); } } else { // Not logged in $this->viewLoginPage(); } }
<?php /* 后台文件 Background entry file */ if (!defined('ACC')) { define('ACC', true); require '../system/init.php'; } // $user = new UserModel(); $userlist = $user->select(); $perPage = 7; $curPage = isset($_GET['page']) ? $_GET['page'] : 1; $pageObj = new PaginationHelper(count($userlist), $perPage, $curPage); $pageMenu = $pageObj->showPageMenu(); $userlist = $user->selectLimited(($curPage - 1) * $perPage, $perPage); $userlist = $user->dataByRealDate($userlist); include __ROOT__ . 'view/admin/templates/userlist.html';
$collection->add('twenty', 'viente'); $collection->add('twenty one', 'viente uno'); $collection->add('twenty two', 'viente dos'); $collection->add('twenty three', 'viente tres'); $collection->add('twenty four', 'viente cuatro'); $collection->add('twenty five', 'viente cinco'); $collection->add('twenty six', 'viente seis'); $collection->add('twenty seven', 'viente siete'); $collection->add('twenty eight', 'viente ocho'); $collection->add('twenty nine', 'viente nueve'); $collection->add('thirty', 'treinte'); $page_number = isset($_GET['page']) ? $_GET['page'] : 1; $items_per_page = 3; $paginator = new Paginator($collection, $page_number, $items_per_page); $template = new Template('templates/standard_pagination.tpl'); $helper = new PaginationHelper($paginator, $template, 2); ?> <p><?php echo $helper->render(); ?> </p> <?php foreach ($paginator->current() as $key => $value) { ?> <strong><?php echo $key; ?> :</strong> <?php echo $value; ?>