亚洲综合原千岁中文字幕_国产精品99久久久久久久vr_无码人妻aⅴ一区二区三区浪潮_成人h动漫精品一区二区三

主頁 > 知識(shí)庫 > php 重寫分頁器 CLinkPager的實(shí)例

php 重寫分頁器 CLinkPager的實(shí)例

熱門標(biāo)簽:商丘外呼系統(tǒng)好處 百度地圖標(biāo)注類型是酒店 隨州銷售電銷機(jī)器人公司 400電話申請(qǐng)辦理 外呼系統(tǒng)人工客服 周口網(wǎng)絡(luò)回?fù)芡夂粝到y(tǒng) 全國(guó)各省地圖標(biāo)注點(diǎn) 福建高頻外呼防封系統(tǒng)哪家好 網(wǎng)絡(luò)電話400申請(qǐng)

php 重寫分頁器 CLinkPager的實(shí)例

1、自定義的分頁器類放在哪里?

有兩個(gè)位置可以放,

第一種是放在 protected/extensions 中,在使用是import進(jìn)來,或在config文件中import進(jìn)來;

第二種是放在 protected/components 中,作為組件存在,不需要import

2、用派生方式是最好的

class MyPager extends CLinkPager 

入口函數(shù)是:public function run() ,當(dāng)顯示分頁器時(shí)run()被調(diào)用,里面的輸出就會(huì)顯示在相應(yīng)位置;

其他的完全自定義,如果你不知道上一頁、下一頁、首頁、尾頁、總頁數(shù)、當(dāng)前頁碼等信息,可以參考CLinkPager的源碼,yii/frameworks/web/widgets/pagers/CLinkPager.php

?php

class MyPager extends CLinkPager
{
  const CSS_FIRST_PAGE='first';
  const CSS_LAST_PAGE='last';
  const CSS_PREVIOUS_PAGE='previous';
  const CSS_NEXT_PAGE='next';
  const CSS_INTERNAL_PAGE='page';
  const CSS_HIDDEN_PAGE='hidden';
  const CSS_SELECTED_PAGE='selected';

  /**
   * @var string the CSS class for the first page button. Defaults to 'first'.
   * @since 1.1.11
   */
  public $firstPageCssClass=self::CSS_FIRST_PAGE;
  /**
   * @var string the CSS class for the last page button. Defaults to 'last'.
   * @since 1.1.11
   */
  public $lastPageCssClass=self::CSS_LAST_PAGE;
  /**
   * @var string the CSS class for the previous page button. Defaults to 'previous'.
   * @since 1.1.11
   */
  public $previousPageCssClass=self::CSS_PREVIOUS_PAGE;
  /**
   * @var string the CSS class for the next page button. Defaults to 'next'.
   * @since 1.1.11
   */
  public $nextPageCssClass=self::CSS_NEXT_PAGE;
  /**
   * @var string the CSS class for the internal page buttons. Defaults to 'page'.
   * @since 1.1.11
   */
  public $internalPageCssClass=self::CSS_INTERNAL_PAGE;
  /**
   * @var string the CSS class for the hidden page buttons. Defaults to 'hidden'.
   * @since 1.1.11
   */
  public $hiddenPageCssClass=self::CSS_HIDDEN_PAGE;
  /**
   * @var string the CSS class for the selected page buttons. Defaults to 'selected'.
   * @since 1.1.11
   */
  public $selectedPageCssClass=self::CSS_SELECTED_PAGE;
  /**
   * @var integer maximum number of page buttons that can be displayed. Defaults to 10.
   */
  public $maxButtonCount=10;
  /**
   * @var string the text label for the next page button. Defaults to 'Next >'.
   */
  public $nextPageLabel;
  /**
   * @var string the text label for the previous page button. Defaults to ' Previous'.
   */
  public $prevPageLabel;
  /**
   * @var string the text label for the first page button. Defaults to ' First'.
   */
  public $firstPageLabel;
  /**
   * @var string the text label for the last page button. Defaults to 'Last >>'.
   */
  public $lastPageLabel;
  /**
   * @var string the text shown before page buttons. Defaults to 'Go to page: '.
   */
  public $header;
  /**
   * @var string the text shown after page buttons.
   */
  public $footer='';
  /**
   * @var mixed the CSS file used for the widget. Defaults to null, meaning
   * using the default CSS file included together with the widget.
   * If false, no CSS file will be used. Otherwise, the specified CSS file
   * will be included when using this widget.
   */
  public $cssFile;
  /**
   * @var array HTML attributes for the pager container tag.
   */
  public $htmlOptions=array();

