diff options
Diffstat (limited to 'src/view/HeaderBuilder.php')
| -rw-r--r-- | src/view/HeaderBuilder.php | 80 |
1 files changed, 33 insertions, 47 deletions
diff --git a/src/view/HeaderBuilder.php b/src/view/HeaderBuilder.php index 5492340..1c82368 100644 --- a/src/view/HeaderBuilder.php +++ b/src/view/HeaderBuilder.php | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\Node; | 6 | use App\Entity\Node; |
| 7 | use App\Entity\Asset; | ||
| 7 | 8 | ||
| 8 | class HeaderBuilder extends AbstractBuilder | 9 | class HeaderBuilder extends AbstractBuilder |
| 9 | { | 10 | { |
| @@ -34,44 +35,19 @@ class HeaderBuilder extends AbstractBuilder | |||
| 34 | 35 | ||
| 35 | if(file_exists($viewFile)) | 36 | if(file_exists($viewFile)) |
| 36 | { | 37 | { |
| 38 | $node_data = $node->getNodeData(); | ||
| 37 | // titre et description | 39 | // titre et description |
| 38 | // => retourne $titre, $description et le tableau associatif: $social | 40 | if(!empty($node_data->getData())) |
| 39 | if(!empty($node->getNodeData()->getData())) | ||
| 40 | { | 41 | { |
| 41 | extract($node->getNodeData()->getData()); | 42 | extract($node_data->getData()); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | // réseaux sociaux + logo dans l'entête | 45 | // réseaux sociaux + logo dans l'entête |
| 46 | $header_logo = Asset::USER_PATH . $node_data->getAssetByRole('header_logo')?->getFileName() ?? ''; | ||
| 47 | $header_background = Asset::USER_PATH . $node_data->getAssetByRole('header_background')?->getFileName() ?? ''; | ||
| 48 | |||
| 45 | $keys = array_keys($social); | 49 | $keys = array_keys($social); |
| 46 | $social_networks = ''; | 50 | $social_networks = ''; |
| 47 | //$header_logo; | ||
| 48 | //$header_background; | ||
| 49 | |||
| 50 | // nécéssite des entrées dans la table node_asset | ||
| 51 | /*foreach($node->getNodeData()->getAssets() as $asset) | ||
| 52 | { | ||
| 53 | for($i = 0; $i < count($keys); $i++) | ||
| 54 | { | ||
| 55 | // réseaux sociaux | ||
| 56 | if(str_contains($asset->getFileName(), $keys[$i])){ | ||
| 57 | $social_networks .= '<a href="' . $social[$keys[$i]] . '" target="_blank" rel="noopener noreferrer"> | ||
| 58 | <img src="' . rtrim($asset->getFilePathMini(), '/') . '" alt="' . $keys[$i] . '_alt"></a>'; | ||
| 59 | break; | ||
| 60 | } | ||
| 61 | // logo en-tête | ||
| 62 | //if(str_contains($asset->getFileName(), 'header_logo')){ | ||
| 63 | //$header_logo = rtrim($asset->getFilePathMini(), '/'); | ||
| 64 | //break; | ||
| 65 | //} | ||
| 66 | // image de fond | ||
| 67 | //if(str_contains($asset->getFileName(), 'header_background')){ | ||
| 68 | //$header_background = rtrim($asset->getFilePath(), '/'); | ||
| 69 | //break; | ||
| 70 | //} | ||
| 71 | } | ||
| 72 | }*/ | ||
| 73 | |||
| 74 | // réseaux sociaux, chemin du ficher dans node_data à déplacer dans asset | ||
| 75 | foreach($keys as $one_key){ | 51 | foreach($keys as $one_key){ |
| 76 | $social_networks .= '<a href="' . $social[$one_key] . '" target="_blank" rel="noopener noreferrer"> | 52 | $social_networks .= '<a href="' . $social[$one_key] . '" target="_blank" rel="noopener noreferrer"> |
| 77 | <img src="assets/' . $one_key . '.svg" alt="' . $one_key . '_alt"></a>'; | 53 | <img src="assets/' . $one_key . '.svg" alt="' . $one_key . '_alt"></a>'; |
| @@ -79,26 +55,36 @@ class HeaderBuilder extends AbstractBuilder | |||
| 79 | 55 | ||
| 80 | // boutons mode admin | 56 | // boutons mode admin |
| 81 | if($_SESSION['admin']){ | 57 | if($_SESSION['admin']){ |
| 82 | $edit_favicon_hidden = 'hidden'; | 58 | // assets dans classe editing_zone |
| 83 | $button_favicon = ''; | 59 | $editing_zone_margin = '5px'; |
| 84 | $button_header_logo = ''; | 60 | $buttons_favicon = '<button id="head_favicon_open" onclick="head_favicon.open()"><img id="head_favicon_img" class="action_icon"> Favicon</button> |
| 85 | //$edit_favicon_hidden = ''; | 61 | <script>document.getElementById(\'head_favicon_img\').src = window.Config.favicon;</script> |
| 86 | //$favicon = 'assets/favicon48x48.png'; // double le code dans HeadBuilder | 62 | <img id="head_favicon_submit" class="action_icon hidden" src="assets/save.svg" onclick="head_favicon.submit()"> |
| 87 | //$button_favicon = '<button onclick="editFavicon()"><img class="action_icon" src="' . $favicon . '"> Favicon</button>'; | 63 | <img id="head_favicon_cancel" class="action_icon hidden" src="assets/close.svg" onclick="head_favicon.cancel()">'; |
| 88 | //$button_header_logo = '<img class="action_icon" src="assets/edit.svg" onclick="editHeaderLogo()">'; | 64 | $buttons_background = '<button id="header_background_open" onclick="header_background.open()"><img id="header_background_img" class="background_button" src="' . $header_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()"> | 65 | <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()"> | 66 | <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()">'; | 67 | |
| 92 | $buttons_header_description = '<img id="header_description_open" class="action_icon" src="assets/edit.svg" onclick="header_description.openTextInput()"> | 68 | // asset dans classe header_content |
| 93 | <img id="header_description_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_description.submitTextInput()"> | 69 | $buttons_header_logo = '<img id="header_logo_open" class="action_icon" src="assets/edit.svg" onclick="header_logo.open()"> |
| 94 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancelTextInput()">'; | 70 | <img id="header_logo_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_logo.submit()"> |
| 71 | <img id="header_logo_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_logo.cancel()">'; | ||
| 72 | // texte dans classe header_content | ||
| 73 | $buttons_header_title = '<img id="header_title_open" class="action_icon" src="assets/edit.svg" onclick="header_title.open()"> | ||
| 74 | <img id="header_title_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_title.submit()"> | ||
| 75 | <img id="header_title_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_title.cancel()">'; | ||
| 76 | $buttons_header_description = '<img id="header_description_open" class="action_icon" src="assets/edit.svg" onclick="header_description.open()"> | ||
| 77 | <img id="header_description_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_description.submit()"> | ||
| 78 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancel()">'; | ||
| 79 | |||
| 95 | //$buttons_social_networks = '<img class="action_icon" src="assets/edit.svg" onclick="editSocialNetworks()">'; | 80 | //$buttons_social_networks = '<img class="action_icon" src="assets/edit.svg" onclick="editSocialNetworks()">'; |
| 96 | $buttons_social_networks = ''; | 81 | $buttons_social_networks = ''; |
| 97 | } | 82 | } |
| 98 | else{ | 83 | else{ |
| 99 | $edit_favicon_hidden = 'hidden'; | 84 | $editing_zone_margin = '0'; |
| 100 | $button_favicon = ''; | 85 | $buttons_favicon = ''; |
| 101 | $button_header_logo = ''; | 86 | $buttons_background = ''; |
| 87 | $buttons_header_logo = ''; | ||
| 102 | $buttons_header_title = ''; | 88 | $buttons_header_title = ''; |
| 103 | $buttons_header_description = ''; | 89 | $buttons_header_description = ''; |
| 104 | $buttons_social_networks = ''; | 90 | $buttons_social_networks = ''; |
