@@ -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,55 +86,55 @@ 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, $view = false) { |
|
111 | + public function getDataLink($rel, $title = NULL, $view = false) { |
|
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, $view); |
116 | 116 | } |
117 | 117 | |
118 | - return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view); |
|
118 | + return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title, NULL, $view); |
|
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 getViewHtmlLink () { |
|
125 | + public function getViewHtmlLink() { |
|
126 | 126 | return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href; |
127 | 127 | } |
128 | 128 | |
129 | - public function getLocalPath () { |
|
130 | - return $this->book->path . "/" . $this->getFilename (); |
|
129 | + public function getLocalPath() { |
|
130 | + return $this->book->path . "/" . $this->getFilename(); |
|
131 | 131 | } |
132 | 132 | |
133 | - public function getHtmlLinkWithRewriting ($title = NULL, $view = false) { |
|
133 | + public function getHtmlLinkWithRewriting($title = NULL, $view = false) { |
|
134 | 134 | global $config; |
135 | 135 | |
136 | 136 | $database = ""; |
137 | - if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/"; |
|
137 | + if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/"; |
|
138 | 138 | |
139 | 139 | $prefix = "download"; |
140 | 140 | if ($view) { |
@@ -143,33 +143,33 @@ discard block |
||
143 | 143 | $href = $prefix . "/" . $this->id . "/" . $database; |
144 | 144 | |
145 | 145 | if ($config['cops_provide_kepub'] == "1" && |
146 | - $this->isEpubValidOnKobo () && |
|
146 | + $this->isEpubValidOnKobo() && |
|
147 | 147 | preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) { |
148 | - $href .= rawurlencode ($this->getUpdatedFilenameKepub ()); |
|
148 | + $href .= rawurlencode($this->getUpdatedFilenameKepub()); |
|
149 | 149 | } else { |
150 | - $href .= rawurlencode ($this->getFilename ()); |
|
150 | + $href .= rawurlencode($this->getFilename()); |
|
151 | 151 | } |
152 | - return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title); |
|
152 | + return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title); |
|
153 | 153 | } |
154 | 154 | |
155 | - public static function getDataByBook ($book) { |
|
156 | - $out = array (); |
|
157 | - $result = parent::getDb ()->prepare('select id, format, name |
|
155 | + public static function getDataByBook($book) { |
|
156 | + $out = array(); |
|
157 | + $result = parent::getDb()->prepare('select id, format, name |
|
158 | 158 | from data where book = ?'); |
159 | - $result->execute (array ($book->id)); |
|
159 | + $result->execute(array($book->id)); |
|
160 | 160 | |
161 | - while ($post = $result->fetchObject ()) |
|
161 | + while ($post = $result->fetchObject()) |
|
162 | 162 | { |
163 | - array_push ($out, new Data ($post, $book)); |
|
163 | + array_push($out, new Data($post, $book)); |
|
164 | 164 | } |
165 | 165 | return $out; |
166 | 166 | } |
167 | 167 | |
168 | - public static function handleThumbnailLink ($urlParam, $height) { |
|
168 | + public static function handleThumbnailLink($urlParam, $height) { |
|
169 | 169 | global $config; |
170 | 170 | |
171 | - if (is_null ($height)) { |
|
172 | - if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
171 | + if (is_null($height)) { |
|
172 | + if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
173 | 173 | $height = $config['cops_opds_thumbnail_height']; |
174 | 174 | } |
175 | 175 | else |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | return $urlParam; |
185 | 185 | } |
186 | 186 | |
187 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
187 | + public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
188 | 188 | { |
189 | 189 | global $config; |
190 | 190 | |
191 | 191 | $urlParam = addURLParameter("", "data", $idData); |
192 | 192 | if ($view) $urlParam = addURLParameter($urlParam, "view", 1); |
193 | 193 | |
194 | - if (Base::useAbsolutePath () || |
|
194 | + if (Base::useAbsolutePath() || |
|
195 | 195 | $rel == Link::OPDS_THUMBNAIL_TYPE || |
196 | 196 | ($type == "epub" && $config['cops_update_epub-metadata'])) |
197 | 197 | { |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | $urlParam = self::handleThumbnailLink($urlParam, $height); |
201 | 201 | } |
202 | 202 | $urlParam = addURLParameter($urlParam, "id", $book->id); |
203 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
203 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
204 | 204 | if ($config['cops_thumbnail_handling'] != "1" && |
205 | 205 | !empty ($config['cops_thumbnail_handling']) && |
206 | 206 | $rel == Link::OPDS_THUMBNAIL_TYPE) { |
207 | - return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
207 | + return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
208 | 208 | } else { |
209 | - return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
209 | + return new Link("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | else |
213 | 213 | { |
214 | - return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); |
|
214 | + return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | } |
@@ -14,53 +14,53 @@ discard block |
||
14 | 14 | * @param Book $book |
15 | 15 | * @return array |
16 | 16 | */ |
17 | - public static function getBookContentArray ($book) { |
|
17 | + public static function getBookContentArray($book) { |
|
18 | 18 | global $config; |
19 | 19 | $i = 0; |
20 | - $preferedData = array (); |
|
20 | + $preferedData = array(); |
|
21 | 21 | foreach ($config['cops_prefered_format'] as $format) |
22 | 22 | { |
23 | 23 | if ($i == 2) { break; } |
24 | - if ($data = $book->getDataFormat ($format)) { |
|
24 | + if ($data = $book->getDataFormat($format)) { |
|
25 | 25 | $i++; |
26 | - array_push ($preferedData, array ("url" => $data->getHtmlLink (), |
|
27 | - "viewUrl" => $data->getViewHtmlLink (), "name" => $format)); |
|
26 | + array_push($preferedData, array("url" => $data->getHtmlLink(), |
|
27 | + "viewUrl" => $data->getViewHtmlLink(), "name" => $format)); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | 31 | $publisher = $book->getPublisher(); |
32 | - if (is_null ($publisher)) { |
|
32 | + if (is_null($publisher)) { |
|
33 | 33 | $pn = ""; |
34 | 34 | $pu = ""; |
35 | 35 | } else { |
36 | 36 | $pn = $publisher->name; |
37 | - $link = new LinkNavigation ($publisher->getUri ()); |
|
38 | - $pu = $link->hrefXhtml (); |
|
37 | + $link = new LinkNavigation($publisher->getUri()); |
|
38 | + $pu = $link->hrefXhtml(); |
|
39 | 39 | } |
40 | 40 | |
41 | - $serie = $book->getSerie (); |
|
42 | - if (is_null ($serie)) { |
|
41 | + $serie = $book->getSerie(); |
|
42 | + if (is_null($serie)) { |
|
43 | 43 | $sn = ""; |
44 | 44 | $scn = ""; |
45 | 45 | $su = ""; |
46 | 46 | } else { |
47 | 47 | $sn = $serie->name; |
48 | - $scn = str_format (localize ("content.series.data"), $book->seriesIndex, $serie->name); |
|
49 | - $link = new LinkNavigation ($serie->getUri ()); |
|
50 | - $su = $link->hrefXhtml (); |
|
48 | + $scn = str_format(localize("content.series.data"), $book->seriesIndex, $serie->name); |
|
49 | + $link = new LinkNavigation($serie->getUri()); |
|
50 | + $su = $link->hrefXhtml(); |
|
51 | 51 | } |
52 | 52 | $cc = $book->getCustomColumnValues($config['cops_calibre_custom_column_list'], true); |
53 | 53 | |
54 | - return array ("id" => $book->id, |
|
54 | + return array("id" => $book->id, |
|
55 | 55 | "hasCover" => $book->hasCover, |
56 | 56 | "preferedData" => $preferedData, |
57 | - "rating" => $book->getRating (), |
|
57 | + "rating" => $book->getRating(), |
|
58 | 58 | "publisherName" => $pn, |
59 | 59 | "publisherurl" => $pu, |
60 | - "pubDate" => $book->getPubDate (), |
|
61 | - "languagesName" => $book->getLanguages (), |
|
62 | - "authorsName" => $book->getAuthorsName (), |
|
63 | - "tagsName" => $book->getTagsName (), |
|
60 | + "pubDate" => $book->getPubDate(), |
|
61 | + "languagesName" => $book->getLanguages(), |
|
62 | + "authorsName" => $book->getAuthorsName(), |
|
63 | + "tagsName" => $book->getTagsName(), |
|
64 | 64 | "seriesName" => $sn, |
65 | 65 | "seriesIndex" => $book->seriesIndex, |
66 | 66 | "seriesCompleteName" => $scn, |
@@ -72,90 +72,90 @@ discard block |
||
72 | 72 | * @param Book $book |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public static function getFullBookContentArray ($book) { |
|
75 | + public static function getFullBookContentArray($book) { |
|
76 | 76 | global $config; |
77 | - $out = self::getBookContentArray ($book); |
|
78 | - $database = GetUrlParam (DB); |
|
77 | + $out = self::getBookContentArray($book); |
|
78 | + $database = GetUrlParam(DB); |
|
79 | 79 | |
80 | - $out ["coverurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml (); |
|
81 | - $out ["thumbnailurl"] = Data::getLink ($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml (); |
|
82 | - $out ["content"] = $book->getComment (false); |
|
83 | - $out ["datas"] = array (); |
|
84 | - $dataKindle = $book->GetMostInterestingDataToSendToKindle (); |
|
80 | + $out ["coverurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_IMAGE_TYPE, "cover.jpg", NULL)->hrefXhtml(); |
|
81 | + $out ["thumbnailurl"] = Data::getLink($book, "jpg", "image/jpeg", Link::OPDS_THUMBNAIL_TYPE, "cover.jpg", NULL, NULL, $config['cops_html_thumbnail_height'] * 2)->hrefXhtml(); |
|
82 | + $out ["content"] = $book->getComment(false); |
|
83 | + $out ["datas"] = array(); |
|
84 | + $dataKindle = $book->GetMostInterestingDataToSendToKindle(); |
|
85 | 85 | foreach ($book->getDatas() as $data) { |
86 | - $tab = array ("id" => $data->id, |
|
86 | + $tab = array("id" => $data->id, |
|
87 | 87 | "format" => $data->format, |
88 | - "url" => $data->getHtmlLink (), |
|
89 | - "viewUrl" => $data->getViewHtmlLink (), |
|
88 | + "url" => $data->getHtmlLink(), |
|
89 | + "viewUrl" => $data->getViewHtmlLink(), |
|
90 | 90 | "mail" => 0, |
91 | 91 | "readerUrl" => ""); |
92 | - if (!empty ($config['cops_mail_configuration']) && !is_null ($dataKindle) && $data->id == $dataKindle->id) { |
|
92 | + if (!empty ($config['cops_mail_configuration']) && !is_null($dataKindle) && $data->id == $dataKindle->id) { |
|
93 | 93 | $tab ["mail"] = 1; |
94 | 94 | } |
95 | 95 | if ($data->format == "EPUB") { |
96 | 96 | $tab ["readerUrl"] = "epubreader.php?data={$data->id}&db={$database}"; |
97 | 97 | } |
98 | - array_push ($out ["datas"], $tab); |
|
98 | + array_push($out ["datas"], $tab); |
|
99 | 99 | } |
100 | - $out ["authors"] = array (); |
|
101 | - foreach ($book->getAuthors () as $author) { |
|
102 | - $link = new LinkNavigation ($author->getUri ()); |
|
103 | - array_push ($out ["authors"], array ("name" => $author->name, "url" => $link->hrefXhtml ())); |
|
100 | + $out ["authors"] = array(); |
|
101 | + foreach ($book->getAuthors() as $author) { |
|
102 | + $link = new LinkNavigation($author->getUri()); |
|
103 | + array_push($out ["authors"], array("name" => $author->name, "url" => $link->hrefXhtml())); |
|
104 | 104 | } |
105 | - $out ["tags"] = array (); |
|
106 | - foreach ($book->getTags () as $tag) { |
|
107 | - $link = new LinkNavigation ($tag->getUri ()); |
|
108 | - array_push ($out ["tags"], array ("name" => $tag->name, "url" => $link->hrefXhtml ())); |
|
105 | + $out ["tags"] = array(); |
|
106 | + foreach ($book->getTags() as $tag) { |
|
107 | + $link = new LinkNavigation($tag->getUri()); |
|
108 | + array_push($out ["tags"], array("name" => $tag->name, "url" => $link->hrefXhtml())); |
|
109 | 109 | } |
110 | 110 | $out ["customcolumns_preview"] = $book->getCustomColumnValues($config['cops_calibre_custom_column_preview'], true); |
111 | 111 | |
112 | 112 | return $out; |
113 | 113 | } |
114 | 114 | |
115 | - public static function getContentArray ($entry) { |
|
115 | + public static function getContentArray($entry) { |
|
116 | 116 | if ($entry instanceof EntryBook) { |
117 | - $out = array ( "title" => $entry->title); |
|
118 | - $out ["book"] = self::getBookContentArray ($entry->book); |
|
117 | + $out = array("title" => $entry->title); |
|
118 | + $out ["book"] = self::getBookContentArray($entry->book); |
|
119 | 119 | return $out; |
120 | 120 | } |
121 | - return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement ); |
|
121 | + return array("title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink(), "number" => $entry->numberOfElement); |
|
122 | 122 | } |
123 | 123 | |
124 | - public static function getContentArrayTypeahead ($page) { |
|
125 | - $out = array (); |
|
124 | + public static function getContentArrayTypeahead($page) { |
|
125 | + $out = array(); |
|
126 | 126 | foreach ($page->entryArray as $entry) { |
127 | 127 | if ($entry instanceof EntryBook) { |
128 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ())); |
|
128 | + array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl())); |
|
129 | 129 | } else { |
130 | - if (empty ($entry->className) xor Base::noDatabaseSelected ()) { |
|
131 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ())); |
|
130 | + if (empty ($entry->className) xor Base::noDatabaseSelected()) { |
|
131 | + array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink())); |
|
132 | 132 | } else { |
133 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ())); |
|
133 | + array_push($out, array("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink())); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
137 | 137 | return $out; |
138 | 138 | } |
139 | 139 | |
140 | - public static function addCompleteArray ($in) { |
|
140 | + public static function addCompleteArray($in) { |
|
141 | 141 | global $config; |
142 | 142 | $out = $in; |
143 | 143 | |
144 | - $out ["c"] = array ("version" => VERSION, "i18n" => array ( |
|
144 | + $out ["c"] = array("version" => VERSION, "i18n" => array( |
|
145 | 145 | "coverAlt" => localize("i18n.coversection"), |
146 | 146 | "authorsTitle" => localize("authors.title"), |
147 | 147 | "bookwordTitle" => localize("bookword.title"), |
148 | 148 | "tagsTitle" => localize("tags.title"), |
149 | 149 | "seriesTitle" => localize("series.title"), |
150 | - "customizeTitle" => localize ("customize.title"), |
|
151 | - "aboutTitle" => localize ("about.title"), |
|
152 | - "previousAlt" => localize ("paging.previous.alternate"), |
|
153 | - "nextAlt" => localize ("paging.next.alternate"), |
|
154 | - "searchAlt" => localize ("search.alternate"), |
|
155 | - "sortAlt" => localize ("sort.alternate"), |
|
156 | - "homeAlt" => localize ("home.alternate"), |
|
157 | - "cogAlt" => localize ("cog.alternate"), |
|
158 | - "permalinkAlt" => localize ("permalink.alternate"), |
|
150 | + "customizeTitle" => localize("customize.title"), |
|
151 | + "aboutTitle" => localize("about.title"), |
|
152 | + "previousAlt" => localize("paging.previous.alternate"), |
|
153 | + "nextAlt" => localize("paging.next.alternate"), |
|
154 | + "searchAlt" => localize("search.alternate"), |
|
155 | + "sortAlt" => localize("sort.alternate"), |
|
156 | + "homeAlt" => localize("home.alternate"), |
|
157 | + "cogAlt" => localize("cog.alternate"), |
|
158 | + "permalinkAlt" => localize("permalink.alternate"), |
|
159 | 159 | "publisherName" => localize("publisher.name"), |
160 | 160 | "pubdateTitle" => localize("pubdate.title"), |
161 | 161 | "languagesTitle" => localize("language.title"), |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | "sortorderAsc" => localize("search.sortorder.asc"), |
164 | 164 | "sortorderDesc" => localize("search.sortorder.desc"), |
165 | 165 | "customizeEmail" => localize("customize.email")), |
166 | - "url" => array ( |
|
166 | + "url" => array( |
|
167 | 167 | "detailUrl" => "index.php?page=13&id={0}&db={1}", |
168 | 168 | "coverUrl" => "fetch.php?id={0}&db={1}", |
169 | 169 | "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), |
170 | - "config" => array ( |
|
170 | + "config" => array( |
|
171 | 171 | "use_fancyapps" => $config ["cops_use_fancyapps"], |
172 | 172 | "max_item_per_page" => $config['cops_max_item_per_page'], |
173 | 173 | "kindleHack" => "", |
174 | - "server_side_rendering" => useServerSideRendering (), |
|
174 | + "server_side_rendering" => useServerSideRendering(), |
|
175 | 175 | "html_tag_filter" => $config['cops_html_tag_filter'])); |
176 | 176 | if ($config['cops_thumbnail_handling'] == "1") { |
177 | 177 | $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"]; |
@@ -184,32 +184,32 @@ discard block |
||
184 | 184 | return $out; |
185 | 185 | } |
186 | 186 | |
187 | - public static function getJson ($complete = false) { |
|
187 | + public static function getJson($complete = false) { |
|
188 | 188 | global $config; |
189 | - $page = getURLParam ("page", Base::PAGE_INDEX); |
|
190 | - $query = getURLParam ("query"); |
|
191 | - $search = getURLParam ("search"); |
|
192 | - $qid = getURLParam ("id"); |
|
193 | - $n = getURLParam ("n", "1"); |
|
194 | - $database = GetUrlParam (DB); |
|
189 | + $page = getURLParam("page", Base::PAGE_INDEX); |
|
190 | + $query = getURLParam("query"); |
|
191 | + $search = getURLParam("search"); |
|
192 | + $qid = getURLParam("id"); |
|
193 | + $n = getURLParam("n", "1"); |
|
194 | + $database = GetUrlParam(DB); |
|
195 | 195 | |
196 | - $currentPage = Page::getPage ($page, $qid, $query, $n); |
|
197 | - $currentPage->InitializeContent (); |
|
196 | + $currentPage = Page::getPage($page, $qid, $query, $n); |
|
197 | + $currentPage->InitializeContent(); |
|
198 | 198 | |
199 | 199 | if ($search) { |
200 | - return self::getContentArrayTypeahead ($currentPage); |
|
200 | + return self::getContentArrayTypeahead($currentPage); |
|
201 | 201 | } |
202 | 202 | |
203 | - $out = array ( "title" => $currentPage->title); |
|
204 | - $entries = array (); |
|
203 | + $out = array("title" => $currentPage->title); |
|
204 | + $entries = array(); |
|
205 | 205 | foreach ($currentPage->entryArray as $entry) { |
206 | - array_push ($entries, self::getContentArray ($entry)); |
|
206 | + array_push($entries, self::getContentArray($entry)); |
|
207 | 207 | } |
208 | - if (!is_null ($currentPage->book)) { |
|
209 | - $out ["book"] = self::getFullBookContentArray ($currentPage->book); |
|
208 | + if (!is_null($currentPage->book)) { |
|
209 | + $out ["book"] = self::getFullBookContentArray($currentPage->book); |
|
210 | 210 | } |
211 | - $out ["databaseId"] = GetUrlParam (DB, ""); |
|
212 | - $out ["databaseName"] = Base::getDbName (); |
|
211 | + $out ["databaseId"] = GetUrlParam(DB, ""); |
|
212 | + $out ["databaseName"] = Base::getDbName(); |
|
213 | 213 | if ($out ["databaseId"] == "") { |
214 | 214 | $out ["databaseName"] = ""; |
215 | 215 | } |
@@ -218,42 +218,42 @@ discard block |
||
218 | 218 | $out ["fullTitle"] = $out ["databaseName"] . " > " . $out ["fullTitle"]; |
219 | 219 | } |
220 | 220 | $out ["page"] = $page; |
221 | - $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled () ? 1 : 0; |
|
221 | + $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled()?1:0; |
|
222 | 222 | $out ["entries"] = $entries; |
223 | 223 | $out ["isPaginated"] = 0; |
224 | - if ($currentPage->isPaginated ()) { |
|
225 | - $prevLink = $currentPage->getPrevLink (); |
|
226 | - $nextLink = $currentPage->getNextLink (); |
|
224 | + if ($currentPage->isPaginated()) { |
|
225 | + $prevLink = $currentPage->getPrevLink(); |
|
226 | + $nextLink = $currentPage->getNextLink(); |
|
227 | 227 | $out ["isPaginated"] = 1; |
228 | 228 | $out ["prevLink"] = ""; |
229 | - if (!is_null ($prevLink)) { |
|
230 | - $out ["prevLink"] = $prevLink->hrefXhtml (); |
|
229 | + if (!is_null($prevLink)) { |
|
230 | + $out ["prevLink"] = $prevLink->hrefXhtml(); |
|
231 | 231 | } |
232 | 232 | $out ["nextLink"] = ""; |
233 | - if (!is_null ($nextLink)) { |
|
234 | - $out ["nextLink"] = $nextLink->hrefXhtml (); |
|
233 | + if (!is_null($nextLink)) { |
|
234 | + $out ["nextLink"] = $nextLink->hrefXhtml(); |
|
235 | 235 | } |
236 | - $out ["maxPage"] = $currentPage->getMaxPage (); |
|
236 | + $out ["maxPage"] = $currentPage->getMaxPage(); |
|
237 | 237 | $out ["currentPage"] = $currentPage->n; |
238 | 238 | } |
239 | - if (!is_null (getURLParam ("complete")) || $complete) { |
|
240 | - $out = self::addCompleteArray ($out); |
|
239 | + if (!is_null(getURLParam("complete")) || $complete) { |
|
240 | + $out = self::addCompleteArray($out); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $out ["containsBook"] = 0; |
244 | - if ($currentPage->containsBook ()) { |
|
244 | + if ($currentPage->containsBook()) { |
|
245 | 245 | $out ["containsBook"] = 1; |
246 | 246 | } |
247 | 247 | |
248 | - $out["abouturl"] = "index.php" . addURLParameter ("?page=" . Base::PAGE_ABOUT, DB, $database); |
|
248 | + $out["abouturl"] = "index.php" . addURLParameter("?page=" . Base::PAGE_ABOUT, DB, $database); |
|
249 | 249 | |
250 | 250 | if ($page == Base::PAGE_ABOUT) { |
251 | - $temp = preg_replace ("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html')); |
|
251 | + $temp = preg_replace("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html')); |
|
252 | 252 | $out ["fullhtml"] = $temp; |
253 | 253 | } |
254 | 254 | |
255 | 255 | $out ["homeurl"] = "index.php"; |
256 | - if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter ("", DB, $database); |
|
256 | + if ($page != Base::PAGE_INDEX && !is_null($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter("", DB, $database); |
|
257 | 257 | |
258 | 258 | return $out; |
259 | 259 | } |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | |
9 | 9 | require 'config.php'; |
10 | 10 | |
11 | -define ('VERSION', '1.2.0'); |
|
12 | -define ('DB', 'db'); |
|
11 | +define('VERSION', '1.2.0'); |
|
12 | +define('DB', 'db'); |
|
13 | 13 | date_default_timezone_set($config['default_timezone']); |
14 | 14 | |
15 | 15 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | function serverSideRender($data) |
23 | 23 | { |
24 | 24 | // Get the templates |
25 | - $theme = getCurrentTemplate (); |
|
25 | + $theme = getCurrentTemplate(); |
|
26 | 26 | $header = file_get_contents('templates/' . $theme . '/header.html'); |
27 | 27 | $footer = file_get_contents('templates/' . $theme . '/footer.html'); |
28 | 28 | $main = file_get_contents('templates/' . $theme . '/main.html'); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | $page = file_get_contents('templates/' . $theme . '/page.html'); |
31 | 31 | |
32 | 32 | // Generate the function for the template |
33 | - $template = new doT (); |
|
34 | - $dot = $template->template ($page, array ('bookdetail' => $bookdetail, |
|
33 | + $template = new doT(); |
|
34 | + $dot = $template->template($page, array('bookdetail' => $bookdetail, |
|
35 | 35 | 'header' => $header, |
36 | 36 | 'footer' => $footer, |
37 | 37 | 'main' => $main)); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | // Execute the template |
44 | 44 | if (!empty ($data)) { |
45 | - return $dot ($data); |
|
45 | + return $dot($data); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return NULL; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | function notFound() |
60 | 60 | { |
61 | - header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); |
|
61 | + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
|
62 | 62 | header('Status: 404 Not Found'); |
63 | 63 | |
64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | { |
77 | 77 | global $config; |
78 | 78 | if (isset($_COOKIE[$option])) { |
79 | - if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) { |
|
80 | - return explode (',', $_COOKIE[$option]); |
|
79 | + if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) { |
|
80 | + return explode(',', $_COOKIE[$option]); |
|
81 | 81 | } else { |
82 | 82 | return $_COOKIE[$option]; |
83 | 83 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | |
92 | 92 | function getCurrentCss() |
93 | 93 | { |
94 | - return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
94 | + return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | function getCurrentTemplate() |
98 | 98 | { |
99 | - return getCurrentOption ('template'); |
|
99 | + return getCurrentOption('template'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | function getUrlWithVersion($url) |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | libxml_use_internal_errors(true); |
161 | 161 | |
162 | 162 | $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . |
163 | - $html . '</body></html>'); // Load the HTML |
|
163 | + $html . '</body></html>'); // Load the HTML |
|
164 | 164 | $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream |
165 | 165 | $output = xml2xhtml($output); |
166 | - if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
166 | + if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
167 | 167 | $output = $matches [1]; // Remove <html><body> |
168 | 168 | } |
169 | 169 | /* |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | */ |
177 | 177 | |
178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
178 | + if (!are_libxml_errors_ok()) $output = 'HTML code not valid.'; |
|
179 | 179 | |
180 | 180 | libxml_use_internal_errors(false); |
181 | 181 | return $output; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | //echo var_dump($langs); |
265 | 265 | $lang_file = NULL; |
266 | 266 | foreach ($langs as $language => $val) { |
267 | - $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
|
267 | + $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json'; |
|
268 | 268 | if (file_exists($temp_file)) { |
269 | 269 | $lang = $language; |
270 | 270 | $lang_file = $temp_file; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | } |
274 | 274 | if (empty ($lang_file)) { |
275 | - $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json'; |
|
275 | + $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json'; |
|
276 | 276 | } |
277 | 277 | return array($lang, $lang_file); |
278 | 278 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * This method is based on this page |
282 | 282 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ |
283 | 283 | */ |
284 | -function localize($phrase, $count=-1, $reset=false) |
|
284 | +function localize($phrase, $count = -1, $reset = false) |
|
285 | 285 | { |
286 | 286 | global $config; |
287 | 287 | if ($count == 0) |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $lang_file_en = NULL; |
302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
303 | 303 | if ($lang != 'en') { |
304 | - $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
|
304 | + $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json'; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $lang_file_content = file_get_contents($lang_file); |
@@ -309,18 +309,18 @@ discard block |
||
309 | 309 | $translations = json_decode($lang_file_content, true); |
310 | 310 | |
311 | 311 | /* Clean the array of all unfinished translations */ |
312 | - foreach (array_keys ($translations) as $key) { |
|
313 | - if (preg_match ('/^##TODO##/', $key)) { |
|
312 | + foreach (array_keys($translations) as $key) { |
|
313 | + if (preg_match('/^##TODO##/', $key)) { |
|
314 | 314 | unset ($translations [$key]); |
315 | 315 | } |
316 | 316 | } |
317 | 317 | if (!is_null($lang_file_en)) { |
318 | 318 | $lang_file_content = file_get_contents($lang_file_en); |
319 | 319 | $translations_en = json_decode($lang_file_content, true); |
320 | - $translations = array_merge ($translations_en, $translations); |
|
320 | + $translations = array_merge($translations_en, $translations); |
|
321 | 321 | } |
322 | 322 | } |
323 | - if (array_key_exists ($phrase, $translations)) { |
|
323 | + if (array_key_exists($phrase, $translations)) { |
|
324 | 324 | return $translations[$phrase]; |
325 | 325 | } |
326 | 326 | return $phrase; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $urlParams = ''; |
333 | 333 | } |
334 | 334 | $start = ''; |
335 | - if (preg_match ('#^\?(.*)#', $urlParams, $matches)) { |
|
335 | + if (preg_match('#^\?(.*)#', $urlParams, $matches)) { |
|
336 | 336 | $start = '?'; |
337 | 337 | $urlParams = $matches[1]; |
338 | 338 | } |