summaryrefslogtreecommitdiff
path: root/src/view/FooterBuilder.php
blob: 14f9cd7d1c4ee35bd5d9cf28a541e3c24097f6a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
// src/view/FooterBuilder.php

declare(strict_types=1);

use App\Entity\Node;

class FooterBuilder extends AbstractBuilder
{
    public function __construct(Node $node)
    {
        $viewFile = self::VIEWS_PATH . $node->getName() . '.php';
        
        if(file_exists($viewFile))
        {
            // $adresses postale et e-mail
            if(!empty($node->getNodeData()->getData()))
            {
                extract($node->getNodeData()->getData());
            }

            $this->useChildrenBuilder($node);
            $breadcrumb = $this->html;

            // zone admin
            $empty_admin_zone = '';
            //$zone_admin = '';
            if($_SESSION['admin'])
            {
                $empty_admin_zone = 'empty_admin_zone';
                $link_edit_page = new URL(['page' => CURRENT_PAGE]);
                if(MainBuilder::$modif_mode){
                    $mode = 'modification de page';
                    $div_admin = 'logged_in modif_mode';
                    $link_edit_label = 'Sortir du mode modification';
                }
                else{
                    $mode = 'administrateur';
                    $div_admin = 'logged_in';
                    $link_edit_page->addParams(['action' => 'modif_page']);
                    $link_edit_label = 'Modifier la page';
                }
                $link_new_page = new URL(['page' => 'nouvelle_page']);
                $link_change_paths = new URL(['page' => 'menu_chemins']);
                
                $link_change_password = new URL(['from' => CURRENT_PAGE, 'action' => 'modif_mdp']);
                isset($_GET['id']) ? $link_change_password->addParams(['id' => $_GET['id']]) : '';

                $link_logout = new URL(['page' => CURRENT_PAGE, 'action' => 'deconnexion']);
                isset($_GET['id']) ? $link_logout->addParams(['id' => $_GET['id']]) : '';

                $zone_admin = '<div class="admin_buttons_zone">
                    <p>Vous êtes en mode ' . $mode . ".</p>\n" . 
                    '<div><a href="' . $link_new_page . '"><button>Nouvelle page</button></a></div>' . "\n" . 
                    '<div><a href="' . $link_edit_page . '"><button>' . $link_edit_label . '</button></a></div>' . "\n" . 
                    '<div><a href="' . $link_change_paths . '"><button>Menu et chemins</button></a></div>' . "\n" . 
                    '<div><a href="' . $link_change_password . '"><button>Changer de mot de passe</button></a></div>' . "\n" . 
                    '<div><a href="' . $link_logout . '"><button>Déconnexion</button></a></div>' . "\n" . 
                '</div>' . "\n";
            }
            else
            {
                $div_admin = 'logged_out';
                $zone_admin = '';
                if(Director::$page_path->getLast()->getEndOfPath() === 'article' && isset($_GET['id'])){
                    $zone_admin = '<button><a href="' . new URL(['page' => 'connexion', 'from' => CURRENT_PAGE, 'id' => $_GET['id']]) . '">Mode admin</a></button>';
                }
                else{
                    $zone_admin = '<button><a href="' . new URL(['page' => 'connexion', 'from' => CURRENT_PAGE]) . '">Mode admin</a></button>';
                }
            }

            ob_start();
            require $viewFile;
            $this->html = ob_get_clean();
        }
    }
}