@@ -38,6 +38,9 @@ |
||
38 | 38 | return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $query |
|
43 | + */ |
|
41 | 44 | public static function getEntryArray ($query, $params) { |
42 | 45 | list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
43 | 46 | $entryArray = array(); |
@@ -22,45 +22,45 @@ |
||
22 | 22 | $this->name = $post->name; |
23 | 23 | } |
24 | 24 | |
25 | - public function getUri () { |
|
26 | - return "?page=".parent::PAGE_PUBLISHER_DETAIL."&id=$this->id"; |
|
25 | + public function getUri() { |
|
26 | + return "?page=" . parent::PAGE_PUBLISHER_DETAIL . "&id=$this->id"; |
|
27 | 27 | } |
28 | 28 | |
29 | - public function getEntryId () { |
|
30 | - return self::ALL_PUBLISHERS_ID.":".$this->id; |
|
29 | + public function getEntryId() { |
|
30 | + return self::ALL_PUBLISHERS_ID . ":" . $this->id; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function getCount() { |
34 | 34 | // str_format (localize("publishers.alphabetical", count(array)) |
35 | - return parent::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, parent::PAGE_ALL_PUBLISHERS); |
|
35 | + return parent::getCountGeneric("publishers", self::ALL_PUBLISHERS_ID, parent::PAGE_ALL_PUBLISHERS); |
|
36 | 36 | } |
37 | 37 | |
38 | - public static function getPublisherByBookId ($bookId) { |
|
39 | - $result = parent::getDb ()->prepare('select publishers.id as id, name |
|
38 | + public static function getPublisherByBookId($bookId) { |
|
39 | + $result = parent::getDb()->prepare('select publishers.id as id, name |
|
40 | 40 | from books_publishers_link, publishers |
41 | 41 | where publishers.id = publisher and book = ?'); |
42 | - $result->execute (array ($bookId)); |
|
43 | - if ($post = $result->fetchObject ()) { |
|
44 | - return new Publisher ($post); |
|
42 | + $result->execute(array($bookId)); |
|
43 | + if ($post = $result->fetchObject()) { |
|
44 | + return new Publisher($post); |
|
45 | 45 | } |
46 | 46 | return NULL; |
47 | 47 | } |
48 | 48 | |
49 | - public static function getPublisherById ($publisherId) { |
|
50 | - $result = parent::getDb ()->prepare('select id, name |
|
49 | + public static function getPublisherById($publisherId) { |
|
50 | + $result = parent::getDb()->prepare('select id, name |
|
51 | 51 | from publishers where id = ?'); |
52 | - $result->execute (array ($publisherId)); |
|
53 | - if ($post = $result->fetchObject ()) { |
|
54 | - return new Publisher ($post); |
|
52 | + $result->execute(array($publisherId)); |
|
53 | + if ($post = $result->fetchObject()) { |
|
54 | + return new Publisher($post); |
|
55 | 55 | } |
56 | 56 | return NULL; |
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function getAllPublishers() { |
60 | - return Base::getEntryArrayWithBookNumber (self::SQL_ALL_PUBLISHERS, self::PUBLISHERS_COLUMNS, array (), "Publisher"); |
|
60 | + return Base::getEntryArrayWithBookNumber(self::SQL_ALL_PUBLISHERS, self::PUBLISHERS_COLUMNS, array(), "Publisher"); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public static function getAllPublishersByQuery($query) { |
64 | - return Base::getEntryArrayWithBookNumber (self::SQL_PUBLISHERS_FOR_SEARCH, self::PUBLISHERS_COLUMNS, array ('%' . $query . '%'), "Publisher"); |
|
64 | + return Base::getEntryArrayWithBookNumber(self::SQL_PUBLISHERS_FOR_SEARCH, self::PUBLISHERS_COLUMNS, array('%' . $query . '%'), "Publisher"); |
|
65 | 65 | } |
66 | 66 | } |
@@ -17,25 +17,30 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) { |
155 | 155 | return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate")); |
156 | 156 | } |
157 | - return NULL; |
|
157 | + return null; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function getPrevLink () |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | if ($this->n > 1) { |
164 | 164 | return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate")); |
165 | 165 | } |
166 | - return NULL; |
|
166 | + return null; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | public function getMaxPage () |
@@ -38,6 +38,9 @@ |
||
38 | 38 | return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $query |
|
43 | + */ |
|
41 | 44 | public static function getEntryArray ($query, $params) { |
42 | 45 | list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
43 | 46 | $entryArray = array(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | const ALL_RATING_ID = "cops:rating"; |
12 | 12 | |
13 | 13 | const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count"; |
14 | - const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating"; |
|
14 | + const SQL_ALL_RATINGS = "select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating"; |
|
15 | 15 | public $id; |
16 | 16 | public $name; |
17 | 17 | |
@@ -20,41 +20,41 @@ discard block |
||
20 | 20 | $this->name = $pname; |
21 | 21 | } |
22 | 22 | |
23 | - public function getUri () { |
|
24 | - return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id"; |
|
23 | + public function getUri() { |
|
24 | + return "?page=" . parent::PAGE_RATING_DETAIL . "&id=$this->id"; |
|
25 | 25 | } |
26 | 26 | |
27 | - public function getEntryId () { |
|
28 | - return self::ALL_RATING_ID.":".$this->id; |
|
27 | + public function getEntryId() { |
|
28 | + return self::ALL_RATING_ID . ":" . $this->id; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | public static function getCount() { |
32 | 32 | // str_format (localize("ratings", count(array)) |
33 | - return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings"); |
|
33 | + return parent::getCountGeneric("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings"); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public static function getAllRatings() { |
37 | - return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
|
37 | + return self::getEntryArray(self::SQL_ALL_RATINGS, array()); |
|
38 | 38 | } |
39 | 39 | |
40 | - public static function getEntryArray ($query, $params) { |
|
41 | - list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
|
40 | + public static function getEntryArray($query, $params) { |
|
41 | + list (, $result) = parent::executeQuery($query, self::RATING_COLUMNS, "", $params, -1); |
|
42 | 42 | $entryArray = array(); |
43 | - while ($post = $result->fetchObject ()) |
|
43 | + while ($post = $result->fetchObject()) |
|
44 | 44 | { |
45 | - $ratingObj = new Rating ($post->id, $post->rating); |
|
46 | - $rating=$post->rating/2; |
|
47 | - $rating = str_format (localize("ratingword", $rating), $rating); |
|
48 | - array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (), |
|
49 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
50 | - array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count)); |
|
45 | + $ratingObj = new Rating($post->id, $post->rating); |
|
46 | + $rating = $post->rating / 2; |
|
47 | + $rating = str_format(localize("ratingword", $rating), $rating); |
|
48 | + array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(), |
|
49 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
50 | + array(new LinkNavigation($ratingObj->getUri())), "", $post->count)); |
|
51 | 51 | } |
52 | 52 | return $entryArray; |
53 | 53 | } |
54 | 54 | |
55 | - public static function getRatingById ($ratingId) { |
|
56 | - $result = parent::getDb ()->prepare('select rating from ratings where id = ?'); |
|
57 | - $result->execute (array ($ratingId)); |
|
58 | - return new Rating ($ratingId, $result->fetchColumn ()); |
|
55 | + public static function getRatingById($ratingId) { |
|
56 | + $result = parent::getDb()->prepare('select rating from ratings where id = ?'); |
|
57 | + $result->execute(array($ratingId)); |
|
58 | + return new Rating($ratingId, $result->fetchColumn()); |
|
59 | 59 | } |
60 | 60 | } |
@@ -15,33 +15,38 @@ discard block |
||
15 | 15 | public $id; |
16 | 16 | public $name; |
17 | 17 | |
18 | - public function __construct($pid, $pname) { |
|
18 | + public function __construct($pid, $pname) |
|
19 | + { |
|
19 | 20 | $this->id = $pid; |
20 | 21 | $this->name = $pname; |
21 | 22 | } |
22 | 23 | |
23 | - public function getUri () { |
|
24 | + public function getUri () |
|
25 | + { |
|
24 | 26 | return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id"; |
25 | 27 | } |
26 | 28 | |
27 | - public function getEntryId () { |
|
29 | + public function getEntryId () |
|
30 | + { |
|
28 | 31 | return self::ALL_RATING_ID.":".$this->id; |
29 | 32 | } |
30 | 33 | |
31 | - public static function getCount() { |
|
34 | + public static function getCount() |
|
35 | + { |
|
32 | 36 | // str_format (localize("ratings", count(array)) |
33 | 37 | return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings"); |
34 | 38 | } |
35 | 39 | |
36 | - public static function getAllRatings() { |
|
40 | + public static function getAllRatings() |
|
41 | + { |
|
37 | 42 | return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
38 | 43 | } |
39 | 44 | |
40 | - public static function getEntryArray ($query, $params) { |
|
45 | + public static function getEntryArray ($query, $params) |
|
46 | + { |
|
41 | 47 | list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
42 | 48 | $entryArray = array(); |
43 | - while ($post = $result->fetchObject ()) |
|
44 | - { |
|
49 | + while ($post = $result->fetchObject ()) { |
|
45 | 50 | $ratingObj = new Rating ($post->id, $post->rating); |
46 | 51 | $rating=$post->rating/2; |
47 | 52 | $rating = str_format (localize("ratingword", $rating), $rating); |
@@ -52,7 +57,8 @@ discard block |
||
52 | 57 | return $entryArray; |
53 | 58 | } |
54 | 59 | |
55 | - public static function getRatingById ($ratingId) { |
|
60 | + public static function getRatingById ($ratingId) |
|
61 | + { |
|
56 | 62 | $result = parent::getDb ()->prepare('select rating from ratings where id = ?'); |
57 | 63 | $result->execute (array ($ratingId)); |
58 | 64 | return new Rating ($ratingId, $result->fetchColumn ()); |
@@ -38,6 +38,9 @@ |
||
38 | 38 | return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
39 | 39 | } |
40 | 40 | |
41 | + /** |
|
42 | + * @param string $query |
|
43 | + */ |
|
41 | 44 | public static function getEntryArray ($query, $params) { |
42 | 45 | list (, $result) = parent::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
43 | 46 | $entryArray = array(); |
@@ -21,44 +21,44 @@ |
||
21 | 21 | $this->name = $post->name; |
22 | 22 | } |
23 | 23 | |
24 | - public function getUri () { |
|
25 | - return "?page=".parent::PAGE_SERIE_DETAIL."&id=$this->id"; |
|
24 | + public function getUri() { |
|
25 | + return "?page=" . parent::PAGE_SERIE_DETAIL . "&id=$this->id"; |
|
26 | 26 | } |
27 | 27 | |
28 | - public function getEntryId () { |
|
29 | - return self::ALL_SERIES_ID.":".$this->id; |
|
28 | + public function getEntryId() { |
|
29 | + return self::ALL_SERIES_ID . ":" . $this->id; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function getCount() { |
33 | 33 | // str_format (localize("series.alphabetical", count(array)) |
34 | - return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES); |
|
34 | + return parent::getCountGeneric("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES); |
|
35 | 35 | } |
36 | 36 | |
37 | - public static function getSerieByBookId ($bookId) { |
|
38 | - $result = parent::getDb ()->prepare('select series.id as id, name |
|
37 | + public static function getSerieByBookId($bookId) { |
|
38 | + $result = parent::getDb()->prepare('select series.id as id, name |
|
39 | 39 | from books_series_link, series |
40 | 40 | where series.id = series and book = ?'); |
41 | - $result->execute (array ($bookId)); |
|
42 | - if ($post = $result->fetchObject ()) { |
|
43 | - return new Serie ($post); |
|
41 | + $result->execute(array($bookId)); |
|
42 | + if ($post = $result->fetchObject()) { |
|
43 | + return new Serie($post); |
|
44 | 44 | } |
45 | 45 | return NULL; |
46 | 46 | } |
47 | 47 | |
48 | - public static function getSerieById ($serieId) { |
|
49 | - $result = parent::getDb ()->prepare('select id, name from series where id = ?'); |
|
50 | - $result->execute (array ($serieId)); |
|
51 | - if ($post = $result->fetchObject ()) { |
|
52 | - return new Serie ($post); |
|
48 | + public static function getSerieById($serieId) { |
|
49 | + $result = parent::getDb()->prepare('select id, name from series where id = ?'); |
|
50 | + $result->execute(array($serieId)); |
|
51 | + if ($post = $result->fetchObject()) { |
|
52 | + return new Serie($post); |
|
53 | 53 | } |
54 | 54 | return NULL; |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function getAllSeries() { |
58 | - return Base::getEntryArrayWithBookNumber (self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array (), "Serie"); |
|
58 | + return Base::getEntryArrayWithBookNumber(self::SQL_ALL_SERIES, self::SERIES_COLUMNS, array(), "Serie"); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | public static function getAllSeriesByQuery($query) { |
62 | - return Base::getEntryArrayWithBookNumber (self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array ('%' . $query . '%'), "Serie"); |
|
62 | + return Base::getEntryArrayWithBookNumber(self::SQL_SERIES_FOR_SEARCH, self::SERIES_COLUMNS, array('%' . $query . '%'), "Serie"); |
|
63 | 63 | } |
64 | 64 | } |
@@ -16,25 +16,30 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if (($this->n) * getCurrentOption ("max_item_per_page") < $this->totalNumber) { |
155 | 155 | return new LinkNavigation ($currentUrl . "&n=" . ($this->n + 1), "next", localize ("paging.next.alternate")); |
156 | 156 | } |
157 | - return NULL; |
|
157 | + return null; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | public function getPrevLink () |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | if ($this->n > 1) { |
164 | 164 | return new LinkNavigation ($currentUrl . "&n=" . ($this->n - 1), "previous", localize ("paging.previous.alternate")); |
165 | 165 | } |
166 | - return NULL; |
|
166 | + return null; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | public function getMaxPage () |
@@ -47,6 +47,10 @@ |
||
47 | 47 | return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag"); |
48 | 48 | } |
49 | 49 | |
50 | + /** |
|
51 | + * @param string $query |
|
52 | + * @param integer $numberPerPage |
|
53 | + */ |
|
50 | 54 | public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
51 | 55 | $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count"; |
52 | 56 | $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name'; |
@@ -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); |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | - $expires = 60*60*24*14; |
|
22 | + $expires = 60 * 60 * 24 * 14; |
|
23 | 23 | header('Pragma: public'); |
24 | 24 | header('Cache-Control: maxage=' . $expires); |
25 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
|
25 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); |
|
26 | 26 | $bookId = getURLParam('id', NULL); |
27 | 27 | $type = getURLParam('type', 'jpg'); |
28 | 28 | $idData = getURLParam('data', NULL); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | if (!$book) { |
36 | - notFound (); |
|
36 | + notFound(); |
|
37 | 37 | return; |
38 | 38 | } |
39 | 39 | |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | header('Content-Type: image/jpeg'); |
56 | 56 | //by default, we don't cache |
57 | 57 | $thumbnailCacheFullpath = null; |
58 | - if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) { |
|
58 | + if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') { |
|
59 | 59 | $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory']; |
60 | 60 | //if multiple databases, add a subfolder with the database ID |
61 | - $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : ''; |
|
61 | + $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:''; |
|
62 | 62 | //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is |
63 | 63 | //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-... |
64 | 64 | $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR; |
65 | 65 | //check if cache folder exists or create it |
66 | - if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) { |
|
66 | + if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) { |
|
67 | 67 | //we name the thumbnail from the book's uuid and it's dimensions (width and/or height) |
68 | 68 | $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.jpg'; |
69 | 69 | $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName; |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) { |
|
76 | + if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) { |
|
77 | 77 | //return the already cached thumbnail |
78 | - readfile( $thumbnailCacheFullpath ); |
|
78 | + readfile($thumbnailCacheFullpath); |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - if ($book->getThumbnail (getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) { |
|
82 | + if ($book->getThumbnail(getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) { |
|
83 | 83 | //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data |
84 | - if ( $thumbnailCacheFullpath === null ) { |
|
84 | + if ($thumbnailCacheFullpath === null) { |
|
85 | 85 | // The cover had to be resized |
86 | 86 | return; |
87 | 87 | } else { |
88 | 88 | //return the just cached thumbnail |
89 | - readfile( $thumbnailCacheFullpath ); |
|
89 | + readfile($thumbnailCacheFullpath); |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | } |
@@ -49,8 +49,7 @@ |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - switch ($type) |
|
53 | - { |
|
52 | + switch ($type) { |
|
54 | 53 | case 'jpg': |
55 | 54 | header('Content-Type: image/jpeg'); |
56 | 55 | //by default, we don't cache |
@@ -23,9 +23,9 @@ |
||
23 | 23 | header('Pragma: public'); |
24 | 24 | header('Cache-Control: maxage=' . $expires); |
25 | 25 | header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
26 | - $bookId = getURLParam('id', NULL); |
|
26 | + $bookId = getURLParam('id', null); |
|
27 | 27 | $type = getURLParam('type', 'jpg'); |
28 | - $idData = getURLParam('data', NULL); |
|
28 | + $idData = getURLParam('data', null); |
|
29 | 29 | if (is_null($bookId)) { |
30 | 30 | $book = Book::getBookByDataId($idData); |
31 | 31 | } else { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * |
190 | 190 | * Note that the composite custom columns are not supported |
191 | 191 | */ |
192 | - $config['cops_calibre_custom_column_list'] = array (); |
|
192 | + $config['cops_calibre_custom_column_list'] = array(); |
|
193 | 193 | |
194 | 194 | /* |
195 | 195 | * Custom Columns for the book preview panel |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * |
200 | 200 | * Note that the composite custom columns are not supported |
201 | 201 | */ |
202 | - $config['cops_calibre_custom_column_preview'] = array (); |
|
202 | + $config['cops_calibre_custom_column_preview'] = array(); |
|
203 | 203 | |
204 | 204 | /* |
205 | 205 | * Rename .epub to .kepub.epub if downloaded from a Kobo eReader |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * "address.from" => "[email protected]" |
232 | 232 | * ); |
233 | 233 | */ |
234 | - $config['cops_mail_configuration'] = NULL; |
|
234 | + $config['cops_mail_configuration'] = null; |
|
235 | 235 | |
236 | 236 | /* |
237 | 237 | * Use filter in HTML catalog |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * array( "username" => "xxx", "password" => "secret") : Enable PHP password protection |
304 | 304 | * NULL : Disable PHP password protection (You can still use htpasswd) |
305 | 305 | */ |
306 | - $config['cops_basic_authentication'] = NULL; |
|
306 | + $config['cops_basic_authentication'] = null; |
|
307 | 307 | |
308 | 308 | /* |
309 | 309 | * Which template is used by default : |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | |
16 | 16 | $idData = getURLParam('data', NULL); |
17 | 17 | $add = 'data=' . $idData . '&'; |
18 | -if (!is_null (GetUrlParam (DB))) { |
|
19 | - $add .= DB . '=' . GetUrlParam (DB) . '&'; |
|
18 | +if (!is_null(GetUrlParam(DB))) { |
|
19 | + $add .= DB . '=' . GetUrlParam(DB) . '&'; |
|
20 | 20 | } |
21 | 21 | $myBook = Book::getBookByDataId($idData); |
22 | 22 | |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | Monocle.DEBUG = true; |
38 | 38 | var bookData = { |
39 | 39 | getComponents: function() { |
40 | - <?php echo 'return [' . implode(', ', array_map(function($comp) { return "'" . $comp . "'"; }, $book->components ())) . '];'; ?> |
|
40 | + <?php echo 'return [' . implode(', ', array_map(function($comp) { return "'" . $comp . "'"; }, $book->components())) . '];'; ?> |
|
41 | 41 | }, |
42 | 42 | getContents: function() { |
43 | - <?php echo 'return [' . implode(', ', array_map(function($content) { return "{title: '" . addslashes($content['title']) . "', src: '". $content['src'] . "'}"; }, $book->contents())) . '];'; ?> |
|
43 | + <?php echo 'return [' . implode(', ', array_map(function($content) { return "{title: '" . addslashes($content['title']) . "', src: '" . $content['src'] . "'}"; }, $book->contents())) . '];'; ?> |
|
44 | 44 | }, |
45 | 45 | getComponent: function (componentId) { |
46 | 46 | return { url: "epubfs.php?<?php echo $add ?>comp=" + componentId }; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
54 | -$idData = getURLParam('data', NULL); |
|
54 | +$idData = getURLParam('data', null); |
|
55 | 55 | $add = 'data=' . $idData . '&'; |
56 | 56 | if (!is_null(GetUrlParam(DB))) { |
57 | 57 | $add .= DB . '=' . GetUrlParam(DB) . '&'; |
@@ -37,14 +37,14 @@ |
||
37 | 37 | header('Content-Type:text/html;charset=utf-8'); |
38 | 38 | |
39 | 39 | $data = array('title' => $config['cops_title_default'], |
40 | - 'version' => VERSION, |
|
41 | - 'opds_url' => $config['cops_full_url'] . 'feed.php', |
|
42 | - 'customHeader' => '', |
|
43 | - 'template' => getCurrentTemplate(), |
|
44 | - 'server_side_rendering' => useServerSideRendering(), |
|
45 | - 'current_css' => getCurrentCss(), |
|
46 | - 'favico' => $config['cops_icon'], |
|
47 | - 'getjson_url' => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1)); |
|
40 | + 'version' => VERSION, |
|
41 | + 'opds_url' => $config['cops_full_url'] . 'feed.php', |
|
42 | + 'customHeader' => '', |
|
43 | + 'template' => getCurrentTemplate(), |
|
44 | + 'server_side_rendering' => useServerSideRendering(), |
|
45 | + 'current_css' => getCurrentCss(), |
|
46 | + 'favico' => $config['cops_icon'], |
|
47 | + 'getjson_url' => 'getJSON.php?' . addURLParameter(getQueryString(), 'complete', 1)); |
|
48 | 48 | if (preg_match('/Kindle/', $_SERVER['HTTP_USER_AGENT'])) { |
49 | 49 | $data['customHeader'] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>'; |
50 | 50 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | } |
51 | 51 | $headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html'); |
52 | 52 | $template = new doT(); |
53 | - $dot = $template->template($headcontent, NULL); |
|
53 | + $dot = $template->template($headcontent, null); |
|
54 | 54 | echo($dot($data)); |
55 | 55 | ?><body> |
56 | 56 | <?php |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function getDescription() |
56 | 56 | { |
57 | 57 | $desc = $this->getDatabaseDescription(); |
58 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
58 | + if ($desc === null || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
59 | 59 | return $desc; |
60 | 60 | } |
61 | 61 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | if ($post = $result->fetchObject()) { |
69 | 69 | return new CustomColumn($post->value, $post->value, $this); |
70 | 70 | } |
71 | - return new CustomColumn(NULL, localize("customcolumn.int.unknown"), $this); |
|
71 | + return new CustomColumn(null, localize("customcolumn.int.unknown"), $this); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function isSearchable() |
@@ -62,7 +62,9 @@ |
||
62 | 62 | public function getDescription() |
63 | 63 | { |
64 | 64 | $desc = $this->getDatabaseDescription(); |
65 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
65 | + if ($desc === NULL || empty($desc)) { |
|
66 | + $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
67 | + } |
|
66 | 68 | return $desc; |
67 | 69 | } |
68 | 70 |