Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination #3102

Merged
merged 4 commits into from Feb 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions layouts/joomla/pagination/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
88 changes: 88 additions & 0 deletions layouts/joomla/pagination/link.php
@@ -0,0 +1,88 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

$item = $displayData['data'];

$display = $item->text;

switch ((string) $item->text)
{
// Check for "Start" item
case JText::_('JLIB_HTML_START') :
$icon = "icon-backward";
break;

// Check for "Prev" item
case $item->text == JText::_('JPREV') :
$item->text = JText::_('JPREVIOUS');
$icon = "icon-step-backward";
break;

// Check for "Next" item
case JText::_('JNEXT') :
$icon = "icon-step-forward";
break;

// Check for "End" item
case JText::_('JLIB_HTML_END') :
$icon = "icon-forward";
break;

default:
$icon = null;
break;
}

if ($icon !== null)
{
$display = '<i class="' . $icon . '"></i>';
}

if ($displayData['active'])
{
if ($item->base > 0)
{
$limit = 'limitstart.value=' . $item->base;
}
else
{
$limit = 'limitstart.value=0';
}

$cssClasses = array();

$title = '';

if (!is_numeric($item->text))
{
JHtml::_('bootstrap.tooltip');
$cssClasses[] = 'hasTooltip';
$title = ' title="' . $item->text . '" ';
}

$onClick = 'document.adminForm.' . $item->prefix . 'limitstart.value=' . ($item->base > 0 ? $item->base : '0') . '; Joomla.submitform();return false;';
}
else
{
$class = (property_exists($item, 'active') && $item->active) ? 'active' : 'disabled';
}
?>
<?php if ($displayData['active']) : ?>
<li>
<a class="<?php echo implode(' ', $cssClasses); ?>" <?php echo $title; ?> href="#" onclick="<?php echo $onClick; ?>">
<?php echo $display; ?>
</a>
</li>
<?php else : ?>
<li class="<?php echo $class; ?>">
<span><?php echo $display; ?></span>
</li>
<?php endif;
84 changes: 84 additions & 0 deletions layouts/joomla/pagination/links.php
@@ -0,0 +1,84 @@
<?php
/**
* @package Joomla.Site
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

$list = $displayData['list'];
$pages = $list['pages'];

$options = new JRegistry($displayData['options']);

$showLimitBox = $options->get('showLimitBox', true);
$showPagesLinks = $options->get('showPagesLinks', true);
$showLimitStart = $options->get('showLimitStart', true);

// Calculate to display range of pages
$currentPage = 1;
$range = 1;
$step = 5;

if (!empty($pages['pages']))
{
foreach ($pages['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);
}
}
?>

<div class="pagination pagination-toolbar clearfix" style="text-align: center;">

<?php if ($showLimitBox) : ?>
<div class="limit pull-right">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM') . $list['limitfield']; ?>
</div>
<?php endif; ?>

<?php if ($showPagesLinks && (!empty($pages))) : ?>
<ul class="pagination-list">
<?php
echo JLayoutHelper::render('joomla.pagination.link', $pages['start']);
echo JLayoutHelper::render('joomla.pagination.link', $pages['previous']); ?>
<?php foreach ($pages['pages'] as $k => $page) : ?>

<?php $output = JLayoutHelper::render('joomla.pagination.link', $page); ?>
<?php if (in_array($k, range($range * $step - ($step + 1), $range * $step))) : ?>
<?php if (($k % $step == 0 || $k == $range * $step - ($step + 1)) && $k != $currentPage && $k != $range * $step - $step) :?>
<?php $output = preg_replace('#(<a.*?>).*?(</a>)#', '$1...$2', $output); ?>
<?php endif; ?>
<?php endif; ?>

<?php echo $output; ?>
<?php endforeach; ?>
<?php
echo JLayoutHelper::render('joomla.pagination.link', $pages['next']);
echo JLayoutHelper::render('joomla.pagination.link', $pages['end']); ?>
</ul>
<?php endif; ?>

<?php if ($showLimitStart) : ?>
<input type="hidden" name="<?php echo $list['prefix']; ?>limitstart" value="<?php echo $list['limitstart']; ?>" />
<?php endif; ?>

</div>
1 change: 1 addition & 0 deletions layouts/joomla/searchtools/default/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
1 change: 1 addition & 0 deletions layouts/joomla/searchtools/grid/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
1 change: 1 addition & 0 deletions layouts/joomla/searchtools/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
1 change: 1 addition & 0 deletions layouts/joomla/tinymce/buttons/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
1 change: 1 addition & 0 deletions layouts/joomla/tinymce/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
102 changes: 89 additions & 13 deletions libraries/cms/pagination/pagination.php
Expand Up @@ -415,29 +415,105 @@ public function getPagesLinks()
}

/**
* Return the pagination footer.
* Get the pagination links
*
* @return string Pagination footer.
* @param string $layoutId Layout to render the links
* @param array $options Optional array with settings for the layout
*
* @since 1.5
* @return string Pagination links.
*
* @since 3.3
*/
public function getListFooter()
public function getPaginationLinks($layoutId = 'joomla.pagination.links', $options = array())
{
// Allow to receive a null layout
$layoutId = (null === $layoutId) ? 'joomla.pagination.links' : $layoutId;

$app = JFactory::getApplication();

$list = array(
'prefix' => $this->prefix,
'limit' => $this->limit,
'limitstart' => $this->limitstart,
'total' => $this->total,
'limitfield' => $this->getLimitBox(),
'pagescounter' => $this->getPagesCounter(),
'pages' => $this->getPaginationPages()
);

return JLayoutHelper::render($layoutId, array('list' => $list, 'options' => $options));
}

