Test Setup Failed
Pull Request — master (#491)
by
unknown
07:16 queued 37s
created
lib/Author.php 1 patch
Braces   +25 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,37 +19,42 @@  discard block
 block discarded – undo
19 19
     public $name;
20 20
     public $sort;
21 21
 
22
-    public function __construct($post) {
22
+    public function __construct($post)
23
+    {
23 24
         $this->id = $post->id;
24 25
         $this->name = str_replace("|", ",", $post->name);
25 26
         $this->sort = $post->sort;
26 27
     }
27 28
 
28
-    public function getUri () {
29
+    public function getUri ()
30
+    {
29 31
         return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id";
30 32
     }
31 33
 
32
-    public function getEntryId () {
34
+    public function getEntryId ()
35
+    {
33 36
         return self::ALL_AUTHORS_ID.":".$this->id;
34 37
     }
35 38
 
36
-    public static function getEntryIdByLetter ($startingLetter) {
39
+    public static function getEntryIdByLetter ($startingLetter)
40
+    {
37 41
         return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
38 42
     }
39 43
 
40
-    public static function getCount() {
44
+    public static function getCount()
45
+    {
41 46
         // str_format (localize("authors.alphabetical", count(array))
42 47
         return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
43 48
     }
44 49
 
45
-    public static function getAllAuthorsByFirstLetter() {
50
+    public static function getAllAuthorsByFirstLetter()
51
+    {
46 52
         list (, $result) = parent::executeQuery ("select {0}
47 53
 from authors
48 54
 group by substr (upper (sort), 1, 1)
49 55
 order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
50 56
         $entryArray = array();
51
-        while ($post = $result->fetchObject ())
52
-        {
57
+        while ($post = $result->fetchObject ()) {
53 58
             array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
54 59
                 str_format (localize("authorword", $post->count), $post->count), "text",
55 60
                 array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
@@ -57,30 +62,36 @@  discard block
 block discarded – undo
57 62
         return $entryArray;
58 63
     }
59 64
 
60
-    public static function getAuthorsByStartingLetter($letter) {
65
+    public static function getAuthorsByStartingLetter($letter)
66
+    {
61 67
         return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
62 68
     }
63 69
 
64
-    public static function getAuthorsForSearch($query) {
70
+    public static function getAuthorsForSearch($query)
71
+    {
65 72
         return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
66 73
     }
67 74
 
68
-    public static function getAllAuthors() {
75
+    public static function getAllAuthors()
76
+    {
69 77
         return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
70 78
     }
71 79
 
72
-    public static function getEntryArray ($query, $params) {
80
+    public static function getEntryArray ($query, $params)
81
+    {
73 82
         return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
74 83
     }
75 84
 
76
-    public static function getAuthorById ($authorId) {
85
+    public static function getAuthorById ($authorId)
86
+    {
77 87
         $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78 88
         $result->execute (array ($authorId));
79 89
         $post = $result->fetchObject ();
80 90
         return new Author ($post);
81 91
     }
82 92
 
83
-    public static function getAuthorByBookId ($bookId) {
93
+    public static function getAuthorByBookId ($bookId)
94
+    {
84 95
         $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
85 96
 where author = authors.id
86 97
 and book = ? order by books_authors_link.id');
Please login to merge, or discard this patch.
lib/PageCustomize.php 1 patch
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@  discard block
 block discarded – undo
8 8
 
9 9
 class PageCustomize extends Page
10 10
 {
11
-    private function isChecked ($key, $testedValue = 1) {
11
+    private function isChecked ($key, $testedValue = 1)
12
+    {
12 13
         $value = getCurrentOption ($key);
13 14
         if (is_array ($value)) {
14 15
             if (in_array ($testedValue, $value)) {
@@ -22,14 +23,16 @@  discard block
 block discarded – undo
22 23
         return "";
23 24
     }
24 25
 
25
-    private function isSelected ($key, $value) {
26
+    private function isSelected ($key, $value)
27
+    {
26 28
         if (getCurrentOption ($key) == $value) {
27 29
             return "selected='selected'";
28 30
         }
29 31
         return "";
30 32
     }
31 33
 
32
-    private function getTemplateList () {
34
+    private function getTemplateList ()
35
+    {
33 36
         $result = array ();
34 37
         foreach (glob ("templates/*") as $filename) {
35 38
             if (preg_match ('/templates\/(.*)/', $filename, $m)) {
@@ -39,7 +42,8 @@  discard block
 block discarded – undo
39 42
         return $result;
40 43
     }    
41 44
 
42
-    private function getStyleList () {
45
+    private function getStyleList ()
46
+    {
43 47
         $result = array ();
44 48
         foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) {
45 49
             if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
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,7 +166,8 @@  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
         global $config;
157 172
 
158 173
         $out = array ();
@@ -169,22 +184,20 @@  discard block
 block discarded – undo
169 184
         $result = parent::getDb ()->prepare($sql);
170 185
         $result->execute (array ($book->id));
171 186
 
172
-        while ($post = $result->fetchObject ())
173
-        {
187
+        while ($post = $result->fetchObject ()) {
174 188
             array_push ($out, new Data ($post, $book));
175 189
         }
176 190
         return $out;
177 191
     }
178 192
 
179
-    public static function handleThumbnailLink ($urlParam, $height) {
193
+    public static function handleThumbnailLink ($urlParam, $height)
194
+    {
180 195
         global $config;
181 196
 
182 197
         if (is_null ($height)) {
183 198
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
184 199
                 $height = $config['cops_opds_thumbnail_height'];
185
-            }
186
-            else
187
-            {
200
+            } else {
188 201
                 $height = $config['cops_html_thumbnail_height'];
189 202
             }
190 203
         }
@@ -200,18 +213,23 @@  discard block
 block discarded – undo
200 213
         global $config;
201 214
 
202 215
         $urlParam = addURLParameter("", "data", $idData);
203
-        if ($view) $urlParam = addURLParameter($urlParam, "view", 1);
216
+        if ($view) {
217
+            $urlParam = addURLParameter($urlParam, "view", 1);
218
+        }
204 219
 
205 220
         if (Base::useAbsolutePath () ||
206 221
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
207
-            ($type == "epub" && $config['cops_update_epub-metadata']))
208
-        {
209
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
222
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
223
+            if ($type != "jpg") {
224
+                $urlParam = addURLParameter($urlParam, "type", $type);
225
+            }
210 226
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
211 227
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
212 228
             }
213 229
             $urlParam = addURLParameter($urlParam, "id", $book->id);
214
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
230
+            if (!is_null (GetUrlParam (DB))) {
231
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
232
+            }
215 233
             if ($config['cops_thumbnail_handling'] != "1" &&
216 234
                 !empty ($config['cops_thumbnail_handling']) &&
217 235
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -219,9 +237,7 @@  discard block
 block discarded – undo
219 237
             } else {
220 238
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
221 239
             }
222
-        }
223
-        else
224
-        {
240
+        } else {
225 241
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
226 242
         }
227 243
     }
Please login to merge, or discard this patch.
lib/Book.php 1 patch
Braces   +106 added lines, -80 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,7 +352,8 @@  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) {
@@ -342,7 +362,8 @@  discard block
 block discarded – undo
342 362
         return $addition . html2xhtml($this->comment);
343 363
     }
344 364
 
345
-    public function getDataFormat($format) {
365
+    public function getDataFormat($format)
366
+    {
346 367
         $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
347 368
             return $data->format == $format;
348 369
         });
@@ -351,23 +372,19 @@  discard block
 block discarded – undo
351 372
 
352 373
     public function getFilePath($extension, $idData = NULL, $relative = false)
353 374
     {
354
-        if ($extension == 'jpg')
355
-        {
375
+        if ($extension == 'jpg') {
356 376
             $file = 'cover.jpg';
357
-        }
358
-        else
359
-        {
377
+        } else {
360 378
             $data = $this->getDataById($idData);
361
-            if (!$data) return NULL;
379
+            if (!$data) {
380
+                return NULL;
381
+            }
362 382
             $file = $data->name . '.' . strtolower($data->format);
363 383
         }
364 384
 
365
-        if ($relative)
366
-        {
385
+        if ($relative) {
367 386
             return $this->relativePath.'/'.$file;
368
-        }
369
-        else
370
-        {
387
+        } else {
371 388
             return $this->path.'/'.$file;
372 389
         }
373 390
     }
@@ -377,8 +394,7 @@  discard block
 block discarded – undo
377 394
         global $config;
378 395
         $data = $this->getDataById($idData);
379 396
 
380
-        try
381
-        {
397
+        try {
382 398
             $epub = new EPub($data->getLocalPath());
383 399
 
384 400
             $epub->Title($this->title);
@@ -403,14 +419,13 @@  discard block
 block discarded – undo
403 419
                 $filename = $data->getUpdatedFilenameKepub();
404 420
             }
405 421
             $epub->download($filename);
406
-        }
407
-        catch (Exception $e)
408
-        {
422
+        } catch (Exception $e) {
409 423
             echo 'Exception : ' . $e->getMessage();
410 424
         }
411 425
     }
412 426
 
413
-    public function getThumbnail($width, $height, $outputfile = NULL) {
427
+    public function getThumbnail($width, $height, $outputfile = NULL)
428
+    {
414 429
         if (is_null($width) && is_null($height)) {
415 430
             return false;
416 431
         }
@@ -449,17 +464,14 @@  discard block
 block discarded – undo
449 464
     {
450 465
         $linkArray = array();
451 466
 
452
-        if ($this->hasCover)
453
-        {
467
+        if ($this->hasCover) {
454 468
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
455 469
 
456 470
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
457 471
         }
458 472
 
459
-        foreach ($this->getDatas() as $data)
460
-        {
461
-            if ($data->isKnownType())
462
-            {
473
+        foreach ($this->getDatas() as $data) {
474
+            if ($data->isKnownType()) {
463 475
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
464 476
             }
465 477
         }
@@ -478,17 +490,20 @@  discard block
 block discarded – undo
478 490
     }
479 491
 
480 492
 
481
-    public function getEntry() {
493
+    public function getEntry()
494
+    {
482 495
         return new EntryBook($this->getTitle(), $this->getEntryId(),
483 496
             $this->getComment(), 'text/html',
484 497
             $this->getLinkArray(), $this);
485 498
     }
486 499
 
487
-    public static function getBookCount($database = NULL) {
500
+    public static function getBookCount($database = NULL)
501
+    {
488 502
         return parent::executeQuerySingle('select count(*) from books', $database);
489 503
     }
490 504
 
491
-    public static function getCount() {
505
+    public static function getCount()
506
+    {
492 507
         global $config;
493 508
         $nBooks = parent::executeQuerySingle('select count(*) from books');
494 509
         $result = array();
@@ -507,27 +522,33 @@  discard block
 block discarded – undo
507 522
         return $result;
508 523
     }
509 524
 
510
-    public static function getBooksByAuthor($authorId, $n) {
525
+    public static function getBooksByAuthor($authorId, $n)
526
+    {
511 527
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
512 528
     }
513 529
 
514
-    public static function getBooksByRating($ratingId, $n) {
530
+    public static function getBooksByRating($ratingId, $n)
531
+    {
515 532
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
516 533
     }
517 534
 
518
-    public static function getBooksByPublisher($publisherId, $n) {
535
+    public static function getBooksByPublisher($publisherId, $n)
536
+    {
519 537
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
520 538
     }
521 539
 
522
-    public static function getBooksBySeries($serieId, $n) {
540
+    public static function getBooksBySeries($serieId, $n)
541
+    {
523 542
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
524 543
     }
525 544
 
526
-    public static function getBooksByTag($tagId, $n) {
545
+    public static function getBooksByTag($tagId, $n)
546
+    {
527 547
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
528 548
     }
529 549
 
530
-    public static function getBooksByLanguage($languageId, $n) {
550
+    public static function getBooksByLanguage($languageId, $n)
551
+    {
531 552
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
532 553
     }
533 554
 
@@ -537,32 +558,33 @@  discard block
 block discarded – undo
537 558
      * @param $n integer
538 559
      * @return array
539 560
      */
540
-    public static function getBooksByCustom($customColumn, $id, $n) {
561
+    public static function getBooksByCustom($customColumn, $id, $n)
562
+    {
541 563
         list($query, $params) = $customColumn->getQuery($id);
542 564
 
543 565
         return self::getEntryArray($query, $params, $n);
544 566
     }
545 567
 
546
-    public static function getBookById($bookId) {
568
+    public static function getBookById($bookId)
569
+    {
547 570
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . '
548 571
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
549 572
 where books.id = ?');
550 573
         $result->execute(array($bookId));
551
-        while ($post = $result->fetchObject())
552
-        {
574
+        while ($post = $result->fetchObject()) {
553 575
             $book = new Book($post);
554 576
             return $book;
555 577
         }
556 578
         return NULL;
557 579
     }
558 580
 
559
-    public static function getBookByDataId($dataId) {
581
+    public static function getBookByDataId($dataId)
582
+    {
560 583
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
561 584
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
562 585
 where data.book = books.id and data.id = ?');
563 586
         $result->execute(array($dataId));
564
-        while ($post = $result->fetchObject())
565
-        {
587
+        while ($post = $result->fetchObject()) {
566 588
             $book = new Book($post);
567 589
             $data = new Data($post, $book);
568 590
             $data->id = $dataId;
@@ -572,7 +594,8 @@  discard block
 block discarded – undo
572 594
         return NULL;
573 595
     }
574 596
 
575
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
597
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
598
+    {
576 599
         $i = 0;
577 600
         $critArray = array();
578 601
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -583,8 +606,7 @@  discard block
 block discarded – undo
583 606
             if (in_array($key, getCurrentOption('ignored_categories')) ||
584 607
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
585 608
                 $critArray[$i] = self::BAD_SEARCH;
586
-            }
587
-            else {
609
+            } else {
588 610
                 if (array_key_exists($key, $query)) {
589 611
                     $critArray[$i] = $query[$key];
590 612
                 } else {
@@ -596,12 +618,14 @@  discard block
 block discarded – undo
596 618
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
597 619
     }
598 620
 
599
-    public static function getBooks($n) {
621
+    public static function getBooks($n)
622
+    {
600 623
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
601 624
         return array($entryArray, $totalNumber);
602 625
     }
603 626
 
604
-    public static function getAllBooks() {
627
+    public static function getAllBooks()
628
+    {
605 629
         /* @var $result PDOStatement */
606 630
 
607 631
         list (, $result) = parent::executeQuery('select {0}
@@ -610,8 +634,7 @@  discard block
 block discarded – undo
610 634
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
611 635
 
612 636
         $entryArray = array();
613
-        while ($post = $result->fetchObject())
614
-        {
637
+        while ($post = $result->fetchObject()) {
615 638
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
616 639
                 str_format(localize('bookword', $post->count), $post->count), 'text',
617 640
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -619,25 +642,27 @@  discard block
 block discarded – undo
619 642
         return $entryArray;
620 643
     }
621 644
 
622
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
645
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
646
+    {
623 647
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
624 648
     }
625 649
 
626
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
650
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
651
+    {
627 652
         /* @var $totalNumber integer */
628 653
         /* @var $result PDOStatement */
629 654
         list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
630 655
 
631 656
         $entryArray = array();
632
-        while ($post = $result->fetchObject())
633
-        {
657
+        while ($post = $result->fetchObject()) {
634 658
             $book = new Book($post);
635 659
             array_push($entryArray, $book->getEntry());
636 660
         }
637 661
         return array($entryArray, $totalNumber);
638 662
     }
639 663
 
640
-    public static function getAllRecentBooks() {
664
+    public static function getAllRecentBooks()
665
+    {
641 666
         global $config;
642 667
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
643 668
         return $entryArray;
@@ -649,7 +674,8 @@  discard block
 block discarded – undo
649 674
      * @param string[] $columns
650 675
      * @return CustomColumn[]
651 676
      */
652
-    public function getCustomColumnValues($columns, $asArray = false) {
677
+    public function getCustomColumnValues($columns, $asArray = false)
678
+    {
653 679
         $result = array();
654 680
 
655 681
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.