diff options
Diffstat (limited to 'src/view/FooterBuilder.php')
| -rw-r--r-- | src/view/FooterBuilder.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/view/FooterBuilder.php b/src/view/FooterBuilder.php new file mode 100644 index 0000000..49da71c --- /dev/null +++ b/src/view/FooterBuilder.php | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | <?php | ||
| 2 | // src/view/FooterBuilder.php | ||
| 3 | |||
| 4 | use App\Entity\Node; | ||
| 5 | |||
| 6 | class FooterBuilder extends AbstractBuilder | ||
| 7 | { | ||
| 8 | public function __construct(Node $node) | ||
| 9 | { | ||
| 10 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 11 | |||
| 12 | if(file_exists($viewFile)) | ||
| 13 | { | ||
| 14 | // $adresses postale et e-mail | ||
| 15 | if(!empty($node->getNodeData()->getData())) | ||
| 16 | { | ||
| 17 | extract($node->getNodeData()->getData()); | ||
| 18 | } | ||
| 19 | |||
| 20 | $this->useChildrenBuilder($node); | ||
| 21 | $breadcrumb = $this->html; | ||
| 22 | |||
| 23 | // zone admin | ||
| 24 | $empty_admin_zone = ''; | ||
| 25 | //$zone_admin = ''; | ||
| 26 | if($_SESSION['admin']) | ||
| 27 | { | ||
| 28 | $div_admin = 'logged_in'; | ||
| 29 | $empty_admin_zone = 'empty_admin_zone'; | ||
| 30 | $link_edit_page = new URL(['page' => CURRENT_PAGE, 'action' => 'modif_page']); | ||
| 31 | $link_new_page = new URL(['from' => CURRENT_PAGE, 'page' => 'nouvelle_page']); | ||
| 32 | $link_change_paths = new URL(['from' => CURRENT_PAGE, 'page' => 'menu_chemins']); | ||
| 33 | |||
| 34 | $link_change_password = new URL(['from' => CURRENT_PAGE, 'action' => 'modif_mdp']); | ||
| 35 | isset($_GET['id']) ? $link_change_password->addParams(['id' => $_GET['id']]) : ''; | ||
| 36 | |||
| 37 | $link_logout = new URL(['page' => CURRENT_PAGE, 'action' => 'deconnexion']); | ||
| 38 | isset($_GET['id']) ? $link_logout->addParams(['id' => $_GET['id']]) : ''; | ||
| 39 | |||
| 40 | $zone_admin = '<p>Vous êtes en mode administrateur.' . "\n" . | ||
| 41 | '<a href="' . $link_edit_page . '"><button>Modifier la page</button></a>' . "\n" . | ||
| 42 | '<a href="' . $link_new_page . '"><button>Nouvelle page</button></a>' . "\n" . | ||
| 43 | '<a href="' . $link_change_paths . '"><button>Menu et chemins</button></a>' . "\n" . | ||
| 44 | '<a href="' . $link_change_password . '"><button>Changer de mot de passe</button></a>' . "\n" . | ||
| 45 | '<a href="' . $link_logout . '"><button>Déconnexion</button></a></p>' . "\n"; | ||
| 46 | } | ||
| 47 | else | ||
| 48 | { | ||
| 49 | $div_admin = 'logged_out'; | ||
| 50 | $zone_admin = ''; | ||
| 51 | if(Director::$page_path->getLast()->getEndOfPath() === 'article' && isset($_GET['id'])){ | ||
| 52 | $zone_admin = '<button><a href="' . new URL(['page' => 'connexion', 'from' => CURRENT_PAGE, 'id' => $_GET['id']]) . '">Mode admin</a></button>'; | ||
| 53 | } | ||
| 54 | else{ | ||
| 55 | $zone_admin = '<button><a href="' . new URL(['page' => 'connexion', 'from' => CURRENT_PAGE]) . '">Mode admin</a></button>'; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | ob_start(); | ||
| 60 | require $viewFile; | ||
| 61 | $this->html = ob_get_clean(); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } \ No newline at end of file | ||
