mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-06-22 22:39:19 +00:00
router mis en place !
This commit is contained in:
@ -1,119 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* classe Pages
|
||||
* a constructor to load additionnal pages and initialize the whole class and load the pages
|
||||
*/
|
||||
// abstract class Page {
|
||||
// private $id;
|
||||
// private $title;
|
||||
// private $regex;
|
||||
// private $content;
|
||||
// private $isLoaded = false;
|
||||
|
||||
/**
|
||||
* Class Pages
|
||||
*
|
||||
* attributes
|
||||
* pageList : Array
|
||||
*
|
||||
* functions
|
||||
*
|
||||
* __construct($pages = array())
|
||||
* # load the pages list from db and static files (index/search)
|
||||
* loadPage($url)
|
||||
* # return a class of type Page (see below)
|
||||
*/
|
||||
// abstract function loadPage();
|
||||
// }
|
||||
|
||||
/**
|
||||
* class Page
|
||||
* contain the Page to load (on init only a light version but when using loadPage the whole page is in the class)
|
||||
* here it contains three extended classes (Index/Search/Post where we will add functions to the loadPage)
|
||||
*/
|
||||
|
||||
/**
|
||||
* abstract Class Page
|
||||
*
|
||||
* attributes
|
||||
* id
|
||||
* title
|
||||
* regex
|
||||
* content
|
||||
* isLoaded: boolean
|
||||
*
|
||||
* functions:
|
||||
* abstract __construct()
|
||||
* absract loadPage()
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* class Post
|
||||
* contains a post
|
||||
* with basics informations at first and when loadPost is launche the whole class will be usable
|
||||
*/
|
||||
|
||||
/**
|
||||
* class Post
|
||||
*
|
||||
* attributes
|
||||
* id
|
||||
* authorName
|
||||
* authorLinkedin
|
||||
* content
|
||||
* isloaded: false
|
||||
*
|
||||
* __construct(id);
|
||||
*
|
||||
* loadPost()
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class Pages {
|
||||
private $pageList = array();
|
||||
|
||||
public function __construct($pages = array()) {
|
||||
$pouet = array();
|
||||
$pages = array_merge($pouet, $pages);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class Page {
|
||||
private $id;
|
||||
private $title;
|
||||
private $regex;
|
||||
private $content;
|
||||
private $isLoaded = false;
|
||||
|
||||
abstract function loadPage();
|
||||
}
|
||||
|
||||
interface Page {
|
||||
public function __construct();
|
||||
public function loadPage();
|
||||
public function getId();
|
||||
public function getTitle();
|
||||
public function getRegex();
|
||||
}
|
||||
// interface Page {
|
||||
// public function __construct();
|
||||
// public function loadPage();
|
||||
// public function getId();
|
||||
// public function getTitle();
|
||||
// public function getRegex();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
class Post {
|
||||
private $id;
|
||||
private $authorName;
|
||||
private $authorLinkedin;
|
||||
private $content;
|
||||
private $isLoaded = false;
|
||||
// class Post {
|
||||
// private $id;
|
||||
// private $authorName;
|
||||
// private $authorLinkedin;
|
||||
// private $content;
|
||||
// private $isLoaded = false;
|
||||
|
||||
public function __construct($id) {
|
||||
$this->id = $id;
|
||||
}
|
||||
// public function __construct($id) {
|
||||
// $this->id = $id;
|
||||
// }
|
||||
|
||||
public function loadPost() {
|
||||
// public function loadPost() {
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
class Posts implements Page {
|
||||
public function __construct() {}
|
||||
// class Posts implements Page {
|
||||
// public function __construct() {}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
include_once "router.php";
|
||||
|
||||
$router = Router::getRouter();
|
||||
|
||||
$home = function() {
|
||||
return file_get_contents("../html/index.html");
|
||||
};
|
||||
|
||||
$router->addRoute("/^\/$/", $home);
|
||||
|
||||
$post = function() {
|
||||
return file_get_contents("../html/post.html");
|
||||
};
|
||||
|
||||
$router->addRoute("/^\/post\/$/", $post);
|
||||
|
||||
$search = function() {
|
||||
return file_get_contents("../html/search.html");
|
||||
};
|
||||
|
||||
$router->addRoute("/^\/search\/$/", $search);
|
||||
|
Reference in New Issue
Block a user