@@ -13,61 +13,61 @@ discard block |
||
| 13 | 13 | * @param null|array $add List of «plugins» directories to add |
| 14 | 14 | */ |
| 15 | 15 | function spip_paths( |
| 16 | - null|array $add = null, |
|
| 16 | + null|array $add = null, |
|
| 17 | 17 | ): AggregatorInterface { |
| 18 | - static $paths = null; |
|
| 19 | - static $last_dossier_squelettes = null; |
|
| 20 | - |
|
| 21 | - $dossier_squelettes = $GLOBALS['dossier_squelettes'] ?? null; |
|
| 22 | - |
|
| 23 | - if ($paths === null) { |
|
| 24 | - $paths = new GroupAggregator(Group::cases(), _ROOT_CWD); |
|
| 25 | - $paths = $paths->with(Group::App, [ |
|
| 26 | - _DIR_RACINE, |
|
| 27 | - _DIR_RACINE . 'squelettes-dist/', |
|
| 28 | - _DIR_RACINE . 'prive/', |
|
| 29 | - _DIR_RESTREINT, |
|
| 30 | - ]); |
|
| 31 | - |
|
| 32 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 33 | - $paths = $paths->with(Group::Templates, [_DIR_RACINE . 'squelettes']); |
|
| 34 | - } |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - if ($add !== null) { |
|
| 38 | - $paths = $paths->prepend(Group::Plugins, $add); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if ($last_dossier_squelettes !== $dossier_squelettes) { |
|
| 42 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 43 | - if ($dossier_squelettes !== '') { |
|
| 44 | - $ds = explode(':', $dossier_squelettes); |
|
| 45 | - foreach ($ds as $key => $directory) { |
|
| 46 | - if (!str_starts_with($directory, '/')) { |
|
| 47 | - $ds[$key] = _DIR_RACINE . $directory; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - $paths = $paths->with(Group::ExtraTemplates, $ds); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - return $paths; |
|
| 18 | + static $paths = null; |
|
| 19 | + static $last_dossier_squelettes = null; |
|
| 20 | + |
|
| 21 | + $dossier_squelettes = $GLOBALS['dossier_squelettes'] ?? null; |
|
| 22 | + |
|
| 23 | + if ($paths === null) { |
|
| 24 | + $paths = new GroupAggregator(Group::cases(), _ROOT_CWD); |
|
| 25 | + $paths = $paths->with(Group::App, [ |
|
| 26 | + _DIR_RACINE, |
|
| 27 | + _DIR_RACINE . 'squelettes-dist/', |
|
| 28 | + _DIR_RACINE . 'prive/', |
|
| 29 | + _DIR_RESTREINT, |
|
| 30 | + ]); |
|
| 31 | + |
|
| 32 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 33 | + $paths = $paths->with(Group::Templates, [_DIR_RACINE . 'squelettes']); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + if ($add !== null) { |
|
| 38 | + $paths = $paths->prepend(Group::Plugins, $add); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if ($last_dossier_squelettes !== $dossier_squelettes) { |
|
| 42 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 43 | + if ($dossier_squelettes !== '') { |
|
| 44 | + $ds = explode(':', $dossier_squelettes); |
|
| 45 | + foreach ($ds as $key => $directory) { |
|
| 46 | + if (!str_starts_with($directory, '/')) { |
|
| 47 | + $ds[$key] = _DIR_RACINE . $directory; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + $paths = $paths->with(Group::ExtraTemplates, $ds); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + return $paths; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | function spip_paths_loader(): Loader { |
| 58 | - static $loaders = []; |
|
| 59 | - static $cache = null; |
|
| 58 | + static $loaders = []; |
|
| 59 | + static $cache = null; |
|
| 60 | 60 | |
| 61 | - if ($cache === null) { |
|
| 62 | - $cache = new FlatFilesystem('paths', Path::makeAbsolute(_DIR_CACHE, _ROOT_CWD)); |
|
| 63 | - if (_request('var_mode')) { |
|
| 64 | - $cache->clear(); |
|
| 65 | - } |
|
| 66 | - } |
|
| 61 | + if ($cache === null) { |
|
| 62 | + $cache = new FlatFilesystem('paths', Path::makeAbsolute(_DIR_CACHE, _ROOT_CWD)); |
|
| 63 | + if (_request('var_mode')) { |
|
| 64 | + $cache->clear(); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $paths = spip_paths(); |
|
| 68 | + $paths = spip_paths(); |
|
| 69 | 69 | |
| 70 | - return $loaders[$paths->getHash()] ??= new Loader($paths, $cache); |
|
| 70 | + return $loaders[$paths->getHash()] ??= new Loader($paths, $cache); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | * Liste des chemins, par ordre de priorité. |
| 103 | 103 | **/ |
| 104 | 104 | function _chemin(string|array|null $dir_path = null): array { |
| 105 | - if (is_array($dir_path) || (is_string($dir_path) && strlen($dir_path))) { |
|
| 106 | - spip_paths(add: is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 107 | - } |
|
| 105 | + if (is_array($dir_path) || (is_string($dir_path) && strlen($dir_path))) { |
|
| 106 | + spip_paths(add: is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - return creer_chemin(); |
|
| 109 | + return creer_chemin(); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * @return array Liste de chemins |
| 116 | 116 | **/ |
| 117 | 117 | function creer_chemin(): array { |
| 118 | - $dirs = spip_paths()->getDirectories(); |
|
| 119 | - // canal historique: avec / sauf si '' |
|
| 120 | - return array_map(fn ($dir) => $dir === '' ? $dir : $dir . DIRECTORY_SEPARATOR, $dirs); |
|
| 118 | + $dirs = spip_paths()->getDirectories(); |
|
| 119 | + // canal historique: avec / sauf si '' |
|
| 120 | + return array_map(fn ($dir) => $dir === '' ? $dir : $dir . DIRECTORY_SEPARATOR, $dirs); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -128,61 +128,61 @@ discard block |
||
| 128 | 128 | * @return string[] Nom des thèmes. |
| 129 | 129 | */ |
| 130 | 130 | function lister_themes_prives(): array { |
| 131 | - static $themes = null; |
|
| 132 | - if (is_null($themes)) { |
|
| 133 | - // si pas encore definie |
|
| 134 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 135 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 136 | - } |
|
| 137 | - $themes = [_SPIP_THEME_PRIVE]; |
|
| 138 | - // Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé |
|
| 139 | - // FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp; |
|
| 140 | - $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 141 | - if (is_string($prefs) && stripos($prefs, 'a:') === 0) { |
|
| 142 | - $prefs = unserialize($prefs); |
|
| 143 | - } else { |
|
| 144 | - $prefs = []; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - $theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null; |
|
| 148 | - if ($theme && $theme !== _SPIP_THEME_PRIVE) { |
|
| 149 | - // placer le theme choisi en tete |
|
| 150 | - array_unshift($themes, $theme); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $themes; |
|
| 131 | + static $themes = null; |
|
| 132 | + if (is_null($themes)) { |
|
| 133 | + // si pas encore definie |
|
| 134 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 135 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 136 | + } |
|
| 137 | + $themes = [_SPIP_THEME_PRIVE]; |
|
| 138 | + // Lors d'une installation neuve, prefs n'est pas definie ; sinon, c'est un tableau sérialisé |
|
| 139 | + // FIXME: Aussitôt après une demande d'inscription, $prefs vaut une chaine statut_tmp; |
|
| 140 | + $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 141 | + if (is_string($prefs) && stripos($prefs, 'a:') === 0) { |
|
| 142 | + $prefs = unserialize($prefs); |
|
| 143 | + } else { |
|
| 144 | + $prefs = []; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + $theme = $prefs['theme'] ?? $GLOBALS['theme_prive_defaut'] ?? null; |
|
| 148 | + if ($theme && $theme !== _SPIP_THEME_PRIVE) { |
|
| 149 | + // placer le theme choisi en tete |
|
| 150 | + array_unshift($themes, $theme); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $themes; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | function find_in_theme($file, $subdir = '', $include = false) { |
| 158 | - static $themefiles = []; |
|
| 159 | - if (isset($themefiles["$subdir$file"])) { |
|
| 160 | - return $themefiles["$subdir$file"]; |
|
| 161 | - } |
|
| 162 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 163 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 164 | - if ( |
|
| 165 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 166 | - && ($file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg') |
|
| 167 | - && ($f = find_in_theme("$file_svg_generique")) |
|
| 168 | - ) { |
|
| 169 | - if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) { |
|
| 170 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 171 | - } |
|
| 172 | - else { |
|
| 173 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $themes = lister_themes_prives(); |
|
| 178 | - foreach ($themes as $theme) { |
|
| 179 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 180 | - return $themefiles["$subdir$file"] = $f; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 184 | - |
|
| 185 | - return $themefiles["$subdir$file"] = ''; |
|
| 158 | + static $themefiles = []; |
|
| 159 | + if (isset($themefiles["$subdir$file"])) { |
|
| 160 | + return $themefiles["$subdir$file"]; |
|
| 161 | + } |
|
| 162 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 163 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 164 | + if ( |
|
| 165 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 166 | + && ($file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg') |
|
| 167 | + && ($f = find_in_theme("$file_svg_generique")) |
|
| 168 | + ) { |
|
| 169 | + if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) { |
|
| 170 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 171 | + } |
|
| 172 | + else { |
|
| 173 | + return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $themes = lister_themes_prives(); |
|
| 178 | + foreach ($themes as $theme) { |
|
| 179 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 180 | + return $themefiles["$subdir$file"] = $f; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 184 | + |
|
| 185 | + return $themefiles["$subdir$file"] = ''; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -206,31 +206,31 @@ discard block |
||
| 206 | 206 | * sinon chaîne vide. |
| 207 | 207 | **/ |
| 208 | 208 | function chemin_image($icone) { |
| 209 | - static $icone_renommer; |
|
| 210 | - if ($p = strpos($icone, '?')) { |
|
| 211 | - $icone = substr($icone, 0, $p); |
|
| 212 | - } |
|
| 213 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 214 | - if (str_contains($icone, '/') && file_exists($icone)) { |
|
| 215 | - return $icone; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 219 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) && ($f = find_in_theme("images/$icone"))) { |
|
| 220 | - return $f; |
|
| 221 | - } |
|
| 222 | - // sinon passer par le module de renommage |
|
| 223 | - if (is_null($icone_renommer)) { |
|
| 224 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 225 | - } |
|
| 226 | - if ($icone_renommer) { |
|
| 227 | - [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 228 | - if (file_exists($icone)) { |
|
| 229 | - return $icone; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 209 | + static $icone_renommer; |
|
| 210 | + if ($p = strpos($icone, '?')) { |
|
| 211 | + $icone = substr($icone, 0, $p); |
|
| 212 | + } |
|
| 213 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 214 | + if (str_contains($icone, '/') && file_exists($icone)) { |
|
| 215 | + return $icone; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 219 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) && ($f = find_in_theme("images/$icone"))) { |
|
| 220 | + return $f; |
|
| 221 | + } |
|
| 222 | + // sinon passer par le module de renommage |
|
| 223 | + if (is_null($icone_renommer)) { |
|
| 224 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 225 | + } |
|
| 226 | + if ($icone_renommer) { |
|
| 227 | + [$icone, $fonction] = $icone_renommer($icone, ''); |
|
| 228 | + if (file_exists($icone)) { |
|
| 229 | + return $icone; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -262,38 +262,38 @@ discard block |
||
| 262 | 262 | **/ |
| 263 | 263 | function find_in_path(string $file, string $dirname = '', bool|string $include = false): ?string { |
| 264 | 264 | |
| 265 | - $loader = spip_paths_loader(); |
|
| 265 | + $loader = spip_paths_loader(); |
|
| 266 | 266 | |
| 267 | - if ($dirname) { |
|
| 268 | - $file = rtrim($dirname, '/') . '/' . $file; |
|
| 269 | - } |
|
| 267 | + if ($dirname) { |
|
| 268 | + $file = rtrim($dirname, '/') . '/' . $file; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - $path = $loader->get($file); |
|
| 272 | - // find in path retourne des chemins relatif, si possible |
|
| 273 | - if ($path !== null && str_starts_with($path, _ROOT_RACINE)) { |
|
| 274 | - $path = _DIR_RACINE . substr($path, strlen(_ROOT_RACINE)); |
|
| 275 | - } |
|
| 271 | + $path = $loader->get($file); |
|
| 272 | + // find in path retourne des chemins relatif, si possible |
|
| 273 | + if ($path !== null && str_starts_with($path, _ROOT_RACINE)) { |
|
| 274 | + $path = _DIR_RACINE . substr($path, strlen(_ROOT_RACINE)); |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - if ($include === false) { |
|
| 278 | - return $path; |
|
| 279 | - } |
|
| 277 | + if ($include === false) { |
|
| 278 | + return $path; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - if ($include === true) { |
|
| 282 | - if ($path === null) { |
|
| 283 | - return null; |
|
| 284 | - } |
|
| 285 | - return $loader->include($file) ? $path : null; |
|
| 286 | - } |
|
| 281 | + if ($include === true) { |
|
| 282 | + if ($path === null) { |
|
| 283 | + return null; |
|
| 284 | + } |
|
| 285 | + return $loader->include($file) ? $path : null; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - if ($include === 'required') { |
|
| 289 | - return $loader->require($file) ? $path : null; |
|
| 290 | - } |
|
| 288 | + if ($include === 'required') { |
|
| 289 | + return $loader->require($file) ? $path : null; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - throw new \InvalidArgumentException(sprintf('$include argument with "%s" value is incorrect.', $include)); |
|
| 292 | + throw new \InvalidArgumentException(sprintf('$include argument with "%s" value is incorrect.', $include)); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | function clear_path_cache() { |
| 296 | - spip_paths_loader()->getCache()->clear(); |
|
| 296 | + spip_paths_loader()->getCache()->clear(); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | function load_path_cache() { |
@@ -320,31 +320,31 @@ discard block |
||
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | 322 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 323 | - $liste_fichiers = []; |
|
| 324 | - $maxfiles = 10000; |
|
| 325 | - |
|
| 326 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 327 | - // on a pas encore inclus flock.php |
|
| 328 | - if (!function_exists('preg_files')) { |
|
| 329 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - // Parcourir le chemin |
|
| 333 | - foreach (creer_chemin() as $d) { |
|
| 334 | - $f = $d . $dir; |
|
| 335 | - if (@is_dir($f)) { |
|
| 336 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 337 | - foreach ($liste as $chemin) { |
|
| 338 | - $nom = basename($chemin); |
|
| 339 | - // ne prendre que les fichiers pas deja trouves |
|
| 340 | - // car find_in_path prend le premier qu'il trouve, |
|
| 341 | - // les autres sont donc masques |
|
| 342 | - if (!isset($liste_fichiers[$nom])) { |
|
| 343 | - $liste_fichiers[$nom] = $chemin; |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - return $liste_fichiers; |
|
| 323 | + $liste_fichiers = []; |
|
| 324 | + $maxfiles = 10000; |
|
| 325 | + |
|
| 326 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 327 | + // on a pas encore inclus flock.php |
|
| 328 | + if (!function_exists('preg_files')) { |
|
| 329 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + // Parcourir le chemin |
|
| 333 | + foreach (creer_chemin() as $d) { |
|
| 334 | + $f = $d . $dir; |
|
| 335 | + if (@is_dir($f)) { |
|
| 336 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
|
| 337 | + foreach ($liste as $chemin) { |
|
| 338 | + $nom = basename($chemin); |
|
| 339 | + // ne prendre que les fichiers pas deja trouves |
|
| 340 | + // car find_in_path prend le premier qu'il trouve, |
|
| 341 | + // les autres sont donc masques |
|
| 342 | + if (!isset($liste_fichiers[$nom])) { |
|
| 343 | + $liste_fichiers[$nom] = $chemin; |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + return $liste_fichiers; |
|
| 350 | 350 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @param null|array $add List of «plugins» directories to add |
| 14 | 14 | */ |
| 15 | 15 | function spip_paths( |
| 16 | - null|array $add = null, |
|
| 16 | + null | array $add = null, |
|
| 17 | 17 | ): AggregatorInterface { |
| 18 | 18 | static $paths = null; |
| 19 | 19 | static $last_dossier_squelettes = null; |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | $paths = new GroupAggregator(Group::cases(), _ROOT_CWD); |
| 25 | 25 | $paths = $paths->with(Group::App, [ |
| 26 | 26 | _DIR_RACINE, |
| 27 | - _DIR_RACINE . 'squelettes-dist/', |
|
| 28 | - _DIR_RACINE . 'prive/', |
|
| 27 | + _DIR_RACINE.'squelettes-dist/', |
|
| 28 | + _DIR_RACINE.'prive/', |
|
| 29 | 29 | _DIR_RESTREINT, |
| 30 | 30 | ]); |
| 31 | 31 | |
| 32 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 33 | - $paths = $paths->with(Group::Templates, [_DIR_RACINE . 'squelettes']); |
|
| 32 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 33 | + $paths = $paths->with(Group::Templates, [_DIR_RACINE.'squelettes']); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $ds = explode(':', $dossier_squelettes); |
| 45 | 45 | foreach ($ds as $key => $directory) { |
| 46 | 46 | if (!str_starts_with($directory, '/')) { |
| 47 | - $ds[$key] = _DIR_RACINE . $directory; |
|
| 47 | + $ds[$key] = _DIR_RACINE.$directory; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | $paths = $paths->with(Group::ExtraTemplates, $ds); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return array |
| 102 | 102 | * Liste des chemins, par ordre de priorité. |
| 103 | 103 | **/ |
| 104 | -function _chemin(string|array|null $dir_path = null): array { |
|
| 104 | +function _chemin(string | array | null $dir_path = null): array { |
|
| 105 | 105 | if (is_array($dir_path) || (is_string($dir_path) && strlen($dir_path))) { |
| 106 | 106 | spip_paths(add: is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
| 107 | 107 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | function creer_chemin(): array { |
| 118 | 118 | $dirs = spip_paths()->getDirectories(); |
| 119 | 119 | // canal historique: avec / sauf si '' |
| 120 | - return array_map(fn ($dir) => $dir === '' ? $dir : $dir . DIRECTORY_SEPARATOR, $dirs); |
|
| 120 | + return array_map(fn ($dir) => $dir === '' ? $dir : $dir.DIRECTORY_SEPARATOR, $dirs); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 164 | 164 | if ( |
| 165 | 165 | preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 166 | - && ($file_svg_generique = substr($file, 0, -strlen($m[0])) . '-xx.svg') |
|
| 166 | + && ($file_svg_generique = substr($file, 0, -strlen($m[0])).'-xx.svg') |
|
| 167 | 167 | && ($f = find_in_theme("$file_svg_generique")) |
| 168 | 168 | ) { |
| 169 | - if (($fsize = substr($f, 0, -6) . $m[1] . '.svg') && file_exists($fsize)) { |
|
| 169 | + if (($fsize = substr($f, 0, -6).$m[1].'.svg') && file_exists($fsize)) { |
|
| 170 | 170 | return $themefiles["$subdir$file"] = $fsize; |
| 171 | 171 | } |
| 172 | 172 | else { |
| 173 | - return $themefiles["$subdir$file"] = "$f?" . $m[1] . 'px'; |
|
| 173 | + return $themefiles["$subdir$file"] = "$f?".$m[1].'px'; |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | return $themefiles["$subdir$file"] = $f; |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 183 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 184 | 184 | |
| 185 | 185 | return $themefiles["$subdir$file"] = ''; |
| 186 | 186 | } |
@@ -260,18 +260,18 @@ discard block |
||
| 260 | 260 | * - string : chemin du fichier trouvé |
| 261 | 261 | * - false : fichier introuvable |
| 262 | 262 | **/ |
| 263 | -function find_in_path(string $file, string $dirname = '', bool|string $include = false): ?string { |
|
| 263 | +function find_in_path(string $file, string $dirname = '', bool | string $include = false): ?string { |
|
| 264 | 264 | |
| 265 | 265 | $loader = spip_paths_loader(); |
| 266 | 266 | |
| 267 | 267 | if ($dirname) { |
| 268 | - $file = rtrim($dirname, '/') . '/' . $file; |
|
| 268 | + $file = rtrim($dirname, '/').'/'.$file; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | $path = $loader->get($file); |
| 272 | 272 | // find in path retourne des chemins relatif, si possible |
| 273 | 273 | if ($path !== null && str_starts_with($path, _ROOT_RACINE)) { |
| 274 | - $path = _DIR_RACINE . substr($path, strlen(_ROOT_RACINE)); |
|
| 274 | + $path = _DIR_RACINE.substr($path, strlen(_ROOT_RACINE)); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | if ($include === false) { |
@@ -326,12 +326,12 @@ discard block |
||
| 326 | 326 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 327 | 327 | // on a pas encore inclus flock.php |
| 328 | 328 | if (!function_exists('preg_files')) { |
| 329 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 329 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Parcourir le chemin |
| 333 | 333 | foreach (creer_chemin() as $d) { |
| 334 | - $f = $d . $dir; |
|
| 334 | + $f = $d.$dir; |
|
| 335 | 335 | if (@is_dir($f)) { |
| 336 | 336 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? [] : $recurs); |
| 337 | 337 | foreach ($liste as $chemin) { |