- PostgreSQL, CockroachDB: Creating partitioned tables (bug #1031)
- PostgreSQL: Move partitioned tables from table list to parent table
- PostgreSQL: Support calling functions returning table (bug #1040)
-- Designs: adminer.css with 'prefers-color-scheme: dark' don't disable dark mode
+- Designs: adminer.css with 'prefers-color-scheme: dark' doesn't disable dark mode
- Plugins: Method bodyClass() to add <body class>
+- Plugins: Allow setting dark mode in css()
- Hindi translation
## Adminer 5.2.1 (released 2025-04-11)
}
/** 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;
<?php
$css = adminer()->css();
- $has_light = false;
- $has_dark = false;
- foreach ($css as $url) {
- if (strpos($url, "adminer.css") !== false) {
- $has_light = true;
- $filename = preg_replace('~\?.*~', '', $url);
- if (!preg_match('~//~', $url) && is_readable($filename) && preg_match('~prefers-color-scheme:\s*dark~', file_get_contents($filename))) {
- $has_dark = true;
- }
- }
- if (strpos($url, "adminer-dark.css") !== false) {
- $has_dark = true;
- }
+ if (is_int(key($css))) { // legacy return value
+ $css = array_fill_keys($css, 'light');
}
+ $has_light = in_array('light', $css) || in_array('', $css);
+ $has_dark = in_array('dark', $css) || in_array('', $css);
$dark = ($has_light
? ($has_dark ? null : false) // both styles - autoswitching, only adminer.css - light
: ($has_dark ?: null) // only adminer-dark.css - dark, neither - autoswitching
echo "<link rel='icon' href='data:image/gif;base64,R0lGODlhEAAQAJEAAAQCBPz+/PwCBAROZCH5BAEAAAAALAAAAAAQABAAAAI2hI+pGO1rmghihiUdvUBnZ3XBQA7f05mOak1RWXrNq5nQWHMKvuoJ37BhVEEfYxQzHjWQ5qIAADs='>\n";
echo "<link rel='apple-touch-icon' href='../adminer/static/logo.png'>\n";
}
- foreach ($css as $val) {
- echo "<link rel='stylesheet'" . (preg_match('~-dark\.~', $val) && !$dark ? $media : "") . " href='" . h($val) . "'>\n";
+ foreach ($css as $url => $mode) {
+ echo "<link rel='stylesheet'" . ($mode == 'dark' && !$dark ? $media : "") . " href='" . h($url) . "'>\n";
}
echo "\n<body class='" . lang('ltr') . " nojs";
adminer()->bodyClass();
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;
function css() {
$return = array();
if (array_key_exists($_SESSION["design"], $this->designs)) {
- $return[] = $_SESSION["design"];
+ $return[$_SESSION["design"]] = (preg_match('~-dark~', $_SESSION["design"]) ? "dark" : "light");
}
return $return;
}