Passed
Push — master ( c5d652...dad459 )
by Sébastien
03:37
created
lib/JSON_renderer.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
             if ($data = $book->getDataFormat ($format)) {
25 25
                 $i++;
26 26
                 array_push ($preferedData, array ("url" => $data->getHtmlLink (),
27
-                  "viewUrl" => $data->getViewHtmlLink (), "name" => $format));
27
+                    "viewUrl" => $data->getViewHtmlLink (), "name" => $format));
28 28
             }
29 29
         }
30 30
 
@@ -52,20 +52,20 @@  discard block
 block discarded – undo
52 52
         $cc = $book->getCustomColumnValues($config['cops_calibre_custom_column_list'], true);
53 53
 
54 54
         return array ("id" => $book->id,
55
-                      "hasCover" => $book->hasCover,
56
-                      "preferedData" => $preferedData,
57
-                      "rating" => $book->getRating (),
58
-                      "publisherName" => $pn,
59
-                      "publisherurl" => $pu,
60
-                      "pubDate" => $book->getPubDate (),
61
-                      "languagesName" => $book->getLanguages (),
62
-                      "authorsName" => $book->getAuthorsName (),
63
-                      "tagsName" => $book->getTagsName (),
64
-                      "seriesName" => $sn,
65
-                      "seriesIndex" => $book->seriesIndex,
66
-                      "seriesCompleteName" => $scn,
67
-                      "seriesurl" => $su,
68
-                      "customcolumns_list" => $cc);
55
+                        "hasCover" => $book->hasCover,
56
+                        "preferedData" => $preferedData,
57
+                        "rating" => $book->getRating (),
58
+                        "publisherName" => $pn,
59
+                        "publisherurl" => $pu,
60
+                        "pubDate" => $book->getPubDate (),
61
+                        "languagesName" => $book->getLanguages (),
62
+                        "authorsName" => $book->getAuthorsName (),
63
+                        "tagsName" => $book->getTagsName (),
64
+                        "seriesName" => $sn,
65
+                        "seriesIndex" => $book->seriesIndex,
66
+                        "seriesCompleteName" => $scn,
67
+                        "seriesurl" => $su,
68
+                        "customcolumns_list" => $cc);
69 69
     }
70 70
 
71 71
     /**
@@ -137,44 +137,44 @@  discard block
 block discarded – undo
137 137
         $out = $in;
138 138
 
139 139
         $out ["c"] = array ("version" => VERSION, "i18n" => array (
140
-                           "coverAlt" => localize("i18n.coversection"),
141
-                           "authorsTitle" => localize("authors.title"),
142
-                           "bookwordTitle" => localize("bookword.title"),
143
-                           "tagsTitle" => localize("tags.title"),
144
-                           "seriesTitle" => localize("series.title"),
145
-                           "customizeTitle" => localize ("customize.title"),
146
-                           "aboutTitle" => localize ("about.title"),
147
-                           "previousAlt" => localize ("paging.previous.alternate"),
148
-                           "nextAlt" => localize ("paging.next.alternate"),
149
-                           "searchAlt" => localize ("search.alternate"),
150
-                           "sortAlt" => localize ("sort.alternate"),
151
-                           "homeAlt" => localize ("home.alternate"),
152
-                           "cogAlt" => localize ("cog.alternate"),
153
-                           "permalinkAlt" => localize ("permalink.alternate"),
154
-                           "publisherName" => localize("publisher.name"),
155
-                           "pubdateTitle" => localize("pubdate.title"),
156
-                           "languagesTitle" => localize("language.title"),
157
-                           "contentTitle" => localize("content.summary"),
158
-                           "sortorderAsc" => localize("search.sortorder.asc"),
159
-                           "sortorderDesc" => localize("search.sortorder.desc"),
160
-                           "customizeEmail" => localize("customize.email")),
161
-                       "url" => array (
162
-                           "detailUrl" => "index.php?page=13&id={0}&db={1}",
163
-                           "coverUrl" => "fetch.php?id={0}&db={1}",
164
-                           "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"),
165
-                       "config" => array (
166
-                           "use_fancyapps" => $config ["cops_use_fancyapps"],
167
-                           "max_item_per_page" => $config['cops_max_item_per_page'],
168
-                           "kindleHack"        => "",
169
-                           "server_side_rendering" => useServerSideRendering (),
170
-                           "html_tag_filter" => $config['cops_html_tag_filter']));
140
+                            "coverAlt" => localize("i18n.coversection"),
141
+                            "authorsTitle" => localize("authors.title"),
142
+                            "bookwordTitle" => localize("bookword.title"),
143
+                            "tagsTitle" => localize("tags.title"),
144
+                            "seriesTitle" => localize("series.title"),
145
+                            "customizeTitle" => localize ("customize.title"),
146
+                            "aboutTitle" => localize ("about.title"),
147
+                            "previousAlt" => localize ("paging.previous.alternate"),
148
+                            "nextAlt" => localize ("paging.next.alternate"),
149
+                            "searchAlt" => localize ("search.alternate"),
150
+                            "sortAlt" => localize ("sort.alternate"),
151
+                            "homeAlt" => localize ("home.alternate"),
152
+                            "cogAlt" => localize ("cog.alternate"),
153
+                            "permalinkAlt" => localize ("permalink.alternate"),
154
+                            "publisherName" => localize("publisher.name"),
155
+                            "pubdateTitle" => localize("pubdate.title"),
156
+                            "languagesTitle" => localize("language.title"),
157
+                            "contentTitle" => localize("content.summary"),
158
+                            "sortorderAsc" => localize("search.sortorder.asc"),
159
+                            "sortorderDesc" => localize("search.sortorder.desc"),
160
+                            "customizeEmail" => localize("customize.email")),
161
+                        "url" => array (
162
+                            "detailUrl" => "index.php?page=13&id={0}&db={1}",
163
+                            "coverUrl" => "fetch.php?id={0}&db={1}",
164
+                            "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"),
165
+                        "config" => array (
166
+                            "use_fancyapps" => $config ["cops_use_fancyapps"],
167
+                            "max_item_per_page" => $config['cops_max_item_per_page'],
168
+                            "kindleHack"        => "",
169
+                            "server_side_rendering" => useServerSideRendering (),
170
+                            "html_tag_filter" => $config['cops_html_tag_filter']));
171 171
         if ($config['cops_thumbnail_handling'] == "1") {
172 172
             $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"];
173 173
         } else if (!empty ($config['cops_thumbnail_handling'])) {
174 174
             $out ["c"]["url"]["thumbnailUrl"] = $config['cops_thumbnail_handling'];
175 175
         }
176 176
         if (preg_match("/./", $_SERVER['HTTP_USER_AGENT'])) {
177
-          $out ["c"]["config"]["kindleHack"] = 'style="text-decoration: none !important;"';
177
+            $out ["c"]["config"]["kindleHack"] = 'style="text-decoration: none !important;"';
178 178
         }
179 179
         return $out;
180 180
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         }
234 234
         if (!is_null (getURLParam ("complete")) || $complete) {
235 235
             $out = self::addCompleteArray ($out);
236
-       }
236
+        }
237 237
 
238 238
         $out ["containsBook"] = 0;
239 239
         if ($currentPage->containsBook ()) {
Please login to merge, or discard this patch.
lib/Data.php 2 patches
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.
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.