コード例 #1
0
ファイル: Userpage.php プロジェクト: sdkawata/tutorial
 /**
  *  preprocess before forwarding.
  *
  *  @access public
  */
 public function preforward()
 {
     $userid = $this->af->getApp('userid');
     $um = new UserManager();
     $this->af->setApp('iconurl', $um->getIconUrl($userid));
     $bm = new BoardManager();
     $boardlist = $bm->boardlist($this->backend);
     krsort($boardlist);
     $mylist = array();
     foreach ($boardlist as $post) {
         if ($post['userid'] == $userid) {
             array_push($mylist, $bm->addUrl($post));
         }
     }
     $this->af->setApp('posts', $mylist);
 }
コード例 #2
0
ファイル: Board.php プロジェクト: sdkawata/tutorial
 /**
  *  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';
 }