<?php
global $urlTo;
$urlTo = $this->getHelper("UrlTo");

function getURL($filters, $page) {
  global $urlTo;

  // retorna o front e o objeto request
  $frontController = Zend_Controller_Front::getInstance();
  $request = $frontController->getRequest();

  // monta o começo da url
  $url =  "".$request->getControllerName() . "/" . $request->getActionName() . "/";

  // altera o registro de pagina
  $filters['p'] = $page;

  // finaliza a url
  $url .= "?" . http_build_query($filters);

  return $urlTo->urlTo($url);
}
?>

<?php if($this->pageCount){ ?>


<div class="row">
                            <div class="col-sm-12 text-center">
                                <ul class="pagination">
                                    
                                    <?php if(isset($this->previous)): ?>
                                      <li class="clear prev "><a href="<?=getURL($this->filters, $this->previous);?>">Anterior</a></li>
    
                                    <?php endif; ?>
                                    
                                    <?php
                                    foreach($this->pagesInRange as $page)
                                    {
                                      echo '<li'. (($page == $this->filters['p'])? ' class="active"': '') .'><a href="'. (getURL($this->filters, $page, $this->view)) .'">'. $page .'</a></li>';
                                    }
                                    ?>
                                    <?php if(isset($this->next)): ?>
                                    <li class="clear next"><a href="<?=getURL($this->filters, $this->next);?>">Próxima</a></li>
                                    <?php endif; ?>
                                    
                                </ul>
                            </div>
                        </div>
<?php } ?>

