@@ -25,69 +25,69 @@ |
||
| 25 | 25 | $this->sort = $post->sort; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function getUri () { |
|
| 29 | - return "?page=".Base::PAGE_AUTHOR_DETAIL."&id=$this->id"; |
|
| 28 | + public function getUri() { |
|
| 29 | + return "?page=" . Base::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 Base::getCountGeneric ("authors", self::ALL_AUTHORS_ID, Base::PAGE_ALL_AUTHORS); |
|
| 42 | + return Base::getCountGeneric("authors", self::ALL_AUTHORS_ID, Base::PAGE_ALL_AUTHORS); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static function getAllAuthorsByFirstLetter() { |
| 46 | - list (, $result) = Base::executeQuery ("select {0} |
|
| 46 | + list (, $result) = Base::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=".Base::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=" . Base::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 = Base::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 = Base::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 = Base::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 = Base::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 = ?'); |
| 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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | const ALL_RATING_ID = "cops:rating"; |
| 12 | 12 | |
| 13 | 13 | const RATING_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count"; |
| 14 | - const SQL_ALL_RATINGS ="select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating"; |
|
| 14 | + const SQL_ALL_RATINGS = "select {0} from ratings, books_ratings_link where books_ratings_link.rating = ratings.id group by ratings.id order by ratings.rating"; |
|
| 15 | 15 | public $id; |
| 16 | 16 | public $name; |
| 17 | 17 | |
@@ -20,41 +20,41 @@ discard block |
||
| 20 | 20 | $this->name = $pname; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function getUri () { |
|
| 24 | - return "?page=".Base::PAGE_RATING_DETAIL."&id=$this->id"; |
|
| 23 | + public function getUri() { |
|
| 24 | + return "?page=" . Base::PAGE_RATING_DETAIL . "&id=$this->id"; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function getEntryId () { |
|
| 28 | - return self::ALL_RATING_ID.":".$this->id; |
|
| 27 | + public function getEntryId() { |
|
| 28 | + return self::ALL_RATING_ID . ":" . $this->id; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public static function getCount() { |
| 32 | 32 | // str_format (localize("ratings", count(array)) |
| 33 | - return Base::getCountGeneric ("ratings", self::ALL_RATING_ID, Base::PAGE_ALL_RATINGS, "ratings"); |
|
| 33 | + return Base::getCountGeneric("ratings", self::ALL_RATING_ID, Base::PAGE_ALL_RATINGS, "ratings"); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public static function getAllRatings() { |
| 37 | - return self::getEntryArray (self::SQL_ALL_RATINGS, array ()); |
|
| 37 | + return self::getEntryArray(self::SQL_ALL_RATINGS, array()); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public static function getEntryArray ($query, $params) { |
|
| 41 | - list (, $result) = Base::executeQuery ($query, self::RATING_COLUMNS, "", $params, -1); |
|
| 40 | + public static function getEntryArray($query, $params) { |
|
| 41 | + list (, $result) = Base::executeQuery($query, self::RATING_COLUMNS, "", $params, -1); |
|
| 42 | 42 | $entryArray = array(); |
| 43 | - while ($post = $result->fetchObject ()) |
|
| 43 | + while ($post = $result->fetchObject()) |
|
| 44 | 44 | { |
| 45 | - $ratingObj = new Rating ($post->id, $post->rating); |
|
| 46 | - $rating=$post->rating/2; |
|
| 47 | - $rating = str_format (localize("ratingword", $rating), $rating); |
|
| 48 | - array_push ($entryArray, new Entry ($rating, $ratingObj->getEntryId (), |
|
| 49 | - str_format (localize("bookword", $post->count), $post->count), "text", |
|
| 50 | - array ( new LinkNavigation ($ratingObj->getUri ())), "", $post->count)); |
|
| 45 | + $ratingObj = new Rating($post->id, $post->rating); |
|
| 46 | + $rating = $post->rating / 2; |
|
| 47 | + $rating = str_format(localize("ratingword", $rating), $rating); |
|
| 48 | + array_push($entryArray, new Entry($rating, $ratingObj->getEntryId(), |
|
| 49 | + str_format(localize("bookword", $post->count), $post->count), "text", |
|
| 50 | + array(new LinkNavigation($ratingObj->getUri())), "", $post->count)); |
|
| 51 | 51 | } |
| 52 | 52 | return $entryArray; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function getRatingById ($ratingId) { |
|
| 56 | - $result = Base::getDb ()->prepare('select rating from ratings where id = ?'); |
|
| 57 | - $result->execute (array ($ratingId)); |
|
| 58 | - return new Rating ($ratingId, $result->fetchColumn ()); |
|
| 55 | + public static function getRatingById($ratingId) { |
|
| 56 | + $result = Base::getDb()->prepare('select rating from ratings where id = ?'); |
|
| 57 | + $result->execute(array($ratingId)); |
|
| 58 | + return new Rating($ratingId, $result->fetchColumn()); |
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -15,8 +15,8 @@ |
||
| 15 | 15 | |
| 16 | 16 | $idData = getURLParam('data', NULL); |
| 17 | 17 | $add = 'data=' . $idData . '&'; |
| 18 | -if (!is_null (GetUrlParam (DB))) { |
|
| 19 | - $add .= DB . '=' . GetUrlParam (DB) . '&'; |
|
| 18 | +if (!is_null(GetUrlParam(DB))) { |
|
| 19 | + $add .= DB . '=' . GetUrlParam(DB) . '&'; |
|
| 20 | 20 | } |
| 21 | 21 | $myBook = Book::getBookByDataId($idData); |
| 22 | 22 | |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | public static function isMultipleDatabaseEnabled() |
| 41 | 41 | { |
| 42 | 42 | global $config; |
| 43 | - return is_array ($config['calibre_directory']); |
|
| 43 | + return is_array($config['calibre_directory']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public static function useAbsolutePath() |
| 47 | 47 | { |
| 48 | 48 | global $config; |
| 49 | 49 | $path = self::getDbDirectory(); |
| 50 | - return preg_match ('/^\//', $path) || // Linux / |
|
| 51 | - preg_match ('/^\w\:/', $path); // Windows X: |
|
| 50 | + return preg_match('/^\//', $path) || // Linux / |
|
| 51 | + preg_match('/^\w\:/', $path); // Windows X: |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public static function noDatabaseSelected() |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | global $config; |
| 72 | 72 | if (self::isMultipleDatabaseEnabled()) { |
| 73 | - return array_keys ($config['calibre_directory']); |
|
| 73 | + return array_keys($config['calibre_directory']); |
|
| 74 | 74 | } else { |
| 75 | - return array (''); |
|
| 75 | + return array(''); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | public static function getDbFileName($database = NULL) |
| 108 | 108 | { |
| 109 | - return self::getDbDirectory($database) .'metadata.db'; |
|
| 109 | + return self::getDbDirectory($database) . 'metadata.db'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | private static function error($database) |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | throw new Exception('Database <' . $database . '> not found.'); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - public static function getDb ($database = NULL) |
|
| 120 | + public static function getDb($database = NULL) |
|
| 121 | 121 | { |
| 122 | - if (is_null (self::$db)) { |
|
| 122 | + if (is_null(self::$db)) { |
|
| 123 | 123 | try { |
| 124 | - if (is_readable(self::getDbFileName ($database))) { |
|
| 125 | - self::$db = new PDO('sqlite:'. self::getDbFileName($database)); |
|
| 124 | + if (is_readable(self::getDbFileName($database))) { |
|
| 125 | + self::$db = new PDO('sqlite:' . self::getDbFileName($database)); |
|
| 126 | 126 | if (useNormAndUp()) { |
| 127 | 127 | self::$db->sqliteCreateFunction('normAndUp', 'normAndUp', 1); |
| 128 | 128 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | $entry = new Entry(localize($table . '.title'), $id, |
| 172 | 172 | str_format(localize($numberOfString, $count), $count), 'text', |
| 173 | - array(new LinkNavigation('?page='.$pageId)), '', $count); |
|
| 173 | + array(new LinkNavigation('?page=' . $pageId)), '', $count); |
|
| 174 | 174 | return $entry; |
| 175 | 175 | } |
| 176 | 176 | |