Completed
Branch master (31966b)
by Markus
09:57
created
author.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -60,6 +60,9 @@  discard block
 block discarded – undo
60 60
         return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
61 61
     }
62 62
 
63
+    /**
64
+     * @param string $query
65
+     */
63 66
     public static function getAuthorsForSearch($query) {
64 67
         return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
65 68
     }
@@ -68,6 +71,9 @@  discard block
 block discarded – undo
68 71
         return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
69 72
     }
70 73
 
74
+    /**
75
+     * @param string $query
76
+     */
71 77
     public static function getEntryArray ($query, $params) {
72 78
         return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
73 79
     }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -24,69 +24,69 @@
 block discarded – undo
24 24
         $this->sort = $post->sort;
25 25
     }
26 26
 
27
-    public function getUri () {
28
-        return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id";
27
+    public function getUri() {
28
+        return "?page=" . parent::PAGE_AUTHOR_DETAIL . "&id=$this->id";
29 29
     }
30 30
 
31
-    public function getEntryId () {
32
-        return self::ALL_AUTHORS_ID.":".$this->id;
31
+    public function getEntryId() {
32
+        return self::ALL_AUTHORS_ID . ":" . $this->id;
33 33
     }
34 34
 
35
-    public static function getEntryIdByLetter ($startingLetter) {
36
-        return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
35
+    public static function getEntryIdByLetter($startingLetter) {
36
+        return self::ALL_AUTHORS_ID . ":letter:" . $startingLetter;
37 37
     }
38 38
 
39 39
     public static function getCount() {
40 40
         // str_format (localize("authors.alphabetical", count(array))
41
-        return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
41
+        return parent::getCountGeneric("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
42 42
     }
43 43
 
44 44
     public static function getAllAuthorsByFirstLetter() {
45
-        list (, $result) = parent::executeQuery ("select {0}
45
+        list (, $result) = parent::executeQuery("select {0}
46 46
 from authors
47 47
 group by substr (upper (sort), 1, 1)
48
-order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
48
+order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1);
49 49
         $entryArray = array();
50
-        while ($post = $result->fetchObject ())
50
+        while ($post = $result->fetchObject())
51 51
         {
52
-            array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
53
-                str_format (localize("authorword", $post->count), $post->count), "text",
54
-                array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
52
+            array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title),
53
+                str_format(localize("authorword", $post->count), $post->count), "text",
54
+                array(new LinkNavigation("?page=" . parent::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count));
55 55
         }
56 56
         return $entryArray;
57 57
     }
58 58
 
59 59
     public static function getAuthorsByStartingLetter($letter) {
60
-        return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
60
+        return self::getEntryArray(self::SQL_AUTHORS_BY_FIRST_LETTER, array($letter . "%"));
61 61
     }
62 62
 
63 63
     public static function getAuthorsForSearch($query) {
64
-        return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
64
+        return self::getEntryArray(self::SQL_AUTHORS_FOR_SEARCH, array($query . "%", $query . "%"));
65 65
     }
66 66
 
67 67
     public static function getAllAuthors() {
68
-        return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
68
+        return self::getEntryArray(self::SQL_ALL_AUTHORS, array());
69 69
     }
70 70
 
71
-    public static function getEntryArray ($query, $params) {
72
-        return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
71
+    public static function getEntryArray($query, $params) {
72
+        return Base::getEntryArrayWithBookNumber($query, self::AUTHOR_COLUMNS, $params, "Author");
73 73
     }
74 74
 
75
-    public static function getAuthorById ($authorId) {
76
-        $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
77
-        $result->execute (array ($authorId));
78
-        $post = $result->fetchObject ();
79
-        return new Author ($post);
75
+    public static function getAuthorById($authorId) {
76
+        $result = parent::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
77
+        $result->execute(array($authorId));
78
+        $post = $result->fetchObject();
79
+        return new Author($post);
80 80
     }
81 81
 
82
-    public static function getAuthorByBookId ($bookId) {
83
-        $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
82
+    public static function getAuthorByBookId($bookId) {
83
+        $result = parent::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
84 84
 where author = authors.id
85 85
 and book = ?');
86
-        $result->execute (array ($bookId));
87
-        $authorArray = array ();
88
-        while ($post = $result->fetchObject ()) {
89
-            array_push ($authorArray, new Author ($post));
86
+        $result->execute(array($bookId));
87
+        $authorArray = array();
88
+        while ($post = $result->fetchObject()) {
89
+            array_push($authorArray, new Author($post));
90 90
         }
91 91
         return $authorArray;
92 92
     }
Please login to merge, or discard this patch.
Braces   +27 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@  discard block
 block discarded – undo
6 6
  * @author     Sébastien Lucas <[email protected]>
7 7
  */
8 8
 
9
-class Author extends Base {
9
+class Author extends Base
10
+{
10 11
     const ALL_AUTHORS_ID = "cops:authors";
11 12
 
12 13
     const AUTHOR_COLUMNS = "authors.id as id, authors.name as name, authors.sort as sort, count(*) as count";
@@ -18,37 +19,42 @@  discard block
 block discarded – undo
18 19
     public $name;
19 20
     public $sort;
20 21
 
21
-    public function __construct($post) {
22
+    public function __construct($post)
23
+    {
22 24
         $this->id = $post->id;
23 25
         $this->name = str_replace("|", ",", $post->name);
24 26
         $this->sort = $post->sort;
25 27
     }
26 28
 
27
-    public function getUri () {
29
+    public function getUri ()
30
+    {
28 31
         return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id";
29 32
     }
30 33
 
31
-    public function getEntryId () {
34
+    public function getEntryId ()
35
+    {
32 36
         return self::ALL_AUTHORS_ID.":".$this->id;
33 37
     }
34 38
 
35
-    public static function getEntryIdByLetter ($startingLetter) {
39
+    public static function getEntryIdByLetter ($startingLetter)
40
+    {
36 41
         return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
37 42
     }
38 43
 
39
-    public static function getCount() {
44
+    public static function getCount()
45
+    {
40 46
         // str_format (localize("authors.alphabetical", count(array))
41 47
         return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
42 48
     }
43 49
 
44
-    public static function getAllAuthorsByFirstLetter() {
50
+    public static function getAllAuthorsByFirstLetter()
51
+    {
45 52
         list (, $result) = parent::executeQuery ("select {0}
46 53
 from authors
47 54
 group by substr (upper (sort), 1, 1)
48 55
 order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
49 56
         $entryArray = array();
50
-        while ($post = $result->fetchObject ())
51
-        {
57
+        while ($post = $result->fetchObject ()) {
52 58
             array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
53 59
                 str_format (localize("authorword", $post->count), $post->count), "text",
54 60
                 array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
@@ -56,30 +62,36 @@  discard block
 block discarded – undo
56 62
         return $entryArray;
57 63
     }
58 64
 
59
-    public static function getAuthorsByStartingLetter($letter) {
65
+    public static function getAuthorsByStartingLetter($letter)
66
+    {
60 67
         return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
61 68
     }
62 69
 
63
-    public static function getAuthorsForSearch($query) {
70
+    public static function getAuthorsForSearch($query)
71
+    {
64 72
         return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
65 73
     }
66 74
 
67
-    public static function getAllAuthors() {
75
+    public static function getAllAuthors()
76
+    {
68 77
         return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
69 78
     }
70 79
 
71
-    public static function getEntryArray ($query, $params) {
80
+    public static function getEntryArray ($query, $params)
81
+    {
72 82
         return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
73 83
     }
74 84
 
75
-    public static function getAuthorById ($authorId) {
85
+    public static function getAuthorById ($authorId)
86
+    {
76 87
         $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
77 88
         $result->execute (array ($authorId));
78 89
         $post = $result->fetchObject ();
79 90
         return new Author ($post);
80 91
     }
81 92
 
82
-    public static function getAuthorByBookId ($bookId) {
93
+    public static function getAuthorByBookId ($bookId)
94
+    {
83 95
         $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
84 96
 where author = authors.id
85 97
 and book = ?');
Please login to merge, or discard this patch.
base.php 5 patches
Doc Comments   +50 added lines patch added patch discarded remove patch
@@ -60,6 +60,9 @@  discard block
 block discarded – undo
60 60
     $_SERVER['REDIRECT_STATUS'] = 404;
61 61
 }
62 62
 
63
+/**
64
+ * @param string $name
65
+ */
63 66
 function getURLParam ($name, $default = NULL) {
64 67
     if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
65 68
         return $_GET[$name];
@@ -95,6 +98,11 @@  discard block
 block discarded – undo
95 98
     return $url . "?v=" . VERSION;
96 99
 }
97 100
 
101
+/**
102
+ * @param string $xml
103
+ *
104
+ * @return string
105
+ */
98 106
 function xml2xhtml($xml) {
99 107
     return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', create_function('$m', '
100 108
         $xhtml_tags = array("br", "hr", "input", "frame", "img", "area", "link", "col", "base", "basefont", "param");
@@ -308,6 +316,9 @@  discard block
 block discarded – undo
308 316
     return $phrase;
309 317
 }
310 318
 
319
+/**
320
+ * @param string $paramName
321
+ */
311 322
 function addURLParameter($urlParams, $paramName, $paramValue) {
312 323
     if (empty ($urlParams)) {
313 324
         $urlParams = "";
@@ -369,6 +380,9 @@  discard block
 block discarded – undo
369 380
         return $this->href;
370 381
     }
371 382
 
383
+    /**
384
+     * @return string
385
+     */
372 386
     public function getScriptName() {
373 387
         $parts = explode('/', $_SERVER["SCRIPT_NAME"]);
374 388
         return $parts[count($parts) - 1];
@@ -377,6 +391,9 @@  discard block
 block discarded – undo
377 391
 
378 392
 class LinkNavigation extends Link
379 393
 {
394
+    /**
395
+     * @param string $prel
396
+     */
380 397
     public function __construct($phref, $prel = NULL, $ptitle = NULL) {
381 398
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
382 399
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
@@ -391,6 +408,9 @@  discard block
 block discarded – undo
391 408
 
392 409
 class LinkFacet extends Link
393 410
 {
411
+    /**
412
+     * @param string $phref
413
+     */
394 414
     public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
395 415
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
396 416
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
@@ -471,6 +491,12 @@  discard block
 block discarded – undo
471 491
 {
472 492
     public $book;
473 493
 
494
+    /**
495
+     * @param string $pid
496
+     * @param string $pcontent
497
+     * @param string $pcontentType
498
+     * @param Book $pbook
499
+     */
474 500
     public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) {
475 501
         parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
476 502
         $this->book = $pbook;
@@ -1044,6 +1070,9 @@  discard block
 block discarded – undo
1044 1070
 
1045 1071
 class PageCustomize extends Page
1046 1072
 {
1073
+    /**
1074
+     * @param string $key
1075
+     */
1047 1076
     private function isChecked ($key, $testedValue = 1) {
1048 1077
         $value = getCurrentOption ($key);
1049 1078
         if (is_array ($value)) {
@@ -1058,6 +1087,9 @@  discard block
 block discarded – undo
1058 1087
         return "";
1059 1088
     }
1060 1089
 
1090
+    /**
1091
+     * @param string $key
1092
+     */
1061 1093
     private function isSelected ($key, $value) {
1062 1094
         if (getCurrentOption ($key) == $value) {
1063 1095
             return "selected='selected'";
@@ -1214,6 +1246,9 @@  discard block
 block discarded – undo
1214 1246
         return "";
1215 1247
     }
1216 1248
 
1249
+    /**
1250
+     * @return string
1251
+     */
1217 1252
     public static function getDbDirectory ($database = NULL) {
1218 1253
         global $config;
1219 1254
         if (self::isMultipleDatabaseEnabled ()) {
@@ -1273,10 +1308,18 @@  discard block
 block discarded – undo
1273 1308
         self::$db = NULL;
1274 1309
     }
1275 1310
 
1311
+    /**
1312
+     * @param string $query
1313
+     */
1276 1314
     public static function executeQuerySingle ($query, $database = NULL) {
1277 1315
         return self::getDb ($database)->query($query)->fetchColumn();
1278 1316
     }
1279 1317
 
1318
+    /**
1319
+     * @param string $table
1320
+     * @param string $id
1321
+     * @param string $numberOfString
1322
+     */
1280 1323
     public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
1281 1324
         if (!$numberOfString) {
1282 1325
             $numberOfString = $table . ".alphabetical";
@@ -1289,6 +1332,10 @@  discard block
 block discarded – undo
1289 1332
         return $entry;
1290 1333
     }
1291 1334
 
1335
+    /**
1336
+     * @param string $columns
1337
+     * @param string $category
1338
+     */
1292 1339
     public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
1293 1340
         list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
1294 1341
         $entryArray = array();
@@ -1307,6 +1354,9 @@  discard block
 block discarded – undo
1307 1354
         return $entryArray;
1308 1355
     }
1309 1356
 
1357
+    /**
1358
+     * @param string $filter
1359
+     */
1310 1360
     public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
1311 1361
         $totalResult = -1;
1312 1362
 
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
     // Generate the function for the template
31 31
     $template = new doT ();
32 32
     $dot = $template->template ($page, array ("bookdetail" => $bookdetail,
33
-                                              "header" => $header,
34
-                                              "footer" => $footer,
35
-                                              "main" => $main));
33
+                                                "header" => $header,
34
+                                                "footer" => $footer,
35
+                                                "main" => $main));
36 36
     // If there is a syntax error in the function created
37 37
     // $dot will be equal to FALSE
38 38
     if (!$dot) {
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         case LIBXML_ERR_WARNING:
112 112
             $return .= "Warning $error->code: ";
113 113
             break;
114
-         case LIBXML_ERR_ERROR:
114
+            case LIBXML_ERR_ERROR:
115 115
             $return .= "Error $error->code: ";
116 116
             break;
117 117
         case LIBXML_ERR_FATAL:
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
     }
121 121
 
122 122
     $return .= trim($error->message) .
123
-               "\n  Line: $error->line" .
124
-               "\n  Column: $error->column";
123
+                "\n  Line: $error->line" .
124
+                "\n  Column: $error->column";
125 125
 
126 126
     if ($error->file) {
127 127
         $return .= "\n  File: $error->file";
@@ -1081,11 +1081,11 @@  discard block
 block discarded – undo
1081 1081
         $this->entryArray = array ();
1082 1082
 
1083 1083
         $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR,
1084
-                                   PageQueryResult::SCOPE_TAG,
1085
-                                   PageQueryResult::SCOPE_SERIES,
1086
-                                   PageQueryResult::SCOPE_PUBLISHER,
1087
-                                   PageQueryResult::SCOPE_RATING,
1088
-                                   "language");
1084
+                                    PageQueryResult::SCOPE_TAG,
1085
+                                    PageQueryResult::SCOPE_SERIES,
1086
+                                    PageQueryResult::SCOPE_PUBLISHER,
1087
+                                    PageQueryResult::SCOPE_RATING,
1088
+                                    "language");
1089 1089
 
1090 1090
         $content = "";
1091 1091
         array_push ($this->entryArray, new Entry ("Template", "",
Please login to merge, or discard this patch.
Spacing   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
 
9 9
 require_once 'config.php';
10 10
 
11
-define ("VERSION", "1.0.0RC4");
12
-define ("DB", "db");
11
+define("VERSION", "1.0.0RC4");
12
+define("DB", "db");
13 13
 date_default_timezone_set($config['default_timezone']);
14 14
 
15 15
 
16
-function useServerSideRendering () {
16
+function useServerSideRendering() {
17 17
     global $config;
18 18
     return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']);
19 19
 }
20 20
 
21
-function serverSideRender ($data) {
21
+function serverSideRender($data) {
22 22
     // Get the templates
23
-    $theme = getCurrentTemplate ();
23
+    $theme = getCurrentTemplate();
24 24
     $header = file_get_contents('templates/' . $theme . '/header.html');
25 25
     $footer = file_get_contents('templates/' . $theme . '/footer.html');
26 26
     $main = file_get_contents('templates/' . $theme . '/main.html');
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     $page = file_get_contents('templates/' . $theme . '/page.html');
29 29
 
30 30
     // Generate the function for the template
31
-    $template = new doT ();
32
-    $dot = $template->template ($page, array ("bookdetail" => $bookdetail,
31
+    $template = new doT();
32
+    $dot = $template->template($page, array("bookdetail" => $bookdetail,
33 33
                                               "header" => $header,
34 34
                                               "footer" => $footer,
35 35
                                               "main" => $main));
@@ -40,38 +40,38 @@  discard block
 block discarded – undo
40 40
     }
41 41
     // Execute the template
42 42
     if (!empty ($data)) {
43
-        return $dot ($data);
43
+        return $dot($data);
44 44
     }
45 45
 
46 46
     return NULL;
47 47
 }
48 48
 
49
-function getQueryString () {
50
-    if ( isset($_SERVER['QUERY_STRING']) ) {
49
+function getQueryString() {
50
+    if (isset($_SERVER['QUERY_STRING'])) {
51 51
         return $_SERVER['QUERY_STRING'];
52 52
     }
53 53
     return "";
54 54
 }
55 55
 
56
-function notFound () {
57
-    header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
56
+function notFound() {
57
+    header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
58 58
     header("Status: 404 Not Found");
59 59
 
60 60
     $_SERVER['REDIRECT_STATUS'] = 404;
61 61
 }
62 62
 
63
-function getURLParam ($name, $default = NULL) {
63
+function getURLParam($name, $default = NULL) {
64 64
     if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
65 65
         return $_GET[$name];
66 66
     }
67 67
     return $default;
68 68
 }
69 69
 
70
-function getCurrentOption ($option) {
70
+function getCurrentOption($option) {
71 71
     global $config;
72 72
     if (isset($_COOKIE[$option])) {
73
-        if (isset($config ["cops_" . $option]) && is_array ($config ["cops_" . $option])) {
74
-            return explode (",", $_COOKIE[$option]);
73
+        if (isset($config ["cops_" . $option]) && is_array($config ["cops_" . $option])) {
74
+            return explode(",", $_COOKIE[$option]);
75 75
         } else {
76 76
             return $_COOKIE[$option];
77 77
         }
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
     return "";
84 84
 }
85 85
 
86
-function getCurrentCss () {
87
-    return "templates/" . getCurrentTemplate () . "/styles/style-" . getCurrentOption ("style") . ".css";
86
+function getCurrentCss() {
87
+    return "templates/" . getCurrentTemplate() . "/styles/style-" . getCurrentOption("style") . ".css";
88 88
 }
89 89
 
90
-function getCurrentTemplate () {
91
-    return getCurrentOption ("template");
90
+function getCurrentTemplate() {
91
+    return getCurrentOption("template");
92 92
 }
93 93
 
94
-function getUrlWithVersion ($url) {
94
+function getUrlWithVersion($url) {
95 95
     return $url . "?v=" . VERSION;
96 96
 }
97 97
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     return "$return\n\n--------------------------------------------\n\n";
131 131
 }
132 132
 
133
-function are_libxml_errors_ok ()
133
+function are_libxml_errors_ok()
134 134
 {
135 135
     $errors = libxml_get_errors();
136 136
 
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
     return true;
141 141
 }
142 142
 
143
-function html2xhtml ($html) {
143
+function html2xhtml($html) {
144 144
     $doc = new DOMDocument();
145 145
     libxml_use_internal_errors(true);
146 146
 
147 147
     $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' .
148
-                        $html  . '</body></html>'); // Load the HTML
148
+                        $html . '</body></html>'); // Load the HTML
149 149
     $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream
150 150
     $output = xml2xhtml($output);
151
-    if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) {
151
+    if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) {
152 152
         $output = $matches [1]; // Remove <html><body>
153 153
     }
154 154
     /*
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     }
161 161
     */
162 162
 
163
-    if (!are_libxml_errors_ok ()) $output = "HTML code not valid.";
163
+    if (!are_libxml_errors_ok()) $output = "HTML code not valid.";
164 164
 
165 165
     libxml_use_internal_errors(false);
166 166
     return $output;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     //echo var_dump($langs);
247 247
     $lang_file = NULL;
248 248
     foreach ($langs as $language => $val) {
249
-        $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json';
249
+        $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json';
250 250
         if (file_exists($temp_file)) {
251 251
             $lang = $language;
252 252
             $lang_file = $temp_file;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         }
255 255
     }
256 256
     if (empty ($lang_file)) {
257
-        $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json';
257
+        $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json';
258 258
     }
259 259
     return array($lang, $lang_file);
260 260
 }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
  * This method is based on this page
264 264
  * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
265 265
  */
266
-function localize($phrase, $count=-1, $reset=false) {
266
+function localize($phrase, $count = -1, $reset = false) {
267 267
     global $config;
268 268
     if ($count == 0)
269 269
         $phrase .= ".none";
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
         $lang_file_en = NULL;
283 283
         list ($lang, $lang_file) = getLangAndTranslationFile();
284 284
         if ($lang != "en") {
285
-            $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json';
285
+            $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json';
286 286
         }
287 287
 
288 288
         $lang_file_content = file_get_contents($lang_file);
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
         $translations = json_decode($lang_file_content, true);
291 291
 
292 292
         /* Clean the array of all unfinished translations */
293
-        foreach (array_keys ($translations) as $key) {
294
-            if (preg_match ("/^##TODO##/", $key)) {
293
+        foreach (array_keys($translations) as $key) {
294
+            if (preg_match("/^##TODO##/", $key)) {
295 295
                 unset ($translations [$key]);
296 296
             }
297 297
         }
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
         {
300 300
             $lang_file_content = file_get_contents($lang_file_en);
301 301
             $translations_en = json_decode($lang_file_content, true);
302
-            $translations = array_merge ($translations_en, $translations);
302
+            $translations = array_merge($translations_en, $translations);
303 303
         }
304 304
     }
305
-    if (array_key_exists ($phrase, $translations)) {
305
+    if (array_key_exists($phrase, $translations)) {
306 306
         return $translations[$phrase];
307 307
     }
308 308
     return $phrase;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $urlParams = "";
314 314
     }
315 315
     $start = "";
316
-    if (preg_match ("#^\?(.*)#", $urlParams, $matches)) {
316
+    if (preg_match("#^\?(.*)#", $urlParams, $matches)) {
317 317
         $start = "?";
318 318
         $urlParams = $matches[1];
319 319
     }
@@ -327,18 +327,18 @@  discard block
 block discarded – undo
327 327
     return $start . http_build_query($params);
328 328
 }
329 329
 
330
-function useNormAndUp () {
330
+function useNormAndUp() {
331 331
     global $config;
332 332
     return $config ['cops_normalized_search'] == "1";
333 333
 }
334 334
 
335
-function normalizeUtf8String( $s) {
335
+function normalizeUtf8String($s) {
336 336
     include_once 'transliteration.php';
337 337
     return _transliteration_process($s);
338 338
 }
339 339
 
340
-function normAndUp ($s) {
341
-    return mb_strtoupper (normalizeUtf8String($s), 'UTF-8');
340
+function normAndUp($s) {
341
+    return mb_strtoupper(normalizeUtf8String($s), 'UTF-8');
342 342
 }
343 343
 
344 344
 class Link
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
         $this->activeFacet = $pactiveFacet;
366 366
     }
367 367
 
368
-    public function hrefXhtml () {
368
+    public function hrefXhtml() {
369 369
         return $this->href;
370 370
     }
371 371
 
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 class LinkNavigation extends Link
379 379
 {
380 380
     public function __construct($phref, $prel = NULL, $ptitle = NULL) {
381
-        parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
382
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
383
-        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
384
-        if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) {
381
+        parent::__construct($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
382
+        if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB));
383
+        if (!preg_match("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
384
+        if (preg_match("/(bookdetail|getJSON).php/", parent::getScriptName())) {
385 385
             $this->href = "index.php" . $this->href;
386 386
         } else {
387 387
             $this->href = parent::getScriptName() . $this->href;
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 class LinkFacet extends Link
393 393
 {
394 394
     public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
395
-        parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
396
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
395
+        parent::__construct($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
396
+        if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB));
397 397
         $this->href = parent::getScriptName() . $this->href;
398 398
     }
399 399
 }
@@ -423,21 +423,21 @@  discard block
 block discarded – undo
423 423
         Publisher::ALL_PUBLISHERS_ID => 'images/publisher.png'
424 424
     );
425 425
 
426
-    public function getUpdatedTime () {
427
-        if (!is_null ($this->localUpdated)) {
428
-            return date (DATE_ATOM, $this->localUpdated);
426
+    public function getUpdatedTime() {
427
+        if (!is_null($this->localUpdated)) {
428
+            return date(DATE_ATOM, $this->localUpdated);
429 429
         }
430
-        if (is_null (self::$updated)) {
430
+        if (is_null(self::$updated)) {
431 431
             self::$updated = time();
432 432
         }
433
-        return date (DATE_ATOM, self::$updated);
433
+        return date(DATE_ATOM, self::$updated);
434 434
     }
435 435
 
436
-    public function getNavLink () {
436
+    public function getNavLink() {
437 437
         foreach ($this->linkArray as $link) {
438 438
             if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; }
439 439
 
440
-            return $link->hrefXhtml ();
440
+            return $link->hrefXhtml();
441 441
         }
442 442
         return "#";
443 443
     }
@@ -456,14 +456,14 @@  discard block
 block discarded – undo
456 456
         {
457 457
             foreach (self::$icons as $reg => $image)
458 458
             {
459
-                if (preg_match ("/" . $reg . "/", $pid)) {
460
-                    array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
459
+                if (preg_match("/" . $reg . "/", $pid)) {
460
+                    array_push($this->linkArray, new Link(getUrlWithVersion($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
461 461
                     break;
462 462
                 }
463 463
             }
464 464
         }
465 465
 
466
-        if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
466
+        if (!is_null(GetUrlParam(DB))) $this->id = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $this->id);
467 467
     }
468 468
 }
469 469
 
@@ -472,23 +472,23 @@  discard block
 block discarded – undo
472 472
     public $book;
473 473
 
474 474
     public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) {
475
-        parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
475
+        parent::__construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
476 476
         $this->book = $pbook;
477 477
         $this->localUpdated = $pbook->timestamp;
478 478
     }
479 479
 
480
-    public function getCoverThumbnail () {
480
+    public function getCoverThumbnail() {
481 481
         foreach ($this->linkArray as $link) {
482 482
             if ($link->rel == Link::OPDS_THUMBNAIL_TYPE)
483
-                return $link->hrefXhtml ();
483
+                return $link->hrefXhtml();
484 484
         }
485 485
         return null;
486 486
     }
487 487
 
488
-    public function getCover () {
488
+    public function getCover() {
489 489
         foreach ($this->linkArray as $link) {
490 490
             if ($link->rel == Link::OPDS_IMAGE_TYPE)
491
-                return $link->hrefXhtml ();
491
+                return $link->hrefXhtml();
492 492
         }
493 493
         return null;
494 494
     }
@@ -510,55 +510,55 @@  discard block
 block discarded – undo
510 510
     public $totalNumber = -1;
511 511
     public $entryArray = array();
512 512
 
513
-    public static function getPage ($pageId, $id, $query, $n)
513
+    public static function getPage($pageId, $id, $query, $n)
514 514
     {
515 515
         switch ($pageId) {
516 516
             case Base::PAGE_ALL_AUTHORS :
517
-                return new PageAllAuthors ($id, $query, $n);
517
+                return new PageAllAuthors($id, $query, $n);
518 518
             case Base::PAGE_AUTHORS_FIRST_LETTER :
519
-                return new PageAllAuthorsLetter ($id, $query, $n);
519
+                return new PageAllAuthorsLetter($id, $query, $n);
520 520
             case Base::PAGE_AUTHOR_DETAIL :
521
-                return new PageAuthorDetail ($id, $query, $n);
521
+                return new PageAuthorDetail($id, $query, $n);
522 522
             case Base::PAGE_ALL_TAGS :
523
-                return new PageAllTags ($id, $query, $n);
523
+                return new PageAllTags($id, $query, $n);
524 524
             case Base::PAGE_TAG_DETAIL :
525
-                return new PageTagDetail ($id, $query, $n);
525
+                return new PageTagDetail($id, $query, $n);
526 526
             case Base::PAGE_ALL_LANGUAGES :
527
-                return new PageAllLanguages ($id, $query, $n);
527
+                return new PageAllLanguages($id, $query, $n);
528 528
             case Base::PAGE_LANGUAGE_DETAIL :
529
-                return new PageLanguageDetail ($id, $query, $n);
529
+                return new PageLanguageDetail($id, $query, $n);
530 530
             case Base::PAGE_ALL_CUSTOMS :
531
-                return new PageAllCustoms ($id, $query, $n);
531
+                return new PageAllCustoms($id, $query, $n);
532 532
             case Base::PAGE_CUSTOM_DETAIL :
533
-                return new PageCustomDetail ($id, $query, $n);
533
+                return new PageCustomDetail($id, $query, $n);
534 534
             case Base::PAGE_ALL_RATINGS :
535
-                return new PageAllRating ($id, $query, $n);
535
+                return new PageAllRating($id, $query, $n);
536 536
             case Base::PAGE_RATING_DETAIL :
537
-                return new PageRatingDetail ($id, $query, $n);
537
+                return new PageRatingDetail($id, $query, $n);
538 538
             case Base::PAGE_ALL_SERIES :
539
-                return new PageAllSeries ($id, $query, $n);
539
+                return new PageAllSeries($id, $query, $n);
540 540
             case Base::PAGE_ALL_BOOKS :
541
-                return new PageAllBooks ($id, $query, $n);
541
+                return new PageAllBooks($id, $query, $n);
542 542
             case Base::PAGE_ALL_BOOKS_LETTER:
543
-                return new PageAllBooksLetter ($id, $query, $n);
543
+                return new PageAllBooksLetter($id, $query, $n);
544 544
             case Base::PAGE_ALL_RECENT_BOOKS :
545
-                return new PageRecentBooks ($id, $query, $n);
545
+                return new PageRecentBooks($id, $query, $n);
546 546
             case Base::PAGE_SERIE_DETAIL :
547
-                return new PageSerieDetail ($id, $query, $n);
547
+                return new PageSerieDetail($id, $query, $n);
548 548
             case Base::PAGE_OPENSEARCH_QUERY :
549
-                return new PageQueryResult ($id, $query, $n);
549
+                return new PageQueryResult($id, $query, $n);
550 550
             case Base::PAGE_BOOK_DETAIL :
551
-                return new PageBookDetail ($id, $query, $n);
551
+                return new PageBookDetail($id, $query, $n);
552 552
             case Base::PAGE_ALL_PUBLISHERS:
553
-                return new PageAllPublishers ($id, $query, $n);
553
+                return new PageAllPublishers($id, $query, $n);
554 554
             case Base::PAGE_PUBLISHER_DETAIL :
555
-                return new PagePublisherDetail ($id, $query, $n);
555
+                return new PagePublisherDetail($id, $query, $n);
556 556
             case Base::PAGE_ABOUT :
557
-                return new PageAbout ($id, $query, $n);
557
+                return new PageAbout($id, $query, $n);
558 558
             case Base::PAGE_CUSTOMIZE :
559
-                return new PageCustomize ($id, $query, $n);
559
+                return new PageCustomize($id, $query, $n);
560 560
             default:
561
-                $page = new Page ($id, $query, $n);
561
+                $page = new Page($id, $query, $n);
562 562
                 $page->idPage = "cops:catalog";
563 563
                 return $page;
564 564
         }
@@ -571,106 +571,106 @@  discard block
 block discarded – undo
571 571
         $this->query = $pquery;
572 572
         $this->n = $pn;
573 573
         $this->favicon = $config['cops_icon'];
574
-        $this->authorName = empty($config['cops_author_name']) ? utf8_encode('Sébastien Lucas') : $config['cops_author_name'];
575
-        $this->authorUri = empty($config['cops_author_uri']) ? 'http://blog.slucas.fr' : $config['cops_author_uri'];
576
-        $this->authorEmail = empty($config['cops_author_email']) ? '[email protected]' : $config['cops_author_email'];
574
+        $this->authorName = empty($config['cops_author_name'])?utf8_encode('Sébastien Lucas'):$config['cops_author_name'];
575
+        $this->authorUri = empty($config['cops_author_uri'])?'http://blog.slucas.fr':$config['cops_author_uri'];
576
+        $this->authorEmail = empty($config['cops_author_email'])?'[email protected]':$config['cops_author_email'];
577 577
     }
578 578
 
579
-    public function InitializeContent ()
579
+    public function InitializeContent()
580 580
     {
581 581
         global $config;
582 582
         $this->title = $config['cops_title_default'];
583 583
         $this->subtitle = $config['cops_subtitle_default'];
584
-        if (Base::noDatabaseSelected ()) {
584
+        if (Base::noDatabaseSelected()) {
585 585
             $i = 0;
586
-            foreach (Base::getDbNameList () as $key) {
587
-                $nBooks = Book::getBookCount ($i);
588
-                array_push ($this->entryArray, new Entry ($key, "cops:{$i}:catalog",
589
-                                        str_format (localize ("bookword", $nBooks), $nBooks), "text",
590
-                                        array ( new LinkNavigation ("?" . DB . "={$i}")), "", $nBooks));
586
+            foreach (Base::getDbNameList() as $key) {
587
+                $nBooks = Book::getBookCount($i);
588
+                array_push($this->entryArray, new Entry($key, "cops:{$i}:catalog",
589
+                                        str_format(localize("bookword", $nBooks), $nBooks), "text",
590
+                                        array(new LinkNavigation("?" . DB . "={$i}")), "", $nBooks));
591 591
                 $i++;
592
-                Base::clearDb ();
592
+                Base::clearDb();
593 593
             }
594 594
         } else {
595
-            if (!in_array (PageQueryResult::SCOPE_AUTHOR, getCurrentOption ('ignored_categories'))) {
596
-                array_push ($this->entryArray, Author::getCount());
595
+            if (!in_array(PageQueryResult::SCOPE_AUTHOR, getCurrentOption('ignored_categories'))) {
596
+                array_push($this->entryArray, Author::getCount());
597 597
             }
598
-            if (!in_array (PageQueryResult::SCOPE_SERIES, getCurrentOption ('ignored_categories'))) {
598
+            if (!in_array(PageQueryResult::SCOPE_SERIES, getCurrentOption('ignored_categories'))) {
599 599
                 $series = Serie::getCount();
600
-                if (!is_null ($series)) array_push ($this->entryArray, $series);
600
+                if (!is_null($series)) array_push($this->entryArray, $series);
601 601
             }
602
-            if (!in_array (PageQueryResult::SCOPE_PUBLISHER, getCurrentOption ('ignored_categories'))) {
602
+            if (!in_array(PageQueryResult::SCOPE_PUBLISHER, getCurrentOption('ignored_categories'))) {
603 603
                 $publisher = Publisher::getCount();
604
-                if (!is_null ($publisher)) array_push ($this->entryArray, $publisher);
604
+                if (!is_null($publisher)) array_push($this->entryArray, $publisher);
605 605
             }
606
-            if (!in_array (PageQueryResult::SCOPE_TAG, getCurrentOption ('ignored_categories'))) {
606
+            if (!in_array(PageQueryResult::SCOPE_TAG, getCurrentOption('ignored_categories'))) {
607 607
                 $tags = Tag::getCount();
608
-                if (!is_null ($tags)) array_push ($this->entryArray, $tags);
608
+                if (!is_null($tags)) array_push($this->entryArray, $tags);
609 609
             }
610
-            if (!in_array (PageQueryResult::SCOPE_RATING, getCurrentOption ('ignored_categories'))) {
610
+            if (!in_array(PageQueryResult::SCOPE_RATING, getCurrentOption('ignored_categories'))) {
611 611
                 $rating = Rating::getCount();
612
-                if (!is_null ($rating)) array_push ($this->entryArray, $rating);
612
+                if (!is_null($rating)) array_push($this->entryArray, $rating);
613 613
             }
614
-            if (!in_array ("language", getCurrentOption ('ignored_categories'))) {
614
+            if (!in_array("language", getCurrentOption('ignored_categories'))) {
615 615
                 $languages = Language::getCount();
616
-                if (!is_null ($languages)) array_push ($this->entryArray, $languages);
616
+                if (!is_null($languages)) array_push($this->entryArray, $languages);
617 617
             }
618 618
             foreach ($config['cops_calibre_custom_column'] as $lookup) {
619
-                $customId = CustomColumn::getCustomId ($lookup);
620
-                if (!is_null ($customId)) {
621
-                    array_push ($this->entryArray, CustomColumn::getCount($customId));
619
+                $customId = CustomColumn::getCustomId($lookup);
620
+                if (!is_null($customId)) {
621
+                    array_push($this->entryArray, CustomColumn::getCount($customId));
622 622
                 }
623 623
             }
624
-            $this->entryArray = array_merge ($this->entryArray, Book::getCount());
624
+            $this->entryArray = array_merge($this->entryArray, Book::getCount());
625 625
 
626
-            if (Base::isMultipleDatabaseEnabled ()) $this->title =  Base::getDbName ();
626
+            if (Base::isMultipleDatabaseEnabled()) $this->title = Base::getDbName();
627 627
         }
628 628
     }
629 629
 
630
-    public function isPaginated ()
630
+    public function isPaginated()
631 631
     {
632
-        return (getCurrentOption ("max_item_per_page") != -1 &&
632
+        return (getCurrentOption("max_item_per_page") != -1 &&
633 633
                 $this->totalNumber != -1 &&
634
-                $this->totalNumber > getCurrentOption ("max_item_per_page"));
634
+                $this->totalNumber > getCurrentOption("max_item_per_page"));
635 635
     }
636 636
 
637
-    public function getNextLink ()
637
+    public function getNextLink()
638 638
     {
639
-        $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
640
-        if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) {
641
-            return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate"));
639
+        $currentUrl = preg_replace("/\&n=.*?$/", "", "?" . getQueryString());
640
+        if (($this->n) * getCurrentOption("max_item_per_page") < $this->totalNumber) {
641
+            return new LinkNavigation($currentUrl . "&n=" . ($this->n + 1), "next", localize("paging.next.alternate"));
642 642
         }
643 643
         return NULL;
644 644
     }
645 645
 
646
-    public function getPrevLink ()
646
+    public function getPrevLink()
647 647
     {
648
-        $currentUrl = preg_replace ("/\&n=.*?$/", "", "?" . getQueryString ());
648
+        $currentUrl = preg_replace("/\&n=.*?$/", "", "?" . getQueryString());
649 649
         if ($this->n > 1) {
650
-            return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate"));
650
+            return new LinkNavigation($currentUrl . "&n=" . ($this->n - 1), "previous", localize("paging.previous.alternate"));
651 651
         }
652 652
         return NULL;
653 653
     }
654 654
 
655
-    public function getMaxPage ()
655
+    public function getMaxPage()
656 656
     {
657
-        return ceil ($this->totalNumber / getCurrentOption ("max_item_per_page"));
657
+        return ceil($this->totalNumber / getCurrentOption("max_item_per_page"));
658 658
     }
659 659
 
660
-    public function containsBook ()
660
+    public function containsBook()
661 661
     {
662
-        if (count ($this->entryArray) == 0) return false;
663
-        if (get_class ($this->entryArray [0]) == "EntryBook") return true;
662
+        if (count($this->entryArray) == 0) return false;
663
+        if (get_class($this->entryArray [0]) == "EntryBook") return true;
664 664
         return false;
665 665
     }
666 666
 }
667 667
 
668 668
 class PageAllAuthors extends Page
669 669
 {
670
-    public function InitializeContent ()
670
+    public function InitializeContent()
671 671
     {
672 672
         $this->title = localize("authors.title");
673
-        if (getCurrentOption ("author_split_first_letter") == 1) {
673
+        if (getCurrentOption("author_split_first_letter") == 1) {
674 674
             $this->entryArray = Author::getAllAuthorsByFirstLetter();
675 675
         }
676 676
         else {
@@ -682,28 +682,28 @@  discard block
 block discarded – undo
682 682
 
683 683
 class PageAllAuthorsLetter extends Page
684 684
 {
685
-    public function InitializeContent ()
685
+    public function InitializeContent()
686 686
     {
687
-        $this->idPage = Author::getEntryIdByLetter ($this->idGet);
688
-        $this->entryArray = Author::getAuthorsByStartingLetter ($this->idGet);
689
-        $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("authorword", count ($this->entryArray)), count ($this->entryArray)), $this->idGet);
687
+        $this->idPage = Author::getEntryIdByLetter($this->idGet);
688
+        $this->entryArray = Author::getAuthorsByStartingLetter($this->idGet);
689
+        $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("authorword", count($this->entryArray)), count($this->entryArray)), $this->idGet);
690 690
     }
691 691
 }
692 692
 
693 693
 class PageAuthorDetail extends Page
694 694
 {
695
-    public function InitializeContent ()
695
+    public function InitializeContent()
696 696
     {
697
-        $author = Author::getAuthorById ($this->idGet);
698
-        $this->idPage = $author->getEntryId ();
697
+        $author = Author::getAuthorById($this->idGet);
698
+        $this->idPage = $author->getEntryId();
699 699
         $this->title = $author->name;
700
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByAuthor ($this->idGet, $this->n);
700
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByAuthor($this->idGet, $this->n);
701 701
     }
702 702
 }
703 703
 
704 704
 class PageAllPublishers extends Page
705 705
 {
706
-    public function InitializeContent ()
706
+    public function InitializeContent()
707 707
     {
708 708
         $this->title = localize("publishers.title");
709 709
         $this->entryArray = Publisher::getAllPublishers();
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
 
714 714
 class PagePublisherDetail extends Page
715 715
 {
716
-    public function InitializeContent ()
716
+    public function InitializeContent()
717 717
     {
718
-        $publisher = Publisher::getPublisherById ($this->idGet);
718
+        $publisher = Publisher::getPublisherById($this->idGet);
719 719
         $this->title = $publisher->name;
720
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByPublisher ($this->idGet, $this->n);
721
-        $this->idPage = $publisher->getEntryId ();
720
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByPublisher($this->idGet, $this->n);
721
+        $this->idPage = $publisher->getEntryId();
722 722
     }
723 723
 }
724 724
 
725 725
 class PageAllTags extends Page
726 726
 {
727
-    public function InitializeContent ()
727
+    public function InitializeContent()
728 728
     {
729 729
         $this->title = localize("tags.title");
730 730
         $this->entryArray = Tag::getAllTags();
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 
735 735
 class PageAllLanguages extends Page
736 736
 {
737
-    public function InitializeContent ()
737
+    public function InitializeContent()
738 738
     {
739 739
         $this->title = localize("languages.title");
740 740
         $this->entryArray = Language::getAllLanguages();
@@ -744,52 +744,52 @@  discard block
 block discarded – undo
744 744
 
745 745
 class PageCustomDetail extends Page
746 746
 {
747
-    public function InitializeContent ()
747
+    public function InitializeContent()
748 748
     {
749
-        $customId = getURLParam ("custom", NULL);
750
-        $custom = CustomColumn::getCustomById ($customId, $this->idGet);
751
-        $this->idPage = $custom->getEntryId ();
749
+        $customId = getURLParam("custom", NULL);
750
+        $custom = CustomColumn::getCustomById($customId, $this->idGet);
751
+        $this->idPage = $custom->getEntryId();
752 752
         $this->title = $custom->name;
753
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom ($customId, $this->idGet, $this->n);
753
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom($customId, $this->idGet, $this->n);
754 754
     }
755 755
 }
756 756
 
757 757
 class PageAllCustoms extends Page
758 758
 {
759
-    public function InitializeContent ()
759
+    public function InitializeContent()
760 760
     {
761
-        $customId = getURLParam ("custom", NULL);
762
-        $this->title = CustomColumn::getAllTitle ($customId);
761
+        $customId = getURLParam("custom", NULL);
762
+        $this->title = CustomColumn::getAllTitle($customId);
763 763
         $this->entryArray = CustomColumn::getAllCustoms($customId);
764
-        $this->idPage = CustomColumn::getAllCustomsId ($customId);
764
+        $this->idPage = CustomColumn::getAllCustomsId($customId);
765 765
     }
766 766
 }
767 767
 
768 768
 class PageTagDetail extends Page
769 769
 {
770
-    public function InitializeContent ()
770
+    public function InitializeContent()
771 771
     {
772
-        $tag = Tag::getTagById ($this->idGet);
773
-        $this->idPage = $tag->getEntryId ();
772
+        $tag = Tag::getTagById($this->idGet);
773
+        $this->idPage = $tag->getEntryId();
774 774
         $this->title = $tag->name;
775
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByTag ($this->idGet, $this->n);
775
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByTag($this->idGet, $this->n);
776 776
     }
777 777
 }
778 778
 
779 779
 class PageLanguageDetail extends Page
780 780
 {
781
-    public function InitializeContent ()
781
+    public function InitializeContent()
782 782
     {
783
-        $language = Language::getLanguageById ($this->idGet);
784
-        $this->idPage = $language->getEntryId ();
783
+        $language = Language::getLanguageById($this->idGet);
784
+        $this->idPage = $language->getEntryId();
785 785
         $this->title = $language->lang_code;
786
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage ($this->idGet, $this->n);
786
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage($this->idGet, $this->n);
787 787
     }
788 788
 }
789 789
 
790 790
 class PageAllSeries extends Page
791 791
 {
792
-    public function InitializeContent ()
792
+    public function InitializeContent()
793 793
     {
794 794
         $this->title = localize("series.title");
795 795
         $this->entryArray = Serie::getAllSeries();
@@ -799,18 +799,18 @@  discard block
 block discarded – undo
799 799
 
800 800
 class PageSerieDetail extends Page
801 801
 {
802
-    public function InitializeContent ()
802
+    public function InitializeContent()
803 803
     {
804
-        $serie = Serie::getSerieById ($this->idGet);
804
+        $serie = Serie::getSerieById($this->idGet);
805 805
         $this->title = $serie->name;
806
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries ($this->idGet, $this->n);
807
-        $this->idPage = $serie->getEntryId ();
806
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries($this->idGet, $this->n);
807
+        $this->idPage = $serie->getEntryId();
808 808
     }
809 809
 }
810 810
 
811 811
 class PageAllRating extends Page
812 812
 {
813
-    public function InitializeContent ()
813
+    public function InitializeContent()
814 814
     {
815 815
         $this->title = localize("ratings.title");
816 816
         $this->entryArray = Rating::getAllRatings();
@@ -820,25 +820,25 @@  discard block
 block discarded – undo
820 820
 
821 821
 class PageRatingDetail extends Page
822 822
 {
823
-    public function InitializeContent ()
823
+    public function InitializeContent()
824 824
     {
825
-        $rating = Rating::getRatingById ($this->idGet);
826
-        $this->idPage = $rating->getEntryId ();
827
-        $this->title =str_format (localize ("ratingword", $rating->name/2), $rating->name/2);
828
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating ($this->idGet, $this->n);
825
+        $rating = Rating::getRatingById($this->idGet);
826
+        $this->idPage = $rating->getEntryId();
827
+        $this->title = str_format(localize("ratingword", $rating->name / 2), $rating->name / 2);
828
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating($this->idGet, $this->n);
829 829
     }
830 830
 }
831 831
 
832 832
 class PageAllBooks extends Page
833 833
 {
834
-    public function InitializeContent ()
834
+    public function InitializeContent()
835 835
     {
836
-        $this->title = localize ("allbooks.title");
837
-        if (getCurrentOption ("titles_split_first_letter") == 1) {
836
+        $this->title = localize("allbooks.title");
837
+        if (getCurrentOption("titles_split_first_letter") == 1) {
838 838
             $this->entryArray = Book::getAllBooks();
839 839
         }
840 840
         else {
841
-            list ($this->entryArray, $this->totalNumber) = Book::getBooks ($this->n);
841
+            list ($this->entryArray, $this->totalNumber) = Book::getBooks($this->n);
842 842
         }
843 843
         $this->idPage = Book::ALL_BOOKS_ID;
844 844
     }
@@ -846,25 +846,25 @@  discard block
 block discarded – undo
846 846
 
847 847
 class PageAllBooksLetter extends Page
848 848
 {
849
-    public function InitializeContent ()
849
+    public function InitializeContent()
850 850
     {
851
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter ($this->idGet, $this->n);
852
-        $this->idPage = Book::getEntryIdByLetter ($this->idGet);
851
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter($this->idGet, $this->n);
852
+        $this->idPage = Book::getEntryIdByLetter($this->idGet);
853 853
 
854 854
         $count = $this->totalNumber;
855 855
         if ($count == -1)
856
-            $count = count ($this->entryArray);
856
+            $count = count($this->entryArray);
857 857
 
858
-        $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet);
858
+        $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("bookword", $count), $count), $this->idGet);
859 859
     }
860 860
 }
861 861
 
862 862
 class PageRecentBooks extends Page
863 863
 {
864
-    public function InitializeContent ()
864
+    public function InitializeContent()
865 865
     {
866
-        $this->title = localize ("recent.title");
867
-        $this->entryArray = Book::getAllRecentBooks ();
866
+        $this->title = localize("recent.title");
867
+        $this->entryArray = Book::getAllRecentBooks();
868 868
         $this->idPage = Book::ALL_RECENT_BOOKS_ID;
869 869
     }
870 870
 }
@@ -878,16 +878,16 @@  discard block
 block discarded – undo
878 878
     const SCOPE_BOOK = "book";
879 879
     const SCOPE_PUBLISHER = "publisher";
880 880
 
881
-    private function useTypeahead () {
882
-        return !is_null (getURLParam ("search"));
881
+    private function useTypeahead() {
882
+        return !is_null(getURLParam("search"));
883 883
     }
884 884
 
885
-    private function searchByScope ($scope, $limit = FALSE) {
885
+    private function searchByScope($scope, $limit = FALSE) {
886 886
         $n = $this->n;
887 887
         $numberPerPage = NULL;
888 888
         $queryNormedAndUp = $this->query;
889
-        if (useNormAndUp ()) {
890
-            $queryNormedAndUp = normAndUp ($this->query);
889
+        if (useNormAndUp()) {
890
+            $queryNormedAndUp = normAndUp($this->query);
891 891
         }
892 892
         if ($limit) {
893 893
             $n = 1;
@@ -895,59 +895,59 @@  discard block
 block discarded – undo
895 895
         }
896 896
         switch ($scope) {
897 897
             case self::SCOPE_BOOK :
898
-                $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
898
+                $array = Book::getBooksByStartingLetter('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
899 899
                 break;
900 900
             case self::SCOPE_AUTHOR :
901
-                $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp);
901
+                $array = Author::getAuthorsForSearch('%' . $queryNormedAndUp);
902 902
                 break;
903 903
             case self::SCOPE_SERIES :
904
-                $array = Serie::getAllSeriesByQuery ($queryNormedAndUp);
904
+                $array = Serie::getAllSeriesByQuery($queryNormedAndUp);
905 905
                 break;
906 906
             case self::SCOPE_TAG :
907
-                $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage);
907
+                $array = Tag::getAllTagsByQuery($queryNormedAndUp, $n, NULL, $numberPerPage);
908 908
                 break;
909 909
             case self::SCOPE_PUBLISHER :
910
-                $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp);
910
+                $array = Publisher::getAllPublishersByQuery($queryNormedAndUp);
911 911
                 break;
912 912
             default:
913
-                $array = Book::getBooksByQuery (
914
-                    array ("all" => "%" . $queryNormedAndUp . "%"), $n);
913
+                $array = Book::getBooksByQuery(
914
+                    array("all" => "%" . $queryNormedAndUp . "%"), $n);
915 915
         }
916 916
 
917 917
         return $array;
918 918
     }
919 919
 
920
-    public function doSearchByCategory () {
921
-        $database = GetUrlParam (DB);
922
-        $out = array ();
920
+    public function doSearchByCategory() {
921
+        $database = GetUrlParam(DB);
922
+        $out = array();
923 923
         $pagequery = Base::PAGE_OPENSEARCH_QUERY;
924
-        $dbArray = array ("");
924
+        $dbArray = array("");
925 925
         $d = $database;
926 926
         $query = $this->query;
927 927
         // Special case when no databases were chosen, we search on all databases
928
-        if (Base::noDatabaseSelected ()) {
929
-            $dbArray = Base::getDbNameList ();
928
+        if (Base::noDatabaseSelected()) {
929
+            $dbArray = Base::getDbNameList();
930 930
             $d = 0;
931 931
         }
932 932
         foreach ($dbArray as $key) {
933
-            if (Base::noDatabaseSelected ()) {
934
-                array_push ($this->entryArray, new Entry ($key, DB . ":query:{$d}",
933
+            if (Base::noDatabaseSelected()) {
934
+                array_push($this->entryArray, new Entry($key, DB . ":query:{$d}",
935 935
                                         " ", "text",
936
-                                        array ( new LinkNavigation ("?" . DB . "={$d}")), "tt-header"));
937
-                Base::getDb ($d);
936
+                                        array(new LinkNavigation("?" . DB . "={$d}")), "tt-header"));
937
+                Base::getDb($d);
938 938
             }
939
-            foreach (array (PageQueryResult::SCOPE_BOOK,
939
+            foreach (array(PageQueryResult::SCOPE_BOOK,
940 940
                             PageQueryResult::SCOPE_AUTHOR,
941 941
                             PageQueryResult::SCOPE_SERIES,
942 942
                             PageQueryResult::SCOPE_TAG,
943 943
                             PageQueryResult::SCOPE_PUBLISHER) as $key) {
944
-                if (in_array($key, getCurrentOption ('ignored_categories'))) {
944
+                if (in_array($key, getCurrentOption('ignored_categories'))) {
945 945
                     continue;
946 946
                 }
947
-                $array = $this->searchByScope ($key, TRUE);
947
+                $array = $this->searchByScope($key, TRUE);
948 948
 
949 949
                 $i = 0;
950
-                if (count ($array) == 2 && is_array ($array [0])) {
950
+                if (count($array) == 2 && is_array($array [0])) {
951 951
                     $total = $array [1];
952 952
                     $array = $array [0];
953 953
                 } else {
@@ -960,32 +960,32 @@  discard block
 block discarded – undo
960 960
                     // str_format (localize("seriesword", count($array))
961 961
                     // str_format (localize("tagword", count($array))
962 962
                     // str_format (localize("publisherword", count($array))
963
-                    array_push ($this->entryArray, new Entry (str_format (localize ("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}",
964
-                                        str_format (localize("{$key}word", $total), $total), "text",
965
-                                        array ( new LinkNavigation ("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")),
966
-                                        Base::noDatabaseSelected () ? "" : "tt-header", $total));
963
+                    array_push($this->entryArray, new Entry(str_format(localize("search.result.{$key}"), $this->query), DB . ":query:{$d}:{$key}",
964
+                                        str_format(localize("{$key}word", $total), $total), "text",
965
+                                        array(new LinkNavigation("?page={$pagequery}&query={$query}&db={$d}&scope={$key}")),
966
+                                        Base::noDatabaseSelected()?"":"tt-header", $total));
967 967
                 }
968
-                if (!Base::noDatabaseSelected () && $this->useTypeahead ()) {
968
+                if (!Base::noDatabaseSelected() && $this->useTypeahead()) {
969 969
                     foreach ($array as $entry) {
970
-                        array_push ($this->entryArray, $entry);
970
+                        array_push($this->entryArray, $entry);
971 971
                         $i++;
972 972
                         if ($i > 4) { break; };
973 973
                     }
974 974
                 }
975 975
             }
976 976
             $d++;
977
-            if (Base::noDatabaseSelected ()) {
978
-                Base::clearDb ();
977
+            if (Base::noDatabaseSelected()) {
978
+                Base::clearDb();
979 979
             }
980 980
         }
981 981
         return $out;
982 982
     }
983 983
 
984
-    public function InitializeContent ()
984
+    public function InitializeContent()
985 985
     {
986
-        $scope = getURLParam ("scope");
986
+        $scope = getURLParam("scope");
987 987
         if (empty ($scope)) {
988
-            $this->title = str_format (localize ("search.result"), $this->query);
988
+            $this->title = str_format(localize("search.result"), $this->query);
989 989
         } else {
990 990
             // Comment to help the perl i18n script
991 991
             // str_format (localize ("search.result.author"), $this->query)
@@ -993,31 +993,31 @@  discard block
 block discarded – undo
993 993
             // str_format (localize ("search.result.series"), $this->query)
994 994
             // str_format (localize ("search.result.book"), $this->query)
995 995
             // str_format (localize ("search.result.publisher"), $this->query)
996
-            $this->title = str_format (localize ("search.result.{$scope}"), $this->query);
996
+            $this->title = str_format(localize("search.result.{$scope}"), $this->query);
997 997
         }
998 998
 
999 999
         $crit = "%" . $this->query . "%";
1000 1000
 
1001 1001
         // Special case when we are doing a search and no database is selected
1002
-        if (Base::noDatabaseSelected () && !$this->useTypeahead ()) {
1002
+        if (Base::noDatabaseSelected() && !$this->useTypeahead()) {
1003 1003
             $i = 0;
1004
-            foreach (Base::getDbNameList () as $key) {
1005
-                Base::clearDb ();
1006
-                list ($array, $totalNumber) = Book::getBooksByQuery (array ("all" => $crit), 1, $i, 1);
1007
-                array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}",
1008
-                                        str_format (localize ("bookword", $totalNumber), $totalNumber), "text",
1009
-                                        array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber));
1004
+            foreach (Base::getDbNameList() as $key) {
1005
+                Base::clearDb();
1006
+                list ($array, $totalNumber) = Book::getBooksByQuery(array("all" => $crit), 1, $i, 1);
1007
+                array_push($this->entryArray, new Entry($key, DB . ":query:{$i}",
1008
+                                        str_format(localize("bookword", $totalNumber), $totalNumber), "text",
1009
+                                        array(new LinkNavigation("?" . DB . "={$i}&page=9&query=" . $this->query)), "", $totalNumber));
1010 1010
                 $i++;
1011 1011
             }
1012 1012
             return;
1013 1013
         }
1014 1014
         if (empty ($scope)) {
1015
-            $this->doSearchByCategory ();
1015
+            $this->doSearchByCategory();
1016 1016
             return;
1017 1017
         }
1018 1018
 
1019
-        $array = $this->searchByScope ($scope);
1020
-        if (count ($array) == 2 && is_array ($array [0])) {
1019
+        $array = $this->searchByScope($scope);
1020
+        if (count($array) == 2 && is_array($array [0])) {
1021 1021
             list ($this->entryArray, $this->totalNumber) = $array;
1022 1022
         } else {
1023 1023
             $this->entryArray = $array;
@@ -1027,27 +1027,27 @@  discard block
 block discarded – undo
1027 1027
 
1028 1028
 class PageBookDetail extends Page
1029 1029
 {
1030
-    public function InitializeContent ()
1030
+    public function InitializeContent()
1031 1031
     {
1032
-        $this->book = Book::getBookById ($this->idGet);
1032
+        $this->book = Book::getBookById($this->idGet);
1033 1033
         $this->title = $this->book->title;
1034 1034
     }
1035 1035
 }
1036 1036
 
1037 1037
 class PageAbout extends Page
1038 1038
 {
1039
-    public function InitializeContent ()
1039
+    public function InitializeContent()
1040 1040
     {
1041
-        $this->title = localize ("about.title");
1041
+        $this->title = localize("about.title");
1042 1042
     }
1043 1043
 }
1044 1044
 
1045 1045
 class PageCustomize extends Page
1046 1046
 {
1047
-    private function isChecked ($key, $testedValue = 1) {
1048
-        $value = getCurrentOption ($key);
1049
-        if (is_array ($value)) {
1050
-            if (in_array ($testedValue, $value)) {
1047
+    private function isChecked($key, $testedValue = 1) {
1048
+        $value = getCurrentOption($key);
1049
+        if (is_array($value)) {
1050
+            if (in_array($testedValue, $value)) {
1051 1051
                 return "checked='checked'";
1052 1052
             }
1053 1053
         } else {
@@ -1058,29 +1058,29 @@  discard block
 block discarded – undo
1058 1058
         return "";
1059 1059
     }
1060 1060
 
1061
-    private function isSelected ($key, $value) {
1062
-        if (getCurrentOption ($key) == $value) {
1061
+    private function isSelected($key, $value) {
1062
+        if (getCurrentOption($key) == $value) {
1063 1063
             return "selected='selected'";
1064 1064
         }
1065 1065
         return "";
1066 1066
     }
1067 1067
 
1068
-    private function getStyleList () {
1069
-        $result = array ();
1070
-        foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) {
1071
-            if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
1072
-                array_push ($result, $m [1]);
1068
+    private function getStyleList() {
1069
+        $result = array();
1070
+        foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) {
1071
+            if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) {
1072
+                array_push($result, $m [1]);
1073 1073
             }
1074 1074
         }
1075 1075
         return $result;
1076 1076
     }
1077 1077
 
1078
-    public function InitializeContent ()
1078
+    public function InitializeContent()
1079 1079
     {
1080
-        $this->title = localize ("customize.title");
1081
-        $this->entryArray = array ();
1080
+        $this->title = localize("customize.title");
1081
+        $this->entryArray = array();
1082 1082
 
1083
-        $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR,
1083
+        $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR,
1084 1084
                                    PageQueryResult::SCOPE_TAG,
1085 1085
                                    PageQueryResult::SCOPE_SERIES,
1086 1086
                                    PageQueryResult::SCOPE_PUBLISHER,
@@ -1088,50 +1088,50 @@  discard block
 block discarded – undo
1088 1088
                                    "language");
1089 1089
 
1090 1090
         $content = "";
1091
-        array_push ($this->entryArray, new Entry ("Template", "",
1091
+        array_push($this->entryArray, new Entry("Template", "",
1092 1092
                                         "<span style='cursor: pointer;' onclick='$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text",
1093
-                                        array ()));
1093
+                                        array()));
1094 1094
         if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
1095 1095
             $content .= '<select id="style" onchange="updateCookie (this);">';
1096
-            foreach ($this-> getStyleList () as $filename) {
1097
-                $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>";
1096
+            foreach ($this-> getStyleList() as $filename) {
1097
+                $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>";
1098 1098
             }
1099 1099
             $content .= '</select>';
1100 1100
         } else {
1101
-            foreach ($this-> getStyleList () as $filename) {
1102
-                $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>";
1101
+            foreach ($this-> getStyleList() as $filename) {
1102
+                $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>";
1103 1103
             }
1104 1104
         }
1105
-        array_push ($this->entryArray, new Entry (localize ("customize.style"), "",
1105
+        array_push($this->entryArray, new Entry(localize("customize.style"), "",
1106 1106
                                         $content, "text",
1107
-                                        array ()));
1108
-        if (!useServerSideRendering ()) {
1109
-            $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />';
1110
-            array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "",
1107
+                                        array()));
1108
+        if (!useServerSideRendering()) {
1109
+            $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />';
1110
+            array_push($this->entryArray, new Entry(localize("customize.fancybox"), "",
1111 1111
                                             $content, "text",
1112
-                                            array ()));
1112
+                                            array()));
1113 1113
         }
1114
-        $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption ("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />';
1115
-        array_push ($this->entryArray, new Entry (localize ("customize.paging"), "",
1114
+        $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />';
1115
+        array_push($this->entryArray, new Entry(localize("customize.paging"), "",
1116 1116
                                         $content, "text",
1117
-                                        array ()));
1118
-        $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />';
1119
-        array_push ($this->entryArray, new Entry (localize ("customize.email"), "",
1117
+                                        array()));
1118
+        $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />';
1119
+        array_push($this->entryArray, new Entry(localize("customize.email"), "",
1120 1120
                                         $content, "text",
1121
-                                        array ()));
1122
-        $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />';
1123
-        array_push ($this->entryArray, new Entry (localize ("customize.filter"), "",
1121
+                                        array()));
1122
+        $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />';
1123
+        array_push($this->entryArray, new Entry(localize("customize.filter"), "",
1124 1124
                                         $content, "text",
1125
-                                        array ()));
1125
+                                        array()));
1126 1126
         $content = "";
1127 1127
         foreach ($ignoredBaseArray as $key) {
1128
-            $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s");
1129
-            $content .=  '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> ';
1128
+            $keyPlural = preg_replace('/(ss)$/', 's', $key . "s");
1129
+            $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> ';
1130 1130
         }
1131 1131
 
1132
-        array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "",
1132
+        array_push($this->entryArray, new Entry(localize("customize.ignored"), "",
1133 1133
                                         $content, "text",
1134
-                                        array ()));
1134
+                                        array()));
1135 1135
     }
1136 1136
 }
1137 1137
 
@@ -1167,142 +1167,142 @@  discard block
 block discarded – undo
1167 1167
 
1168 1168
     private static $db = NULL;
1169 1169
 
1170
-    public static function isMultipleDatabaseEnabled () {
1170
+    public static function isMultipleDatabaseEnabled() {
1171 1171
         global $config;
1172
-        return is_array ($config['calibre_directory']);
1172
+        return is_array($config['calibre_directory']);
1173 1173
     }
1174 1174
 
1175
-    public static function useAbsolutePath () {
1175
+    public static function useAbsolutePath() {
1176 1176
         global $config;
1177 1177
         $path = self::getDbDirectory();
1178
-        return preg_match ('/^\//', $path) || // Linux /
1179
-               preg_match ('/^\w\:/', $path); // Windows X:
1178
+        return preg_match('/^\//', $path) || // Linux /
1179
+               preg_match('/^\w\:/', $path); // Windows X:
1180 1180
     }
1181 1181
 
1182
-    public static function noDatabaseSelected () {
1183
-        return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
1182
+    public static function noDatabaseSelected() {
1183
+        return self::isMultipleDatabaseEnabled() && is_null(GetUrlParam(DB));
1184 1184
     }
1185 1185
 
1186
-    public static function getDbList () {
1186
+    public static function getDbList() {
1187 1187
         global $config;
1188
-        if (self::isMultipleDatabaseEnabled ()) {
1188
+        if (self::isMultipleDatabaseEnabled()) {
1189 1189
             return $config['calibre_directory'];
1190 1190
         } else {
1191
-            return array ("" => $config['calibre_directory']);
1191
+            return array("" => $config['calibre_directory']);
1192 1192
         }
1193 1193
     }
1194 1194
 
1195
-    public static function getDbNameList () {
1195
+    public static function getDbNameList() {
1196 1196
         global $config;
1197
-        if (self::isMultipleDatabaseEnabled ()) {
1198
-            return array_keys ($config['calibre_directory']);
1197
+        if (self::isMultipleDatabaseEnabled()) {
1198
+            return array_keys($config['calibre_directory']);
1199 1199
         } else {
1200
-            return array ("");
1200
+            return array("");
1201 1201
         }
1202 1202
     }
1203 1203
 
1204
-    public static function getDbName ($database = NULL) {
1204
+    public static function getDbName($database = NULL) {
1205 1205
         global $config;
1206
-        if (self::isMultipleDatabaseEnabled ()) {
1207
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
1206
+        if (self::isMultipleDatabaseEnabled()) {
1207
+            if (is_null($database)) $database = GetUrlParam(DB, 0);
1208 1208
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
1209
-                return self::error ($database);
1209
+                return self::error($database);
1210 1210
             }
1211
-            $array = array_keys ($config['calibre_directory']);
1211
+            $array = array_keys($config['calibre_directory']);
1212 1212
             return  $array[$database];
1213 1213
         }
1214 1214
         return "";
1215 1215
     }
1216 1216
 
1217
-    public static function getDbDirectory ($database = NULL) {
1217
+    public static function getDbDirectory($database = NULL) {
1218 1218
         global $config;
1219
-        if (self::isMultipleDatabaseEnabled ()) {
1220
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
1219
+        if (self::isMultipleDatabaseEnabled()) {
1220
+            if (is_null($database)) $database = GetUrlParam(DB, 0);
1221 1221
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
1222
-                return self::error ($database);
1222
+                return self::error($database);
1223 1223
             }
1224
-            $array = array_values ($config['calibre_directory']);
1224
+            $array = array_values($config['calibre_directory']);
1225 1225
             return  $array[$database];
1226 1226
         }
1227 1227
         return $config['calibre_directory'];
1228 1228
     }
1229 1229
 
1230 1230
 
1231
-    public static function getDbFileName ($database = NULL) {
1232
-        return self::getDbDirectory ($database) .'metadata.db';
1231
+    public static function getDbFileName($database = NULL) {
1232
+        return self::getDbDirectory($database) . 'metadata.db';
1233 1233
     }
1234 1234
 
1235
-    private static function error ($database) {
1235
+    private static function error($database) {
1236 1236
         if (php_sapi_name() != "cli") {
1237 1237
             header("location: checkconfig.php?err=1");
1238 1238
         }
1239 1239
         throw new Exception("Database <{$database}> not found.");
1240 1240
     }
1241 1241
 
1242
-    public static function getDb ($database = NULL) {
1243
-        if (is_null (self::$db)) {
1242
+    public static function getDb($database = NULL) {
1243
+        if (is_null(self::$db)) {
1244 1244
             try {
1245
-                if (is_readable (self::getDbFileName ($database))) {
1246
-                    self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
1247
-                    if (useNormAndUp ()) {
1248
-                        self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1);
1245
+                if (is_readable(self::getDbFileName($database))) {
1246
+                    self::$db = new PDO('sqlite:' . self::getDbFileName($database));
1247
+                    if (useNormAndUp()) {
1248
+                        self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1);
1249 1249
                     }
1250 1250
                 } else {
1251
-                    self::error ($database);
1251
+                    self::error($database);
1252 1252
                 }
1253 1253
             } catch (Exception $e) {
1254
-                self::error ($database);
1254
+                self::error($database);
1255 1255
             }
1256 1256
         }
1257 1257
         return self::$db;
1258 1258
     }
1259 1259
 
1260
-    public static function checkDatabaseAvailability () {
1261
-        if (self::noDatabaseSelected ()) {
1262
-            for ($i = 0; $i < count (self::getDbList ()); $i++) {
1263
-                self::getDb ($i);
1264
-                self::clearDb ();
1260
+    public static function checkDatabaseAvailability() {
1261
+        if (self::noDatabaseSelected()) {
1262
+            for ($i = 0; $i < count(self::getDbList()); $i++) {
1263
+                self::getDb($i);
1264
+                self::clearDb();
1265 1265
             }
1266 1266
         } else {
1267
-            self::getDb ();
1267
+            self::getDb();
1268 1268
         }
1269 1269
         return true;
1270 1270
     }
1271 1271
 
1272
-    public static function clearDb () {
1272
+    public static function clearDb() {
1273 1273
         self::$db = NULL;
1274 1274
     }
1275 1275
 
1276
-    public static function executeQuerySingle ($query, $database = NULL) {
1277
-        return self::getDb ($database)->query($query)->fetchColumn();
1276
+    public static function executeQuerySingle($query, $database = NULL) {
1277
+        return self::getDb($database)->query($query)->fetchColumn();
1278 1278
     }
1279 1279
 
1280 1280
     public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
1281 1281
         if (!$numberOfString) {
1282 1282
             $numberOfString = $table . ".alphabetical";
1283 1283
         }
1284
-        $count = self::executeQuerySingle ('select count(*) from ' . $table);
1284
+        $count = self::executeQuerySingle('select count(*) from ' . $table);
1285 1285
         if ($count == 0) return NULL;
1286
-        $entry = new Entry (localize($table . ".title"), $id,
1287
-            str_format (localize($numberOfString, $count), $count), "text",
1288
-            array ( new LinkNavigation ("?page=".$pageId)), "", $count);
1286
+        $entry = new Entry(localize($table . ".title"), $id,
1287
+            str_format(localize($numberOfString, $count), $count), "text",
1288
+            array(new LinkNavigation("?page=" . $pageId)), "", $count);
1289 1289
         return $entry;
1290 1290
     }
1291 1291
 
1292
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
1293
-        list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
1292
+    public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) {
1293
+        list (, $result) = self::executeQuery($query, $columns, "", $params, -1);
1294 1294
         $entryArray = array();
1295
-        while ($post = $result->fetchObject ())
1295
+        while ($post = $result->fetchObject())
1296 1296
         {
1297
-            $instance = new $category ($post);
1297
+            $instance = new $category($post);
1298 1298
             if (property_exists($post, "sort")) {
1299 1299
                 $title = $post->sort;
1300 1300
             } else {
1301 1301
                 $title = $post->name;
1302 1302
             }
1303
-            array_push ($entryArray, new Entry ($title, $instance->getEntryId (),
1304
-                str_format (localize("bookword", $post->count), $post->count), "text",
1305
-                array ( new LinkNavigation ($instance->getUri ())), "", $post->count));
1303
+            array_push($entryArray, new Entry($title, $instance->getEntryId(),
1304
+                str_format(localize("bookword", $post->count), $post->count), "text",
1305
+                array(new LinkNavigation($instance->getUri())), "", $post->count));
1306 1306
         }
1307 1307
         return $entryArray;
1308 1308
     }
@@ -1310,30 +1310,30 @@  discard block
 block discarded – undo
1310 1310
     public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
1311 1311
         $totalResult = -1;
1312 1312
 
1313
-        if (useNormAndUp ()) {
1313
+        if (useNormAndUp()) {
1314 1314
             $query = preg_replace("/upper/", "normAndUp", $query);
1315 1315
             $columns = preg_replace("/upper/", "normAndUp", $columns);
1316 1316
         }
1317 1317
 
1318
-        if (is_null ($numberPerPage)) {
1319
-            $numberPerPage = getCurrentOption ("max_item_per_page");
1318
+        if (is_null($numberPerPage)) {
1319
+            $numberPerPage = getCurrentOption("max_item_per_page");
1320 1320
         }
1321 1321
 
1322 1322
         if ($numberPerPage != -1 && $n != -1)
1323 1323
         {
1324 1324
             // First check total number of results
1325
-            $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
1326
-            $result->execute ($params);
1327
-            $totalResult = $result->fetchColumn ();
1325
+            $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter));
1326
+            $result->execute($params);
1327
+            $totalResult = $result->fetchColumn();
1328 1328
 
1329 1329
             // Next modify the query and params
1330 1330
             $query .= " limit ?, ?";
1331
-            array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage);
1331
+            array_push($params, ($n - 1) * $numberPerPage, $numberPerPage);
1332 1332
         }
1333 1333
 
1334
-        $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter));
1335
-        $result->execute ($params);
1336
-        return array ($totalResult, $result);
1334
+        $result = self::getDb($database)->prepare(str_format($query, $columns, $filter));
1335
+        $result->execute($params);
1336
+        return array($totalResult, $result);
1337 1337
     }
1338 1338
 
1339 1339
 }
Please login to merge, or discard this patch.
Braces   +186 added lines, -99 removed lines patch added patch discarded remove patch
@@ -13,12 +13,14 @@  discard block
 block discarded – undo
13 13
 date_default_timezone_set($config['default_timezone']);
14 14
 
15 15
 
16
-function useServerSideRendering () {
16
+function useServerSideRendering ()
17
+{
17 18
     global $config;
18 19
     return preg_match("/" . $config['cops_server_side_render'] . "/", $_SERVER['HTTP_USER_AGENT']);
19 20
 }
20 21
 
21
-function serverSideRender ($data) {
22
+function serverSideRender ($data)
23
+{
22 24
     // Get the templates
23 25
     $theme = getCurrentTemplate ();
24 26
     $header = file_get_contents('templates/' . $theme . '/header.html');
@@ -46,28 +48,32 @@  discard block
 block discarded – undo
46 48
     return NULL;
47 49
 }
48 50
 
49
-function getQueryString () {
51
+function getQueryString ()
52
+{
50 53
     if ( isset($_SERVER['QUERY_STRING']) ) {
51 54
         return $_SERVER['QUERY_STRING'];
52 55
     }
53 56
     return "";
54 57
 }
55 58
 
56
-function notFound () {
59
+function notFound ()
60
+{
57 61
     header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
58 62
     header("Status: 404 Not Found");
59 63
 
60 64
     $_SERVER['REDIRECT_STATUS'] = 404;
61 65
 }
62 66
 
63
-function getURLParam ($name, $default = NULL) {
67
+function getURLParam ($name, $default = NULL)
68
+{
64 69
     if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
65 70
         return $_GET[$name];
66 71
     }
67 72
     return $default;
68 73
 }
69 74
 
70
-function getCurrentOption ($option) {
75
+function getCurrentOption ($option)
76
+{
71 77
     global $config;
72 78
     if (isset($_COOKIE[$option])) {
73 79
         if (isset($config ["cops_" . $option]) && is_array ($config ["cops_" . $option])) {
@@ -83,19 +89,23 @@  discard block
 block discarded – undo
83 89
     return "";
84 90
 }
85 91
 
86
-function getCurrentCss () {
92
+function getCurrentCss ()
93
+{
87 94
     return "templates/" . getCurrentTemplate () . "/styles/style-" . getCurrentOption ("style") . ".css";
88 95
 }
89 96
 
90
-function getCurrentTemplate () {
97
+function getCurrentTemplate ()
98
+{
91 99
     return getCurrentOption ("template");
92 100
 }
93 101
 
94
-function getUrlWithVersion ($url) {
102
+function getUrlWithVersion ($url)
103
+{
95 104
     return $url . "?v=" . VERSION;
96 105
 }
97 106
 
98
-function xml2xhtml($xml) {
107
+function xml2xhtml($xml)
108
+{
99 109
     return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', create_function('$m', '
100 110
         $xhtml_tags = array("br", "hr", "input", "frame", "img", "area", "link", "col", "base", "basefont", "param");
101 111
         return in_array($m[1], $xhtml_tags) ? "<$m[1]$m[2] />" : "<$m[1]$m[2]></$m[1]>";
@@ -135,12 +145,15 @@  discard block
 block discarded – undo
135 145
     $errors = libxml_get_errors();
136 146
 
137 147
     foreach ($errors as $error) {
138
-        if ($error->code == 801) return false;
148
+        if ($error->code == 801) {
149
+            return false;
150
+        }
139 151
     }
140 152
     return true;
141 153
 }
142 154
 
143
-function html2xhtml ($html) {
155
+function html2xhtml ($html)
156
+{
144 157
     $doc = new DOMDocument();
145 158
     libxml_use_internal_errors(true);
146 159
 
@@ -160,7 +173,9 @@  discard block
 block discarded – undo
160 173
     }
161 174
     */
162 175
 
163
-    if (!are_libxml_errors_ok ()) $output = "HTML code not valid.";
176
+    if (!are_libxml_errors_ok ()) {
177
+        $output = "HTML code not valid.";
178
+    }
164 179
 
165 180
     libxml_use_internal_errors(false);
166 181
     return $output;
@@ -170,7 +185,8 @@  discard block
 block discarded – undo
170 185
  * This method is a direct copy-paste from
171 186
  * http://tmont.com/blargh/2010/1/string-format-in-php
172 187
  */
173
-function str_format($format) {
188
+function str_format($format)
189
+{
174 190
     $args = func_get_args();
175 191
     $format = array_shift($args);
176 192
 
@@ -190,7 +206,8 @@  discard block
 block discarded – undo
190 206
  * languages id are normalized : fr-fr -> fr_FR
191 207
  * @return array of languages
192 208
  */
193
-function getAcceptLanguages() {
209
+function getAcceptLanguages()
210
+{
194 211
     $langs = array();
195 212
 
196 213
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
@@ -218,7 +235,9 @@  discard block
 block discarded – undo
218 235
 
219 236
             // set default to 1 for any without q factor
220 237
             foreach ($langs as $lang => $val) {
221
-                if ($val === '') $langs[$lang] = 1;
238
+                if ($val === '') {
239
+                    $langs[$lang] = 1;
240
+                }
222 241
             }
223 242
 
224 243
             // sort list based on value
@@ -233,14 +252,14 @@  discard block
 block discarded – undo
233 252
  * Find the best translation file possible based on the accepted languages
234 253
  * @return array of language and language file
235 254
  */
236
-function getLangAndTranslationFile() {
255
+function getLangAndTranslationFile()
256
+{
237 257
     global $config;
238 258
     $langs = array();
239 259
     $lang = "en";
240 260
     if (!empty($config['cops_language'])) {
241 261
         $lang = $config['cops_language'];
242
-    }
243
-    elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
262
+    } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
244 263
         $langs = getAcceptLanguages();
245 264
     }
246 265
     //echo var_dump($langs);
@@ -263,14 +282,18 @@  discard block
 block discarded – undo
263 282
  * This method is based on this page
264 283
  * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
265 284
  */
266
-function localize($phrase, $count=-1, $reset=false) {
285
+function localize($phrase, $count=-1, $reset=false)
286
+{
267 287
     global $config;
268
-    if ($count == 0)
269
-        $phrase .= ".none";
270
-    if ($count == 1)
271
-        $phrase .= ".one";
272
-    if ($count > 1)
273
-        $phrase .= ".many";
288
+    if ($count == 0) {
289
+            $phrase .= ".none";
290
+    }
291
+    if ($count == 1) {
292
+            $phrase .= ".one";
293
+    }
294
+    if ($count > 1) {
295
+            $phrase .= ".many";
296
+    }
274 297
 
275 298
     /* Static keyword is used to ensure the file is loaded only once */
276 299
     static $translations = NULL;
@@ -295,8 +318,7 @@  discard block
 block discarded – undo
295 318
                 unset ($translations [$key]);
296 319
             }
297 320
         }
298
-        if ($lang_file_en)
299
-        {
321
+        if ($lang_file_en) {
300 322
             $lang_file_content = file_get_contents($lang_file_en);
301 323
             $translations_en = json_decode($lang_file_content, true);
302 324
             $translations = array_merge ($translations_en, $translations);
@@ -308,7 +330,8 @@  discard block
 block discarded – undo
308 330
     return $phrase;
309 331
 }
310 332
 
311
-function addURLParameter($urlParams, $paramName, $paramValue) {
333
+function addURLParameter($urlParams, $paramName, $paramValue)
334
+{
312 335
     if (empty ($urlParams)) {
313 336
         $urlParams = "";
314 337
     }
@@ -327,17 +350,20 @@  discard block
 block discarded – undo
327 350
     return $start . http_build_query($params);
328 351
 }
329 352
 
330
-function useNormAndUp () {
353
+function useNormAndUp ()
354
+{
331 355
     global $config;
332 356
     return $config ['cops_normalized_search'] == "1";
333 357
 }
334 358
 
335
-function normalizeUtf8String( $s) {
359
+function normalizeUtf8String( $s)
360
+{
336 361
     include_once 'transliteration.php';
337 362
     return _transliteration_process($s);
338 363
 }
339 364
 
340
-function normAndUp ($s) {
365
+function normAndUp ($s)
366
+{
341 367
     return mb_strtoupper (normalizeUtf8String($s), 'UTF-8');
342 368
 }
343 369
 
@@ -356,7 +382,8 @@  discard block
 block discarded – undo
356 382
     public $facetGroup;
357 383
     public $activeFacet;
358 384
 
359
-    public function __construct($phref, $ptype, $prel = NULL, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
385
+    public function __construct($phref, $ptype, $prel = NULL, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE)
386
+    {
360 387
         $this->href = $phref;
361 388
         $this->type = $ptype;
362 389
         $this->rel = $prel;
@@ -365,11 +392,13 @@  discard block
 block discarded – undo
365 392
         $this->activeFacet = $pactiveFacet;
366 393
     }
367 394
 
368
-    public function hrefXhtml () {
395
+    public function hrefXhtml ()
396
+    {
369 397
         return $this->href;
370 398
     }
371 399
 
372
-    public function getScriptName() {
400
+    public function getScriptName()
401
+    {
373 402
         $parts = explode('/', $_SERVER["SCRIPT_NAME"]);
374 403
         return $parts[count($parts) - 1];
375 404
     }
@@ -377,10 +406,15 @@  discard block
 block discarded – undo
377 406
 
378 407
 class LinkNavigation extends Link
379 408
 {
380
-    public function __construct($phref, $prel = NULL, $ptitle = NULL) {
409
+    public function __construct($phref, $prel = NULL, $ptitle = NULL)
410
+    {
381 411
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
382
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
383
-        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
412
+        if (!is_null (GetUrlParam (DB))) {
413
+            $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
414
+        }
415
+        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) {
416
+            $this->href = "?" . $this->href;
417
+        }
384 418
         if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) {
385 419
             $this->href = "index.php" . $this->href;
386 420
         } else {
@@ -391,9 +425,12 @@  discard block
 block discarded – undo
391 425
 
392 426
 class LinkFacet extends Link
393 427
 {
394
-    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
428
+    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE)
429
+    {
395 430
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
396
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
431
+        if (!is_null (GetUrlParam (DB))) {
432
+            $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
433
+        }
397 434
         $this->href = parent::getScriptName() . $this->href;
398 435
     }
399 436
 }
@@ -423,7 +460,8 @@  discard block
 block discarded – undo
423 460
         Publisher::ALL_PUBLISHERS_ID => 'images/publisher.png'
424 461
     );
425 462
 
426
-    public function getUpdatedTime () {
463
+    public function getUpdatedTime ()
464
+    {
427 465
         if (!is_null ($this->localUpdated)) {
428 466
             return date (DATE_ATOM, $this->localUpdated);
429 467
         }
@@ -433,7 +471,8 @@  discard block
 block discarded – undo
433 471
         return date (DATE_ATOM, self::$updated);
434 472
     }
435 473
 
436
-    public function getNavLink () {
474
+    public function getNavLink ()
475
+    {
437 476
         foreach ($this->linkArray as $link) {
438 477
             if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; }
439 478
 
@@ -442,7 +481,8 @@  discard block
 block discarded – undo
442 481
         return "#";
443 482
     }
444 483
 
445
-    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0) {
484
+    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0)
485
+    {
446 486
         global $config;
447 487
         $this->title = $ptitle;
448 488
         $this->id = $pid;
@@ -452,10 +492,8 @@  discard block
 block discarded – undo
452 492
         $this->className = $pclass;
453 493
         $this->numberOfElement = $pcount;
454 494
 
455
-        if ($config['cops_show_icons'] == 1)
456
-        {
457
-            foreach (self::$icons as $reg => $image)
458
-            {
495
+        if ($config['cops_show_icons'] == 1) {
496
+            foreach (self::$icons as $reg => $image) {
459 497
                 if (preg_match ("/" . $reg . "/", $pid)) {
460 498
                     array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
461 499
                     break;
@@ -463,7 +501,9 @@  discard block
 block discarded – undo
463 501
             }
464 502
         }
465 503
 
466
-        if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
504
+        if (!is_null (GetUrlParam (DB))) {
505
+            $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
506
+        }
467 507
     }
468 508
 }
469 509
 
@@ -471,24 +511,29 @@  discard block
 block discarded – undo
471 511
 {
472 512
     public $book;
473 513
 
474
-    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) {
514
+    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook)
515
+    {
475 516
         parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
476 517
         $this->book = $pbook;
477 518
         $this->localUpdated = $pbook->timestamp;
478 519
     }
479 520
 
480
-    public function getCoverThumbnail () {
521
+    public function getCoverThumbnail ()
522
+    {
481 523
         foreach ($this->linkArray as $link) {
482
-            if ($link->rel == Link::OPDS_THUMBNAIL_TYPE)
483
-                return $link->hrefXhtml ();
524
+            if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) {
525
+                            return $link->hrefXhtml ();
526
+            }
484 527
         }
485 528
         return null;
486 529
     }
487 530
 
488
-    public function getCover () {
531
+    public function getCover ()
532
+    {
489 533
         foreach ($this->linkArray as $link) {
490
-            if ($link->rel == Link::OPDS_IMAGE_TYPE)
491
-                return $link->hrefXhtml ();
534
+            if ($link->rel == Link::OPDS_IMAGE_TYPE) {
535
+                            return $link->hrefXhtml ();
536
+            }
492 537
         }
493 538
         return null;
494 539
     }
@@ -564,7 +609,8 @@  discard block
 block discarded – undo
564 609
         }
565 610
     }
566 611
 
567
-    public function __construct($pid, $pquery, $pn) {
612
+    public function __construct($pid, $pquery, $pn)
613
+    {
568 614
         global $config;
569 615
 
570 616
         $this->idGet = $pid;
@@ -597,23 +643,33 @@  discard block
 block discarded – undo
597 643
             }
598 644
             if (!in_array (PageQueryResult::SCOPE_SERIES, getCurrentOption ('ignored_categories'))) {
599 645
                 $series = Serie::getCount();
600
-                if (!is_null ($series)) array_push ($this->entryArray, $series);
646
+                if (!is_null ($series)) {
647
+                    array_push ($this->entryArray, $series);
648
+                }
601 649
             }
602 650
             if (!in_array (PageQueryResult::SCOPE_PUBLISHER, getCurrentOption ('ignored_categories'))) {
603 651
                 $publisher = Publisher::getCount();
604
-                if (!is_null ($publisher)) array_push ($this->entryArray, $publisher);
652
+                if (!is_null ($publisher)) {
653
+                    array_push ($this->entryArray, $publisher);
654
+                }
605 655
             }
606 656
             if (!in_array (PageQueryResult::SCOPE_TAG, getCurrentOption ('ignored_categories'))) {
607 657
                 $tags = Tag::getCount();
608
-                if (!is_null ($tags)) array_push ($this->entryArray, $tags);
658
+                if (!is_null ($tags)) {
659
+                    array_push ($this->entryArray, $tags);
660
+                }
609 661
             }
610 662
             if (!in_array (PageQueryResult::SCOPE_RATING, getCurrentOption ('ignored_categories'))) {
611 663
                 $rating = Rating::getCount();
612
-                if (!is_null ($rating)) array_push ($this->entryArray, $rating);
664
+                if (!is_null ($rating)) {
665
+                    array_push ($this->entryArray, $rating);
666
+                }
613 667
             }
614 668
             if (!in_array ("language", getCurrentOption ('ignored_categories'))) {
615 669
                 $languages = Language::getCount();
616
-                if (!is_null ($languages)) array_push ($this->entryArray, $languages);
670
+                if (!is_null ($languages)) {
671
+                    array_push ($this->entryArray, $languages);
672
+                }
617 673
             }
618 674
             foreach ($config['cops_calibre_custom_column'] as $lookup) {
619 675
                 $customId = CustomColumn::getCustomId ($lookup);
@@ -623,7 +679,9 @@  discard block
 block discarded – undo
623 679
             }
624 680
             $this->entryArray = array_merge ($this->entryArray, Book::getCount());
625 681
 
626
-            if (Base::isMultipleDatabaseEnabled ()) $this->title =  Base::getDbName ();
682
+            if (Base::isMultipleDatabaseEnabled ()) {
683
+                $this->title =  Base::getDbName ();
684
+            }
627 685
         }
628 686
     }
629 687
 
@@ -659,8 +717,12 @@  discard block
 block discarded – undo
659 717
 
660 718
     public function containsBook ()
661 719
     {
662
-        if (count ($this->entryArray) == 0) return false;
663
-        if (get_class ($this->entryArray [0]) == "EntryBook") return true;
720
+        if (count ($this->entryArray) == 0) {
721
+            return false;
722
+        }
723
+        if (get_class ($this->entryArray [0]) == "EntryBook") {
724
+            return true;
725
+        }
664 726
         return false;
665 727
     }
666 728
 }
@@ -672,8 +734,7 @@  discard block
 block discarded – undo
672 734
         $this->title = localize("authors.title");
673 735
         if (getCurrentOption ("author_split_first_letter") == 1) {
674 736
             $this->entryArray = Author::getAllAuthorsByFirstLetter();
675
-        }
676
-        else {
737
+        } else {
677 738
             $this->entryArray = Author::getAllAuthors();
678 739
         }
679 740
         $this->idPage = Author::ALL_AUTHORS_ID;
@@ -836,8 +897,7 @@  discard block
 block discarded – undo
836 897
         $this->title = localize ("allbooks.title");
837 898
         if (getCurrentOption ("titles_split_first_letter") == 1) {
838 899
             $this->entryArray = Book::getAllBooks();
839
-        }
840
-        else {
900
+        } else {
841 901
             list ($this->entryArray, $this->totalNumber) = Book::getBooks ($this->n);
842 902
         }
843 903
         $this->idPage = Book::ALL_BOOKS_ID;
@@ -852,8 +912,9 @@  discard block
 block discarded – undo
852 912
         $this->idPage = Book::getEntryIdByLetter ($this->idGet);
853 913
 
854 914
         $count = $this->totalNumber;
855
-        if ($count == -1)
856
-            $count = count ($this->entryArray);
915
+        if ($count == -1) {
916
+                    $count = count ($this->entryArray);
917
+        }
857 918
 
858 919
         $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet);
859 920
     }
@@ -878,11 +939,13 @@  discard block
 block discarded – undo
878 939
     const SCOPE_BOOK = "book";
879 940
     const SCOPE_PUBLISHER = "publisher";
880 941
 
881
-    private function useTypeahead () {
942
+    private function useTypeahead ()
943
+    {
882 944
         return !is_null (getURLParam ("search"));
883 945
     }
884 946
 
885
-    private function searchByScope ($scope, $limit = FALSE) {
947
+    private function searchByScope ($scope, $limit = FALSE)
948
+    {
886 949
         $n = $this->n;
887 950
         $numberPerPage = NULL;
888 951
         $queryNormedAndUp = $this->query;
@@ -917,7 +980,8 @@  discard block
 block discarded – undo
917 980
         return $array;
918 981
     }
919 982
 
920
-    public function doSearchByCategory () {
983
+    public function doSearchByCategory ()
984
+    {
921 985
         $database = GetUrlParam (DB);
922 986
         $out = array ();
923 987
         $pagequery = Base::PAGE_OPENSEARCH_QUERY;
@@ -1044,7 +1108,8 @@  discard block
 block discarded – undo
1044 1108
 
1045 1109
 class PageCustomize extends Page
1046 1110
 {
1047
-    private function isChecked ($key, $testedValue = 1) {
1111
+    private function isChecked ($key, $testedValue = 1)
1112
+    {
1048 1113
         $value = getCurrentOption ($key);
1049 1114
         if (is_array ($value)) {
1050 1115
             if (in_array ($testedValue, $value)) {
@@ -1058,14 +1123,16 @@  discard block
 block discarded – undo
1058 1123
         return "";
1059 1124
     }
1060 1125
 
1061
-    private function isSelected ($key, $value) {
1126
+    private function isSelected ($key, $value)
1127
+    {
1062 1128
         if (getCurrentOption ($key) == $value) {
1063 1129
             return "selected='selected'";
1064 1130
         }
1065 1131
         return "";
1066 1132
     }
1067 1133
 
1068
-    private function getStyleList () {
1134
+    private function getStyleList ()
1135
+    {
1069 1136
         $result = array ();
1070 1137
         foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) {
1071 1138
             if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
@@ -1167,23 +1234,27 @@  discard block
 block discarded – undo
1167 1234
 
1168 1235
     private static $db = NULL;
1169 1236
 
1170
-    public static function isMultipleDatabaseEnabled () {
1237
+    public static function isMultipleDatabaseEnabled ()
1238
+    {
1171 1239
         global $config;
1172 1240
         return is_array ($config['calibre_directory']);
1173 1241
     }
1174 1242
 
1175
-    public static function useAbsolutePath () {
1243
+    public static function useAbsolutePath ()
1244
+    {
1176 1245
         global $config;
1177 1246
         $path = self::getDbDirectory();
1178 1247
         return preg_match ('/^\//', $path) || // Linux /
1179 1248
                preg_match ('/^\w\:/', $path); // Windows X:
1180 1249
     }
1181 1250
 
1182
-    public static function noDatabaseSelected () {
1251
+    public static function noDatabaseSelected ()
1252
+    {
1183 1253
         return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
1184 1254
     }
1185 1255
 
1186
-    public static function getDbList () {
1256
+    public static function getDbList ()
1257
+    {
1187 1258
         global $config;
1188 1259
         if (self::isMultipleDatabaseEnabled ()) {
1189 1260
             return $config['calibre_directory'];
@@ -1192,7 +1263,8 @@  discard block
 block discarded – undo
1192 1263
         }
1193 1264
     }
1194 1265
 
1195
-    public static function getDbNameList () {
1266
+    public static function getDbNameList ()
1267
+    {
1196 1268
         global $config;
1197 1269
         if (self::isMultipleDatabaseEnabled ()) {
1198 1270
             return array_keys ($config['calibre_directory']);
@@ -1201,10 +1273,13 @@  discard block
 block discarded – undo
1201 1273
         }
1202 1274
     }
1203 1275
 
1204
-    public static function getDbName ($database = NULL) {
1276
+    public static function getDbName ($database = NULL)
1277
+    {
1205 1278
         global $config;
1206 1279
         if (self::isMultipleDatabaseEnabled ()) {
1207
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
1280
+            if (is_null ($database)) {
1281
+                $database = GetUrlParam (DB, 0);
1282
+            }
1208 1283
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
1209 1284
                 return self::error ($database);
1210 1285
             }
@@ -1214,10 +1289,13 @@  discard block
 block discarded – undo
1214 1289
         return "";
1215 1290
     }
1216 1291
 
1217
-    public static function getDbDirectory ($database = NULL) {
1292
+    public static function getDbDirectory ($database = NULL)
1293
+    {
1218 1294
         global $config;
1219 1295
         if (self::isMultipleDatabaseEnabled ()) {
1220
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
1296
+            if (is_null ($database)) {
1297
+                $database = GetUrlParam (DB, 0);
1298
+            }
1221 1299
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
1222 1300
                 return self::error ($database);
1223 1301
             }
@@ -1228,18 +1306,21 @@  discard block
 block discarded – undo
1228 1306
     }
1229 1307
 
1230 1308
 
1231
-    public static function getDbFileName ($database = NULL) {
1309
+    public static function getDbFileName ($database = NULL)
1310
+    {
1232 1311
         return self::getDbDirectory ($database) .'metadata.db';
1233 1312
     }
1234 1313
 
1235
-    private static function error ($database) {
1314
+    private static function error ($database)
1315
+    {
1236 1316
         if (php_sapi_name() != "cli") {
1237 1317
             header("location: checkconfig.php?err=1");
1238 1318
         }
1239 1319
         throw new Exception("Database <{$database}> not found.");
1240 1320
     }
1241 1321
 
1242
-    public static function getDb ($database = NULL) {
1322
+    public static function getDb ($database = NULL)
1323
+    {
1243 1324
         if (is_null (self::$db)) {
1244 1325
             try {
1245 1326
                 if (is_readable (self::getDbFileName ($database))) {
@@ -1257,7 +1338,8 @@  discard block
 block discarded – undo
1257 1338
         return self::$db;
1258 1339
     }
1259 1340
 
1260
-    public static function checkDatabaseAvailability () {
1341
+    public static function checkDatabaseAvailability ()
1342
+    {
1261 1343
         if (self::noDatabaseSelected ()) {
1262 1344
             for ($i = 0; $i < count (self::getDbList ()); $i++) {
1263 1345
                 self::getDb ($i);
@@ -1269,31 +1351,36 @@  discard block
 block discarded – undo
1269 1351
         return true;
1270 1352
     }
1271 1353
 
1272
-    public static function clearDb () {
1354
+    public static function clearDb ()
1355
+    {
1273 1356
         self::$db = NULL;
1274 1357
     }
1275 1358
 
1276
-    public static function executeQuerySingle ($query, $database = NULL) {
1359
+    public static function executeQuerySingle ($query, $database = NULL)
1360
+    {
1277 1361
         return self::getDb ($database)->query($query)->fetchColumn();
1278 1362
     }
1279 1363
 
1280
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
1364
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL)
1365
+    {
1281 1366
         if (!$numberOfString) {
1282 1367
             $numberOfString = $table . ".alphabetical";
1283 1368
         }
1284 1369
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
1285
-        if ($count == 0) return NULL;
1370
+        if ($count == 0) {
1371
+            return NULL;
1372
+        }
1286 1373
         $entry = new Entry (localize($table . ".title"), $id,
1287 1374
             str_format (localize($numberOfString, $count), $count), "text",
1288 1375
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
1289 1376
         return $entry;
1290 1377
     }
1291 1378
 
1292
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
1379
+    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category)
1380
+    {
1293 1381
         list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
1294 1382
         $entryArray = array();
1295
-        while ($post = $result->fetchObject ())
1296
-        {
1383
+        while ($post = $result->fetchObject ()) {
1297 1384
             $instance = new $category ($post);
1298 1385
             if (property_exists($post, "sort")) {
1299 1386
                 $title = $post->sort;
@@ -1307,7 +1394,8 @@  discard block
 block discarded – undo
1307 1394
         return $entryArray;
1308 1395
     }
1309 1396
 
1310
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
1397
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL)
1398
+    {
1311 1399
         $totalResult = -1;
1312 1400
 
1313 1401
         if (useNormAndUp ()) {
@@ -1319,8 +1407,7 @@  discard block
 block discarded – undo
1319 1407
             $numberPerPage = getCurrentOption ("max_item_per_page");
1320 1408
         }
1321 1409
 
1322
-        if ($numberPerPage != -1 && $n != -1)
1323
-        {
1410
+        if ($numberPerPage != -1 && $n != -1) {
1324 1411
             // First check total number of results
1325 1412
             $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
1326 1413
             $result->execute ($params);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
     // If there is a syntax error in the function created
37 37
     // $dot will be equal to FALSE
38 38
     if (!$dot) {
39
-        return FALSE;
39
+        return false;
40 40
     }
41 41
     // Execute the template
42 42
     if (!empty ($data)) {
43 43
         return $dot ($data);
44 44
     }
45 45
 
46
-    return NULL;
46
+    return null;
47 47
 }
48 48
 
49 49
 function getQueryString () {
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     $_SERVER['REDIRECT_STATUS'] = 404;
61 61
 }
62 62
 
63
-function getURLParam ($name, $default = NULL) {
63
+function getURLParam ($name, $default = null) {
64 64
     if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != "") {
65 65
         return $_GET[$name];
66 66
     }
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 
110 110
     switch ($error->level) {
111 111
         case LIBXML_ERR_WARNING:
112
-            $return .= "Warning $error->code: ";
112
+            $return .= "warning $error->code: ";
113 113
             break;
114 114
          case LIBXML_ERR_ERROR:
115
-            $return .= "Error $error->code: ";
115
+            $return .= "error $error->code: ";
116 116
             break;
117 117
         case LIBXML_ERR_FATAL:
118 118
             $return .= "Fatal Error $error->code: ";
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         $langs = getAcceptLanguages();
245 245
     }
246 246
     //echo var_dump($langs);
247
-    $lang_file = NULL;
247
+    $lang_file = null;
248 248
     foreach ($langs as $language => $val) {
249 249
         $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json';
250 250
         if (file_exists($temp_file)) {
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
         $phrase .= ".many";
274 274
 
275 275
     /* Static keyword is used to ensure the file is loaded only once */
276
-    static $translations = NULL;
276
+    static $translations = null;
277 277
     if ($reset) {
278
-        $translations = NULL;
278
+        $translations = null;
279 279
     }
280 280
     /* If no instance of $translations has occured load the language file */
281 281
     if (is_null($translations)) {
282
-        $lang_file_en = NULL;
282
+        $lang_file_en = null;
283 283
         list ($lang, $lang_file) = getLangAndTranslationFile();
284 284
         if ($lang != "en") {
285 285
             $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json';
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
     public $facetGroup;
357 357
     public $activeFacet;
358 358
 
359
-    public function __construct($phref, $ptype, $prel = NULL, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
359
+    public function __construct($phref, $ptype, $prel = null, $ptitle = null, $pfacetGroup = null, $pactiveFacet = false) {
360 360
         $this->href = $phref;
361 361
         $this->type = $ptype;
362 362
         $this->rel = $prel;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 
378 378
 class LinkNavigation extends Link
379 379
 {
380
-    public function __construct($phref, $prel = NULL, $ptitle = NULL) {
380
+    public function __construct($phref, $prel = null, $ptitle = null) {
381 381
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
382 382
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
383 383
         if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 
392 392
 class LinkFacet extends Link
393 393
 {
394
-    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
394
+    public function __construct($phref, $ptitle = null, $pfacetGroup = null, $pactiveFacet = false) {
395 395
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
396 396
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
397 397
         $this->href = parent::getScriptName() . $this->href;
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     public $linkArray;
409 409
     public $localUpdated;
410 410
     public $className;
411
-    private static $updated = NULL;
411
+    private static $updated = null;
412 412
 
413 413
     public static $icons = array(
414 414
         Author::ALL_AUTHORS_ID       => 'images/author.png',
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
         if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) {
641 641
             return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate"));
642 642
         }
643
-        return NULL;
643
+        return null;
644 644
     }
645 645
 
646 646
     public function getPrevLink ()
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
         if ($this->n > 1) {
650 650
             return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate"));
651 651
         }
652
-        return NULL;
652
+        return null;
653 653
     }
654 654
 
655 655
     public function getMaxPage ()
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 {
747 747
     public function InitializeContent ()
748 748
     {
749
-        $customId = getURLParam ("custom", NULL);
749
+        $customId = getURLParam ("custom", null);
750 750
         $custom = CustomColumn::getCustomById ($customId, $this->idGet);
751 751
         $this->idPage = $custom->getEntryId ();
752 752
         $this->title = $custom->name;
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 {
759 759
     public function InitializeContent ()
760 760
     {
761
-        $customId = getURLParam ("custom", NULL);
761
+        $customId = getURLParam ("custom", null);
762 762
         $this->title = CustomColumn::getAllTitle ($customId);
763 763
         $this->entryArray = CustomColumn::getAllCustoms($customId);
764 764
         $this->idPage = CustomColumn::getAllCustomsId ($customId);
@@ -882,9 +882,9 @@  discard block
 block discarded – undo
882 882
         return !is_null (getURLParam ("search"));
883 883
     }
884 884
 
885
-    private function searchByScope ($scope, $limit = FALSE) {
885
+    private function searchByScope ($scope, $limit = false) {
886 886
         $n = $this->n;
887
-        $numberPerPage = NULL;
887
+        $numberPerPage = null;
888 888
         $queryNormedAndUp = $this->query;
889 889
         if (useNormAndUp ()) {
890 890
             $queryNormedAndUp = normAndUp ($this->query);
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
         }
896 896
         switch ($scope) {
897 897
             case self::SCOPE_BOOK :
898
-                $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, NULL, $numberPerPage);
898
+                $array = Book::getBooksByStartingLetter ('%' . $queryNormedAndUp, $n, null, $numberPerPage);
899 899
                 break;
900 900
             case self::SCOPE_AUTHOR :
901 901
                 $array = Author::getAuthorsForSearch ('%' . $queryNormedAndUp);
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
                 $array = Serie::getAllSeriesByQuery ($queryNormedAndUp);
905 905
                 break;
906 906
             case self::SCOPE_TAG :
907
-                $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, NULL, $numberPerPage);
907
+                $array = Tag::getAllTagsByQuery ($queryNormedAndUp, $n, null, $numberPerPage);
908 908
                 break;
909 909
             case self::SCOPE_PUBLISHER :
910 910
                 $array = Publisher::getAllPublishersByQuery ($queryNormedAndUp);
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
                 if (in_array($key, getCurrentOption ('ignored_categories'))) {
945 945
                     continue;
946 946
                 }
947
-                $array = $this->searchByScope ($key, TRUE);
947
+                $array = $this->searchByScope ($key, true);
948 948
 
949 949
                 $i = 0;
950 950
                 if (count ($array) == 2 && is_array ($array [0])) {
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 
1166 1166
     const COMPATIBILITY_XML_ALDIKO = "aldiko";
1167 1167
 
1168
-    private static $db = NULL;
1168
+    private static $db = null;
1169 1169
 
1170 1170
     public static function isMultipleDatabaseEnabled () {
1171 1171
         global $config;
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
         }
1202 1202
     }
1203 1203
 
1204
-    public static function getDbName ($database = NULL) {
1204
+    public static function getDbName ($database = null) {
1205 1205
         global $config;
1206 1206
         if (self::isMultipleDatabaseEnabled ()) {
1207 1207
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
         return "";
1215 1215
     }
1216 1216
 
1217
-    public static function getDbDirectory ($database = NULL) {
1217
+    public static function getDbDirectory ($database = null) {
1218 1218
         global $config;
1219 1219
         if (self::isMultipleDatabaseEnabled ()) {
1220 1220
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
     }
1229 1229
 
1230 1230
 
1231
-    public static function getDbFileName ($database = NULL) {
1231
+    public static function getDbFileName ($database = null) {
1232 1232
         return self::getDbDirectory ($database) .'metadata.db';
1233 1233
     }
1234 1234
 
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
         throw new Exception("Database <{$database}> not found.");
1240 1240
     }
1241 1241
 
1242
-    public static function getDb ($database = NULL) {
1242
+    public static function getDb ($database = null) {
1243 1243
         if (is_null (self::$db)) {
1244 1244
             try {
1245 1245
                 if (is_readable (self::getDbFileName ($database))) {
@@ -1270,19 +1270,19 @@  discard block
 block discarded – undo
1270 1270
     }
1271 1271
 
1272 1272
     public static function clearDb () {
1273
-        self::$db = NULL;
1273
+        self::$db = null;
1274 1274
     }
1275 1275
 
1276
-    public static function executeQuerySingle ($query, $database = NULL) {
1276
+    public static function executeQuerySingle ($query, $database = null) {
1277 1277
         return self::getDb ($database)->query($query)->fetchColumn();
1278 1278
     }
1279 1279
 
1280
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
1280
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = null) {
1281 1281
         if (!$numberOfString) {
1282 1282
             $numberOfString = $table . ".alphabetical";
1283 1283
         }
1284 1284
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
1285
-        if ($count == 0) return NULL;
1285
+        if ($count == 0) return null;
1286 1286
         $entry = new Entry (localize($table . ".title"), $id,
1287 1287
             str_format (localize($numberOfString, $count), $count), "text",
1288 1288
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
         return $entryArray;
1308 1308
     }
1309 1309
 
1310
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
1310
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) {
1311 1311
         $totalResult = -1;
1312 1312
 
1313 1313
         if (useNormAndUp ()) {
Please login to merge, or discard this patch.
book.php 5 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -287,6 +287,9 @@  discard block
 block discarded – undo
287 287
         return reset ($reduced);
288 288
     }
289 289
 
290
+    /**
291
+     * @param string $extension
292
+     */
290 293
     public function getFilePath ($extension, $idData = NULL, $relative = false)
291 294
     {
292 295
         if ($extension == "jpg")
@@ -419,6 +422,9 @@  discard block
 block discarded – undo
419 422
             $this->getLinkArray (), $this);
420 423
     }
421 424
 
425
+    /**
426
+     * @param integer $database
427
+     */
422 428
     public static function getBookCount($database = NULL) {
423 429
         return parent::executeQuerySingle ('select count(*) from books', $database);
424 430
     }
@@ -500,6 +506,10 @@  discard block
 block discarded – undo
500 506
         return NULL;
501 507
     }
502 508
 
509
+    /**
510
+     * @param integer $database
511
+     * @param integer $numberPerPage
512
+     */
503 513
     public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
504 514
         $i = 0;
505 515
         $critArray = array ();
@@ -544,6 +554,9 @@  discard block
 block discarded – undo
544 554
         return $entryArray;
545 555
     }
546 556
 
557
+    /**
558
+     * @param integer $numberPerPage
559
+     */
547 560
     public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
548 561
         return self::getEntryArray (self::SQL_BOOKS_BY_FIRST_LETTER, array ($letter . "%"), $n, $database, $numberPerPage);
549 562
     }
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -428,15 +428,15 @@
 block discarded – undo
428 428
         $nBooks = parent::executeQuerySingle ('select count(*) from books');
429 429
         $result = array();
430 430
         $entry = new Entry (localize ("allbooks.title"),
431
-                          self::ALL_BOOKS_ID,
432
-                          str_format (localize ("allbooks.alphabetical", $nBooks), $nBooks), "text",
433
-                          array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS)), "", $nBooks);
431
+                            self::ALL_BOOKS_ID,
432
+                            str_format (localize ("allbooks.alphabetical", $nBooks), $nBooks), "text",
433
+                            array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS)), "", $nBooks);
434 434
         array_push ($result, $entry);
435 435
         if ($config['cops_recentbooks_limit'] > 0) {
436 436
             $entry = new Entry (localize ("recent.title"),
437
-                              self::ALL_RECENT_BOOKS_ID,
438
-                              str_format (localize ("recent.list"), $config['cops_recentbooks_limit']), "text",
439
-                              array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']);
437
+                                self::ALL_RECENT_BOOKS_ID,
438
+                                str_format (localize ("recent.list"), $config['cops_recentbooks_limit']), "text",
439
+                                array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']);
440 440
             array_push ($result, $entry);
441 441
         }
442 442
         return $result;
Please login to merge, or discard this patch.
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  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_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
29
+define('SQL_BOOKS_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
30 30
                                                     where (
31 31
                                                     exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or
32 32
                                                     exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or
33 33
                                                     exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or
34 34
                                                     exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or
35 35
                                                     title like ?) {1} order by books.sort");
36
-define ('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
36
+define('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
37 37
                                                     where 1=1 {1} order by timestamp desc limit ");
38
-define ('SQL_BOOKS_BY_RATING', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
38
+define('SQL_BOOKS_BY_RATING', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
39 39
                                                     where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort");
40 40
 
41 41
 class Book extends Base {
@@ -76,133 +76,133 @@  discard block
 block discarded – undo
76 76
     public $serie = NULL;
77 77
     public $tags = NULL;
78 78
     public $languages = NULL;
79
-    public $format = array ();
79
+    public $format = array();
80 80
 
81 81
 
82 82
     public function __construct($line) {
83 83
         $this->id = $line->id;
84 84
         $this->title = $line->title;
85
-        $this->timestamp = strtotime ($line->timestamp);
85
+        $this->timestamp = strtotime($line->timestamp);
86 86
         $this->pubdate = $line->pubdate;
87
-        $this->path = Base::getDbDirectory () . $line->path;
87
+        $this->path = Base::getDbDirectory() . $line->path;
88 88
         $this->relativePath = $line->path;
89 89
         $this->seriesIndex = $line->series_index;
90 90
         $this->comment = $line->comment;
91 91
         $this->uuid = $line->uuid;
92 92
         $this->hasCover = $line->has_cover;
93
-        if (!file_exists ($this->getFilePath ("jpg"))) {
93
+        if (!file_exists($this->getFilePath("jpg"))) {
94 94
             // double check
95 95
             $this->hasCover = 0;
96 96
         }
97 97
         $this->rating = $line->rating;
98 98
     }
99 99
 
100
-    public function getEntryId () {
101
-        return self::ALL_BOOKS_UUID.":".$this->uuid;
100
+    public function getEntryId() {
101
+        return self::ALL_BOOKS_UUID . ":" . $this->uuid;
102 102
     }
103 103
 
104
-    public static function getEntryIdByLetter ($startingLetter) {
105
-        return self::ALL_BOOKS_ID.":letter:".$startingLetter;
104
+    public static function getEntryIdByLetter($startingLetter) {
105
+        return self::ALL_BOOKS_ID . ":letter:" . $startingLetter;
106 106
     }
107 107
 
108
-    public function getUri () {
109
-        return "?page=".parent::PAGE_BOOK_DETAIL."&id=$this->id";
108
+    public function getUri() {
109
+        return "?page=" . parent::PAGE_BOOK_DETAIL . "&id=$this->id";
110 110
     }
111 111
 
112
-    public function getDetailUrl () {
113
-        $urlParam = $this->getUri ();
114
-        if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
112
+    public function getDetailUrl() {
113
+        $urlParam = $this->getUri();
114
+        if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
115 115
         return 'index.php' . $urlParam;
116 116
     }
117 117
 
118
-    public function getTitle () {
118
+    public function getTitle() {
119 119
         return $this->title;
120 120
     }
121 121
 
122 122
     /* Other class (author, series, tag, ...) initialization and accessors */
123 123
 
124
-    public function getAuthors () {
125
-        if (is_null ($this->authors)) {
126
-            $this->authors = Author::getAuthorByBookId ($this->id);
124
+    public function getAuthors() {
125
+        if (is_null($this->authors)) {
126
+            $this->authors = Author::getAuthorByBookId($this->id);
127 127
         }
128 128
         return $this->authors;
129 129
     }
130 130
 
131
-    public function getAuthorsName () {
132
-        return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
131
+    public function getAuthorsName() {
132
+        return implode(", ", array_map(function($author) { return $author->name; }, $this->getAuthors()));
133 133
     }
134 134
 
135
-    public function getAuthorsSort () {
136
-        return implode (", ", array_map (function ($author) { return $author->sort; }, $this->getAuthors ()));
135
+    public function getAuthorsSort() {
136
+        return implode(", ", array_map(function($author) { return $author->sort; }, $this->getAuthors()));
137 137
     }
138 138
 
139
-    public function getPublisher () {
140
-        if (is_null ($this->publisher)) {
141
-            $this->publisher = Publisher::getPublisherByBookId ($this->id);
139
+    public function getPublisher() {
140
+        if (is_null($this->publisher)) {
141
+            $this->publisher = Publisher::getPublisherByBookId($this->id);
142 142
         }
143 143
         return $this->publisher;
144 144
     }
145 145
 
146
-    public function getSerie () {
147
-        if (is_null ($this->serie)) {
148
-            $this->serie = Serie::getSerieByBookId ($this->id);
146
+    public function getSerie() {
147
+        if (is_null($this->serie)) {
148
+            $this->serie = Serie::getSerieByBookId($this->id);
149 149
         }
150 150
         return $this->serie;
151 151
     }
152 152
 
153
-    public function getLanguages () {
154
-        $lang = array ();
155
-        $result = parent::getDb ()->prepare('select languages.lang_code
153
+    public function getLanguages() {
154
+        $lang = array();
155
+        $result = parent::getDb()->prepare('select languages.lang_code
156 156
                 from books_languages_link, languages
157 157
                 where books_languages_link.lang_code = languages.id
158 158
                 and book = ?
159 159
                 order by item_order');
160
-        $result->execute (array ($this->id));
161
-        while ($post = $result->fetchObject ())
160
+        $result->execute(array($this->id));
161
+        while ($post = $result->fetchObject())
162 162
         {
163
-            array_push ($lang, Language::getLanguageString($post->lang_code));
163
+            array_push($lang, Language::getLanguageString($post->lang_code));
164 164
         }
165
-        return implode (", ", $lang);
165
+        return implode(", ", $lang);
166 166
     }
167 167
 
168
-    public function getTags () {
169
-        if (is_null ($this->tags)) {
170
-            $this->tags = array ();
168
+    public function getTags() {
169
+        if (is_null($this->tags)) {
170
+            $this->tags = array();
171 171
 
172
-            $result = parent::getDb ()->prepare('select tags.id as id, name
172
+            $result = parent::getDb()->prepare('select tags.id as id, name
173 173
                 from books_tags_link, tags
174 174
                 where tag = tags.id
175 175
                 and book = ?
176 176
                 order by name');
177
-            $result->execute (array ($this->id));
178
-            while ($post = $result->fetchObject ())
177
+            $result->execute(array($this->id));
178
+            while ($post = $result->fetchObject())
179 179
             {
180
-                array_push ($this->tags, new Tag ($post));
180
+                array_push($this->tags, new Tag($post));
181 181
             }
182 182
         }
183 183
         return $this->tags;
184 184
     }
185 185
 
186
-    public function getTagsName () {
187
-        return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ()));
186
+    public function getTagsName() {
187
+        return implode(", ", array_map(function($tag) { return $tag->name; }, $this->getTags()));
188 188
     }
189 189
 
190
-    public function getDatas ()
190
+    public function getDatas()
191 191
     {
192
-        if (is_null ($this->datas)) {
193
-            $this->datas = Data::getDataByBook ($this);
192
+        if (is_null($this->datas)) {
193
+            $this->datas = Data::getDataByBook($this);
194 194
         }
195 195
         return $this->datas;
196 196
     }
197 197
 
198 198
     /* End of other class (author, series, tag, ...) initialization and accessors */
199 199
 
200
-    public static function getFilterString () {
201
-        $filter = getURLParam ("tag", NULL);
200
+    public static function getFilterString() {
201
+        $filter = getURLParam("tag", NULL);
202 202
         if (empty ($filter)) return "";
203 203
 
204 204
         $exists = true;
205
-        if (preg_match ("/^!(.*)$/", $filter, $matches)) {
205
+        if (preg_match("/^!(.*)$/", $filter, $matches)) {
206 206
             $exists = false;
207 207
             $filter = $matches[1];
208 208
         }
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
         return "and " . $result;
217 217
     }
218 218
 
219
-    public function GetMostInterestingDataToSendToKindle ()
219
+    public function GetMostInterestingDataToSendToKindle()
220 220
     {
221
-        $bestFormatForKindle = array ("EPUB", "PDF", "AZW3", "MOBI");
221
+        $bestFormatForKindle = array("EPUB", "PDF", "AZW3", "MOBI");
222 222
         $bestRank = -1;
223 223
         $bestData = NULL;
224
-        foreach ($this->getDatas () as $data) {
225
-            $key = array_search ($data->format, $bestFormatForKindle);
224
+        foreach ($this->getDatas() as $data) {
225
+            $key = array_search($data->format, $bestFormatForKindle);
226 226
             if ($key !== false && $key > $bestRank) {
227 227
                 $bestRank = $key;
228 228
                 $bestData = $data;
@@ -231,16 +231,16 @@  discard block
 block discarded – undo
231 231
         return $bestData;
232 232
     }
233 233
 
234
-    public function getDataById ($idData)
234
+    public function getDataById($idData)
235 235
     {
236
-        $reduced = array_filter ($this->getDatas (), function ($data) use ($idData) {
236
+        $reduced = array_filter($this->getDatas(), function($data) use ($idData) {
237 237
             return $data->id == $idData;
238 238
         });
239
-        return reset ($reduced);
239
+        return reset($reduced);
240 240
     }
241 241
 
242
-    public function getRating () {
243
-        if (is_null ($this->rating) || $this->rating == 0) {
242
+    public function getRating() {
243
+        if (is_null($this->rating) || $this->rating == 0) {
244 244
             return "";
245 245
         }
246 246
         $retour = "";
@@ -253,41 +253,41 @@  discard block
 block discarded – undo
253 253
         return $retour;
254 254
     }
255 255
 
256
-    public function getPubDate () {
256
+    public function getPubDate() {
257 257
         if (empty ($this->pubdate)) {
258 258
             return "";
259 259
         }
260
-        $dateY = (int) substr($this->pubdate, 0, 4);
260
+        $dateY = (int)substr($this->pubdate, 0, 4);
261 261
         if ($dateY > 102) {
262 262
             return str_pad($dateY, 4, "0", STR_PAD_LEFT);
263 263
         }
264 264
         return "";
265 265
     }
266 266
 
267
-    public function getComment ($withSerie = true) {
267
+    public function getComment($withSerie = true) {
268 268
         $addition = "";
269
-        $se = $this->getSerie ();
270
-        if (!is_null ($se) && $withSerie) {
271
-            $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format (localize ("content.series.data"), $this->seriesIndex, htmlspecialchars ($se->name)) . "<br />\n";
269
+        $se = $this->getSerie();
270
+        if (!is_null($se) && $withSerie) {
271
+            $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format(localize("content.series.data"), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
272 272
         }
273
-        if (preg_match ("/<\/(div|p|a|span)>/", $this->comment))
273
+        if (preg_match("/<\/(div|p|a|span)>/", $this->comment))
274 274
         {
275
-            return $addition . html2xhtml ($this->comment);
275
+            return $addition . html2xhtml($this->comment);
276 276
         }
277 277
         else
278 278
         {
279
-            return $addition . htmlspecialchars ($this->comment);
279
+            return $addition . htmlspecialchars($this->comment);
280 280
         }
281 281
     }
282 282
 
283
-    public function getDataFormat ($format) {
284
-        $reduced = array_filter ($this->getDatas (), function ($data) use ($format) {
283
+    public function getDataFormat($format) {
284
+        $reduced = array_filter($this->getDatas(), function($data) use ($format) {
285 285
             return $data->format == $format;
286 286
         });
287
-        return reset ($reduced);
287
+        return reset($reduced);
288 288
     }
289 289
 
290
-    public function getFilePath ($extension, $idData = NULL, $relative = false)
290
+    public function getFilePath($extension, $idData = NULL, $relative = false)
291 291
     {
292 292
         if ($extension == "jpg")
293 293
         {
@@ -295,50 +295,50 @@  discard block
 block discarded – undo
295 295
         }
296 296
         else
297 297
         {
298
-            $data = $this->getDataById ($idData);
298
+            $data = $this->getDataById($idData);
299 299
             if (!$data) return NULL;
300
-            $file = $data->name . "." . strtolower ($data->format);
300
+            $file = $data->name . "." . strtolower($data->format);
301 301
         }
302 302
 
303 303
         if ($relative)
304 304
         {
305
-            return $this->relativePath."/".$file;
305
+            return $this->relativePath . "/" . $file;
306 306
         }
307 307
         else
308 308
         {
309
-            return $this->path."/".$file;
309
+            return $this->path . "/" . $file;
310 310
         }
311 311
     }
312 312
 
313
-    public function getUpdatedEpub ($idData)
313
+    public function getUpdatedEpub($idData)
314 314
     {
315 315
         global $config;
316
-        $data = $this->getDataById ($idData);
316
+        $data = $this->getDataById($idData);
317 317
 
318 318
         try
319 319
         {
320
-            $epub = new EPub ($data->getLocalPath ());
320
+            $epub = new EPub($data->getLocalPath());
321 321
 
322
-            $epub->Title ($this->title);
323
-            $authorArray = array ();
322
+            $epub->Title($this->title);
323
+            $authorArray = array();
324 324
             foreach ($this->getAuthors() as $author) {
325 325
                 $authorArray [$author->sort] = $author->name;
326 326
             }
327
-            $epub->Authors ($authorArray);
328
-            $epub->Language ($this->getLanguages ());
329
-            $epub->Description ($this->getComment (false));
330
-            $epub->Subjects ($this->getTagsName ());
331
-            $epub->Cover2 ($this->getFilePath ("jpg"), "image/jpeg");
332
-            $epub->Calibre ($this->uuid);
333
-            $se = $this->getSerie ();
334
-            if (!is_null ($se)) {
335
-                $epub->Serie ($se->name);
336
-                $epub->SerieIndex ($this->seriesIndex);
327
+            $epub->Authors($authorArray);
328
+            $epub->Language($this->getLanguages());
329
+            $epub->Description($this->getComment(false));
330
+            $epub->Subjects($this->getTagsName());
331
+            $epub->Cover2($this->getFilePath("jpg"), "image/jpeg");
332
+            $epub->Calibre($this->uuid);
333
+            $se = $this->getSerie();
334
+            if (!is_null($se)) {
335
+                $epub->Serie($se->name);
336
+                $epub->SerieIndex($this->seriesIndex);
337 337
             }
338
-            if ($config['cops_provide_kepub'] == "1"  && preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
339
-                $epub->updateForKepub ();
338
+            if ($config['cops_provide_kepub'] == "1" && preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
339
+                $epub->updateForKepub();
340 340
             }
341
-            $epub->download ($data->getUpdatedFilenameEpub ());
341
+            $epub->download($data->getUpdatedFilenameEpub());
342 342
         }
343 343
         catch (Exception $e)
344 344
         {
@@ -346,25 +346,25 @@  discard block
 block discarded – undo
346 346
         }
347 347
     }
348 348
 
349
-    public function getThumbnail ($width, $height, $outputfile = NULL) {
350
-        if (is_null ($width) && is_null ($height)) {
349
+    public function getThumbnail($width, $height, $outputfile = NULL) {
350
+        if (is_null($width) && is_null($height)) {
351 351
             return false;
352 352
         }
353 353
 
354
-        $file = $this->getFilePath ("jpg");
354
+        $file = $this->getFilePath("jpg");
355 355
         // get image size
356 356
         if ($size = GetImageSize($file)) {
357 357
             $w = $size[0];
358 358
             $h = $size[1];
359 359
             //set new size
360
-            if (!is_null ($width)) {
360
+            if (!is_null($width)) {
361 361
                 $nw = $width;
362 362
                 if ($nw >= $w) { return false; }
363
-                $nh = ($nw*$h)/$w;
363
+                $nh = ($nw * $h) / $w;
364 364
             } else {
365 365
                 $nh = $height;
366 366
                 if ($nh >= $h) { return false; }
367
-                $nw = ($nh*$w)/$h;
367
+                $nw = ($nh * $w) / $h;
368 368
             }
369 369
         } else {
370 370
             return false;
@@ -372,129 +372,129 @@  discard block
 block discarded – undo
372 372
 
373 373
         //draw the image
374 374
         $src_img = imagecreatefromjpeg($file);
375
-        $dst_img = imagecreatetruecolor($nw,$nh);
376
-        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image
377
-        imagejpeg($dst_img,$outputfile,80);
375
+        $dst_img = imagecreatetruecolor($nw, $nh);
376
+        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image
377
+        imagejpeg($dst_img, $outputfile, 80);
378 378
         imagedestroy($src_img);
379 379
         imagedestroy($dst_img);
380 380
 
381 381
         return true;
382 382
     }
383 383
 
384
-    public function getLinkArray ()
384
+    public function getLinkArray()
385 385
     {
386 386
         $linkArray = array();
387 387
 
388 388
         if ($this->hasCover)
389 389
         {
390
-            array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL));
390
+            array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL));
391 391
 
392
-            array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
392
+            array_push($linkArray, Data::getLink($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
393 393
         }
394 394
 
395
-        foreach ($this->getDatas () as $data)
395
+        foreach ($this->getDatas() as $data)
396 396
         {
397
-            if ($data->isKnownType ())
397
+            if ($data->isKnownType())
398 398
             {
399
-                array_push ($linkArray, $data->getDataLink (Link::OPDS_ACQUISITION_TYPE, $data->format));
399
+                array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
400 400
             }
401 401
         }
402 402
 
403
-        foreach ($this->getAuthors () as $author) {
404
-            array_push ($linkArray, new LinkNavigation ($author->getUri (), "related", str_format (localize ("bookentry.author"), localize ("splitByLetter.book.other"), $author->name)));
403
+        foreach ($this->getAuthors() as $author) {
404
+            array_push($linkArray, new LinkNavigation($author->getUri(), "related", str_format(localize("bookentry.author"), localize("splitByLetter.book.other"), $author->name)));
405 405
         }
406 406
 
407
-        $serie = $this->getSerie ();
408
-        if (!is_null ($serie)) {
409
-            array_push ($linkArray, new LinkNavigation ($serie->getUri (), "related", str_format (localize ("content.series.data"), $this->seriesIndex, $serie->name)));
407
+        $serie = $this->getSerie();
408
+        if (!is_null($serie)) {
409
+            array_push($linkArray, new LinkNavigation($serie->getUri(), "related", str_format(localize("content.series.data"), $this->seriesIndex, $serie->name)));
410 410
         }
411 411
 
412 412
         return $linkArray;
413 413
     }
414 414
 
415 415
 
416
-    public function getEntry () {
417
-        return new EntryBook ($this->getTitle (), $this->getEntryId (),
418
-            $this->getComment (), "text/html",
419
-            $this->getLinkArray (), $this);
416
+    public function getEntry() {
417
+        return new EntryBook($this->getTitle(), $this->getEntryId(),
418
+            $this->getComment(), "text/html",
419
+            $this->getLinkArray(), $this);
420 420
     }
421 421
 
422 422
     public static function getBookCount($database = NULL) {
423
-        return parent::executeQuerySingle ('select count(*) from books', $database);
423
+        return parent::executeQuerySingle('select count(*) from books', $database);
424 424
     }
425 425
 
426 426
     public static function getCount() {
427 427
         global $config;
428
-        $nBooks = parent::executeQuerySingle ('select count(*) from books');
428
+        $nBooks = parent::executeQuerySingle('select count(*) from books');
429 429
         $result = array();
430
-        $entry = new Entry (localize ("allbooks.title"),
430
+        $entry = new Entry(localize("allbooks.title"),
431 431
                           self::ALL_BOOKS_ID,
432
-                          str_format (localize ("allbooks.alphabetical", $nBooks), $nBooks), "text",
433
-                          array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS)), "", $nBooks);
434
-        array_push ($result, $entry);
432
+                          str_format(localize("allbooks.alphabetical", $nBooks), $nBooks), "text",
433
+                          array(new LinkNavigation("?page=" . parent::PAGE_ALL_BOOKS)), "", $nBooks);
434
+        array_push($result, $entry);
435 435
         if ($config['cops_recentbooks_limit'] > 0) {
436
-            $entry = new Entry (localize ("recent.title"),
436
+            $entry = new Entry(localize("recent.title"),
437 437
                               self::ALL_RECENT_BOOKS_ID,
438
-                              str_format (localize ("recent.list"), $config['cops_recentbooks_limit']), "text",
439
-                              array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']);
440
-            array_push ($result, $entry);
438
+                              str_format(localize("recent.list"), $config['cops_recentbooks_limit']), "text",
439
+                              array(new LinkNavigation("?page=" . parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']);
440
+            array_push($result, $entry);
441 441
         }
442 442
         return $result;
443 443
     }
444 444
 
445 445
     public static function getBooksByAuthor($authorId, $n) {
446
-        return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n);
446
+        return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
447 447
     }
448 448
 
449 449
     public static function getBooksByRating($ratingId, $n) {
450
-        return self::getEntryArray (self::SQL_BOOKS_BY_RATING, array ($ratingId), $n);
450
+        return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
451 451
     }
452 452
 
453 453
     public static function getBooksByPublisher($publisherId, $n) {
454
-        return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n);
454
+        return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
455 455
     }
456 456
 
457 457
     public static function getBooksBySeries($serieId, $n) {
458
-        return self::getEntryArray (self::SQL_BOOKS_BY_SERIE, array ($serieId), $n);
458
+        return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
459 459
     }
460 460
 
461 461
     public static function getBooksByTag($tagId, $n) {
462
-        return self::getEntryArray (self::SQL_BOOKS_BY_TAG, array ($tagId), $n);
462
+        return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
463 463
     }
464 464
 
465 465
     public static function getBooksByLanguage($languageId, $n) {
466
-        return self::getEntryArray (self::SQL_BOOKS_BY_LANGUAGE, array ($languageId), $n);
466
+        return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
467 467
     }
468 468
 
469 469
     public static function getBooksByCustom($customId, $id, $n) {
470
-        $query = str_format (self::SQL_BOOKS_BY_CUSTOM, "{0}", "{1}", CustomColumn::getTableLinkName ($customId), CustomColumn::getTableLinkColumn ($customId));
471
-        return self::getEntryArray ($query, array ($id), $n);
470
+        $query = str_format(self::SQL_BOOKS_BY_CUSTOM, "{0}", "{1}", CustomColumn::getTableLinkName($customId), CustomColumn::getTableLinkColumn($customId));
471
+        return self::getEntryArray($query, array($id), $n);
472 472
     }
473 473
 
474 474
     public static function getBookById($bookId) {
475
-        $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . '
475
+        $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . '
476 476
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
477 477
 where books.id = ?');
478
-        $result->execute (array ($bookId));
479
-        while ($post = $result->fetchObject ())
478
+        $result->execute(array($bookId));
479
+        while ($post = $result->fetchObject())
480 480
         {
481
-            $book = new Book ($post);
481
+            $book = new Book($post);
482 482
             return $book;
483 483
         }
484 484
         return NULL;
485 485
     }
486 486
 
487 487
     public static function getBookByDataId($dataId) {
488
-        $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
488
+        $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
489 489
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
490 490
 where data.book = books.id and data.id = ?');
491
-        $result->execute (array ($dataId));
492
-        while ($post = $result->fetchObject ())
491
+        $result->execute(array($dataId));
492
+        while ($post = $result->fetchObject())
493 493
         {
494
-            $book = new Book ($post);
495
-            $data = new Data ($post, $book);
494
+            $book = new Book($post);
495
+            $data = new Data($post, $book);
496 496
             $data->id = $dataId;
497
-            $book->datas = array ($data);
497
+            $book->datas = array($data);
498 498
             return $book;
499 499
         }
500 500
         return NULL;
@@ -502,18 +502,18 @@  discard block
 block discarded – undo
502 502
 
503 503
     public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
504 504
         $i = 0;
505
-        $critArray = array ();
506
-        foreach (array (PageQueryResult::SCOPE_AUTHOR,
505
+        $critArray = array();
506
+        foreach (array(PageQueryResult::SCOPE_AUTHOR,
507 507
                         PageQueryResult::SCOPE_TAG,
508 508
                         PageQueryResult::SCOPE_SERIES,
509 509
                         PageQueryResult::SCOPE_PUBLISHER,
510 510
                         PageQueryResult::SCOPE_BOOK) as $key) {
511
-            if (in_array($key, getCurrentOption ('ignored_categories')) ||
512
-                (!array_key_exists ($key, $query) && !array_key_exists ("all", $query))) {
511
+            if (in_array($key, getCurrentOption('ignored_categories')) ||
512
+                (!array_key_exists($key, $query) && !array_key_exists("all", $query))) {
513 513
                 $critArray [$i] = self::BAD_SEARCH;
514 514
             }
515 515
             else {
516
-                if (array_key_exists ($key, $query)) {
516
+                if (array_key_exists($key, $query)) {
517 517
                     $critArray [$i] = $query [$key];
518 518
                 } else {
519 519
                     $critArray [$i] = $query ["all"];
@@ -521,48 +521,48 @@  discard block
 block discarded – undo
521 521
             }
522 522
             $i++;
523 523
         }
524
-        return self::getEntryArray (self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
524
+        return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
525 525
     }
526 526
 
527 527
     public static function getBooks($n) {
528
-        list ($entryArray, $totalNumber) = self::getEntryArray (self::SQL_BOOKS_ALL , array (), $n);
529
-        return array ($entryArray, $totalNumber);
528
+        list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n);
529
+        return array($entryArray, $totalNumber);
530 530
     }
531 531
 
532 532
     public static function getAllBooks() {
533
-        list (, $result) = parent::executeQuery ("select {0}
533
+        list (, $result) = parent::executeQuery("select {0}
534 534
 from books
535 535
 group by substr (upper (sort), 1, 1)
536
-order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", self::getFilterString (), array (), -1);
536
+order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", self::getFilterString(), array(), -1);
537 537
         $entryArray = array();
538
-        while ($post = $result->fetchObject ())
538
+        while ($post = $result->fetchObject())
539 539
         {
540
-            array_push ($entryArray, new Entry ($post->title, Book::getEntryIdByLetter ($post->title),
541
-                str_format (localize("bookword", $post->count), $post->count), "text",
542
-                array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
540
+            array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
541
+                str_format(localize("bookword", $post->count), $post->count), "text",
542
+                array(new LinkNavigation("?page=" . parent::PAGE_ALL_BOOKS_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count));
543 543
         }
544 544
         return $entryArray;
545 545
     }
546 546
 
547 547
     public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
548
-        return self::getEntryArray (self::SQL_BOOKS_BY_FIRST_LETTER, array ($letter . "%"), $n, $database, $numberPerPage);
548
+        return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . "%"), $n, $database, $numberPerPage);
549 549
     }
550 550
 
551
-    public static function getEntryArray ($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
552
-        list ($totalNumber, $result) = parent::executeQuery ($query, self::BOOK_COLUMNS, self::getFilterString (), $params, $n, $database, $numberPerPage);
551
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
552
+        list ($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
553 553
         $entryArray = array();
554
-        while ($post = $result->fetchObject ())
554
+        while ($post = $result->fetchObject())
555 555
         {
556
-            $book = new Book ($post);
557
-            array_push ($entryArray, $book->getEntry ());
556
+            $book = new Book($post);
557
+            array_push($entryArray, $book->getEntry());
558 558
         }
559
-        return array ($entryArray, $totalNumber);
559
+        return array($entryArray, $totalNumber);
560 560
     }
561 561
 
562 562
 
563 563
     public static function getAllRecentBooks() {
564 564
         global $config;
565
-        list ($entryArray, ) = self::getEntryArray (self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array (), -1);
565
+        list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
566 566
         return $entryArray;
567 567
     }
568 568
 
Please login to merge, or discard this patch.
Braces   +105 added lines, -82 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
38 38
 define ('SQL_BOOKS_BY_RATING', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
39 39
                                                     where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort");
40 40
 
41
-class Book extends Base {
41
+class Book extends Base
42
+{
42 43
     const ALL_BOOKS_UUID = "urn:uuid";
43 44
     const ALL_BOOKS_ID = "cops:books";
44 45
     const ALL_RECENT_BOOKS_ID = "cops:recentbooks";
@@ -79,7 +80,8 @@  discard block
 block discarded – undo
79 80
     public $format = array ();
80 81
 
81 82
 
82
-    public function __construct($line) {
83
+    public function __construct($line)
84
+    {
83 85
         $this->id = $line->id;
84 86
         $this->title = $line->title;
85 87
         $this->timestamp = strtotime ($line->timestamp);
@@ -97,60 +99,73 @@  discard block
 block discarded – undo
97 99
         $this->rating = $line->rating;
98 100
     }
99 101
 
100
-    public function getEntryId () {
102
+    public function getEntryId ()
103
+    {
101 104
         return self::ALL_BOOKS_UUID.":".$this->uuid;
102 105
     }
103 106
 
104
-    public static function getEntryIdByLetter ($startingLetter) {
107
+    public static function getEntryIdByLetter ($startingLetter)
108
+    {
105 109
         return self::ALL_BOOKS_ID.":letter:".$startingLetter;
106 110
     }
107 111
 
108
-    public function getUri () {
112
+    public function getUri ()
113
+    {
109 114
         return "?page=".parent::PAGE_BOOK_DETAIL."&id=$this->id";
110 115
     }
111 116
 
112
-    public function getDetailUrl () {
117
+    public function getDetailUrl ()
118
+    {
113 119
         $urlParam = $this->getUri ();
114
-        if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
120
+        if (!is_null (GetUrlParam (DB))) {
121
+            $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
122
+        }
115 123
         return 'index.php' . $urlParam;
116 124
     }
117 125
 
118
-    public function getTitle () {
126
+    public function getTitle ()
127
+    {
119 128
         return $this->title;
120 129
     }
121 130
 
122 131
     /* Other class (author, series, tag, ...) initialization and accessors */
123 132
 
124
-    public function getAuthors () {
133
+    public function getAuthors ()
134
+    {
125 135
         if (is_null ($this->authors)) {
126 136
             $this->authors = Author::getAuthorByBookId ($this->id);
127 137
         }
128 138
         return $this->authors;
129 139
     }
130 140
 
131
-    public function getAuthorsName () {
141
+    public function getAuthorsName ()
142
+    {
132 143
         return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
133 144
     }
134 145
 
135
-    public function getAuthorsSort () {
146
+    public function getAuthorsSort ()
147
+    {
136 148
         return implode (", ", array_map (function ($author) { return $author->sort; }, $this->getAuthors ()));
137 149
     }
138 150
 
139
-    public function getPublisher () {
151
+    public function getPublisher ()
152
+    {
140 153
         if (is_null ($this->publisher)) {
141 154
             $this->publisher = Publisher::getPublisherByBookId ($this->id);
142 155
         }
143 156
         return $this->publisher;
144 157
     }
145 158
 
146
-    public function getSerie () {
159
+    public function getSerie ()
160
+    {
147 161
         if (is_null ($this->serie)) {
148 162
             $this->serie = Serie::getSerieByBookId ($this->id);
149 163
         }
150 164
         return $this->serie;
151 165
     }
152 166
 
153
-    public function getLanguages () {
167
+    public function getLanguages ()
168
+    {
154 169
         $lang = array ();
155 170
         $result = parent::getDb ()->prepare('select languages.lang_code
156 171
                 from books_languages_link, languages
@@ -158,14 +173,14 @@  discard block
 block discarded – undo
158 173
                 and book = ?
159 174
                 order by item_order');
160 175
         $result->execute (array ($this->id));
161
-        while ($post = $result->fetchObject ())
162
-        {
176
+        while ($post = $result->fetchObject ()) {
163 177
             array_push ($lang, Language::getLanguageString($post->lang_code));
164 178
         }
165 179
         return implode (", ", $lang);
166 180
     }
167 181
 
168
-    public function getTags () {
182
+    public function getTags ()
183
+    {
169 184
         if (is_null ($this->tags)) {
170 185
             $this->tags = array ();
171 186
 
@@ -175,15 +190,15 @@  discard block
 block discarded – undo
175 190
                 and book = ?
176 191
                 order by name');
177 192
             $result->execute (array ($this->id));
178
-            while ($post = $result->fetchObject ())
179
-            {
193
+            while ($post = $result->fetchObject ()) {
180 194
                 array_push ($this->tags, new Tag ($post));
181 195
             }
182 196
         }
183 197
         return $this->tags;
184 198
     }
185 199
 
186
-    public function getTagsName () {
200
+    public function getTagsName ()
201
+    {
187 202
         return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ()));
188 203
     }
189 204
 
@@ -197,9 +212,12 @@  discard block
 block discarded – undo
197 212
 
198 213
     /* End of other class (author, series, tag, ...) initialization and accessors */
199 214
 
200
-    public static function getFilterString () {
215
+    public static function getFilterString ()
216
+    {
201 217
         $filter = getURLParam ("tag", NULL);
202
-        if (empty ($filter)) return "";
218
+        if (empty ($filter)) {
219
+            return "";
220
+        }
203 221
 
204 222
         $exists = true;
205 223
         if (preg_match ("/^!(.*)$/", $filter, $matches)) {
@@ -239,7 +257,8 @@  discard block
 block discarded – undo
239 257
         return reset ($reduced);
240 258
     }
241 259
 
242
-    public function getRating () {
260
+    public function getRating ()
261
+    {
243 262
         if (is_null ($this->rating) || $this->rating == 0) {
244 263
             return "";
245 264
         }
@@ -253,7 +272,8 @@  discard block
 block discarded – undo
253 272
         return $retour;
254 273
     }
255 274
 
256
-    public function getPubDate () {
275
+    public function getPubDate ()
276
+    {
257 277
         if (empty ($this->pubdate)) {
258 278
             return "";
259 279
         }
@@ -264,23 +284,22 @@  discard block
 block discarded – undo
264 284
         return "";
265 285
     }
266 286
 
267
-    public function getComment ($withSerie = true) {
287
+    public function getComment ($withSerie = true)
288
+    {
268 289
         $addition = "";
269 290
         $se = $this->getSerie ();
270 291
         if (!is_null ($se) && $withSerie) {
271 292
             $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format (localize ("content.series.data"), $this->seriesIndex, htmlspecialchars ($se->name)) . "<br />\n";
272 293
         }
273
-        if (preg_match ("/<\/(div|p|a|span)>/", $this->comment))
274
-        {
294
+        if (preg_match ("/<\/(div|p|a|span)>/", $this->comment)) {
275 295
             return $addition . html2xhtml ($this->comment);
276
-        }
277
-        else
278
-        {
296
+        } else {
279 297
             return $addition . htmlspecialchars ($this->comment);
280 298
         }
281 299
     }
282 300
 
283
-    public function getDataFormat ($format) {
301
+    public function getDataFormat ($format)
302
+    {
284 303
         $reduced = array_filter ($this->getDatas (), function ($data) use ($format) {
285 304
             return $data->format == $format;
286 305
         });
@@ -289,23 +308,19 @@  discard block
 block discarded – undo
289 308
 
290 309
     public function getFilePath ($extension, $idData = NULL, $relative = false)
291 310
     {
292
-        if ($extension == "jpg")
293
-        {
311
+        if ($extension == "jpg") {
294 312
             $file = "cover.jpg";
295
-        }
296
-        else
297
-        {
313
+        } else {
298 314
             $data = $this->getDataById ($idData);
299
-            if (!$data) return NULL;
315
+            if (!$data) {
316
+                return NULL;
317
+            }
300 318
             $file = $data->name . "." . strtolower ($data->format);
301 319
         }
302 320
 
303
-        if ($relative)
304
-        {
321
+        if ($relative) {
305 322
             return $this->relativePath."/".$file;
306
-        }
307
-        else
308
-        {
323
+        } else {
309 324
             return $this->path."/".$file;
310 325
         }
311 326
     }
@@ -315,8 +330,7 @@  discard block
 block discarded – undo
315 330
         global $config;
316 331
         $data = $this->getDataById ($idData);
317 332
 
318
-        try
319
-        {
333
+        try {
320 334
             $epub = new EPub ($data->getLocalPath ());
321 335
 
322 336
             $epub->Title ($this->title);
@@ -339,14 +353,13 @@  discard block
 block discarded – undo
339 353
                 $epub->updateForKepub ();
340 354
             }
341 355
             $epub->download ($data->getUpdatedFilenameEpub ());
342
-        }
343
-        catch (Exception $e)
344
-        {
356
+        } catch (Exception $e) {
345 357
             echo "Exception : " . $e->getMessage();
346 358
         }
347 359
     }
348 360
 
349
-    public function getThumbnail ($width, $height, $outputfile = NULL) {
361
+    public function getThumbnail ($width, $height, $outputfile = NULL)
362
+    {
350 363
         if (is_null ($width) && is_null ($height)) {
351 364
             return false;
352 365
         }
@@ -385,17 +398,14 @@  discard block
 block discarded – undo
385 398
     {
386 399
         $linkArray = array();
387 400
 
388
-        if ($this->hasCover)
389
-        {
401
+        if ($this->hasCover) {
390 402
             array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL));
391 403
 
392 404
             array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
393 405
         }
394 406
 
395
-        foreach ($this->getDatas () as $data)
396
-        {
397
-            if ($data->isKnownType ())
398
-            {
407
+        foreach ($this->getDatas () as $data) {
408
+            if ($data->isKnownType ()) {
399 409
                 array_push ($linkArray, $data->getDataLink (Link::OPDS_ACQUISITION_TYPE, $data->format));
400 410
             }
401 411
         }
@@ -413,17 +423,20 @@  discard block
 block discarded – undo
413 423
     }
414 424
 
415 425
 
416
-    public function getEntry () {
426
+    public function getEntry ()
427
+    {
417 428
         return new EntryBook ($this->getTitle (), $this->getEntryId (),
418 429
             $this->getComment (), "text/html",
419 430
             $this->getLinkArray (), $this);
420 431
     }
421 432
 
422
-    public static function getBookCount($database = NULL) {
433
+    public static function getBookCount($database = NULL)
434
+    {
423 435
         return parent::executeQuerySingle ('select count(*) from books', $database);
424 436
     }
425 437
 
426
-    public static function getCount() {
438
+    public static function getCount()
439
+    {
427 440
         global $config;
428 441
         $nBooks = parent::executeQuerySingle ('select count(*) from books');
429 442
         $result = array();
@@ -442,55 +455,62 @@  discard block
 block discarded – undo
442 455
         return $result;
443 456
     }
444 457
 
445
-    public static function getBooksByAuthor($authorId, $n) {
458
+    public static function getBooksByAuthor($authorId, $n)
459
+    {
446 460
         return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n);
447 461
     }
448 462
 
449
-    public static function getBooksByRating($ratingId, $n) {
463
+    public static function getBooksByRating($ratingId, $n)
464
+    {
450 465
         return self::getEntryArray (self::SQL_BOOKS_BY_RATING, array ($ratingId), $n);
451 466
     }
452 467
 
453
-    public static function getBooksByPublisher($publisherId, $n) {
468
+    public static function getBooksByPublisher($publisherId, $n)
469
+    {
454 470
         return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n);
455 471
     }
456 472
 
457
-    public static function getBooksBySeries($serieId, $n) {
473
+    public static function getBooksBySeries($serieId, $n)
474
+    {
458 475
         return self::getEntryArray (self::SQL_BOOKS_BY_SERIE, array ($serieId), $n);
459 476
     }
460 477
 
461
-    public static function getBooksByTag($tagId, $n) {
478
+    public static function getBooksByTag($tagId, $n)
479
+    {
462 480
         return self::getEntryArray (self::SQL_BOOKS_BY_TAG, array ($tagId), $n);
463 481
     }
464 482
 
465
-    public static function getBooksByLanguage($languageId, $n) {
483
+    public static function getBooksByLanguage($languageId, $n)
484
+    {
466 485
         return self::getEntryArray (self::SQL_BOOKS_BY_LANGUAGE, array ($languageId), $n);
467 486
     }
468 487
 
469
-    public static function getBooksByCustom($customId, $id, $n) {
488
+    public static function getBooksByCustom($customId, $id, $n)
489
+    {
470 490
         $query = str_format (self::SQL_BOOKS_BY_CUSTOM, "{0}", "{1}", CustomColumn::getTableLinkName ($customId), CustomColumn::getTableLinkColumn ($customId));
471 491
         return self::getEntryArray ($query, array ($id), $n);
472 492
     }
473 493
 
474
-    public static function getBookById($bookId) {
494
+    public static function getBookById($bookId)
495
+    {
475 496
         $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . '
476 497
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
477 498
 where books.id = ?');
478 499
         $result->execute (array ($bookId));
479
-        while ($post = $result->fetchObject ())
480
-        {
500
+        while ($post = $result->fetchObject ()) {
481 501
             $book = new Book ($post);
482 502
             return $book;
483 503
         }
484 504
         return NULL;
485 505
     }
486 506
 
487
-    public static function getBookByDataId($dataId) {
507
+    public static function getBookByDataId($dataId)
508
+    {
488 509
         $result = parent::getDb ()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
489 510
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
490 511
 where data.book = books.id and data.id = ?');
491 512
         $result->execute (array ($dataId));
492
-        while ($post = $result->fetchObject ())
493
-        {
513
+        while ($post = $result->fetchObject ()) {
494 514
             $book = new Book ($post);
495 515
             $data = new Data ($post, $book);
496 516
             $data->id = $dataId;
@@ -500,7 +520,8 @@  discard block
 block discarded – undo
500 520
         return NULL;
501 521
     }
502 522
 
503
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
523
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
524
+    {
504 525
         $i = 0;
505 526
         $critArray = array ();
506 527
         foreach (array (PageQueryResult::SCOPE_AUTHOR,
@@ -511,8 +532,7 @@  discard block
 block discarded – undo
511 532
             if (in_array($key, getCurrentOption ('ignored_categories')) ||
512 533
                 (!array_key_exists ($key, $query) && !array_key_exists ("all", $query))) {
513 534
                 $critArray [$i] = self::BAD_SEARCH;
514
-            }
515
-            else {
535
+            } else {
516 536
                 if (array_key_exists ($key, $query)) {
517 537
                     $critArray [$i] = $query [$key];
518 538
                 } else {
@@ -524,19 +544,20 @@  discard block
 block discarded – undo
524 544
         return self::getEntryArray (self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
525 545
     }
526 546
 
527
-    public static function getBooks($n) {
547
+    public static function getBooks($n)
548
+    {
528 549
         list ($entryArray, $totalNumber) = self::getEntryArray (self::SQL_BOOKS_ALL , array (), $n);
529 550
         return array ($entryArray, $totalNumber);
530 551
     }
531 552
 
532
-    public static function getAllBooks() {
553
+    public static function getAllBooks()
554
+    {
533 555
         list (, $result) = parent::executeQuery ("select {0}
534 556
 from books
535 557
 group by substr (upper (sort), 1, 1)
536 558
 order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", self::getFilterString (), array (), -1);
537 559
         $entryArray = array();
538
-        while ($post = $result->fetchObject ())
539
-        {
560
+        while ($post = $result->fetchObject ()) {
540 561
             array_push ($entryArray, new Entry ($post->title, Book::getEntryIdByLetter ($post->title),
541 562
                 str_format (localize("bookword", $post->count), $post->count), "text",
542 563
                 array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
@@ -544,15 +565,16 @@  discard block
 block discarded – undo
544 565
         return $entryArray;
545 566
     }
546 567
 
547
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
568
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
569
+    {
548 570
         return self::getEntryArray (self::SQL_BOOKS_BY_FIRST_LETTER, array ($letter . "%"), $n, $database, $numberPerPage);
549 571
     }
550 572
 
551
-    public static function getEntryArray ($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
573
+    public static function getEntryArray ($query, $params, $n, $database = NULL, $numberPerPage = NULL)
574
+    {
552 575
         list ($totalNumber, $result) = parent::executeQuery ($query, self::BOOK_COLUMNS, self::getFilterString (), $params, $n, $database, $numberPerPage);
553 576
         $entryArray = array();
554
-        while ($post = $result->fetchObject ())
555
-        {
577
+        while ($post = $result->fetchObject ()) {
556 578
             $book = new Book ($post);
557 579
             array_push ($entryArray, $book->getEntry ());
558 580
         }
@@ -560,7 +582,8 @@  discard block
 block discarded – undo
560 582
     }
561 583
 
562 584
 
563
-    public static function getAllRecentBooks() {
585
+    public static function getAllRecentBooks()
586
+    {
564 587
         global $config;
565 588
         list ($entryArray, ) = self::getEntryArray (self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array (), -1);
566 589
         return $entryArray;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
     public $seriesIndex;
71 71
     public $comment;
72 72
     public $rating;
73
-    public $datas = NULL;
74
-    public $authors = NULL;
75
-    public $publisher = NULL;
76
-    public $serie = NULL;
77
-    public $tags = NULL;
78
-    public $languages = NULL;
73
+    public $datas = null;
74
+    public $authors = null;
75
+    public $publisher = null;
76
+    public $serie = null;
77
+    public $tags = null;
78
+    public $languages = null;
79 79
     public $format = array ();
80 80
 
81 81
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     /* End of other class (author, series, tag, ...) initialization and accessors */
199 199
 
200 200
     public static function getFilterString () {
201
-        $filter = getURLParam ("tag", NULL);
201
+        $filter = getURLParam ("tag", null);
202 202
         if (empty ($filter)) return "";
203 203
 
204 204
         $exists = true;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     {
221 221
         $bestFormatForKindle = array ("EPUB", "PDF", "AZW3", "MOBI");
222 222
         $bestRank = -1;
223
-        $bestData = NULL;
223
+        $bestData = null;
224 224
         foreach ($this->getDatas () as $data) {
225 225
             $key = array_search ($data->format, $bestFormatForKindle);
226 226
             if ($key !== false && $key > $bestRank) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         return reset ($reduced);
288 288
     }
289 289
 
290
-    public function getFilePath ($extension, $idData = NULL, $relative = false)
290
+    public function getFilePath ($extension, $idData = null, $relative = false)
291 291
     {
292 292
         if ($extension == "jpg")
293 293
         {
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         else
297 297
         {
298 298
             $data = $this->getDataById ($idData);
299
-            if (!$data) return NULL;
299
+            if (!$data) return null;
300 300
             $file = $data->name . "." . strtolower ($data->format);
301 301
         }
302 302
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         }
347 347
     }
348 348
 
349
-    public function getThumbnail ($width, $height, $outputfile = NULL) {
349
+    public function getThumbnail ($width, $height, $outputfile = null) {
350 350
         if (is_null ($width) && is_null ($height)) {
351 351
             return false;
352 352
         }
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 
388 388
         if ($this->hasCover)
389 389
         {
390
-            array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL));
390
+            array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", null));
391 391
 
392
-            array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL));
392
+            array_push ($linkArray, Data::getLink ($this, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", null));
393 393
         }
394 394
 
395 395
         foreach ($this->getDatas () as $data)
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
             $this->getLinkArray (), $this);
420 420
     }
421 421
 
422
-    public static function getBookCount($database = NULL) {
422
+    public static function getBookCount($database = null) {
423 423
         return parent::executeQuerySingle ('select count(*) from books', $database);
424 424
     }
425 425
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
             $book = new Book ($post);
482 482
             return $book;
483 483
         }
484
-        return NULL;
484
+        return null;
485 485
     }
486 486
 
487 487
     public static function getBookByDataId($dataId) {
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
             $book->datas = array ($data);
498 498
             return $book;
499 499
         }
500
-        return NULL;
500
+        return null;
501 501
     }
502 502
 
503
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
503
+    public static function getBooksByQuery($query, $n, $database = null, $numberPerPage = null) {
504 504
         $i = 0;
505 505
         $critArray = array ();
506 506
         foreach (array (PageQueryResult::SCOPE_AUTHOR,
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
         return $entryArray;
545 545
     }
546 546
 
547
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
547
+    public static function getBooksByStartingLetter($letter, $n, $database = null, $numberPerPage = null) {
548 548
         return self::getEntryArray (self::SQL_BOOKS_BY_FIRST_LETTER, array ($letter . "%"), $n, $database, $numberPerPage);
549 549
     }
550 550
 
551
-    public static function getEntryArray ($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
551
+    public static function getEntryArray ($query, $params, $n, $database = null, $numberPerPage = null) {
552 552
         list ($totalNumber, $result) = parent::executeQuery ($query, self::BOOK_COLUMNS, self::getFilterString (), $params, $n, $database, $numberPerPage);
553 553
         $entryArray = array();
554 554
         while ($post = $result->fetchObject ())
Please login to merge, or discard this patch.
data.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -141,6 +141,9 @@  discard block
 block discarded – undo
141 141
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
142 142
     }
143 143
 
144
+    /**
145
+     * @param Book $book
146
+     */
144 147
     public static function getDataByBook ($book) {
145 148
         $out = array ();
146 149
         $result = parent::getDb ()->prepare('select id, format, name
@@ -154,6 +157,9 @@  discard block
 block discarded – undo
154 157
         return $out;
155 158
     }
156 159
 
160
+    /**
161
+     * @param string $urlParam
162
+     */
157 163
     public static function handleThumbnailLink ($urlParam, $height) {
158 164
         global $config;
159 165
 
@@ -173,6 +179,10 @@  discard block
 block discarded – undo
173 179
         return $urlParam;
174 180
     }
175 181
 
182
+    /**
183
+     * @param string $type
184
+     * @param string $filename
185
+     */
176 186
     public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
177 187
     {
178 188
         global $config;
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
         $this->id = $post->id;
59 59
         $this->name = $post->name;
60 60
         $this->format = $post->format;
61
-        $this->realFormat = str_replace ("ORIGINAL_", "", $post->format);
62
-        $this->extension = strtolower ($this->realFormat);
61
+        $this->realFormat = str_replace("ORIGINAL_", "", $post->format);
62
+        $this->extension = strtolower($this->realFormat);
63 63
         $this->book = $book;
64 64
     }
65 65
 
66
-    public function isKnownType () {
67
-        return array_key_exists ($this->extension, self::$mimetypes);
66
+    public function isKnownType() {
67
+        return array_key_exists($this->extension, self::$mimetypes);
68 68
     }
69 69
 
70
-    public function getMimeType () {
70
+    public function getMimeType() {
71 71
         $result = "application/octet-stream";
72
-        if ($this->isKnownType ()) {
72
+        if ($this->isKnownType()) {
73 73
             return self::$mimetypes [$this->extension];
74 74
         } elseif (function_exists('finfo_open') === true) {
75 75
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
76 76
 
77 77
             if (is_resource($finfo) === true)
78 78
             {
79
-                $result = finfo_file($finfo, $this->getLocalPath ());
79
+                $result = finfo_file($finfo, $this->getLocalPath());
80 80
             }
81 81
 
82 82
             finfo_close($finfo);
@@ -85,80 +85,80 @@  discard block
 block discarded – undo
85 85
         return $result;
86 86
     }
87 87
 
88
-    public function isEpubValidOnKobo () {
88
+    public function isEpubValidOnKobo() {
89 89
         return $this->format == "EPUB" || $this->format == "KEPUB";
90 90
     }
91 91
 
92
-    public function getFilename () {
93
-        return $this->name . "." . strtolower ($this->format);
92
+    public function getFilename() {
93
+        return $this->name . "." . strtolower($this->format);
94 94
     }
95 95
 
96
-    public function getUpdatedFilename () {
97
-        return $this->book->getAuthorsSort () . " - " . $this->book->title;
96
+    public function getUpdatedFilename() {
97
+        return $this->book->getAuthorsSort() . " - " . $this->book->title;
98 98
     }
99 99
 
100
-    public function getUpdatedFilenameEpub () {
101
-        return $this->getUpdatedFilename () . ".epub";
100
+    public function getUpdatedFilenameEpub() {
101
+        return $this->getUpdatedFilename() . ".epub";
102 102
     }
103 103
 
104
-    public function getUpdatedFilenameKepub () {
105
-        return $this->getUpdatedFilename () . ".kepub.epub";
104
+    public function getUpdatedFilenameKepub() {
105
+        return $this->getUpdatedFilename() . ".kepub.epub";
106 106
     }
107 107
 
108
-    public function getDataLink ($rel, $title = NULL) {
108
+    public function getDataLink($rel, $title = NULL) {
109 109
         global $config;
110 110
 
111 111
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
112 112
             return $this->getHtmlLinkWithRewriting($title);
113 113
         }
114 114
 
115
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
115
+        return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title);
116 116
     }
117 117
 
118
-    public function getHtmlLink () {
118
+    public function getHtmlLink() {
119 119
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
120 120
     }
121 121
 
122
-    public function getLocalPath () {
123
-        return $this->book->path . "/" . $this->getFilename ();
122
+    public function getLocalPath() {
123
+        return $this->book->path . "/" . $this->getFilename();
124 124
     }
125 125
 
126
-    public function getHtmlLinkWithRewriting ($title = NULL) {
126
+    public function getHtmlLinkWithRewriting($title = NULL) {
127 127
         global $config;
128 128
 
129 129
         $database = "";
130
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
130
+        if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/";
131 131
 
132 132
         $href = "download/" . $this->id . "/" . $database;
133 133
 
134 134
         if ($config['cops_provide_kepub'] == "1" &&
135
-            $this->isEpubValidOnKobo () &&
135
+            $this->isEpubValidOnKobo() &&
136 136
             preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
137
-            $href .= rawurlencode ($this->getUpdatedFilenameKepub ());
137
+            $href .= rawurlencode($this->getUpdatedFilenameKepub());
138 138
         } else {
139
-            $href .= rawurlencode ($this->getFilename ());
139
+            $href .= rawurlencode($this->getFilename());
140 140
         }
141
-        return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
141
+        return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title);
142 142
     }
143 143
 
144
-    public static function getDataByBook ($book) {
145
-        $out = array ();
146
-        $result = parent::getDb ()->prepare('select id, format, name
144
+    public static function getDataByBook($book) {
145
+        $out = array();
146
+        $result = parent::getDb()->prepare('select id, format, name
147 147
                                              from data where book = ?');
148
-        $result->execute (array ($book->id));
148
+        $result->execute(array($book->id));
149 149
 
150
-        while ($post = $result->fetchObject ())
150
+        while ($post = $result->fetchObject())
151 151
         {
152
-            array_push ($out, new Data ($post, $book));
152
+            array_push($out, new Data($post, $book));
153 153
         }
154 154
         return $out;
155 155
     }
156 156
 
157
-    public static function handleThumbnailLink ($urlParam, $height) {
157
+    public static function handleThumbnailLink($urlParam, $height) {
158 158
         global $config;
159 159
 
160
-        if (is_null ($height)) {
161
-            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
160
+        if (is_null($height)) {
161
+            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
162 162
                 $height = $config['cops_opds_thumbnail_height'];
163 163
             }
164 164
             else
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
         return $urlParam;
174 174
     }
175 175
 
176
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
176
+    public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
177 177
     {
178 178
         global $config;
179 179
 
180 180
         $urlParam = addURLParameter("", "data", $idData);
181 181
 
182
-        if (Base::useAbsolutePath () ||
182
+        if (Base::useAbsolutePath() ||
183 183
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
184 184
             ($type == "epub" && $config['cops_update_epub-metadata']))
185 185
         {
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
189 189
             }
190 190
             $urlParam = addURLParameter($urlParam, "id", $book->id);
191
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
191
+            if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
192 192
             if ($config['cops_thumbnail_handling'] != "1" &&
193 193
                 !empty ($config['cops_thumbnail_handling']) &&
194 194
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
195
-                return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title);
195
+                return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title);
196 196
             } else {
197
-                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
197
+                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title);
198 198
             }
199 199
         }
200 200
         else
201 201
         {
202
-            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
202
+            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title);
203 203
         }
204 204
     }
205 205
 }
Please login to merge, or discard this patch.
Braces   +44 added lines, -30 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@  discard block
 block discarded – undo
6 6
  * @author     Sébastien Lucas <[email protected]>
7 7
  */
8 8
 
9
-class Data extends Base {
9
+class Data extends Base
10
+{
10 11
     public $id;
11 12
     public $name;
12 13
     public $format;
@@ -54,7 +55,8 @@  discard block
 block discarded – undo
54 55
         'zip'   => 'application/zip'
55 56
     );
56 57
 
57
-    public function __construct($post, $book = null) {
58
+    public function __construct($post, $book = null)
59
+    {
58 60
         $this->id = $post->id;
59 61
         $this->name = $post->name;
60 62
         $this->format = $post->format;
@@ -63,19 +65,20 @@  discard block
 block discarded – undo
63 65
         $this->book = $book;
64 66
     }
65 67
 
66
-    public function isKnownType () {
68
+    public function isKnownType ()
69
+    {
67 70
         return array_key_exists ($this->extension, self::$mimetypes);
68 71
     }
69 72
 
70
-    public function getMimeType () {
73
+    public function getMimeType ()
74
+    {
71 75
         $result = "application/octet-stream";
72 76
         if ($this->isKnownType ()) {
73 77
             return self::$mimetypes [$this->extension];
74 78
         } elseif (function_exists('finfo_open') === true) {
75 79
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
76 80
 
77
-            if (is_resource($finfo) === true)
78
-            {
81
+            if (is_resource($finfo) === true) {
79 82
                 $result = finfo_file($finfo, $this->getLocalPath ());
80 83
             }
81 84
 
@@ -85,27 +88,33 @@  discard block
 block discarded – undo
85 88
         return $result;
86 89
     }
87 90
 
88
-    public function isEpubValidOnKobo () {
91
+    public function isEpubValidOnKobo ()
92
+    {
89 93
         return $this->format == "EPUB" || $this->format == "KEPUB";
90 94
     }
91 95
 
92
-    public function getFilename () {
96
+    public function getFilename ()
97
+    {
93 98
         return $this->name . "." . strtolower ($this->format);
94 99
     }
95 100
 
96
-    public function getUpdatedFilename () {
101
+    public function getUpdatedFilename ()
102
+    {
97 103
         return $this->book->getAuthorsSort () . " - " . $this->book->title;
98 104
     }
99 105
 
100
-    public function getUpdatedFilenameEpub () {
106
+    public function getUpdatedFilenameEpub ()
107
+    {
101 108
         return $this->getUpdatedFilename () . ".epub";
102 109
     }
103 110
 
104
-    public function getUpdatedFilenameKepub () {
111
+    public function getUpdatedFilenameKepub ()
112
+    {
105 113
         return $this->getUpdatedFilename () . ".kepub.epub";
106 114
     }
107 115
 
108
-    public function getDataLink ($rel, $title = NULL) {
116
+    public function getDataLink ($rel, $title = NULL)
117
+    {
109 118
         global $config;
110 119
 
111 120
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -115,19 +124,24 @@  discard block
 block discarded – undo
115 124
         return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
116 125
     }
117 126
 
118
-    public function getHtmlLink () {
127
+    public function getHtmlLink ()
128
+    {
119 129
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
120 130
     }
121 131
 
122
-    public function getLocalPath () {
132
+    public function getLocalPath ()
133
+    {
123 134
         return $this->book->path . "/" . $this->getFilename ();
124 135
     }
125 136
 
126
-    public function getHtmlLinkWithRewriting ($title = NULL) {
137
+    public function getHtmlLinkWithRewriting ($title = NULL)
138
+    {
127 139
         global $config;
128 140
 
129 141
         $database = "";
130
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
142
+        if (!is_null (GetUrlParam (DB))) {
143
+            $database = GetUrlParam (DB) . "/";
144
+        }
131 145
 
132 146
         $href = "download/" . $this->id . "/" . $database;
133 147
 
@@ -141,28 +155,27 @@  discard block
 block discarded – undo
141 155
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
142 156
     }
143 157
 
144
-    public static function getDataByBook ($book) {
158
+    public static function getDataByBook ($book)
159
+    {
145 160
         $out = array ();
146 161
         $result = parent::getDb ()->prepare('select id, format, name
147 162
                                              from data where book = ?');
148 163
         $result->execute (array ($book->id));
149 164
 
150
-        while ($post = $result->fetchObject ())
151
-        {
165
+        while ($post = $result->fetchObject ()) {
152 166
             array_push ($out, new Data ($post, $book));
153 167
         }
154 168
         return $out;
155 169
     }
156 170
 
157
-    public static function handleThumbnailLink ($urlParam, $height) {
171
+    public static function handleThumbnailLink ($urlParam, $height)
172
+    {
158 173
         global $config;
159 174
 
160 175
         if (is_null ($height)) {
161 176
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
162 177
                 $height = $config['cops_opds_thumbnail_height'];
163
-            }
164
-            else
165
-            {
178
+            } else {
166 179
                 $height = $config['cops_html_thumbnail_height'];
167 180
             }
168 181
         }
@@ -181,14 +194,17 @@  discard block
 block discarded – undo
181 194
 
182 195
         if (Base::useAbsolutePath () ||
183 196
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
184
-            ($type == "epub" && $config['cops_update_epub-metadata']))
185
-        {
186
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
197
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
198
+            if ($type != "jpg") {
199
+                $urlParam = addURLParameter($urlParam, "type", $type);
200
+            }
187 201
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
188 202
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
189 203
             }
190 204
             $urlParam = addURLParameter($urlParam, "id", $book->id);
191
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
205
+            if (!is_null (GetUrlParam (DB))) {
206
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
207
+            }
192 208
             if ($config['cops_thumbnail_handling'] != "1" &&
193 209
                 !empty ($config['cops_thumbnail_handling']) &&
194 210
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -196,9 +212,7 @@  discard block
 block discarded – undo
196 212
             } else {
197 213
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
198 214
             }
199
-        }
200
-        else
201
-        {
215
+        } else {
202 216
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
203 217
         }
204 218
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         return $this->getUpdatedFilename () . ".kepub.epub";
106 106
     }
107 107
 
108
-    public function getDataLink ($rel, $title = NULL) {
108
+    public function getDataLink ($rel, $title = null) {
109 109
         global $config;
110 110
 
111 111
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         return $this->book->path . "/" . $this->getFilename ();
124 124
     }
125 125
 
126
-    public function getHtmlLinkWithRewriting ($title = NULL) {
126
+    public function getHtmlLinkWithRewriting ($title = null) {
127 127
         global $config;
128 128
 
129 129
         $database = "";
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         return $urlParam;
174 174
     }
175 175
 
176
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
176
+    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = null, $height = null)
177 177
     {
178 178
         global $config;
179 179
 
Please login to merge, or discard this patch.
rating.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -36,6 +36,9 @@
 block discarded – undo
36 36
         return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
37 37
     }
38 38
 
39
+    /**
40
+     * @param string $query
41
+     */
39 42
     public static function getEntryArray ($query, $params) {
40 43
         list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
41 44
         $entryArray = array();
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     const ALL_RATING_ID = "cops:rating";
11 11
 
12 12
     const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
13
-    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";
13
+    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 14
     public $id;
15 15
     public $name;
16 16
 
@@ -19,41 +19,41 @@  discard block
 block discarded – undo
19 19
         $this->name = $pname;
20 20
     }
21 21
 
22
-    public function getUri () {
23
-        return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id";
22
+    public function getUri() {
23
+        return "?page=" . parent::PAGE_RATING_DETAIL . "&id=$this->id";
24 24
     }
25 25
 
26
-    public function getEntryId () {
27
-        return self::ALL_RATING_ID.":".$this->id;
26
+    public function getEntryId() {
27
+        return self::ALL_RATING_ID . ":" . $this->id;
28 28
     }
29 29
 
30 30
     public static function getCount() {
31 31
         // str_format (localize("ratings", count(array))
32
-        return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
32
+        return parent::getCountGeneric("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
33 33
     }
34 34
 
35 35
     public static function getAllRatings() {
36
-        return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
36
+        return self::getEntryArray(self::SQL_ALL_RATINGS, array());
37 37
     }
38 38
 
39
-    public static function getEntryArray ($query, $params) {
40
-        list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
39
+    public static function getEntryArray($query, $params) {
40
+        list (, $result) = parent::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
41 41
         $entryArray = array();
42
-        while ($post = $result->fetchObject ())
42
+        while ($post = $result->fetchObject())
43 43
         {
44
-            $ratingObj = new Rating ($post->id, $post->rating);
45
-            $rating=$post->rating/2;
46
-            $rating = str_format (localize("ratingword", $rating), $rating);
47
-            array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (),
48
-                str_format (localize("bookword", $post->count), $post->count), "text",
49
-                array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count));
44
+            $ratingObj = new Rating($post->id, $post->rating);
45
+            $rating = $post->rating / 2;
46
+            $rating = str_format(localize("ratingword", $rating), $rating);
47
+            array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(),
48
+                str_format(localize("bookword", $post->count), $post->count), "text",
49
+                array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
50 50
         }
51 51
         return $entryArray;
52 52
     }
53 53
 
54
-    public static function getRatingById ($ratingId) {
55
-        $result = parent::getDb ()->prepare('select rating from ratings where id = ?');
56
-        $result->execute (array ($ratingId));
57
-        return new Rating ($ratingId, $result->fetchColumn ());
54
+    public static function getRatingById($ratingId) {
55
+        $result = parent::getDb()->prepare('select rating from ratings where id = ?');
56
+        $result->execute(array($ratingId));
57
+        return new Rating($ratingId, $result->fetchColumn());
58 58
     }
59 59
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@  discard block
 block discarded – undo
6 6
  * @author     Michael Pfitzner
7 7
  */
8 8
 
9
-class Rating extends Base {
9
+class Rating extends Base
10
+{
10 11
     const ALL_RATING_ID = "cops:rating";
11 12
 
12 13
     const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
@@ -14,33 +15,38 @@  discard block
 block discarded – undo
14 15
     public $id;
15 16
     public $name;
16 17
 
17
-    public function __construct($pid, $pname) {
18
+    public function __construct($pid, $pname)
19
+    {
18 20
         $this->id = $pid;
19 21
         $this->name = $pname;
20 22
     }
21 23
 
22
-    public function getUri () {
24
+    public function getUri ()
25
+    {
23 26
         return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id";
24 27
     }
25 28
 
26
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
27 31
         return self::ALL_RATING_ID.":".$this->id;
28 32
     }
29 33
 
30
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
31 36
         // str_format (localize("ratings", count(array))
32 37
         return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
33 38
     }
34 39
 
35
-    public static function getAllRatings() {
40
+    public static function getAllRatings()
41
+    {
36 42
         return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
37 43
     }
38 44
 
39
-    public static function getEntryArray ($query, $params) {
45
+    public static function getEntryArray ($query, $params)
46
+    {
40 47
         list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
41 48
         $entryArray = array();
42
-        while ($post = $result->fetchObject ())
43
-        {
49
+        while ($post = $result->fetchObject ()) {
44 50
             $ratingObj = new Rating ($post->id, $post->rating);
45 51
             $rating=$post->rating/2;
46 52
             $rating = str_format (localize("ratingword", $rating), $rating);
@@ -51,7 +57,8 @@  discard block
 block discarded – undo
51 57
         return $entryArray;
52 58
     }
53 59
 
54
-    public static function getRatingById ($ratingId) {
60
+    public static function getRatingById ($ratingId)
61
+    {
55 62
         $result = parent::getDb ()->prepare('select rating from ratings where id = ?');
56 63
         $result->execute (array ($ratingId));
57 64
         return new Rating ($ratingId, $result->fetchColumn ());
Please login to merge, or discard this patch.
tag.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -45,6 +45,9 @@
 block discarded – undo
45 45
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
46 46
     }
47 47
 
48
+    /**
49
+     * @param integer $numberPerPage
50
+     */
48 51
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
49 52
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50 53
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,44 +19,44 @@
 block discarded – undo
19 19
         $this->name = $post->name;
20 20
     }
21 21
 
22
-    public function getUri () {
23
-        return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
22
+    public function getUri() {
23
+        return "?page=" . parent::PAGE_TAG_DETAIL . "&id=$this->id";
24 24
     }
25 25
 
26
-    public function getEntryId () {
27
-        return self::ALL_TAGS_ID.":".$this->id;
26
+    public function getEntryId() {
27
+        return self::ALL_TAGS_ID . ":" . $this->id;
28 28
     }
29 29
 
30 30
     public static function getCount() {
31 31
         // str_format (localize("tags.alphabetical", count(array))
32
-        return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
32
+        return parent::getCountGeneric("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
33 33
     }
34 34
 
35
-    public static function getTagById ($tagId) {
36
-        $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
37
-        $result->execute (array ($tagId));
38
-        if ($post = $result->fetchObject ()) {
39
-            return new Tag ($post);
35
+    public static function getTagById($tagId) {
36
+        $result = parent::getDb()->prepare('select id, name  from tags where id = ?');
37
+        $result->execute(array($tagId));
38
+        if ($post = $result->fetchObject()) {
39
+            return new Tag($post);
40 40
         }
41 41
         return NULL;
42 42
     }
43 43
 
44 44
     public static function getAllTags() {
45
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
45
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_TAGS, self::TAG_COLUMNS, array(), "Tag");
46 46
     }
47 47
 
48 48
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
49
-        $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
49
+        $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50 50
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
51
-        list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
51
+        list ($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
52 52
         $entryArray = array();
53
-        while ($post = $result->fetchObject ())
53
+        while ($post = $result->fetchObject())
54 54
         {
55
-            $tag = new Tag ($post);
56
-            array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
57
-                str_format (localize("bookword", $post->count), $post->count), "text",
58
-                array ( new LinkNavigation ($tag->getUri ()))));
55
+            $tag = new Tag($post);
56
+            array_push($entryArray, new Entry($tag->name, $tag->getEntryId(),
57
+                str_format(localize("bookword", $post->count), $post->count), "text",
58
+                array(new LinkNavigation($tag->getUri()))));
59 59
         }
60
-        return array ($entryArray, $totalNumber);
60
+        return array($entryArray, $totalNumber);
61 61
     }
62 62
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@  discard block
 block discarded – undo
6 6
  * @author     Sébastien Lucas <[email protected]>
7 7
  */
8 8
 
9
-class Tag extends Base {
9
+class Tag extends Base
10
+{
10 11
     const ALL_TAGS_ID = "cops:tags";
11 12
     const TAG_COLUMNS = "tags.id as id, tags.name as name, count(*) as count";
12 13
     const SQL_ALL_TAGS = "select {0} from tags, books_tags_link where tags.id = tag group by tags.id, tags.name order by tags.name";
@@ -14,25 +15,30 @@  discard block
 block discarded – undo
14 15
     public $id;
15 16
     public $name;
16 17
 
17
-    public function __construct($post) {
18
+    public function __construct($post)
19
+    {
18 20
         $this->id = $post->id;
19 21
         $this->name = $post->name;
20 22
     }
21 23
 
22
-    public function getUri () {
24
+    public function getUri ()
25
+    {
23 26
         return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
24 27
     }
25 28
 
26
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
27 31
         return self::ALL_TAGS_ID.":".$this->id;
28 32
     }
29 33
 
30
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
31 36
         // str_format (localize("tags.alphabetical", count(array))
32 37
         return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
33 38
     }
34 39
 
35
-    public static function getTagById ($tagId) {
40
+    public static function getTagById ($tagId)
41
+    {
36 42
         $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
37 43
         $result->execute (array ($tagId));
38 44
         if ($post = $result->fetchObject ()) {
@@ -41,17 +47,18 @@  discard block
 block discarded – undo
41 47
         return NULL;
42 48
     }
43 49
 
44
-    public static function getAllTags() {
50
+    public static function getAllTags()
51
+    {
45 52
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
46 53
     }
47 54
 
48
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
55
+    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
56
+    {
49 57
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50 58
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
51 59
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
52 60
         $entryArray = array();
53
-        while ($post = $result->fetchObject ())
54
-        {
61
+        while ($post = $result->fetchObject ()) {
55 62
             $tag = new Tag ($post);
56 63
             array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
57 64
                 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
@@ -38,14 +38,14 @@
 block discarded – undo
38 38
         if ($post = $result->fetchObject ()) {
39 39
             return new Tag ($post);
40 40
         }
41
-        return NULL;
41
+        return null;
42 42
     }
43 43
 
44 44
     public static function getAllTags() {
45 45
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
46 46
     }
47 47
 
48
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
48
+    public static function getAllTagsByQuery($query, $n, $database = null, $numberPerPage = null) {
49 49
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50 50
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
51 51
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
Please login to merge, or discard this patch.
transliteration.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
 /**
164 164
  * Replaces a Unicode character using the transliteration database.
165 165
  *
166
- * @param $ord
166
+ * @param integer $ord
167 167
  *   An ordinal Unicode character code.
168 168
  * @param $unknown
169 169
  *   Replacement string for characters that do not have a suitable ASCII
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -26,56 +26,56 @@  discard block
 block discarded – undo
26 26
  *   Transliterated text.
27 27
  */
28 28
 function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
29
-  // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30
-  // avoid the overhead of initializing the decomposition tables by skipping
31
-  // out early.
32
-  if (!preg_match('/[\x80-\xff]/', $string)) {
29
+    // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30
+    // avoid the overhead of initializing the decomposition tables by skipping
31
+    // out early.
32
+    if (!preg_match('/[\x80-\xff]/', $string)) {
33 33
     return $string;
34
-  }
34
+    }
35 35
 
36
-  static $tail_bytes;
36
+    static $tail_bytes;
37 37
 
38
-  if (!isset($tail_bytes)) {
38
+    if (!isset($tail_bytes)) {
39 39
     // Each UTF-8 head byte is followed by a certain number of tail bytes.
40 40
     $tail_bytes = array();
41 41
     for ($n = 0; $n < 256; $n++) {
42
-      if ($n < 0xc0) {
42
+        if ($n < 0xc0) {
43 43
         $remaining = 0;
44
-      }
45
-      elseif ($n < 0xe0) {
44
+        }
45
+        elseif ($n < 0xe0) {
46 46
         $remaining = 1;
47
-      }
48
-      elseif ($n < 0xf0) {
47
+        }
48
+        elseif ($n < 0xf0) {
49 49
         $remaining = 2;
50
-      }
51
-      elseif ($n < 0xf8) {
50
+        }
51
+        elseif ($n < 0xf8) {
52 52
         $remaining = 3;
53
-      }
54
-      elseif ($n < 0xfc) {
53
+        }
54
+        elseif ($n < 0xfc) {
55 55
         $remaining = 4;
56
-      }
57
-      elseif ($n < 0xfe) {
56
+        }
57
+        elseif ($n < 0xfe) {
58 58
         $remaining = 5;
59
-      }
60
-      else {
59
+        }
60
+        else {
61 61
         $remaining = 0;
62
-      }
63
-      $tail_bytes[chr($n)] = $remaining;
62
+        }
63
+        $tail_bytes[chr($n)] = $remaining;
64
+    }
64 65
     }
65
-  }
66 66
 
67
-  // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can
68
-  // be handled much more quickly. Don't chop up Unicode areas for punctuation,
69
-  // though, that wastes energy.
70
-  preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches);
67
+    // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can
68
+    // be handled much more quickly. Don't chop up Unicode areas for punctuation,
69
+    // though, that wastes energy.
70
+    preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches);
71 71
 
72
-  $result = '';
73
-  foreach ($matches[0] as $str) {
72
+    $result = '';
73
+    foreach ($matches[0] as $str) {
74 74
     if ($str[0] < "\x80") {
75
-      // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so
76
-      // skip over it.
77
-      $result .= $str;
78
-      continue;
75
+        // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so
76
+        // skip over it.
77
+        $result .= $str;
78
+        continue;
79 79
     }
80 80
 
81 81
     // We'll have to examine the chunk byte by byte to ensure that it consists
@@ -91,73 +91,73 @@  discard block
 block discarded – undo
91 91
     $len = $chunk + 1;
92 92
 
93 93
     for ($i = -1; --$len; ) {
94
-      $c = $str[++$i];
95
-      if ($remaining = $tail_bytes[$c]) {
94
+        $c = $str[++$i];
95
+        if ($remaining = $tail_bytes[$c]) {
96 96
         // UTF-8 head byte!
97 97
         $sequence = $head = $c;
98 98
         do {
99
-          // Look for the defined number of tail bytes...
100
-          if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
99
+            // Look for the defined number of tail bytes...
100
+            if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
101 101
             // Legal tail bytes are nice.
102 102
             $sequence .= $c;
103
-          }
104
-          else {
103
+            }
104
+            else {
105 105
             if ($len == 0) {
106
-              // Premature end of string! Drop a replacement character into
107
-              // output to represent the invalid UTF-8 sequence.
108
-              $result .= $unknown;
109
-              break 2;
106
+                // Premature end of string! Drop a replacement character into
107
+                // output to represent the invalid UTF-8 sequence.
108
+                $result .= $unknown;
109
+                break 2;
110 110
             }
111 111
             else {
112
-              // Illegal tail byte; abandon the sequence.
113
-              $result .= $unknown;
114
-              // Back up and reprocess this byte; it may itself be a legal
115
-              // ASCII or UTF-8 sequence head.
116
-              --$i;
117
-              ++$len;
118
-              continue 2;
112
+                // Illegal tail byte; abandon the sequence.
113
+                $result .= $unknown;
114
+                // Back up and reprocess this byte; it may itself be a legal
115
+                // ASCII or UTF-8 sequence head.
116
+                --$i;
117
+                ++$len;
118
+                continue 2;
119
+            }
119 120
             }
120
-          }
121 121
         } while (--$remaining);
122 122
 
123 123
         $n = ord($head);
124 124
         if ($n <= 0xdf) {
125
-          $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
125
+            $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
126 126
         }
127 127
         elseif ($n <= 0xef) {
128
-          $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
128
+            $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
129 129
         }
130 130
         elseif ($n <= 0xf7) {
131
-          $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
131
+            $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
132 132
         }
133 133
         elseif ($n <= 0xfb) {
134
-          $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
134
+            $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
135 135
         }
136 136
         elseif ($n <= 0xfd) {
137
-          $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
137
+            $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
138 138
         }
139 139
         $result .= _transliteration_replace($ord, $unknown, $source_langcode);
140 140
         $head = '';
141
-      }
142
-      elseif ($c < "\x80") {
141
+        }
142
+        elseif ($c < "\x80") {
143 143
         // ASCII byte.
144 144
         $result .= $c;
145 145
         $head = '';
146
-      }
147
-      elseif ($c < "\xc0") {
146
+        }
147
+        elseif ($c < "\xc0") {
148 148
         // Illegal tail bytes.
149 149
         if ($head == '') {
150
-          $result .= $unknown;
150
+            $result .= $unknown;
151
+        }
151 152
         }
152
-      }
153
-      else {
153
+        else {
154 154
         // Miscellaneous freaks.
155 155
         $result .= $unknown;
156 156
         $head = '';
157
-      }
157
+        }
158 158
     }
159
-  }
160
-  return $result;
159
+    }
160
+    return $result;
161 161
 }
162 162
 
163 163
 /**
@@ -176,36 +176,36 @@  discard block
 block discarded – undo
176 176
  *   ASCII replacement character.
177 177
  */
178 178
 function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
179
-  static $map = array();
179
+    static $map = array();
180 180
 
181
-  //GL: set language later
182
-  /*
181
+    //GL: set language later
182
+    /*
183 183
   if (!isset($langcode)) {
184 184
     global $language;
185 185
     $langcode = $language->language;
186 186
   }
187 187
   */
188 188
 
189
-  $bank = $ord >> 8;
189
+    $bank = $ord >> 8;
190 190
 
191
-  if (!isset($map[$bank][$langcode])) {
191
+    if (!isset($map[$bank][$langcode])) {
192 192
     $file = './resources/transliteration-data/' . sprintf('x%02x', $bank) . '.php';  
193 193
     if (file_exists($file)) {
194
-      include $file;
195
-      if ($langcode != 'en' && isset($variant[$langcode])) {
194
+        include $file;
195
+        if ($langcode != 'en' && isset($variant[$langcode])) {
196 196
         // Merge in language specific mappings.
197 197
         $map[$bank][$langcode] = $variant[$langcode] + $base;
198
-      }
199
-      else {
198
+        }
199
+        else {
200 200
         $map[$bank][$langcode] = $base;
201
-      }
201
+        }
202 202
     }
203 203
     else {
204
-      $map[$bank][$langcode] = array();
204
+        $map[$bank][$langcode] = array();
205
+    }
205 206
     }
206
-  }
207 207
 
208
-  $ord = $ord & 255;
208
+    $ord = $ord & 255;
209 209
 
210
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
210
+    return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
211 211
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     // Counting down is faster. I'm *so* sorry.
91 91
     $len = $chunk + 1;
92 92
 
93
-    for ($i = -1; --$len; ) {
93
+    for ($i = -1; --$len;) {
94 94
       $c = $str[++$i];
95 95
       if ($remaining = $tail_bytes[$c]) {
96 96
         // UTF-8 head byte!
@@ -207,5 +207,5 @@  discard block
 block discarded – undo
207 207
 
208 208
   $ord = $ord & 255;
209 209
 
210
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
210
+  return isset($map[$bank][$langcode][$ord])?$map[$bank][$langcode][$ord]:$unknown;
211 211
 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
  * @return
26 26
  *   Transliterated text.
27 27
  */
28
-function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
28
+function _transliteration_process($string, $unknown = '?', $source_langcode = NULL)
29
+{
29 30
   // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30 31
   // avoid the overhead of initializing the decomposition tables by skipping
31 32
   // out early.
@@ -41,23 +42,17 @@  discard block
 block discarded – undo
41 42
     for ($n = 0; $n < 256; $n++) {
42 43
       if ($n < 0xc0) {
43 44
         $remaining = 0;
44
-      }
45
-      elseif ($n < 0xe0) {
45
+      } elseif ($n < 0xe0) {
46 46
         $remaining = 1;
47
-      }
48
-      elseif ($n < 0xf0) {
47
+      } elseif ($n < 0xf0) {
49 48
         $remaining = 2;
50
-      }
51
-      elseif ($n < 0xf8) {
49
+      } elseif ($n < 0xf8) {
52 50
         $remaining = 3;
53
-      }
54
-      elseif ($n < 0xfc) {
51
+      } elseif ($n < 0xfc) {
55 52
         $remaining = 4;
56
-      }
57
-      elseif ($n < 0xfe) {
53
+      } elseif ($n < 0xfe) {
58 54
         $remaining = 5;
59
-      }
60
-      else {
55
+      } else {
61 56
         $remaining = 0;
62 57
       }
63 58
       $tail_bytes[chr($n)] = $remaining;
@@ -100,15 +95,13 @@  discard block
 block discarded – undo
100 95
           if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
101 96
             // Legal tail bytes are nice.
102 97
             $sequence .= $c;
103
-          }
104
-          else {
98
+          } else {
105 99
             if ($len == 0) {
106 100
               // Premature end of string! Drop a replacement character into
107 101
               // output to represent the invalid UTF-8 sequence.
108 102
               $result .= $unknown;
109 103
               break 2;
110
-            }
111
-            else {
104
+            } else {
112 105
               // Illegal tail byte; abandon the sequence.
113 106
               $result .= $unknown;
114 107
               // Back up and reprocess this byte; it may itself be a legal
@@ -123,34 +116,27 @@  discard block
 block discarded – undo
123 116
         $n = ord($head);
124 117
         if ($n <= 0xdf) {
125 118
           $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
126
-        }
127
-        elseif ($n <= 0xef) {
119
+        } elseif ($n <= 0xef) {
128 120
           $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
129
-        }
130
-        elseif ($n <= 0xf7) {
121
+        } elseif ($n <= 0xf7) {
131 122
           $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
132
-        }
133
-        elseif ($n <= 0xfb) {
123
+        } elseif ($n <= 0xfb) {
134 124
           $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
135
-        }
136
-        elseif ($n <= 0xfd) {
125
+        } elseif ($n <= 0xfd) {
137 126
           $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
138 127
         }
139 128
         $result .= _transliteration_replace($ord, $unknown, $source_langcode);
140 129
         $head = '';
141
-      }
142
-      elseif ($c < "\x80") {
130
+      } elseif ($c < "\x80") {
143 131
         // ASCII byte.
144 132
         $result .= $c;
145 133
         $head = '';
146
-      }
147
-      elseif ($c < "\xc0") {
134
+      } elseif ($c < "\xc0") {
148 135
         // Illegal tail bytes.
149 136
         if ($head == '') {
150 137
           $result .= $unknown;
151 138
         }
152
-      }
153
-      else {
139
+      } else {
154 140
         // Miscellaneous freaks.
155 141
         $result .= $unknown;
156 142
         $head = '';
@@ -175,7 +161,8 @@  discard block
 block discarded – undo
175 161
  * @return
176 162
  *   ASCII replacement character.
177 163
  */
178
-function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
164
+function _transliteration_replace($ord, $unknown = '?', $langcode = NULL)
165
+{
179 166
   static $map = array();
180 167
 
181 168
   //GL: set language later
@@ -195,12 +182,10 @@  discard block
 block discarded – undo
195 182
       if ($langcode != 'en' && isset($variant[$langcode])) {
196 183
         // Merge in language specific mappings.
197 184
         $map[$bank][$langcode] = $variant[$langcode] + $base;
198
-      }
199
-      else {
185
+      } else {
200 186
         $map[$bank][$langcode] = $base;
201 187
       }
202
-    }
203
-    else {
188
+    } else {
204 189
       $map[$bank][$langcode] = array();
205 190
     }
206 191
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return
26 26
  *   Transliterated text.
27 27
  */
28
-function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
28
+function _transliteration_process($string, $unknown = '?', $source_langcode = null) {
29 29
   // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30 30
   // avoid the overhead of initializing the decomposition tables by skipping
31 31
   // out early.
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  * @return
176 176
  *   ASCII replacement character.
177 177
  */
178
-function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
178
+function _transliteration_replace($ord, $unknown = '?', $langcode = null) {
179 179
   static $map = array();
180 180
 
181 181
   //GL: set language later
Please login to merge, or discard this patch.
serie.php 3 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -20,44 +20,44 @@
 block discarded – undo
20 20
         $this->name = $post->name;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . parent::PAGE_SERIE_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_SERIES_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_SERIES_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("series.alphabetical", count(array))
33
-        return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
33
+        return parent::getCountGeneric("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
34 34
     }
35 35
 
36
-    public static function getSerieByBookId ($bookId) {
37
-        $result = parent::getDb ()->prepare('select  series.id as id, name
36
+    public static function getSerieByBookId($bookId) {
37
+        $result = parent::getDb()->prepare('select  series.id as id, name
38 38
 from books_series_link, series
39 39
 where series.id = series and book = ?');
40
-        $result->execute (array ($bookId));
41
-        if ($post = $result->fetchObject ()) {
42
-            return new Serie ($post);
40
+        $result->execute(array($bookId));
41
+        if ($post = $result->fetchObject()) {
42
+            return new Serie($post);
43 43
         }
44 44
         return NULL;
45 45
     }
46 46
 
47
-    public static function getSerieById ($serieId) {
48
-        $result = parent::getDb ()->prepare('select id, name  from series where id = ?');
49
-        $result->execute (array ($serieId));
50
-        if ($post = $result->fetchObject ()) {
51
-            return new Serie ($post);
47
+    public static function getSerieById($serieId) {
48
+        $result = parent::getDb()->prepare('select id, name  from series where id = ?');
49
+        $result->execute(array($serieId));
50
+        if ($post = $result->fetchObject()) {
51
+            return new Serie($post);
52 52
         }
53 53
         return NULL;
54 54
     }
55 55
 
56 56
     public static function getAllSeries() {
57
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
57
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array(), "Serie");
58 58
     }
59 59
 
60 60
     public static function getAllSeriesByQuery($query) {
61
-        return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
61
+        return Base::getEntryArrayWithBookNumber(self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array('%' . $query . '%'), "Serie");
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,7 +6,8 @@  discard block
 block discarded – undo
6 6
  * @author     Sébastien Lucas <[email protected]>
7 7
  */
8 8
 
9
-class Serie extends Base {
9
+class Serie extends Base
10
+{
10 11
     const ALL_SERIES_ID = "cops:series";
11 12
     const SERIES_COLUMNS = "series.id as id, series.name as name, series.sort as sort, count(*) as count";
12 13
     const SQL_ALL_SERIES = "select {0} from series, books_series_link where series.id = series group by series.id, series.name, series.sort order by series.sort";
@@ -15,25 +16,30 @@  discard block
 block discarded – undo
15 16
     public $id;
16 17
     public $name;
17 18
 
18
-    public function __construct($post) {
19
+    public function __construct($post)
20
+    {
19 21
         $this->id = $post->id;
20 22
         $this->name = $post->name;
21 23
     }
22 24
 
23
-    public function getUri () {
25
+    public function getUri ()
26
+    {
24 27
         return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
25 28
     }
26 29
 
27
-    public function getEntryId () {
30
+    public function getEntryId ()
31
+    {
28 32
         return self::ALL_SERIES_ID.":".$this->id;
29 33
     }
30 34
 
31
-    public static function getCount() {
35
+    public static function getCount()
36
+    {
32 37
         // str_format (localize("series.alphabetical", count(array))
33 38
         return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
34 39
     }
35 40
 
36
-    public static function getSerieByBookId ($bookId) {
41
+    public static function getSerieByBookId ($bookId)
42
+    {
37 43
         $result = parent::getDb ()->prepare('select  series.id as id, name
38 44
 from books_series_link, series
39 45
 where series.id = series and book = ?');
@@ -44,7 +50,8 @@  discard block
 block discarded – undo
44 50
         return NULL;
45 51
     }
46 52
 
47
-    public static function getSerieById ($serieId) {
53
+    public static function getSerieById ($serieId)
54
+    {
48 55
         $result = parent::getDb ()->prepare('select id, name  from series where id = ?');
49 56
         $result->execute (array ($serieId));
50 57
         if ($post = $result->fetchObject ()) {
@@ -53,11 +60,13 @@  discard block
 block discarded – undo
53 60
         return NULL;
54 61
     }
55 62
 
56
-    public static function getAllSeries() {
63
+    public static function getAllSeries()
64
+    {
57 65
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
58 66
     }
59 67
 
60
-    public static function getAllSeriesByQuery($query) {
68
+    public static function getAllSeriesByQuery($query)
69
+    {
61 70
         return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
62 71
     }
63 72
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         if ($post = $result->fetchObject ()) {
42 42
             return new Serie ($post);
43 43
         }
44
-        return NULL;
44
+        return null;
45 45
     }
46 46
 
47 47
     public static function getSerieById ($serieId) {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if ($post = $result->fetchObject ()) {
51 51
             return new Serie ($post);
52 52
         }
53
-        return NULL;
53
+        return null;
54 54
     }
55 55
 
56 56
     public static function getAllSeries() {
Please login to merge, or discard this patch.
fetch.php 3 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
     if ($config ['cops_fetch_protect'] == "1") {
14 14
         session_start();
15 15
         if (!isset($_SESSION['connected'])) {
16
-            notFound ();
16
+            notFound();
17 17
             return;
18 18
         }
19 19
     }
20 20
 
21
-    $expires = 60*60*24*14;
21
+    $expires = 60 * 60 * 24 * 14;
22 22
     header("Pragma: public");
23
-    header("Cache-Control: maxage=".$expires);
24
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
25
-    $bookId = getURLParam ("id", NULL);
26
-    $type = getURLParam ("type", "jpg");
27
-    $idData = getURLParam ("data", NULL);
28
-    if (is_null ($bookId))
23
+    header("Cache-Control: maxage=" . $expires);
24
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
25
+    $bookId = getURLParam("id", NULL);
26
+    $type = getURLParam("type", "jpg");
27
+    $idData = getURLParam("data", NULL);
28
+    if (is_null($bookId))
29 29
     {
30 30
         $book = Book::getBookByDataId($idData);
31 31
     }
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     if (!$book) {
38
-        notFound ();
38
+        notFound();
39 39
         return;
40 40
     }
41 41
 
42 42
     if ($book && ($type == "jpg" || empty ($config['calibre_internal_directory']))) {
43 43
         if ($type == "jpg") {
44
-            $file = $book->getFilePath ($type);
44
+            $file = $book->getFilePath($type);
45 45
         } else {
46
-            $file = $book->getFilePath ($type, $idData);
46
+            $file = $book->getFilePath($type, $idData);
47 47
         }
48
-        if (!$file || !file_exists ($file)) {
49
-            notFound ();
48
+        if (!$file || !file_exists($file)) {
49
+            notFound();
50 50
             return;
51 51
         }
52 52
     }
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
             header("Content-Type: image/jpeg");
58 58
             //by default, we don't cache
59 59
             $thumbnailCacheFullpath = null;
60
-            if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
60
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
61 61
                 $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
62 62
                 //if multiple databases, add a subfolder with the database ID
63
-                $thumbnailCacheFullpath .= !is_null (GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : '';
63
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
64 64
                 //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
65 65
                 //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
66 66
                 $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
67 67
                 //check if cache folder exists or create it
68
-                if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) {
68
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
69 69
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
70
-                    $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam ("width") . 'x' . getURLParam ("height") . '.jpg';
70
+                    $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam("width") . 'x' . getURLParam("height") . '.jpg';
71 71
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
72 72
                 }
73 73
                 else {
@@ -76,45 +76,45 @@  discard block
 block discarded – undo
76 76
                 }
77 77
             }
78 78
 
79
-            if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) {
79
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
80 80
                 //return the already cached thumbnail
81
-                readfile( $thumbnailCacheFullpath );
81
+                readfile($thumbnailCacheFullpath);
82 82
                 return;
83 83
             }
84 84
 
85
-            if ($book->getThumbnail (getURLParam ("width"), getURLParam ("height"), $thumbnailCacheFullpath)) {
85
+            if ($book->getThumbnail(getURLParam("width"), getURLParam("height"), $thumbnailCacheFullpath)) {
86 86
                 //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
87
-                if ( $thumbnailCacheFullpath === null ) {
87
+                if ($thumbnailCacheFullpath === null) {
88 88
                     // The cover had to be resized
89 89
                     return;
90 90
                 }
91 91
                 else {
92 92
                     //return the just cached thumbnail
93
-                    readfile( $thumbnailCacheFullpath );
93
+                    readfile($thumbnailCacheFullpath);
94 94
                     return;
95 95
                 }
96 96
             }
97 97
             break;
98 98
         default:
99
-            $data = $book->getDataById ($idData);
100
-            header("Content-Type: " . $data->getMimeType ());
99
+            $data = $book->getDataById($idData);
100
+            header("Content-Type: " . $data->getMimeType());
101 101
             break;
102 102
     }
103
-    $file = $book->getFilePath ($type, $idData, true);
103
+    $file = $book->getFilePath($type, $idData, true);
104 104
     if ($type == "epub" && $config['cops_update_epub-metadata'])
105 105
     {
106
-        $book->getUpdatedEpub ($idData);
106
+        $book->getUpdatedEpub($idData);
107 107
         return;
108 108
     }
109 109
     if ($type == "jpg") {
110
-        header('Content-Disposition: filename="' . basename ($file) . '"');
110
+        header('Content-Disposition: filename="' . basename($file) . '"');
111 111
     } else {
112
-        header('Content-Disposition: attachment; filename="' . basename ($file) . '"');
112
+        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
113 113
     }
114 114
 
115 115
     $dir = $config['calibre_internal_directory'];
116 116
     if (empty ($config['calibre_internal_directory'])) {
117
-        $dir = Base::getDbDirectory ();
117
+        $dir = Base::getDbDirectory();
118 118
     }
119 119
 
120 120
     if (empty ($config['cops_x_accel_redirect'])) {
@@ -124,5 +124,5 @@  discard block
 block discarded – undo
124 124
         fpassthru($fp);
125 125
     }
126 126
     else {
127
-        header ($config['cops_x_accel_redirect'] . ": " . $dir . $file);
127
+        header($config['cops_x_accel_redirect'] . ": " . $dir . $file);
128 128
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,12 +25,9 @@  discard block
 block discarded – undo
25 25
     $bookId = getURLParam ("id", NULL);
26 26
     $type = getURLParam ("type", "jpg");
27 27
     $idData = getURLParam ("data", NULL);
28
-    if (is_null ($bookId))
29
-    {
28
+    if (is_null ($bookId)) {
30 29
         $book = Book::getBookByDataId($idData);
31
-    }
32
-    else
33
-    {
30
+    } else {
34 31
         $book = Book::getBookById($bookId);
35 32
     }
36 33
 
@@ -51,8 +48,7 @@  discard block
 block discarded – undo
51 48
         }
52 49
     }
53 50
 
54
-    switch ($type)
55
-    {
51
+    switch ($type) {
56 52
         case "jpg":
57 53
             header("Content-Type: image/jpeg");
58 54
             //by default, we don't cache
@@ -69,8 +65,7 @@  discard block
 block discarded – undo
69 65
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
70 66
                     $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam ("width") . 'x' . getURLParam ("height") . '.jpg';
71 67
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
72
-                }
73
-                else {
68
+                } else {
74 69
                     //error creating the folder, so we don't cache
75 70
                     $thumbnailCacheFullpath = null;
76 71
                 }
@@ -87,8 +82,7 @@  discard block
 block discarded – undo
87 82
                 if ( $thumbnailCacheFullpath === null ) {
88 83
                     // The cover had to be resized
89 84
                     return;
90
-                }
91
-                else {
85
+                } else {
92 86
                     //return the just cached thumbnail
93 87
                     readfile( $thumbnailCacheFullpath );
94 88
                     return;
@@ -101,8 +95,7 @@  discard block
 block discarded – undo
101 95
             break;
102 96
     }
103 97
     $file = $book->getFilePath ($type, $idData, true);
104
-    if ($type == "epub" && $config['cops_update_epub-metadata'])
105
-    {
98
+    if ($type == "epub" && $config['cops_update_epub-metadata']) {
106 99
         $book->getUpdatedEpub ($idData);
107 100
         return;
108 101
     }
@@ -122,7 +115,6 @@  discard block
 block discarded – undo
122 115
         $fp = fopen($filename, 'rb');
123 116
         header("Content-Length: " . filesize($filename));
124 117
         fpassthru($fp);
125
-    }
126
-    else {
118
+    } else {
127 119
         header ($config['cops_x_accel_redirect'] . ": " . $dir . $file);
128 120
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
     header("Pragma: public");
23 23
     header("Cache-Control: maxage=".$expires);
24 24
     header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
25
-    $bookId = getURLParam ("id", NULL);
25
+    $bookId = getURLParam ("id", null);
26 26
     $type = getURLParam ("type", "jpg");
27
-    $idData = getURLParam ("data", NULL);
27
+    $idData = getURLParam ("data", null);
28 28
     if (is_null ($bookId))
29 29
     {
30 30
         $book = Book::getBookByDataId($idData);
Please login to merge, or discard this patch.