1da933f89SLORTET# Pagesicon 2da933f89SLORTET 3da933f89SLORTETJ'aime beaucoup DokuWiki, mais je l'ai toujours trouvé un peu triste : il manquait une façon simple de mettre de belles icônes sur les pages. 4da933f89SLORTETAvec **pagesicon**, c'est possible. 5da933f89SLORTET 6da933f89SLORTET`pagesicon` est à la fois : 7da933f89SLORTET- un **plugin** (affichage et gestion des icônes), 8da933f89SLORTET- un **helper** (API réutilisable par d'autres plugins, comme `catmenu` et `visualindex`). 9da933f89SLORTET 10*74a9e763SLORTET## Ce que fait le plugin 11da933f89SLORTET 12da933f89SLORTET- Affiche une icône en haut de la page (`show`), si activé. 13da933f89SLORTET- Peut utiliser l'icône de la page comme favicon d'onglet (`show_as_favicon`). 14da933f89SLORTET- Fournit une page de gestion d'icône par page : `?do=pagesicon`. 15da933f89SLORTET- Gère les variantes `big` et `small`. 16*74a9e763SLORTET- Notifie les autres plugins quand une icône change via `PLUGIN_PAGESICON_UPDATED` (pour invalider leurs caches). 17da933f89SLORTET 18*74a9e763SLORTET## Paramètres de configuration 19da933f89SLORTET 20da933f89SLORTETDans le `Configuration Manager` : 21da933f89SLORTET 22da933f89SLORTET- `icon_name` : noms candidats pour l'icône `big` (séparés par `;`). 23da933f89SLORTET Supporte `~pagename~`. 24da933f89SLORTET 25da933f89SLORTET- `icon_thumbnail_name` : noms candidats pour l'icône `small` (séparés par `;`). 26da933f89SLORTET Supporte `~pagename~`. 27da933f89SLORTET 28*74a9e763SLORTET- `default_image` : image par défaut (mediaID) utilisée uniquement quand le fallback est explicitement activé dans l'API helper. 29*74a9e763SLORTET 30da933f89SLORTET- `icon_size` : taille (px) de l'icône affichée en haut de page. 31da933f89SLORTET 32da933f89SLORTET- `extensions` : extensions autorisées (séparées par `;`), par exemple `svg;png;jpg;jpeg`. 33da933f89SLORTET 34da933f89SLORTET- `show_on_top` : activer/désactiver l'affichage en haut de page. 35da933f89SLORTET 36da933f89SLORTET- `show_as_favicon` : utiliser l'icône de la page comme favicon. 37da933f89SLORTET 38da933f89SLORTET## Usage 39da933f89SLORTET 40da933f89SLORTETDepuis une page, utiliser l'action `Gérer l'icône` puis uploader/supprimer. 41da933f89SLORTET 42da933f89SLORTETLe plugin travaille sur la **page courante** (`$ID`), pas sur une cible passée en paramètre. 43da933f89SLORTET 44*74a9e763SLORTET## API helper 45da933f89SLORTET 46da933f89SLORTETCharger le helper : 47da933f89SLORTET 48da933f89SLORTET```php 49da933f89SLORTET$pagesicon = plugin_load('helper', 'pagesicon'); 50da933f89SLORTET``` 51da933f89SLORTET 52*74a9e763SLORTET### Résolution en mediaID 53da933f89SLORTET 54*74a9e763SLORTET- `getPageIconId(string $namespace, string $pageID, string $size = 'bigorsmall')` 55da933f89SLORTET Retourne un mediaID (`ns:file.ext`) ou `false`. 56da933f89SLORTET 57*74a9e763SLORTET- `getMediaIconId(string $mediaID, string $size = 'bigorsmall')` 58da933f89SLORTET Retourne le mediaID d'icône pour un média, ou `false`. 59da933f89SLORTET 60da933f89SLORTET`size` accepte : `big`, `small`, `bigorsmall`, `smallorbig`. 61da933f89SLORTET 62*74a9e763SLORTET### Résolution en URL versionnée 63da933f89SLORTET 64*74a9e763SLORTET- `getPageIconUrl(string $namespace, string $pageID, string $size = 'bigorsmall', array $params = ['width' => 55], ?int &$mtime = null, bool $withDefault = false)` 65da933f89SLORTET Retourne une URL d'icône (avec `pi_ts=<filemtime>`) ou `false`. 66da933f89SLORTET Renseigne aussi `$mtime`. 67da933f89SLORTET 68*74a9e763SLORTET- `getMediaIconUrl(string $mediaID, string $size = 'bigorsmall', array $params = ['width' => 55], ?int &$mtime = null, bool $withDefault = false)` 69da933f89SLORTET Retourne une URL d'icône de média (avec `pi_ts=<filemtime>`) ou `false`. 70da933f89SLORTET Renseigne aussi `$mtime`. 71da933f89SLORTET 72*74a9e763SLORTET- `getDefaultIconUrl(array $params = ['width' => 55], ?int &$mtime = null)` 73*74a9e763SLORTET Retourne l'URL de l'image par défaut configurée, ou `false`. 74*74a9e763SLORTET 75*74a9e763SLORTET### URLs de gestion 76da933f89SLORTET 77da933f89SLORTET- `getUploadIconPage(string $targetPage = '')` 78da933f89SLORTET Retourne l'URL `?do=pagesicon` d'une page, ou `null` si non autorisé. 79da933f89SLORTET 80da933f89SLORTET- `getUploadMediaIconPage(string $mediaID = '')` 81da933f89SLORTET Retourne l'URL de gestion d'icône associée à un média. 82da933f89SLORTET 83da933f89SLORTET### Notification 84da933f89SLORTET 85da933f89SLORTET- `notifyIconUpdated(string $targetPage, string $action = 'update', string $mediaID = '')` 86da933f89SLORTET 87da933f89SLORTETEffets : 88da933f89SLORTET- met à jour `purgefile`, 89da933f89SLORTET- déclenche l'événement `PLUGIN_PAGESICON_UPDATED`. 90da933f89SLORTET 91da933f89SLORTETPayload : 92da933f89SLORTET- `target_page`, 93da933f89SLORTET- `action`, 94da933f89SLORTET- `media_id`. 95da933f89SLORTET 96da933f89SLORTETChaque plugin consommateur est responsable de sa propre invalidation de cache. 97*74a9e763SLORTET 98*74a9e763SLORTET## Compatibilité des signatures 99*74a9e763SLORTET 100*74a9e763SLORTET- Avant `09-03-2025` : 101*74a9e763SLORTET - `getPageImage(string $namespace, string $pageID, string $size = 'bigorsmall')` 102*74a9e763SLORTET - `getMediaImage(string $mediaID, string $size = 'bigorsmall')` 103*74a9e763SLORTET - `getImageIcon(string $namespace, string $pageID, string $size = 'bigorsmall', array $params = ['width' => 55], ?int &$mtime = null)` 104*74a9e763SLORTET - `getMediaIcon(string $mediaID, string $size = 'bigorsmall', array $params = ['width' => 55], ?int &$mtime = null)` 105*74a9e763SLORTET 106*74a9e763SLORTETLa compatibilité est conservée via des alias legacy : 107*74a9e763SLORTET- `getPageImage(...)` -> `getPageIconId(...)` (le paramètre legacy `$withDefault` est ignoré) 108*74a9e763SLORTET- `getMediaImage(...)` -> `getMediaIconId(...)` (le paramètre legacy `$withDefault` est ignoré) 109*74a9e763SLORTET- `getImageIcon(...)` -> `getPageIconUrl(...)` 110*74a9e763SLORTET- `getMediaIcon(...)` -> `getMediaIconUrl(...)` 111*74a9e763SLORTET- `getDefaultImageIcon(...)` -> `getDefaultIconUrl(...)` 112