Skip to content
This repository has been archived by the owner on Jan 13, 2019. It is now read-only.

Coding Style And Tweaks #1

Merged
merged 3 commits into from
Dec 16, 2013
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor
composer.phar
composer.lock
.DS_Store
.DS_Store
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ language: php
php:
- 5.3
- 5.4
- 5.5

before_script:
- curl -s http://getcomposer.org/installer | php
- php composer.phar install --dev
- composer self-update
- composer install --prefer-source --no-interaction --dev

script: phpunit
script:
- phpunit
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ This package sits on top of Laravel 4's Pagination, so use it the same way. [Lar
* `prev_link_text`: Set the previous link text. Default: `← Previous`.
* `next_link_text`: Set the next link text. Default: `Next →`.

To change the pagination view, edit `app/config/view.php` and change the `pagination` value. Want to create your own? Model it after [one of the views](src/views).
To change the pagination view, edit `app/config/view.php` and change the `pagination` value. Want to create your own? Model it after [one of the views](src/views).
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
}
},
"minimum-stability": "dev"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion provides.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"providers": [
"Kmd\Pagination\PaginationServiceProvider"
]
}
}
225 changes: 103 additions & 122 deletions src/Kmd/Pagination/BootstrapPresenter.php
Original file line number Diff line number Diff line change
@@ -1,130 +1,111 @@
<?php namespace Kmd\Pagination;

