Completed
Push — master ( d9ae77...ee63f9 )
by Markus
04:15
created
lib/Rating.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     const ALL_RATING_ID = "cops:rating";
12 12
 
13 13
     const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
14
-    const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
14
+    const SQL_ALL_RATINGS = "select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
15 15
     public $id;
16 16
     public $name;
17 17
 
@@ -20,41 +20,41 @@  discard block
 block discarded – undo
20 20
         $this->name = $pname;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".Base::PAGE_RATING_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . Base::PAGE_RATING_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_RATING_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_RATING_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("ratings", count(array))
33
-        return Base::getCountGeneric ("ratings", self::ALL_RATING_ID, Base::PAGE_ALL_RATINGS, "ratings");
33
+        return Base::getCountGeneric("ratings", self::ALL_RATING_ID, Base::PAGE_ALL_RATINGS, "ratings");
34 34
     }
35 35
 
36 36
     public static function getAllRatings() {
37
-        return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
37
+        return self::getEntryArray(self::SQL_ALL_RATINGS, array());
38 38
     }
39 39
 
40
-    public static function getEntryArray ($query, $params) {
41
-        list (, $result) = Base::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
40
+    public static function getEntryArray($query, $params) {
41
+        list (, $result) = Base::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
42 42
         $entryArray = array();
43
-        while ($post = $result->fetchObject ())
43
+        while ($post = $result->fetchObject())
44 44
         {
45
-            $ratingObj = new Rating ($post->id, $post->rating);
46
-            $rating=$post->rating/2;
47
-            $rating = str_format (localize("ratingword", $rating), $rating);
48
-            array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (),
49
-                str_format (localize("bookword", $post->count), $post->count), "text",
50
-                array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count));
45
+            $ratingObj = new Rating($post->id, $post->rating);
46
+            $rating = $post->rating / 2;
47
+            $rating = str_format(localize("ratingword", $rating), $rating);
48
+            array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(),
49
+                str_format(localize("bookword", $post->count), $post->count), "text",
50
+                array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
51 51
         }
52 52
         return $entryArray;
53 53
     }
54 54
 
55
-    public static function getRatingById ($ratingId) {
56
-        $result = Base::getDb ()->prepare('select rating from ratings where id = ?');
57
-        $result->execute (array ($ratingId));
58
-        return new Rating ($ratingId, $result->fetchColumn ());
55
+    public static function getRatingById($ratingId) {
56
+        $result = Base::getDb()->prepare('select rating from ratings where id = ?');
57
+        $result->execute(array($ratingId));
58
+        return new Rating($ratingId, $result->fetchColumn());
59 59
     }
60 60
 }
Please login to merge, or discard this patch.
epubreader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 
16 16
 $idData = getURLParam('data', NULL);
17 17
 $add = 'data=' . $idData . '&';
18
-if (!is_null (GetUrlParam (DB))) {
19
-    $add .= DB . '=' . GetUrlParam (DB) . '&';
18
+if (!is_null(GetUrlParam(DB))) {
19
+    $add .= DB . '=' . GetUrlParam(DB) . '&';
20 20
 }
21 21
 $myBook = Book::getBookByDataId($idData);
22 22
 
Please login to merge, or discard this patch.
lib/Base.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
     public static function isMultipleDatabaseEnabled()
41 41
     {
42 42
         global $config;
43
-        return is_array ($config['calibre_directory']);
43
+        return is_array($config['calibre_directory']);
44 44
     }
45 45
 
46 46
     public static function useAbsolutePath()
47 47
     {
48 48
         global $config;
49 49
         $path = self::getDbDirectory();
50
-        return preg_match ('/^\//', $path) || // Linux /
51
-               preg_match ('/^\w\:/', $path); // Windows X:
50
+        return preg_match('/^\//', $path) || // Linux /
51
+               preg_match('/^\w\:/', $path); // Windows X:
52 52
     }
53 53
 
54 54
     public static function noDatabaseSelected()
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     {
71 71
         global $config;
72 72
         if (self::isMultipleDatabaseEnabled()) {
73
-            return array_keys ($config['calibre_directory']);
73
+            return array_keys($config['calibre_directory']);
74 74
         } else {
75
-            return array ('');
75
+            return array('');
76 76
         }
77 77
     }
78 78
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
     public static function getDbFileName($database = NULL)
108 108
     {
109
-        return self::getDbDirectory($database) .'metadata.db';
109
+        return self::getDbDirectory($database) . 'metadata.db';
110 110
     }
111 111
 
112 112
     private static function error($database)
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
         throw new Exception('Database <' . $database . '> not found.');
118 118
     }
119 119
 
