Improves on Paginator
This commit is contained in:
parent
38326d8c63
commit
983dc20f60
|
@ -24,21 +24,43 @@ class Paginator {
|
||||||
return self::$pager[$key];
|
return self::$pager[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function urlNextPage()
|
||||||
|
{
|
||||||
|
global $Url;
|
||||||
|
|
||||||
|
$domain = trim(DOMAIN_BASE,'/');
|
||||||
|
$filter = trim($Url->activeFilter(), '/');
|
||||||
|
|
||||||
|
if(empty($filter)) {
|
||||||
|
$url = $domain.'/'.$Url->slug();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url.'?page='.self::get('nextPage');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function urlPrevPage()
|
||||||
|
{
|
||||||
|
global $Url;
|
||||||
|
|
||||||
|
$domain = trim(DOMAIN_BASE,'/');
|
||||||
|
$filter = trim($Url->activeFilter(), '/');
|
||||||
|
|
||||||
|
if(empty($filter)) {
|
||||||
|
$url = $domain.'/'.$Url->slug();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$url = $domain.'/'.$filter.'/'.$Url->slug();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url.'?page='.self::get('prevPage');
|
||||||
|
}
|
||||||
|
|
||||||
public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false)
|
public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false)
|
||||||
{
|
{
|
||||||
global $Language;
|
global $Language;
|
||||||
global $Url;
|
|
||||||
|
|
||||||
$url = trim(DOMAIN_BASE,'/');
|
|
||||||
|
|
||||||
$filter = '';
|
|
||||||
if($Url->whereAmI()=='tag') {
|
|
||||||
$filter = trim($Url->filters('tag'), '/');
|
|
||||||
$url = $url.'/'.$filter.'/'.$Url->slug();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$url = $url.'/';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = '<div id="paginator">';
|
$html = '<div id="paginator">';
|
||||||
$html .= '<ul>';
|
$html .= '<ul>';
|
||||||
|
@ -50,7 +72,7 @@ class Paginator {
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '<li class="left">';
|
$html .= '<li class="left">';
|
||||||
$html .= '<a href="'.$url.'?page='.self::get('prevPage').'">'.$textPrevPage.'</a>';
|
$html .= '<a href="'.self::urlPrevPage().'?page='.self::get('prevPage').'">'.$textPrevPage.'</a>';
|
||||||
$html .= '</li>';
|
$html .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +87,7 @@ class Paginator {
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '<li class="right">';
|
$html .= '<li class="right">';
|
||||||
$html .= '<a href="'.$url.'?page='.self::get('nextPage').'">'.$textNextPage.'</a>';
|
$html .= '<a href="'.self::urlNextPage().'?page='.self::get('nextPage').'">'.$textNextPage.'</a>';
|
||||||
$html .= '</li>';
|
$html .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Url
|
||||||
private $filters; // Filters for the URI
|
private $filters; // Filters for the URI
|
||||||
private $notFound;
|
private $notFound;
|
||||||
private $parameters;
|
private $parameters;
|
||||||
|
private $activeFilter;
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
@ -30,6 +31,8 @@ class Url
|
||||||
$this->slug = '';
|
$this->slug = '';
|
||||||
|
|
||||||
$this->filters = array();
|
$this->filters = array();
|
||||||
|
|
||||||
|
$this->activeFilter = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filters change for different languages
|
// Filters change for different languages
|
||||||
|
@ -57,6 +60,7 @@ class Url
|
||||||
{
|
{
|
||||||
$this->slug = $slug;
|
$this->slug = $slug;
|
||||||
$this->whereAmI = $filterName;
|
$this->whereAmI = $filterName;
|
||||||
|
$this->activeFilter = $filterURI;
|
||||||
|
|
||||||
// If the slug is empty
|
// If the slug is empty
|
||||||
if(Text::isEmpty($slug))
|
if(Text::isEmpty($slug))
|
||||||
|
@ -93,6 +97,11 @@ class Url
|
||||||
return $this->slug;
|
return $this->slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function activeFilter()
|
||||||
|
{
|
||||||
|
return $this->activeFilter;
|
||||||
|
}
|
||||||
|
|
||||||
public function explodeSlug($delimiter="/")
|
public function explodeSlug($delimiter="/")
|
||||||
{
|
{
|
||||||
return explode($delimiter, $this->slug);
|
return explode($delimiter, $this->slug);
|
||||||
|
|
|
@ -65,11 +65,11 @@
|
||||||
<ul class="actions pagination">
|
<ul class="actions pagination">
|
||||||
<?php
|
<?php
|
||||||
if( Paginator::get('showNewer') ) {
|
if( Paginator::get('showNewer') ) {
|
||||||
echo '<li><a href="'.HTML_PATH_ROOT.'?page='.Paginator::get('prevPage').'" class="button big previous">Previous Page</a></li>';
|
echo '<li><a href="'.Paginator::urlPrevPage().'" class="button big previous">Previous Page</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Paginator::get('showOlder') ) {
|
if( Paginator::get('showOlder') ) {
|
||||||
echo '<li><a href="'.HTML_PATH_ROOT.'?page='.Paginator::get('nextPage').'" class="button big next">Next Page</a></li>';
|
echo '<li><a href="'.Paginator::urlNextPage().'" class="button big next">Next Page</a></li>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue