mirror of
https://gitlab.com/harald.mueller/aktuelle.kurse.git
synced 2024-11-27 20:21:56 +01:00
muh
This commit is contained in:
parent
984b54f217
commit
1d1b9ce84a
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
Source code for Model View Controller Tutorial in PHP: http://php-html.net/tutorials/model-view-controller-in-php/
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
include_once("model/Model.php");
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
public $model;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->model = new Model();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function invoke()
|
||||||
|
{
|
||||||
|
if (!isset($_GET['book']))
|
||||||
|
{
|
||||||
|
// no special book is requested, we'll show a list of all available books
|
||||||
|
$books = $this->model->getBookList();
|
||||||
|
include 'view/booklist.php';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// show the requested book
|
||||||
|
$book = $this->model->getBook($_GET['book']);
|
||||||
|
include 'view/viewbook.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
include_once("controller/Controller.php");
|
||||||
|
|
||||||
|
$controller = new Controller();
|
||||||
|
$controller->invoke();
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Book {
|
||||||
|
public $title;
|
||||||
|
public $author;
|
||||||
|
public $description;
|
||||||
|
|
||||||
|
public function __construct($title, $author, $description)
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
$this->author = $author;
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include_once("model/Book.php");
|
||||||
|
|
||||||
|
class Model {
|
||||||
|
public function getBookList()
|
||||||
|
{
|
||||||
|
// here goes some hardcoded values to simulate the database
|
||||||
|
return array(
|
||||||
|
"Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."),
|
||||||
|
"Moonwalker" => new Book("Moonwalker", "J. Walker", ""),
|
||||||
|
"PHP for Dummies" => new Book("PHP for Dummies", "Some Smart Guy", "")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBook($title)
|
||||||
|
{
|
||||||
|
// we use the previous function to get all the books and then we return the requested one.
|
||||||
|
// in a real life scenario this will be done through a db select command
|
||||||
|
$allBooks = $this->getBookList();
|
||||||
|
return $allBooks[$title];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -0,0 +1,19 @@
|
|||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr><td>Title</td><td>Author</td><td>Description</td></tr>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach ($books as $title => $book)
|
||||||
|
{
|
||||||
|
echo '<tr><td><a href="index.php?book='.$book->title.'">'.$book->title.'</a></td><td>'.$book->author.'</td><td>'.$book->description.'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,15 @@
|
|||||||
|
<html>
|
||||||
|
<head></head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo 'Title:' . $book->title . '<br/>';
|
||||||
|
echo 'Author:' . $book->author . '<br/>';
|
||||||
|
echo 'Description:' . $book->description . '<br/>';
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 3.2 MiB |
@ -1,2 +0,0 @@
|
|||||||
PHP Rapid
|
|
||||||
https://www.rapidphpeditor.com/de/?gclid=Cj0KCQiAkZHTBRCBARIsAMbXLhF6uOJ-qY-cPvGUF4Qp44wuAacVhmVoq6t9yCsgqmD3RSp7XhdML74aAtflEALw_wcB
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user