Completed
Pull Request — master (#274)
by Markus
07:36
created
lib/CustomColumnTypeRating.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 
58 58
     public function getCustom($id)
59 59
     {
60
-        return new CustomColumn ($id, str_format(localize("customcolumn.stars", $id / 2), $id / 2), $this);
60
+        return new CustomColumn($id, str_format(localize("customcolumn.stars", $id / 2), $id / 2), $this);
61 61
     }
62 62
 
63 63
     protected function getAllCustomValuesFromDatabase()
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
         if ($post = $result->fetchObject()) {
101 101
             return new CustomColumn($post->value, str_format(localize("customcolumn.stars", $post->value / 2), $post->value / 2), $this);
102 102
         }
103
-        return new CustomColumn(NULL, localize("customcolumn.rating.unknown"), $this);
103
+        return new CustomColumn(null, localize("customcolumn.rating.unknown"), $this);
104 104
     }
105 105
 
106 106
     public function isSearchable()
Please login to merge, or discard this patch.
lib/PageAllCustoms.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 
9 9
 class PageAllCustoms extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $customId = getURLParam ("custom", NULL);
13
+        $customId = getURLParam("custom", NULL);
14 14
         $columnType = CustomColumnType::createByCustomID($customId);
15 15
         
16 16
         $this->title = $columnType->getTitle();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     public function InitializeContent ()
