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


PHP Paginator类代码示例

本文整理汇总了PHP中Paginator的典型用法代码示例。如果您正苦于以下问题:PHP Paginator类的具体用法?PHP Paginator怎么用?PHP Paginator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: run

 /**
  * Run method with main page logic
  * 
  * Read in album information and photos associated with an album from the database.
  * Populate template and display results in the page. Pagination possible
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     $albumDAO = AlbumDAO::getInstance();
     $photoDAO = PhotoDAO::getInstance();
     $album = $photo_array = $photo_count = $paginator_page = $queryVars = null;
     $title = "";
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $id = isset($_GET["id"]) && is_numeric($_GET["id"]) ? intval($_GET["id"]) : 0;
     if ($id <= 0) {
         header("Location: " . BASE_URL);
         return;
     }
     $album = $albumDAO->load($id, array("joins" => true));
     if ($album) {
         $title = $album->getTitle();
         $count = $photoDAO->countByAlbum($album);
         $paginator = new Paginator($count, $PAGINATION_LIMIT);
         $paginator_page = $paginator->getPage($page);
         $photo_array = $photoDAO->allByAlbum($album, array("limit" => $paginator_page));
         $queryVars = array("id" => $id);
     }
     $this->template->render(array("title" => "View Album - {$title}", "session" => $session, "album" => $album, "photo_array" => $photo_array, "paginator_page" => $paginator_page, "queryVars" => $queryVars, "main_page" => "view_album_tpl.php"));
 }
开发者ID:Ryochan7,项目名称:UGA-Proposal-Website,代码行数:36,代码来源:view_album.php

示例2: GetList

 public static function GetList($arOrder = array(), $arFilter = array(), $arSelect = array(), $arLimit = array())
 {
     $DB = App::DB();
     $arFilter = self::GetFilter($arFilter);
     if (empty($arOrder)) {
         $arOrder = array("SORT" => "ASC");
     }
     $arOrder = self::GetSort($arOrder);
     $tables = array("CATALOG" => self::$table_catalog, "ELEMENT" => self::$table);
     if (is_array($arLimit) and !empty($arLimit)) {
         $page = !empty($arLimit['PAGE']) ? (int) $arLimit['PAGE'] : 1;
         $total_count = self::GetCount($arFilter);
         $arLimit['COUNT'] = $arLimit['COUNT'] > 0 ? $arLimit['COUNT'] : 3;
         $pagination = new Paginator($arLimit['PAGE'], $arLimit['COUNT'], $total_count);
         self::$pagination = $pagination->GetHtml();
         $arLimit['OFFSET'] = $pagination->Offset();
     } else {
         $arLimit = array();
         self::$pagination = '';
     }
     $sql = getListSql($tables, $arOrder, $arFilter, $arSelect, $arLimit);
     //d($sql);
     $res = $DB->Query($sql, "ScriptAcid\\CatalogElementResult");
     if ($DB->Error()) {
         dbError($DB->Error());
         return false;
     }
     parent::$result = $res;
     return $res;
 }
开发者ID:r3c130n,项目名称:scriptacid,代码行数:30,代码来源:lib.CatalogElement.php

示例3: run

 /**
  * Run method with main page logic
  * 
  * Read in list of albums and the latest photos for each album. Pagination enabled.
  * Populate template with data and display results in the page.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     $albumDAO = AlbumDAO::getInstance();
     $photoDAO = PhotoDAO::getInstance();
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $count = $paginator = $paginator_page = null;
     $album = $photo_info_array = null;
     $title = "";
     $count = $albumDAO->count();
     $paginator = new Paginator($count, $PAGINATION_LIMIT);
     $paginator_page = $paginator->getPage($page);
     $album_array = $albumDAO->all(array("limit" => $paginator_page));
     $photo_info_array = array();
     foreach ($album_array as $album) {
         $count = $photoDAO->countByAlbum($album);
         if ($count > 0) {
             $tmp_paginator = new Paginator($count, 1);
             $tmp_paginator_page = $paginator->getPage($page);
             // Only get latest item
             list($latest_photo) = $photoDAO->allByAlbum($album, array("order" => "id DESC", "limit" => $tmp_paginator_page));
             $photo_info_array[] = array($count, $latest_photo);
         }
     }
     $this->template->render(array("title" => "Album List", "main_page" => "album_list_tpl.php", "session" => $session, "album_array" => $album_array, "photo_info_array" => $photo_info_array, "paginator_page" => $paginator_page));
 }
开发者ID:Ryochan7,项目名称:UGA-Proposal-Website,代码行数:38,代码来源:album_list.php

示例4: pagination

 function pagination($url = null)
 {
     $sql = "SELECT id, first_name, last_name, role, email, active, gender, profile_image,fb_id, created_on FROM user ORDER BY created_on DESC";
     $table_page = PATH_ADMIN_VIEWS . "user/paginator/row.php";
     $paginator = new \Paginator();
     $paginator->execute($sql, $table_page, $url);
 }
开发者ID:sks40gb,项目名称:jnv,代码行数:7,代码来源:UserModel.php

示例5: run

 /**
  * Run method with main page logic
  * 
  * Read in list of the latest published articles. Pagination enabled.
  * Populate template and display results in the page.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     /*
     if ($user == null || !$user->validUser ()) {
         header ("Location: " . BASE_URL);
         return;
     }
     */
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $count = $paginator = $paginator_page = null;
     $article = $articletags_array = null;
     $title = "";
     $count = $articleDAO->countPublished(true);
     $paginator = new Paginator($count, $PAGINATION_LIMIT);
     $paginator_page = $paginator->getPage($page);
     $article_array = $articleDAO->allPublished(true, array("order" => "{$articleDAO->getTableName()}.postDate DESC, {$articleDAO->getTableName()}.id DESC", "limit" => $paginator_page, "joins" => true));
     foreach ($article_array as $article) {
         $articletags_array[] = $tagDAO->allArticleTags($article, array("order" => "name"));
     }
     $this->template->render(array("title" => "Latests Articles", "main_page" => "article_list_tpl.php", "session" => $session, "article_array" => $article_array, "articletags_array" => $articletags_array, "paginator_page" => $paginator_page));
 }
