Refactor the use of Calibre path to prepare multi database. re #40

This commit is contained in:
Sébastien Lucas 2013-04-03 15:00:09 +02:00
rodič f8f20f3d5c
revize d86d544074
4 změnil soubory, kde provedl 17 přidání a 7 odebrání

Zobrazit soubor

@ -622,10 +622,20 @@ abstract class Base
const COMPATIBILITY_XML_ALDIKO = "aldiko";
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 () {

Zobrazit soubor

@ -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;

Zobrazit soubor

@ -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;

Zobrazit soubor

@ -100,7 +100,7 @@
$dir = $config['calibre_internal_directory'];
if (empty ($config['calibre_internal_directory'])) {
$dir = $config['calibre_directory'];
$dir = Base::getDbDirectory ();
}
if (empty ($config['cops_x_accel_redirect'])) {