Skip to content
Snippets Groups Projects
Commit 6e6b2985 authored by Simon Pototzki's avatar Simon Pototzki
Browse files

Change name

parent 836bc125
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ abstract class Page
}
/********************************************/
$this->_database = new MySQLi($host, "public", "public", "YOUR_DATABASE");
$this->_database = new MySQLi($host, "public", "public", "pizzaservice");
if ($this->_database->connect_errno) {
throw new Exception("Connect failed: " . $this->_database->connect_errno);
......@@ -92,8 +92,16 @@ abstract class Page
$title = htmlspecialchars($title);
header("Content-type: text/html; charset=UTF-8");
// to do: handle all parameters
// to do: output common beginning of HTML code
echo <<< HTML
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>{$title}</title>
</head>
<body>
HTML;
}
/**
......@@ -102,7 +110,10 @@ abstract class Page
*/
protected function generatePageFooter():void
{
// to do: output common end of HTML code
echo <<< HTML
</body>
</html>
HTML;
}
/**
......
<?php declare(strict_types=1);
// UTF-8 marker äöüÄÖÜ߀
/**
* Class PageTemplate for the exercises of the EWA lecture
* Class shop for the exercises of the EWA lecture
* Demonstrates use of PHP including class and OO.
* Implements Zend coding standards.
* Generate documentation with Doxygen or phpdoc
*
* PHP Version 7.4
*
* @file PageTemplate.php
* @file shop.php
* @package Page Templates
* @author Bernhard Kreling, <bernhard.kreling@h-da.de>
* @author Ralf Hahn, <ralf.hahn@h-da.de>
* @version 3.1
*/
// to do: change name 'PageTemplate' throughout this file
// to do: change name 'shop' throughout this file
require_once './Page.php';
/**
......@@ -29,11 +29,10 @@ require_once './Page.php';
* @author Bernhard Kreling, <bernhard.kreling@h-da.de>
* @author Ralf Hahn, <ralf.hahn@h-da.de>
*/
class PageTemplate extends Page
class Shop extends Page
{
// to do: declare reference variables for members
// representing substructures/blocks
public array $pizzaList;
/**
* Instantiates members (to be defined above).
* Calls the constructor of the parent i.e. page class.
......@@ -43,7 +42,6 @@ class PageTemplate extends Page
protected function __construct()
{
parent::__construct();
// to do: instantiate members representing substructures/blocks
}
/**
......@@ -65,7 +63,23 @@ class PageTemplate extends Page
protected function getViewData():array
{
// to do: fetch data for this view from the database
// to do: return array containing data
$result = $this->_database->query("SELECT * FROM article;");
$pizzaList = array();
while ($row = $result->fetch_row()) {
$pizza = array(
"article_id" => $row[0],
"name" => $row[1],
"picture" => $row[2],
"price" => $row[3]
);
array_push($pizzaList, $pizza);
}
$this->pizzaList = $pizzaList;
return $pizzaList;
}
/**
......@@ -79,8 +93,64 @@ class PageTemplate extends Page
protected function generateView():void
{
$data = $this->getViewData(); //NOSONAR ignore unused $data
$this->generatePageHeader('to do: change headline'); //to do: set optional parameters
// to do: output view of this page
$this->generatePageHeader('Pizzaservice'); //to do: set optional parameters
echo <<< HTML
<section id="bestellungSection">
<h1 id="bestellungTitle">shop</h1>
<hr>
<section id="speisekarteSection">
<h2>Speisekarte</h2>
<label>
<img alt="Image of Pizza Margherita" src="./img/Veganer_Scheisse.png">
<br>
Margherita<br>
4,00
</label>
<br>
<label>
<img alt="Image of Pizza Salami" src="./img/Hackbällchen_Magherite.png">
<br>
Salami<br>
4,50
</label>
<br>
<label>
<img alt="Image of Pizza Afterburner" src="./img/Afterburner.png">
<br>
Afterburner<br>
5,50
</label>
<br>
</section>
<hr>
<section id="warenkorbSection">
<h2>Warenkorb</h2>
<form accept-charset="UTF-8" action="https://echo.fbi.h-da.de/" method="get">
<label for="warenkorb"></label>
<select id="warenkorb" multiple name="Pizza[]" size="3">
<option value="Margherita">Margherita</option>
<option value="Salami">Salami</option>
<option value="Afterburner">Afterburner</option>
</select>
<p>14,50</p>
<label for="address"></label><input id="address" name="Adresse" placeholder="Ihre Adresse" type="text"><br>
<input type="reset" value="Alles Löschen">
<input type="reset" value="Auswahl Löschen">
<input type="submit" value="Bestellen">
</form>
</section>
</section>
HTML;
$this->generatePageFooter();
}
......@@ -110,7 +180,7 @@ class PageTemplate extends Page
public static function main():void
{
try {
$page = new PageTemplate();
$page = new shop();
$page->processReceivedData();
$page->generateView();
} catch (Exception $e) {
......@@ -123,7 +193,7 @@ class PageTemplate extends Page
// This call is starting the creation of the page.
// That is input is processed and output is created.
PageTemplate::main();
shop::main();
// Zend standard does not like closing php-tag!
// PHP doesn't require the closing tag (it is assumed when the file ends).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment