@@ -208,6 +208,9 @@ discard block |
||
| 208 | 208 | return 'index.php' . $urlParam; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | + /** |
|
| 212 | + * @return string |
|
| 213 | + */ |
|
| 211 | 214 | public function getTitle () { |
| 212 | 215 | return $this->title; |
| 213 | 216 | } |
@@ -395,6 +398,9 @@ discard block |
||
| 395 | 398 | return reset($reduced); |
| 396 | 399 | } |
| 397 | 400 | |
| 401 | + /** |
|
| 402 | + * @param string $extension |
|
| 403 | + */ |
|
| 398 | 404 | public function getFilePath($extension, $idData = NULL, $relative = false) |
| 399 | 405 | { |
| 400 | 406 | /*if ($extension == 'jpg') |
@@ -562,6 +568,9 @@ discard block |
||
| 562 | 568 | $this->getLinkArray(), $this); |
| 563 | 569 | } |
| 564 | 570 | |
| 571 | + /** |
|
| 572 | + * @param integer $database |
|
| 573 | + */ |
|
| 565 | 574 | public static function getBookCount($database = NULL) { |
| 566 | 575 | return parent::executeQuerySingle('select count(*) from books', $database); |
| 567 | 576 | } |
@@ -610,7 +619,7 @@ discard block |
||
| 610 | 619 | } |
| 611 | 620 | |
| 612 | 621 | /** |
| 613 | - * @param $customColumn CustomColumn |
|
| 622 | + * @param CustomColumn $customColumn CustomColumn |
|
| 614 | 623 | * @param $id integer |
| 615 | 624 | * @param $n integer |
| 616 | 625 | * @return array |
@@ -650,6 +659,10 @@ discard block |
||
| 650 | 659 | return NULL; |
| 651 | 660 | } |
| 652 | 661 | |
| 662 | + /** |
|
| 663 | + * @param integer $database |
|
| 664 | + * @param integer $numberPerPage |
|
| 665 | + */ |
|
| 653 | 666 | public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
| 654 | 667 | $i = 0; |
| 655 | 668 | $critArray = array(); |
@@ -697,6 +710,9 @@ discard block |
||
| 697 | 710 | return $entryArray; |
| 698 | 711 | } |
| 699 | 712 | |
| 713 | + /** |
|
| 714 | + * @param integer $numberPerPage |
|
| 715 | + */ |
|
| 700 | 716 | public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { |
| 701 | 717 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); |
| 702 | 718 | } |
@@ -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()) |
@@ -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) { |
@@ -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'] !== '' ) { |
@@ -54,6 +54,10 @@ |
||
| 54 | 54 | return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag"); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | + /** |
|
| 58 | + * @param string $query |
|
| 59 | + * @param integer $numberPerPage |
|
| 60 | + */ |
|
| 57 | 61 | public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
| 58 | 62 | $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count"; |
| 59 | 63 | $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name'; |
@@ -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 | } |