/**
* Create and return the pagination page list string, ie. Previous, Next, 1 2 3 ... x.
*
* @return string Pagination page list string.
*
* @since 3.3
*/
public function getPaginationPages()
{
$list = array();
$list['prefix'] = $this->prefix;
$list['limit'] = $this->limit;
$list['limitstart'] = $this->limitstart;
$list['total'] = $this->total;
$list['limitfield'] = $this->getLimitBox();
$list['pagescounter'] = $this->getPagesCounter();
$list['pageslinks'] = $this->getPagesLinks();

$chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php';
if ($this->total > $this->limit)
{
// Build the page navigation list.
$data = $this->_buildDataObject();

// All
$list['all']['active'] = (null !== $data->all->base);
$list['all']['data'] = $data->all;

// Start
$list['start']['active'] = (null !== $data->start->base);
$list['start']['data'] = $data->start;

// Previous link
$list['previous']['active'] = (null !== $data->previous->base);
$list['previous']['data'] = $data->previous;

// Make sure it exists
$list['pages'] = array();

foreach ($data->pages as $i => $page)
{
$list['pages'][$i]['active'] = (null !== $page->base);
$list['pages'][$i]['data'] = $page;
}

$list['next']['active'] = (null !== $data->next->base);
$list['next']['data'] = $data->next;

$list['end']['active'] = (null !== $data->end->base);
$list['end']['data'] = $data->end;
}

return $list;
}

/**
* Return the pagination footer.
*
* @return string Pagination footer.
*
* @since 1.5
*/
public function getListFooter()
{
// Keep B/C for overrides done with chromes
$chromePath = JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/pagination.php';

if (file_exists($chromePath))
{
$list = array();
$list['prefix'] = $this->prefix;
$list['limit'] = $this->limit;
$list['limitstart'] = $this->limitstart;
$list['total'] = $this->total;
$list['limitfield'] = $this->getLimitBox();
$list['pagescounter'] = $this->getPagesCounter();
$list['pageslinks'] = $this->getPagesLinks();

include_once $chromePath;

if (function_exists('pagination_list_footer'))
Expand All @@ -446,7 +522,7 @@ public function getListFooter()
}
}

return $this->_list_footer($list);
return $this->getPaginationLinks();
}

/**
Expand Down