Completed
Branch master (31966b)
by Markus
09:57
created
data.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -58,25 +58,25 @@  discard block
 block discarded – undo
58 58
         $this->id = $post->id;
59 59
         $this->name = $post->name;
60 60
         $this->format = $post->format;
61
-        $this->realFormat = str_replace ("ORIGINAL_", "", $post->format);
62
-        $this->extension = strtolower ($this->realFormat);
61
+        $this->realFormat = str_replace("ORIGINAL_", "", $post->format);
62
+        $this->extension = strtolower($this->realFormat);
63 63
         $this->book = $book;
64 64
     }
65 65
 
66
-    public function isKnownType () {
67
-        return array_key_exists ($this->extension, self::$mimetypes);
66
+    public function isKnownType() {
67
+        return array_key_exists($this->extension, self::$mimetypes);
68 68
     }
69 69
 
70
-    public function getMimeType () {
70
+    public function getMimeType() {
71 71
         $result = "application/octet-stream";
72
-        if ($this->isKnownType ()) {
72
+        if ($this->isKnownType()) {
73 73
             return self::$mimetypes [$this->extension];
74 74
         } elseif (function_exists('finfo_open') === true) {
75 75
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
76 76
 
77 77
             if (is_resource($finfo) === true)
78 78
             {
79
-                $result = finfo_file($finfo, $this->getLocalPath ());
79
+                $result = finfo_file($finfo, $this->getLocalPath());
80 80
             }
81 81
 
82 82
             finfo_close($finfo);
@@ -85,80 +85,80 @@  discard block
 block discarded – undo
85 85
         return $result;
86 86
     }
87 87
 
88
-    public function isEpubValidOnKobo () {
88
+    public function isEpubValidOnKobo() {
89 89
         return $this->format == "EPUB" || $this->format == "KEPUB";
90 90
     }
91 91
 
92
-    public function getFilename () {
93
-        return $this->name . "." . strtolower ($this->format);
92
+    public function getFilename() {
93
+        return $this->name . "." . strtolower($this->format);
94 94
     }
95 95
 
96
-    public function getUpdatedFilename () {
97
-        return $this->book->getAuthorsSort () . " - " . $this->book->title;
96
+    public function getUpdatedFilename() {
97
+        return $this->book->getAuthorsSort() . " - " . $this->book->title;
98 98
     }
99 99
 
100
-    public function getUpdatedFilenameEpub () {
101
-        return $this->getUpdatedFilename () . ".epub";
100
+    public function getUpdatedFilenameEpub() {
101
+        return $this->getUpdatedFilename() . ".epub";
102 102
     }
103 103
 
104
-    public function getUpdatedFilenameKepub () {
105
-        return $this->getUpdatedFilename () . ".kepub.epub";
104
+    public function getUpdatedFilenameKepub() {
105
+        return $this->getUpdatedFilename() . ".kepub.epub";
106 106
     }
107 107
 
108
-    public function getDataLink ($rel, $title = NULL) {
108
+    public function getDataLink($rel, $title = NULL) {
109 109
         global $config;
110 110
 
111 111
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
112 112
             return $this->getHtmlLinkWithRewriting($title);
113 113
         }
114 114
 
115
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
115
+        return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title);
116 116
     }
117 117
 
118
-    public function getHtmlLink () {
118
+    public function getHtmlLink() {
119 119
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
120 120
     }
121 121
 
122
-    public function getLocalPath () {
123
-        return $this->book->path . "/" . $this->getFilename ();
122
+    public function getLocalPath() {
123
+        return $this->book->path . "/" . $this->getFilename();
124 124
     }
125 125
 
126
-    public function getHtmlLinkWithRewriting ($title = NULL) {
126
+    public function getHtmlLinkWithRewriting($title = NULL) {
127 127
         global $config;
128 128
 
129 129
         $database = "";
130
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
130
+        if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/";
131 131
 
132 132
         $href = "download/" . $this->id . "/" . $database;
133 133
 
134 134
         if ($config['cops_provide_kepub'] == "1" &&
135
-            $this->isEpubValidOnKobo () &&
135
+            $this->isEpubValidOnKobo() &&
136 136
             preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
137
-            $href .= rawurlencode ($this->getUpdatedFilenameKepub ());
137
+            $href .= rawurlencode($this->getUpdatedFilenameKepub());
138 138
         } else {
139
-            $href .= rawurlencode ($this->getFilename ());
139
+            $href .= rawurlencode($this->getFilename());
140 140
         }
141
-        return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
141
+        return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title);
142 142
     }
143 143
 
144
-    public static function getDataByBook ($book) {
145
-        $out = array ();
146
-        $result = parent::getDb ()->prepare('select id, format, name
144
+    public static function getDataByBook($book) {
145
+        $out = array();
146
+        $result = parent::getDb()->prepare('select id, format, name
147 147
                                              from data where book = ?');
148
-        $result->execute (array ($book->id));
148
+        $result->execute(array($book->id));
149 149
 
150
-        while ($post = $result->fetchObject ())
150
+        while ($post = $result->fetchObject())
151 151
         {
152
-            array_push ($out, new Data ($post, $book));
152
+            array_push($out, new Data($post, $book));
153 153
         }
154 154
         return $out;
155 155
     }
156 156
 
157
-    public static function handleThumbnailLink ($urlParam, $height) {
157
+    public static function handleThumbnailLink($urlParam, $height) {
158 158
         global $config;
159 159
 
160
-        if (is_null ($height)) {
161
-            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
160
+        if (is_null($height)) {
161
+            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
162 162
                 $height = $config['cops_opds_thumbnail_height'];
163 163
             }
164 164
             else
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
         return $urlParam;
174 174
     }
175 175
 
176
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
176
+    public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
177 177
     {
178 178
         global $config;
179 179
 
180 180
         $urlParam = addURLParameter("", "data", $idData);
181 181
 
182
-        if (Base::useAbsolutePath () ||
182
+        if (Base::useAbsolutePath() ||
183 183
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
184 184
             ($type == "epub" && $config['cops_update_epub-metadata']))
185 185
         {
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
189 189
             }
190 190
             $urlParam = addURLParameter($urlParam, "id", $book->id);
191
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
191
+            if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
192 192
             if ($config['cops_thumbnail_handling'] != "1" &&
193 193
                 !empty ($config['cops_thumbnail_handling']) &&
194 194
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
195
-                return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title);
195
+                return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title);
196 196
             } else {
197
-                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
197
+                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title);
198 198
             }
199 199
         }
200 200
         else
201 201
         {
202
-            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
202
+            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title);
203 203
         }
204 204
     }
205 205
 }
Please login to merge, or discard this patch.
config_default.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * The two first will be displayed in book entries
107 107
      * The other only appear in book detail
108 108
      */
109
-    $config['cops_prefered_format'] = array ("EPUB", "PDF", "AZW3", "AZW", "MOBI", "CBR", "CBZ");
109
+    $config['cops_prefered_format'] = array("EPUB", "PDF", "AZW3", "AZW", "MOBI", "CBR", "CBZ");
110 110
 
111 111
     /*
112 112
      * use URL rewriting for downloading of ebook in HTML catalog
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      *
169 169
      * Example : array ("All" => "", "Unread" => "!Read", "Read" => "Read")
170 170
      */
171
-    $config['cops_books_filter'] = array ();
171
+    $config['cops_books_filter'] = array();
172 172
 
173 173
     /*
174 174
      * Custom Columns to add  as an array containing the lookup names
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      *
179 179
      * Note that for now only the first, second and forth type of custom columns are supported
180 180
      */
181
-    $config['cops_calibre_custom_column'] = array ();
181
+    $config['cops_calibre_custom_column'] = array();
182 182
 
183 183
     /*
184 184
      * Rename .epub to .kepub.epub if downloaded from a Kobo eReader
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      * - rating
257 257
      * - language
258 258
      */
259
-    $config ['cops_ignored_categories'] = array ();
259
+    $config ['cops_ignored_categories'] = array();
260 260
 
261 261
     /*
262 262
      * If you use a Sony eReader or Aldiko you can't download ebooks if your catalog
Please login to merge, or discard this patch.
checkconfig.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
     require_once ("config.php");
13 13
     require_once ("base.php");
14 14
 
15
-    header ("Content-Type:text/html; charset=UTF-8");
15
+    header("Content-Type:text/html; charset=UTF-8");
16 16
 
17
-    $err = getURLParam ("err", -1);
18
-    $full = getURLParam ("full");
17
+    $err = getURLParam("err", -1);
18
+    $full = getURLParam("full");
19 19
     $error = NULL;
20 20
     switch ($err) {
21 21
         case 1 :
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     <meta charset="utf-8">
29 29
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
30 30
     <title>COPS Configuration Check</title>
31
-    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
31
+    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss()) ?>" media="screen" />
32 32
 </head>
33 33
 <body>
34 34
 <div class="container">
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     <div id="content" style="display: none;"></div>
41 41
     <section>
42 42
         <?php
43
-        if (!is_null ($error)) {
43
+        if (!is_null($error)) {
44 44
         ?>
45 45
         <article class="frontpage">
46 46
             <h2>You've been redirected because COPS is not configured properly</h2>
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             <h2>Check if the rendering will be done on client side or server side</h2>
154 154
             <h4>
155 155
             <?php
156
-            if (useServerSideRendering ()) {
156
+            if (useServerSideRendering()) {
157 157
                 echo "Server side rendering";
158 158
             } else {
159 159
                 echo "Client side rendering";
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
         </article>
164 164
 <?php
165 165
 $i = 0;
166
-foreach (Base::getDbList () as $name => $database) {
166
+foreach (Base::getDbList() as $name => $database) {
167 167
 ?>
168 168
         <article class="frontpage">
169 169
             <h2>Check if Calibre database path is not an URL</h2>
170 170
             <h4>
171 171
             <?php
172
-            if (!preg_match ("#^http#", $database)) {
172
+            if (!preg_match("#^http#", $database)) {
173 173
                 echo "OK";
174 174
             } else {
175 175
                 echo "Calibre path has to be local (no URL allowed)";
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
             <h2>Check if Calibre database file exists and is readable</h2>
182 182
             <h4>
183 183
             <?php
184
-            if (is_readable (Base::getDbFileName ($i))) {
184
+            if (is_readable(Base::getDbFileName($i))) {
185 185
                 echo "{$name} OK";
186 186
             } else {
187
-                echo "{$name} File " . Base::getDbFileName ($i) . " not found,
187
+                echo "{$name} File " . Base::getDbFileName($i) . " not found,
188 188
 Please check
189 189
 <ul>
190 190
 <li>Value of \$config['calibre_directory'] in config_local.php</li>
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
             ?>
197 197
             </h4>
198 198
         </article>
199
-    <?php if (is_readable (Base::getDbFileName ($i))) { ?>
199
+    <?php if (is_readable(Base::getDbFileName($i))) { ?>
200 200
         <article class="frontpage">
201 201
             <h2>Check if Calibre database file can be opened with PHP</h2>
202 202
             <h4>
203 203
             <?php
204 204
             try {
205
-                $db = new PDO('sqlite:'. Base::getDbFileName ($i));
205
+                $db = new PDO('sqlite:' . Base::getDbFileName($i));
206 206
                 echo "{$name} OK";
207 207
             } catch (Exception $e) {
208 208
                 echo "{$name} If the file is readable, check your php configuration. Exception detail : " . $e;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             <h4>
216 216
             <?php
217 217
             try {
218
-                $db = new PDO('sqlite:'. Base::getDbFileName ($i));
218
+                $db = new PDO('sqlite:' . Base::getDbFileName($i));
219 219
                 $count = $db->query("select count(*) FROM sqlite_master WHERE type='table' AND name in ('books', 'authors', 'tags', 'series')")->fetchColumn();
220 220
                 if ($count == 4) {
221 221
                     echo "{$name} OK";
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
             <h4>
235 235
             <?php
236 236
             try {
237
-                $db = new PDO('sqlite:'. Base::getDbFileName ($i));
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
-                $result->execute ();
240
-                while ($post = $result->fetchObject ())
239
+                $result->execute();
240
+                while ($post = $result->fetchObject())
241 241
                 {
242
-                    if (!is_file (Base::getDbDirectory ($i) . $post->fullpath)) {
243
-                        echo "<p>" . Base::getDbDirectory ($i) . $post->fullpath . "</p>";
242
+                    if (!is_file(Base::getDbDirectory($i) . $post->fullpath)) {
243
+                        echo "<p>" . Base::getDbDirectory($i) . $post->fullpath . "</p>";
244 244
                     }
245 245
                 }
246 246
             } catch (Exception $e) {
Please login to merge, or discard this patch.