@@ -25,69 +25,69 @@ |
||
25 | 25 | $this->sort = $post->sort; |
26 | 26 | } |
27 | 27 | |
28 | - public function getUri () { |
|
29 | - return "?page=".parent::PAGE_AUTHOR_DETAIL."&id=$this->id"; |
|
28 | + public function getUri() { |
|
29 | + return "?page=" . parent::PAGE_AUTHOR_DETAIL . "&id=$this->id"; |
|
30 | 30 | } |
31 | 31 | |
32 | - public function getEntryId () { |
|
33 | - return self::ALL_AUTHORS_ID.":".$this->id; |
|
32 | + public function getEntryId() { |
|
33 | + return self::ALL_AUTHORS_ID . ":" . $this->id; |
|
34 | 34 | } |
35 | 35 | |
36 | - public static function getEntryIdByLetter ($startingLetter) { |
|
37 | - return self::ALL_AUTHORS_ID.":letter:".$startingLetter; |
|
36 | + public static function getEntryIdByLetter($startingLetter) { |
|
37 | + return self::ALL_AUTHORS_ID . ":letter:" . $startingLetter; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public static function getCount() { |
41 | 41 | // str_format (localize("authors.alphabetical", count(array)) |
42 | - return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); |
|
42 | + return parent::getCountGeneric("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function getAllAuthorsByFirstLetter() { |
46 | - list (, $result) = parent::executeQuery ("select {0} |
|
46 | + list (, $result) = parent::executeQuery("select {0} |
|
47 | 47 | from authors |
48 | 48 | group by substr (upper (sort), 1, 1) |
49 | -order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array (), -1); |
|
49 | +order by substr (upper (sort), 1, 1)", "substr (upper (sort), 1, 1) as title, count(*) as count", "", array(), -1); |
|
50 | 50 | $entryArray = array(); |
51 | - while ($post = $result->fetchObject ()) |
|
51 | + while ($post = $result->fetchObject()) |
|
52 | 52 | { |
53 | - array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title), |
|
54 | - str_format (localize("authorword", $post->count), $post->count), "text", |
|
55 | - array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))), "", $post->count)); |
|
53 | + array_push($entryArray, new Entry($post->title, Author::getEntryIdByLetter($post->title), |
|
54 | + str_format(localize("authorword", $post->count), $post->count), "text", |
|
55 | + array(new LinkNavigation("?page=" . parent::PAGE_AUTHORS_FIRST_LETTER . "&id=" . rawurlencode($post->title))), "", $post->count)); |
|
56 | 56 | } |
57 | 57 | return $entryArray; |
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function getAuthorsByStartingLetter($letter) { |
61 | - return self::getEntryArray (self::SQL_AUTHORS_BY_FIRST_LETTER, array ($letter . "%")); |
|
61 | + return self::getEntryArray(self::SQL_AUTHORS_BY_FIRST_LETTER, array($letter . "%")); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public static function getAuthorsForSearch($query) { |
65 | - return self::getEntryArray (self::SQL_AUTHORS_FOR_SEARCH, array ($query . "%", $query . "%")); |
|
65 | + return self::getEntryArray(self::SQL_AUTHORS_FOR_SEARCH, array($query . "%", $query . "%")); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function getAllAuthors() { |
69 | - return self::getEntryArray (self::SQL_ALL_AUTHORS, array ()); |
|
69 | + return self::getEntryArray(self::SQL_ALL_AUTHORS, array()); |
|
70 | 70 | } |
71 | 71 | |
72 | - public static function getEntryArray ($query, $params) { |
|
73 | - return Base::getEntryArrayWithBookNumber ($query, self::AUTHOR_COLUMNS, $params, "Author"); |
|
72 | + public static function getEntryArray($query, $params) { |
|
73 | + return Base::getEntryArrayWithBookNumber($query, self::AUTHOR_COLUMNS, $params, "Author"); |
|
74 | 74 | } |
75 | 75 | |
76 | - public static function getAuthorById ($authorId) { |
|
77 | - $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); |
|
78 | - $result->execute (array ($authorId)); |
|
79 | - $post = $result->fetchObject (); |
|
80 | - return new Author ($post); |
|
76 | + public static function getAuthorById($authorId) { |
|
77 | + $result = parent::getDb()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?'); |
|
78 | + $result->execute(array($authorId)); |
|
79 | + $post = $result->fetchObject(); |
|
80 | + return new Author($post); |
|
81 | 81 | } |
82 | 82 | |
83 | - public static function getAuthorByBookId ($bookId) { |
|
84 | - $result = parent::getDb ()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link |
|
83 | + public static function getAuthorByBookId($bookId) { |
|
84 | + $result = parent::getDb()->prepare('select authors.id as id, authors.name as name, authors.sort as sort from authors, books_authors_link |
|
85 | 85 | where author = authors.id |
86 | 86 | and book = ? order by books_authors_link.id'); |
87 | - $result->execute (array ($bookId)); |
|
88 | - $authorArray = array (); |
|
89 | - while ($post = $result->fetchObject ()) { |
|
90 | - array_push ($authorArray, new Author ($post)); |
|
87 | + $result->execute(array($bookId)); |
|
88 | + $authorArray = array(); |
|
89 | + while ($post = $result->fetchObject()) { |
|
90 | + array_push($authorArray, new Author($post)); |
|
91 | 91 | } |
92 | 92 | return $authorArray; |
93 | 93 | } |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | |
9 | 9 | class PageCustomize extends Page |
10 | 10 | { |
11 | - private function isChecked ($key, $testedValue = 1) { |
|
12 | - $value = getCurrentOption ($key); |
|
13 | - if (is_array ($value)) { |
|
14 | - if (in_array ($testedValue, $value)) { |
|
11 | + private function isChecked($key, $testedValue = 1) { |
|
12 | + $value = getCurrentOption($key); |
|
13 | + if (is_array($value)) { |
|
14 | + if (in_array($testedValue, $value)) { |
|
15 | 15 | return "checked='checked'"; |
16 | 16 | } |
17 | 17 | } else { |
@@ -22,39 +22,39 @@ discard block |
||
22 | 22 | return ""; |
23 | 23 | } |
24 | 24 | |
25 | - private function isSelected ($key, $value) { |
|
26 | - if (getCurrentOption ($key) == $value) { |
|
25 | + private function isSelected($key, $value) { |
|
26 | + if (getCurrentOption($key) == $value) { |
|
27 | 27 | return "selected='selected'"; |
28 | 28 | } |
29 | 29 | return ""; |
30 | 30 | } |
31 | 31 | |
32 | - private function getTemplateList () { |
|
33 | - $result = array (); |
|
34 | - foreach (glob ("templates/*") as $filename) { |
|
35 | - if (preg_match ('/templates\/(.*)/', $filename, $m)) { |
|
36 | - array_push ($result, $m [1]); |
|
32 | + private function getTemplateList() { |
|
33 | + $result = array(); |
|
34 | + foreach (glob("templates/*") as $filename) { |
|
35 | + if (preg_match('/templates\/(.*)/', $filename, $m)) { |
|
36 | + array_push($result, $m [1]); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | return $result; |
40 | 40 | } |
41 | 41 | |
42 | - private function getStyleList () { |
|
43 | - $result = array (); |
|
44 | - foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
|
45 | - if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
46 | - array_push ($result, $m [1]); |
|
42 | + private function getStyleList() { |
|
43 | + $result = array(); |
|
44 | + foreach (glob("templates/" . getCurrentTemplate() . "/styles/style-*.css") as $filename) { |
|
45 | + if (preg_match('/styles\/style-(.*?)\.css/', $filename, $m)) { |
|
46 | + array_push($result, $m [1]); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public function InitializeContent () |
|
52 | + public function InitializeContent() |
|
53 | 53 | { |
54 | - $this->title = localize ("customize.title"); |
|
55 | - $this->entryArray = array (); |
|
54 | + $this->title = localize("customize.title"); |
|
55 | + $this->entryArray = array(); |
|
56 | 56 | |
57 | - $ignoredBaseArray = array (PageQueryResult::SCOPE_AUTHOR, |
|
57 | + $ignoredBaseArray = array(PageQueryResult::SCOPE_AUTHOR, |
|
58 | 58 | PageQueryResult::SCOPE_TAG, |
59 | 59 | PageQueryResult::SCOPE_SERIES, |
60 | 60 | PageQueryResult::SCOPE_PUBLISHER, |
@@ -65,60 +65,60 @@ discard block |
||
65 | 65 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
66 | 66 | $content .= "<select id='template' onchange='updateCookie (this); window.location=$(\".headleft\").attr(\"href\");'>"; |
67 | 67 | |
68 | - foreach ($this-> getTemplateList () as $filename) { |
|
69 | - $content .= "<option value='{$filename}' " . $this->isSelected ("template", $filename) . ">{$filename}</option>"; |
|
68 | + foreach ($this-> getTemplateList() as $filename) { |
|
69 | + $content .= "<option value='{$filename}' " . $this->isSelected("template", $filename) . ">{$filename}</option>"; |
|
70 | 70 | } |
71 | 71 | $content .= '</select>'; |
72 | 72 | } else { |
73 | - foreach ($this-> getTemplateList () as $filename) { |
|
74 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this); window.location=$(\".headleft\").attr(\"href\");' id='template' name='template' value='{$filename}' " . $this->isChecked ("template", $filename) . " /><label for='template-{$filename}'> {$filename} </label>"; |
|
73 | + foreach ($this-> getTemplateList() as $filename) { |
|
74 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this); window.location=$(\".headleft\").attr(\"href\");' id='template' name='template' value='{$filename}' " . $this->isChecked("template", $filename) . " /><label for='template-{$filename}'> {$filename} </label>"; |
|
75 | 75 | } |
76 | 76 | } |
77 | - array_push ($this->entryArray, new Entry ("Template", "", |
|
77 | + array_push($this->entryArray, new Entry("Template", "", |
|
78 | 78 | $content, "text", |
79 | - array ())); |
|
79 | + array())); |
|
80 | 80 | |
81 | 81 | $content = ""; |
82 | 82 | if (!preg_match("/(Kobo|Kindle\/3.0|EBRD1101)/", $_SERVER['HTTP_USER_AGENT'])) { |
83 | 83 | $content .= '<select id="style" onchange="updateCookie (this);">'; |
84 | - foreach ($this-> getStyleList () as $filename) { |
|
85 | - $content .= "<option value='{$filename}' " . $this->isSelected ("style", $filename) . ">{$filename}</option>"; |
|
84 | + foreach ($this-> getStyleList() as $filename) { |
|
85 | + $content .= "<option value='{$filename}' " . $this->isSelected("style", $filename) . ">{$filename}</option>"; |
|
86 | 86 | } |
87 | 87 | $content .= '</select>'; |
88 | 88 | } else { |
89 | - foreach ($this-> getStyleList () as $filename) { |
|
90 | - $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked ("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
89 | + foreach ($this-> getStyleList() as $filename) { |
|
90 | + $content .= "<input type='radio' onchange='updateCookieFromCheckbox (this);' id='style-{$filename}' name='style' value='{$filename}' " . $this->isChecked("style", $filename) . " /><label for='style-{$filename}'> {$filename} </label>"; |
|
91 | 91 | } |
92 | 92 | } |
93 | - array_push ($this->entryArray, new Entry (localize ("customize.style"), "", |
|
93 | + array_push($this->entryArray, new Entry(localize("customize.style"), "", |
|
94 | 94 | $content, "text", |
95 | - array ())); |
|
96 | - if (!useServerSideRendering ()) { |
|
97 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked ("use_fancyapps") . ' />'; |
|
98 | - array_push ($this->entryArray, new Entry (localize ("customize.fancybox"), "", |
|
95 | + array())); |
|
96 | + if (!useServerSideRendering()) { |
|
97 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="use_fancyapps" ' . $this->isChecked("use_fancyapps") . ' />'; |
|
98 | + array_push($this->entryArray, new Entry(localize("customize.fancybox"), "", |
|
99 | 99 | $content, "text", |
100 | - array ())); |
|
100 | + array())); |
|
101 | 101 | } |
102 | - $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption ("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
103 | - array_push ($this->entryArray, new Entry (localize ("customize.paging"), "", |
|
102 | + $content = '<input type="number" onchange="updateCookie (this);" id="max_item_per_page" value="' . getCurrentOption("max_item_per_page") . '" min="-1" max="1200" pattern="^[-+]?[0-9]+$" />'; |
|
103 | + array_push($this->entryArray, new Entry(localize("customize.paging"), "", |
|
104 | 104 | $content, "text", |
105 | - array ())); |
|
106 | - $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption ("email") . '" />'; |
|
107 | - array_push ($this->entryArray, new Entry (localize ("customize.email"), "", |
|
105 | + array())); |
|
106 | + $content = '<input type="text" onchange="updateCookie (this);" id="email" value="' . getCurrentOption("email") . '" />'; |
|
107 | + array_push($this->entryArray, new Entry(localize("customize.email"), "", |
|
108 | 108 | $content, "text", |
109 | - array ())); |
|
110 | - $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked ("html_tag_filter") . ' />'; |
|
111 | - array_push ($this->entryArray, new Entry (localize ("customize.filter"), "", |
|
109 | + array())); |
|
110 | + $content = '<input type="checkbox" onchange="updateCookieFromCheckbox (this);" id="html_tag_filter" ' . $this->isChecked("html_tag_filter") . ' />'; |
|
111 | + array_push($this->entryArray, new Entry(localize("customize.filter"), "", |
|
112 | 112 | $content, "text", |
113 | - array ())); |
|
113 | + array())); |
|
114 | 114 | $content = ""; |
115 | 115 | foreach ($ignoredBaseArray as $key) { |
116 | - $keyPlural = preg_replace ('/(ss)$/', 's', $key . "s"); |
|
117 | - $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked ("ignored_categories", $key) . ' > ' . localize ("{$keyPlural}.title") . '</input> '; |
|
116 | + $keyPlural = preg_replace('/(ss)$/', 's', $key . "s"); |
|
117 | + $content .= '<input type="checkbox" name="ignored_categories[]" onchange="updateCookieFromCheckboxGroup (this);" id="ignored_categories_' . $key . '" ' . $this->isChecked("ignored_categories", $key) . ' > ' . localize("{$keyPlural}.title") . '</input> '; |
|
118 | 118 | } |
119 | 119 | |
120 | - array_push ($this->entryArray, new Entry (localize ("customize.ignored"), "", |
|
120 | + array_push($this->entryArray, new Entry(localize("customize.ignored"), "", |
|
121 | 121 | $content, "text", |
122 | - array ())); |
|
122 | + array())); |
|
123 | 123 | } |
124 | 124 | } |
@@ -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,19 +143,19 @@ 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) { |
|
155 | + public static function getDataByBook($book) { |
|
156 | 156 | global $config; |
157 | 157 | |
158 | - $out = array (); |
|
158 | + $out = array(); |
|
159 | 159 | |
160 | 160 | $sql = 'select id, format, name from data where book = ?'; |
161 | 161 | |
@@ -166,21 +166,21 @@ discard block |
||
166 | 166 | . "')"; |
167 | 167 | } |
168 | 168 | |
169 | - $result = parent::getDb ()->prepare($sql); |
|
170 | - $result->execute (array ($book->id)); |
|
169 | + $result = parent::getDb()->prepare($sql); |
|
170 | + $result->execute(array($book->id)); |
|
171 | 171 | |
172 | - while ($post = $result->fetchObject ()) |
|
172 | + while ($post = $result->fetchObject()) |
|
173 | 173 | { |
174 | - array_push ($out, new Data ($post, $book)); |
|
174 | + array_push($out, new Data($post, $book)); |
|
175 | 175 | } |
176 | 176 | return $out; |
177 | 177 | } |
178 | 178 | |
179 | - public static function handleThumbnailLink ($urlParam, $height) { |
|
179 | + public static function handleThumbnailLink($urlParam, $height) { |
|
180 | 180 | global $config; |
181 | 181 | |
182 | - if (is_null ($height)) { |
|
183 | - if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
182 | + if (is_null($height)) { |
|
183 | + if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) { |
|
184 | 184 | $height = $config['cops_opds_thumbnail_height']; |
185 | 185 | } |
186 | 186 | else |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | return $urlParam; |
196 | 196 | } |
197 | 197 | |
198 | - public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
198 | + public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false) |
|
199 | 199 | { |
200 | 200 | global $config; |
201 | 201 | |
202 | 202 | $urlParam = addURLParameter("", "data", $idData); |
203 | 203 | if ($view) $urlParam = addURLParameter($urlParam, "view", 1); |
204 | 204 | |
205 | - if (Base::useAbsolutePath () || |
|
205 | + if (Base::useAbsolutePath() || |
|
206 | 206 | $rel == Link::OPDS_THUMBNAIL_TYPE || |
207 | 207 | ($type == "epub" && $config['cops_update_epub-metadata'])) |
208 | 208 | { |
@@ -211,18 +211,18 @@ discard block |
||
211 | 211 | $urlParam = self::handleThumbnailLink($urlParam, $height); |
212 | 212 | } |
213 | 213 | $urlParam = addURLParameter($urlParam, "id", $book->id); |
214 | - if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB)); |
|
214 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
215 | 215 | if ($config['cops_thumbnail_handling'] != "1" && |
216 | 216 | !empty ($config['cops_thumbnail_handling']) && |
217 | 217 | $rel == Link::OPDS_THUMBNAIL_TYPE) { |
218 | - return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
218 | + return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title); |
|
219 | 219 | } else { |
220 | - return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
220 | + return new Link("fetch.php?" . $urlParam, $mime, $rel, $title); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | else |
224 | 224 | { |
225 | - return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title); |
|
225 | + return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | } |
@@ -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,45 +72,45 @@ 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 | |
111 | - $out ["identifiers"] = array (); |
|
112 | - foreach ($book->getIdentifiers () as $ident) { |
|
113 | - array_push ($out ["identifiers"], array ("name" => $ident->formattedType, "url" => $ident->getUri ())); |
|
111 | + $out ["identifiers"] = array(); |
|
112 | + foreach ($book->getIdentifiers() as $ident) { |
|
113 | + array_push($out ["identifiers"], array("name" => $ident->formattedType, "url" => $ident->getUri())); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $out ["customcolumns_preview"] = $book->getCustomColumnValues($config['cops_calibre_custom_column_preview'], true); |
@@ -118,51 +118,51 @@ discard block |
||
118 | 118 | return $out; |
119 | 119 | } |
120 | 120 | |
121 | - public static function getContentArray ($entry) { |
|
121 | + public static function getContentArray($entry) { |
|
122 | 122 | if ($entry instanceof EntryBook) { |
123 | - $out = array ( "title" => $entry->title); |
|
124 | - $out ["book"] = self::getBookContentArray ($entry->book); |
|
123 | + $out = array("title" => $entry->title); |
|
124 | + $out ["book"] = self::getBookContentArray($entry->book); |
|
125 | 125 | return $out; |
126 | 126 | } |
127 | - return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement ); |
|
127 | + return array("title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink(), "number" => $entry->numberOfElement); |
|
128 | 128 | } |
129 | 129 | |
130 | - public static function getContentArrayTypeahead ($page) { |
|
131 | - $out = array (); |
|
130 | + public static function getContentArrayTypeahead($page) { |
|
131 | + $out = array(); |
|
132 | 132 | foreach ($page->entryArray as $entry) { |
133 | 133 | if ($entry instanceof EntryBook) { |
134 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl ())); |
|
134 | + array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->book->getDetailUrl())); |
|
135 | 135 | } else { |
136 | - if (empty ($entry->className) xor Base::noDatabaseSelected ()) { |
|
137 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink ())); |
|
136 | + if (empty ($entry->className) xor Base::noDatabaseSelected()) { |
|
137 | + array_push($out, array("class" => $entry->className, "title" => $entry->title, "navlink" => $entry->getNavLink())); |
|
138 | 138 | } else { |
139 | - array_push ($out, array ("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink ())); |
|
139 | + array_push($out, array("class" => $entry->className, "title" => $entry->content, "navlink" => $entry->getNavLink())); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | return $out; |
144 | 144 | } |
145 | 145 | |
146 | - public static function addCompleteArray ($in) { |
|
146 | + public static function addCompleteArray($in) { |
|
147 | 147 | global $config; |
148 | 148 | $out = $in; |
149 | 149 | |
150 | - $out ["c"] = array ("version" => VERSION, "i18n" => array ( |
|
150 | + $out ["c"] = array("version" => VERSION, "i18n" => array( |
|
151 | 151 | "coverAlt" => localize("i18n.coversection"), |
152 | 152 | "authorsTitle" => localize("authors.title"), |
153 | 153 | "bookwordTitle" => localize("bookword.title"), |
154 | 154 | "tagsTitle" => localize("tags.title"), |
155 | 155 | "linksTitle" => localize("links.title"), |
156 | 156 | "seriesTitle" => localize("series.title"), |
157 | - "customizeTitle" => localize ("customize.title"), |
|
158 | - "aboutTitle" => localize ("about.title"), |
|
159 | - "previousAlt" => localize ("paging.previous.alternate"), |
|
160 | - "nextAlt" => localize ("paging.next.alternate"), |
|
161 | - "searchAlt" => localize ("search.alternate"), |
|
162 | - "sortAlt" => localize ("sort.alternate"), |
|
163 | - "homeAlt" => localize ("home.alternate"), |
|
164 | - "cogAlt" => localize ("cog.alternate"), |
|
165 | - "permalinkAlt" => localize ("permalink.alternate"), |
|
157 | + "customizeTitle" => localize("customize.title"), |
|
158 | + "aboutTitle" => localize("about.title"), |
|
159 | + "previousAlt" => localize("paging.previous.alternate"), |
|
160 | + "nextAlt" => localize("paging.next.alternate"), |
|
161 | + "searchAlt" => localize("search.alternate"), |
|
162 | + "sortAlt" => localize("sort.alternate"), |
|
163 | + "homeAlt" => localize("home.alternate"), |
|
164 | + "cogAlt" => localize("cog.alternate"), |
|
165 | + "permalinkAlt" => localize("permalink.alternate"), |
|
166 | 166 | "publisherName" => localize("publisher.name"), |
167 | 167 | "pubdateTitle" => localize("pubdate.title"), |
168 | 168 | "languagesTitle" => localize("language.title"), |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | "sortorderAsc" => localize("search.sortorder.asc"), |
172 | 172 | "sortorderDesc" => localize("search.sortorder.desc"), |
173 | 173 | "customizeEmail" => localize("customize.email")), |
174 | - "url" => array ( |
|
174 | + "url" => array( |
|
175 | 175 | "detailUrl" => "index.php?page=13&id={0}&db={1}", |
176 | 176 | "coverUrl" => "fetch.php?id={0}&db={1}", |
177 | 177 | "thumbnailUrl" => "fetch.php?height=" . $config['cops_html_thumbnail_height'] . "&id={0}&db={1}"), |
178 | - "config" => array ( |
|
178 | + "config" => array( |
|
179 | 179 | "use_fancyapps" => $config ["cops_use_fancyapps"], |
180 | 180 | "max_item_per_page" => $config['cops_max_item_per_page'], |
181 | 181 | "kindleHack" => "", |
182 | - "server_side_rendering" => useServerSideRendering (), |
|
182 | + "server_side_rendering" => useServerSideRendering(), |
|
183 | 183 | "html_tag_filter" => $config['cops_html_tag_filter'])); |
184 | 184 | if ($config['cops_thumbnail_handling'] == "1") { |
185 | 185 | $out ["c"]["url"]["thumbnailUrl"] = $out ["c"]["url"]["coverUrl"]; |
@@ -192,32 +192,32 @@ discard block |
||
192 | 192 | return $out; |
193 | 193 | } |
194 | 194 | |
195 | - public static function getJson ($complete = false) { |
|
195 | + public static function getJson($complete = false) { |
|
196 | 196 | global $config; |
197 | - $page = getURLParam ("page", Base::PAGE_INDEX); |
|
198 | - $query = getURLParam ("query"); |
|
199 | - $search = getURLParam ("search"); |
|
200 | - $qid = getURLParam ("id"); |
|
201 | - $n = getURLParam ("n", "1"); |
|
202 | - $database = GetUrlParam (DB); |
|
197 | + $page = getURLParam("page", Base::PAGE_INDEX); |
|
198 | + $query = getURLParam("query"); |
|
199 | + $search = getURLParam("search"); |
|
200 | + $qid = getURLParam("id"); |
|
201 | + $n = getURLParam("n", "1"); |
|
202 | + $database = GetUrlParam(DB); |
|
203 | 203 | |
204 | - $currentPage = Page::getPage ($page, $qid, $query, $n); |
|
205 | - $currentPage->InitializeContent (); |
|
204 | + $currentPage = Page::getPage($page, $qid, $query, $n); |
|
205 | + $currentPage->InitializeContent(); |
|
206 | 206 | |
207 | 207 | if ($search) { |
208 | - return self::getContentArrayTypeahead ($currentPage); |
|
208 | + return self::getContentArrayTypeahead($currentPage); |
|
209 | 209 | } |
210 | 210 | |
211 | - $out = array ( "title" => $currentPage->title); |
|
212 | - $entries = array (); |
|
211 | + $out = array("title" => $currentPage->title); |
|
212 | + $entries = array(); |
|
213 | 213 | foreach ($currentPage->entryArray as $entry) { |
214 | - array_push ($entries, self::getContentArray ($entry)); |
|
214 | + array_push($entries, self::getContentArray($entry)); |
|
215 | 215 | } |
216 | - if (!is_null ($currentPage->book)) { |
|
217 | - $out ["book"] = self::getFullBookContentArray ($currentPage->book); |
|
216 | + if (!is_null($currentPage->book)) { |
|
217 | + $out ["book"] = self::getFullBookContentArray($currentPage->book); |
|
218 | 218 | } |
219 | - $out ["databaseId"] = GetUrlParam (DB, ""); |
|
220 | - $out ["databaseName"] = Base::getDbName (); |
|
219 | + $out ["databaseId"] = GetUrlParam(DB, ""); |
|
220 | + $out ["databaseName"] = Base::getDbName(); |
|
221 | 221 | if ($out ["databaseId"] == "") { |
222 | 222 | $out ["databaseName"] = ""; |
223 | 223 | } |
@@ -226,42 +226,42 @@ discard block |
||
226 | 226 | $out ["fullTitle"] = $out ["databaseName"] . " > " . $out ["fullTitle"]; |
227 | 227 | } |
228 | 228 | $out ["page"] = $page; |
229 | - $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled () ? 1 : 0; |
|
229 | + $out ["multipleDatabase"] = Base::isMultipleDatabaseEnabled()?1:0; |
|
230 | 230 | $out ["entries"] = $entries; |
231 | 231 | $out ["isPaginated"] = 0; |
232 | - if ($currentPage->isPaginated ()) { |
|
233 | - $prevLink = $currentPage->getPrevLink (); |
|
234 | - $nextLink = $currentPage->getNextLink (); |
|
232 | + if ($currentPage->isPaginated()) { |
|
233 | + $prevLink = $currentPage->getPrevLink(); |
|
234 | + $nextLink = $currentPage->getNextLink(); |
|
235 | 235 | $out ["isPaginated"] = 1; |
236 | 236 | $out ["prevLink"] = ""; |
237 | - if (!is_null ($prevLink)) { |
|
238 | - $out ["prevLink"] = $prevLink->hrefXhtml (); |
|
237 | + if (!is_null($prevLink)) { |
|
238 | + $out ["prevLink"] = $prevLink->hrefXhtml(); |
|
239 | 239 | } |
240 | 240 | $out ["nextLink"] = ""; |
241 | - if (!is_null ($nextLink)) { |
|
242 | - $out ["nextLink"] = $nextLink->hrefXhtml (); |
|
241 | + if (!is_null($nextLink)) { |
|
242 | + $out ["nextLink"] = $nextLink->hrefXhtml(); |
|
243 | 243 | } |
244 | - $out ["maxPage"] = $currentPage->getMaxPage (); |
|
244 | + $out ["maxPage"] = $currentPage->getMaxPage(); |
|
245 | 245 | $out ["currentPage"] = $currentPage->n; |
246 | 246 | } |
247 | - if (!is_null (getURLParam ("complete")) || $complete) { |
|
248 | - $out = self::addCompleteArray ($out); |
|
247 | + if (!is_null(getURLParam("complete")) || $complete) { |
|
248 | + $out = self::addCompleteArray($out); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $out ["containsBook"] = 0; |
252 | - if ($currentPage->containsBook ()) { |
|
252 | + if ($currentPage->containsBook()) { |
|
253 | 253 | $out ["containsBook"] = 1; |
254 | 254 | } |
255 | 255 | |
256 | - $out["abouturl"] = "index.php" . addURLParameter ("?page=" . Base::PAGE_ABOUT, DB, $database); |
|
256 | + $out["abouturl"] = "index.php" . addURLParameter("?page=" . Base::PAGE_ABOUT, DB, $database); |
|
257 | 257 | |
258 | 258 | if ($page == Base::PAGE_ABOUT) { |
259 | - $temp = preg_replace ("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html')); |
|
259 | + $temp = preg_replace("/\<h1\>About COPS\<\/h1\>/", "<h1>About COPS " . VERSION . "</h1>", file_get_contents('about.html')); |
|
260 | 260 | $out ["fullhtml"] = $temp; |
261 | 261 | } |
262 | 262 | |
263 | 263 | $out ["homeurl"] = "index.php"; |
264 | - if ($page != Base::PAGE_INDEX && !is_null ($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter ("", DB, $database); |
|
264 | + if ($page != Base::PAGE_INDEX && !is_null($database)) $out ["homeurl"] = $out ["homeurl"] . "?" . addURLParameter("", DB, $database); |
|
265 | 265 | |
266 | 266 | return $out; |
267 | 267 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public function __construct($post) |
18 | 18 | { |
19 | 19 | $this->id = $post->id; |
20 | - $this->type = strtolower($post->type);; |
|
20 | + $this->type = strtolower($post->type); ; |
|
21 | 21 | $this->val = $post->val; |
22 | 22 | $this->formatType(); |
23 | 23 | } |
@@ -7,55 +7,55 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // Silly thing because PHP forbid string concatenation in class const |
10 | -define ('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id |
|
10 | +define('SQL_BOOKS_LEFT_JOIN', 'left outer join comments on comments.book = books.id |
|
11 | 11 | left outer join books_ratings_link on books_ratings_link.book = books.id |
12 | 12 | left outer join ratings on books_ratings_link.rating = ratings.id '); |
13 | -define ('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort '); |
|
14 | -define ('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
13 | +define('SQL_BOOKS_ALL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' order by books.sort '); |
|
14 | +define('SQL_BOOKS_BY_PUBLISHER', 'select {0} from books_publishers_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
15 | 15 | where books_publishers_link.book = books.id and publisher = ? {1} order by publisher'); |
16 | -define ('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
16 | +define('SQL_BOOKS_BY_FIRST_LETTER', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
17 | 17 | where upper (books.sort) like ? order by books.sort'); |
18 | -define ('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
18 | +define('SQL_BOOKS_BY_AUTHOR', 'select {0} from books_authors_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
19 | 19 | left outer join books_series_link on books_series_link.book = books.id |
20 | 20 | where books_authors_link.book = books.id and author = ? {1} order by series desc, series_index asc, pubdate asc'); |
21 | -define ('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
21 | +define('SQL_BOOKS_BY_SERIE', 'select {0} from books_series_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
22 | 22 | where books_series_link.book = books.id and series = ? {1} order by series_index'); |
23 | -define ('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
23 | +define('SQL_BOOKS_BY_TAG', 'select {0} from books_tags_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
24 | 24 | where books_tags_link.book = books.id and tag = ? {1} order by sort'); |
25 | -define ('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
25 | +define('SQL_BOOKS_BY_LANGUAGE', 'select {0} from books_languages_link, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
26 | 26 | where books_languages_link.book = books.id and lang_code = ? {1} order by sort'); |
27 | -define ('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
27 | +define('SQL_BOOKS_BY_CUSTOM', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
28 | 28 | where {2}.book = books.id and {2}.{3} = ? {1} order by sort'); |
29 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
29 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_TRUE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
30 | 30 | where {2}.book = books.id and {2}.value = 1 {1} order by sort'); |
31 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
31 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_FALSE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
32 | 32 | where {2}.book = books.id and {2}.value = 0 {1} order by sort'); |
33 | -define ('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
33 | +define('SQL_BOOKS_BY_CUSTOM_BOOL_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
34 | 34 | where books.id not in (select book from {2}) {1} order by sort'); |
35 | -define ('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
35 | +define('SQL_BOOKS_BY_CUSTOM_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
36 | 36 | left join {2} on {2}.book = books.id |
37 | 37 | left join {3} on {3}.id = {2}.{4} |
38 | 38 | where {3}.value = ? order by sort'); |
39 | -define ('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
39 | +define('SQL_BOOKS_BY_CUSTOM_RATING_NULL', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
40 | 40 | left join {2} on {2}.book = books.id |
41 | 41 | left join {3} on {3}.id = {2}.{4} |
42 | 42 | where ((books.id not in (select {2}.book from {2})) or ({3}.value = 0)) {1} order by sort'); |
43 | -define ('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
43 | +define('SQL_BOOKS_BY_CUSTOM_DATE', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
44 | 44 | where {2}.book = books.id and date({2}.value) = ? {1} order by sort'); |
45 | -define ('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
45 | +define('SQL_BOOKS_BY_CUSTOM_DIRECT', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
46 | 46 | where {2}.book = books.id and {2}.value = ? {1} order by sort'); |
47 | -define ('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
47 | +define('SQL_BOOKS_BY_CUSTOM_DIRECT_ID', 'select {0} from {2}, books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
48 | 48 | where {2}.book = books.id and {2}.id = ? {1} order by sort'); |
49 | -define ('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
49 | +define('SQL_BOOKS_QUERY', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
50 | 50 | where ( |
51 | 51 | exists (select null from authors, books_authors_link where book = books.id and author = authors.id and authors.name like ?) or |
52 | 52 | exists (select null from tags, books_tags_link where book = books.id and tag = tags.id and tags.name like ?) or |
53 | 53 | exists (select null from series, books_series_link on book = books.id and books_series_link.series = series.id and series.name like ?) or |
54 | 54 | exists (select null from publishers, books_publishers_link where book = books.id and books_publishers_link.publisher = publishers.id and publishers.name like ?) or |
55 | 55 | title like ?) {1} order by books.sort'); |
56 | -define ('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
56 | +define('SQL_BOOKS_RECENT', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
57 | 57 | where 1=1 {1} order by timestamp desc limit '); |
58 | -define ('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
58 | +define('SQL_BOOKS_BY_RATING', 'select {0} from books ' . SQL_BOOKS_LEFT_JOIN . ' |
|
59 | 59 | where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort'); |
60 | 60 | |
61 | 61 | require('Identifier.php'); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | public $tags = NULL; |
109 | 109 | public $identifiers = NULL; |
110 | 110 | public $languages = NULL; |
111 | - public $format = array (); |
|
111 | + public $format = array(); |
|
112 | 112 | |
113 | 113 | |
114 | 114 | public function __construct($line) { |
@@ -130,24 +130,24 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | public function getEntryId() { |
133 | - return self::ALL_BOOKS_UUID.':'.$this->uuid; |
|
133 | + return self::ALL_BOOKS_UUID . ':' . $this->uuid; |
|
134 | 134 | } |
135 | 135 | |
136 | - public static function getEntryIdByLetter ($startingLetter) { |
|
137 | - return self::ALL_BOOKS_ID.':letter:'.$startingLetter; |
|
136 | + public static function getEntryIdByLetter($startingLetter) { |
|
137 | + return self::ALL_BOOKS_ID . ':letter:' . $startingLetter; |
|
138 | 138 | } |
139 | 139 | |
140 | - public function getUri () { |
|
141 | - return '?page='.parent::PAGE_BOOK_DETAIL.'&id=' . $this->id; |
|
140 | + public function getUri() { |
|
141 | + return '?page=' . parent::PAGE_BOOK_DETAIL . '&id=' . $this->id; |
|
142 | 142 | } |
143 | 143 | |
144 | - public function getDetailUrl () { |
|
144 | + public function getDetailUrl() { |
|
145 | 145 | $urlParam = $this->getUri(); |
146 | - if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam (DB)); |
|
146 | + if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB)); |
|
147 | 147 | return 'index.php' . $urlParam; |
148 | 148 | } |
149 | 149 | |
150 | - public function getTitle () { |
|
150 | + public function getTitle() { |
|
151 | 151 | return $this->title; |
152 | 152 | } |
153 | 153 | |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * @return Author[] |
158 | 158 | */ |
159 | - public function getAuthors () { |
|
159 | + public function getAuthors() { |
|
160 | 160 | if (is_null($this->authors)) { |
161 | 161 | $this->authors = Author::getAuthorByBookId($this->id); |
162 | 162 | } |
163 | 163 | return $this->authors; |
164 | 164 | } |
165 | 165 | |
166 | - public function getAuthorsName () { |
|
167 | - return implode(', ', array_map(function ($author) { return $author->name; }, $this->getAuthors())); |
|
166 | + public function getAuthorsName() { |
|
167 | + return implode(', ', array_map(function($author) { return $author->name; }, $this->getAuthors())); |
|
168 | 168 | } |
169 | 169 | |
170 | - public function getAuthorsSort () { |
|
171 | - return implode(', ', array_map(function ($author) { return $author->sort; }, $this->getAuthors())); |
|
170 | + public function getAuthorsSort() { |
|
171 | + return implode(', ', array_map(function($author) { return $author->sort; }, $this->getAuthors())); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function getPublisher () { |
|
174 | + public function getPublisher() { |
|
175 | 175 | if (is_null($this->publisher)) { |
176 | 176 | $this->publisher = Publisher::getPublisherByBookId($this->id); |
177 | 177 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @return Tag[] |
211 | 211 | */ |
212 | 212 | public function getTags() { |
213 | - if (is_null ($this->tags)) { |
|
213 | + if (is_null($this->tags)) { |
|
214 | 214 | $this->tags = array(); |
215 | 215 | |
216 | 216 | $result = parent::getDb()->prepare('select tags.id as id, name |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | public function getTagsName() { |
231 | - return implode(', ', array_map(function ($tag) { return $tag->name; }, $this->getTags())); |
|
231 | + return implode(', ', array_map(function($tag) { return $tag->name; }, $this->getTags())); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return Identifiers[] |
237 | 237 | */ |
238 | 238 | public function getIdentifiers() { |
239 | - if (is_null ($this->identifiers)) { |
|
239 | + if (is_null($this->identifiers)) { |
|
240 | 240 | $this->identifiers = array(); |
241 | 241 | |
242 | 242 | $result = parent::getDb()->prepare('select type, val, id |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | public function getDataById($idData) |
304 | 304 | { |
305 | - $reduced = array_filter($this->getDatas(), function ($data) use ($idData) { |
|
305 | + $reduced = array_filter($this->getDatas(), function($data) use ($idData) { |
|
306 | 306 | return $data->id == $idData; |
307 | 307 | }); |
308 | 308 | return reset($reduced); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | if (empty ($this->pubdate)) { |
327 | 327 | return ''; |
328 | 328 | } |
329 | - $dateY = (int) substr($this->pubdate, 0, 4); |
|
329 | + $dateY = (int)substr($this->pubdate, 0, 4); |
|
330 | 330 | if ($dateY > 102) { |
331 | 331 | return str_pad($dateY, 4, '0', STR_PAD_LEFT); |
332 | 332 | } |
@@ -335,15 +335,15 @@ discard block |
||
335 | 335 | |
336 | 336 | public function getComment($withSerie = true) { |
337 | 337 | $addition = ''; |
338 | - $se = $this->getSerie (); |
|
339 | - if (!is_null ($se) && $withSerie) { |
|
338 | + $se = $this->getSerie(); |
|
339 | + if (!is_null($se) && $withSerie) { |
|
340 | 340 | $addition = $addition . '<strong>' . localize('content.series') . '</strong>' . str_format(localize('content.series.data'), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n"; |
341 | 341 | } |
342 | 342 | return $addition . html2xhtml($this->comment); |
343 | 343 | } |
344 | 344 | |
345 | 345 | public function getDataFormat($format) { |
346 | - $reduced = array_filter($this->getDatas(), function ($data) use ($format) { |
|
346 | + $reduced = array_filter($this->getDatas(), function($data) use ($format) { |
|
347 | 347 | return $data->format == $format; |
348 | 348 | }); |
349 | 349 | return reset($reduced); |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | |
365 | 365 | if ($relative) |
366 | 366 | { |
367 | - return $this->relativePath.'/'.$file; |
|
367 | + return $this->relativePath . '/' . $file; |
|
368 | 368 | } |
369 | 369 | else |
370 | 370 | { |
371 | - return $this->path.'/'.$file; |
|
371 | + return $this->path . '/' . $file; |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } |
389 | 389 | $epub->Authors($authorArray); |
390 | 390 | $epub->Language($this->getLanguages()); |
391 | - $epub->Description ($this->getComment(false)); |
|
391 | + $epub->Description($this->getComment(false)); |
|
392 | 392 | $epub->Subjects($this->getTagsName()); |
393 | 393 | $epub->Cover2($this->getFilePath('jpg'), 'image/jpeg'); |
394 | 394 | $epub->Calibre($this->uuid); |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | $epub->SerieIndex($this->seriesIndex); |
399 | 399 | } |
400 | 400 | $filename = $data->getUpdatedFilenameEpub(); |
401 | - if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) { |
|
401 | + if ($config['cops_provide_kepub'] == '1' && preg_match('/Kobo/', $_SERVER['HTTP_USER_AGENT'])) { |
|
402 | 402 | $epub->updateForKepub(); |
403 | 403 | $filename = $data->getUpdatedFilenameKepub(); |
404 | 404 | } |
@@ -424,11 +424,11 @@ discard block |
||
424 | 424 | if (!is_null($width)) { |
425 | 425 | $nw = $width; |
426 | 426 | if ($nw >= $w) { return false; } |
427 | - $nh = ($nw*$h)/$w; |
|
427 | + $nh = ($nw * $h) / $w; |
|
428 | 428 | } else { |
429 | 429 | $nh = $height; |
430 | 430 | if ($nh >= $h) { return false; } |
431 | - $nw = ($nh*$w)/$h; |
|
431 | + $nw = ($nh * $w) / $h; |
|
432 | 432 | } |
433 | 433 | } else { |
434 | 434 | return false; |
@@ -436,16 +436,16 @@ discard block |
||
436 | 436 | |
437 | 437 | //draw the image |
438 | 438 | $src_img = imagecreatefromjpeg($file); |
439 | - $dst_img = imagecreatetruecolor($nw,$nh); |
|
440 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h);//resizing the image |
|
441 | - imagejpeg($dst_img,$outputfile,80); |
|
439 | + $dst_img = imagecreatetruecolor($nw, $nh); |
|
440 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nw, $nh, $w, $h); //resizing the image |
|
441 | + imagejpeg($dst_img, $outputfile, 80); |
|
442 | 442 | imagedestroy($src_img); |
443 | 443 | imagedestroy($dst_img); |
444 | 444 | |
445 | 445 | return true; |
446 | 446 | } |
447 | 447 | |
448 | - public function getLinkArray () |
|
448 | + public function getLinkArray() |
|
449 | 449 | { |
450 | 450 | $linkArray = array(); |
451 | 451 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | } |
471 | 471 | |
472 | 472 | $serie = $this->getSerie(); |
473 | - if (!is_null ($serie)) { |
|
473 | + if (!is_null($serie)) { |
|
474 | 474 | array_push($linkArray, new LinkNavigation($serie->getUri(), 'related', str_format(localize('content.series.data'), $this->seriesIndex, $serie->name))); |
475 | 475 | } |
476 | 476 | |
@@ -495,13 +495,13 @@ discard block |
||
495 | 495 | $entry = new Entry(localize('allbooks.title'), |
496 | 496 | self::ALL_BOOKS_ID, |
497 | 497 | str_format(localize('allbooks.alphabetical', $nBooks), $nBooks), 'text', |
498 | - array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
498 | + array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS)), '', $nBooks); |
|
499 | 499 | array_push($result, $entry); |
500 | 500 | if ($config['cops_recentbooks_limit'] > 0) { |
501 | 501 | $entry = new Entry(localize('recent.title'), |
502 | 502 | self::ALL_RECENT_BOOKS_ID, |
503 | 503 | str_format(localize('recent.list'), $config['cops_recentbooks_limit']), 'text', |
504 | - array ( new LinkNavigation ('?page='.parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
504 | + array(new LinkNavigation('?page=' . parent::PAGE_ALL_RECENT_BOOKS)), '', $config['cops_recentbooks_limit']); |
|
505 | 505 | array_push($result, $entry); |
506 | 506 | } |
507 | 507 | return $result; |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | public static function getBooks($n) { |
600 | - list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL , array (), $n); |
|
600 | + list ($entryArray, $totalNumber) = self::getEntryArray(self::SQL_BOOKS_ALL, array(), $n); |
|
601 | 601 | return array($entryArray, $totalNumber); |
602 | 602 | } |
603 | 603 | |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | { |
615 | 615 | array_push($entryArray, new Entry($post->title, Book::getEntryIdByLetter($post->title), |
616 | 616 | str_format(localize('bookword', $post->count), $post->count), 'text', |
617 | - array(new LinkNavigation('?page='.parent::PAGE_ALL_BOOKS_LETTER.'&id='. rawurlencode($post->title))), '', $post->count)); |
|
617 | + array(new LinkNavigation('?page=' . parent::PAGE_ALL_BOOKS_LETTER . '&id=' . rawurlencode($post->title))), '', $post->count)); |
|
618 | 618 | } |
619 | 619 | return $entryArray; |
620 | 620 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | |
640 | 640 | public static function getAllRecentBooks() { |
641 | 641 | global $config; |
642 | - list ($entryArray, ) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
|
642 | + list ($entryArray,) = self::getEntryArray(self::SQL_BOOKS_RECENT . $config['cops_recentbooks_limit'], array(), -1); |
|
643 | 643 | return $entryArray; |
644 | 644 | } |
645 | 645 |