@@ -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 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if ($post = $result->fetchObject ()) { |
| 61 | 61 | return $post->id; |
| 62 | 62 | } |
| 63 | - return NULL; |
|
| 63 | + return null; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public static function getCount($customId) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if ($post = $result->fetchObject ()) { |
| 78 | 78 | return new CustomColumn ($post->id, $post->name, $customId); |
| 79 | 79 | } |
| 80 | - return NULL; |
|
| 80 | + return null; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public static function getAllCustoms($customId) { |
@@ -21,44 +21,44 @@ |
||
| 21 | 21 | $this->name = $post->name; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getUri () { |
|
| 25 | - return "?page=".Base::PAGE_SERIE_DETAIL."&id=$this->id"; |
|
| 24 | + public function getUri() { |
|
| 25 | + return "?page=" . Base::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 Base::getCountGeneric ("series", self::ALL_SERIES_ID, Base::PAGE_ALL_SERIES); |
|
| 34 | + return Base::getCountGeneric("series", self::ALL_SERIES_ID, Base::PAGE_ALL_SERIES); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function getSerieByBookId ($bookId) { |
|
| 38 | - $result = Base::getDb ()->prepare('select series.id as id, name |
|
| 37 | + public static function getSerieByBookId($bookId) { |
|
| 38 | + $result = Base::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 = Base::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 = Base::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 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageRatingDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $rating = Rating::getRatingById ($this->idGet); |
|
| 14 | - $this->idPage = $rating->getEntryId (); |
|
| 15 | - $this->title =str_format (localize ("ratingword", $rating->name/2), $rating->name/2); |
|
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating ($this->idGet, $this->n); |
|
| 13 | + $rating = Rating::getRatingById($this->idGet); |
|
| 14 | + $this->idPage = $rating->getEntryId(); |
|
| 15 | + $this->title = str_format(localize("ratingword", $rating->name / 2), $rating->name / 2); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -13,266 +13,266 @@ |
||
| 13 | 13 | private $xmlStream = NULL; |
| 14 | 14 | private $updated = NULL; |
| 15 | 15 | |
| 16 | - private function getUpdatedTime () { |
|
| 17 | - if (is_null ($this->updated)) { |
|
| 16 | + private function getUpdatedTime() { |
|
| 17 | + if (is_null($this->updated)) { |
|
| 18 | 18 | $this->updated = time(); |
| 19 | 19 | } |
| 20 | - return date (DATE_ATOM, $this->updated); |
|
| 20 | + return date(DATE_ATOM, $this->updated); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - private function getXmlStream () { |
|
| 24 | - if (is_null ($this->xmlStream)) { |
|
| 23 | + private function getXmlStream() { |
|
| 24 | + if (is_null($this->xmlStream)) { |
|
| 25 | 25 | $this->xmlStream = new XMLWriter(); |
| 26 | 26 | $this->xmlStream->openMemory(); |
| 27 | - $this->xmlStream->setIndent (true); |
|
| 27 | + $this->xmlStream->setIndent(true); |
|
| 28 | 28 | } |
| 29 | 29 | return $this->xmlStream; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function getOpenSearch () { |
|
| 32 | + public function getOpenSearch() { |
|
| 33 | 33 | global $config; |
| 34 | - $xml = new XMLWriter (); |
|
| 35 | - $xml->openMemory (); |
|
| 36 | - $xml->setIndent (true); |
|
| 37 | - $xml->startDocument('1.0','UTF-8'); |
|
| 38 | - $xml->startElement ("OpenSearchDescription"); |
|
| 39 | - $xml->writeAttribute ("xmlns", "http://a9.com/-/spec/opensearch/1.1/"); |
|
| 40 | - $xml->startElement ("ShortName"); |
|
| 41 | - $xml->text ("My catalog"); |
|
| 42 | - $xml->endElement (); |
|
| 43 | - $xml->startElement ("Description"); |
|
| 44 | - $xml->text ("Search for ebooks"); |
|
| 45 | - $xml->endElement (); |
|
| 46 | - $xml->startElement ("InputEncoding"); |
|
| 47 | - $xml->text ("UTF-8"); |
|
| 48 | - $xml->endElement (); |
|
| 49 | - $xml->startElement ("OutputEncoding"); |
|
| 50 | - $xml->text ("UTF-8"); |
|
| 51 | - $xml->endElement (); |
|
| 52 | - $xml->startElement ("Image"); |
|
| 53 | - $xml->writeAttribute ("type", "image/x-icon"); |
|
| 54 | - $xml->writeAttribute ("width", "16"); |
|
| 55 | - $xml->writeAttribute ("height", "16"); |
|
| 56 | - $xml->text ($config['cops_icon']); |
|
| 57 | - $xml->endElement (); |
|
| 58 | - $xml->startElement ("Url"); |
|
| 59 | - $xml->writeAttribute ("type", 'application/atom+xml'); |
|
| 34 | + $xml = new XMLWriter(); |
|
| 35 | + $xml->openMemory(); |
|
| 36 | + $xml->setIndent(true); |
|
| 37 | + $xml->startDocument('1.0', 'UTF-8'); |
|
| 38 | + $xml->startElement("OpenSearchDescription"); |
|
| 39 | + $xml->writeAttribute("xmlns", "http://a9.com/-/spec/opensearch/1.1/"); |
|
| 40 | + $xml->startElement("ShortName"); |
|
| 41 | + $xml->text("My catalog"); |
|
| 42 | + $xml->endElement(); |
|
| 43 | + $xml->startElement("Description"); |
|
| 44 | + $xml->text("Search for ebooks"); |
|
| 45 | + $xml->endElement(); |
|
| 46 | + $xml->startElement("InputEncoding"); |
|
| 47 | + $xml->text("UTF-8"); |
|
| 48 | + $xml->endElement(); |
|
| 49 | + $xml->startElement("OutputEncoding"); |
|
| 50 | + $xml->text("UTF-8"); |
|
| 51 | + $xml->endElement(); |
|
| 52 | + $xml->startElement("Image"); |
|
| 53 | + $xml->writeAttribute("type", "image/x-icon"); |
|
| 54 | + $xml->writeAttribute("width", "16"); |
|
| 55 | + $xml->writeAttribute("height", "16"); |
|
| 56 | + $xml->text($config['cops_icon']); |
|
| 57 | + $xml->endElement(); |
|
| 58 | + $xml->startElement("Url"); |
|
| 59 | + $xml->writeAttribute("type", 'application/atom+xml'); |
|
| 60 | 60 | $urlparam = "?query={searchTerms}"; |
| 61 | - if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 62 | - $urlparam = str_replace ("%7B", "{", $urlparam); |
|
| 63 | - $urlparam = str_replace ("%7D", "}", $urlparam); |
|
| 64 | - $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam); |
|
| 65 | - $xml->endElement (); |
|
| 66 | - $xml->startElement ("Query"); |
|
| 67 | - $xml->writeAttribute ("role", "example"); |
|
| 68 | - $xml->writeAttribute ("searchTerms", "robot"); |
|
| 69 | - $xml->endElement (); |
|
| 70 | - $xml->endElement (); |
|
| 61 | + if (!is_null(GetUrlParam(DB))) $urlparam = addURLParameter($urlparam, DB, GetUrlParam(DB)); |
|
| 62 | + $urlparam = str_replace("%7B", "{", $urlparam); |
|
| 63 | + $urlparam = str_replace("%7D", "}", $urlparam); |
|
| 64 | + $xml->writeAttribute("template", $config['cops_full_url'] . 'feed.php' . $urlparam); |
|
| 65 | + $xml->endElement(); |
|
| 66 | + $xml->startElement("Query"); |
|
| 67 | + $xml->writeAttribute("role", "example"); |
|
| 68 | + $xml->writeAttribute("searchTerms", "robot"); |
|
| 69 | + $xml->endElement(); |
|
| 70 | + $xml->endElement(); |
|
| 71 | 71 | $xml->endDocument(); |
| 72 | 72 | return $xml->outputMemory(true); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - private function startXmlDocument ($page) { |
|
| 75 | + private function startXmlDocument($page) { |
|
| 76 | 76 | global $config; |
| 77 | - self::getXmlStream ()->startDocument('1.0','UTF-8'); |
|
| 78 | - self::getXmlStream ()->startElement ("feed"); |
|
| 79 | - self::getXmlStream ()->writeAttribute ("xmlns", "http://www.w3.org/2005/Atom"); |
|
| 80 | - self::getXmlStream ()->writeAttribute ("xmlns:xhtml", "http://www.w3.org/1999/xhtml"); |
|
| 81 | - self::getXmlStream ()->writeAttribute ("xmlns:opds", "http://opds-spec.org/2010/catalog"); |
|
| 82 | - self::getXmlStream ()->writeAttribute ("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/"); |
|
| 83 | - self::getXmlStream ()->writeAttribute ("xmlns:dcterms", "http://purl.org/dc/terms/"); |
|
| 84 | - self::getXmlStream ()->startElement ("title"); |
|
| 85 | - self::getXmlStream ()->text ($page->title); |
|
| 86 | - self::getXmlStream ()->endElement (); |
|
| 77 | + self::getXmlStream()->startDocument('1.0', 'UTF-8'); |
|
| 78 | + self::getXmlStream()->startElement("feed"); |
|
| 79 | + self::getXmlStream()->writeAttribute("xmlns", "http://www.w3.org/2005/Atom"); |
|
| 80 | + self::getXmlStream()->writeAttribute("xmlns:xhtml", "http://www.w3.org/1999/xhtml"); |
|
| 81 | + self::getXmlStream()->writeAttribute("xmlns:opds", "http://opds-spec.org/2010/catalog"); |
|
| 82 | + self::getXmlStream()->writeAttribute("xmlns:opensearch", "http://a9.com/-/spec/opensearch/1.1/"); |
|
| 83 | + self::getXmlStream()->writeAttribute("xmlns:dcterms", "http://purl.org/dc/terms/"); |
|
| 84 | + self::getXmlStream()->startElement("title"); |
|
| 85 | + self::getXmlStream()->text($page->title); |
|
| 86 | + self::getXmlStream()->endElement(); |
|
| 87 | 87 | if ($page->subtitle != "") |
| 88 | 88 | { |
| 89 | - self::getXmlStream ()->startElement ("subtitle"); |
|
| 90 | - self::getXmlStream ()->text ($page->subtitle); |
|
| 91 | - self::getXmlStream ()->endElement (); |
|
| 89 | + self::getXmlStream()->startElement("subtitle"); |
|
| 90 | + self::getXmlStream()->text($page->subtitle); |
|
| 91 | + self::getXmlStream()->endElement(); |
|
| 92 | 92 | } |
| 93 | - self::getXmlStream ()->startElement ("id"); |
|
| 93 | + self::getXmlStream()->startElement("id"); |
|
| 94 | 94 | if ($page->idPage) |
| 95 | 95 | { |
| 96 | 96 | $idPage = $page->idPage; |
| 97 | - if (!is_null (GetUrlParam (DB))) $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage); |
|
| 98 | - self::getXmlStream ()->text ($idPage); |
|
| 97 | + if (!is_null(GetUrlParam(DB))) $idPage = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $idPage); |
|
| 98 | + self::getXmlStream()->text($idPage); |
|
| 99 | 99 | } |
| 100 | 100 | else |
| 101 | 101 | { |
| 102 | - self::getXmlStream ()->text ($_SERVER['REQUEST_URI']); |
|
| 102 | + self::getXmlStream()->text($_SERVER['REQUEST_URI']); |
|
| 103 | 103 | } |
| 104 | - self::getXmlStream ()->endElement (); |
|
| 105 | - self::getXmlStream ()->startElement ("updated"); |
|
| 106 | - self::getXmlStream ()->text (self::getUpdatedTime ()); |
|
| 107 | - self::getXmlStream ()->endElement (); |
|
| 108 | - self::getXmlStream ()->startElement ("icon"); |
|
| 109 | - self::getXmlStream ()->text ($page->favicon); |
|
| 110 | - self::getXmlStream ()->endElement (); |
|
| 111 | - self::getXmlStream ()->startElement ("author"); |
|
| 112 | - self::getXmlStream ()->startElement ("name"); |
|
| 113 | - self::getXmlStream ()->text ($page->authorName); |
|
| 114 | - self::getXmlStream ()->endElement (); |
|
| 115 | - self::getXmlStream ()->startElement ("uri"); |
|
| 116 | - self::getXmlStream ()->text ($page->authorUri); |
|
| 117 | - self::getXmlStream ()->endElement (); |
|
| 118 | - self::getXmlStream ()->startElement ("email"); |
|
| 119 | - self::getXmlStream ()->text ($page->authorEmail); |
|
| 120 | - self::getXmlStream ()->endElement (); |
|
| 121 | - self::getXmlStream ()->endElement (); |
|
| 122 | - $link = new LinkNavigation ("", "start", "Home"); |
|
| 123 | - self::renderLink ($link); |
|
| 124 | - $link = new LinkNavigation ("?" . getQueryString (), "self"); |
|
| 125 | - self::renderLink ($link); |
|
| 104 | + self::getXmlStream()->endElement(); |
|
| 105 | + self::getXmlStream()->startElement("updated"); |
|
| 106 | + self::getXmlStream()->text(self::getUpdatedTime()); |
|
| 107 | + self::getXmlStream()->endElement(); |
|
| 108 | + self::getXmlStream()->startElement("icon"); |
|
| 109 | + self::getXmlStream()->text($page->favicon); |
|
| 110 | + self::getXmlStream()->endElement(); |
|
| 111 | + self::getXmlStream()->startElement("author"); |
|
| 112 | + self::getXmlStream()->startElement("name"); |
|
| 113 | + self::getXmlStream()->text($page->authorName); |
|
| 114 | + self::getXmlStream()->endElement(); |
|
| 115 | + self::getXmlStream()->startElement("uri"); |
|
| 116 | + self::getXmlStream()->text($page->authorUri); |
|
| 117 | + self::getXmlStream()->endElement(); |
|
| 118 | + self::getXmlStream()->startElement("email"); |
|
| 119 | + self::getXmlStream()->text($page->authorEmail); |
|
| 120 | + self::getXmlStream()->endElement(); |
|
| 121 | + self::getXmlStream()->endElement(); |
|
| 122 | + $link = new LinkNavigation("", "start", "Home"); |
|
| 123 | + self::renderLink($link); |
|
| 124 | + $link = new LinkNavigation("?" . getQueryString(), "self"); |
|
| 125 | + self::renderLink($link); |
|
| 126 | 126 | $urlparam = "?"; |
| 127 | - if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 127 | + if (!is_null(GetUrlParam(DB))) $urlparam = addURLParameter($urlparam, DB, GetUrlParam(DB)); |
|
| 128 | 128 | if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 129 | 129 | // Good and compliant way of handling search |
| 130 | - $urlparam = addURLParameter ($urlparam, "page", Base::PAGE_OPENSEARCH); |
|
| 131 | - $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here"); |
|
| 130 | + $urlparam = addURLParameter($urlparam, "page", Base::PAGE_OPENSEARCH); |
|
| 131 | + $link = new Link("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here"); |
|
| 132 | 132 | } |
| 133 | 133 | else |
| 134 | 134 | { |
| 135 | 135 | // Bad way, will be removed when OPDS client are fixed |
| 136 | - $urlparam = addURLParameter ($urlparam, "query", "{searchTerms}"); |
|
| 137 | - $urlparam = str_replace ("%7B", "{", $urlparam); |
|
| 138 | - $urlparam = str_replace ("%7D", "}", $urlparam); |
|
| 139 | - $link = new Link ($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here"); |
|
| 136 | + $urlparam = addURLParameter($urlparam, "query", "{searchTerms}"); |
|
| 137 | + $urlparam = str_replace("%7B", "{", $urlparam); |
|
| 138 | + $urlparam = str_replace("%7D", "}", $urlparam); |
|
| 139 | + $link = new Link($config['cops_full_url'] . 'feed.php' . $urlparam, "application/atom+xml", "search", "Search here"); |
|
| 140 | 140 | } |
| 141 | - self::renderLink ($link); |
|
| 142 | - if ($page->containsBook () && !is_null ($config['cops_books_filter']) && count ($config['cops_books_filter']) > 0) { |
|
| 143 | - $Urlfilter = getURLParam ("tag", ""); |
|
| 141 | + self::renderLink($link); |
|
| 142 | + if ($page->containsBook() && !is_null($config['cops_books_filter']) && count($config['cops_books_filter']) > 0) { |
|
| 143 | + $Urlfilter = getURLParam("tag", ""); |
|
| 144 | 144 | foreach ($config['cops_books_filter'] as $lib => $filter) { |
| 145 | - $link = new LinkFacet ("?" . addURLParameter (getQueryString (), "tag", $filter), $lib, localize ("tagword.title"), $filter == $Urlfilter); |
|
| 146 | - self::renderLink ($link); |
|
| 145 | + $link = new LinkFacet("?" . addURLParameter(getQueryString(), "tag", $filter), $lib, localize("tagword.title"), $filter == $Urlfilter); |
|
| 146 | + self::renderLink($link); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - private function endXmlDocument () { |
|
| 152 | - self::getXmlStream ()->endElement (); |
|
| 153 | - self::getXmlStream ()->endDocument (); |
|
| 154 | - return self::getXmlStream ()->outputMemory(true); |
|
| 151 | + private function endXmlDocument() { |
|
| 152 | + self::getXmlStream()->endElement(); |
|
| 153 | + self::getXmlStream()->endDocument(); |
|
| 154 | + return self::getXmlStream()->outputMemory(true); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - private function renderLink ($link) { |
|
| 158 | - self::getXmlStream ()->startElement ("link"); |
|
| 159 | - self::getXmlStream ()->writeAttribute ("href", $link->href); |
|
| 160 | - self::getXmlStream ()->writeAttribute ("type", $link->type); |
|
| 161 | - if (!is_null ($link->rel)) { |
|
| 162 | - self::getXmlStream ()->writeAttribute ("rel", $link->rel); |
|
| 157 | + private function renderLink($link) { |
|
| 158 | + self::getXmlStream()->startElement("link"); |
|
| 159 | + self::getXmlStream()->writeAttribute("href", $link->href); |
|
| 160 | + self::getXmlStream()->writeAttribute("type", $link->type); |
|
| 161 | + if (!is_null($link->rel)) { |
|
| 162 | + self::getXmlStream()->writeAttribute("rel", $link->rel); |
|
| 163 | 163 | } |
| 164 | - if (!is_null ($link->title)) { |
|
| 165 | - self::getXmlStream ()->writeAttribute ("title", $link->title); |
|
| 164 | + if (!is_null($link->title)) { |
|
| 165 | + self::getXmlStream()->writeAttribute("title", $link->title); |
|
| 166 | 166 | } |
| 167 | - if (!is_null ($link->facetGroup)) { |
|
| 168 | - self::getXmlStream ()->writeAttribute ("opds:facetGroup", $link->facetGroup); |
|
| 167 | + if (!is_null($link->facetGroup)) { |
|
| 168 | + self::getXmlStream()->writeAttribute("opds:facetGroup", $link->facetGroup); |
|
| 169 | 169 | } |
| 170 | 170 | if ($link->activeFacet) { |
| 171 | - self::getXmlStream ()->writeAttribute ("opds:activeFacet", "true"); |
|
| 171 | + self::getXmlStream()->writeAttribute("opds:activeFacet", "true"); |
|
| 172 | 172 | } |
| 173 | - self::getXmlStream ()->endElement (); |
|
| 173 | + self::getXmlStream()->endElement(); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | private function getPublicationDate($book) { |
| 177 | 177 | $dateYmd = substr($book->pubdate, 0, 10); |
| 178 | 178 | $pubdate = \DateTime::createFromFormat('Y-m-d', $dateYmd); |
| 179 | 179 | if ($pubdate === false || |
| 180 | - $pubdate->format ("Y") == "0101" || |
|
| 181 | - $pubdate->format ("Y") == "0100") { |
|
| 180 | + $pubdate->format("Y") == "0101" || |
|
| 181 | + $pubdate->format("Y") == "0100") { |
|
| 182 | 182 | return ""; |
| 183 | 183 | } |
| 184 | 184 | return $pubdate->format("Y-m-d"); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - private function renderEntry ($entry) { |
|
| 188 | - self::getXmlStream ()->startElement ("title"); |
|
| 189 | - self::getXmlStream ()->text ($entry->title); |
|
| 190 | - self::getXmlStream ()->endElement (); |
|
| 191 | - self::getXmlStream ()->startElement ("updated"); |
|
| 192 | - self::getXmlStream ()->text (self::getUpdatedTime ()); |
|
| 193 | - self::getXmlStream ()->endElement (); |
|
| 194 | - self::getXmlStream ()->startElement ("id"); |
|
| 195 | - self::getXmlStream ()->text ($entry->id); |
|
| 196 | - self::getXmlStream ()->endElement (); |
|
| 197 | - self::getXmlStream ()->startElement ("content"); |
|
| 198 | - self::getXmlStream ()->writeAttribute ("type", $entry->contentType); |
|
| 187 | + private function renderEntry($entry) { |
|
| 188 | + self::getXmlStream()->startElement("title"); |
|
| 189 | + self::getXmlStream()->text($entry->title); |
|
| 190 | + self::getXmlStream()->endElement(); |
|
| 191 | + self::getXmlStream()->startElement("updated"); |
|
| 192 | + self::getXmlStream()->text(self::getUpdatedTime()); |
|
| 193 | + self::getXmlStream()->endElement(); |
|
| 194 | + self::getXmlStream()->startElement("id"); |
|
| 195 | + self::getXmlStream()->text($entry->id); |
|
| 196 | + self::getXmlStream()->endElement(); |
|
| 197 | + self::getXmlStream()->startElement("content"); |
|
| 198 | + self::getXmlStream()->writeAttribute("type", $entry->contentType); |
|
| 199 | 199 | if ($entry->contentType == "text") { |
| 200 | - self::getXmlStream ()->text ($entry->content); |
|
| 200 | + self::getXmlStream()->text($entry->content); |
|
| 201 | 201 | } else { |
| 202 | - self::getXmlStream ()->writeRaw ($entry->content); |
|
| 202 | + self::getXmlStream()->writeRaw($entry->content); |
|
| 203 | 203 | } |
| 204 | - self::getXmlStream ()->endElement (); |
|
| 204 | + self::getXmlStream()->endElement(); |
|
| 205 | 205 | foreach ($entry->linkArray as $link) { |
| 206 | - self::renderLink ($link); |
|
| 206 | + self::renderLink($link); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if (get_class ($entry) != "EntryBook") { |
|
| 209 | + if (get_class($entry) != "EntryBook") { |
|
| 210 | 210 | return; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - foreach ($entry->book->getAuthors () as $author) { |
|
| 214 | - self::getXmlStream ()->startElement ("author"); |
|
| 215 | - self::getXmlStream ()->startElement ("name"); |
|
| 216 | - self::getXmlStream ()->text ($author->name); |
|
| 217 | - self::getXmlStream ()->endElement (); |
|
| 218 | - self::getXmlStream ()->startElement ("uri"); |
|
| 219 | - self::getXmlStream ()->text ("feed.php" . $author->getUri ()); |
|
| 220 | - self::getXmlStream ()->endElement (); |
|
| 221 | - self::getXmlStream ()->endElement (); |
|
| 213 | + foreach ($entry->book->getAuthors() as $author) { |
|
| 214 | + self::getXmlStream()->startElement("author"); |
|
| 215 | + self::getXmlStream()->startElement("name"); |
|
| 216 | + self::getXmlStream()->text($author->name); |
|
| 217 | + self::getXmlStream()->endElement(); |
|
| 218 | + self::getXmlStream()->startElement("uri"); |
|
| 219 | + self::getXmlStream()->text("feed.php" . $author->getUri()); |
|
| 220 | + self::getXmlStream()->endElement(); |
|
| 221 | + self::getXmlStream()->endElement(); |
|
| 222 | 222 | } |
| 223 | - foreach ($entry->book->getTags () as $category) { |
|
| 224 | - self::getXmlStream ()->startElement ("category"); |
|
| 225 | - self::getXmlStream ()->writeAttribute ("term", $category->name); |
|
| 226 | - self::getXmlStream ()->writeAttribute ("label", $category->name); |
|
| 227 | - self::getXmlStream ()->endElement (); |
|
| 223 | + foreach ($entry->book->getTags() as $category) { |
|
| 224 | + self::getXmlStream()->startElement("category"); |
|
| 225 | + self::getXmlStream()->writeAttribute("term", $category->name); |
|
| 226 | + self::getXmlStream()->writeAttribute("label", $category->name); |
|
| 227 | + self::getXmlStream()->endElement(); |
|
| 228 | 228 | } |
| 229 | - if ($entry->book->getPubDate () != "") { |
|
| 230 | - self::getXmlStream ()->startElement ("dcterms:issued"); |
|
| 231 | - self::getXmlStream ()->text (self::getPublicationDate($entry->book)); |
|
| 232 | - self::getXmlStream ()->endElement (); |
|
| 233 | - self::getXmlStream ()->startElement ("published"); |
|
| 234 | - self::getXmlStream ()->text (self::getPublicationDate($entry->book) . "T08:08:08Z"); |
|
| 235 | - self::getXmlStream ()->endElement (); |
|
| 229 | + if ($entry->book->getPubDate() != "") { |
|
| 230 | + self::getXmlStream()->startElement("dcterms:issued"); |
|
| 231 | + self::getXmlStream()->text(self::getPublicationDate($entry->book)); |
|
| 232 | + self::getXmlStream()->endElement(); |
|
| 233 | + self::getXmlStream()->startElement("published"); |
|
| 234 | + self::getXmlStream()->text(self::getPublicationDate($entry->book) . "T08:08:08Z"); |
|
| 235 | + self::getXmlStream()->endElement(); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $lang = $entry->book->getLanguages (); |
|
| 238 | + $lang = $entry->book->getLanguages(); |
|
| 239 | 239 | if (!empty ($lang)) { |
| 240 | - self::getXmlStream ()->startElement ("dcterms:language"); |
|
| 241 | - self::getXmlStream ()->text ($lang); |
|
| 242 | - self::getXmlStream ()->endElement (); |
|
| 240 | + self::getXmlStream()->startElement("dcterms:language"); |
|
| 241 | + self::getXmlStream()->text($lang); |
|
| 242 | + self::getXmlStream()->endElement(); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - public function render ($page) { |
|
| 247 | + public function render($page) { |
|
| 248 | 248 | global $config; |
| 249 | - self::startXmlDocument ($page); |
|
| 250 | - if ($page->isPaginated ()) |
|
| 249 | + self::startXmlDocument($page); |
|
| 250 | + if ($page->isPaginated()) |
|
| 251 | 251 | { |
| 252 | - self::getXmlStream ()->startElement ("opensearch:totalResults"); |
|
| 253 | - self::getXmlStream ()->text ($page->totalNumber); |
|
| 254 | - self::getXmlStream ()->endElement (); |
|
| 255 | - self::getXmlStream ()->startElement ("opensearch:itemsPerPage"); |
|
| 256 | - self::getXmlStream ()->text ($config['cops_max_item_per_page']); |
|
| 257 | - self::getXmlStream ()->endElement (); |
|
| 258 | - self::getXmlStream ()->startElement ("opensearch:startIndex"); |
|
| 259 | - self::getXmlStream ()->text (($page->n - 1) * $config['cops_max_item_per_page'] + 1); |
|
| 260 | - self::getXmlStream ()->endElement (); |
|
| 261 | - $prevLink = $page->getPrevLink (); |
|
| 262 | - $nextLink = $page->getNextLink (); |
|
| 263 | - if (!is_null ($prevLink)) { |
|
| 264 | - self::renderLink ($prevLink); |
|
| 252 | + self::getXmlStream()->startElement("opensearch:totalResults"); |
|
| 253 | + self::getXmlStream()->text($page->totalNumber); |
|
| 254 | + self::getXmlStream()->endElement(); |
|
| 255 | + self::getXmlStream()->startElement("opensearch:itemsPerPage"); |
|
| 256 | + self::getXmlStream()->text($config['cops_max_item_per_page']); |
|
| 257 | + self::getXmlStream()->endElement(); |
|
| 258 | + self::getXmlStream()->startElement("opensearch:startIndex"); |
|
| 259 | + self::getXmlStream()->text(($page->n - 1) * $config['cops_max_item_per_page'] + 1); |
|
| 260 | + self::getXmlStream()->endElement(); |
|
| 261 | + $prevLink = $page->getPrevLink(); |
|
| 262 | + $nextLink = $page->getNextLink(); |
|
| 263 | + if (!is_null($prevLink)) { |
|
| 264 | + self::renderLink($prevLink); |
|
| 265 | 265 | } |
| 266 | - if (!is_null ($nextLink)) { |
|
| 267 | - self::renderLink ($nextLink); |
|
| 266 | + if (!is_null($nextLink)) { |
|
| 267 | + self::renderLink($nextLink); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | foreach ($page->entryArray as $entry) { |
| 271 | - self::getXmlStream ()->startElement ("entry"); |
|
| 272 | - self::renderEntry ($entry); |
|
| 273 | - self::getXmlStream ()->endElement (); |
|
| 271 | + self::getXmlStream()->startElement("entry"); |
|
| 272 | + self::renderEntry($entry); |
|
| 273 | + self::getXmlStream()->endElement(); |
|
| 274 | 274 | } |
| 275 | - return self::endXmlDocument (); |
|
| 275 | + return self::endXmlDocument(); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
@@ -13,14 +13,16 @@ discard block |
||
| 13 | 13 | private $xmlStream = NULL; |
| 14 | 14 | private $updated = NULL; |
| 15 | 15 | |
| 16 | - private function getUpdatedTime () { |
|
| 16 | + private function getUpdatedTime () |
|
| 17 | + { |
|
| 17 | 18 | if (is_null ($this->updated)) { |
| 18 | 19 | $this->updated = time(); |
| 19 | 20 | } |
| 20 | 21 | return date (DATE_ATOM, $this->updated); |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - private function getXmlStream () { |
|
| 24 | + private function getXmlStream () |
|
| 25 | + { |
|
| 24 | 26 | if (is_null ($this->xmlStream)) { |
| 25 | 27 | $this->xmlStream = new XMLWriter(); |
| 26 | 28 | $this->xmlStream->openMemory(); |
@@ -29,7 +31,8 @@ discard block |
||
| 29 | 31 | return $this->xmlStream; |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | - public function getOpenSearch () { |
|
| 34 | + public function getOpenSearch () |
|
| 35 | + { |
|
| 33 | 36 | global $config; |
| 34 | 37 | $xml = new XMLWriter (); |
| 35 | 38 | $xml->openMemory (); |
@@ -58,7 +61,9 @@ discard block |
||
| 58 | 61 | $xml->startElement ("Url"); |
| 59 | 62 | $xml->writeAttribute ("type", 'application/atom+xml'); |
| 60 | 63 | $urlparam = "?query={searchTerms}"; |
| 61 | - if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 64 | + if (!is_null (GetUrlParam (DB))) { |
|
| 65 | + $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 66 | + } |
|
| 62 | 67 | $urlparam = str_replace ("%7B", "{", $urlparam); |
| 63 | 68 | $urlparam = str_replace ("%7D", "}", $urlparam); |
| 64 | 69 | $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam); |
@@ -72,7 +77,8 @@ discard block |
||
| 72 | 77 | return $xml->outputMemory(true); |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | - private function startXmlDocument ($page) { |
|
| 80 | + private function startXmlDocument ($page) |
|
| 81 | + { |
|
| 76 | 82 | global $config; |
| 77 | 83 | self::getXmlStream ()->startDocument('1.0','UTF-8'); |
| 78 | 84 | self::getXmlStream ()->startElement ("feed"); |
@@ -84,21 +90,19 @@ discard block |
||
| 84 | 90 | self::getXmlStream ()->startElement ("title"); |
| 85 | 91 | self::getXmlStream ()->text ($page->title); |
| 86 | 92 | self::getXmlStream ()->endElement (); |
| 87 | - if ($page->subtitle != "") |
|
| 88 | - { |
|
| 93 | + if ($page->subtitle != "") { |
|
| 89 | 94 | self::getXmlStream ()->startElement ("subtitle"); |
| 90 | 95 | self::getXmlStream ()->text ($page->subtitle); |
| 91 | 96 | self::getXmlStream ()->endElement (); |
| 92 | 97 | } |
| 93 | 98 | self::getXmlStream ()->startElement ("id"); |
| 94 | - if ($page->idPage) |
|
| 95 | - { |
|
| 99 | + if ($page->idPage) { |
|
| 96 | 100 | $idPage = $page->idPage; |
| 97 | - if (!is_null (GetUrlParam (DB))) $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage); |
|
| 101 | + if (!is_null (GetUrlParam (DB))) { |
|
| 102 | + $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage); |
|
| 103 | + } |
|
| 98 | 104 | self::getXmlStream ()->text ($idPage); |
| 99 | - } |
|
| 100 | - else |
|
| 101 | - { |
|
| 105 | + } else { |
|
| 102 | 106 | self::getXmlStream ()->text ($_SERVER['REQUEST_URI']); |
| 103 | 107 | } |
| 104 | 108 | self::getXmlStream ()->endElement (); |
@@ -124,14 +128,14 @@ discard block |
||
| 124 | 128 | $link = new LinkNavigation ("?" . getQueryString (), "self"); |
| 125 | 129 | self::renderLink ($link); |
| 126 | 130 | $urlparam = "?"; |
| 127 | - if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 131 | + if (!is_null (GetUrlParam (DB))) { |
|
| 132 | + $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 133 | + } |
|
| 128 | 134 | if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 129 | 135 | // Good and compliant way of handling search |
| 130 | 136 | $urlparam = addURLParameter ($urlparam, "page", Base::PAGE_OPENSEARCH); |
| 131 | 137 | $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here"); |
| 132 | - } |
|
| 133 | - else |
|
| 134 | - { |
|
| 138 | + } else { |
|
| 135 | 139 | // Bad way, will be removed when OPDS client are fixed |
| 136 | 140 | $urlparam = addURLParameter ($urlparam, "query", "{searchTerms}"); |
| 137 | 141 | $urlparam = str_replace ("%7B", "{", $urlparam); |
@@ -148,13 +152,15 @@ discard block |
||
| 148 | 152 | } |
| 149 | 153 | } |
| 150 | 154 | |
| 151 | - private function endXmlDocument () { |
|
| 155 | + private function endXmlDocument () |
|
| 156 | + { |
|
| 152 | 157 | self::getXmlStream ()->endElement (); |
| 153 | 158 | self::getXmlStream ()->endDocument (); |
| 154 | 159 | return self::getXmlStream ()->outputMemory(true); |
| 155 | 160 | } |
| 156 | 161 | |
| 157 | - private function renderLink ($link) { |
|
| 162 | + private function renderLink ($link) |
|
| 163 | + { |
|
| 158 | 164 | self::getXmlStream ()->startElement ("link"); |
| 159 | 165 | self::getXmlStream ()->writeAttribute ("href", $link->href); |
| 160 | 166 | self::getXmlStream ()->writeAttribute ("type", $link->type); |
@@ -173,7 +179,8 @@ discard block |
||
| 173 | 179 | self::getXmlStream ()->endElement (); |
| 174 | 180 | } |
| 175 | 181 | |
| 176 | - private function getPublicationDate($book) { |
|
| 182 | + private function getPublicationDate($book) |
|
| 183 | + { |
|
| 177 | 184 | $dateYmd = substr($book->pubdate, 0, 10); |
| 178 | 185 | $pubdate = \DateTime::createFromFormat('Y-m-d', $dateYmd); |
| 179 | 186 | if ($pubdate === false || |
@@ -184,7 +191,8 @@ discard block |
||
| 184 | 191 | return $pubdate->format("Y-m-d"); |
| 185 | 192 | } |
| 186 | 193 | |
| 187 | - private function renderEntry ($entry) { |
|
| 194 | + private function renderEntry ($entry) |
|
| 195 | + { |
|
| 188 | 196 | self::getXmlStream ()->startElement ("title"); |
| 189 | 197 | self::getXmlStream ()->text ($entry->title); |
| 190 | 198 | self::getXmlStream ()->endElement (); |
@@ -244,11 +252,11 @@ discard block |
||
| 244 | 252 | |
| 245 | 253 | } |
| 246 | 254 | |
| 247 | - public function render ($page) { |
|
| 255 | + public function render ($page) |
|
| 256 | + { |
|
| 248 | 257 | global $config; |
| 249 | 258 | self::startXmlDocument ($page); |
| 250 | - if ($page->isPaginated ()) |
|
| 251 | - { |
|
| 259 | + if ($page->isPaginated ()) { |
|
| 252 | 260 | self::getXmlStream ()->startElement ("opensearch:totalResults"); |
| 253 | 261 | self::getXmlStream ()->text ($page->totalNumber); |
| 254 | 262 | self::getXmlStream ()->endElement (); |
@@ -10,8 +10,8 @@ |
||
| 10 | 10 | |
| 11 | 11 | class OPDSRenderer |
| 12 | 12 | { |
| 13 | - private $xmlStream = NULL; |
|
| 14 | - private $updated = NULL; |
|
| 13 | + private $xmlStream = null; |
|
| 14 | + private $updated = null; |
|
| 15 | 15 | |
| 16 | 16 | private function getUpdatedTime () { |
| 17 | 17 | if (is_null ($this->updated)) { |
@@ -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 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | if ($post = $result->fetchObject ()) { |
| 61 | 61 | return $post->id; |
| 62 | 62 | } |
| 63 | - return NULL; |
|
| 63 | + return null; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public static function getCount($customId) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if ($post = $result->fetchObject ()) { |
| 78 | 78 | return new CustomColumn ($post->id, $post->name, $customId); |
| 79 | 79 | } |
| 80 | - return NULL; |
|
| 80 | + return null; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | public static function getAllCustoms($customId) { |
@@ -22,45 +22,45 @@ |
||
| 22 | 22 | $this->name = $post->name; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function getUri () { |
|
| 26 | - return "?page=".Base::PAGE_PUBLISHER_DETAIL."&id=$this->id"; |
|
| 25 | + public function getUri() { |
|
| 26 | + return "?page=" . Base::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 Base::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, Base::PAGE_ALL_PUBLISHERS); |
|
| 35 | + return Base::getCountGeneric("publishers", self::ALL_PUBLISHERS_ID, Base::PAGE_ALL_PUBLISHERS); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public static function getPublisherByBookId ($bookId) { |
|
| 39 | - $result = Base::getDb ()->prepare('select publishers.id as id, name |
|
| 38 | + public static function getPublisherByBookId($bookId) { |
|
| 39 | + $result = Base::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 = Base::getDb ()->prepare('select id, name |
|
| 49 | + public static function getPublisherById($publisherId) { |
|
| 50 | + $result = Base::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 | } |
@@ -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", |
@@ -38,14 +38,14 @@ |
||
| 38 | 38 | if ($post = $result->fetchObject ()) { |
| 39 | 39 | return new Tag ($post); |
| 40 | 40 | } |
| 41 | - return NULL; |
|
| 41 | + return null; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public static function getAllTags() { |
| 45 | 45 | return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag"); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 48 | + public static function getAllTagsByQuery($query, $n, $database = null, $numberPerPage = null) { |
|
| 49 | 49 | $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count"; |
| 50 | 50 | $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name'; |
| 51 | 51 | list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage); |
@@ -20,44 +20,44 @@ |
||
| 20 | 20 | $this->name = $post->name; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function getUri () { |
|
| 24 | - return "?page=".Base::PAGE_TAG_DETAIL."&id=$this->id"; |
|
| 23 | + public function getUri() { |
|
| 24 | + return "?page=" . Base::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 Base::getCountGeneric ("tags", self::ALL_TAGS_ID, Base::PAGE_ALL_TAGS); |
|
| 33 | + return Base::getCountGeneric("tags", self::ALL_TAGS_ID, Base::PAGE_ALL_TAGS); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public static function getTagById ($tagId) { |
|
| 37 | - $result = Base::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 = Base::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) = Base::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage); |
|
| 52 | + list ($totalNumber, $result) = Base::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 | } |
@@ -8,14 +8,14 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllBooks extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->title = localize ("allbooks.title"); |
|
| 14 | - if (getCurrentOption ("titles_split_first_letter") == 1) { |
|
| 13 | + $this->title = localize("allbooks.title"); |
|
| 14 | + if (getCurrentOption("titles_split_first_letter") == 1) { |
|
| 15 | 15 | $this->entryArray = Book::getAllBooks(); |
| 16 | 16 | } |
| 17 | 17 | else { |
| 18 | - list ($this->entryArray, $this->totalNumber) = Book::getBooks ($this->n); |
|
| 18 | + list ($this->entryArray, $this->totalNumber) = Book::getBooks($this->n); |
|
| 19 | 19 | } |
| 20 | 20 | $this->idPage = Book::ALL_BOOKS_ID; |
| 21 | 21 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | $this->title = localize ("allbooks.title"); |
| 14 | 14 | if (getCurrentOption ("titles_split_first_letter") == 1) { |
| 15 | 15 | $this->entryArray = Book::getAllBooks(); |
| 16 | - } |
|
| 17 | - else { |
|
| 16 | + } else { |
|
| 18 | 17 | list ($this->entryArray, $this->totalNumber) = Book::getBooks ($this->n); |
| 19 | 18 | } |
| 20 | 19 | $this->idPage = Book::ALL_BOOKS_ID; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllSeries extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | 13 | $this->title = localize("series.title"); |
| 14 | 14 | $this->entryArray = Serie::getAllSeries(); |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAbout extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $this->title = localize ("about.title"); |
|
| 13 | + $this->title = localize("about.title"); |
|
| 14 | 14 | } |
| 15 | 15 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PagePublisherDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $publisher = Publisher::getPublisherById ($this->idGet); |
|
| 13 | + $publisher = Publisher::getPublisherById($this->idGet); |
|
| 14 | 14 | $this->title = $publisher->name; |
| 15 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByPublisher ($this->idGet, $this->n); |
|
| 16 | - $this->idPage = $publisher->getEntryId (); |
|
| 15 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByPublisher($this->idGet, $this->n); |
|
| 16 | + $this->idPage = $publisher->getEntryId(); |
|
| 17 | 17 | } |
| 18 | 18 | } |