History felület alapok és némi refaktor
4 files modified
5 files added
1 files deleted
| | |
| | | const ROLE_ATTACK = 'att'; |
| | | const ROLE_DEFEND = 'def'; |
| | | |
| | | protected $sites = [ |
| | | protected $maps = [ |
| | | 'Bank' => [ |
| | | 'CEO Office / Executive Lounge', |
| | | 'Open Area / Staff Room', |
| | |
| | | /** |
| | | * @return array |
| | | */ |
| | | public function getSites(): array |
| | | public function getMaps(): array |
| | | { |
| | | return $this->sites; |
| | | return $this->maps; |
| | | } |
| | | |
| | | public function getMapNames() |
| | | { |
| | | return array_keys($this->maps); |
| | | } |
| | | |
| | | /** |
| | |
| | | public function getCurrentMap(): string |
| | | { |
| | | return $this->currentMap; |
| | | } |
| | | |
| | | public function getCurrentSites(): array |
| | | { |
| | | return $this->maps[$this->currentMap]; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | private function validMap($mapName) |
| | | { |
| | | $mapList = array_keys($this->sites); |
| | | $mapList = array_keys($this->maps); |
| | | return in_array($mapName, $mapList); |
| | | } |
| | | |
| | | private function validSite($siteName) |
| | | { |
| | | return in_array($siteName, $this->sites[$this->currentMap]); |
| | | return in_array($siteName, $this->maps[$this->currentMap]); |
| | | } |
| | | |
| | | public function setCurrentMap(string $mapName) |
| | |
| | | define('SITE_ROOT', dirname(__DIR__)); |
| | | define('OVERLAY_DIR', dirname(SITE_ROOT) . '/overlays/'); |
| | | |
| | | $last_json = OVERLAY_DIR . 'last.json'; |
| | | define('STRIPE_JSON', OVERLAY_DIR . 'last.json'); |
| | | define('TEAMS_JSON', OVERLAY_DIR . 'teams.json'); |
| | | define('HISTORY_JSON', OVERLAY_DIR . 'history.json'); |
| | | |
| | | $twig = \EOG\Utils\TwigFactory::getEnvironment(SITE_ROOT.'/templates/'); |
New file |
| | |
| | | <?php |
| | | include_once "common/base.php"; |
| | | |
| | | $s = new \EOG\Models\Stripe(); |
| | | |
| | | if (file_exists(STRIPE_JSON)) { |
| | | $raw_json = file_get_contents(STRIPE_JSON); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) { |
| | | $s->loadFromArray($stateArray); |
| | | } |
| | | } |
| | | |
| | | $history = new \EOG\Models\MatchHistory(); |
| | | |
| | | if (file_exists(HISTORY_JSON)) { |
| | | $raw_json = file_get_contents(HISTORY_JSON); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) { |
| | | $history->loadState($stateArray); |
| | | } |
| | | } |
| | |
| | | $s->loadFromArray($_POST['stripe']); |
| | | |
| | | if (!empty($s->getState())) { |
| | | file_put_contents($last_json, $s->getJson()); |
| | | file_put_contents(STRIPE_JSON, $s->getJson()); |
| | | } |
| | | |
| | | $s->setClass('simple'); |
| | |
| | | file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content); |
| | | |
| | | } else { |
| | | if (file_exists($last_json)) { |
| | | $raw_json = file_get_contents($last_json); |
| | | if (file_exists(STRIPE_JSON)) { |
| | | $raw_json = file_get_contents(STRIPE_JSON); |
| | | $stateArray = json_decode($raw_json, true); |
| | | if (is_array($stateArray)) { |
| | | $s->loadFromArray($stateArray); |
| | |
| | | |
| | | $teams = new \EOG\Models\TeamList(); |
| | | |
| | | if (file_exists(OVERLAY_DIR . 'teams.json')) { |
| | | $teams->fromJson(file_get_contents(OVERLAY_DIR . 'teams.json')); |
| | | if (file_exists(TEAMS_JSON)) { |
| | | $teams->fromJson(file_get_contents(TEAMS_JSON)); |
| | | } |
| | | |
| | | $var = [ |
New file |
| | |
| | | <?php |
| | | include_once "common/history-base.php"; |
| | | |
| | | $var = [ |
| | | 'stripe' => $s, |
| | | 'post' => !empty($_POST['stripe']), |
| | | 'history' => $history, |
| | | ]; |
| | | |
| | | echo $twig->render('admin/history.twig', $var); |
New file |
| | |
| | | <?php |
| | | include_once "common/history-base.php"; |
| | | |
| | | |
| | | //validate & store as JSON |
New file |
| | |
| | | {% set classes = [ 'btn btn-outline-secondary', 'btn btn-outline-success', 'btn btn-outline-danger', 'btn btn-outline-warning', 'btn btn-outline-info', 'btn btn-outline-light', 'btn btn-outline-dark', 'btn btn-outline-link', 'btn btn-outline-primary'] %} |
| | | {% set activeClasses = [ 'btn btn-secondary', 'btn btn-success', 'btn btn-danger', 'btn btn-warning', 'btn btn-info', 'btn btn-light', 'btn btn-dark', 'btn btn-link', 'btn btn-primary'] %} |
| | | |
| | | <div class="form-row"> |
| | | {% for site in history.getCurrentSites %} |
| | | <button class="{{ cycle(classes, loop.index0)}}" id="r_{{ loop.parent.loop.index0 }}_b_{{ loop.index0 }}" |
| | | data-outline="{{ cycle(classes, loop.index0)}}" data-selected="{{ cycle(activeClasses, loop.index0)}}" onclick="return false;">{{ site }}</button> |
| | | {% endfor %} |
| | | </div> |
| | | {{ dump(round) }} |
New file |
| | |
| | | {% extends "admin/html-skeleton.twig" %} |
| | | {% block body %} |
| | | <form action="/generator/match-history.php" method="post"> |
| | | <select name="currentMap" id="currentMap" onchange="updateSites()"> |
| | | {% for map in history.getMapNames %} |
| | | <option value="{{ map }}" {{ history.getCurrentMap == map ? "selected" }}>{{ map }}</option> |
| | | {% endfor %} |
| | | </select> |
| | | <div class="form-group"> |
| | | <pre> |
| | | {% for round in history %} |
| | | {% include "admin/history-round.twig" %} |
| | | {% endfor %} |
| | | </pre> |
| | | </div> |
| | | </form> |
| | | {% endblock %} |
| | | |
| | | {% block lazyload %} |
| | | {{ parent() }} |
| | | <script type="text/javascript"> |
| | | var maps = {{ history.getMaps|json_encode|raw }} |
| | | function updateSites() { |
| | | var currentMap = document.getElementById('currentMap').value; |
| | | console.log(maps[currentMap]); |
| | | } |
| | | </script> |
| | | {% endblock %} |
| | |
| | | </div> |
| | | </form> |
| | | |
| | | <a href="/generator/team-history.php" class="btn btn-secondary">Meccstörténet</a> |
| | | <a href="/generator/match-history.php" class="btn btn-secondary">Meccstörténet</a> |
| | | {% endblock %} |
| | | {% block lazyload %} |
| | | {{ parent() }} |