Ejemplo n.º 1
0
 /**
  *  preprocess before forwarding.
  *
  *  @access public
  */
 public function preforward()
 {
     $start = $this->af->get('start');
     error_log('start:' . $start);
     if ($start === NULL) {
         $start = 0;
     }
     if ($start < 0) {
         $start = 0;
     }
     $count = 5;
     $bm = new BoardManager();
     $um = new UserManager();
     $boardlist = $bm->boardlist($this->backend);
     krsort($boardlist);
     $total = count($boardlist);
     $display_posts = array();
     for ($i = $start; $i < $start + $count && $i < $total; $i++) {
         $cur = current(array_slice($boardlist, $i, 1, true));
         array_push($display_posts, $bm->addUrl($cur));
     }
     if ($start > 0) {
         $this->af->setApp('hasprev', true);
         $this->af->setApp('prev', $start - $count);
     } else {
         $this->af->setApp('hasprev', false);
     }
     if ($start + $count < $total) {
         $this->af->setApp('hasnext', true);
         $this->af->setApp('next', $start + $count);
         $this->af->setApp('last', (ceil($total / $count) - 1) * $count);
     } else {
         $this->af->setApp('hasnext', false);
     }
     $this->af->setApp('posts', $display_posts);
     $this->af->setApp('link', '/?action_board=true');
     $this->af->setApp('count', $count);
     $this->af->setApp('current', $start);
     $this->af->setApp('pager', Ethna_Util::getDirectLinkList($total, $start, $count));
     return 'board';
 }
Ejemplo n.º 2
0
 /**
  *  ナビゲーション情報を取得する
  *
  *  @access private
  *  @param  int     $total      検索総件数
  *  @param  array   $list       検索結果
  *  @return array   ナビゲーション情報を格納した配列
  */
 function _getNavigation($total, &$list)
 {
     $nav = array();
     $nav['offset'] = $this->offset;
     $nav['from'] = $this->offset + 1;
     if ($total == 0) {
         $nav['from'] = 0;
     }
     $nav['to'] = $this->offset + count($list);
     $nav['total'] = $total;
     if ($this->offset > 0) {
         $prev_offset = $this->offset - $this->count;
         if ($prev_offset < 0) {
             $prev_offset = 0;
         }
         $nav['prev_offset'] = $prev_offset;
     }
     if ($this->offset + $this->count < $total) {
         $next_offset = $this->offset + count($list);
         $nav['next_offset'] = $next_offset;
     }
     $nav['direct_link_list'] = Ethna_Util::getDirectLinkList($total, $this->offset, $this->count);
     return $nav;
 }