diff options
| author | polo <ordipolo@gmx.fr> | 2025-10-23 14:15:01 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-10-23 14:15:01 +0200 |
| commit | f9a9bf1ae4fac9317fd71f0bcb207544b000e6f1 (patch) | |
| tree | a0ca5cdc0374529b80951d7d126f1c49442bae68 /src/view | |
| parent | db5521f7b194190013dd0ad606a018ab68464562 (diff) | |
| download | cms-f9a9bf1ae4fac9317fd71f0bcb207544b000e6f1.zip | |
téléchargement d'assets dans head, header et footer
Diffstat (limited to 'src/view')
| -rw-r--r-- | src/view/AbstractBuilder.php | 2 | ||||
| -rw-r--r-- | src/view/FooterBuilder.php | 23 | ||||
| -rw-r--r-- | src/view/HeadBuilder.php | 4 | ||||
| -rw-r--r-- | src/view/HeaderBuilder.php | 42 | ||||
| -rw-r--r-- | src/view/templates/footer.php | 17 | ||||
| -rw-r--r-- | src/view/templates/header.php | 34 |
6 files changed, 81 insertions, 41 deletions
diff --git a/src/view/AbstractBuilder.php b/src/view/AbstractBuilder.php index 34d1462..3d315b1 100644 --- a/src/view/AbstractBuilder.php +++ b/src/view/AbstractBuilder.php | |||
| @@ -7,7 +7,7 @@ use App\Entity\Node; | |||
| 7 | 7 | ||
| 8 | abstract class AbstractBuilder | 8 | abstract class AbstractBuilder |
| 9 | { | 9 | { |
| 10 | public const VIEWS_PATH = '../src/view/templates/'; | 10 | const VIEWS_PATH = '../src/view/templates/'; |
| 11 | protected string $html = ''; | 11 | protected string $html = ''; |
| 12 | protected int $id_node; | 12 | protected int $id_node; |
| 13 | 13 | ||
diff --git a/src/view/FooterBuilder.php b/src/view/FooterBuilder.php index dc0d31d..35df010 100644 --- a/src/view/FooterBuilder.php +++ b/src/view/FooterBuilder.php | |||
| @@ -26,15 +26,19 @@ class FooterBuilder extends AbstractBuilder | |||
| 26 | if($_SESSION['admin']) | 26 | if($_SESSION['admin']) |
| 27 | { | 27 | { |
| 28 | // données du footer | 28 | // données du footer |
| 29 | $buttons_footer_name = '<img id="footer_name_open" class="action_icon" src="assets/edit.svg" onclick="footer_name.openTextInput()"> | 29 | $buttons_footer_name = '<img id="footer_name_open" class="action_icon" src="assets/edit.svg" onclick="footer_name.open()"> |
| 30 | <img id="footer_name_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_name.submitTextInput()"> | 30 | <img id="footer_name_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_name.submit()"> |
| 31 | <img id="footer_name_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_name.cancelTextInput()">'; | 31 | <img id="footer_name_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_name.cancel()">'; |
| 32 | $buttons_footer_address = '<img id="footer_address_open" class="action_icon" src="assets/edit.svg" onclick="footer_address.openTextInput()"> | 32 | $buttons_footer_address = '<img id="footer_address_open" class="action_icon" src="assets/edit.svg" onclick="footer_address.open()"> |
| 33 | <img id="footer_address_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_address.submitTextInput()"> | 33 | <img id="footer_address_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_address.submit()"> |
| 34 | <img id="footer_address_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_address.cancelTextInput()">'; | 34 | <img id="footer_address_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_address.cancel()">'; |
| 35 | $buttons_footer_email = '<img id="footer_email_open" class="action_icon" src="assets/edit.svg" onclick="footer_email.openTextInput()"> | 35 | $buttons_footer_email = '<img id="footer_email_open" class="action_icon" src="assets/edit.svg" onclick="footer_email.open()"> |
| 36 | <img id="footer_email_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_email.submitTextInput()"> | 36 | <img id="footer_email_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_email.submit()"> |
| 37 | <img id="footer_email_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_email.cancelTextInput()">'; | 37 | <img id="footer_email_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_email.cancel()">'; |
| 38 | |||
| 39 | $buttons_footer_logo = '<img id="footer_logo_open" class="action_icon" src="assets/edit.svg" onclick="footer_logo.open()"> | ||
| 40 | <img id="footer_logo_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_logo.submit()"> | ||
| 41 | <img id="footer_logo_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_logo.cancel()">'; | ||
| 38 | 42 | ||
| 39 | // zone admin | 43 | // zone admin |
| 40 | $empty_admin_zone = 'empty_admin_zone'; | 44 | $empty_admin_zone = 'empty_admin_zone'; |
| @@ -76,6 +80,7 @@ class FooterBuilder extends AbstractBuilder | |||
| 76 | $buttons_footer_name = ''; | 80 | $buttons_footer_name = ''; |
| 77 | $buttons_footer_address = ''; | 81 | $buttons_footer_address = ''; |
| 78 | $buttons_footer_email = ''; | 82 | $buttons_footer_email = ''; |
| 83 | $buttons_footer_logo = ''; | ||
| 79 | } | 84 | } |
| 80 | 85 | ||
| 81 | ob_start(); | 86 | ob_start(); |
diff --git a/src/view/HeadBuilder.php b/src/view/HeadBuilder.php index 978d9ed..b3d78aa 100644 --- a/src/view/HeadBuilder.php +++ b/src/view/HeadBuilder.php | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\Asset; | ||
| 6 | use App\Entity\Node; | 7 | use App\Entity\Node; |
| 7 | 8 | ||
| 8 | class HeadBuilder extends AbstractBuilder | 9 | class HeadBuilder extends AbstractBuilder |
| @@ -36,6 +37,7 @@ class HeadBuilder extends AbstractBuilder | |||
| 36 | if($_SESSION['admin']){ | 37 | if($_SESSION['admin']){ |
| 37 | // édition éléments sur toutes les pages (header, footer et favicon) | 38 | // édition éléments sur toutes les pages (header, footer et favicon) |
| 38 | $js .= '<script src="' . self::versionedFileURL('js', 'InputText') . '"></script>' . "\n"; | 39 | $js .= '<script src="' . self::versionedFileURL('js', 'InputText') . '"></script>' . "\n"; |
| 40 | $js .= '<script src="' . self::versionedFileURL('js', 'InputFile') . '"></script>' . "\n"; | ||
| 39 | 41 | ||
| 40 | // tinymce, nécéssite un script de copie dans composer.json | 42 | // tinymce, nécéssite un script de copie dans composer.json |
| 41 | $css .= '<link rel="stylesheet" href="' . self::versionedFileURL('css', 'tinymce') . '">' . "\n"; | 43 | $css .= '<link rel="stylesheet" href="' . self::versionedFileURL('css', 'tinymce') . '">' . "\n"; |
| @@ -57,7 +59,7 @@ class HeadBuilder extends AbstractBuilder | |||
| 57 | }*/ | 59 | }*/ |
| 58 | 60 | ||
| 59 | // en dur temporairement | 61 | // en dur temporairement |
| 60 | $favicon = 'assets/favicon48x48.png'; | 62 | $favicon = Asset::USER_PATH . 'favicon48x48.png'; |
| 61 | $alt = 'favicon'; | 63 | $alt = 'favicon'; |
| 62 | 64 | ||
| 63 | ob_start(); | 65 | ob_start(); |
diff --git a/src/view/HeaderBuilder.php b/src/view/HeaderBuilder.php index 5492340..3b45a11 100644 --- a/src/view/HeaderBuilder.php +++ b/src/view/HeaderBuilder.php | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\Asset; | ||
| 6 | use App\Entity\Node; | 7 | use App\Entity\Node; |
| 7 | 8 | ||
| 8 | class HeaderBuilder extends AbstractBuilder | 9 | class HeaderBuilder extends AbstractBuilder |
| @@ -79,26 +80,35 @@ class HeaderBuilder extends AbstractBuilder | |||
| 79 | 80 | ||
| 80 | // boutons mode admin | 81 | // boutons mode admin |
| 81 | if($_SESSION['admin']){ | 82 | if($_SESSION['admin']){ |
| 82 | $edit_favicon_hidden = 'hidden'; | 83 | $editing_zone_margin = '5px'; |
| 83 | $button_favicon = ''; | 84 | $favicon = Asset::USER_PATH . 'favicon48x48.png'; // double le code dans HeadBuilder |
| 84 | $button_header_logo = ''; | 85 | $buttons_favicon = '<button id="head_favicon_open" onclick="head_favicon.open()"><img id="head_favicon_img" class="action_icon" src="' . $favicon . '"> Favicon</button> |
| 85 | //$edit_favicon_hidden = ''; | 86 | <img id="head_favicon_submit" class="action_icon hidden" src="assets/save.svg" onclick="head_favicon.submit()"> |
| 86 | //$favicon = 'assets/favicon48x48.png'; // double le code dans HeadBuilder | 87 | <img id="head_favicon_cancel" class="action_icon hidden" src="assets/close.svg" onclick="head_favicon.cancel()">'; |
| 87 | //$button_favicon = '<button onclick="editFavicon()"><img class="action_icon" src="' . $favicon . '"> Favicon</button>'; | 88 | $background = Asset::USER_PATH . 'fond-piscine.jpg'; |
| 88 | //$button_header_logo = '<img class="action_icon" src="assets/edit.svg" onclick="editHeaderLogo()">'; | 89 | $buttons_background = '<button id="header_background_open" onclick="header_background.open()"><img id="header_background_img" class="background_button" src="' . $background . '"> Image de fond</button> |
| 89 | $buttons_header_title = '<img id="header_title_open" class="action_icon" src="assets/edit.svg" onclick="header_title.openTextInput()"> | 90 | <img id="header_background_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_background.submit()"> |
| 90 | <img id="header_title_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_title.submitTextInput()"> | 91 | <img id="header_background_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_background.cancel()">'; |
| 91 | <img id="header_title_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_title.cancelTextInput()">'; | 92 | |
| 92 | $buttons_header_description = '<img id="header_description_open" class="action_icon" src="assets/edit.svg" onclick="header_description.openTextInput()"> | 93 | $buttons_header_logo = '<img id="header_logo_open" class="action_icon" src="assets/edit.svg" onclick="header_logo.open()"> |
| 93 | <img id="header_description_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_description.submitTextInput()"> | 94 | <img id="header_logo_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_logo.submit()"> |
| 94 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancelTextInput()">'; | 95 | <img id="header_logo_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_logo.cancel()">'; |
| 96 | |||
| 97 | $buttons_header_title = '<img id="header_title_open" class="action_icon" src="assets/edit.svg" onclick="header_title.open()"> | ||
| 98 | <img id="header_title_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_title.submit()"> | ||
| 99 | <img id="header_title_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_title.cancel()">'; | ||
| 100 | $buttons_header_description = '<img id="header_description_open" class="action_icon" src="assets/edit.svg" onclick="header_description.open()"> | ||
| 101 | <img id="header_description_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_description.submit()"> | ||
| 102 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancel()">'; | ||
| 103 | |||
| 95 | //$buttons_social_networks = '<img class="action_icon" src="assets/edit.svg" onclick="editSocialNetworks()">'; | 104 | //$buttons_social_networks = '<img class="action_icon" src="assets/edit.svg" onclick="editSocialNetworks()">'; |
| 96 | $buttons_social_networks = ''; | 105 | $buttons_social_networks = ''; |
| 97 | } | 106 | } |
| 98 | else{ | 107 | else{ |
| 99 | $edit_favicon_hidden = 'hidden'; | 108 | $editing_zone_margin = '0'; |
| 100 | $button_favicon = ''; | 109 | $buttons_favicon = ''; |
| 101 | $button_header_logo = ''; | 110 | $buttons_background = ''; |
| 111 | $buttons_header_logo = ''; | ||
| 102 | $buttons_header_title = ''; | 112 | $buttons_header_title = ''; |
| 103 | $buttons_header_description = ''; | 113 | $buttons_header_description = ''; |
| 104 | $buttons_social_networks = ''; | 114 | $buttons_social_networks = ''; |
diff --git a/src/view/templates/footer.php b/src/view/templates/footer.php index 33647a6..2bb5a9e 100644 --- a/src/view/templates/footer.php +++ b/src/view/templates/footer.php | |||
| @@ -4,25 +4,34 @@ | |||
| 4 | <div class="data"> | 4 | <div class="data"> |
| 5 | <div class="contact"> | 5 | <div class="contact"> |
| 6 | <div id="footer_name"> | 6 | <div id="footer_name"> |
| 7 | <script>let footer_name = new InputText('footer_name');</script> | ||
| 8 | <span id="footer_name_span"><?= htmlspecialchars($name ?? '') ?></span> | 7 | <span id="footer_name_span"><?= htmlspecialchars($name ?? '') ?></span> |
| 9 | <input type="text" id="footer_name_input" class="hidden" value="<?= htmlspecialchars($name ?? '') ?>" size="30"> | 8 | <input type="text" id="footer_name_input" class="hidden" value="<?= htmlspecialchars($name ?? '') ?>" size="30"> |
| 10 | <?= $buttons_footer_name ?> | 9 | <?= $buttons_footer_name ?> |
| 11 | </div> | 10 | </div> |
| 12 | <div id="footer_address"> | 11 | <div id="footer_address"> |
| 13 | <script>let footer_address = new InputText('footer_address');</script> | ||
| 14 | <span id="footer_address_span"><?= htmlspecialchars($address ?? '') ?></span> | 12 | <span id="footer_address_span"><?= htmlspecialchars($address ?? '') ?></span> |
| 15 | <input type="text" id="footer_address_input" class="hidden" value="<?= htmlspecialchars($address ?? '') ?>" size="30"> | 13 | <input type="text" id="footer_address_input" class="hidden" value="<?= htmlspecialchars($address ?? '') ?>" size="30"> |
| 16 | <?= $buttons_footer_address ?> | 14 | <?= $buttons_footer_address ?> |
| 17 | </div> | 15 | </div> |
| 18 | <div id="footer_email"> | 16 | <div id="footer_email"> |
| 19 | <script>let footer_email = new InputText('footer_email');</script> | ||
| 20 | <a href="mailto:<?= $email ?>"><span id="footer_email_span"><?= htmlspecialchars($email ?? '') ?></span></a> | 17 | <a href="mailto:<?= $email ?>"><span id="footer_email_span"><?= htmlspecialchars($email ?? '') ?></span></a> |
| 21 | <input type="text" id="footer_email_input" class="hidden" value="<?= htmlspecialchars($email ?? '') ?>" size="30"> | 18 | <input type="text" id="footer_email_input" class="hidden" value="<?= htmlspecialchars($email ?? '') ?>" size="30"> |
| 22 | <?= $buttons_footer_email ?> | 19 | <?= $buttons_footer_email ?> |
| 23 | </div> | 20 | </div> |
| 24 | </div> | 21 | </div> |
| 25 | <p class="footer_logo"><img src="<?= $footer_logo ?>" alt="logo"></p> | 22 | <div id="footer_logo"> |
| 23 | <a href="<?= new URL ?>"><img id="footer_logo_img" src="<?= $footer_logo ?>" alt="logo_alt"></a> | ||
| 24 | <input type="file" id="footer_logo_input" class="hidden" accept="image/png, image/jpeg, image/gif, image/webp, image/tiff"> | ||
| 25 | <?= $buttons_footer_logo ?> | ||
| 26 | </div> | ||
| 27 | <?php if($_SESSION['admin']){ ?> | ||
| 28 | <script> | ||
| 29 | let footer_name = new InputText('footer_name'); | ||
| 30 | let footer_address = new InputText('footer_address'); | ||
| 31 | let footer_email = new InputText('footer_email'); | ||
| 32 | let footer_logo = new InputFile('footer_logo'); | ||
| 33 | </script> | ||
| 34 | <?php } ?> | ||
| 26 | </div> | 35 | </div> |
| 27 | <div class="<?= $empty_admin_zone ?>"></div> | 36 | <div class="<?= $empty_admin_zone ?>"></div> |
| 28 | <div class="<?= $div_admin ?>"> | 37 | <div class="<?= $div_admin ?>"> |
diff --git a/src/view/templates/header.php b/src/view/templates/header.php index 7977ef3..b63aa84 100644 --- a/src/view/templates/header.php +++ b/src/view/templates/header.php | |||
| @@ -5,15 +5,22 @@ | |||
| 5 | <div id="nav_zone"> | 5 | <div id="nav_zone"> |
| 6 | <?= $nav ?> | 6 | <?= $nav ?> |
| 7 | </div> | 7 | </div> |
| 8 | 8 | <div class="editing_zone"> | |
| 9 | <div class="header-content"> | 9 | <div id="head_favicon" style="margin: <?= $editing_zone_margin ?>;"> |
| 10 | <input type="file" id="head_favicon_input" class="hidden" accept="image/png, image/jpeg, image/gif, image/webp, image/tiff, image/x-icon, image/bmp"> | ||
| 11 | <?= $buttons_favicon ?> | ||
| 12 | </div> | ||
| 13 | <div id="header_background"> | ||
| 14 | <input type="file" id="header_background_input" class="hidden" accept="image/png, image/jpeg, image/gif, image/webp, image/tiff"> | ||
| 15 | <?= $buttons_background ?> | ||
| 16 | </div> | ||
| 17 | </div> | ||
| 18 | <div class="header_content"> | ||
| 10 | <div class="header_left_col"> | 19 | <div class="header_left_col"> |
| 11 | <div id="edit_favicon_zone" class="<?= $edit_favicon_hidden ?>"> | 20 | <div id="header_logo"> |
| 12 | <?= $button_favicon ?> | 21 | <a href="<?= new URL ?>"><img id="header_logo_img" src="<?= $header_logo ?>" alt="logo_alt"></a> |
| 13 | </div> | 22 | <input type="file" id="header_logo_input" class="hidden" accept="image/png, image/jpeg, image/gif, image/webp, image/tiff"> |
| 14 | <div> | 23 | <?= $buttons_header_logo ?> |
| 15 | <a href="<?= new URL ?>"><img id="header_logo" src="<?= $header_logo ?>" alt="logo_alt"></a> | ||
| 16 | <?= $button_header_logo ?> | ||
| 17 | </div> | 24 | </div> |
| 18 | </div> | 25 | </div> |
| 19 | <div class="nav_button"> | 26 | <div class="nav_button"> |
| @@ -21,13 +28,11 @@ | |||
| 21 | </div> | 28 | </div> |
| 22 | <div class="site_title"> | 29 | <div class="site_title"> |
| 23 | <h1 id="header_title"> | 30 | <h1 id="header_title"> |
| 24 | <script>let header_title = new InputText('header_title');</script> | ||
| 25 | <a href="<?= new URL ?>"><span id="header_title_span"><?= htmlspecialchars($title ?? '') ?></span></a> | 31 | <a href="<?= new URL ?>"><span id="header_title_span"><?= htmlspecialchars($title ?? '') ?></span></a> |
| 26 | <input type="text" id="header_title_input" class="hidden" value="<?= htmlspecialchars($title ?? '') ?>" size="30"> | 32 | <input type="text" id="header_title_input" class="hidden" value="<?= htmlspecialchars($title ?? '') ?>" size="30"> |
| 27 | <?= $buttons_header_title ?> | 33 | <?= $buttons_header_title ?> |
| 28 | </h1> | 34 | </h1> |
| 29 | <h2 id="header_description"> | 35 | <h2 id="header_description"> |
| 30 | <script>let header_description = new InputText('header_description');</script> | ||
| 31 | <span id="header_description_span"><?= htmlspecialchars($description ?? '') ?></span> | 36 | <span id="header_description_span"><?= htmlspecialchars($description ?? '') ?></span> |
| 32 | <input type="text" id="header_description_input" class="hidden" value="<?= htmlspecialchars($description ?? '') ?>" size="30"> | 37 | <input type="text" id="header_description_input" class="hidden" value="<?= htmlspecialchars($description ?? '') ?>" size="30"> |
| 33 | <?= $buttons_header_description ?> | 38 | <?= $buttons_header_description ?> |
| @@ -41,4 +46,13 @@ | |||
| 41 | <?= $breadcrumb ?? '' ?> | 46 | <?= $breadcrumb ?? '' ?> |
| 42 | </div> | 47 | </div> |
| 43 | </div> | 48 | </div> |
| 49 | <?php if($_SESSION['admin']){ ?> | ||
| 50 | <script> | ||
| 51 | let head_favicon = new InputFile('head_favicon'); | ||
| 52 | let header_background = new InputFile('header_background'); | ||
| 53 | let header_logo = new InputFile('header_logo'); | ||
| 54 | let header_title = new InputText('header_title'); | ||
| 55 | let header_description = new InputText('header_description'); | ||
| 56 | </script> | ||
| 57 | <?php } ?> | ||
| 44 | </header> \ No newline at end of file | 58 | </header> \ No newline at end of file |