  /**
   * Initializes the pager by setting some default property values.
   */
  public function init()
  {
    if($this->nextPageLabel===null)
      $this->nextPageLabel=Yii::t('yii','Next >');
    if($this->prevPageLabel===null)
      $this->prevPageLabel=Yii::t('yii',' Previous');
    //if($this->firstPageLabel===null)
    // $this->firstPageLabel=Yii::t('yii',' First');
    //if($this->lastPageLabel===null)
    // $this->lastPageLabel=Yii::t('yii','Last >>');
    if($this->header===null)
      $this->header=Yii::t('yii','Go to page: ');

    if(!isset($this->htmlOptions['id']))
      $this->htmlOptions['id']=$this->getId();
    if(!isset($this->htmlOptions['class']))
      $this->htmlOptions['class']='yiiPager';
  }

  /**
   * Executes the widget.
   * This overrides the parent implementation by displaying the generated page buttons.
   */
  public function run()
  {
    $this->registerClientScript();
    $buttons=$this->createPageButtons();
    if(empty($buttons))
      return;
    echo $this->header;
//   echo CHtml::tag('ul',$this->htmlOptions,implode("\n",$buttons));
    echo implode("\n",$buttons);
    echo $this->footer;
  }

  /**
   * Creates the page buttons.
   * @return array a list of page buttons (in HTML code).
   */
  protected function createPageButtons()
  {
    if(($pageCount=$this->getPageCount())=1)
      return array();

    list($beginPage,$endPage,$ellipsis)=$this->getPageRange();

    $currentPage=$this->getCurrentPage(false); // currentPage is calculated in getPageRange()
    $buttons=array();

    // first page
    //$buttons[]=$this->createPageButton($this->firstPageLabel,0,$this->firstPageCssClass,$currentPage=0,false);

    // prev page
    if(($page=$currentPage-1)0)
      $page=0;
    if($currentPage == 0){
      $buttons[] = "span style='background:#a3a3a3'>上一頁/span>";
    }else{
      $buttons[]=$this->createPageButton($this->prevPageLabel,$page,$this->previousPageCssClass,$currentPage=0,false);
    }
    // internal pages start
    // first
    $buttons[]=$this->createPageButton(1,0,$this->internalPageCssClass,false,$i==$currentPage);
    //middle
    if($ellipsis == 'both'){
      $buttons[] = "span style='background:#a3a3a3'>.../span>";
    }
    for($i=$beginPage;$i=$endPage;++$i){
      if($ellipsis == 'left'  $i == $beginPage){
        $buttons[] = "span style='background:#a3a3a3'>.../span>";
      }
      $buttons[]=$this->createPageButton($i+1,$i,$this->internalPageCssClass,false,$i==$currentPage);
      if($ellipsis == 'right'  $i == $endPage){
        $buttons[] = "span style='background:#a3a3a3'>.../span>";
      }
    }  
    if($ellipsis == 'both'){
      $buttons[] = "span style='background:#a3a3a3'>.../span>";
    }
    // last
    $buttons[]=$this->createPageButton($pageCount,$pageCount - 1,$this->internalPageCssClass,false,$i==$currentPage);
    // internal pages end
    // next page
    if(($page=$currentPage+1)>=$pageCount-1)
      $page=$pageCount-1;
    if($currentPage == ($pageCount-1)){
      $buttons[] = "span style='background:#a3a3a3'>下一頁>/span>";
    }else{
      $buttons[]=$this->createPageButton($this->nextPageLabel,$page,$this->nextPageCssClass,$currentPage>=$pageCount-1,false);
    }
    // last page
    //$buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1,$this->lastPageCssClass,$currentPage>=$pageCount-1,false);

    return $buttons;
  }

