lumo:creation_plugin_dokuwiki_namespacelogo:accueil
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| lumo:creation_plugin_dokuwiki_namespacelogo:accueil [2026/03/16 17:24] – estro | lumo:creation_plugin_dokuwiki_namespacelogo:accueil [2026/03/19 07:20] (Version actuelle) – estro | ||
|---|---|---|---|
| Ligne 2: | Ligne 2: | ||
| ---- | ---- | ||
| [[../ | [[../ | ||
| + | <adm danger Créer les fichiers> | ||
| + | Création d'un dossier pour y créer les fichiers de définition du " | ||
| + | <code bash> | ||
| + | cd / | ||
| + | mkdir namespacelogo | ||
| + | cd namespacelogo | ||
| + | touch plugin.info.txt action.php helper.php style.less | ||
| + | chmod 644 *.php *.less | ||
| + | chmod 755 ../ | ||
| + | </ | ||
| + | </ | ||
| <adm note plugin.info.txt> | <adm note plugin.info.txt> | ||
| < | < | ||
| Ligne 10: | Ligne 20: | ||
| date | date | ||
| name | name | ||
| - | desc | + | desc |
| </ | </ | ||
| </ | </ | ||
| Ligne 19: | Ligne 29: | ||
| * @license | * @license | ||
| * @author | * @author | ||
| + | | ||
| + | * Plugin DokuWiki pour afficher un logo par namespace | ||
| + | * Fonctionnalités : | ||
| + | * - Support de multiples formats (png, jpg, jpeg, gif, svg) | ||
| + | * - Fallback hiérarchique (cherche dans les namespaces parents) | ||
| + | * - Fallback vers le logo global si aucun logo trouvé | ||
| */ | */ | ||
| class action_plugin_namespacelogo extends DokuWiki_Action_Plugin { | class action_plugin_namespacelogo extends DokuWiki_Action_Plugin { | ||
| + | |||
| + | /** | ||
| + | * Formats d' | ||
| + | */ | ||
| + | protected $supportedFormats = [' | ||
| /** | /** | ||
| Ligne 40: | Ligne 61: | ||
| $ns = getNS($ID); | $ns = getNS($ID); | ||
| | | ||
| - | // Si pas de namespace (racine), on utilise | + | // Trouver |
| - | if (empty($ns)) { | + | $logoPath = $this-> |
| - | return; | + | |
| - | } | + | |
| - | + | ||
| - | // Chemin vers le logo dans le namespace | + | |
| - | $logoPath = ':' | + | |
| | | ||
| - | | + | if ($logoPath) { |
| - | | + | |
| // Générer l'URL de l' | // Générer l'URL de l' | ||
| $imgUrl = ml($logoPath); | $imgUrl = ml($logoPath); | ||
| Ligne 56: | Ligne 71: | ||
| $logoHtml = '< | $logoHtml = '< | ||
| '< | '< | ||
| - | ' | + | ' |
| ' | ' | ||
| ' | ' | ||
| Ligne 65: | Ligne 80: | ||
| } | } | ||
| } | } | ||
| - | } | ||
| + | /** | ||
| + | * Trouver le chemin du logo avec fallback hiérarchique | ||
| + | * @param string $ns Namespace de départ | ||
| + | * @return string|null Chemin du logo ou null si aucun trouvé | ||
| + | */ | ||
| + | protected function _findLogoPath($ns) { | ||
| + | // Liste des namespaces à vérifier (du plus spécifique au plus général) | ||
| + | $namespacesToCheck = $this-> | ||
| + | | ||
| + | // Vérifier chaque namespace dans l' | ||
| + | foreach ($namespacesToCheck as $checkNs) { | ||
| + | foreach ($this-> | ||
| + | $path = ':' | ||
| + | | ||
| + | if (@media_exists($path)) { | ||
| + | return $path; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | return null; | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Construire la hiérarchie des namespaces pour le fallback | ||
| + | * Ex: ' | ||
| + | * @param string $ns Namespace de départ | ||
| + | * @return array Liste des namespaces à vérifier | ||
| + | */ | ||
| + | protected function _buildNamespaceHierarchy($ns) { | ||
| + | $hierarchy = []; | ||
| + | | ||
| + | // Ajouter le namespace actuel | ||
| + | if (!empty($ns)) { | ||
| + | $hierarchy[] = $ns; | ||
| + | } | ||
| + | | ||
| + | // Remonter dans la hiérarchie | ||
| + | $parts = explode(':', | ||
| + | while (count($parts) > 1) { | ||
| + | array_pop($parts); | ||
| + | $parentNs = implode(':', | ||
| + | if (!empty($parentNs)) { | ||
| + | $hierarchy[] = $parentNs; | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | // Ajouter la racine (vide) pour le fallback global | ||
| + | $hierarchy[] = ''; | ||
| + | | ||
| + | return $hierarchy; | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Extraire le namespace du chemin du logo pour l' | ||
| + | * @param string $path Chemin du logo (ex: ': | ||
| + | * @return string Nom du namespace | ||
| + | */ | ||
| + | protected function _extractNamespaceFromPath($path) { | ||
| + | // Supprimer les deux-points initiaux et le nom du fichier | ||
| + | $cleanPath = trim($path, ':' | ||
| + | $parts = explode(':', | ||
| + | | ||
| + | // Retirer le dernier élément (logo.png, etc.) | ||
| + | array_pop($parts); | ||
| + | | ||
| + | return implode(' | ||
| + | } | ||
| + | } | ||
| + | ?> | ||
| </ | </ | ||
| </ | </ | ||
| Ligne 78: | Ligne 162: | ||
| class helper_plugin_namespacelogo extends DokuWiki_Plugin { | class helper_plugin_namespacelogo extends DokuWiki_Plugin { | ||
| + | |||
| + | protected $supportedFormats = [' | ||
| /** | /** | ||
| - | * Obtenir le logo du namespace actuel | + | * Obtenir le logo du namespace actuel |
| * @return string|null HTML du logo ou null si aucun logo trouvé | * @return string|null HTML du logo ou null si aucun logo trouvé | ||
| */ | */ | ||
| Ligne 87: | Ligne 173: | ||
| | | ||
| $ns = getNS($ID); | $ns = getNS($ID); | ||
| + | $logoPath = $this-> | ||
| | | ||
| - | if (empty($ns)) { | + | if ($logoPath) { |
| - | return null; | + | |
| - | } | + | |
| - | + | ||
| - | $logoPath = ':' | + | |
| - | + | ||
| - | if (@media_exists($logoPath)) { | + | |
| $imgUrl = ml($logoPath); | $imgUrl = ml($logoPath); | ||
| - | return '< | + | |
| + | | ||
| } | } | ||
| | | ||
| Ligne 108: | Ligne 190: | ||
| */ | */ | ||
| public function hasLogo($ns) { | public function hasLogo($ns) { | ||
| - | $logoPath | + | |
| - | return @media_exists($logoPath); | + | } |
| + | |||
| + | /** | ||
| + | * Obtenir le chemin du logo pour un namespace spécifique | ||
| + | * @param string $ns Namespace | ||
| + | * @return string|null | ||
| + | */ | ||
| + | public function getLogoPath($ns) { | ||
| + | return $this-> | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Trouver le chemin du logo avec fallback hiérarchique | ||
| + | * @param string $ns Namespace de départ | ||
| + | * @return string|null | ||
| + | */ | ||
| + | protected function _findLogoPath($ns) { | ||
| + | $hierarchy = $this-> | ||
| + | |||
| + | foreach ($hierarchy as $checkNs) { | ||
| + | foreach ($this-> | ||
| + | | ||
| + | |||
| + | if (@media_exists($path)) { | ||
| + | return $path; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | return null; | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Construire la hiérarchie des namespaces | ||
| + | * @param string $ns | ||
| + | * @return array | ||
| + | */ | ||
| + | protected function _buildNamespaceHierarchy($ns) { | ||
| + | $hierarchy = []; | ||
| + | |||
| + | if (!empty($ns)) { | ||
| + | $hierarchy[] = $ns; | ||
| + | } | ||
| + | |||
| + | $parts = explode(':', $ns); | ||
| + | while (count($parts) > 1) { | ||
| + | array_pop($parts); | ||
| + | $parentNs = implode(':', | ||
| + | if (!empty($parentNs)) { | ||
| + | $hierarchy[] = $parentNs; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | $hierarchy[] = ''; | ||
| + | | ||
| + | return | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * Extraire le namespace du chemin | ||
| + | | ||
| + | * @return string | ||
| + | */ | ||
| + | protected function _extractNamespaceFromPath($path) { | ||
| + | $cleanPath = trim($path, ':' | ||
| + | $parts = explode(':', | ||
| + | array_pop($parts); | ||
| + | |||
| + | return implode(' | ||
| } | } | ||
| } | } | ||
| + | ?> | ||
| </ | </ | ||
| </ | </ | ||
| Ligne 138: | Ligne 289: | ||
| max-height: 80px; | max-height: 80px; | ||
| } | } | ||
| + | } | ||
| + | |||
| + | /* Indicateur visuel du fallback (optionnel) */ | ||
| + | .ns-logo-container.fallback-parent { | ||
| + | border-left: | ||
| + | padding-left: | ||
| } | } | ||
| </ | </ | ||
| </ | </ | ||
| + | ---- | ||
| + | |||
| + | ===== Fonctionnalités intégrées ===== | ||
| + | |||
| + | |||
lumo/creation_plugin_dokuwiki_namespacelogo/accueil.1773681870.txt.gz · Dernière modification : de estro
