From 58514668410cb902dab613221a8e7f963cc36317 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 26 Jul 2026 19:29:53 +0200 Subject: versioning fichiers CSS et JS --- view/Versioning.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 view/Versioning.php (limited to 'view/Versioning.php') diff --git a/view/Versioning.php b/view/Versioning.php new file mode 100644 index 0000000..f75afe1 --- /dev/null +++ b/view/Versioning.php @@ -0,0 +1,24 @@ +' . "\n"; + } + static function insertJS(string $name, bool $module = false): string + { + return '' . "\n"; + } + + static function versionedFileURL(string $type, string $filename, ?string $custom_path = null): string + { + $path = $custom_path ?? 'public/' . $type . '/' . $filename . '.' . $type; // si custom_path, $type et $filename ne servent à rien + + if(file_exists(getcwd() . '/' . $path)){ + $version = substr(md5_file($path), 0, 8); + return $path . '?v=' . $version; + } + return $path; // sécurité fichier absent + } +} -- cgit v1.2.3