开发者ID:Ryochan7,项目名称:UGA-Proposal-Website,代码行数:36,代码来源:article_list.php

示例6: getTemplateParameters

 /**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     $teamId = $this->_websoccer->getUser()->getClubId($this->_websoccer, $this->_db);
     // last training executions
     $lastExecution = TrainingDataService::getLatestTrainingExecutionTime($this->_websoccer, $this->_db, $teamId);
     $unitsCount = TrainingDataService::countRemainingTrainingUnits($this->_websoccer, $this->_db, $teamId);
     $paginator = null;
     $trainers = null;
     // has valid training unit?
     $training_unit = TrainingDataService::getValidTrainingUnit($this->_websoccer, $this->_db, $teamId);
     if (!isset($training_unit["id"])) {
         // get trainers
         $count = TrainingDataService::countTrainers($this->_websoccer, $this->_db);
         $eps = $this->_websoccer->getConfig("entries_per_page");
         $paginator = new Paginator($count, $eps, $this->_websoccer);
         if ($count > 0) {
             $trainers = TrainingDataService::getTrainers($this->_websoccer, $this->_db, $paginator->getFirstIndex(), $eps);
         }
     } else {
         $training_unit["trainer"] = TrainingDataService::getTrainerById($this->_websoccer, $this->_db, $training_unit["trainer_id"]);
     }
     // collect effects of executed training unit
     $trainingEffects = array();
     $contextParameters = $this->_websoccer->getContextParameters();
     if (isset($contextParameters["trainingEffects"])) {
         $trainingEffects = $contextParameters["trainingEffects"];
     }
     return array("unitsCount" => $unitsCount, "lastExecution" => $lastExecution, "training_unit" => $training_unit, "trainers" => $trainers, "paginator" => $paginator, "trainingEffects" => $trainingEffects);
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:33,代码来源:TrainingModel.class.php

示例7: action_index

 public function action_index()
 {
     $this->_parse_uri();
     $category_id = (int) $this->category->id;
     $list_categories = ORM::factory('catalog_Category')->where('category_id', '=', $category_id)->find_all()->as_array();
     $elements_orm = ORM::factory('catalog_Element')->where('category_id', '=', $category_id);
     $paginator_orm = clone $elements_orm;
     $paginator = new Paginator('layout/paginator');
     $paginator->per_page($this->limit)->count($paginator_orm->count_all());
     unset($paginator_orm);
     $list = $elements_orm->paginator($paginator)->find_all()->as_array();
     $properties = array();
     if (!empty($category_id)) {
         $property_helper = ORM_Helper::factory('catalog_Category', $category_id)->property_helper();
         $property_helper->set_owner_id($category_id);
         $properties = $property_helper->get_list();
         $titlebar_title = Arr::path($properties, 'Title.value');
         if (empty($titlebar_title)) {
             $titlebar_title = $this->category->title;
         }
     } else {
         $orm_helper = ORM_Helper::factory('page', $this->page_id);
         $properties = $orm_helper->property_list();
         $titlebar_title = Arr::path($properties, 'Title.value');
         if (empty($titlebar_title)) {
             $titlebar_title = __('Categories of goods');
         }
     }
     $this->template->set_filename('modules/catalog/list')->set('list_categories', $list_categories)->set('list', $list)->set('paginator', $paginator)->set('properties', $properties)->set('titlebar_title', $titlebar_title);
 }
开发者ID:greor,项目名称:satin-spb,代码行数:30,代码来源:catalog.php

示例8: leave

 public function leave()
 {
     $smarty = parent::load('smarty');
     $leave_form = parent::load('form', 'LeaveForm', $_POST);
     parent::load('model', 'forms');
     parent::load('model', 'system/contrib/auth.User');
     if (!$this->is_post()) {
         import('system/share/web/paginator');
         if (User::has_role('人力资源') || User::has_role('总经理')) {
             $data = Forms::get_by_type_and_user('请假申请');
             $smarty->assign('has_role', true);
         } else {
             $data = Forms::get_by_type_and_user('请假申请', User::info('id'));
         }
         $paginator = new Paginator((array) $data, $_GET['page'], 10);
         $smarty->assign('paginator', $paginator->output());
         $smarty->assign('page_title', '请假申请');
         $smarty->assign('leave_form', $leave_form->output());
         $smarty->display('forms/leave');
         return;
     }
     $form_data = new Forms();
     $form_data->user_id = User::info('id');
     $form_data->state = 0;
     $form_data->type = '请假申请';
     $form_data->form_data = serialize($_POST);
     $form_data->save();
     import('system/share/network/redirect');
     HTTPRedirect::flash_to('forms/leave', '提交请假申请成功, 请耐心等待审核', $smarty);
 }
开发者ID:uwitec,项目名称:mgoa,代码行数:30,代码来源:FormsController.php

示例9: showAction

 public function showAction($offset = 0)
 {
     $this->_view->title = 'ActiveRecord Database MVC';
     $oContentCats = new ContentCats(2);
     $rsCat = $oContentCats->find();
     $oContents = new Contents();
     $items_per_page = 15;
     $offset = $offset % $items_per_page != 0 ? 0 : $offset;
     $rs = $oContents->find(NULL, 'sort ASC', NULL, "{$offset},{$items_per_page}");
     $pages = new Paginator();
     $pages->current_url = base_url() . 'active-record/active-record/show/%d';
     $pages->offset = $offset;
     $pages->items_per_page = $items_per_page;
     $pages->items_total = $oContents->getTotalRow();
     $pages->mid_range = 7;
     $pages->paginate();
     $this->_view->pages = $pages;
     $this->_view->rs = $rs;
     $this->_view->rsCat = $rsCat;
     $this->_view->filter_link = base_url() . 'active-record/active-record/show';
     $this->_view->add_link = base_url() . 'active-record/active-record/ar-add-model/';
     $this->_view->edit_link = base_url() . 'active-record/active-record/ar-edit-model/';
     $this->_view->delete_link = base_url() . 'active-record/active-record/ar-delete-model/';
     $this->renderView('active-record/active-record/show');
 }
开发者ID:ngukho,项目名称:mvc-cms,代码行数:25,代码来源:ActiveRecordController.php

示例10: getDataFromDb

 public function getDataFromDb($pageNumber)
 {
     //new database connection
     $db = new Database();
     // $start = 0;
     //  $limit = 5;
     //execute query
     // $db->executeQuery("INSERT INTO cars(id,name,price) VALUES('9','maruti','5400')");
     //$db->executeQuery("INSERT INTO test_table(name,email) VALUES('kumaran','kumaran@gmail.com')");
     //  $db->executeQuery("INSERT INTO fruits(name,color) VALUES('mango','orange')");
     //  $db->executeQuery("DELETE FROM fruits WHERE color='violet'");
     $db->executeQuery("SELECT * FROM first_names");
     // $db->executeQuery("DELETE FROM test_table WHERE name='gfdg' OR name='tty' ");
     //  $db->executeQuery("DELETE FROM test_table WHERE name='kumaran'");
     //return result array
     // $db->getAllRows(); // ok
     $page = new Paginator($db->getAllRows(), 10);
     //array , limit, pages count [optional. default is 10]
     $rows = $page->getPage($pageNumber);
     $this->navLinks = $page->pageCount();
     return $rows;
     // print_r ($db->getRows(1,3)); //ok
     //  print_r($db->getRowAt(1)); // ok
     //  print_r ($db->getRow()); // return first row
     // print_r($db->affectedRows());  // ok
     //  print_r($db->count());  // ok
     //  print_r($db->lastInsertId());  //ok
     /*
      * to escape string
      *  $email="kumaran@gmail.com";
      *  $db->escapeString($email);
      */
 }
