Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WS23 EWA Praktikum Pizzaservice
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Omar Ibrahim Arfa
WS23 EWA Praktikum Pizzaservice
Commits
6e6b2985
Commit
6e6b2985
authored
1 year ago
by
Simon Pototzki
Browse files
Options
Downloads
Patches
Plain Diff
Change name
parent
836bc125
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Praktikum/Prak2/Page.php
+15
-4
15 additions, 4 deletions
src/Praktikum/Prak2/Page.php
src/Praktikum/Prak2/shop.php
+82
-12
82 additions, 12 deletions
src/Praktikum/Prak2/shop.php
with
97 additions
and
16 deletions
src/Praktikum/Prak2/Page.php
+
15
−
4
View file @
6e6b2985
...
...
@@ -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
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/Praktikum/Prak2/
PageTemplate
.php
→
src/Praktikum/Prak2/
shop
.php
+
82
−
12
View file @
6e6b2985
<?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).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment