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