Esempio n. 1
0
File: Home.php Progetto: vincium/lot
 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');
 }