From 46d3c239a7ad2b00e86373f2fd0e829fdcba57f7 Mon Sep 17 00:00:00 2001 From: polo Date: Sat, 1 Nov 2025 17:54:22 +0100 Subject: =?UTF-8?q?utilisation=20des=20ic=C3=B4nes=20SVG=20=20du=20d=C3=A9?= =?UTF-8?q?p=C3=B4t=20twbs/bootstrap-icons=20pour=20les=20r=C3=A9seaux=20s?= =?UTF-8?q?ociaux,=20am=C3=A9lioration=20du=20CSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 11 ++++++----- bin/install_tinymce_lang.php | 9 +++++++-- composer.json | 20 +++++++++++--------- public/assets/facebook-nb.svg | 1 - public/assets/facebook.svg | 37 ------------------------------------- public/assets/github-nb.svg | 1 - public/assets/github.svg | 37 ------------------------------------- public/assets/instagram-nb.svg | 1 - public/assets/instagram.svg | 37 ------------------------------------- public/assets/linkedin-nb.svg | 1 - public/assets/linkedin.svg | 37 ------------------------------------- public/css/body.css | 2 +- public/css/head.css | 30 ++++++++++++++++++++++++++---- public/css/menu.css | 6 ++---- public/css/new_page.css | 7 +++---- public/js/main.js | 4 ++-- src/model/entities/NodeData.php | 2 +- src/view/AbstractBuilder.php | 17 +++++++++++++++++ src/view/HeadBuilder.php | 6 ++---- src/view/HeaderBuilder.php | 19 ++++++++++--------- src/view/templates/header.php | 3 ++- src/view/templates/new_page.php | 2 +- 22 files changed, 91 insertions(+), 199 deletions(-) delete mode 100644 public/assets/facebook-nb.svg delete mode 100644 public/assets/facebook.svg delete mode 100644 public/assets/github-nb.svg delete mode 100644 public/assets/github.svg delete mode 100644 public/assets/instagram-nb.svg delete mode 100644 public/assets/instagram.svg delete mode 100644 public/assets/linkedin-nb.svg delete mode 100644 public/assets/linkedin.svg diff --git a/.gitignore b/.gitignore index e612f8c..a343b29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ vendor/ config/config.ini -public/js/tinymce/ -public/js/tinymce-langs/ -public/user_data/ -public/images/ -public/images-mini/ +public/js/tinymce +public/js/tinymce-langs +public/icons +public/user_data +public/images +public/images-mini composer.lock diff --git a/bin/install_tinymce_lang.php b/bin/install_tinymce_lang.php index 4950cc1..e76ec91 100644 --- a/bin/install_tinymce_lang.php +++ b/bin/install_tinymce_lang.php @@ -2,7 +2,8 @@ // bin/install_tinymce_lang.php function installTinymceLang(string $lang = 'fr_FR'): void { - $dest = 'public/js/tinymce-langs/' . $lang . '.js'; + $path = 'public/js/tinymce-langs'; + $dest = $lang . '.js'; $link = "https://cdn.jsdelivr.net/npm/tinymce-lang/langs/" . $lang . ".min.js"; $curl = curl_init($link); @@ -10,8 +11,12 @@ function installTinymceLang(string $lang = 'fr_FR'): void echo "Erreur : Impossible d'initialiser cURL.\n"; return; } + + if(!is_dir($path)){ + mkdir($path, 0755, true); + } - $file = @fopen($dest, 'w+'); // @masque l'erreur pour la traiter soi-même + $file = @fopen($path . '/' . $dest, 'w+'); // @masque l'erreur pour la traiter soi-même if(!$file){ // erreur écriture fichier echo "Erreur : Impossible d'ouvrir le fichier $dest pour l'écriture.\n"; return; diff --git a/composer.json b/composer.json index 5435c0e..a661963 100644 --- a/composer.json +++ b/composer.json @@ -2,24 +2,26 @@ "name": "ordipolo/cms", "description": "CMS maison avec PHP, doctrine et tinMCE", "require": { - "doctrine/dbal": "^4.2", - "doctrine/orm": "^3.3", - "symfony/cache": "^7.2", + "doctrine/dbal": "^4.3", + "doctrine/orm": "^3.5", + "symfony/cache": "^7.3", "composer": "*", "htmlawed/htmlawed": "^1.2", - "tinymce/tinymce": "^7.7", - "phpmailer/phpmailer": "^6.10", - "symfony/http-foundation": "^7.3" + "tinymce/tinymce": "^8.2", + "phpmailer/phpmailer": "^7.0", + "symfony/http-foundation": "^7.3", + "twbs/bootstrap-icons": "^1.13" }, "scripts": { "post-install-cmd": [ "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/tinymce/tinymce public/js/tinymce", - "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_tinymce_lang.php fr_FR" - + "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_tinymce_lang.php fr_FR", + "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/twbs/bootstrap-icons/icons public/icons" ], "post-update-cmd": [ "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/tinymce/tinymce public/js/tinymce", - "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_tinymce_lang.php fr_FR" + "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/install_tinymce_lang.php fr_FR", + "PHP_PATH=${PHP_PATH:-php} && $PHP_PATH bin/copy_directory.php vendor/twbs/bootstrap-icons/icons public/icons" ] }, "authors": [ diff --git a/public/assets/facebook-nb.svg b/public/assets/facebook-nb.svg deleted file mode 100644 index 543537c..0000000 --- a/public/assets/facebook-nb.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/assets/facebook.svg b/public/assets/facebook.svg deleted file mode 100644 index d09d296..0000000 --- a/public/assets/facebook.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - diff --git a/public/assets/github-nb.svg b/public/assets/github-nb.svg deleted file mode 100644 index fdda08a..0000000 --- a/public/assets/github-nb.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/assets/github.svg b/public/assets/github.svg deleted file mode 100644 index 69a8733..0000000 --- a/public/assets/github.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - diff --git a/public/assets/instagram-nb.svg b/public/assets/instagram-nb.svg deleted file mode 100644 index c51ee39..0000000 --- a/public/assets/instagram-nb.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/assets/instagram.svg b/public/assets/instagram.svg deleted file mode 100644 index feb8ae8..0000000 --- a/public/assets/instagram.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - diff --git a/public/assets/linkedin-nb.svg b/public/assets/linkedin-nb.svg deleted file mode 100644 index 42449fc..0000000 --- a/public/assets/linkedin-nb.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/assets/linkedin.svg b/public/assets/linkedin.svg deleted file mode 100644 index 0cb2381..0000000 --- a/public/assets/linkedin.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - diff --git a/public/css/body.css b/public/css/body.css index 57afe92..1f6ef7e 100644 --- a/public/css/body.css +++ b/public/css/body.css @@ -47,7 +47,7 @@ main } .hidden { - display: none; + display: none; /* attention, conflit si la même balise a déjà une règle display */ } section { diff --git a/public/css/head.css b/public/css/head.css index 1844f93..1b805fe 100644 --- a/public/css/head.css +++ b/public/css/head.css @@ -86,12 +86,34 @@ header a display: flex; gap: 4px; flex-wrap: wrap; + margin: 4px; } -#header_social_content a img +#header_social_content > div{ + margin: auto; + background-color: #ffffff7f; +} +#header_social_content a:hover +{ + background-color: yellow; +} +#header_social_content > div, #header_social_content a:hover +{ + border-radius: 10px; +} +#header_social_content a +{ + padding: 2px; + display: inline-flex; /* flex pour que la taille de élément dépende de ses enfants, inline pour que este inline */ + vertical-align: bottom; +} +#header_social_content a svg +{ + width: 24px; + height: 24px; +} +.svg_fill_red { - width: 28px; - background-color: #ffffffb3; - border-radius: 50%; + fill: #dd3333; } #header_social_content .action_icon { diff --git a/public/css/menu.css b/public/css/menu.css index 0dfb840..aa8fde3 100644 --- a/public/css/menu.css +++ b/public/css/menu.css @@ -1,9 +1,7 @@ /*-- page "Menu et chemins" uniquement --*/ -.menu -{ - padding: 0 20px; -} +/*.menu +{}*/ .menu_edit_entry { margin-left: 29px; diff --git a/public/css/new_page.css b/public/css/new_page.css index 6d6fe43..80c7e1d 100644 --- a/public/css/new_page.css +++ b/public/css/new_page.css @@ -1,8 +1,7 @@ /*-- page "Nouvelle page" uniquement --*/ -.new_page -{ - padding: 0 15px; -} + +/*.new_page +{}*/ .new_page .form_zone { background-color: white; diff --git a/public/js/main.js b/public/js/main.js index 39a31f5..42bae70 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -207,8 +207,8 @@ function checkSocialNetwork(id){ method: 'POST', onSuccess: (data) => { checkbox.checked = data.checked; - document.getElementById(id + '_content').src = 'assets/' + id.split('_')[1] + (data.checked ? '': '-nb') + '.svg'; // assets/facebook.svg ou assets/facebook-nb.svg - toastNotify('Le logo "' + id.split('_')[1] + '" ' + (data.checked ? 'sera' : 'ne sera pas') + ' affiché aux visiteurs.'); + document.getElementById(id + '_content').classList.toggle('svg_fill_red', data.checked); + toastNotify('Le logo "' + id.split('_')[1] + '" ' + (data.checked ? 'sera' : 'ne sera pas') + ' affiché.'); }, onFailure: (data) => { console.error(data.message || "Erreur serveur"); 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 #[ORM\Table(name: TABLE_PREFIX . "node_data")] class NodeData { - static array $social_networks = ['facebook', 'instagram', 'linkedin', 'github']; // à completer + static array $social_networks = ['facebook', 'instagram', 'whatsapp', 'snapchat', 'tiktok', 'linkedin', 'github']; // à completer #[ORM\Id] #[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 { $this->html .= $html; } + + protected function insertSVG(string $path, array $attributes = []): string + { + $svg = file_get_contents($path); + + // modification des attributs + if(!empty($attributes)){ + $dom = new DOMDocument(); + $dom->loadXML($svg); + $svg_elem = $dom->documentElement; + foreach($attributes as $key => $value){ + $svg_elem->setAttribute($key, $value); + } + $svg = $dom->saveXML($svg_elem); + } + return $svg; + } } \ 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 $page = Model::$page_path->getLast(); $css = ''; - foreach($page->getCSS() as $name) - { + foreach($page->getCSS() as $name){ $css .= '' . "\n"; } $js = ''; - foreach($page->getJS() as $name) - { + foreach($page->getJS() as $name){ $js .= '' . "\n"; } 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 { private ?Node $nav = null; private ?Node $breadcrumb = null; + const ICON_PATH = 'icons/'; public function __construct(Node $node) { @@ -55,7 +56,6 @@ class HeaderBuilder extends AbstractBuilder // assets dans classe header_additional_inputs $admin_favicon = ' - '; $admin_background = ' @@ -80,7 +80,6 @@ class HeaderBuilder extends AbstractBuilder '; // icônes réseaux sociaux - $header_social_flex_direction = 'column'; // boucle sur la liste complète de réseaux sociaux foreach(NodeData::$social_networks as $network){ $checked = (isset($social_show[$network]) && $social_show[$network]) ? 'checked' : ''; @@ -88,15 +87,16 @@ class HeaderBuilder extends AbstractBuilder $social_networks .= '
- - '. $network . '_alt - - + ' + . $this->insertSVG(self::ICON_PATH . $network . '.svg', ['id' => 'header_' . $network . '_content', 'class' => ($checked ? 'svg_fill_red' : '')]) + . ' + - +
'; + // {'has_content': false} => InputToggle ne gèrera pas cette balise } } else{ @@ -106,14 +106,15 @@ class HeaderBuilder extends AbstractBuilder $admin_header_title = ''; $admin_header_description = ''; - $header_social_flex_direction = 'row'; if(isset($social_show)){ // boucle sur les réseaux sociaux "activés" foreach(array_keys($social_show) as $network){ if($social_show[$network]){ $href = (isset($social[$network]) && $social[$network] !== '') ? 'href="' . $social[$network] . '"' : ''; $social_networks .= '
- '. $network . '_alt + ' + . $this->insertSVG(self::ICON_PATH . $network . '.svg', ['id' => 'header_' . $network . '_content','class' => 'svg_fill_red']) + . '
'; } } 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 @@
-
+
@@ -44,6 +44,7 @@