diff options
| author | polo <ordipolo@gmx.fr> | 2025-10-28 23:23:03 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-10-28 23:23:03 +0100 |
| commit | f653506421ee8e2c46c78e93d28ee2418a1d399d (patch) | |
| tree | 93f54c301538960f543ffdb5fafd387c83dec94a | |
| parent | cf8c9c1d380afbd8529a6da0afd55a9e3d8f1bf4 (diff) | |
| download | cms-f653506421ee8e2c46c78e93d28ee2418a1d399d.zip | |
modification liens réseaux sociaux, placeholder input text, correction erreurs CSS
| -rw-r--r-- | public/css/head.css | 33 | ||||
| -rw-r--r-- | public/js/Input.js | 15 | ||||
| -rw-r--r-- | src/controller/HeadFootController.php | 11 | ||||
| -rw-r--r-- | src/model/entities/NodeData.php | 2 | ||||
| -rw-r--r-- | src/view/FooterBuilder.php | 6 | ||||
| -rw-r--r-- | src/view/HeaderBuilder.php | 43 | ||||
| -rw-r--r-- | src/view/templates/header.php | 12 |
7 files changed, 90 insertions, 32 deletions
diff --git a/public/css/head.css b/public/css/head.css index c178d3a..3d9d6ca 100644 --- a/public/css/head.css +++ b/public/css/head.css | |||
| @@ -4,6 +4,7 @@ header | |||
| 4 | /*padding-top: 5px;*/ | 4 | /*padding-top: 5px;*/ |
| 5 | /*padding-bottom: 10px;*/ | 5 | /*padding-bottom: 10px;*/ |
| 6 | background-size: cover; /* largeur du bloc_page */ | 6 | background-size: cover; /* largeur du bloc_page */ |
| 7 | background-position: center; | ||
| 7 | } | 8 | } |
| 8 | #nav_zone | 9 | #nav_zone |
| 9 | { | 10 | { |
| @@ -44,6 +45,7 @@ header | |||
| 44 | { | 45 | { |
| 45 | background-color: #ffffff7f; | 46 | background-color: #ffffff7f; |
| 46 | border-radius: 10px; | 47 | border-radius: 10px; |
| 48 | padding: 1px; /* pour que les marges de h1 et h2 ne mordent pas le bloc parent */ | ||
| 47 | } | 49 | } |
| 48 | header h1 | 50 | header h1 |
| 49 | { | 51 | { |
| @@ -79,13 +81,27 @@ header a | |||
| 79 | display: flex; | 81 | display: flex; |
| 80 | justify-content: center; | 82 | justify-content: center; |
| 81 | } | 83 | } |
| 84 | #header_social_content | ||
| 85 | { | ||
| 86 | display: flex; | ||
| 87 | gap: 4px; | ||
| 88 | flex-wrap: wrap; | ||
| 89 | } | ||
| 82 | #header_social_content img | 90 | #header_social_content img |
| 83 | { | 91 | { |
| 84 | width: 28px; | 92 | width: 28px; |
| 93 | |||
| 94 | } | ||
| 95 | #header_social_content a img | ||
| 96 | { | ||
| 97 | width: 28px; | ||
| 85 | background-color: #ffffffb3; | 98 | background-color: #ffffffb3; |
| 86 | border-radius: 50%; | 99 | border-radius: 50%; |
| 87 | } | 100 | } |
| 88 | 101 | #header_social_content .action_icon | |
| 102 | { | ||
| 103 | width: 24px; | ||
| 104 | } | ||
| 89 | #header_social_content img:hover | 105 | #header_social_content img:hover |
| 90 | { | 106 | { |
| 91 | background-color: yellow; | 107 | background-color: yellow; |
| @@ -98,7 +114,8 @@ header a | |||
| 98 | } | 114 | } |
| 99 | 115 | ||
| 100 | @media screen and (max-width: 1000px){ | 116 | @media screen and (max-width: 1000px){ |
| 101 | .header_content{ | 117 | .header_content |
| 118 | { | ||
| 102 | padding: 15px 0; | 119 | padding: 15px 0; |
| 103 | } | 120 | } |
| 104 | header img | 121 | header img |
| @@ -106,14 +123,20 @@ header a | |||
| 106 | max-width: 160px; | 123 | max-width: 160px; |
| 107 | } | 124 | } |
| 108 | } | 125 | } |
| 109 | @media screen and (max-width: 500px){ | 126 | @media screen and (max-width: 800px){ |
| 110 | .header_content | 127 | .header_content |
| 111 | { | 128 | { |
| 112 | display: block; | 129 | grid-template-columns: 2fr 1fr; /* on vire la colonne de gauche et on permet au deux autres de "se pousser" si besoin */ |
| 113 | padding: 10px; | 130 | padding: 10px; |
| 114 | } | 131 | } |
| 115 | #header_logo | 132 | .header_left_col |
| 116 | { | 133 | { |
| 117 | display: none; | 134 | display: none; |
| 118 | } | 135 | } |
| 136 | } | ||
| 137 | @media screen and (max-width: 600px){ | ||
| 138 | .header_content | ||
| 139 | { | ||
| 140 | display: block; | ||
| 141 | } | ||
| 119 | } \ No newline at end of file | 142 | } \ No newline at end of file |
diff --git a/public/js/Input.js b/public/js/Input.js index be7cd8d..6c5af10 100644 --- a/public/js/Input.js +++ b/public/js/Input.js | |||
| @@ -54,7 +54,7 @@ class InputText extends InputToggler{ | |||
| 54 | .then(response => response.json()) | 54 | .then(response => response.json()) |
| 55 | .then(data => { | 55 | .then(data => { |
| 56 | if(data.success){ | 56 | if(data.success){ |
| 57 | this.content_elem.innerHTML = this.input_elem.value; | 57 | this.onSuccess(data); |
| 58 | this.close(); | 58 | this.close(); |
| 59 | } | 59 | } |
| 60 | else{ | 60 | else{ |
| @@ -65,12 +65,25 @@ class InputText extends InputToggler{ | |||
| 65 | console.error('Erreur:', error); | 65 | console.error('Erreur:', error); |
| 66 | }); | 66 | }); |
| 67 | } | 67 | } |
| 68 | onSuccess(data){ | ||
| 69 | this.content_elem.innerHTML = this.input_elem.value; | ||
| 70 | } | ||
| 68 | cancel(){ | 71 | cancel(){ |
| 69 | this.input_elem.value = this.content_elem.innerHTML; | 72 | this.input_elem.value = this.content_elem.innerHTML; |
| 70 | super.cancel(); | 73 | super.cancel(); |
| 71 | } | 74 | } |
| 72 | } | 75 | } |
| 73 | 76 | ||
| 77 | class InputTextSocialNetwork extends InputText{ | ||
| 78 | open(){ | ||
| 79 | this.input_elem.value = this.content_elem.parentNode.href; | ||
| 80 | super.open(); | ||
| 81 | } | ||
| 82 | onSuccess(data){ | ||
| 83 | this.content_elem.parentNode.href = this.input_elem.value; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 74 | class InputFile extends InputToggler{ | 87 | class InputFile extends InputToggler{ |
| 75 | constructor(name, options = {}){ | 88 | constructor(name, options = {}){ |
| 76 | super(name, options); | 89 | super(name, options); |
diff --git a/src/controller/HeadFootController.php b/src/controller/HeadFootController.php index d3e75ee..ffa33bc 100644 --- a/src/controller/HeadFootController.php +++ b/src/controller/HeadFootController.php | |||
| @@ -9,6 +9,8 @@ use Doctrine\ORM\EntityManager; | |||
| 9 | 9 | ||
| 10 | class HeadFootController | 10 | class HeadFootController |
| 11 | { | 11 | { |
| 12 | static array $social_networks = ['facebook', 'instagram', 'linkedin', 'github']; // à completer | ||
| 13 | |||
| 12 | static public function setTextData(EntityManager $entityManager, string $request_params, array $json): void | 14 | static public function setTextData(EntityManager $entityManager, string $request_params, array $json): void |
| 13 | { | 15 | { |
| 14 | $params_array = explode('_', $request_params); // header_title, header_description, footer_name, footer_address, footer_email | 16 | $params_array = explode('_', $request_params); // header_title, header_description, footer_name, footer_address, footer_email |
| @@ -20,7 +22,14 @@ class HeadFootController | |||
| 20 | $model = new Model($entityManager); | 22 | $model = new Model($entityManager); |
| 21 | if($model->findWhateverNode('name_node', $params_array[0])){ | 23 | if($model->findWhateverNode('name_node', $params_array[0])){ |
| 22 | $node_data = $model->getNode()->getNodeData(); | 24 | $node_data = $model->getNode()->getNodeData(); |
| 23 | $node_data->updateData($params_array[1], $json['new_text']); // $params_array[1] n'est pas contrôlé | 25 | if(in_array($params_array[1], self::$social_networks)){ |
| 26 | $social = $node_data->getData()['social']; | ||
| 27 | $social[$params_array[1]] = $json['new_text']; | ||
| 28 | $node_data->updateData('social', $social); | ||
| 29 | } | ||
| 30 | else{ | ||
| 31 | $node_data->updateData($params_array[1], $json['new_text']); // $params_array[1] n'est pas contrôlé | ||
| 32 | } | ||
| 24 | $entityManager->flush(); | 33 | $entityManager->flush(); |
| 25 | echo json_encode(['success' => true]); | 34 | echo json_encode(['success' => true]); |
| 26 | } | 35 | } |
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index 47e7208..ed94f1b 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php | |||
| @@ -67,7 +67,7 @@ class NodeData | |||
| 67 | { | 67 | { |
| 68 | $this->data = $data; | 68 | $this->data = $data; |
| 69 | }*/ | 69 | }*/ |
| 70 | public function updateData(string $key, string $value = ''): void | 70 | public function updateData(string $key, string|array $value = ''): void |
| 71 | { | 71 | { |
| 72 | if($value !== ''){ | 72 | if($value !== ''){ |
| 73 | $this->data[$key] = $value; | 73 | $this->data[$key] = $value; |
diff --git a/src/view/FooterBuilder.php b/src/view/FooterBuilder.php index 277de4b..d810170 100644 --- a/src/view/FooterBuilder.php +++ b/src/view/FooterBuilder.php | |||
| @@ -30,15 +30,15 @@ class FooterBuilder extends AbstractBuilder | |||
| 30 | if($_SESSION['admin']) | 30 | if($_SESSION['admin']) |
| 31 | { | 31 | { |
| 32 | // données du footer | 32 | // données du footer |
| 33 | $admin_footer_name = '<input type="text" id="footer_name_input" class="hidden" value="' . htmlspecialchars($name ?? '') . '" size="30"> | 33 | $admin_footer_name = '<input type="text" id="footer_name_input" class="hidden" value="' . htmlspecialchars($name ?? '') . '" placeholder="raison sociale" size="30"> |
| 34 | <img id="footer_name_open" class="action_icon" src="assets/edit.svg" onclick="footer_name.open()"> | 34 | <img id="footer_name_open" class="action_icon" src="assets/edit.svg" onclick="footer_name.open()"> |
| 35 | <img id="footer_name_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_name.submit()"> | 35 | <img id="footer_name_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_name.submit()"> |
| 36 | <img id="footer_name_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_name.cancel()">'; | 36 | <img id="footer_name_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_name.cancel()">'; |
| 37 | $admin_footer_address = '<input type="text" id="footer_address_input" class="hidden" value="' . htmlspecialchars($address ?? '') . '" size="30"> | 37 | $admin_footer_address = '<input type="text" id="footer_address_input" class="hidden" value="' . htmlspecialchars($address ?? '') . '" placeholder="adresse" size="30"> |
| 38 | <img id="footer_address_open" class="action_icon" src="assets/edit.svg" onclick="footer_address.open()"> | 38 | <img id="footer_address_open" class="action_icon" src="assets/edit.svg" onclick="footer_address.open()"> |
| 39 | <img id="footer_address_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_address.submit()"> | 39 | <img id="footer_address_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_address.submit()"> |
| 40 | <img id="footer_address_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_address.cancel()">'; | 40 | <img id="footer_address_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_address.cancel()">'; |
| 41 | $admin_footer_email = '<input type="text" id="footer_email_input" class="hidden" value="' . htmlspecialchars($email ?? '') . '" size="30"> | 41 | $admin_footer_email = '<input type="text" id="footer_email_input" class="hidden" value="' . htmlspecialchars($email ?? '') . '" placeholder="e-mail" size="30"> |
| 42 | <img id="footer_email_open" class="action_icon" src="assets/edit.svg" onclick="footer_email.open()"> | 42 | <img id="footer_email_open" class="action_icon" src="assets/edit.svg" onclick="footer_email.open()"> |
| 43 | <img id="footer_email_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_email.submit()"> | 43 | <img id="footer_email_submit" class="action_icon hidden" src="assets/save.svg" onclick="footer_email.submit()"> |
| 44 | <img id="footer_email_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_email.cancel()">'; | 44 | <img id="footer_email_cancel" class="action_icon hidden" src="assets/close.svg" onclick="footer_email.cancel()">'; |
diff --git a/src/view/HeaderBuilder.php b/src/view/HeaderBuilder.php index 4651418..4fbf941 100644 --- a/src/view/HeaderBuilder.php +++ b/src/view/HeaderBuilder.php | |||
| @@ -48,13 +48,6 @@ class HeaderBuilder extends AbstractBuilder | |||
| 48 | $header_background_name = $node_data->getAssetByRole('header_background')?->getFileName(); | 48 | $header_background_name = $node_data->getAssetByRole('header_background')?->getFileName(); |
| 49 | $header_background = $header_background_name ? Asset::USER_PATH . $header_background_name : ''; | 49 | $header_background = $header_background_name ? Asset::USER_PATH . $header_background_name : ''; |
| 50 | 50 | ||
| 51 | $keys = array_keys($social); | ||
| 52 | $social_networks = ''; | ||
| 53 | foreach($keys as $one_key){ | ||
| 54 | $social_networks .= '<a href="' . $social[$one_key] . '" target="_blank" rel="noopener noreferrer"> | ||
| 55 | <img src="assets/' . $one_key . '.svg" alt="' . $one_key . '_alt"></a>'; | ||
| 56 | } | ||
| 57 | |||
| 58 | // boutons mode admin | 51 | // boutons mode admin |
| 59 | if($_SESSION['admin']){ | 52 | if($_SESSION['admin']){ |
| 60 | // assets dans classe header_additional_inputs | 53 | // assets dans classe header_additional_inputs |
| @@ -74,29 +67,40 @@ class HeaderBuilder extends AbstractBuilder | |||
| 74 | <img id="header_logo_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_logo.submit()"> | 67 | <img id="header_logo_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_logo.submit()"> |
| 75 | <img id="header_logo_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_logo.cancel()">'; | 68 | <img id="header_logo_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_logo.cancel()">'; |
| 76 | // texte dans classe header_content | 69 | // texte dans classe header_content |
| 77 | $admin_header_title = '<input type="text" id="header_title_input" class="hidden" value="' . htmlspecialchars($title ?? '') . '" size="30"> | 70 | $admin_header_title = '<input type="text" id="header_title_input" class="hidden" value="' . htmlspecialchars($title ?? '') . '" placeholder="nom du site web" size="30"> |
| 78 | <img id="header_title_open" class="action_icon" src="assets/edit.svg" onclick="header_title.open()"> | 71 | <img id="header_title_open" class="action_icon" src="assets/edit.svg" onclick="header_title.open()"> |
| 79 | <img id="header_title_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_title.submit()"> | 72 | <img id="header_title_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_title.submit()"> |
| 80 | <img id="header_title_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_title.cancel()">'; | 73 | <img id="header_title_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_title.cancel()">'; |
| 81 | $admin_header_description = '<input type="text" id="header_description_input" class="hidden" value="' . htmlspecialchars($description ?? '') . '" size="30"> | 74 | $admin_header_description = '<input type="text" id="header_description_input" class="hidden" value="' . htmlspecialchars($description ?? '') . '" placeholder="sous-titre ou description" size="30"> |
| 82 | <img id="header_description_open" class="action_icon" src="assets/edit.svg" onclick="header_description.open()"> | 75 | <img id="header_description_open" class="action_icon" src="assets/edit.svg" onclick="header_description.open()"> |
| 83 | <img id="header_description_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_description.submit()"> | 76 | <img id="header_description_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_description.submit()"> |
| 84 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancel()">'; | 77 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancel()">'; |
| 85 | 78 | ||
| 86 | // icônes réseaux sociaux | 79 | // icônes réseaux sociaux |
| 87 | $social_networks_inputs = '<div id="header_social_input" class="hidden">'; | 80 | $header_social_flex_direction = 'column'; |
| 88 | foreach($keys as $one_key){ | 81 | $admin_social_networks = []; |
| 82 | foreach(array_keys($social) as $one_key){ | ||
| 83 | //<input type="file" id="header_' . $one_key . '_input" class="hidden" accept="image/svg+xml, image/png, image/jpeg, image/gif, image/webp, image/tiff"> | ||
| 84 | // sinon plutôt qu'on bouton nouveau réseau, utiliser le foreach avec HeadFootController::$social_networks pour tous les parcourir et placer des cases à cocher | ||
| 85 | // les icones seront ajoutées par mes soins | ||
| 86 | $admin_social_networks[$one_key] = '<input type="text" id="header_' . $one_key . '_input" class="hidden" value="' . $social[$one_key] . '" placeholder="nom du réseau social" size="30"> | ||
| 87 | <img id="header_' . $one_key . '_open" class="action_icon" src="assets/edit.svg" onclick="header_' . $one_key . '.open()"> | ||
| 88 | <img id="header_' . $one_key . '_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_' . $one_key . '.submit()"> | ||
| 89 | <img id="header_' . $one_key . '_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_' . $one_key . '.cancel()"> | ||
| 90 | <script>let header_' . $one_key . ' = new InputTextSocialNetwork(\'header_' . $one_key . '\');</script>'; | ||
| 91 | } | ||
| 92 | //$admin_social_new_network = '<div>nouveau réseau</div>'; | ||
| 93 | $admin_social_new_network = ''; | ||
| 94 | |||
| 95 | /*$social_networks_inputs = '<div id="header_social_input" class="hidden">'; | ||
| 96 | foreach(array_keys($social) as $one_key){ | ||
| 89 | $social_networks_inputs .= '<div> | 97 | $social_networks_inputs .= '<div> |
| 90 | <input type="text" placeholder="nom du réseau social"> | 98 | <input type="text" placeholder="nom du réseau social"> |
| 91 | <input type="text" placeholder="lien https://..."> | 99 | <input type="text" placeholder="lien https://..."> |
| 92 | <input type="file"> | 100 | <input type="file"> |
| 93 | </div>'; | 101 | </div>'; |
| 94 | } | 102 | } |
| 95 | $social_networks_inputs .= '</div>'; | 103 | $social_networks_inputs .= '</div>';*/ |
| 96 | /*$admin_social_networks = $social_networks_inputs . '<img id="header_social_open" class="action_icon" src="assets/edit.svg" onclick="header_social.open()"> | ||
| 97 | <div id="header_social_submit" class="hidden"></div> | ||
| 98 | <img id="header_social_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_social.cancel()">';*/ | ||
| 99 | $admin_social_networks = ''; | ||
| 100 | } | 104 | } |
| 101 | else{ | 105 | else{ |
| 102 | $admin_favicon = ''; | 106 | $admin_favicon = ''; |
| @@ -104,7 +108,12 @@ class HeaderBuilder extends AbstractBuilder | |||
| 104 | $admin_header_logo = ''; | 108 | $admin_header_logo = ''; |
| 105 | $admin_header_title = ''; | 109 | $admin_header_title = ''; |
| 106 | $admin_header_description = ''; | 110 | $admin_header_description = ''; |
| 107 | $admin_social_networks = ''; | 111 | $header_social_flex_direction = 'row'; |
| 112 | $admin_social_networks = []; | ||
| 113 | foreach(array_keys($social) as $one_key){ | ||
| 114 | $admin_social_networks[$one_key] = ''; | ||
| 115 | } | ||
| 116 | $admin_social_new_network = ''; | ||
| 108 | } | 117 | } |
| 109 | 118 | ||
| 110 | ob_start(); | 119 | ob_start(); |
diff --git a/src/view/templates/header.php b/src/view/templates/header.php index 9c74f9b..89cdd4b 100644 --- a/src/view/templates/header.php +++ b/src/view/templates/header.php | |||
| @@ -35,10 +35,15 @@ | |||
| 35 | </div> | 35 | </div> |
| 36 | <div class="header_right_col"> | 36 | <div class="header_right_col"> |
| 37 | <div id="header_social"> | 37 | <div id="header_social"> |
| 38 | <div id="header_social_content"> | 38 | <div id="header_social_content" style="flex-direction: <?= $header_social_flex_direction ?>;"> |
| 39 | <?= $social_networks ?> | 39 | <?php foreach(array_keys($social) as $one_key){ ?> |
| 40 | <div id="header_<?= $one_key ?>"> | ||
| 41 | <a href="<?= $social[$one_key] ?>" target="_blank" rel="noopener noreferrer"><img id="header_<?= $one_key ?>_content" src="assets/<?= $one_key ?>.svg" alt="<?= $one_key ?>_alt"></a> | ||
| 42 | <?= $admin_social_networks[$one_key] ?> | ||
| 43 | </div> | ||
| 44 | <?php } ?> | ||
| 45 | <?= $admin_social_new_network ?> | ||
| 40 | </div> | 46 | </div> |
| 41 | <?= $admin_social_networks ?> | ||
| 42 | </div> | 47 | </div> |
| 43 | <?= $breadcrumb ?? '' ?> | 48 | <?= $breadcrumb ?? '' ?> |
| 44 | </div> | 49 | </div> |
| @@ -50,7 +55,6 @@ | |||
| 50 | let header_logo = new InputFile('header_logo'); | 55 | let header_logo = new InputFile('header_logo'); |
| 51 | let header_title = new InputText('header_title'); | 56 | let header_title = new InputText('header_title'); |
| 52 | let header_description = new InputText('header_description'); | 57 | let header_description = new InputText('header_description'); |
| 53 | let header_social = new InputToggler('header_social'); | ||
| 54 | </script> | 58 | </script> |
| 55 | <?php } ?> | 59 | <?php } ?> |
| 56 | </header> \ No newline at end of file | 60 | </header> \ No newline at end of file |
