@@ -13,266 +13,266 @@ |
||
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 |
@@ -13,14 +13,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 (); |
@@ -10,8 +10,8 @@ |
||
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)) { |
@@ -8,11 +8,11 @@ |
||
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 | } |
@@ -8,11 +8,11 @@ |
||
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 | } |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | $nBooks = parent::executeQuerySingle('select count(*) from books'); |
474 | 474 | $result = array(); |
475 | 475 | $entry = new Entry(localize('allbooks.title'), |
476 | - self::ALL_BOOKS_ID, |
|
477 | - str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', |
|
478 | - array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
476 | + self::ALL_BOOKS_ID, |
|
477 | + str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', |
|
478 | + array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
479 | 479 | array_push($result, $entry); |
480 | 480 | if ($config['cops_recentbooks_limit'] > 0) { |
481 | 481 | $entry = new Entry(localize('recent.title'), |
482 | - self::ALL_RECENT_BOOKS_ID, |
|
483 | - str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', |
|
484 | - array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
482 | + self::ALL_RECENT_BOOKS_ID, |
|
483 | + str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', |
|
484 | + array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
485 | 485 | array_push($result, $entry); |
486 | 486 | } |
487 | 487 | return $result; |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | $i = 0; |
557 | 557 | $critArray = array(); |
558 | 558 | foreach (array(PageQueryResult::SCOPE_AUTHOR, |
559 | - PageQueryResult::SCOPE_TAG, |
|
560 | - PageQueryResult::SCOPE_SERIES, |
|
561 | - PageQueryResult::SCOPE_PUBLISHER, |
|
562 | - PageQueryResult::SCOPE_BOOK) as $key) { |
|
559 | + PageQueryResult::SCOPE_TAG, |
|
560 | + PageQueryResult::SCOPE_SERIES, |
|
561 | + PageQueryResult::SCOPE_PUBLISHER, |
|
562 | + PageQueryResult::SCOPE_BOOK) as $key) { |
|
563 | 563 | if (in_array($key, getCurrentOption('ignored_categories')) || |
564 | 564 | (!array_key_exists($key, $query) && !array_key_exists('all', $query))) { |
565 | 565 | $critArray[$i] = self::BAD_SEARCH; |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | public $seriesIndex; |
100 | 100 | public $comment; |
101 | 101 | public $rating; |
102 | - public $datas = NULL; |
|
103 | - public $authors = NULL; |
|
104 | - public $publisher = NULL; |
|
105 | - public $serie = NULL; |
|
106 | - public $tags = NULL; |
|
107 | - public $languages = NULL; |
|
102 | + public $datas = null; |
|
103 | + public $authors = null; |
|
104 | + public $publisher = null; |
|
105 | + public $serie = null; |
|
106 | + public $tags = null; |
|
107 | + public $languages = null; |
|
108 | 108 | public $format = array (); |
109 | 109 | |
110 | 110 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | /* End of other class (author, series, tag, ...) initialization and accessors */ |
243 | 243 | |
244 | 244 | public static function getFilterString() { |
245 | - $filter = getURLParam('tag', NULL); |
|
245 | + $filter = getURLParam('tag', null); |
|
246 | 246 | if (empty($filter)) return ''; |
247 | 247 | |
248 | 248 | $exists = true; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | { |
265 | 265 | $bestFormatForKindle = array('EPUB', 'PDF', 'AZW3', 'MOBI'); |
266 | 266 | $bestRank = -1; |
267 | - $bestData = NULL; |
|
267 | + $bestData = null; |
|
268 | 268 | foreach ($this->getDatas() as $data) { |
269 | 269 | $key = array_search($data->format, $bestFormatForKindle); |
270 | 270 | if ($key !== false && $key > $bestRank) { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | return reset($reduced); |
332 | 332 | } |
333 | 333 | |
334 | - public function getFilePath($extension, $idData = NULL, $relative = false) |
|
334 | + public function getFilePath($extension, $idData = null, $relative = false) |
|
335 | 335 | { |
336 | 336 | if ($extension == 'jpg') |
337 | 337 | { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | else |
341 | 341 | { |
342 | 342 | $data = $this->getDataById($idData); |
343 | - if (!$data) return NULL; |
|
343 | + if (!$data) return null; |
|
344 | 344 | $file = $data->name . '.' . strtolower($data->format); |
345 | 345 | } |
346 | 346 | |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - public function getThumbnail($width, $height, $outputfile = NULL) { |
|
393 | + public function getThumbnail($width, $height, $outputfile = null) { |
|
394 | 394 | if (is_null($width) && is_null($height)) { |
395 | 395 | return false; |
396 | 396 | } |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | |
432 | 432 | if ($this->hasCover) |
433 | 433 | { |
434 | - array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
|
434 | + array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', null)); |
|
435 | 435 | |
436 | - array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); |
|
436 | + array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', null)); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | foreach ($this->getDatas() as $data) |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $this->getLinkArray(), $this); |
465 | 465 | } |
466 | 466 | |
467 | - public static function getBookCount($database = NULL) { |
|
467 | + public static function getBookCount($database = null) { |
|
468 | 468 | return parent::executeQuerySingle('select count(*) from books', $database); |
469 | 469 | } |
470 | 470 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $book = new Book($post); |
534 | 534 | return $book; |
535 | 535 | } |
536 | - return NULL; |
|
536 | + return null; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | public static function getBookByDataId($dataId) { |
@@ -549,10 +549,10 @@ discard block |
||
549 | 549 | $book->datas = array($data); |
550 | 550 | return $book; |
551 | 551 | } |
552 | - return NULL; |
|
552 | + return null; |
|
553 | 553 | } |
554 | 554 | |
555 | - public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
|
555 | + public static function getBooksByQuery($query, $n, $database = null, $numberPerPage = null) { |
|
556 | 556 | $i = 0; |
557 | 557 | $critArray = array(); |
558 | 558 | foreach (array(PageQueryResult::SCOPE_AUTHOR, |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | return $entryArray; |
600 | 600 | } |
601 | 601 | |
602 | - public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { |
|
602 | + public static function getBooksByStartingLetter($letter, $n, $database = null, $numberPerPage = null) { |
|
603 | 603 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); |
604 | 604 | } |
605 | 605 | |
606 | - public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
606 | + public static function getEntryArray($query, $params, $n, $database = null, $numberPerPage = null) { |
|
607 | 607 | /* @var $totalNumber integer */ |
608 | 608 | /* @var $result PDOStatement */ |
609 | 609 | list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage); |
@@ -7,55 +7,55 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Silly thing because PHP forbid string concatenation in class const |
10 | -define ('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id |
|
10 | +define('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id |
|
11 | 11 | left outer join books_ratings_link on books_ratings_link.book = books.id |
12 | 12 | left outer join ratings on books_ratings_link.rating = ratings.id '); |
13 | -define ('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort '); |
|
14 | -define ('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
13 | +define('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort '); |
|
14 | +define('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
15 | 15 | where books_publishers_link.book = books.id and publisher = ? {1} order by publisher'); |
16 | -define ('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
16 | +define('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
17 | 17 | where upper (books.sort) like ? order by books.sort'); |
18 | -define ('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
18 | +define('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
19 | 19 | left outer join books_series_link on books_series_link.book = books.id |
20 | 20 | where books_authors_link.book = books.id and author = ? {1} order by series desc, series_index asc, pubdate asc'); |
21 | -define ('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
21 | +define('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
22 | 22 | where books_series_link.book = books.id and series = ? {1} order by series_index'); |
23 | -define ('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
23 | +define('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
24 | 24 | where books_tags_link.book = books.id and tag = ? {1} order by sort'); |
25 | -define ('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
25 | +define('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
26 | 26 | where books_languages_link.book = books.id and lang_code = ? {1} order by sort'); |
27 | -define ('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
27 | +define('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
28 | 28 | where {2}.book = books.id and {2}.{3} = ? {1} order by sort'); |
29 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
29 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
30 | 30 | where {2}.book = books.id and {2}.value = 1 {1} order by sort'); |
31 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
31 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
32 | 32 | where {2}.book = books.id and {2}.value = 0 {1} order by sort'); |
33 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
33 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
34 | 34 | where books.id not in (select book from {2}) {1} order by sort'); |
35 | -define ('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
35 | +define('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
36 | 36 | left join {2} on {2}.book = books.id |
37 | 37 | left join {3} on {3}.id = {2}.{4} |
38 | 38 | where {3}.value = ? order by sort'); |
39 | -define ('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
39 | +define('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
40 | 40 | left join {2} on {2}.book = books.id |
41 | 41 | left join {3} on {3}.id = {2}.{4} |
42 | 42 | where ((books.id not in (select {2}.book from {2})) or ({3}.value = 0)) {1} order by sort'); |
43 | -define ('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
43 | +define('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
44 | 44 | where {2}.book = books.id and date({2}.value) = ? {1} order by sort'); |
45 | -define ('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
45 | +define('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
46 | 46 | where {2}.book = books.id and {2}.value = ? {1} order by sort'); |
47 | -define ('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
47 | +define('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
48 | 48 | where {2}.book = books.id and {2}.id = ? {1} order by sort'); |
49 | -define ('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
49 | +define('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
50 | 50 | where ( |
51 | 51 | exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or |
52 | 52 | exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or |
53 | 53 | exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or |
54 | 54 | exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or |
55 | 55 | title like ?) {1} order by books.sort'); |
56 | -define ('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
56 | +define('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
57 | 57 | where 1=1 {1} order by timestamp desc limit '); |
58 | -define ('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
58 | +define('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
59 | 59 | where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort'); |
60 | 60 | |
61 | 61 | class Book extends Base |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | public $serie = NULL; |
106 | 106 | public $tags = NULL; |
107 | 107 | public $languages = NULL; |
108 | - public $format = array (); |
|
108 | + public $format = array(); |
|
109 | 109 | |
110 | 110 | |
111 | 111 | public function __construct($line) { |
@@ -127,24 +127,24 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | public function getEntryId() { |
130 | - return self::ALL_BOOKS_UUID.':'.$this->uuid; |
|
130 | + return self::ALL_BOOKS_UUID . ':' . $this->uuid; |
|
131 | 131 | } |
132 | 132 | |
133 | - public static function getEntryIdByLetter ($startingLetter) { |
|
134 | - return self::ALL_BOOKS_ID.':letter:'.$startingLetter; |
|
133 | + public static function getEntryIdByLetter($startingLetter) { |
|
134 | + return self::ALL_BOOKS_ID . ':letter:' . $startingLetter; |
|
135 | 135 | } |
136 | 136 | |
137 | - public function getUri () { |
|
138 | - return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id; |
|
137 | + public function getUri() { |
|
138 | + return '?page=' . parent::PAGE_BOOK_DETAIL . '&id=' . $this->id; |
|
139 | 139 | } |
140 | 140 | |
141 | - public function getDetailUrl () { |
|
141 | + public function getDetailUrl() { |
|
142 | 142 | $urlParam = $this->getUri(); |
143 | - if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); |
|
143 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
144 | 144 | return 'index.php' . $urlParam; |
145 | 145 | } |
146 | 146 | |
147 | - public function getTitle () { |
|
147 | + public function getTitle() { |
|
148 | 148 | return $this->title; |
149 | 149 | } |
150 | 150 | |
@@ -153,22 +153,22 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * @return Author[] |
155 | 155 | */ |
156 | - public function getAuthors () { |
|
156 | + public function getAuthors() { |
|
157 | 157 | if (is_null($this->authors)) { |
158 | 158 | $this->authors = Author::getAuthorByBookId($this->id); |
159 | 159 | } |
160 | 160 | return $this->authors; |
161 | 161 | } |
162 | 162 | |
163 | - public function getAuthorsName () { |
|
164 | - return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors())); |
|
163 | + public function getAuthorsName() { |
|
164 | + return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors())); |
|
165 | 165 | } |
166 | 166 | |
167 | - public function getAuthorsSort () { |
|
168 | - return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors())); |
|
167 | + public function getAuthorsSort() { |
|
168 | + return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors())); |
|
169 | 169 | } |
170 | 170 | |
171 | - public function getPublisher () { |
|
171 | + public function getPublisher() { |
|
172 | 172 | if (is_null($this->publisher)) { |
173 | 173 | $this->publisher = Publisher::getPublisherByBookId($this->id); |
174 | 174 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return Tag[] |
208 | 208 | */ |
209 | 209 | public function getTags() { |
210 | - if (is_null ($this->tags)) { |
|
210 | + if (is_null($this->tags)) { |
|
211 | 211 | $this->tags = array(); |
212 | 212 | |
213 | 213 | $result = parent::getDb()->prepare('select tags.id as id, name |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | |
227 | 227 | public function getTagsName() { |
228 | - return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags())); |
|
228 | + return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags())); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | |
278 | 278 | public function getDataById($idData) |
279 | 279 | { |
280 | - $reduced = array_filter($this->getDatas(), function ($data) use ($idData) { |
|
280 | + $reduced = array_filter($this->getDatas(), function($data) use ($idData) { |
|
281 | 281 | return $data->id == $idData; |
282 | 282 | }); |
283 | 283 | return reset($reduced); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | if (empty ($this->pubdate)) { |
302 | 302 | return ''; |
303 | 303 | } |
304 | - $dateY = (int) substr($this->pubdate, 0, 4); |
|
304 | + $dateY = (int)substr($this->pubdate, 0, 4); |
|
305 | 305 | if ($dateY > 102) { |
306 | 306 | return str_pad($dateY, 4, '0', STR_PAD_LEFT); |
307 | 307 | } |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | |
311 | 311 | public function getComment($withSerie = true) { |
312 | 312 | $addition = ''; |
313 | - $se = $this->getSerie (); |
|
314 | - if (!is_null ($se) && $withSerie) { |
|
313 | + $se = $this->getSerie(); |
|
314 | + if (!is_null($se) && $withSerie) { |
|
315 | 315 | $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; |
316 | 316 | } |
317 | 317 | if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | public function getDataFormat($format) { |
328 | - $reduced = array_filter($this->getDatas(), function ($data) use ($format) { |
|
328 | + $reduced = array_filter($this->getDatas(), function($data) use ($format) { |
|
329 | 329 | return $data->format == $format; |
330 | 330 | }); |
331 | 331 | return reset($reduced); |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | |
347 | 347 | if ($relative) |
348 | 348 | { |
349 | - return $this->relativePath.'/'.$file; |
|
349 | + return $this->relativePath . '/' . $file; |
|
350 | 350 | } |
351 | 351 | else |
352 | 352 | { |
353 | - return $this->path.'/'.$file; |
|
353 | + return $this->path . '/' . $file; |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | $epub->Authors($authorArray); |
372 | 372 | $epub->Language($this->getLanguages()); |
373 | - $epub->Description ($this->getComment(false)); |
|
373 | + $epub->Description($this->getComment(false)); |
|
374 | 374 | $epub->Subjects($this->getTagsName()); |
375 | 375 | $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg'); |
376 | 376 | $epub->Calibre($this->uuid); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $epub->SerieIndex($this->seriesIndex); |
381 | 381 | } |
382 | 382 | $filename = $data->getUpdatedFilenameEpub(); |
383 | - if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) { |
|
383 | + if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) { |
|
384 | 384 | $epub->updateForKepub(); |
385 | 385 | $filename = $data->getUpdatedFilenameKepub(); |
386 | 386 | } |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | if (!is_null($width)) { |
407 | 407 | $nw = $width; |
408 | 408 | if ($nw >= $w) { return false; } |
409 | - $nh = ($nw*$h)/$w; |
|
409 | + $nh = ($nw * $h) / $w; |
|
410 | 410 | } else { |
411 | 411 | $nh = $height; |
412 | 412 | if ($nh >= $h) { return false; } |
413 | - $nw = ($nh*$w)/$h; |
|
413 | + $nw = ($nh * $w) / $h; |
|
414 | 414 | } |
415 | 415 | } else { |
416 | 416 | return false; |
@@ -418,16 +418,16 @@ discard block |
||
418 | 418 | |
419 | 419 | //draw the image |
420 | 420 | $src_img = imagecreatefromjpeg($file); |
421 | - $dst_img = imagecreatetruecolor($nw,$nh); |
|
422 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image |
|
423 | - imagejpeg($dst_img,$outputfile,80); |
|
421 | + $dst_img = imagecreatetruecolor($nw, $nh); |
|
422 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image |
|
423 | + imagejpeg($dst_img, $outputfile, 80); |
|
424 | 424 | imagedestroy($src_img); |
425 | 425 | imagedestroy($dst_img); |
426 | 426 | |
427 | 427 | return true; |
428 | 428 | } |
429 | 429 | |
430 | - public function getLinkArray () |
|
430 | + public function getLinkArray() |
|
431 | 431 | { |
432 | 432 | $linkArray = array(); |
433 | 433 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | $serie = $this->getSerie(); |
455 | - if (!is_null ($serie)) { |
|
455 | + if (!is_null($serie)) { |
|
456 | 456 | array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name))); |
457 | 457 | } |
458 | 458 | |
@@ -477,13 +477,13 @@ discard block |
||
477 | 477 | $entry = new Entry(localize('allbooks.title'), |
478 | 478 | self::ALL_BOOKS_ID, |
479 | 479 | str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', |
480 | - array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
480 | + array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
481 | 481 | array_push($result, $entry); |
482 | 482 | if ($config['cops_recentbooks_limit'] > 0) { |
483 | 483 | $entry = new Entry(localize('recent.title'), |
484 | 484 | self::ALL_RECENT_BOOKS_ID, |
485 | 485 | str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', |
486 | - array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
486 | + array(new LinkNavigation('?page=' . parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
487 | 487 | array_push($result, $entry); |
488 | 488 | } |
489 | 489 | return $result; |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | public static function getBooks($n) { |
582 | - list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n); |
|
582 | + list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n); |
|
583 | 583 | return array($entryArray, $totalNumber); |
584 | 584 | } |
585 | 585 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | { |
597 | 597 | array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), |
598 | 598 | str_format(localize('bookword', $post->count), $post->count), 'text', |
599 | - array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count)); |
|
599 | + array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count)); |
|
600 | 600 | } |
601 | 601 | return $entryArray; |
602 | 602 | } |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | |
622 | 622 | public static function getAllRecentBooks() { |
623 | 623 | global $config; |
624 | - list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
|
624 | + list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
|
625 | 625 | return $entryArray; |
626 | 626 | } |
627 | 627 |
@@ -108,7 +108,8 @@ discard block |
||
108 | 108 | public $format = array (); |
109 | 109 | |
110 | 110 | |
111 | - public function __construct($line) { |
|
111 | + public function __construct($line) |
|
112 | + { |
|
112 | 113 | $this->id = $line->id; |
113 | 114 | $this->title = $line->title; |
114 | 115 | $this->timestamp = strtotime($line->timestamp); |
@@ -126,25 +127,32 @@ discard block |
||
126 | 127 | $this->rating = $line->rating; |
127 | 128 | } |
128 | 129 | |
129 | - public function getEntryId() { |
|
130 | + public function getEntryId() |
|
131 | + { |
|
130 | 132 | return self::ALL_BOOKS_UUID.':'.$this->uuid; |
131 | 133 | } |
132 | 134 | |
133 | - public static function getEntryIdByLetter ($startingLetter) { |
|
135 | + public static function getEntryIdByLetter ($startingLetter) |
|
136 | + { |
|
134 | 137 | return self::ALL_BOOKS_ID.':letter:'.$startingLetter; |
135 | 138 | } |
136 | 139 | |
137 | - public function getUri () { |
|
140 | + public function getUri () |
|
141 | + { |
|
138 | 142 | return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id; |
139 | 143 | } |
140 | 144 | |
141 | - public function getDetailUrl () { |
|
145 | + public function getDetailUrl () |
|
146 | + { |
|
142 | 147 | $urlParam = $this->getUri(); |
143 | - if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); |
|
148 | + if (!is_null(GetUrlParam(DB))) { |
|
149 | + $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); |
|
150 | + } |
|
144 | 151 | return 'index.php' . $urlParam; |
145 | 152 | } |
146 | 153 | |
147 | - public function getTitle () { |
|
154 | + public function getTitle () |
|
155 | + { |
|
148 | 156 | return $this->title; |
149 | 157 | } |
150 | 158 | |
@@ -153,22 +161,26 @@ discard block |
||
153 | 161 | /** |
154 | 162 | * @return Author[] |
155 | 163 | */ |
156 | - public function getAuthors () { |
|
164 | + public function getAuthors () |
|
165 | + { |
|
157 | 166 | if (is_null($this->authors)) { |
158 | 167 | $this->authors = Author::getAuthorByBookId($this->id); |
159 | 168 | } |
160 | 169 | return $this->authors; |
161 | 170 | } |
162 | 171 | |
163 | - public function getAuthorsName () { |
|
172 | + public function getAuthorsName () |
|
173 | + { |
|
164 | 174 | return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors())); |
165 | 175 | } |
166 | 176 | |
167 | - public function getAuthorsSort () { |
|
177 | + public function getAuthorsSort () |
|
178 | + { |
|
168 | 179 | return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors())); |
169 | 180 | } |
170 | 181 | |
171 | - public function getPublisher () { |
|
182 | + public function getPublisher () |
|
183 | + { |
|
172 | 184 | if (is_null($this->publisher)) { |
173 | 185 | $this->publisher = Publisher::getPublisherByBookId($this->id); |
174 | 186 | } |
@@ -178,7 +190,8 @@ discard block |
||
178 | 190 | /** |
179 | 191 | * @return Serie |
180 | 192 | */ |
181 | - public function getSerie() { |
|
193 | + public function getSerie() |
|
194 | + { |
|
182 | 195 | if (is_null($this->serie)) { |
183 | 196 | $this->serie = Serie::getSerieByBookId($this->id); |
184 | 197 | } |
@@ -188,7 +201,8 @@ discard block |
||
188 | 201 | /** |
189 | 202 | * @return string |
190 | 203 | */ |
191 | - public function getLanguages() { |
|
204 | + public function getLanguages() |
|
205 | + { |
|
192 | 206 | $lang = array(); |
193 | 207 | $result = parent::getDb()->prepare('select languages.lang_code |
194 | 208 | from books_languages_link, languages |
@@ -196,8 +210,7 @@ discard block |
||
196 | 210 | and book = ? |
197 | 211 | order by item_order'); |
198 | 212 | $result->execute(array($this->id)); |
199 | - while ($post = $result->fetchObject()) |
|
200 | - { |
|
213 | + while ($post = $result->fetchObject()) { |
|
201 | 214 | array_push($lang, Language::getLanguageString($post->lang_code)); |
202 | 215 | } |
203 | 216 | return implode(', ', $lang); |
@@ -206,7 +219,8 @@ discard block |
||
206 | 219 | /** |
207 | 220 | * @return Tag[] |
208 | 221 | */ |
209 | - public function getTags() { |
|
222 | + public function getTags() |
|
223 | + { |
|
210 | 224 | if (is_null ($this->tags)) { |
211 | 225 | $this->tags = array(); |
212 | 226 | |
@@ -216,15 +230,15 @@ discard block |
||
216 | 230 | and book = ? |
217 | 231 | order by name'); |
218 | 232 | $result->execute(array($this->id)); |
219 | - while ($post = $result->fetchObject()) |
|
220 | - { |
|
233 | + while ($post = $result->fetchObject()) { |
|
221 | 234 | array_push($this->tags, new Tag($post)); |
222 | 235 | } |
223 | 236 | } |
224 | 237 | return $this->tags; |
225 | 238 | } |
226 | 239 | |
227 | - public function getTagsName() { |
|
240 | + public function getTagsName() |
|
241 | + { |
|
228 | 242 | return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags())); |
229 | 243 | } |
230 | 244 | |
@@ -241,9 +255,12 @@ discard block |
||
241 | 255 | |
242 | 256 | /* End of other class (author, series, tag, ...) initialization and accessors */ |
243 | 257 | |
244 | - public static function getFilterString() { |
|
258 | + public static function getFilterString() |
|
259 | + { |
|
245 | 260 | $filter = getURLParam('tag', NULL); |
246 | - if (empty($filter)) return ''; |
|
261 | + if (empty($filter)) { |
|
262 | + return ''; |
|
263 | + } |
|
247 | 264 | |
248 | 265 | $exists = true; |
249 | 266 | if (preg_match("/^!(.*)$/", $filter, $matches)) { |
@@ -283,7 +300,8 @@ discard block |
||
283 | 300 | return reset($reduced); |
284 | 301 | } |
285 | 302 | |
286 | - public function getRating() { |
|
303 | + public function getRating() |
|
304 | + { |
|
287 | 305 | if (is_null($this->rating) || $this->rating == 0) { |
288 | 306 | return ''; |
289 | 307 | } |
@@ -297,7 +315,8 @@ discard block |
||
297 | 315 | return $retour; |
298 | 316 | } |
299 | 317 | |
300 | - public function getPubDate() { |
|
318 | + public function getPubDate() |
|
319 | + { |
|
301 | 320 | if (empty ($this->pubdate)) { |
302 | 321 | return ''; |
303 | 322 | } |
@@ -308,23 +327,22 @@ discard block |
||
308 | 327 | return ''; |
309 | 328 | } |
310 | 329 | |
311 | - public function getComment($withSerie = true) { |
|
330 | + public function getComment($withSerie = true) |
|
331 | + { |
|
312 | 332 | $addition = ''; |
313 | 333 | $se = $this->getSerie (); |
314 | 334 | if (!is_null ($se) && $withSerie) { |
315 | 335 | $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; |
316 | 336 | } |
317 | - if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) |
|
318 | - { |
|
337 | + if (preg_match('/<\/(div|p|a|span)>/', $this->comment)) { |
|
319 | 338 | return $addition . html2xhtml($this->comment); |
320 | - } |
|
321 | - else |
|
322 | - { |
|
339 | + } else { |
|
323 | 340 | return $addition . htmlspecialchars($this->comment); |
324 | 341 | } |
325 | 342 | } |
326 | 343 | |
327 | - public function getDataFormat($format) { |
|
344 | + public function getDataFormat($format) |
|
345 | + { |
|
328 | 346 | $reduced = array_filter($this->getDatas(), function ($data) use ($format) { |
329 | 347 | return $data->format == $format; |
330 | 348 | }); |
@@ -333,23 +351,19 @@ discard block |
||
333 | 351 | |
334 | 352 | public function getFilePath($extension, $idData = NULL, $relative = false) |
335 | 353 | { |
336 | - if ($extension == 'jpg') |
|
337 | - { |
|
354 | + if ($extension == 'jpg') { |
|
338 | 355 | $file = 'cover.jpg'; |
339 | - } |
|
340 | - else |
|
341 | - { |
|
356 | + } else { |
|
342 | 357 | $data = $this->getDataById($idData); |
343 | - if (!$data) return NULL; |
|
358 | + if (!$data) { |
|
359 | + return NULL; |
|
360 | + } |
|
344 | 361 | $file = $data->name . '.' . strtolower($data->format); |
345 | 362 | } |
346 | 363 | |
347 | - if ($relative) |
|
348 | - { |
|
364 | + if ($relative) { |
|
349 | 365 | return $this->relativePath.'/'.$file; |
350 | - } |
|
351 | - else |
|
352 | - { |
|
366 | + } else { |
|
353 | 367 | return $this->path.'/'.$file; |
354 | 368 | } |
355 | 369 | } |
@@ -359,8 +373,7 @@ discard block |
||
359 | 373 | global $config; |
360 | 374 | $data = $this->getDataById($idData); |
361 | 375 | |
362 | - try |
|
363 | - { |
|
376 | + try { |
|
364 | 377 | $epub = new EPub($data->getLocalPath()); |
365 | 378 | |
366 | 379 | $epub->Title($this->title); |
@@ -385,14 +398,13 @@ discard block |
||
385 | 398 | $filename = $data->getUpdatedFilenameKepub(); |
386 | 399 | } |
387 | 400 | $epub->download($filename); |
388 | - } |
|
389 | - catch (Exception $e) |
|
390 | - { |
|
401 | + } catch (Exception $e) { |
|
391 | 402 | echo 'Exception : ' . $e->getMessage(); |
392 | 403 | } |
393 | 404 | } |
394 | 405 | |
395 | - public function getThumbnail($width, $height, $outputfile = NULL) { |
|
406 | + public function getThumbnail($width, $height, $outputfile = NULL) |
|
407 | + { |
|
396 | 408 | if (is_null($width) && is_null($height)) { |
397 | 409 | return false; |
398 | 410 | } |
@@ -431,17 +443,14 @@ discard block |
||
431 | 443 | { |
432 | 444 | $linkArray = array(); |
433 | 445 | |
434 | - if ($this->hasCover) |
|
435 | - { |
|
446 | + if ($this->hasCover) { |
|
436 | 447 | array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL)); |
437 | 448 | |
438 | 449 | array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL)); |
439 | 450 | } |
440 | 451 | |
441 | - foreach ($this->getDatas() as $data) |
|
442 | - { |
|
443 | - if ($data->isKnownType()) |
|
444 | - { |
|
452 | + foreach ($this->getDatas() as $data) { |
|
453 | + if ($data->isKnownType()) { |
|
445 | 454 | array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format)); |
446 | 455 | } |
447 | 456 | } |
@@ -460,17 +469,20 @@ discard block |
||
460 | 469 | } |
461 | 470 | |
462 | 471 | |
463 | - public function getEntry() { |
|
472 | + public function getEntry() |
|
473 | + { |
|
464 | 474 | return new EntryBook($this->getTitle(), $this->getEntryId(), |
465 | 475 | $this->getComment(), 'text/html', |
466 | 476 | $this->getLinkArray(), $this); |
467 | 477 | } |
468 | 478 | |
469 | - public static function getBookCount($database = NULL) { |
|
479 | + public static function getBookCount($database = NULL) |
|
480 | + { |
|
470 | 481 | return parent::executeQuerySingle('select count(*) from books', $database); |
471 | 482 | } |
472 | 483 | |
473 | - public static function getCount() { |
|
484 | + public static function getCount() |
|
485 | + { |
|
474 | 486 | global $config; |
475 | 487 | $nBooks = parent::executeQuerySingle('select count(*) from books'); |
476 | 488 | $result = array(); |
@@ -489,27 +501,33 @@ discard block |
||
489 | 501 | return $result; |
490 | 502 | } |
491 | 503 | |
492 | - public static function getBooksByAuthor($authorId, $n) { |
|
504 | + public static function getBooksByAuthor($authorId, $n) |
|
505 | + { |
|
493 | 506 | return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n); |
494 | 507 | } |
495 | 508 | |
496 | - public static function getBooksByRating($ratingId, $n) { |
|
509 | + public static function getBooksByRating($ratingId, $n) |
|
510 | + { |
|
497 | 511 | return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n); |
498 | 512 | } |
499 | 513 | |
500 | - public static function getBooksByPublisher($publisherId, $n) { |
|
514 | + public static function getBooksByPublisher($publisherId, $n) |
|
515 | + { |
|
501 | 516 | return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n); |
502 | 517 | } |
503 | 518 | |
504 | - public static function getBooksBySeries($serieId, $n) { |
|
519 | + public static function getBooksBySeries($serieId, $n) |
|
520 | + { |
|
505 | 521 | return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n); |
506 | 522 | } |
507 | 523 | |
508 | - public static function getBooksByTag($tagId, $n) { |
|
524 | + public static function getBooksByTag($tagId, $n) |
|
525 | + { |
|
509 | 526 | return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n); |
510 | 527 | } |
511 | 528 | |
512 | - public static function getBooksByLanguage($languageId, $n) { |
|
529 | + public static function getBooksByLanguage($languageId, $n) |
|
530 | + { |
|
513 | 531 | return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n); |
514 | 532 | } |
515 | 533 | |
@@ -519,32 +537,33 @@ discard block |
||
519 | 537 | * @param $n integer |
520 | 538 | * @return array |
521 | 539 | */ |
522 | - public static function getBooksByCustom($customColumn, $id, $n) { |
|
540 | + public static function getBooksByCustom($customColumn, $id, $n) |
|
541 | + { |
|
523 | 542 | list($query, $params) = $customColumn->getQuery($id); |
524 | 543 | |
525 | 544 | return self::getEntryArray($query, $params, $n); |
526 | 545 | } |
527 | 546 | |
528 | - public static function getBookById($bookId) { |
|
547 | + public static function getBookById($bookId) |
|
548 | + { |
|
529 | 549 | $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ' |
530 | 550 | from books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
531 | 551 | where books.id = ?'); |
532 | 552 | $result->execute(array($bookId)); |
533 | - while ($post = $result->fetchObject()) |
|
534 | - { |
|
553 | + while ($post = $result->fetchObject()) { |
|
535 | 554 | $book = new Book($post); |
536 | 555 | return $book; |
537 | 556 | } |
538 | 557 | return NULL; |
539 | 558 | } |
540 | 559 | |
541 | - public static function getBookByDataId($dataId) { |
|
560 | + public static function getBookByDataId($dataId) |
|
561 | + { |
|
542 | 562 | $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format |
543 | 563 | from data, books ' . self::SQL_BOOKS_LEFT_JOIN . ' |
544 | 564 | where data.book = books.id and data.id = ?'); |
545 | 565 | $result->execute(array($dataId)); |
546 | - while ($post = $result->fetchObject()) |
|
547 | - { |
|
566 | + while ($post = $result->fetchObject()) { |
|
548 | 567 | $book = new Book($post); |
549 | 568 | $data = new Data($post, $book); |
550 | 569 | $data->id = $dataId; |
@@ -554,7 +573,8 @@ discard block |
||
554 | 573 | return NULL; |
555 | 574 | } |
556 | 575 | |
557 | - public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
|
576 | + public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) |
|
577 | + { |
|
558 | 578 | $i = 0; |
559 | 579 | $critArray = array(); |
560 | 580 | foreach (array(PageQueryResult::SCOPE_AUTHOR, |
@@ -565,8 +585,7 @@ discard block |
||
565 | 585 | if (in_array($key, getCurrentOption('ignored_categories')) || |
566 | 586 | (!array_key_exists($key, $query) && !array_key_exists('all', $query))) { |
567 | 587 | $critArray[$i] = self::BAD_SEARCH; |
568 | - } |
|
569 | - else { |
|
588 | + } else { |
|
570 | 589 | if (array_key_exists($key, $query)) { |
571 | 590 | $critArray[$i] = $query[$key]; |
572 | 591 | } else { |
@@ -578,12 +597,14 @@ discard block |
||
578 | 597 | return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage); |
579 | 598 | } |
580 | 599 | |
581 | - public static function getBooks($n) { |
|
600 | + public static function getBooks($n) |
|
601 | + { |
|
582 | 602 | list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n); |
583 | 603 | return array($entryArray, $totalNumber); |
584 | 604 | } |
585 | 605 | |
586 | - public static function getAllBooks() { |
|
606 | + public static function getAllBooks() |
|
607 | + { |
|
587 | 608 | /* @var $result PDOStatement */ |
588 | 609 | |
589 | 610 | list (, $result) = parent::executeQuery('select {0} |
@@ -592,8 +613,7 @@ discard block |
||
592 | 613 | order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1); |
593 | 614 | |
594 | 615 | $entryArray = array(); |
595 | - while ($post = $result->fetchObject()) |
|
596 | - { |
|
616 | + while ($post = $result->fetchObject()) { |
|
597 | 617 | array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), |
598 | 618 | str_format(localize('bookword', $post->count), $post->count), 'text', |
599 | 619 | array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count)); |
@@ -601,25 +621,27 @@ discard block |
||
601 | 621 | return $entryArray; |
602 | 622 | } |
603 | 623 | |
604 | - public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) { |
|
624 | + public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) |
|
625 | + { |
|
605 | 626 | return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage); |
606 | 627 | } |
607 | 628 | |
608 | - public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
629 | + public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) |
|
630 | + { |
|
609 | 631 | /* @var $totalNumber integer */ |
610 | 632 | /* @var $result PDOStatement */ |
611 | 633 | list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage); |
612 | 634 | |
613 | 635 | $entryArray = array(); |
614 | - while ($post = $result->fetchObject()) |
|
615 | - { |
|
636 | + while ($post = $result->fetchObject()) { |
|
616 | 637 | $book = new Book($post); |
617 | 638 | array_push($entryArray, $book->getEntry()); |
618 | 639 | } |
619 | 640 | return array($entryArray, $totalNumber); |
620 | 641 | } |
621 | 642 | |
622 | - public static function getAllRecentBooks() { |
|
643 | + public static function getAllRecentBooks() |
|
644 | + { |
|
623 | 645 | global $config; |
624 | 646 | list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
625 | 647 | return $entryArray; |
@@ -631,7 +653,8 @@ discard block |
||
631 | 653 | * @param string[] $columns |
632 | 654 | * @return CustomColumn[] |
633 | 655 | */ |
634 | - public function getCustomColumnValues($columns, $asArray = false) { |
|
656 | + public function getCustomColumnValues($columns, $asArray = false) |
|
657 | + { |
|
635 | 658 | $result = array(); |
636 | 659 | |
637 | 660 | foreach ($columns as $lookup) { |
@@ -8,11 +8,11 @@ |
||
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 | } |
@@ -20,44 +20,44 @@ |
||
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 | } |
@@ -15,25 +15,30 @@ discard block |
||
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 |
||
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", |
@@ -39,14 +39,14 @@ |
||
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); |
@@ -45,11 +45,11 @@ |
||
45 | 45 | $this->entryArray = array (); |
46 | 46 | |
47 | 47 | $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
48 | - PageQueryResult::SCOPE_TAG, |
|
49 | - PageQueryResult::SCOPE_SERIES, |
|
50 | - PageQueryResult::SCOPE_PUBLISHER, |
|
51 | - PageQueryResult::SCOPE_RATING, |
|
52 | - "language"); |
|
48 | + PageQueryResult::SCOPE_TAG, |
|
49 | + PageQueryResult::SCOPE_SERIES, |
|
50 | + PageQueryResult::SCOPE_PUBLISHER, |
|
51 | + PageQueryResult::SCOPE_RATING, |
|
52 | + "language"); |
|
53 | 53 | |
54 | 54 | $content = ""; |
55 | 55 | array_push ($this->entryArray, new Entry ("Template", "", |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | |
9 | 9 | class PageCustomize extends Page |
10 | 10 | { |
11 | - private function isChecked ($key, $testedValue = 1) { |
|
12 | - $value = getCurrentOption ($key); |
|
13 | - if (is_array ($value)) { |
|
14 | - if (in_array ($testedValue, $value)) { |
|
11 | + private function isChecked($key, $testedValue = 1) { |
|
12 | + $value = getCurrentOption($key); |
|
13 | + if (is_array($value)) { |
|
14 | + if (in_array($testedValue, $value)) { |
|
15 | 15 | return "checked='checked'"; |
16 | 16 | } |
17 | 17 | } else { |
@@ -22,29 +22,29 @@ discard block |
||
22 | 22 | return ""; |
23 | 23 | } |
24 | 24 | |
25 | - private function isSelected ($key, $value) { |
|
26 | - if (getCurrentOption ($key) == $value) { |
|
25 | + private function isSelected($key, $value) { |
|
26 | + if (getCurrentOption($key) == $value) { |
|
27 | 27 | return "selected='selected'"; |
28 | 28 | } |
29 | 29 | return ""; |
30 | 30 | } |
31 | 31 | |
32 | - private function getStyleList () { |
|
33 | - $result = array (); |
|
34 | - foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
|
35 | - if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
36 | - array_push ($result, $m [1]); |
|
32 | + private function getStyleList() { |
|
33 | + $result = array(); |
|
34 | + foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) { |
|
35 | + if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
36 | + array_push($result, $m [1]); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | return $result; |
40 | 40 | } |
41 | 41 | |
42 | - public function InitializeContent () |
|
42 | + public function InitializeContent() |
|
43 | 43 | { |
44 | - $this->title = localize ("customize.title"); |
|
45 | - $this->entryArray = array (); |
|
44 | + $this->title = localize("customize.title"); |
|
45 | + $this->entryArray = array(); |
|
46 | 46 | |
47 | - $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
|
47 | + $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR, |
|
48 | 48 | PageQueryResult::SCOPE_TAG, |
49 | 49 | PageQueryResult::SCOPE_SERIES, |
50 | 50 | PageQueryResult::SCOPE_PUBLISHER, |
@@ -52,49 +52,49 @@ discard block |
||
52 | 52 | "language"); |
53 | 53 | |
54 | 54 | $content = ""; |
55 | - array_push ($this->entryArray, new Entry ("Template", "", |
|
55 | + array_push($this->entryArray, new Entry("Template", "", |
|
56 | 56 | "<span style='cursor: pointer;' onclick='$.cookie(\"template\", \"bootstrap\", { expires: 365 });window.location=$(\".headleft\").attr(\"href\");'>Click to switch to Bootstrap</span>", "text", |
57 | - array ())); |
|
57 | + array())); |
|
58 | 58 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
59 | 59 | $content .= '<select id="style" onchange="updateCookie (this);">'; |
60 | - foreach ($this-> getStyleList () as $filename) { |
|
61 | - $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>"; |
|
60 | + foreach ($this-> getStyleList() as $filename) { |
|
61 | + $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>"; |
|
62 | 62 | } |
63 | 63 | $content .= '</select>'; |
64 | 64 | } else { |
65 | - foreach ($this-> getStyleList () as $filename) { |
|
66 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
65 | + foreach ($this-> getStyleList() as $filename) { |
|
66 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
67 | 67 | } |
68 | 68 | } |
69 | - array_push ($this->entryArray, new Entry (localize ("customize.style"), "", |
|
69 | + array_push($this->entryArray, new Entry(localize("customize.style"), "", |
|
70 | 70 | $content, "text", |
71 | - array ())); |
|
72 | - if (!useServerSideRendering ()) { |
|
73 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />'; |
|
74 | - array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "", |
|
71 | + array())); |
|
72 | + if (!useServerSideRendering()) { |
|
73 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />'; |
|
74 | + array_push($this->entryArray, new Entry(localize("customize.fancybox"), "", |
|
75 | 75 | $content, "text", |
76 | - array ())); |
|
76 | + array())); |
|
77 | 77 | } |
78 | - $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption ("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
79 | - array_push ($this->entryArray, new Entry (localize ("customize.paging"), "", |
|
78 | + $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
79 | + array_push($this->entryArray, new Entry(localize("customize.paging"), "", |
|
80 | 80 | $content, "text", |
81 | - array ())); |
|
82 | - $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />'; |
|
83 | - array_push ($this->entryArray, new Entry (localize ("customize.email"), "", |
|
81 | + array())); |
|
82 | + $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />'; |
|
83 | + array_push($this->entryArray, new Entry(localize("customize.email"), "", |
|
84 | 84 | $content, "text", |
85 | - array ())); |
|
86 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />'; |
|
87 | - array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", |
|
85 | + array())); |
|
86 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />'; |
|
87 | + array_push($this->entryArray, new Entry(localize("customize.filter"), "", |
|
88 | 88 | $content, "text", |
89 | - array ())); |
|
89 | + array())); |
|
90 | 90 | $content = ""; |
91 | 91 | foreach ($ignoredBaseArray as $key) { |
92 | - $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); |
|
93 | - $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> '; |
|
92 | + $keyPlural = preg_replace('/(ss)$/', 's', $key . "s"); |
|
93 | + $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> '; |
|
94 | 94 | } |
95 | 95 | |
96 | - array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", |
|
96 | + array_push($this->entryArray, new Entry(localize("customize.ignored"), "", |
|
97 | 97 | $content, "text", |
98 | - array ())); |
|
98 | + array())); |
|
99 | 99 | } |
100 | 100 | } |
@@ -8,7 +8,8 @@ discard block |
||
8 | 8 | |
9 | 9 | class PageCustomize extends Page |
10 | 10 | { |
11 | - private function isChecked ($key, $testedValue = 1) { |
|
11 | + private function isChecked ($key, $testedValue = 1) |
|
12 | + { |
|
12 | 13 | $value = getCurrentOption ($key); |
13 | 14 | if (is_array ($value)) { |
14 | 15 | if (in_array ($testedValue, $value)) { |
@@ -22,14 +23,16 @@ discard block |
||
22 | 23 | return ""; |
23 | 24 | } |
24 | 25 | |
25 | - private function isSelected ($key, $value) { |
|
26 | + private function isSelected ($key, $value) |
|
27 | + { |
|
26 | 28 | if (getCurrentOption ($key) == $value) { |
27 | 29 | return "selected='selected'"; |
28 | 30 | } |
29 | 31 | return ""; |
30 | 32 | } |
31 | 33 | |
32 | - private function getStyleList () { |
|
34 | + private function getStyleList () |
|
35 | + { |
|
33 | 36 | $result = array (); |
34 | 37 | foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
35 | 38 | if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
@@ -11,8 +11,8 @@ discard block |
||
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 |
||
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 |
@@ -42,7 +42,7 @@ |
||
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 |
@@ -20,27 +20,27 @@ |
||
20 | 20 | * @param Book $pbook |
21 | 21 | */ |
22 | 22 | public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) { |
23 | - parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
|
23 | + parent::__construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
|
24 | 24 | $this->book = $pbook; |
25 | 25 | $this->localUpdated = $pbook->timestamp; |
26 | 26 | } |
27 | 27 | |
28 | - public function getCoverThumbnail () { |
|
28 | + public function getCoverThumbnail() { |
|
29 | 29 | foreach ($this->linkArray as $link) { |
30 | 30 | /* @var $link LinkNavigation */ |
31 | 31 | |
32 | 32 | if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) |
33 | - return $link->hrefXhtml (); |
|
33 | + return $link->hrefXhtml(); |
|
34 | 34 | } |
35 | 35 | return null; |
36 | 36 | } |
37 | 37 | |
38 | - public function getCover () { |
|
38 | + public function getCover() { |
|
39 | 39 | foreach ($this->linkArray as $link) { |
40 | 40 | /* @var $link LinkNavigation */ |
41 | 41 | |
42 | 42 | if ($link->rel == Link::OPDS_IMAGE_TYPE) |
43 | - return $link->hrefXhtml (); |
|
43 | + return $link->hrefXhtml(); |
|
44 | 44 | } |
45 | 45 | return null; |
46 | 46 | } |
@@ -19,28 +19,33 @@ |
||
19 | 19 | * @param array $plinkArray |
20 | 20 | * @param Book $pbook |
21 | 21 | */ |
22 | - public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) { |
|
22 | + public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) |
|
23 | + { |
|
23 | 24 | parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
24 | 25 | $this->book = $pbook; |
25 | 26 | $this->localUpdated = $pbook->timestamp; |
26 | 27 | } |
27 | 28 | |
28 | - public function getCoverThumbnail () { |
|
29 | + public function getCoverThumbnail () |
|
30 | + { |
|
29 | 31 | foreach ($this->linkArray as $link) { |
30 | 32 | /* @var $link LinkNavigation */ |
31 | 33 | |
32 | - if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) |
|
33 | - return $link->hrefXhtml (); |
|
34 | + if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) { |
|
35 | + return $link->hrefXhtml (); |
|
36 | + } |
|
34 | 37 | } |
35 | 38 | return null; |
36 | 39 | } |
37 | 40 | |
38 | - public function getCover () { |
|
41 | + public function getCover () |
|
42 | + { |
|
39 | 43 | foreach ($this->linkArray as $link) { |
40 | 44 | /* @var $link LinkNavigation */ |
41 | 45 | |
42 | - if ($link->rel == Link::OPDS_IMAGE_TYPE) |
|
43 | - return $link->hrefXhtml (); |
|
46 | + if ($link->rel == Link::OPDS_IMAGE_TYPE) { |
|
47 | + return $link->hrefXhtml (); |
|
48 | + } |
|
44 | 49 | } |
45 | 50 | return null; |
46 | 51 | } |