Exemplo n.º 1
0
 public function testWhitelist()
 {
     $this->assertEqual(UrlComponent::whitelist(array()), '/myapp/mycontroller/myaction');
     $this->assertEqual(UrlComponent::whitelist(array('p1')), '/myapp/mycontroller/myaction/p1/1');
     $this->assertEqual(UrlComponent::whitelist(array('p1', 'p2')), '/myapp/mycontroller/myaction/p1/1/p2/2');
     $this->assertEqual(UrlComponent::whitelist(array('p1', 'p2', 'p3')), '/myapp/mycontroller/myaction/p1/1/p2/2/p3/3');
 }
Exemplo n.º 2
0
 static function orderBy($field, $label)
 {
     $Dispatcher = Dispatcher::getInstance();
     $params = $Dispatcher->getParams();
     $orderby = $field;
     $dir = 'asc';
     $reverse = 'desc';
     $class = '';
     $filter = Config::get('pagination.filter');
     $path = UrlComponent::whitelist(array_remove($filter, array('orderby', 'dir')));
     if (isset($params['orderby']) && $params['orderby'] == $field) {
         $orderby = $params['orderby'];
         if (isset($params['dir']) && $params['dir'] == 'asc') {
             $class = 'class="order-asc"';
             $reverse = 'desc';
         } else {
             $class = 'class="order-desc"';
             $reverse = 'asc';
         }
     }
     return '<a href="' . $path . '/orderby/' . $orderby . '/dir/' . $reverse . '" ' . $class . '>' . $label . '</a>';
 }
Exemplo n.º 3
0
<? if (isset($Pager)) : ?>
<? if ($Pager->haveToPaginate()): 
   $range   = $Pager->getRange('Sliding', array('chunk' => Config::get('pagination.chunk')));
   $pages   = $range->rangeAroundPage();
   
   $filter  = Config::get('pagination.filter');
   $path    = UrlComponent::whitelist(array_remove($filter, 'page'));
?>
<ul class="pagination">
<? if ($Pager->getPage() > 1) : ?>
    <li class="previous"><a href="<?php 
echo $path;
?>
/page/<?php 
echo $Pager->getPreviousPage();
?>
">&laquo; Précédente</a></li>
<? else: ?>
    <li class="previous-off">&laquo; Précédente</li>
<? endif ?>
<? if (isset($pages[0]) && $pages[0] > 1) : ?>
   <li><a href="<?php 
echo $path;
?>
/page/1">1</a></li>
<? endif ?>
<? if (isset($pages[0]) && $pages[0] > 2) : ?>
	<li class="more">...</li>
<? endif ?>
<? foreach($pages as $page): ?>
<? if ($page == $Pager->getPage()): ?>