Passed
Push — master ( c5d652...dad459 )
by Sébastien
03:37
created
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/JSON_renderer.php 2 patches
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.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -14,53 +14,53 @@  discard block
 block discarded – undo
14 14
      * @param Book $book
15 15
      * @return array
16 16
      */
17
-    public static function getBookContentArray ($book) {
17
+    public static function getBookContentArray($book) {
18 18
         global $config;
19 19
         $i = 0;
20
-        $preferedData = array ();
20
+        $preferedData = array();
21 21
         foreach ($config['cops_prefered_format'] as $format)
22 22
         {
23 23
             if ($i == 2) { break; }
24
-            if ($data = $book->getDataFormat ($format)) {
24
+            if ($data = $book->getDataFormat($format)) {
25 25
                 $i++;
26
-                array_push ($preferedData, array ("url" => $data->getHtmlLink (),
27
-                  "viewUrl" => $data->getViewHtmlLink (), "name" => $format));
26
+                array_push($preferedData, array("url" => $data->getHtmlLink(),
27
+                  "viewUrl" => $data->getViewHtmlLink(), "name" => $format));
28 28
             }
29 29
         }
30 30
 
31 31
         $publisher = $book->getPublisher();
32
-        if (is_null ($publisher)) {
32
+        if (is_null($publisher)) {
33 33
             $pn = "";
34 34
             $pu = "";
35 35
         } else {
36 36
             $pn = $publisher->name;
37
-            $link = new LinkNavigation ($publisher->getUri ());
38
-            $pu = $link->hrefXhtml ();
37
+            $link = new LinkNavigation($publisher->getUri());
38
+            $pu = $link->hrefXhtml();
39 39
         }
40 40
 
41
-        $serie = $book->getSerie ();
42
-        if (is_null ($serie)) {
41
+        $serie = $book->getSerie();
42
+        if (is_null($serie)) {
43 43
             $sn = "";
44 44
             $scn = "";
45 45
             $su = "";
46 46
         } else {
47 47
             $sn = $serie->name;
48
-            $scn = str_format (localize ("content.series.data"), $book->seriesIndex, $serie->name);
49
-            $link = new LinkNavigation ($serie->getUri ());
50
-            $su = $link->hrefXhtml ();
48
+            $scn = str_format(localize("content.series.data"), $book->seriesIndex, $serie->name);
49
+            $link = new LinkNavigation($serie->getUri());
50
+            $su = $link->hrefXhtml();
51 51
         }
52 52
         $cc = $book->getCustomColumnValues($config['cops_calibre_custom_column_list'], true);
53 53
 
54
-        return array ("id" => $book->id,
54
+        return array("id" => $book->id,
55 55
                       "hasCover" => $book->hasCover,
56 56
                       "preferedData" => $preferedData,
57
-                      "rating" => $book->getRating (),
57
+                      "rating" => $book->getRating(),
58 58
                       "publisherName" => $pn,
59 59
                       "publisherurl" => $pu,
60
-                      "pubDate" => $book->getPubDate (),
61
-                      "languagesName" => $book->getLanguages (),
62
-                      "authorsName" => $book->getAuthorsName (),
63
-                      "tagsName" => $book->getTagsName (),
60
+                      "pubDate" => $book->getPubDate(),
61
+                      "languagesName" => $book->getLanguages(),
62
+                      "authorsName" => $book->getAuthorsName(),
63
+                      "tagsName" => $book->getTagsName(),
64 64
                       "seriesName" => $sn,
65 65
                       "seriesIndex" => $book->seriesIndex,
66 66
                       "seriesCompleteName" => $scn,
@@ -72,85 +72,85 @@  discard block
 block discarded – undo
72 72
      * @param Book $book
73 73
      * @return array
74 74
      */
75
-    public static function getFullBookContentArray ($book) {
75
+    public static function getFullBookContentArray($book) {
76 76
         global $config;
77
-        $out = self::getBookContentArray ($book);
78
-        $database = GetUrlParam (DB);
79
-
80
-        $out ["coverurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml ();
81
-        $out ["thumbnailurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml ();
82
-        $out ["content"] = $book->getComment (false);
83
-        $out ["datas"] = array ();
84
-        $dataKindle = $book->GetMostInterestingDataToSendToKindle ();
77
+        $out = self::getBookContentArray($book);
78
+        $database = GetUrlParam(DB);
79
+
80
+        $out ["coverurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml();
81
+        $out ["thumbnailurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml();
82
+        $out ["content"] = $book->getComment(false);
83
+        $out ["datas"] = array();
84
+        $dataKindle = $book->GetMostInterestingDataToSendToKindle();
85 85
         foreach ($book->getDatas() as $data) {
86
-            $tab = array ("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink (), "mail" => 0, "readerUrl" => "");
87
-            if (!empty ($config['cops_mail_configuration']) && !is_null ($dataKindle) && $data->id == $dataKindle->id) {
86
+            $tab = array("id" => $data->id, "format" => $data->format, "url" => $data->getHtmlLink(), "mail" => 0, "readerUrl" => "");
87
+            if (!empty ($config['cops_mail_configuration']) && !is_null($dataKindle) && $data->id == $dataKindle->id) {
88 88
                 $tab ["mail"] = 1;
89 89
             }
90 90
             if ($data->format == "EPUB") {
91 91
                 $tab ["readerUrl"] = "epubreader.php?data={$data->id}&db={$database}";
92 92
             }
93
-            array_push ($out ["datas"], $tab);
93
+            array_push($out ["datas"], $tab);
94 94
         }
95
-        $out ["authors"] = array ();
96
-        foreach ($book->getAuthors () as $author) {
97
-            $link = new LinkNavigation ($author->getUri ());
98
-            array_push ($out ["authors"], array ("name" => $author->name, "url" => $link->hrefXhtml ()));
95
+        $out ["authors"] = array();
96
+        foreach ($book->getAuthors() as $author) {
97
+            $link = new LinkNavigation($author->getUri());
98
+            array_push($out ["authors"], array("name" => $author->name, "url" => $link->hrefXhtml()));
99 99
         }
100
-        $out ["tags"] = array ();
101
-        foreach ($book->getTags () as $tag) {
102
-            $link = new LinkNavigation ($tag->getUri ());
103
-            array_push ($out ["tags"], array ("name" => $tag->name, "url" => $link->hrefXhtml ()));
100
+        $out ["tags"] = array();
101
+        foreach ($book->getTags() as $tag) {
102
+            $link = new LinkNavigation($tag->getUri());
103
+            array_push($out ["tags"], array("name" => $tag->name, "url" => $link->hrefXhtml()));
104 104
         }
105 105
         $out ["customcolumns_preview"] = $book->getCustomColumnValues($config['cops_calibre_custom_column_preview'], true);
106 106
 
107 107
         return $out;
108 108
     }
109 109
 
110
-    public static function getContentArray ($entry) {
110
+    public static function getContentArray($entry) {
111 111
         if ($entry instanceof EntryBook) {
112
-            $out = array ( "title" => $entry->title);
113
-            $out ["book"] = self::getBookContentArray ($entry->book);
112
+            $out = array("title" => $entry->title);
113
+            $out ["book"] = self::getBookContentArray($entry->book);
114 114
             return $out;
115 115
         }
116
-        return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement );
116
+        return array("title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink(), "number" => $entry->numberOfElement);
117 117
     }
118 118
 
119
-    public static function getContentArrayTypeahead ($page) {
120
-        $out = array ();
119
+    public static function getContentArrayTypeahead($page) {
120
+        $out = array();
121 121
         foreach ($page->entryArray as $entry) {
122 122
             if ($entry instanceof EntryBook) {
123
-                array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ()));
123
+                array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl()));
124 124
             } else {
125
-                if (empty ($entry->className) xor Base::noDatabaseSelected ()) {
126
-                    array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ()));
125
+                if (empty ($entry->className) xor Base::noDatabaseSelected()) {
126
+                    array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink()));
127 127
                 } else {
128
-                    array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ()));
128
+                    array_push($out, array("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink()));
129 129
                 }
130 130
             }
131 131
         }
132 132
         return $out;
133 133
     }
134 134
 
135
-    public static function addCompleteArray ($in) {
135
+    public static function addCompleteArray($in) {
136 136
         global $config;
137 137
         $out = $in;
138 138
 
139
-        $out ["c"] = array ("version" => VERSION, "i18n" => array (
139
+        $out ["c"] = array("version" => VERSION, "i18n" => array(
140 140
                            "coverAlt" => localize("i18n.coversection"),
141 141
                            "authorsTitle" => localize("authors.title"),
142 142
                            "bookwordTitle" => localize("bookword.title"),
143 143
                            "tagsTitle" => localize("tags.title"),
144 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"),
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 154
                            "publisherName" => localize("publisher.name"),
155 155
                            "pubdateTitle" => localize("pubdate.title"),
156 156
                            "languagesTitle" => localize("language.title"),
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
                            "sortorderAsc" => localize("search.sortorder.asc"),
159 159
                            "sortorderDesc" => localize("search.sortorder.desc"),
160 160
                            "customizeEmail" => localize("customize.email")),
161
-                       "url" => array (
161
+                       "url" => array(
162 162
                            "detailUrl" => "index.php?page=13&id={0}&db={1}",
163 163
                            "coverUrl" => "fetch.php?id={0}&db={1}",
164 164
                            "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"),
165
-                       "config" => array (
165
+                       "config" => array(
166 166
                            "use_fancyapps" => $config ["cops_use_fancyapps"],
167 167
                            "max_item_per_page" => $config['cops_max_item_per_page'],
168 168
                            "kindleHack"        => "",
169
-                           "server_side_rendering" => useServerSideRendering (),
169
+                           "server_side_rendering" => useServerSideRendering(),
170 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"];
@@ -179,32 +179,32 @@  discard block
 block discarded – undo
179 179
         return $out;
180 180
     }
181 181
 
182
-    public static function getJson ($complete = false) {
182
+    public static function getJson($complete = false) {
183 183
         global $config;
184
-        $page = getURLParam ("page", Base::PAGE_INDEX);
185
-        $query = getURLParam ("query");
186
-        $search = getURLParam ("search");
187
-        $qid = getURLParam ("id");
188
-        $n = getURLParam ("n", "1");
189
-        $database = GetUrlParam (DB);
184
+        $page = getURLParam("page", Base::PAGE_INDEX);
185
+        $query = getURLParam("query");
186
+        $search = getURLParam("search");
187
+        $qid = getURLParam("id");
188
+        $n = getURLParam("n", "1");
189
+        $database = GetUrlParam(DB);
190 190
 
191
-        $currentPage = Page::getPage ($page, $qid, $query, $n);
192
-        $currentPage->InitializeContent ();
191
+        $currentPage = Page::getPage($page, $qid, $query, $n);
192
+        $currentPage->InitializeContent();
193 193
 
194 194
         if ($search) {
195
-            return self::getContentArrayTypeahead ($currentPage);
195
+            return self::getContentArrayTypeahead($currentPage);
196 196
         }
197 197
 
198
-        $out = array ( "title" => $currentPage->title);
199
-        $entries = array ();
198
+        $out = array("title" => $currentPage->title);
199
+        $entries = array();
200 200
         foreach ($currentPage->entryArray as $entry) {
201
-            array_push ($entries, self::getContentArray ($entry));
201
+            array_push($entries, self::getContentArray($entry));
202 202
         }
203
-        if (!is_null ($currentPage->book)) {
204
-            $out ["book"] = self::getFullBookContentArray ($currentPage->book);
203
+        if (!is_null($currentPage->book)) {
204
+            $out ["book"] = self::getFullBookContentArray($currentPage->book);
205 205
         }
206
-        $out ["databaseId"] = GetUrlParam (DB, "");
207
-        $out ["databaseName"] = Base::getDbName ();
206
+        $out ["databaseId"] = GetUrlParam(DB, "");
207
+        $out ["databaseName"] = Base::getDbName();
208 208
         if ($out ["databaseId"] == "") {
209 209
             $out ["databaseName"] = "";
210 210
         }
@@ -213,42 +213,42 @@  discard block
 block discarded – undo
213 213
             $out ["fullTitle"] = $out ["databaseName"] . " > " . $out ["fullTitle"];
214 214
         }
215 215
         $out ["page"] = $page;
216
-        $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled () ? 1 : 0;
216
+        $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled()?1:0;
217 217
         $out ["entries"] = $entries;
218 218
         $out ["isPaginated"] = 0;
219
-        if ($currentPage->isPaginated ()) {
220
-            $prevLink = $currentPage->getPrevLink ();
221
-            $nextLink = $currentPage->getNextLink ();
219
+        if ($currentPage->isPaginated()) {
220
+            $prevLink = $currentPage->getPrevLink();
221
+            $nextLink = $currentPage->getNextLink();
222 222
             $out ["isPaginated"] = 1;
223 223
             $out ["prevLink"] = "";
224
-            if (!is_null ($prevLink)) {
225
-                $out ["prevLink"] = $prevLink->hrefXhtml ();
224
+            if (!is_null($prevLink)) {
225
+                $out ["prevLink"] = $prevLink->hrefXhtml();
226 226
             }
227 227
             $out ["nextLink"] = "";
228
-            if (!is_null ($nextLink)) {
229
-                $out ["nextLink"] = $nextLink->hrefXhtml ();
228
+            if (!is_null($nextLink)) {
229
+                $out ["nextLink"] = $nextLink->hrefXhtml();
230 230
             }
231
-            $out ["maxPage"] = $currentPage->getMaxPage ();
231
+            $out ["maxPage"] = $currentPage->getMaxPage();
232 232
             $out ["currentPage"] = $currentPage->n;
233 233
         }
234
-        if (!is_null (getURLParam ("complete")) || $complete) {
235
-            $out = self::addCompleteArray ($out);
234
+        if (!is_null(getURLParam("complete")) || $complete) {
235
+            $out = self::addCompleteArray($out);
236 236
        }
237 237
 
238 238
         $out ["containsBook"] = 0;
239
-        if ($currentPage->containsBook ()) {
239
+        if ($currentPage->containsBook()) {
240 240
             $out ["containsBook"] = 1;
241 241
         }
242 242
 
243
-        $out["abouturl"] = "index.php" . addURLParameter ("?page=" . Base::PAGE_ABOUT, DB, $database);
243
+        $out["abouturl"] = "index.php" . addURLParameter("?page=" . Base::PAGE_ABOUT, DB, $database);
244 244
 
245 245
         if ($page == Base::PAGE_ABOUT) {
246
-            $temp = preg_replace ("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html'));
246
+            $temp = preg_replace("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html'));
247 247
             $out ["fullhtml"] = $temp;
248 248
         }
249 249
 
250 250
         $out ["homeurl"] = "index.php";
251
-        if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] .  "?" . addURLParameter ("", DB, $database);
251
+        if ($page != Base::PAGE_INDEX && !is_null($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter("", DB, $database);
252 252
 
253 253
         return $out;
254 254
     }
Please login to merge, or discard this patch.