Completed
Pull Request — master (#424)
by
unknown
54:45 queued 45:01
created
lib/Book.php 5 patches
Doc Comments   +17 added lines, -1 removed lines patch added patch discarded remove patch
@@ -208,6 +208,9 @@  discard block
 block discarded – undo
208 208
         return 'index.php' . $urlParam;
209 209
     }
210 210
 
211
+    /**
212
+     * @return string
213
+     */
211 214
     public function getTitle () {
212 215
         return $this->title;
213 216
     }
@@ -395,6 +398,9 @@  discard block
 block discarded – undo
395 398
         return reset($reduced);
396 399
     }
397 400
 
401
+    /**
402
+     * @param string $extension
403
+     */
398 404
     public function getFilePath($extension, $idData = NULL, $relative = false)
399 405
     {
400 406
         /*if ($extension == 'jpg')
@@ -562,6 +568,9 @@  discard block
 block discarded – undo
562 568
             $this->getLinkArray(), $this);
563 569
     }
564 570
 
571
+    /**
572
+     * @param integer $database
573
+     */
565 574
     public static function getBookCount($database = NULL) {
566 575
         return parent::executeQuerySingle('select count(*) from books', $database);
567 576
     }
@@ -610,7 +619,7 @@  discard block
 block discarded – undo
610 619
     }
611 620
 
612 621
     /**
613
-     * @param $customColumn CustomColumn
622
+     * @param CustomColumn $customColumn CustomColumn
614 623
      * @param $id integer
615 624
      * @param $n integer
616 625
      * @return array
@@ -650,6 +659,10 @@  discard block
 block discarded – undo
650 659
         return NULL;
651 660
     }
652 661
 
662
+    /**
663
+     * @param integer $database
664
+     * @param integer $numberPerPage
665
+     */
653 666
     public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
654 667
         $i = 0;
655 668
         $critArray = array();
@@ -697,6 +710,9 @@  discard block
 block discarded – undo
697 710
         return $entryArray;
698 711
     }
699 712
 
713
+    /**
714
+     * @param integer $numberPerPage
715
+     */
700 716
     public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
701 717
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
702 718
     }
Please login to merge, or discard this patch.
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     private $coverFileName = NULL;
110 110
 
111 111
     public function __construct($line) {
112
-    	global $config;
112
+        global $config;
113 113
 
114 114
         $this->id = $line->id;
115 115
         $this->title = $line->title;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         // -DC- Init relative or full path
121 121
         $this->path = $line->path;
122 122
         if (!is_dir($this->path)) {
123
-        	$this->path = Base::getDbDirectory() . $line->path;
123
+            $this->path = Base::getDbDirectory() . $line->path;
124 124
         }
125 125
         $this->seriesIndex = $line->series_index;
126 126
         $this->comment = $line->comment;
@@ -132,47 +132,47 @@  discard block
 block discarded – undo
132 132
         //    $this->hasCover = 0;
133 133
         //}
134 134
         if ($this->hasCover) {
135
-        	if (!empty($config['calibre_database_field_cover'])) {
136
-        		$imgDirectory = Base::getImgDirectory();
137
-        		$this->coverFileName = $line->cover;
138
-        		if (!file_exists($this->coverFileName)) {
139
-        			$this->coverFileName = NULL;
140
-        		}
141
-        		if (empty($this->coverFileName)) {
142
-        			$this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover);
143
-        			if (!file_exists($this->coverFileName)) {
144
-        				$this->coverFileName = NULL;
145
-        			}
146
-        		}
147
-        		if (empty($this->coverFileName)) {
148
-        			$data = $this->getDataById($this->id);
149
-        			if ($data) {
150
-        				$this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover);
151
-        				if (!file_exists($this->coverFileName)) {
152
-        					$this->coverFileName = NULL;
153
-        				}
154
-        				if (empty($this->coverFileName)) {
155
-        					$this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name);
156
-        					if (!file_exists($this->coverFileName)) {
157
-        						$this->coverFileName = NULL;
158
-        					}
159
-        				}
160
-        			}
161
-        		}
162
-        	}
163
-        	// Else try with default cover file name
164
-        	if (empty($this->coverFileName)) {
165
-        		$cover = $this->getFilePath("jpg");
166
-        		if ($cover === false || !file_exists($cover)) {
167
-        			$cover = $this->getFilePath("png");
168
-        		}
169
-        		if ($cover === false || !file_exists($cover)) {
170
-        			$this->hasCover = 0;
171
-        		}
172
-        		else {
173
-        			$this->coverFileName = $cover;
174
-        		}
175
-        	}
135
+            if (!empty($config['calibre_database_field_cover'])) {
136
+                $imgDirectory = Base::getImgDirectory();
137
+                $this->coverFileName = $line->cover;
138
+                if (!file_exists($this->coverFileName)) {
139
+                    $this->coverFileName = NULL;
140
+                }
141
+                if (empty($this->coverFileName)) {
142
+                    $this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover);
143
+                    if (!file_exists($this->coverFileName)) {
144
+                        $this->coverFileName = NULL;
145
+                    }
146
+                }
147
+                if (empty($this->coverFileName)) {
148
+                    $data = $this->getDataById($this->id);
149
+                    if ($data) {
150
+                        $this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover);
151
+                        if (!file_exists($this->coverFileName)) {
152
+                            $this->coverFileName = NULL;
153
+                        }
154
+                        if (empty($this->coverFileName)) {
155
+                            $this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name);
156
+                            if (!file_exists($this->coverFileName)) {
157
+                                $this->coverFileName = NULL;
158
+                            }
159
+                        }
160
+                    }
161
+                }
162
+            }
163
+            // Else try with default cover file name
164
+            if (empty($this->coverFileName)) {
165
+                $cover = $this->getFilePath("jpg");
166
+                if ($cover === false || !file_exists($cover)) {
167
+                    $cover = $this->getFilePath("png");
168
+                }
169
+                if ($cover === false || !file_exists($cover)) {
170
+                    $this->hasCover = 0;
171
+                }
172
+                else {
173
+                    $this->coverFileName = $cover;
174
+                }
175
+            }
176 176
         }
177 177
         $this->rating = $line->rating;
178 178
     }
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
     // -DC- Get customisable book columns
181 181
     private static function getBookColumns()
182 182
     {
183
-    	global $config;
183
+        global $config;
184 184
 
185
-    	$res = self::BOOK_COLUMNS;
186
-    	if (!empty($config['calibre_database_field_cover'])) {
187
-    		$res = str_replace('has_cover,', 'has_cover, ' . $config['calibre_database_field_cover'] . ',', $res);
188
-    	}
185
+        $res = self::BOOK_COLUMNS;
186
+        if (!empty($config['calibre_database_field_cover'])) {
187
+            $res = str_replace('has_cover,', 'has_cover, ' . $config['calibre_database_field_cover'] . ',', $res);
188
+        }
189 189
 
190
-    	return $res;
190
+        return $res;
191 191
     }
192 192
 
193 193
     public function getEntryId() {
@@ -416,26 +416,26 @@  discard block
 block discarded – undo
416 416
         {
417 417
             return $this->path.'/'.$file;
418 418
         }*/
419
-    	if ($extension == "jpg" || $extension == "png") {
420
-    		if (empty($this->coverFileName)) {
421
-    			return $this->path . '/cover.' . $extension;
422
-    		}
423
-    		else {
424
-    			$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
425
-    			if ($ext == $extension) {
426
-    				return $this->coverFileName;
427
-    			}
428
-    		}
429
-    		return false;
430
-    	}
431
-    	else {
432
-    		$data = $this->getDataById($idData);
433
-    		if (!$data) {
434
-    			return NULL;
435
-    		}
436
-    		$file = $data->name . "." . strtolower($data->format);
437
-    		return $this->path . '/' . $file;
438
-    	}
419
+        if ($extension == "jpg" || $extension == "png") {
420
+            if (empty($this->coverFileName)) {
421
+                return $this->path . '/cover.' . $extension;
422
+            }
423
+            else {
424
+                $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
425
+                if ($ext == $extension) {
426
+                    return $this->coverFileName;
427
+                }
428
+            }
429
+            return false;
430
+        }
431
+        else {
432
+            $data = $this->getDataById($idData);
433
+            if (!$data) {
434
+                return NULL;
435
+            }
436
+            $file = $data->name . "." . strtolower($data->format);
437
+            return $this->path . '/' . $file;
438
+        }
439 439
     }
440 440
 
441 441
     public function getUpdatedEpub($idData)
