Completed
Push — master ( fab96a...b13dbf )
by Sébastien
03:31
created
lib/PageAllBooks.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
         $this->title = localize("authors.title");
14 14
         if (getCurrentOption ("author_split_first_letter") == 1) {
15 15
             $this->entryArray = Author::getAllAuthorsByFirstLetter();
16
-        }
17
-        else {
16
+        } else {
18 17
             $this->entryArray = Author::getAllAuthors();
19 18
         }
20 19
         $this->idPage = Author::ALL_AUTHORS_ID;
Please login to merge, or discard this patch.
lib/CustomColumnTypeFloat.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@
 block discarded – undo
62 62
     public function getDescription()
63 63
     {
64 64
         $desc = $this->getDatabaseDescription();
65
-        if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle());
65
+        if ($desc === NULL || empty($desc)) {
66
+            $desc = str_format(localize("customcolumn.description"), $this->getTitle());
67
+        }
66 68
         return $desc;
67 69
     }
68 70
 
Please login to merge, or discard this patch.
lib/CustomColumnTypeComment.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@
 block discarded – undo
62 62
     public function getDescription()
63 63
     {
64 64
         $desc = $this->getDatabaseDescription();
65
-        if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle());
65
+        if ($desc === NULL || empty($desc)) {
66
+            $desc = str_format(localize("customcolumn.description"), $this->getTitle());
67
+        }
66 68
         return $desc;
67 69
     }
68 70
 
Please login to merge, or discard this patch.
lib/Book.php 1 patch
Braces   +105 added lines, -82 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@  discard block
 block discarded – undo
108 108
     public $format = array ();
109 109
 
110 110
 
