Completed
Pull Request — master (#424)
by
unknown
54:45 queued 45:01
created
base.php 5 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -64,6 +64,9 @@  discard block
 block discarded – undo
64 64
     $_SERVER['REDIRECT_STATUS'] = 404;
65 65
 }
66 66
 
67
+/**
68
+ * @param string $name
69
+ */
67 70
 function getURLParam($name, $default = NULL)
68 71
 {
69 72
     if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') {
@@ -104,6 +107,11 @@  discard block
 block discarded – undo
104 107
     return $url . '?v=' . VERSION;
105 108
 }
106 109
 
110
+/**
111
+ * @param string $xml
112
+ *
113
+ * @return string
114
+ */
107 115
 function xml2xhtml($xml)
108 116
 {
109 117
     return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', function($m) {
@@ -326,6 +334,9 @@  discard block
 block discarded – undo
326 334
     return $phrase;
327 335
 }
328 336
 
337
+/**
338
+ * @param string $paramName
339
+ */
329 340
 function addURLParameter($urlParams, $paramName, $paramValue)
330 341
 {
331 342
     if (empty ($urlParams)) {
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
     // Generate the function for the template
33 33
     $template = new doT ();
34 34
     $dot = $template->template ($page, array ('bookdetail' => $bookdetail,
35
-                                              'header' => $header,
36
-                                              'footer' => $footer,
37
-                                              'main' => $main));
35
+                                                'header' => $header,
36
+                                                'footer' => $footer,
37
+                                                'main' => $main));
38 38
     // If there is a syntax error in the function created
39 39
     // $dot will be equal to FALSE
40 40
     if (!$dot) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         case LIBXML_ERR_WARNING:
126 126
             $return .= 'Warning ' . $error->code . ': ';
127 127
             break;
128
-         case LIBXML_ERR_ERROR:
128
+            case LIBXML_ERR_ERROR:
129 129
             $return .= 'Error ' . $error->code . ': ';
130 130
             break;
131 131
         case LIBXML_ERR_FATAL:
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
     }
135 135
 
136 136
     $return .= trim($error->message) .
137
-               "\n  Line: " . $error->line .
138
-               "\n  Column: " . $error->column;
137
+                "\n  Line: " . $error->line .
138
+                "\n  Column: " . $error->column;
139 139
 
140 140
     if ($error->file) {
141 141
         $return .= "\n  File: " . $error->file;
Please login to merge, or discard this patch.
Braces   +19 added lines, -11 removed lines patch added patch discarded remove patch
@@ -149,7 +149,9 @@  discard block
 block discarded – undo
149 149
     $errors = libxml_get_errors();
150 150
 
151 151
     foreach ($errors as $error) {
152
-        if ($error->code == 801) return false;
152
+        if ($error->code == 801) {
153
+            return false;
154
+        }
153 155
     }
154 156
     return true;
155 157
 }
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
     }
176 178
     */
177 179
 
178
-    if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.';
180
+    if (!are_libxml_errors_ok ()) {
181
+        $output = 'HTML code not valid.';
182
+    }
179 183
 
180 184
     libxml_use_internal_errors(false);
181 185
     return $output;
@@ -235,7 +239,9 @@  discard block
 block discarded – undo
235 239
 
236 240
             // set default to 1 for any without q factor
237 241
             foreach ($langs as $lang => $val) {
238
-                if ($val === '') $langs[$lang] = 1;
242
+                if ($val === '') {
243
+                    $langs[$lang] = 1;
244
+                }
239 245
             }
240 246
 
241 247
             // sort list based on value
@@ -257,8 +263,7 @@  discard block
 block discarded – undo
257 263
     $lang = 'en';
258 264
     if (!empty($config['cops_language'])) {
259 265
         $lang = $config['cops_language'];
260
-    }
261
-    elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
266
+    } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
262 267
         $langs = getAcceptLanguages();
263 268
     }
264 269
     //echo var_dump($langs);
@@ -284,12 +289,15 @@  discard block
 block discarded – undo
284 289
 function localize($phrase, $count=-1, $reset=false)
285 290
 {
286 291
     global $config;
287
-    if ($count == 0)
288
-        $phrase .= '.none';
289
-    if ($count == 1)
290
-        $phrase .= '.one';
291
-    if ($count > 1)
292
-        $phrase .= '.many';
292
+    if ($count == 0) {
293
+            $phrase .= '.none';
294
+    }
295
+    if ($count == 1) {
296
+            $phrase .= '.one';
297
+    }
298
+    if ($count > 1) {
299
+            $phrase .= '.many';
300
+    }
293 301
 
294 302
     /* Static keyword is used to ensure the file is loaded only once */
295 303
     static $translations = NULL;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
     // If there is a syntax error in the function created
39 39
     // $dot will be equal to FALSE
40 40
     if (!$dot) {
41
-        return FALSE;
41
+        return false;
42 42
     }
43 43
     // Execute the template
44 44
     if (!empty ($data)) {
45 45
         return $dot ($data);
46 46
     }
47 47
 
48
-    return NULL;
48
+    return null;
49 49
 }
50 50
 
51 51
 function getQueryString()
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     $_SERVER['REDIRECT_STATUS'] = 404;
65 65
 }
66 66
 
