Base d'un site web v2
This commit is contained in:
@ -15,13 +15,13 @@ class Controller {
|
||||
protected function view() {
|
||||
ob_start();
|
||||
extract($this->data);
|
||||
require 'src/View/'.str_replace('\\', '/', preg_replace('#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class($this))).'.php';
|
||||
require 'src/View/' . str_replace('\\', '/', preg_replace('#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class($this))) . '.php';
|
||||
ob_end_flush();
|
||||
exit();
|
||||
}
|
||||
|
||||
protected function addData($data) {
|
||||
$this->data += $data;
|
||||
$this->data += $data;
|
||||
}
|
||||
|
||||
protected function returnJson($data) {
|
||||
|
@ -31,7 +31,7 @@ class ControllerSite {
|
||||
require 'src/View/Site/tpl/head.php';
|
||||
}
|
||||
|
||||
require 'src/View/'.str_replace('\\', '/', preg_replace('#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class($this))).'.php';
|
||||
require 'src/View/'.str_replace('\\', '/', preg_replace('#^' . Config::NAMESPACE . '\\\Controller\\\#', '', get_class($this))) . '.php';
|
||||
|
||||
if ($footer) {
|
||||
require 'src/View/Site/tpl/footer.php';
|
||||
|
@ -9,10 +9,16 @@ class Index extends ControllerSite {
|
||||
/**
|
||||
* Index constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->addHead([
|
||||
]);
|
||||
|
||||
$this->addFooter([
|
||||
|
||||
]);
|
||||
|
||||
$this->addData([]);
|
||||
$this->view();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class SiteError extends ControllerSite {
|
||||
* @param int $ErrCode
|
||||
* @param string $message
|
||||
*/
|
||||
public function __construct($ErrCode = 500, $message = ''){
|
||||
public function __construct($ErrCode = 500, $message = '') {
|
||||
parent::__construct();
|
||||
|
||||
$tabCode = [
|
||||
@ -74,23 +74,23 @@ class SiteError extends ControllerSite {
|
||||
511 => ['label' => '511 Network Authentication Required', 'msg' => '511 Network Authentication Required']
|
||||
];
|
||||
|
||||
if(isset($tabCode[$ErrCode])){
|
||||
if (isset($tabCode[$ErrCode])) {
|
||||
header($_SERVER['SERVER_PROTOCOL'].' '.$tabCode[$ErrCode]['label']);
|
||||
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||
$this->throwError('Erreur '.$tabCode[$ErrCode]['label'], 'Erreur_'.$ErrCode);
|
||||
}
|
||||
$erreur = $tabCode[$ErrCode]['msg'];
|
||||
$this->addData(['erreur' => $erreur]);
|
||||
}else{
|
||||
} else {
|
||||
header($_SERVER['SERVER_PROTOCOL'].' '.$tabCode[500]['label']);
|
||||
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||
$this->throwError('Erreur '.$tabCode[500]['label'], 'Erreur_500');
|
||||
}
|
||||
$erreur = $tabCode[500]['msg'];
|
||||
$this->addData(['erreur' => $erreur]);
|
||||
}
|
||||
|
||||
if(!empty($message)){
|
||||
if (!empty($message)) {
|
||||
$this->addData(['message' => $message]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user