开发者ID:prajeenapk,项目名称:VioletPHP,代码行数:33,代码来源:dbModel.php

示例11: action_index

 public function action_index()
 {
     $category_uri = $this->request->param('category_uri');
     $news_category = new News_Category();
     $category_list = $news_category->get_list($this->page_id);
     if (empty($category_list)) {
         throw new HTTP_Exception_404();
     }
     $category_orm = $news_category->by_uri($category_list, $category_uri);
     $orm = ORM::factory('news')->where('category_id', 'IN', array_keys($category_list));
     if ($category_orm) {
         $orm->where('category_id', '=', $category_orm->id);
         $properties = $news_category->get_properties(array($category_orm));
         $properties = reset($properties);
         $this->title = $category_orm->title;
         $this->breadcrumbs[] = array('title' => $category_orm->title);
     } else {
         $orm_helper = ORM_Helper::factory('page', $this->page_id);
         $properties = $orm_helper->property_list();
     }
     $paginator_orm = clone $orm;
     $paginator = new Paginator('layout/paginator');
     $paginator->per_page($this->limit)->count($paginator_orm->count_all());
     unset($paginator_orm);
     $list = $orm->paginator($paginator)->find_all()->as_array();
     $titlebar_title = Arr::path($properties, 'Title.value');
     if (empty($titlebar_title)) {
         $titlebar_title = __('Blog');
     }
     $this->template->set_filename('modules/news/list')->set('list', $list)->set('paginator', $paginator)->set('categories', $category_list)->set('properties', $properties)->set('titlebar_title', $titlebar_title);
 }
