diff options
| author | polo <ordipolo@gmx.fr> | 2025-11-01 17:54:22 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-11-01 17:54:22 +0100 |
| commit | 46d3c239a7ad2b00e86373f2fd0e829fdcba57f7 (patch) | |
| tree | 054d8e5d3c43bcfc587bb5308e6d2a444eec54bf /src | |
| parent | f33135c5d36d0e747d07773919ae0bc84cbceac1 (diff) | |
| download | cms-46d3c239a7ad2b00e86373f2fd0e829fdcba57f7.tar.gz cms-46d3c239a7ad2b00e86373f2fd0e829fdcba57f7.tar.bz2 cms-46d3c239a7ad2b00e86373f2fd0e829fdcba57f7.zip | |
utilisation des icônes SVG du dépôt twbs/bootstrap-icons pour les réseaux sociaux, amélioration du CSS
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/entities/NodeData.php | 2 | ||||
| -rw-r--r-- | src/view/AbstractBuilder.php | 17 | ||||
| -rw-r--r-- | src/view/HeadBuilder.php | 6 | ||||
| -rw-r--r-- | src/view/HeaderBuilder.php | 19 | ||||
| -rw-r--r-- | src/view/templates/header.php | 3 | ||||
| -rw-r--r-- | src/view/templates/new_page.php | 2 |
6 files changed, 33 insertions, 16 deletions
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index b0aaef9..85cc0a6 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php | |||
| @@ -13,7 +13,7 @@ use Doctrine\Common\Collections\Collection; // interface | |||
| 13 | #[ORM\Table(name: TABLE_PREFIX . "node_data")] | 13 | #[ORM\Table(name: TABLE_PREFIX . "node_data")] |
| 14 | class NodeData | 14 | class NodeData |
| 15 | { | 15 | { |
| 16 | static array $social_networks = ['facebook', 'instagram', 'linkedin', 'github']; // à completer | 16 | static array $social_networks = ['facebook', 'instagram', 'whatsapp', 'snapchat', 'tiktok', 'linkedin', 'github']; // à completer |
| 17 | 17 | ||
| 18 | #[ORM\Id] | 18 | #[ORM\Id] |
| 19 | #[ORM\GeneratedValue] | 19 | #[ORM\GeneratedValue] |
diff --git a/src/view/AbstractBuilder.php b/src/view/AbstractBuilder.php index 3d315b1..b9a1d7f 100644 --- a/src/view/AbstractBuilder.php +++ b/src/view/AbstractBuilder.php | |||
| @@ -57,4 +57,21 @@ abstract class AbstractBuilder | |||
| 57 | { | 57 | { |
| 58 | $this->html .= $html; | 58 | $this->html .= $html; |
| 59 | } | 59 | } |
| 60 | |||
| 61 | protected function insertSVG(string $path, array $attributes = []): string | ||
| 62 | { | ||
| 63 | $svg = file_get_contents($path); | ||
| 64 | |||
| 65 | // modification des attributs | ||
| 66 | if(!empty($attributes)){ | ||
| 67 | $dom = new DOMDocument(); | ||
| 68 | $dom->loadXML($svg); | ||
| 69 | $svg_elem = $dom->documentElement; | ||
| 70 | foreach($attributes as $key => $value){ | ||
| 71 | $svg_elem->setAttribute($key, $value); | ||
| 72 | } | ||
| 73 | $svg = $dom->saveXML($svg_elem); | ||
| 74 | } | ||
| 75 | return $svg; | ||
| 76 | } | ||
| 60 | } \ No newline at end of file | 77 | } \ No newline at end of file |
diff --git a/src/view/HeadBuilder.php b/src/view/HeadBuilder.php index e3d620c..fa0f063 100644 --- a/src/view/HeadBuilder.php +++ b/src/view/HeadBuilder.php | |||
| @@ -18,14 +18,12 @@ class HeadBuilder extends AbstractBuilder | |||
| 18 | $page = Model::$page_path->getLast(); | 18 | $page = Model::$page_path->getLast(); |
| 19 | 19 | ||
| 20 | $css = ''; | 20 | $css = ''; |
| 21 | foreach($page->getCSS() as $name) | 21 | foreach($page->getCSS() as $name){ |
| 22 | { | ||
| 23 | $css .= '<link rel="stylesheet" href="' . self::versionedFileURL('css', $name) . '">' . "\n"; | 22 | $css .= '<link rel="stylesheet" href="' . self::versionedFileURL('css', $name) . '">' . "\n"; |
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | $js = ''; | 25 | $js = ''; |
| 27 | foreach($page->getJS() as $name) | 26 | foreach($page->getJS() as $name){ |
| 28 | { | ||
| 29 | $js .= '<script src="' . self::versionedFileURL('js', $name) . '"></script>' . "\n"; | 27 | $js .= '<script src="' . self::versionedFileURL('js', $name) . '"></script>' . "\n"; |
| 30 | } | 28 | } |
| 31 | 29 | ||
diff --git a/src/view/HeaderBuilder.php b/src/view/HeaderBuilder.php index 1339659..266aab8 100644 --- a/src/view/HeaderBuilder.php +++ b/src/view/HeaderBuilder.php | |||
| @@ -11,6 +11,7 @@ class HeaderBuilder extends AbstractBuilder | |||
| 11 | { | 11 | { |
| 12 | private ?Node $nav = null; | 12 | private ?Node $nav = null; |
| 13 | private ?Node $breadcrumb = null; | 13 | private ?Node $breadcrumb = null; |
| 14 | const ICON_PATH = 'icons/'; | ||
| 14 | 15 | ||
| 15 | public function __construct(Node $node) | 16 | public function __construct(Node $node) |
| 16 | { | 17 | { |
| @@ -55,7 +56,6 @@ class HeaderBuilder extends AbstractBuilder | |||
| 55 | // assets dans classe header_additional_inputs | 56 | // assets dans classe header_additional_inputs |
| 56 | $admin_favicon = '<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"> | 57 | $admin_favicon = '<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"> |
| 57 | <button id="head_favicon_open" onclick="head_favicon.open()"><img id="head_favicon_content" class="action_icon"> Favicon</button> | 58 | <button id="head_favicon_open" onclick="head_favicon.open()"><img id="head_favicon_content" class="action_icon"> Favicon</button> |
| 58 | <script>document.getElementById("head_favicon_content").src = window.Config.favicon;</script> | ||
| 59 | <img id="head_favicon_submit" class="action_icon hidden" src="assets/save.svg" onclick="head_favicon.submit()"> | 59 | <img id="head_favicon_submit" class="action_icon hidden" src="assets/save.svg" onclick="head_favicon.submit()"> |
| 60 | <img id="head_favicon_cancel" class="action_icon hidden" src="assets/close.svg" onclick="head_favicon.cancel()">'; | 60 | <img id="head_favicon_cancel" class="action_icon hidden" src="assets/close.svg" onclick="head_favicon.cancel()">'; |
| 61 | $admin_background = '<input type="file" id="header_background_input" class="hidden" accept="image/png, image/jpeg, image/gif, image/webp, image/tiff"> | 61 | $admin_background = '<input type="file" id="header_background_input" class="hidden" accept="image/png, image/jpeg, image/gif, image/webp, image/tiff"> |
| @@ -80,7 +80,6 @@ class HeaderBuilder extends AbstractBuilder | |||
| 80 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancel()">'; | 80 | <img id="header_description_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_description.cancel()">'; |
| 81 | 81 | ||
| 82 | // icônes réseaux sociaux | 82 | // icônes réseaux sociaux |
| 83 | $header_social_flex_direction = 'column'; | ||
| 84 | // boucle sur la liste complète de réseaux sociaux | 83 | // boucle sur la liste complète de réseaux sociaux |
| 85 | foreach(NodeData::$social_networks as $network){ | 84 | foreach(NodeData::$social_networks as $network){ |
| 86 | $checked = (isset($social_show[$network]) && $social_show[$network]) ? 'checked' : ''; | 85 | $checked = (isset($social_show[$network]) && $social_show[$network]) ? 'checked' : ''; |
| @@ -88,15 +87,16 @@ class HeaderBuilder extends AbstractBuilder | |||
| 88 | 87 | ||
| 89 | $social_networks .= '<div id="header_' . $network . '"> | 88 | $social_networks .= '<div id="header_' . $network . '"> |
| 90 | <input type="checkbox" onclick="checkSocialNetwork(\'header_' . $network . '\')" ' . $checked . '> | 89 | <input type="checkbox" onclick="checkSocialNetwork(\'header_' . $network . '\')" ' . $checked . '> |
| 91 | <a ' . $href . ' target="_blank" rel="noopener noreferrer"> | 90 | <a ' . $href . ' target="_blank" rel="noopener noreferrer">' |
| 92 | <img id="header_' . $network . '_content" src="assets/' . $network . ($checked ? '' : '-nb') . '.svg" alt="'. $network . '_alt"> | 91 | . $this->insertSVG(self::ICON_PATH . $network . '.svg', ['id' => 'header_' . $network . '_content', 'class' => ($checked ? 'svg_fill_red' : '')]) |
| 93 | </a> | 92 | . '</a> |
| 94 | <input type="text" id="header_' . $network . '_input" class="hidden" value="' . ($social[$network] ?? "") . '" placeholder="nom du réseau social" size="30"> | 93 | <input type="text" id="header_' . $network . '_input" class="hidden" value="' . ($social[$network] ?? "") . '" placeholder="lien http://..." size="30"> |
| 95 | <img id="header_' . $network . '_open" class="action_icon" src="assets/edit.svg" onclick="header_' . $network . '.open()"> | 94 | <img id="header_' . $network . '_open" class="action_icon" src="assets/edit.svg" onclick="header_' . $network . '.open()"> |
| 96 | <img id="header_' . $network . '_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_' . $network . '.submit()"> | 95 | <img id="header_' . $network . '_submit" class="action_icon hidden" src="assets/save.svg" onclick="header_' . $network . '.submit()"> |
| 97 | <img id="header_' . $network . '_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_' . $network . '.cancel()"> | 96 | <img id="header_' . $network . '_cancel" class="action_icon hidden" src="assets/close.svg" onclick="header_' . $network . '.cancel()"> |
| 98 | <script>let header_' . $network . ' = new InputTextSocialNetwork(\'header_' . $network . '\');</script> | 97 | <script>let header_' . $network . ' = new InputTextSocialNetwork(\'header_' . $network . '\', {\'has_content\': false});</script> |
| 99 | </div>'; | 98 | </div>'; |
| 99 | // {'has_content': false} => InputToggle ne gèrera pas cette balise | ||
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | else{ | 102 | else{ |
| @@ -106,14 +106,15 @@ class HeaderBuilder extends AbstractBuilder | |||
| 106 | $admin_header_title = ''; | 106 | $admin_header_title = ''; |
| 107 | $admin_header_description = ''; | 107 | $admin_header_description = ''; |
| 108 | 108 | ||
| 109 | $header_social_flex_direction = 'row'; | ||
| 110 | if(isset($social_show)){ | 109 | if(isset($social_show)){ |
| 111 | // boucle sur les réseaux sociaux "activés" | 110 | // boucle sur les réseaux sociaux "activés" |
| 112 | foreach(array_keys($social_show) as $network){ | 111 | foreach(array_keys($social_show) as $network){ |
| 113 | if($social_show[$network]){ | 112 | if($social_show[$network]){ |
| 114 | $href = (isset($social[$network]) && $social[$network] !== '') ? 'href="' . $social[$network] . '"' : ''; | 113 | $href = (isset($social[$network]) && $social[$network] !== '') ? 'href="' . $social[$network] . '"' : ''; |
| 115 | $social_networks .= '<div id="header_' . $network . '"> | 114 | $social_networks .= '<div id="header_' . $network . '"> |
| 116 | <a ' . $href . ' target="_blank" rel="noopener noreferrer"><img id="header_' . $network . '_content" src="assets/' . $network . '.svg" alt="'. $network . '_alt"></a> | 115 | <a ' . $href . ' target="_blank" rel="noopener noreferrer">' |
| 116 | . $this->insertSVG(self::ICON_PATH . $network . '.svg', ['id' => 'header_' . $network . '_content','class' => 'svg_fill_red']) | ||
| 117 | . '</a> | ||
| 117 | </div>'; | 118 | </div>'; |
| 118 | } | 119 | } |
| 119 | } | 120 | } |
diff --git a/src/view/templates/header.php b/src/view/templates/header.php index 4c39cfd..a2d472d 100644 --- a/src/view/templates/header.php +++ b/src/view/templates/header.php | |||
| @@ -35,7 +35,7 @@ | |||
| 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" style="flex-direction: <?= $header_social_flex_direction ?>;"> | 38 | <div id="header_social_content"> |
| 39 | <?= $social_networks ?> | 39 | <?= $social_networks ?> |
| 40 | </div> | 40 | </div> |
| 41 | </div> | 41 | </div> |
| @@ -44,6 +44,7 @@ | |||
| 44 | </div> | 44 | </div> |
| 45 | <?php if($_SESSION['admin']){ ?> | 45 | <?php if($_SESSION['admin']){ ?> |
| 46 | <script> | 46 | <script> |
| 47 | document.getElementById("head_favicon_content").src = window.Config.favicon; | ||
| 47 | let head_favicon = new InputFileFavicon('head_favicon'); | 48 | let head_favicon = new InputFileFavicon('head_favicon'); |
| 48 | let header_background = new InputFileHeaderBackground('header_background'); | 49 | let header_background = new InputFileHeaderBackground('header_background'); |
| 49 | let header_logo = new InputFile('header_logo'); | 50 | let header_logo = new InputFile('header_logo'); |
diff --git a/src/view/templates/new_page.php b/src/view/templates/new_page.php index 1756a78..7bf4c01 100644 --- a/src/view/templates/new_page.php +++ b/src/view/templates/new_page.php | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | <input type="hidden" name="new_page_hidden"> | 20 | <input type="hidden" name="new_page_hidden"> |
| 21 | <p> | 21 | <p> |
| 22 | <label class="label_textarea" for="page_description">Description qui apparaît sous le titre dans les moteurs de recherche</label> | 22 | <label class="label_textarea" for="page_description">Description qui apparaît sous le titre dans les moteurs de recherche</label> |
| 23 | <textarea id="page_description" name="page_description" cols="40" rows="3" placeholder="ex: nous faisons ceci et cela, etc"></textarea> | 23 | <textarea id="page_description" name="page_description" cols="35" rows="3" placeholder="ex: nous faisons ceci et cela, etc"></textarea> |
| 24 | </p> | 24 | </p> |
| 25 | <input type="submit" value="Créer la page"> | 25 | <input type="submit" value="Créer la page"> |
| 26 | </form> | 26 | </form> |