@@ -520,18 +520,18 @@  discard block
 block discarded – undo
520 520
         $linkArray = array();
521 521
 
522 522
         if ($this->hasCover) {
523
-        	// -DC- Use cover file name
524
-        	//array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
525
-        	//array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
526
-        	$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
527
-        	if ($ext == 'png') {
528
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
529
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
530
-        	}
531
-        	else {
532
-        		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
533
-        		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
534
-        	}
523
+            // -DC- Use cover file name
524
+            //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
525
+            //array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
526
+            $ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
527
+            if ($ext == 'png') {
528
+                array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
529
+                array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
530
+            }
531
+            else {
532
+                array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
533
+                array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
534
+            }
535 535
         }
536 536
 
537 537
         foreach ($this->getDatas() as $data)
@@ -571,15 +571,15 @@  discard block
 block discarded – undo
571 571
         $nBooks = parent::executeQuerySingle('select count(*) from books');
572 572
         $result = array();
573 573
         $entry = new Entry(localize('allbooks.title'),
574
-                          self::ALL_BOOKS_ID,
575
-                          str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
576
-                          array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks);
574
+                            self::ALL_BOOKS_ID,
575
+                            str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
576
+                            array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks);
577 577
         array_push($result, $entry);
578 578
         if ($config['cops_recentbooks_limit'] > 0) {
579 579
             $entry = new Entry(localize('recent.title'),
580
-                              self::ALL_RECENT_BOOKS_ID,
581
-                              str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
582
-                              array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
580
+                                self::ALL_RECENT_BOOKS_ID,
581
+                                str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
582
+                                array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
583 583
             array_push($result, $entry);
584 584
         }
585 585
         return $result;
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
     }
623 623
 
