Browse Source

Centralize the getCount function.

master
Sébastien Lucas 10 years ago
parent
commit
4be0366a0a
7 changed files with 24 additions and 34 deletions
  1. +2
    -5
      author.php
  2. +12
    -0
      base.php
  3. +2
    -6
      language.php
  4. +2
    -6
      publisher.php
  5. +2
    -5
      rating.php
  6. +2
    -6
      serie.php
  7. +2
    -6
      tag.php

+ 2
- 5
author.php View File

@@ -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
- 0
base.php View File

@@ -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;



+ 2
- 6
language.php View File

@@ -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) {


+ 2
- 6
publisher.php View File

@@ -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) {


+ 2
- 5
rating.php View File

@@ -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() {


+ 2
- 6
serie.php View File

@@ -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) {


+ 2
- 6
tag.php View File

@@ -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…
Cancel
Save