Completed
Push — master ( e0dd35...f294bb )
by Markus
08:06 queued 57s
created
lib/PageAllRating.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class PageAllSeries extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13 13
         $this->title = localize("series.title");
14 14
         $this->entryArray = Serie::getAllSeries();
Please login to merge, or discard this patch.
lib/PageAllLanguages.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class PageAllSeries extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13 13
         $this->title = localize("series.title");
14 14
         $this->entryArray = Serie::getAllSeries();
Please login to merge, or discard this patch.
lib/PageCustomDetail.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     public function InitializeContent ()
12 12
     {
13
-        $customId = getURLParam ("custom", NULL);
13
+        $customId = getURLParam ("custom", null);
14 14
         $this->title = CustomColumn::getAllTitle ($customId);
15 15
         $this->entryArray = CustomColumn::getAllCustoms($customId);
16 16
         $this->idPage = CustomColumn::getAllCustomsId ($customId);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@
 block discarded – undo
8 8
 
9 9
 class PageCustomDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $customId = getURLParam ("custom", NULL);
14
-        $custom = CustomColumn::createCustom ($customId, $this->idGet);
15
-        $this->idPage = $custom->getEntryId ();
13
+        $customId = getURLParam("custom", NULL);
14
+        $custom = CustomColumn::createCustom($customId, $this->idGet);
15
+        $this->idPage = $custom->getEntryId();
16 16
         $this->title = $custom->value;
17
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom ($custom, $this->idGet, $this->n);
17
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom($custom, $this->idGet, $this->n);
18 18
     }
19 19
 }
Please login to merge, or discard this patch.
lib/PageAllPublishers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class PageAllSeries extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13 13
         $this->title = localize("series.title");
14 14
         $this->entryArray = Serie::getAllSeries();
Please login to merge, or discard this patch.
fetch.php 3 patches
Spacing   +11 added lines, -11 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: maxage=' . $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);
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     if (!$book) {
36
-        notFound ();
36
+        notFound();
37 37
         return;
38 38
     }
39 39
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
             header('Content-Type: image/jpeg');
56 56
             //by default, we don't cache
57 57
             $thumbnailCacheFullpath = null;
58
-            if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
58
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
59 59
                 $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
60 60
                 //if multiple databases, add a subfolder with the database ID
61
-                $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : '';
61
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
62 62
                 //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
63 63
                 //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
64 64
                 $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
65 65
                 //check if cache folder exists or create it
66
-                if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) {
66
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
67 67
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
68 68
                     $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.jpg';
69 69
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
                 }
74 74
             }
75 75
 
76
-            if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) {
76
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
77 77
                 //return the already cached thumbnail
78
-                readfile( $thumbnailCacheFullpath );
78
+                readfile($thumbnailCacheFullpath);
79 79
                 return;
80 80
             }
81 81
 
