1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 22:56:46 +02:00

Plugins: Allow setting dark mode in css() (bug #1049)

This commit is contained in:
Jakub Vrana
2025-04-17 16:57:28 +02:00
parent d9c1ac00f3
commit 3dad86d279
5 changed files with 20 additions and 20 deletions

View File

@@ -114,14 +114,18 @@ class Adminer {
}
/** Get URLs of the CSS files
* @return list<string>
* @return string[] key is URL, value is either 'light' (supports only light color scheme), 'dark' or '' (both)
*/
function css(): array {
$return = array();
foreach (array("", "-dark") as $mode) {
$filename = "adminer$mode.css";
if (file_exists($filename)) {
$return[] = "$filename?v=" . crc32(file_get_contents($filename));
$file = file_get_contents($filename);
$return["$filename?v=" . crc32($file)] = ($mode
? "dark"
: (preg_match('~prefers-color-scheme:\s*dark~', $file) ? '' : 'light')
);
}
}
return $return;