Test Setup Failed
Push — master ( 9fbeaf...6ecf0d )
by Sébastien
03:30 queued 33s
created
sendtomail.php 1 patch
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
3 3
 require_once dirname(__FILE__) . '/config.php';
4 4
 require_once dirname(__FILE__) . '/base.php';
5 5
 
6
-function checkConfiguration () {
6
+function checkConfiguration ()
7
+{
7 8
     global $config;
8 9
 
9 10
     if (is_null ($config['cops_mail_configuration']) ||
@@ -15,7 +16,8 @@  discard block
 block discarded – undo
15 16
     return False;
16 17
 }
17 18
 
18
-function checkRequest ($idData, $emailDest) {
19
+function checkRequest ($idData, $emailDest)
20
+{
19 21
     if (empty ($idData)) {
20 22
         return 'No data sent.';
21 23
     }
@@ -59,10 +61,18 @@  discard block
 block discarded – undo
59 61
     $mail->Port = 465;
60 62
 }
61 63
 $mail->SMTPAuth = !empty ($config['cops_mail_configuration']["smtp.username"]);
62
-if (!empty ($config['cops_mail_configuration']["smtp.username"])) $mail->Username = $config['cops_mail_configuration']["smtp.username"];
63
-if (!empty ($config['cops_mail_configuration']["smtp.password"])) $mail->Password = $config['cops_mail_configuration']["smtp.password"];
64
-if (!empty ($config['cops_mail_configuration']["smtp.secure"])) $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
65
-if (!empty ($config['cops_mail_configuration']["smtp.port"])) $mail->Port = $config['cops_mail_configuration']["smtp.port"];
64
+if (!empty ($config['cops_mail_configuration']["smtp.username"])) {
65
+    $mail->Username = $config['cops_mail_configuration']["smtp.username"];
66
+}
67
+if (!empty ($config['cops_mail_configuration']["smtp.password"])) {
68
+    $mail->Password = $config['cops_mail_configuration']["smtp.password"];
69
+}
70
+if (!empty ($config['cops_mail_configuration']["smtp.secure"])) {
71
+    $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
72
+}
73
+if (!empty ($config['cops_mail_configuration']["smtp.port"])) {
74
+    $mail->Port = $config['cops_mail_configuration']["smtp.port"];
75
+}
66 76
 
67 77
 $mail->From = $config['cops_mail_configuration']["address.from"];
68 78
 $mail->FromName = $config['cops_title_default'];
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);
@@ -385,14 +398,13 @@  discard block
 block discarded – undo
385 398
                 $filename = $data->getUpdatedFilenameKepub();
386 399
             }
387 400
             $epub->download($filename);
388
-        }
389
-        catch (Exception $e)
390
-        {
401
+        } catch (Exception $e) {
391 402
             echo 'Exception : ' . $e->getMessage();
392 403
         }
393 404
     }
394 405
 
