From 32b88146d7c82e394447f94e7d95a37340095eb9 Mon Sep 17 00:00:00 2001 From: Roberto - phproberto Date: Tue, 19 Nov 2013 00:33:08 +0100 Subject: [PATCH 1/4] [imp][libraries] use overridable layouts for pagination --- layouts/joomla/pagination/link.php | 88 ++++++++++++++++++++++++ layouts/joomla/pagination/links.php | 80 ++++++++++++++++++++++ libraries/cms/pagination/pagination.php | 90 ++++++++++++++++++++----- 3 files changed, 240 insertions(+), 18 deletions(-) create mode 100644 layouts/joomla/pagination/link.php create mode 100644 layouts/joomla/pagination/links.php diff --git a/layouts/joomla/pagination/link.php b/layouts/joomla/pagination/link.php new file mode 100644 index 0000000000000..c6aee97606f97 --- /dev/null +++ b/layouts/joomla/pagination/link.php @@ -0,0 +1,88 @@ +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 = ''; +} + +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'; +} +?> + +
  • + href="#" onclick=""> + + +
  • + +
  • + +
  • +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); + } +} +?> + + diff --git a/libraries/cms/pagination/pagination.php b/libraries/cms/pagination/pagination.php index 32b045a8c012f..f2cecdd099d17 100644 --- a/libraries/cms/pagination/pagination.php +++ b/libraries/cms/pagination/pagination.php @@ -415,38 +415,92 @@ 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.2 */ - 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(); - $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(); + $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)); + } - $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php'; + /** + * Create and return the pagination page list string, ie. Previous, Next, 1 2 3 ... x. + * + * @return string Pagination page list string. + * + * @since 3.2 + */ + public function getPaginationPages() + { + $list = array(); - if (file_exists($chromePath)) + if ($this->total > $this->limit) { - include_once $chromePath; + // 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; - if (function_exists('pagination_list_footer')) + // Make sure it exists + $list['pages'] = array(); + + foreach ($data->pages as $i => $page) { - return pagination_list_footer($list); + $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 $this->_list_footer($list); + return $list; + } + + /** + * Return the pagination footer. + * + * @return string Pagination footer. + * + * @since 1.5 + */ + public function getListFooter() + { + return $this->getPaginationLinks(); } /** From 31c427604a45b0c9d6d6f7eaa136b200d1f15519 Mon Sep 17 00:00:00 2001 From: Roberto - phproberto Date: Tue, 19 Nov 2013 00:50:40 +0100 Subject: [PATCH 2/4] [fix][libraries] add B/C for pagination overrides done with chromes --- libraries/cms/pagination/pagination.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libraries/cms/pagination/pagination.php b/libraries/cms/pagination/pagination.php index f2cecdd099d17..f02d844a0b584 100644 --- a/libraries/cms/pagination/pagination.php +++ b/libraries/cms/pagination/pagination.php @@ -500,6 +500,28 @@ public function getPaginationPages() */ 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')) + { + return pagination_list_footer($list); + } + } + return $this->getPaginationLinks(); } From ca2c3a597229bf00eb6f68bda4e4beb5fbcd4e76 Mon Sep 17 00:00:00 2001 From: Roberto - phproberto Date: Fri, 14 Feb 2014 09:25:21 +0100 Subject: [PATCH 3/4] [imp] copyright + version fixes --- layouts/joomla/pagination/link.php | 4 ++-- layouts/joomla/pagination/links.php | 6 +++++- libraries/cms/pagination/pagination.php | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/layouts/joomla/pagination/link.php b/layouts/joomla/pagination/link.php index c6aee97606f97..bee0caf0355ad 100644 --- a/layouts/joomla/pagination/link.php +++ b/layouts/joomla/pagination/link.php @@ -3,7 +3,7 @@ * @package Joomla.Site * @subpackage Layout * - * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved. + * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ @@ -85,4 +85,4 @@
  • - diff --git a/libraries/cms/pagination/pagination.php b/libraries/cms/pagination/pagination.php index f02d844a0b584..3c8844a1b6219 100644 --- a/libraries/cms/pagination/pagination.php +++ b/libraries/cms/pagination/pagination.php @@ -422,7 +422,7 @@ public function getPagesLinks() * * @return string Pagination links. * - * @since 3.2 + * @since 3.3 */ public function getPaginationLinks($layoutId = 'joomla.pagination.links', $options = array()) { @@ -449,7 +449,7 @@ public function getPaginationLinks($layoutId = 'joomla.pagination.links', $optio * * @return string Pagination page list string. * - * @since 3.2 + * @since 3.3 */ public function getPaginationPages() { From 79b718d7f2e73d11386aa2481183b9b2323ef2fe Mon Sep 17 00:00:00 2001 From: Roberto - phproberto Date: Fri, 14 Feb 2014 13:34:03 +0100 Subject: [PATCH 4/4] [imp] missing index.html files --- layouts/joomla/pagination/index.html | 1 + layouts/joomla/searchtools/default/index.html | 1 + layouts/joomla/searchtools/grid/index.html | 1 + layouts/joomla/searchtools/index.html | 1 + layouts/joomla/tinymce/buttons/index.html | 1 + layouts/joomla/tinymce/index.html | 1 + 6 files changed, 6 insertions(+) create mode 100644 layouts/joomla/pagination/index.html create mode 100644 layouts/joomla/searchtools/default/index.html create mode 100644 layouts/joomla/searchtools/grid/index.html create mode 100644 layouts/joomla/searchtools/index.html create mode 100644 layouts/joomla/tinymce/buttons/index.html create mode 100644 layouts/joomla/tinymce/index.html diff --git a/layouts/joomla/pagination/index.html b/layouts/joomla/pagination/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/layouts/joomla/pagination/index.html @@ -0,0 +1 @@ + diff --git a/layouts/joomla/searchtools/default/index.html b/layouts/joomla/searchtools/default/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/layouts/joomla/searchtools/default/index.html @@ -0,0 +1 @@ + diff --git a/layouts/joomla/searchtools/grid/index.html b/layouts/joomla/searchtools/grid/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/layouts/joomla/searchtools/grid/index.html @@ -0,0 +1 @@ + diff --git a/layouts/joomla/searchtools/index.html b/layouts/joomla/searchtools/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/layouts/joomla/searchtools/index.html @@ -0,0 +1 @@ + diff --git a/layouts/joomla/tinymce/buttons/index.html b/layouts/joomla/tinymce/buttons/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/layouts/joomla/tinymce/buttons/index.html @@ -0,0 +1 @@ + diff --git a/layouts/joomla/tinymce/index.html b/layouts/joomla/tinymce/index.html new file mode 100644 index 0000000000000..2efb97f319a35 --- /dev/null +++ b/layouts/joomla/tinymce/index.html @@ -0,0 +1 @@ +