Test Setup Failed
Push — master ( dad459...432eb0 )
by Sébastien
02:25
created
lib/JSON_renderer.php 1 patch
Spacing   +96 added lines, -96 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,90 +72,90 @@  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);
77
+        $out = self::getBookContentArray($book);
78
+        $database = GetUrlParam(DB);
79 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 ();
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,
86
+            $tab = array("id" => $data->id,
87 87
                 "format" => $data->format, 
88
-                "url" => $data->getHtmlLink (),
89
-                "viewUrl" => $data->getViewHtmlLink (),
88
+                "url" => $data->getHtmlLink(),
89
+                "viewUrl" => $data->getViewHtmlLink(),
90 90
                 "mail" => 0, 
91 91
                 "readerUrl" => "");
92
-            if (!empty ($config['cops_mail_configuration']) && !is_null ($dataKindle) && $data->id == $dataKindle->id) {
92
+            if (!empty ($config['cops_mail_configuration']) && !is_null($dataKindle) && $data->id == $dataKindle->id) {
93 93
                 $tab ["mail"] = 1;
94 94
             }
95 95
             if ($data->format == "EPUB") {
96 96
                 $tab ["readerUrl"] = "epubreader.php?data={$data->id}&db={$database}";
97 97
             }
98
-            array_push ($out ["datas"], $tab);
98
+            array_push($out ["datas"], $tab);
99 99
         }
100
-        $out ["authors"] = array ();
101
-        foreach ($book->getAuthors () as $author) {
102
-            $link = new LinkNavigation ($author->getUri ());
103
-            array_push ($out ["authors"], array ("name" => $author->name, "url" => $link->hrefXhtml ()));
100
+        $out ["authors"] = array();
101
+        foreach ($book->getAuthors() as $author) {
102
+            $link = new LinkNavigation($author->getUri());
103
+            array_push($out ["authors"], array("name" => $author->name, "url" => $link->hrefXhtml()));
104 104
         }
105
-        $out ["tags"] = array ();
106
-        foreach ($book->getTags () as $tag) {
107
-            $link = new LinkNavigation ($tag->getUri ());
108
-            array_push ($out ["tags"], array ("name" => $tag->name, "url" => $link->hrefXhtml ()));
105
+        $out ["tags"] = array();
106
+        foreach ($book->getTags() as $tag) {
107
+            $link = new LinkNavigation($tag->getUri());
108
+            array_push($out ["tags"], array("name" => $tag->name, "url" => $link->hrefXhtml()));
109 109
         }
110 110
         $out ["customcolumns_preview"] = $book->getCustomColumnValues($config['cops_calibre_custom_column_preview'], true);
111 111
 
112 112
         return $out;
113 113
     }
114 114
 
115
-    public static function getContentArray ($entry) {
115
+    public static function getContentArray($entry) {
116 116
         if ($entry instanceof EntryBook) {
117
-            $out = array ( "title" => $entry->title);
118
-            $out ["book"] = self::getBookContentArray ($entry->book);
117
+            $out = array("title" => $entry->title);
118
+            $out ["book"] = self::getBookContentArray($entry->book);
119 119
             return $out;
120 120
         }
121
-        return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement );
121
+        return array("title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink(), "number" => $entry->numberOfElement);
122 122
     }
123 123
 
124
-    public static function getContentArrayTypeahead ($page) {
125
-        $out = array ();
124
+    public static function getContentArrayTypeahead($page) {
125
+        $out = array();
126 126
         foreach ($page->entryArray as $entry) {
127 127
             if ($entry instanceof EntryBook) {
128
-                array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ()));
128
+                array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl()));
129 129
             } else {
130
-                if (empty ($entry->className) xor Base::noDatabaseSelected ()) {
131
-                    array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ()));
130
+                if (empty ($entry->className) xor Base::noDatabaseSelected()) {
131
+                    array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink()));
132 132
                 } else {
133
-                    array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ()));
133
+                    array_push($out, array("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink()));
134 134
                 }
135 135
             }
136 136
         }
137 137
         return $out;
138 138
     }
139 139
 
