Completed
Push — master ( 306060...2234f3 )
by Markus
03:46
created
lib/PageLanguageDetail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/PageAllAuthorsLetter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/EntryBook.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
lib/PageSerieDetail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/PageTagDetail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/LinkNavigation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
lib/Book.php 1 patch
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
lib/Rating.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     const ALL_RATING_ID = "cops:rating";
11 11
 
12 12
     const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
13
-    const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
13
+    const SQL_ALL_RATINGS = "select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
14 14
     public $id;
15 15
     public $name;
16 16
 
@@ -19,41 +19,41 @@  discard block
 block discarded – undo
19 19
         $this->name = $pname;
20 20
     }
21 21
 
22
-    public function getUri () {
23
-        return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id";
22
+    public function getUri() {
23
+        return "?page=" . parent::PAGE_RATING_DETAIL . "&id=$this->id";
24 24
     }
25 25
 
26
-    public function getEntryId () {
27
-        return self::ALL_RATING_ID.":".$this->id;
26
+    public function getEntryId() {
27
+        return self::ALL_RATING_ID . ":" . $this->id;
28 28
     }
29 29
 
30 30
     public static function getCount() {
31 31
         // str_format (localize("ratings", count(array))
32
-        return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
32
+        return parent::getCountGeneric("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
33 33
     }
34 34
 
35 35
     public static function getAllRatings() {
36
-        return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
36
+        return self::getEntryArray(self::SQL_ALL_RATINGS, array());
37 37
     }
38 38
 
39
-    public static function getEntryArray ($query, $params) {
40
-        list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
39
+    public static function getEntryArray($query, $params) {
40
+        list (, $result) = parent::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
41 41
         $entryArray = array();
42
-        while ($post = $result->fetchObject ())
42
+        while ($post = $result->fetchObject())
43 43
         {
44
-            $ratingObj = new Rating ($post->id, $post->rating);
45
-            $rating=$post->rating/2;
46
-            $rating = str_format (localize("ratingword", $rating), $rating);
47
-            array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (),
48
-                str_format (localize("bookword", $post->count), $post->count), "text",
49
-                array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count));
44
+            $ratingObj = new Rating($post->id, $post->rating);
45
+            $rating = $post->rating / 2;
46
+            $rating = str_format(localize("ratingword", $rating), $rating);
47
+            array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(),
48
+                str_format(localize("bookword", $post->count), $post->count), "text",
49
+                array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
50 50
         }
51 51
         return $entryArray;
52 52
     }
53 53
 
54
-    public static function getRatingById ($ratingId) {
55
-        $result = parent::getDb ()->prepare('select rating from ratings where id = ?');
56
-        $result->execute (array ($ratingId));
57
-        return new Rating ($ratingId, $result->fetchColumn ());
54
+    public static function getRatingById($ratingId) {
55
+        $result = parent::getDb()->prepare('select rating from ratings where id = ?');
56
+        $result->execute(array($ratingId));
57
+        return new Rating($ratingId, $result->fetchColumn());
58 58
     }
59 59
 }
Please login to merge, or discard this patch.
lib/Base.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -37,142 +37,142 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.