@@ -15,11 +15,13 @@ discard block |
||
| 15 | 15 | const SCOPE_BOOK = "book"; |
| 16 | 16 | const SCOPE_PUBLISHER = "publisher"; |
| 17 | 17 | |
| 18 | - private function useTypeahead () { |
|
| 18 | + private function useTypeahead () |
|
| 19 | + { |
|
| 19 | 20 | return !is_null (getURLParam ("search")); |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | - private function searchByScope ($scope, $limit = FALSE) { |
|
| 23 | + private function searchByScope ($scope, $limit = FALSE) |
|
| 24 | + { |
|
| 23 | 25 | $n = $this->n; |
| 24 | 26 | $numberPerPage = NULL; |
| 25 | 27 | $queryNormedAndUp = trim($this->query); |
@@ -54,7 +56,8 @@ discard block |
||
| 54 | 56 | return $array; |
| 55 | 57 | } |
| 56 | 58 | |
| 57 | - public function doSearchByCategory () { |
|
| 59 | + public function doSearchByCategory () |
|
| 60 | + { |
|
| 58 | 61 | $database = GetUrlParam (DB); |
| 59 | 62 | $out = array (); |
| 60 | 63 | $pagequery = Base::PAGE_OPENSEARCH_QUERY; |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | $this->title = localize("authors.title"); |
| 14 | 14 | if (getCurrentOption ("author_split_first_letter") == 1) { |
| 15 | 15 | $this->entryArray = Author::getAllAuthorsByFirstLetter(); |
| 16 | - } |
|
| 17 | - else { |
|
| 16 | + } else { |
|
| 18 | 17 | $this->entryArray = Author::getAllAuthors(); |
| 19 | 18 | } |
| 20 | 19 | $this->idPage = Author::ALL_AUTHORS_ID; |
@@ -8,9 +8,12 @@ |
||
| 8 | 8 | |
| 9 | 9 | class LinkFacet extends Link |
| 10 | 10 | { |
| 11 | - public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |
|
| 11 | + public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) |
|
| 12 | + { |
|
| 12 | 13 | parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |
| 13 | - if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 14 | + if (!is_null (GetUrlParam (DB))) { |
|
| 15 | + $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |
|
| 16 | + } |
|
| 14 | 17 | $this->href = parent::getScriptName() . $this->href; |
| 15 | 18 | } |
| 16 | 19 | } |
@@ -13,14 +13,16 @@ discard block |
||
| 13 | 13 | private $xmlStream = NULL; |
| 14 | 14 | private $updated = NULL; |
| 15 | 15 | |
| 16 | - private function getUpdatedTime () { |
|
| 16 | + private function getUpdatedTime () |
|
| 17 | + { |
|
| 17 | 18 | if (is_null ($this->updated)) { |
| 18 | 19 | $this->updated = time(); |
| 19 | 20 | } |
| 20 | 21 | return date (DATE_ATOM, $this->updated); |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - private function getXmlStream () { |
|
| 24 | + private function getXmlStream () |
|
| 25 | + { |
|
| 24 | 26 | if (is_null ($this->xmlStream)) { |
| 25 | 27 | $this->xmlStream = new XMLWriter(); |
| 26 | 28 | $this->xmlStream->openMemory(); |
@@ -29,7 +31,8 @@ discard block |
||
| 29 | 31 | return $this->xmlStream; |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | - public function getOpenSearch () { |
|
| 34 | + public function getOpenSearch () |
|
| 35 | + { |
|
| 33 | 36 | global $config; |
| 34 | 37 | $xml = new XMLWriter (); |
| 35 | 38 | $xml->openMemory (); |
@@ -58,7 +61,9 @@ discard block |
||
| 58 | 61 | $xml->startElement ("Url"); |
| 59 | 62 | $xml->writeAttribute ("type", 'application/atom+xml'); |
| 60 | 63 | $urlparam = "?query={searchTerms}"; |
| 61 | - if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 64 | + if (!is_null (GetUrlParam (DB))) { |
|
| 65 | + $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 66 | + } |
|
| 62 | 67 | $urlparam = str_replace ("%7B", "{", $urlparam); |
| 63 | 68 | $urlparam = str_replace ("%7D", "}", $urlparam); |
| 64 | 69 | $xml->writeAttribute ("template", $config['cops_full_url'] . 'feed.php' . $urlparam); |
@@ -72,7 +77,8 @@ discard block |
||
| 72 | 77 | return $xml->outputMemory(true); |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | - private function startXmlDocument ($page) { |
|
| 80 | + private function startXmlDocument ($page) |
|
| 81 | + { |
|
| 76 | 82 | global $config; |
| 77 | 83 | self::getXmlStream ()->startDocument('1.0','UTF-8'); |
| 78 | 84 | self::getXmlStream ()->startElement ("feed"); |
@@ -84,21 +90,19 @@ discard block |
||
| 84 | 90 | self::getXmlStream ()->startElement ("title"); |
| 85 | 91 | self::getXmlStream ()->text ($page->title); |
| 86 | 92 | self::getXmlStream ()->endElement (); |
| 87 | - if ($page->subtitle != "") |
|
| 88 | - { |
|
| 93 | + if ($page->subtitle != "") { |
|
| 89 | 94 | self::getXmlStream ()->startElement ("subtitle"); |
| 90 | 95 | self::getXmlStream ()->text ($page->subtitle); |
| 91 | 96 | self::getXmlStream ()->endElement (); |
| 92 | 97 | } |
| 93 | 98 | self::getXmlStream ()->startElement ("id"); |
| 94 | - if ($page->idPage) |
|
| 95 | - { |
|
| 99 | + if ($page->idPage) { |
|
| 96 | 100 | $idPage = $page->idPage; |
| 97 | - if (!is_null (GetUrlParam (DB))) $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage); |
|
| 101 | + if (!is_null (GetUrlParam (DB))) { |
|
| 102 | + $idPage = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $idPage); |
|
| 103 | + } |
|
| 98 | 104 | self::getXmlStream ()->text ($idPage); |
| 99 | - } |
|
| 100 | - else |
|
| 101 | - { |
|
| 105 | + } else { |
|
| 102 | 106 | self::getXmlStream ()->text ($_SERVER['REQUEST_URI']); |
| 103 | 107 | } |
| 104 | 108 | self::getXmlStream ()->endElement (); |
@@ -124,14 +128,14 @@ discard block |
||
| 124 | 128 | $link = new LinkNavigation ("?" . getQueryString (), "self"); |
| 125 | 129 | self::renderLink ($link); |
| 126 | 130 | $urlparam = "?"; |
| 127 | - if (!is_null (GetUrlParam (DB))) $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 131 | + if (!is_null (GetUrlParam (DB))) { |
|
| 132 | + $urlparam = addURLParameter ($urlparam, DB, GetUrlParam (DB)); |
|
| 133 | + } |
|
| 128 | 134 | if ($config['cops_generate_invalid_opds_stream'] == 0 || preg_match("/(MantanoReader|FBReader)/", $_SERVER['HTTP_USER_AGENT'])) { |
| 129 | 135 | // Good and compliant way of handling search |
| 130 | 136 | $urlparam = addURLParameter ($urlparam, "page", Base::PAGE_OPENSEARCH); |
| 131 | 137 | $link = new Link ("feed.php" . $urlparam, "application/opensearchdescription+xml", "search", "Search here"); |
| 132 | - } |
|
| 133 | - else |
|
| 134 | - { |
|
| 138 | + } else { |
|
| 135 | 139 | // Bad way, will be removed when OPDS client are fixed |
| 136 | 140 | $urlparam = addURLParameter ($urlparam, "query", "{searchTerms}"); |
| 137 | 141 | $urlparam = str_replace ("%7B", "{", $urlparam); |
@@ -148,13 +152,15 @@ discard block |
||
| 148 | 152 | } |
| 149 | 153 | } |
| 150 | 154 | |
| 151 | - private function endXmlDocument () { |
|
| 155 | + private function endXmlDocument () |
|
| 156 | + { |
|
| 152 | 157 | self::getXmlStream ()->endElement (); |
| 153 | 158 | self::getXmlStream ()->endDocument (); |
| 154 | 159 | return self::getXmlStream ()->outputMemory(true); |
| 155 | 160 | } |
| 156 | 161 | |
| 157 | - private function renderLink ($link) { |
|
| 162 | + private function renderLink ($link) |
|
| 163 | + { |
|
| 158 | 164 | self::getXmlStream ()->startElement ("link"); |
| 159 | 165 | self::getXmlStream ()->writeAttribute ("href", $link->href); |
| 160 | 166 | self::getXmlStream ()->writeAttribute ("type", $link->type); |
@@ -173,7 +179,8 @@ discard block |
||
| 173 | 179 | self::getXmlStream ()->endElement (); |
| 174 | 180 | } |
| 175 | 181 | |
| 176 | - private function getPublicationDate($book) { |
|
| 182 | + private function getPublicationDate($book) |
|
| 183 | + { |
|
| 177 | 184 | $dateYmd = substr($book->pubdate, 0, 10); |
| 178 | 185 | $pubdate = \DateTime::createFromFormat('Y-m-d', $dateYmd); |
| 179 | 186 | if ($pubdate === false || |
@@ -184,7 +191,8 @@ discard block |
||
| 184 | 191 | return $pubdate->format("Y-m-d"); |
| 185 | 192 | } |
| 186 | 193 | |
| 187 | - private function renderEntry ($entry) { |
|
| 194 | + private function renderEntry ($entry) |
|
| 195 | + { |
|
| 188 | 196 | self::getXmlStream ()->startElement ("title"); |
| 189 | 197 | self::getXmlStream ()->text ($entry->title); |
| 190 | 198 | self::getXmlStream ()->endElement (); |
@@ -244,11 +252,11 @@ discard block |
||
| 244 | 252 | |
| 245 | 253 | } |
| 246 | 254 | |
| 247 | - public function render ($page) { |
|
| 255 | + public function render ($page) |
|
| 256 | + { |
|
| 248 | 257 | global $config; |
| 249 | 258 | self::startXmlDocument ($page); |
| 250 | - if ($page->isPaginated ()) |
|
| 251 | - { |
|
| 259 | + if ($page->isPaginated ()) { |
|
| 252 | 260 | self::getXmlStream ()->startElement ("opensearch:totalResults"); |
| 253 | 261 | self::getXmlStream ()->text ($page->totalNumber); |
| 254 | 262 | self::getXmlStream ()->endElement (); |
@@ -15,25 +15,30 @@ discard block |
||
| 15 | 15 | public $id; |
| 16 | 16 | public $name; |
| 17 | 17 | |
| 18 | - public function __construct($post) { |
|
| 18 | + public function __construct($post) |
|
| 19 | + { |
|
| 19 | 20 | $this->id = $post->id; |
| 20 | 21 | $this->name = $post->name; |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - public function getUri () { |
|
| 24 | + public function getUri () |
|
| 25 | + { |
|
| 24 | 26 | return "?page=".parent::PAGE_TAG_DETAIL."&id=$this->id"; |
| 25 | 27 | } |
| 26 | 28 | |
| 27 | - public function getEntryId () { |
|
| 29 | + public function getEntryId () |
|
| 30 | + { |
|
| 28 | 31 | return self::ALL_TAGS_ID.":".$this->id; |
| 29 | 32 | } |
| 30 | 33 | |
| 31 | - public static function getCount() { |
|
| 34 | + public static function getCount() |
|
| 35 | + { |
|
| 32 | 36 | // str_format (localize("tags.alphabetical", count(array)) |
| 33 | 37 | return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS); |
| 34 | 38 | } |
| 35 | 39 | |
| 36 | - public static function getTagById ($tagId) { |
|
| 40 | + public static function getTagById ($tagId) |
|
| 41 | + { |
|
| 37 | 42 | $result = parent::getDb ()->prepare('select id, name from tags where id = ?'); |
| 38 | 43 | $result->execute (array ($tagId)); |
| 39 | 44 | if ($post = $result->fetchObject ()) { |
@@ -42,17 +47,18 @@ discard block |
||
| 42 | 47 | return NULL; |
| 43 | 48 | } |
| 44 | 49 | |
| 45 | - public static function getAllTags() { |
|
| 50 | + public static function getAllTags() |
|
| 51 | + { |
|
| 46 | 52 | return Base::getEntryArrayWithBookNumber (self::SQL_ALL_TAGS, self::TAG_COLUMNS, array (), "Tag"); |
| 47 | 53 | } |
| 48 | 54 | |
| 49 | - public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 55 | + public static function getAllTagsByQuery($query, $n, $database = NULL, $numberPerPage = NULL) |
|
| 56 | + { |
|
| 50 | 57 | $columns = "tags.id as id, tags.name as name, (select count(*) from books_tags_link where tags.id = tag) as count"; |
| 51 | 58 | $sql = 'select {0} from tags where upper (tags.name) like ? {1} order by tags.name'; |
| 52 | 59 | list ($totalNumber, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), $n, $database, $numberPerPage); |
| 53 | 60 | $entryArray = array(); |
| 54 | - while ($post = $result->fetchObject ()) |
|
| 55 | - { |
|
| 61 | + while ($post = $result->fetchObject ()) { |
|
| 56 | 62 | $tag = new Tag ($post); |
| 57 | 63 | array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (), |
| 58 | 64 | str_format (localize("bookword", $post->count), $post->count), "text", |
@@ -8,7 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class PageCustomize extends Page |
| 10 | 10 | { |
| 11 | - private function isChecked ($key, $testedValue = 1) { |
|
| 11 | + private function isChecked ($key, $testedValue = 1) |
|
| 12 | + { |
|
| 12 | 13 | $value = getCurrentOption ($key); |
| 13 | 14 | if (is_array ($value)) { |
| 14 | 15 | if (in_array ($testedValue, $value)) { |
@@ -22,14 +23,16 @@ discard block |
||
| 22 | 23 | return ""; |
| 23 | 24 | } |
| 24 | 25 | |
| 25 | - private function isSelected ($key, $value) { |
|
| 26 | + private function isSelected ($key, $value) |
|
| 27 | + { |
|
| 26 | 28 | if (getCurrentOption ($key) == $value) { |
| 27 | 29 | return "selected='selected'"; |
| 28 | 30 | } |
| 29 | 31 | return ""; |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | - private function getStyleList () { |
|
| 34 | + private function getStyleList () |
|
| 35 | + { |
|
| 33 | 36 | $result = array (); |
| 34 | 37 | foreach (glob ("templates/" . getCurrentTemplate () . "/styles/style-*.css") as $filename) { |
| 35 | 38 | if (preg_match ('/styles\/style-(.*?)\.css/', $filename, $m)) { |
@@ -19,28 +19,33 @@ |
||
| 19 | 19 | * @param array $plinkArray |
| 20 | 20 | * @param Book $pbook |
| 21 | 21 | */ |
| 22 | - public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) { |
|
| 22 | + public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) |
|
| 23 | + { |
|
| 23 | 24 | parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray); |
| 24 | 25 | $this->book = $pbook; |
| 25 | 26 | $this->localUpdated = $pbook->timestamp; |
| 26 | 27 | } |
| 27 | 28 | |
| 28 | - public function getCoverThumbnail () { |
|
| 29 | + public function getCoverThumbnail () |
|
| 30 | + { |
|
| 29 | 31 | foreach ($this->linkArray as $link) { |
| 30 | 32 | /* @var $link LinkNavigation */ |
| 31 | 33 | |
| 32 | - if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) |
|
| 33 | - return $link->hrefXhtml (); |
|
| 34 | + if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) { |
|
| 35 | + return $link->hrefXhtml (); |
|
| 36 | + } |
|
| 34 | 37 | } |
| 35 | 38 | return null; |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | - public function getCover () { |
|
| 41 | + public function getCover () |
|
| 42 | + { |
|
| 39 | 43 | foreach ($this->linkArray as $link) { |
| 40 | 44 | /* @var $link LinkNavigation */ |
| 41 | 45 | |
| 42 | - if ($link->rel == Link::OPDS_IMAGE_TYPE) |
|
| 43 | - return $link->hrefXhtml (); |
|
| 46 | + if ($link->rel == Link::OPDS_IMAGE_TYPE) { |
|
| 47 | + return $link->hrefXhtml (); |
|
| 48 | + } |
|
| 44 | 49 | } |
| 45 | 50 | return null; |
| 46 | 51 | } |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | $result = $this->getDb()->query($query); |
| 69 | 69 | $entryArray = array(); |
| 70 | - while ($post = $result->fetchObject()) |
|
| 71 | - { |
|
| 70 | + while ($post = $result->fetchObject()) { |
|
| 72 | 71 | $entryPContent = str_format(localize("bookword", $post->count), $post->count); |
| 73 | 72 | $entryPLinkArray = array(new LinkNavigation ($this->getUri($post->id))); |
| 74 | 73 | |
@@ -82,7 +81,9 @@ discard block |
||
| 82 | 81 | public function getDescription() |
| 83 | 82 | { |
| 84 | 83 | $desc = $this->getDatabaseDescription(); |
| 85 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 84 | + if ($desc === NULL || empty($desc)) { |
|
| 85 | + $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 86 | + } |
|
| 86 | 87 | return $desc; |
| 87 | 88 | } |
| 88 | 89 | |
@@ -37,23 +37,27 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private static $db = NULL; |
| 39 | 39 | |
| 40 | - public static function isMultipleDatabaseEnabled () { |
|
| 40 | + public static function isMultipleDatabaseEnabled () |
|
| 41 | + { |
|
| 41 | 42 | global $config; |
| 42 | 43 | return is_array ($config['calibre_directory']); |
| 43 | 44 | } |
| 44 | 45 | |
| 45 | - public static function useAbsolutePath () { |
|
| 46 | + public static function useAbsolutePath () |
|
| 47 | + { |
|
| 46 | 48 | global $config; |
| 47 | 49 | $path = self::getDbDirectory(); |
| 48 | 50 | return preg_match ('/^\//', $path) || // Linux / |
| 49 | 51 | preg_match ('/^\w\:/', $path); // Windows X: |
| 50 | 52 | } |
| 51 | 53 | |
| 52 | - public static function noDatabaseSelected () { |
|
| 54 | + public static function noDatabaseSelected () |
|
| 55 | + { |
|
| 53 | 56 | return self::isMultipleDatabaseEnabled () && is_null (GetUrlParam (DB)); |
| 54 | 57 | } |
| 55 | 58 | |
| 56 | - public static function getDbList () { |
|
| 59 | + public static function getDbList () |
|
| 60 | + { |
|
| 57 | 61 | global $config; |
| 58 | 62 | if (self::isMultipleDatabaseEnabled ()) { |
| 59 | 63 | return $config['calibre_directory']; |
@@ -62,7 +66,8 @@ discard block |
||
| 62 | 66 | } |
| 63 | 67 | } |
| 64 | 68 | |
| 65 | - public static function getDbNameList () { |
|
| 69 | + public static function getDbNameList () |
|
| 70 | + { |
|
| 66 | 71 | global $config; |
| 67 | 72 | if (self::isMultipleDatabaseEnabled ()) { |
| 68 | 73 | return array_keys ($config['calibre_directory']); |
@@ -71,10 +76,13 @@ discard block |
||
| 71 | 76 | } |
| 72 | 77 | } |
| 73 | 78 | |
| 74 | - public static function getDbName ($database = NULL) { |
|
| 79 | + public static function getDbName ($database = NULL) |
|
| 80 | + { |
|
| 75 | 81 | global $config; |
| 76 | 82 | if (self::isMultipleDatabaseEnabled ()) { |
| 77 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
| 83 | + if (is_null ($database)) { |
|
| 84 | + $database = GetUrlParam (DB, 0); |
|
| 85 | + } |
|
| 78 | 86 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 79 | 87 | self::error ($database); |
| 80 | 88 | } |
@@ -84,10 +92,13 @@ discard block |
||
| 84 | 92 | return ""; |
| 85 | 93 | } |
| 86 | 94 | |
| 87 | - public static function getDbDirectory ($database = NULL) { |
|
| 95 | + public static function getDbDirectory ($database = NULL) |
|
| 96 | + { |
|
| 88 | 97 | global $config; |
| 89 | 98 | if (self::isMultipleDatabaseEnabled ()) { |
| 90 | - if (is_null ($database)) $database = GetUrlParam (DB, 0); |
|
| 99 | + if (is_null ($database)) { |
|
| 100 | + $database = GetUrlParam (DB, 0); |
|
| 101 | + } |
|
| 91 | 102 | if (!is_null($database) && !preg_match('/^\d+$/', $database)) { |
| 92 | 103 | self::error ($database); |
| 93 | 104 | } |
@@ -98,18 +109,21 @@ discard block |
||
| 98 | 109 | } |
| 99 | 110 | |
| 100 | 111 | |
| 101 | - public static function getDbFileName ($database = NULL) { |
|
| 112 | + public static function getDbFileName ($database = NULL) |
|
| 113 | + { |
|
| 102 | 114 | return self::getDbDirectory ($database) .'metadata.db'; |
| 103 | 115 | } |
| 104 | 116 | |
| 105 | - private static function error ($database) { |
|
| 117 | + private static function error ($database) |
|
| 118 | + { |
|
| 106 | 119 | if (php_sapi_name() != "cli") { |
| 107 | 120 | header("location: checkconfig.php?err=1"); |
| 108 | 121 | } |
| 109 | 122 | throw new Exception("Database <{$database}> not found."); |
| 110 | 123 | } |
| 111 | 124 | |
| 112 | - public static function getDb ($database = NULL) { |
|
| 125 | + public static function getDb ($database = NULL) |
|
| 126 | + { |
|
| 113 | 127 | if (is_null (self::$db)) { |
| 114 | 128 | try { |
| 115 | 129 | if (is_readable (self::getDbFileName ($database))) { |
@@ -127,7 +141,8 @@ discard block |
||
| 127 | 141 | return self::$db; |
| 128 | 142 | } |
| 129 | 143 | |
| 130 | - public static function checkDatabaseAvailability () { |
|
| 144 | + public static function checkDatabaseAvailability () |
|
| 145 | + { |
|
| 131 | 146 | if (self::noDatabaseSelected ()) { |
| 132 | 147 | for ($i = 0; $i < count (self::getDbList ()); $i++) { |
| 133 | 148 | self::getDb ($i); |
@@ -139,33 +154,38 @@ discard block |
||
| 139 | 154 | return true; |
| 140 | 155 | } |
| 141 | 156 | |
| 142 | - public static function clearDb () { |
|
| 157 | + public static function clearDb () |
|
| 158 | + { |
|
| 143 | 159 | self::$db = NULL; |
| 144 | 160 | } |
| 145 | 161 | |
| 146 | - public static function executeQuerySingle ($query, $database = NULL) { |
|
| 162 | + public static function executeQuerySingle ($query, $database = NULL) |
|
| 163 | + { |
|
| 147 | 164 | return self::getDb ($database)->query($query)->fetchColumn(); |
| 148 | 165 | } |
| 149 | 166 | |
| 150 | - public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) { |
|
| 167 | + public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) |
|
| 168 | + { |
|
| 151 | 169 | if (!$numberOfString) { |
| 152 | 170 | $numberOfString = $table . ".alphabetical"; |
| 153 | 171 | } |
| 154 | 172 | $count = self::executeQuerySingle ('select count(*) from ' . $table); |
| 155 | - if ($count == 0) return NULL; |
|
| 173 | + if ($count == 0) { |
|
| 174 | + return NULL; |
|
| 175 | + } |
|
| 156 | 176 | $entry = new Entry (localize($table . ".title"), $id, |
| 157 | 177 | str_format (localize($numberOfString, $count), $count), "text", |
| 158 | 178 | array ( new LinkNavigation ("?page=".$pageId)), "", $count); |
| 159 | 179 | return $entry; |
| 160 | 180 | } |
| 161 | 181 | |
| 162 | - public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) { |
|
| 182 | + public static function getEntryArrayWithBookNumber ($query, $columns, $params, $category) |
|
| 183 | + { |
|
| 163 | 184 | /* @var $result PDOStatement */ |
| 164 | 185 | |
| 165 | 186 | list (, $result) = self::executeQuery ($query, $columns, "", $params, -1); |
| 166 | 187 | $entryArray = array(); |
| 167 | - while ($post = $result->fetchObject ()) |
|
| 168 | - { |
|
| 188 | + while ($post = $result->fetchObject ()) { |
|
| 169 | 189 | /* @var $instance Author|Tag|Serie|Publisher */ |
| 170 | 190 | |
| 171 | 191 | $instance = new $category ($post); |
@@ -181,7 +201,8 @@ discard block |
||
| 181 | 201 | return $entryArray; |
| 182 | 202 | } |
| 183 | 203 | |
| 184 | - public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { |
|
| 204 | + public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) |
|
| 205 | + { |
|
| 185 | 206 | $totalResult = -1; |
| 186 | 207 | |
| 187 | 208 | if (useNormAndUp ()) { |
@@ -193,8 +214,7 @@ discard block |
||
| 193 | 214 | $numberPerPage = getCurrentOption ("max_item_per_page"); |
| 194 | 215 | } |
| 195 | 216 | |
| 196 | - if ($numberPerPage != -1 && $n != -1) |
|
| 197 | - { |
|
| 217 | + if ($numberPerPage != -1 && $n != -1) { |
|
| 198 | 218 | // First check total number of results |
| 199 | 219 | $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); |
| 200 | 220 | $result->execute ($params); |