Beispiel #1
0
 public function index()
 {
     if (isset($_POST['sign-out'])) {
         \Rebond\Core\UserSecurity\Service::signOut($this->signedUser);
     }
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['www']);
     if ($this->player->getId() == 0) {
         $tpl = 'index-guest';
         $matchView = \Own\Bus\Match\Data::loadLastMatch();
     } else {
         $tpl = 'index';
         $matchView = \Own\Bus\Match\Data::loadRecentByPlayerId($this->player->getId());
         $nextMatch = \Own\Bus\Match\Data::loadNextMatchByPlayerId($this->player->getId());
         $soon = isset($nextMatch) && $nextMatch->getScheduled() < time() + Engine::DAY * 360 ? true : false;
         $tplMain->set('player', $this->player);
         $tplMain->set('notificationCount', \Own\Bus\Notification\Data::countByPlayerId($this->player->getId()));
         $tplMain->set('isBonusDayXp', $this->player->isBonusDayXp());
         $tplMain->set('nextBonusDayXp', $this->player->getNextBonusDayXp());
         $tplMain->set('nextMatch', $nextMatch);
         $tplMain->set('soon', $soon);
     }
     $tplMain->set('matchView', $matchView);
     $options = [];
     $options['where'][] = 'configuration.property = \'nextWeek\'';
     $nextWeek = \Own\Bus\Configuration\Data::load($options);
     $options = [];
     $options['where'][] = 'configuration.property = \'nextMonth\'';
     $nextMonth = \Own\Bus\Configuration\Data::load($options);
     $options = [];
     $options['where'][] = 'configuration.property = \'nextYear\'';
     $nextYear = \Own\Bus\Configuration\Data::load($options);
     if (!isset($nextWeek, $nextMonth, $nextYear)) {
         Util\error::kill(Util\Code::UNHANDLED_ERROR, 'nextWeek, nextMonth or nextYear is not set in bus_configuration', __FILE__, __LINE__);
     }
     $tplMain->set('gameTime', Engine::renderTime($this->app->site()->getCreatedDate()));
     $tplMain->set('endWeek', (new Util\DateTime())->setTimestamp($nextWeek->getValue()));
     $tplMain->set('endMonth', (new Util\DateTime())->setTimestamp($nextMonth->getValue()));
     $tplMain->set('endYear', (new Util\DateTime())->setTimestamp($nextYear->getValue()));
     // view
     $this->setTpl();
     // layout
     $this->tplLayout->set('column1', $tplMain->render($tpl));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-center'));
     return $this->tplMaster->render('tpl-default');
 }
Beispiel #2
0
 public function player()
 {
     $json = [];
     $json['result'] = \Rebond\Core\ResultType::ERROR;
     $matchView = \Own\Bus\Match\Data::loadRecentByPlayerId($this->player->getId());
     if (isset($matchView)) {
         $json['message'] = Util\Lang::lang('matchView');
         return json_encode($json);
     }
     // check
     $id = Util\Converter::toInt('id', 'post');
     // cache
     $cacheTime = $this->app->site()->getCacheTime();
     $cache = Util\Cache::getCache('profile', $this->signedUser->getId() . '_' . $id, $cacheTime);
     if (isset($cache)) {
         $json['html'] = $cache;
         $json['result'] = \Rebond\Core\ResultType::SUCCESS;
         return json_encode($json);
     }
     $player = \Own\Bus\Player\Data::loadById($id);
     if (!isset($player)) {
         $json['message'] = Util\Lang::lang('playerNotFound');
         return json_encode($json);
     }
     $self = $player->getId() == $this->player->getId();
     $stats = \Own\Bus\Match\Data::loadStatsByPlayerId($player->getId(), $self);
     $options = [];
     $options['where'][] = 'winner_id = ' . $player->getId();
     $titles = \Own\Bus\Tournament\Data::count($options);
     $faceToFace = null;
     if (!$self) {
         $faceToFace = \Own\Bus\Match\Data::loadFaceToFace($this->player->getId(), $player->getId());
     }
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['www']);
     $tplMain->set('self', $self);
     $tplMain->set('player', $player);
     $tplMain->set('stats', $stats);
     $tplMain->set('titles', $titles);
     $tplMain->set('faceToFace', $faceToFace);
     $tplMain->set('ajax', true);
     // layout
     $cache = $tplMain->render('profile');
     Util\Cache::saveCache('profile', $this->signedUser->getId() . '_' . $id, $cacheTime, $cache);
     $json['title'] = $player->getUsername();
     $json['html'] = $cache;
     $json['result'] = \Rebond\Core\ResultType::SUCCESS;
     return json_encode($json);
 }