Centralize the getCount function.
This commit is contained in:
parent
70611e5c50
commit
4be0366a0a
|
@ -39,11 +39,8 @@ class Author extends Base {
|
|||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nAuthors = parent::executeQuerySingle ('select count(*) from authors');
|
||||
$entry = new Entry (localize("authors.title"), self::ALL_AUTHORS_ID,
|
||||
str_format (localize("authors.alphabetical", $nAuthors), $nAuthors), "text",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_AUTHORS)));
|
||||
return $entry;
|
||||
// str_format (localize("authors.alphabetical", count(array))
|
||||
return parent::getCountGeneric ("authors", self::ALL_AUTHORS_ID, parent::PAGE_ALL_AUTHORS);
|
||||
}
|
||||
|
||||
public static function getAllAuthorsByFirstLetter() {
|
||||
|
|
12
base.php
12
base.php
|
@ -1252,6 +1252,18 @@ abstract class Base
|
|||
return self::getDb ($database)->query($query)->fetchColumn();
|
||||
}
|
||||
|
||||
public static function getCountGeneric($table, $id, $pageId, $numberOfString = NULL) {
|
||||
if (!$numberOfString) {
|
||||
$numberOfString = $table . ".alphabetical";
|
||||
}
|
||||
$count = self::executeQuerySingle ('select count(*) from ' . $table);
|
||||
if ($count == 0) return NULL;
|
||||
$entry = new Entry (localize($table . ".title"), $id,
|
||||
str_format (localize($numberOfString, $count), $count), "text",
|
||||
array ( new LinkNavigation ("?page=".$pageId)));
|
||||
return $entry;
|
||||
}
|
||||
|
||||
public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) {
|
||||
$totalResult = -1;
|
||||
|
||||
|
|
|
@ -36,12 +36,8 @@ class language extends Base {
|
|||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nLanguages = parent::executeQuerySingle ('select count(*) from languages');
|
||||
if ($nLanguages == 0) return NULL;
|
||||
$entry = new Entry (localize("languages.title"), self::ALL_LANGUAGES_ID,
|
||||
str_format (localize("languages.alphabetical", $nLanguages), $nLanguages), "text",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_LANGUAGES)));
|
||||
return $entry;
|
||||
// str_format (localize("languages.alphabetical", count(array))
|
||||
return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES);
|
||||
}
|
||||
|
||||
public static function getLanguageById ($languageId) {
|
||||
|
|
|
@ -28,12 +28,8 @@ class Publisher extends Base {
|
|||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nPublishers = parent::executeQuerySingle ('select count(*) from publishers');
|
||||
if ($nPublishers == 0) return NULL;
|
||||
$entry = new Entry (localize("publishers.title"), self::ALL_PUBLISHERS_ID,
|
||||
str_format (localize("publishers.alphabetical", $nPublishers), $nPublishers), "text",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_PUBLISHERS)));
|
||||
return $entry;
|
||||
// str_format (localize("publishers.alphabetical", count(array))
|
||||
return parent::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, parent::PAGE_ALL_PUBLISHERS);
|
||||
}
|
||||
|
||||
public static function getPublisherByBookId ($bookId) {
|
||||
|
|
|
@ -30,11 +30,8 @@ class Rating extends Base {
|
|||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nRatings = parent::executeQuerySingle ('select count(*) from ratings');
|
||||
$entry = new Entry (localize("ratings.title"), self::ALL_RATING_ID,
|
||||
str_format (localize("ratings", $nRatings), $nRatings), "text",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RATINGS)));
|
||||
return $entry;
|
||||
// str_format (localize("ratings", count(array))
|
||||
return parent::getCountGeneric ("ratings", self::ALL_RATING_ID, parent::PAGE_ALL_RATINGS, "ratings");
|
||||
}
|
||||
|
||||
public static function getAllRatings() {
|
||||
|
|
|
@ -28,12 +28,8 @@ class Serie extends Base {
|
|||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nSeries = parent::executeQuerySingle ('select count(*) from series');
|
||||
if ($nSeries == 0) return NULL;
|
||||
$entry = new Entry (localize("series.title"), self::ALL_SERIES_ID,
|
||||
str_format (localize("series.alphabetical", $nSeries), $nSeries), "text",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_SERIES)));
|
||||
return $entry;
|
||||
// str_format (localize("series.alphabetical", count(array))
|
||||
return parent::getCountGeneric ("series", self::ALL_SERIES_ID, parent::PAGE_ALL_SERIES);
|
||||
}
|
||||
|
||||
public static function getSerieByBookId ($bookId) {
|
||||
|
|
8
tag.php
8
tag.php
|
@ -28,12 +28,8 @@ class tag extends Base {
|
|||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nTags = parent::executeQuerySingle ('select count(*) from tags');
|
||||
if ($nTags == 0) return NULL;
|
||||
$entry = new Entry (localize("tags.title"), self::ALL_TAGS_ID,
|
||||
str_format (localize("tags.alphabetical", $nTags), $nTags), "text",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_TAGS)));
|
||||
return $entry;
|
||||
// str_format (localize("tags.alphabetical", count(array))
|
||||
return parent::getCountGeneric ("tags", self::ALL_TAGS_ID, parent::PAGE_ALL_TAGS);
|
||||
}
|
||||
|
||||
public static function getTagById ($tagId) {
|
||||
|
|
Loading…
Reference in a new issue