Skip to content

Commit 5be76d3

Browse files
author
Emmanuel ROY
committed
big update : session authentification guard, some exemaples and docs
1 parent eb54203 commit 5be76d3

File tree

30 files changed

+163
-60
lines changed

30 files changed

+163
-60
lines changed

application/class/Application.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ public function __construct()
2323

2424
public function launch()
2525
{
26-
//on declare la session lors du chargement du controlleur,
27-
// ainsi on instancie la page précédente et le javascript et le css asynchrone
28-
\MVC\Object\Session::createAndTestSession();
29-
3026
$controlleur = new Controlleur($this);
3127
//si la page n'est un controlleur d'action alors on affiche l'écran
3228
if (!$this->url->page['control']) {

application/class/Asynchonous.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
4+
namespace MVC\Classe;
5+
6+
class Asynchonous
7+
{
8+
private $_css;
9+
private $_javascript;
10+
11+
public function __construct()
12+
{
13+
$this->_css = "";
14+
$this->_javascript = "";
15+
}
16+
17+
public function addCss($code)
18+
{
19+
$this->_css .= "\n";
20+
$this->_css .= $code;
21+
}
22+
23+
public function addJs($code)
24+
{
25+
$this->_javascript .= "\n";
26+
$this->_javascript .= $code;
27+
}
28+
29+
public function printCss()
30+
{
31+
echo $this->_css;
32+
}
33+
34+
public function printJs()
35+
{
36+
echo $this->_javascript;
37+
}
38+
}

application/class/Bdd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Bdd
66
{
77
public $bdd;
88

9-
public function __construct($bdd = 'default')
9+
public function __construct($bdd = 'bdd')
1010
{
1111
switch ($bdd) {
1212
case 'bdd1':

application/class/Controlleur.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public function __construct($application)
3737
require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php';
3838
} else {
3939
$this->modele = new Modele($application->url->page);
40+
if(isset($this->modele->page['authentification']) && $this->modele->page['authentification'] == 'yes'){
41+
//on declare la session lors du chargement du controlleur,
42+
// ainsi on instancie la page précédente et le javascript et le css asynchrone
43+
\MVC\Object\Session::createAndTestSession();
44+
}else{
45+
\MVC\Object\Session::sessionStart();
46+
\MVC\Object\History::setPagePrecedente();
47+
\MVC\Object\Asynchronous::declare();
48+
}
4049
$this->vue = new Vue($this);
4150
}
4251
}

application/class/Url.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ public static function absolute_link_rewrite($isControlPatern, $page, $params =
192192
$scheme = 'http';
193193
}
194194
$base_url = $scheme . "://" . $url;
195+
$url = $base_url;
195196
}else{
196197
$base_url = PATH_URL;
198+
$url = $base_url . BASE_SERVER_DIRECTORY;
197199
}
198200
if ($isControlPatern) {
199201
$uri = self::controlLink_rewrite($page, $params);
@@ -202,6 +204,10 @@ public static function absolute_link_rewrite($isControlPatern, $page, $params =
202204
}
203205

204206

205-
return ( $base_url . BASE_SERVER_DIRECTORY . $uri);
207+
return ( $url . $uri);
208+
}
209+
210+
public static function getBaseDirectory(){
211+
return '/' . BASE_SERVER_DIRECTORY;
206212
}
207213
}

application/config/app-parameters.php.skel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
define("BASE_SERVER_DIRECTORY", "");
88

99
// Optionnel! il n'est nécessaire que si vous l'utilisez dans les fichiers de traitement ou dans une commande console
10-
// si vous l'utilisez dans les fichiers de traitement -> il est plus simple d'utiliser l'Objet page précédente
11-
define('PATH_URL',"http://www.domain.org");
10+
define('PATH_URL',"http://www.domain.org/");
1211

1312
define('ENV', "DEV");

application/include/conduits/DocConduit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class DocConduit extends Conduit
88
// Route('/docs')
99
public function index()
1010
{
11-
11+
\MVC\Object\Session::createAndTestSession();
1212
$files = array();
1313

1414
if ($handle = opendir(DATA_PATH . '/docs')) {
@@ -36,7 +36,7 @@ public function index()
3636
// Route('/docs/file/{file}')
3737
public function readfile()
3838
{
39-
39+
\MVC\Object\Session::createAndTestSession();
4040
$markdown = file_get_contents(DATA_PATH . '/docs/' . $this->file);
4141

4242
$my_html = MarkdownExtra::defaultTransform($markdown);

application/include/conduits/FooConduit.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ class FooConduit extends Conduit
88
// Route('/foo')
99
public function index()
1010
{
11+
\MVC\Object\Session::createAndTestSession();
1112
echo "blob of foo";
1213
return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit'));
1314
}
1415

1516
// Route('/foo/{id}')
1617
public function load()
1718
{
19+
\MVC\Object\Session::createAndTestSession();
1820
echo "load of foo";
1921
return $this->render('foo', array('page_title' => 'Foo', 'description' => 'FooConduit', 'id' => $this->id));
2022
}

application/include/conduits/IndexConduit.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class IndexConduit extends Conduit
88
// Route('/')
99
public function homepage()
1010
{
11+
\MVC\Object\Session::createAndTestSession();
1112
echo "IndexControlleur";
1213
return $this->render('index', array("templating_a"=>'blade',"templating_b"=>'twig',"templating_c"=>'edge'));
1314
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name : admin
22
page_title : Administration de l'application
33
description : Administration de l'application
4+
45
engine : blade
5-
params : params
6+
authentification : yes
7+
8+
ariane : {acceuil}
9+
arianelink : {index}
610

0 commit comments

Comments
 (0)