* Handles returning arrays based on a given pagenumber.
* By specifing a $_GET['pagenum'] or if not(page = 1 will be used) a few elements from a specific query will be returned. Not all elements have to be loaded into objects, only
* the elements needed for that specific page, this is a good thing performance wise. This is done by passign the query to the constructor and specifying how many you want to display.
* @author Daan Janssens, mentored by Matthew Lagoe
* will fetch the correct elements that match to a specific page (specified by the $_GET['pagenum'] variable). The query has to be passed as a string to the function
* that way it will only load the specific elements that are related to the pagenumber. The $params, parameter is optional and is used to pass the parameters for the query.
* The result class will be used to instantiate the found elements with, their set() function will be called. The class its getters can be later used to get the info out of the object.
* @param $query the query to be paginated
* @param $db the db on which the query should be performed
* @param $nrDisplayed the amount of elements that should be displayed /page
* @param $resultClass the elements that should be returned should be of that specific class.
* @param $params the parameters used by the query (optional)
*/
function __construct($query, $db, $nrDisplayed, $resultClass, $params = array()) {
function __construct($query, $db, $nrDisplayed, $resultClass, $params = array()) {
if (!(isset($_GET['pagenum']))){
if (!(isset($_GET['pagenum']))){
$this->current= 1;
$this->current= 1;
@ -52,22 +68,47 @@ class Pagination{
}
}
/**
* return the number of the 'last' object attribute
* @return the number of the last page
*/
public function getLast(){
public function getLast(){
return $this->last;
return $this->last;
}
}
/**
* return the number of the 'current' object attribute
* @return the number of the current page
*/
public function getCurrent(){
public function getCurrent(){
return $this->current;
return $this->current;
}
}
/**
* return the elements array of the object
* @return the elements of a specific page (these are instantiations of the class passed as parameter ($resultClass) to the constructor)
*/
public function getElements(){
public function getElements(){
return $this->element_array;
return $this->element_array;
}
}
/**
* return total amount of rows for the original query
* @return the total amount of rows for the original query
*/
public function getAmountOfRows(){
public function getAmountOfRows(){
return $this->amountOfRows;
return $this->amountOfRows;
}
}
/**
* return the page links.
* (for browsing the pages, placed under a table for example) the $nrOfLinks parameter specifies the amount of links you want to return.
* it will show the links closest to the current page on both sides (in case one side can't show more, it will show more on the other side)
* @return an array of integerswhich refer to the clickable pagenumbers for browsing other pages.
*/
public function getLinks($nrOfLinks){
public function getLinks($nrOfLinks){
$pageLinks = Array();
$pageLinks = Array();
//if amount of showable links is greater than the amount of pages: show all!
//if amount of showable links is greater than the amount of pages: show all!
* groups moderators & admins together. A Support Group is a group of people with the same skills or knowledge. A typical example will be the (Developers group, webteam group, management, etc..)
* The idea is that tickets can be forwarded to a group of persons that might be able to answer that specific question. Support Groups are also the key of handling the emails, because the email addresses
* of the support groups will be used by the Mail_Handler class.
* @author Daan Janssens, mentored by Matthew Lagoe
* @param $values should be an array of the form array('SGroupId' => groupid, 'Name' => name, 'Tag' => tag, 'GroupEmail' => mail, 'IMAP_MailServer' => server, 'IMAP_Username' => username,'IMAP_Password' => pass).