Test Setup Failed
Pull Request — master (#497)
by
unknown
02:29
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/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.
lib/Book.php 1 patch
Braces   +108 added lines, -85 removed lines patch added patch discarded remove patch
@@ -111,7 +111,8 @@  discard block
 block discarded – undo
111 111
     public $format = array ();
112 112
 
113 113
 
114
-    public function __construct($line) {
114
+    public function __construct($line)
115
+    {
115 116
         $this->id = $line->id;
116 117
         $this->title = $line->title;
117 118
         $this->timestamp = strtotime($line->timestamp);
@@ -129,25 +130,32 @@  discard block
 block discarded – undo
129 130
         $this->rating = $line->rating;
130 131
     }
131 132
 
132
-    public function getEntryId() {
133
+    public function getEntryId()
134
+    {
133 135
         return self::ALL_BOOKS_UUID.':'.$this->uuid;
134 136
     }
135 137
 
136
-    public static function getEntryIdByLetter ($startingLetter) {
138
+    public static function getEntryIdByLetter ($startingLetter)
139
+    {
137 140
         return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
138 141
     }
139 142
 
140
-    public function getUri () {
143
+    public function getUri ()
144
+    {
141 145
         return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id;
142 146
     }
143 147
 
144
-    public function getDetailUrl () {
148
+    public function getDetailUrl ()
149
+    {
145 150
         $urlParam = $this->getUri();
146
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
151
+        if (!is_null(GetUrlParam(DB))) {
152
+            $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
153
+        }
147 154
         return 'index.php' . $urlParam;
148 155
     }
149 156
 
150
-    public function getTitle () {
157
+    public function getTitle ()
158
+    {
151 159
         return $this->title;
152 160
     }
153 161
 
@@ -156,22 +164,26 @@  discard block
 block discarded – undo
156 164
     /**
157 165
      * @return Author[]
158 166
      */
159
-    public function getAuthors () {
167
+    public function getAuthors ()
168
+    {
160 169
         if (is_null($this->authors)) {
161 170
             $this->authors = Author::getAuthorByBookId($this->id);
162 171
         }
163 172
         return $this->authors;
164 173
     }
165 174
 
166
-    public function getAuthorsName () {
175
+    public function getAuthorsName ()
176
+    {
167 177
         return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
168 178
     }
169 179
 
170
-    public function getAuthorsSort () {
180
+    public function getAuthorsSort ()
181
+    {
171 182
         return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
172 183
     }
173 184
 
174
-    public function getPublisher () {
185
+    public function getPublisher ()
186
+    {
175 187
         if (is_null($this->publisher)) {
176 188
             $this->publisher = Publisher::getPublisherByBookId($this->id);
177 189
         }
@@ -181,7 +193,8 @@  discard block
 block discarded – undo
181 193
     /**
182 194
      * @return Serie
183 195
      */
184
-    public function getSerie() {
196
+    public function getSerie()
197
+    {
185 198
         if (is_null($this->serie)) {
186 199
             $this->serie = Serie::getSerieByBookId($this->id);
187 200
         }
@@ -191,7 +204,8 @@  discard block
 block discarded – undo
191 204
     /**
192 205
      * @return string
193 206
      */
194
-    public function getLanguages() {
207
+    public function getLanguages()
208
+    {
195 209
         $lang = array();
196 210
         $result = parent::getDb()->prepare('select languages.lang_code
197 211
                 from books_languages_link, languages
@@ -199,8 +213,7 @@  discard block
 block discarded – undo
199 213
                 and book = ?
200 214
                 order by item_order');
201 215
         $result->execute(array($this->id));
202
-        while ($post = $result->fetchObject())
203
-        {
216
+        while ($post = $result->fetchObject()) {
204 217
             array_push($lang, Language::getLanguageString($post->lang_code));
205 218
         }
206 219
         return implode(', ', $lang);
@@ -209,7 +222,8 @@  discard block
 block discarded – undo
209 222
     /**
210 223
      * @return Tag[]
211 224
      */
212
-    public function getTags() {
225
+    public function getTags()
226
+    {
213 227
         if (is_null ($this->tags)) {
214 228
             $this->tags = array();
215 229
 
@@ -219,15 +233,15 @@  discard block
 block discarded – undo
219 233
                 and book = ?
220 234
                 order by name');
221 235
             $result->execute(array($this->id));
222
-            while ($post = $result->fetchObject())
223
-            {
236
+            while ($post = $result->fetchObject()) {
224 237
                 array_push($this->tags, new Tag($post));
225 238
             }
226 239
         }
227 240
         return $this->tags;
228 241
     }
229 242
 
230
-    public function getTagsName() {
243
+    public function getTagsName()
244
+    {
231 245
         return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
232 246
     }
233 247
 
@@ -235,7 +249,8 @@  discard block
 block discarded – undo
235 249
     /**
236 250
      * @return Identifiers[]
237 251
      */
238
-    public function getIdentifiers() {
252
+    public function getIdentifiers()
253
+    {
239 254
         if (is_null ($this->identifiers)) {
240 255
             $this->identifiers = array();
241 256
 
@@ -244,8 +259,7 @@  discard block
 block discarded – undo
244 259
                 where book = ?
245 260
                 order by type');
246 261
             $result->execute(array($this->id));
247
-            while ($post = $result->fetchObject())
248
-            {
262
+            while ($post = $result->fetchObject()) {
249 263
                 array_push($this->identifiers, new Identifier($post));
250 264
             }
251 265
             
@@ -266,9 +280,12 @@  discard block
 block discarded – undo
266 280
 
267 281
     /* End of other class (author, series, tag, ...) initialization and accessors */
268 282
 
269
-    public static function getFilterString() {
283
+    public static function getFilterString()
284
+    {
270 285
         $filter = getURLParam('tag', NULL);
271
-        if (empty($filter)) return '';
286
+        if (empty($filter)) {
287
+            return '';
288
+        }
272 289
 
273 290
         $exists = true;
274 291
         if (preg_match("/^!(.*)$/", $filter, $matches)) {
@@ -308,7 +325,8 @@  discard block
 block discarded – undo
308 325
         return reset($reduced);
309 326
     }
310 327
 
311
-    public function getRating() {
328
+    public function getRating()
329
+    {
312 330
         if (is_null($this->rating) || $this->rating == 0) {
313 331
             return '';
314 332
         }
@@ -322,7 +340,8 @@  discard block
 block discarded – undo
322 340
         return $retour;
323 341
     }
324 342
 
325
-    public function getPubDate() {
343
+    public function getPubDate()
344
+    {
326 345
         if (empty ($this->pubdate)) {
327 346
             return '';
328 347
         }
@@ -333,23 +352,22 @@  discard block
 block discarded – undo
333 352
         return '';
334 353
     }
335 354
 
336
-    public function getComment($withSerie = true) {
355
+    public function getComment($withSerie = true)
356
+    {
337 357
         $addition = '';
338 358
         $se = $this->getSerie ();
339 359
         if (!is_null ($se) && $withSerie) {
340 360
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
341 361
         }
342
-        if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
343
-        {
362
+        if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) {
344 363
             return $addition . html2xhtml($this->comment);
345
-        }
346
-        else
347
-        {
364
+        } else {
348 365
             return $addition . htmlspecialchars($this->comment);
349 366
         }
350 367
     }
351 368
 
352
-    public function getDataFormat($format) {
369
+    public function getDataFormat($format)
370
+    {
353 371
         $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
354 372
             return $data->format == $format;
355 373
         });
@@ -358,23 +376,19 @@  discard block
 block discarded – undo
358 376
 
359 377
     public function getFilePath($extension, $idData = NULL, $relative = false)
360 378
     {
361
-        if ($extension == 'jpg')
362
-        {
379
+        if ($extension == 'jpg') {
363 380
             $file = 'cover.jpg';
364
-        }
365
-        else
366
-        {
381
+        } else {
367 382
             $data = $this->getDataById($idData);
368
-            if (!$data) return NULL;
383
+            if (!$data) {
384
+                return NULL;
385
+            }
369 386
             $file = $data->name . '.' . strtolower($data->format);
370 387
         }
371 388
 
372
-        if ($relative)
373
-        {
389
+        if ($relative) {
374 390
             return $this->relativePath.'/'.$file;
375
-        }
376
-        else
377
-        {
391
+        } else {
378 392
             return $this->path.'/'.$file;
379 393
         }
380 394
     }
@@ -384,8 +398,7 @@  discard block
 block discarded – undo
384 398
         global $config;
385 399
         $data = $this->getDataById($idData);
386 400
 
387
-        try
388
-        {
401
+        try {
389 402
             $epub = new EPub($data->getLocalPath());
390 403
 
391 404
             $epub->Title($this->title);
@@ -410,14 +423,13 @@  discard block
 block discarded – undo
410 423
                 $filename = $data->getUpdatedFilenameKepub();
411 424
             }
412 425
             $epub->download($filename);
413
-        }
414
-        catch (Exception $e)
415
-        {
426
+        } catch (Exception $e) {
416 427
             echo 'Exception : ' . $e->getMessage();
417 428
         }
418 429
     }
419 430
 
420
-    public function getThumbnail($width, $height, $outputfile = NULL) {
431
+    public function getThumbnail($width, $height, $outputfile = NULL)
432
+    {
421 433
         if (is_null($width) && is_null($height)) {
422 434
             return false;
423 435
         }
@@ -456,17 +468,14 @@  discard block
 block discarded – undo
456 468
     {
457 469
         $linkArray = array();
458 470
 
459
-        if ($this->hasCover)
460
-        {
471
+        if ($this->hasCover) {
461 472
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
462 473
 
463 474
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
464 475
         }
465 476
 
466
-        foreach ($this->getDatas() as $data)
467
-        {
468
-            if ($data->isKnownType())
469
-            {
477
+        foreach ($this->getDatas() as $data) {
478
+            if ($data->isKnownType()) {
470 479
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
471 480
             }
472 481
         }
@@ -485,17 +494,20 @@  discard block
 block discarded – undo
485 494
     }
486 495
 
487 496
 
488
-    public function getEntry() {
497
+    public function getEntry()
498
+    {
489 499
         return new EntryBook($this->getTitle(), $this->getEntryId(),
490 500
             $this->getComment(), 'text/html',
491 501
             $this->getLinkArray(), $this);
492 502
     }
493 503
 
494
-    public static function getBookCount($database = NULL) {
504
+    public static function getBookCount($database = NULL)
505
+    {
495 506
         return parent::executeQuerySingle('select count(*) from books', $database);
496 507
     }
497 508
 
498
-    public static function getCount() {
509
+    public static function getCount()
510
+    {
499 511
         global $config;
500 512
         $nBooks = parent::executeQuerySingle('select count(*) from books');
501 513
         $result = array();
@@ -514,27 +526,33 @@  discard block
 block discarded – undo
514 526
         return $result;
515 527
     }
516 528
 
517
-    public static function getBooksByAuthor($authorId, $n) {
529
+    public static function getBooksByAuthor($authorId, $n)
530
+    {
518 531
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
519 532
     }
520 533
 
521
-    public static function getBooksByRating($ratingId, $n) {
534
+    public static function getBooksByRating($ratingId, $n)
535
+    {
522 536
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
523 537
     }
524 538
 
525
-    public static function getBooksByPublisher($publisherId, $n) {
539
+    public static function getBooksByPublisher($publisherId, $n)
540
+    {
526 541
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
527 542
     }
528 543
 
529
-    public static function getBooksBySeries($serieId, $n) {
544
+    public static function getBooksBySeries($serieId, $n)
545
+    {
530 546
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
531 547
     }
532 548
 
533
-    public static function getBooksByTag($tagId, $n) {
549
+    public static function getBooksByTag($tagId, $n)
550
+    {
534 551
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
535 552
     }
536 553
 
537
-    public static function getBooksByLanguage($languageId, $n) {
554
+    public static function getBooksByLanguage($languageId, $n)
555
+    {
538 556
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
539 557
     }
540 558
 
@@ -544,32 +562,33 @@  discard block
 block discarded – undo
544 562
      * @param $n integer
545 563
      * @return array
546 564
      */
547
-    public static function getBooksByCustom($customColumn, $id, $n) {
565
+    public static function getBooksByCustom($customColumn, $id, $n)
566
+    {
548 567
         list($query, $params) = $customColumn->getQuery($id);
549 568
 
550 569
         return self::getEntryArray($query, $params, $n);
551 570
     }
552 571
 
553
-    public static function getBookById($bookId) {
572
+    public static function getBookById($bookId)
573
+    {
554 574
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . '
555 575
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
556 576
 where books.id = ?');
557 577
         $result->execute(array($bookId));
558
-        while ($post = $result->fetchObject())
559
-        {
578
+        while ($post = $result->fetchObject()) {
560 579
             $book = new Book($post);
561 580
             return $book;
562 581
         }
563 582
         return NULL;
564 583
     }
565 584
 
566
-    public static function getBookByDataId($dataId) {
585
+    public static function getBookByDataId($dataId)
586
+    {
567 587
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
568 588
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
569 589
 where data.book = books.id and data.id = ?');
570 590
         $result->execute(array($dataId));
571
-        while ($post = $result->fetchObject())
572
-        {
591
+        while ($post = $result->fetchObject()) {
573 592
             $book = new Book($post);
574 593
             $data = new Data($post, $book);
575 594
             $data->id = $dataId;
@@ -579,7 +598,8 @@  discard block
 block discarded – undo
579 598
         return NULL;
580 599
     }
581 600
 
582
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
601
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
602
+    {
583 603
         $i = 0;
584 604
         $critArray = array();
585 605
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -590,8 +610,7 @@  discard block
 block discarded – undo
590 610
             if (in_array($key, getCurrentOption('ignored_categories')) ||
591 611
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
592 612
                 $critArray[$i] = self::BAD_SEARCH;
593
-            }
594
-            else {
613
+            } else {
595 614
                 if (array_key_exists($key, $query)) {
596 615
                     $critArray[$i] = $query[$key];
597 616
                 } else {
@@ -603,12 +622,14 @@  discard block
 block discarded – undo
603 622
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
604 623
     }
605 624
 
606
-    public static function getBooks($n) {
625
+    public static function getBooks($n)
626
+    {
607 627
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
608 628
         return array($entryArray, $totalNumber);
609 629
     }
610 630
 
611
-    public static function getAllBooks() {
631
+    public static function getAllBooks()
632
+    {
612 633
         /* @var $result PDOStatement */
613 634
 
614 635
         list (, $result) = parent::executeQuery('select {0}
@@ -617,8 +638,7 @@  discard block
 block discarded – undo
617 638
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
618 639
 
619 640
         $entryArray = array();
620
-        while ($post = $result->fetchObject())
621
-        {
641
+        while ($post = $result->fetchObject()) {
622 642
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
623 643
                 str_format(localize('bookword', $post->count), $post->count), 'text',
624 644
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -626,25 +646,27 @@  discard block
 block discarded – undo
626 646
         return $entryArray;
627 647
     }
628 648
 
629
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
649
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
650
+    {
630 651
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
631 652
     }
632 653
 
633
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
654
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
655
+    {
634 656
         /* @var $totalNumber integer */
635 657
         /* @var $result PDOStatement */
636 658
         list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
637 659
 
638 660
         $entryArray = array();
639
-        while ($post = $result->fetchObject())
640
-        {
661
+        while ($post = $result->fetchObject()) {
641 662
             $book = new Book($post);
642 663
             array_push($entryArray, $book->getEntry());
643 664
         }
644 665
         return array($entryArray, $totalNumber);
645 666
     }
646 667
 
647
-    public static function getAllRecentBooks() {
668
+    public static function getAllRecentBooks()
669
+    {
648 670
         global $config;
649 671
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
650 672
         return $entryArray;
@@ -656,7 +678,8 @@  discard block
 block discarded – undo
656 678
      * @param string[] $columns
657 679
      * @return CustomColumn[]
658 680
      */
659
-    public function getCustomColumnValues($columns, $asArray = false) {
681
+    public function getCustomColumnValues($columns, $asArray = false)
682
+    {
660 683
         $result = array();
661 684
 
662 685
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.