Completed
Push — master ( 7c8e79...b8091b )
by Markus
04:56
created
lib/Serie.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,44 +21,44 @@
 block discarded – undo
21 21
         $this->name = $post->name;
22 22
     }
23 23
 
24
-    public function getUri () {
25
-        return "?page=".Base::PAGE_SERIE_DETAIL."&id=$this->id";
24
+    public function getUri() {
25
+        return "?page=" . Base::PAGE_SERIE_DETAIL . "&id=$this->id";
26 26
     }
27 27
 
28
-    public function getEntryId () {
29
-        return self::ALL_SERIES_ID.":".$this->id;
28
+    public function getEntryId() {
29
+        return self::ALL_SERIES_ID . ":" . $this->id;
30 30
     }
31 31
 
32 32
     public static function getCount() {
33 33
         // str_format (localize("series.alphabetical", count(array))
34
-        return Base::getCountGeneric ("series", self::ALL_SERIES_ID, Base::PAGE_ALL_SERIES);
34
+        return Base::getCountGeneric("series", self::ALL_SERIES_ID, Base::PAGE_ALL_SERIES);
35 35
     }
36 36
 
37
-    public static function getSerieByBookId ($bookId) {
38
-        $result = Base::getDb ()->prepare('select  series.id as id, name
37
+    public static function getSerieByBookId($bookId) {
38
+        $result = Base::getDb()->prepare('select  series.id as id, name
39 39
 from books_series_link, series
40 40
 where series.id = series and book = ?');
41
-        $result->execute (array ($bookId));
42
-        if ($post = $result->fetchObject ()) {
43
-            return new Serie ($post);
41
+        $result->execute(array($bookId));
42
+        if ($post = $result->fetchObject()) {
43
+            return new Serie($post);
44 44
         }
45 45
         return NULL;
46 46
     }
47 47
 
48
-    public static function getSerieById ($serieId) {
49
-        $result = Base::getDb ()->prepare('select id, name  from series where id = ?');
50
-        $result->execute (array ($serieId));
51
-        if ($post = $result->fetchObject ()) {
52
-            return new Serie ($post);
48
+    public static function getSerieById($serieId) {
49
+        $result = Base::getDb()->prepare('select id, name  from series where id = ?');
50
+        $result->execute(array($serieId));
51
+        if ($post = $result->fetchObject()) {
52
+            return new Serie($post);
53 53
         }
54 54
         return NULL;
55 55
     }
56 56
 
57 57
     public static function getAllSeries() {
58
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
58
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array(), "Serie");
59 59
     }
60 60
 
61 61
     public static function getAllSeriesByQuery($query) {
62
-        return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
62
+        return Base::getEntryArrayWithBookNumber(self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array('%' . $query . '%'), "Serie");
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
lib/Book.php 2 patches
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.
lib/Data.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -59,25 +59,25 @@  discard block
 block discarded – undo
59 59
         $this->id = $post->id;
60 60
         $this->name = $post->name;
61 61
         $this->format = $post->format;
62
-        $this->realFormat = str_replace ("ORIGINAL_", "", $post->format);
63
-        $this->extension = strtolower ($this->realFormat);
62
+        $this->realFormat = str_replace("ORIGINAL_", "", $post->format);
63
+        $this->extension = strtolower($this->realFormat);
64 64
         $this->book = $book;
65 65
     }
66 66
 
67
-    public function isKnownType () {
68
-        return array_key_exists ($this->extension, self::$mimetypes);
67
+    public function isKnownType() {
68
+        return array_key_exists($this->extension, self::$mimetypes);
69 69
     }
70 70
 
71
-    public function getMimeType () {
71
+    public function getMimeType() {
72 72
         $result = "application/octet-stream";
73
-        if ($this->isKnownType ()) {
73
+        if ($this->isKnownType()) {
74 74
             return self::$mimetypes [$this->extension];
75 75
         } elseif (function_exists('finfo_open') === true) {
76 76
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
77 77
 
78 78
             if (is_resource($finfo) === true)
79 79
             {
80
-                $result = finfo_file($finfo, $this->getLocalPath ());
80
+                $result = finfo_file($finfo, $this->getLocalPath());
81 81
             }
82 82
 
83 83
             finfo_close($finfo);
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         return $result;
87 87
     }
88 88
 
89
-    public function isEpubValidOnKobo () {
89
+    public function isEpubValidOnKobo() {
90 90
         return $this->format == "EPUB" || $this->format == "KEPUB";
91 91
     }
92 92
 
93
-    public function getFilename () {
94
-        return $this->name . "." . strtolower ($this->format);
93
+    public function getFilename() {
94
+        return $this->name . "." . strtolower($this->format);
95 95
     }
96 96
 
97
-    public function getUpdatedFilename () {
98
-        return $this->book->getAuthorsSort () . " - " . $this->book->title;
97
+    public function getUpdatedFilename() {
98
+        return $this->book->getAuthorsSort() . " - " . $this->book->title;
99 99
     }
100 100
 
101
-    public function getUpdatedFilenameEpub () {
102
-        return $this->getUpdatedFilename () . ".epub";
101
+    public function getUpdatedFilenameEpub() {
102
+        return $this->getUpdatedFilename() . ".epub";
103 103
     }
104 104
 
105
-    public function getUpdatedFilenameKepub () {
106
-        $str = $this->getUpdatedFilename () . ".kepub.epub";
105
+    public function getUpdatedFilenameKepub() {
106
+        $str = $this->getUpdatedFilename() . ".kepub.epub";
107 107
         return str_replace(array(':', '#', '&'),
108
-                           array('-', '-', ' '), $str );
108
+                           array('-', '-', ' '), $str);
109 109
     }
110 110
 
111
-    public function getDataLink ($rel, $title = NULL) {
111
+    public function getDataLink($rel, $title = NULL) {
112 112
         global $config;
113 113
 
114 114
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
115 115
             return $this->getHtmlLinkWithRewriting($title);
116 116
         }
117 117
 
118
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
118
+        return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title);
119 119
     }
120 120
 
121
-    public function getHtmlLink () {
121
+    public function getHtmlLink() {
122 122
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
123 123
     }
124 124
 
125
-    public function getLocalPath () {
126
-        return $this->book->path . "/" . $this->getFilename ();
125
+    public function getLocalPath() {
126
+        return $this->book->path . "/" . $this->getFilename();
127 127
     }
128 128
 
129
-    public function getHtmlLinkWithRewriting ($title = NULL) {
129
+    public function getHtmlLinkWithRewriting($title = NULL) {
130 130
         global $config;
131 131
 
132 132
         $database = "";
133
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
133
+        if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/";
134 134
 
135 135
         $href = "download/" . $this->id . "/" . $database;
136 136
 
137 137
         if ($config['cops_provide_kepub'] == "1" &&
138
-            $this->isEpubValidOnKobo () &&
138
+            $this->isEpubValidOnKobo() &&
139 139
             preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
140
-            $href .= rawurlencode ($this->getUpdatedFilenameKepub ());
140
+            $href .= rawurlencode($this->getUpdatedFilenameKepub());
141 141
         } else {
142
-            $href .= rawurlencode ($this->getFilename ());
142
+            $href .= rawurlencode($this->getFilename());
143 143
         }
144
-        return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
144
+        return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title);
145 145
     }
146 146
 
147
-    public static function getDataByBook ($book) {
148
-        $out = array ();
149
-        $result = Base::getDb ()->prepare('select id, format, name
147
+    public static function getDataByBook($book) {
148
+        $out = array();
149
+        $result = Base::getDb()->prepare('select id, format, name
150 150
                                              from data where book = ?');
151
-        $result->execute (array ($book->id));
151
+        $result->execute(array($book->id));
152 152
 
153
-        while ($post = $result->fetchObject ())
153
+        while ($post = $result->fetchObject())
154 154
         {
155
-            array_push ($out, new Data ($post, $book));
155
+            array_push($out, new Data($post, $book));
156 156
         }
157 157
         return $out;
158 158
     }
159 159
 
160
-    public static function handleThumbnailLink ($urlParam, $height) {
160
+    public static function handleThumbnailLink($urlParam, $height) {
161 161
         global $config;
162 162
 
163
-        if (is_null ($height)) {
164
-            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
163
+        if (is_null($height)) {
164
+            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
165 165
                 $height = $config['cops_opds_thumbnail_height'];
166 166
             }
167 167
             else
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
         return $urlParam;
177 177
     }
178 178
 
179
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
179
+    public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
180 180
     {
181 181
         global $config;
182 182
 
183 183
         $urlParam = addURLParameter("", "data", $idData);
184 184
 
185
-        if (Base::useAbsolutePath () ||
185
+        if (Base::useAbsolutePath() ||
186 186
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
187 187
             ($type == "epub" && $config['cops_update_epub-metadata']))
188 188
         {
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
192 192
             }
193 193
             $urlParam = addURLParameter($urlParam, "id", $book->id);
194
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
194
+            if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
195 195
             if ($config['cops_thumbnail_handling'] != "1" &&
196 196
                 !empty ($config['cops_thumbnail_handling']) &&
197 197
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
198
-                return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title);
198
+                return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title);
199 199
             } else {
200
-                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
200
+                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title);
201 201
             }
202 202
         }
203 203
         else
204 204
         {
205
-            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
205
+            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title);
206 206
         }
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
lib/Publisher.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,45 +22,45 @@
 block discarded – undo
22 22
         $this->name = $post->name;
23 23
     }
24 24
 
25
-    public function getUri () {
26
-        return "?page=".Base::PAGE_PUBLISHER_DETAIL."&id=$this->id";
25
+    public function getUri() {
26
+        return "?page=" . Base::PAGE_PUBLISHER_DETAIL . "&id=$this->id";
27 27
     }
28 28
 
29
-    public function getEntryId () {
30
-        return self::ALL_PUBLISHERS_ID.":".$this->id;
29
+    public function getEntryId() {
30
+        return self::ALL_PUBLISHERS_ID . ":" . $this->id;
31 31
     }
32 32
 
33 33
     public static function getCount() {
34 34
         // str_format (localize("publishers.alphabetical", count(array))
35
-        return Base::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, Base::PAGE_ALL_PUBLISHERS);
35
+        return Base::getCountGeneric("publishers", self::ALL_PUBLISHERS_ID, Base::PAGE_ALL_PUBLISHERS);
36 36
     }
37 37
 
38
-    public static function getPublisherByBookId ($bookId) {
39
-        $result = Base::getDb ()->prepare('select publishers.id as id, name
38
+    public static function getPublisherByBookId($bookId) {
39
+        $result = Base::getDb()->prepare('select publishers.id as id, name
40 40
 from books_publishers_link, publishers
41 41
 where publishers.id = publisher and book = ?');
42
-        $result->execute (array ($bookId));
43
-        if ($post = $result->fetchObject ()) {
44
-            return new Publisher ($post);
42
+        $result->execute(array($bookId));
43
+        if ($post = $result->fetchObject()) {
44
+            return new Publisher($post);
45 45
         }
46 46
         return NULL;
47 47
     }
48 48
 
49
-    public static function getPublisherById ($publisherId) {
50
-        $result = Base::getDb ()->prepare('select id, name
49
+    public static function getPublisherById($publisherId) {
50
+        $result = Base::getDb()->prepare('select id, name
51 51
 from publishers where id = ?');
52
-        $result->execute (array ($publisherId));
53
-        if ($post = $result->fetchObject ()) {
54
-            return new Publisher ($post);
52
+        $result->execute(array($publisherId));
53
+        if ($post = $result->fetchObject()) {
54
+            return new Publisher($post);
55 55
         }
56 56
         return NULL;
57 57
     }
58 58
 
59 59
     public static function getAllPublishers() {
60
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_PUBLISHERS, self::PUBLISHERS_COLUMNS, array (), "Publisher");
60
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_PUBLISHERS, self::PUBLISHERS_COLUMNS, array(), "Publisher");
61 61
     }
62 62
 
63 63
     public static function getAllPublishersByQuery($query) {
64
-        return Base::getEntryArrayWithBookNumber (self::SQL_PUBLISHERS_FOR_SEARCH, self::PUBLISHERS_COLUMNS, array ('%' . $query . '%'), "Publisher");
64
+        return Base::getEntryArrayWithBookNumber(self::SQL_PUBLISHERS_FOR_SEARCH, self::PUBLISHERS_COLUMNS, array('%' . $query . '%'), "Publisher");
65 65
     }
66 66
 }
Please login to merge, or discard this patch.
lib/Tag.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,44 +20,44 @@
 block discarded – undo
20 20
         $this->name = $post->name;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".Base::PAGE_TAG_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . Base::PAGE_TAG_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_TAGS_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_TAGS_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("tags.alphabetical", count(array))
33
-        return Base::getCountGeneric ("tags", self::ALL_TAGS_ID, Base::PAGE_ALL_TAGS);
33
+        return Base::getCountGeneric("tags", self::ALL_TAGS_ID, Base::PAGE_ALL_TAGS);
34 34
     }
35 35
 
36
-    public static function getTagById ($tagId) {
37
-        $result = Base::getDb ()->prepare('select id, name  from tags where id = ?');
38
-        $result->execute (array ($tagId));
39
-        if ($post = $result->fetchObject ()) {
40
-            return new Tag ($post);
36
+    public static function getTagById($tagId) {
37
+        $result = Base::getDb()->prepare('select id, name  from tags where id = ?');
38
+        $result->execute(array($tagId));
39
+        if ($post = $result->fetchObject()) {
40
+            return new Tag($post);
41 41
         }
42 42
         return NULL;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
46
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_TAGS, self::TAG_COLUMNS, array(), "Tag");
47 47
     }
48 48
 
49 49
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
50
-        $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50
+        $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 51
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52
-        list ($totalNumber, $result) = Base::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
52
+        list ($totalNumber, $result) = Base::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
53 53
         $entryArray = array();
54
-        while ($post = $result->fetchObject ())
54
+        while ($post = $result->fetchObject())
55 55
         {
56
-            $tag = new Tag ($post);
57
-            array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
58
-                str_format (localize("bookword", $post->count), $post->count), "text",
59
-                array ( new LinkNavigation ($tag->getUri ()))));
56
+            $tag = new Tag($post);
57
+            array_push($entryArray, new Entry($tag->name, $tag->getEntryId(),
58
+                str_format(localize("bookword", $post->count), $post->count), "text",
59
+                array(new LinkNavigation($tag->getUri()))));
60 60
         }
61
-        return array ($entryArray, $totalNumber);
61
+        return array($entryArray, $totalNumber);
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
lib/Language.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
         $this->lang_code = $plang_code;
19 19
     }
20 20
 
21
-    public function getUri () {
22
-        return "?page=".Base::PAGE_LANGUAGE_DETAIL."&id=$this->id";
21
+    public function getUri() {
22
+        return "?page=" . Base::PAGE_LANGUAGE_DETAIL . "&id=$this->id";
23 23
     }
24 24
 
25
-    public function getEntryId () {
26
-        return self::ALL_LANGUAGES_ID.":".$this->id;
25
+    public function getEntryId() {
26
+        return self::ALL_LANGUAGES_ID . ":" . $this->id;
27 27
     }
28 28
 
29
-    public static function getLanguageString ($code) {
30
-        $string = localize("languages.".$code);
31
-        if (preg_match ("/^languages/", $string)) {
29
+    public static function getLanguageString($code) {
30
+        $string = localize("languages." . $code);
31
+        if (preg_match("/^languages/", $string)) {
32 32
             return $code;
33 33
         }
34 34
         return $string;
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 
37 37
     public static function getCount() {
38 38
         // str_format (localize("languages.alphabetical", count(array))
39
-        return Base::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, Base::PAGE_ALL_LANGUAGES);
39
+        return Base::getCountGeneric("languages", self::ALL_LANGUAGES_ID, Base::PAGE_ALL_LANGUAGES);
40 40
     }
41 41
 
42
-    public static function getLanguageById ($languageId) {
43
-        $result = Base::getDb ()->prepare('select id, lang_code  from languages where id = ?');
44
-        $result->execute (array ($languageId));
45
-        if ($post = $result->fetchObject ()) {
46
-            return new Language ($post->id, Language::getLanguageString ($post->lang_code));
42
+    public static function getLanguageById($languageId) {
43
+        $result = Base::getDb()->prepare('select id, lang_code  from languages where id = ?');
44
+        $result->execute(array($languageId));
45
+        if ($post = $result->fetchObject()) {
46
+            return new Language($post->id, Language::getLanguageString($post->lang_code));
47 47
         }
48 48
         return NULL;
49 49
     }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 group by languages.id, books_languages_link.lang_code
58 58
 order by languages.lang_code');
59 59
         $entryArray = array();
60
-        while ($post = $result->fetchObject ())
60
+        while ($post = $result->fetchObject())
61 61
         {
62
-            $language = new Language ($post->id, $post->lang_code);
63
-            array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (),
64
-                str_format (localize("bookword", $post->count), $post->count), "text",
65
-                array ( new LinkNavigation ($language->getUri ())), "", $post->count));
62
+            $language = new Language($post->id, $post->lang_code);
63
+            array_push($entryArray, new Entry(Language::getLanguageString($language->lang_code), $language->getEntryId(),
64
+                str_format(localize("bookword", $post->count), $post->count), "text",
65
+                array(new LinkNavigation($language->getUri())), "", $post->count));
66 66
         }
67 67
         return $entryArray;
68 68
     }
Please login to merge, or discard this patch.
lib/Author.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -25,69 +25,69 @@
 block discarded – undo
25 25
         $this->sort = $post->sort;
26 26
     }
27 27
 
28
-    public function getUri () {
29
-        return "?page=".Base::PAGE_AUTHOR_DETAIL."&id=$this->id";
28
+    public function getUri() {
29
+        return "?page=" . Base::PAGE_AUTHOR_DETAIL . "&id=$this->id";
30 30
     }
31 31
 
32
-    public function getEntryId () {
33
-        return self::ALL_AUTHORS_ID.":".$this->id;
32
+    public function getEntryId() {
33
+        return self::ALL_AUTHORS_ID . ":" . $this->id;
34 34
     }
35 35
 
36
-    public static function getEntryIdByLetter ($startingLetter) {
37
-        return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
36
+    public static function getEntryIdByLetter($startingLetter) {
37
+        return self::ALL_AUTHORS_ID . ":letter:" . $startingLetter;
38 38
     }
39 39
 
40 40
     public static function getCount() {
41 41
         // str_format (localize("authors.alphabetical", count(array))
42
-        return Base::getCountGeneric ("authors", self::ALL_AUTHORS_ID, Base::PAGE_ALL_AUTHORS);
42
+        return Base::getCountGeneric("authors", self::ALL_AUTHORS_ID, Base::PAGE_ALL_AUTHORS);
43 43
     }
44 44
 
45 45
     public static function getAllAuthorsByFirstLetter() {
46
-        list (, $result) = Base::executeQuery ("select {0}
46
+        list (, $result) = Base::executeQuery("select {0}
47 47
 from authors
48 48
 group by substr (upper (sort), 1, 1)
49
-order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
49
+order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1);
50 50
         $entryArray = array();
51
-        while ($post = $result->fetchObject ())
51
+        while ($post = $result->fetchObject())
52 52
         {
53
-            array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
54
-                str_format (localize("authorword", $post->count), $post->count), "text",
55
-                array ( new LinkNavigation ("?page=".Base::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
53
+            array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title),
54
+                str_format(localize("authorword", $post->count), $post->count), "text",
55
+                array(new LinkNavigation("?page=" . Base::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count));
56 56
         }
57 57
         return $entryArray;
58 58
     }
59 59
 
60 60
     public static function getAuthorsByStartingLetter($letter) {
61
-        return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
61
+        return self::getEntryArray(self::SQL_AUTHORS_BY_FIRST_LETTER, array($letter . "%"));
62 62
     }
63 63
 
64 64
     public static function getAuthorsForSearch($query) {
65
-        return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
65
+        return self::getEntryArray(self::SQL_AUTHORS_FOR_SEARCH, array($query . "%", $query . "%"));
66 66
     }
67 67
 
68 68
     public static function getAllAuthors() {
69
-        return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
69
+        return self::getEntryArray(self::SQL_ALL_AUTHORS, array());
70 70
     }
71 71
 
72
-    public static function getEntryArray ($query, $params) {
73
-        return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
72
+    public static function getEntryArray($query, $params) {
73
+        return Base::getEntryArrayWithBookNumber($query, self::AUTHOR_COLUMNS, $params, "Author");
74 74
     }
75 75
 
76
-    public static function getAuthorById ($authorId) {
77
-        $result = Base::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78
-        $result->execute (array ($authorId));
79
-        $post = $result->fetchObject ();
80
-        return new Author ($post);
76
+    public static function getAuthorById($authorId) {
77
+        $result = Base::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78
+        $result->execute(array($authorId));
79
+        $post = $result->fetchObject();
80
+        return new Author($post);
81 81
     }
82 82
 
83
-    public static function getAuthorByBookId ($bookId) {
84
-        $result = Base::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
83
+    public static function getAuthorByBookId($bookId) {
84
+        $result = Base::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
85 85
 where author = authors.id
86 86
 and book = ?');
87
-        $result->execute (array ($bookId));
88
-        $authorArray = array ();
89
-        while ($post = $result->fetchObject ()) {
90
-            array_push ($authorArray, new Author ($post));
87
+        $result->execute(array($bookId));
88
+        $authorArray = array();
89
+        while ($post = $result->fetchObject()) {
90
+            array_push($authorArray, new Author($post));
91 91
         }
92 92
         return $authorArray;
93 93
     }
Please login to merge, or discard this patch.
lib/Rating.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     const ALL_RATING_ID = "cops:rating";
12 12
 
13 13
     const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
14
-    const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
14
+    const SQL_ALL_RATINGS = "select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
15 15
     public $id;
16 16
     public $name;
17 17
 
@@ -20,41 +20,41 @@  discard block
 block discarded – undo
20 20
         $this->name = $pname;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".Base::PAGE_RATING_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . Base::PAGE_RATING_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_RATING_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_RATING_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("ratings", count(array))
33
-        return Base::getCountGeneric ("ratings", self::ALL_RATING_ID, Base::PAGE_ALL_RATINGS, "ratings");
33
+        return Base::getCountGeneric("ratings", self::ALL_RATING_ID, Base::PAGE_ALL_RATINGS, "ratings");
34 34
     }
35 35
 
36 36
     public static function getAllRatings() {
37
-        return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
37
+        return self::getEntryArray(self::SQL_ALL_RATINGS, array());
38 38
     }
39 39
 
40
-    public static function getEntryArray ($query, $params) {
41
-        list (, $result) = Base::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
40
+    public static function getEntryArray($query, $params) {
41
+        list (, $result) = Base::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
42 42
         $entryArray = array();
43
-        while ($post = $result->fetchObject ())
43
+        while ($post = $result->fetchObject())
44 44
         {
45
-            $ratingObj = new Rating ($post->id, $post->rating);
46
-            $rating=$post->rating/2;
47
-            $rating = str_format (localize("ratingword", $rating), $rating);
48
-            array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (),
49
-                str_format (localize("bookword", $post->count), $post->count), "text",
50
-                array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count));
45
+            $ratingObj = new Rating($post->id, $post->rating);
46
+            $rating = $post->rating / 2;
47
+            $rating = str_format(localize("ratingword", $rating), $rating);
48
+            array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(),
49
+                str_format(localize("bookword", $post->count), $post->count), "text",
50
+                array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
51 51
         }
52 52
         return $entryArray;
53 53
     }
54 54
 
55
-    public static function getRatingById ($ratingId) {
56
-        $result = Base::getDb ()->prepare('select rating from ratings where id = ?');
57
-        $result->execute (array ($ratingId));
58
-        return new Rating ($ratingId, $result->fetchColumn ());
55
+    public static function getRatingById($ratingId) {
56
+        $result = Base::getDb()->prepare('select rating from ratings where id = ?');
57
+        $result->execute(array($ratingId));
58
+        return new Rating($ratingId, $result->fetchColumn());
59 59
     }
60 60
 }
Please login to merge, or discard this patch.