diff --git a/source/plg_system_t3/includes/joomla25/pagination.php b/source/plg_system_t3/includes/joomla25/pagination.php index c97c420eb5..3cfbebe23d 100644 --- a/source/plg_system_t3/includes/joomla25/pagination.php +++ b/source/plg_system_t3/includes/joomla25/pagination.php @@ -448,7 +448,7 @@ public function getLimitBox() 'select.genericlist', $limits, $this->prefix . 'limit', - 'class="input" size="1" onchange="Joomla.submitform();"', + 'class="inputbox" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected @@ -460,7 +460,7 @@ public function getLimitBox() 'select.genericlist', $limits, $this->prefix . 'limit', - 'class="input" size="1" onchange="this.form.submit()"', + 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', $selected diff --git a/source/plg_system_t3/includes/joomla30/pagination.php b/source/plg_system_t3/includes/joomla30/pagination.php index cfcaa2e6e1..2b7aca13f0 100644 --- a/source/plg_system_t3/includes/joomla30/pagination.php +++ b/source/plg_system_t3/includes/joomla30/pagination.php @@ -1,75 +1,74 @@ pagesStart = $this->pagesCurrent - ($displayedPages / 2); + if ($this->pagesStart < 1) { $this->pagesStart = 1; } + if ($this->pagesStart + $displayedPages > $this->pagesTotal) { $this->pagesStop = $this->pagesTotal; + if ($this->pagesTotal < $displayedPages) { $this->pagesStart = 1; @@ -167,7 +169,7 @@ public function __construct($total, $limitstart, $limit, $prefix = '') * * @return mixed The old value for the parameter. * - * @since 11.1 + * @since 1.6 */ public function setAdditionalUrlParam($key, $value) { @@ -195,7 +197,7 @@ public function setAdditionalUrlParam($key, $value) * * @return mixed The value if it exists or null if it does not. * - * @since 11.1 + * @since 1.6 */ public function getAdditionalUrlParam($key) { @@ -211,7 +213,7 @@ public function getAdditionalUrlParam($key) * * @return integer Rationalised offset for a row with a given index. * - * @since 11.1 + * @since 1.5 */ public function getRowOffset($index) { @@ -223,15 +225,17 @@ public function getRowOffset($index) * * @return object Pagination data object. * - * @since 11.1 + * @since 1.5 */ public function getData() { static $data; + if (!is_object($data)) { $data = $this->_buildDataObject(); } + return $data; } @@ -240,15 +244,17 @@ public function getData() * * @return string Pagination pages counter string. * - * @since 11.1 + * @since 1.5 */ public function getPagesCounter() { $html = null; + if ($this->pagesTotal > 1) { $html .= JText::sprintf('JLIB_HTML_PAGE_CURRENT_OF_TOTAL', $this->pagesCurrent, $this->pagesTotal); } + return $html; } @@ -257,7 +263,7 @@ public function getPagesCounter() * * @return string Pagination result set counter string. * - * @since 11.1 + * @since 1.5 */ public function getResultsCounter() { @@ -293,7 +299,7 @@ public function getResultsCounter() * * @return string Pagination page list string. * - * @since 11.1 + * @since 1.5 */ public function getPagesLinks() { @@ -308,16 +314,19 @@ public function getPagesLinks() $itemOverride = false; $listOverride = false; + // $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php'; // T3: detect if chrome pagination.php in template or in plugin - $chromePath = T3Path::getPath ('html/pagination.php'); - //$chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php'; + $chromePath = T3Path::getPath ('html/pagination.php'); + if (file_exists($chromePath)) { include_once $chromePath; + if (function_exists('pagination_item_active') && function_exists('pagination_item_inactive')) { $itemOverride = true; } + if (function_exists('pagination_list_render')) { $listOverride = true; @@ -346,6 +355,7 @@ public function getPagesLinks() $list['start']['active'] = false; $list['start']['data'] = ($itemOverride) ? pagination_item_inactive($data->start) : $this->_item_inactive($data->start); } + if ($data->previous->base !== null) { $list['previous']['active'] = true; @@ -359,6 +369,7 @@ public function getPagesLinks() // Make sure it exists $list['pages'] = array(); + foreach ($data->pages as $i => $page) { if ($page->base !== null) @@ -406,37 +417,116 @@ 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 11.1 + * @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(); + 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'; // T3: detect if chrome pagination.php in template or in plugin - $chromePath = T3Path::getPath ('html/pagination.php'); - //$chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php'; + $chromePath = T3Path::getPath ('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->_list_footer($list); + + return $this->getPaginationLinks(); } /** @@ -444,7 +534,7 @@ public function getListFooter() * * @return string The HTML for the limit # input box. * - * @since 11.1 + * @since 1.5 */ public function getLimitBox() { @@ -456,6 +546,7 @@ public function getLimitBox() { $limits[] = JHtml::_('select.option', "$i"); } + $limits[] = JHtml::_('select.option', '50', JText::_('J50')); $limits[] = JHtml::_('select.option', '100', JText::_('J100')); $limits[] = JHtml::_('select.option', '0', JText::_('JALL')); @@ -469,7 +560,7 @@ public function getLimitBox() 'select.genericlist', $limits, $this->prefix . 'limit', - 'class="input input-mini" size="1" onchange="Joomla.submitform();"', + 'class="inputbox input-mini" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected @@ -481,12 +572,13 @@ public function getLimitBox() 'select.genericlist', $limits, $this->prefix . 'limit', - 'class="input input-mini" size="1" onchange="this.form.submit()"', + 'class="inputbox input-mini" size="1" onchange="this.form.submit()"', 'value', 'text', $selected ); } + return $html; } @@ -502,7 +594,7 @@ public function getLimitBox() * * @return string Either the icon to move an item up or a space. * - * @since 11.1 + * @since 1.5 */ public function orderUpIcon($i, $condition = true, $task = 'orderup', $alt = 'JLIB_HTML_MOVE_UP', $enabled = true, $checkbox = 'cb') { @@ -529,7 +621,7 @@ public function orderUpIcon($i, $condition = true, $task = 'orderup', $alt = 'JL * * @return string Either the icon to move an item down or a space. * - * @since 11.1 + * @since 1.5 */ public function orderDownIcon($i, $n, $condition = true, $task = 'orderdown', $alt = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $checkbox = 'cb') { @@ -550,7 +642,7 @@ public function orderDownIcon($i, $n, $condition = true, $task = 'orderdown', $a * * @return string HTML for a list footer * - * @since 11.1 + * @since 1.5 */ protected function _list_footer($list) { @@ -573,7 +665,7 @@ protected function _list_footer($list) * * @return string HTML for a list start, previous, next,end * - * @since 11.1 + * @since 1.5 */ protected function _list_render($list) { @@ -581,10 +673,12 @@ protected function _list_render($list) $html = '