class BootstrapPresenter extends \Illuminate\Pagination\BootstrapPresenter {
class BootstrapPresenter extends \Illuminate\Pagination\BootstrapPresenter
{
/**
* Render the Bootstrap pagination contents.
*
* @return string
*/
public function render()
{
// The hard-coded thirteen represents the minimum number of pages we need to
// be able to create a sliding page window. If we have less than that, we
// will just render a simple range of page links insteadof the sliding.
if ($this->lastPage < 13) {
$content = $this->getPageRange(1, $this->lastPage);
} else {
$content = $this->getPageSlider();
}

/**
* Render the Bootstrap pagination contents.
*
* @return string
*/
public function render()
{
// The hard-coded thirteen represents the minimum number of pages we need to
// be able to create a sliding page window. If we have less than that, we
// will just render a simple range of page links insteadof the sliding.
if ($this->lastPage < 13)
{
$content = $this->getPageRange(1, $this->lastPage);
}
else
{
$content = $this->getPageSlider();
}
if (\Config::get('pagination::show_first_last') === true) {
return $this->getFirst().$this->getPrevious().$content.$this->getNext().$this->getLast();
}

if (\Config::get('pagination::show_first_last') === true)
return $this->getFirst().$this->getPrevious().$content.$this->getNext().$this->getLast();
return $this->getPrevious().$content.$this->getNext();
}

return $this->getPrevious().$content.$this->getNext();
}

/**
* Get the previous page pagination element.
*
* @param string $text
* @return string
*/
public function getPrevious($text = null)
{
$text = \Config::get('pagination::slider.prev_link_text', $text);
$class = \Config::get('pagination::align_simple') ? 'previous' : '';
// If the current page is less than or equal to one, it means we can't go any
// further back in the pages, so we will render a disabled previous button
// when that is the case. Otherwise, we will give it an active "status".
if ($this->currentPage <= 1)
{
$class = ltrim($class . ' ') . 'disabled';
return '<li class="'.$class.'"><span>'.$text.'</span></li>';
}
else
{
$url = $this->paginator->getUrl($this->currentPage - 1);
/**
* Get the previous page pagination element.
*
* @param string $text
* @return string
*/
public function getPrevious($text = null)
{
$text = \Config::get('pagination::slider.prev_link_text', $text);
$class = \Config::get('pagination::align_simple') ? 'previous' : '';
// If the current page is less than or equal to one, it means we can't go any
// further back in the pages, so we will render a disabled previous button
// when that is the case. Otherwise, we will give it an active "status".
if ($this->currentPage <= 1) {
$class = ltrim($class . ' ') . 'disabled';
return '<li class="'.$class.'"><span>'.$text.'</span></li>';
} else {
$url = $this->paginator->getUrl($this->currentPage - 1);
return '<li class="'.$class.'"><a href="'.$url.'">'.$text.'</a></li>';
}
}

return '<li class="'.$class.'"><a href="'.$url.'">'.$text.'</a></li>';
}
}
/**
* Get the next page pagination element.
*
* @param string $text
* @return string
*/
public function getNext($text = null)
{
$text = \Config::get('pagination::slider.next_link_text', $text);
$class = \Config::get('pagination::align_simple') ? 'previous' : '';
// If the current page is greater than or equal to the last page, it means we
// can't go any further into the pages, as we're already on this last page
// that is available, so we will make it the "next" link style disabled.
if ($this->currentPage >= $this->lastPage) {
$class = ltrim($class . ' ') . 'disabled';
return '<li class="'.$class.'"><span>'.$text.'</span></li>';
} else {
$url = $this->paginator->getUrl($this->currentPage + 1);
return '<li class="'.$class.'"><a href="'.$url.'">'.$text.'</a></li>';
}
}

/**
* Get the next page pagination element.
*
* @param string $text
* @return string
*/
public function getNext($text = null)
{
$text = \Config::get('pagination::slider.next_link_text', $text);
$class = \Config::get('pagination::align_simple') ? 'previous' : '';
// If the current page is greater than or equal to the last page, it means we
// can't go any further into the pages, as we're already on this last page
// that is available, so we will make it the "next" link style disabled.
if ($this->currentPage >= $this->lastPage)
{
$class = ltrim($class . ' ') . 'disabled';
return '<li class="'.$class.'"><span>'.$text.'</span></li>';
}
else
{
$url = $this->paginator->getUrl($this->currentPage + 1);
/**
* Get the first page pagination element.
*
* @param string $text
* @return string
*/
public function getFirst($text = null)
{
$text = \Config::get('pagination::slider.first_link_text', $text);
// If the current page is less than or equal to one, it means we can't go any
// further back in the pages, so we will render a disabled previous button
// when that is the case. Otherwise, we will give it an active "status".
if ($this->currentPage <= 1) {
return '<li class="disabled"><span>'.$text.'</span></li>';
} else {
$url = $this->paginator->getUrl(1);
return '<li><a href="'.$url.'">'.$text.'</a></li>';
}
}

return '<li class="'.$class.'"><a href="'.$url.'">'.$text.'</a></li>';
}
}

/**
* Get the first page pagination element.
*
* @param string $text
* @return string
*/
public function getFirst($text = null)
{
$text = \Config::get('pagination::slider.first_link_text', $text);
// If the current page is less than or equal to one, it means we can't go any
// further back in the pages, so we will render a disabled previous button
// when that is the case. Otherwise, we will give it an active "status".
if ($this->currentPage <= 1)
{
return '<li class="disabled"><span>'.$text.'</span></li>';
}
else
{
$url = $this->paginator->getUrl(1);

return '<li><a href="'.$url.'">'.$text.'</a></li>';
}
}

/**
* Get the last page pagination element.
*
* @param string $text
* @return string
*/
public function getLast($text = null)
{
$text = \Config::get('pagination::slider.last_link_text', $text);
// If the current page is greater than or equal to the last page, it means we
// can't go any further into the pages, as we're already on this last page
// that is available, so we will make it the "next" link style disabled.
if ($this->currentPage >= $this->lastPage)
{
return '<li class="disabled"><span>'.$text.'</span></li>';
}
else
{
$url = $this->paginator->getUrl($this->lastPage);

return '<li><a href="'.$url.'">'.$text.'</a></li>';
}
}

}
/**
* Get the last page pagination element.
*
* @param string $text
* @return string
*/
public function getLast($text = null)
{
$text = \Config::get('pagination::slider.last_link_text', $text);
// If the current page is greater than or equal to the last page, it means we
// can't go any further into the pages, as we're already on this last page
// that is available, so we will make it the "next" link style disabled.
if ($this->currentPage >= $this->lastPage) {
return '<li class="disabled"><span>'.$text.'</span></li>';
} else {
$url = $this->paginator->getUrl($this->lastPage);
return '<li><a href="'.$url.'">'.$text.'</a></li>';
}
}
}
14 changes: 8 additions & 6 deletions src/Kmd/Pagination/PaginationFacade.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?php namespace Kmd\Pagination;

use Illuminate\Support\Facades\Facade;
class PaginationFacade extends Facade {

class PaginationFacade extends Facade
{
/**
* Get the registered name of the component.
*
* @access protected
* @return string
*/
protected static function getFacadeAccessor() { return 'pagination'; }

protected static function getFacadeAccessor()
{
return 'pagination';
}
}
Loading