Skip to content

Commit

Permalink
Fixed problems with pagination.php file
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed Oct 19, 2012
1 parent 8bd3b1e commit ea21ab9
Showing 1 changed file with 223 additions and 111 deletions.
334 changes: 223 additions & 111 deletions meet_gavern/html/pagination.php
Original file line number Diff line number Diff line change
@@ -1,114 +1,226 @@
<?php
/**
* @version $Id: pagination.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined('_JEXEC') or die;

/**
* This is a file to add template specific chrome to pagination rendering.
*
* pagination_list_footer
* Input variable $list is an array with offsets:
* $list[limit] : int
* $list[limitstart] : int
* $list[total] : int
* $list[limitfield] : string
* $list[pagescounter] : string
* $list[pageslinks] : string
*
* pagination_list_render
* Input variable $list is an array with offsets:
* $list[all]
* [data] : string
* [active] : boolean
* $list[start]
* [data] : string
* [active] : boolean
* $list[previous]
* [data] : string
* [active] : boolean
* $list[next]
* [data] : string
* [active] : boolean
* $list[end]
* [data] : string
* [active] : boolean
* $list[pages]
* [{PAGE}][data] : string
* [{PAGE}][active] : boolean
*
* pagination_item_active
* Input variable $item is an object with fields:
* $item->base : integer
* $item->link : string
* $item->text : string
*
* pagination_item_inactive
* Input variable $item is an object with fields:
* $item->base : integer
* $item->link : string
* $item->text : string
*
* This gives template designers ultimate control over how pagination is rendered.
*
* NOTE: If you override pagination_item_active OR pagination_item_inactive you MUST override them both
*/

function pagination_list_footer($list)
{
$html = "<div class=\"pagination\">\n";
$html .= $list['pageslinks'];
$html .= "\n<input type=\"hidden\" name=\"" . $list['prefix'] . "limitstart\" value=\"".$list['limitstart']."\" />";
$html .= "\n</div>";

return $html;
}

function pagination_list_render($list)
{
// Initialize variables
$html = "<ul class=\"pagination-list\">";
$html .= '<li><a>&larr;</a></li>'.$list['start']['data'];
$html .= $list['previous']['data'];

foreach( $list['pages'] as $page )
{
if($page['data']['active']) {
}

$html .= $page['data'];

if($page['data']['active']) {
}
}

$html .= $list['next']['data'];
$html .= $list['end']['data'];
$html .= '<li><a>&rarr;</a></li>';

$html .= "</ul>";
<?php
/**
* @package Joomla.Administrator
* @subpackage Templates.protostar
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* This is a file to add template specific chrome to pagination rendering.
*
* pagination_list_footer
* Input variable $list is an array with offsets:
* $list[limit] : int
* $list[limitstart] : int
* $list[total] : int
* $list[limitfield] : string
* $list[pagescounter] : string
* $list[pageslinks] : string
*
* pagination_list_render
* Input variable $list is an array with offsets:
* $list[all]
* [data] : string
* [active] : boolean
* $list[start]
* [data] : string
* [active] : boolean
* $list[previous]
* [data] : string
* [active] : boolean
* $list[next]
* [data] : string
* [active] : boolean
* $list[end]
* [data] : string
* [active] : boolean
* $list[pages]
* [{PAGE}][data] : string
* [{PAGE}][active] : boolean
*
* pagination_item_active
* Input variable $item is an object with fields:
* $item->base : integer
* $item->link : string
* $item->text : string
*
* pagination_item_inactive
* Input variable $item is an object with fields:
* $item->base : integer
* $item->link : string
* $item->text : string
*
* This gives template designers ultimate control over how pagination is rendered.
*
* NOTE: If you override pagination_item_active OR pagination_item_inactive you MUST override them both
*/

/**
* Renders the pagination footer
*
* @param array $list Array containing pagination footer
*
* @return string HTML markup for the full pagination footer
*
* @since 3.0
*/
function pagination_list_footer($list)
{
$html = "<div class=\"pagination\">\n";
$html .= $list['pageslinks'];
$html .= "\n<input type=\"hidden\" name=\"" . $list['prefix'] . "limitstart\" value=\"" . $list['limitstart'] . "\" />";
$html .= "\n</div>";

return $html;
}

/**
* Renders the pagination list
*
* @param array $list Array containing pagination information
*
* @return string HTML markup for the full pagination object
*
* @since 3.0
*/
function pagination_list_render($list)
{
// Calculate to display range of pages
$currentPage = 1;
$range = 1;
$step = 5;
foreach ($list['pages'] as $k => $page)
{
if (!$page['active'])
{
$currentPage = $k;
}
}
if ($currentPage >= $step)
{
if ($currentPage % $step == 0)
{
$range = ceil($currentPage / $step) + 1;
}
else
{
$range = ceil($currentPage / $step);
}
}

$html = '<ul class="pagination-list">';
$html .= $list['start']['data'];
$html .= $list['previous']['data'];

foreach($list['pages'] as $k => $page)
{
if (in_array($k, range($range * $step - ($step + 1), $range * $step)))
{
if (($k % $step == 0 || $k == $range * $step - ($step + 1)) && $k != $currentPage && $k != $range * $step - $step)
{
$page['data'] = preg_replace('#(<a.*?>).*?(</a>)#', '$1...$2', $page['data']);
}
}

$html .= $page['data'];
}

$html .= $list['next']['data'];
$html .= $list['end']['data'];

$html .= '</ul>';
return $html;

}
}

