This commit is contained in:
Robert
2023-11-05 17:17:58 +01:00
parent c7e17faeaf
commit fc22cd51df
2 changed files with 77 additions and 10 deletions

21
M2/Beispiele/Test.php Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<body>
<?php
$anweisung = 3;
switch ($anweisung) {
case 1:
echo "catch _1_ !";
break;
case 2:
echo "catch _2_ !";
break;
case 3:
echo "catch _3_ !";
default:
echo "nothing to catch!";
break;
}
?>
</body>
</html>

View File

@@ -1,7 +1,9 @@
<?php <?php
const GET_PARAM_MIN_STARS = 'search_min_stars'; const GET_PARAM_MIN_STARS = 'search_min_stars';
const GET_PARAM_SEARCH_TEXT = 'search_text'; const GET_PARAM_SEARCH_TEXT = 'search_text';
const GET_PARAM_SHOW_DESCRIPTION = 'show_description';
const GET_PARAM_SPRACHE = 'sprache';
const GET_PARAM_TOP_FLOPP = 'top_flop';
/** /**
* List of all allergens. * List of all allergens.
*/ */
@@ -37,6 +39,39 @@ $ratings = [
'stars' => 3 ] 'stars' => 3 ]
]; ];
$dic = [
[ "Gericht" => "Gericht",
"Allergien" => "Allergien",
"Bewertungen" => "Bewertungen (Insgesamt: ",
"Text" => "Text",
"Sterne" => "Sterne",
"Author" => "Author",
"Preis" => "Preis",
"Gaeste" => "Gäste"
],
[ "Gericht" => "Meal",
"Allergien" => "Allergies",
"Bewertungen" => "Review (overall: ",
"Text" => "Text",
"Sterne" => "Stars",
"Author" => "Author",
"Preis" => "Price",
"Gaeste" => "Guests"
]
];
$translation = $dic[0];
$language = "de";
if (!empty($_GET[GET_PARAM_SPRACHE])){
$language = $_GET[GET_PARAM_SPRACHE];
}
if($language == "en"){$translation = $dic[1];}
if (empty($_GET[GET_PARAM_SHOW_DESCRIPTION])){
$meal['description'] = "";
}
$searchTerm = "";
$showRatings = []; $showRatings = [];
if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) { if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) {
$searchTerm = $_GET[GET_PARAM_SEARCH_TEXT]; $searchTerm = $_GET[GET_PARAM_SEARCH_TEXT];
@@ -75,7 +110,7 @@ function calcMeanStars (array $ratings) : float {
<html lang="de"> <html lang="de">
<head> <head>
<meta charset="UTF-8"/> <meta charset="UTF-8"/>
<title>Gericht: <?php echo $meal['name']; ?></title> <title><?php echo $translation["Gericht"].": ". $meal['name']; ?></title>
<style> <style>
* { * {
font-family: Arial, serif; font-family: Arial, serif;
@@ -86,10 +121,17 @@ function calcMeanStars (array $ratings) : float {
</style> </style>
</head> </head>
<body> <body>
<h1>Gericht: <?php echo $meal['name']; ?></h1> <h1><?php echo $translation["Gericht"].": ". $meal['name']; ?></h1>
<p><?php echo $meal['description']; ?></p> <p><?php echo $meal['description']; ?>
</p>
<h4>Allergien: </h4> <h4><?php echo $translation["Preis"].":"?></h4>
<p>
<?php echo $translation["Preis"]." intern: ".$meal["price_intern"]."€";?> <br>
<?php echo $translation["Preis"]." ".$translation["Gaeste"].": ".$meal["price_extern"]."€";?>
</p>
<h4><?php echo $translation["Allergien"].":"?> </h4>
<ul> <ul>
<?php <?php
foreach ($meal['allergens'] as $all) { foreach ($meal['allergens'] as $all) {
@@ -97,19 +139,19 @@ function calcMeanStars (array $ratings) : float {
} }
?> ?>
</ul> </ul>
<h1>Bewertungen (Insgesamt: <?php echo calcMeanStars($ratings); ?>)</h1> <h1><?php echo $translation["Bewertungen"].calcMeanStars($ratings); ?>)</h1>
<!--Such form in den Bewertungen für den User --> <!--Such form in den Bewertungen für den User -->
<form method="get"> <form method="get">
<label for="search_text">Filter:</label> <label for="search_text">Filter:</label>
<input id="search_text" type="text" name="search_text"> <input id="search_text" type="text" name="search_text" value=<?php echo $searchTerm?>>
<input type="submit" value="Suchen"> <input type="submit" value="Suchen">
</form> </form>
<table class="rating"> <table class="rating">
<thead> <thead>
<tr> <tr>
<td>Text</td> <td><?php echo $translation["Text"]?></td>
<td>Sterne</td> <td><?php echo $translation["Sterne"]?></td>
<td>Author</td> <td><?php echo $translation["Author"]?></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -123,5 +165,9 @@ function calcMeanStars (array $ratings) : float {
?> ?>
</tbody> </tbody>
</table> </table>
<br>
<br>
<a href="?sprache=de">Deutsch</a> oder <a href="?sprache=en">English</a>
</body> </body>
</html> </html>