Aufgabe 7

This commit is contained in:
Robert
2023-12-08 17:21:01 +01:00
parent c69ffd7aa2
commit 070945c4a5
72 changed files with 9225 additions and 995 deletions

View File

@@ -0,0 +1,23 @@
<!doctype html>
<html class="no-js" lang="DE">
<head>
<meta charset="utf-8">
<title>E-Mensa Routing Script</title>
<meta name="description" content="unused">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/default.min.css">
<?php echo $this->yieldContent("cssextra"); ?>
<meta name="theme-color" content="#dadada">
<!-- good developers check the markup ;) -->
</head>
<body>
<div class="container">
<div class="row">
<?php echo $this->yieldContent("content"); ?>
</div>
</div>
<?php echo $this->yieldContent("jsextra"); ?>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!doctype html>
<html class="no-js" lang="DE">
<head>
<meta charset="utf-8">
<title><?php echo \htmlentities($title??'', ENT_QUOTES, 'UTF-8', false); ?></title>
<?php echo $this->yieldContent("header"); ?>
<!-- good developers check the markup ;) -->
</head>
<body>
<?php echo $this->yieldContent("body"); ?>
<footer>
<table class="fusszeile">
<?php echo $this->yieldContent("footer"); ?>
</table>
</footer>
</body>
</html>

View File

@@ -0,0 +1,6 @@
<h1>This is a blade view showing phpinfo();</h1>
<p><a href="/">go back</a>.</p>
<?php
phpinfo();
?>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Beispiel: Daten aus der Datenbank</title>
</head>
<body>
<?php if(isset($data['error'])): ?>
<h1>Es gab ein Problem mit der Datenbankverbindung</h1>
<p>Fehlermeldung</p>
<pre> <?php echo \htmlentities($data['beschreibung']??'', ENT_QUOTES, 'UTF-8', false); ?></pre>
<?php else: ?>
<article>
<h1>Daten aus der Datenbank der Tabelle: Gerichte</h1>
<p>Der Controller inkludiert das benötigte Model (gerichte.php in diesem Fall)
und ruft die benötigte Funktion <code>db_gerichte_select_all()</code> zum Laden der Daten auf</p>
<ul>
<?php $__empty_1 = true; foreach($data as $a): $__empty_1 = false; ?>
<li><?php echo \htmlentities($a['name']??'', ENT_QUOTES, 'UTF-8', false); ?></li>
<?php endforeach; if ($__empty_1): ?>
<li>Keine Daten vorhanden.</li>
<?php endif; ?>
</ul>
</article>
<?php endif; ?>
</body>
</html>

View File