/**
* Renders an active item in the pagination block
*
* @param JPaginationObject $item The current pagination object
*
* @return string HTML markup for active item
*
* @since 3.0
*/
function pagination_item_active(&$item)
{
if ($item->base>0)
return "<li><a href=\"#\" title=\"".$item->text."\" onclick=\"document.adminForm." . $item->prefix . "limitstart.value=".$item->base."; Joomla.submitform();return false;\">".$item->text."</a></li>";
else
return "<li><a href=\"#\" title=\"".$item->text."\" onclick=\"document.adminForm." . $item->prefix . "limitstart.value=0; Joomla.submitform();return false;\">".$item->text."</a></li>";
}

function pagination_item_inactive(&$item) {
return "<li class=\"disabled\"><a>".$item->text."</a></li>";
}
?>
// Check for "Start" item
if ($item->text == JText::_('JLIB_HTML_START'))
{
$display = '<i class="icon-first"></i>';
}

// Check for "Prev" item
if ($item->text == JText::_('JPREV'))
{
$display = '<i class="icon-previous"></i>';
}

// Check for "Next" item
if ($item->text == JText::_('JNEXT'))
{
$display = '<i class="icon-next"></i>';
}

// Check for "End" item
if ($item->text == JText::_('JLIB_HTML_END'))
{
$display = '<i class="icon-last"></i>';
}

// If the display object isn't set already, just render the item with its text
if (!isset($display))
{
$display = $item->text;
}

return "<li><a title=\"" . $item->text . "\" href=\"" . $item->link . "\" class=\"pagenav\">" . $item->text . "</a><li>";
}

/**
* Renders an inactive item in the pagination block
*
* @param JPaginationObject $item The current pagination object
*
* @return string HTML markup for inactive item
*
* @since 3.0
*/
function pagination_item_inactive(&$item)
{
// Check for "Start" item
if ($item->text == JText::_('JLIB_HTML_START'))
{
return '<li class="disabled"><a>'.JText::_('JLIB_HTML_START').'</a></li>';
}

// Check for "Prev" item
if ($item->text == JText::_('JPREV'))
{
return '<li class="disabled"><a>'.JText::_('JPREV').'</a></li>';
}

// Check for "Next" item
if ($item->text == JText::_('JNEXT'))
{
return '<li class="disabled"><a>'.JText::_('JNEXT').'</a></li>';
}

// Check for "End" item
if ($item->text == JText::_('JLIB_HTML_END'))
{
return '<li class="disabled"><a>'.JText::_('JLIB_HTML_END').'</a></li>';
}

// Check if the item is the active page
if (isset($item->active) && ($item->active))
{
return '<li class="active"><a>' . $item->text . '</a></li>';
}

// Doesn't match any other condition, render a normal item
return '<li class="disabled"><a>' . $item->text . '</a></li>';
}

0 comments on commit ea21ab9

Please sign in to comment.