Refactor the use of Calibre path to prepare multi database. re #40
This commit is contained in:
parent
f8f20f3d5c
commit
d86d544074
16
base.php
16
base.php
|
@ -622,10 +622,20 @@ abstract class Base
|
||||||
const COMPATIBILITY_XML_ALDIKO = "aldiko";
|
const COMPATIBILITY_XML_ALDIKO = "aldiko";
|
||||||
|
|
||||||
private static $db = NULL;
|
private static $db = NULL;
|
||||||
|
|
||||||
public static function getDbFileName () {
|
public static function getDbDirectory () {
|
||||||
global $config;
|
global $config;
|
||||||
return $config['calibre_directory'] .'metadata.db';
|
if (is_array ($config['calibre_directory'])) {
|
||||||
|
$database = GetUrlParam ("database", 0);
|
||||||
|
$array = array_values ($config['calibre_directory']);
|
||||||
|
return $array[$database];
|
||||||
|
}
|
||||||
|
return $config['calibre_directory'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function getDbFileName () {
|
||||||
|
return self::getDbDirectory () .'metadata.db';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDb () {
|
public static function getDb () {
|
||||||
|
|
2
book.php
2
book.php
|
@ -72,7 +72,7 @@ class Book extends Base {
|
||||||
$this->title = $line->title;
|
$this->title = $line->title;
|
||||||
$this->timestamp = strtotime ($line->timestamp);
|
$this->timestamp = strtotime ($line->timestamp);
|
||||||
$this->pubdate = strtotime ($line->pubdate);
|
$this->pubdate = strtotime ($line->pubdate);
|
||||||
$this->path = $config['calibre_directory'] . $line->path;
|
$this->path = Base::getDbDirectory () . $line->path;
|
||||||
$this->relativePath = $line->path;
|
$this->relativePath = $line->path;
|
||||||
$this->seriesIndex = $line->series_index;
|
$this->seriesIndex = $line->series_index;
|
||||||
$this->comment = $line->comment;
|
$this->comment = $line->comment;
|
||||||
|
|
4
data.php
4
data.php
|
@ -117,8 +117,8 @@ class Data extends Base {
|
||||||
$textData = "&data=" . $idData;
|
$textData = "&data=" . $idData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match ('/^\//', $config['calibre_directory']) || // Linux /
|
if (preg_match ('/^\//', Base::getDbDirectory ()) || // Linux /
|
||||||
preg_match ('/^\w\:/', $config['calibre_directory']) || // Windows X:
|
preg_match ('/^\w\:/', Base::getDbDirectory ()) || // Windows X:
|
||||||
($type == "epub" && $config['cops_update_epub-metadata']))
|
($type == "epub" && $config['cops_update_epub-metadata']))
|
||||||
{
|
{
|
||||||
if ($type != "jpg") $textData .= "&type=" . $type;
|
if ($type != "jpg") $textData .= "&type=" . $type;
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
$dir = $config['calibre_internal_directory'];
|
$dir = $config['calibre_internal_directory'];
|
||||||
if (empty ($config['calibre_internal_directory'])) {
|
if (empty ($config['calibre_internal_directory'])) {
|
||||||
$dir = $config['calibre_directory'];
|
$dir = Base::getDbDirectory ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty ($config['cops_x_accel_redirect'])) {
|
if (empty ($config['cops_x_accel_redirect'])) {
|
||||||
|
|
Loading…
Reference in a new issue