Fibinger Ádám
2019-10-16 1867e166c90eb8366707c48a6f8540c3f91a1957
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
ini_set('display_errors', E_ALL);
 
include "vendor/autoload.php";
 
define('IS_DEV', (!isset($_SERVER['HTTP_HOST'])));
define('SITE_ROOT', __DIR__);
 
if (IS_DEV)
{
    define('OVERLAY_DIR', dirname(__DIR__) . '/esl-overlay/');
}
else
{
    define('OVERLAY_DIR', dirname(__DIR__) . '/overlays/');
}
 
$last_json = OVERLAY_DIR . 'last.json';
 
$twig = \EOG\Utils\TwigFactory::getEnvironment(SITE_ROOT);
 
$s = new \EOG\Models\Stripe();
 
if (!empty($_POST['stripe']))
{
    $s->loadFromArray($_POST['stripe']);
 
    if (!empty($s->getState()))
    {
        file_put_contents($last_json, $s->getJson());
    }
 
    $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 = [
    'stripe'    => $s,
    'operators' => $s->getOperators(),
    'post'      => !empty($_POST['stripe'])
];
echo $twig->render('templates/admin/form.twig', $var);