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
|
<?php
|
||||||
|
|
||||||
class Controller
|
class App
|
||||||
{
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$config = require __DIR__ . '/../config.php';
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
public function model(string $model): object
|
public function model(string $model): object
|
||||||
{
|
{
|
||||||
// Require model file
|
// 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';
|
require __DIR__ . '/core/' . $class_name . '.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define global CONFIG constant.
|
// God mode class that instantiates many other classes... or something like that
|
||||||
define("CONFIG",
|
return new App();
|
||||||
require __DIR__ . '/config.php'
|
|
||||||
);
|
|
@ -1,7 +1,3 @@
|
|||||||
<?php $this->view('template/header', ['title' => $title]); ?>
|
|
||||||
|
|
||||||
<h1>Velkommen til forsida!</h1>
|
<h1>Velkommen til forsida!</h1>
|
||||||
<p>Ting fungerer noen ganger.</p>
|
<p>Ting fungerer noen ganger.</p>
|
||||||
<p><?=$data?></p>
|
<p><?=$data?></p>
|
||||||
|
|
||||||
<?php $this->view('template/footer'); ?>
|
|
@ -1,5 +1,3 @@
|
|||||||
<?php $this->view('template/header', ['title' => $title]); ?>
|
|
||||||
|
|
||||||
<h1>Logg inn</h1>
|
<h1>Logg inn</h1>
|
||||||
<p>Fyll inn påloggingsinformasjonen din.</p>
|
<p>Fyll inn påloggingsinformasjonen din.</p>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
@ -14,5 +12,3 @@
|
|||||||
<br>
|
<br>
|
||||||
<input type="submit" value="Bekreft">
|
<input type="submit" value="Bekreft">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php $this->view('template/footer'); ?>
|
|
@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><?=htmlspecialchars($title);?> – Stafett for livet</title>
|
<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>
|
<body>
|
||||||
|
|
||||||
<div id="header">
|
<div id="header">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<div id="menu">
|
<div id="menu">
|
||||||
<small>
|
<small>
|
||||||
<span>Ikke pålogget</span>
|
<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>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -28,9 +28,9 @@
|
|||||||
|
|
||||||
<div id="nav">
|
<div id="nav">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="<?=CONFIG['root_url']?>/index.php">Forside</a></li>
|
<li><a href="<?=$this->config['root_url']?>/index.php">Forside</a></li>
|
||||||
<li><a href="<?=CONFIG['root_url']?>/login.php">Logg inn</a></li>
|
<li><a href="<?=$this->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']?>">Eksempel</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
require("../app/inc.php");
|
$app = require("../app/inc.php");
|
||||||
|
|
||||||
// Instantiate a new controller
|
$model = $app->model('Index');
|
||||||
$contr = new Controller;
|
|
||||||
|
|
||||||
// Grab the model
|
$app->view('template/header', ["title" => "Forside"]);
|
||||||
$model = $contr->model('Index');
|
$app->view('index', [
|
||||||
|
"data" => $model->getUsername()
|
||||||
// Perform database task with model
|
|
||||||
$username = $model->getUsername();
|
|
||||||
|
|
||||||
// Display view with retrieved data
|
|
||||||
$contr->view('index', [
|
|
||||||
"title" => "Forside",
|
|
||||||
"data" => $username
|
|
||||||
]);
|
]);
|
||||||
|
$app->view('template/footer');
|
@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require("../app/inc.php");
|
$app = require("../app/inc.php");
|
||||||
|
|
||||||
$contr = new Controller;
|
$app->view('template/header', ["title" => "Logg inn"]);
|
||||||
|
$app->view('login');
|
||||||
$contr->view('login', [
|
$app->view('template/footer');
|
||||||
"title" => "Logg inn",
|
|
||||||
]);
|
|
Reference in New Issue
Block a user