Permalink
Browse files

Fix indentation

Replaced tabs with spaces and wrapped lines under 80 characters.
  • Loading branch information...
1 parent 2fd36ca commit a3be0b169b4bd4bf891ce904c326e515d4262631 @simonewebdesign committed Dec 29, 2012
Showing with 326 additions and 307 deletions.
  1. +22 −17 library/classes/Paginator.php
  2. +304 −290 library/classes/Table.php
@@ -1,12 +1,14 @@
<?php
/** Paginator.php
- * A convenient class to paginate an arbitrary number of elements.
+ * A convenient class for paginating an arbitrary number of elements.
* Required parameters:
@param $elements the total number of elements to paginate.
@param $current_page the current page.
* Optional parameters:
@param $elements_per_page number of desired elements per page.
- * For the paginate() function is also required the URL, that must respect this format: http://example.com/elements.php?page=$1 (where $1 is the placeholder for page).
+ * For the paginate() function is also required the URL, that must respect this
+ format:
+ http://example.com/elements.php?page=$1 (where $1 is the placeholder for page).
* @version 1.2 - 28/08/2012
* @author Simone <hello@simonewebdesign.it>
*/
@@ -17,9 +19,9 @@ class Paginator {
* [LIMIT {[offset,] row_count | row_count OFFSET offset}]
*/
var $offset = 0; // where to start displaying elements
- var $elements_per_page = 0; // limit
+ var $elements_per_page = 0; // limit
- var $page = 0; // current page
+ var $page = 0; // current page
var $pages = 0; // all pages
var $elements = 0; // all elements
var $displayed_elements = 0; // elements in the current page
@@ -30,19 +32,18 @@ class Paginator {
function setElements($elements) {
$this->elements = $elements;
}
-
function setElementsPerPage($elements_per_page) {
$this->elements_per_page = $elements_per_page;
}
-
function setPage($current_page=1) {
// paginate
$this->page = (int) ($current_page > 0 ? $current_page : 1);
- $this->offset = (int) $this->page * $this->elements_per_page - $this->elements_per_page;
+ $this->offset = (int) $this->page * $this->elements_per_page
+ - $this->elements_per_page;
$this->pages = (int) ceil( $this->elements / $this->elements_per_page );
- $this->displayed_elements = $this->page == $this->pages ? $this->elements % $this->elements_per_page : $this->elements_per_page;
+ $this->displayed_elements = $this->page == $this->pages ? $this->elements
+ % $this->elements_per_page : $this->elements_per_page;
}
-
function setURL($url) {
$this->url = $url;
}
@@ -84,12 +85,14 @@ function paginate() {
if ($this->elements > $this->elements_per_page) {
if ($this->page > 0) {
if ($this->page > 1) {
- // we are not in the first page, so we print the first navigation arrows
+ // we aren't in the first page so we print the 1st navigation arrows
$html .= '<li>';
- $html .= '<a href="' . $this->URLreplacedWithPage(1) . '"> &lt;&lt; </a>'; // first page
+ $html .= '<a href="' . $this->URLreplacedWithPage(1)
+ . '"> &lt;&lt; </a>'; // first page
$html .= '</li>';
$html .= '<li>';
- $html .= '<a href="' . $this->URLreplacedWithPage($this->page - 1) . '"> &lt; </a>'; // previous page
+ $html .= '<a href="' . $this->URLreplacedWithPage($this->page - 1)
+ . '"> &lt; </a>'; // previous page
$html .= '</li>';
}
@@ -105,18 +108,20 @@ function paginate() {
}
if ($this->page < $this->pages) {
- // we are not in the last page, so we print the last navigation arrows
+ // we aren't in the last page so we print the last navigation arrows
$html .= '<li>';
- $html .= '<a href="' . $this->URLreplacedWithPage($this->page + 1) . '"> &gt; </a>'; // next page
+ $html .= '<a href="' . $this->URLreplacedWithPage($this->page + 1)
+ . '"> &gt; </a>'; // next page
$html .= '</li>';
$html .= '<li>';
- $html .= '<a href="' . $this->URLreplacedWithPage($this->pages) . '"> &gt;&gt; </a>'; // last page
+ $html .= '<a href="' . $this->URLreplacedWithPage($this->pages)
+ . '"> &gt;&gt; </a>'; // last page
$html .= '</li>';
}
}
}
$html .= '</ul>';
$html .= '</div>';
return $html;
- } // end paginate
-} // end Paginator
+ } // end paginate function
+} // end Paginator class
Oops, something went wrong.

0 comments on commit a3be0b1

Please sign in to comment.