@@ -99,13 +99,13 @@ |
||
99 | 99 | |
100 | 100 | // -DC- Add image directory |
101 | 101 | public static function getImgDirectory ($database = NULL) { |
102 | - global $config; |
|
103 | - if (self::isMultipleDatabaseEnabled ()) { |
|
104 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
105 | - $array = array_values ($config['image_directory']); |
|
106 | - return $array[$database]; |
|
107 | - } |
|
108 | - return $config['image_directory']; |
|
102 | + global $config; |
|
103 | + if (self::isMultipleDatabaseEnabled ()) { |
|
104 | + if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
105 | + $array = array_values ($config['image_directory']); |
|
106 | + return $array[$database]; |
|
107 | + } |
|
108 | + return $config['image_directory']; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | public static function getDbFileName ($database = NULL) { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | private $coverFileName = NULL; |
110 | 110 | |
111 | 111 | public function __construct($line) { |
112 | - global $config; |
|
112 | + global $config; |
|
113 | 113 | |
114 | 114 | $this->id = $line->id; |
115 | 115 | $this->title = $line->title; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | // -DC- Init relative or full path |
121 | 121 | $this->path = $line->path; |
122 | 122 | if (!is_dir($this->path)) { |
123 | - $this->path = Base::getDbDirectory() . $line->path; |
|
123 | + $this->path = Base::getDbDirectory() . $line->path; |
|
124 | 124 | } |
125 | 125 | $this->seriesIndex = $line->series_index; |
126 | 126 | $this->comment = $line->comment; |
@@ -132,47 +132,47 @@ discard block |
||
132 | 132 | // $this->hasCover = 0; |
133 | 133 | //} |
134 | 134 | if ($this->hasCover) { |
135 | - if (!empty($config['calibre_database_field_cover'])) { |
|
136 | - $imgDirectory = Base::getImgDirectory(); |
|
137 | - $this->coverFileName = $line->cover; |
|
138 | - if (!file_exists($this->coverFileName)) { |
|
139 | - $this->coverFileName = NULL; |
|
140 | - } |
|
141 | - if (empty($this->coverFileName)) { |
|
142 | - $this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover); |
|
143 | - if (!file_exists($this->coverFileName)) { |
|
144 | - $this->coverFileName = NULL; |
|
145 | - } |
|
146 | - } |
|
147 | - if (empty($this->coverFileName)) { |
|
148 | - $data = $this->getDataById($this->id); |
|
149 | - if ($data) { |
|
150 | - $this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover); |
|
151 | - if (!file_exists($this->coverFileName)) { |
|
152 | - $this->coverFileName = NULL; |
|
153 | - } |
|
154 | - if (empty($this->coverFileName)) { |
|
155 | - $this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name); |
|
156 | - if (!file_exists($this->coverFileName)) { |
|
157 | - $this->coverFileName = NULL; |
|
158 | - } |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
163 | - // Else try with default cover file name |
|
164 | - if (empty($this->coverFileName)) { |
|
165 | - $cover = $this->getFilePath("jpg"); |
|
166 | - if ($cover === false || !file_exists($cover)) { |
|
167 | - $cover = $this->getFilePath("png"); |
|
168 | - } |
|
169 | - if ($cover === false || !file_exists($cover)) { |
|
170 | - $this->hasCover = 0; |
|
171 | - } |
|
172 | - else { |
|
173 | - $this->coverFileName = $cover; |
|
174 | - } |
|
175 | - } |
|
135 | + if (!empty($config['calibre_database_field_cover'])) { |
|
136 | + $imgDirectory = Base::getImgDirectory(); |
|
137 | + $this->coverFileName = $line->cover; |
|
138 | + if (!file_exists($this->coverFileName)) { |
|
139 | + $this->coverFileName = NULL; |
|
140 | + } |
|
141 | + if (empty($this->coverFileName)) { |
|
142 | + $this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover); |
|
143 | + if (!file_exists($this->coverFileName)) { |
|
144 | + $this->coverFileName = NULL; |
|
145 | + } |
|
146 | + } |
|
147 | + if (empty($this->coverFileName)) { |
|
148 | + $data = $this->getDataById($this->id); |
|
149 | + if ($data) { |
|
150 | + $this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover); |
|
151 | + if (!file_exists($this->coverFileName)) { |
|
152 | + $this->coverFileName = NULL; |
|
153 | + } |
|
154 | + if (empty($this->coverFileName)) { |
|
155 | + $this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name); |
|
156 | + if (!file_exists($this->coverFileName)) { |
|
157 | + $this->coverFileName = NULL; |
|
158 | + } |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | + // Else try with default cover file name |
|
164 | + if (empty($this->coverFileName)) { |
|
165 | + $cover = $this->getFilePath("jpg"); |
|
166 | + if ($cover === false || !file_exists($cover)) { |
|
167 | + $cover = $this->getFilePath("png"); |
|
168 | + } |
|
169 | + if ($cover === false || !file_exists($cover)) { |
|
170 | + $this->hasCover = 0; |
|
171 | + } |
|
172 | + else { |
|
173 | + $this->coverFileName = $cover; |
|
174 | + } |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | $this->rating = $line->rating; |
178 | 178 | } |
@@ -180,14 +180,14 @@ discard block |
||
180 | 180 | // -DC- Get customisable book columns |
181 | 181 | private static function getBookColumns() |
182 | 182 | { |
183 | - global $config; |
|
183 | + global $config; |
|
184 | 184 | |
185 | - $res = self::BOOK_COLUMNS; |
|
186 | - if (!empty($config['calibre_database_field_cover'])) { |
|
187 | - $res = str_replace('has_cover,', 'has_cover, ' . $config['calibre_database_field_cover'] . ',', $res); |
|
188 | - } |
|
185 | + $res = self::BOOK_COLUMNS; |
|
186 | + if (!empty($config['calibre_database_field_cover'])) { |
|
187 | + $res = str_replace('has_cover,', 'has_cover, ' . $config['calibre_database_field_cover'] . ',', $res); |
|
188 | + } |
|
189 | 189 | |
190 | - return $res; |
|
190 | + return $res; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | public function getEntryId() { |
@@ -416,26 +416,26 @@ discard block |
||
416 | 416 | { |
417 | 417 | return $this->path.'/'.$file; |
418 | 418 | }*/ |
419 | - if ($extension == "jpg" || $extension == "png") { |
|
420 | - if (empty($this->coverFileName)) { |
|
421 | - return $this->path . '/cover.' . $extension; |
|
422 | - } |
|
423 | - else { |
|
424 | - $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION)); |
|
425 | - if ($ext == $extension) { |
|
426 | - return $this->coverFileName; |
|
427 | - } |
|
428 | - } |
|
429 | - return false; |
|
430 | - } |
|
431 | - else { |
|
432 | - $data = $this->getDataById($idData); |
|
433 | - if (!$data) { |
|
434 | - return NULL; |
|
435 | - } |
|
436 | - $file = $data->name . "." . strtolower($data->format); |
|
437 | - return $this->path . '/' . $file; |
|
438 | - } |
|
419 | + if ($extension == "jpg" || $extension == "png") { |
|
420 | + if (empty($this->coverFileName)) { |
|
421 | + return $this->path . '/cover.' . $extension; |
|
422 | + } |
|
423 | + else { |
|
424 | + $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION)); |
|
425 | + if ($ext == $extension) { |
|
426 | + return $this->coverFileName; |
|
427 | + } |
|
428 | + } |
|
429 | + return false; |
|
430 | + } |
|
431 | + else { |
|
432 | + $data = $this->getDataById($idData); |
|
433 | + if (!$data) { |
|
434 | + return NULL; |
|
435 | + } |
|
436 | + $file = $data->name . "." . strtolower($data->format); |
|
437 | + return $this->path . '/' . $file; |
|
438 | + } |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | public function getUpdatedEpub($idData) |
@@ -520,18 +520,18 @@ discard block |
||
520 | 520 | $linkArray = array(); |
521 | 521 | |
522 | 522 | if ($this->hasCover) { |
523 | - // -DC- Use cover file name |
|
524 | - //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
|
525 | - //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); |
|
526 | - $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION)); |
|
527 | - if ($ext == 'png') { |
|
528 | - array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL)); |
|
529 | - array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL)); |
|
530 | - } |
|
531 | - else { |
|
532 | - array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
|
533 | - array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL)); |
|
534 | - } |
|
523 | + // -DC- Use cover file name |
|
524 | + //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
|
525 | + //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); |
|
526 | + $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION)); |
|
527 | + if ($ext == 'png') { |
|
528 | + array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL)); |
|
529 | + array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL)); |
|
530 | + } |
|
531 | + else { |
|
532 | + array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
|
533 | + array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL)); |
|
534 | + } |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | foreach ($this->getDatas() as $data) |
@@ -571,15 +571,15 @@ discard block |
||
571 | 571 | $nBooks = parent::executeQuerySingle('select count(*) from books'); |
572 | 572 | $result = array(); |
573 | 573 | $entry = new Entry(localize('allbooks.title'), |
574 | - self::ALL_BOOKS_ID, |
|
575 | - str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', |
|
576 | - array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
574 | + self::ALL_BOOKS_ID, |
|
575 | + str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', |
|
576 | + array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
577 | 577 | array_push($result, $entry); |
578 | 578 | if ($config['cops_recentbooks_limit'] > 0) { |
579 | 579 | $entry = new Entry(localize('recent.title'), |
580 | - self::ALL_RECENT_BOOKS_ID, |
|
581 | - str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', |
|
582 | - array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
580 | + self::ALL_RECENT_BOOKS_ID, |
|
581 | + str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', |
|
582 | + array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
583 | 583 | array_push($result, $entry); |
584 | 584 | } |
585 | 585 | return $result; |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | } |
623 | 623 | |
624 | 624 | public static function getBookById($bookId) { |
625 | - $result = parent::getDb()->prepare('select ' . self::getBookColumns() . ' |
|
625 | + $result = parent::getDb()->prepare('select ' . self::getBookColumns() . ' |
|
626 | 626 | from books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
627 | 627 | where books.id = ?'); |
628 | 628 | $result->execute(array($bookId)); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | } |
636 | 636 | |
637 | 637 | public static function getBookByDataId($dataId) { |
638 | - $result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format |
|
638 | + $result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format |
|
639 | 639 | from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
640 | 640 | where data.book = books.id and data.id = ?'); |
641 | 641 | $result->execute(array($dataId)); |
@@ -654,10 +654,10 @@ discard block |
||
654 | 654 | $i = 0; |
655 | 655 | $critArray = array(); |
656 | 656 | foreach (array(PageQueryResult::SCOPE_AUTHOR, |
657 | - PageQueryResult::SCOPE_TAG, |
|
658 | - PageQueryResult::SCOPE_SERIES, |
|
659 | - PageQueryResult::SCOPE_PUBLISHER, |
|
660 | - PageQueryResult::SCOPE_BOOK) as $key) { |
|
657 | + PageQueryResult::SCOPE_TAG, |
|
658 | + PageQueryResult::SCOPE_SERIES, |
|
659 | + PageQueryResult::SCOPE_PUBLISHER, |
|
660 | + PageQueryResult::SCOPE_BOOK) as $key) { |
|
661 | 661 | if (in_array($key, getCurrentOption('ignored_categories')) || |
662 | 662 | (!array_key_exists($key, $query) && !array_key_exists('all', $query))) { |
663 | 663 | $critArray[$i] = self::BAD_SEARCH; |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { |
705 | 705 | /* @var $totalNumber integer */ |
706 | 706 | /* @var $result PDOStatement */ |
707 | - list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage); |
|
707 | + list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage); |
|
708 | 708 | |
709 | 709 | $entryArray = array(); |
710 | 710 | while ($post = $result->fetchObject()) |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | // -DC- Add png type |
43 | 43 | if ($book && ($type == 'jpg' || $type == 'png' || empty ($config['calibre_internal_directory']))) { |
44 | - if ($type == 'jpg' || $type == 'png') { |
|
44 | + if ($type == 'jpg' || $type == 'png') { |
|
45 | 45 | $file = $book->getFilePath($type); |
46 | 46 | } else { |
47 | 47 | $file = $book->getFilePath($type, $idData); |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | |
55 | 55 | switch ($type) |
56 | 56 | { |
57 | - // -DC- Add png type |
|
57 | + // -DC- Add png type |
|
58 | 58 | case 'jpg': |
59 | 59 | case 'png': |
60 | - if ($type == 'jpg') { |
|
61 | - header('Content-Type: image/jpeg'); |
|
62 | - } |
|
63 | - else { |
|
64 | - header('Content-Type: image/png'); |
|
65 | - } |
|
60 | + if ($type == 'jpg') { |
|
61 | + header('Content-Type: image/jpeg'); |
|
62 | + } |
|
63 | + else { |
|
64 | + header('Content-Type: image/png'); |
|
65 | + } |
|
66 | 66 | //by default, we don't cache |
67 | 67 | $thumbnailCacheFullpath = null; |
68 | 68 | if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) { |
@@ -43,13 +43,13 @@ |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function getAllTags() { |
46 | - global $config; |
|
46 | + global $config; |
|
47 | 47 | |
48 | - $sql = self::SQL_ALL_TAGS; |
|
49 | - $sortField = $config['calibre_database_field_sort']; |
|
50 | - if (!empty($sortField)) { |
|
51 | - $sql = str_replace('tags.name', 'tags.' . $sortField, $sql); |
|
52 | - } |
|
48 | + $sql = self::SQL_ALL_TAGS; |
|
49 | + $sortField = $config['calibre_database_field_sort']; |
|
50 | + if (!empty($sortField)) { |
|
51 | + $sql = str_replace('tags.name', 'tags.' . $sortField, $sql); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag"); |
55 | 55 | } |