Passed
Push — master ( 1a2937...7c8e79 )
by Markus
14:21
created
lib/Base.php 1 patch
Braces   +43 added lines, -23 removed lines patch added patch discarded remove patch
@@ -37,23 +37,27 @@  discard block
 block discarded – undo
37 37
 
38 38
     private static $db = NULL;
39 39
 
40
-    public static function isMultipleDatabaseEnabled () {
40
+    public static function isMultipleDatabaseEnabled ()
41
+    {
41 42
         global $config;
42 43
         return is_array ($config['calibre_directory']);
43 44
     }
44 45
 
45
-    public static function useAbsolutePath () {
46
+    public static function useAbsolutePath ()
47
+    {
46 48
         global $config;
47 49
         $path = self::getDbDirectory();
48 50
         return preg_match ('/^\//', $path) || // Linux /
49 51
                preg_match ('/^\w\:/', $path); // Windows X:
50 52
     }
51 53
 
52
-    public static function noDatabaseSelected () {
54
+    public static function noDatabaseSelected ()
55
+    {
53 56
         return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB));
54 57
     }
55 58
 
56
-    public static function getDbList () {
59
+    public static function getDbList ()
60
+    {
57 61
         global $config;
58 62
         if (self::isMultipleDatabaseEnabled ()) {
59 63
             return $config['calibre_directory'];
@@ -62,7 +66,8 @@  discard block
 block discarded – undo
62 66
         }
63 67
     }
64 68
 
65
-    public static function getDbNameList () {
69
+    public static function getDbNameList ()
70
+    {
66 71
         global $config;
67 72
         if (self::isMultipleDatabaseEnabled ()) {
68 73
             return array_keys ($config['calibre_directory']);
@@ -71,10 +76,13 @@  discard block
 block discarded – undo
71 76
         }
72 77
     }
73 78
 
74
-    public static function getDbName ($database = NULL) {
79
+    public static function getDbName ($database = NULL)
80
+    {
75 81
         global $config;
76 82
         if (self::isMultipleDatabaseEnabled ()) {
77
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
83
+            if (is_null ($database)) {
84
+                $database = GetUrlParam (DB, 0);
85
+            }
78 86
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
79 87
                 return self::error ($database);
80 88
             }
@@ -84,10 +92,13 @@  discard block
 block discarded – undo
84 92
         return "";
85 93
     }
86 94
 
87
-    public static function getDbDirectory ($database = NULL) {
95
+    public static function getDbDirectory ($database = NULL)
96
+    {
88 97
         global $config;
89 98
         if (self::isMultipleDatabaseEnabled ()) {
90
-            if (is_null ($database)) $database = GetUrlParam (DB, 0);
99
+            if (is_null ($database)) {
100
+                $database = GetUrlParam (DB, 0);
101
+            }
91 102
             if (!is_null($database) && !preg_match('/^\d+$/', $database)) {
92 103
                 return self::error ($database);
93 104
             }
@@ -98,18 +109,21 @@  discard block
 block discarded – undo
98 109
     }
99 110
 
100 111
 
101
-    public static function getDbFileName ($database = NULL) {
112
+    public static function getDbFileName ($database = NULL)
113
+    {
102 114
         return self::getDbDirectory ($database) .'metadata.db';
103 115
     }
104 116
 
105
-    private static function error ($database) {
117
+    private static function error ($database)
118
+    {
106 119
         if (php_sapi_name() != "cli") {
107 120
             header("location: checkconfig.php?err=1");
108 121
         }
109 122
         throw new Exception("Database <{$database}> not found.");
110 123
     }
111 124
 
112
-    public static function getDb ($database = NULL) {
125
+    public static function getDb ($database = NULL)
126
+    {
113 127
         if (is_null (self::$db)) {
114 128
             try {
115 129
                 if (is_readable (self::getDbFileName ($database))) {
@@ -127,7 +141,8 @@  discard block
 block discarded – undo
127 141
         return self::$db;
128 142
     }
129 143
 
130
-    public static function checkDatabaseAvailability () {
144
+    public static function checkDatabaseAvailability ()
145
+    {
131 146
         if (self::noDatabaseSelected ()) {
132 147
             for ($i = 0; $i < count (self::getDbList ()); $i++) {
133 148
                 self::getDb ($i);
@@ -139,31 +154,36 @@  discard block
 block discarded – undo
139 154
         return true;
140 155
     }
141 156
 
142
-    public static function clearDb () {
157
+    public static function clearDb ()
158
+    {
143 159
         self::$db = NULL;
144 160
     }
145 161
 
146
-    public static function executeQuerySingle ($query, $database = NULL) {
162
+    public static function executeQuerySingle ($query, $database = NULL)
163
+    {
147 164
         return self::getDb ($database)->query($query)->fetchColumn();
148 165
     }
149 166
 
150
-    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
167
+    public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL)
168
+    {
151 169
         if (!$numberOfString) {
152 170
             $numberOfString = $table . ".alphabetical";
153 171
         }
154 172
         $count = self::executeQuerySingle ('select count(*) from ' . $table);
155
-        if ($count == 0) return NULL;
173
+        if ($count == 0) {
174
+            return NULL;
175
+        }
156 176
         $entry = new Entry (localize($table . ".title"), $id,
157 177
             str_format (localize($numberOfString, $count), $count), "text",
158 178
             array ( new LinkNavigation ("?page=".$pageId)), "", $count);
159 179
         return $entry;
160 180
     }
161 181
 
162
-    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) {
182
+    public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category)
183
+    {
163 184
         list (, $result) = self::executeQuery ($query, $columns, "", $params, -1);
164 185
         $entryArray = array();
165
-        while ($post = $result->fetchObject ())
166
-        {
186
+        while ($post = $result->fetchObject ()) {
167 187
             $instance = new $category ($post);
168 188
             if (property_exists($post, "sort")) {
169 189
                 $title = $post->sort;
@@ -177,7 +197,8 @@  discard block
 block discarded – undo
177 197
         return $entryArray;
178 198
     }
179 199
 
180
-    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
200
+    public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL)
201
+    {
181 202
         $totalResult = -1;
182 203
 
183 204
         if (useNormAndUp ()) {
@@ -189,8 +210,7 @@  discard block
 block discarded – undo
189 210
             $numberPerPage = getCurrentOption ("max_item_per_page");
190 211
         }
191 212
 
192
-        if ($numberPerPage != -1 && $n != -1)
193
-        {
213
+        if ($numberPerPage != -1 && $n != -1) {
194 214
             // First check total number of results
195 215
             $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
196 216
             $result->execute ($params);
Please login to merge, or discard this patch.
lib/Entry.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@  discard block
 block discarded – undo
31 31
         Publisher::ALL_PUBLISHERS_ID => 'images/publisher.png'
32 32
     );
33 33
 
34
-    public function getUpdatedTime () {
34
+    public function getUpdatedTime ()
35
+    {
35 36
         if (!is_null ($this->localUpdated)) {
36 37
             return date (DATE_ATOM, $this->localUpdated);
37 38
         }
@@ -41,7 +42,8 @@  discard block
 block discarded – undo
41 42
         return date (DATE_ATOM, self::$updated);
42 43
     }
43 44
 
44
-    public function getNavLink () {
45
+    public function getNavLink ()
46
+    {
45 47
         foreach ($this->linkArray as $link) {
46 48
             if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; }
47 49
 
@@ -50,7 +52,8 @@  discard block
 block discarded – undo
50 52
         return "#";
51 53
     }
52 54
 
53
-    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0) {
55
+    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0)
56
+    {
54 57
         global $config;
55 58
         $this->title = $ptitle;
56 59
         $this->id = $pid;
@@ -60,10 +63,8 @@  discard block
 block discarded – undo
60 63
         $this->className = $pclass;
61 64
         $this->numberOfElement = $pcount;
62 65
 
63
-        if ($config['cops_show_icons'] == 1)
64
-        {
65
-            foreach (self::$icons as $reg => $image)
66
-            {
66
+        if ($config['cops_show_icons'] == 1) {
67
+            foreach (self::$icons as $reg => $image) {
67 68
                 if (preg_match ("/" . $reg . "/", $pid)) {
68 69
                     array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
69 70
                     break;
@@ -71,6 +72,8 @@  discard block
 block discarded – undo
71 72
             }
72 73
         }
73 74
 
74
-        if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
75
+        if (!is_null (GetUrlParam (DB))) {
76
+            $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
77
+        }
75 78
     }
76 79
 }
Please login to merge, or discard this patch.
lib/Link.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
     public $facetGroup;
22 22
     public $activeFacet;
23 23
 
24
-    public function __construct($phref, $ptype, $prel = NULL, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) {
24
+    public function __construct($phref, $ptype, $prel = NULL, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE)
25
+    {
25 26
         $this->href = $phref;
26 27
         $this->type = $ptype;
27 28
         $this->rel = $prel;
@@ -30,11 +31,13 @@  discard block
 block discarded – undo
30 31
         $this->activeFacet = $pactiveFacet;
31 32
     }
32 33
 
33
-    public function hrefXhtml () {
34
+    public function hrefXhtml ()
35
+    {
34 36
         return $this->href;
35 37
     }
36 38
 
37
-    public function getScriptName() {
39
+    public function getScriptName()
40
+    {
38 41
         $parts = explode('/', $_SERVER["SCRIPT_NAME"]);
39 42
         return $parts[count($parts) - 1];
40 43
     }
Please login to merge, or discard this patch.
lib/JSON_renderer.php 1 patch
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
 
11 11
 class JSONRenderer
12 12
 {
13
-    public static function getBookContentArray ($book) {
13
+    public static function getBookContentArray ($book)
14
+    {
14 15
         global $config;
15 16
         $i = 0;
16 17
         $preferedData = array ();
17
-        foreach ($config['cops_prefered_format'] as $format)
18
-        {
18
+        foreach ($config['cops_prefered_format'] as $format) {
19 19
             if ($i == 2) { break; }
20 20
             if ($data = $book->getDataFormat ($format)) {
21 21
                 $i++;
@@ -61,7 +61,8 @@  discard block
 block discarded – undo
61 61
                       "seriesurl" => $su);
62 62
     }
63 63
 
64
-    public static function getFullBookContentArray ($book) {
64
+    public static function getFullBookContentArray ($book)
65
+    {
65 66
         global $config;
66 67
         $out = self::getBookContentArray ($book);
67 68
         $database = GetUrlParam (DB);
@@ -95,7 +96,8 @@  discard block
 block discarded – undo
95 96
         return $out;
96 97
     }
97 98
 
98
-    public static function getContentArray ($entry) {
99
+    public static function getContentArray ($entry)
100
+    {
99 101
         if ($entry instanceof EntryBook) {
100 102
             $out = array ( "title" => $entry->title);
101 103
             $out ["book"] = self::getBookContentArray ($entry->book);
@@ -104,7 +106,8 @@  discard block
 block discarded – undo
104 106
         return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement );
105 107
     }
106 108
 
107
-    public static function getContentArrayTypeahead ($page) {
109
+    public static function getContentArrayTypeahead ($page)
110
+    {
108 111
         $out = array ();
109 112
         foreach ($page->entryArray as $entry) {
110 113
             if ($entry instanceof EntryBook) {
@@ -120,7 +123,8 @@  discard block
 block discarded – undo
120 123
         return $out;
121 124
     }
122 125
 
123
-    public static function addCompleteArray ($in) {
126
+    public static function addCompleteArray ($in)
127
+    {
124 128
         global $config;
125 129
         $out = $in;
126 130
 
@@ -167,7 +171,8 @@  discard block
 block discarded – undo
167 171
         return $out;
168 172
     }
169 173
 
170
-    public static function getJson ($complete = false) {
174
+    public static function getJson ($complete = false)
175
+    {
171 176
         global $config;
172 177
         $page = getURLParam ("page", Base::PAGE_INDEX);
173 178
         $query = getURLParam ("query");
@@ -236,7 +241,9 @@  discard block
 block discarded – undo
236 241
         }
237 242
 
238 243
         $out ["homeurl"] = "index.php";
239
-        if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] .  "?" . addURLParameter ("", DB, $database);
244
+        if ($page != Base::PAGE_INDEX && !is_null ($database)) {
245
+            $out ["homeurl"] = $out ["homeurl"] .  "?" . addURLParameter ("", DB, $database);
246
+        }
240 247
 
241 248
         return $out;
242 249
     }
Please login to merge, or discard this patch.
lib/Author.php 1 patch
Braces   +25 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,37 +19,42 @@  discard block
 block discarded – undo
19 19
     public $name;
20 20
     public $sort;
21 21
 
22
-    public function __construct($post) {
22
+    public function __construct($post)
23
+    {
23 24
         $this->id = $post->id;
24 25
         $this->name = str_replace("|", ",", $post->name);
25 26
         $this->sort = $post->sort;
26 27
     }
27 28
 
28
-    public function getUri () {
29
+    public function getUri ()
30
+    {
29 31
         return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id";
30 32
     }
31 33
 
32
-    public function getEntryId () {
34
+    public function getEntryId ()
35
+    {
33 36
         return self::ALL_AUTHORS_ID.":".$this->id;
34 37
     }
35 38
 
36
-    public static function getEntryIdByLetter ($startingLetter) {
39
+    public static function getEntryIdByLetter ($startingLetter)
40
+    {
37 41
         return self::ALL_AUTHORS_ID.":letter:".$startingLetter;
38 42
     }
39 43
 
40
-    public static function getCount() {
44
+    public static function getCount()
45
+    {
41 46
         // str_format (localize("authors.alphabetical", count(array))
42 47
         return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
43 48
     }
44 49
 
45
-    public static function getAllAuthorsByFirstLetter() {
50
+    public static function getAllAuthorsByFirstLetter()
51
+    {
46 52
         list (, $result) = parent::executeQuery ("select {0}
47 53
 from authors
48 54
 group by substr (upper (sort), 1, 1)
49 55
 order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1);
50 56
         $entryArray = array();
51
-        while ($post = $result->fetchObject ())
52
-        {
57
+        while ($post = $result->fetchObject ()) {
53 58
             array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title),
54 59
                 str_format (localize("authorword", $post->count), $post->count), "text",
55 60
                 array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count));
@@ -57,30 +62,36 @@  discard block
 block discarded – undo
57 62
         return $entryArray;
58 63
     }
59 64
 
60
-    public static function getAuthorsByStartingLetter($letter) {
65
+    public static function getAuthorsByStartingLetter($letter)
66
+    {
61 67
         return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%"));
62 68
     }
63 69
 
64
-    public static function getAuthorsForSearch($query) {
70
+    public static function getAuthorsForSearch($query)
71
+    {
65 72
         return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%"));
66 73
     }
67 74
 
68
-    public static function getAllAuthors() {
75
+    public static function getAllAuthors()
76
+    {
69 77
         return self::getEntryArray (self::SQL_ALL_AUTHORS, array ());
70 78
     }
71 79
 
72
-    public static function getEntryArray ($query, $params) {
80
+    public static function getEntryArray ($query, $params)
81
+    {
73 82
         return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author");
74 83
     }
75 84
 
76
-    public static function getAuthorById ($authorId) {
85
+    public static function getAuthorById ($authorId)
86
+    {
77 87
         $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
78 88
         $result->execute (array ($authorId));
79 89
         $post = $result->fetchObject ();
80 90
         return new Author ($post);
81 91
     }
82 92
 
83
-    public static function getAuthorByBookId ($bookId) {
93
+    public static function getAuthorByBookId ($bookId)
94
+    {
84 95
         $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link
85 96
 where author = authors.id
86 97
 and book = ?');
Please login to merge, or discard this patch.
lib/Serie.php 1 patch
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,25 +16,30 @@  discard block
 block discarded – undo
16 16
     public $id;
17 17
     public $name;
18 18
 
19
-    public function __construct($post) {
19
+    public function __construct($post)
20
+    {
20 21
         $this->id = $post->id;
21 22
         $this->name = $post->name;
22 23
     }
23 24
 
24
-    public function getUri () {
25
+    public function getUri ()
26
+    {
25 27
         return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id";
26 28
     }
27 29
 
28
-    public function getEntryId () {
30
+    public function getEntryId ()
31
+    {
29 32
         return self::ALL_SERIES_ID.":".$this->id;
30 33
     }
31 34
 
32
-    public static function getCount() {
35
+    public static function getCount()
36
+    {
33 37
         // str_format (localize("series.alphabetical", count(array))
34 38
         return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
35 39
     }
36 40
 
37
-    public static function getSerieByBookId ($bookId) {
41
+    public static function getSerieByBookId ($bookId)
42
+    {
38 43
         $result = parent::getDb ()->prepare('select  series.id as id, name
39 44
 from books_series_link, series
40 45
 where series.id = series and book = ?');
@@ -45,7 +50,8 @@  discard block
 block discarded – undo
45 50
         return NULL;
46 51
     }
47 52
 
48
-    public static function getSerieById ($serieId) {
53
+    public static function getSerieById ($serieId)
54
+    {
49 55
         $result = parent::getDb ()->prepare('select id, name  from series where id = ?');
50 56
         $result->execute (array ($serieId));
51 57
         if ($post = $result->fetchObject ()) {
@@ -54,11 +60,13 @@  discard block
 block discarded – undo
54 60
         return NULL;
55 61
     }
56 62
 
57
-    public static function getAllSeries() {
63
+    public static function getAllSeries()
64
+    {
58 65
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie");
59 66
     }
60 67
 
61
-    public static function getAllSeriesByQuery($query) {
68
+    public static function getAllSeriesByQuery($query)
69
+    {
62 70
         return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie");
63 71
     }
64 72
 }
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/Publisher.php 1 patch
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,25 +17,30 @@  discard block
 block discarded – undo
17 17
     public $id;
18 18
     public $name;
19 19
 
20
-    public function __construct($post) {
20
+    public function __construct($post)
21
+    {
21 22
         $this->id = $post->id;
22 23
         $this->name = $post->name;
23 24
     }
24 25
 
25
-    public function getUri () {
26
+    public function getUri ()
27
+    {
26 28
         return "?page=".parent::PAGE_PUBLISHER_DETAIL."&id=$this->id";
27 29
     }
28 30
 
29
-    public function getEntryId () {
31
+    public function getEntryId ()
32
+    {
30 33
         return self::ALL_PUBLISHERS_ID.":".$this->id;
31 34
     }
32 35
 
33
-    public static function getCount() {
36
+    public static function getCount()
37
+    {
34 38
         // str_format (localize("publishers.alphabetical", count(array))
35 39
         return parent::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, parent::PAGE_ALL_PUBLISHERS);
36 40
     }
37 41
 
38
-    public static function getPublisherByBookId ($bookId) {
42
+    public static function getPublisherByBookId ($bookId)
43
+    {
39 44
         $result = parent::getDb ()->prepare('select publishers.id as id, name
40 45
 from books_publishers_link, publishers
41 46
 where publishers.id = publisher and book = ?');
@@ -46,7 +51,8 @@  discard block
 block discarded – undo
46 51
         return NULL;
47 52
     }
48 53
 
49
-    public static function getPublisherById ($publisherId) {
54
+    public static function getPublisherById ($publisherId)
55
+    {
50 56
         $result = parent::getDb ()->prepare('select id, name
51 57
 from publishers where id = ?');
52 58
         $result->execute (array ($publisherId));
@@ -56,11 +62,13 @@  discard block
 block discarded – undo
56 62
         return NULL;
57 63
     }
58 64
 
59
-    public static function getAllPublishers() {
65
+    public static function getAllPublishers()
66
+    {
60 67
         return Base::getEntryArrayWithBookNumber (self::SQL_ALL_PUBLISHERS, self::PUBLISHERS_COLUMNS, array (), "Publisher");
61 68
     }
62 69
 
63
-    public static function getAllPublishersByQuery($query) {
70
+    public static function getAllPublishersByQuery($query)
71
+    {
64 72
         return Base::getEntryArrayWithBookNumber (self::SQL_PUBLISHERS_FOR_SEARCH, self::PUBLISHERS_COLUMNS, array ('%' . $query . '%'), "Publisher");
65 73
     }
66 74
 }
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.