Commit
This commit is contained in:
parent
cf19bb3bd5
commit
550a64f57e
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Extended controller for RESTful APIs
|
||||
class ApiController extends Controller
|
||||
{
|
||||
// TODO: ...
|
||||
}
|
@ -1,7 +1,13 @@
|
||||
<?php
|
||||
|
||||
class Controller
|
||||
class App
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$config = require __DIR__ . '/../config.php';
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function model(string $model): object
|
||||
{
|
||||
// Require model file
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
// Provide user feedback by flashing a message on the next request. This is usually combined with a layout template that does this.
|
||||
class Flash extends Session {
|
||||
public function add(): void
|
||||
{
|
||||
// TODO: ...
|
||||
}
|
||||
}
|
@ -17,7 +17,5 @@ spl_autoload_register(function ($class_name) {
|
||||
require __DIR__ . '/core/' . $class_name . '.php';
|
||||
});
|
||||
|
||||
// Define global CONFIG constant.
|
||||
define("CONFIG",
|
||||
require __DIR__ . '/config.php'
|
||||
);
|
||||
// God mode class that instantiates many other classes... or something like that
|
||||
return new App();
|
@ -1,7 +1,3 @@
|
||||
<?php $this->view('template/header', ['title' => $title]); ?>
|
||||
|
||||
<h1>Velkommen til forsida!</h1>
|
||||
<p>Ting fungerer noen ganger.</p>
|
||||
<p><?=$data?></p>
|
||||
|
||||
<?php $this->view('template/footer'); ?>
|
@ -1,5 +1,3 @@
|
||||
<?php $this->view('template/header', ['title' => $title]); ?>
|
||||
|
||||
<h1>Logg inn</h1>
|
||||
<p>Fyll inn påloggingsinformasjonen din.</p>
|
||||
<form method="post">
|
||||
@ -14,5 +12,3 @@
|
||||
<br>
|
||||
<input type="submit" value="Bekreft">
|
||||
</form>
|
||||
|
||||
<?php $this->view('template/footer'); ?>
|
@ -6,7 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?=htmlspecialchars($title);?> – Stafett for livet</title>
|
||||
|
||||
<link rel="stylesheet" href="<?=CONFIG['root_url']?>/static/style/main.css">
|
||||
<link rel="stylesheet" href="<?=$this->config['root_url']?>/static/style/main.css">
|
||||
<body>
|
||||
|
||||
<div id="header">
|
||||
@ -18,7 +18,7 @@
|
||||
<div id="menu">
|
||||
<small>
|
||||
<span>Ikke pålogget</span>
|
||||
<a href="<?=CONFIG['root_url']?>/login.php">Logg inn</a>
|
||||
<a href="<?=$this->config['root_url']?>/login.php">Logg inn</a>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
@ -28,9 +28,9 @@
|
||||
|
||||
<div id="nav">
|
||||
<ul>
|
||||
<li><a href="<?=CONFIG['root_url']?>/index.php">Forside</a></li>
|
||||
<li><a href="<?=CONFIG['root_url']?>/login.php">Logg inn</a></li>
|
||||
<li><a href="<?=CONFIG['root_url']?>">Eksempel</a></li>
|
||||
<li><a href="<?=$this->config['root_url']?>/index.php">Forside</a></li>
|
||||
<li><a href="<?=$this->config['root_url']?>/login.php">Logg inn</a></li>
|
||||
<li><a href="<?=$this->config['root_url']?>">Eksempel</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -1,17 +1,10 @@
|
||||
<?php
|
||||
require("../app/inc.php");
|
||||
$app = require("../app/inc.php");
|
||||
|
||||
// Instantiate a new controller
|
||||
$contr = new Controller;
|
||||
$model = $app->model('Index');
|
||||
|
||||
// Grab the model
|
||||
$model = $contr->model('Index');
|
||||
|
||||
// Perform database task with model
|
||||
$username = $model->getUsername();
|
||||
|
||||
// Display view with retrieved data
|
||||
$contr->view('index', [
|
||||
"title" => "Forside",
|
||||
"data" => $username
|
||||
$app->view('template/header', ["title" => "Forside"]);
|
||||
$app->view('index', [
|
||||
"data" => $model->getUsername()
|
||||
]);
|
||||
$app->view('template/footer');
|
@ -1,8 +1,6 @@
|
||||
<?php
|
||||
require("../app/inc.php");
|
||||
$app = require("../app/inc.php");
|
||||
|
||||
$contr = new Controller;
|
||||
|
||||
$contr->view('login', [
|
||||
"title" => "Logg inn",
|
||||
]);
|
||||
$app->view('template/header', ["title" => "Logg inn"]);
|
||||
$app->view('login');
|
||||
$app->view('template/footer');
|
Reference in New Issue
Block a user