From ff95d618dbe804c79926c0a18d3296420d542c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Thu, 4 Apr 2013 20:53:44 +0200 Subject: [PATCH] Checkconfig can now handle multi database. re #40 --- base.php | 19 ++++++++++++++----- checkconfig.php | 26 +++++++++++++++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/base.php b/base.php index feaac9e..f8f594d 100644 --- a/base.php +++ b/base.php @@ -635,11 +635,20 @@ abstract class Base const COMPATIBILITY_XML_ALDIKO = "aldiko"; private static $db = NULL; - - public static function getDbDirectory () { + + public static function getDbList () { global $config; if (is_array ($config['calibre_directory'])) { - $database = GetUrlParam (DB, 0); + return $config['calibre_directory']; + } else { + return array ("" => $config['calibre_directory']); + } + } + + public static function getDbDirectory ($database = NULL) { + global $config; + if (is_array ($config['calibre_directory'])) { + if (is_null ($database)) $database = GetUrlParam (DB, 0); $array = array_values ($config['calibre_directory']); return $array[$database]; } @@ -647,8 +656,8 @@ abstract class Base } - public static function getDbFileName () { - return self::getDbDirectory () .'metadata.db'; + public static function getDbFileName ($database = NULL) { + return self::getDbDirectory ($database) .'metadata.db'; } public static function getDb () { diff --git a/checkconfig.php b/checkconfig.php index 3d48ff6..75cd05d 100644 --- a/checkconfig.php +++ b/checkconfig.php @@ -74,15 +74,18 @@ ?> - + $database) { +?>
Check if Calibre database file exists and is readable
  • Value of \$config['calibre_directory'] in config_local.php
  • @@ -99,10 +102,10 @@ Please check
    @@ -112,19 +115,20 @@ Please check
    query("select count(*) FROM sqlite_master WHERE type='table' AND name in ('books', 'authors', 'tags', 'series')")->fetchColumn(); if ($count == 4) { - echo "OK"; + echo "{$name} OK"; } else { - echo "Not all Calibre tables were found. Are you you're using the correct database."; + echo "{$name} Not all Calibre tables were found. Are you you're using the correct database."; } } catch (Exception $e) { - echo "If the file is readable, check your php configuration. Exception detail : " . $e; + echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e; } ?>
    +