120
-    public static function getDb ($database = NULL)
120
+    public static function getDb($database = NULL)
121 121
     {
122
-        if (is_null (self::$db)) {
122
+        if (is_null(self::$db)) {
123 123
             try {
124
-                if (is_readable(self::getDbFileName ($database))) {
125
-                    self::$db = new PDO('sqlite:'. self::getDbFileName($database));
124
+                if (is_readable(self::getDbFileName($database))) {
125
+                    self::$db = new PDO('sqlite:' . self::getDbFileName($database));
126 126
                     if (useNormAndUp()) {
127 127
                         self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1);
128 128
                     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         }
171 171
         $entry = new Entry(localize($table . '.title'), $id,
172 172
             str_format(localize($numberOfString, $count), $count), 'text',
173
-            array(new LinkNavigation('?page='.$pageId)), '', $count);
173
+            array(new LinkNavigation('?page=' . $pageId)), '', $count);
174 174
         return $entry;
175 175
     }
176 176
 
Please login to merge, or discard this patch.
lib/Book.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -7,55 +7,55 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Silly thing because PHP forbid string concatenation in class const
10
-define ('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id
10
+define('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id
11 11
                                 left outer join books_ratings_link on books_ratings_link.book = books.id
12 12
                                 left outer join ratings on books_ratings_link.rating = ratings.id ');
13
-define ('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort ');
14
-define ('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . '
13
+define('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort ');
14
+define('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . '
15 15
                                                     where books_publishers_link.book = books.id and publisher = ? {1} order by publisher');
16
-define ('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
16
+define('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
17 17
                                                     where upper (books.sort) like ? order by books.sort');
18
-define ('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . '
18
+define('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . '
19 19
                                                     left outer join books_series_link on books_series_link.book = books.id
20 20
                                                     where books_authors_link.book = books.id and author = ? {1} order by series desc, series_index asc, pubdate asc');
21
-define ('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . '
21
+define('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . '
22 22
                                                     where books_series_link.book = books.id and series = ? {1} order by series_index');
23
-define ('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . '
23
+define('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . '
24 24
                                                     where books_tags_link.book = books.id and tag = ? {1} order by sort');
25
-define ('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . '
25
+define('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . '
26 26
                                                     where books_languages_link.book = books.id and lang_code = ? {1} order by sort');
27
-define ('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
27
+define('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
28 28
                                                     where {2}.book = books.id and {2}.{3} = ? {1} order by sort');
29
-define ('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
29
+define('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
30 30
                                                     where {2}.book = books.id and {2}.value = 1 {1} order by sort');
31
-define ('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
31
+define('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
32 32
                                                     where {2}.book = books.id and {2}.value = 0 {1} order by sort');
33
-define ('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
33
+define('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
34 34
                                                     where books.id not in (select book from {2}) {1} order by sort');
35
-define ('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
35
+define('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
36 36
                                                     left join {2} on {2}.book = books.id
37 37
                                                     left join {3} on {3}.id = {2}.{4}
38 38
                                                     where {3}.value = ?  order by sort');
39
-define ('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
39
+define('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
40 40
 								                    left join {2} on {2}.book = books.id
41 41
 								                    left join {3} on {3}.id = {2}.{4}
42 42
                                                     where ((books.id not in (select {2}.book from {2})) or ({3}.value = 0)) {1} order by sort');
43
-define ('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
43
+define('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
44 44
                                                     where {2}.book = books.id and date({2}.value) = ? {1} order by sort');
45
-define ('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
45
+define('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
46 46
                                                     where {2}.book = books.id and {2}.value = ? {1} order by sort');
47
-define ('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
47
+define('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . '
48 48
                                                     where {2}.book = books.id and {2}.id = ? {1} order by sort');
49
-define ('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
49
+define('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
50 50
                                                     where (
51 51
                                                     exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or
52 52
                                                     exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or
53 53
                                                     exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or
54 54
                                                     exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or
55 55
                                                     title like ?) {1} order by books.sort');
56
-define ('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
56
+define('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
57 57
                                                     where 1=1 {1} order by timestamp desc limit ');
58
-define ('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
58
+define('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . '
59 59
                                                     where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort');
60 60
 
61 61
 class Book
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     public $serie = NULL;
106 106
     public $tags = NULL;
107 107
     public $languages = NULL;
108
-    public $format = array ();
108
+    public $format = array();
109 109
 
110 110
 
111 111
     public function __construct($line) {
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
     }
128 128
 
129 129
     public function getEntryId() {
130
-        return self::ALL_BOOKS_UUID.':'.$this->uuid;
130
+        return self::ALL_BOOKS_UUID . ':' . $this->uuid;
131 131
     }
132 132
 
133
-    public static function getEntryIdByLetter ($startingLetter) {
134
-        return self::ALL_BOOKS_ID.':letter:'.$startingLetter;
133
+    public static function getEntryIdByLetter($startingLetter) {
134
+        return self::ALL_BOOKS_ID . ':letter:' . $startingLetter;
135 135
     }
136 136
 
137
-    public function getUri () {
138
-        return '?page='.Base::PAGE_BOOK_DETAIL.'&id=' . $this->id;
137
+    public function getUri() {
138
+        return '?page=' . Base::PAGE_BOOK_DETAIL . '&id=' . $this->id;
139 139
     }
140 140
 
141
-    public function getDetailUrl () {
141
+    public function getDetailUrl() {
142 142
         $urlParam = $this->getUri();
143
-        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB));
143
+        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
144 144
         return 'index.php' . $urlParam;
145 145
     }
146 146
 
147
-    public function getTitle () {
147
+    public function getTitle() {
148 148
         return $this->title;
149 149
     }
150 150
 
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
     /**
154 154
      * @return Author[]
155 155
      */
156
-    public function getAuthors () {
156
+    public function getAuthors() {
157 157
         if (is_null($this->authors)) {
158 158
             $this->authors = Author::getAuthorByBookId($this->id);
159 159
         }
160 160
         return $this->authors;
161 161
     }
162 162
 
163
-    public function getAuthorsName () {
164
-        return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors()));
163
+    public function getAuthorsName() {
164
+        return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors()));
165 165
     }
166 166
 
167
-    public function getAuthorsSort () {
168
-        return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors()));
167
+    public function getAuthorsSort() {
168
+        return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors()));
169 169
     }
170 170
 
171
-    public function getPublisher () {
171
+    public function getPublisher() {
172 172
         if (is_null($this->publisher)) {
173 173
             $this->publisher = Publisher::getPublisherByBookId($this->id);
174 174
         }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return Tag[]
208 208
      */
209 209
     public function getTags() {
210
-        if (is_null ($this->tags)) {
210
+        if (is_null($this->tags)) {
211 211
             $this->tags = array();
212 212
 
213 213
             $result = Base::getDb()->prepare('select tags.id as id, name
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     }
226 226
 
227 227
     public function getTagsName() {
228
-        return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags()));
228
+        return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags()));
229 229
     }
230 230
 
231 231
     /**
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
     public function getDataById($idData)
279 279
     {
280
-        $reduced = array_filter($this->getDatas(), function ($data) use ($idData) {
280
+        $reduced = array_filter($this->getDatas(), function($data) use ($idData) {
281 281
             return $data->id == $idData;
282 282
         });
283 283
         return reset($reduced);
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         if (empty ($this->pubdate)) {
302 302
             return '';
303 303
         }
304
-        $dateY = (int) substr($this->pubdate, 0, 4);
304
+        $dateY = (int)substr($this->pubdate, 0, 4);
305 305
         if ($dateY > 102) {
306 306
             return str_pad($dateY, 4, '0', STR_PAD_LEFT);
307 307
         }
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 
311 311
     public function getComment($withSerie = true) {
312 312
         $addition = '';
313
-        $se = $this->getSerie ();
314
-        if (!is_null ($se) && $withSerie) {
313
+        $se = $this->getSerie();
314
+        if (!is_null($se) && $withSerie) {
315 315
             $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
316 316
         }
317 317
         if (preg_match('/<\/(div|p|a|span)>/', $this->comment))
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
     }
326 326
 
327 327
     public function getDataFormat($format) {
328
-        $reduced = array_filter($this->getDatas(), function ($data) use ($format) {
328
+        $reduced = array_filter($this->getDatas(), function($data) use ($format) {
329 329
             return $data->format == $format;
330 330
         });
331 331
         return reset($reduced);
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
 
347 347
         if ($relative)
348 348
         {
349
-            return $this->relativePath.'/'.$file;
349
+            return $this->relativePath . '/' . $file;
350 350
         }
351 351
         else
352 352
         {
353
-            return $this->path.'/'.$file;
353
+            return $this->path . '/' . $file;
354 354
         }
355 355
     }
356 356
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             }
371 371
             $epub->Authors($authorArray);
372 372
             $epub->Language($this->getLanguages());
373
-            $epub->Description ($this->getComment(false));
373
+            $epub->Description($this->getComment(false));
374 374
             $epub->Subjects($this->getTagsName());
375 375
             $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg');
376 376
             $epub->Calibre($this->uuid);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
                 $epub->Serie($se->name);
380 380
                 $epub->SerieIndex($this->seriesIndex);
381 381
             }
382
-            if ($config['cops_provide_kepub'] == '1'  && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
382
+            if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) {
383 383
                 $epub->updateForKepub();
384 384
             }
385 385
             $epub->download($data->getUpdatedFilenameEpub());
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
             if (!is_null($width)) {
405 405
                 $nw = $width;
406 406
                 if ($nw >= $w) { return false; }
407
-                $nh = ($nw*$h)/$w;
407
+                $nh = ($nw * $h) / $w;
408 408
             } else {
409 409
                 $nh = $height;
410 410
                 if ($nh >= $h) { return false; }
411
-                $nw = ($nh*$w)/$h;
411
+                $nw = ($nh * $w) / $h;
412 412
             }
413 413
         } else {
414 414
             return false;
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
 
417 417
         //draw the image
418 418
         $src_img = imagecreatefromjpeg($file);
419
-        $dst_img = imagecreatetruecolor($nw,$nh);
420
-        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image
421
-        imagejpeg($dst_img,$outputfile,80);
419
+        $dst_img = imagecreatetruecolor($nw, $nh);
420
+        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image
421
+        imagejpeg($dst_img, $outputfile, 80);
422 422
         imagedestroy($src_img);
423 423
         imagedestroy($dst_img);
424 424
 
425 425
         return true;
426 426
     }
427 427
 
428
-    public function getLinkArray ()
428
+    public function getLinkArray()
429 429
     {
430 430
         $linkArray = array();
431 431
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         }
451 451
 
452 452
         $serie = $this->getSerie();
453
-        if (!is_null ($serie)) {
453
+        if (!is_null($serie)) {
454 454
             array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name)));
455 455
         }
456 456
 
@@ -475,13 +475,13 @@  discard block
 block discarded – undo
475 475
         $entry = new Entry(localize('allbooks.title'),
476 476
                           self::ALL_BOOKS_ID,
477 477
                           str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text',
478
-                          array(new LinkNavigation('?page='.Base::PAGE_ALL_BOOKS)), '', $nBooks);
478
+                          array(new LinkNavigation('?page=' . Base::PAGE_ALL_BOOKS)), '', $nBooks);
479 479
         array_push($result, $entry);
480 480
         if ($config['cops_recentbooks_limit'] > 0) {
481 481
             $entry = new Entry(localize('recent.title'),
482 482
                               self::ALL_RECENT_BOOKS_ID,
483 483
                               str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text',
484
-                              array ( new LinkNavigation ('?page='.Base::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
484
+                              array(new LinkNavigation('?page=' . Base::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']);
485 485
             array_push($result, $entry);
486 486
         }
487 487
         return $result;
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
     }
578 578
 
579 579
     public static function getBooks($n) {
580
-        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
580
+        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n);
581 581
         return array($entryArray, $totalNumber);
582 582
     }
583 583
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
         {
595 595
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
596 596
                 str_format(localize('bookword', $post->count), $post->count), 'text',
597
-                array(new LinkNavigation('?page='.Base::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
597
+                array(new LinkNavigation('?page=' . Base::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count));
598 598
         }
599 599
         return $entryArray;
600 600
     }
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 
620 620
     public static function getAllRecentBooks() {
621 621
         global $config;
622
-        list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
622
+        list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
623 623
         return $entryArray;
624 624
     }
625 625
 
Please login to merge, or discard this patch.
lib/CustomColumnType.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
  */
12 12
 abstract class CustomColumnType
13 13
 {
14
-    const ALL_CUSTOMS_ID       = "cops:custom";
14
+    const ALL_CUSTOMS_ID = "cops:custom";
15 15
 
16
-    const CUSTOM_TYPE_TEXT      = "text";        // type 1 + 2
17
-    const CUSTOM_TYPE_COMMENT   = "comments";    // type 3
18
-    const CUSTOM_TYPE_SERIES    = "series";      // type 4
16
+    const CUSTOM_TYPE_TEXT      = "text"; // type 1 + 2
17
+    const CUSTOM_TYPE_COMMENT   = "comments"; // type 3
18
+    const CUSTOM_TYPE_SERIES    = "series"; // type 4
19 19
     const CUSTOM_TYPE_ENUM      = "enumeration"; // type 5
20
-    const CUSTOM_TYPE_DATE      = "datetime";    // type 6
21
-    const CUSTOM_TYPE_FLOAT     = "float";       // type 7
22
-    const CUSTOM_TYPE_INT       = "int";         // type 8
23
-    const CUSTOM_TYPE_RATING    = "rating";      // type 9
24
-    const CUSTOM_TYPE_BOOL      = "bool";        // type 10
25
-    const CUSTOM_TYPE_COMPOSITE = "composite";   // type 11 + 12
20
+    const CUSTOM_TYPE_DATE      = "datetime"; // type 6
21
+    const CUSTOM_TYPE_FLOAT     = "float"; // type 7
22
+    const CUSTOM_TYPE_INT       = "int"; // type 8
23
+    const CUSTOM_TYPE_RATING    = "rating"; // type 9
24
+    const CUSTOM_TYPE_BOOL      = "bool"; // type 10
25
+    const CUSTOM_TYPE_COMPOSITE = "composite"; // type 11 + 12
26 26
 
27 27
     /** @var array[integer]CustomColumnType  */
28 28
     private static $customColumnCacheID = array();
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $result->execute(array($this->customId));
111 111
         if ($post = $result->fetchObject()) {
112 112
             $json = json_decode($post->display);
113
-            return (isset($json->description) && !empty($json->description)) ? $json->description : NULL;
113
+            return (isset($json->description) && !empty($json->description))?$json->description:NULL;
114 114
         }
115 115
         return NULL;
116 116
     }
Please login to merge, or discard this patch.
lib/Entry.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
         Publisher::ALL_PUBLISHERS_ID     => 'images/publisher.png'
32 32
     );
33 33
 
34
-    public function getUpdatedTime () {
35
-        if (!is_null ($this->localUpdated)) {
36
-            return date (DATE_ATOM, $this->localUpdated);
34
+    public function getUpdatedTime() {
35
+        if (!is_null($this->localUpdated)) {
36
+            return date(DATE_ATOM, $this->localUpdated);
37 37
         }
38
-        if (is_null (self::$updated)) {
38
+        if (is_null(self::$updated)) {
39 39
             self::$updated = time();
40 40
         }
41
-        return date (DATE_ATOM, self::$updated);
41
+        return date(DATE_ATOM, self::$updated);
42 42
     }
43 43
 
44
-    public function getNavLink () {
44
+    public function getNavLink() {
45 45
         foreach ($this->linkArray as $link) {
46 46
             /* @var $link LinkNavigation */
47 47
 
48 48
             if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; }
49 49
 
50
-            return $link->hrefXhtml ();
50
+            return $link->hrefXhtml();
51 51
         }
52 52
         return "#";
53 53
     }
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
         {
67 67
             foreach (self::$icons as $reg => $image)
68 68
             {
69
-                if (preg_match ("/" . $reg . "/", $pid)) {
70
-                    array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
69
+                if (preg_match("/" . $reg . "/", $pid)) {
70
+                    array_push($this->linkArray, new Link(getUrlWithVersion($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
71 71
                     break;
72 72
                 }
73 73
             }
74 74
         }
75 75
 
76
-        if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
76
+        if (!is_null(GetUrlParam(DB))) $this->id = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $this->id);
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
lib/CustomColumnTypeEnumeration.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $result = Base::getDb()->prepare(str_format("SELECT id, value AS name FROM {0} WHERE id = ?", $this->getTableName()));
56 56
         $result->execute(array($id));
57 57
         if ($post = $result->fetchObject()) {
58
-            return new CustomColumn ($id, $post->name, $this);
58
+            return new CustomColumn($id, $post->name, $this);
59 59
         }
60 60
         return NULL;
61 61
     }
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
         $entryArray = array();
70 70
         while ($post = $result->fetchObject()) {
71 71
             $entryPContent = str_format(localize("bookword", $post->count), $post->count);
72
-            $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id)));
72
+            $entryPLinkArray = array(new LinkNavigation($this->getUri($post->id)));
73 73
 
74
-            $entry = new Entry ($post->name, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
74
+            $entry = new Entry($post->name, $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
75 75
 
76 76
             array_push($entryArray, $entry);
77 77
         }
Please login to merge, or discard this patch.
lib/JSON_renderer.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -14,52 +14,52 @@  discard block
 block discarded – undo
14 14
      * @param Book $book
15 15
      * @return array
16 16
      */
17
-    public static function getBookContentArray ($book) {
17
+    public static function getBookContentArray($book) {
18 18
         global $config;
19 19
         $i = 0;
20
-        $preferedData = array ();
20
+        $preferedData = array();
21 21
         foreach ($config['cops_prefered_format'] as $format)
22 22
         {
23 23
             if ($i == 2) { break; }
24
-            if ($data = $book->getDataFormat ($format)) {
24
+            if ($data = $book->getDataFormat($format)) {
25 25
                 $i++;
26
-                array_push ($preferedData, array ("url" => $data->getHtmlLink (), "name" => $format));
26
+                array_push($preferedData, array("url" => $data->getHtmlLink(), "name" => $format));
27 27
             }
28 28
         }
29 29
 
30 30
         $publisher = $book->getPublisher();
31
-        if (is_null ($publisher)) {
31
+        if (is_null($publisher)) {
32 32
             $pn = "";
33 33
             $pu = "";
34 34
         } else {
35 35
             $pn = $publisher->name;
36
-            $link = new LinkNavigation ($publisher->getUri ());
37
-            $pu = $link->hrefXhtml ();
36
+            $link = new LinkNavigation($publisher->getUri());
37
+            $pu = $link->hrefXhtml();
38 38
         }
39 39
 
40
-        $serie = $book->getSerie ();
41
-        if (is_null ($serie)) {
40
+        $serie = $book->getSerie();
41
+        if (is_null($serie)) {
42 42
             $sn = "";
43 43
             $scn = "";
44 44
             $su = "";
45 45
         } else {
46 46
             $sn = $serie->name;
47
-            $scn = str_format (localize ("content.series.data"), $book->seriesIndex, $serie->name);
48
-            $link = new LinkNavigation ($serie->getUri ());
49
-            $su = $link->hrefXhtml ();
47
+            $scn = str_format(localize("content.series.data"), $book->seriesIndex, $serie->name);
48
+            $link = new LinkNavigation($serie->getUri());
49
+            $su = $link->hrefXhtml();
50 50
         }
51 51
         $cc = $book->getCustomColumnValues($config['cops_calibre_custom_column_list'], true);
52 52
 
53
-        return array ("id" => $book->id,
53
+        return array("id" => $book->id,
54 54
                       "hasCover" => $book->hasCover,
55 55
                       "preferedData" => $preferedData,
56
-                      "rating" => $book->getRating (),
56
+                      "rating" => $book->getRating(),
57 57
                       "publisherName" => $pn,
58 58
                       "publisherurl" => $pu,
59
-                      "pubDate" => $book->getPubDate (),
60
-                      "languagesName" => $book->getLanguages (),
61
-                      "authorsName" => $book->getAuthorsName (),
62
-                      "tagsName" => $book->getTagsName (),
59
+                      "pubDate" => $book->getPubDate(),
60
+                      "languagesName" => $book->getLanguages(),
61
+                      "authorsName" => $book->getAuthorsName(),
62
+                      "tagsName" => $book->getTagsName(),
63 63
                       "seriesName" => $sn,
64 64
                       "seriesIndex" => $book->seriesIndex,
65 65
                       "seriesCompleteName" => $scn,
@@ -71,85 +71,85 @@  discard block
 block discarded – undo
71 71
      * @param Book $book
72 72
      * @return array
73 73
      */
74
-    public static function getFullBookContentArray ($book) {
74
+    public static function getFullBookContentArray($book) {
75 75
         global $config;
76
-        $out = self::getBookContentArray ($book);
77
-        $database = GetUrlParam (DB);
78
-
79
-        $out ["coverurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml ();
80
-        $out ["thumbnailurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml ();
81
-        $out ["content"] = $book->getComment (false);
82
-        $out ["datas"] = array ();
83
-        $dataKindle = $book->GetMostInterestingDataToSendToKindle ();
76
+        $out = self::getBookContentArray($book);
77
+        $database = GetUrlParam(DB);
78
+
79
+        $out ["coverurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml();
80
+        $out ["thumbnailurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml();
81
+        $out ["content"] = $book->getComment(false);
82
+        $out ["datas"] = array();
83
+        $dataKindle = $book->GetMostInterestingDataToSendToKindle();
84 84
         foreach ($book->getDatas() as $data) {
85
-            $tab = array ("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink (), "mail" => 0, "readerUrl" => "");
86
-            if (!empty ($config['cops_mail_configuration']) && !is_null ($dataKindle) && $data->id == $dataKindle->id) {
85
+            $tab = array("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink(), "mail" => 0, "readerUrl" => "");
86
+            if (!empty ($config['cops_mail_configuration']) && !is_null($dataKindle) && $data->id == $dataKindle->id) {
87 87
                 $tab ["mail"] = 1;
88 88
             }
89 89
             if ($data->format == "EPUB") {
90 90
                 $tab ["readerUrl"] = "epubreader.php?data={$data->id}&db={$database}";
91 91
             }
92
-            array_push ($out ["datas"], $tab);
92
+            array_push($out ["datas"], $tab);
93 93
         }
94
-        $out ["authors"] = array ();
95
-        foreach ($book->getAuthors () as $author) {
96
-            $link = new LinkNavigation ($author->getUri ());
97
-            array_push ($out ["authors"], array ("name" => $author->name, "url" => $link->hrefXhtml ()));
94
+        $out ["authors"] = array();
95
+        foreach ($book->getAuthors() as $author) {
96
+            $link = new LinkNavigation($author->getUri());
97
+            array_push($out ["authors"], array("name" => $author->name, "url" => $link->hrefXhtml()));
98 98
         }
99
-        $out ["tags"] = array ();
100
-        foreach ($book->getTags () as $tag) {
101
-            $link = new LinkNavigation ($tag->getUri ());
102
-            array_push ($out ["tags"], array ("name" => $tag->name, "url" => $link->hrefXhtml ()));
99
+        $out ["tags"] = array();
100
+        foreach ($book->getTags() as $tag) {
101
+            $link = new LinkNavigation($tag->getUri());
102
+            array_push($out ["tags"], array("name" => $tag->name, "url" => $link->hrefXhtml()));
103 103
         }
104 104
         $out ["customcolumns_preview"] = $book->getCustomColumnValues($config['cops_calibre_custom_column_preview'], true);
105 105
 
106 106
         return $out;
107 107
     }
108 108
 
109
-    public static function getContentArray ($entry) {
109
+    public static function getContentArray($entry) {
110 110
         if ($entry instanceof EntryBook) {
111
-            $out = array ( "title" => $entry->title);
112
-            $out ["book"] = self::getBookContentArray ($entry->book);
111
+            $out = array("title" => $entry->title);
112
+            $out ["book"] = self::getBookContentArray($entry->book);
113 113
             return $out;
114 114
         }
115
-        return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement );
115
+        return array("title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink(), "number" => $entry->numberOfElement);
116 116
     }
117 117
 
118
-    public static function getContentArrayTypeahead ($page) {
119
-        $out = array ();
118
+    public static function getContentArrayTypeahead($page) {
119
+        $out = array();
120 120
         foreach ($page->entryArray as $entry) {
121 121
             if ($entry instanceof EntryBook) {
122
-                array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ()));
122
+                array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl()));
123 123
             } else {
124
-                if (empty ($entry->className) xor Base::noDatabaseSelected ()) {
125
-                    array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ()));
124
+                if (empty ($entry->className) xor Base::noDatabaseSelected()) {
125
+                    array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink()));
126 126
                 } else {
127
-                    array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ()));
127
+                    array_push($out, array("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink()));
128 128
                 }
129 129
             }
130 130
         }
131 131
         return $out;
132 132
     }
133 133
 
134
-    public static function addCompleteArray ($in) {
134
+    public static function addCompleteArray($in) {
135 135
         global $config;
136 136
         $out = $in;
137 137
 
138
-        $out ["c"] = array ("version" => VERSION, "i18n" => array (
138
+        $out ["c"] = array("version" => VERSION, "i18n" => array(
139 139
                            "coverAlt" => localize("i18n.coversection"),
140 140
                            "authorsTitle" => localize("authors.title"),
141 141
                            "bookwordTitle" => localize("bookword.title"),
142 142
                            "tagsTitle" => localize("tags.title"),
143 143
                            "seriesTitle" => localize("series.title"),
144
-                           "customizeTitle" => localize ("customize.title"),
145
-                           "aboutTitle" => localize ("about.title"),
146
-                           "previousAlt" => localize ("paging.previous.alternate"),
147
-                           "nextAlt" => localize ("paging.next.alternate"),
148
-                           "searchAlt" => localize ("search.alternate"),
149
-                           "sortAlt" => localize ("sort.alternate"),
150
-                           "homeAlt" => localize ("home.alternate"),
151
-                           "cogAlt" => localize ("cog.alternate"),
152
-                           "permalinkAlt" => localize ("permalink.alternate"),
144
+                           "customizeTitle" => localize("customize.title"),
145
+                           "aboutTitle" => localize("about.title"),
146
+                           "previousAlt" => localize("paging.previous.alternate"),
147
+                           "nextAlt" => localize("paging.next.alternate"),
148
+                           "searchAlt" => localize("search.alternate"),
149
+                           "sortAlt" => localize("sort.alternate"),
150
+                           "homeAlt" => localize("home.alternate"),
151
+                           "cogAlt" => localize("cog.alternate"),
152
+                           "permalinkAlt" => localize("permalink.alternate"),
153 153
                            "publisherName" => localize("publisher.name"),
154 154
                            "pubdateTitle" => localize("pubdate.title"),
155 155
                            "languagesTitle" => localize("language.title"),
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
                            "sortorderAsc" => localize("search.sortorder.asc"),
158 158
                            "sortorderDesc" => localize("search.sortorder.desc"),
159 159
                            "customizeEmail" => localize("customize.email")),
160
-                       "url" => array (
160
+                       "url" => array(
161 161
                            "detailUrl" => "index.php?page=13&id={0}&db={1}",
162 162
                            "coverUrl" => "fetch.php?id={0}&db={1}",
163 163
                            "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"),
164
-                       "config" => array (
164
+                       "config" => array(
165 165
                            "use_fancyapps" => $config ["cops_use_fancyapps"],
166 166
                            "max_item_per_page" => $config['cops_max_item_per_page'],
167 167
                            "kindleHack"        => "",
168
-                           "server_side_rendering" => useServerSideRendering (),
168
+                           "server_side_rendering" => useServerSideRendering(),
169 169
                            "html_tag_filter" => $config['cops_html_tag_filter']));
170 170
         if ($config['cops_thumbnail_handling'] == "1") {
171 171
             $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"];
@@ -178,32 +178,32 @@  discard block
 block discarded – undo
178 178
         return $out;
179 179
     }
180 180
 
181
-    public static function getJson ($complete = false) {
181
+    public static function getJson($complete = false) {
182 182
         global $config;
183
-        $page = getURLParam ("page", Base::PAGE_INDEX);
184
-        $query = getURLParam ("query");
185
-        $search = getURLParam ("search");
186
-        $qid = getURLParam ("id");
187
-        $n = getURLParam ("n", "1");
188
-        $database = GetUrlParam (DB);
183
+        $page = getURLParam("page", Base::PAGE_INDEX);
184
+        $query = getURLParam("query");
185
+        $search = getURLParam("search");
186
+        $qid = getURLParam("id");
187
+        $n = getURLParam("n", "1");
188
+        $database = GetUrlParam(DB);
189 189
 
190
-        $currentPage = Page::getPage ($page, $qid, $query, $n);
191
-        $currentPage->InitializeContent ();
190
+        $currentPage = Page::getPage($page, $qid, $query, $n);
191
+        $currentPage->InitializeContent();
192 192
 
193 193
         if ($search) {
194
-            return self::getContentArrayTypeahead ($currentPage);
194
+            return self::getContentArrayTypeahead($currentPage);
195 195
         }
196 196
 
197
-        $out = array ( "title" => $currentPage->title);
198
-        $entries = array ();
197
+        $out = array("title" => $currentPage->title);
198
+        $entries = array();
199 199
         foreach ($currentPage->entryArray as $entry) {
200
-            array_push ($entries, self::getContentArray ($entry));
200
+            array_push($entries, self::getContentArray($entry));
201 201
         }
202
-        if (!is_null ($currentPage->book)) {
203
-            $out ["book"] = self::getFullBookContentArray ($currentPage->book);
202
+        if (!is_null($currentPage->book)) {
203
+            $out ["book"] = self::getFullBookContentArray($currentPage->book);
204 204
         }
205
-        $out ["databaseId"] = GetUrlParam (DB, "");
206
-        $out ["databaseName"] = Base::getDbName ();
205
+        $out ["databaseId"] = GetUrlParam(DB, "");
206
+        $out ["databaseName"] = Base::getDbName();
207 207
         if ($out ["databaseId"] == "") {
208 208
             $out ["databaseName"] = "";
209 209
         }
@@ -212,42 +212,42 @@  discard block
 block discarded – undo
212 212
             $out ["fullTitle"] = $out ["databaseName"] . " > " . $out ["fullTitle"];
213 213
         }
214 214
         $out ["page"] = $page;
215
-        $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled () ? 1 : 0;
215
+        $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled()?1:0;
216 216
         $out ["entries"] = $entries;
217 217
         $out ["isPaginated"] = 0;
218
-        if ($currentPage->isPaginated ()) {
219
-            $prevLink = $currentPage->getPrevLink ();
220
-            $nextLink = $currentPage->getNextLink ();
218
+        if ($currentPage->isPaginated()) {
219
+            $prevLink = $currentPage->getPrevLink();
220
+            $nextLink = $currentPage->getNextLink();
221 221
             $out ["isPaginated"] = 1;
222 222
             $out ["prevLink"] = "";
223
-            if (!is_null ($prevLink)) {
224
-                $out ["prevLink"] = $prevLink->hrefXhtml ();
223
+            if (!is_null($prevLink)) {
224
+                $out ["prevLink"] = $prevLink->hrefXhtml();
225 225
             }
226 226
             $out ["nextLink"] = "";
227
-            if (!is_null ($nextLink)) {
228
-                $out ["nextLink"] = $nextLink->hrefXhtml ();
227
+            if (!is_null($nextLink)) {
228
+                $out ["nextLink"] = $nextLink->hrefXhtml();
229 229
             }
230
-            $out ["maxPage"] = $currentPage->getMaxPage ();
230
+            $out ["maxPage"] = $currentPage->getMaxPage();
231 231
             $out ["currentPage"] = $currentPage->n;
232 232
         }
233
-        if (!is_null (getURLParam ("complete")) || $complete) {
234
-            $out = self::addCompleteArray ($out);
233
+        if (!is_null(getURLParam("complete")) || $complete) {
234
+            $out = self::addCompleteArray($out);
235 235
        }
236 236
 
237 237
         $out ["containsBook"] = 0;
238
-        if ($currentPage->containsBook ()) {
238
+        if ($currentPage->containsBook()) {
239 239
             $out ["containsBook"] = 1;
240 240
         }
241 241
 
242
-        $out["abouturl"] = "index.php" . addURLParameter ("?page=" . Base::PAGE_ABOUT, DB, $database);
242
+        $out["abouturl"] = "index.php" . addURLParameter("?page=" . Base::PAGE_ABOUT, DB, $database);
243 243
 
244 244
         if ($page == Base::PAGE_ABOUT) {
245
-            $temp = preg_replace ("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html'));
245
+            $temp = preg_replace("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html'));
246 246
             $out ["fullhtml"] = $temp;
247 247
         }
248 248
 
249 249
         $out ["homeurl"] = "index.php";
250
-        if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] .  "?" . addURLParameter ("", DB, $database);
250
+        if ($page != Base::PAGE_INDEX && !is_null($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter("", DB, $database);
251 251
 
252 252
         return $out;
253 253
     }
Please login to merge, or discard this patch.
lib/PageQueryResult.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
     const SCOPE_BOOK = "book";
16 16
     const SCOPE_PUBLISHER = "publisher";
17 17
 
18
-    private function useTypeahead () {
19
-        return !is_null (getURLParam ("search"));
18
+    private function useTypeahead() {
19
+        return !is_null(getURLParam("search"));
20 20
     }
21 21
 
22
-    private function searchByScope ($scope, $limit = FALSE) {
22
+    private function searchByScope($scope, $limit = FALSE) {
23 23
         $n = $this->n;
24 24
         $numberPerPage = NULL;
25 25
         $queryNormedAndUp = trim($this->query);
26
-        if (useNormAndUp ()) {
27
-            $queryNormedAndUp = normAndUp ($this->query);
26
+        if (useNormAndUp()) {
27
+            $queryNormedAndUp = normAndUp($this->query);
28 28
         }
29 29
         if ($limit) {
30 30
             $n = 1;
@@ -32,59 +32,59 @@  discard block
 block discarded – undo
32 32
         }
33 33
         switch ($scope) {
34 34
             case self::SCOPE_BOOK :
35
-                $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
35
+                $array = Book::getBooksByStartingLetter('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
36 36
                 break;
37 37
             case self::SCOPE_AUTHOR :
38
-                $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp);
38
+                $array = Author::getAuthorsForSearch('%' . $queryNormedAndUp);
39 39
                 break;
40 40
             case self::SCOPE_SERIES :
41
-                $array = Serie::getAllSeriesByQuery ($queryNormedAndUp);
41
+                $array = Serie::getAllSeriesByQuery($queryNormedAndUp);
42 42
                 break;
43 43
             case self::SCOPE_TAG :
44
-                $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage);
44
+                $array = Tag::getAllTagsByQuery($queryNormedAndUp, $n, NULL, $numberPerPage);
45 45
                 break;
46 46
             case self::SCOPE_PUBLISHER :
47
-                $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp);
47
+                $array = Publisher::getAllPublishersByQuery($queryNormedAndUp);
48 48
                 break;
49 49
             default:
50
-                $array = Book::getBooksByQuery (
51
-                    array ("all" => "%" . $queryNormedAndUp . "%"), $n);
50
+                $array = Book::getBooksByQuery(
51
+                    array("all" => "%" . $queryNormedAndUp . "%"), $n);
52 52
         }
53 53
 
54 54
         return $array;
55 55
     }
56 56
 
57
-    public function doSearchByCategory () {
58
-        $database = GetUrlParam (DB);
59
-        $out = array ();
57
+    public function doSearchByCategory() {
58
+        $database = GetUrlParam(DB);
59
+        $out = array();
60 60
         $pagequery = Base::PAGE_OPENSEARCH_QUERY;
61
-        $dbArray = array ("");
61
+        $dbArray = array("");
62 62
         $d = $database;
63 63
         $query = $this->query;
64 64
         // Special case when no databases were chosen, we search on all databases
65
-        if (Base::noDatabaseSelected ()) {
66
-            $dbArray = Base::getDbNameList ();
65
+        if (Base::noDatabaseSelected()) {
66
+            $dbArray = Base::getDbNameList();
67 67
             $d = 0;
68 68
         }
69 69
         foreach ($dbArray as $key) {
70
-            if (Base::noDatabaseSelected ()) {
71
-                array_push ($this->entryArray, new Entry ($key, DB . ":query:{$d}",
70
+            if (Base::noDatabaseSelected()) {
71
+                array_push($this->entryArray, new Entry($key, DB . ":query:{$d}",
72 72
                                         " ", "text",
73
-                                        array ( new LinkNavigation ("?" . DB . "={$d}")), "tt-header"));
74
-                Base::getDb ($d);
73
+                                        array(new LinkNavigation("?" . DB . "={$d}")), "tt-header"));
74
+                Base::getDb($d);
75 75
             }
76
-            foreach (array (PageQueryResult::SCOPE_BOOK,
76
+            foreach (array(PageQueryResult::SCOPE_BOOK,
77 77
                             PageQueryResult::SCOPE_AUTHOR,
78 78
                             PageQueryResult::SCOPE_SERIES,
79 79
                             PageQueryResult::SCOPE_TAG,
80 80
                             PageQueryResult::SCOPE_PUBLISHER) as $key) {
81
-                if (in_array($key, getCurrentOption ('ignored_categories'))) {
81
+                if (in_array($key, getCurrentOption('ignored_categories'))) {
82 82
                     continue;
83 83
                 }
84
-                $array = $this->searchByScope ($key, TRUE);
84
+                $array = $this->searchByScope($key, TRUE);
85 85
 
86 86
                 $i = 0;
87
-                if (count ($array) == 2 && is_array ($array [0])) {
87
+                if (count($array) == 2 && is_array($array [0])) {
88 88
                     $total = $array [1];
89 89
                     $array = $array [0];
90 90
                 } else {
@@ -97,32 +97,32 @@  discard block
 block discarded – undo
97 97
                     // str_format (localize("seriesword", count($array))
98 98
                     // str_format (localize("tagword", count($array))
99 99
                     // str_format (localize("publisherword", count($array))
100
-                    array_push ($this->entryArray, new Entry (str_format (localize ("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}",
101
-                                        str_format (localize("{$key}word", $total), $total), "text",
102
-                                        array ( new LinkNavigation ("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")),
103
-                                        Base::noDatabaseSelected () ? "" : "tt-header", $total));
100
+                    array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}",
101
+                                        str_format(localize("{$key}word", $total), $total), "text",
102
+                                        array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")),
103
+                                        Base::noDatabaseSelected()?"":"tt-header", $total));
104 104
                 }
105
-                if (!Base::noDatabaseSelected () && $this->useTypeahead ()) {
105
+                if (!Base::noDatabaseSelected() && $this->useTypeahead()) {
106 106
                     foreach ($array as $entry) {
107
-                        array_push ($this->entryArray, $entry);
107
+                        array_push($this->entryArray, $entry);
108 108
                         $i++;
109 109
                         if ($i > 4) { break; };
110 110
                     }
111 111
                 }
112 112
             }
113 113
             $d++;
114
-            if (Base::noDatabaseSelected ()) {
115
-                Base::clearDb ();
114
+            if (Base::noDatabaseSelected()) {
115
+                Base::clearDb();
116 116
             }
117 117
         }
118 118
         return $out;
119 119
     }
120 120
 
121
-    public function InitializeContent ()
121
+    public function InitializeContent()
122 122
     {
123
-        $scope = getURLParam ("scope");
123
+        $scope = getURLParam("scope");
124 124
         if (empty ($scope)) {
125
-            $this->title = str_format (localize ("search.result"), $this->query);
125
+            $this->title = str_format(localize("search.result"), $this->query);
126 126
         } else {
127 127
             // Comment to help the perl i18n script
128 128
             // str_format (localize ("search.result.author"), $this->query)
@@ -130,31 +130,31 @@  discard block
 block discarded – undo
130 130
             // str_format (localize ("search.result.series"), $this->query)
131 131
             // str_format (localize ("search.result.book"), $this->query)
132 132
             // str_format (localize ("search.result.publisher"), $this->query)
133
-            $this->title = str_format (localize ("search.result.{$scope}"), $this->query);
133
+            $this->title = str_format(localize("search.result.{$scope}"), $this->query);
134 134
         }
135 135
 
136 136
         $crit = "%" . $this->query . "%";
137 137
 
138 138
         // Special case when we are doing a search and no database is selected
139
-        if (Base::noDatabaseSelected () && !$this->useTypeahead ()) {
139
+        if (Base::noDatabaseSelected() && !$this->useTypeahead()) {
140 140
             $i = 0;
141
-            foreach (Base::getDbNameList () as $key) {
142
-                Base::clearDb ();
143
-                list ($array, $totalNumber) = Book::getBooksByQuery (array ("all" => $crit), 1, $i, 1);
144
-                array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}",
145
-                                        str_format (localize ("bookword", $totalNumber), $totalNumber), "text",
146
-                                        array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber));
141
+            foreach (Base::getDbNameList() as $key) {
142
+                Base::clearDb();
143
+                list ($array, $totalNumber) = Book::getBooksByQuery(array("all" => $crit), 1, $i, 1);
144
+                array_push($this->entryArray, new Entry($key, DB . ":query:{$i}",
145
+                                        str_format(localize("bookword", $totalNumber), $totalNumber), "text",
146
+                                        array(new LinkNavigation("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber));
147 147
                 $i++;
148 148
             }
149 149
             return;
150 150
         }
151 151
         if (empty ($scope)) {
152
-            $this->doSearchByCategory ();
152
+            $this->doSearchByCategory();
153 153
             return;
154 154
         }
155 155
 
156
-        $array = $this->searchByScope ($scope);
157
-        if (count ($array) == 2 && is_array ($array [0])) {
156
+        $array = $this->searchByScope($scope);
157
+        if (count($array) == 2 && is_array($array [0])) {
158 158
             list ($this->entryArray, $this->totalNumber) = $array;
159 159
         } else {
160 160
             $this->entryArray = $array;
Please login to merge, or discard this patch.