From 1867e166c90eb8366707c48a6f8540c3f91a1957 Mon Sep 17 00:00:00 2001
From: Fibinger Ádám <adam.fibinger@wup.hu>
Date: Wed, 16 Oct 2019 20:15:49 +0200
Subject: [PATCH] További javítások

---
 form.php              |   73 ++++++++++++++----------------------
 EOG/Models/Stripe.php |   10 +++++
 2 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/EOG/Models/Stripe.php b/EOG/Models/Stripe.php
index 1531e3f..52bd5e9 100644
--- a/EOG/Models/Stripe.php
+++ b/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'];
+	}
 }
\ No newline at end of file
diff --git a/form.php b/form.php
index 226b006..3d6c68c 100644
--- a/form.php
+++ b/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,53 +25,36 @@
 {
 	$s->loadFromArray($_POST['stripe']);
 
-    if (!empty($s->getState())) {
-        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);
-        }
-    }
-}
 
-echo "<pre>State:".PHP_EOL;
-var_dump($s->getState());
-echo "</pre>";
+	$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,

--
Gitblit v1.8.0