diff --git a/CREDITS b/CREDITS index 9c49176f2..d6874a7bb 100644 --- a/CREDITS +++ b/CREDITS @@ -6,11 +6,9 @@ poche is based on : * PHP Simple HTML DOM Parser (for Pocket import) http://simplehtmldom.sourceforge.net/ * Session https://github.com/tontof/kriss_feed/blob/master/src/class/Session.php * Twig http://twig.sensiolabs.org +* Flash messages https://github.com/plasticbrain/PHP-Flash-Messages +* Pagination https://github.com/daveismyname/pagination poche is developed by Nicolas Lœuillet under the Do What the Fuck You Want to Public License -Contributors : -Nicolas Lœuillet aka nico_somb -Tom.C. aka tmos -PeaceCopathe -Gregoire_M \ No newline at end of file +Contributors : https://github.com/inthepoche/poche/graphs/contributors \ No newline at end of file diff --git a/inc/3rdparty/paginator.php b/inc/3rdparty/paginator.php new file mode 100644 index 000000000..e8801555b --- /dev/null +++ b/inc/3rdparty/paginator.php @@ -0,0 +1,198 @@ +_instance = $instance; + $this->_perPage = $perPage; + $this->set_instance(); + } + + /** + * get_start + * + * creates the starting point for limiting the dataset + * @return numeric + */ + private function get_start(){ + return ($this->_page * $this->_perPage) - $this->_perPage; + } + + /** + * set_instance + * + * sets the instance parameter, if numeric value is 0 then set to 1 + * + * @var numeric + */ + private function set_instance(){ + $this->_page = (int) (!isset($_GET[$this->_instance]) ? 1 : $_GET[$this->_instance]); + $this->_page = ($this->_page == 0 ? 1 : $this->_page); + } + + /** + * set_total + * + * collect a numberic value and assigns it to the totalRows + * + * @var numeric + */ + public function set_total($_totalRows){ + $this->_totalRows = $_totalRows; + } + + /** + * get_limit + * + * returns the limit for the data source, calling the get_start method and passing in the number of items perp page + * + * @return string + */ + public function get_limit(){ + return "LIMIT ".$this->get_start().",$this->_perPage"; + } + + /** + * page_links + * + * create the html links for navigating through the dataset + * + * @var sting $path optionally set the path for the link + * @var sting $ext optionally pass in extra parameters to the GET + * @return string returns the html menu + */ + public function page_links($path='?',$ext=null) + { + $adjacents = "2"; + $prev = $this->_page - 1; + $next = $this->_page + 1; + $lastpage = ceil($this->_totalRows/$this->_perPage); + $lpm1 = $lastpage - 1; + + $pagination = ""; + if($lastpage > 1) + { + $pagination .= "