82
-            if ($book->getThumbnail (getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) {
82
+            if ($book->getThumbnail(getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) {
83 83
                 //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
84
-                if ( $thumbnailCacheFullpath === null ) {
84
+                if ($thumbnailCacheFullpath === null) {
85 85
                     // The cover had to be resized
86 86
                     return;
87 87
                 } else {
88 88
                     //return the just cached thumbnail
89
-                    readfile( $thumbnailCacheFullpath );
89
+                    readfile($thumbnailCacheFullpath);
90 90
                     return;
91 91
                 }
92 92
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@
 block discarded – undo
49 49
         }
50 50
     }
51 51
 
52
-    switch ($type)
53
-    {
52
+    switch ($type) {
54 53
         case 'jpg':
55 54
             header('Content-Type: image/jpeg');
56 55
             //by default, we don't cache
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
     header('Pragma: public');
24 24
     header('Cache-Control: maxage=' . $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);
28
+    $idData = getURLParam('data', null);
29 29
     if (is_null($bookId)) {
30 30
         $book = Book::getBookByDataId($idData);
31 31
     } else {
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
     header('Content-Type:text/html;charset=utf-8');
38 38
 
39 39
     $data = array('title'                 => $config['cops_title_default'],
40
-                  'version'               => VERSION,
41
-                  'opds_url'              => $config['cops_full_url'] . 'feed.php',
42
-                  'customHeader'          => '',
43
-                  'template'              => getCurrentTemplate(),
44
-                  'server_side_rendering' => useServerSideRendering(),
45
-                  'current_css'           => getCurrentCss(),
46
-                  'favico'                => $config['cops_icon'],
47
-                  'getjson_url'           => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1));
40
+                    'version'               => VERSION,
41
+                    'opds_url'              => $config['cops_full_url'] . 'feed.php',
42
+                    'customHeader'          => '',
43
+                    'template'              => getCurrentTemplate(),
44
+                    'server_side_rendering' => useServerSideRendering(),
45
+                    'current_css'           => getCurrentCss(),
46
+                    'favico'                => $config['cops_icon'],
47
+                    'getjson_url'           => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1));
48 48
     if (preg_match('/Kindle/', $_SERVER['HTTP_USER_AGENT'])) {
49 49
         $data['customHeader'] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>';
50 50
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     }
51 51
     $headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html');
52 52
     $template = new doT();
53
-    $dot = $template->template($headcontent, NULL);
53
+    $dot = $template->template($headcontent, null);
54 54
     echo($dot($data));
55 55
 ?><body>
56 56
 <?php
Please login to merge, or discard this patch.
epubfs.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@
 block discarded – undo
72 72
 try {
73 73
     $data = getComponentContent($book, $component, $add);
74 74
 
75
-    $expires = 60*60*24*14;
75
+    $expires = 60 * 60 * 24 * 14;
76 76
     header('Pragma: public');
77
-    header('Cache-Control: maxage='.$expires);
78
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
79
-    header ('Content-Type: ' . $book->componentContentType($component));
77
+    header('Cache-Control: maxage=' . $expires);
78
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
79
+    header('Content-Type: ' . $book->componentContentType($component));
80 80
     echo $data;
81 81
 } catch (Exception $e) {
82 82
     error_log($e);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     return;
52 52
 }
53 53
 
54
-$idData = getURLParam('data', NULL);
54
+$idData = getURLParam('data', null);
55 55
 $add = 'data=' . $idData . '&';
56 56
 if (!is_null(GetUrlParam(DB))) {
57 57
     $add .= DB . '=' . GetUrlParam(DB) . '&';
Please login to merge, or discard this patch.
epubreader.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     return;
52 52
 }
53 53
 
54
-$idData = getURLParam('data', NULL);
54
+$idData = getURLParam('data', null);
55 55
 $add = 'data=' . $idData . '&';
56 56
 if (!is_null(GetUrlParam(DB))) {
57 57
     $add .= DB . '=' . GetUrlParam(DB) . '&';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 
16 16
 $idData = getURLParam('data', NULL);
17 17
 $add = 'data=' . $idData . '&';
18
-if (!is_null (GetUrlParam (DB))) {
19
-    $add .= DB . '=' . GetUrlParam (DB) . '&';
18
+if (!is_null(GetUrlParam(DB))) {
19
+    $add .= DB . '=' . GetUrlParam(DB) . '&';
20 20
 }
21 21
 $myBook = Book::getBookByDataId($idData);
22 22
 
Please login to merge, or discard this patch.
lib/Book.php 5 patches
Doc Comments   +17 added lines, -1 removed lines patch added patch discarded remove patch
@@ -144,6 +144,9 @@  discard block
 block discarded – undo
144 144
         return 'index.php' . $urlParam;
145 145
     }
146 146
 
147
+    /**
148
+     * @return string
149
+     */
147 150
     public function getTitle () {
148 151
         return $this->title;
149 152
     }
@@ -331,6 +334,9 @@  discard block
 block discarded – undo
331 334
         return reset ($reduced);
332 335
     }
333 336
 
337
+    /**
338
+     * @param string $extension
339
+     */
334 340
     public function getFilePath ($extension, $idData = NULL, $relative = false)
335 341
     {
336 342
         if ($extension == "jpg")
@@ -464,6 +470,9 @@  discard block
 block discarded – undo
464 470
             $this->getLinkArray (), $this);
465 471
     }
466 472
 
473
+    /**
474
+     * @param integer $database
475
+     */
467 476
     public static function getBookCount($database = NULL) {
468 477
         return parent::executeQuerySingle ('select count(*) from books', $database);
469 478
     }
@@ -512,7 +521,7 @@  discard block
 block discarded – undo
512 521
     }
513 522
 
514 523
     /**
515
-     * @param $customColumn CustomColumn
524
+     * @param CustomColumn $customColumn CustomColumn
516 525
      * @param $id integer
517 526
      * @param $n integer
518 527
      * @return array
@@ -552,6 +561,10 @@  discard block
 block discarded – undo
552 561
         return NULL;
553 562
     }
554 563
 
564
+    /**
565
+     * @param integer $database
566
+     * @param integer $numberPerPage
567
+     */
555 568
     public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
556 569
         $i = 0;
557 570
         $critArray = array ();
@@ -599,6 +612,9 @@  discard block
 block discarded – undo
599 612
         return $entryArray;
600 613
     }
601 614
 
