raw sketch of ratings category
This commit is contained in:
parent
4c4cd05eb1
commit
4b7743397b
32
base.php
32
base.php
|
@ -438,6 +438,10 @@ class Page
|
||||||
return new PageAllCustoms ($id, $query, $n);
|
return new PageAllCustoms ($id, $query, $n);
|
||||||
case Base::PAGE_CUSTOM_DETAIL :
|
case Base::PAGE_CUSTOM_DETAIL :
|
||||||
return new PageCustomDetail ($id, $query, $n);
|
return new PageCustomDetail ($id, $query, $n);
|
||||||
|
case Base::PAGE_ALL_RATINGS :
|
||||||
|
return new PageAllRating ($id, $query, $n);
|
||||||
|
case Base::PAGE_RATING_DETAIL :
|
||||||
|
return new PageRatingDetail ($id, $query, $n);
|
||||||
case Base::PAGE_ALL_SERIES :
|
case Base::PAGE_ALL_SERIES :
|
||||||
return new PageAllSeries ($id, $query, $n);
|
return new PageAllSeries ($id, $query, $n);
|
||||||
case Base::PAGE_ALL_BOOKS :
|
case Base::PAGE_ALL_BOOKS :
|
||||||
|
@ -510,6 +514,10 @@ class Page
|
||||||
$tags = Tag::getCount();
|
$tags = Tag::getCount();
|
||||||
if (!is_null ($tags)) array_push ($this->entryArray, $tags);
|
if (!is_null ($tags)) array_push ($this->entryArray, $tags);
|
||||||
}
|
}
|
||||||
|
if (!in_array (PageQueryResult::SCOPE_RATING, getCurrentOption ('ignored_categories'))) {
|
||||||
|
$rating = Rating::getCount();
|
||||||
|
if (!is_null ($rating)) array_push ($this->entryArray, $rating);
|
||||||
|
}
|
||||||
if (!in_array ("language", getCurrentOption ('ignored_categories'))) {
|
if (!in_array ("language", getCurrentOption ('ignored_categories'))) {
|
||||||
$languages = Language::getCount();
|
$languages = Language::getCount();
|
||||||
if (!is_null ($languages)) array_push ($this->entryArray, $languages);
|
if (!is_null ($languages)) array_push ($this->entryArray, $languages);
|
||||||
|
@ -707,6 +715,27 @@ class PageSerieDetail extends Page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PageAllRating extends Page
|
||||||
|
{
|
||||||
|
public function InitializeContent ()
|
||||||
|
{
|
||||||
|
$this->title = localize("rating.title");
|
||||||
|
$this->entryArray = Rating::getAllRatings();
|
||||||
|
$this->idPage = Rating::ALL_RATING_ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PageRatingDetail extends Page
|
||||||
|
{
|
||||||
|
public function InitializeContent ()
|
||||||
|
{
|
||||||
|
$rating = Rating::getRatingById ($this->idGet);
|
||||||
|
$this->idPage = $rating->getEntryId ();
|
||||||
|
$this->title = $rating->name;
|
||||||
|
list ($this->entryArray, $this->totalNumber) = Book::getBooksByRating ($this->idGet, $this->n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PageAllBooks extends Page
|
class PageAllBooks extends Page
|
||||||
{
|
{
|
||||||
public function InitializeContent ()
|
public function InitializeContent ()
|
||||||
|
@ -750,6 +779,7 @@ class PageRecentBooks extends Page
|
||||||
class PageQueryResult extends Page
|
class PageQueryResult extends Page
|
||||||
{
|
{
|
||||||
const SCOPE_TAG = "tag";
|
const SCOPE_TAG = "tag";
|
||||||
|
const SCOPE_RATING = "rating";
|
||||||
const SCOPE_SERIES = "series";
|
const SCOPE_SERIES = "series";
|
||||||
const SCOPE_AUTHOR = "author";
|
const SCOPE_AUTHOR = "author";
|
||||||
const SCOPE_BOOK = "book";
|
const SCOPE_BOOK = "book";
|
||||||
|
@ -1029,6 +1059,8 @@ abstract class Base
|
||||||
const PAGE_CUSTOMIZE = "19";
|
const PAGE_CUSTOMIZE = "19";
|
||||||
const PAGE_ALL_PUBLISHERS = "20";
|
const PAGE_ALL_PUBLISHERS = "20";
|
||||||
const PAGE_PUBLISHER_DETAIL = "21";
|
const PAGE_PUBLISHER_DETAIL = "21";
|
||||||
|
const PAGE_ALL_RATINGS = "22";
|
||||||
|
const PAGE_RATING_DETAIL = "23";
|
||||||
|
|
||||||
const COMPATIBILITY_XML_ALDIKO = "aldiko";
|
const COMPATIBILITY_XML_ALDIKO = "aldiko";
|
||||||
|
|
||||||
|
|
8
book.php
8
book.php
|
@ -9,6 +9,7 @@
|
||||||
require_once('base.php');
|
require_once('base.php');
|
||||||
require_once('serie.php');
|
require_once('serie.php');
|
||||||
require_once('author.php');
|
require_once('author.php');
|
||||||
|
require_once('rating.php');
|
||||||
require_once('publisher.php');
|
require_once('publisher.php');
|
||||||
require_once('tag.php');
|
require_once('tag.php');
|
||||||
require_once('language.php');
|
require_once('language.php');
|
||||||
|
@ -44,6 +45,8 @@ define ('SQL_BOOKS_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
|
||||||
title like ?) {1} order by books.sort");
|
title like ?) {1} order by books.sort");
|
||||||
define ('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
|
define ('SQL_BOOKS_RECENT', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
|
||||||
where 1=1 {1} order by timestamp desc limit ");
|
where 1=1 {1} order by timestamp desc limit ");
|
||||||
|
define ('SQL_BOOKS_BY_RATING', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
|
||||||
|
where books_ratings_link.book = books.id and ratings.id = ? {1} order by sort");
|
||||||
|
|
||||||
class Book extends Base {
|
class Book extends Base {
|
||||||
const ALL_BOOKS_UUID = "urn:uuid";
|
const ALL_BOOKS_UUID = "urn:uuid";
|
||||||
|
@ -62,6 +65,7 @@ class Book extends Base {
|
||||||
const SQL_BOOKS_BY_CUSTOM = SQL_BOOKS_BY_CUSTOM;
|
const SQL_BOOKS_BY_CUSTOM = SQL_BOOKS_BY_CUSTOM;
|
||||||
const SQL_BOOKS_QUERY = SQL_BOOKS_QUERY;
|
const SQL_BOOKS_QUERY = SQL_BOOKS_QUERY;
|
||||||
const SQL_BOOKS_RECENT = SQL_BOOKS_RECENT;
|
const SQL_BOOKS_RECENT = SQL_BOOKS_RECENT;
|
||||||
|
const SQL_BOOKS_BY_RATING = SQL_BOOKS_BY_RATING;
|
||||||
|
|
||||||
const BAD_SEARCH = "QQQQQ";
|
const BAD_SEARCH = "QQQQQ";
|
||||||
|
|
||||||
|
@ -447,6 +451,10 @@ class Book extends Base {
|
||||||
return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n);
|
return self::getEntryArray (self::SQL_BOOKS_BY_AUTHOR, array ($authorId), $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getBooksByRating($ratingId, $n) {
|
||||||
|
return self::getEntryArray (self::SQL_BOOKS_BY_RATING, array ($ratingId), $n);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getBooksByPublisher($publisherId, $n) {
|
public static function getBooksByPublisher($publisherId, $n) {
|
||||||
return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n);
|
return self::getEntryArray (self::SQL_BOOKS_BY_PUBLISHER, array ($publisherId), $n);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
require_once ("config.php");
|
require_once ("config.php");
|
||||||
require_once ("base.php");
|
require_once ("base.php");
|
||||||
require_once ("author.php");
|
require_once ("author.php");
|
||||||
|
require_once ("rating.php");
|
||||||
require_once ("publisher.php");
|
require_once ("publisher.php");
|
||||||
require_once ("serie.php");
|
require_once ("serie.php");
|
||||||
require_once ("tag.php");
|
require_once ("tag.php");
|
||||||
|
|
65
rating.php
Normal file
65
rating.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* COPS (Calibre OPDS PHP Server) class file
|
||||||
|
*
|
||||||
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||||
|
* @author Michael Pfitzner
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('base.php');
|
||||||
|
|
||||||
|
class Rating extends Base {
|
||||||
|
const ALL_RATING_ID = "cops:rating";
|
||||||
|
|
||||||
|
const AUTHOR_COLUMNS = "ratings.id as id, ratings.rating as rating, count(*) as count";
|
||||||
|
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";
|
||||||
|
public $id;
|
||||||
|
public $name;
|
||||||
|
public $sort;
|
||||||
|
|
||||||
|
public function __construct($pid, $pname) {
|
||||||
|
$this->id = $pid;
|
||||||
|
$this->name = $pname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUri () {
|
||||||
|
return "?page=".parent::PAGE_RATING_DETAIL."&id=$this->id";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEntryId () {
|
||||||
|
return self::ALL_RATING_ID.":".$this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCount() {
|
||||||
|
$nAuthors = parent::getDb ()->query('select count(*) from ratings')->fetchColumn();
|
||||||
|
$entry = new Entry (localize("rating.title"), self::ALL_RATING_ID,
|
||||||
|
str_format (localize("ratings", $nAuthors), $nAuthors), "text",
|
||||||
|
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RATINGS)));
|
||||||
|
return $entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getAllRatings() {
|
||||||
|
return self::getEntryArray (self::SQL_ALL_RATINGS, array ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEntryArray ($query, $params) {
|
||||||
|
list ($totalNumber, $result) = parent::executeQuery ($query, self::AUTHOR_COLUMNS, "", $params, -1);
|
||||||
|
$entryArray = array();
|
||||||
|
while ($post = $result->fetchObject ())
|
||||||
|
{
|
||||||
|
$rating = new Rating ($post->id, $post->rating);
|
||||||
|
$bewertung=$post->rating/2;
|
||||||
|
$bewertung.=" Sterne";
|
||||||
|
array_push ($entryArray, new Entry ($bewertung, $rating->getEntryId (),
|
||||||
|
str_format (localize("bookword", $post->count), $post->count), "text",
|
||||||
|
array ( new LinkNavigation ($rating->getUri ()))));
|
||||||
|
}
|
||||||
|
return $entryArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRatingById ($ratingId) {
|
||||||
|
$result = parent::getDb ()->prepare('select rating from ratings where id = ?');
|
||||||
|
$result->execute (array ($ratingId));
|
||||||
|
return new Author ($ratingId, $result->fetchColumn ());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue