@@ -24,69 +24,69 @@ |
||
| 24 | 24 | $this->sort = $post->sort; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function getUri () { |
|
| 28 | - return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id"; |
|
| 27 | + public function getUri() { |
|
| 28 | + return "?page=" . parent::PAGE_AUTHOR_DETAIL . "&id=$this->id"; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function getEntryId () { |
|
| 32 | - return self::ALL_AUTHORS_ID.":".$this->id; |
|
| 31 | + public function getEntryId() { |
|
| 32 | + return self::ALL_AUTHORS_ID . ":" . $this->id; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function getEntryIdByLetter ($startingLetter) { |
|
| 36 | - return self::ALL_AUTHORS_ID.":letter:".$startingLetter; |
|
| 35 | + public static function getEntryIdByLetter($startingLetter) { |
|
| 36 | + return self::ALL_AUTHORS_ID . ":letter:" . $startingLetter; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public static function getCount() { |
| 40 | 40 | // str_format (localize("authors.alphabetical", count(array)) |
| 41 | - return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); |
|
| 41 | + return parent::getCountGeneric("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public static function getAllAuthorsByFirstLetter() { |
| 45 | - list (, $result) = parent::executeQuery ("select {0} |
|
| 45 | + list (, $result) = parent::executeQuery("select {0} |
|
| 46 | 46 | from authors |
| 47 | 47 | group by substr (upper (sort), 1, 1) |
| 48 | -order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1); |
|
| 48 | +order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1); |
|
| 49 | 49 | $entryArray = array(); |
| 50 | - while ($post = $result->fetchObject ()) |
|
| 50 | + while ($post = $result->fetchObject()) |
|
| 51 | 51 | { |
| 52 | - array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title), |
|
| 53 | - str_format (localize("authorword", $post->count), $post->count), "text", |
|
| 54 | - array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); |
|
| 52 | + array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title), |
|
| 53 | + str_format(localize("authorword", $post->count), $post->count), "text", |
|
| 54 | + array(new LinkNavigation("?page=" . parent::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count)); |
|
| 55 | 55 | } |
| 56 | 56 | return $entryArray; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function getAuthorsByStartingLetter($letter) { |
| 60 | - return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); |
|
| 60 | + return self::getEntryArray(self::SQL_AUTHORS_BY_FIRST_LETTER, array($letter . "%")); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public static function getAuthorsForSearch($query) { |
| 64 | - return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); |
|
| 64 | + return self::getEntryArray(self::SQL_AUTHORS_FOR_SEARCH, array($query . "%", $query . "%")); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public static function getAllAuthors() { |
| 68 | - return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); |
|
| 68 | + return self::getEntryArray(self::SQL_ALL_AUTHORS, array()); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public static function getEntryArray ($query, $params) { |
|
| 72 | - return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); |
|
| 71 | + public static function getEntryArray($query, $params) { |
|
| 72 | + return Base::getEntryArrayWithBookNumber($query, self::AUTHOR_COLUMNS, $params, "Author"); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function getAuthorById ($authorId) { |
|
| 76 | - $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); |
|
| 77 | - $result->execute (array ($authorId)); |
|
| 78 | - $post = $result->fetchObject (); |
|
| 79 | - return new Author ($post); |
|
| 75 | + public static function getAuthorById($authorId) { |
|
| 76 | + $result = parent::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); |
|
| 77 | + $result->execute(array($authorId)); |
|
| 78 | + $post = $result->fetchObject(); |
|
| 79 | + return new Author($post); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public static function getAuthorByBookId ($bookId) { |
|
| 83 | - $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link |
|
| 82 | + public static function getAuthorByBookId($bookId) { |
|
| 83 | + $result = parent::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link |
|
| 84 | 84 | where author = authors.id |
| 85 | 85 | and book = ?'); |
| 86 | - $result->execute (array ($bookId)); |
|
| 87 | - $authorArray = array (); |
|
| 88 | - while ($post = $result->fetchObject ()) { |
|
| 89 | - array_push ($authorArray, new Author ($post)); |
|
| 86 | + $result->execute(array($bookId)); |
|
| 87 | + $authorArray = array(); |
|
| 88 | + while ($post = $result->fetchObject()) { |
|
| 89 | + array_push($authorArray, new Author($post)); |
|
| 90 | 90 | } |
| 91 | 91 | return $authorArray; |
| 92 | 92 | } |
@@ -11,15 +11,15 @@ discard block |
||
| 11 | 11 | require_once ("config.php"); |
| 12 | 12 | require_once ("base.php"); |
| 13 | 13 | |
| 14 | -header ("Content-Type: text/html;charset=utf-8"); |
|
| 14 | +header("Content-Type: text/html;charset=utf-8"); |
|
| 15 | 15 | |
| 16 | -$idData = getURLParam ("data", NULL); |
|
| 16 | +$idData = getURLParam("data", NULL); |
|
| 17 | 17 | $add = "data=$idData&"; |
| 18 | -if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&"; |
|
| 18 | +if (!is_null(GetUrlParam(DB))) $add .= DB . "=" . GetUrlParam(DB) . "&"; |
|
| 19 | 19 | $myBook = Book::getBookByDataId($idData); |
| 20 | 20 | |
| 21 | -$book = new EPub ($myBook->getFilePath ("EPUB", $idData)); |
|
| 22 | -$book->initSpineComponent (); |
|
| 21 | +$book = new EPub($myBook->getFilePath("EPUB", $idData)); |
|
| 22 | +$book->initSpineComponent(); |
|
| 23 | 23 | |
| 24 | 24 | ?> |
| 25 | 25 | <head> |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | Monocle.DEBUG = true; |
| 36 | 36 | var bookData = { |
| 37 | 37 | getComponents: function () { |
| 38 | - <?php echo "return [" . implode (", ", array_map (function ($comp) { return "'" . $comp . "'"; }, $book->components ())) . "];"; ?> |
|
| 38 | + <?php echo "return [" . implode(", ", array_map(function($comp) { return "'" . $comp . "'"; }, $book->components())) . "];"; ?> |
|
| 39 | 39 | }, |
| 40 | 40 | getContents: function () { |
| 41 | - <?php echo "return [" . implode (", ", array_map (function ($content) { return "{title: '" . addslashes($content["title"]) . "', src: '". $content["src"] . "'}"; }, $book->contents ())) . "];"; ?> |
|
| 41 | + <?php echo "return [" . implode(", ", array_map(function($content) { return "{title: '" . addslashes($content["title"]) . "', src: '" . $content["src"] . "'}"; }, $book->contents())) . "];"; ?> |
|
| 42 | 42 | }, |
| 43 | 43 | getComponent: function (componentId) { |
| 44 | 44 | return { url: "epubfs.php?<?php echo $add ?>comp=" + componentId }; |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | require_once ("config.php"); |
| 11 | 11 | require_once ("base.php"); |
| 12 | 12 | |
| 13 | - header ("Content-Type:application/xml"); |
|
| 14 | - $page = getURLParam ("page", Base::PAGE_INDEX); |
|
| 15 | - $query = getURLParam ("query"); |
|
| 16 | - $n = getURLParam ("n", "1"); |
|
| 13 | + header("Content-Type:application/xml"); |
|
| 14 | + $page = getURLParam("page", Base::PAGE_INDEX); |
|
| 15 | + $query = getURLParam("query"); |
|
| 16 | + $n = getURLParam("n", "1"); |
|
| 17 | 17 | if ($query) |
| 18 | 18 | $page = Base::PAGE_OPENSEARCH_QUERY; |
| 19 | - $qid = getURLParam ("id"); |
|
| 19 | + $qid = getURLParam("id"); |
|
| 20 | 20 | |
| 21 | 21 | if ($config ['cops_fetch_protect'] == "1") { |
| 22 | 22 | session_start(); |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $OPDSRender = new OPDSRenderer (); |
|
| 28 | + $OPDSRender = new OPDSRenderer(); |
|
| 29 | 29 | |
| 30 | 30 | switch ($page) { |
| 31 | 31 | case Base::PAGE_OPENSEARCH : |
| 32 | - echo $OPDSRender->getOpenSearch (); |
|
| 32 | + echo $OPDSRender->getOpenSearch(); |
|
| 33 | 33 | return; |
| 34 | 34 | default: |
| 35 | - $currentPage = Page::getPage ($page, $qid, $query, $n); |
|
| 36 | - $currentPage->InitializeContent (); |
|
| 37 | - echo $OPDSRender->render ($currentPage); |
|
| 35 | + $currentPage = Page::getPage($page, $qid, $query, $n); |
|
| 36 | + $currentPage->InitializeContent(); |
|
| 37 | + echo $OPDSRender->render($currentPage); |
|
| 38 | 38 | return; |
| 39 | 39 | } |
@@ -10,135 +10,135 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class JSONRenderer |
| 12 | 12 | { |
| 13 | - public static function getBookContentArray ($book) { |
|
| 13 | + public static function getBookContentArray($book) { |
|
| 14 | 14 | global $config; |
| 15 | 15 | $i = 0; |
| 16 | - $preferedData = array (); |
|
| 16 | + $preferedData = array(); |
|
| 17 | 17 | foreach ($config['cops_prefered_format'] as $format) |
| 18 | 18 | { |
| 19 | 19 | if ($i == 2) { break; } |
| 20 | - if ($data = $book->getDataFormat ($format)) { |
|
| 20 | + if ($data = $book->getDataFormat($format)) { |
|
| 21 | 21 | $i++; |
| 22 | - array_push ($preferedData, array ("url" => $data->getHtmlLink (), "name" => $format)); |
|
| 22 | + array_push($preferedData, array("url" => $data->getHtmlLink(), "name" => $format)); |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $publisher = $book->getPublisher(); |
| 27 | - if (is_null ($publisher)) { |
|
| 27 | + if (is_null($publisher)) { |
|
| 28 | 28 | $pn = ""; |
| 29 | 29 | $pu = ""; |
| 30 | 30 | } else { |
| 31 | 31 | $pn = $publisher->name; |
| 32 | - $link = new LinkNavigation ($publisher->getUri ()); |
|
| 33 | - $pu = $link->hrefXhtml (); |
|
| 32 | + $link = new LinkNavigation($publisher->getUri()); |
|
| 33 | + $pu = $link->hrefXhtml(); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $serie = $book->getSerie (); |
|
| 37 | - if (is_null ($serie)) { |
|
| 36 | + $serie = $book->getSerie(); |
|
| 37 | + if (is_null($serie)) { |
|
| 38 | 38 | $sn = ""; |
| 39 | 39 | $scn = ""; |
| 40 | 40 | $su = ""; |
| 41 | 41 | } else { |
| 42 | 42 | $sn = $serie->name; |
| 43 | - $scn = str_format (localize ("content.series.data"), $book->seriesIndex, $serie->name); |
|
| 44 | - $link = new LinkNavigation ($serie->getUri ()); |
|
| 45 | - $su = $link->hrefXhtml (); |
|
| 43 | + $scn = str_format(localize("content.series.data"), $book->seriesIndex, $serie->name); |
|
| 44 | + $link = new LinkNavigation($serie->getUri()); |
|
| 45 | + $su = $link->hrefXhtml(); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return array ("id" => $book->id, |
|
| 48 | + return array("id" => $book->id, |
|
| 49 | 49 | "hasCover" => $book->hasCover, |
| 50 | 50 | "preferedData" => $preferedData, |
| 51 | - "rating" => $book->getRating (), |
|
| 51 | + "rating" => $book->getRating(), |
|
| 52 | 52 | "publisherName" => $pn, |
| 53 | 53 | "publisherurl" => $pu, |
| 54 | - "pubDate" => $book->getPubDate (), |
|
| 55 | - "languagesName" => $book->getLanguages (), |
|
| 56 | - "authorsName" => $book->getAuthorsName (), |
|
| 57 | - "tagsName" => $book->getTagsName (), |
|
| 54 | + "pubDate" => $book->getPubDate(), |
|
| 55 | + "languagesName" => $book->getLanguages(), |
|
| 56 | + "authorsName" => $book->getAuthorsName(), |
|
| 57 | + "tagsName" => $book->getTagsName(), |
|
| 58 | 58 | "seriesName" => $sn, |
| 59 | 59 | "seriesIndex" => $book->seriesIndex, |
| 60 | 60 | "seriesCompleteName" => $scn, |
| 61 | 61 | "seriesurl" => $su); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public static function getFullBookContentArray ($book) { |
|
| 64 | + public static function getFullBookContentArray($book) { |
|
| 65 | 65 | global $config; |
| 66 | - $out = self::getBookContentArray ($book); |
|
| 67 | - $database = GetUrlParam (DB); |
|
| 68 | - |
|
| 69 | - $out ["coverurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml (); |
|
| 70 | - $out ["thumbnailurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml (); |
|
| 71 | - $out ["content"] = $book->getComment (false); |
|
| 72 | - $out ["datas"] = array (); |
|
| 73 | - $dataKindle = $book->GetMostInterestingDataToSendToKindle (); |
|
| 66 | + $out = self::getBookContentArray($book); |
|
| 67 | + $database = GetUrlParam(DB); |
|
| 68 | + |
|
| 69 | + $out ["coverurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml(); |
|
| 70 | + $out ["thumbnailurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml(); |
|
| 71 | + $out ["content"] = $book->getComment(false); |
|
| 72 | + $out ["datas"] = array(); |
|
| 73 | + $dataKindle = $book->GetMostInterestingDataToSendToKindle(); |
|
| 74 | 74 | foreach ($book->getDatas() as $data) { |
| 75 | - $tab = array ("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink (), "mail" => 0, "readerUrl" => ""); |
|
| 76 | - if (!empty ($config['cops_mail_configuration']) && !is_null ($dataKindle) && $data->id == $dataKindle->id) { |
|
| 75 | + $tab = array("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink(), "mail" => 0, "readerUrl" => ""); |
|
| 76 | + if (!empty ($config['cops_mail_configuration']) && !is_null($dataKindle) && $data->id == $dataKindle->id) { |
|
| 77 | 77 | $tab ["mail"] = 1; |
| 78 | 78 | } |
| 79 | 79 | if ($data->format == "EPUB") { |
| 80 | 80 | $tab ["readerUrl"] = "epubreader.php?data={$data->id}&db={$database}"; |
| 81 | 81 | } |
| 82 | - array_push ($out ["datas"], $tab); |
|
| 82 | + array_push($out ["datas"], $tab); |
|
| 83 | 83 | } |
| 84 | - $out ["authors"] = array (); |
|
| 85 | - foreach ($book->getAuthors () as $author) { |
|
| 86 | - $link = new LinkNavigation ($author->getUri ()); |
|
| 87 | - array_push ($out ["authors"], array ("name" => $author->name, "url" => $link->hrefXhtml ())); |
|
| 84 | + $out ["authors"] = array(); |
|
| 85 | + foreach ($book->getAuthors() as $author) { |
|
| 86 | + $link = new LinkNavigation($author->getUri()); |
|
| 87 | + array_push($out ["authors"], array("name" => $author->name, "url" => $link->hrefXhtml())); |
|
| 88 | 88 | } |
| 89 | - $out ["tags"] = array (); |
|
| 90 | - foreach ($book->getTags () as $tag) { |
|
| 91 | - $link = new LinkNavigation ($tag->getUri ()); |
|
| 92 | - array_push ($out ["tags"], array ("name" => $tag->name, "url" => $link->hrefXhtml ())); |
|
| 89 | + $out ["tags"] = array(); |
|
| 90 | + foreach ($book->getTags() as $tag) { |
|
| 91 | + $link = new LinkNavigation($tag->getUri()); |
|
| 92 | + array_push($out ["tags"], array("name" => $tag->name, "url" => $link->hrefXhtml())); |
|
| 93 | 93 | } |
| 94 | 94 | ; |
| 95 | 95 | return $out; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public static function getContentArray ($entry) { |
|
| 98 | + public static function getContentArray($entry) { |
|
| 99 | 99 | if ($entry instanceof EntryBook) { |
| 100 | - $out = array ( "title" => $entry->title); |
|
| 101 | - $out ["book"] = self::getBookContentArray ($entry->book); |
|
| 100 | + $out = array("title" => $entry->title); |
|
| 101 | + $out ["book"] = self::getBookContentArray($entry->book); |
|
| 102 | 102 | return $out; |
| 103 | 103 | } |
| 104 | - return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement ); |
|
| 104 | + return array("title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink(), "number" => $entry->numberOfElement); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public static function getContentArrayTypeahead ($page) { |
|
| 108 | - $out = array (); |
|
| 107 | + public static function getContentArrayTypeahead($page) { |
|
| 108 | + $out = array(); |
|
| 109 | 109 | foreach ($page->entryArray as $entry) { |
| 110 | 110 | if ($entry instanceof EntryBook) { |
| 111 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ())); |
|
| 111 | + array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl())); |
|
| 112 | 112 | } else { |
| 113 | - if (empty ($entry->className) xor Base::noDatabaseSelected ()) { |
|
| 114 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ())); |
|
| 113 | + if (empty ($entry->className) xor Base::noDatabaseSelected()) { |
|
| 114 | + array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink())); |
|
| 115 | 115 | } else { |
| 116 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ())); |
|
| 116 | + array_push($out, array("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink())); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | return $out; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public static function addCompleteArray ($in) { |
|
| 123 | + public static function addCompleteArray($in) { |
|
| 124 | 124 | global $config; |
| 125 | 125 | $out = $in; |
| 126 | 126 | |
| 127 | - $out ["c"] = array ("version" => VERSION, "i18n" => array ( |
|
| 127 | + $out ["c"] = array("version" => VERSION, "i18n" => array( |
|
| 128 | 128 | "coverAlt" => localize("i18n.coversection"), |
| 129 | 129 | "authorsTitle" => localize("authors.title"), |
| 130 | 130 | "bookwordTitle" => localize("bookword.title"), |
| 131 | 131 | "tagsTitle" => localize("tags.title"), |
| 132 | 132 | "seriesTitle" => localize("series.title"), |
| 133 | - "customizeTitle" => localize ("customize.title"), |
|
| 134 | - "aboutTitle" => localize ("about.title"), |
|
| 135 | - "previousAlt" => localize ("paging.previous.alternate"), |
|
| 136 | - "nextAlt" => localize ("paging.next.alternate"), |
|
| 137 | - "searchAlt" => localize ("search.alternate"), |
|
| 138 | - "sortAlt" => localize ("sort.alternate"), |
|
| 139 | - "homeAlt" => localize ("home.alternate"), |
|
| 140 | - "cogAlt" => localize ("cog.alternate"), |
|
| 141 | - "permalinkAlt" => localize ("permalink.alternate"), |
|
| 133 | + "customizeTitle" => localize("customize.title"), |
|
| 134 | + "aboutTitle" => localize("about.title"), |
|
| 135 | + "previousAlt" => localize("paging.previous.alternate"), |
|
| 136 | + "nextAlt" => localize("paging.next.alternate"), |
|
| 137 | + "searchAlt" => localize("search.alternate"), |
|
| 138 | + "sortAlt" => localize("sort.alternate"), |
|
| 139 | + "homeAlt" => localize("home.alternate"), |
|
| 140 | + "cogAlt" => localize("cog.alternate"), |
|
| 141 | + "permalinkAlt" => localize("permalink.alternate"), |
|
| 142 | 142 | "publisherName" => localize("publisher.name"), |
| 143 | 143 | "pubdateTitle" => localize("pubdate.title"), |
| 144 | 144 | "languagesTitle" => localize("language.title"), |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | "sortorderAsc" => localize("search.sortorder.asc"), |
| 147 | 147 | "sortorderDesc" => localize("search.sortorder.desc"), |
| 148 | 148 | "customizeEmail" => localize("customize.email")), |
| 149 | - "url" => array ( |
|
| 149 | + "url" => array( |
|
| 150 | 150 | "detailUrl" => "index.php?page=13&id={0}&db={1}", |
| 151 | 151 | "coverUrl" => "fetch.php?id={0}&db={1}", |
| 152 | 152 | "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), |
| 153 | - "config" => array ( |
|
| 153 | + "config" => array( |
|
| 154 | 154 | "use_fancyapps" => $config ["cops_use_fancyapps"], |
| 155 | 155 | "max_item_per_page" => $config['cops_max_item_per_page'], |
| 156 | 156 | "kindleHack" => "", |
| 157 | - "server_side_rendering" => useServerSideRendering (), |
|
| 157 | + "server_side_rendering" => useServerSideRendering(), |
|
| 158 | 158 | "html_tag_filter" => $config['cops_html_tag_filter'])); |
| 159 | 159 | if ($config['cops_thumbnail_handling'] == "1") { |
| 160 | 160 | $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"]; |
@@ -167,32 +167,32 @@ discard block |
||
| 167 | 167 | return $out; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public static function getJson ($complete = false) { |
|
| 170 | + public static function getJson($complete = false) { |
|
| 171 | 171 | global $config; |
| 172 | - $page = getURLParam ("page", Base::PAGE_INDEX); |
|
| 173 | - $query = getURLParam ("query"); |
|
| 174 | - $search = getURLParam ("search"); |
|
| 175 | - $qid = getURLParam ("id"); |
|
| 176 | - $n = getURLParam ("n", "1"); |
|
| 177 | - $database = GetUrlParam (DB); |
|
| 172 | + $page = getURLParam("page", Base::PAGE_INDEX); |
|
| 173 | + $query = getURLParam("query"); |
|
| 174 | + $search = getURLParam("search"); |
|
| 175 | + $qid = getURLParam("id"); |
|
| 176 | + $n = getURLParam("n", "1"); |
|
| 177 | + $database = GetUrlParam(DB); |
|
| 178 | 178 | |
| 179 | - $currentPage = Page::getPage ($page, $qid, $query, $n); |
|
| 180 | - $currentPage->InitializeContent (); |
|
| 179 | + $currentPage = Page::getPage($page, $qid, $query, $n); |
|
| 180 | + $currentPage->InitializeContent(); |
|
| 181 | 181 | |
| 182 | 182 | if ($search) { |
| 183 | - return self::getContentArrayTypeahead ($currentPage); |
|
| 183 | + return self::getContentArrayTypeahead($currentPage); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $out = array ( "title" => $currentPage->title); |
|
| 187 | - $entries = array (); |
|
| 186 | + $out = array("title" => $currentPage->title); |
|
| 187 | + $entries = array(); |
|
| 188 | 188 | foreach ($currentPage->entryArray as $entry) { |
| 189 | - array_push ($entries, self::getContentArray ($entry)); |
|
| 189 | + array_push($entries, self::getContentArray($entry)); |
|
| 190 | 190 | } |
| 191 | - if (!is_null ($currentPage->book)) { |
|
| 192 | - $out ["book"] = self::getFullBookContentArray ($currentPage->book); |
|
| 191 | + if (!is_null($currentPage->book)) { |
|
| 192 | + $out ["book"] = self::getFullBookContentArray($currentPage->book); |
|
| 193 | 193 | } |
| 194 | - $out ["databaseId"] = GetUrlParam (DB, ""); |
|
| 195 | - $out ["databaseName"] = Base::getDbName (); |
|
| 194 | + $out ["databaseId"] = GetUrlParam(DB, ""); |
|
| 195 | + $out ["databaseName"] = Base::getDbName(); |
|
| 196 | 196 | if ($out ["databaseId"] == "") { |
| 197 | 197 | $out ["databaseName"] = ""; |
| 198 | 198 | } |
@@ -201,42 +201,42 @@ discard block |
||
| 201 | 201 | $out ["fullTitle"] = $out ["databaseName"] . " > " . $out ["fullTitle"]; |
| 202 | 202 | } |
| 203 | 203 | $out ["page"] = $page; |
| 204 | - $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled () ? 1 : 0; |
|
| 204 | + $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled()?1:0; |
|
| 205 | 205 | $out ["entries"] = $entries; |
| 206 | 206 | $out ["isPaginated"] = 0; |
| 207 | - if ($currentPage->isPaginated ()) { |
|
| 208 | - $prevLink = $currentPage->getPrevLink (); |
|
| 209 | - $nextLink = $currentPage->getNextLink (); |
|
| 207 | + if ($currentPage->isPaginated()) { |
|
| 208 | + $prevLink = $currentPage->getPrevLink(); |
|
| 209 | + $nextLink = $currentPage->getNextLink(); |
|
| 210 | 210 | $out ["isPaginated"] = 1; |
| 211 | 211 | $out ["prevLink"] = ""; |
| 212 | - if (!is_null ($prevLink)) { |
|
| 213 | - $out ["prevLink"] = $prevLink->hrefXhtml (); |
|
| 212 | + if (!is_null($prevLink)) { |
|
| 213 | + $out ["prevLink"] = $prevLink->hrefXhtml(); |
|
| 214 | 214 | } |
| 215 | 215 | $out ["nextLink"] = ""; |
| 216 | - if (!is_null ($nextLink)) { |
|
| 217 | - $out ["nextLink"] = $nextLink->hrefXhtml (); |
|
| 216 | + if (!is_null($nextLink)) { |
|
| 217 | + $out ["nextLink"] = $nextLink->hrefXhtml(); |
|
| 218 | 218 | } |
| 219 | - $out ["maxPage"] = $currentPage->getMaxPage (); |
|
| 219 | + $out ["maxPage"] = $currentPage->getMaxPage(); |
|
| 220 | 220 | $out ["currentPage"] = $currentPage->n; |
| 221 | 221 | } |
| 222 | - if (!is_null (getURLParam ("complete")) || $complete) { |
|
| 223 | - $out = self::addCompleteArray ($out); |
|
| 222 | + if (!is_null(getURLParam("complete")) || $complete) { |
|
| 223 | + $out = self::addCompleteArray($out); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $out ["containsBook"] = 0; |
| 227 | - if ($currentPage->containsBook ()) { |
|
| 227 | + if ($currentPage->containsBook()) { |
|
| 228 | 228 | $out ["containsBook"] = 1; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $out["abouturl"] = "index.php" . addURLParameter ("?page=" . Base::PAGE_ABOUT, DB, $database); |
|
| 231 | + $out["abouturl"] = "index.php" . addURLParameter("?page=" . Base::PAGE_ABOUT, DB, $database); |
|
| 232 | 232 | |
| 233 | 233 | if ($page == Base::PAGE_ABOUT) { |
| 234 | - $temp = preg_replace ("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html')); |
|
| 234 | + $temp = preg_replace("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html')); |
|
| 235 | 235 | $out ["fullhtml"] = $temp; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | $out ["homeurl"] = "index.php"; |
| 239 | - if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter ("", DB, $database); |
|
| 239 | + if ($page != Base::PAGE_INDEX && !is_null($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter("", DB, $database); |
|
| 240 | 240 | |
| 241 | 241 | return $out; |
| 242 | 242 | } |
@@ -7,35 +7,35 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Silly thing because PHP forbid string concatenation in class const |
| 10 | -define ('SQL_BOOKS_LEFT_JOIN', "left outer join comments on comments.book = books.id |
|
| 10 | +define('SQL_BOOKS_LEFT_JOIN', "left outer join comments on comments.book = books.id |
|
| 11 | 11 | left outer join books_ratings_link on books_ratings_link.book = books.id |
| 12 | 12 | left outer join ratings on books_ratings_link.rating = ratings.id "); |
| 13 | -define ('SQL_BOOKS_ALL', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " order by books.sort "); |
|
| 14 | -define ('SQL_BOOKS_BY_PUBLISHER', "select {0} from books_publishers_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 13 | +define('SQL_BOOKS_ALL', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " order by books.sort "); |
|
| 14 | +define('SQL_BOOKS_BY_PUBLISHER', "select {0} from books_publishers_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 15 | 15 | where books_publishers_link.book = books.id and publisher = ? {1} order by publisher"); |
| 16 | -define ('SQL_BOOKS_BY_FIRST_LETTER', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 16 | +define('SQL_BOOKS_BY_FIRST_LETTER', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 17 | 17 | where upper (books.sort) like ? order by books.sort"); |
| 18 | -define ('SQL_BOOKS_BY_AUTHOR', "select {0} from books_authors_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 18 | +define('SQL_BOOKS_BY_AUTHOR', "select {0} from books_authors_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 19 | 19 | left outer join books_series_link on books_series_link.book = books.id |
| 20 | 20 | where books_authors_link.book = books.id and author = ? {1} order by series desc, series_index asc, pubdate asc"); |
| 21 | -define ('SQL_BOOKS_BY_SERIE', "select {0} from books_series_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 21 | +define('SQL_BOOKS_BY_SERIE', "select {0} from books_series_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 22 | 22 | where books_series_link.book = books.id and series = ? {1} order by series_index"); |
| 23 | -define ('SQL_BOOKS_BY_TAG', "select {0} from books_tags_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 23 | +define('SQL_BOOKS_BY_TAG', "select {0} from books_tags_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 24 | 24 | where books_tags_link.book = books.id and tag = ? {1} order by sort"); |
| 25 | -define ('SQL_BOOKS_BY_LANGUAGE', "select {0} from books_languages_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 25 | +define('SQL_BOOKS_BY_LANGUAGE', "select {0} from books_languages_link, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 26 | 26 | where books_languages_link.book = books.id and lang_code = ? {1} order by sort"); |
| 27 | -define ('SQL_BOOKS_BY_CUSTOM', "select {0} from {2}, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 27 | +define('SQL_BOOKS_BY_CUSTOM', "select {0} from {2}, books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 28 | 28 | where {2}.book = books.id and {2}.{3} = ? {1} order by sort"); |
| 29 | -define ('SQL_BOOKS_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 29 | +define('SQL_BOOKS_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 30 | 30 | where ( |
| 31 | 31 | exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or |
| 32 | 32 | exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or |
| 33 | 33 | exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or |
| 34 | 34 | exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or |
| 35 | 35 | title like ?) {1} order by books.sort"); |
| 36 | -define ('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 36 | +define('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 37 | 37 | where 1=1 {1} order by timestamp desc limit "); |
| 38 | -define ('SQL_BOOKS_BY_RATING', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 38 | +define('SQL_BOOKS_BY_RATING', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . " |
|
| 39 | 39 | where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort"); |
| 40 | 40 | |
| 41 | 41 | class Book extends Base { |
@@ -76,133 +76,133 @@ discard block |
||
| 76 | 76 | public $serie = NULL; |
| 77 | 77 | public $tags = NULL; |
| 78 | 78 | public $languages = NULL; |
| 79 | - public $format = array (); |
|
| 79 | + public $format = array(); |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | public function __construct($line) { |
| 83 | 83 | $this->id = $line->id; |
| 84 | 84 | $this->title = $line->title; |
| 85 | - $this->timestamp = strtotime ($line->timestamp); |
|
| 85 | + $this->timestamp = strtotime($line->timestamp); |
|
| 86 | 86 | $this->pubdate = $line->pubdate; |
| 87 | - $this->path = Base::getDbDirectory () . $line->path; |
|
| 87 | + $this->path = Base::getDbDirectory() . $line->path; |
|
| 88 | 88 | $this->relativePath = $line->path; |
| 89 | 89 | $this->seriesIndex = $line->series_index; |
| 90 | 90 | $this->comment = $line->comment; |
| 91 | 91 | $this->uuid = $line->uuid; |
| 92 | 92 | $this->hasCover = $line->has_cover; |
| 93 | - if (!file_exists ($this->getFilePath ("jpg"))) { |
|
| 93 | + if (!file_exists($this->getFilePath("jpg"))) { |
|
| 94 | 94 | // double check |
| 95 | 95 | $this->hasCover = 0; |
| 96 | 96 | } |
| 97 | 97 | $this->rating = $line->rating; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function getEntryId () { |
|
| 101 | - return self::ALL_BOOKS_UUID.":".$this->uuid; |
|
| 100 | + public function getEntryId() { |
|
| 101 | + return self::ALL_BOOKS_UUID . ":" . $this->uuid; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public static function getEntryIdByLetter ($startingLetter) { |
|
| 105 | - return self::ALL_BOOKS_ID.":letter:".$startingLetter; |
|
| 104 | + public static function getEntryIdByLetter($startingLetter) { |
|
| 105 | + return self::ALL_BOOKS_ID . ":letter:" . $startingLetter; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function getUri () { |
|
| 109 | - return "?page=".parent::PAGE_BOOK_DETAIL."&id=$this->id"; |
|
| 108 | + public function getUri() { |
|
| 109 | + return "?page=" . parent::PAGE_BOOK_DETAIL . "&id=$this->id"; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function getDetailUrl () { |
|
| 113 | - $urlParam = $this->getUri (); |
|
| 114 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
| 112 | + public function getDetailUrl() { |
|
| 113 | + $urlParam = $this->getUri(); |
|
| 114 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
| 115 | 115 | return 'index.php' . $urlParam; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function getTitle () { |
|
| 118 | + public function getTitle() { |
|
| 119 | 119 | return $this->title; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /* Other class (author, series, tag, ...) initialization and accessors */ |
| 123 | 123 | |
| 124 | - public function getAuthors () { |
|
| 125 | - if (is_null ($this->authors)) { |
|
| 126 | - $this->authors = Author::getAuthorByBookId ($this->id); |
|
| 124 | + public function getAuthors() { |
|
| 125 | + if (is_null($this->authors)) { |
|
| 126 | + $this->authors = Author::getAuthorByBookId($this->id); |
|
| 127 | 127 | } |
| 128 | 128 | return $this->authors; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function getAuthorsName () { |
|
| 132 | - return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ())); |
|
| 131 | + public function getAuthorsName() { |
|
| 132 | + return implode(", ", array_map(function($author) { return $author->name; }, $this->getAuthors())); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public function getAuthorsSort () { |
|
| 136 | - return implode (", ", array_map (function ($author) { return $author->sort; }, $this->getAuthors ())); |
|
| 135 | + public function getAuthorsSort() { |
|
| 136 | + return implode(", ", array_map(function($author) { return $author->sort; }, $this->getAuthors())); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function getPublisher () { |
|
| 140 | - if (is_null ($this->publisher)) { |
|
| 141 | - $this->publisher = Publisher::getPublisherByBookId ($this->id); |
|
| 139 | + public function getPublisher() { |
|
| 140 | + if (is_null($this->publisher)) { |
|
| 141 | + $this->publisher = Publisher::getPublisherByBookId($this->id); |
|
| 142 | 142 | } |
| 143 | 143 | return $this->publisher; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function getSerie () { |
|
| 147 | - if (is_null ($this->serie)) { |
|
| 148 | - $this->serie = Serie::getSerieByBookId ($this->id); |
|
| 146 | + public function getSerie() { |
|
| 147 | + if (is_null($this->serie)) { |
|
| 148 | + $this->serie = Serie::getSerieByBookId($this->id); |
|
| 149 | 149 | } |
| 150 | 150 | return $this->serie; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - public function getLanguages () { |
|
| 154 | - $lang = array (); |
|
| 155 | - $result = parent::getDb ()->prepare('select languages.lang_code |
|
| 153 | + public function getLanguages() { |
|
| 154 | + $lang = array(); |
|
| 155 | + $result = parent::getDb()->prepare('select languages.lang_code |
|
| 156 | 156 | from books_languages_link, languages |
| 157 | 157 | where books_languages_link.lang_code = languages.id |
| 158 | 158 | and book = ? |
| 159 | 159 | order by item_order'); |
| 160 | - $result->execute (array ($this->id)); |
|
| 161 | - while ($post = $result->fetchObject ()) |
|
| 160 | + $result->execute(array($this->id)); |
|
| 161 | + while ($post = $result->fetchObject()) |
|
| 162 | 162 | { |
| 163 | - array_push ($lang, Language::getLanguageString($post->lang_code)); |
|
| 163 | + array_push($lang, Language::getLanguageString($post->lang_code)); |
|
| 164 | 164 | } |
| 165 | - return implode (", ", $lang); |
|
| 165 | + return implode(", ", $lang); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - public function getTags () { |
|
| 169 | - if (is_null ($this->tags)) { |
|
| 170 | - $this->tags = array (); |
|
| 168 | + public function getTags() { |
|
| 169 | + if (is_null($this->tags)) { |
|
| 170 | + $this->tags = array(); |
|
| 171 | 171 | |
| 172 | - $result = parent::getDb ()->prepare('select tags.id as id, name |
|
| 172 | + $result = parent::getDb()->prepare('select tags.id as id, name |
|
| 173 | 173 | from books_tags_link, tags |
| 174 | 174 | where tag = tags.id |
| 175 | 175 | and book = ? |
| 176 | 176 | order by name'); |
| 177 | - $result->execute (array ($this->id)); |
|
| 178 | - while ($post = $result->fetchObject ()) |
|
| 177 | + $result->execute(array($this->id)); |
|
| 178 | + while ($post = $result->fetchObject()) |
|
| 179 | 179 | { |
| 180 | - array_push ($this->tags, new Tag ($post)); |
|
| 180 | + array_push($this->tags, new Tag($post)); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | return $this->tags; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function getTagsName () { |
|
| 187 | - return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ())); |
|
| 186 | + public function getTagsName() { |
|
| 187 | + return implode(", ", array_map(function($tag) { return $tag->name; }, $this->getTags())); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - public function getDatas () |
|
| 190 | + public function getDatas() |
|
| 191 | 191 | { |
| 192 | - if (is_null ($this->datas)) { |
|
| 193 | - $this->datas = Data::getDataByBook ($this); |
|
| 192 | + if (is_null($this->datas)) { |
|
| 193 | + $this->datas = Data::getDataByBook($this); |
|
| 194 | 194 | } |
| 195 | 195 | return $this->datas; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /* End of other class (author, series, tag, ...) initialization and accessors */ |
| 199 | 199 | |
| 200 | - public static function getFilterString () { |
|
| 201 | - $filter = getURLParam ("tag", NULL); |
|
| 200 | + public static function getFilterString() { |
|
| 201 | + $filter = getURLParam("tag", NULL); |
|
| 202 | 202 | if (empty ($filter)) return ""; |
| 203 | 203 | |
| 204 | 204 | $exists = true; |
| 205 | - if (preg_match ("/^!(.*)$/", $filter, $matches)) { |
|
| 205 | + if (preg_match("/^!(.*)$/", $filter, $matches)) { |
|
| 206 | 206 | $exists = false; |
| 207 | 207 | $filter = $matches[1]; |
| 208 | 208 | } |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | return "and " . $result; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public function GetMostInterestingDataToSendToKindle () |
|
| 219 | + public function GetMostInterestingDataToSendToKindle() |
|
| 220 | 220 | { |
| 221 | - $bestFormatForKindle = array ("EPUB", "PDF", "AZW3", "MOBI"); |
|
| 221 | + $bestFormatForKindle = array("EPUB", "PDF", "AZW3", "MOBI"); |
|
| 222 | 222 | $bestRank = -1; |
| 223 | 223 | $bestData = NULL; |
| 224 | - foreach ($this->getDatas () as $data) { |
|
| 225 | - $key = array_search ($data->format, $bestFormatForKindle); |
|
| 224 | + foreach ($this->getDatas() as $data) { |
|
| 225 | + $key = array_search($data->format, $bestFormatForKindle); |
|
| 226 | 226 | if ($key !== false && $key > $bestRank) { |
| 227 | 227 | $bestRank = $key; |
| 228 | 228 | $bestData = $data; |
@@ -231,16 +231,16 @@ discard block |
||
| 231 | 231 | return $bestData; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - public function getDataById ($idData) |
|
| 234 | + public function getDataById($idData) |
|
| 235 | 235 | { |
| 236 | - $reduced = array_filter ($this->getDatas (), function ($data) use ($idData) { |
|
| 236 | + $reduced = array_filter($this->getDatas(), function($data) use ($idData) { |
|
| 237 | 237 | return $data->id == $idData; |
| 238 | 238 | }); |
| 239 | - return reset ($reduced); |
|
| 239 | + return reset($reduced); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public function getRating () { |
|
| 243 | - if (is_null ($this->rating) || $this->rating == 0) { |
|
| 242 | + public function getRating() { |
|
| 243 | + if (is_null($this->rating) || $this->rating == 0) { |
|
| 244 | 244 | return ""; |
| 245 | 245 | } |
| 246 | 246 | $retour = ""; |
@@ -253,41 +253,41 @@ discard block |
||
| 253 | 253 | return $retour; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - public function getPubDate () { |
|
| 256 | + public function getPubDate() { |
|
| 257 | 257 | if (empty ($this->pubdate)) { |
| 258 | 258 | return ""; |
| 259 | 259 | } |
| 260 | - $dateY = (int) substr($this->pubdate, 0, 4); |
|
| 260 | + $dateY = (int)substr($this->pubdate, 0, 4); |
|
| 261 | 261 | if ($dateY > 102) { |
| 262 | 262 | return str_pad($dateY, 4, "0", STR_PAD_LEFT); |
| 263 | 263 | } |
| 264 | 264 | return ""; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - public function getComment ($withSerie = true) { |
|
| 267 | + public function getComment($withSerie = true) { |
|
| 268 | 268 | $addition = ""; |
| 269 | - $se = $this->getSerie (); |
|
| 270 | - if (!is_null ($se) && $withSerie) { |
|
| 271 | - $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format (localize ("content.series.data"), $this->seriesIndex, htmlspecialchars ($se->name)) . "<br />\n"; |
|
| 269 | + $se = $this->getSerie(); |
|
| 270 | + if (!is_null($se) && $withSerie) { |
|
| 271 | + $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format(localize("content.series.data"), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; |
|
| 272 | 272 | } |
| 273 | - if (preg_match ("/<\/(div|p|a|span)>/", $this->comment)) |
|
| 273 | + if (preg_match("/<\/(div|p|a|span)>/", $this->comment)) |
|
| 274 | 274 | { |
| 275 | - return $addition . html2xhtml ($this->comment); |
|
| 275 | + return $addition . html2xhtml($this->comment); |
|
| 276 | 276 | } |
| 277 | 277 | else |
| 278 | 278 | { |
| 279 | - return $addition . htmlspecialchars ($this->comment); |
|
| 279 | + return $addition . htmlspecialchars($this->comment); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - public function getDataFormat ($format) { |
|
| 284 | - $reduced = array_filter ($this->getDatas (), function ($data) use ($format) { |
|
| 283 | + public function getDataFormat($format) { |
|
| 284 | + $reduced = array_filter($this->getDatas(), function($data) use ($format) { |
|
| 285 | 285 | return $data->format == $format; |
| 286 | 286 | }); |
| 287 | - return reset ($reduced); |
|
| 287 | + return reset($reduced); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - public function getFilePath ($extension, $idData = NULL, $relative = false) |
|
| 290 | + public function getFilePath($extension, $idData = NULL, $relative = false) |
|
| 291 | 291 | { |
| 292 | 292 | if ($extension == "jpg") |
| 293 | 293 | { |
@@ -295,50 +295,50 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | else |
| 297 | 297 | { |
| 298 | - $data = $this->getDataById ($idData); |
|
| 298 | + $data = $this->getDataById($idData); |
|
| 299 | 299 | if (!$data) return NULL; |
| 300 | - $file = $data->name . "." . strtolower ($data->format); |
|
| 300 | + $file = $data->name . "." . strtolower($data->format); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | if ($relative) |
| 304 | 304 | { |
| 305 | - return $this->relativePath."/".$file; |
|
| 305 | + return $this->relativePath . "/" . $file; |
|
| 306 | 306 | } |
| 307 | 307 | else |
| 308 | 308 | { |
| 309 | - return $this->path."/".$file; |
|
| 309 | + return $this->path . "/" . $file; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - public function getUpdatedEpub ($idData) |
|
| 313 | + public function getUpdatedEpub($idData) |
|
| 314 | 314 | { |
| 315 | 315 | global $config; |
| 316 | - $data = $this->getDataById ($idData); |
|
| 316 | + $data = $this->getDataById($idData); |
|
| 317 | 317 | |
| 318 | 318 | try |
| 319 | 319 | { |
| 320 | - $epub = new EPub ($data->getLocalPath ()); |
|
| 320 | + $epub = new EPub($data->getLocalPath()); |
|
| 321 | 321 | |
| 322 | - $epub->Title ($this->title); |
|
| 323 | - $authorArray = array (); |
|
| 322 | + $epub->Title($this->title); |
|
| 323 | + $authorArray = array(); |
|
| 324 | 324 | foreach ($this->getAuthors() as $author) { |
| 325 | 325 | $authorArray [$author->sort] = $author->name; |
| 326 | 326 | } |
| 327 | - $epub->Authors ($authorArray); |
|
| 328 | - $epub->Language ($this->getLanguages ()); |
|
| 329 | - $epub->Description ($this->getComment (false)); |
|
| 330 | - $epub->Subjects ($this->getTagsName ()); |
|
| 331 | - $epub->Cover2 ($this->getFilePath ("jpg"), "image/jpeg"); |
|
| 332 | - $epub->Calibre ($this->uuid); |
|
| 333 | - $se = $this->getSerie (); |
|
| 334 | - if (!is_null ($se)) { |
|
| 335 | - $epub->Serie ($se->name); |
|
| 336 | - $epub->SerieIndex ($this->seriesIndex); |
|
| 327 | + $epub->Authors($authorArray); |
|
| 328 | + $epub->Language($this->getLanguages()); |
|
| 329 | + $epub->Description($this->getComment(false)); |
|
| 330 | + $epub->Subjects($this->getTagsName()); |
|
| 331 | + $epub->Cover2($this->getFilePath("jpg"), "image/jpeg"); |
|
| 332 | + $epub->Calibre($this->uuid); |
|
| 333 | + $se = $this->getSerie(); |
|
| 334 | + if (!is_null($se)) { |
|
| 335 | + $epub->Serie($se->name); |
|
| 336 | + $epub->SerieIndex($this->seriesIndex); |
|
| 337 | 337 | } |
| 338 | - if ($config['cops_provide_kepub'] == "1" && preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
|
| 339 | - $epub->updateForKepub (); |
|
| 338 | + if ($config['cops_provide_kepub'] == "1" && preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
|
| 339 | + $epub->updateForKepub(); |
|
| 340 | 340 | } |
| 341 | - $epub->download ($data->getUpdatedFilenameEpub ()); |
|
| 341 | + $epub->download($data->getUpdatedFilenameEpub()); |
|
| 342 | 342 | } |
| 343 | 343 | catch (Exception $e) |
| 344 | 344 | { |
@@ -346,25 +346,25 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - public function getThumbnail ($width, $height, $outputfile = NULL) { |
|
| 350 | - if (is_null ($width) && is_null ($height)) { |
|
| 349 | + public function getThumbnail($width, $height, $outputfile = NULL) { |
|
| 350 | + if (is_null($width) && is_null($height)) { |
|
| 351 | 351 | return false; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $file = $this->getFilePath ("jpg"); |
|
| 354 | + $file = $this->getFilePath("jpg"); |
|
| 355 | 355 | // get image size |
| 356 | 356 | if ($size = GetImageSize($file)) { |
| 357 | 357 | $w = $size[0]; |
| 358 | 358 | $h = $size[1]; |
| 359 | 359 | //set new size |
| 360 | - if (!is_null ($width)) { |
|
| 360 | + if (!is_null($width)) { |
|
| 361 | 361 | $nw = $width; |
| 362 | 362 | if ($nw >= $w) { return false; } |
| 363 | - $nh = ($nw*$h)/$w; |
|
| 363 | + $nh = ($nw * $h) / $w; |
|
| 364 | 364 | } else { |
| 365 | 365 | $nh = $height; |
| 366 | 366 | if ($nh >= $h) { return false; } |
| 367 | - $nw = ($nh*$w)/$h; |
|
| 367 | + $nw = ($nh * $w) / $h; |
|
| 368 | 368 | } |
| 369 | 369 | } else { |
| 370 | 370 | return false; |
@@ -372,129 +372,129 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | //draw the image |
| 374 | 374 | $src_img = imagecreatefromjpeg($file); |
| 375 | - $dst_img = imagecreatetruecolor($nw,$nh); |
|
| 376 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image |
|
| 377 | - imagejpeg($dst_img,$outputfile,80); |
|
| 375 | + $dst_img = imagecreatetruecolor($nw, $nh); |
|
| 376 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image |
|
| 377 | + imagejpeg($dst_img, $outputfile, 80); |
|
| 378 | 378 | imagedestroy($src_img); |
| 379 | 379 | imagedestroy($dst_img); |
| 380 | 380 | |
| 381 | 381 | return true; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - public function getLinkArray () |
|
| 384 | + public function getLinkArray() |
|
| 385 | 385 | { |
| 386 | 386 | $linkArray = array(); |
| 387 | 387 | |
| 388 | 388 | if ($this->hasCover) |
| 389 | 389 | { |
| 390 | - array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)); |
|
| 390 | + array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)); |
|
| 391 | 391 | |
| 392 | - array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL)); |
|
| 392 | + array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL)); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - foreach ($this->getDatas () as $data) |
|
| 395 | + foreach ($this->getDatas() as $data) |
|
| 396 | 396 | { |
| 397 | - if ($data->isKnownType ()) |
|
| 397 | + if ($data->isKnownType()) |
|
| 398 | 398 | { |
| 399 | - array_push ($linkArray, $data->getDataLink (Link::OPDS_ACQUISITION_TYPE, $data->format)); |
|
| 399 | + array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format)); |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - foreach ($this->getAuthors () as $author) { |
|
| 404 | - array_push ($linkArray, new LinkNavigation ($author->getUri (), "related", str_format (localize ("bookentry.author"), localize ("splitByLetter.book.other"), $author->name))); |
|
| 403 | + foreach ($this->getAuthors() as $author) { |
|
| 404 | + array_push($linkArray, new LinkNavigation($author->getUri(), "related", str_format(localize("bookentry.author"), localize("splitByLetter.book.other"), $author->name))); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - $serie = $this->getSerie (); |
|
| 408 | - if (!is_null ($serie)) { |
|
| 409 | - array_push ($linkArray, new LinkNavigation ($serie->getUri (), "related", str_format (localize ("content.series.data"), $this->seriesIndex, $serie->name))); |
|
| 407 | + $serie = $this->getSerie(); |
|
| 408 | + if (!is_null($serie)) { |
|
| 409 | + array_push($linkArray, new LinkNavigation($serie->getUri(), "related", str_format(localize("content.series.data"), $this->seriesIndex, $serie->name))); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | return $linkArray; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
| 416 | - public function getEntry () { |
|
| 417 | - return new EntryBook ($this->getTitle (), $this->getEntryId (), |
|
| 418 | - $this->getComment (), "text/html", |
|
| 419 | - $this->getLinkArray (), $this); |
|
| 416 | + public function getEntry() { |
|
| 417 | + return new EntryBook($this->getTitle(), $this->getEntryId(), |
|
| 418 | + $this->getComment(), "text/html", |
|
| 419 | + $this->getLinkArray(), $this); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | public static function getBookCount($database = NULL) { |
| 423 | - return parent::executeQuerySingle ('select count(*) from books', $database); |
|
| 423 | + return parent::executeQuerySingle('select count(*) from books', $database); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | public static function getCount() { |
| 427 | 427 | global $config; |
| 428 | - $nBooks = parent::executeQuerySingle ('select count(*) from books'); |
|
| 428 | + $nBooks = parent::executeQuerySingle('select count(*) from books'); |
|
| 429 | 429 | $result = array(); |
| 430 | - $entry = new Entry (localize ("allbooks.title"), |
|
| 430 | + $entry = new Entry(localize("allbooks.title"), |
|
| 431 | 431 | self::ALL_BOOKS_ID, |
| 432 | - str_format (localize ("allbooks.alphabetical", $nBooks), $nBooks), "text", |
|
| 433 | - array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS)), "", $nBooks); |
|
| 434 | - array_push ($result, $entry); |
|
| 432 | + str_format(localize("allbooks.alphabetical", $nBooks), $nBooks), "text", |
|
| 433 | + array(new LinkNavigation("?page=" . parent::PAGE_ALL_BOOKS)), "", $nBooks); |
|
| 434 | + array_push($result, $entry); |
|
| 435 | 435 | if ($config['cops_recentbooks_limit'] > 0) { |
| 436 | - $entry = new Entry (localize ("recent.title"), |
|
| 436 | + $entry = new Entry(localize("recent.title"), |
|
| 437 | 437 | self::ALL_RECENT_BOOKS_ID, |
| 438 | - str_format (localize ("recent.list"), $config['cops_recentbooks_limit']), "text", |
|
| 439 | - array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']); |
|
| 440 | - array_push ($result, $entry); |
|
| 438 | + str_format(localize("recent.list"), $config['cops_recentbooks_limit']), "text", |
|
| 439 | + array(new LinkNavigation("?page=" . parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']); |
|
| 440 | + array_push($result, $entry); |
|
| 441 | 441 | } |
| 442 | 442 | return $result; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | public static function getBooksByAuthor($authorId, $n) { |
| 446 | - return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n); |
|
| 446 | + return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | public static function getBooksByRating($ratingId, $n) { |
| 450 | - return self::getEntryArray (self::SQL_BOOKS_BY_RATING, array ($ratingId), $n); |
|
| 450 | + return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | public static function getBooksByPublisher($publisherId, $n) { |
| 454 | - return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n); |
|
| 454 | + return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n); |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | public static function getBooksBySeries($serieId, $n) { |
| 458 | - return self::getEntryArray (self::SQL_BOOKS_BY_SERIE, array ($serieId), $n); |
|
| 458 | + return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | public static function getBooksByTag($tagId, $n) { |
| 462 | - return self::getEntryArray (self::SQL_BOOKS_BY_TAG, array ($tagId), $n); |
|
| 462 | + return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | public static function getBooksByLanguage($languageId, $n) { |
| 466 | - return self::getEntryArray (self::SQL_BOOKS_BY_LANGUAGE, array ($languageId), $n); |
|
| 466 | + return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | public static function getBooksByCustom($customId, $id, $n) { |
| 470 | - $query = str_format (self::SQL_BOOKS_BY_CUSTOM, "{0}", "{1}", CustomColumn::getTableLinkName ($customId), CustomColumn::getTableLinkColumn ($customId)); |
|
| 471 | - return self::getEntryArray ($query, array ($id), $n); |
|
| 470 | + $query = str_format(self::SQL_BOOKS_BY_CUSTOM, "{0}", "{1}", CustomColumn::getTableLinkName($customId), CustomColumn::getTableLinkColumn($customId)); |
|
| 471 | + return self::getEntryArray($query, array($id), $n); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | public static function getBookById($bookId) { |
| 475 | - $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . ' |
|
| 475 | + $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ' |
|
| 476 | 476 | from books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
| 477 | 477 | where books.id = ?'); |
| 478 | - $result->execute (array ($bookId)); |
|
| 479 | - while ($post = $result->fetchObject ()) |
|
| 478 | + $result->execute(array($bookId)); |
|
| 479 | + while ($post = $result->fetchObject()) |
|
| 480 | 480 | { |
| 481 | - $book = new Book ($post); |
|
| 481 | + $book = new Book($post); |
|
| 482 | 482 | return $book; |
| 483 | 483 | } |
| 484 | 484 | return NULL; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | public static function getBookByDataId($dataId) { |
| 488 | - $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format |
|
| 488 | + $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format |
|
| 489 | 489 | from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
| 490 | 490 | where data.book = books.id and data.id = ?'); |
| 491 | - $result->execute (array ($dataId)); |
|
| 492 | - while ($post = $result->fetchObject ()) |
|
| 491 | + $result->execute(array($dataId)); |
|
| 492 | + while ($post = $result->fetchObject()) |
|
| 493 | 493 | { |
| 494 | - $book = new Book ($post); |
|
| 495 | - $data = new Data ($post, $book); |
|
| 494 | + $book = new Book($post); |
|
| 495 | + $data = new Data($post, $book); |
|
| 496 | 496 | $data->id = $dataId; |
| 497 | - $book->datas = array ($data); |
|
| 497 | + $book->datas = array($data); |
|
| 498 | 498 | return $book; |
| 499 | 499 | } |
| 500 | 500 | return NULL; |
@@ -502,18 +502,18 @@ discard block |
||
| 502 | 502 | |
| 503 | 503 | public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
| 504 | 504 | $i = 0; |
| 505 | - $critArray = array (); |
|
| 506 | - foreach (array (PageQueryResult::SCOPE_AUTHOR, |
|
| 505 | + $critArray = array(); |
|
| 506 | + foreach (array(PageQueryResult::SCOPE_AUTHOR, |
|
| 507 | 507 | PageQueryResult::SCOPE_TAG, |
| 508 | 508 | PageQueryResult::SCOPE_SERIES, |
| 509 | 509 | PageQueryResult::SCOPE_PUBLISHER, |
| 510 | 510 | PageQueryResult::SCOPE_BOOK) as $key) { |
| 511 | - if (in_array($key, getCurrentOption ('ignored_categories')) || |
|
| 512 | - (!array_key_exists ($key, $query) && !array_key_exists ("all", $query))) { |
|
| 511 | + if (in_array($key, getCurrentOption('ignored_categories')) || |
|
| 512 | + (!array_key_exists($key, $query) && !array_key_exists("all", $query))) { |
|
| 513 | 513 | $critArray [$i] = self::BAD_SEARCH; |
| 514 | 514 | } |
| 515 | 515 | else { |
| 516 | - if (array_key_exists ($key, $query)) { |
|
| 516 | + if (array_key_exists($key, $query)) { |
|
| 517 | 517 | $critArray [$i] = $query [$key]; |
| 518 | 518 | } else { |
| 519 | 519 | $critArray [$i] = $query ["all"]; |
@@ -521,48 +521,48 @@ discard block |
||
| 521 | 521 | } |
| 522 | 522 | $i++; |
| 523 | 523 | } |
| 524 | - return self::getEntryArray (self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage); |
|
| 524 | + return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | public static function getBooks($n) { |
| 528 | - list ($entryArray, $totalNumber) = self::getEntryArray (self::SQL_BOOKS_ALL , array (), $n); |
|
| 529 | - return array ($entryArray, $totalNumber); |
|
| 528 | + list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n); |
|
| 529 | + return array($entryArray, $totalNumber); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | public static function getAllBooks() { |
| 533 | - list (, $result) = parent::executeQuery ("select {0} |
|
| 533 | + list (, $result) = parent::executeQuery("select {0} |
|
| 534 | 534 | from books |
| 535 | 535 | group by substr (upper (sort), 1, 1) |
| 536 | -order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", self::getFilterString (), array (), -1); |
|
| 536 | +order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", self::getFilterString(), array(), -1); |
|
| 537 | 537 | $entryArray = array(); |
| 538 | - while ($post = $result->fetchObject ()) |
|
| 538 | + while ($post = $result->fetchObject()) |
|
| 539 | 539 | { |
| 540 | - array_push ($entryArray, new Entry ($post->title, Book::getEntryIdByLetter ($post->title), |
|
| 541 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 542 | - array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); |
|
| 540 | + array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), |
|
| 541 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 542 | + array(new LinkNavigation("?page=" . parent::PAGE_ALL_BOOKS_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count)); |
|
| 543 | 543 | } |
| 544 | 544 | return $entryArray; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { |
| 548 | - return self::getEntryArray (self::SQL_BOOKS_BY_FIRST_LETTER, array ($letter . "%"), $n, $database, $numberPerPage); |
|
| 548 | + return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . "%"), $n, $database, $numberPerPage); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - public static function getEntryArray ($query, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 552 | - list ($totalNumber, $result) = parent::executeQuery ($query, self::BOOK_COLUMNS, self::getFilterString (), $params, $n, $database, $numberPerPage); |
|
| 551 | + public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 552 | + list ($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage); |
|
| 553 | 553 | $entryArray = array(); |
| 554 | - while ($post = $result->fetchObject ()) |
|
| 554 | + while ($post = $result->fetchObject()) |
|
| 555 | 555 | { |
| 556 | - $book = new Book ($post); |
|
| 557 | - array_push ($entryArray, $book->getEntry ()); |
|
| 556 | + $book = new Book($post); |
|
| 557 | + array_push($entryArray, $book->getEntry()); |
|
| 558 | 558 | } |
| 559 | - return array ($entryArray, $totalNumber); |
|
| 559 | + return array($entryArray, $totalNumber); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | |
| 563 | 563 | public static function getAllRecentBooks() { |
| 564 | 564 | global $config; |
| 565 | - list ($entryArray, ) = self::getEntryArray (self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array (), -1); |
|
| 565 | + list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
|
| 566 | 566 | return $entryArray; |
| 567 | 567 | } |
| 568 | 568 | |
@@ -16,16 +16,16 @@ discard block |
||
| 16 | 16 | exit (); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - $page = getURLParam ("page", Base::PAGE_INDEX); |
|
| 20 | - $query = getURLParam ("query"); |
|
| 21 | - $qid = getURLParam ("id"); |
|
| 22 | - $n = getURLParam ("n", "1"); |
|
| 23 | - $database = GetUrlParam (DB); |
|
| 19 | + $page = getURLParam("page", Base::PAGE_INDEX); |
|
| 20 | + $query = getURLParam("query"); |
|
| 21 | + $qid = getURLParam("id"); |
|
| 22 | + $n = getURLParam("n", "1"); |
|
| 23 | + $database = GetUrlParam(DB); |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | // Access the database ASAP to be sure it's readable, redirect if that's not the case. |
| 27 | 27 | // It has to be done before any header is sent. |
| 28 | - Base::checkDatabaseAvailability (); |
|
| 28 | + Base::checkDatabaseAvailability(); |
|
| 29 | 29 | |
| 30 | 30 | if ($config ['cops_fetch_protect'] == "1") { |
| 31 | 31 | session_start(); |
@@ -34,32 +34,32 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - header ("Content-Type:text/html;charset=utf-8"); |
|
| 37 | + header("Content-Type:text/html;charset=utf-8"); |
|
| 38 | 38 | |
| 39 | 39 | $data = array("title" => $config['cops_title_default'], |
| 40 | 40 | "version" => VERSION, |
| 41 | 41 | "opds_url" => $config['cops_full_url'] . "feed.php", |
| 42 | 42 | "customHeader" => "", |
| 43 | - "template" => getCurrentTemplate (), |
|
| 44 | - "server_side_rendering" => useServerSideRendering (), |
|
| 45 | - "current_css" => getCurrentCss (), |
|
| 43 | + "template" => getCurrentTemplate(), |
|
| 44 | + "server_side_rendering" => useServerSideRendering(), |
|
| 45 | + "current_css" => getCurrentCss(), |
|
| 46 | 46 | "favico" => $config['cops_icon'], |
| 47 | - "getjson_url" => "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1)); |
|
| 47 | + "getjson_url" => "getJSON.php?" . addURLParameter(getQueryString(), "complete", 1)); |
|
| 48 | 48 | if (preg_match("/Kindle/", $_SERVER['HTTP_USER_AGENT'])) { |
| 49 | 49 | $data ["customHeader"] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>'; |
| 50 | 50 | } |
| 51 | - $headcontent = file_get_contents('templates/' . getCurrentTemplate () . '/file.html'); |
|
| 52 | - $template = new doT (); |
|
| 53 | - $dot = $template->template ($headcontent, NULL); |
|
| 54 | - echo ($dot ($data)); |
|
| 51 | + $headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html'); |
|
| 52 | + $template = new doT(); |
|
| 53 | + $dot = $template->template($headcontent, NULL); |
|
| 54 | + echo ($dot($data)); |
|
| 55 | 55 | ?><body> |
| 56 | 56 | <?php |
| 57 | -if (useServerSideRendering ()) { |
|
| 57 | +if (useServerSideRendering()) { |
|
| 58 | 58 | // Get the data |
| 59 | 59 | require_once ("JSON_renderer.php"); |
| 60 | - $data = JSONRenderer::getJson (true); |
|
| 60 | + $data = JSONRenderer::getJson(true); |
|
| 61 | 61 | |
| 62 | - echo serverSideRender ($data); |
|
| 62 | + echo serverSideRender($data); |
|
| 63 | 63 | } |
| 64 | 64 | ?> |
| 65 | 65 | </body> |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | |
| 10 | 10 | require_once ("config.php"); |
| 11 | 11 | |
| 12 | - header ("Content-Type:application/json;charset=utf-8"); |
|
| 12 | + header("Content-Type:application/json;charset=utf-8"); |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | - echo json_encode (JSONRenderer::getJson ()); |
|
| 15 | + echo json_encode(JSONRenderer::getJson()); |
|
| 16 | 16 | |
@@ -19,44 +19,44 @@ |
||
| 19 | 19 | $this->name = $post->name; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function getUri () { |
|
| 23 | - return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id"; |
|
| 22 | + public function getUri() { |
|
| 23 | + return "?page=" . parent::PAGE_TAG_DETAIL . "&id=$this->id"; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function getEntryId () { |
|
| 27 | - return self::ALL_TAGS_ID.":".$this->id; |
|
| 26 | + public function getEntryId() { |
|
| 27 | + return self::ALL_TAGS_ID . ":" . $this->id; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public static function getCount() { |
| 31 | 31 | // str_format (localize("tags.alphabetical", count(array)) |
| 32 | - return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS); |
|
| 32 | + return parent::getCountGeneric("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function getTagById ($tagId) { |
|
| 36 | - $result = parent::getDb ()->prepare('select id, name from tags where id = ?'); |
|
| 37 | - $result->execute (array ($tagId)); |
|
| 38 | - if ($post = $result->fetchObject ()) { |
|
| 39 | - return new Tag ($post); |
|
| 35 | + public static function getTagById($tagId) { |
|
| 36 | + $result = parent::getDb()->prepare('select id, name from tags where id = ?'); |
|
| 37 | + $result->execute(array($tagId)); |
|
| 38 | + if ($post = $result->fetchObject()) { |
|
| 39 | + return new Tag($post); |
|
| 40 | 40 | } |
| 41 | 41 | return NULL; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public static function getAllTags() { |
| 45 | - return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag"); |
|
| 45 | + return Base::getEntryArrayWithBookNumber(self::SQL_ALL_TAGS, self::TAG_COLUMNS, array(), "Tag"); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
| 49 | - $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count"; |
|
| 49 | + $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count"; |
|
| 50 | 50 | $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name'; |
| 51 | - list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage); |
|
| 51 | + list ($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage); |
|
| 52 | 52 | $entryArray = array(); |
| 53 | - while ($post = $result->fetchObject ()) |
|
| 53 | + while ($post = $result->fetchObject()) |
|
| 54 | 54 | { |
| 55 | - $tag = new Tag ($post); |
|
| 56 | - array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (), |
|
| 57 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 58 | - array ( new LinkNavigation ($tag->getUri ())))); |
|
| 55 | + $tag = new Tag($post); |
|
| 56 | + array_push($entryArray, new Entry($tag->name, $tag->getEntryId(), |
|
| 57 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 58 | + array(new LinkNavigation($tag->getUri())))); |
|
| 59 | 59 | } |
| 60 | - return array ($entryArray, $totalNumber); |
|
| 60 | + return array($entryArray, $totalNumber); |
|
| 61 | 61 | } |
| 62 | 62 | } |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | $this->lang_code = $plang_code; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function getUri () { |
|
| 21 | - return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id"; |
|
| 20 | + public function getUri() { |
|
| 21 | + return "?page=" . parent::PAGE_LANGUAGE_DETAIL . "&id=$this->id"; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getEntryId () { |
|
| 25 | - return self::ALL_LANGUAGES_ID.":".$this->id; |
|
| 24 | + public function getEntryId() { |
|
| 25 | + return self::ALL_LANGUAGES_ID . ":" . $this->id; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function getLanguageString ($code) { |
|
| 29 | - $string = localize("languages.".$code); |
|
| 30 | - if (preg_match ("/^languages/", $string)) { |
|
| 28 | + public static function getLanguageString($code) { |
|
| 29 | + $string = localize("languages." . $code); |
|
| 30 | + if (preg_match("/^languages/", $string)) { |
|
| 31 | 31 | return $code; |
| 32 | 32 | } |
| 33 | 33 | return $string; |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public static function getCount() { |
| 37 | 37 | // str_format (localize("languages.alphabetical", count(array)) |
| 38 | - return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES); |
|
| 38 | + return parent::getCountGeneric("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public static function getLanguageById ($languageId) { |
|
| 42 | - $result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?'); |
|
| 43 | - $result->execute (array ($languageId)); |
|
| 44 | - if ($post = $result->fetchObject ()) { |
|
| 45 | - return new Language ($post->id, Language::getLanguageString ($post->lang_code)); |
|
| 41 | + public static function getLanguageById($languageId) { |
|
| 42 | + $result = parent::getDb()->prepare('select id, lang_code from languages where id = ?'); |
|
| 43 | + $result->execute(array($languageId)); |
|
| 44 | + if ($post = $result->fetchObject()) { |
|
| 45 | + return new Language($post->id, Language::getLanguageString($post->lang_code)); |
|
| 46 | 46 | } |
| 47 | 47 | return NULL; |
| 48 | 48 | } |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | public static function getAllLanguages() { |
| 53 | - $result = parent::getDb ()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count |
|
| 53 | + $result = parent::getDb()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count |
|
| 54 | 54 | from languages, books_languages_link |
| 55 | 55 | where languages.id = books_languages_link.lang_code |
| 56 | 56 | group by languages.id, books_languages_link.lang_code |
| 57 | 57 | order by languages.lang_code'); |
| 58 | 58 | $entryArray = array(); |
| 59 | - while ($post = $result->fetchObject ()) |
|
| 59 | + while ($post = $result->fetchObject()) |
|
| 60 | 60 | { |
| 61 | - $language = new Language ($post->id, $post->lang_code); |
|
| 62 | - array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (), |
|
| 63 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 64 | - array ( new LinkNavigation ($language->getUri ())), "", $post->count)); |
|
| 61 | + $language = new Language($post->id, $post->lang_code); |
|
| 62 | + array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(), |
|
| 63 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 64 | + array(new LinkNavigation($language->getUri())), "", $post->count)); |
|
| 65 | 65 | } |
| 66 | 66 | return $entryArray; |
| 67 | 67 | } |