| 
                         /** 
- 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,$class,$hidden,$selected) 
{ 
if($hidden || $selected) 
$class.=' '.($hidden ? $this->hiddenPageCssClass : $this->selectedPageCssClass); 
if ($selected) { 
$result = "" . ++$page . ""; 
} 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,$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、调用方式 
                        (编辑:滁州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |