Dotclear

Changeset 1909:e73d8d511f5c for inc


Ignore:
Timestamp:
09/16/13 14:50:24 (12 years ago)
Author:
Dsls
Branch:
default
Message:

New paging style 1st shot, see #1607

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/lib.pager.php

    r1670 r1909  
    1212if (!defined('DC_RC_PATH')) { return; } 
    1313 
     14class dcPager extends pager 
     15{ 
     16 
     17     protected function getLink($li_class,$href,$img_src,$img_alt,$enable_link) { 
     18          if ($enable_link) { 
     19               $formatter = '<li class="%s"><a href="%s"><img src="%s" alt="%s"/>'. 
     20                    '<span class="hidden">%s</span></a></li>'; 
     21               return sprintf ($formatter, 
     22                    $li_class,$href,$img_src,$img_alt,$img_alt); 
     23          } else { 
     24               $formatter = '<li class="%s"><img src="%s" alt="%s"/>'. 
     25                    '<span class="hidden">%s</span></li>'; 
     26               return sprintf ($formatter, 
     27                    $li_class,$img_src,$img_alt,$img_alt); 
     28          } 
     29     } 
     30 
     31     /** 
     32     * Pager Links 
     33     * 
     34     * Returns pager links 
     35     * 
     36     * @return string 
     37     */ 
     38     public function getLinks() 
     39     { 
     40          $this->setURL(); 
     41          $htmlFirst = $this->getLink( 
     42               "first", 
     43               sprintf($this->page_url,1), 
     44               "style/page/pagination_1_first.png", 
     45               __('First page'), 
     46               ($this->env > 1) 
     47          ); 
     48          $htmlPrev = $this->getLink( 
     49               "prev", 
     50               sprintf($this->page_url,$this->env-1), 
     51               "style/page/pagination_1_previous.png", 
     52               __('Previous page'), 
     53               ($this->env > 1) 
     54          ); 
     55          $htmlNext = $this->getLink( 
     56               "next", 
     57               sprintf($this->page_url,$this->env+1), 
     58               "style/page/pagination_1_next.png", 
     59               __('Next page'), 
     60               ($this->env < $this->nb_pages) 
     61          ); 
     62          $htmlLast = $this->getLink( 
     63               "last", 
     64               sprintf($this->page_url,$this->nb_pages), 
     65               "style/page/pagination_1_last.png", 
     66               __('Last page'), 
     67               ($this->env < $this->nb_pages) 
     68          ); 
     69          $htmlCurrent =  
     70               '<li class="active"><strong>'. 
     71               sprintf(__('Page %s / %s'),$this->env,$this->nb_pages). 
     72               '</strong></li>'; 
     73                
     74          $htmlDirect =  
     75               sprintf('<p>'.__('Direct access page %s'), 
     76                    form::field(array('page'),3,10)). 
     77               '<input type="submit" value="'.__('Ok').'" '. 
     78               'name="ok" /></p>'; 
     79           
     80          $res =     
     81               '<form action="'.$this->page_url.'" method="get">'. 
     82               '<div class="pagination"><ul>'. 
     83               $htmlFirst. 
     84               $htmlPrev. 
     85               $htmlCurrent. 
     86               $htmlNext. 
     87               $htmlLast. 
     88               '</ul>'. 
     89               $htmlDirect. 
     90               '</div>'. 
     91               '</form>' 
     92          ; 
     93           
     94          return $this->nb_elements > 0 ? $res : ''; 
     95     } 
     96} 
     97 
    1498class adminGenericList 
    1599{ 
     
    23107          $this->rs =& $rs; 
    24108          $this->rs_count = $rs_count; 
    25           $this->html_prev = __('&#171; prev.'); 
    26           $this->html_next = __('next &#187;'); 
    27109     } 
    28110} 
     
    38120          else 
    39121          { 
    40                $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    41                $pager->html_prev = $this->html_prev; 
    42                $pager->html_next = $this->html_next; 
    43                $pager->var_page = 'page'; 
     122               $pager = new dcPager($page,$this->rs_count,$nb_per_page,10); 
    44123               $entries = array(); 
    45124               if (isset($_REQUEST['entries'])) { 
     
    63142               } 
    64143                
    65                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     144               echo $pager->getLinks(); 
    66145                
    67146               $blocks = explode('%s',$html_block); 
     
    76155               echo $blocks[1]; 
    77156                
    78                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     157               echo $pager->getLinks(); 
    79158          } 
    80159     } 
     
    159238          { 
    160239               $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    161                $pager->html_prev = $this->html_prev; 
    162                $pager->html_next = $this->html_next; 
    163                $pager->var_page = 'page'; 
    164240                
    165241               $html_block = 
     
    175251               } 
    176252                
    177                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     253               echo $pager->getLinks(); 
    178254                
    179255               $blocks = explode('%s',$html_block); 
     
    188264               echo $blocks[1]; 
    189265                
    190                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     266               echo $pager->getLinks(); 
    191267          } 
    192268     } 
     
    254330          { 
    255331               $pager = new pager($page,$this->rs_count,$nb_per_page,10); 
    256                $pager->html_prev = $this->html_prev; 
    257                $pager->html_next = $this->html_next; 
    258                $pager->var_page = 'page'; 
    259332                
    260333               $html_block = 
     
    271344               } 
    272345                
    273                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     346               echo $pager->getLinks(); 
    274347                
    275348               $blocks = explode('%s',$html_block); 
     
    284357               echo $blocks[1]; 
    285358                
    286                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     359               echo $pager->getLinks(); 
    287360          } 
    288361     } 
     
    382455               } 
    383456                
    384                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     457               echo $pager->getLinks(); 
    385458                
    386459               $blocks = explode('%s',$html_block); 
     
    395468               echo $blocks[1]; 
    396469                
    397                echo '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; 
     470               echo $pager->getLinks(); 
    398471          } 
    399472     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map