624 624
     public static function getBookById($bookId) {
625
-    	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . '
625
+        $result = parent::getDb()->prepare('select ' . self::getBookColumns() . '
626 626
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
627 627
 where books.id = ?');
628 628
         $result->execute(array($bookId));
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
     }
636 636
 
637 637
     public static function getBookByDataId($dataId) {
638
-    	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format
638
+        $result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format
639 639
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
640 640
 where data.book = books.id and data.id = ?');
641 641
         $result->execute(array($dataId));
@@ -654,10 +654,10 @@  discard block
 block discarded – undo
654 654
         $i = 0;
655 655
         $critArray = array();
656 656
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
657
-                       PageQueryResult::SCOPE_TAG,
658
-                       PageQueryResult::SCOPE_SERIES,
659
-                       PageQueryResult::SCOPE_PUBLISHER,
660
-                       PageQueryResult::SCOPE_BOOK) as $key) {
657
+                        PageQueryResult::SCOPE_TAG,
658
+                        PageQueryResult::SCOPE_SERIES,
659
+                        PageQueryResult::SCOPE_PUBLISHER,
660
+                        PageQueryResult::SCOPE_BOOK) as $key) {
661 661
             if (in_array($key, getCurrentOption('ignored_categories')) ||
662 662
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
663 663
                 $critArray[$i] = self::BAD_SEARCH;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
     public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
705 705
         /* @var $totalNumber integer */
706 706
         /* @var $result PDOStatement */
707
-    	list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
707
+        list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
708 708
 
709 709
         $entryArray = array();
710 710
         while ($post = $result->fetchObject())
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 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 extends Base
@@ -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
     private $coverFileName = NULL;
110 110
 
111 111
     public function __construct($line) {
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     public function getEntryId() {
194
-        return self::ALL_BOOKS_UUID.':'.$this->uuid;
194
+        return self::ALL_BOOKS_UUID . ':' . $this->uuid;
195 195
     }
196 196
 
197
-    public static function getEntryIdByLetter ($startingLetter) {
198
-        return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
197
+    public static function getEntryIdByLetter($startingLetter) {
198
+        return self::ALL_BOOKS_ID . ':letter:' . $startingLetter;
199 199
     }
200 200
 
201
-    public function getUri () {
202
-        return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id;
201
+    public function getUri() {
202
+        return '?page=' . parent::PAGE_BOOK_DETAIL . '&id=' . $this->id;
203 203
     }
204 204
 
205
-    public function getDetailUrl () {
205
+    public function getDetailUrl() {
206 206
         $urlParam = $this->getUri();
207
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
207
+        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
208 208
         return 'index.php' . $urlParam;
209 209
     }
210 210
 
211
-    public function getTitle () {
211
+    public function getTitle() {
212 212
         return $this->title;
213 213
     }
214 214
 
@@ -217,22 +217,22 @@  discard block
 block discarded – undo
217 217
     /**
218 218
      * @return Author[]
219 219
      */
220
-    public function getAuthors () {
220
+    public function getAuthors() {
221 221
         if (is_null($this->authors)) {
222 222
             $this->authors = Author::getAuthorByBookId($this->id);
223 223
         }
224 224
         return $this->authors;
225 225
     }
226 226
 
227
-    public function getAuthorsName () {
228
-        return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
227
+    public function getAuthorsName() {
228
+        return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors()));
229 229
     }
230 230
 
231
-    public function getAuthorsSort () {
232
-        return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
231
+    public function getAuthorsSort() {
232
+        return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors()));
233 233
     }
234 234
 
235
-    public function getPublisher () {
235
+    public function getPublisher() {
236 236
         if (is_null($this->publisher)) {
237 237
             $this->publisher = Publisher::getPublisherByBookId($this->id);
238 238
         }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      * @return Tag[]
272 272
      */
273 273
     public function getTags() {
274
-        if (is_null ($this->tags)) {
274
+        if (is_null($this->tags)) {
275 275
             $this->tags = array();
276 276
 
277 277
             $result = parent::getDb()->prepare('select tags.id as id, name
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     }
290 290
 
291 291
     public function getTagsName() {
292
-        return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
292
+        return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags()));
293 293
     }
294 294
 
295 295
     /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     public function getDataById($idData)
343 343
     {
344
-        $reduced = array_filter($this->getDatas(), function ($data) use ($idData) {
344
+        $reduced = array_filter($this->getDatas(), function($data) use ($idData) {
345 345
             return $data->id == $idData;
346 346
         });
347 347
         return reset($reduced);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         if (empty ($this->pubdate)) {
366 366
             return '';
367 367
         }
368
-        $dateY = (int) substr($this->pubdate, 0, 4);
368
+        $dateY = (int)substr($this->pubdate, 0, 4);
369 369
         if ($dateY > 102) {
370 370
             return str_pad($dateY, 4, '0', STR_PAD_LEFT);
371 371
         }
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
 
375 375
     public function getComment($withSerie = true) {
376 376
         $addition = '';
377
-        $se = $this->getSerie ();
378
-        if (!is_null ($se) && $withSerie) {
377
+        $se = $this->getSerie();
378
+        if (!is_null($se) && $withSerie) {
379 379
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
380 380
         }
381 381
         if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     }
390 390
 
391 391
     public function getDataFormat($format) {
392
-        $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
392
+        $reduced = array_filter($this->getDatas(), function($data) use ($format) {
393 393
             return $data->format == $format;
394 394
         });
395 395
         return reset($reduced);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             }
455 455
             $epub->Authors($authorArray);
456 456
             $epub->Language($this->getLanguages());
457
-            $epub->Description ($this->getComment(false));
457
+            $epub->Description($this->getComment(false));
458 458
             $epub->Subjects($this->getTagsName());
459 459
             // -DC- Use cover file name
460 460
             // $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg');
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                 $epub->SerieIndex($this->seriesIndex);
467 467
             }
468 468
             $filename = $data->getUpdatedFilenameEpub();
469
-            if ($config['cops_provide_kepub'] == '1'  && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
469
+            if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
470 470
                 $epub->updateForKepub();
471 471
                 $filename = $data->getUpdatedFilenameKepub();
472 472
             }
@@ -494,11 +494,11 @@  discard block
 block discarded – undo
494 494
             if (!is_null($width)) {
495 495
                 $nw = $width;
496 496
                 if ($nw >= $w) { return false; }
497
-                $nh = ($nw*$h)/$w;
497
+                $nh = ($nw * $h) / $w;
498 498
             } else {
499 499
                 $nh = $height;
500 500
                 if ($nh >= $h) { return false; }
501
-                $nw = ($nh*$w)/$h;
501
+                $nw = ($nh * $w) / $h;
502 502
             }
503 503
         } else {
504 504
             return false;
@@ -506,16 +506,16 @@  discard block
 block discarded – undo
506 506
 
507 507
         //draw the image
508 508
         $src_img = imagecreatefromjpeg($file);
509
-        $dst_img = imagecreatetruecolor($nw,$nh);
510
-        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image
511
-        imagejpeg($dst_img,$outputfile,80);
509
+        $dst_img = imagecreatetruecolor($nw, $nh);
510
+        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image
511
+        imagejpeg($dst_img, $outputfile, 80);
512 512
         imagedestroy($src_img);
513 513
         imagedestroy($dst_img);
514 514
 
515 515
         return true;
516 516
     }
517 517
 
518
-    public function getLinkArray ()
518
+    public function getLinkArray()
519 519
     {
520 520
         $linkArray = array();
521 521
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         }
549 549
 
550 550
         $serie = $this->getSerie();
551
-        if (!is_null ($serie)) {
551
+        if (!is_null($serie)) {
552 552
             array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name)));
553 553
         }
554 554
 
@@ -573,13 +573,13 @@  discard block
 block discarded – undo
573 573
         $entry = new Entry(localize('allbooks.title'),
574 574
                           self::ALL_BOOKS_ID,
575 575
                           str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
576
-                          array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks);
576
+                          array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS)), '', $nBooks);
577 577
         array_push($result, $entry);
578 578
         if ($config['cops_recentbooks_limit'] > 0) {
579 579
             $entry = new Entry(localize('recent.title'),
580 580
                               self::ALL_RECENT_BOOKS_ID,
581 581
                               str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
582
-                              array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
582
+                              array(new LinkNavigation('?page=' . parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
583 583
             array_push($result, $entry);
584 584
         }
585 585
         return $result;
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
     }
676 676
 
677 677
     public static function getBooks($n) {
678
-        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
678
+        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n);
679 679
         return array($entryArray, $totalNumber);
680 680
     }
681 681
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
         {
693 693
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
694 694
                 str_format(localize('bookword', $post->count), $post->count), 'text',
695
-                array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
695
+                array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count));
696 696
         }
697 697
         return $entryArray;
698 698
     }
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
     public static function getAllRecentBooks() {
719 719
         global $config;
720
-        list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
720
+        list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
721 721
         return $entryArray;
722 722
     }
723 723
 
Please login to merge, or discard this patch.
Braces   +101 added lines, -77 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@  discard block
 block discarded – undo
108 108
     public $format = array ();
109 109
     private $coverFileName = NULL;
110 110
 
111
-    public function __construct($line) {
111
+    public function __construct($line)
112
+    {
112 113
     	global $config;
113 114
 
114 115
         $this->id = $line->id;
@@ -168,8 +169,7 @@  discard block
 block discarded – undo
168 169
         		}
169 170
         		if ($cover === false || !file_exists($cover)) {
170 171
         			$this->hasCover = 0;
171
-        		}
172
-        		else {
172
+        		} else {
173 173
         			$this->coverFileName = $cover;
174 174
         		}
175 175
         	}
@@ -190,25 +190,32 @@  discard block
 block discarded – undo
190 190
     	return $res;
191 191
     }
192 192
 
193
-    public function getEntryId() {
193
+    public function getEntryId()
194
+    {
194 195
         return self::ALL_BOOKS_UUID.':'.$this->uuid;
195 196
     }
196 197
 
197
-    public static function getEntryIdByLetter ($startingLetter) {
198
+    public static function getEntryIdByLetter ($startingLetter)
199
+    {
198 200
         return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
199 201
     }
200 202
 
201
-    public function getUri () {
203
+    public function getUri ()
204
+    {
202 205
         return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id;
203 206
     }
204 207
 
205
-    public function getDetailUrl () {
208
+    public function getDetailUrl ()
209
+    {
206 210
         $urlParam = $this->getUri();
207
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
211
+        if (!is_null(GetUrlParam(DB))) {
212
+            $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
213
+        }
208 214
         return 'index.php' . $urlParam;
209 215
     }
210 216
 
211
-    public function getTitle () {
217
+    public function getTitle ()
218
+    {
212 219
         return $this->title;
213 220
     }
214 221
 
@@ -217,22 +224,26 @@  discard block
 block discarded – undo
217 224
     /**
218 225
      * @return Author[]
219 226
      */
220
-    public function getAuthors () {
227
+    public function getAuthors ()
228
+    {
221 229
         if (is_null($this->authors)) {
222 230
             $this->authors = Author::getAuthorByBookId($this->id);
223 231
         }
224 232
         return $this->authors;
225 233
     }
226 234
 
227
-    public function getAuthorsName () {
235
+    public function getAuthorsName ()
236
+    {
228 237
         return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
229 238
     }
230 239
 
231
-    public function getAuthorsSort () {
240
+    public function getAuthorsSort ()
241
+    {
232 242
         return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
233 243
     }
234 244
 
235
-    public function getPublisher () {
245
+    public function getPublisher ()
246
+    {
236 247
         if (is_null($this->publisher)) {
237 248
             $this->publisher = Publisher::getPublisherByBookId($this->id);
238 249
         }
@@ -242,7 +253,8 @@  discard block
 block discarded – undo
242 253
     /**
243 254
      * @return Serie
244 255
      */
245
-    public function getSerie() {
256
+    public function getSerie()
257
+    {
246 258
         if (is_null($this->serie)) {
247 259
             $this->serie = Serie::getSerieByBookId($this->id);
248 260
         }
@@ -252,7 +264,8 @@  discard block
 block discarded – undo
252 264
     /**
253 265
      * @return string
254 266
      */
255
-    public function getLanguages() {
267
+    public function getLanguages()
268
+    {
256 269
         $lang = array();
257 270
         $result = parent::getDb()->prepare('select languages.lang_code
258 271
                 from books_languages_link, languages
@@ -260,8 +273,7 @@  discard block
 block discarded – undo
260 273
                 and book = ?
261 274
                 order by item_order');
262 275
         $result->execute(array($this->id));
263
-        while ($post = $result->fetchObject())
264
-        {
276
+        while ($post = $result->fetchObject()) {
265 277
             array_push($lang, Language::getLanguageString($post->lang_code));
266 278
         }
267 279
         return implode(', ', $lang);
@@ -270,7 +282,8 @@  discard block
 block discarded – undo
270 282
     /**
271 283
      * @return Tag[]
272 284
      */
273
-    public function getTags() {
285
+    public function getTags()
286
+    {
274 287
         if (is_null ($this->tags)) {
275 288
             $this->tags = array();
276 289
 
@@ -280,15 +293,15 @@  discard block
 block discarded – undo
280 293
                 and book = ?
281 294
                 order by name');
282 295
             $result->execute(array($this->id));
283
-            while ($post = $result->fetchObject())
284
-            {
296
+            while ($post = $result->fetchObject()) {
285 297
                 array_push($this->tags, new Tag($post));
286 298
             }
287 299
         }
288 300
         return $this->tags;
289 301
     }
290 302
 
291
-    public function getTagsName() {
303
+    public function getTagsName()
304
+    {
292 305
         return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
293 306
     }
294 307
 
@@ -305,9 +318,12 @@  discard block
 block discarded – undo
305 318
 
306 319
     /* End of other class (author, series, tag, ...) initialization and accessors */
307 320
 
308
-    public static function getFilterString() {
321
+    public static function getFilterString()
322
+    {
309 323
         $filter = getURLParam('tag', NULL);
310
-        if (empty($filter)) return '';
324
+        if (empty($filter)) {
325
+            return '';
326
+        }
311 327
 
312 328
         $exists = true;
313 329
         if (preg_match("/^!(.*)$/", $filter, $matches)) {
@@ -347,7 +363,8 @@  discard block
 block discarded – undo
347 363
         return reset($reduced);
348 364
     }
349 365
 
350
-    public function getRating() {
366
+    public function getRating()
367
+    {
351 368
         if (is_null($this->rating) || $this->rating == 0) {
352 369
             return '';
353 370
         }
@@ -361,7 +378,8 @@  discard block
 block discarded – undo
361 378
         return $retour;
362 379
     }
363 380
 
364
-    public function getPubDate() {
381
+    public function getPubDate()
382
+    {
365 383
         if (empty ($this->pubdate)) {
366 384
             return '';
367 385
         }
@@ -372,23 +390,22 @@  discard block
 block discarded – undo
372 390
         return '';
373 391
     }
374 392
 
375
-    public function getComment($withSerie = true) {
393
+    public function getComment($withSerie = true)
394
+    {
376 395
         $addition = '';
377 396
         $se = $this->getSerie ();
378 397
         if (!is_null ($se) && $withSerie) {
379 398
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
380 399
         }
381
-        if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
382
-        {
400
+        if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) {
383 401
             return $addition . html2xhtml($this->comment);
384
-        }
385
-        else
386
-        {
402
+        } else {
387 403
             return $addition . htmlspecialchars($this->comment);
388 404
         }
389 405
     }
390 406
 
391
-    public function getDataFormat($format) {
407
+    public function getDataFormat($format)
408
+    {
392 409
         $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
393 410
             return $data->format == $format;
394 411
         });
@@ -419,16 +436,14 @@  discard block
 block discarded – undo
419 436
     	if ($extension == "jpg" || $extension == "png") {
420 437
     		if (empty($this->coverFileName)) {
421 438
     			return $this->path . '/cover.' . $extension;
422
-    		}
423
-    		else {
439
+    		} else {
424 440
     			$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
425 441
     			if ($ext == $extension) {
426 442
     				return $this->coverFileName;
427 443
     			}
428 444
     		}
429 445
     		return false;
430
-    	}
431
-    	else {
446
+    	} else {
432 447
     		$data = $this->getDataById($idData);
433 448
     		if (!$data) {
434 449
     			return NULL;
@@ -443,8 +458,7 @@  discard block
 block discarded – undo
443 458
         global $config;
444 459
         $data = $this->getDataById($idData);
445 460
 
446
-        try
447
-        {
461
+        try {
448 462
             $epub = new EPub($data->getLocalPath());
449 463
 
450 464
             $epub->Title($this->title);
@@ -471,14 +485,13 @@  discard block
 block discarded – undo
471 485
                 $filename = $data->getUpdatedFilenameKepub();
472 486
             }
473 487
             $epub->download($filename);
474
-        }
475
-        catch (Exception $e)
476
-        {
488
+        } catch (Exception $e) {
477 489
             echo 'Exception : ' . $e->getMessage();
478 490
         }
479 491
     }
480 492
 
481
-    public function getThumbnail($width, $height, $outputfile = NULL) {
493
+    public function getThumbnail($width, $height, $outputfile = NULL)
494
+    {
482 495
         if (is_null($width) && is_null($height)) {
483 496
             return false;
484 497
         }
@@ -527,17 +540,14 @@  discard block
 block discarded – undo
527 540
         	if ($ext == 'png') {
528 541
         		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
529 542
         		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
530
-        	}
531
-        	else {
543
+        	} else {
532 544
         		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
533 545
         		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
534 546
         	}
535 547
         }
536 548
 
537
-        foreach ($this->getDatas() as $data)
538
-        {
539
-            if ($data->isKnownType())
540
-            {
549
+        foreach ($this->getDatas() as $data) {
550
+            if ($data->isKnownType()) {
541 551
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
542 552
             }
543 553
         }
@@ -556,17 +566,20 @@  discard block
 block discarded – undo
556 566
     }
557 567
 
558 568
 
559
-    public function getEntry() {
569
+    public function getEntry()
570
+    {
560 571
         return new EntryBook($this->getTitle(), $this->getEntryId(),
561 572
             $this->getComment(), 'text/html',
562 573
             $this->getLinkArray(), $this);
563 574
     }
564 575
 
565
-    public static function getBookCount($database = NULL) {
576
+    public static function getBookCount($database = NULL)
577
+    {
566 578
         return parent::executeQuerySingle('select count(*) from books', $database);
567 579
     }
568 580
 
569
-    public static function getCount() {
581
+    public static function getCount()
582
+    {
570 583
         global $config;
571 584
         $nBooks = parent::executeQuerySingle('select count(*) from books');
572 585
         $result = array();
@@ -585,27 +598,33 @@  discard block
 block discarded – undo
585 598
         return $result;
586 599
     }
587 600
 
588
-    public static function getBooksByAuthor($authorId, $n) {
601
+    public static function getBooksByAuthor($authorId, $n)
602
+    {
589 603
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
590 604
     }
591 605
 
592
-    public static function getBooksByRating($ratingId, $n) {
606
+    public static function getBooksByRating($ratingId, $n)
607
+    {
593 608
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
594 609
     }
595 610
 
596
-    public static function getBooksByPublisher($publisherId, $n) {
611
+    public static function getBooksByPublisher($publisherId, $n)
612
+    {
597 613
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
598 614
     }
599 615
 
600
-    public static function getBooksBySeries($serieId, $n) {
616
+    public static function getBooksBySeries($serieId, $n)
617
+    {
601 618
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
602 619
     }
603 620
 
604
-    public static function getBooksByTag($tagId, $n) {
621
+    public static function getBooksByTag($tagId, $n)
622
+    {
605 623
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
606 624
     }
607 625
 
608
-    public static function getBooksByLanguage($languageId, $n) {
626
+    public static function getBooksByLanguage($languageId, $n)
627
+    {
609 628
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
610 629
     }
611 630
 
@@ -615,32 +634,33 @@  discard block
 block discarded – undo
615 634
      * @param $n integer
616 635
      * @return array
617 636
      */
618
-    public static function getBooksByCustom($customColumn, $id, $n) {
637
+    public static function getBooksByCustom($customColumn, $id, $n)
638
+    {
619 639
         list($query, $params) = $customColumn->getQuery($id);
620 640
 
621 641
         return self::getEntryArray($query, $params, $n);
622 642
     }
623 643
 
624
-    public static function getBookById($bookId) {
644
+    public static function getBookById($bookId)
645
+    {
625 646
     	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . '
626 647
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
627 648
 where books.id = ?');
628 649
         $result->execute(array($bookId));
629
-        while ($post = $result->fetchObject())
630
-        {
650
+        while ($post = $result->fetchObject()) {
631 651
             $book = new Book($post);
632 652
             return $book;
633 653
         }
634 654
         return NULL;
635 655
     }
636 656
 
637
-    public static function getBookByDataId($dataId) {
657
+    public static function getBookByDataId($dataId)
658
+    {
638 659
     	$result = parent::getDb()->prepare('select ' . self::getBookColumns() . ', data.name, data.format
639 660
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
640 661
 where data.book = books.id and data.id = ?');
641 662
         $result->execute(array($dataId));
642
-        while ($post = $result->fetchObject())
643
-        {
663
+        while ($post = $result->fetchObject()) {
644 664
             $book = new Book($post);
645 665
             $data = new Data($post, $book);
646 666
             $data->id = $dataId;
@@ -650,7 +670,8 @@  discard block
 block discarded – undo
650 670
         return NULL;
651 671
     }
652 672
 
653
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
673
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
674
+    {
654 675
         $i = 0;
655 676
         $critArray = array();
656 677
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -661,8 +682,7 @@  discard block
 block discarded – undo
661 682
             if (in_array($key, getCurrentOption('ignored_categories')) ||
662 683
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
663 684
                 $critArray[$i] = self::BAD_SEARCH;
664
-            }
665
-            else {
685
+            } else {
666 686
                 if (array_key_exists($key, $query)) {
667 687
                     $critArray[$i] = $query[$key];
668 688
                 } else {
@@ -674,12 +694,14 @@  discard block
 block discarded – undo
674 694
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
675 695
     }
676 696
 
677
-    public static function getBooks($n) {
697
+    public static function getBooks($n)
698
+    {
678 699
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
679 700
         return array($entryArray, $totalNumber);
680 701
     }
681 702
 
682
-    public static function getAllBooks() {
703
+    public static function getAllBooks()
704
+    {
683 705
         /* @var $result PDOStatement */
684 706
 
685 707
         list (, $result) = parent::executeQuery('select {0}
@@ -688,8 +710,7 @@  discard block
 block discarded – undo
688 710
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
689 711
 
690 712
         $entryArray = array();
691
-        while ($post = $result->fetchObject())
692
-        {
713
+        while ($post = $result->fetchObject()) {
693 714
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
694 715
                 str_format(localize('bookword', $post->count), $post->count), 'text',
695 716
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -697,25 +718,27 @@  discard block
 block discarded – undo
697 718
         return $entryArray;
698 719
     }
699 720
 
700
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
721
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
722
+    {
701 723
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
702 724
     }
703 725
 
704
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
726
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
727
+    {
705 728
         /* @var $totalNumber integer */
706 729
         /* @var $result PDOStatement */
707 730
     	list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
708 731
 
709 732
         $entryArray = array();
710
-        while ($post = $result->fetchObject())
711
-        {
733
+        while ($post = $result->fetchObject()) {
712 734
             $book = new Book($post);
713 735
             array_push($entryArray, $book->getEntry());
714 736
         }
715 737
         return array($entryArray, $totalNumber);
716 738
     }
717 739
 
718
-    public static function getAllRecentBooks() {
740
+    public static function getAllRecentBooks()
741
+    {
719 742
         global $config;
720 743
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
721 744
         return $entryArray;
@@ -727,7 +750,8 @@  discard block
 block discarded – undo
727 750
      * @param string[] $columns
728 751
      * @return CustomColumn[]
729 752
      */
730
-    public function getCustomColumnValues($columns, $asArray = false) {
753
+    public function getCustomColumnValues($columns, $asArray = false)
754
+    {
731 755
         $result = array();
732 756
 
733 757
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -99,14 +99,14 @@  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
-    private $coverFileName = NULL;
109
+    private $coverFileName = null;
110 110
 
111 111
     public function __construct($line) {
112 112
     	global $config;
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         		$imgDirectory = Base::getImgDirectory();
137 137
         		$this->coverFileName = $line->cover;
138 138
         		if (!file_exists($this->coverFileName)) {
139
-        			$this->coverFileName = NULL;
139
+        			$this->coverFileName = null;
140 140
         		}
141 141
         		if (empty($this->coverFileName)) {
142 142
         			$this->coverFileName = sprintf('%s%s', $imgDirectory, $line->cover);
143 143
         			if (!file_exists($this->coverFileName)) {
144
-        				$this->coverFileName = NULL;
144
+        				$this->coverFileName = null;
145 145
         			}
146 146
         		}
147 147
         		if (empty($this->coverFileName)) {
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
         			if ($data) {
150 150
         				$this->coverFileName = sprintf('%s%s/%s', $imgDirectory, $data->name, $line->cover);
151 151
         				if (!file_exists($this->coverFileName)) {
152
-        					$this->coverFileName = NULL;
152
+        					$this->coverFileName = null;
153 153
         				}
154 154
         				if (empty($this->coverFileName)) {
155 155
         					$this->coverFileName = sprintf('%s%s.jpg', $imgDirectory, $data->name);
156 156
         					if (!file_exists($this->coverFileName)) {
157
-        						$this->coverFileName = NULL;
157
+        						$this->coverFileName = null;
158 158
         					}
159 159
         				}
160 160
         			}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     /* End of other class (author, series, tag, ...) initialization and accessors */
307 307
 
308 308
     public static function getFilterString() {
309
-        $filter = getURLParam('tag', NULL);
309
+        $filter = getURLParam('tag', null);
310 310
         if (empty($filter)) return '';
311 311
 
312 312
         $exists = true;
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
     {
329 329
         $bestFormatForKindle = array('EPUB', 'PDF', 'AZW3', 'MOBI');
330 330
         $bestRank = -1;
331
-        $bestData = NULL;
331
+        $bestData = null;
332 332
         foreach ($this->getDatas() as $data) {
333 333
             $key = array_search($data->format, $bestFormatForKindle);
334 334
             if ($key !== false && $key > $bestRank) {
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         return reset($reduced);
396 396
     }
397 397
 
398
-    public function getFilePath($extension, $idData = NULL, $relative = false)
398
+    public function getFilePath($extension, $idData = null, $relative = false)
399 399
     {
400 400
         /*if ($extension == 'jpg')
401 401
         {
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     	else {
432 432
     		$data = $this->getDataById($idData);
433 433
     		if (!$data) {
434
-    			return NULL;
434
+    			return null;
435 435
     		}
436 436
     		$file = $data->name . "." . strtolower($data->format);
437 437
     		return $this->path . '/' . $file;
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         }
479 479
     }
480 480
 
481
-    public function getThumbnail($width, $height, $outputfile = NULL) {
481
+    public function getThumbnail($width, $height, $outputfile = null) {
482 482
         if (is_null($width) && is_null($height)) {
483 483
             return false;
484 484
         }
@@ -525,12 +525,12 @@  discard block
 block discarded – undo
525 525
         	//array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
526 526
         	$ext = strtolower(pathinfo($this->coverFileName, PATHINFO_EXTENSION));
527 527
         	if ($ext == 'png') {
528
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", NULL));
529
-        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", NULL));
528
+        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_IMAGE_TYPE, "cover.png", null));
529
+        		array_push($linkArray, Data::getLink($this, "png", "image/png", Link::OPDS_THUMBNAIL_TYPE, "cover.png", null));
530 530
         	}
531 531
         	else {
532
-        		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
533
-        		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
532
+        		array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', null));
533
+        		array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", null));
534 534
         	}
535 535
         }
536 536
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
             $this->getLinkArray(), $this);
563 563
     }
564 564
 
565
-    public static function getBookCount($database = NULL) {
565
+    public static function getBookCount($database = null) {
566 566
         return parent::executeQuerySingle('select count(*) from books', $database);
567 567
     }
568 568
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             $book = new Book($post);
632 632
             return $book;
633 633
         }
634
-        return NULL;
634
+        return null;
635 635
     }
636 636
 
637 637
     public static function getBookByDataId($dataId) {
@@ -647,10 +647,10 @@  discard block
 block discarded – undo
647 647
             $book->datas = array($data);
648 648
             return $book;
649 649
         }
650
-        return NULL;
650
+        return null;
651 651
     }
652 652
 
653
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
653
+    public static function getBooksByQuery($query, $n, $database = null, $numberPerPage = null) {
654 654
         $i = 0;
655 655
         $critArray = array();
656 656
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
         return $entryArray;
698 698
     }
699 699
 
700
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
700
+    public static function getBooksByStartingLetter($letter, $n, $database = null, $numberPerPage = null) {
701 701
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
702 702
     }
703 703
 
704
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
704
+    public static function getEntryArray($query, $params, $n, $database = null, $numberPerPage = null) {
705 705
         /* @var $totalNumber integer */
706 706
         /* @var $result PDOStatement */
707 707
     	list($totalNumber, $result) = parent::executeQuery($query, self::getBookColumns(), self::getFilterString(), $params, $n, $database, $numberPerPage);
Please login to merge, or discard this patch.
lib/Base.php 4 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,13 +99,13 @@
 block discarded – undo
99 99
 
100 100
     // -DC- Add image directory
101 101
     public static function getImgDirectory ($database = NULL) {
102
-    	global $config;
103
-    	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
-    		$array = array_values ($config['image_directory']);
106
-    		return  $array[$database];
107
-    	}
108
-    	return $config['image_directory'];
102
+        global $config;
103
+        if (self::isMultipleDatabaseEnabled ()) {
104
+            if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
+            $array = array_values ($config['image_directory']);
106
+            return  $array[$database];
107
+        }
108
+        return $config['image_directory'];
109 109
     }
110 110
 
111 111
     public static function getDbFileName ($database = NULL) {
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -37,156 +37,156 @@  discard block
 block discarded – undo
37 37
 
38 38
     private static $db = NULL;
39 39
 
40
-    public static function isMultipleDatabaseEnabled () {
40
+    public static function isMultipleDatabaseEnabled() {
41 41
         global $config;
42
-        return is_array ($config['calibre_directory']);
42
+        return is_array($config['calibre_directory']);
43 43
     }
44 44
 
45
-    public static function useAbsolutePath () {
45
+    public static function useAbsolutePath() {
46 46
         global $config;
47 47
         $path = self::getDbDirectory();
48
-        return preg_match ('/^\//', $path) || // Linux /
49
-               preg_match ('/^\w\:/', $path); // Windows X:
48
+        return preg_match('/^\//', $path) || // Linux /
49
+               preg_match('/^\w\:/', $path); // Windows X:
50 50
     }
51 51
 
52
-    public static function noDatabaseSelected () {
53
-        return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
52
+    public static function noDatabaseSelected() {
53
+        return self::isMultipleDatabaseEnabled() && is_null(GetUrlParam(DB));
54 54
     }
55 55
 
56
-    public static function getDbList () {
56
+    public static function getDbList() {
57 57
         global $config;
58
-        if (self::isMultipleDatabaseEnabled ()) {
58
+        if (self::isMultipleDatabaseEnabled()) {
59 59
             return $config['calibre_directory'];
60 60
         } else {
61
-            return array ("" => $config['calibre_directory']);
61
+            return array("" => $config['calibre_directory']);
62 62
         }
63 63
     }
64 64
 
65
-    public static function getDbNameList () {
65
+    public static function getDbNameList() {
66 66
         global $config;
67
-        if (self::isMultipleDatabaseEnabled ()) {
68
-            return array_keys ($config['calibre_directory']);
67
+        if (self::isMultipleDatabaseEnabled()) {
68
+            return array_keys($config['calibre_directory']);
69 69
         } else {
70
-            return array ("");
70
+            return array("");
71 71
         }
72 72
     }
73 73
 
74
-    public static function getDbName ($database = NULL) {
74
+    public static function getDbName($database = NULL) {
75 75
         global $config;
76
-        if (self::isMultipleDatabaseEnabled ()) {
77
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
76
+        if (self::isMultipleDatabaseEnabled()) {
77
+            if (is_null($database)) $database = GetUrlParam(DB, 0);
78 78
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
79
-                self::error ($database);
79
+                self::error($database);
80 80
             }
81
-            $array = array_keys ($config['calibre_directory']);
81
+            $array = array_keys($config['calibre_directory']);
82 82
             return  $array[$database];
83 83
         }
84 84
         return "";
85 85
     }
86 86
 
87
-    public static function getDbDirectory ($database = NULL) {
87
+    public static function getDbDirectory($database = NULL) {
88 88
         global $config;
89
-        if (self::isMultipleDatabaseEnabled ()) {
90
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
89
+        if (self::isMultipleDatabaseEnabled()) {
90
+            if (is_null($database)) $database = GetUrlParam(DB, 0);
91 91
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
92
-                self::error ($database);
92
+                self::error($database);
93 93
             }
94
-            $array = array_values ($config['calibre_directory']);
94
+            $array = array_values($config['calibre_directory']);
95 95
             return  $array[$database];
96 96
         }
97 97
         return $config['calibre_directory'];
98 98
     }
99 99
 
100 100
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
101
+    public static function getImgDirectory($database = NULL) {
102 102
     	global $config;
103
-    	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
-    		$array = array_values ($config['image_directory']);
103
+    	if (self::isMultipleDatabaseEnabled()) {
104
+    		if (is_null($database)) $database = GetUrlParam(DB, 0);
105
+    		$array = array_values($config['image_directory']);
106 106
     		return  $array[$database];
107 107
     	}
108 108
     	return $config['image_directory'];
109 109
     }
110 110
 
111
-    public static function getDbFileName ($database = NULL) {
112
-        return self::getDbDirectory ($database) .'metadata.db';
111
+    public static function getDbFileName($database = NULL) {
112
+        return self::getDbDirectory($database) . 'metadata.db';
113 113
     }
114 114
 
115
-    private static function error ($database) {
115
+    private static function error($database) {
116 116
         if (php_sapi_name() != "cli") {
117 117
             header("location: checkconfig.php?err=1");
118 118
         }
119 119
         throw new Exception("Database <{$database}> not found.");
120 120
     }
121 121
 
122
-    public static function getDb ($database = NULL) {
123
-        if (is_null (self::$db)) {
122
+    public static function getDb($database = NULL) {
123
+        if (is_null(self::$db)) {
124 124
             try {
125
-                if (is_readable (self::getDbFileName ($database))) {
126
-                    self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
127
-                    if (useNormAndUp ()) {
128
-                        self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1);
125
+                if (is_readable(self::getDbFileName($database))) {
126
+                    self::$db = new PDO('sqlite:' . self::getDbFileName($database));
127
+                    if (useNormAndUp()) {
128
+                        self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1);
129 129
                     }
130 130
                 } else {
131
-                    self::error ($database);
131
+                    self::error($database);
132 132
                 }
133 133
             } catch (Exception $e) {
134
-                self::error ($database);
134
+                self::error($database);
135 135
             }
136 136
         }
137 137
         return self::$db;
138 138
     }
139 139
 
140
-    public static function checkDatabaseAvailability () {
141
-        if (self::noDatabaseSelected ()) {
142
-            for ($i = 0; $i < count (self::getDbList ()); $i++) {
143
-                self::getDb ($i);
144
-                self::clearDb ();
140
+    public static function checkDatabaseAvailability() {
141
+        if (self::noDatabaseSelected()) {
142
+            for ($i = 0; $i < count(self::getDbList()); $i++) {
143
+                self::getDb($i);
144
+                self::clearDb();
145 145
             }
146 146
         } else {
147
-            self::getDb ();
147
+            self::getDb();
148 148
         }
149 149
         return true;
150 150
     }
151 151
 
152
-    public static function clearDb () {
152
+    public static function clearDb() {
153 153
         self::$db = NULL;
154 154
     }
155 155
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
157
-        return self::getDb ($database)->query($query)->fetchColumn();
156
+    public static function executeQuerySingle($query, $database = NULL) {
157
+        return self::getDb($database)->query($query)->fetchColumn();
158 158
     }
159 159
 
160 160
     public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
161 161
         if (!$numberOfString) {
162 162
             $numberOfString = $table . ".alphabetical";
163 163
         }
164
-        $count = self::executeQuerySingle ('select count(*) from ' . $table);
164
+        $count = self::executeQuerySingle('select count(*) from ' . $table);
165 165
         if ($count == 0) return NULL;
166
-        $entry = new Entry (localize($table . ".title"), $id,
167
-            str_format (localize($numberOfString, $count), $count), "text",
168
-            array ( new LinkNavigation ("?page=".$pageId)), "", $count);
166
+        $entry = new Entry(localize($table . ".title"), $id,
167
+            str_format(localize($numberOfString, $count), $count), "text",
168
+            array(new LinkNavigation("?page=" . $pageId)), "", $count);
169 169
         return $entry;
170 170
     }
171 171
 
172
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
172
+    public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) {
173 173
         /* @var $result PDOStatement */
174 174
 
175
-        list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
175
+        list (, $result) = self::executeQuery($query, $columns, "", $params, -1);
176 176
         $entryArray = array();
177
-        while ($post = $result->fetchObject ())
177
+        while ($post = $result->fetchObject())
178 178
         {
179 179
             /* @var $instance Author|Tag|Serie|Publisher */
180 180
 
181
-            $instance = new $category ($post);
181
+            $instance = new $category($post);
182 182
             if (property_exists($post, "sort")) {
183 183
                 $title = $post->sort;
184 184
             } else {
185 185
                 $title = $post->name;
186 186
             }
187
-            array_push ($entryArray, new Entry ($title, $instance->getEntryId (),
188
-                str_format (localize("bookword", $post->count), $post->count), "text",
189
-                array ( new LinkNavigation ($instance->getUri ())), "", $post->count));
187
+            array_push($entryArray, new Entry($title, $instance->getEntryId(),
188
+                str_format(localize("bookword", $post->count), $post->count), "text",
189
+                array(new LinkNavigation($instance->getUri())), "", $post->count));
190 190
         }
191 191
         return $entryArray;
192 192
     }
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
     public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
195 195
         $totalResult = -1;
196 196
 
197
-        if (useNormAndUp ()) {
197
+        if (useNormAndUp()) {
198 198
             $query = preg_replace("/upper/", "normAndUp", $query);
199 199
             $columns = preg_replace("/upper/", "normAndUp", $columns);
200 200
         }
201 201
 
202
-        if (is_null ($numberPerPage)) {
203
-            $numberPerPage = getCurrentOption ("max_item_per_page");
202
+        if (is_null($numberPerPage)) {
203
+            $numberPerPage = getCurrentOption("max_item_per_page");
204 204
         }
205 205
 
206 206
         if ($numberPerPage != -1 && $n != -1)
207 207
         {
208 208
             // First check total number of results
209
-            $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
210
-            $result->execute ($params);
211
-            $totalResult = $result->fetchColumn ();
209
+            $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter));
210
+            $result->execute($params);
211
+            $totalResult = $result->fetchColumn();
212 212
 
213 213
             // Next modify the query and params
214 214
             $query .= " limit ?, ?";
215
-            array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage);
215
+            array_push($params, ($n - 1) * $numberPerPage, $numberPerPage);
216 216
         }
217 217
 
218
-        $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter));
219
-        $result->execute ($params);
220
-        return array ($totalResult, $result);
218
+        $result = self::getDb($database)->prepare(str_format($query, $columns, $filter));
219
+        $result->execute($params);
220
+        return array($totalResult, $result);
221 221
     }
222 222
 
223 223
 }
Please login to merge, or discard this patch.
Braces   +48 added lines, -25 removed lines patch added patch discarded remove patch
@@ -37,23 +37,27 @@  discard block
 block discarded – undo
37 37
 
38 38
     private static $db = NULL;
39 39
 
40
-    public static function isMultipleDatabaseEnabled () {
40
+    public static function isMultipleDatabaseEnabled ()
41
+    {
41 42
         global $config;
42 43
         return is_array ($config['calibre_directory']);
43 44
     }
44 45
 
45
-    public static function useAbsolutePath () {
46
+    public static function useAbsolutePath ()
47
+    {
46 48
         global $config;
47 49
         $path = self::getDbDirectory();
48 50
         return preg_match ('/^\//', $path) || // Linux /
49 51
                preg_match ('/^\w\:/', $path); // Windows X:
50 52
     }
51 53
 
52
-    public static function noDatabaseSelected () {
54
+    public static function noDatabaseSelected ()
55
+    {
53 56
         return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
54 57
     }
55 58
 
56
-    public static function getDbList () {
59
+    public static function getDbList ()
60
+    {
57 61
         global $config;
58 62
         if (self::isMultipleDatabaseEnabled ()) {
59 63
             return $config['calibre_directory'];
@@ -62,7 +66,8 @@  discard block
 block discarded – undo
62 66
         }
63 67
     }
64 68
 
65
-    public static function getDbNameList () {
69
+    public static function getDbNameList ()
70
+    {
66 71
         global $config;
67 72
         if (self::isMultipleDatabaseEnabled ()) {
68 73
             return array_keys ($config['calibre_directory']);
@@ -71,10 +76,13 @@  discard block
 block discarded – undo
71 76
         }
72 77
     }
73 78
 
74
-    public static function getDbName ($database = NULL) {
79
+    public static function getDbName ($database = NULL)
80
+    {
75 81
         global $config;
76 82
         if (self::isMultipleDatabaseEnabled ()) {
77
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
83
+            if (is_null ($database)) {
84
+                $database = GetUrlParam (DB, 0);
85
+            }
78 86
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
79 87
                 self::error ($database);
80 88
             }
@@ -84,10 +92,13 @@  discard block
 block discarded – undo
84 92
         return "";
85 93
     }
86 94
 
87
-    public static function getDbDirectory ($database = NULL) {
95
+    public static function getDbDirectory ($database = NULL)
96
+    {
88 97
         global $config;
89 98
         if (self::isMultipleDatabaseEnabled ()) {
90
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
99
+            if (is_null ($database)) {
100
+                $database = GetUrlParam (DB, 0);
101
+            }
91 102
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
92 103
                 self::error ($database);
93 104
             }
@@ -98,28 +109,34 @@  discard block
 block discarded – undo
98 109
     }
99 110
 
100 111
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
112
+    public static function getImgDirectory ($database = NULL)
113
+    {
102 114
     	global $config;
103 115
     	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
116
+    		if (is_null ($database)) {
117
+    		    $database = GetUrlParam (DB, 0);
118
+    		}
105 119
     		$array = array_values ($config['image_directory']);
106 120
     		return  $array[$database];
107 121
     	}
108 122
     	return $config['image_directory'];
109 123
     }
110 124
 
111
-    public static function getDbFileName ($database = NULL) {
125
+    public static function getDbFileName ($database = NULL)
126
+    {
112 127
         return self::getDbDirectory ($database) .'metadata.db';
113 128
     }
114 129
 
115
-    private static function error ($database) {
130
+    private static function error ($database)
131
+    {
116 132
         if (php_sapi_name() != "cli") {
117 133
             header("location: checkconfig.php?err=1");
118 134
         }
119 135
         throw new Exception("Database <{$database}> not found.");
120 136
     }
121 137
 
122
-    public static function getDb ($database = NULL) {
138
+    public static function getDb ($database = NULL)
139
+    {
123 140
         if (is_null (self::$db)) {
124 141
             try {
125 142
                 if (is_readable (self::getDbFileName ($database))) {
@@ -137,7 +154,8 @@  discard block
 block discarded – undo
137 154
         return self::$db;
138 155
     }
139 156
 
140
-    public static function checkDatabaseAvailability () {
157
+    public static function checkDatabaseAvailability ()
158
+    {
141 159
         if (self::noDatabaseSelected ()) {
142 160
             for ($i = 0; $i < count (self::getDbList ()); $i++) {
143 161
                 self::getDb ($i);
@@ -149,33 +167,38 @@  discard block
 block discarded – undo
149 167
         return true;
150 168
     }
151 169
 
152
-    public static function clearDb () {
170
+    public static function clearDb ()
171
+    {
153 172
         self::$db = NULL;
154 173
     }
155 174
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
175
+    public static function executeQuerySingle ($query, $database = NULL)
176
+    {
157 177
         return self::getDb ($database)->query($query)->fetchColumn();
158 178
     }
159 179
 
160
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
180
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL)
181
+    {
161 182
         if (!$numberOfString) {
162 183
             $numberOfString = $table . ".alphabetical";
163 184
         }
164 185
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
165
-        if ($count == 0) return NULL;
186
+        if ($count == 0) {
187
+            return NULL;
188
+        }
166 189
         $entry = new Entry (localize($table . ".title"), $id,
167 190
             str_format (localize($numberOfString, $count), $count), "text",
168 191
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
169 192
         return $entry;
170 193
     }
171 194
 
172
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
195
+    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category)
196
+    {
173 197
         /* @var $result PDOStatement */
174 198
 
175 199
         list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
176 200
         $entryArray = array();
177
-        while ($post = $result->fetchObject ())
178
-        {
201
+        while ($post = $result->fetchObject ()) {
179 202
             /* @var $instance Author|Tag|Serie|Publisher */
180 203
 
181 204
             $instance = new $category ($post);
@@ -191,7 +214,8 @@  discard block
 block discarded – undo
191 214
         return $entryArray;
192 215
     }
193 216
 
194
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
217
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL)
218
+    {
195 219
         $totalResult = -1;
196 220
 
197 221
         if (useNormAndUp ()) {
@@ -203,8 +227,7 @@  discard block
 block discarded – undo
203 227
             $numberPerPage = getCurrentOption ("max_item_per_page");
204 228
         }
205 229
 
206
-        if ($numberPerPage != -1 && $n != -1)
207
-        {
230
+        if ($numberPerPage != -1 && $n != -1) {
208 231
             // First check total number of results
209 232
             $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
210 233
             $result->execute ($params);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     const COMPATIBILITY_XML_ALDIKO = "aldiko";
37 37
 
38
-    private static $db = NULL;
38
+    private static $db = null;
39 39
 
40 40
     public static function isMultipleDatabaseEnabled () {
41 41
         global $config;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         }
72 72
     }
73 73
 
74
-    public static function getDbName ($database = NULL) {
74
+    public static function getDbName ($database = null) {
75 75
         global $config;
76 76
         if (self::isMultipleDatabaseEnabled ()) {
77 77
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         return "";
85 85
     }
86 86
 
87
-    public static function getDbDirectory ($database = NULL) {
87
+    public static function getDbDirectory ($database = null) {
88 88
         global $config;
89 89
         if (self::isMultipleDatabaseEnabled ()) {
90 90
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
101
+    public static function getImgDirectory ($database = null) {
102 102
     	global $config;
103 103
     	if (self::isMultipleDatabaseEnabled ()) {
104 104
     		if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     	return $config['image_directory'];
109 109
     }
110 110
 
111
-    public static function getDbFileName ($database = NULL) {
111
+    public static function getDbFileName ($database = null) {
112 112
         return self::getDbDirectory ($database) .'metadata.db';
113 113
     }
114 114
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         throw new Exception("Database <{$database}> not found.");
120 120
     }
121 121
 
122
-    public static function getDb ($database = NULL) {
122
+    public static function getDb ($database = null) {
123 123
         if (is_null (self::$db)) {
124 124
             try {
125 125
                 if (is_readable (self::getDbFileName ($database))) {
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
     }
151 151
 
152 152
     public static function clearDb () {
153
-        self::$db = NULL;
153
+        self::$db = null;
154 154
     }
155 155
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
156
+    public static function executeQuerySingle ($query, $database = null) {
157 157
         return self::getDb ($database)->query($query)->fetchColumn();
158 158
     }
159 159
 
160
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
160
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = null) {
161 161
         if (!$numberOfString) {
162 162
             $numberOfString = $table . ".alphabetical";
163 163
         }
164 164
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
165
-        if ($count == 0) return NULL;
165
+        if ($count == 0) return null;
166 166
         $entry = new Entry (localize($table . ".title"), $id,
167 167
             str_format (localize($numberOfString, $count), $count), "text",
168 168
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         return $entryArray;
192 192
     }
193 193
 
194
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
194
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) {
195 195
         $totalResult = -1;
196 196
 
197 197
         if (useNormAndUp ()) {
Please login to merge, or discard this patch.
fetch.php 4 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
     // -DC- Add png type
43 43
     if ($book && ($type == 'jpg' || $type == 'png' || empty ($config['calibre_internal_directory']))) {
44
-    	  if ($type == 'jpg' || $type == 'png') {
44
+            if ($type == 'jpg' || $type == 'png') {
45 45
             $file = $book->getFilePath($type);
46 46
         } else {
47 47
             $file = $book->getFilePath($type, $idData);
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 
55 55
     switch ($type)
56 56
     {
57
-    		// -DC- Add png type
57
+            // -DC- Add png type
58 58
         case 'jpg':
59 59
         case 'png':
60
-        		if ($type == 'jpg') {
61
-          	  header('Content-Type: image/jpeg');
62
-        		}
63
-        		else {
64
-        			header('Content-Type: image/png');
65
-        		}
60
+                if ($type == 'jpg') {
61
+                header('Content-Type: image/jpeg');
62
+                }
63
+                else {
64
+                    header('Content-Type: image/png');
65
+                }
66 66
             //by default, we don't cache
67 67
             $thumbnailCacheFullpath = null;
68 68
             if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
Please login to merge, or discard this patch.
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: max-age=' . $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);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     if (!$book) {
38
-        notFound ();
38
+        notFound();
39 39
         return;
40 40
     }
41 41
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
         		}
66 66
             //by default, we don't cache
67 67
             $thumbnailCacheFullpath = null;
68
-            if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
68
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
69 69
                 $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
70 70
                 //if multiple databases, add a subfolder with the database ID
71
-                $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : '';
71
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
72 72
                 //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
73 73
                 //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
74 74
                 $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
75 75
                 //check if cache folder exists or create it
76
-                if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) {
76
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
77 77
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
78 78
                     $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.' . $type;
79 79
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
@@ -83,20 +83,20 @@  discard block
 block discarded – undo
83 83
                 }
84 84
             }
85 85
 
86
-            if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) {
86
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
87 87
                 //return the already cached thumbnail
88
-                readfile( $thumbnailCacheFullpath );
88
+                readfile($thumbnailCacheFullpath);
89 89
                 return;
90 90
             }
91 91
 
92
-            if ($book->getThumbnail (getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) {
92
+            if ($book->getThumbnail(getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) {
93 93
                 //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
94
-                if ( $thumbnailCacheFullpath === null ) {
94
+                if ($thumbnailCacheFullpath === null) {
95 95
                     // The cover had to be resized
96 96
                     return;
97 97
                 } else {
98 98
                     //return the just cached thumbnail
99
-                    readfile( $thumbnailCacheFullpath );
99
+                    readfile($thumbnailCacheFullpath);
100 100
                     return;
101 101
                 }
102 102
             }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,15 +52,13 @@
 block discarded – undo
52 52
         }
53 53
     }
54 54
 
55
-    switch ($type)
56
-    {
55
+    switch ($type) {
57 56
     		// -DC- Add png type
58 57
         case 'jpg':
59 58
         case 'png':
60 59
         		if ($type == 'jpg') {
61 60
           	  header('Content-Type: image/jpeg');
62
-        		}
63
-        		else {
61
+        		} else {
64 62
         			header('Content-Type: image/png');
65 63
         		}
66 64
             //by default, we don't cache
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
     header('Pragma: public');
24 24
     header('Cache-Control: max-age=' . $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);
29
-    $viewOnly = getURLParam('view', FALSE);
28
+    $idData   = getURLParam('data', null);
29
+    $viewOnly = getURLParam('view', false);
30 30
 
31 31
     if (is_null($bookId)) {
32 32
         $book = Book::getBookByDataId($idData);
Please login to merge, or discard this patch.
lib/Tag.php 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -54,6 +54,10 @@
 block discarded – undo
54 54
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 55
     }
56 56
 
57
+    /**
58
+     * @param string $query
59
+     * @param integer $numberPerPage
60
+     */
57 61
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
58 62
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 63
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@
 block discarded – undo
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46
-    	global $config;
46
+        global $config;
47 47
 
48
-    	$sql = self::SQL_ALL_TAGS;
49
-    	$sortField = $config['calibre_database_field_sort'];
50
-    	if (!empty($sortField)) {
51
-    		$sql = str_replace('tags.name', 'tags.' . $sortField, $sql);
52
-    	}
48
+        $sql = self::SQL_ALL_TAGS;
49
+        $sortField = $config['calibre_database_field_sort'];
50
+        if (!empty($sortField)) {
51
+            $sql = str_replace('tags.name', 'tags.' . $sortField, $sql);
52
+        }
53 53
 
54 54
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 55
     }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,24 +20,24 @@  discard block
 block discarded – undo
20 20
         $this->name = $post->name;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . parent::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 parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
33
+        return parent::getCountGeneric("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 34
     }
35 35
 
36
-    public static function getTagById ($tagId) {
37
-        $result = parent::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 = parent::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
     }
@@ -51,21 +51,21 @@  discard block
 block discarded – undo
51 51
     		$sql = str_replace('tags.name', 'tags.' . $sortField, $sql);
52 52
     	}
53 53
 
54
-        return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
54
+        return Base::getEntryArrayWithBookNumber($sql, self::TAG_COLUMNS, array(), "Tag");
55 55
     }
56 56
 
57 57
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
58
-        $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
58
+        $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 59
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
60
-        list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
60
+        list ($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
61 61
         $entryArray = array();
62
-        while ($post = $result->fetchObject ())
62
+        while ($post = $result->fetchObject())
63 63
         {
64
-            $tag = new Tag ($post);
65
-            array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
66
-                str_format (localize("bookword", $post->count), $post->count), "text",
67
-                array ( new LinkNavigation ($tag->getUri ()))));
64
+            $tag = new Tag($post);
65
+            array_push($entryArray, new Entry($tag->name, $tag->getEntryId(),
66
+                str_format(localize("bookword", $post->count), $post->count), "text",
67
+                array(new LinkNavigation($tag->getUri()))));
68 68
         }
69
-        return array ($entryArray, $totalNumber);
69
+        return array($entryArray, $totalNumber);
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,25 +15,30 @@  discard block
 block discarded – undo
15 15
     public $id;
16 16
     public $name;
17 17
 
18
-    public function __construct($post) {
18
+    public function __construct($post)
19
+    {
19 20
         $this->id = $post->id;
20 21
         $this->name = $post->name;
21 22
     }
22 23
 
23
-    public function getUri () {
24
+    public function getUri ()
25
+    {
24 26
         return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
25 27
     }
26 28
 
27
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
28 31
         return self::ALL_TAGS_ID.":".$this->id;
29 32
     }
30 33
 
31
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
32 36
         // str_format (localize("tags.alphabetical", count(array))
33 37
         return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 38
     }
35 39
 
36
-    public static function getTagById ($tagId) {
40
+    public static function getTagById ($tagId)
41
+    {
37 42
         $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38 43
         $result->execute (array ($tagId));
39 44
         if ($post = $result->fetchObject ()) {
@@ -42,7 +47,8 @@  discard block
 block discarded – undo
42 47
         return NULL;
43 48
     }
44 49
 
45
-    public static function getAllTags() {
50
+    public static function getAllTags()
51
+    {
46 52
     	global $config;
47 53
 
48 54
     	$sql = self::SQL_ALL_TAGS;
@@ -54,13 +60,13 @@  discard block
 block discarded – undo
54 60
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 61
     }
56 62
 
57
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
63
+    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
64
+    {
58 65
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 66
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
60 67
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
61 68
         $entryArray = array();
62
-        while ($post = $result->fetchObject ())
63
-        {
69
+        while ($post = $result->fetchObject ()) {
64 70
             $tag = new Tag ($post);
65 71
             array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
66 72
                 str_format (localize("bookword", $post->count), $post->count), "text",
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         if ($post = $result->fetchObject ()) {
40 40
             return new Tag ($post);
41 41
         }
42
-        return NULL;
42
+        return null;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         return Base::getEntryArrayWithBookNumber ($sql, self::TAG_COLUMNS, array (), "Tag");
55 55
     }
56 56
 
57
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
57
+    public static function getAllTagsByQuery($query, $n, $database = null, $numberPerPage = null) {
58 58
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
59 59
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
60 60
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
Please login to merge, or discard this patch.