开发者ID:greor,项目名称:satin-spb,代码行数:31,代码来源:news.php

示例12: index

 public function index()
 {
     $this->view->js_link[] = $this->make_link('js', SITE_ASSETS, 'pages/sidebar_search.js');
     $this->view->js_link[] = $this->make_link('js', SITE_ASSETS, 'pages/common.js');
     // alapbeállítások lekérdezése
     $this->view->settings = $this->munkak_model->get_settings();
     // 3 legfrissebb munka
     $this->view->latest_jobs = $this->munkak_model->jobs_query(3);
     $this->view->title = 'Munka diákoknak | Multijob Iskolaszövetkezet.';
     $this->view->description = 'Munka diákoknak a Multijob Iskolaszövetkezetnél. Diákmunka az ország több területén.';
     $this->view->keywords = 'diákmunka, alkalmi munka, multijob';
     // paginator
     include LIBS . '/pagine_class.php';
     // paginátor objektum létrehozása (paraméter neve, limit)
     $pagine = new Paginator('oldal', 9);
     // adatok lekérdezése limittel
     $this->view->jobs_data = $this->munkak_model->jobs_filter_query($pagine->get_limit(), $pagine->get_offset());
     // szűrési feltételeknek megfelelő összes rekord száma
     $filter_count = $this->munkak_model->jobs_filter_count_query();
     $pagine->set_total($filter_count);
     // lapozó linkek
     $this->view->pagine_links = $pagine->page_links($this->registry->uri_path);
     //$this->view->debug(true);
     $this->view->render('munkak/tpl_munkak');
 }
