From: Michael M Slusarz Date: Fri, 23 Jul 2010 20:53:14 +0000 (-0600) Subject: Clean up Horde_Ui_Core_Pager::. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d4ffbab1a0d6377b5052d870dc766490bb495bd3;p=horde.git Clean up Horde_Ui_Core_Pager::. Use Horde_Url. Combine statements. --- diff --git a/framework/Core/lib/Horde/Core/Ui/Pager.php b/framework/Core/lib/Horde/Core/Ui/Pager.php index 7dab22f6e..b5e03c0d8 100644 --- a/framework/Core/lib/Horde/Core/Ui/Pager.php +++ b/framework/Core/lib/Horde/Core/Ui/Pager.php @@ -29,6 +29,11 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget ), $config); parent::__construct($name, $vars, $config); + + // @todo Make sure 'url' argument is a Horde_Url object. + if (!($this->_config['url'] instanceof Horde_Url)) { + $this->_config['url'] = new Horde_Url($this->_config['url']); + } } /** @@ -65,14 +70,13 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget if ($current_page > 0) { // Create the '<< Prev' link if we are not on the first page. - $link = Horde_Util::addParameter($url, $this->_name, $current_page - 1); - $link = $this->_addPreserved($link); - $link = $this->_link($link); - if (isset($this->_config['previousHTML'])) { - $html .= Horde::link($link, '', 'prev') . $this->_config['previousHTML'] . ''; - } else { - $html .= Horde::link($link, '', 'prev') . htmlspecialchars(_("'; - } + $link = $this->_link($this->_addPreserved($url->copy()->add($this->_name, $current_page - 1))); + + $prev_text = isset($this->_config['previousHTML']) + ? $this->_config['previousHTML'] + : htmlspecialchars(_("'; } // Figure out the top & bottom display limits. @@ -84,10 +88,8 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget } // Create bottom '[x-y]' link if necessary. - $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $bottom - 1)); - $link = $this->_link($link); - if ($bottom > 0) { + $link = $this->_link($this->_addPreserved($url->copy()->add($this->_name, $bottom - 1))); $html .= ' ' . Horde::link($link, '', 'prevRange') . '[' . ($bottom == 1 ? $bottom : '1-' . $bottom) . ']'; } @@ -96,16 +98,14 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget if ($i == $current_page) { $html .= ' (' . ($i + 1) . ')'; } elseif ($i >= 0 && $i <= $pages) { - $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $i)); - $link = $this->_link($link); + $link = $this->_link($this->_addPreserved($url->copy()->add($this->_name, $i))); $html .= ' ' . Horde::link($link) . ($i + 1) . ''; } } // Create top '[x-y]' link if necessary. if ($top < $pages) { - $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $top + 1)); - $link = $this->_link($link); + $link = $this->_link($this->_addPreserved($url->copy()->add($this->_name, $top + 1))); $html .= ' ' . Horde::link($link, '', 'nextRange') . '[' . ($top + 2 == $pages + 1 ? $pages + 1 : ($top + 2) . '-' . ($pages + 1)) . ']'; @@ -113,13 +113,13 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget // Create the 'Next>>' link if we are not on the last page. if ($current_page < $pages) { - $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $current_page + 1)); - $link = $this->_link($link); - if (isset($this->_config['nextHTML'])) { - $html .= Horde::link($link, '', 'next') . $this->_config['nextHTML'] . ''; - } else { - $html .= ' ' . Horde::link($link, '', 'next') . htmlspecialchars(_("Next>")) . ''; - } + $link = $this->_link($this->_addPreserved($url->copy()->add($this->_name, $current_page + 1))); + + $next_text = isset($this->_config['nextHTML']) + ? $this->_config['nextHTML'] + : htmlspecialchars(_("Next>")); + + $html .= Horde::link($link, '', 'next') . $next_text . ''; } return $html . '';