12 12
     {
13
-        $customId = getURLParam ("custom", NULL);
13
+        $customId = getURLParam ("custom", null);
14 14
         $custom = CustomColumn::createCustom ($customId, $this->idGet);
15 15
         $this->idPage = $custom->getEntryId ();
16 16
         $this->title = $custom->value;
Please login to merge, or discard this patch.
lib/OPDS_renderer.php 3 patches
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -13,266 +13,266 @@
 block discarded – undo
13 13
     private $xmlStream = NULL;
14 14
     private $updated = NULL;
15 15
 
16
-    private function getUpdatedTime () {
17
-        if (is_null ($this->updated)) {
16
+    private function getUpdatedTime() {
17
+        if (is_null($this->updated)) {
18 18
             $this->updated = time();
19 19
         }
20
-        return date (DATE_ATOM, $this->updated);
20
+        return date(DATE_ATOM, $this->updated);
21 21
     }
22 22
 
23
-    private function getXmlStream () {
24
-        if (is_null ($this->xmlStream)) {
23
+    private function getXmlStream() {
24
+        if (is_null($this->xmlStream)) {
25 25
             $this->xmlStream = new XMLWriter();
26 26
             $this->xmlStream->openMemory();
27
-            $this->xmlStream->setIndent (true);
27
+            $this->xmlStream->setIndent(true);
28 28
         }
29 29
         return $this->xmlStream;
30 30
     }
31 31
 
32
-    public function getOpenSearch () {
32
+    public function getOpenSearch() {
33 33
         global $config;
34
-        $xml = new XMLWriter ();
35
-        $xml->openMemory ();
36
-        $xml->setIndent (true);
37
-        $xml->startDocument('1.0','UTF-8');
38
-            $xml->startElement ("OpenSearchDescription");
39
-                $xml->writeAttribute ("xmlns", "http://a9.com/-/spec/opensearch/1.1/");
40
-                $xml->startElement ("ShortName");
41
-                    $xml->text ("My catalog");
42
-                $xml->endElement ();
43
-                $xml->startElement ("Description");
44
-                    $xml->text ("Search for ebooks");
45
-                $xml->endElement ();
46
-                $xml->startElement ("InputEncoding");
47
-                    $xml->text ("UTF-8");
48
-                $xml->endElement ();
49
-                $xml->startElement ("OutputEncoding");
50
-                    $xml->text ("UTF-8");
51
-                $xml->endElement ();
52
-                $xml->startElement ("Image");
53
-                    $xml->writeAttribute ("type", "image/x-icon");
54
-                    $xml->writeAttribute ("width", "16");
55
-                    $xml->writeAttribute ("height", "16");
56
-                    $xml->text ($config['cops_icon']);
57
-                $xml->endElement ();
58
-                $xml->startElement ("Url");
59
-                    $xml->writeAttribute ("type", 'application/atom+xml');
34
+        $xml = new XMLWriter();
35
+        $xml->openMemory();
36
+        $xml->setIndent(true);
37
+        $xml->startDocument('1.0', 'UTF-8');
38
+            $xml->startElement("OpenSearchDescription");
39
+                $xml->writeAttribute("xmlns", "http://a9.com/-/spec/opensearch/1.1/");
40
+                $xml->startElement("ShortName");
41
+                    $xml->text("My catalog");
42
+                $xml->endElement();
43
+                $xml->startElement("Description");
44
+                    $xml->text("Search for ebooks");
45
+                $xml->endElement();
46
+                $xml->startElement("InputEncoding");
47
+                    $xml->text("UTF-8");
48
+                $xml->endElement();
49
+                $xml->startElement("OutputEncoding");
50
+                    $xml->text("UTF-8");
51
+                $xml->endElement();
52
+                $xml->startElement("Image");
53
+                    $xml->writeAttribute("type", "image/x-icon");
54
+                    $xml->writeAttribute("width", "16");
55
+                    $xml->writeAttribute("height", "16");
56
+                    $xml->text($config['cops_icon']);
57
+                $xml->endElement();
58
+                $xml->startElement("Url");
59
+                    $xml->writeAttribute("type", 'application/atom+xml');
60 60
                     $urlparam = "?query={searchTerms}";
61
-                    if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
62
-                    $urlparam = str_replace ("%7B", "{", $urlparam);
63
-                    $urlparam = str_replace ("%7D", "}", $urlparam);
64
-                    $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam);
65
-                $xml->endElement ();
66
-                $xml->startElement ("Query");
67
-                    $xml->writeAttribute ("role", "example");
68
-                    $xml->writeAttribute ("searchTerms", "robot");
69
-                $xml->endElement ();
70
-            $xml->endElement ();
61
+                    if (!is_null(GetUrlParam(DB))) $urlparam = addURLParameter($urlparam, DB, GetUrlParam(DB));
62
+                    $urlparam = str_replace("%7B", "{", $urlparam);
63
+                    $urlparam = str_replace("%7D", "}", $urlparam);
64
+                    $xml->writeAttribute("template", $config['cops_full_url'] . 'feed.php' . $urlparam);
65
+                $xml->endElement();
66
+                $xml->startElement("Query");
67
+                    $xml->writeAttribute("role", "example");
68
+                    $xml->writeAttribute("searchTerms", "robot");
69
+                $xml->endElement();
70
+            $xml->endElement();
71 71
         $xml->endDocument();
72 72
         return $xml->outputMemory(true);
73 73
     }
74 74
 
75
-    private function startXmlDocument ($page) {
75
+    private function startXmlDocument($page) {
76 76
         global $config;
77
-        self::getXmlStream ()->startDocument('1.0','UTF-8');
78
-        self::getXmlStream ()->startElement ("feed");
79
-            self::getXmlStream ()->writeAttribute ("xmlns", "http://www.w3.org/2005/Atom");
80
-            self::getXmlStream ()->writeAttribute ("xmlns:xhtml", "http://www.w3.org/1999/xhtml");
81
-            self::getXmlStream ()->writeAttribute ("xmlns:opds", "http://opds-spec.org/2010/catalog");
82
-            self::getXmlStream ()->writeAttribute ("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/");
83
-            self::getXmlStream ()->writeAttribute ("xmlns:dcterms", "http://purl.org/dc/terms/");
84
-            self::getXmlStream ()->startElement ("title");
85
-                self::getXmlStream ()->text ($page->title);
86
-            self::getXmlStream ()->endElement ();
77
+        self::getXmlStream()->startDocument('1.0', 'UTF-8');
78
+        self::getXmlStream()->startElement("feed");
79
+            self::getXmlStream()->writeAttribute("xmlns", "http://www.w3.org/2005/Atom");
80
+            self::getXmlStream()->writeAttribute("xmlns:xhtml", "http://www.w3.org/1999/xhtml");
81
+            self::getXmlStream()->writeAttribute("xmlns:opds", "http://opds-spec.org/2010/catalog");
82
+            self::getXmlStream()->writeAttribute("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/");
83
+            self::getXmlStream()->writeAttribute("xmlns:dcterms", "http://purl.org/dc/terms/");
84
+            self::getXmlStream()->startElement("title");
85
+                self::getXmlStream()->text($page->title);
86
+            self::getXmlStream()->endElement();
87 87
             if ($page->subtitle != "")
88 88
             {
89
-                self::getXmlStream ()->startElement ("subtitle");
90
-                    self::getXmlStream ()->text ($page->subtitle);
91
-                self::getXmlStream ()->endElement ();
89
+                self::getXmlStream()->startElement("subtitle");
90
+                    self::getXmlStream()->text($page->subtitle);
91
+                self::getXmlStream()->endElement();
92 92
             }
93
-            self::getXmlStream ()->startElement ("id");
93
+            self::getXmlStream()->startElement("id");
94 94
                 if ($page->idPage)
95 95
                 {
96 96
                     $idPage = $page->idPage;
97
-                    if (!is_null (GetUrlParam (DB))) $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage);
98
-                    self::getXmlStream ()->text ($idPage);
97
+                    if (!is_null(GetUrlParam(DB))) $idPage = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $idPage);
98
+                    self::getXmlStream()->text($idPage);
99 99
                 }
100 100
                 else
101 101
                 {
102
-                    self::getXmlStream ()->text ($_SERVER['REQUEST_URI']);
102
+                    self::getXmlStream()->text($_SERVER['REQUEST_URI']);
103 103
                 }
104
-            self::getXmlStream ()->endElement ();
105
-            self::getXmlStream ()->startElement ("updated");
106
-                self::getXmlStream ()->text (self::getUpdatedTime ());
107
-            self::getXmlStream ()->endElement ();
108
-            self::getXmlStream ()->startElement ("icon");
109
-                self::getXmlStream ()->text ($page->favicon);
110
-            self::getXmlStream ()->endElement ();
111
-            self::getXmlStream ()->startElement ("author");
112
-                self::getXmlStream ()->startElement ("name");
113
-                    self::getXmlStream ()->text ($page->authorName);
114
-                self::getXmlStream ()->endElement ();
115
-                self::getXmlStream ()->startElement ("uri");
116
-                    self::getXmlStream ()->text ($page->authorUri);
117
-                self::getXmlStream ()->endElement ();
118
-                self::getXmlStream ()->startElement ("email");
119
-                    self::getXmlStream ()->text ($page->authorEmail);
120
-                self::getXmlStream ()->endElement ();
121
-            self::getXmlStream ()->endElement ();
122
-            $link = new LinkNavigation ("", "start", "Home");
123
-            self::renderLink ($link);
124
-            $link = new LinkNavigation ("?" . getQueryString (), "self");
125
-            self::renderLink ($link);
104
+            self::getXmlStream()->endElement();
105
+            self::getXmlStream()->startElement("updated");
106
+                self::getXmlStream()->text(self::getUpdatedTime());
107
+            self::getXmlStream()->endElement();
108
+            self::getXmlStream()->startElement("icon");
109
+                self::getXmlStream()->text($page->favicon);
110
+            self::getXmlStream()->endElement();
111
+            self::getXmlStream()->startElement("author");
112
+                self::getXmlStream()->startElement("name");
113
+                    self::getXmlStream()->text($page->authorName);
114
+                self::getXmlStream()->endElement();
115
+                self::getXmlStream()->startElement("uri");
116
+                    self::getXmlStream()->text($page->authorUri);
117
+                self::getXmlStream()->endElement();
118
+                self::getXmlStream()->startElement("email");
119
+                    self::getXmlStream()->text($page->authorEmail);
120
+                self::getXmlStream()->endElement();
121
+            self::getXmlStream()->endElement();
122
+            $link = new LinkNavigation("", "start", "Home");
123
+            self::renderLink($link);
124
+            $link = new LinkNavigation("?" . getQueryString(), "self");
125
+            self::renderLink($link);
126 126
             $urlparam = "?";
127
-            if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
127
+            if (!is_null(GetUrlParam(DB))) $urlparam = addURLParameter($urlparam, DB, GetUrlParam(DB));
128 128
             if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) {
129 129
                 // Good and compliant way of handling search
130
-                $urlparam = addURLParameter ($urlparam, "page", Base::PAGE_OPENSEARCH);
131
-                $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here");
130
+                $urlparam = addURLParameter($urlparam, "page", Base::PAGE_OPENSEARCH);
131
+                $link = new Link("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here");
132 132
             }
133 133
             else
134 134
             {
135 135
                 // Bad way, will be removed when OPDS client are fixed
136
-                $urlparam = addURLParameter ($urlparam, "query", "{searchTerms}");
137
-                $urlparam = str_replace ("%7B", "{", $urlparam);
138
-                $urlparam = str_replace ("%7D", "}", $urlparam);
139
-                $link = new Link ($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here");
136
+                $urlparam = addURLParameter($urlparam, "query", "{searchTerms}");
137
+                $urlparam = str_replace("%7B", "{", $urlparam);
138
+                $urlparam = str_replace("%7D", "}", $urlparam);
139
+                $link = new Link($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here");
140 140
             }
141
-            self::renderLink ($link);
142
-            if ($page->containsBook () && !is_null ($config['cops_books_filter']) && count ($config['cops_books_filter']) > 0) {
143
-                $Urlfilter = getURLParam ("tag", "");
141
+            self::renderLink($link);
142
+            if ($page->containsBook() && !is_null($config['cops_books_filter']) && count($config['cops_books_filter']) > 0) {
143
+                $Urlfilter = getURLParam("tag", "");
144 144
                 foreach ($config['cops_books_filter'] as $lib => $filter) {
145
-                    $link = new LinkFacet ("?" . addURLParameter (getQueryString (), "tag", $filter), $lib, localize ("tagword.title"), $filter == $Urlfilter);
146
-                    self::renderLink ($link);
145
+                    $link = new LinkFacet("?" . addURLParameter(getQueryString(), "tag", $filter), $lib, localize("tagword.title"), $filter == $Urlfilter);
146
+                    self::renderLink($link);
147 147
                 }
148 148
             }
149 149
     }
150 150
 
151
-    private function endXmlDocument () {
152
-        self::getXmlStream ()->endElement ();
153
-        self::getXmlStream ()->endDocument ();
154
-        return self::getXmlStream ()->outputMemory(true);
151
+    private function endXmlDocument() {
152
+        self::getXmlStream()->endElement();
153
+        self::getXmlStream()->endDocument();
154
+        return self::getXmlStream()->outputMemory(true);
155 155
     }
156 156
 
157
-    private function renderLink ($link) {
158
-        self::getXmlStream ()->startElement ("link");
159
-            self::getXmlStream ()->writeAttribute ("href", $link->href);
160
-            self::getXmlStream ()->writeAttribute ("type", $link->type);
161
-            if (!is_null ($link->rel)) {
162
-                self::getXmlStream ()->writeAttribute ("rel", $link->rel);
157
+    private function renderLink($link) {
158
+        self::getXmlStream()->startElement("link");
159
+            self::getXmlStream()->writeAttribute("href", $link->href);
160
+            self::getXmlStream()->writeAttribute("type", $link->type);
161
+            if (!is_null($link->rel)) {
162
+                self::getXmlStream()->writeAttribute("rel", $link->rel);
163 163
             }
164
-            if (!is_null ($link->title)) {
165
-                self::getXmlStream ()->writeAttribute ("title", $link->title);
164
+            if (!is_null($link->title)) {
165
+                self::getXmlStream()->writeAttribute("title", $link->title);
166 166
             }
167
-            if (!is_null ($link->facetGroup)) {
168
-                self::getXmlStream ()->writeAttribute ("opds:facetGroup", $link->facetGroup);
167
+            if (!is_null($link->facetGroup)) {
168
+                self::getXmlStream()->writeAttribute("opds:facetGroup", $link->facetGroup);
169 169
             }
170 170
             if ($link->activeFacet) {
171
-                self::getXmlStream ()->writeAttribute ("opds:activeFacet", "true");
171
+                self::getXmlStream()->writeAttribute("opds:activeFacet", "true");
172 172
             }
173
-        self::getXmlStream ()->endElement ();
173
+        self::getXmlStream()->endElement();
174 174
     }
175 175
 
176 176
     private function getPublicationDate($book) {
177 177
         $dateYmd = substr($book->pubdate, 0, 10);
178 178
         $pubdate = \DateTime::createFromFormat('Y-m-d', $dateYmd);
179 179
         if ($pubdate === false ||
180
-            $pubdate->format ("Y") == "0101" ||
181
-            $pubdate->format ("Y") == "0100") {
180
+            $pubdate->format("Y") == "0101" ||
181
+            $pubdate->format("Y") == "0100") {
182 182
             return "";
183 183
         }
184 184
         return $pubdate->format("Y-m-d");
185 185
     }
186 186
 
187
-    private function renderEntry ($entry) {
188
-        self::getXmlStream ()->startElement ("title");
189
-            self::getXmlStream ()->text ($entry->title);
190
-        self::getXmlStream ()->endElement ();
191
-        self::getXmlStream ()->startElement ("updated");
192
-            self::getXmlStream ()->text (self::getUpdatedTime ());
193
-        self::getXmlStream ()->endElement ();
194
-        self::getXmlStream ()->startElement ("id");
195
-            self::getXmlStream ()->text ($entry->id);
196
-        self::getXmlStream ()->endElement ();
197
-        self::getXmlStream ()->startElement ("content");
198
-            self::getXmlStream ()->writeAttribute ("type", $entry->contentType);
187
+    private function renderEntry($entry) {
188
+        self::getXmlStream()->startElement("title");
189
+            self::getXmlStream()->text($entry->title);
190
+        self::getXmlStream()->endElement();
191
+        self::getXmlStream()->startElement("updated");
192
+            self::getXmlStream()->text(self::getUpdatedTime());
193
+        self::getXmlStream()->endElement();
194
+        self::getXmlStream()->startElement("id");
195
+            self::getXmlStream()->text($entry->id);
196
+        self::getXmlStream()->endElement();
197
+        self::getXmlStream()->startElement("content");
198
+            self::getXmlStream()->writeAttribute("type", $entry->contentType);
199 199
             if ($entry->contentType == "text") {
200
-                self::getXmlStream ()->text ($entry->content);
200
+                self::getXmlStream()->text($entry->content);
201 201
             } else {
202
-                self::getXmlStream ()->writeRaw ($entry->content);
202
+                self::getXmlStream()->writeRaw($entry->content);
203 203
             }
204
-        self::getXmlStream ()->endElement ();
204
+        self::getXmlStream()->endElement();
205 205
         foreach ($entry->linkArray as $link) {
206
-            self::renderLink ($link);
206
+            self::renderLink($link);
207 207
         }
208 208
 
209
-        if (get_class ($entry) != "EntryBook") {
209
+        if (get_class($entry) != "EntryBook") {
210 210
             return;
211 211
         }
212 212
 
213
-        foreach ($entry->book->getAuthors () as $author) {
214
-            self::getXmlStream ()->startElement ("author");
215
-                self::getXmlStream ()->startElement ("name");
216
-                    self::getXmlStream ()->text ($author->name);
217
-                self::getXmlStream ()->endElement ();
218
-                self::getXmlStream ()->startElement ("uri");
219
-                    self::getXmlStream ()->text ("feed.php" . $author->getUri ());
220
-                self::getXmlStream ()->endElement ();
221
-            self::getXmlStream ()->endElement ();
213
+        foreach ($entry->book->getAuthors() as $author) {
214
+            self::getXmlStream()->startElement("author");
215
+                self::getXmlStream()->startElement("name");
216
+                    self::getXmlStream()->text($author->name);
217
+                self::getXmlStream()->endElement();
218
+                self::getXmlStream()->startElement("uri");
219
+                    self::getXmlStream()->text("feed.php" . $author->getUri());
220
+                self::getXmlStream()->endElement();
221
+            self::getXmlStream()->endElement();
222 222
         }
223
-        foreach ($entry->book->getTags () as $category) {
224
-            self::getXmlStream ()->startElement ("category");
225
-                self::getXmlStream ()->writeAttribute ("term", $category->name);
226
-                self::getXmlStream ()->writeAttribute ("label", $category->name);
227
-            self::getXmlStream ()->endElement ();
223
+        foreach ($entry->book->getTags() as $category) {
224
+            self::getXmlStream()->startElement("category");
225
+                self::getXmlStream()->writeAttribute("term", $category->name);
226
+                self::getXmlStream()->writeAttribute("label", $category->name);
227
+            self::getXmlStream()->endElement();
228 228
         }
229
-        if ($entry->book->getPubDate () != "") {
230
-            self::getXmlStream ()->startElement ("dcterms:issued");
231
-                self::getXmlStream ()->text (self::getPublicationDate($entry->book));
232
-            self::getXmlStream ()->endElement ();
233
-            self::getXmlStream ()->startElement ("published");
234
-                self::getXmlStream ()->text (self::getPublicationDate($entry->book) . "T08:08:08Z");
235
-            self::getXmlStream ()->endElement ();
229
+        if ($entry->book->getPubDate() != "") {
230
+            self::getXmlStream()->startElement("dcterms:issued");
231
+                self::getXmlStream()->text(self::getPublicationDate($entry->book));
232
+            self::getXmlStream()->endElement();
233
+            self::getXmlStream()->startElement("published");
234
+                self::getXmlStream()->text(self::getPublicationDate($entry->book) . "T08:08:08Z");
235
+            self::getXmlStream()->endElement();
236 236
         }
237 237
 
238
-        $lang = $entry->book->getLanguages ();
238
+        $lang = $entry->book->getLanguages();
239 239
         if (!empty ($lang)) {
240
-            self::getXmlStream ()->startElement ("dcterms:language");
241
-                self::getXmlStream ()->text ($lang);
242
-            self::getXmlStream ()->endElement ();
240
+            self::getXmlStream()->startElement("dcterms:language");
241
+                self::getXmlStream()->text($lang);
242
+            self::getXmlStream()->endElement();
243 243
         }
244 244
 
245 245
     }
246 246
 
247
-    public function render ($page) {
247
+    public function render($page) {
248 248
         global $config;
249
-        self::startXmlDocument ($page);
250
-        if ($page->isPaginated ())
249
+        self::startXmlDocument($page);
250
+        if ($page->isPaginated())
251 251
         {
252
-            self::getXmlStream ()->startElement ("opensearch:totalResults");
253
-                self::getXmlStream ()->text ($page->totalNumber);
254
-            self::getXmlStream ()->endElement ();
255
-            self::getXmlStream ()->startElement ("opensearch:itemsPerPage");
256
-                self::getXmlStream ()->text ($config['cops_max_item_per_page']);
257
-            self::getXmlStream ()->endElement ();
258
-            self::getXmlStream ()->startElement ("opensearch:startIndex");
259
-                self::getXmlStream ()->text (($page->n - 1) * $config['cops_max_item_per_page'] + 1);
260
-            self::getXmlStream ()->endElement ();
261
-            $prevLink = $page->getPrevLink ();
262
-            $nextLink = $page->getNextLink ();
263
-            if (!is_null ($prevLink)) {
264
-                self::renderLink ($prevLink);
252
+            self::getXmlStream()->startElement("opensearch:totalResults");
253
+                self::getXmlStream()->text($page->totalNumber);
254
+            self::getXmlStream()->endElement();
255
+            self::getXmlStream()->startElement("opensearch:itemsPerPage");
256
+                self::getXmlStream()->text($config['cops_max_item_per_page']);
257
+            self::getXmlStream()->endElement();
258
+            self::getXmlStream()->startElement("opensearch:startIndex");
259
+                self::getXmlStream()->text(($page->n - 1) * $config['cops_max_item_per_page'] + 1);
260
+            self::getXmlStream()->endElement();
261
+            $prevLink = $page->getPrevLink();
262
+            $nextLink = $page->getNextLink();
263
+            if (!is_null($prevLink)) {
264
+                self::renderLink($prevLink);
265 265
             }
266
-            if (!is_null ($nextLink)) {
267
-                self::renderLink ($nextLink);
266
+            if (!is_null($nextLink)) {
267
+                self::renderLink($nextLink);
268 268
             }
269 269
         }
270 270
         foreach ($page->entryArray as $entry) {
271
-            self::getXmlStream ()->startElement ("entry");
272
-                self::renderEntry ($entry);
273
-            self::getXmlStream ()->endElement ();
271
+            self::getXmlStream()->startElement("entry");
272
+                self::renderEntry($entry);
273
+            self::getXmlStream()->endElement();
274 274
         }
275
-        return self::endXmlDocument ();
275
+        return self::endXmlDocument();
276 276
     }
277 277
 }
278 278
 
Please login to merge, or discard this patch.
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,14 +13,16 @@  discard block
 block discarded – undo
13 13
     private $xmlStream = NULL;
14 14
     private $updated = NULL;
15 15
 
16
-    private function getUpdatedTime () {
16
+    private function getUpdatedTime ()
17
+    {
17 18
         if (is_null ($this->updated)) {
18 19
             $this->updated = time();
19 20
         }
20 21
         return date (DATE_ATOM, $this->updated);
21 22
     }
22 23
 
23
-    private function getXmlStream () {
24
+    private function getXmlStream ()
25
+    {
24 26
         if (is_null ($this->xmlStream)) {
25 27
             $this->xmlStream = new XMLWriter();
26 28
             $this->xmlStream->openMemory();
@@ -29,7 +31,8 @@  discard block
 block discarded – undo
29 31
         return $this->xmlStream;
30 32
     }
31 33
 
32
-    public function getOpenSearch () {
34
+    public function getOpenSearch ()
35
+    {
33 36
         global $config;
34 37
         $xml = new XMLWriter ();
35 38
         $xml->openMemory ();
@@ -58,7 +61,9 @@  discard block
 block discarded – undo
58 61
                 $xml->startElement ("Url");
59 62
                     $xml->writeAttribute ("type", 'application/atom+xml');
60 63
                     $urlparam = "?query={searchTerms}";
61
-                    if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
64
+                    if (!is_null (GetUrlParam (DB))) {
65
+                        $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
66
+                    }
62 67
                     $urlparam = str_replace ("%7B", "{", $urlparam);
63 68
                     $urlparam = str_replace ("%7D", "}", $urlparam);
64 69
                     $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam);
@@ -72,7 +77,8 @@  discard block
 block discarded – undo
72 77
         return $xml->outputMemory(true);
73 78
     }
74 79
 
75
-    private function startXmlDocument ($page) {
80
+    private function startXmlDocument ($page)
81
+    {
76 82
         global $config;
77 83
         self::getXmlStream ()->startDocument('1.0','UTF-8');
78 84
         self::getXmlStream ()->startElement ("feed");
@@ -84,21 +90,19 @@  discard block
 block discarded – undo
84 90
             self::getXmlStream ()->startElement ("title");
85 91
                 self::getXmlStream ()->text ($page->title);
86 92
             self::getXmlStream ()->endElement ();
87
-            if ($page->subtitle != "")
88
-            {
93
+            if ($page->subtitle != "") {
89 94
                 self::getXmlStream ()->startElement ("subtitle");
90 95
                     self::getXmlStream ()->text ($page->subtitle);
91 96
                 self::getXmlStream ()->endElement ();
92 97
             }
93 98
             self::getXmlStream ()->startElement ("id");
94
-                if ($page->idPage)
95
-                {
99
+                if ($page->idPage) {
96 100
                     $idPage = $page->idPage;
97
-                    if (!is_null (GetUrlParam (DB))) $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage);
101
+                    if (!is_null (GetUrlParam (DB))) {
102
+                        $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage);
103
+                    }
98 104
                     self::getXmlStream ()->text ($idPage);
99
-                }
100
-                else
101
-                {
105
+                } else {
102 106
                     self::getXmlStream ()->text ($_SERVER['REQUEST_URI']);
103 107
                 }
104 108
             self::getXmlStream ()->endElement ();
@@ -124,14 +128,14 @@  discard block
 block discarded – undo
124 128
             $link = new LinkNavigation ("?" . getQueryString (), "self");
125 129
             self::renderLink ($link);
126 130
             $urlparam = "?";
127
-            if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
131
+            if (!is_null (GetUrlParam (DB))) {
132
+                $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
133
+            }
128 134
             if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) {
129 135
                 // Good and compliant way of handling search
130 136
                 $urlparam = addURLParameter ($urlparam, "page", Base::PAGE_OPENSEARCH);
131 137
                 $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here");
132
-            }
133
-            else
134
-            {
138
+            } else {
135 139
                 // Bad way, will be removed when OPDS client are fixed
136 140
                 $urlparam = addURLParameter ($urlparam, "query", "{searchTerms}");
137 141
                 $urlparam = str_replace ("%7B", "{", $urlparam);
@@ -148,13 +152,15 @@  discard block
 block discarded – undo
148 152
             }
149 153
     }
150 154
 
151
-    private function endXmlDocument () {
155
+    private function endXmlDocument ()
156
+    {
152 157
         self::getXmlStream ()->endElement ();
153 158
         self::getXmlStream ()->endDocument ();
154 159
         return self::getXmlStream ()->outputMemory(true);
155 160
     }
156 161
 
157
-    private function renderLink ($link) {
162
+    private function renderLink ($link)
163
+    {
158 164
         self::getXmlStream ()->startElement ("link");
159 165
             self::getXmlStream ()->writeAttribute ("href", $link->href);
160 166
             self::getXmlStream ()->writeAttribute ("type", $link->type);
@@ -173,7 +179,8 @@  discard block
 block discarded – undo
173 179
         self::getXmlStream ()->endElement ();
174 180
     }
175 181
 
176
-    private function getPublicationDate($book) {
182
+    private function getPublicationDate($book)
183
+    {
177 184
         $dateYmd = substr($book->pubdate, 0, 10);
178 185
         $pubdate = \DateTime::createFromFormat('Y-m-d', $dateYmd);
179 186
         if ($pubdate === false ||
@@ -184,7 +191,8 @@  discard block
 block discarded – undo
184 191
         return $pubdate->format("Y-m-d");
185 192
     }
186 193
 
187
-    private function renderEntry ($entry) {
194
+    private function renderEntry ($entry)
195
+    {
188 196
         self::getXmlStream ()->startElement ("title");
189 197
             self::getXmlStream ()->text ($entry->title);
190 198
         self::getXmlStream ()->endElement ();
@@ -244,11 +252,11 @@  discard block
 block discarded – undo
244 252
 
245 253
     }
246 254
 
247
-    public function render ($page) {
255
+    public function render ($page)
256
+    {
248 257
         global $config;
249 258
         self::startXmlDocument ($page);
250
-        if ($page->isPaginated ())
251
-        {
259
+        if ($page->isPaginated ()) {
252 260
             self::getXmlStream ()->startElement ("opensearch:totalResults");
253 261
                 self::getXmlStream ()->text ($page->totalNumber);
254 262
             self::getXmlStream ()->endElement ();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
 
11 11
 class OPDSRenderer
12 12
 {
13
-    private $xmlStream = NULL;
14
-    private $updated = NULL;
13
+    private $xmlStream = null;
14
+    private $updated = null;
15 15
 
16 16
     private function getUpdatedTime () {
17 17
         if (is_null ($this->updated)) {
Please login to merge, or discard this patch.
lib/PageRatingDetail.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
8 8
 
9 9
 class PageRatingDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $rating = Rating::getRatingById ($this->idGet);
14
-        $this->idPage = $rating->getEntryId ();
15
-        $this->title =str_format (localize ("ratingword", $rating->name/2), $rating->name/2);
16
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating ($this->idGet, $this->n);
13
+        $rating = Rating::getRatingById($this->idGet);
14
+        $this->idPage = $rating->getEntryId();
15
+        $this->title = str_format(localize("ratingword", $rating->name / 2), $rating->name / 2);
16
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating($this->idGet, $this->n);
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
lib/PageAuthorDetail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
8 8
 
9 9
 class PageAuthorDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $author = Author::getAuthorById ($this->idGet);
14
-        $this->idPage = $author->getEntryId ();
13
+        $author = Author::getAuthorById($this->idGet);
14
+        $this->idPage = $author->getEntryId();
15 15
         $this->title = $author->name;
16
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByAuthor ($this->idGet, $this->n);
16
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByAuthor($this->idGet, $this->n);
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
lib/Data.php 4 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) {
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 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,82 +86,82 @@  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) {
111
+    public function getDataLink($rel, $title = NULL) {
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);
116 116
         }
117 117
 
118
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
118
+        return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title);
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 getLocalPath () {
126
-        return $this->book->path . "/" . $this->getFilename ();
125
+    public function getLocalPath() {
126
+        return $this->book->path . "/" . $this->getFilename();
127 127
     }
128 128
 
129
-    public function getHtmlLinkWithRewriting ($title = NULL) {
129
+    public function getHtmlLinkWithRewriting($title = NULL) {
130 130
         global $config;
131 131
 
132 132
         $database = "";
133
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
133
+        if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/";
134 134
 
135 135
         $href = "download/" . $this->id . "/" . $database;
136 136
 
137 137
         if ($config['cops_provide_kepub'] == "1" &&
138
-            $this->isEpubValidOnKobo () &&
138
+            $this->isEpubValidOnKobo() &&
139 139
             preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
140
-            $href .= rawurlencode ($this->getUpdatedFilenameKepub ());
140
+            $href .= rawurlencode($this->getUpdatedFilenameKepub());
141 141
         } else {
142
-            $href .= rawurlencode ($this->getFilename ());
142
+            $href .= rawurlencode($this->getFilename());
143 143
         }
144
-        return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
144
+        return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title);
145 145
     }
146 146
 
147
-    public static function getDataByBook ($book) {
148
-        $out = array ();
149
-        $result = parent::getDb ()->prepare('select id, format, name
147
+    public static function getDataByBook($book) {
148
+        $out = array();
149
+        $result = parent::getDb()->prepare('select id, format, name
150 150
                                              from data where book = ?');
151
-        $result->execute (array ($book->id));
151
+        $result->execute(array($book->id));
152 152
 
153
-        while ($post = $result->fetchObject ())
153
+        while ($post = $result->fetchObject())
154 154
         {
155
-            array_push ($out, new Data ($post, $book));
155
+            array_push($out, new Data($post, $book));
156 156
         }
157 157
         return $out;
158 158
     }
159 159
 
160
-    public static function handleThumbnailLink ($urlParam, $height) {
160
+    public static function handleThumbnailLink($urlParam, $height) {
161 161
         global $config;
162 162
 
163
-        if (is_null ($height)) {
164
-            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
163
+        if (is_null($height)) {
164
+            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
165 165
                 $height = $config['cops_opds_thumbnail_height'];
166 166
             }
167 167
             else
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
         return $urlParam;
177 177
     }
178 178
 
179
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
179
+    public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
180 180
     {
181 181
         global $config;
182 182
 
183 183
         $urlParam = addURLParameter("", "data", $idData);
184 184
 
185
-        if (Base::useAbsolutePath () ||
185
+        if (Base::useAbsolutePath() ||
186 186
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
187 187
             ($type == "epub" && $config['cops_update_epub-metadata']))
188 188
         {
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
192 192
             }
193 193
             $urlParam = addURLParameter($urlParam, "id", $book->id);
194
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
194
+            if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
195 195
             if ($config['cops_thumbnail_handling'] != "1" &&
196 196
                 !empty ($config['cops_thumbnail_handling']) &&
197 197
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
198
-                return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title);
198
+                return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title);
199 199
             } else {
200
-                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
200
+                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title);
201 201
             }
202 202
         }
203 203
         else
204 204
         {
205
-            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
205
+            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title);
206 206
         }
207 207
     }
208 208
 }
Please login to merge, or discard this patch.
Braces   +42 added lines, -29 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) {
118
+    public function getDataLink ($rel, $title = NULL)
119
+    {
112 120
         global $config;
113 121
 
114 122
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -118,19 +126,24 @@  discard block
 block discarded – undo
118 126
         return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
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 getLocalPath () {
134
+    public function getLocalPath ()
135
+    {
126 136
         return $this->book->path . "/" . $this->getFilename ();
127 137
     }
128 138
 
129
-    public function getHtmlLinkWithRewriting ($title = NULL) {
139
+    public function getHtmlLinkWithRewriting ($title = NULL)
140
+    {
130 141
         global $config;
131 142
 
132 143
         $database = "";
133
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
144
+        if (!is_null (GetUrlParam (DB))) {
145
+            $database = GetUrlParam (DB) . "/";
146
+        }
134 147
 
135 148
         $href = "download/" . $this->id . "/" . $database;
136 149
 
@@ -144,28 +157,27 @@  discard block
 block discarded – undo
144 157
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
145 158
     }
146 159
 
147
-    public static function getDataByBook ($book) {
160
+    public static function getDataByBook ($book)
161
+    {
148 162
         $out = array ();
149 163
         $result = parent::getDb ()->prepare('select id, format, name
150 164
                                              from data where book = ?');
151 165
         $result->execute (array ($book->id));
152 166
 
153
-        while ($post = $result->fetchObject ())
154
-        {
167
+        while ($post = $result->fetchObject ()) {
155 168
             array_push ($out, new Data ($post, $book));
156 169
         }
157 170
         return $out;
158 171
     }
159 172
 
160
-    public static function handleThumbnailLink ($urlParam, $height) {
173
+    public static function handleThumbnailLink ($urlParam, $height)
174
+    {
161 175
         global $config;
162 176
 
163 177
         if (is_null ($height)) {
164 178
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
165 179
                 $height = $config['cops_opds_thumbnail_height'];
166
-            }
167
-            else
168
-            {
180
+            } else {
169 181
                 $height = $config['cops_html_thumbnail_height'];
170 182
             }
171 183
         }
@@ -184,14 +196,17 @@  discard block
 block discarded – undo
184 196
 
185 197
         if (Base::useAbsolutePath () ||
186 198
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
187
-            ($type == "epub" && $config['cops_update_epub-metadata']))
188
-        {
189
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
199
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
200
+            if ($type != "jpg") {
201
+                $urlParam = addURLParameter($urlParam, "type", $type);
202
+            }
190 203
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
191 204
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
192 205
             }
193 206
             $urlParam = addURLParameter($urlParam, "id", $book->id);
194
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
207
+            if (!is_null (GetUrlParam (DB))) {
208
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
209
+            }
195 210
             if ($config['cops_thumbnail_handling'] != "1" &&
196 211
                 !empty ($config['cops_thumbnail_handling']) &&
197 212
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -199,9 +214,7 @@  discard block
 block discarded – undo
199 214
             } else {
200 215
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
201 216
             }
202
-        }
203
-        else
204
-        {
217
+        } else {
205 218
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
206 219
         }
207 220
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                            array('-', '-', ' '), $str );
109 109
     }
110 110
 
111
-    public function getDataLink ($rel, $title = NULL) {
111
+    public function getDataLink ($rel, $title = null) {
112 112
         global $config;
113 113
 
114 114
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         return $this->book->path . "/" . $this->getFilename ();
127 127
     }
128 128
 
129
-    public function getHtmlLinkWithRewriting ($title = NULL) {
129
+    public function getHtmlLinkWithRewriting ($title = null) {
130 130
         global $config;
131 131
 
132 132
         $database = "";
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         return $urlParam;
177 177
     }
178 178
 
179
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL)
179
+    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = null, $height = null)
180 180
     {
181 181
         global $config;
182 182
 
Please login to merge, or discard this patch.
lib/PageSerieDetail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
8 8
 
9 9
 class PageSerieDetail extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        $serie = Serie::getSerieById ($this->idGet);
13
+        $serie = Serie::getSerieById($this->idGet);
14 14
         $this->title = $serie->name;
15
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries ($this->idGet, $this->n);
16
-        $this->idPage = $serie->getEntryId ();
15
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries($this->idGet, $this->n);
16
+        $this->idPage = $serie->getEntryId();
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
lib/Tag.php 3 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,44 +20,44 @@
 block discarded – undo
20 20
         $this->name = $post->name;
21 21
     }
22 22
 
23
-    public function getUri () {
24
-        return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
23
+    public function getUri() {
24
+        return "?page=" . parent::PAGE_TAG_DETAIL . "&id=$this->id";
25 25
     }
26 26
 
27
-    public function getEntryId () {
28
-        return self::ALL_TAGS_ID.":".$this->id;
27
+    public function getEntryId() {
28
+        return self::ALL_TAGS_ID . ":" . $this->id;
29 29
     }
30 30
 
31 31
     public static function getCount() {
32 32
         // str_format (localize("tags.alphabetical", count(array))
33
-        return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
33
+        return parent::getCountGeneric("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 34
     }
35 35
 
36
-    public static function getTagById ($tagId) {
37
-        $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38
-        $result->execute (array ($tagId));
39
-        if ($post = $result->fetchObject ()) {
40
-            return new Tag ($post);
36
+    public static function getTagById($tagId) {
37
+        $result = parent::getDb()->prepare('select id, name  from tags where id = ?');
38
+        $result->execute(array($tagId));
39
+        if ($post = $result->fetchObject()) {
40
+            return new Tag($post);
41 41
         }
42 42
         return NULL;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46
-        return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
46
+        return Base::getEntryArrayWithBookNumber(self::SQL_ALL_TAGS, self::TAG_COLUMNS, array(), "Tag");
47 47
     }
48 48
 
49 49
     public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
50
-        $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
50
+        $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 51
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52
-        list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
52
+        list ($totalNumber, $result) = parent::executeQuery($sql, $columns, "", array('%' . $query . '%'), $n, $database, $numberPerPage);
53 53
         $entryArray = array();
54
-        while ($post = $result->fetchObject ())
54
+        while ($post = $result->fetchObject())
55 55
         {
56
-            $tag = new Tag ($post);
57
-            array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
58
-                str_format (localize("bookword", $post->count), $post->count), "text",
59
-                array ( new LinkNavigation ($tag->getUri ()))));
56
+            $tag = new Tag($post);
57
+            array_push($entryArray, new Entry($tag->name, $tag->getEntryId(),
58
+                str_format(localize("bookword", $post->count), $post->count), "text",
59
+                array(new LinkNavigation($tag->getUri()))));
60 60
         }
61
-        return array ($entryArray, $totalNumber);
61
+        return array($entryArray, $totalNumber);
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,25 +15,30 @@  discard block
 block discarded – undo
15 15
     public $id;
16 16
     public $name;
17 17
 
18
-    public function __construct($post) {
18
+    public function __construct($post)
19
+    {
19 20
         $this->id = $post->id;
20 21
         $this->name = $post->name;
21 22
     }
22 23
 
23
-    public function getUri () {
24
+    public function getUri ()
25
+    {
24 26
         return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
25 27
     }
26 28
 
27
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
28 31
         return self::ALL_TAGS_ID.":".$this->id;
29 32
     }
30 33
 
31
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
32 36
         // str_format (localize("tags.alphabetical", count(array))
33 37
         return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 38
     }
35 39
 
36
-    public static function getTagById ($tagId) {
40
+    public static function getTagById ($tagId)
41
+    {
37 42
         $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38 43
         $result->execute (array ($tagId));
39 44
         if ($post = $result->fetchObject ()) {
@@ -42,17 +47,18 @@  discard block
 block discarded – undo
42 47
         return NULL;
43 48
     }
44 49
 
45
-    public static function getAllTags() {
50
+    public static function getAllTags()
51
+    {
46 52
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
47 53
     }
48 54
 
49
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
55
+    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
56
+    {
50 57
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 58
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52 59
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
53 60
         $entryArray = array();
54
-        while ($post = $result->fetchObject ())
55
-        {
61
+        while ($post = $result->fetchObject ()) {
56 62
             $tag = new Tag ($post);
57 63
             array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
58 64
                 str_format (localize("bookword", $post->count), $post->count), "text",
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@
 block discarded – undo
39 39
         if ($post = $result->fetchObject ()) {
40 40
             return new Tag ($post);
41 41
         }
42
-        return NULL;
42
+        return null;
43 43
     }
44 44
 
45 45
     public static function getAllTags() {
46 46
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
47 47
     }
48 48
 
49
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
49
+    public static function getAllTagsByQuery($query, $n, $database = null, $numberPerPage = null) {
50 50
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 51
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52 52
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
Please login to merge, or discard this patch.
lib/CustomColumnTypeBool.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
     // PHP pre 5.6 does not support const arrays
12 12
     private $BOOLEAN_NAMES = array(
13 13
         -1 => "customcolumn.boolean.unknown", // localize("customcolumn.boolean.unknown")
14
-        00 => "customcolumn.boolean.no",      // localize("customcolumn.boolean.no")
15
-        +1 => "customcolumn.boolean.yes",     // localize("customcolumn.boolean.yes")
14
+        00 => "customcolumn.boolean.no", // localize("customcolumn.boolean.no")
15
+        +1 => "customcolumn.boolean.yes", // localize("customcolumn.boolean.yes")
16 16
     );
17 17
 
18 18
     protected function __construct($pcustomId)
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $entryArray = array();
61 61
         while ($post = $result->fetchObject()) {
62 62
             $entryPContent = str_format(localize("bookword", $post->count), $post->count);
63
-            $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id)));
63
+            $entryPLinkArray = array(new LinkNavigation($this->getUri($post->id)));
64 64
 
65 65
             $entry = new Entry(localize($this->BOOLEAN_NAMES[$post->id]), $this->getEntryId($post->id), $entryPContent, $this->datatype, $entryPLinkArray, "", $post->count);
66 66
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
             $query = str_format(Book::SQL_BOOKS_BY_CUSTOM_BOOL_TRUE, "{0}", "{1}", $this->getTableName());
43 43
             return array($query, array());
44 44
         } else {
45
-            return NULL;
45
+            return null;
46 46
         }
47 47
     }
48 48
 
Please login to merge, or discard this patch.