0dabedc06dea5066fce2d77286a966e9b00beeb3..1867e166c90eb8366707c48a6f8540c3f91a1957
2019-10-16 Fibinger Ádám
További javítások
1867e1 diff | tree
2019-10-16 Fibinger Ádám
Form javított verziója
268b32 diff | tree
3 files modified
89 ■■■■ changed files
EOG/Models/Stripe.php 10 ●●●●● patch | view | raw | blame | history
form.php 69 ●●●●● patch | view | raw | blame | history
templates/admin/form.twig 10 ●●●● patch | view | raw | blame | history
EOG/Models/Stripe.php
@@ -173,4 +173,14 @@
    {
        return $this->state;
    }
    public function getType()
    {
        if (empty($this->state['stripe']['class']))
        {
            return null;
        }
        return $this->state['stripe']['class'];
    }
}
form.php
@@ -15,7 +15,7 @@
    define('OVERLAY_DIR', dirname(__DIR__) . '/overlays/');
}
$last_json = OVERLAY_DIR.'last.json';
$last_json = OVERLAY_DIR . 'last.json';
$twig = \EOG\Utils\TwigFactory::getEnvironment(SITE_ROOT);
@@ -25,48 +25,35 @@
{
    $s->loadFromArray($_POST['stripe']);
    if (!empty($s->stripe['class'])) {
        file_put_contents($last_json, $s->getJson());
    }
    switch ($s->stripe['class'])
    if (!empty($s->getState()))
    {
        case 'simple':
            $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
            file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
            break;
        case 'team':
            $s->setClass('simple');
            $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
            file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
            $s->setClass('team');
            $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
            file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
            break;
        case 'team-ban':
            $s->setClass('simple');
            $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
            file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
            $s->setClass('team');
            $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
            file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
            $s->setClass('team-ban');
            $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
            file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
            break;
        file_put_contents($last_json, $s->getJson());
    }
} else {
    if (file_exists($last_json)) {
        $raw_json = file_get_contents($last_json);
        $stateArray = json_decode($raw_json, true);
        if (is_array($stateArray)) {
            $s->loadFromArray($stateArray);
        }
    }
    $s->setClass('simple');
    $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'simple.html', $html_content);
    $s->setClass('team');
    $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'team.html', $html_content);
    $s->setClass('team-ban');
    $html_content = $twig->render('templates/overlay-base.twig', ['stripe' => $s]);
    file_put_contents(OVERLAY_DIR . 'team-ban.html', $html_content);
}
else
{
    if (file_exists($last_json))
    {
        $raw_json = file_get_contents($last_json);
        $stateArray = json_decode($raw_json, true);
        if (is_array($stateArray))
        {
            $s->loadFromArray($stateArray);
        }
    }
}
$var = [
templates/admin/form.twig
@@ -12,7 +12,7 @@
                </div>
                <div class="col-md-2 mb-3">
                    <label for="validationServer02">Kupa sorszám</label>
                    <input type="text" class="form-control" id="validationServer02" placeholder="Pld.: #654"
                    <input type="text" name="stripe[cup][number]" class="form-control" id="validationServer02" placeholder="Pld.: #654"
                           value="{{ stripe.cup.number }}" required>
                    <div class="valid-feedback">
                        Looks good!
@@ -31,10 +31,10 @@
                    </div>
                    <div class="col-md-12 mb-4">
                        <label for="op-blue" class="bg-primary">Banolt operátorok</label>
                        <select name="stripe[team][blue][ban]" class="operators" id="op-blue" style="width: 100%"
                        <select name="stripe[team][blue][ban][]" class="operators" id="op-blue" style="width: 100%"
                                multiple>
                            {% for operator in operators %}
                                <option value="{{ operator }}">{{ operator|capitalize }}</option>
                                <option value="{{ operator }}" {{ operator in stripe.team.blue.ban ? "selected"}}>{{ operator|capitalize }}</option>
                            {% endfor %}
                        </select>
                    </div>
@@ -50,10 +50,10 @@
                    </div>
                    <div class="col-md-12 mb-4">
                        <label for="op-orange" class="bg-warning">Banolt operátorok</label>
                        <select name="stripe[team][blue][ban]" class="operators" id="op-orange" style="width: 100%"
                        <select name="stripe[team][orange][ban][]" class="operators" id="op-orange" style="width: 100%"
                                multiple>
                            {% for operator in operators %}
                                <option value="{{ operator }}">{{ operator|capitalize }}</option>
                                <option value="{{ operator }}" {{ operator in stripe.team.orange.ban ? "selected"}}>{{ operator|capitalize }}</option>
                            {% endfor %}
                        </select>
                    </div>