Completed
Pull Request — master (#274)
by Markus
06:26
created
lib/PageAllAuthors.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
         $this->title = localize("authors.title");
14 14
         if (getCurrentOption ("author_split_first_letter") == 1) {
15 15
             $this->entryArray = Author::getAllAuthorsByFirstLetter();
16
-        }
17
-        else {
16
+        } else {
18 17
             $this->entryArray = Author::getAllAuthors();
19 18
         }
20 19
         $this->idPage = Author::ALL_AUTHORS_ID;
Please login to merge, or discard this patch.
lib/LinkFacet.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,9 +8,12 @@
 block discarded – undo
8 8
 
9 9
 class LinkFacet extends Link
10 10
 {
11
-    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
11
+    public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE)
12
+    {
12 13
         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet);
13
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14
+        if (!is_null (GetUrlParam (DB))) {
15
+            $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
16
+        }
14 17
         $this->href = parent::getScriptName() . $this->href;
15 18
     }
16 19
 }
Please login to merge, or discard this patch.
lib/OPDS_renderer.php 1 patch
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -13,14 +13,16 @@  discard block
 block discarded – undo
13 13
     private $xmlStream = NULL;
14 14
     private $updated = NULL;
15 15
 
16
-    private function getUpdatedTime () {
16
+    private function getUpdatedTime ()
17
+    {
17 18
         if (is_null ($this->updated)) {
18 19
             $this->updated = time();
19 20
         }
20 21
         return date (DATE_ATOM, $this->updated);
21 22
     }
22 23
 
23
-    private function getXmlStream () {
24
+    private function getXmlStream ()
25
+    {
24 26
         if (is_null ($this->xmlStream)) {
25 27
             $this->xmlStream = new XMLWriter();
26 28
             $this->xmlStream->openMemory();
@@ -29,7 +31,8 @@  discard block
 block discarded – undo
29 31
         return $this->xmlStream;
30 32
     }
31 33
 
32
-    public function getOpenSearch () {
34
+    public function getOpenSearch ()
35
+    {
33 36
         global $config;
34 37
         $xml = new XMLWriter ();
35 38
         $xml->openMemory ();
@@ -58,7 +61,9 @@  discard block
 block discarded – undo
58 61
                 $xml->startElement ("Url");
59 62
                     $xml->writeAttribute ("type", 'application/atom+xml');
60 63
                     $urlparam = "?query={searchTerms}";
61
-                    if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
64
+                    if (!is_null (GetUrlParam (DB))) {
65
+                        $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
66
+                    }
62 67
                     $urlparam = str_replace ("%7B", "{", $urlparam);
63 68
                     $urlparam = str_replace ("%7D", "}", $urlparam);
64 69
                     $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam);
@@ -72,7 +77,8 @@  discard block
 block discarded – undo
72 77
         return $xml->outputMemory(true);
73 78
     }
74 79
 
75
-    private function startXmlDocument ($page) {
80
+    private function startXmlDocument ($page)
81
+    {
76 82
         global $config;
77 83
         self::getXmlStream ()->startDocument('1.0','UTF-8');
78 84
         self::getXmlStream ()->startElement ("feed");
@@ -84,21 +90,19 @@  discard block
 block discarded – undo
84 90
             self::getXmlStream ()->startElement ("title");
85 91
                 self::getXmlStream ()->text ($page->title);
86 92
             self::getXmlStream ()->endElement ();
87
-            if ($page->subtitle != "")
88
-            {
93
+            if ($page->subtitle != "") {
89 94
                 self::getXmlStream ()->startElement ("subtitle");
90 95
                     self::getXmlStream ()->text ($page->subtitle);
91 96
                 self::getXmlStream ()->endElement ();
92 97
             }
93 98
             self::getXmlStream ()->startElement ("id");
94
-                if ($page->idPage)
95
-                {
99
+                if ($page->idPage) {
96 100
                     $idPage = $page->idPage;
97
-                    if (!is_null (GetUrlParam (DB))) $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage);
101
+                    if (!is_null (GetUrlParam (DB))) {
102
+                        $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage);
103
+                    }
98 104
                     self::getXmlStream ()->text ($idPage);
99
-                }
100
-                else
101
-                {
105
+                } else {
102 106
                     self::getXmlStream ()->text ($_SERVER['REQUEST_URI']);
103 107
                 }
104 108
             self::getXmlStream ()->endElement ();
@@ -124,14 +128,14 @@  discard block
 block discarded – undo
124 128
             $link = new LinkNavigation ("?" . getQueryString (), "self");
125 129
             self::renderLink ($link);
126 130
             $urlparam = "?";
127
-            if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
131
+            if (!is_null (GetUrlParam (DB))) {
132
+                $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB));
133
+            }
128 134
             if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) {
129 135
                 // Good and compliant way of handling search
130 136
                 $urlparam = addURLParameter ($urlparam, "page", Base::PAGE_OPENSEARCH);
131 137
                 $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here");
132
-            }
133
-            else
134
-            {
138
+            } else {
135 139
                 // Bad way, will be removed when OPDS client are fixed
136 140
                 $urlparam = addURLParameter ($urlparam, "query", "{searchTerms}");
137 141
                 $urlparam = str_replace ("%7B", "{", $urlparam);
@@ -148,13 +152,15 @@  discard block
 block discarded – undo
148 152
             }
149 153
     }
150 154
 
151
-    private function endXmlDocument () {
155
+    private function endXmlDocument ()
156
+    {
152 157
         self::getXmlStream ()->endElement ();
153 158
         self::getXmlStream ()->endDocument ();
154 159
         return self::getXmlStream ()->outputMemory(true);
155 160
     }
156 161
 
157
-    private function renderLink ($link) {
162
+    private function renderLink ($link)
163
+    {
158 164
         self::getXmlStream ()->startElement ("link");
159 165
             self::getXmlStream ()->writeAttribute ("href", $link->href);
160 166
             self::getXmlStream ()->writeAttribute ("type", $link->type);
@@ -173,7 +179,8 @@  discard block
 block discarded – undo
173 179
         self::getXmlStream ()->endElement ();
174 180
     }
175 181
 
176
-    private function getPublicationDate($book) {
182
+    private function getPublicationDate($book)
183
+    {
177 184
         $dateYmd = substr($book->pubdate, 0, 10);
178 185
         $pubdate = \DateTime::createFromFormat('Y-m-d', $dateYmd);
179 186
         if ($pubdate === false ||
@@ -184,7 +191,8 @@  discard block
 block discarded – undo
184 191
         return $pubdate->format("Y-m-d");
185 192
     }
186 193
 
187
-    private function renderEntry ($entry) {
194
+    private function renderEntry ($entry)
195
+    {
188 196
         self::getXmlStream ()->startElement ("title");
189 197
             self::getXmlStream ()->text ($entry->title);
190 198
         self::getXmlStream ()->endElement ();
@@ -244,11 +252,11 @@  discard block
 block discarded – undo
244 252
 
245 253
     }
246 254
 
247
-    public function render ($page) {
255
+    public function render ($page)
256
+    {
248 257
         global $config;
249 258
         self::startXmlDocument ($page);
250
-        if ($page->isPaginated ())
251
-        {
259
+        if ($page->isPaginated ()) {
252 260
             self::getXmlStream ()->startElement ("opensearch:totalResults");
253 261
                 self::getXmlStream ()->text ($page->totalNumber);
254 262
             self::getXmlStream ()->endElement ();
Please login to merge, or discard this patch.
lib/Data.php 1 patch
Braces   +42 added lines, -29 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
         'zip'   => 'application/zip'
56 56
     );
57 57
 
58
-    public function __construct($post, $book = null) {
58
+    public function __construct($post, $book = null)
59
+    {
59 60
         $this->id = $post->id;
60 61
         $this->name = $post->name;
61 62
         $this->format = $post->format;
@@ -64,19 +65,20 @@  discard block
 block discarded – undo
64 65
         $this->book = $book;
65 66
     }
66 67
 
67
-    public function isKnownType () {
68
+    public function isKnownType ()
69
+    {
68 70
         return array_key_exists ($this->extension, self::$mimetypes);
69 71
     }
70 72
 
71
-    public function getMimeType () {
73
+    public function getMimeType ()
74
+    {
72 75
         $result = "application/octet-stream";
73 76
         if ($this->isKnownType ()) {
74 77
             return self::$mimetypes [$this->extension];
75 78
         } elseif (function_exists('finfo_open') === true) {
76 79
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
77 80
 
78
-            if (is_resource($finfo) === true)
79
-            {
81
+            if (is_resource($finfo) === true) {
80 82
                 $result = finfo_file($finfo, $this->getLocalPath ());
81 83
             }
82 84
 
@@ -86,29 +88,35 @@  discard block
 block discarded – undo
86 88
         return $result;
87 89
     }
88 90
 
89
-    public function isEpubValidOnKobo () {
91
+    public function isEpubValidOnKobo ()
92
+    {
90 93
         return $this->format == "EPUB" || $this->format == "KEPUB";
91 94
     }
92 95
 
93
-    public function getFilename () {
96
+    public function getFilename ()
97
+    {
94 98
         return $this->name . "." . strtolower ($this->format);
95 99
     }
96 100
 
97
-    public function getUpdatedFilename () {
101
+    public function getUpdatedFilename ()
102
+    {
98 103
         return $this->book->getAuthorsSort () . " - " . $this->book->title;
99 104
     }
100 105
 
101
-    public function getUpdatedFilenameEpub () {
106
+    public function getUpdatedFilenameEpub ()
107
+    {
102 108
         return $this->getUpdatedFilename () . ".epub";
103 109
     }
104 110
 
105
-    public function getUpdatedFilenameKepub () {
111
+    public function getUpdatedFilenameKepub ()
112
+    {
106 113
         $str = $this->getUpdatedFilename () . ".kepub.epub";
107 114
         return str_replace(array(':', '#', '&'),
108 115
                            array('-', '-', ' '), $str );
109 116
     }
110 117
 
111
-    public function getDataLink ($rel, $title = NULL) {
118
+    public function getDataLink ($rel, $title = NULL)
119
+    {
112 120
         global $config;
113 121
 
114 122
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -118,19 +126,24 @@  discard block
 block discarded – undo
118 126
         return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
119 127
     }
120 128
 
121
-    public function getHtmlLink () {
129
+    public function getHtmlLink ()
130
+    {
122 131
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
123 132
     }
124 133
 
125
-    public function getLocalPath () {
134
+    public function getLocalPath ()
135
+    {
126 136
         return $this->book->path . "/" . $this->getFilename ();
127 137
     }
128 138
 
129
-    public function getHtmlLinkWithRewriting ($title = NULL) {
139
+    public function getHtmlLinkWithRewriting ($title = NULL)
140
+    {
130 141
         global $config;
131 142
 
132 143
         $database = "";
133
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
144
+        if (!is_null (GetUrlParam (DB))) {
145
+            $database = GetUrlParam (DB) . "/";
146
+        }
134 147
 
135 148
         $href = "download/" . $this->id . "/" . $database;
136 149
 
@@ -144,28 +157,27 @@  discard block
 block discarded – undo
144 157
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
145 158
     }
146 159
 
147
-    public static function getDataByBook ($book) {
160
+    public static function getDataByBook ($book)
161
+    {
148 162
         $out = array ();
149 163
         $result = parent::getDb ()->prepare('select id, format, name
150 164
                                              from data where book = ?');
151 165
         $result->execute (array ($book->id));
152 166
 
153
-        while ($post = $result->fetchObject ())
154
-        {
167
+        while ($post = $result->fetchObject ()) {
155 168
             array_push ($out, new Data ($post, $book));
156 169
         }
157 170
         return $out;
158 171
     }
159 172
 
160
-    public static function handleThumbnailLink ($urlParam, $height) {
173
+    public static function handleThumbnailLink ($urlParam, $height)
174
+    {
161 175
         global $config;
162 176
 
163 177
         if (is_null ($height)) {
164 178
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
165 179
                 $height = $config['cops_opds_thumbnail_height'];
166
-            }
167
-            else
168
-            {
180
+            } else {
169 181
                 $height = $config['cops_html_thumbnail_height'];
170 182
             }
171 183
         }
@@ -184,14 +196,17 @@  discard block
 block discarded – undo
184 196
 
185 197
         if (Base::useAbsolutePath () ||
186 198
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
187
-            ($type == "epub" && $config['cops_update_epub-metadata']))
188
-        {
189
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
199
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
200
+            if ($type != "jpg") {
201
+                $urlParam = addURLParameter($urlParam, "type", $type);
202
+            }
190 203
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
191 204
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
192 205
             }
193 206
             $urlParam = addURLParameter($urlParam, "id", $book->id);
194
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
207
+            if (!is_null (GetUrlParam (DB))) {
208
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
209
+            }
195 210
             if ($config['cops_thumbnail_handling'] != "1" &&
196 211
                 !empty ($config['cops_thumbnail_handling']) &&
197 212
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -199,9 +214,7 @@  discard block
 block discarded – undo
199 214
             } else {
200 215
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
201 216
             }
202
-        }
203
-        else
204
-        {
217
+        } else {
205 218
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
206 219
         }
207 220
     }
Please login to merge, or discard this patch.
lib/Book.php 1 patch
Braces   +105 added lines, -82 removed lines patch added patch discarded remove patch
@@ -108,7 +108,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
@@ -383,14 +396,13 @@  discard block
 block discarded – undo
383 396
                 $epub->updateForKepub();
384 397
             }
385 398
             $epub->download($data->getUpdatedFilenameEpub());
386
-        }
387
-        catch (Exception $e)
388
-        {
399
+        } catch (Exception $e) {
389 400
             echo 'Exception : ' . $e->getMessage();
390 401
         }
391 402
     }
392 403
 
393
-    public function getThumbnail($width, $height, $outputfile = NULL) {
404
+    public function getThumbnail($width, $height, $outputfile = NULL)
405
+    {
394 406
         if (is_null($width) && is_null($height)) {
395 407
             return false;
396 408
         }
@@ -429,17 +441,14 @@  discard block
 block discarded – undo
429 441
     {
430 442
         $linkArray = array();
431 443
 
432
-        if ($this->hasCover)
433
-        {
444
+        if ($this->hasCover) {
434 445
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_IMAGE_TYPE, 'cover.jpg', NULL));
435 446
 
436 447
             array_push($linkArray, Data::getLink($this, 'jpg', 'image/jpeg', Link::OPDS_THUMBNAIL_TYPE, 'cover.jpg', NULL));
437 448
         }
438 449
 
439
-        foreach ($this->getDatas() as $data)
440
-        {
441
-            if ($data->isKnownType())
442
-            {
450
+        foreach ($this->getDatas() as $data) {
451
+            if ($data->isKnownType()) {
443 452
                 array_push($linkArray, $data->getDataLink(Link::OPDS_ACQUISITION_TYPE, $data->format));
444 453
             }
445 454
         }
@@ -458,17 +467,20 @@  discard block
 block discarded – undo
458 467
     }
459 468
 
460 469
 
461
-    public function getEntry() {
470
+    public function getEntry()
471
+    {
462 472
         return new EntryBook($this->getTitle(), $this->getEntryId(),
463 473
             $this->getComment(), 'text/html',
464 474
             $this->getLinkArray(), $this);
465 475
     }
466 476
 
467
-    public static function getBookCount($database = NULL) {
477
+    public static function getBookCount($database = NULL)
478
+    {
468 479
         return parent::executeQuerySingle('select count(*) from books', $database);
469 480
     }
470 481
 
471
-    public static function getCount() {
482
+    public static function getCount()
483
+    {
472 484
         global $config;
473 485
         $nBooks = parent::executeQuerySingle('select count(*) from books');
474 486
         $result = array();
@@ -487,27 +499,33 @@  discard block
 block discarded – undo
487 499
         return $result;
488 500
     }
489 501
 
490
-    public static function getBooksByAuthor($authorId, $n) {
502
+    public static function getBooksByAuthor($authorId, $n)
503
+    {
491 504
         return self::getEntryArray(self::SQL_BOOKS_BY_AUTHOR, array($authorId), $n);
492 505
     }
493 506
 
494
-    public static function getBooksByRating($ratingId, $n) {
507
+    public static function getBooksByRating($ratingId, $n)
508
+    {
495 509
         return self::getEntryArray(self::SQL_BOOKS_BY_RATING, array($ratingId), $n);
496 510
     }
497 511
 
498
-    public static function getBooksByPublisher($publisherId, $n) {
512
+    public static function getBooksByPublisher($publisherId, $n)
513
+    {
499 514
         return self::getEntryArray(self::SQL_BOOKS_BY_PUBLISHER, array($publisherId), $n);
500 515
     }
501 516
 
502
-    public static function getBooksBySeries($serieId, $n) {
517
+    public static function getBooksBySeries($serieId, $n)
518
+    {
503 519
         return self::getEntryArray(self::SQL_BOOKS_BY_SERIE, array($serieId), $n);
504 520
     }
505 521
 
506
-    public static function getBooksByTag($tagId, $n) {
522
+    public static function getBooksByTag($tagId, $n)
523
+    {
507 524
         return self::getEntryArray(self::SQL_BOOKS_BY_TAG, array($tagId), $n);
508 525
     }
509 526
 
510
-    public static function getBooksByLanguage($languageId, $n) {
527
+    public static function getBooksByLanguage($languageId, $n)
528
+    {
511 529
         return self::getEntryArray(self::SQL_BOOKS_BY_LANGUAGE, array($languageId), $n);
512 530
     }
513 531
 
@@ -517,32 +535,33 @@  discard block
 block discarded – undo
517 535
      * @param $n integer
518 536
      * @return array
519 537
      */
520
-    public static function getBooksByCustom($customColumn, $id, $n) {
538
+    public static function getBooksByCustom($customColumn, $id, $n)
539
+    {
521 540
         list($query, $params) = $customColumn->getQuery($id);
522 541
 
523 542
         return self::getEntryArray($query, $params, $n);
524 543
     }
525 544
 
526
-    public static function getBookById($bookId) {
545
+    public static function getBookById($bookId)
546
+    {
527 547
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . '
528 548
 from books ' . self::SQL_BOOKS_LEFT_JOIN . '
529 549
 where books.id = ?');
530 550
         $result->execute(array($bookId));
531
-        while ($post = $result->fetchObject())
532
-        {
551
+        while ($post = $result->fetchObject()) {
533 552
             $book = new Book($post);
534 553
             return $book;
535 554
         }
536 555
         return NULL;
537 556
     }
538 557
 
539
-    public static function getBookByDataId($dataId) {
558
+    public static function getBookByDataId($dataId)
559
+    {
540 560
         $result = parent::getDb()->prepare('select ' . self::BOOK_COLUMNS . ', data.name, data.format
541 561
 from data, books ' . self::SQL_BOOKS_LEFT_JOIN . '
542 562
 where data.book = books.id and data.id = ?');
543 563
         $result->execute(array($dataId));
544
-        while ($post = $result->fetchObject())
545
-        {
564
+        while ($post = $result->fetchObject()) {
546 565
             $book = new Book($post);
547 566
             $data = new Data($post, $book);
548 567
             $data->id = $dataId;
@@ -552,7 +571,8 @@  discard block
 block discarded – undo
552 571
         return NULL;
553 572
     }
554 573
 
555
-    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
574
+    public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
575
+    {
556 576
         $i = 0;
557 577
         $critArray = array();
558 578
         foreach (array(PageQueryResult::SCOPE_AUTHOR,
@@ -563,8 +583,7 @@  discard block
 block discarded – undo
563 583
             if (in_array($key, getCurrentOption('ignored_categories')) ||
564 584
                 (!array_key_exists($key, $query) && !array_key_exists('all', $query))) {
565 585
                 $critArray[$i] = self::BAD_SEARCH;
566
-            }
567
-            else {
586
+            } else {
568 587
                 if (array_key_exists($key, $query)) {
569 588
                     $critArray[$i] = $query[$key];
570 589
                 } else {
@@ -576,12 +595,14 @@  discard block
 block discarded – undo
576 595
         return self::getEntryArray(self::SQL_BOOKS_QUERY, $critArray, $n, $database, $numberPerPage);
577 596
     }
578 597
 
579
-    public static function getBooks($n) {
598
+    public static function getBooks($n)
599
+    {
580 600
         list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n);
581 601
         return array($entryArray, $totalNumber);
582 602
     }
583 603
 
584
-    public static function getAllBooks() {
604
+    public static function getAllBooks()
605
+    {
585 606
         /* @var $result PDOStatement */
586 607
 
587 608
         list (, $result) = parent::executeQuery('select {0}
@@ -590,8 +611,7 @@  discard block
 block discarded – undo
590 611
 order by substr (upper (sort), 1, 1)', 'substr (upper (sort), 1, 1) as title, count(*) as count', self::getFilterString(), array(), -1);
591 612
 
592 613
         $entryArray = array();
593
-        while ($post = $result->fetchObject())
594
-        {
614
+        while ($post = $result->fetchObject()) {
595 615
             array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title),
596 616
                 str_format(localize('bookword', $post->count), $post->count), 'text',
597 617
                 array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count));
@@ -599,25 +619,27 @@  discard block
 block discarded – undo
599 619
         return $entryArray;
600 620
     }
601 621
 
602
-    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL) {
622
+    public static function getBooksByStartingLetter($letter, $n, $database = NULL, $numberPerPage = NULL)
623
+    {
603 624
         return self::getEntryArray(self::SQL_BOOKS_BY_FIRST_LETTER, array($letter . '%'), $n, $database, $numberPerPage);
604 625
     }
605 626
 
606
-    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL) {
627
+    public static function getEntryArray($query, $params, $n, $database = NULL, $numberPerPage = NULL)
628
+    {
607 629
         /* @var $totalNumber integer */
608 630
         /* @var $result PDOStatement */
609 631
         list($totalNumber, $result) = parent::executeQuery($query, self::BOOK_COLUMNS, self::getFilterString(), $params, $n, $database, $numberPerPage);
610 632
 
611 633
         $entryArray = array();
612
-        while ($post = $result->fetchObject())
613
-        {
634
+        while ($post = $result->fetchObject()) {
614 635
             $book = new Book($post);
615 636
             array_push($entryArray, $book->getEntry());
616 637
         }
617 638
         return array($entryArray, $totalNumber);
618 639
     }
619 640
 
620
-    public static function getAllRecentBooks() {
641
+    public static function getAllRecentBooks()
642
+    {
621 643
         global $config;
622 644
         list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1);
623 645
         return $entryArray;
@@ -629,7 +651,8 @@  discard block
 block discarded – undo
629 651
      * @param string[] $columns
630 652
      * @return CustomColumn[]
631 653
      */
632
-    public function getCustomColumnValues($columns) {
654
+    public function getCustomColumnValues($columns)
655
+    {
633 656
         $result = array();
634 657
         
635 658
         foreach ($columns as $lookup) {
Please login to merge, or discard this patch.
lib/Tag.php 1 patch
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,25 +15,30 @@  discard block
 block discarded – undo
15 15
     public $id;
16 16
     public $name;
17 17
 
18
-    public function __construct($post) {
18
+    public function __construct($post)
19
+    {
19 20
         $this->id = $post->id;
20 21
         $this->name = $post->name;
21 22
     }
22 23
 
23
-    public function getUri () {
24
+    public function getUri ()
25
+    {
24 26
         return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id";
25 27
     }
26 28
 
27
-    public function getEntryId () {
29
+    public function getEntryId ()
30
+    {
28 31
         return self::ALL_TAGS_ID.":".$this->id;
29 32
     }
30 33
 
31
-    public static function getCount() {
34
+    public static function getCount()
35
+    {
32 36
         // str_format (localize("tags.alphabetical", count(array))
33 37
         return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
34 38
     }
35 39
 
36
-    public static function getTagById ($tagId) {
40
+    public static function getTagById ($tagId)
41
+    {
37 42
         $result = parent::getDb ()->prepare('select id, name  from tags where id = ?');
38 43
         $result->execute (array ($tagId));
39 44
         if ($post = $result->fetchObject ()) {
@@ -42,17 +47,18 @@  discard block
 block discarded – undo
42 47
         return NULL;
43 48
     }
44 49
 
45
-    public static function getAllTags() {
50
+    public static function getAllTags()
51
+    {
46 52
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag");
47 53
     }
48 54
 
49
-    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) {
55
+    public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL)
56
+    {
50 57
         $columns  = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count";
51 58
         $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name';
52 59
         list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage);
53 60
         $entryArray = array();
54
-        while ($post = $result->fetchObject ())
55
-        {
61
+        while ($post = $result->fetchObject ()) {
56 62
             $tag = new Tag ($post);
57 63
             array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (),
58 64
                 str_format (localize("bookword", $post->count), $post->count), "text",
Please login to merge, or discard this patch.
lib/PageCustomize.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)) {
Please login to merge, or discard this patch.
lib/EntryBook.php 1 patch
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,28 +19,33 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
lib/CustomColumnTypeText.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,8 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
         $result = $this->getDb()->query($query);
69 69
         $entryArray = array();
70
-        while ($post = $result->fetchObject())
71
-        {
70
+        while ($post = $result->fetchObject()) {
72 71
             $entryPContent = str_format(localize("bookword", $post->count), $post->count);
73 72
             $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id)));
74 73
 
@@ -82,7 +81,9 @@  discard block
 block discarded – undo
82 81
     public function getDescription()
83 82
     {
84 83
         $desc = $this->getDatabaseDescription();
85
-        if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle());
84
+        if ($desc === NULL || empty($desc)) {
85
+            $desc = str_format(localize("customcolumn.description"), $this->getTitle());
86
+        }
86 87
         return $desc;
87 88
     }
88 89
 
Please login to merge, or discard this patch.