111
-    public function __construct($line) {
111
+    public function __construct($line)
112
+    {
112 113
         $this->id = $line->id;
113 114
         $this->title = $line->title;
114 115
         $this->timestamp = strtotime($line->timestamp);
@@ -126,25 +127,32 @@  discard block
 block discarded – undo
126 127
         $this->rating = $line->rating;
127 128
     }
128 129
 
129
-    public function getEntryId() {
130
+    public function getEntryId()
131
+    {
130 132
         return self::ALL_BOOKS_UUID.':'.$this->uuid;
131 133
     }
132 134
 
133
-    public static function getEntryIdByLetter ($startingLetter) {
135
+    public static function getEntryIdByLetter ($startingLetter)
136
+    {
134 137
         return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
135 138
     }
136 139
 
137
-    public function getUri () {
140
+    public function getUri ()
141
+    {
138 142
         return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id;
139 143
     }
140 144
 
141
-    public function getDetailUrl () {
145
+    public function getDetailUrl ()
146
+    {
142 147
         $urlParam = $this->getUri();
143
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
148
+        if (!is_null(GetUrlParam(DB))) {
149
+            $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
150
+        }
144 151
         return 'index.php' . $urlParam;
145 152
     }
146 153
 
147
-    public function getTitle () {
154
+    public function getTitle ()
155
+    {
148 156
         return $this->title;
149 157
     }
150 158
 
@@ -153,22 +161,26 @@  discard block
 block discarded – undo
153 161
     /**
154 162
      * @return Author[]
155 163
      */
156
-    public function getAuthors () {
164
+    public function getAuthors ()
165
+    {
157 166
         if (is_null($this->authors)) {
158 167
             $this->authors = Author::getAuthorByBookId($this->id);
159 168
         }
160 169
         return $this->authors;
161 170
     }
162 171
 
163
-    public function getAuthorsName () {
172
+    public function getAuthorsName ()
173
+    {
164 174
         return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
165 175
     }
166 176
 
167
-    public function getAuthorsSort () {
177
+    public function getAuthorsSort ()
178
+    {
168 179
         return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
169 180
     }
170 181
 
171
-    public function getPublisher () {
182
+    public function getPublisher ()
183
+    {
172 184
         if (is_null($this->publisher)) {
173 185
             $this->publisher = Publisher::getPublisherByBookId($this->id);
174 186
         }
@@ -178,7 +190,8 @@  discard block
 block discarded – undo
178 190
     /**
179 191
      * @return Serie
180 192
      */
181
-    public function getSerie() {
193
+    public function getSerie()
194
+    {
182 195
         if (is_null($this->serie)) {
183 196
             $this->serie = Serie::getSerieByBookId($this->id);
184 197
         }
@@ -188,7 +201,8 @@  discard block
 block discarded – undo
188 201
     /**
189 202
      * @return string
190 203
      */
191
-    public function getLanguages() {
204
+    public function getLanguages()
205
+    {
192 206
         $lang = array();
193 207
         $result = parent::getDb()->prepare('select languages.lang_code
194 208
                 from books_languages_link, languages
@@ -196,8 +210,7 @@  discard block
 block discarded – undo
196 210
                 and book = ?
197 211
                 order by item_order');
198 212
         $result->execute(array($this->id));
199
-        while ($post = $result->fetchObject())
200
-        {
213
+        while ($post = $result->fetchObject()) {
201 214
             array_push($lang, Language::getLanguageString($post->lang_code));
202 215
         }
203 216
         return implode(', ', $lang);
@@ -206,7 +219,8 @@  discard block
 block discarded – undo
206 219
     /**
207 220
      * @return Tag[]
208 221
      */
209
-    public function getTags() {
222
+    public function getTags()
223
+    {
210 224
         if (is_null ($this->tags)) {
211 225
             $this->tags = array();
212 226
 
@@ -216,15 +230,15 @@  discard block
 block discarded – undo
216 230
                 and book = ?
217 231
                 order by name');
218 232
             $result->execute(array($this->id));
219
-            while ($post = $result->fetchObject())
220
-            {
233
+            while ($post = $result->fetchObject()) {
221 234
                 array_push($this->tags, new Tag($post));
222 235
             }
223 236
         }
224 237
         return $this->tags;
225 238
     }
226 239
 
227
-    public function getTagsName() {
240
+    public function getTagsName()
241
+    {
228 242
         return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
229 243
     }
230 244
 
@@ -241,9 +255,12 @@  discard block
 block discarded – undo
241 255
 
242 256
     /* End of other class (author, series, tag, ...) initialization and accessors */
243 257
 
244
-    public static function getFilterString() {
258
+    public static function getFilterString()
259
+    {
245 260
         $filter = getURLParam('tag', NULL);
246
-        if (empty($filter)) return '';
261
+        if (empty($filter)) {
262
+            return '';
263
+        }
247 264
 
248 265
         $exists = true;
249 266
         if (preg_match("/^!(.*)$/", $filter, $matches)) {
@@ -283,7 +300,8 @@  discard block
 block discarded – undo
283 300
         return reset($reduced);
284 301
     }
285 302
 
286
-    public function getRating() {
303
+    public function getRating()
304
+    {
287 305
         if (is_null($this->rating) || $this->rating == 0) {
288 306
             return '';
289 307
         }
@@ -297,7 +315,8 @@  discard block
 block discarded – undo
297 315
         return $retour;
298 316
     }
299 317
 
300
-    public function getPubDate() {
318
+    public function getPubDate()
319
+    {
301 320
         if (empty ($this->pubdate)) {
302 321
             return '';
303 322
         }
@@ -308,23 +327,22 @@  discard block
 block discarded – undo
308 327
         return '';
309 328
     }
310 329
 
311
-    public function getComment($withSerie = true) {
330
+    public function getComment($withSerie = true)
331
+    {
312 332
         $addition = '';
313 333
         $se = $this->getSerie ();
314 334
         if (!is_null ($se) && $withSerie) {
315 335
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
316 336
         }
317
-        if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
318
-        {
337
+        if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) {
319 338
             return $addition . html2xhtml($this->comment);
320
-        }
321
-        else
322
-        {
339
+        } else {
323 340
             return $addition . htmlspecialchars($this->comment);
324 341
         }
325 342
     }
326 343
 
327
-    public function getDataFormat($format) {
344
+    public function getDataFormat($format)
345
+    {
328 346
         $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
329 347
             return $data->format == $format;
330 348
         });
@@ -333,23 +351,19 @@  discard block
 block discarded – undo
333 351
 
334 352
     public function getFilePath($extension, $idData = NULL, $relative = false)
335 353
     {
336
-        if ($extension == 'jpg')
337
-        {
354
+        if ($extension == 'jpg') {
338 355
             $file = 'cover.jpg';
339
-        }
340
-        else
341
-        {
356
+        } else {
342 357
             $data = $this->getDataById($idData);
343
-            if (!$data) return NULL;
358
+            if (!$data) {
359
+                return NULL;
360
+            }
344 361
             $file = $data->name . '.' . strtolower($data->format);
345 362
         }
346 363
 
347
-        if ($relative)
348
-        {
364
+        if ($relative) {
349 365
             return $this->relativePath.'/'.$file;
350
-        }
351
-        else
352
-        {
366
+        } else {
353 367
             return $this->path.'/'.$file;
354 368
         }
355 369
     }
@@ -359,8 +373,7 @@  discard block
 block discarded – undo
359 373
         global $config;
360 374
         $data = $this->getDataById($idData);
361 375
 
362
-        try
363
-        {
376
+        try {
364 377
             $epub = new EPub($data->getLocalPath());
365 378
 
366 379
             $epub->Title($this->title);
@@ -383,14 +396,13 @@  discard block
 block discarded – undo
383 396
                 $epub->updateForKepub();
384 397
             }
385 398
             $epub->download($data->getUpdatedFilenameEpub());
386
-        }
387
-        catch (Exception $e)
388
-        {
399
+        } catch (Exception $e) {
389 400
             echo 'Exception : ' . $e->getMessage();
390 401
         }
391 402
     }
392 403
 
393
-    public function getThumbnail($width, $height, $outputfile = NULL) {
404
+    public function getThumbnail($width, $height, $outputfile = NULL)
405
+    {
394 406
         if (is_null($width) && is_null($height)) {
395 407
             return false;
396 408
         }
@@ -429,17 +441,14 @@  discard block
 block discarded – undo
429 441
     {
430 442
         $linkArray = array();
431 443
 
432
-        if ($this->hasCover)
433
-        {
444
+        if ($this->hasCover) {
434 445
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
435 446
 
436 447
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
437 448
         }
438 449
 
439
-        foreach ($this->getDatas() as $data)
440
-        {
441
-            if ($data->isKnownType())
442
-            {
450
+        foreach ($this->getDatas() as $data) {
451
+            if ($data->isKnownType()) {
443 452
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
444 453
             }
445 454
         }
@@ -458,17 +467,20 @@  discard block
 block discarded – undo
458 467
     }
459 468
 
460 469
 
461
-    public function getEntry() {
470
+    public function getEntry()
471
+    {
462 472
         return new EntryBook($this->getTitle(), $this->getEntryId(),
463 473
             $this->getComment(), 'text/html',
464 474
             $this->getLinkArray(), $this);
465 475
     }
466 476
 
467
-    public static function getBookCount($database = NULL) {
477
+    public static function getBookCount($database = NULL)
478
+    {
468 479
         return parent::executeQuerySingle('select count(*) from books', $database);
469 480
     }
470 481
 
471
-    public static function getCount() {
482
+    public static function getCount()
483
+    {
472 484
         global $config;
473 485
         $nBooks = parent::executeQuerySingle('select count(*) from books');
474 486
         $result = array();
@@ -487,27 +499,33 @@  discard block
 block discarded – undo
487 499
         return $result;
488 500
     }
489 501
 
490
-    public static function getBooksByAuthor($authorId, $n) {
502
+    public static function getBooksByAuthor($authorId, $n)
503
+    {
491 504
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
492 505
     }
493 506
 
494
-    public static function getBooksByRating($ratingId, $n) {
507
+    public static function getBooksByRating($ratingId, $n)
508
+    {
495 509
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
496 510
     }
497 511
 
498
-    public static function getBooksByPublisher($publisherId, $n) {
512
+    public static function getBooksByPublisher($publisherId, $n)
513
+    {
499 514
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
500 515
     }
501 516
 
502
-    public static function getBooksBySeries($serieId, $n) {
517
+    public static function getBooksBySeries($serieId, $n)
518
+    {
503 519
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
504 520
     }
505 521
 
506
-    public static function getBooksByTag($tagId, $n) {
522
+    public static function getBooksByTag($tagId, $n)
523
+    {
507 524
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
508 525
     }
509 526
 
510
-    public static function getBooksByLanguage($languageId, $n) {
527
+    public static function getBooksByLanguage($languageId, $n)
528
+    {
511 529
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
512 530
     }
513 531
 
@@ -517,32 +535,33 @@  discard block
 block discarded – undo
517 535
      * @param $n integer
518 536
      * @return array
519 537
      */
520
-    public static function getBooksByCustom($customColumn, $id, $n) {
538
+    public static function getBooksByCustom($customColumn, $id, $n)
539
+    {
521 540
         list($query, $params) = $customColumn->getQuery($id);
522 541
 
523 542
         return self::getEntryArray($query, $params, $n);
524 543
     }
525 544
 
526
-    public static function getBookById($bookId) {
545
+    public static function getBookById($bookId)
546
+    {
527 547
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . '
528 548
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
529 549
 where books.id = ?');
530 550
         $result->execute(array($bookId));
531
-        while ($post = $result->fetchObject())
532
-        {
551
+        while ($post = $result->fetchObject()) {
533 552
             $book = new Book($post);
534 553
             return $book;
535 554
         }
536 555
         return NULL;
537 556
     }
538 557
 
539
-    public static function getBookByDataId($dataId) {
558
+    public static function getBookByDataId($dataId)
559
+    {
540 560
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
541 561
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
542 562
 where data.book = books.id and data.id = ?');
543 563
         $result->execute(array($dataId));
544
-        while ($post = $result->fetchObject())
545
-        {
564
+        while ($post = $result->fetchObject()) {
546 565
             $book = new Book($post);
547 566
             $data = new Data($post, $book);
548 567
             $data->id = $dataId;
@@ -552,7 +571,8 @@  discard block
 block discarded – undo
552 571
         return NULL;
553 572
     }
554 573
 
555
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
574
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
575
+    {
556 576
         $i = 0;
557 577
         $critArray = array();
558 578
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -563,8 +583,7 @@  discard block
 block discarded – undo
563 583
             if (in_array($key, getCurrentOption('ignored_categories')) ||
564 584
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
565 585
                 $critArray[$i] = self::BAD_SEARCH;
566
-            }
567
-            else {
586
+            } else {
568 587
                 if (array_key_exists($key, $query)) {
569 588
                     $critArray[$i] = $query[$key];
570 589
                 } else {
@@ -576,12 +595,14 @@  discard block
 block discarded – undo
576 595
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
577 596
     }
578 597
 
579
-    public static function getBooks($n) {
598
+    public static function getBooks($n)
599
+    {
580 600
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
581 601
         return array($entryArray, $totalNumber);
582 602
     }
583 603
 
584
-    public static function getAllBooks() {
604
+    public static function getAllBooks()
605
+    {
585 606
         /* @var $result PDOStatement */
586 607
 
587 608
         list (, $result) = parent::executeQuery('select {0}
@@ -590,8 +611,7 @@  discard block
 block discarded – undo
590 611
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
591 612
 
592 613
         $entryArray = array();
593
-        while ($post = $result->fetchObject())
594
-        {
614
+        while ($post = $result->fetchObject()) {
595 615
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
596 616
                 str_format(localize('bookword', $post->count), $post->count), 'text',
597 617
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -599,25 +619,27 @@  discard block
 block discarded – undo
599 619
         return $entryArray;
600 620
     }
601 621
 
602
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
622
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
623
+    {
603 624
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
604 625
     }
605 626
 
606
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
627
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
628
+    {
607 629
         /* @var $totalNumber integer */
608 630
         /* @var $result PDOStatement */
609 631
         list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
610 632
 
611 633
         $entryArray = array();
612
-        while ($post = $result->fetchObject())
613
-        {
634
+        while ($post = $result->fetchObject()) {
614 635
             $book = new Book($post);
615 636
             array_push($entryArray, $book->getEntry());
616 637
         }
617 638
         return array($entryArray, $totalNumber);
618 639
     }
619 640
 
620
-    public static function getAllRecentBooks() {
641
+    public static function getAllRecentBooks()
642
+    {
621 643
         global $config;
622 644
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
623 645
         return $entryArray;
@@ -629,7 +651,8 @@  discard block
 block discarded – undo
629 651
      * @param string[] $columns
630 652
      * @return CustomColumn[]
631 653
      */
632
-    public function getCustomColumnValues($columns, $asArray = false) {
654
+    public function getCustomColumnValues($columns, $asArray = false)
655
+    {
633 656
         $result = array();
634 657
 
635 658
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.