  /**
   * Creates a page button.
   * You may override this method to customize the page buttons.
   * @param string $label the text label for the button
   * @param integer $page the page number
   * @param string $class the CSS class for the page button.
   * @param boolean $hidden whether this page button is visible
   * @param boolean $selected whether this page button is selected
   * @return string the generated button
   */
  protected function createPageButton($label,$page,$class,$hidden,$selected)
  {
    if($hidden || $selected)
      $class.=' '.($hidden ? $this->hiddenPageCssClass : $this->selectedPageCssClass);
    if ($selected) {
      $result = "span>" . ++$page . "/span>";
    } else {
      $result = CHtml::link($label,$this->createPageUrl($page));
    }
    return $result;
  }

  /**
   * @return array the begin and end pages that need to be displayed.
   */
  protected function getPageRange()
  {
    $currentPage=$this->getCurrentPage();
    $pageCount=$this->getPageCount();
    /*$beginPage=max(0, $currentPage-(int)($this->maxButtonCount/2));
    if(($endPage=$beginPage+$this->maxButtonCount-1)>=$pageCount)
    {
      $endPage=$pageCount-1;
      $beginPage=max(0,$endPage-$this->maxButtonCount+1);
    }*/
    if($pageCount > $this->maxButtonCount){
      if($currentPage > 4  $currentPage  ($pageCount - 4)){
        // print_r('a');
        $beginPage = $currentPage - 2;
        $endPage = $currentPage + 2;
        $ellipsis = 'both';
      }else{
        $beginPage=max(1, $currentPage-(int)($this->maxButtonCount/2));
        if($beginPage == 1){
          $ellipsis = 'right';
        }else{
          $ellipsis = 'left';
        }
        if(($endPage=$beginPage+$this->maxButtonCount-1)>=$pageCount)
        {
          // print_r('b');
          $endPage=$pageCount-2;
          $beginPage=max(1,$endPage-$this->maxButtonCount+1);
        }elseif(($endPage=$beginPage+$this->maxButtonCount-1)>=$pageCount-2){
          // print_r('c');
          $endPage=$pageCount-2;
        }

      }
    }else{
      $beginPage=max(1, $currentPage-(int)($this->maxButtonCount/2));
      if(($endPage=$beginPage+$this->maxButtonCount-1)>=$pageCount)
      {
        $endPage=$pageCount-2;
        $beginPage=max(1,$endPage-$this->maxButtonCount+1);
      }
    }

    return array($beginPage,$endPage, $ellipsis);
  }

  /**
   * Registers the needed client scripts (mainly CSS file).
   */
  public function registerClientScript()
  {
    if($this->cssFile!==false)
      self::registerCssFile($this->cssFile);
  }

  /**
   * Registers the needed CSS file.
   * @param string $url the CSS URL. If null, a default CSS URL will be used.
   */
  public static function registerCssFile($url=null)
  {
    if($url===null)
      $url=CHtml::asset(Yii::getPathOfAlias('system.web.widgets.pagers.pager').'.css');
    Yii::app()->getClientScript()->registerCssFile($url);
  }
}

3、調(diào)用方式

在View里的相應(yīng)widget,定義pager的class為自定義的分頁器類名即可,參考:

$this->widget('zii.widgets.CListView', array(
  'dataProvider'=>$dataProvider,
  'itemView'=>'_view_t',
  'pager'=>array(
  'class'=>'MyPager',
 )
));

如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