140
-    public static function addCompleteArray ($in) {
140
+    public static function addCompleteArray($in) {
141 141
         global $config;
142 142
         $out = $in;
143 143
 
144
-        $out ["c"] = array ("version" => VERSION, "i18n" => array (
144
+        $out ["c"] = array("version" => VERSION, "i18n" => array(
145 145
                            "coverAlt" => localize("i18n.coversection"),
146 146
                            "authorsTitle" => localize("authors.title"),
147 147
                            "bookwordTitle" => localize("bookword.title"),
148 148
                            "tagsTitle" => localize("tags.title"),
149 149
                            "seriesTitle" => localize("series.title"),
150
-                           "customizeTitle" => localize ("customize.title"),
151
-                           "aboutTitle" => localize ("about.title"),
152
-                           "previousAlt" => localize ("paging.previous.alternate"),
153
-                           "nextAlt" => localize ("paging.next.alternate"),
154
-                           "searchAlt" => localize ("search.alternate"),
155
-                           "sortAlt" => localize ("sort.alternate"),
156
-                           "homeAlt" => localize ("home.alternate"),
157
-                           "cogAlt" => localize ("cog.alternate"),
158
-                           "permalinkAlt" => localize ("permalink.alternate"),
150
+                           "customizeTitle" => localize("customize.title"),
151
+                           "aboutTitle" => localize("about.title"),
152
+                           "previousAlt" => localize("paging.previous.alternate"),
153
+                           "nextAlt" => localize("paging.next.alternate"),
154
+                           "searchAlt" => localize("search.alternate"),
155
+                           "sortAlt" => localize("sort.alternate"),
156
+                           "homeAlt" => localize("home.alternate"),
157
+                           "cogAlt" => localize("cog.alternate"),
158
+                           "permalinkAlt" => localize("permalink.alternate"),
159 159
                            "publisherName" => localize("publisher.name"),
160 160
                            "pubdateTitle" => localize("pubdate.title"),
161 161
                            "languagesTitle" => localize("language.title"),
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
                            "sortorderAsc" => localize("search.sortorder.asc"),
164 164
                            "sortorderDesc" => localize("search.sortorder.desc"),
165 165
                            "customizeEmail" => localize("customize.email")),
166
-                       "url" => array (
166
+                       "url" => array(
167 167
                            "detailUrl" => "index.php?page=13&id={0}&db={1}",
168 168
                            "coverUrl" => "fetch.php?id={0}&db={1}",
169 169
                            "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"),
170
-                       "config" => array (
170
+                       "config" => array(
171 171
                            "use_fancyapps" => $config ["cops_use_fancyapps"],
172 172
                            "max_item_per_page" => $config['cops_max_item_per_page'],
173 173
                            "kindleHack"        => "",
174
-                           "server_side_rendering" => useServerSideRendering (),
174
+                           "server_side_rendering" => useServerSideRendering(),
175 175
                            "html_tag_filter" => $config['cops_html_tag_filter']));
176 176
         if ($config['cops_thumbnail_handling'] == "1") {
177 177
             $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"];
@@ -184,32 +184,32 @@  discard block
 block discarded – undo
184 184
         return $out;
185 185
     }
186 186
 
187
-    public static function getJson ($complete = false) {
187
+    public static function getJson($complete = false) {
188 188
         global $config;
189
-        $page = getURLParam ("page", Base::PAGE_INDEX);
190
-        $query = getURLParam ("query");
191
-        $search = getURLParam ("search");
192
-        $qid = getURLParam ("id");
193
-        $n = getURLParam ("n", "1");
194
-        $database = GetUrlParam (DB);
189
+        $page = getURLParam("page", Base::PAGE_INDEX);
190
+        $query = getURLParam("query");
191
+        $search = getURLParam("search");
192
+        $qid = getURLParam("id");
193
+        $n = getURLParam("n", "1");
194
+        $database = GetUrlParam(DB);
195 195
 
196
-        $currentPage = Page::getPage ($page, $qid, $query, $n);
197
-        $currentPage->InitializeContent ();
196
+        $currentPage = Page::getPage($page, $qid, $query, $n);
197
+        $currentPage->InitializeContent();
198 198
 
199 199
         if ($search) {
200
-            return self::getContentArrayTypeahead ($currentPage);
200
+            return self::getContentArrayTypeahead($currentPage);
201 201
         }
202 202
 
203
-        $out = array ( "title" => $currentPage->title);
204
-        $entries = array ();
203
+        $out = array("title" => $currentPage->title);
204
+        $entries = array();
205 205
         foreach ($currentPage->entryArray as $entry) {
206
-            array_push ($entries, self::getContentArray ($entry));
206
+            array_push($entries, self::getContentArray($entry));
207 207
         }
208
-        if (!is_null ($currentPage->book)) {
209
-            $out ["book"] = self::getFullBookContentArray ($currentPage->book);
208
+        if (!is_null($currentPage->book)) {
209
+            $out ["book"] = self::getFullBookContentArray($currentPage->book);
210 210
         }
211
-        $out ["databaseId"] = GetUrlParam (DB, "");
212
-        $out ["databaseName"] = Base::getDbName ();
211
+        $out ["databaseId"] = GetUrlParam(DB, "");
212
+        $out ["databaseName"] = Base::getDbName();
213 213
         if ($out ["databaseId"] == "") {
214 214
             $out ["databaseName"] = "";
215 215
         }
@@ -218,42 +218,42 @@  discard block
 block discarded – undo
218 218
             $out ["fullTitle"] = $out ["databaseName"] . " > " . $out ["fullTitle"];
219 219
         }
220 220
         $out ["page"] = $page;
221
-        $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled () ? 1 : 0;
221
+        $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled()?1:0;
222 222
         $out ["entries"] = $entries;
223 223
         $out ["isPaginated"] = 0;
224
-        if ($currentPage->isPaginated ()) {
225
-            $prevLink = $currentPage->getPrevLink ();
226
-            $nextLink = $currentPage->getNextLink ();
224
+        if ($currentPage->isPaginated()) {
225
+            $prevLink = $currentPage->getPrevLink();
226
+            $nextLink = $currentPage->getNextLink();
227 227
             $out ["isPaginated"] = 1;
228 228
             $out ["prevLink"] = "";
229
-            if (!is_null ($prevLink)) {
230
-                $out ["prevLink"] = $prevLink->hrefXhtml ();
229
+            if (!is_null($prevLink)) {
230
+                $out ["prevLink"] = $prevLink->hrefXhtml();
231 231
             }
232 232
             $out ["nextLink"] = "";
233
-            if (!is_null ($nextLink)) {
234
-                $out ["nextLink"] = $nextLink->hrefXhtml ();
233
+            if (!is_null($nextLink)) {
234
+                $out ["nextLink"] = $nextLink->hrefXhtml();
235 235
             }
236
-            $out ["maxPage"] = $currentPage->getMaxPage ();
236
+            $out ["maxPage"] = $currentPage->getMaxPage();
237 237
             $out ["currentPage"] = $currentPage->n;
238 238
         }
239
-        if (!is_null (getURLParam ("complete")) || $complete) {
240
-            $out = self::addCompleteArray ($out);
239
+        if (!is_null(getURLParam("complete")) || $complete) {
240
+            $out = self::addCompleteArray($out);
241 241
        }
242 242
 
243 243
         $out ["containsBook"] = 0;
244
-        if ($currentPage->containsBook ()) {
244
+        if ($currentPage->containsBook()) {
245 245
             $out ["containsBook"] = 1;
246 246
         }
247 247
 
248
-        $out["abouturl"] = "index.php" . addURLParameter ("?page=" . Base::PAGE_ABOUT, DB, $database);
248
+        $out["abouturl"] = "index.php" . addURLParameter("?page=" . Base::PAGE_ABOUT, DB, $database);
249 249
 
250 250
         if ($page == Base::PAGE_ABOUT) {
251
-            $temp = preg_replace ("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html'));
251
+            $temp = preg_replace("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html'));
252 252
             $out ["fullhtml"] = $temp;
253 253
         }
254 254
 
255 255
         $out ["homeurl"] = "index.php";
256
-        if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] .  "?" . addURLParameter ("", DB, $database);
256
+        if ($page != Base::PAGE_INDEX && !is_null($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter("", DB, $database);
257 257
 
258 258
         return $out;
259 259
     }
Please login to merge, or discard this patch.