Browse Source

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

master
Sébastien Lucas 11 years ago
parent
commit
d86d544074
4 changed files with 17 additions and 7 deletions
  1. +13
    -3
      base.php
  2. +1
    -1
      book.php
  3. +2
    -2
      data.php
  4. +1
    -1
      fetch.php

+ 13
- 3
base.php View File

@@ -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 () {


+ 1
- 1
book.php View File

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


+ 2
- 2
data.php View File

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


+ 1
- 1
fetch.php View File

@@ -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'])) {


Loading…
Cancel
Save