395
-    public function getThumbnail($width, $height, $outputfile = NULL) {
406
+    public function getThumbnail($width, $height, $outputfile = NULL)
407
+    {
396 408
         if (is_null($width) && is_null($height)) {
397 409
             return false;
398 410
         }
@@ -431,17 +443,14 @@  discard block
 block discarded – undo
431 443
     {
432 444
         $linkArray = array();
433 445
 
434
-        if ($this->hasCover)
435
-        {
446
+        if ($this->hasCover) {
436 447
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
437 448
 
438 449
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
439 450
         }
440 451
 
441
-        foreach ($this->getDatas() as $data)
442
-        {
443
-            if ($data->isKnownType())
444
-            {
452
+        foreach ($this->getDatas() as $data) {
453
+            if ($data->isKnownType()) {
445 454
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
446 455
             }
447 456
         }
@@ -460,17 +469,20 @@  discard block
 block discarded – undo
460 469
     }
461 470
 
462 471
 
463
-    public function getEntry() {
472
+    public function getEntry()
473
+    {
464 474
         return new EntryBook($this->getTitle(), $this->getEntryId(),
465 475
             $this->getComment(), 'text/html',
466 476
             $this->getLinkArray(), $this);
467 477
     }
468 478
 
469
-    public static function getBookCount($database = NULL) {
479
+    public static function getBookCount($database = NULL)
480
+    {
470 481
         return parent::executeQuerySingle('select count(*) from books', $database);
471 482
     }
472 483
 
473
-    public static function getCount() {
484
+    public static function getCount()
485
+    {
474 486
         global $config;
475 487
         $nBooks = parent::executeQuerySingle('select count(*) from books');
476 488
         $result = array();
@@ -489,27 +501,33 @@  discard block
 block discarded – undo
489 501
         return $result;
490 502
     }
491 503
 
492
-    public static function getBooksByAuthor($authorId, $n) {
504
+    public static function getBooksByAuthor($authorId, $n)
505
+    {
493 506
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
494 507
     }
495 508
 
496
-    public static function getBooksByRating($ratingId, $n) {
509
+    public static function getBooksByRating($ratingId, $n)
510
+    {
497 511
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
498 512
     }
499 513
 
500
-    public static function getBooksByPublisher($publisherId, $n) {
514
+    public static function getBooksByPublisher($publisherId, $n)
515
+    {
501 516
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
502 517
     }
503 518
 
504
-    public static function getBooksBySeries($serieId, $n) {
519
+    public static function getBooksBySeries($serieId, $n)
520
+    {
505 521
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
506 522
     }
507 523
 
508
-    public static function getBooksByTag($tagId, $n) {
524
+    public static function getBooksByTag($tagId, $n)
525
+    {
509 526
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
510 527
     }
511 528
 
512
-    public static function getBooksByLanguage($languageId, $n) {
529
+    public static function getBooksByLanguage($languageId, $n)
530
+    {
513 531
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
514 532
     }
515 533
 
@@ -519,32 +537,33 @@  discard block
 block discarded – undo
519 537
      * @param $n integer
520 538
      * @return array
521 539
      */
522
-    public static function getBooksByCustom($customColumn, $id, $n) {
540
+    public static function getBooksByCustom($customColumn, $id, $n)
541
+    {
523 542
         list($query, $params) = $customColumn->getQuery($id);
524 543
 
525 544
         return self::getEntryArray($query, $params, $n);
526 545
     }
527 546
 
528
-    public static function getBookById($bookId) {
547
+    public static function getBookById($bookId)
548
+    {
529 549
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . '
530 550
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
531 551
 where books.id = ?');
532 552
         $result->execute(array($bookId));
533
-        while ($post = $result->fetchObject())
534
-        {
553
+        while ($post = $result->fetchObject()) {
535 554
             $book = new Book($post);
536 555
             return $book;
537 556
         }
538 557
         return NULL;
539 558
     }
540 559
 
541
-    public static function getBookByDataId($dataId) {
560
+    public static function getBookByDataId($dataId)
561
+    {
542 562
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
543 563
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
544 564
 where data.book = books.id and data.id = ?');
545 565
         $result->execute(array($dataId));
546
-        while ($post = $result->fetchObject())
547
-        {
566
+        while ($post = $result->fetchObject()) {
548 567
             $book = new Book($post);
549 568
             $data = new Data($post, $book);
550 569
             $data->id = $dataId;
@@ -554,7 +573,8 @@  discard block
 block discarded – undo
554 573
         return NULL;
555 574
     }
556 575
 
557
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
576
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
577
+    {
558 578
         $i = 0;
559 579
         $critArray = array();
560 580
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -565,8 +585,7 @@  discard block
 block discarded – undo
565 585
             if (in_array($key, getCurrentOption('ignored_categories')) ||
566 586
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
567 587
                 $critArray[$i] = self::BAD_SEARCH;
568
-            }
569
-            else {
588
+            } else {
570 589
                 if (array_key_exists($key, $query)) {
571 590
                     $critArray[$i] = $query[$key];
572 591
                 } else {
@@ -578,12 +597,14 @@  discard block
 block discarded – undo
578 597
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
579 598
     }
580 599
 
581
-    public static function getBooks($n) {
600
+    public static function getBooks($n)
601
+    {
582 602
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
583 603
         return array($entryArray, $totalNumber);
584 604
     }
585 605
 
586
-    public static function getAllBooks() {
606
+    public static function getAllBooks()
607
+    {
587 608
         /* @var $result PDOStatement */
588 609
 
589 610
         list (, $result) = parent::executeQuery('select {0}
@@ -592,8 +613,7 @@  discard block
 block discarded – undo
592 613
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
593 614
 
594 615
         $entryArray = array();
595
-        while ($post = $result->fetchObject())
596
-        {
616
+        while ($post = $result->fetchObject()) {
597 617
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
598 618
                 str_format(localize('bookword', $post->count), $post->count), 'text',
599 619
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -601,25 +621,27 @@  discard block
 block discarded – undo
601 621
         return $entryArray;
602 622
     }
603 623
 
604
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
624
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
625
+    {
605 626
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
606 627
     }
607 628
 
608
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
629
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
630
+    {
609 631
         /* @var $totalNumber integer */
610 632
         /* @var $result PDOStatement */
611 633
         list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
612 634
 
613 635
         $entryArray = array();
614
-        while ($post = $result->fetchObject())
615
-        {
636
+        while ($post = $result->fetchObject()) {
616 637
             $book = new Book($post);
617 638
             array_push($entryArray, $book->getEntry());
618 639
         }
619 640
         return array($entryArray, $totalNumber);
620 641
     }
621 642
 
622
-    public static function getAllRecentBooks() {
643
+    public static function getAllRecentBooks()
644
+    {
623 645
         global $config;
624 646
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
625 647
         return $entryArray;
@@ -631,7 +653,8 @@  discard block
 block discarded – undo
631 653
      * @param string[] $columns
632 654
      * @return CustomColumn[]
633 655
      */
634
-    public function getCustomColumnValues($columns, $asArray = false) {
656
+    public function getCustomColumnValues($columns, $asArray = false)
657
+    {
635 658
         $result = array();
636 659
 
637 660
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.
lib/Data.php 1 patch
Braces   +47 added lines, -31 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
         'zip'   => 'application/zip'
56 56
     );
57 57
 
58
-    public function __construct($post, $book = null) {
58
+    public function __construct($post, $book = null)
59
+    {
59 60
         $this->id = $post->id;
60 61
         $this->name = $post->name;
61 62
         $this->format = $post->format;
@@ -64,19 +65,20 @@  discard block
 block discarded – undo
64 65
         $this->book = $book;
65 66
     }
66 67
 
67
-    public function isKnownType () {
68
+    public function isKnownType ()
69
+    {
68 70
         return array_key_exists ($this->extension, self::$mimetypes);
69 71
     }
70 72
 
71
-    public function getMimeType () {
73
+    public function getMimeType ()
74
+    {
72 75
         $result = "application/octet-stream";
73 76
         if ($this->isKnownType ()) {
74 77
             return self::$mimetypes [$this->extension];
75 78
         } elseif (function_exists('finfo_open') === true) {
76 79
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
77 80
 
78
-            if (is_resource($finfo) === true)
79
-            {
81
+            if (is_resource($finfo) === true) {
80 82
                 $result = finfo_file($finfo, $this->getLocalPath ());
81 83
             }
82 84
 
@@ -86,29 +88,35 @@  discard block
 block discarded – undo
86 88
         return $result;
87 89
     }
88 90
 
89
-    public function isEpubValidOnKobo () {
91
+    public function isEpubValidOnKobo ()
92
+    {
90 93
         return $this->format == "EPUB" || $this->format == "KEPUB";
91 94
     }
92 95
 
93
-    public function getFilename () {
96
+    public function getFilename ()
97
+    {
94 98
         return $this->name . "." . strtolower ($this->format);
95 99
     }
96 100
 
97
-    public function getUpdatedFilename () {
101
+    public function getUpdatedFilename ()
102
+    {
98 103
         return $this->book->getAuthorsSort () . " - " . $this->book->title;
99 104
     }
100 105
 
101
-    public function getUpdatedFilenameEpub () {
106
+    public function getUpdatedFilenameEpub ()
107
+    {
102 108
         return $this->getUpdatedFilename () . ".epub";
103 109
     }
104 110
 
105
-    public function getUpdatedFilenameKepub () {
111
+    public function getUpdatedFilenameKepub ()
112
+    {
106 113
         $str = $this->getUpdatedFilename () . ".kepub.epub";
107 114
         return str_replace(array(':', '#', '&'),
108 115
                            array('-', '-', ' '), $str );
109 116
     }
110 117
 
111
-    public function getDataLink ($rel, $title = NULL, $view = false) {
118
+    public function getDataLink ($rel, $title = NULL, $view = false)
119
+    {
112 120
         global $config;
113 121
 
114 122
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -118,23 +126,29 @@  discard block
 block discarded – undo
118 126
         return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view);
119 127
     }
120 128
 
121
-    public function getHtmlLink () {
129
+    public function getHtmlLink ()
130
+    {
122 131
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
123 132
     }
124 133
 
125
-    public function getViewHtmlLink () {
134
+    public function getViewHtmlLink ()
135
+    {
126 136
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href;
127 137
     }
128 138
 
129
-    public function getLocalPath () {
139
+    public function getLocalPath ()
140
+    {
130 141
         return $this->book->path . "/" . $this->getFilename ();
131 142
     }
132 143
 
133
-    public function getHtmlLinkWithRewriting ($title = NULL, $view = false) {
144
+    public function getHtmlLinkWithRewriting ($title = NULL, $view = false)
145
+    {
134 146
         global $config;
135 147
 
136 148
         $database = "";
137
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
149
+        if (!is_null (GetUrlParam (DB))) {
150
+            $database = GetUrlParam (DB) . "/";
151
+        }
138 152
 
139 153
         $prefix = "download";
140 154
         if ($view) {
@@ -152,28 +166,27 @@  discard block
 block discarded – undo
152 166
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
153 167
     }
154 168
 
155
-    public static function getDataByBook ($book) {
169
+    public static function getDataByBook ($book)
170
+    {
156 171
         $out = array ();
157 172
         $result = parent::getDb ()->prepare('select id, format, name
158 173
                                              from data where book = ?');
159 174
         $result->execute (array ($book->id));
160 175
 
161
-        while ($post = $result->fetchObject ())
162
-        {
176
+        while ($post = $result->fetchObject ()) {
163 177
             array_push ($out, new Data ($post, $book));
164 178
         }
165 179
         return $out;
166 180
     }
167 181
 
168
-    public static function handleThumbnailLink ($urlParam, $height) {
182
+    public static function handleThumbnailLink ($urlParam, $height)
183
+    {
169 184
         global $config;
170 185
 
171 186
         if (is_null ($height)) {
172 187
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
173 188
                 $height = $config['cops_opds_thumbnail_height'];
174
-            }
175
-            else
176
-            {
189
+            } else {
177 190
                 $height = $config['cops_html_thumbnail_height'];
178 191
             }
179 192
         }
@@ -189,18 +202,23 @@  discard block
 block discarded – undo
189 202
         global $config;
190 203
 
191 204
         $urlParam = addURLParameter("", "data", $idData);
192
-        if ($view) $urlParam = addURLParameter($urlParam, "view", 1);
205
+        if ($view) {
206
+            $urlParam = addURLParameter($urlParam, "view", 1);
207
+        }
193 208
 
194 209
         if (Base::useAbsolutePath () ||
195 210
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
196
-            ($type == "epub" && $config['cops_update_epub-metadata']))
197
-        {
198
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
211
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
212
+            if ($type != "jpg") {
213
+                $urlParam = addURLParameter($urlParam, "type", $type);
214
+            }
199 215
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
200 216
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
201 217
             }
202 218
             $urlParam = addURLParameter($urlParam, "id", $book->id);
203
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
219
+            if (!is_null (GetUrlParam (DB))) {
220
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
221
+            }
204 222
             if ($config['cops_thumbnail_handling'] != "1" &&
205 223
                 !empty ($config['cops_thumbnail_handling']) &&
206 224
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -208,9 +226,7 @@  discard block
 block discarded – undo
208 226
             } else {
209 227
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
210 228
             }
211
-        }
212
-        else
213
-        {
229
+        } else {
214 230
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
215 231
         }
216 232
     }
Please login to merge, or discard this patch.