Test Setup Failed
Pull Request — master (#424)
by
unknown
03:11
created
lib/Book.php 5 patches
Doc Comments   +17 added lines, -1 removed lines patch added patch discarded remove patch
@@ -208,6 +208,9 @@  discard block
 block discarded – undo
208 208
         return 'index.php' . $urlParam;
209 209
     }
210 210
 
211
+    /**
212
+     * @return string
213
+     */
211 214
     public function getTitle () {
212 215
         return $this->title;
213 216
     }
@@ -395,6 +398,9 @@  discard block
 block discarded – undo
395 398
         return reset($reduced);
396 399
     }
397 400
 
401
+    /**
402
+     * @param string $extension
403
+     */
398 404
     public function getFilePath($extension, $idData = NULL, $relative = false)
399 405
     {
400 406
         /*if ($extension == 'jpg')
@@ -562,6 +568,9 @@  discard block
 block discarded – undo
562 568
             $this->getLinkArray(), $this);
563 569
     }
564 570
 
571
+    /**
572
+     * @param integer $database
573
+     */
565 574
     public static function getBookCount($database = NULL) {
566 575
         return parent::executeQuerySingle('select count(*) from books', $database);
567 576
     }
@@ -610,7 +619,7 @@  discard block
 block discarded – undo
610 619
     }
611 620
 
612 621
     /**
613
-     * @param $customColumn CustomColumn
622
+     * @param CustomColumn $customColumn CustomColumn
614 623
      * @param $id integer
615 624
      * @param $n integer
616 625
      * @return array
@@ -650,6 +659,10 @@  discard block
 block discarded – undo
650 659
         return NULL;
651 660
     }
652 661
 
662
+    /**
663
+     * @param integer $database
664
+     * @param integer $numberPerPage
665
+     */
653 666
     public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
654 667
         $i = 0;
655 668
         $critArray = array();
@@ -697,6 +710,9 @@  discard block
 block discarded – undo
697 710
         return $entryArray;
698 711
     }
699 712
 
713
+    /**
714
+     * @param integer $numberPerPage
715
+     */
700 716
     public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
701 717
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
702 718
     }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -7,55 +7,55 @@  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_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