615
+    /**
616
+     * @param integer $numberPerPage
617
+     */
602 618
     public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
603 619
         return self::getEntryArray (self::SQL_BOOKS_BY_FIRST_LETTER, array ($letter . "%"), $n, $database, $numberPerPage);
604 620
     }
Please login to merge, or discard this 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) {
654
+    public function getCustomColumnValues($columns)
655
+    {
633 656
         $result = array();
634 657
         
635 658
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -99,12 +99,12 @@  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 109
 
110 110
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     /* End of other class (author, series, tag, ...) initialization and accessors */
243 243
 
244 244
     public static function getFilterString() {
245
-        $filter = getURLParam('tag', NULL);
245
+        $filter = getURLParam('tag', null);
246 246
         if (empty($filter)) return '';
247 247
 
248 248
         $exists = true;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     {
265 265
         $bestFormatForKindle = array('EPUB', 'PDF', 'AZW3', 'MOBI');
266 266
         $bestRank = -1;
267
-        $bestData = NULL;
267
+        $bestData = null;
268 268
         foreach ($this->getDatas() as $data) {
269 269
             $key = array_search($data->format, $bestFormatForKindle);
270 270
             if ($key !== false && $key > $bestRank) {
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         return reset($reduced);
332 332
     }
333 333
 
334
-    public function getFilePath($extension, $idData = NULL, $relative = false)
334
+    public function getFilePath($extension, $idData = null, $relative = false)
335 335
     {
336 336
         if ($extension == 'jpg')
337 337
         {
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         else
341 341
         {
342 342
             $data = $this->getDataById($idData);
343
-            if (!$data) return NULL;
343
+            if (!$data) return null;
344 344
             $file = $data->name . '.' . strtolower($data->format);
345 345
         }
346 346
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         }
391 391
     }
392 392
 
393
-    public function getThumbnail($width, $height, $outputfile = NULL) {
393
+    public function getThumbnail($width, $height, $outputfile = null) {
394 394
         if (is_null($width) && is_null($height)) {
395 395
             return false;
396 396
         }
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
 
432 432
         if ($this->hasCover)
433 433
         {
434
-            array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
434
+            array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', null));
435 435
 
436
-            array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
436
+            array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', null));
437 437
         }
438 438
 
439 439
         foreach ($this->getDatas() as $data)
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
             $this->getLinkArray(), $this);
465 465
     }
466 466
 
467
-    public static function getBookCount($database = NULL) {
467
+    public static function getBookCount($database = null) {
468 468
         return parent::executeQuerySingle('select count(*) from books', $database);
469 469
     }
470 470
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             $book = new Book($post);
534 534
             return $book;
535 535
         }
536
-        return NULL;
536
+        return null;
537 537
     }
538 538
 
539 539
     public static function getBookByDataId($dataId) {
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
             $book->datas = array($data);
550 550
             return $book;
551 551
         }
552
-        return NULL;
552
+        return null;
553 553
     }
554 554
 
555
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
555
+    public static function getBooksByQuery($query, $n, $database = null, $numberPerPage = null) {
556 556
         $i = 0;
557 557
         $critArray = array();
558 558
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
         return $entryArray;
600 600
     }
601 601
 
602
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
602
+    public static function getBooksByStartingLetter($letter, $n, $database = null, $numberPerPage = null) {
603 603
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
604 604
     }
605 605
 
606
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
606
+    public static function getEntryArray($query, $params, $n, $database = null, $numberPerPage = null) {
607 607
         /* @var $totalNumber integer */
608 608
         /* @var $result PDOStatement */
609 609
         list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
         $nBooks = Base::executeQuerySingle('select count(*) from books');
474 474
         $result = array();
475 475
         $entry = new Entry(localize('allbooks.title'),
476
-                          self::ALL_BOOKS_ID,
477
-                          str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
478
-                          array(new LinkNavigation('?page='.Base::PAGE_ALL_BOOKS)), '', $nBooks);
476
+                            self::ALL_BOOKS_ID,
477
+                            str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
478
+                            array(new LinkNavigation('?page='.Base::PAGE_ALL_BOOKS)), '', $nBooks);
479 479
         array_push($result, $entry);
480 480
         if ($config['cops_recentbooks_limit'] > 0) {
481 481
             $entry = new Entry(localize('recent.title'),
482
-                              self::ALL_RECENT_BOOKS_ID,
483
-                              str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
484
-                              array ( new LinkNavigation ('?page='.Base::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
482
+                                self::ALL_RECENT_BOOKS_ID,
483
+                                str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
484
+                                array ( new LinkNavigation ('?page='.Base::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
485 485
             array_push($result, $entry);
486 486
         }
487 487
         return $result;
@@ -556,10 +556,10 @@  discard block
 block discarded – undo
556 556
         $i = 0;
557 557
         $critArray = array();
558 558
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
559
-                       PageQueryResult::SCOPE_TAG,
560
-                       PageQueryResult::SCOPE_SERIES,
561
-                       PageQueryResult::SCOPE_PUBLISHER,
562
-                       PageQueryResult::SCOPE_BOOK) as $key) {
559
+                        PageQueryResult::SCOPE_TAG,
560
+                        PageQueryResult::SCOPE_SERIES,
561
+                        PageQueryResult::SCOPE_PUBLISHER,
562
+                        PageQueryResult::SCOPE_BOOK) as $key) {
563 563
             if (in_array($key, getCurrentOption('ignored_categories')) ||
564 564
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
565 565
                 $critArray[$i] = self::BAD_SEARCH;
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 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
@@ -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
 
110 110
 
111 111
     public function __construct($line) {
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
     }
128 128
 
129 129
     public function getEntryId() {
130
-        return self::ALL_BOOKS_UUID.':'.$this->uuid;
130
+        return self::ALL_BOOKS_UUID . ':' . $this->uuid;
131 131
     }
132 132
 
133
-    public static function getEntryIdByLetter ($startingLetter) {
134
-        return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
133
+    public static function getEntryIdByLetter($startingLetter) {
134
+        return self::ALL_BOOKS_ID . ':letter:' . $startingLetter;
135 135
     }
136 136
 
137
-    public function getUri () {
138
-        return '?page='.Base::PAGE_BOOK_DETAIL.'&id=' . $this->id;
137
+    public function getUri() {
138
+        return '?page=' . Base::PAGE_BOOK_DETAIL . '&id=' . $this->id;
139 139
     }
140 140
 
141
-    public function getDetailUrl () {
141
+    public function getDetailUrl() {
142 142
         $urlParam = $this->getUri();
143
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
143
+        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
144 144
         return 'index.php' . $urlParam;
145 145
     }
146 146
 
147
-    public function getTitle () {
147
+    public function getTitle() {
148 148
         return $this->title;
149 149
     }
150 150
 
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
     /**
154 154
      * @return Author[]
155 155
      */
156
-    public function getAuthors () {
156
+    public function getAuthors() {
157 157
         if (is_null($this->authors)) {
158 158
             $this->authors = Author::getAuthorByBookId($this->id);
159 159
         }
160 160
         return $this->authors;
161 161
     }
162 162
 
163
-    public function getAuthorsName () {
164
-        return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
163
+    public function getAuthorsName() {
164
+        return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors()));
165 165
     }
166 166
 
167
-    public function getAuthorsSort () {
168
-        return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
167
+    public function getAuthorsSort() {
168
+        return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors()));
169 169
     }
170 170
 
171
-    public function getPublisher () {
171
+    public function getPublisher() {
172 172
         if (is_null($this->publisher)) {
173 173
             $this->publisher = Publisher::getPublisherByBookId($this->id);
174 174
         }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return Tag[]
208 208
      */
209 209
     public function getTags() {
210
-        if (is_null ($this->tags)) {
210
+        if (is_null($this->tags)) {
211 211
             $this->tags = array();
212 212
 
213 213
             $result = Base::getDb()->prepare('select tags.id as id, name
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     }
226 226
 
227 227
     public function getTagsName() {
228
-        return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
228
+        return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags()));
229 229
     }
230 230
 
231 231
     /**
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
     public function getDataById($idData)
279 279
     {
280
-        $reduced = array_filter($this->getDatas(), function ($data) use ($idData) {
280
+        $reduced = array_filter($this->getDatas(), function($data) use ($idData) {
281 281
             return $data->id == $idData;
282 282
         });
283 283
         return reset($reduced);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         if (empty ($this->pubdate)) {
302 302
             return '';
303 303
         }
304
-        $dateY = (int) substr($this->pubdate, 0, 4);
304
+        $dateY = (int)substr($this->pubdate, 0, 4);
305 305
         if ($dateY > 102) {
306 306
             return str_pad($dateY, 4, '0', STR_PAD_LEFT);
307 307
         }
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 
311 311
     public function getComment($withSerie = true) {
312 312
         $addition = '';
313
-        $se = $this->getSerie ();
314
-        if (!is_null ($se) && $withSerie) {
313
+        $se = $this->getSerie();
314
+        if (!is_null($se) && $withSerie) {
315 315
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
316 316
         }
317 317
         if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     }
326 326
 
327 327
     public function getDataFormat($format) {
328
-        $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
328
+        $reduced = array_filter($this->getDatas(), function($data) use ($format) {
329 329
             return $data->format == $format;
330 330
         });
331 331
         return reset($reduced);
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 
347 347
         if ($relative)
348 348
         {
349
-            return $this->relativePath.'/'.$file;
349
+            return $this->relativePath . '/' . $file;
350 350
         }
351 351
         else
352 352
         {
353
-            return $this->path.'/'.$file;
353
+            return $this->path . '/' . $file;
354 354
         }
355 355
     }
356 356
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             }
371 371
             $epub->Authors($authorArray);
372 372
             $epub->Language($this->getLanguages());
373
-            $epub->Description ($this->getComment(false));
373
+            $epub->Description($this->getComment(false));
374 374
             $epub->Subjects($this->getTagsName());
375 375
             $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg');
376 376
             $epub->Calibre($this->uuid);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
                 $epub->Serie($se->name);
380 380
                 $epub->SerieIndex($this->seriesIndex);
381 381
             }
382
-            if ($config['cops_provide_kepub'] == '1'  && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
382
+            if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
383 383
                 $epub->updateForKepub();
384 384
             }
385 385
             $epub->download($data->getUpdatedFilenameEpub());
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
             if (!is_null($width)) {
405 405
                 $nw = $width;
406 406
                 if ($nw >= $w) { return false; }
407
-                $nh = ($nw*$h)/$w;
407
+                $nh = ($nw * $h) / $w;
408 408
             } else {
409 409
                 $nh = $height;
410 410
                 if ($nh >= $h) { return false; }
411
-                $nw = ($nh*$w)/$h;
411
+                $nw = ($nh * $w) / $h;
412 412
             }
413 413
         } else {
414 414
             return false;
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
 
417 417
         //draw the image
418 418
         $src_img = imagecreatefromjpeg($file);
419
-        $dst_img = imagecreatetruecolor($nw,$nh);
420
-        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image
421
-        imagejpeg($dst_img,$outputfile,80);
419
+        $dst_img = imagecreatetruecolor($nw, $nh);
420
+        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image
421
+        imagejpeg($dst_img, $outputfile, 80);
422 422
         imagedestroy($src_img);
423 423
         imagedestroy($dst_img);
424 424
 
425 425
         return true;
426 426
     }
427 427
 
428
-    public function getLinkArray ()
428
+    public function getLinkArray()
429 429
     {
430 430
         $linkArray = array();
431 431
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         }
451 451
 
452 452
         $serie = $this->getSerie();
453
-        if (!is_null ($serie)) {
453
+        if (!is_null($serie)) {
454 454
             array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name)));
455 455
         }
456 456
 
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
         $entry = new Entry(localize('allbooks.title'),
476 476
                           self::ALL_BOOKS_ID,
477 477
                           str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
478
-                          array(new LinkNavigation('?page='.Base::PAGE_ALL_BOOKS)), '', $nBooks);
478
+                          array(new LinkNavigation('?page=' . Base::PAGE_ALL_BOOKS)), '', $nBooks);
479 479
         array_push($result, $entry);
480 480
         if ($config['cops_recentbooks_limit'] > 0) {
481 481
             $entry = new Entry(localize('recent.title'),
482 482
                               self::ALL_RECENT_BOOKS_ID,
483 483
                               str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
484
-                              array ( new LinkNavigation ('?page='.Base::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
484
+                              array(new LinkNavigation('?page=' . Base::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
485 485
             array_push($result, $entry);
486 486
         }
487 487
         return $result;
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
     }
578 578
 
579 579
     public static function getBooks($n) {
580
-        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
580
+        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n);
581 581
         return array($entryArray, $totalNumber);
582 582
     }
583 583
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
         {
595 595
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
596 596
                 str_format(localize('bookword', $post->count), $post->count), 'text',
597
-                array(new LinkNavigation('?page='.Base::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
597
+                array(new LinkNavigation('?page=' . Base::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count));
598 598
         }
599 599
         return $entryArray;
600 600
     }
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 
620 620
     public static function getAllRecentBooks() {
621 621
         global $config;
622
-        list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
622
+        list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
623 623
         return $entryArray;
624 624
     }
625 625
 
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
         
635 635
         foreach ($columns as $lookup) {
636 636
             $col = CustomColumnType::createByLookup($lookup);
637
-            if (! is_null($col)) {
637
+            if (!is_null($col)) {
638 638
                 $cust = $col->getCustomByBook($this);
639
-                if (! is_null($cust)) {
639
+                if (!is_null($cust)) {
640 640
                     array_push($result, $cust);
641 641
                 }
642 642
             }
Please login to merge, or discard this patch.