Skip to content

Commit

Permalink
first Page and last Page
Browse files Browse the repository at this point in the history
  • Loading branch information
javiacei committed Sep 21, 2011
1 parent ef4ef49 commit b7d8bce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
20 changes: 15 additions & 5 deletions Paginator/Paginator.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */

namespace Ideup\SimplePaginatorBundle\Paginator;

use Symfony\Component\HttpFoundation\Request as Request;
use Doctrine\ORM\Query as Query;
use DoctrineExtensions\Paginate\Paginate;

use
Symfony\Component\HttpFoundation\Request,
Doctrine\ORM\Query as Query,
DoctrineExtensions\Paginate\Paginate
;

/**
* IdeupSimplePaginatorBundle
*
* Class that defines the Dependency Injection Extension to expose the bundle's semantic configuration
* @package IdeupSimplePaginatorBundle
* @subpackage Paginator
* @author Francisco Javier Aceituno <javier.aceituno@ideup.com>
* @author Moises Maciá <moises.macia@ideup.com>
*/
class Paginator
{
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul {% if container_class %} class="{{ container_class }} {% endif %}">
<ul class="{{ container_class }}">
{% if currentPage > 1 %}
<li><a class="{{ previousEnabledClass }}" href="{{ path(route, {'page': previousPage, 'paginatorId': id}) }}">{{ previosPageText }}</a></li>
{% else %}
Expand All @@ -14,7 +14,7 @@
{% endfor %}

{% if currentPage < lastPage %}
<li class="{{ nextEnabledClass }}"><a href="{{ path(route, {'page': paginator.nextPage(id), 'paginatorId': id}) }}">{{ nextPageText }}</a></li>
<li class="{{ nextEnabledClass }}"><a href="{{ path(route, {'page': nextPage, 'paginatorId': id}) }}">{{ nextPageText }}</a></li>
{% else %}
<li class="{{ nextDisabledClass }}">{{ nextPageText }}</li>
{% endif %}
Expand Down
13 changes: 10 additions & 3 deletions Templating/Helper/PaginatorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,29 @@ public function render($route, $id = null, $options = array(), $view = null)
$view = (!is_null($view)) ? $view : 'IdeupSimplePaginatorBundle:Paginator:simple-paginator-list-view.html.twig';

$defaultOptions = array(
'container_class' => '',
'container_class' => 'simple_paginator',
'paginator' => $this->paginator,
'id' => $id,
'route' => $route,

'previousPage' => $this->paginator->getPreviousPage($id),
'previosPageText' => 'previous',
'previousEnabledClass' => 'left',
'previousDisabledClass' => 'left_disabled',

'minPage' => $this->paginator->getMinPageInRange($id),
'maxPage' => $this->paginator->getMaxPageInRange($id),

'currentPage' => $this->paginator->getCurrentPage($id),
'currentClass' => 'current',

'firstPage' => $this->paginator->getFirstPage(),
'lastPage' => $this->paginator->getLastPage($id),

'nextPage' => $this->paginator->getNextPage($id),
'nextPageText' => 'next',
'nextEnabledClass' => 'right',
'nextDisabledClass' => 'right_disabled',
'nextPageText' => 'next'
'nextDisabledClass' => 'right_disabled'
);

$options = \array_merge($defaultOptions, $options);
Expand Down

0 comments on commit b7d8bce

Please sign in to comment.