29
+define('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
30 30
                                                     where {2}.book = books.id and {2}.value = 1 {1} order by sort');
31
-define ('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
31
+define('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
32 32
                                                     where {2}.book = books.id and {2}.value = 0 {1} order by sort');
33
-define ('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
33
+define('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
34 34
                                                     where books.id not in (select book from {2}) {1} order by sort');
35
-define ('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
35
+define('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
36 36
                                                     left join {2} on {2}.book = books.id
37 37
                                                     left join {3} on {3}.id = {2}.{4}
38 38
                                                     where {3}.value = ?  order by sort');
39
-define ('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
39
+define('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
40 40
 								                    left join {2} on {2}.book = books.id
41 41
 								                    left join {3} on {3}.id = {2}.{4}
42 42
                                                     where ((books.id not in (select {2}.book from {2})) or ({3}.value = 0)) {1} order by sort');
43
-define ('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
43
+define('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
44 44
                                                     where {2}.book = books.id and date({2}.value) = ? {1} order by sort');
45
-define ('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
45
+define('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
46 46
                                                     where {2}.book = books.id and {2}.value = ? {1} order by sort');
47
-define ('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
47
+define('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
48 48
                                                     where {2}.book = books.id and {2}.id = ? {1} order by sort');
49
-define ('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
49
+define('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
50 50
                                                     where (
51 51
                                                     exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or
52 52
                                                     exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or
53 53
                                                     exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or
54 54
                                                     exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or
55 55
                                                     title like ?) {1} order by books.sort');
56
-define ('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
56
+define('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
57 57
                                                     where 1=1 {1} order by timestamp desc limit ');
58
-define ('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
58
+define('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
59 59
                                                     where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort');
60 60
 
61 61
 class Book extends Base
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     public $serie = NULL;
106 106
     public $tags = NULL;
107 107
     public $languages = NULL;
108
-    public $format = array ();
108
+    public $format = array();
109 109
     private $coverFileName = NULL;
110 110
 
111 111
     public function __construct($line) {
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     public function getEntryId() {
194
-        return self::ALL_BOOKS_UUID.':'.$this->uuid;
194
+        return self::ALL_BOOKS_UUID . ':' . $this->uuid;
195 195
     }
196 196
 
197
-    public static function getEntryIdByLetter ($startingLetter) {
198
-        return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
197
+    public static function getEntryIdByLetter($startingLetter) {
198
+        return self::ALL_BOOKS_ID . ':letter:' . $startingLetter;
199 199
     }
200 200
 
201
-    public function getUri () {
202
-        return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id;
201
+    public function getUri() {
202
+        return '?page=' . parent::PAGE_BOOK_DETAIL . '&id=' . $this->id;
203 203
     }
204 204
 
205
-    public function getDetailUrl () {
205
+    public function getDetailUrl() {
206 206
         $urlParam = $this->getUri();
207
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
207
+        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
208 208
         return 'index.php' . $urlParam;
209 209
     }
210 210
 
211
-    public function getTitle () {
211
+    public function getTitle() {
212 212
         return $this->title;
213 213
     }
214 214
 
@@ -217,22 +217,22 @@  discard block
 block discarded – undo
217 217
     /**
218 218
      * @return Author[]
219 219
      */
220
-    public function getAuthors () {
220
+    public function getAuthors() {
221 221
         if (is_null($this->authors)) {
222 222
             $this->authors = Author::getAuthorByBookId($this->id);
223 223
         }
224 224
         return $this->authors;
225 225
     }
226 226
 
227
-    public function getAuthorsName () {
228
-        return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
227
+    public function getAuthorsName() {
228
+        return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors()));
229 229
     }
230 230
 
231
-    public function getAuthorsSort () {
232
-        return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
231
+    public function getAuthorsSort() {
232
+        return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors()));
233 233
     }
234 234
 
235
-    public function getPublisher () {
235
+    public function getPublisher() {
236 236
         if (is_null($this->publisher)) {
237 237
             $this->publisher = Publisher::getPublisherByBookId($this->id);
238 238
         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      * @return Tag[]
272 272
      */
273 273
     public function getTags() {
274
-        if (is_null ($this->tags)) {
274
+        if (is_null($this->tags)) {
275 275
             $this->tags = array();
276 276
 
277 277
             $result = parent::getDb()->prepare('select tags.id as id, name
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     }
290 290
 
291 291
     public function getTagsName() {
292
-        return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
292
+        return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags()));
293 293
     }
294 294
 
295 295
     /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     public function getDataById($idData)
343 343
     {
344
-        $reduced = array_filter($this->getDatas(), function ($data) use ($idData) {
344
+        $reduced = array_filter($this->getDatas(), function($data) use ($idData) {
345 345
             return $data->id == $idData;
346 346
         });
347 347
         return reset($reduced);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         if (empty ($this->pubdate)) {
366 366
             return '';
367 367
         }
368
-        $dateY = (int) substr($this->pubdate, 0, 4);
368
+        $dateY = (int)substr($this->pubdate, 0, 4);
369 369
         if ($dateY > 102) {
370 370
             return str_pad($dateY, 4, '0', STR_PAD_LEFT);
371 371
         }
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 
375 375
     public function getComment($withSerie = true) {
376 376
         $addition = '';
377
-        $se = $this->getSerie ();
378
-        if (!is_null ($se) && $withSerie) {
377
+        $se = $this->getSerie();
378
+        if (!is_null($se) && $withSerie) {
379 379
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
380 380
         }
381 381
         if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     }
390 390
 
391 391
     public function getDataFormat($format) {
392
-        $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
392
+        $reduced = array_filter($this->getDatas(), function($data) use ($format) {
393 393
             return $data->format == $format;
394 394
         });
395 395
         return reset($reduced);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             }
455 455
             $epub->Authors($authorArray);
456 456
             $epub->Language($this->getLanguages());
457
-            $epub->Description ($this->getComment(false));
457
+            $epub->Description($this->getComment(false));
458 458
             $epub->Subjects($this->getTagsName());
459 459
             // -DC- Use cover file name
460 460
             // $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg');
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                 $epub->SerieIndex($this->seriesIndex);
467 467
             }
468 468
             $filename = $data->getUpdatedFilenameEpub();
469
-            if ($config['cops_provide_kepub'] == '1'  && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
469
+            if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
470 470
                 $epub->updateForKepub();
471 471
                 $filename = $data->getUpdatedFilenameKepub();
472 472
             }
@@ -494,11 +494,11 @@  discard block
 block discarded – undo
494 494
             if (!is_null($width)) {
495 495
                 $nw = $width;
496 496
                 if ($nw >= $w) { return false; }
497
-                $nh = ($nw*$h)/$w;
497
+                $nh = ($nw * $h) / $w;
498 498
             } else {
499 499
                 $nh = $height;
500 500
                 if ($nh >= $h) { return false; }
501
-                $nw = ($nh*$w)/$h;
501
+                $nw = ($nh * $w) / $h;
502 502
             }
503 503
         } else {
504 504
             return false;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         else {
512 512
         	$src_img = imagecreatefromjpeg($file);
513 513
         }
514
-        $dst_img = imagecreatetruecolor($nw,$nh);
514
+        $dst_img = imagecreatetruecolor($nw, $nh);
515 515
         if (!imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h)) {
516 516
         	return false;
517 517
         }
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         return true;
532 532
     }
533 533
 
534
-    public function getLinkArray ()
534
+    public function getLinkArray()
535 535
     {
536 536
         $linkArray = array();
537 537
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         }
565 565
 
566 566
         $serie = $this->getSerie();
567
-        if (!is_null ($serie)) {
567
+        if (!is_null($serie)) {
568 568
             array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name)));
569 569
         }
570 570
 
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
         $entry = new Entry(localize('allbooks.title'),
590 590
                           self::ALL_BOOKS_ID,
591 591
                           str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
592
-                          array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks);
592
+                          array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS)), '', $nBooks);
593 593
         array_push($result, $entry);
594 594
         if ($config['cops_recentbooks_limit'] > 0) {
595 595
             $entry = new Entry(localize('recent.title'),
596 596
                               self::ALL_RECENT_BOOKS_ID,
597 597
                               str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
598
-                              array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
598
+                              array(new LinkNavigation('?page=' . parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
599 599
             array_push($result, $entry);
600 600
         }
601 601
         return $result;
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
     }
692 692
 
693 693
     public static function getBooks($n) {
694
-        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
694
+        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n);
695 695
         return array($entryArray, $totalNumber);
696 696
     }
697 697
 
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
         {
709 709
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
710 710
                 str_format(localize('bookword', $post->count), $post->count), 'text',
711
-                array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
711
+                array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count));
712 712
         }
713 713
         return $entryArray;
714 714
     }
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 
734 734
     public static function getAllRecentBooks() {
735 735
         global $config;
736
-        list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
736
+        list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
737 737
         return $entryArray;
738 738
     }
739 739
 
Please login to merge, or discard this patch.
Braces   +103 added lines, -81 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@  discard block
 block discarded – undo
108 108
     public $format = array ();
109 109
     private $coverFileName = NULL;
110 110
 
111
-    public function __construct($line) {
111
+    public function __construct($line)
112
+    {
112 113
     	global $config;
113 114
 
114 115
         $this->id = $line->id;
@@ -168,8 +169,7 @@  discard block
 block discarded – undo
168 169
         		}
169 170
         		if ($cover === false || !file_exists($cover)) {
170 171
         			$this->hasCover = 0;
171
-        		}
172
-        		else {
172
+        		} else {
173 173
         			$this->coverFileName = $cover;
174 174
         		}
175 175
         	}
@@ -190,25 +190,32 @@  discard block
 block discarded – undo
190 190
     	return $res;
191 191
     }
192 192
 
193
-    public function getEntryId() {
193
+    public function getEntryId()
194
+    {
194 195
         return self::ALL_BOOKS_UUID.':'.$this->uuid;
195 196
     }
196 197
 
197
-    public static function getEntryIdByLetter ($startingLetter) {
198
+    public static function getEntryIdByLetter ($startingLetter)
199
+    {
198 200
         return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
199 201
     }
200 202
 
201
-    public function getUri () {
203
+    public function getUri ()
204
+    {
202 205
         return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id;
203 206
     }
204 207
 
205
-    public function getDetailUrl () {
208
+    public function getDetailUrl ()
209
+    {
206 210
         $urlParam = $this->getUri();
207
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
211
+        if (!is_null(GetUrlParam(DB))) {
212
+            $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
213
+        }
208 214
         return 'index.php' . $urlParam;
209 215
     }
210 216
 
211
-    public function getTitle () {
217
+    public function getTitle ()
218
+    {
212 219
         return $this->title;
213 220
     }
214 221
 
@@ -217,22 +224,26 @@  discard block
 block discarded – undo
217 224
     /**
218 225
      * @return Author[]
219 226
      */
220
-    public function getAuthors () {
227
+    public function getAuthors ()
228
+    {
221 229
         if (is_null($this->authors)) {
222 230
             $this->authors = Author::getAuthorByBookId($this->id);
223 231
         }
224 232
         return $this->authors;
225 233
     }
226 234
 
227
-    public function getAuthorsName () {
235
+    public function getAuthorsName ()
236
+    {
228 237
         return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
229 238
     }
230 239
 
231
-    public function getAuthorsSort () {
240
+    public function getAuthorsSort ()
241
+    {
232 242
         return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
233 243
     }
234 244
 
235
-    public function getPublisher () {
245
+    public function getPublisher ()
246
+    {
236 247
         if (is_null($this->publisher)) {
237 248
             $this->publisher = Publisher::getPublisherByBookId($this->id);
238 249
         }
@@ -242,7 +253,8 @@  discard block
 block discarded – undo
242 253
     /**
243 254
      * @return Serie
244 255
      */
245
-    public function getSerie() {
256
+    public function getSerie()
257
+    {
246 258
         if (is_null($this->serie)) {
247 259
             $this->serie = Serie::getSerieByBookId($this->id);
248 260
         }
@@ -252,7 +264,8 @@  discard block
 block discarded – undo
252 264
     /**
253 265
      * @return string
254 266
      */
255
-    public function getLanguages() {
267
+    public function getLanguages()
268
+    {
256 269
         $lang = array();
257 270
         $result = parent::getDb()->prepare('select languages.lang_code
258 271
                 from books_languages_link, languages
@@ -260,8 +273,7 @@  discard block
 block discarded – undo
260 273
                 and book = ?
261 274
                 order by item_order');
262 275
         $result->execute(array($this->id));
263
-        while ($post = $result->fetchObject())
264
-        {
276
+        while ($post = $result->fetchObject()) {
265 277
             array_push($lang, Language::getLanguageString($post->lang_code));
266 278
         }
267 279
         return implode(', ', $lang);
@@ -270,7 +282,8 @@  discard block
 block discarded – undo
270 282
     /**
271 283
      * @return Tag[]
272 284
      */
273
-    public function getTags() {
285
+    public function getTags()
286
+    {
274 287
         if (is_null ($this->tags)) {
275 288
             $this->tags = array();
276 289
 
@@ -280,15 +293,15 @@  discard block
 block discarded – undo
280 293
                 and book = ?
281 294
                 order by name');
282 295
             $result->execute(array($this->id));
283
-            while ($post = $result->fetchObject())
284
-            {
296
+            while ($post = $result->fetchObject()) {
285 297
                 array_push($this->tags, new Tag($post));
286 298
             }
287 299
         }
288 300
         return $this->tags;
289 301
     }
290 302
 
291
-    public function getTagsName() {
303
+    public function getTagsName()
304
+    {
292 305
         return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
293 306
     }
294 307
 
@@ -305,9 +318,12 @@  discard block
 block discarded – undo
305 318
 
306 319
     /* End of other class (author, series, tag, ...) initialization and accessors */
307 320
 
308
-    public static function getFilterString() {
321
+    public static function getFilterString()
322
+    {
309 323
         $filter = getURLParam('tag', NULL);
310
-        if (empty($filter)) return '';
324
+        if (empty($filter)) {
325
+            return '';
326
+        }
311 327
 
312 328
         $exists = true;
313 329
         if (preg_match("/^!(.*)$/", $filter, $matches)) {
@@ -347,7 +363,8 @@  discard block
 block discarded – undo
347 363
         return reset($reduced);
348 364
     }
349 365
 
350
-    public function getRating() {
366
+    public function getRating()
367
+    {
351 368
         if (is_null($this->rating) || $this->rating == 0) {
352 369
             return '';
353 370
         }
@@ -361,7 +378,8 @@  discard block
 block discarded – undo
361 378
         return $retour;
362 379
     }
363 380
 
364
-    public function getPubDate() {
381
+    public function getPubDate()
382
+    {
365 383
         if (empty ($this->pubdate)) {
366 384
             return '';
367 385
         }
@@ -372,23 +390,22 @@  discard block
 block discarded – undo
372 390
         return '';
373 391
     }
374 392
 
375
-    public function getComment($withSerie = true) {
393
+    public function getComment($withSerie = true)
394
+    {
376 395
         $addition = '';
377 396
         $se = $this->getSerie ();
378 397
         if (!is_null ($se) && $withSerie) {
379 398
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
380 399
         }
381
-        if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
382
-        {
400
+        if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) {
383 401
             return $addition . html2xhtml($this->comment);
384
-        }
385
-        else
386
-        {
402
+        } else {
387 403
             return $addition . htmlspecialchars($this->comment);
388 404
         }
389 405
     }
390 406
 
391
-    public function getDataFormat($format) {
407
+    public function getDataFormat($format)
408
+    {
392 409
         $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
393 410
             return $data->format == $format;
394 411
         });
@@ -419,16 +436,14 @@  discard block
 block discarded – undo
419 436
     	if ($extension == "jpg" || $extension == "png") {
420 437
     		if (empty($this->coverFileName)) {
421 438
     			return $this->path . '/cover.' . $extension;
422
-    		}
423
-    		else {
439
+    		} else {
424 440
     			$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
425 441
     			if ($ext == $extension) {
426 442
     				return $this->coverFileName;
427 443
     			}
428 444
     		}
429 445
     		return false;
430
-    	}
431
-    	else {
446
+    	} else {
432 447
     		$data = $this->getDataById($idData);
433 448
     		if (!$data) {
434 449
     			return NULL;
@@ -443,8 +458,7 @@  discard block
 block discarded – undo
443 458
         global $config;
444 459
         $data = $this->getDataById($idData);
445 460
 
446
-        try
447
-        {
461
+        try {
448 462
             $epub = new EPub($data->getLocalPath());
449 463
 
450 464
             $epub->Title($this->title);
@@ -471,14 +485,13 @@  discard block
 block discarded – undo
471 485
                 $filename = $data->getUpdatedFilenameKepub();
472 486
             }
473 487
             $epub->download($filename);
474
-        }
475
-        catch (Exception $e)
476
-        {
488
+        } catch (Exception $e) {
477 489
             echo 'Exception : ' . $e->getMessage();
478 490
         }
479 491
     }
480 492
 
481
-    public function getThumbnail($width, $height, $outputfile = NULL, $inType = 'jpg') {
493
+    public function getThumbnail($width, $height, $outputfile = NULL, $inType = 'jpg')
494
+    {
482 495
         if (is_null($width) && is_null($height)) {
483 496
             return false;
484 497
         }
@@ -507,8 +520,7 @@  discard block
 block discarded – undo
507 520
         // Draw the image
508 521
         if ($inType == 'png') {
509 522
         	$src_img = imagecreatefrompng($file);
510
-        }
511
-        else {
523
+        } else {
512 524
         	$src_img = imagecreatefromjpeg($file);
513 525
         }
514 526
         $dst_img = imagecreatetruecolor($nw,$nh);
@@ -519,8 +531,7 @@  discard block
 block discarded – undo
519 531
         	if (!imagepng($dst_img, $outputfile, 9)) {
520 532
         		return false;
521 533
         	}
522
-        }
523
-        else {
534
+        } else {
524 535
         	if (!imagejpeg($dst_img, $outputfile, 80)) {
525 536
         		return false;
526 537
         	}
@@ -543,17 +554,14 @@  discard block
 block discarded – undo
543 554
         	if ($ext == 'png') {
544 555
         		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
545 556
         		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
546
-        	}
547
-        	else {
557
+        	} else {
548 558
         		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
549 559
         		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
550 560
         	}
551 561
         }
552 562
 
553
-        foreach ($this->getDatas() as $data)
554
-        {
555
-            if ($data->isKnownType())
556
-            {
563
+        foreach ($this->getDatas() as $data) {
564
+            if ($data->isKnownType()) {
557 565
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
558 566
             }
559 567
         }
@@ -572,17 +580,20 @@  discard block
 block discarded – undo
572 580
     }
573 581
 
574 582
 
575
-    public function getEntry() {
583
+    public function getEntry()
584
+    {
576 585
         return new EntryBook($this->getTitle(), $this->getEntryId(),
577 586
             $this->getComment(), 'text/html',
578 587
             $this->getLinkArray(), $this);
579 588
     }
580 589
 
581
-    public static function getBookCount($database = NULL) {
590
+    public static function getBookCount($database = NULL)
591
+    {
582 592
         return parent::executeQuerySingle('select count(*) from books', $database);
583 593
     }
584 594
 
585
-    public static function getCount() {
595
+    public static function getCount()
596
+    {
586 597
         global $config;
587 598
         $nBooks = parent::executeQuerySingle('select count(*) from books');
588 599
         $result = array();
@@ -601,27 +612,33 @@  discard block
 block discarded – undo
601 612
         return $result;
602 613
     }
603 614
 
604
-    public static function getBooksByAuthor($authorId, $n) {
615
+    public static function getBooksByAuthor($authorId, $n)
616
+    {
605 617
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
606 618
     }
607 619
 
608
-    public static function getBooksByRating($ratingId, $n) {
620
+    public static function getBooksByRating($ratingId, $n)
621
+    {
609 622
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
610 623
     }
611 624
 
612
-    public static function getBooksByPublisher($publisherId, $n) {
625
+    public static function getBooksByPublisher($publisherId, $n)
626
+    {
613 627
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
614 628
     }
615 629
 
616
-    public static function getBooksBySeries($serieId, $n) {
630
+    public static function getBooksBySeries($serieId, $n)
631
+    {
617 632
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
618 633
     }
619 634
 
620
-    public static function getBooksByTag($tagId, $n) {
635
+    public static function getBooksByTag($tagId, $n)
636
+    {
621 637
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
622 638
     }
623 639
 
624
-    public static function getBooksByLanguage($languageId, $n) {
640
+    public static function getBooksByLanguage($languageId, $n)
641
+    {
625 642
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
626 643
     }
627 644
 
@@ -631,32 +648,33 @@  discard block
 block discarded – undo
631 648
      * @param $n integer
632 649
      * @return array
633 650
      */
634
-    public static function getBooksByCustom($customColumn, $id, $n) {
651
+    public static function getBooksByCustom($customColumn, $id, $n)
652
+    {
635 653
         list($query, $params) = $customColumn->getQuery($id);
636 654
 
637 655
         return self::getEntryArray($query, $params, $n);
638 656
     }
639 657
 
640
-    public static function getBookById($bookId) {
658
+    public static function getBookById($bookId)
659
+    {
641 660
     	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . '
642 661
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
643 662
 where books.id = ?');
644 663
         $result->execute(array($bookId));
645
-        while ($post = $result->fetchObject())
646
-        {
664
+        while ($post = $result->fetchObject()) {
647 665
             $book = new Book($post);
648 666
             return $book;
649 667
         }
650 668
         return NULL;
651 669
     }
652 670
 
653
-    public static function getBookByDataId($dataId) {
671
+    public static function getBookByDataId($dataId)
672
+    {
654 673
     	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format
655 674
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
656 675
 where data.book = books.id and data.id = ?');
657 676
         $result->execute(array($dataId));
658
-        while ($post = $result->fetchObject())
659
-        {
677
+        while ($post = $result->fetchObject()) {
660 678
             $book = new Book($post);
661 679
             $data = new Data($post, $book);
662 680
             $data->id = $dataId;
@@ -666,7 +684,8 @@  discard block
 block discarded – undo
666 684
         return NULL;
667 685
     }
668 686
 
669
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
687
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
688
+    {
670 689
         $i = 0;
671 690
         $critArray = array();
672 691
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -677,8 +696,7 @@  discard block
 block discarded – undo
677 696
             if (in_array($key, getCurrentOption('ignored_categories')) ||
678 697
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
679 698
                 $critArray[$i] = self::BAD_SEARCH;
680
-            }
681
-            else {
699
+            } else {
682 700
                 if (array_key_exists($key, $query)) {
683 701
                     $critArray[$i] = $query[$key];
684 702
                 } else {
@@ -690,12 +708,14 @@  discard block
 block discarded – undo
690 708
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
691 709
     }
692 710
 
693
-    public static function getBooks($n) {
711
+    public static function getBooks($n)
712
+    {
694 713
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
695 714
         return array($entryArray, $totalNumber);
696 715
     }
697 716
 
698
-    public static function getAllBooks() {
717
+    public static function getAllBooks()
718
+    {
699 719
         /* @var $result PDOStatement */
700 720
 
701 721
         list (, $result) = parent::executeQuery('select {0}
@@ -704,8 +724,7 @@  discard block
 block discarded – undo
704 724
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
705 725
 
706 726
         $entryArray = array();
707
-        while ($post = $result->fetchObject())
708
-        {
727
+        while ($post = $result->fetchObject()) {
709 728
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
710 729
                 str_format(localize('bookword', $post->count), $post->count), 'text',
711 730
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -713,25 +732,27 @@  discard block
 block discarded – undo
713 732
         return $entryArray;
714 733
     }
715 734
 
716
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
735
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
736
+    {
717 737
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
718 738
     }
719 739
 
720
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
740
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
741
+    {
721 742
         /* @var $totalNumber integer */
722 743
         /* @var $result PDOStatement */
723 744
     	list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
724 745
 
725 746
         $entryArray = array();
726
-        while ($post = $result->fetchObject())
727
-        {
747
+        while ($post = $result->fetchObject()) {
728 748
             $book = new Book($post);
729 749
             array_push($entryArray, $book->getEntry());
730 750
         }
731 751
         return array($entryArray, $totalNumber);
732 752
     }
733 753
 
734
-    public static function getAllRecentBooks() {
754
+    public static function getAllRecentBooks()
755
+    {
735 756
         global $config;
736 757
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
737 758
         return $entryArray;
@@ -743,7 +764,8 @@  discard block
 block discarded – undo
743 764
      * @param string[] $columns
744 765
      * @return CustomColumn[]
745 766
      */
746
-    public function getCustomColumnValues($columns, $asArray = false) {
767
+    public function getCustomColumnValues($columns, $asArray = false)
768
+    {
747 769
         $result = array();
748 770
 
749 771
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
     public $seriesIndex;
100 100
     public $comment;
101 101
     public $rating;
102
-    public $datas = NULL;
103
-    public $authors = NULL;
104
-    public $publisher = NULL;
105
-    public $serie = NULL;
106
-    public $tags = NULL;
107
-    public $languages = NULL;
102
+    public $datas = null;
103
+    public $authors = null;
104
+    public $publisher = null;
105
+    public $serie = null;
106
+    public $tags = null;
107
+    public $languages = null;
108 108
     public $format = array ();
109
-    private $coverFileName = NULL;
109
+    private $coverFileName = null;
110 110
 
111 111
     public function __construct($line) {
112 112
     	global $config;
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         		$imgDirectory = Base::getImgDirectory();
137 137
         		$this->coverFileName = $line->cover;
138 138
         		if (!file_exists($this->coverFileName)) {
139
-        			$this->coverFileName = NULL;
139
+        			$this->coverFileName = null;
140 140
         		}
141 141
         		if (empty($this->coverFileName)) {
142 142
         			$this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover);
143 143
         			if (!file_exists($this->coverFileName)) {
144
-        				$this->coverFileName = NULL;
144
+        				$this->coverFileName = null;
145 145
         			}
146 146
         		}
147 147
         		if (empty($this->coverFileName)) {
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
         			if ($data) {
150 150
         				$this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover);
151 151
         				if (!file_exists($this->coverFileName)) {
152
-        					$this->coverFileName = NULL;
152
+        					$this->coverFileName = null;
153 153
         				}
154 154
         				if (empty($this->coverFileName)) {
155 155
         					$this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name);
156 156
         					if (!file_exists($this->coverFileName)) {
157
-        						$this->coverFileName = NULL;
157
+        						$this->coverFileName = null;
158 158
         					}
159 159
         				}
160 160
         			}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     /* End of other class (author, series, tag, ...) initialization and accessors */
307 307
 
308 308
     public static function getFilterString() {
309
-        $filter = getURLParam('tag', NULL);
309
+        $filter = getURLParam('tag', null);
310 310
         if (empty($filter)) return '';
311 311
 
312 312
         $exists = true;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
     {
329 329
         $bestFormatForKindle = array('EPUB', 'PDF', 'AZW3', 'MOBI');
330 330
         $bestRank = -1;
331
-        $bestData = NULL;
331
+        $bestData = null;
332 332
         foreach ($this->getDatas() as $data) {
333 333
             $key = array_search($data->format, $bestFormatForKindle);
334 334
             if ($key !== false && $key > $bestRank) {
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         return reset($reduced);
396 396
     }
397 397
 
398
-    public function getFilePath($extension, $idData = NULL, $relative = false)
398
+    public function getFilePath($extension, $idData = null, $relative = false)
399 399
     {
400 400
         /*if ($extension == 'jpg')
401 401
         {
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     	else {
432 432
     		$data = $this->getDataById($idData);
433 433
     		if (!$data) {
434
-    			return NULL;
434
+    			return null;
435 435
     		}
436 436
     		$file = $data->name . "." . strtolower($data->format);
437 437
     		return $this->path . '/' . $file;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         }
479 479
     }
480 480
 
481
-    public function getThumbnail($width, $height, $outputfile = NULL, $inType = 'jpg') {
481
+    public function getThumbnail($width, $height, $outputfile = null, $inType = 'jpg') {
482 482
         if (is_null($width) && is_null($height)) {
483 483
             return false;
484 484
         }
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
         	//array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
542 542
         	$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
543 543
         	if ($ext == 'png') {
544
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
545
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
544
+        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", null));
545
+        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", null));
546 546
         	}
547 547
         	else {
548
-        		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
549
-        		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
548
+        		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', null));
549
+        		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", null));
550 550
         	}
551 551
         }
552 552
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
             $this->getLinkArray(), $this);
579 579
     }
580 580
 
581
-    public static function getBookCount($database = NULL) {
581
+    public static function getBookCount($database = null) {
582 582
         return parent::executeQuerySingle('select count(*) from books', $database);
583 583
     }
584 584
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
             $book = new Book($post);
648 648
             return $book;
649 649
         }
650
-        return NULL;
650
+        return null;
651 651
     }
652 652
 
653 653
     public static function getBookByDataId($dataId) {
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
             $book->datas = array($data);
664 664
             return $book;
665 665
         }
666
-        return NULL;
666
+        return null;
667 667
     }
668 668
 
669
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
669
+    public static function getBooksByQuery($query, $n, $database = null, $numberPerPage = null) {
670 670
         $i = 0;
671 671
         $critArray = array();
672 672
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
         return $entryArray;
714 714
     }
715 715
 
716
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
716
+    public static function getBooksByStartingLetter($letter, $n, $database = null, $numberPerPage = null) {
717 717
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
718 718
     }
719 719
 
720
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
720
+    public static function getEntryArray($query, $params, $n, $database = null, $numberPerPage = null) {
721 721
         /* @var $totalNumber integer */
722 722
         /* @var $result PDOStatement */
723 723
     	list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
Please login to merge, or discard this patch.
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     private $coverFileName = NULL;
110 110
 
111 111
     public function __construct($line) {
112
-    	global $config;
112
+        global $config;
113 113
 
114 114
         $this->id = $line->id;
115 115
         $this->title = $line->title;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         // -DC- Init relative or full path
121 121
         $this->path = $line->path;
122 122
         if (!is_dir($this->path)) {
123
-        	$this->path = Base::getDbDirectory() . $line->path;
123
+            $this->path = Base::getDbDirectory() . $line->path;
124 124
         }
125 125
         $this->seriesIndex = $line->series_index;
126 126
         $this->comment = $line->comment;
@@ -132,48 +132,48 @@  discard block
 block discarded – undo
132 132
         //    $this->hasCover = 0;
133 133
         //}
134 134
         if ($this->hasCover) {
135
-        	if (!empty($config['calibre_database_field_cover'])) {
136
-        		$imgDirectory = Base::getImgDirectory();
137
-        		$this->coverFileName = $line->cover;
138
-        		if (!file_exists($this->coverFileName)) {
139
-        			$this->coverFileName = NULL;
140
-        		}
141
-        		if (empty($this->coverFileName)) {
142
-        			$this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover);
143
-        			if (!file_exists($this->coverFileName)) {
144
-        				$this->coverFileName = NULL;
145
-        			}
146
-        		}
147
-        		if (empty($this->coverFileName)) {
148
-        			// Try with the epub file name
149
-        			$data = $this->getDataFormat('EPUB');
150
-        			if ($data) {
151
-        				$this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover);
152
-        				if (!file_exists($this->coverFileName)) {
153
-        					$this->coverFileName = NULL;
154
-        				}
155
-        				if (empty($this->coverFileName)) {
156
-        					$this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name);
157
-        					if (!file_exists($this->coverFileName)) {
158
-        						$this->coverFileName = NULL;
159
-        					}
160
-        				}
161
-        			}
162
-        		}
163
-        	}
164
-        	// Else try with default cover file name
165
-        	if (empty($this->coverFileName)) {
166
-        		$cover = $this->getFilePath("jpg");
167
-        		if ($cover === false || !file_exists($cover)) {
168
-        			$cover = $this->getFilePath("png");
169
-        		}
170
-        		if ($cover === false || !file_exists($cover)) {
171
-        			$this->hasCover = 0;
172
-        		}
173
-        		else {
174
-        			$this->coverFileName = $cover;
175
-        		}
176
-        	}
135
+            if (!empty($config['calibre_database_field_cover'])) {
136
+                $imgDirectory = Base::getImgDirectory();
137
+                $this->coverFileName = $line->cover;
138
+                if (!file_exists($this->coverFileName)) {
139
+                    $this->coverFileName = NULL;
140
+                }
141
+                if (empty($this->coverFileName)) {
142
+                    $this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover);
143
+                    if (!file_exists($this->coverFileName)) {
144
+                        $this->coverFileName = NULL;
145
+                    }
146
+                }
147
+                if (empty($this->coverFileName)) {
148
+                    // Try with the epub file name
149
+                    $data = $this->getDataFormat('EPUB');
150
+                    if ($data) {
151
+                        $this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover);
152
+                        if (!file_exists($this->coverFileName)) {
153
+                            $this->coverFileName = NULL;
154
+                        }
155
+                        if (empty($this->coverFileName)) {
156
+                            $this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name);
157
+                            if (!file_exists($this->coverFileName)) {
158
+                                $this->coverFileName = NULL;
159
+                            }
160
+                        }
161
+                    }
162
+                }
163
+            }
164
+            // Else try with default cover file name
165
+            if (empty($this->coverFileName)) {
166
+                $cover = $this->getFilePath("jpg");
167
+                if ($cover === false || !file_exists($cover)) {
168
+                    $cover = $this->getFilePath("png");
169
+                }
170
+                if ($cover === false || !file_exists($cover)) {
171
+                    $this->hasCover = 0;
172
+                }
173
+                else {
174
+                    $this->coverFileName = $cover;
175
+                }
176
+            }
177 177
         }
178 178
         $this->rating = $line->rating;
179 179
     }
@@ -181,14 +181,14 @@  discard block
 block discarded – undo
181 181
     // -DC- Get customisable book columns
182 182
     private static function getBookColumns()
183 183
     {
184
-    	global $config;
184
+        global $config;
185 185
 
186
-    	$res = self::BOOK_COLUMNS;
187
-    	if (!empty($config['calibre_database_field_cover'])) {
188
-    		$res = str_replace('has_cover,', 'has_cover, ' . $config['calibre_database_field_cover'] . ',', $res);
189
-    	}
186
+        $res = self::BOOK_COLUMNS;
187
+        if (!empty($config['calibre_database_field_cover'])) {
188
+            $res = str_replace('has_cover,', 'has_cover, ' . $config['calibre_database_field_cover'] . ',', $res);
189
+        }
190 190
 
191
-    	return $res;
191
+        return $res;
192 192
     }
193 193
 
194 194
     public function getEntryId() {
@@ -417,26 +417,26 @@  discard block
 block discarded – undo
417 417
         {
418 418
             return $this->path.'/'.$file;
419 419
         }*/
420
-    	if ($extension == "jpg" || $extension == "png") {
421
-    		if (empty($this->coverFileName)) {
422
-    			return $this->path . '/cover.' . $extension;
423
-    		}
424
-    		else {
425
-    			$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
426
-    			if ($ext == $extension) {
427
-    				return $this->coverFileName;
428
-    			}
429
-    		}
430
-    		return false;
431
-    	}
432
-    	else {
433
-    		$data = $this->getDataById($idData);
434
-    		if (!$data) {
435
-    			return NULL;
436
-    		}
437
-    		$file = $data->name . "." . strtolower($data->format);
438
-    		return $this->path . '/' . $file;
439
-    	}
420
+        if ($extension == "jpg" || $extension == "png") {
421
+            if (empty($this->coverFileName)) {
422
+                return $this->path . '/cover.' . $extension;
423
+            }
424
+            else {
425
+                $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
426
+                if ($ext == $extension) {
427
+                    return $this->coverFileName;
428
+                }
429
+            }
430
+            return false;
431
+        }
432
+        else {
433
+            $data = $this->getDataById($idData);
434
+            if (!$data) {
435
+                return NULL;
436
+            }
437
+            $file = $data->name . "." . strtolower($data->format);
438
+            return $this->path . '/' . $file;
439
+        }
440 440
     }
441 441
 
442 442
     public function getUpdatedEpub($idData)
@@ -507,24 +507,24 @@  discard block
 block discarded – undo
507 507
 
508 508
         // Draw the image
509 509
         if ($inType == 'png') {
510
-        	$src_img = imagecreatefrompng($file);
510
+            $src_img = imagecreatefrompng($file);
511 511
         }
512 512
         else {
513
-        	$src_img = imagecreatefromjpeg($file);
513
+            $src_img = imagecreatefromjpeg($file);
514 514
         }
515 515
         $dst_img = imagecreatetruecolor($nw,$nh);
516 516
         if (!imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h)) {
517
-        	return false;
517
+            return false;
518 518
         }
519 519
         if ($inType == 'png') {
520
-        	if (!imagepng($dst_img, $outputfile, 9)) {
521
-        		return false;
522
-        	}
520
+            if (!imagepng($dst_img, $outputfile, 9)) {
521
+                return false;
522
+            }
523 523
         }
524 524
         else {
525
-        	if (!imagejpeg($dst_img, $outputfile, 80)) {
526
-        		return false;
527
-        	}
525
+            if (!imagejpeg($dst_img, $outputfile, 80)) {
526
+                return false;
527
+            }
528 528
         }
529 529
         imagedestroy($src_img);
530 530
         imagedestroy($dst_img);
@@ -537,18 +537,18 @@  discard block
 block discarded – undo
537 537
         $linkArray = array();
538 538
 
539 539
         if ($this->hasCover) {
540
-        	// -DC- Use cover file name
541
-        	//array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
542
-        	//array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
543
-        	$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
544
-        	if ($ext == 'png') {
545
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
546
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
547
-        	}
548
-        	else {
549
-        		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
550
-        		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
551
-        	}
540
+            // -DC- Use cover file name
541
+            //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
542
+            //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
543
+            $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
544
+            if ($ext == 'png') {
545
+                array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
546
+                array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
547
+            }
548
+            else {
549
+                array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
550
+                array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
551
+            }
552 552
         }
553 553
 
554 554
         foreach ($this->getDatas() as $data)
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
         $nBooks = parent::executeQuerySingle('select count(*) from books');
589 589
         $result = array();
590 590
         $entry = new Entry(localize('allbooks.title'),
591
-                          self::ALL_BOOKS_ID,
592
-                          str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
593
-                          array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks);
591
+                            self::ALL_BOOKS_ID,
592
+                            str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
593
+                            array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks);
594 594
         array_push($result, $entry);
595 595
         if ($config['cops_recentbooks_limit'] > 0) {
596 596
             $entry = new Entry(localize('recent.title'),
597
-                              self::ALL_RECENT_BOOKS_ID,
598
-                              str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
599
-                              array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
597
+                                self::ALL_RECENT_BOOKS_ID,
598
+                                str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
599
+                                array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
600 600
             array_push($result, $entry);
601 601
         }
602 602
         return $result;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
     }
640 640
 
641 641
     public static function getBookById($bookId) {
642
-    	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . '
642
+        $result = parent::getDb()->prepare('select ' . self::getBookColumns() . '
643 643
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
644 644
 where books.id = ?');
645 645
         $result->execute(array($bookId));
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
     }
653 653
 
654 654
     public static function getBookByDataId($dataId) {
655
-    	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format
655
+        $result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format
656 656
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
657 657
 where data.book = books.id and data.id = ?');
658 658
         $result->execute(array($dataId));
@@ -671,10 +671,10 @@  discard block
 block discarded – undo
671 671
         $i = 0;
672 672
         $critArray = array();
673 673
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
674
-                       PageQueryResult::SCOPE_TAG,
675
-                       PageQueryResult::SCOPE_SERIES,
676
-                       PageQueryResult::SCOPE_PUBLISHER,
677
-                       PageQueryResult::SCOPE_BOOK) as $key) {
674
+                        PageQueryResult::SCOPE_TAG,
675
+                        PageQueryResult::SCOPE_SERIES,
676
+                        PageQueryResult::SCOPE_PUBLISHER,
677
+                        PageQueryResult::SCOPE_BOOK) as $key) {
678 678
             if (in_array($key, getCurrentOption('ignored_categories')) ||
679 679
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
680 680
                 $critArray[$i] = self::BAD_SEARCH;
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
     public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
722 722
         /* @var $totalNumber integer */
723 723
         /* @var $result PDOStatement */
724
-    	list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
724
+        list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
725 725
 
726 726
         $entryArray = array();
727 727
         while ($post = $result->fetchObject())
Please login to merge, or discard this patch.
lib/Base.php 4 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,13 +99,13 @@
 block discarded – undo
99 99
 
100 100
     // -DC- Add image directory
101 101
     public static function getImgDirectory ($database = NULL) {
102
-    	global $config;
103
-    	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
-    		$array = array_values ($config['image_directory']);
106
-    		return  $array[$database];
107
-    	}
108
-    	return $config['image_directory'];
102
+        global $config;
103
+        if (self::isMultipleDatabaseEnabled ()) {
104
+            if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
+            $array = array_values ($config['image_directory']);
106
+            return  $array[$database];
107
+        }
108
+        return $config['image_directory'];
109 109
     }
110 110
 
111 111
     public static function getDbFileName ($database = NULL) {
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -37,156 +37,156 @@  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
-                self::error ($database);
79
+                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
-                self::error ($database);
92
+                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
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
101
+    public static function getImgDirectory($database = NULL) {
102 102
     	global $config;
103
-    	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
-    		$array = array_values ($config['image_directory']);
103
+    	if (self::isMultipleDatabaseEnabled()) {
104
+    		if (is_null($database)) $database = GetUrlParam(DB, 0);
105
+    		$array = array_values($config['image_directory']);
106 106
     		return  $array[$database];
107 107
     	}
108 108
     	return $config['image_directory'];
109 109
     }
110 110
 
111
-    public static function getDbFileName ($database = NULL) {
112
-        return self::getDbDirectory ($database) .'metadata.db';
111
+    public static function getDbFileName($database = NULL) {
112
+        return self::getDbDirectory($database) . 'metadata.db';
113 113
     }
114 114
 
115
-    private static function error ($database) {
115
+    private static function error($database) {
116 116
         if (php_sapi_name() != "cli") {
117 117
             header("location: checkconfig.php?err=1");
118 118
         }
119 119
         throw new Exception("Database <{$database}> not found.");
120 120
     }
121 121
 
122
-    public static function getDb ($database = NULL) {
123
-        if (is_null (self::$db)) {
122
+    public static function getDb($database = NULL) {
123
+        if (is_null(self::$db)) {
124 124
             try {
125
-                if (is_readable (self::getDbFileName ($database))) {
126
-                    self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
127
-                    if (useNormAndUp ()) {
128
-                        self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1);
125
+                if (is_readable(self::getDbFileName($database))) {
126
+                    self::$db = new PDO('sqlite:' . self::getDbFileName($database));
127
+                    if (useNormAndUp()) {
128
+                        self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1);
129 129
                     }
130 130
                 } else {
131
-                    self::error ($database);
131
+                    self::error($database);
132 132
                 }
133 133
             } catch (Exception $e) {
134
-                self::error ($database);
134
+                self::error($database);
135 135
             }
136 136
         }
137 137
         return self::$db;
138 138
     }
139 139
 
140
-    public static function checkDatabaseAvailability () {
141
-        if (self::noDatabaseSelected ()) {
142
-            for ($i = 0; $i < count (self::getDbList ()); $i++) {
143
-                self::getDb ($i);
144
-                self::clearDb ();
140
+    public static function checkDatabaseAvailability() {
141
+        if (self::noDatabaseSelected()) {
142
+            for ($i = 0; $i < count(self::getDbList()); $i++) {
143
+                self::getDb($i);
144
+                self::clearDb();
145 145
             }
146 146
         } else {
147
-            self::getDb ();
147
+            self::getDb();
148 148
         }
149 149
         return true;
150 150
     }
151 151
 
152
-    public static function clearDb () {
152
+    public static function clearDb() {
153 153
         self::$db = NULL;
154 154
     }
155 155
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
157
-        return self::getDb ($database)->query($query)->fetchColumn();
156
+    public static function executeQuerySingle($query, $database = NULL) {
157
+        return self::getDb($database)->query($query)->fetchColumn();
158 158
     }
159 159
 
160 160
     public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
161 161
         if (!$numberOfString) {
162 162
             $numberOfString = $table . ".alphabetical";
163 163
         }
164
-        $count = self::executeQuerySingle ('select count(*) from ' . $table);
164
+        $count = self::executeQuerySingle('select count(*) from ' . $table);
165 165
         if ($count == 0) return NULL;
166
-        $entry = new Entry (localize($table . ".title"), $id,
167
-            str_format (localize($numberOfString, $count), $count), "text",
168
-            array ( new LinkNavigation ("?page=".$pageId)), "", $count);
166
+        $entry = new Entry(localize($table . ".title"), $id,
167
+            str_format(localize($numberOfString, $count), $count), "text",
168
+            array(new LinkNavigation("?page=" . $pageId)), "", $count);
169 169
         return $entry;
170 170
     }
171 171
 
172
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
172
+    public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) {
173 173
         /* @var $result PDOStatement */
174 174
 
175
-        list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
175
+        list (, $result) = self::executeQuery($query, $columns, "", $params, -1);
176 176
         $entryArray = array();
177
-        while ($post = $result->fetchObject ())
177
+        while ($post = $result->fetchObject())
178 178
         {
179 179
             /* @var $instance Author|Tag|Serie|Publisher */
180 180
 
181
-            $instance = new $category ($post);
181
+            $instance = new $category($post);
182 182
             if (property_exists($post, "sort")) {
183 183
                 $title = $post->sort;
184 184
             } else {
185 185
                 $title = $post->name;
186 186
             }
187
-            array_push ($entryArray, new Entry ($title, $instance->getEntryId (),
188
-                str_format (localize("bookword", $post->count), $post->count), "text",
189
-                array ( new LinkNavigation ($instance->getUri ())), "", $post->count));
187
+            array_push($entryArray, new Entry($title, $instance->getEntryId(),
188
+                str_format(localize("bookword", $post->count), $post->count), "text",
189
+                array(new LinkNavigation($instance->getUri())), "", $post->count));
190 190
         }
191 191
         return $entryArray;
192 192
     }
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
     public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
195 195
         $totalResult = -1;
196 196
 
197
-        if (useNormAndUp ()) {
197
+        if (useNormAndUp()) {
198 198
             $query = preg_replace("/upper/", "normAndUp", $query);
199 199
             $columns = preg_replace("/upper/", "normAndUp", $columns);
200 200
         }
201 201
 
202
-        if (is_null ($numberPerPage)) {
203
-            $numberPerPage = getCurrentOption ("max_item_per_page");
202
+        if (is_null($numberPerPage)) {
203
+            $numberPerPage = getCurrentOption("max_item_per_page");
204 204
         }
205 205
 
206 206
         if ($numberPerPage != -1 && $n != -1)
207 207
         {
208 208
             // First check total number of results
209
-            $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
210
-            $result->execute ($params);
211
-            $totalResult = $result->fetchColumn ();
209
+            $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter));
210
+            $result->execute($params);
211
+            $totalResult = $result->fetchColumn();
212 212
 
213 213
             // Next modify the query and params
214 214
             $query .= " limit ?, ?";
215
-            array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage);
215
+            array_push($params, ($n - 1) * $numberPerPage, $numberPerPage);
216 216
         }
217 217
 
218
-        $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter));
219
-        $result->execute ($params);
220
-        return array ($totalResult, $result);
218
+        $result = self::getDb($database)->prepare(str_format($query, $columns, $filter));
219
+        $result->execute($params);
220
+        return array($totalResult, $result);
221 221
     }
222 222
 
223 223
 }
Please login to merge, or discard this patch.
Braces   +48 added lines, -25 removed lines patch added patch discarded remove patch
@@ -37,23 +37,27 @@  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 42
         global $config;
42 43
         return is_array ($config['calibre_directory']);
43 44
     }
44 45
 
45
-    public static function useAbsolutePath () {
46
+    public static function useAbsolutePath ()
47
+    {
46 48
         global $config;
47 49
         $path = self::getDbDirectory();
48 50
         return preg_match ('/^\//', $path) || // Linux /
49 51
                preg_match ('/^\w\:/', $path); // Windows X:
50 52
     }
51 53
 
52
-    public static function noDatabaseSelected () {
54
+    public static function noDatabaseSelected ()
55
+    {
53 56
         return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
54 57
     }
55 58
 
56
-    public static function getDbList () {
59
+    public static function getDbList ()
60
+    {
57 61
         global $config;
58 62
         if (self::isMultipleDatabaseEnabled ()) {
59 63
             return $config['calibre_directory'];
@@ -62,7 +66,8 @@  discard block
 block discarded – undo
62 66
         }
63 67
     }
64 68
 
65
-    public static function getDbNameList () {
69
+    public static function getDbNameList ()
70
+    {
66 71
         global $config;
67 72
         if (self::isMultipleDatabaseEnabled ()) {
68 73
             return array_keys ($config['calibre_directory']);
@@ -71,10 +76,13 @@  discard block
 block discarded – undo
71 76
         }
72 77
     }
73 78
 
74
-    public static function getDbName ($database = NULL) {
79
+    public static function getDbName ($database = NULL)
80
+    {
75 81
         global $config;
76 82
         if (self::isMultipleDatabaseEnabled ()) {
77
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
83
+            if (is_null ($database)) {
84
+                $database = GetUrlParam (DB, 0);
85
+            }
78 86
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
79 87
                 self::error ($database);
80 88
             }
@@ -84,10 +92,13 @@  discard block
 block discarded – undo
84 92
         return "";
85 93
     }
86 94
 
87
-    public static function getDbDirectory ($database = NULL) {
95
+    public static function getDbDirectory ($database = NULL)
96
+    {
88 97
         global $config;
89 98
         if (self::isMultipleDatabaseEnabled ()) {
90
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
99
+            if (is_null ($database)) {
100
+                $database = GetUrlParam (DB, 0);
101
+            }
91 102
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
92 103
                 self::error ($database);
93 104
             }
@@ -98,28 +109,34 @@  discard block
 block discarded – undo
98 109
     }
99 110
 
100 111
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
112
+    public static function getImgDirectory ($database = NULL)
113
+    {
102 114
     	global $config;
103 115
     	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
116
+    		if (is_null ($database)) {
117
+    		    $database = GetUrlParam (DB, 0);
118
+    		}
105 119
     		$array = array_values ($config['image_directory']);
106 120
     		return  $array[$database];
107 121
     	}
108 122
     	return $config['image_directory'];
109 123
     }
110 124
 
111
-    public static function getDbFileName ($database = NULL) {
125
+    public static function getDbFileName ($database = NULL)
126
+    {
112 127
         return self::getDbDirectory ($database) .'metadata.db';
113 128
     }
114 129
 
115
-    private static function error ($database) {
130
+    private static function error ($database)
131
+    {
116 132
         if (php_sapi_name() != "cli") {
117 133
             header("location: checkconfig.php?err=1");
118 134
         }
119 135
         throw new Exception("Database <{$database}> not found.");
120 136
     }
121 137
 
122
-    public static function getDb ($database = NULL) {
138
+    public static function getDb ($database = NULL)
139
+    {
123 140
         if (is_null (self::$db)) {
124 141
             try {
125 142
                 if (is_readable (self::getDbFileName ($database))) {
@@ -137,7 +154,8 @@  discard block
 block discarded – undo
137 154
         return self::$db;
138 155
     }
139 156
 
140
-    public static function checkDatabaseAvailability () {
157
+    public static function checkDatabaseAvailability ()
158
+    {
141 159
         if (self::noDatabaseSelected ()) {
142 160
             for ($i = 0; $i < count (self::getDbList ()); $i++) {
143 161
                 self::getDb ($i);
@@ -149,33 +167,38 @@  discard block
 block discarded – undo
149 167
         return true;
150 168
     }
151 169
 
152
-    public static function clearDb () {
170
+    public static function clearDb ()
171
+    {
153 172
         self::$db = NULL;
154 173
     }
155 174
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
175
+    public static function executeQuerySingle ($query, $database = NULL)
176
+    {
157 177
         return self::getDb ($database)->query($query)->fetchColumn();
158 178
     }
159 179
 
160
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
180
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL)
181
+    {
161 182
         if (!$numberOfString) {
162 183
             $numberOfString = $table . ".alphabetical";
163 184
         }
164 185
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
165
-        if ($count == 0) return NULL;
186
+        if ($count == 0) {
187
+            return NULL;
188
+        }
166 189
         $entry = new Entry (localize($table . ".title"), $id,
167 190
             str_format (localize($numberOfString, $count), $count), "text",
168 191
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
169 192
         return $entry;
170 193
     }
171 194
 
172
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
195
+    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category)
196
+    {
173 197
         /* @var $result PDOStatement */
174 198
 
175 199
         list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
176 200
         $entryArray = array();
177
-        while ($post = $result->fetchObject ())
178
-        {
201
+        while ($post = $result->fetchObject ()) {
179 202
             /* @var $instance Author|Tag|Serie|Publisher */
180 203
 
181 204
             $instance = new $category ($post);
@@ -191,7 +214,8 @@  discard block
 block discarded – undo
191 214
         return $entryArray;
192 215
     }
193 216
 
194
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
217
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL)
218
+    {
195 219
         $totalResult = -1;
196 220
 
197 221
         if (useNormAndUp ()) {
@@ -203,8 +227,7 @@  discard block
 block discarded – undo
203 227
             $numberPerPage = getCurrentOption ("max_item_per_page");
204 228
         }
205 229
 
206
-        if ($numberPerPage != -1 && $n != -1)
207
-        {
230
+        if ($numberPerPage != -1 && $n != -1) {
208 231
             // First check total number of results
209 232
             $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
210 233
             $result->execute ($params);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     const COMPATIBILITY_XML_ALDIKO = "aldiko";
37 37
 
38
-    private static $db = NULL;
38
+    private static $db = null;
39 39
 
40 40
     public static function isMultipleDatabaseEnabled () {
41 41
         global $config;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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 76
         if (self::isMultipleDatabaseEnabled ()) {
77 77
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
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 89
         if (self::isMultipleDatabaseEnabled ()) {
90 90
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
101
+    public static function getImgDirectory ($database = null) {
102 102
     	global $config;
103 103
     	if (self::isMultipleDatabaseEnabled ()) {
104 104
     		if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     	return $config['image_directory'];
109 109
     }
110 110
 
111
-    public static function getDbFileName ($database = NULL) {
111
+    public static function getDbFileName ($database = null) {
112 112
         return self::getDbDirectory ($database) .'metadata.db';
113 113
     }
114 114
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         throw new Exception("Database <{$database}> not found.");
120 120
     }
121 121
 
122
-    public static function getDb ($database = NULL) {
122
+    public static function getDb ($database = null) {
123 123
         if (is_null (self::$db)) {
124 124
             try {
125 125
                 if (is_readable (self::getDbFileName ($database))) {
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
     }
151 151
 
152 152
     public static function clearDb () {
153
-        self::$db = NULL;
153
+        self::$db = null;
154 154
     }
155 155
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
156
+    public static function executeQuerySingle ($query, $database = null) {
157 157
         return self::getDb ($database)->query($query)->fetchColumn();
158 158
     }
159 159
 
160
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
160
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = null) {
161 161
         if (!$numberOfString) {
162 162
             $numberOfString = $table . ".alphabetical";
163 163
         }
164 164
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
165
-        if ($count == 0) return NULL;
165
+        if ($count == 0) return null;
166 166
         $entry = new Entry (localize($table . ".title"), $id,
167 167
             str_format (localize($numberOfString, $count), $count), "text",
168 168
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         return $entryArray;
192 192
     }
193 193
 
194
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
194
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) {
195 195
         $totalResult = -1;
196 196
 
197 197
         if (useNormAndUp ()) {
Please login to merge, or discard this patch.
fetch.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     // -DC- Add png type
43 43
     if ($book && ($type == 'jpg' || $type == 'png' || empty ($config['calibre_internal_directory']))) {
44
-    	  if ($type == 'jpg' || $type == 'png') {
44
+            if ($type == 'jpg' || $type == 'png') {
45 45
             $file = $book->getFilePath($type);
46 46
         } else {
47 47
             $file = $book->getFilePath($type, $idData);
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 
55 55
     switch ($type)
56 56
     {
57
-    		// -DC- Add png type
57
+            // -DC- Add png type
58 58
         case 'jpg':
59 59
         case 'png':
60
-        		if ($type == 'jpg') {
61
-          	  header('Content-Type: image/jpeg');
62
-        		}
63
-        		else {
64
-        			header('Content-Type: image/png');
65
-        		}
60
+                if ($type == 'jpg') {
61
+                header('Content-Type: image/jpeg');
62
+                }
63
+                else {
64
+                    header('Content-Type: image/png');
65
+                }
66 66
             //by default, we don't cache
67 67
             $thumbnailCacheFullpath = null;
68 68
             if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,15 +52,13 @@
 block discarded – undo
52 52
         }
53 53
     }
54 54
 
55
-    switch ($type)
56
-    {
55
+    switch ($type) {
57 56
     		// -DC- Add png type
58 57
         case 'jpg':
59 58
         case 'png':
60 59
         		if ($type == 'jpg') {
61 60
           	  header('Content-Type: image/jpeg');
62
-        		}
63
-        		else {
61
+        		} else {
64 62
         			header('Content-Type: image/png');
65 63
         		}
66 64
             //by default, we don't cache
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
     header('Pragma: public');
24 24
     header('Cache-Control: max-age=' . $expires);
25 25
     header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
26
-    $bookId   = getURLParam('id', NULL);
26
+    $bookId   = getURLParam('id', null);
27 27
     $type     = getURLParam('type', 'jpg');
28
-    $idData   = getURLParam('data', NULL);
29
-    $viewOnly = getURLParam('view', FALSE);
28
+    $idData   = getURLParam('data', null);
29
+    $viewOnly = getURLParam('view', false);
30 30
 
31 31
     if (is_null($bookId)) {
32 32
         $book = Book::getBookByDataId($idData);
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
         }
20 20
     }
21 21
 
22
-    $expires = 60*60*24*14;
22
+    $expires = 60 * 60 * 24 * 14;
23 23
     header('Pragma: public');
24 24
     header('Cache-Control: max-age=' . $expires);
25
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
25
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
26 26
     $bookId   = getURLParam('id', NULL);
27 27
     $type     = getURLParam('type', 'jpg');
28 28
     $idData   = getURLParam('data', NULL);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     if (!$book) {
38
-        notFound ();
38
+        notFound();
39 39
         return;
40 40
     }
41 41
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
         		}
66 66
             //by default, we don't cache
67 67
             $thumbnailCacheFullpath = null;
68
-            if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
68
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
69 69
                 $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
70 70
                 //if multiple databases, add a subfolder with the database ID
71
-                $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : '';
71
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
72 72
                 //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
73 73
                 //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
74 74
                 $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
75 75
                 //check if cache folder exists or create it
76
-                if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) {
76
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
77 77
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
78 78
                     $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.' . $type;
79 79
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
                 }
84 84
             }
85 85
 
86
-            if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) {
86
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
87 87
                 //return the already cached thumbnail
88
-                readfile( $thumbnailCacheFullpath );
88
+                readfile($thumbnailCacheFullpath);
89 89
                 return;
90 90
             }
91 91
 
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
             $height = getURLParam('height');
94 94
             if ($book->getThumbnail($width, $height, $thumbnailCacheFullpath, $type)) {
95 95
                 //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
96
-                if ( $thumbnailCacheFullpath === null ) {
96
+                if ($thumbnailCacheFullpath === null) {
97 97
                     // The cover had to be resized
98 98
                     return;
99 99
                 } else {
100 100
                     //return the just cached thumbnail
101
-                    readfile( $thumbnailCacheFullpath );
101
+                    readfile($thumbnailCacheFullpath);
102 102
                     return;
103 103
                 }
104 104
             }
Please login to merge, or discard this patch.
lib/Tag.php 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -54,6 +54,10 @@
 block discarded – undo
54 54
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 55
     }
56 56
 
57
+    /**
58
+     * @param string $query
59
+     * @param integer $numberPerPage
60
+     */
57 61
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
58 62
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 63
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@
 block discarded – undo
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46
-    	global $config;
46
+        global $config;
47 47
 
48
-    	$sql = self::SQL_ALL_TAGS;
49
-    	$sortField = $config['calibre_database_field_sort'];
50
-    	if (!empty($sortField)) {
51
-    		$sql = str_replace('tags.name', 'tags.' . $sortField, $sql);
52
-    	}
48
+        $sql = self::SQL_ALL_TAGS;
49
+        $sortField = $config['calibre_database_field_sort'];
50
+        if (!empty($sortField)) {
51
+            $sql = str_replace('tags.name', 'tags.' . $sortField, $sql);
52
+        }
53 53
 
54 54
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 55
     }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,24 +20,24 @@  discard block
 block discarded – undo
20 20
         $this->name = $post->name;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . parent::PAGE_TAG_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_TAGS_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_TAGS_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("tags.alphabetical", count(array))
33
-        return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
33
+        return parent::getCountGeneric("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 34
     }
35 35
 
36
-    public static function getTagById ($tagId) {
37
-        $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38
-        $result->execute (array ($tagId));
39
-        if ($post = $result->fetchObject ()) {
40
-            return new Tag ($post);
36
+    public static function getTagById($tagId) {
37
+        $result = parent::getDb()->prepare('select id, name  from tags where id = ?');
38
+        $result->execute(array($tagId));
39
+        if ($post = $result->fetchObject()) {
40
+            return new Tag($post);
41 41
         }
42 42
         return NULL;
43 43
     }
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
     		$sql = str_replace('tags.name', 'tags.' . $sortField, $sql);
52 52
     	}
53 53
 
54
-        return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
54
+        return Base::getEntryArrayWithBookNumber($sql, self::TAG_COLUMNS, array(), "Tag");
55 55
     }
56 56
 
57 57
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
58
-        $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
58
+        $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 59
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
60
-        list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
60
+        list ($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
61 61
         $entryArray = array();
62
-        while ($post = $result->fetchObject ())
62
+        while ($post = $result->fetchObject())
63 63
         {
64
-            $tag = new Tag ($post);
65
-            array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
66
-                str_format (localize("bookword", $post->count), $post->count), "text",
67
-                array ( new LinkNavigation ($tag->getUri ()))));
64
+            $tag = new Tag($post);
65
+            array_push($entryArray, new Entry($tag->name, $tag->getEntryId(),
66
+                str_format(localize("bookword", $post->count), $post->count), "text",
67
+                array(new LinkNavigation($tag->getUri()))));
68 68
         }
69
-        return array ($entryArray, $totalNumber);
69
+        return array($entryArray, $totalNumber);
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,25 +15,30 @@  discard block
 block discarded – undo
15 15
     public $id;
16 16
     public $name;
17 17
 
18
-    public function __construct($post) {
18
+    public function __construct($post)
19
+    {
19 20
         $this->id = $post->id;
20 21
         $this->name = $post->name;
21 22
     }
22 23
 
23
-    public function getUri () {
24
+    public function getUri ()
25
+    {
24 26
         return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
25 27
     }
26 28
 
27
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
28 31
         return self::ALL_TAGS_ID.":".$this->id;
29 32
     }
30 33
 
31
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
32 36
         // str_format (localize("tags.alphabetical", count(array))
33 37
         return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 38
     }
35 39
 
36
-    public static function getTagById ($tagId) {
40
+    public static function getTagById ($tagId)
41
+    {
37 42
         $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38 43
         $result->execute (array ($tagId));
39 44
         if ($post = $result->fetchObject ()) {
@@ -42,7 +47,8 @@  discard block
 block discarded – undo
42 47
         return NULL;
43 48
     }
44 49
 
45
-    public static function getAllTags() {
50
+    public static function getAllTags()
51
+    {
46 52
     	global $config;
47 53
 
48 54
     	$sql = self::SQL_ALL_TAGS;
@@ -54,13 +60,13 @@  discard block
 block discarded – undo
54 60
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 61
     }
56 62
 
57
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
63
+    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
64
+    {
58 65
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 66
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
60 67
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
61 68
         $entryArray = array();
62
-        while ($post = $result->fetchObject ())
63
-        {
69
+        while ($post = $result->fetchObject ()) {
64 70
             $tag = new Tag ($post);
65 71
             array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
66 72
                 str_format (localize("bookword", $post->count), $post->count), "text",
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         if ($post = $result->fetchObject ()) {
40 40
             return new Tag ($post);
41 41
         }
42
-        return NULL;
42
+        return null;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 55
     }
56 56
 
57
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
57
+    public static function getAllTagsByQuery($query, $n, $database = null, $numberPerPage = null) {
58 58
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 59
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
60 60
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
Please login to merge, or discard this patch.