您可能感興趣的文章:
  • thinkPHP實(shí)現(xiàn)的驗(yàn)證碼登錄功能示例
  • thinkPHP實(shí)現(xiàn)上傳圖片及生成縮略圖功能示例
  • php+ajax+h5實(shí)現(xiàn)圖片上傳功能
  • PHP實(shí)現(xiàn)找出數(shù)組中出現(xiàn)次數(shù)超過數(shù)組長(zhǎng)度一半的數(shù)字算法示例
  • 史上最全的PHP正則表達(dá)式(手機(jī)號(hào)需要加上177-***)
  • PHP用函數(shù)嵌入網(wǎng)站訪問量計(jì)數(shù)器
  • PHP實(shí)現(xiàn)網(wǎng)站訪問量計(jì)數(shù)器
  • 利用php獲得flv視頻長(zhǎng)度的實(shí)例代碼

標(biāo)簽:南寧 佛山 迪慶 六安 樂山 十堰 定西 海南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《php 重寫分頁器 CLinkPager的實(shí)例》,本文關(guān)鍵詞  php,重寫,分頁,器,CLinkPager,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《php 重寫分頁器 CLinkPager的實(shí)例》相關(guān)的同類信息!
  • 本頁收集關(guān)于php 重寫分頁器 CLinkPager的實(shí)例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    国产成人精品一区二区视频| 国产伦精品一区三区视频| 欧美一区二区三区性| a级毛片免费全部播放| 国产亚洲精品aaa大片| 国产精品1024永久免费视频| 精品视频一区二区三区| 久久99爰这里有精品国产| 999久久久免费精品国产牛牛| 91麻豆爱豆果冻天美星空| 国产成人精品综合| 可以免费看污视频的网站| 高清一级片| 久久久久久久网| 久久精品欧美一区二区| 九九免费精品视频| 国产一区二区精品| 日韩综合| 亚洲 国产精品 日韩| 国产精品免费精品自在线观看| 国产精品自拍亚洲| 日日夜夜婷婷| 青青青草影院| 999久久66久6只有精品| 国产91素人搭讪系列天堂| 亚洲精品影院一区二区| 九九九国产| 国产成人精品综合| 好男人天堂网 久久精品国产这里是免费 国产精品成人一区二区 男人天堂网2021 男人的天堂在线观看 丁香六月综合激情 | 天天色成人| 欧美夜夜骑 青草视频在线观看完整版 久久精品99无色码中文字幕 欧美日韩一区二区在线观看视频 欧美中文字幕在线视频 www.99精品 香蕉视频久久 | 成人高清视频免费观看| 日本特黄一级| 成人免费观看的视频黄页| 久久精品道一区二区三区| 天天色成人| a级精品九九九大片免费看| 国产极品精频在线观看| 一级毛片看真人在线视频| 免费国产一级特黄aa大片在线| 日韩免费在线视频| 99久久精品国产国产毛片| 深夜做爰性大片中文| 欧美夜夜骑 青草视频在线观看完整版 久久精品99无色码中文字幕 欧美日韩一区二区在线观看视频 欧美中文字幕在线视频 www.99精品 香蕉视频久久 | 日本伦理黄色大片在线观看网站| 国产不卡高清| 久久精品道一区二区三区| 成人高清视频免费观看| 久久精品道一区二区三区| 91麻豆精品国产综合久久久| 日本免费看视频| 欧美18性精品| 精品国产一区二区三区免费 | 99热视热频这里只有精品| 国产视频一区二区在线播放| 香蕉视频久久| 国产欧美精品午夜在线播放| 精品国产香蕉在线播出| 国产高清在线精品一区二区| 亚洲 国产精品 日韩| 亚洲第一页色| 日韩免费在线视频| 日韩中文字幕一区二区不卡| 亚洲不卡一区二区三区在线| a级精品九九九大片免费看| 国产精品12| 精品国产亚洲人成在线| 欧美激情影院| 国产成人啪精品视频免费软件| 国产欧美精品午夜在线播放| 韩国毛片基地| 精品国产香蕉在线播出| 国产成人精品一区二区视频| 99热视热频这里只有精品| 日韩专区一区| 亚洲 国产精品 日韩| 成人在免费观看视频国产| 成人影视在线播放| 成人免费观看视频| 国产精品12| 成人在免费观看视频国产| 久久国产一区二区| 韩国毛片基地| 日本免费看视频| 黄色免费三级| 国产亚洲精品aaa大片| 精品在线观看一区| 高清一级片| 国产福利免费观看| 可以在线看黄的网站| 国产成人精品综合在线| 亚洲www美色| 日韩中文字幕一区二区不卡| 可以免费看污视频的网站| 天天做人人爱夜夜爽2020毛片| 国产麻豆精品hdvideoss| 国产视频在线免费观看| 国产一级生活片| 国产91精品露脸国语对白| 免费国产在线观看不卡| 欧美1区| 国产不卡在线观看| 成人免费观看视频| 免费国产在线观看不卡| 欧美a级片免费看| 日韩在线观看免费完整版视频| 国产一区二区精品| 一级女性全黄生活片免费| 色综合久久天天综合绕观看| 欧美激情伊人| 欧美大片a一级毛片视频| 亚洲 国产精品 日韩| 好男人天堂网 久久精品国产这里是免费 国产精品成人一区二区 男人天堂网2021 男人的天堂在线观看 丁香六月综合激情 | 国产一区免费在线观看| 欧美18性精品| 色综合久久天天综合| 黄色福利片| 99热视热频这里只有精品| 天天做人人爱夜夜爽2020毛片| 欧美大片a一级毛片视频| 久久精品欧美一区二区| 国产国产人免费视频成69堂| 欧美夜夜骑 青草视频在线观看完整版 久久精品99无色码中文字幕 欧美日韩一区二区在线观看视频 欧美中文字幕在线视频 www.99精品 香蕉视频久久 | 精品国产一区二区三区久久久狼| 精品久久久久久免费影院| 色综合久久天天综合| 99色播| 青青久久国产成人免费网站| 国产美女在线观看| 高清一级片| 日韩在线观看免费完整版视频| 国产伦精品一区三区视频| 亚洲 欧美 成人日韩| 日韩免费在线视频| 精品视频免费观看| 国产高清在线精品一区二区| 亚欧成人乱码一区二区| 午夜在线亚洲男人午在线| 日本在线不卡视频| 亚洲 国产精品 日韩| 国产一区二区精品久久| 香蕉视频一级| 一级毛片视频免费| 成人免费福利片在线观看| 国产精品免费精品自在线观看| 中文字幕97| 99久久精品费精品国产一区二区| 日本免费看视频| 欧美另类videosbestsex| 精品国产一区二区三区免费 | 成人免费观看的视频黄页| 99久久精品国产国产毛片| 美女免费精品高清毛片在线视| 亚洲精品影院一区二区| 国产亚洲免费观看| 国产一区免费在线观看| 成人a大片在线观看| 欧美激情一区二区三区视频高清| 欧美电影免费看大全| 国产网站免费观看| 欧美一区二区三区性| 国产麻豆精品视频| 亚洲 国产精品 日韩| 久久精品免视看国产明星 | 欧美国产日韩在线| a级精品九九九大片免费看| 国产麻豆精品视频| 亚欧成人乱码一区二区| 日本特黄特黄aaaaa大片| 国产视频一区二区三区四区| 99色播| 亚洲精品影院| 欧美日本免费| 香蕉视频久久| 韩国三级视频网站| 亚洲第一视频在线播放| 亚洲不卡一区二区三区在线| 九九精品影院| 99色视频在线| 青青久久国产成人免费网站| 成人影院一区二区三区| 日韩中文字幕在线观看视频| 九九久久99| 午夜欧美成人香蕉剧场| 欧美电影免费看大全| 精品在线观看一区| 国产91素人搭讪系列天堂| 中文字幕一区二区三区 精品| 色综合久久久久综合体桃花网| 99色视频在线| 久草免费在线色站| 国产一区精品| 亚洲精品中文一区不卡| 国产91精品露脸国语对白| 亚洲第一页色| 99热视热频这里只有精品| 九九精品影院| 国产亚洲精品aaa大片| 国产视频一区二区在线播放| 青青青草影院|