67
-function getURLParam($name, $default = NULL)
67
+function getURLParam($name, $default = null)
68 68
 {
69 69
     if (!empty ($_GET) && isset($_GET[$name]) && $_GET[$name] != '') {
70 70
         return $_GET[$name];
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         $langs = getAcceptLanguages();
263 263
     }
264 264
     //echo var_dump($langs);
265
-    $lang_file = NULL;
265
+    $lang_file = null;
266 266
     foreach ($langs as $language => $val) {
267 267
         $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json';
268 268
         if (file_exists($temp_file)) {
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
         $phrase .= '.many';
293 293
 
294 294
     /* Static keyword is used to ensure the file is loaded only once */
295
-    static $translations = NULL;
295
+    static $translations = null;
296 296
     if ($reset) {
297
-        $translations = NULL;
297
+        $translations = null;
298 298
     }
299 299
     /* If no instance of $translations has occured load the language file */
300 300
     if (is_null($translations)) {
301
-        $lang_file_en = NULL;
301
+        $lang_file_en = null;
302 302
         list ($lang, $lang_file) = getLangAndTranslationFile();
303 303
         if ($lang != 'en') {
304 304
             $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json';
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 
9 9
 require 'config.php';
10 10
 
11
-define ('VERSION', '1.1.3');
12
-define ('DB', 'db');
11
+define('VERSION', '1.1.3');
12
+define('DB', 'db');
13 13
 date_default_timezone_set($config['default_timezone']);
14 14
 
15 15
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 function serverSideRender($data)
23 23
 {
24 24
     // Get the templates
25
-    $theme = getCurrentTemplate ();
25
+    $theme = getCurrentTemplate();
26 26
     $header = file_get_contents('templates/' . $theme . '/header.html');
27 27
     $footer = file_get_contents('templates/' . $theme . '/footer.html');
28 28
     $main = file_get_contents('templates/' . $theme . '/main.html');
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
     $page = file_get_contents('templates/' . $theme . '/page.html');
31 31
 
32 32
     // Generate the function for the template
33
-    $template = new doT ();
34
-    $dot = $template->template ($page, array ('bookdetail' => $bookdetail,
33
+    $template = new doT();
34
+    $dot = $template->template($page, array('bookdetail' => $bookdetail,
35 35
                                               'header' => $header,
36 36
                                               'footer' => $footer,
37 37
                                               'main' => $main));
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     }
43 43
     // Execute the template
44 44
     if (!empty ($data)) {
45
-        return $dot ($data);
45
+        return $dot($data);
46 46
     }
47 47
 
48 48
     return NULL;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 function notFound()
60 60
 {
61
-    header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
61
+    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
62 62
     header('Status: 404 Not Found');
63 63
 
64 64
     $_SERVER['REDIRECT_STATUS'] = 404;
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 {
77 77
     global $config;
78 78
     if (isset($_COOKIE[$option])) {
79
-        if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) {
80
-            return explode (',', $_COOKIE[$option]);
79
+        if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) {
80
+            return explode(',', $_COOKIE[$option]);
81 81
         } else {
82 82
             return $_COOKIE[$option];
83 83
         }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 function getCurrentCss()
93 93
 {
94
-    return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css';
94
+    return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css';
95 95
 }
96 96
 
97 97
 function getCurrentTemplate()
98 98
 {
99
-    return getCurrentOption ('template');
99
+    return getCurrentOption('template');
100 100
 }
101 101
 
102 102
 function getUrlWithVersion($url)
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
     libxml_use_internal_errors(true);
161 161
 
162 162
     $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' .
163
-                        $html  . '</body></html>'); // Load the HTML
163
+                        $html . '</body></html>'); // Load the HTML
164 164
     $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream
165 165
     $output = xml2xhtml($output);
166
-    if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) {
166
+    if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) {
167 167
         $output = $matches [1]; // Remove <html><body>
168 168
     }
169 169
     /*
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     }
176 176
     */
177 177
 
178
-    if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.';
178
+    if (!are_libxml_errors_ok()) $output = 'HTML code not valid.';
179 179
 
180 180
     libxml_use_internal_errors(false);
181 181
     return $output;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     //echo var_dump($langs);
265 265
     $lang_file = NULL;
266 266
     foreach ($langs as $language => $val) {
267
-        $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json';
267
+        $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json';
268 268
         if (file_exists($temp_file)) {
269 269
             $lang = $language;
270 270
             $lang_file = $temp_file;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
     }
274 274
     if (empty ($lang_file)) {
275
-        $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json';
275
+        $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json';
276 276
     }
277 277
     return array($lang, $lang_file);
278 278
 }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
  * This method is based on this page
282 282
  * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
283 283
  */
284
-function localize($phrase, $count=-1, $reset=false)
284
+function localize($phrase, $count = -1, $reset = false)
285 285
 {
286 286
     global $config;
287 287
     if ($count == 0)
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $lang_file_en = NULL;
302 302
         list ($lang, $lang_file) = getLangAndTranslationFile();
303 303
         if ($lang != 'en') {
304
-            $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json';
304
+            $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json';
305 305
         }
306 306
 
307 307
         $lang_file_content = file_get_contents($lang_file);
@@ -309,18 +309,18 @@  discard block
 block discarded – undo
309 309
         $translations = json_decode($lang_file_content, true);
310 310
 
311 311
         /* Clean the array of all unfinished translations */
312
-        foreach (array_keys ($translations) as $key) {
313
-            if (preg_match ('/^##TODO##/', $key)) {
312
+        foreach (array_keys($translations) as $key) {
313
+            if (preg_match('/^##TODO##/', $key)) {
314 314
                 unset ($translations [$key]);
315 315
             }
316 316
         }
317 317
         if (!is_null($lang_file_en)) {
318 318
             $lang_file_content = file_get_contents($lang_file_en);
319 319
             $translations_en = json_decode($lang_file_content, true);
320
-            $translations = array_merge ($translations_en, $translations);
320
+            $translations = array_merge($translations_en, $translations);
321 321
         }
322 322
     }
323
-    if (array_key_exists ($phrase, $translations)) {
323
+    if (array_key_exists($phrase, $translations)) {
324 324
         return $translations[$phrase];
325 325
     }
326 326
     return $phrase;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         $urlParams = '';
333 333
     }
334 334
     $start = '';
335
-    if (preg_match ('#^\?(.*)#', $urlParams, $matches)) {
335
+    if (preg_match('#^\?(.*)#', $urlParams, $matches)) {
336 336
         $start = '?';
337 337
         $urlParams = $matches[1];
338 338
     }
Please login to merge, or discard this patch.
lib/Author.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -62,6 +62,9 @@  discard block
 block discarded – undo
62 62
         return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
63 63
     }
64 64
 
65
+    /**
66
+     * @param string $query
67
+     */
65 68
     public static function getAuthorsForSearch($query) {
66 69
         return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
67 70
     }
@@ -70,6 +73,9 @@  discard block
 block discarded – undo
70 73
         return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
71 74
     }
72 75
 
76
+    /**
77
+     * @param string $query
78
+     */
73 79
     public static function getEntryArray ($query, $params) {
74 80
         return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
75 81
     }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -25,69 +25,69 @@
 block discarded – undo
25 25
         $this->sort = $post->sort;
26 26
     }
27 27
 
28
-    public function getUri () {
29
-        return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id";
28
+    public function getUri() {
29
+        return "?page=" . parent::PAGE_AUTHOR_DETAIL . "&id=$this->id";
30 30
     }
31 31
 
32
-    public function getEntryId () {
33
-        return self::ALL_AUTHORS_ID.":".$this->id;
32
+    public function getEntryId() {
33
+        return self::ALL_AUTHORS_ID . ":" . $this->id;
34 34
     }
35 35
 
36
-    public static function getEntryIdByLetter ($startingLetter) {
37
-        return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
36
+    public static function getEntryIdByLetter($startingLetter) {
37
+        return self::ALL_AUTHORS_ID . ":letter:" . $startingLetter;
38 38
     }
39 39
 
40 40
     public static function getCount() {
41 41
         // str_format (localize("authors.alphabetical", count(array))
42
-        return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
42
+        return parent::getCountGeneric("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
43 43
     }
44 44
 
45 45
     public static function getAllAuthorsByFirstLetter() {
46
-        list (, $result) = parent::executeQuery ("select {0}
46
+        list (, $result) = parent::executeQuery("select {0}
47 47
 from authors
48 48
 group by substr (upper (sort), 1, 1)
49
-order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
49
+order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1);
50 50
         $entryArray = array();
51
-        while ($post = $result->fetchObject ())
51
+        while ($post = $result->fetchObject())
52 52
         {
53
-            array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
54
-                str_format (localize("authorword", $post->count), $post->count), "text",
55
-                array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
53
+            array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title),
54
+                str_format(localize("authorword", $post->count), $post->count), "text",
55
+                array(new LinkNavigation("?page=" . parent::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count));
56 56
         }
57 57
         return $entryArray;
58 58
     }
59 59
 
60 60
     public static function getAuthorsByStartingLetter($letter) {
61
-        return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
61
+        return self::getEntryArray(self::SQL_AUTHORS_BY_FIRST_LETTER, array($letter . "%"));
62 62
     }
63 63
 
64 64
     public static function getAuthorsForSearch($query) {
65
-        return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
65
+        return self::getEntryArray(self::SQL_AUTHORS_FOR_SEARCH, array($query . "%", $query . "%"));
66 66
     }
67 67
 
68 68
     public static function getAllAuthors() {
69
-        return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
69
+        return self::getEntryArray(self::SQL_ALL_AUTHORS, array());
70 70
     }
71 71
 
72
-    public static function getEntryArray ($query, $params) {
73
-        return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
72
+    public static function getEntryArray($query, $params) {
73
+        return Base::getEntryArrayWithBookNumber($query, self::AUTHOR_COLUMNS, $params, "Author");
74 74
     }
75 75
 
76
-    public static function getAuthorById ($authorId) {
77
-        $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78
-        $result->execute (array ($authorId));
79
-        $post = $result->fetchObject ();
80
-        return new Author ($post);
76
+    public static function getAuthorById($authorId) {
77
+        $result = parent::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78
+        $result->execute(array($authorId));
79
+        $post = $result->fetchObject();
80
+        return new Author($post);
81 81
     }
82 82
 
83
-    public static function getAuthorByBookId ($bookId) {
84
-        $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
83
+    public static function getAuthorByBookId($bookId) {
84
+        $result = parent::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
85 85
 where author = authors.id
86 86
 and book = ?');
87
-        $result->execute (array ($bookId));
88
-        $authorArray = array ();
89
-        while ($post = $result->fetchObject ()) {
90
-            array_push ($authorArray, new Author ($post));
87
+        $result->execute(array($bookId));
88
+        $authorArray = array();
89
+        while ($post = $result->fetchObject()) {
90
+            array_push($authorArray, new Author($post));
91 91
         }
92 92
         return $authorArray;
93 93
     }
Please login to merge, or discard this patch.
Braces   +25 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,37 +19,42 @@  discard block
 block discarded – undo
19 19
     public $name;
20 20
     public $sort;
21 21
 
22
-    public function __construct($post) {
22
+    public function __construct($post)
23
+    {
23 24
         $this->id = $post->id;
24 25
         $this->name = str_replace("|", ",", $post->name);
25 26
         $this->sort = $post->sort;
26 27
     }
27 28
 
28
-    public function getUri () {
29
+    public function getUri ()
30
+    {
29 31
         return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id";
30 32
     }
31 33
 
32
-    public function getEntryId () {
34
+    public function getEntryId ()
35
+    {
33 36
         return self::ALL_AUTHORS_ID.":".$this->id;
34 37
     }
35 38
 
36
-    public static function getEntryIdByLetter ($startingLetter) {
39
+    public static function getEntryIdByLetter ($startingLetter)
40
+    {
37 41
         return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
38 42
     }
39 43
 
40
-    public static function getCount() {
44
+    public static function getCount()
45
+    {
41 46
         // str_format (localize("authors.alphabetical", count(array))
42 47
         return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
43 48
     }
44 49
 
45
-    public static function getAllAuthorsByFirstLetter() {
50
+    public static function getAllAuthorsByFirstLetter()
51
+    {
46 52
         list (, $result) = parent::executeQuery ("select {0}
47 53
 from authors
48 54
 group by substr (upper (sort), 1, 1)
49 55
 order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
50 56
         $entryArray = array();
51
-        while ($post = $result->fetchObject ())
52
-        {
57
+        while ($post = $result->fetchObject ()) {
53 58
             array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
54 59
                 str_format (localize("authorword", $post->count), $post->count), "text",
55 60
                 array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
@@ -57,30 +62,36 @@  discard block
 block discarded – undo
57 62
         return $entryArray;
58 63
     }
59 64
 
60
-    public static function getAuthorsByStartingLetter($letter) {
65
+    public static function getAuthorsByStartingLetter($letter)
66
+    {
61 67
         return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
62 68
     }
63 69
 
64
-    public static function getAuthorsForSearch($query) {
70
+    public static function getAuthorsForSearch($query)
71
+    {
65 72
         return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
66 73
     }
67 74
 
68
-    public static function getAllAuthors() {
75
+    public static function getAllAuthors()
76
+    {
69 77
         return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
70 78
     }
71 79
 
72
-    public static function getEntryArray ($query, $params) {
80
+    public static function getEntryArray ($query, $params)
81
+    {
73 82
         return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
74 83
     }
75 84
 
76
-    public static function getAuthorById ($authorId) {
85
+    public static function getAuthorById ($authorId)
86
+    {
77 87
         $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78 88
         $result->execute (array ($authorId));
79 89
         $post = $result->fetchObject ();
80 90
         return new Author ($post);
81 91
     }
82 92
 
83
-    public static function getAuthorByBookId ($bookId) {
93
+    public static function getAuthorByBookId ($bookId)
94
+    {
84 95
         $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
85 96
 where author = authors.id
86 97
 and book = ?');
Please login to merge, or discard this patch.
lib/Base.php 5 patches
Doc Comments   +18 added lines patch added patch discarded remove patch
@@ -84,6 +84,9 @@  discard block
 block discarded – undo
84 84
         return "";
85 85
     }
86 86
 
87
+    /**
88
+     * @return string
89
+     */
87 90
     public static function getDbDirectory ($database = NULL) {
88 91
         global $config;
89 92
         if (self::isMultipleDatabaseEnabled ()) {
@@ -143,10 +146,18 @@  discard block
 block discarded – undo
143 146
         self::$db = NULL;
144 147
     }
145 148
 
149
+    /**
150
+     * @param string $query
151
+     */
146 152
     public static function executeQuerySingle ($query, $database = NULL) {
147 153
         return self::getDb ($database)->query($query)->fetchColumn();
148 154
     }
149 155
 
156
+    /**
157
+     * @param string $table
158
+     * @param string $id
159
+     * @param string $numberOfString
160
+     */
150 161
     public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
151 162
         if (!$numberOfString) {
152 163
             $numberOfString = $table . ".alphabetical";
@@ -159,6 +170,10 @@  discard block
 block discarded – undo
159 170
         return $entry;
160 171
     }
161 172
 
173
+    /**
174
+     * @param string $columns
175
+     * @param string $category
176
+     */
162 177
     public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
163 178
         /* @var $result PDOStatement */
164 179
 
@@ -181,6 +196,9 @@  discard block
 block discarded – undo
181 196
         return $entryArray;
182 197
     }
183 198
 
199
+    /**
200
+     * @param string $filter
201
+     */
184 202
     public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
185 203
         $totalResult = -1;
186 204
 
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,13 +99,13 @@
 block discarded – undo
99 99
 
100 100
     // -DC- Add image directory
101 101
     public static function getImgDirectory ($database = NULL) {
102
-    	global $config;
103
-    	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
-    		$array = array_values ($config['image_directory']);
106
-    		return  $array[$database];
107
-    	}
108
-    	return $config['image_directory'];
102
+        global $config;
103
+        if (self::isMultipleDatabaseEnabled ()) {
104
+            if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
+            $array = array_values ($config['image_directory']);
106
+            return  $array[$database];
107
+        }
108
+        return $config['image_directory'];
109 109
     }
110 110
 
111 111
     public static function getDbFileName ($database = NULL) {
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -37,156 +37,156 @@  discard block
 block discarded – undo
37 37
 
38 38
     private static $db = NULL;
39 39
 
40
-    public static function isMultipleDatabaseEnabled () {
40
+    public static function isMultipleDatabaseEnabled() {
41 41
         global $config;
42
-        return is_array ($config['calibre_directory']);
42
+        return is_array($config['calibre_directory']);
43 43
     }
44 44
 
45
-    public static function useAbsolutePath () {
45
+    public static function useAbsolutePath() {
46 46
         global $config;
47 47
         $path = self::getDbDirectory();
48
-        return preg_match ('/^\//', $path) || // Linux /
49
-               preg_match ('/^\w\:/', $path); // Windows X:
48
+        return preg_match('/^\//', $path) || // Linux /
49
+               preg_match('/^\w\:/', $path); // Windows X:
50 50
     }
51 51
 
52
-    public static function noDatabaseSelected () {
53
-        return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
52
+    public static function noDatabaseSelected() {
53
+        return self::isMultipleDatabaseEnabled() && is_null(GetUrlParam(DB));
54 54
     }
55 55
 
56
-    public static function getDbList () {
56
+    public static function getDbList() {
57 57
         global $config;
58
-        if (self::isMultipleDatabaseEnabled ()) {
58
+        if (self::isMultipleDatabaseEnabled()) {
59 59
             return $config['calibre_directory'];
60 60
         } else {
61
-            return array ("" => $config['calibre_directory']);
61
+            return array("" => $config['calibre_directory']);
62 62
         }
63 63
     }
64 64
 
65
-    public static function getDbNameList () {
65
+    public static function getDbNameList() {
66 66
         global $config;
67
-        if (self::isMultipleDatabaseEnabled ()) {
68
-            return array_keys ($config['calibre_directory']);
67
+        if (self::isMultipleDatabaseEnabled()) {
68
+            return array_keys($config['calibre_directory']);
69 69
         } else {
70
-            return array ("");
70
+            return array("");
71 71
         }
72 72
     }
73 73
 
74
-    public static function getDbName ($database = NULL) {
74
+    public static function getDbName($database = NULL) {
75 75
         global $config;
76
-        if (self::isMultipleDatabaseEnabled ()) {
77
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
76
+        if (self::isMultipleDatabaseEnabled()) {
77
+            if (is_null($database)) $database = GetUrlParam(DB, 0);
78 78
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
79
-                self::error ($database);
79
+                self::error($database);
80 80
             }
81
-            $array = array_keys ($config['calibre_directory']);
81
+            $array = array_keys($config['calibre_directory']);
82 82
             return  $array[$database];
83 83
         }
84 84
         return "";
85 85
     }
86 86
 
87
-    public static function getDbDirectory ($database = NULL) {
87
+    public static function getDbDirectory($database = NULL) {
88 88
         global $config;
89
-        if (self::isMultipleDatabaseEnabled ()) {
90
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
89
+        if (self::isMultipleDatabaseEnabled()) {
90
+            if (is_null($database)) $database = GetUrlParam(DB, 0);
91 91
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
92
-                self::error ($database);
92
+                self::error($database);
93 93
             }
94
-            $array = array_values ($config['calibre_directory']);
94
+            $array = array_values($config['calibre_directory']);
95 95
             return  $array[$database];
96 96
         }
97 97
         return $config['calibre_directory'];
98 98
     }
99 99
 
100 100
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
101
+    public static function getImgDirectory($database = NULL) {
102 102
     	global $config;
103
-    	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
105
-    		$array = array_values ($config['image_directory']);
103
+    	if (self::isMultipleDatabaseEnabled()) {
104
+    		if (is_null($database)) $database = GetUrlParam(DB, 0);
105
+    		$array = array_values($config['image_directory']);
106 106
     		return  $array[$database];
107 107
     	}
108 108
     	return $config['image_directory'];
109 109
     }
110 110
 
111
-    public static function getDbFileName ($database = NULL) {
112
-        return self::getDbDirectory ($database) .'metadata.db';
111
+    public static function getDbFileName($database = NULL) {
112
+        return self::getDbDirectory($database) . 'metadata.db';
113 113
     }
114 114
 
115
-    private static function error ($database) {
115
+    private static function error($database) {
116 116
         if (php_sapi_name() != "cli") {
117 117
             header("location: checkconfig.php?err=1");
118 118
         }
119 119
         throw new Exception("Database <{$database}> not found.");
120 120
     }
121 121
 
122
-    public static function getDb ($database = NULL) {
123
-        if (is_null (self::$db)) {
122
+    public static function getDb($database = NULL) {
123
+        if (is_null(self::$db)) {
124 124
             try {
125
-                if (is_readable (self::getDbFileName ($database))) {
126
-                    self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
127
-                    if (useNormAndUp ()) {
128
-                        self::$db->sqliteCreateFunction ('normAndUp', 'normAndUp', 1);
125
+                if (is_readable(self::getDbFileName($database))) {
126
+                    self::$db = new PDO('sqlite:' . self::getDbFileName($database));
127
+                    if (useNormAndUp()) {
128
+                        self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1);
129 129
                     }
130 130
                 } else {
131
-                    self::error ($database);
131
+                    self::error($database);
132 132
                 }
133 133
             } catch (Exception $e) {
134
-                self::error ($database);
134
+                self::error($database);
135 135
             }
136 136
         }
137 137
         return self::$db;
138 138
     }
139 139
 
140
-    public static function checkDatabaseAvailability () {
141
-        if (self::noDatabaseSelected ()) {
142
-            for ($i = 0; $i < count (self::getDbList ()); $i++) {
143
-                self::getDb ($i);
144
-                self::clearDb ();
140
+    public static function checkDatabaseAvailability() {
141
+        if (self::noDatabaseSelected()) {
142
+            for ($i = 0; $i < count(self::getDbList()); $i++) {
143
+                self::getDb($i);
144
+                self::clearDb();
145 145
             }
146 146
         } else {
147
-            self::getDb ();
147
+            self::getDb();
148 148
         }
149 149
         return true;
150 150
     }
151 151
 
152
-    public static function clearDb () {
152
+    public static function clearDb() {
153 153
         self::$db = NULL;
154 154
     }
155 155
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
157
-        return self::getDb ($database)->query($query)->fetchColumn();
156
+    public static function executeQuerySingle($query, $database = NULL) {
157
+        return self::getDb($database)->query($query)->fetchColumn();
158 158
     }
159 159
 
160 160
     public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
161 161
         if (!$numberOfString) {
162 162
             $numberOfString = $table . ".alphabetical";
163 163
         }
164
-        $count = self::executeQuerySingle ('select count(*) from ' . $table);
164
+        $count = self::executeQuerySingle('select count(*) from ' . $table);
165 165
         if ($count == 0) return NULL;
166
-        $entry = new Entry (localize($table . ".title"), $id,
167
-            str_format (localize($numberOfString, $count), $count), "text",
168
-            array ( new LinkNavigation ("?page=".$pageId)), "", $count);
166
+        $entry = new Entry(localize($table . ".title"), $id,
167
+            str_format(localize($numberOfString, $count), $count), "text",
168
+            array(new LinkNavigation("?page=" . $pageId)), "", $count);
169 169
         return $entry;
170 170
     }
171 171
 
172
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
172
+    public static function getEntryArrayWithBookNumber($query, $columns, $params, $category) {
173 173
         /* @var $result PDOStatement */
174 174
 
175
-        list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
175
+        list (, $result) = self::executeQuery($query, $columns, "", $params, -1);
176 176
         $entryArray = array();
177
-        while ($post = $result->fetchObject ())
177
+        while ($post = $result->fetchObject())
178 178
         {
179 179
             /* @var $instance Author|Tag|Serie|Publisher */
180 180
 
181
-            $instance = new $category ($post);
181
+            $instance = new $category($post);
182 182
             if (property_exists($post, "sort")) {
183 183
                 $title = $post->sort;
184 184
             } else {
185 185
                 $title = $post->name;
186 186
             }
187
-            array_push ($entryArray, new Entry ($title, $instance->getEntryId (),
188
-                str_format (localize("bookword", $post->count), $post->count), "text",
189
-                array ( new LinkNavigation ($instance->getUri ())), "", $post->count));
187
+            array_push($entryArray, new Entry($title, $instance->getEntryId(),
188
+                str_format(localize("bookword", $post->count), $post->count), "text",
189
+                array(new LinkNavigation($instance->getUri())), "", $post->count));
190 190
         }
191 191
         return $entryArray;
192 192
     }
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
     public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
195 195
         $totalResult = -1;
196 196
 
197
-        if (useNormAndUp ()) {
197
+        if (useNormAndUp()) {
198 198
             $query = preg_replace("/upper/", "normAndUp", $query);
199 199
             $columns = preg_replace("/upper/", "normAndUp", $columns);
200 200
         }
201 201
 
202
-        if (is_null ($numberPerPage)) {
203
-            $numberPerPage = getCurrentOption ("max_item_per_page");
202
+        if (is_null($numberPerPage)) {
203
+            $numberPerPage = getCurrentOption("max_item_per_page");
204 204
         }
205 205
 
206 206
         if ($numberPerPage != -1 && $n != -1)
207 207
         {
208 208
             // First check total number of results
209
-            $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
210
-            $result->execute ($params);
211
-            $totalResult = $result->fetchColumn ();
209
+            $result = self::getDb($database)->prepare(str_format($query, "count(*)", $filter));
210
+            $result->execute($params);
211
+            $totalResult = $result->fetchColumn();
212 212
 
213 213
             // Next modify the query and params
214 214
             $query .= " limit ?, ?";
215
-            array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage);
215
+            array_push($params, ($n - 1) * $numberPerPage, $numberPerPage);
216 216
         }
217 217
 
218
-        $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter));
219
-        $result->execute ($params);
220
-        return array ($totalResult, $result);
218
+        $result = self::getDb($database)->prepare(str_format($query, $columns, $filter));
219
+        $result->execute($params);
220
+        return array($totalResult, $result);
221 221
     }
222 222
 
223 223
 }
Please login to merge, or discard this patch.
Braces   +48 added lines, -25 removed lines patch added patch discarded remove patch
@@ -37,23 +37,27 @@  discard block
 block discarded – undo
37 37
 
38 38
     private static $db = NULL;
39 39
 
40
-    public static function isMultipleDatabaseEnabled () {
40
+    public static function isMultipleDatabaseEnabled ()
41
+    {
41 42
         global $config;
42 43
         return is_array ($config['calibre_directory']);
43 44
     }
44 45
 
45
-    public static function useAbsolutePath () {
46
+    public static function useAbsolutePath ()
47
+    {
46 48
         global $config;
47 49
         $path = self::getDbDirectory();
48 50
         return preg_match ('/^\//', $path) || // Linux /
49 51
                preg_match ('/^\w\:/', $path); // Windows X:
50 52
     }
51 53
 
52
-    public static function noDatabaseSelected () {
54
+    public static function noDatabaseSelected ()
55
+    {
53 56
         return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
54 57
     }
55 58
 
56
-    public static function getDbList () {
59
+    public static function getDbList ()
60
+    {
57 61
         global $config;
58 62
         if (self::isMultipleDatabaseEnabled ()) {
59 63
             return $config['calibre_directory'];
@@ -62,7 +66,8 @@  discard block
 block discarded – undo
62 66
         }
63 67
     }
64 68
 
65
-    public static function getDbNameList () {
69
+    public static function getDbNameList ()
70
+    {
66 71
         global $config;
67 72
         if (self::isMultipleDatabaseEnabled ()) {
68 73
             return array_keys ($config['calibre_directory']);
@@ -71,10 +76,13 @@  discard block
 block discarded – undo
71 76
         }
72 77
     }
73 78
 
74
-    public static function getDbName ($database = NULL) {
79
+    public static function getDbName ($database = NULL)
80
+    {
75 81
         global $config;
76 82
         if (self::isMultipleDatabaseEnabled ()) {
77
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
83
+            if (is_null ($database)) {
84
+                $database = GetUrlParam (DB, 0);
85
+            }
78 86
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
79 87
                 self::error ($database);
80 88
             }
@@ -84,10 +92,13 @@  discard block
 block discarded – undo
84 92
         return "";
85 93
     }
86 94
 
87
-    public static function getDbDirectory ($database = NULL) {
95
+    public static function getDbDirectory ($database = NULL)
96
+    {
88 97
         global $config;
89 98
         if (self::isMultipleDatabaseEnabled ()) {
90
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
99
+            if (is_null ($database)) {
100
+                $database = GetUrlParam (DB, 0);
101
+            }
91 102
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
92 103
                 self::error ($database);
93 104
             }
@@ -98,28 +109,34 @@  discard block
 block discarded – undo
98 109
     }
99 110
 
100 111
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
112
+    public static function getImgDirectory ($database = NULL)
113
+    {
102 114
     	global $config;
103 115
     	if (self::isMultipleDatabaseEnabled ()) {
104
-    		if (is_null ($database)) $database = GetUrlParam (DB, 0);
116
+    		if (is_null ($database)) {
117
+    		    $database = GetUrlParam (DB, 0);
118
+    		}
105 119
     		$array = array_values ($config['image_directory']);
106 120
     		return  $array[$database];
107 121
     	}
108 122
     	return $config['image_directory'];
109 123
     }
110 124
 
111
-    public static function getDbFileName ($database = NULL) {
125
+    public static function getDbFileName ($database = NULL)
126
+    {
112 127
         return self::getDbDirectory ($database) .'metadata.db';
113 128
     }
114 129
 
115
-    private static function error ($database) {
130
+    private static function error ($database)
131
+    {
116 132
         if (php_sapi_name() != "cli") {
117 133
             header("location: checkconfig.php?err=1");
118 134
         }
119 135
         throw new Exception("Database <{$database}> not found.");
120 136
     }
121 137
 
122
-    public static function getDb ($database = NULL) {
138
+    public static function getDb ($database = NULL)
139
+    {
123 140
         if (is_null (self::$db)) {
124 141
             try {
125 142
                 if (is_readable (self::getDbFileName ($database))) {
@@ -137,7 +154,8 @@  discard block
 block discarded – undo
137 154
         return self::$db;
138 155
     }
139 156
 
140
-    public static function checkDatabaseAvailability () {
157
+    public static function checkDatabaseAvailability ()
158
+    {
141 159
         if (self::noDatabaseSelected ()) {
142 160
             for ($i = 0; $i < count (self::getDbList ()); $i++) {
143 161
                 self::getDb ($i);
@@ -149,33 +167,38 @@  discard block
 block discarded – undo
149 167
         return true;
150 168
     }
151 169
 
152
-    public static function clearDb () {
170
+    public static function clearDb ()
171
+    {
153 172
         self::$db = NULL;
154 173
     }
155 174
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
175
+    public static function executeQuerySingle ($query, $database = NULL)
176
+    {
157 177
         return self::getDb ($database)->query($query)->fetchColumn();
158 178
     }
159 179
 
160
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
180
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL)
181
+    {
161 182
         if (!$numberOfString) {
162 183
             $numberOfString = $table . ".alphabetical";
163 184
         }
164 185
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
165
-        if ($count == 0) return NULL;
186
+        if ($count == 0) {
187
+            return NULL;
188
+        }
166 189
         $entry = new Entry (localize($table . ".title"), $id,
167 190
             str_format (localize($numberOfString, $count), $count), "text",
168 191
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
169 192
         return $entry;
170 193
     }
171 194
 
172
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
195
+    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category)
196
+    {
173 197
         /* @var $result PDOStatement */
174 198
 
175 199
         list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
176 200
         $entryArray = array();
177
-        while ($post = $result->fetchObject ())
178
-        {
201
+        while ($post = $result->fetchObject ()) {
179 202
             /* @var $instance Author|Tag|Serie|Publisher */
180 203
 
181 204
             $instance = new $category ($post);
@@ -191,7 +214,8 @@  discard block
 block discarded – undo
191 214
         return $entryArray;
192 215
     }
193 216
 
194
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
217
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL)
218
+    {
195 219
         $totalResult = -1;
196 220
 
197 221
         if (useNormAndUp ()) {
@@ -203,8 +227,7 @@  discard block
 block discarded – undo
203 227
             $numberPerPage = getCurrentOption ("max_item_per_page");
204 228
         }
205 229
 
206
-        if ($numberPerPage != -1 && $n != -1)
207
-        {
230
+        if ($numberPerPage != -1 && $n != -1) {
208 231
             // First check total number of results
209 232
             $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
210 233
             $result->execute ($params);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     const COMPATIBILITY_XML_ALDIKO = "aldiko";
37 37
 
38
-    private static $db = NULL;
38
+    private static $db = null;
39 39
 
40 40
     public static function isMultipleDatabaseEnabled () {
41 41
         global $config;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         }
72 72
     }
73 73
 
74
-    public static function getDbName ($database = NULL) {
74
+    public static function getDbName ($database = null) {
75 75
         global $config;
76 76
         if (self::isMultipleDatabaseEnabled ()) {
77 77
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         return "";
85 85
     }
86 86
 
87
-    public static function getDbDirectory ($database = NULL) {
87
+    public static function getDbDirectory ($database = null) {
88 88
         global $config;
89 89
         if (self::isMultipleDatabaseEnabled ()) {
90 90
             if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
     // -DC- Add image directory
101
-    public static function getImgDirectory ($database = NULL) {
101
+    public static function getImgDirectory ($database = null) {
102 102
     	global $config;
103 103
     	if (self::isMultipleDatabaseEnabled ()) {
104 104
     		if (is_null ($database)) $database = GetUrlParam (DB, 0);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     	return $config['image_directory'];
109 109
     }
110 110
 
111
-    public static function getDbFileName ($database = NULL) {
111
+    public static function getDbFileName ($database = null) {
112 112
         return self::getDbDirectory ($database) .'metadata.db';
113 113
     }
114 114
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         throw new Exception("Database <{$database}> not found.");
120 120
     }
121 121
 
122
-    public static function getDb ($database = NULL) {
122
+    public static function getDb ($database = null) {
123 123
         if (is_null (self::$db)) {
124 124
             try {
125 125
                 if (is_readable (self::getDbFileName ($database))) {
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
     }
151 151
 
152 152
     public static function clearDb () {
153
-        self::$db = NULL;
153
+        self::$db = null;
154 154
     }
155 155
 
156
-    public static function executeQuerySingle ($query, $database = NULL) {
156
+    public static function executeQuerySingle ($query, $database = null) {
157 157
         return self::getDb ($database)->query($query)->fetchColumn();
158 158
     }
159 159
 
160
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
160
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = null) {
161 161
         if (!$numberOfString) {
162 162
             $numberOfString = $table . ".alphabetical";
163 163
         }
164 164
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
165
-        if ($count == 0) return NULL;
165
+        if ($count == 0) return null;
166 166
         $entry = new Entry (localize($table . ".title"), $id,
167 167
             str_format (localize($numberOfString, $count), $count), "text",
168 168
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         return $entryArray;
192 192
     }
193 193
 
194
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
194
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = null, $numberPerPage = null) {
195 195
         $totalResult = -1;
196 196
 
197 197
         if (useNormAndUp ()) {
Please login to merge, or discard this patch.
lib/CustomColumnType.php 4 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,6 +39,9 @@  discard block
 block discarded – undo
39 39
     /** @var null|Entry[] */
40 40
     private $customValues = NULL;
41 41
 
42
+    /**
43
+     * @param string $pdatatype
44
+     */
42 45
     protected function __construct($pcustomId, $pdatatype)
43 46
     {
44 47
         $this->columnTitle = self::getTitleByCustomID($pcustomId);
@@ -147,7 +150,7 @@  discard block
 block discarded – undo
147 150
     /**
148 151
      * Encode a value of this column ready to be displayed in an HTML document
149 152
      *
150
-     * @param integer|string $value
153
+     * @param string $value
151 154
      * @return string
152 155
      */
153 156
     public function encodeHTMLValue($value)
@@ -277,7 +280,7 @@  discard block
 block discarded – undo
277 280
     /**
278 281
      * Get a CustomColumn for a specified (by ID) value
279 282
      *
280
-     * @param string|integer $id the id of the searched value
283
+     * @param integer $id the id of the searched value
281 284
      * @return CustomColumn
282 285
      */
283 286
     abstract public function getCustom($id);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
  */
12 12
 abstract class CustomColumnType extends Base
13 13
 {
14
-    const ALL_CUSTOMS_ID       = "cops:custom";
14
+    const ALL_CUSTOMS_ID = "cops:custom";
15 15
 
16
-    const CUSTOM_TYPE_TEXT      = "text";        // type 1 + 2
17
-    const CUSTOM_TYPE_COMMENT   = "comments";    // type 3
18
-    const CUSTOM_TYPE_SERIES    = "series";      // type 4
16
+    const CUSTOM_TYPE_TEXT      = "text"; // type 1 + 2
17
+    const CUSTOM_TYPE_COMMENT   = "comments"; // type 3
18
+    const CUSTOM_TYPE_SERIES    = "series"; // type 4
19 19
     const CUSTOM_TYPE_ENUM      = "enumeration"; // type 5
20
-    const CUSTOM_TYPE_DATE      = "datetime";    // type 6
21
-    const CUSTOM_TYPE_FLOAT     = "float";       // type 7
22
-    const CUSTOM_TYPE_INT       = "int";         // type 8
23
-    const CUSTOM_TYPE_RATING    = "rating";      // type 9
24
-    const CUSTOM_TYPE_BOOL      = "bool";        // type 10
25
-    const CUSTOM_TYPE_COMPOSITE = "composite";   // type 11 + 12
20
+    const CUSTOM_TYPE_DATE      = "datetime"; // type 6
21
+    const CUSTOM_TYPE_FLOAT     = "float"; // type 7
22
+    const CUSTOM_TYPE_INT       = "int"; // type 8
23
+    const CUSTOM_TYPE_RATING    = "rating"; // type 9
24
+    const CUSTOM_TYPE_BOOL      = "bool"; // type 10
25
+    const CUSTOM_TYPE_COMPOSITE = "composite"; // type 11 + 12
26 26
 
27 27
     /** @var array[integer]CustomColumnType  */
28 28
     private static $customColumnCacheID = array();
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $result->execute(array($this->customId));
111 111
         if ($post = $result->fetchObject()) {
112 112
             $json = json_decode($post->display);
113
-            return (isset($json->description) && !empty($json->description)) ? $json->description : NULL;
113
+            return (isset($json->description) && !empty($json->description))?$json->description:NULL;
114 114
         }
115 115
         return NULL;
116 116
     }
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -181,8 +181,9 @@  discard block
 block discarded – undo
181 181
     public static function createByCustomID($customId)
182 182
     {
183 183
         // Reuse already created CustomColumns for performance
184
-        if (array_key_exists($customId, self::$customColumnCacheID))
185
-            return self::$customColumnCacheID[$customId];
184
+        if (array_key_exists($customId, self::$customColumnCacheID)) {
185
+                    return self::$customColumnCacheID[$customId];
186
+        }
186 187
 
187 188
         $datatype = self::getDatatypeByCustomID($customId);
188 189
 
@@ -221,8 +222,9 @@  discard block
 block discarded – undo
221 222
     public static function createByLookup($lookup)
222 223
     {
223 224
         // Reuse already created CustomColumns for performance
224
-        if (array_key_exists($lookup, self::$customColumnCacheLookup))
225
-            return self::$customColumnCacheLookup[$lookup];
225
+        if (array_key_exists($lookup, self::$customColumnCacheLookup)) {
226
+                    return self::$customColumnCacheLookup[$lookup];
227
+        }
226 228
 
227 229
         $result = parent::getDb()->prepare('SELECT id FROM custom_columns WHERE label = ?');
228 230
         $result->execute(array($lookup));
@@ -241,8 +243,9 @@  discard block
 block discarded – undo
241 243
     public function getAllCustomValues()
242 244
     {
243 245
         // lazy loading
244
-        if ($this->customValues == NULL)
245
-            $this->customValues = $this->getAllCustomValuesFromDatabase();
246
+        if ($this->customValues == NULL) {
247
+                    $this->customValues = $this->getAllCustomValuesFromDatabase();
248
+        }
246 249
 
247 250
         return $this->customValues;
248 251
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
     /** @var string the datatype of this column (one of the CUSTOM_TYPE_* constant values) */
38 38
     public $datatype;
39 39
     /** @var null|Entry[] */
40
-    private $customValues = NULL;
40
+    private $customValues = null;
41 41
 
42 42
     protected function __construct($pcustomId, $pdatatype)
43 43
     {
44 44
         $this->columnTitle = self::getTitleByCustomID($pcustomId);
45 45
         $this->customId = $pcustomId;
46 46
         $this->datatype = $pdatatype;
47
-        $this->customValues = NULL;
47
+        $this->customValues = null;
48 48
     }
49 49
 
50 50
     /**
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
         $result->execute(array($this->customId));
111 111
         if ($post = $result->fetchObject()) {
112 112
             $json = json_decode($post->display);
113
-            return (isset($json->description) && !empty($json->description)) ? $json->description : NULL;
113
+            return (isset($json->description) && !empty($json->description)) ? $json->description : null;
114 114
         }
115
-        return NULL;
115
+        return null;
116 116
     }
117 117
 
118 118
     /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         if ($post = $result->fetchObject()) {
169 169
             return $post->datatype;
170 170
         }
171
-        return NULL;
171
+        return null;
172 172
     }
173 173
 
174 174
     /**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             case self::CUSTOM_TYPE_BOOL:
207 207
                 return self::$customColumnCacheID[$customId] = new CustomColumnTypeBool($customId);
208 208
             case self::CUSTOM_TYPE_COMPOSITE:
209
-                return NULL; //TODO Currently not supported
209
+                return null; //TODO Currently not supported
210 210
             default:
211 211
                 throw new Exception("Unkown column type: " . $datatype);
212 212
         }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         if ($post = $result->fetchObject()) {
230 230
             return self::$customColumnCacheLookup[$lookup] = self::createByCustomID($post->id);
231 231
         }
232
-        return self::$customColumnCacheLookup[$lookup] = NULL;
232
+        return self::$customColumnCacheLookup[$lookup] = null;
233 233
     }
234 234
 
235 235
     /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     public function getAllCustomValues()
242 242
     {
243 243
         // lazy loading
244
-        if ($this->customValues == NULL)
244
+        if ($this->customValues == null)
245 245
             $this->customValues = $this->getAllCustomValuesFromDatabase();
246 246
 
247 247
         return $this->customValues;
Please login to merge, or discard this patch.
lib/LinkFacet.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -8,6 +8,9 @@
 block discarded – undo
8 8
 
9 9
 class LinkFacet extends Link
10 10
 {
11
+    /**
12
+     * @param string $phref
13
+     */
11 14
     public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
12 15
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
13 16
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
 class LinkFacet extends Link
10 10
 {
11 11
     public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
12
-        parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
13
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
12
+        parent::__construct($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
13
+        if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB));
14 14
         $this->href = parent::getScriptName() . $this->href;
15 15
     }
16 16
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,12 @@
 block discarded – undo
8 8
 
9 9
 class LinkFacet extends Link
10 10
 {
11
-    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
11
+    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE)
12
+    {
12 13
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
13
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14
+        if (!is_null (GetUrlParam (DB))) {
15
+            $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
16
+        }
14 17
         $this->href = parent::getScriptName() . $this->href;
15 18
     }
16 19
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class LinkFacet extends Link
10 10
 {
11
-    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
11
+    public function __construct($phref, $ptitle = null, $pfacetGroup = null, $pactiveFacet = false) {
12 12
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
13 13
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14 14
         $this->href = parent::getScriptName() . $this->href;
Please login to merge, or discard this patch.
lib/LinkNavigation.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -8,6 +8,9 @@
 block discarded – undo
8 8
 
9 9
 class LinkNavigation extends Link
10 10
 {
11
+    /**
12
+     * @param string $prel
13
+     */
11 14
     public function __construct($phref, $prel = NULL, $ptitle = NULL) {
12 15
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
13 16
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
 class LinkNavigation extends Link
10 10
 {
11 11
     public function __construct($phref, $prel = NULL, $ptitle = NULL) {
12
-        parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
13
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14
-        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
15
-        if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) {
12
+        parent::__construct($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
13
+        if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB));
14
+        if (!preg_match("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
15
+        if (preg_match("/(bookdetail|getJSON).php/", parent::getScriptName())) {
16 16
             $this->href = "index.php" . $this->href;
17 17
         } else {
18 18
             $this->href = parent::getScriptName() . $this->href;
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,10 +8,15 @@
 block discarded – undo
8 8
 
9 9
 class LinkNavigation extends Link
10 10
 {
11
-    public function __construct($phref, $prel = NULL, $ptitle = NULL) {
11
+    public function __construct($phref, $prel = NULL, $ptitle = NULL)
12
+    {
12 13
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
13
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14
-        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
14
+        if (!is_null (GetUrlParam (DB))) {
15
+            $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
16
+        }
17
+        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) {
18
+            $this->href = "?" . $this->href;
19
+        }
15 20
         if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) {
16 21
             $this->href = "index.php" . $this->href;
17 22
         } else {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class LinkNavigation extends Link
10 10
 {
11
-    public function __construct($phref, $prel = NULL, $ptitle = NULL) {
11
+    public function __construct($phref, $prel = null, $ptitle = null) {
12 12
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
13 13
         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14 14
         if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
Please login to merge, or discard this patch.
lib/PageCustomize.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -8,6 +8,9 @@  discard block
 block discarded – undo
8 8
 
9 9
 class PageCustomize extends Page
10 10
 {
11
+    /**
12
+     * @param string $key
13
+     */
11 14
     private function isChecked ($key, $testedValue = 1) {
12 15
         $value = getCurrentOption ($key);
13 16
         if (is_array ($value)) {
@@ -22,6 +25,9 @@  discard block
 block discarded – undo
22 25
         return "";
23 26
     }
24 27
 
28
+    /**
29
+     * @param string $key
30
+     */
25 31
     private function isSelected ($key, $value) {
26 32
         if (getCurrentOption ($key) == $value) {
27 33
             return "selected='selected'";
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@
 block discarded – undo
45 45
         $this->entryArray = array ();
46 46
 
47 47
         $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR,
48
-                                   PageQueryResult::SCOPE_TAG,
49
-                                   PageQueryResult::SCOPE_SERIES,
50
-                                   PageQueryResult::SCOPE_PUBLISHER,
51
-                                   PageQueryResult::SCOPE_RATING,
52
-                                   "language");
48
+                                    PageQueryResult::SCOPE_TAG,
49
+                                    PageQueryResult::SCOPE_SERIES,
50
+                                    PageQueryResult::SCOPE_PUBLISHER,
51
+                                    PageQueryResult::SCOPE_RATING,
52
+                                    "language");
53 53
 
54 54
         $content = "";
55 55
         array_push ($this->entryArray, new Entry ("Template", "",
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 
9 9
 class PageCustomize extends Page
10 10
 {
11
-    private function isChecked ($key, $testedValue = 1) {
12
-        $value = getCurrentOption ($key);
13
-        if (is_array ($value)) {
14
-            if (in_array ($testedValue, $value)) {
11
+    private function isChecked($key, $testedValue = 1) {
12
+        $value = getCurrentOption($key);
13
+        if (is_array($value)) {
14
+            if (in_array($testedValue, $value)) {
15 15
                 return "checked='checked'";
16 16
             }
17 17
         } else {
@@ -22,29 +22,29 @@  discard block
 block discarded – undo
22 22
         return "";
23 23
     }
24 24
 
25
-    private function isSelected ($key, $value) {
26
-        if (getCurrentOption ($key) == $value) {
25
+    private function isSelected($key, $value) {
26
+        if (getCurrentOption($key) == $value) {
27 27
             return "selected='selected'";
28 28
         }
29 29
         return "";
30 30
     }
31 31
 
32
-    private function getStyleList () {
33
-        $result = array ();
34
-        foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) {
35
-            if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
36
-                array_push ($result, $m [1]);
32
+    private function getStyleList() {
33
+        $result = array();
34
+        foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) {
35
+            if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) {
36
+                array_push($result, $m [1]);
37 37
             }
38 38
         }
39 39
         return $result;
40 40
     }
41 41
 
42
-    public function InitializeContent ()
42
+    public function InitializeContent()
43 43
     {
44
-        $this->title = localize ("customize.title");
45
-        $this->entryArray = array ();
44
+        $this->title = localize("customize.title");
45
+        $this->entryArray = array();
46 46
 
47
-        $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR,
47
+        $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR,
48 48
                                    PageQueryResult::SCOPE_TAG,
49 49
                                    PageQueryResult::SCOPE_SERIES,
50 50
                                    PageQueryResult::SCOPE_PUBLISHER,
@@ -52,49 +52,49 @@  discard block
 block discarded – undo
52 52
                                    "language");
53 53
 
54 54
         $content = "";
55
-        array_push ($this->entryArray, new Entry ("Template", "",
55
+        array_push($this->entryArray, new Entry("Template", "",
56 56
                                         "<span style='cursor: pointer;' onclick='$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text",
57
-                                        array ()));
57
+                                        array()));
58 58
         if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) {
59 59
             $content .= '<select id="style" onchange="updateCookie (this);">';
60
-            foreach ($this-> getStyleList () as $filename) {
61
-                $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>";
60
+            foreach ($this-> getStyleList() as $filename) {
61
+                $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>";
62 62
             }
63 63
             $content .= '</select>';
64 64
         } else {
65
-            foreach ($this-> getStyleList () as $filename) {
66
-                $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>";
65
+            foreach ($this-> getStyleList() as $filename) {
66
+                $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>";
67 67
             }
68 68
         }
69
-        array_push ($this->entryArray, new Entry (localize ("customize.style"), "",
69
+        array_push($this->entryArray, new Entry(localize("customize.style"), "",
70 70
                                         $content, "text",
71
-                                        array ()));
72
-        if (!useServerSideRendering ()) {
73
-            $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />';
74
-            array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "",
71
+                                        array()));
72
+        if (!useServerSideRendering()) {
73
+            $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />';
74
+            array_push($this->entryArray, new Entry(localize("customize.fancybox"), "",
75 75
                                             $content, "text",
76
-                                            array ()));
76
+                                            array()));
77 77
         }
78
-        $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]+$" />';
79
-        array_push ($this->entryArray, new Entry (localize ("customize.paging"), "",
78
+        $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]+$" />';
79
+        array_push($this->entryArray, new Entry(localize("customize.paging"), "",
80 80
                                         $content, "text",
81
-                                        array ()));
82
-        $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />';
83
-        array_push ($this->entryArray, new Entry (localize ("customize.email"), "",
81
+                                        array()));
82
+        $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />';
83
+        array_push($this->entryArray, new Entry(localize("customize.email"), "",
84 84
                                         $content, "text",
85
-                                        array ()));
86
-        $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />';
87
-        array_push ($this->entryArray, new Entry (localize ("customize.filter"), "",
85
+                                        array()));
86
+        $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />';
87
+        array_push($this->entryArray, new Entry(localize("customize.filter"), "",
88 88
                                         $content, "text",
89
-                                        array ()));
89
+                                        array()));
90 90
         $content = "";
91 91
         foreach ($ignoredBaseArray as $key) {
92
-            $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s");
93
-            $content .=  '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> ';
92
+            $keyPlural = preg_replace('/(ss)$/', 's', $key . "s");
93
+            $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> ';
94 94
         }
95 95
 
96
-        array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "",
96
+        array_push($this->entryArray, new Entry(localize("customize.ignored"), "",
97 97
                                         $content, "text",
98
-                                        array ()));
98
+                                        array()));
99 99
     }
100 100
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@  discard block
 block discarded – undo
8 8
 
9 9
 class PageCustomize extends Page
10 10
 {
11
-    private function isChecked ($key, $testedValue = 1) {
11
+    private function isChecked ($key, $testedValue = 1)
12
+    {
12 13
         $value = getCurrentOption ($key);
13 14
         if (is_array ($value)) {
14 15
             if (in_array ($testedValue, $value)) {
@@ -22,14 +23,16 @@  discard block
 block discarded – undo
22 23
         return "";
23 24
     }
24 25
 
25
-    private function isSelected ($key, $value) {
26
+    private function isSelected ($key, $value)
27
+    {
26 28
         if (getCurrentOption ($key) == $value) {
27 29
             return "selected='selected'";
28 30
         }
29 31
         return "";
30 32
     }
31 33
 
32
-    private function getStyleList () {
34
+    private function getStyleList ()
35
+    {
33 36
         $result = array ();
34 37
         foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) {
35 38
             if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) {
Please login to merge, or discard this patch.
lib/Rating.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -38,6 +38,9 @@
 block discarded – undo
38 38
         return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
39 39
     }
40 40
 
41
+    /**
42
+     * @param string $query
43
+     */
41 44
     public static function getEntryArray ($query, $params) {
42 45
         list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
43 46
         $entryArray = array();
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     const ALL_RATING_ID = "cops:rating";
12 12
 
13 13
     const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
14
-    const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
14
+    const SQL_ALL_RATINGS = "select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating";
15 15
     public $id;
16 16
     public $name;
17 17
 
@@ -20,41 +20,41 @@  discard block
 block discarded – undo
20 20
         $this->name = $pname;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . parent::PAGE_RATING_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_RATING_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_RATING_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("ratings", count(array))
33
-        return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
33
+        return parent::getCountGeneric("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
34 34
     }
35 35
 
36 36
     public static function getAllRatings() {
37
-        return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
37
+        return self::getEntryArray(self::SQL_ALL_RATINGS, array());
38 38
     }
39 39
 
40
-    public static function getEntryArray ($query, $params) {
41
-        list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
40
+    public static function getEntryArray($query, $params) {
41
+        list (, $result) = parent::executeQuery($query, self::RATING_COLUMNS, "", $params, -1);
42 42
         $entryArray = array();
43
-        while ($post = $result->fetchObject ())
43
+        while ($post = $result->fetchObject())
44 44
         {
45
-            $ratingObj = new Rating ($post->id, $post->rating);
46
-            $rating=$post->rating/2;
47
-            $rating = str_format (localize("ratingword", $rating), $rating);
48
-            array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (),
49
-                str_format (localize("bookword", $post->count), $post->count), "text",
50
-                array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count));
45
+            $ratingObj = new Rating($post->id, $post->rating);
46
+            $rating = $post->rating / 2;
47
+            $rating = str_format(localize("ratingword", $rating), $rating);
48
+            array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(),
49
+                str_format(localize("bookword", $post->count), $post->count), "text",
50
+                array(new LinkNavigation($ratingObj->getUri())), "", $post->count));
51 51
         }
52 52
         return $entryArray;
53 53
     }
54 54
 
55
-    public static function getRatingById ($ratingId) {
56
-        $result = parent::getDb ()->prepare('select rating from ratings where id = ?');
57
-        $result->execute (array ($ratingId));
58
-        return new Rating ($ratingId, $result->fetchColumn ());
55
+    public static function getRatingById($ratingId) {
56
+        $result = parent::getDb()->prepare('select rating from ratings where id = ?');
57
+        $result->execute(array($ratingId));
58
+        return new Rating($ratingId, $result->fetchColumn());
59 59
     }
60 60
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,33 +15,38 @@  discard block
 block discarded – undo
15 15
     public $id;
16 16
     public $name;
17 17
 
18
-    public function __construct($pid, $pname) {
18
+    public function __construct($pid, $pname)
19
+    {
19 20
         $this->id = $pid;
20 21
         $this->name = $pname;
21 22
     }
22 23
 
23
-    public function getUri () {
24
+    public function getUri ()
25
+    {
24 26
         return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id";
25 27
     }
26 28
 
27
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
28 31
         return self::ALL_RATING_ID.":".$this->id;
29 32
     }
30 33
 
31
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
32 36
         // str_format (localize("ratings", count(array))
33 37
         return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
34 38
     }
35 39
 
36
-    public static function getAllRatings() {
40
+    public static function getAllRatings()
41
+    {
37 42
         return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
38 43
     }
39 44
 
40
-    public static function getEntryArray ($query, $params) {
45
+    public static function getEntryArray ($query, $params)
46
+    {
41 47
         list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1);
42 48
         $entryArray = array();
43
-        while ($post = $result->fetchObject ())
44
-        {
49
+        while ($post = $result->fetchObject ()) {
45 50
             $ratingObj = new Rating ($post->id, $post->rating);
46 51
             $rating=$post->rating/2;
47 52
             $rating = str_format (localize("ratingword", $rating), $rating);
@@ -52,7 +57,8 @@  discard block
 block discarded – undo
52 57
         return $entryArray;
53 58
     }
54 59
 
55
-    public static function getRatingById ($ratingId) {
60
+    public static function getRatingById ($ratingId)
61
+    {
56 62
         $result = parent::getDb ()->prepare('select rating from ratings where id = ?');
57 63
         $result->execute (array ($ratingId));
58 64
         return new Rating ($ratingId, $result->fetchColumn ());
Please login to merge, or discard this patch.
config_default.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
      *
190 190
      * Note that the composite custom columns are not supported
191 191
      */
192
-    $config['cops_calibre_custom_column_list'] = array ();
192
+    $config['cops_calibre_custom_column_list'] = array();
193 193
 
194 194
     /*
195 195
      * Custom Columns for the book preview panel
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      *
200 200
      * Note that the composite custom columns are not supported
201 201
      */
202
-    $config['cops_calibre_custom_column_preview'] = array ();
202
+    $config['cops_calibre_custom_column_preview'] = array();
203 203
 
204 204
     /*
205 205
      * Rename .epub to .kepub.epub if downloaded from a Kobo eReader
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      *                                           "address.from"  => "[email protected]"
232 232
      *                                           );
233 233
      */
234
-    $config['cops_mail_configuration'] = NULL;
234
+    $config['cops_mail_configuration'] = null;
235 235
 
236 236
     /*
237 237
      * Use filter in HTML catalog
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * array( "username" => "xxx", "password" => "secret") : Enable PHP password protection
304 304
      * NULL : Disable PHP password protection (You can still use htpasswd)
305 305
      */
306
-    $config['cops_basic_authentication'] = NULL;
306
+    $config['cops_basic_authentication'] = null;
307 307
 
308 308
     /*
309 309
      * Which template is used by default :
Please login to merge, or discard this patch.