コード例 #1
0
ファイル: Match.php プロジェクト: vincium/lot
 public function history()
 {
     // check
     $type = Util\Converter::toString('type', 'get', 'own');
     $page = Util\Converter::toInt('page', 'get', 1);
     $id = Util\Converter::toInt('id', 'get', 0);
     $url = '/match/history?';
     $title = '';
     if (!in_array($type, ['own', 'all', 'f2f'])) {
         $type = 'own';
     }
     if ($type == 'all') {
         $count = \Own\Bus\Match\Data::countFinished($this->player->getId());
         $matches = \Own\Bus\Match\Data::loadAllFinished($this->player->getId(), true, $page - 1);
         $title = '(' . Util\Lang::lower('all') . ')';
         $url .= 'type=all&';
     } else {
         if ($type == 'f2f' && $id != 0) {
             $player = \Own\Bus\Player\Data::loadById($id);
             if (!isset($player)) {
                 $type = 'own';
             } else {
                 $count = \Own\Bus\Match\Data::countFace2Face($player->getId(), $this->player->getId());
                 $matches = \Own\Bus\Match\Data::loadAllFace2Face($player->getId(), $this->player->getId(), $page - 1);
                 $title = '(' . Util\Lang::lower('faceToFace') . ')';
                 $url .= 'type=f2f&id=' . $id . '&';
             }
         }
     }
     if ($type == 'own') {
         if ($id == 0) {
             $player = $this->player;
         } else {
             $player = \Own\Bus\Player\Data::loadById($id);
             if (!isset($player)) {
                 $player = $this->player;
             }
             $title = '';
             $url .= 'id=' . $id . '&';
         }
         $count = \Own\Bus\Match\Data::countFinishedByPlayerId($player->getId(), $this->player->getId() == $player->getId());
         $matches = \Own\Bus\Match\Data::loadAllFinishedByPlayerId($player->getId(), $this->player->getId() == $player->getId(), $page - 1);
     }
     // view
     $this->setTpl();
     // filter
     $tplFilter = new Util\Template(Util\Template::SITE, ['www']);
     $tplFilter->set('current', $page);
     $tplFilter->set('count', $count);
     $tplFilter->set('type', $type);
     $tplFilter->set('title', $title);
     $tplFilter->set('url', $url . 'page=');
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['www']);
     $tplMain->set('matches', $matches);
     if ($type != 'all') {
         $tplMain->set('playerId', 0);
         $tplMain->set('username', $player->getUsername());
     } else {
         $tplMain->set('playerId', $this->player->getId());
     }
     $tplMain->set('type', $type);
     // layout
     $this->tplLayout->set('column1', $tplFilter->render('match-history-filter'));
     $this->tplLayout->add('column1', $tplMain->render('match-history'));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-center'));
     return $this->tplMaster->render('tpl-default');
 }