2011年3月25日 星期五

Values of window begins, window ends, previous window begins, next window begins‏

$windowBegins = floor(($currentPage - 1) / $this->_windowSize) * $this->_windowSize + 1;
 #e.g. #1: [1][2][3][4][5][6] #2: [7][8]

$windowEnds = (floor(($currentPage - 1) / $this->_windowSize) == floor(($totalPage - 1) / $this->_windowSize)) ? $totalPage: $this->_windowBegins + ($this->_windowSize - 1);

$previousWindowBegins = ($currentPage > $this->_windowSize) ? $currentPage - $this->_windowSize : 0;    #0為不顯示上一個或下一個window
       
 #e.g. totalPage = 13, windowSize = 10,
 if(($currentPage + $this->_windowSize) <= $totalPage){
            #curent = 1~3
            $nextWindowBegins = $currentPage + $this->_windowSize;
 }else if((floor(($currentPage - 1) / $this->_windowSize)) == (floor(($totalPage - 1) / $this->_windowSize))){
            #current > 10
            $nextWindowBegins = 0;
  }else if(($currentPage + $this->windowSize) > $this->totalPage){
            #current = 4~10
            $nextWindowBegins = $this->_windowBegins+ $this->_windowSize;
  }

沒有留言:

張貼留言