@@ -0,0 +1,94 @@
<?php $_shouldextend[1]=1; ?>
<?php $this->startSection("content"); ?>
<div>
<h1>Demo für <?php echo \htmlentities($name??'', ENT_QUOTES, 'UTF-8', false); ?></h1>
<p>Kurze Übersicht, wie die Arbeit mit dem Router und der Blade View-Engine funktioniert.</p>
<h2>Router</h2>
<p>Der Router nimmt den Request entgegen und zerlegt ihn in die einzelnen Teile der URI. Wichtig ist hier vor
allem der Pfad und der Querystring.</p>
<p>Wenn der Pfad in der Routenkonfiguration (<code>\$config</code> Array aus der Datei
<code>routes/web.php</code>) gefunden wird, lädt der Router die angegebene Klasse.</p>
<h3>Funktionsweise</h3>
<p>Im vorliegenden Beispiel sehen Sie diese Seite ... </p>
<ol>
<li>weil der Pfad in der Routenkonfiguration gefunden wurde</li>
<li>und dort <span class="code">'DemoController@howto'</span> hinterlegt ist</li>
<li>und im Ordner <span class="code">controllers/</span> die Datei <code class="language-php">DemoController.php</code> gefunden werden konnte
</li>
<li>und mit ihr ein Objekt des Typs <span class="code">DemoController</span> instanziiert werden konnte</li>
<li>und dieses Objekt die Funktion (Action) <span class="code">howto()</span> ausgeführt hat</li>
</ol>
<p>Sie sehen: da muss einiges stimmen und vieles davon ist Konvention.</p>
<h3>Querystrings und Pfadsegmente</h3>
<p>Die Actions in den Controller-Klassen sollen per Konvention immer ein <span class="code">RequestData</span> Objekt
entgegennehmen. Beispiel: <code class="language-php">howto(RequestData \$rd)</code></p>
<p>Dieses RequestData Objekt wird durch den Router befüllt, wenn Daten in der URL extrahiert werden konnten.</p>
<p>Daten finden sich URLs...</p>
<ul>
<li>
<p>
<strong>im Querystring</strong><br>Beispiel: rufen Sie diese mit
<code class="language-http"><?php echo \htmlentities(strtolower(explode('/',$_SERVER["SERVER_PROTOCOL"])[0])??'', ENT_QUOTES, 'UTF-8', false); ?>://<?php echo \htmlentities($_SERVER["HTTP_HOST"]??'', ENT_QUOTES, 'UTF-8', false); ?>/demo?<strong>bgcolor=fefbd8&name=Remmy</strong></code>
auf, werden <span class="language-php">bgcolor</span> und <code class="language-php">name</code> mitsamt Werten als Query Array
<code class="language-php">$rd->query</code>) übergeben
</p>
</li>
</ul>
<p>Probieren Sie es aus ;)</p>
<?php if(count($rd->args)): ?>
<p><strong>Argumente dieses Aufrufs:</strong></p>
<?php $__empty_1 = true; foreach($rd->args as $a): $__empty_1 = false; ?>
<div><span class="code"><?php echo \htmlentities($a??'', ENT_QUOTES, 'UTF-8', false); ?></span></div>
<?php endforeach; if ($__empty_1): ?>
<p>Keine weiteren Argumente im Request</p>
<?php endif; ?>
<?php endif; ?>
<?php if(count($rd->query)): ?>
<p><strong>Daten aus der Query dieses Aufrufs:</strong></p>
<pre><code class="language-php">
<?php $__empty_1 = true; foreach($rd->query as $k => $v): $__empty_1 = false; ?>
$rd->query['<?php echo \htmlentities($k??'', ENT_QUOTES, 'UTF-8', false); ?>']=<?php echo \htmlentities($v??'', ENT_QUOTES, 'UTF-8', false); ?>
<?php endforeach; if ($__empty_1): ?>
<p>Keine Querydaten</p>
<?php endif; ?>
</code></pre>
<?php endif; ?>
<h2>Blade</h2>
<p>Blade <a href="https://github.com/EFTEC/BladeOne#install-pick-one-of-the-next-one">muss installiert</a> sein.
Die Installation ist bereits geschehen und die Bibliothek liegt unter /vendor.
</p>
<h3>Daten übergeben und View rendern</h3>
<p>Bei der Verwendung der View-Engine gelten einige Konventionen:
Die Dateien müssen <code class="language-php">&lt;viewname&gt;.blade.php</code> heißen und im Ordner <code class="language-php">views</code> liegen.
</p>
<p>Sie können der View dann Daten mitgeben, indem Sie alle Daten in ein Array schreiben und dieses dann
übergeben.</p>
<p>Beispiel:</p>
<pre><code class="language-php">
view("viewtest",
array(
"texts"=>$textArray,
"persona"=>$persona,
"rd"=>$rd
)); // öffnet ../views/viewtest.blade.php
</code></pre>
</div>
<?php $this->stopSection(); ?>
<?php $this->startSection("cssextra"); ?>
<style>
body > div {background-color: <?php echo \htmlentities('#' . $bgcolor??'', ENT_QUOTES, 'UTF-8', false); ?>; }
</style>
<?php $this->stopSection(); ?>
<?php $this->startSection("jsextra"); ?>
<script src="/js/highlight.min.js"></script><script>hljs.highlightAll();</script>
<?php $this->stopSection(); ?>
<?php if (isset($_shouldextend[1])) { echo $this->runChild(".layouts.layout"); } ?>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>7a</title>
</head>
<body>
Der Wert von name lautet: <?php echo \htmlentities($request??'', ENT_QUOTES, 'UTF-8', false); ?>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Beispiel: Daten aus der Datenbank</title>
<style>
h1 {
font-weight: 300;
}
</style>
</head>
<body>
<?php if(isset($data['error'])): ?>
<h1>Es gab ein Problem mit der Datenbankverbindung</h1>
<p>Fehlermeldung</p>
<pre> <?php echo \htmlentities($data['beschreibung']??'', ENT_QUOTES, 'UTF-8', false); ?></pre>
<?php else: ?>
<?php
$zweites = false; ?>
<article>
<h1>Daten aus der Datenbank der Tabelle: Kategorien</h1>
<ul>
<?php $__empty_1 = true; foreach($data as $a): $__empty_1 = false; ?>
<?php if($zweites): ?> <h1><li><?php echo \htmlentities($a['name']??'', ENT_QUOTES, 'UTF-8', false); ?></li></h1> <?php $zweites = false; ?>
<?php else: ?>
<li><?php echo \htmlentities($a['name']??'', ENT_QUOTES, 'UTF-8', false); ?></li> <?php $zweites = true; ?>
<?php endif; ?>
<?php endforeach; if ($__empty_1): ?>
<li>Keine Daten vorhanden.</li>
<?php endif; ?>
</ul>
</article>
<?php endif; ?>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Beispiel: Daten aus der Datenbank</title>
</head>
<body>
<?php if(isset($data['error'])): ?>
<h1>Es gab ein Problem mit der Datenbankverbindung</h1>
<p>Fehlermeldung</p>
<pre> <?php echo \htmlentities($data['beschreibung']??'', ENT_QUOTES, 'UTF-8', false); ?></pre>
<?php else: ?>
<article>
<h1>Daten aus der Datenbank der Tabelle: Kategorien</h1>
<ul>
<?php $__empty_1 = true; foreach($data as $a): $__empty_1 = false; ?>
<?php if(!empty($a['name'])): ?>
<li><?php echo \htmlentities($a['name']??'', ENT_QUOTES, 'UTF-8', false); ?></li>
<?php endif; ?>
<?php endforeach; if ($__empty_1): ?>
<li>Es sind keine Gerichte vorhanden</li>
<?php endif; ?>
</ul>
</article>
<?php endif; ?>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<?php $_shouldextend[1]=1; ?>
<?php $this->startSection("header"); ?>
<?php $this->stopSection(); ?>
<?php $this->startSection("body"); ?>
<p>Page 1</p>
<?php $this->stopSection(); ?>
<?php $this->startSection("footer"); ?>
<p>Footer of Page 1</p>
<?php $this->stopSection(); ?>
<?php if (isset($_shouldextend[1])) { echo $this->runChild(".layouts.m4_7d_layout",['title' => "Page 1"]); } ?>

