PHP Classes

File: manualscroll.php

Recommend this page to a friend!
  Classes of Stanislav Okhvat   PageNavigator   manualscroll.php   Download  
File: manualscroll.php
Role: ???
Content type: text/plain
Description: Child class with manual scroll (pages are divided in sets) behavior
Class: PageNavigator
Author: By
Last change:
Date: 22 years ago
Size: 4,268 bytes
 

Contents

Class file image Download
<?php /** * PageNavigator_ManualScroll is a class for creating page views that * should be scrolled manually, i.e. a set of pages does not change unless * the user clicks one of the buttons rendered by FormatMovePrevSet and * FormatMoveNextSet. * * @author Stanislav Okhvat <stanis@ngs.ru> * @version $Id: PageNavigator_ManualScroll.php,v 1.00 2002/02/20 11:40:00 stasokhvat Exp $ * @package PageNavigator_ManualScroll * @access public */ class PageNavigator_ManualScroll extends PageNavigator { /** * Number of pages to show within one set of pages. * * @var integer * @access private */ var $pages_per_set; /** * Constructor. Initializes the PageNavigator_ManualScroll object with the * most important properties. * * @param integer current page number * @param integer number of records per one page * @param integer total records. May be initialized later. * @param integer number of pages to be displayed per one set of * pages. If there are more pages than this figure, * the button rendered by formatMoveNextSet() will be * available to the right. Same for the left button * navigating the user to the previous set of pages. * @return void * @access public */ function PageNavigator_ManualScroll($current_page=0, $records_per_page=15, $total_records=0, $pages_per_set=10, $query_vars='') { PageNavigator::PageNavigator($current_page, $records_per_page, $total_records, $query_vars); $this->pages_per_set = $pages_per_set; } // end func /* PagesPerSet */ function setPagesPerSet($pages_per_set) { $this->pages_per_set = $pages_per_set; } function getPagesPerSet() { return $this->pages_per_set; } /** * Returns the set we are on. * * @return integer current set of pages * @access public */ function getCurrentSet() { return floor(($this->current_page - 1) / $this->pages_per_set); } function preCalculateParameters() { $this->totalpages = $this->getTotalPages(); $this->startpage = ($this->getCurrentSet() * $this->pages_per_set) + 1; if (($this->startpage + $this->pages_per_set - 1) > $this->totalpages) { $this->endpage = $this->totalpages; } else { $this->endpage = $this->startpage + $this->pages_per_set - 1; } } // end func preCalculateParameters function render() { // do not allow to proceed if not initialized correctly if ($this->total_records == 0) { return false; } // HEADER $output = $this->formatHeader(); // GET INITIAL VARS $this->preCalculateParameters(); // calculate totalpages, startpage, endpage $set = $this->getCurrentSet(); // CACHE QUERY STRING STRIPPED OF VARIABLES NEEDED BY THIS CLASS $this->setProcessedQueryString(); // first generate all cells containing links to various pages $pages = ''; for ($int = $this->startpage; $int <= $this->endpage; $int++) { $pages .= ( ($int == $this->current_page) ? $this->formatActivePage($int) : $this->formatPage($int) ); } // LINK TO PREVIOUS SET if ($set > 0) { $prevset = $this->formatMovePrevSet($this->current_page - $this->pages_per_set); } else { $prevset = $this->empty_cell; } // LINK TO PREVIOUS PAGE if ($this->current_page > 1) { $prevpage = $this->formatMovePrevious($this->current_page - 1); } else { $prevpage = $this->empty_cell; } // LINK TO NEXT PAGE if ($this->current_page < $this->totalpages) { $nextpage = $this->formatMoveNext($this->current_page + 1); } else { $nextpage = $this->empty_cell; } // LINK TO NEXT SET if ( ($this->endpage + 1) <= $this->totalpages ) { $nextset = $this->formatMoveNextSet($this->endpage + 1); } else { $nextset = $this->empty_cell; } // RENDER PAGE NAVIGATION VIEW $output .= $prevset.$prevpage.$pages.$nextpage.$nextset; // ADD TABLE FOOTER $output .= $this->formatFooter(); return $output; } // end func render } // end class PageNavigator_ManualScroll ?>