Refactor the use of Calibre path to prepare multi database. re #40
This commit is contained in:
parent
f8f20f3d5c
commit
d86d544074
14
base.php
14
base.php
|
@ -623,9 +623,19 @@ abstract class Base
|
|||
|
||||
private static $db = NULL;
|
||||
|
||||
public static function getDbFileName () {
|
||||
public static function getDbDirectory () {
|
||||
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 () {
|
||||
|
|
2
book.php
2
book.php
|
@ -72,7 +72,7 @@ class Book extends Base {
|
|||
$this->title = $line->title;
|
||||
$this->timestamp = strtotime ($line->timestamp);
|
||||
$this->pubdate = strtotime ($line->pubdate);
|
||||
$this->path = $config['calibre_directory'] . $line->path;
|
||||
$this->path = Base::getDbDirectory () . $line->path;
|
||||
$this->relativePath = $line->path;
|
||||
$this->seriesIndex = $line->series_index;
|
||||
$this->comment = $line->comment;
|
||||
|
|
4
data.php
4
data.php
|
@ -117,8 +117,8 @@ class Data extends Base {
|
|||
$textData = "&data=" . $idData;
|
||||
}
|
||||
|
||||
if (preg_match ('/^\//', $config['calibre_directory']) || // Linux /
|
||||
preg_match ('/^\w\:/', $config['calibre_directory']) || // Windows X:
|
||||
if (preg_match ('/^\//', Base::getDbDirectory ()) || // Linux /
|
||||
preg_match ('/^\w\:/', Base::getDbDirectory ()) || // Windows X:
|
||||
($type == "epub" && $config['cops_update_epub-metadata']))
|
||||
{
|
||||
if ($type != "jpg") $textData .= "&type=" . $type;
|
||||
|
|
Loading…
Reference in a new issue