@@ -2,11 +2,11 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | require_once ("config.php"); |
| 4 | 4 | |
| 5 | -function checkConfiguration () { |
|
| 5 | +function checkConfiguration() { |
|
| 6 | 6 | global $config; |
| 7 | 7 | |
| 8 | - if (is_null ($config['cops_mail_configuration']) || |
|
| 9 | - !is_array ($config['cops_mail_configuration']) || |
|
| 8 | + if (is_null($config['cops_mail_configuration']) || |
|
| 9 | + !is_array($config['cops_mail_configuration']) || |
|
| 10 | 10 | empty ($config['cops_mail_configuration']["smtp.host"]) || |
| 11 | 11 | empty ($config['cops_mail_configuration']["address.from"])) { |
| 12 | 12 | return "NOK. bad configuration."; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | return False; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -function checkRequest ($idData, $emailDest) { |
|
| 17 | +function checkRequest($idData, $emailDest) { |
|
| 18 | 18 | if (empty ($idData)) { |
| 19 | 19 | return 'No data sent.'; |
| 20 | 20 | } |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | global $config; |
| 30 | 30 | |
| 31 | -if ($error = checkConfiguration ()) { |
|
| 31 | +if ($error = checkConfiguration()) { |
|
| 32 | 32 | echo $error; |
| 33 | 33 | exit; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $idData = $_REQUEST["data"]; |
| 37 | 37 | $emailDest = $_REQUEST["email"]; |
| 38 | -if ($error = checkRequest ($idData, $emailDest)) { |
|
| 38 | +if ($error = checkRequest($idData, $emailDest)) { |
|
| 39 | 39 | echo $error; |
| 40 | 40 | exit; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $book = Book::getBookByDataId($idData); |
| 44 | -$data = $book->getDataById ($idData); |
|
| 44 | +$data = $book->getDataById($idData); |
|
| 45 | 45 | |
| 46 | -if (filesize ($data->getLocalPath ()) > 10 * 1024 * 1024) { |
|
| 46 | +if (filesize($data->getLocalPath()) > 10 * 1024 * 1024) { |
|
| 47 | 47 | echo 'Attachment too big'; |
| 48 | 48 | exit; |
| 49 | 49 | } |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | $mail->From = $config['cops_mail_configuration']["address.from"]; |
| 66 | 66 | $mail->FromName = $config['cops_title_default']; |
| 67 | 67 | |
| 68 | -foreach (explode (";", $emailDest) as $emailAddress) { |
|
| 68 | +foreach (explode(";", $emailDest) as $emailAddress) { |
|
| 69 | 69 | if (empty ($emailAddress)) { continue; } |
| 70 | 70 | $mail->AddAddress($emailAddress); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -$mail->AddAttachment($data->getLocalPath ()); |
|
| 73 | +$mail->AddAttachment($data->getLocalPath()); |
|
| 74 | 74 | |
| 75 | 75 | $mail->IsHTML(true); |
| 76 | -$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename (); |
|
| 77 | -$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName () . "</h2>" . $book->getComment (); |
|
| 76 | +$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename(); |
|
| 77 | +$mail->Body = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment(); |
|
| 78 | 78 | $mail->AltBody = "Sent by COPS"; |
| 79 | 79 | |
| 80 | 80 | if (!$mail->Send()) { |
| 81 | - echo localize ("mail.messagenotsent"); |
|
| 81 | + echo localize("mail.messagenotsent"); |
|
| 82 | 82 | echo 'Mailer Error: ' . $mail->ErrorInfo; |
| 83 | 83 | exit; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | -echo localize ("mail.messagesent"); |
|
| 86 | +echo localize("mail.messagesent"); |
|
| 87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | // Counting down is faster. I'm *so* sorry. |
| 91 | 91 | $len = $chunk + 1; |
| 92 | 92 | |
| 93 | - for ($i = -1; --$len; ) { |
|
| 93 | + for ($i = -1; --$len;) { |
|
| 94 | 94 | $c = $str[++$i]; |
| 95 | 95 | if ($remaining = $tail_bytes[$c]) { |
| 96 | 96 | // UTF-8 head byte! |
@@ -207,5 +207,5 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $ord = $ord & 255; |
| 209 | 209 | |
| 210 | - return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown; |
|
| 210 | + return isset($map[$bank][$langcode][$ord])?$map[$bank][$langcode][$ord]:$unknown; |
|
| 211 | 211 | } |
@@ -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 | } |
@@ -15,16 +15,16 @@ discard block |
||
| 15 | 15 | const SCOPE_BOOK = "book"; |
| 16 | 16 | const SCOPE_PUBLISHER = "publisher"; |
| 17 | 17 | |
| 18 | - private function useTypeahead () { |
|
| 19 | - return !is_null (getURLParam ("search")); |
|
| 18 | + private function useTypeahead() { |
|
| 19 | + return !is_null(getURLParam("search")); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - private function searchByScope ($scope, $limit = FALSE) { |
|
| 22 | + private function searchByScope($scope, $limit = FALSE) { |
|
| 23 | 23 | $n = $this->n; |
| 24 | 24 | $numberPerPage = NULL; |
| 25 | 25 | $queryNormedAndUp = $this->query; |
| 26 | - if (useNormAndUp ()) { |
|
| 27 | - $queryNormedAndUp = normAndUp ($this->query); |
|
| 26 | + if (useNormAndUp()) { |
|
| 27 | + $queryNormedAndUp = normAndUp($this->query); |
|
| 28 | 28 | } |
| 29 | 29 | if ($limit) { |
| 30 | 30 | $n = 1; |
@@ -32,59 +32,59 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | switch ($scope) { |
| 34 | 34 | case self::SCOPE_BOOK : |
| 35 | - $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 35 | + $array = Book::getBooksByStartingLetter('%' . $queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 36 | 36 | break; |
| 37 | 37 | case self::SCOPE_AUTHOR : |
| 38 | - $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp); |
|
| 38 | + $array = Author::getAuthorsForSearch('%' . $queryNormedAndUp); |
|
| 39 | 39 | break; |
| 40 | 40 | case self::SCOPE_SERIES : |
| 41 | - $array = Serie::getAllSeriesByQuery ($queryNormedAndUp); |
|
| 41 | + $array = Serie::getAllSeriesByQuery($queryNormedAndUp); |
|
| 42 | 42 | break; |
| 43 | 43 | case self::SCOPE_TAG : |
| 44 | - $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 44 | + $array = Tag::getAllTagsByQuery($queryNormedAndUp, $n, NULL, $numberPerPage); |
|
| 45 | 45 | break; |
| 46 | 46 | case self::SCOPE_PUBLISHER : |
| 47 | - $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp); |
|
| 47 | + $array = Publisher::getAllPublishersByQuery($queryNormedAndUp); |
|
| 48 | 48 | break; |
| 49 | 49 | default: |
| 50 | - $array = Book::getBooksByQuery ( |
|
| 51 | - array ("all" => "%" . $queryNormedAndUp . "%"), $n); |
|
| 50 | + $array = Book::getBooksByQuery( |
|
| 51 | + array("all" => "%" . $queryNormedAndUp . "%"), $n); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return $array; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function doSearchByCategory () { |
|
| 58 | - $database = GetUrlParam (DB); |
|
| 59 | - $out = array (); |
|
| 57 | + public function doSearchByCategory() { |
|
| 58 | + $database = GetUrlParam(DB); |
|
| 59 | + $out = array(); |
|
| 60 | 60 | $pagequery = Base::PAGE_OPENSEARCH_QUERY; |
| 61 | - $dbArray = array (""); |
|
| 61 | + $dbArray = array(""); |
|
| 62 | 62 | $d = $database; |
| 63 | 63 | $query = $this->query; |
| 64 | 64 | // Special case when no databases were chosen, we search on all databases |
| 65 | - if (Base::noDatabaseSelected ()) { |
|
| 66 | - $dbArray = Base::getDbNameList (); |
|
| 65 | + if (Base::noDatabaseSelected()) { |
|
| 66 | + $dbArray = Base::getDbNameList(); |
|
| 67 | 67 | $d = 0; |
| 68 | 68 | } |
| 69 | 69 | foreach ($dbArray as $key) { |
| 70 | - if (Base::noDatabaseSelected ()) { |
|
| 71 | - array_push ($this->entryArray, new Entry ($key, DB . ":query:{$d}", |
|
| 70 | + if (Base::noDatabaseSelected()) { |
|
| 71 | + array_push($this->entryArray, new Entry($key, DB . ":query:{$d}", |
|
| 72 | 72 | " ", "text", |
| 73 | - array ( new LinkNavigation ("?" . DB . "={$d}")), "tt-header")); |
|
| 74 | - Base::getDb ($d); |
|
| 73 | + array(new LinkNavigation("?" . DB . "={$d}")), "tt-header")); |
|
| 74 | + Base::getDb($d); |
|
| 75 | 75 | } |
| 76 | - foreach (array (PageQueryResult::SCOPE_BOOK, |
|
| 76 | + foreach (array(PageQueryResult::SCOPE_BOOK, |
|
| 77 | 77 | PageQueryResult::SCOPE_AUTHOR, |
| 78 | 78 | PageQueryResult::SCOPE_SERIES, |
| 79 | 79 | PageQueryResult::SCOPE_TAG, |
| 80 | 80 | PageQueryResult::SCOPE_PUBLISHER) as $key) { |
| 81 | - if (in_array($key, getCurrentOption ('ignored_categories'))) { |
|
| 81 | + if (in_array($key, getCurrentOption('ignored_categories'))) { |
|
| 82 | 82 | continue; |
| 83 | 83 | } |
| 84 | - $array = $this->searchByScope ($key, TRUE); |
|
| 84 | + $array = $this->searchByScope($key, TRUE); |
|
| 85 | 85 | |
| 86 | 86 | $i = 0; |
| 87 | - if (count ($array) == 2 && is_array ($array [0])) { |
|
| 87 | + if (count($array) == 2 && is_array($array [0])) { |
|
| 88 | 88 | $total = $array [1]; |
| 89 | 89 | $array = $array [0]; |
| 90 | 90 | } else { |
@@ -97,32 +97,32 @@ discard block |
||
| 97 | 97 | // str_format (localize("seriesword", count($array)) |
| 98 | 98 | // str_format (localize("tagword", count($array)) |
| 99 | 99 | // str_format (localize("publisherword", count($array)) |
| 100 | - array_push ($this->entryArray, new Entry (str_format (localize ("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", |
|
| 101 | - str_format (localize("{$key}word", $total), $total), "text", |
|
| 102 | - array ( new LinkNavigation ("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), |
|
| 103 | - Base::noDatabaseSelected () ? "" : "tt-header", $total)); |
|
| 100 | + array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}", |
|
| 101 | + str_format(localize("{$key}word", $total), $total), "text", |
|
| 102 | + array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")), |
|
| 103 | + Base::noDatabaseSelected()?"":"tt-header", $total)); |
|
| 104 | 104 | } |
| 105 | - if (!Base::noDatabaseSelected () && $this->useTypeahead ()) { |
|
| 105 | + if (!Base::noDatabaseSelected() && $this->useTypeahead()) { |
|
| 106 | 106 | foreach ($array as $entry) { |
| 107 | - array_push ($this->entryArray, $entry); |
|
| 107 | + array_push($this->entryArray, $entry); |
|
| 108 | 108 | $i++; |
| 109 | 109 | if ($i > 4) { break; }; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | $d++; |
| 114 | - if (Base::noDatabaseSelected ()) { |
|
| 115 | - Base::clearDb (); |
|
| 114 | + if (Base::noDatabaseSelected()) { |
|
| 115 | + Base::clearDb(); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | return $out; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function InitializeContent () |
|
| 121 | + public function InitializeContent() |
|
| 122 | 122 | { |
| 123 | - $scope = getURLParam ("scope"); |
|
| 123 | + $scope = getURLParam("scope"); |
|
| 124 | 124 | if (empty ($scope)) { |
| 125 | - $this->title = str_format (localize ("search.result"), $this->query); |
|
| 125 | + $this->title = str_format(localize("search.result"), $this->query); |
|
| 126 | 126 | } else { |
| 127 | 127 | // Comment to help the perl i18n script |
| 128 | 128 | // str_format (localize ("search.result.author"), $this->query) |
@@ -130,31 +130,31 @@ discard block |
||
| 130 | 130 | // str_format (localize ("search.result.series"), $this->query) |
| 131 | 131 | // str_format (localize ("search.result.book"), $this->query) |
| 132 | 132 | // str_format (localize ("search.result.publisher"), $this->query) |
| 133 | - $this->title = str_format (localize ("search.result.{$scope}"), $this->query); |
|
| 133 | + $this->title = str_format(localize("search.result.{$scope}"), $this->query); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $crit = "%" . $this->query . "%"; |
| 137 | 137 | |
| 138 | 138 | // Special case when we are doing a search and no database is selected |
| 139 | - if (Base::noDatabaseSelected () && !$this->useTypeahead ()) { |
|
| 139 | + if (Base::noDatabaseSelected() && !$this->useTypeahead()) { |
|
| 140 | 140 | $i = 0; |
| 141 | - foreach (Base::getDbNameList () as $key) { |
|
| 142 | - Base::clearDb (); |
|
| 143 | - list ($array, $totalNumber) = Book::getBooksByQuery (array ("all" => $crit), 1, $i, 1); |
|
| 144 | - array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}", |
|
| 145 | - str_format (localize ("bookword", $totalNumber), $totalNumber), "text", |
|
| 146 | - array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber)); |
|
| 141 | + foreach (Base::getDbNameList() as $key) { |
|
| 142 | + Base::clearDb(); |
|
| 143 | + list ($array, $totalNumber) = Book::getBooksByQuery(array("all" => $crit), 1, $i, 1); |
|
| 144 | + array_push($this->entryArray, new Entry($key, DB . ":query:{$i}", |
|
| 145 | + str_format(localize("bookword", $totalNumber), $totalNumber), "text", |
|
| 146 | + array(new LinkNavigation("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber)); |
|
| 147 | 147 | $i++; |
| 148 | 148 | } |
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | if (empty ($scope)) { |
| 152 | - $this->doSearchByCategory (); |
|
| 152 | + $this->doSearchByCategory(); |
|
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - $array = $this->searchByScope ($scope); |
|
| 157 | - if (count ($array) == 2 && is_array ($array [0])) { |
|
| 156 | + $array = $this->searchByScope($scope); |
|
| 157 | + if (count($array) == 2 && is_array($array [0])) { |
|
| 158 | 158 | list ($this->entryArray, $this->totalNumber) = $array; |
| 159 | 159 | } else { |
| 160 | 160 | $this->entryArray = $array; |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageBookDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->book = Book::getBookById ($this->idGet); |
|
| 13 | + $this->book = Book::getBookById($this->idGet); |
|
| 14 | 14 | $this->title = $this->book->title; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -58,25 +58,25 @@ discard block |
||
| 58 | 58 | $this->id = $post->id; |
| 59 | 59 | $this->name = $post->name; |
| 60 | 60 | $this->format = $post->format; |
| 61 | - $this->realFormat = str_replace ("ORIGINAL_", "", $post->format); |
|
| 62 | - $this->extension = strtolower ($this->realFormat); |
|
| 61 | + $this->realFormat = str_replace("ORIGINAL_", "", $post->format); |
|
| 62 | + $this->extension = strtolower($this->realFormat); |
|
| 63 | 63 | $this->book = $book; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function isKnownType () { |
|
| 67 | - return array_key_exists ($this->extension, self::$mimetypes); |
|
| 66 | + public function isKnownType() { |
|
| 67 | + return array_key_exists($this->extension, self::$mimetypes); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function getMimeType () { |
|
| 70 | + public function getMimeType() { |
|
| 71 | 71 | $result = "application/octet-stream"; |
| 72 | - if ($this->isKnownType ()) { |
|
| 72 | + if ($this->isKnownType()) { |
|
| 73 | 73 | return self::$mimetypes [$this->extension]; |
| 74 | 74 | } elseif (function_exists('finfo_open') === true) { |
| 75 | 75 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 76 | 76 | |
| 77 | 77 | if (is_resource($finfo) === true) |
| 78 | 78 | { |
| 79 | - $result = finfo_file($finfo, $this->getLocalPath ()); |
|
| 79 | + $result = finfo_file($finfo, $this->getLocalPath()); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | finfo_close($finfo); |
@@ -85,80 +85,80 @@ discard block |
||
| 85 | 85 | return $result; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function isEpubValidOnKobo () { |
|
| 88 | + public function isEpubValidOnKobo() { |
|
| 89 | 89 | return $this->format == "EPUB" || $this->format == "KEPUB"; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public function getFilename () { |
|
| 93 | - return $this->name . "." . strtolower ($this->format); |
|
| 92 | + public function getFilename() { |
|
| 93 | + return $this->name . "." . strtolower($this->format); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - public function getUpdatedFilename () { |
|
| 97 | - return $this->book->getAuthorsSort () . " - " . $this->book->title; |
|
| 96 | + public function getUpdatedFilename() { |
|
| 97 | + return $this->book->getAuthorsSort() . " - " . $this->book->title; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function getUpdatedFilenameEpub () { |
|
| 101 | - return $this->getUpdatedFilename () . ".epub"; |
|
| 100 | + public function getUpdatedFilenameEpub() { |
|
| 101 | + return $this->getUpdatedFilename() . ".epub"; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public function getUpdatedFilenameKepub () { |
|
| 105 | - return $this->getUpdatedFilename () . ".kepub.epub"; |
|
| 104 | + public function getUpdatedFilenameKepub() { |
|
| 105 | + return $this->getUpdatedFilename() . ".kepub.epub"; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function getDataLink ($rel, $title = NULL) { |
|
| 108 | + public function getDataLink($rel, $title = NULL) { |
|
| 109 | 109 | global $config; |
| 110 | 110 | |
| 111 | 111 | if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") { |
| 112 | 112 | return $this->getHtmlLinkWithRewriting($title); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title); |
|
| 115 | + return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function getHtmlLink () { |
|
| 118 | + public function getHtmlLink() { |
|
| 119 | 119 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function getLocalPath () { |
|
| 123 | - return $this->book->path . "/" . $this->getFilename (); |
|
| 122 | + public function getLocalPath() { |
|
| 123 | + return $this->book->path . "/" . $this->getFilename(); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function getHtmlLinkWithRewriting ($title = NULL) { |
|
| 126 | + public function getHtmlLinkWithRewriting($title = NULL) { |
|
| 127 | 127 | global $config; |
| 128 | 128 | |
| 129 | 129 | $database = ""; |
| 130 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; |
|
| 130 | + if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/"; |
|
| 131 | 131 | |
| 132 | 132 | $href = "download/" . $this->id . "/" . $database; |
| 133 | 133 | |
| 134 | 134 | if ($config['cops_provide_kepub'] == "1" && |
| 135 | - $this->isEpubValidOnKobo () && |
|
| 135 | + $this->isEpubValidOnKobo() && |
|
| 136 | 136 | preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
| 137 | - $href .= rawurlencode ($this->getUpdatedFilenameKepub ()); |
|
| 137 | + $href .= rawurlencode($this->getUpdatedFilenameKepub()); |
|
| 138 | 138 | } else { |
| 139 | - $href .= rawurlencode ($this->getFilename ()); |
|
| 139 | + $href .= rawurlencode($this->getFilename()); |
|
| 140 | 140 | } |
| 141 | - return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); |
|
| 141 | + return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - public static function getDataByBook ($book) { |
|
| 145 | - $out = array (); |
|
| 146 | - $result = parent::getDb ()->prepare('select id, format, name |
|
| 144 | + public static function getDataByBook($book) { |
|
| 145 | + $out = array(); |
|
| 146 | + $result = parent::getDb()->prepare('select id, format, name |
|
| 147 | 147 | from data where book = ?'); |
| 148 | - $result->execute (array ($book->id)); |
|
| 148 | + $result->execute(array($book->id)); |
|
| 149 | 149 | |
| 150 | - while ($post = $result->fetchObject ()) |
|
| 150 | + while ($post = $result->fetchObject()) |
|
| 151 | 151 | { |
| 152 | - array_push ($out, new Data ($post, $book)); |
|
| 152 | + array_push($out, new Data($post, $book)); |
|
| 153 | 153 | } |
| 154 | 154 | return $out; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public static function handleThumbnailLink ($urlParam, $height) { |
|
| 157 | + public static function handleThumbnailLink($urlParam, $height) { |
|
| 158 | 158 | global $config; |
| 159 | 159 | |
| 160 | - if (is_null ($height)) { |
|
| 161 | - if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
| 160 | + if (is_null($height)) { |
|
| 161 | + if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
| 162 | 162 | $height = $config['cops_opds_thumbnail_height']; |
| 163 | 163 | } |
| 164 | 164 | else |
@@ -173,13 +173,13 @@ discard block |
||
| 173 | 173 | return $urlParam; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) |
|
| 176 | + public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) |
|
| 177 | 177 | { |
| 178 | 178 | global $config; |
| 179 | 179 | |
| 180 | 180 | $urlParam = addURLParameter("", "data", $idData); |
| 181 | 181 | |
| 182 | - if (Base::useAbsolutePath () || |
|
| 182 | + if (Base::useAbsolutePath() || |
|
| 183 | 183 | $rel == Link::OPDS_THUMBNAIL_TYPE || |
| 184 | 184 | ($type == "epub" && $config['cops_update_epub-metadata'])) |
| 185 | 185 | { |
@@ -188,18 +188,18 @@ discard block |
||
| 188 | 188 | $urlParam = self::handleThumbnailLink($urlParam, $height); |
| 189 | 189 | } |
| 190 | 190 | $urlParam = addURLParameter($urlParam, "id", $book->id); |
| 191 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
| 191 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
| 192 | 192 | if ($config['cops_thumbnail_handling'] != "1" && |
| 193 | 193 | !empty ($config['cops_thumbnail_handling']) && |
| 194 | 194 | $rel == Link::OPDS_THUMBNAIL_TYPE) { |
| 195 | - return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
| 195 | + return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
| 196 | 196 | } else { |
| 197 | - return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
| 197 | + return new Link("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | else |
| 201 | 201 | { |
| 202 | - return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); |
|
| 202 | + return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -8,15 +8,15 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllBooksLetter extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter ($this->idGet, $this->n); |
|
| 14 | - $this->idPage = Book::getEntryIdByLetter ($this->idGet); |
|
| 13 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter($this->idGet, $this->n); |
|
| 14 | + $this->idPage = Book::getEntryIdByLetter($this->idGet); |
|
| 15 | 15 | |
| 16 | 16 | $count = $this->totalNumber; |
| 17 | 17 | if ($count == -1) |
| 18 | - $count = count ($this->entryArray); |
|
| 18 | + $count = count($this->entryArray); |
|
| 19 | 19 | |
| 20 | - $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet); |
|
| 20 | + $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("bookword", $count), $count), $this->idGet); |
|
| 21 | 21 | } |
| 22 | 22 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageLanguageDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $language = Language::getLanguageById ($this->idGet); |
|
| 14 | - $this->idPage = $language->getEntryId (); |
|
| 13 | + $language = Language::getLanguageById($this->idGet); |
|
| 14 | + $this->idPage = $language->getEntryId(); |
|
| 15 | 15 | $this->title = $language->lang_code; |
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage ($this->idGet, $this->n); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllAuthorsLetter extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->idPage = Author::getEntryIdByLetter ($this->idGet); |
|
| 14 | - $this->entryArray = Author::getAuthorsByStartingLetter ($this->idGet); |
|
| 15 | - $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("authorword", count ($this->entryArray)), count ($this->entryArray)), $this->idGet); |
|
| 13 | + $this->idPage = Author::getEntryIdByLetter($this->idGet); |
|
| 14 | + $this->entryArray = Author::getAuthorsByStartingLetter($this->idGet); |
|
| 15 | + $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("authorword", count($this->entryArray)), count($this->entryArray)), $this->idGet); |
|
| 16 | 16 | } |
| 17 | 17 | } |