@@ -11,23 +11,23 @@ |
||
| 11 | 11 | public $book; |
| 12 | 12 | |
| 13 | 13 | public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) { |
| 14 | - parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
|
| 14 | + parent::__construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
|
| 15 | 15 | $this->book = $pbook; |
| 16 | 16 | $this->localUpdated = $pbook->timestamp; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function getCoverThumbnail () { |
|
| 19 | + public function getCoverThumbnail() { |
|
| 20 | 20 | foreach ($this->linkArray as $link) { |
| 21 | 21 | if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) |
| 22 | - return $link->hrefXhtml (); |
|
| 22 | + return $link->hrefXhtml(); |
|
| 23 | 23 | } |
| 24 | 24 | return null; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function getCover () { |
|
| 27 | + public function getCover() { |
|
| 28 | 28 | foreach ($this->linkArray as $link) { |
| 29 | 29 | if ($link->rel == Link::OPDS_IMAGE_TYPE) |
| 30 | - return $link->hrefXhtml (); |
|
| 30 | + return $link->hrefXhtml(); |
|
| 31 | 31 | } |
| 32 | 32 | return null; |
| 33 | 33 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageSerieDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $serie = Serie::getSerieById ($this->idGet); |
|
| 13 | + $serie = Serie::getSerieById($this->idGet); |
|
| 14 | 14 | $this->title = $serie->name; |
| 15 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries ($this->idGet, $this->n); |
|
| 16 | - $this->idPage = $serie->getEntryId (); |
|
| 15 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries($this->idGet, $this->n); |
|
| 16 | + $this->idPage = $serie->getEntryId(); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageTagDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $tag = Tag::getTagById ($this->idGet); |
|
| 14 | - $this->idPage = $tag->getEntryId (); |
|
| 13 | + $tag = Tag::getTagById($this->idGet); |
|
| 14 | + $this->idPage = $tag->getEntryId(); |
|
| 15 | 15 | $this->title = $tag->name; |
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByTag ($this->idGet, $this->n); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByTag($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | class LinkNavigation extends Link |
| 10 | 10 | { |
| 11 | 11 | public function __construct($phref, $prel = NULL, $ptitle = NULL) { |
| 12 | - parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
|
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 14 | - if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
|
| 15 | - if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
|
| 12 | + parent::__construct($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |
|
| 13 | + if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB)); |
|
| 14 | + if (!preg_match("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |
|
| 15 | + if (preg_match("/(bookdetail|getJSON).php/", parent::getScriptName())) { |
|
| 16 | 16 | $this->href = "index.php" . $this->href; |
| 17 | 17 | } else { |
| 18 | 18 | $this->href = parent::getScriptName() . $this->href; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllPublishers extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | 13 | $this->title = localize("publishers.title"); |
| 14 | 14 | $this->entryArray = Publisher::getAllPublishers(); |
@@ -37,142 +37,142 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private static $db = NULL; |
| 39 | 39 | |
| 40 | - public static function isMultipleDatabaseEnabled () { |
|
| 40 | + public static function isMultipleDatabaseEnabled() { |
|
| 41 | 41 | global $config; |
| 42 | - return is_array ($config['calibre_directory']); |
|
| 42 | + return is_array($config['calibre_directory']); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public static function useAbsolutePath () { |
|
| 45 | + public static function useAbsolutePath() { |
|
| 46 | 46 | global $config; |
| 47 | 47 | $path = self::getDbDirectory(); |
| 48 | - return preg_match ('/^\//', $path) || // Linux / |
|
| 49 | - preg_match ('/^\w\:/', $path); // Windows X: |
|
| 48 | + return preg_match('/^\//', $path) || // Linux / |
|
| 49 | + preg_match('/^\w\:/', $path); // Windows X: |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function noDatabaseSelected () { |
|
| 53 | - return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB)); |
|
| 52 | + public static function noDatabaseSelected() { |
|
| 53 | + return self::isMultipleDatabaseEnabled() && is_null(GetUrlParam(DB)); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public static function getDbList () { |
|
| 56 | + public static function getDbList() { |
|
| 57 | 57 | global $config; |
| 58 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 58 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 59 | 59 | return $config['calibre_directory']; |
| 60 | 60 | } else { |
| 61 | - return array ("" => $config['calibre_directory']); |
|
| 61 | + return array("" => $config['calibre_directory']); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function getDbNameList () { |
|
| 65 | + public static function getDbNameList() { |
|
| 66 | 66 | global $config; |
| 67 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 68 | - return array_keys ($config['calibre_directory']); |
|
| 67 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 68 | + return array_keys($config['calibre_directory']); |
|
| 69 | 69 | } else { |
| 70 | - return array (""); |
|
| 70 | + return array(""); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public static function getDbName ($database = NULL) { |
|
| 74 | + public static function getDbName($database = NULL) { |
|
| 75 | 75 | global $config; |
| 76 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 77 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
| 76 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 77 | + if (is_null($database)) $database = GetUrlParam(DB, 0); |
|
| 78 | 78 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 79 | - return self::error ($database); |
|
| 79 | + return self::error($database); |
|
| 80 | 80 | } |
| 81 | - $array = array_keys ($config['calibre_directory']); |
|
| 81 | + $array = array_keys($config['calibre_directory']); |
|
| 82 | 82 | return $array[$database]; |
| 83 | 83 | } |
| 84 | 84 | return ""; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public static function getDbDirectory ($database = NULL) { |
|
| 87 | + public static function getDbDirectory($database = NULL) { |
|
| 88 | 88 | global $config; |
| 89 | - if (self::isMultipleDatabaseEnabled ()) { |
|
| 90 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
| 89 | + if (self::isMultipleDatabaseEnabled()) { |
|
| 90 | + if (is_null($database)) $database = GetUrlParam(DB, 0); |
|
| 91 | 91 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 92 | - return self::error ($database); |
|
| 92 | + return self::error($database); |
|
| 93 | 93 | } |
| 94 | - $array = array_values ($config['calibre_directory']); |
|
| 94 | + $array = array_values($config['calibre_directory']); |
|
| 95 | 95 | return $array[$database]; |
| 96 | 96 | } |
| 97 | 97 | return $config['calibre_directory']; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - public static function getDbFileName ($database = NULL) { |
|
| 102 | - return self::getDbDirectory ($database) .'metadata.db'; |
|
| 101 | + public static function getDbFileName($database = NULL) { |
|
| 102 | + return self::getDbDirectory($database) . 'metadata.db'; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - private static function error ($database) { |
|
| 105 | + private static function error($database) { |
|
| 106 | 106 | if (php_sapi_name() != "cli") { |
| 107 | 107 | header("location: checkconfig.php?err=1"); |
| 108 | 108 | } |
| 109 | 109 | throw new Exception("Database <{$database}> not found."); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public static function getDb ($database = NULL) { |
|
| 113 | - if (is_null (self::$db)) { |
|
| 112 | + public static function getDb($database = NULL) { |
|
| 113 | + if (is_null(self::$db)) { |
|
| 114 | 114 | try { |
| 115 | - if (is_readable (self::getDbFileName ($database))) { |
|
| 116 | - self::$db = new PDO('sqlite:'. self::getDbFileName ($database)); |
|
| 117 | - if (useNormAndUp ()) { |
|
| 118 | - self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1); |
|
| 115 | + if (is_readable(self::getDbFileName($database))) { |
|
| 116 | + self::$db = new PDO('sqlite:' . self::getDbFileName($database)); |
|
| 117 | + if (useNormAndUp()) { |
|
| 118 | + self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1); |
|
| 119 | 119 | } |
| 120 | 120 | } else { |
| 121 | - self::error ($database); |
|
| 121 | + self::error($database); |
|
| 122 | 122 | } |
| 123 | 123 | } catch (Exception $e) { |
| 124 | - self::error ($database); |
|
| 124 | + self::error($database); |
|
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | return self::$db; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function checkDatabaseAvailability () { |
|
| 131 | - if (self::noDatabaseSelected ()) { |
|
| 132 | - for ($i = 0; $i < count (self::getDbList ()); $i++) { |
|
| 133 | - self::getDb ($i); |
|
| 134 | - self::clearDb (); |
|
| 130 | + public static function checkDatabaseAvailability() { |
|
| 131 | + if (self::noDatabaseSelected()) { |
|
| 132 | + for ($i = 0; $i < count(self::getDbList()); $i++) { |
|
| 133 | + self::getDb($i); |
|
| 134 | + self::clearDb(); |
|
| 135 | 135 | } |
| 136 | 136 | } else { |
| 137 | - self::getDb (); |
|
| 137 | + self::getDb(); |
|
| 138 | 138 | } |
| 139 | 139 | return true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function clearDb () { |
|
| 142 | + public static function clearDb() { |
|
| 143 | 143 | self::$db = NULL; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public static function executeQuerySingle ($query, $database = NULL) { |
|
| 147 | - return self::getDb ($database)->query($query)->fetchColumn(); |
|
| 146 | + public static function executeQuerySingle($query, $database = NULL) { |
|
| 147 | + return self::getDb($database)->query($query)->fetchColumn(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
| 151 | 151 | if (!$numberOfString) { |
| 152 | 152 | $numberOfString = $table . ".alphabetical"; |
| 153 | 153 | } |
| 154 | - $count = self::executeQuerySingle ('select count(*) from ' . $table); |
|
| 154 | + $count = self::executeQuerySingle('select count(*) from ' . $table); |
|
| 155 | 155 | if ($count == 0) return NULL; |
| 156 | - $entry = new Entry (localize($table . ".title"), $id, |
|
| 157 | - str_format (localize($numberOfString, $count), $count), "text", |
|
| 158 | - array ( new LinkNavigation ("?page=".$pageId)), "", $count); |
|
| 156 | + $entry = new Entry(localize($table . ".title"), $id, |
|
| 157 | + str_format(localize($numberOfString, $count), $count), "text", |
|
| 158 | + array(new LinkNavigation("?page=" . $pageId)), "", $count); |
|
| 159 | 159 | return $entry; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { |
|
| 163 | - list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
|
| 162 | + public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) { |
|
| 163 | + list (, $result) = self::executeQuery($query, $columns, "", $params, -1); |
|
| 164 | 164 | $entryArray = array(); |
| 165 | - while ($post = $result->fetchObject ()) |
|
| 165 | + while ($post = $result->fetchObject()) |
|
| 166 | 166 | { |
| 167 | - $instance = new $category ($post); |
|
| 167 | + $instance = new $category($post); |
|
| 168 | 168 | if (property_exists($post, "sort")) { |
| 169 | 169 | $title = $post->sort; |
| 170 | 170 | } else { |
| 171 | 171 | $title = $post->name; |
| 172 | 172 | } |
| 173 | - array_push ($entryArray, new Entry ($title, $instance->getEntryId (), |
|
| 174 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 175 | - array ( new LinkNavigation ($instance->getUri ())), "", $post->count)); |
|
| 173 | + array_push($entryArray, new Entry($title, $instance->getEntryId(), |
|
| 174 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 175 | + array(new LinkNavigation($instance->getUri())), "", $post->count)); |
|
| 176 | 176 | } |
| 177 | 177 | return $entryArray; |
| 178 | 178 | } |
@@ -180,30 +180,30 @@ discard block |
||
| 180 | 180 | public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
| 181 | 181 | $totalResult = -1; |
| 182 | 182 | |
| 183 | - if (useNormAndUp ()) { |
|
| 183 | + if (useNormAndUp()) { |
|
| 184 | 184 | $query = preg_replace("/upper/", "normAndUp", $query); |
| 185 | 185 | $columns = preg_replace("/upper/", "normAndUp", $columns); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if (is_null ($numberPerPage)) { |
|
| 189 | - $numberPerPage = getCurrentOption ("max_item_per_page"); |
|
| 188 | + if (is_null($numberPerPage)) { |
|
| 189 | + $numberPerPage = getCurrentOption("max_item_per_page"); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if ($numberPerPage != -1 && $n != -1) |
| 193 | 193 | { |
| 194 | 194 | // First check total number of results |
| 195 | - $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); |
|
| 196 | - $result->execute ($params); |
|
| 197 | - $totalResult = $result->fetchColumn (); |
|
| 195 | + $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter)); |
|
| 196 | + $result->execute($params); |
|
| 197 | + $totalResult = $result->fetchColumn(); |
|
| 198 | 198 | |
| 199 | 199 | // Next modify the query and params |
| 200 | 200 | $query .= " limit ?, ?"; |
| 201 | - array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage); |
|
| 201 | + array_push($params, ($n - 1) * $numberPerPage, $numberPerPage); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter)); |
|
| 205 | - $result->execute ($params); |
|
| 206 | - return array ($totalResult, $result); |
|
| 204 | + $result = self::getDb($database)->prepare(str_format($query, $columns, $filter)); |
|
| 205 | + $result->execute($params); |
|
| 206 | + return array($totalResult, $result); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | } |
@@ -31,21 +31,21 @@ discard block |
||
| 31 | 31 | Publisher::ALL_PUBLISHERS_ID => 'images/publisher.png' |
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | - public function getUpdatedTime () { |
|
| 35 | - if (!is_null ($this->localUpdated)) { |
|
| 36 | - return date (DATE_ATOM, $this->localUpdated); |
|
| 34 | + public function getUpdatedTime() { |
|
| 35 | + if (!is_null($this->localUpdated)) { |
|
| 36 | + return date(DATE_ATOM, $this->localUpdated); |
|
| 37 | 37 | } |
| 38 | - if (is_null (self::$updated)) { |
|
| 38 | + if (is_null(self::$updated)) { |
|
| 39 | 39 | self::$updated = time(); |
| 40 | 40 | } |
| 41 | - return date (DATE_ATOM, self::$updated); |
|
| 41 | + return date(DATE_ATOM, self::$updated); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function getNavLink () { |
|
| 44 | + public function getNavLink() { |
|
| 45 | 45 | foreach ($this->linkArray as $link) { |
| 46 | 46 | if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; } |
| 47 | 47 | |
| 48 | - return $link->hrefXhtml (); |
|
| 48 | + return $link->hrefXhtml(); |
|
| 49 | 49 | } |
| 50 | 50 | return "#"; |
| 51 | 51 | } |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | foreach (self::$icons as $reg => $image) |
| 66 | 66 | { |
| 67 | - if (preg_match ("/" . $reg . "/", $pid)) { |
|
| 68 | - array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE)); |
|
| 67 | + if (preg_match("/" . $reg . "/", $pid)) { |
|
| 68 | + array_push($this->linkArray, new Link(getUrlWithVersion($image), "image/png", Link::OPDS_THUMBNAIL_TYPE)); |
|
| 69 | 69 | break; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id); |
|
| 74 | + if (!is_null(GetUrlParam(DB))) $this->id = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $this->id); |
|
| 75 | 75 | } |
| 76 | 76 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | $this->activeFacet = $pactiveFacet; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function hrefXhtml () { |
|
| 33 | + public function hrefXhtml() { |
|
| 34 | 34 | return $this->href; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllAuthors extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | 13 | $this->title = localize("authors.title"); |
| 14 | - if (getCurrentOption ("author_split_first_letter") == 1) { |
|
| 14 | + if (getCurrentOption("author_split_first_letter") == 1) { |
|
| 15 | 15 | $this->entryArray = Author::getAllAuthorsByFirstLetter(); |
| 16 | 16 | } |
| 17 | 17 | else { |