View File

@@ -0,0 +1,14 @@
<?php $_shouldextend[1]=1; ?>
<?php $this->startSection("header"); ?>
<?php $this->stopSection(); ?>
<?php $this->startSection("body"); ?>
<p>Page 2</p>
<?php $this->stopSection(); ?>
<?php $this->startSection("footer"); ?>
<p>Footer of Page 2</p>
<?php $this->stopSection(); ?>
<?php if (isset($_shouldextend[1])) { echo $this->runChild(".layouts.m4_7d_layout",['title' => "Page 2"]); } ?>

View File

@@ -0,0 +1,36 @@
<?php $_shouldextend[1]=1; ?>
<?php $this->startSection("content"); ?>
<header class="mt-5">
<h1>Hauptseite E-Mensa</h1>
<img src="/img/test.jpg"
alt="Testbild von https://cdn.pixabay.com/photo/2014/06/03/19/38/road-sign-361513_960_720.jpg">
</header>
<nav class="mt-5">
<strong>Navigation</strong>
<ul>
<li><a href="/demo">Demo</a></li>
<li><a href="/dbconnect">Datenbank: Gerichte</a></li>
</ul>
<ul>
<li><a href="/debug"><code class="language-php">phpinfo();</code></a></li>
</ul>
</nav>
<footer>
&copy; Team-Name DBWT
</footer>
<?php $this->stopSection(); ?>
<?php $this->startSection("cssextra"); ?>
<style>
body > div {
background-color: <?php echo \htmlentities($rd->query['bgcolor'] ?? 'ffffff'??'', ENT_QUOTES, 'UTF-8', false); ?>
}
</style>
<?php $this->stopSection(); ?>
<?php $this->startSection("jsextra"); ?>
<script src="/js/highlight.min.js"></script><script>hljs.highlightAll();</script>
<?php $this->stopSection(); ?>
<?php if (isset($_shouldextend[1])) { echo $this->runChild("layouts.layout"); } ?>

View File

@@ -0,0 +1,23 @@
<!doctype html>
<html class="no-js" lang="DE">
<head>
<meta charset="utf-8">
<title>E-Mensa Routing Script</title>
<meta name="description" content="unused">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/default.min.css">
<?php echo $this->yieldContent("cssextra"); ?>
<meta name="theme-color" content="#dadada">
<!-- good developers check the markup ;) -->
</head>
<body>
<div class="container">
<div class="row">
<?php echo $this->yieldContent("content"); ?>
</div>
</div>
<?php echo $this->yieldContent("jsextra"); ?>
</body>
</html>