@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllAuthors extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | 13 | $this->title = localize("authors.title"); |
| 14 | - if (getCurrentOption ("author_split_first_letter") == 1) { |
|
| 14 | + if (getCurrentOption("author_split_first_letter") == 1) { |
|
| 15 | 15 | $this->entryArray = Author::getAllAuthorsByFirstLetter(); |
| 16 | 16 | } |
| 17 | 17 | else { |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | public function getCustom($id) |
| 59 | 59 | { |
| 60 | - return new CustomColumn ($id, str_format(localize("customcolumn.stars", $id / 2), $id / 2), $this); |
|
| 60 | + return new CustomColumn($id, str_format(localize("customcolumn.stars", $id / 2), $id / 2), $this); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | protected function getAllCustomValuesFromDatabase() |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAllCustoms extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $customId = getURLParam ("custom", NULL); |
|
| 13 | + $customId = getURLParam("custom", NULL); |
|
| 14 | 14 | $columnType = CustomColumnType::createByCustomID($customId); |
| 15 | 15 | |
| 16 | 16 | $this->title = $columnType->getTitle(); |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | 11 | public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
| 12 | - parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
|
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 12 | + parent::__construct($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
|
| 13 | + if (!is_null(GetUrlParam(DB))) $this->href = addURLParameter($this->href, DB, GetUrlParam(DB)); |
|
| 14 | 14 | $this->href = parent::getScriptName() . $this->href; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -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 | |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageRatingDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $rating = Rating::getRatingById ($this->idGet); |
|
| 14 | - $this->idPage = $rating->getEntryId (); |
|
| 15 | - $this->title =str_format (localize ("ratingword", $rating->name/2), $rating->name/2); |
|
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating ($this->idGet, $this->n); |
|
| 13 | + $rating = Rating::getRatingById($this->idGet); |
|
| 14 | + $this->idPage = $rating->getEntryId(); |
|
| 15 | + $this->title = str_format(localize("ratingword", $rating->name / 2), $rating->name / 2); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageAuthorDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $author = Author::getAuthorById ($this->idGet); |
|
| 14 | - $this->idPage = $author->getEntryId (); |
|
| 13 | + $author = Author::getAuthorById($this->idGet); |
|
| 14 | + $this->idPage = $author->getEntryId(); |
|
| 15 | 15 | $this->title = $author->name; |
| 16 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksByAuthor ($this->idGet, $this->n); |
|
| 16 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksByAuthor($this->idGet, $this->n); |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -59,25 +59,25 @@ discard block |
||
| 59 | 59 | $this->id = $post->id; |
| 60 | 60 | $this->name = $post->name; |
| 61 | 61 | $this->format = $post->format; |
| 62 | - $this->realFormat = str_replace ("ORIGINAL_", "", $post->format); |
|
| 63 | - $this->extension = strtolower ($this->realFormat); |
|
| 62 | + $this->realFormat = str_replace("ORIGINAL_", "", $post->format); |
|
| 63 | + $this->extension = strtolower($this->realFormat); |
|
| 64 | 64 | $this->book = $book; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public function isKnownType () { |
|
| 68 | - return array_key_exists ($this->extension, self::$mimetypes); |
|
| 67 | + public function isKnownType() { |
|
| 68 | + return array_key_exists($this->extension, self::$mimetypes); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function getMimeType () { |
|
| 71 | + public function getMimeType() { |
|
| 72 | 72 | $result = "application/octet-stream"; |
| 73 | - if ($this->isKnownType ()) { |
|
| 73 | + if ($this->isKnownType()) { |
|
| 74 | 74 | return self::$mimetypes [$this->extension]; |
| 75 | 75 | } elseif (function_exists('finfo_open') === true) { |
| 76 | 76 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 77 | 77 | |
| 78 | 78 | if (is_resource($finfo) === true) |
| 79 | 79 | { |
| 80 | - $result = finfo_file($finfo, $this->getLocalPath ()); |
|
| 80 | + $result = finfo_file($finfo, $this->getLocalPath()); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | finfo_close($finfo); |
@@ -86,82 +86,82 @@ discard block |
||
| 86 | 86 | return $result; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function isEpubValidOnKobo () { |
|
| 89 | + public function isEpubValidOnKobo() { |
|
| 90 | 90 | return $this->format == "EPUB" || $this->format == "KEPUB"; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function getFilename () { |
|
| 94 | - return $this->name . "." . strtolower ($this->format); |
|
| 93 | + public function getFilename() { |
|
| 94 | + return $this->name . "." . strtolower($this->format); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function getUpdatedFilename () { |
|
| 98 | - return $this->book->getAuthorsSort () . " - " . $this->book->title; |
|
| 97 | + public function getUpdatedFilename() { |
|
| 98 | + return $this->book->getAuthorsSort() . " - " . $this->book->title; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function getUpdatedFilenameEpub () { |
|
| 102 | - return $this->getUpdatedFilename () . ".epub"; |
|
| 101 | + public function getUpdatedFilenameEpub() { |
|
| 102 | + return $this->getUpdatedFilename() . ".epub"; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function getUpdatedFilenameKepub () { |
|
| 106 | - $str = $this->getUpdatedFilename () . ".kepub.epub"; |
|
| 105 | + public function getUpdatedFilenameKepub() { |
|
| 106 | + $str = $this->getUpdatedFilename() . ".kepub.epub"; |
|
| 107 | 107 | return str_replace(array(':', '#', '&'), |
| 108 | - array('-', '-', ' '), $str ); |
|
| 108 | + array('-', '-', ' '), $str); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - public function getDataLink ($rel, $title = NULL) { |
|
| 111 | + public function getDataLink($rel, $title = NULL) { |
|
| 112 | 112 | global $config; |
| 113 | 113 | |
| 114 | 114 | if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") { |
| 115 | 115 | return $this->getHtmlLinkWithRewriting($title); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title); |
|
| 118 | + return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function getHtmlLink () { |
|
| 121 | + public function getHtmlLink() { |
|
| 122 | 122 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function getLocalPath () { |
|
| 126 | - return $this->book->path . "/" . $this->getFilename (); |
|
| 125 | + public function getLocalPath() { |
|
| 126 | + return $this->book->path . "/" . $this->getFilename(); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - public function getHtmlLinkWithRewriting ($title = NULL) { |
|
| 129 | + public function getHtmlLinkWithRewriting($title = NULL) { |
|
| 130 | 130 | global $config; |
| 131 | 131 | |
| 132 | 132 | $database = ""; |
| 133 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; |
|
| 133 | + if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/"; |
|
| 134 | 134 | |
| 135 | 135 | $href = "download/" . $this->id . "/" . $database; |
| 136 | 136 | |
| 137 | 137 | if ($config['cops_provide_kepub'] == "1" && |
| 138 | - $this->isEpubValidOnKobo () && |
|
| 138 | + $this->isEpubValidOnKobo() && |
|
| 139 | 139 | preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
| 140 | - $href .= rawurlencode ($this->getUpdatedFilenameKepub ()); |
|
| 140 | + $href .= rawurlencode($this->getUpdatedFilenameKepub()); |
|
| 141 | 141 | } else { |
| 142 | - $href .= rawurlencode ($this->getFilename ()); |
|
| 142 | + $href .= rawurlencode($this->getFilename()); |
|
| 143 | 143 | } |
| 144 | - return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); |
|
| 144 | + return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public static function getDataByBook ($book) { |
|
| 148 | - $out = array (); |
|
| 149 | - $result = parent::getDb ()->prepare('select id, format, name |
|
| 147 | + public static function getDataByBook($book) { |
|
| 148 | + $out = array(); |
|
| 149 | + $result = parent::getDb()->prepare('select id, format, name |
|
| 150 | 150 | from data where book = ?'); |
| 151 | - $result->execute (array ($book->id)); |
|
| 151 | + $result->execute(array($book->id)); |
|
| 152 | 152 | |
| 153 | - while ($post = $result->fetchObject ()) |
|
| 153 | + while ($post = $result->fetchObject()) |
|
| 154 | 154 | { |
| 155 | - array_push ($out, new Data ($post, $book)); |
|
| 155 | + array_push($out, new Data($post, $book)); |
|
| 156 | 156 | } |
| 157 | 157 | return $out; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public static function handleThumbnailLink ($urlParam, $height) { |
|
| 160 | + public static function handleThumbnailLink($urlParam, $height) { |
|
| 161 | 161 | global $config; |
| 162 | 162 | |
| 163 | - if (is_null ($height)) { |
|
| 164 | - if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
| 163 | + if (is_null($height)) { |
|
| 164 | + if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
| 165 | 165 | $height = $config['cops_opds_thumbnail_height']; |
| 166 | 166 | } |
| 167 | 167 | else |
@@ -176,13 +176,13 @@ discard block |
||
| 176 | 176 | return $urlParam; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) |
|
| 179 | + public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL) |
|
| 180 | 180 | { |
| 181 | 181 | global $config; |
| 182 | 182 | |
| 183 | 183 | $urlParam = addURLParameter("", "data", $idData); |
| 184 | 184 | |
| 185 | - if (Base::useAbsolutePath () || |
|
| 185 | + if (Base::useAbsolutePath() || |
|
| 186 | 186 | $rel == Link::OPDS_THUMBNAIL_TYPE || |
| 187 | 187 | ($type == "epub" && $config['cops_update_epub-metadata'])) |
| 188 | 188 | { |
@@ -191,18 +191,18 @@ discard block |
||
| 191 | 191 | $urlParam = self::handleThumbnailLink($urlParam, $height); |
| 192 | 192 | } |
| 193 | 193 | $urlParam = addURLParameter($urlParam, "id", $book->id); |
| 194 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
| 194 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
| 195 | 195 | if ($config['cops_thumbnail_handling'] != "1" && |
| 196 | 196 | !empty ($config['cops_thumbnail_handling']) && |
| 197 | 197 | $rel == Link::OPDS_THUMBNAIL_TYPE) { |
| 198 | - return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
| 198 | + return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
| 199 | 199 | } else { |
| 200 | - return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
| 200 | + return new Link("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | else |
| 204 | 204 | { |
| 205 | - return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); |
|
| 205 | + return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title); |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class PageSerieDetail extends Page |
| 10 | 10 | { |
| 11 | - public function InitializeContent () |
|
| 11 | + public function InitializeContent() |
|
| 12 | 12 | { |
| 13 | - $serie = Serie::getSerieById ($this->idGet); |
|
| 13 | + $serie = Serie::getSerieById($this->idGet); |
|
| 14 | 14 | $this->title = $serie->name; |
| 15 | - list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries ($this->idGet, $this->n); |
|
| 16 | - $this->idPage = $serie->getEntryId (); |
|
| 15 | + list ($this->entryArray, $this->totalNumber) = Book::getBooksBySeries($this->idGet, $this->n); |
|
| 16 | + $this->idPage = $serie->getEntryId(); |
|
| 17 | 17 | } |
| 18 | 18 | } |