public function index() { // auth Util\Auth::isAuthorized($this->signedUser, 'member', false, '/profile/sign-in'); \Own\Bus\Match\Data::checkMatchToView($this->player->getId()); $stats = \Own\Bus\Match\Data::loadStatsByPlayerId($this->player->getId()); $options = []; $options['where'][] = 'winner_id = ' . $this->player->getId(); $titles = \Own\Bus\Tournament\Data::count($options); // view $this->setTpl(); // main $tplMain = new Util\Template(Util\Template::SITE, ['www']); $tplMain->set('self', true); $tplMain->set('player', $this->player); $tplMain->set('stats', $stats); $tplMain->set('titles', $titles); $tplMain->set('ajax', false); // layout $this->tplLayout->set('column1', $tplMain->render('profile')); // template $this->tplMaster->set('layout', $this->tplLayout->render('layout-center')); return $this->tplMaster->render('tpl-default'); }
public function vs() { // auth Util\Auth::isAuthorized($this->signedUser, 'member', false, '/profile/sign-in'); $matchId = Util\Converter::toInt('matchId', 'get', 0); $options = []; $options['clearSelect'] = true; $options['select'][] = \Own\Bus\Match\Data::getList(['id', 'player_match1_id', 'player_match2_id', 'surface', 'current_set', 'best_of_sets', 'type', 'winner_id', 'position', 'tournament_id', 'league_id', 'status', 'scheduled']); $options['select'][] = \Own\Bus\PlayerMatch\Data::getList(['id', 'player_id'], 'match_player_match'); $options['join'][] = 'bus_player_match match_player_match'; $options['where'][] = 'match_player_match.id = match.player_match1_id OR match_player_match.id = match.player_match2_id'; $options['where'][] = ['match.id = ?', $matchId]; $options['where'][] = ['match.status IN (?)', [1, 2, 3, 4]]; $match = \Own\Bus\Match\Data::load($options); if (!isset($match)) { Util\Session::siteError('noMatch', null, '/match/schedule'); } if (in_array($match->getStatus(), [MatchStatus::PLAYING, MatchStatus::FINISHED])) { Util\Session::siteSuccess('matchStarted', '/match/view?id=' . $match->getId() . '&live=true'); } $stats1 = \Own\Bus\Match\Data::loadStatsByPlayerId($this->player->getId()); $stats2 = \Own\Bus\Match\Data::loadStatsByPlayerId($match->getPlayerMatch2()->getPlayerId(), false); // view $this->setTpl(); // main $tplMain = new Util\Template(Util\Template::SITE, ['www']); $tplMain->set('match', $match); $tplMain->set('stats1', $stats1); $tplMain->set('stats2', $stats2); // layout $this->tplLayout->set('column1', $tplMain->render('match-vs')); // template $this->tplMaster->set('layout', $this->tplLayout->render('layout-center')); return $this->tplMaster->render('tpl-default'); }
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); }