开发者ID:hillmediakft,项目名称:multijob,代码行数:25,代码来源:munkak.php

示例13: run

 /**
  * Run method with main page logic
  * 
  * Read in list of the latest published events and populate template with results.
  * Display results in the page. Pagination enabled
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     $eventDAO = EventDAO::getInstance();
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     $platform_id = isset($_GET["platform"]) && is_numeric($_GET["platform"]) ? intval($_GET["platform"]) : 0;
     if ($page < 1) {
         $page = 1;
     }
     $count = $paginator = $paginator_page = $queryVars = $current_platform = null;
     if ($platform_id <= 0) {
         $count = $eventDAO->countStatus(Event::APPROVED_STATUS);
         $paginator = new Paginator($count, $PAGINATION_LIMIT);
         $paginator_page = $paginator->getPage($page);
         $event_array = $eventDAO->allByStatus(Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
     } else {
         $count = $eventDAO->countPlatformStatus($platform_id, Event::APPROVED_STATUS);
         $paginator = new Paginator($count, $PAGINATION_LIMIT);
         $paginator_page = $paginator->getPage($page);
         $event_array = $eventDAO->allByPlatformStatus($platform_id, Event::APPROVED_STATUS, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true, "limit" => $paginator_page));
         $queryVars = array("platform" => $platform_id);
     }
     $platformDAO = PlatformDAO::getInstance();
     $platform_array = $platformDAO->all();
     //print_r ($event_array);
     if ($platform_id > 0) {
         $current_platform = $platformDAO->load($platform_id);
     }
     $this->template->render(array("title" => "Event List", "main_page" => "event_list_tpl.php", "event_array" => $event_array, "session" => $session, "paginator_page" => $paginator_page, "sidebar_extra" => joinPath("fragments", "event_sidebar_tpl.php"), "platform_array" => $platform_array, "queryVars" => $queryVars, "current_platform" => $current_platform));
 }
开发者ID:Ryochan7,项目名称:UGA-Proposal-Website,代码行数:39,代码来源:event_list.php

示例14: testPaginationOnlyPage

 public function testPaginationOnlyPage()
 {
     $paginator = new Paginator();
     $output = $paginator->paginate($this->baseUrl, 100, 1, 100);
     $this->assertFalse($this->didFindString($output, 'Older Tweets'));
     $this->assertFalse($this->didFindString($output, 'Newer Tweets'));
 }
开发者ID:mkody,项目名称:archive-my-tweets,代码行数:7,代码来源:paginatorTest.php

示例15: paginate

 function paginate($dql, $pageSize = 10, $currentPage = 1)
 {
     $paginator = new Paginator($dql);
     $paginator->getQuery()->setFirstResult($pageSize * ($currentPage - 1))->setMaxResults($pageSize);
     // set the limit
     return $paginator;
 }
开发者ID:kmachoCr,项目名称:Sigpro,代码行数:7,代码来源:ProjectRepository.php


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