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