1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* COPS (Calibre OPDS PHP Server) class file |
4
|
|
|
* |
5
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
6
|
|
|
* @author At Libitum <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
require_once('base.php'); |
10
|
|
|
|
11
|
|
|
class Publisher extends Base { |
12
|
|
|
const ALL_PUBLISHERS_ID = "cops:publishers"; |
13
|
|
|
const SQL_ALL_PUBLISHERS = |
14
|
|
|
"select publishers.id as id, publishers.name as name, count(*) as count |
15
|
|
|
from publishers |
16
|
|
|
inner join books_publishers_link as link on publishers.id = link.publisher |
17
|
|
|
inner join ({0}) as filter on filter.id = link.book |
18
|
|
|
group by publishers.id, publishers.name |
19
|
|
|
order by publishers.name"; |
20
|
|
|
const SQL_PUBLISHERS_FOR_SEARCH = |
21
|
11 |
|
"select publishers.id as id, publishers.name as name, count(*) as count |
22
|
11 |
|
from publishers |
23
|
11 |
|
inner join books_publishers_link as link on publishers.id = link.publisher |
24
|
11 |
|
inner join ({0}) as filter on filter.id = link.book |
25
|
|
|
where upper (publishers.name) like ? |
26
|
9 |
|
group by publishers.id, publishers.name |
27
|
9 |
|
order by publishers.name"; |
28
|
|
|
|
29
|
|
|
|
30
|
7 |
|
public $id; |
31
|
7 |
|
public $name; |
32
|
|
|
|
33
|
|
|
public function __construct($post) { |
34
|
7 |
|
$this->id = $post->id; |
35
|
|
|
$this->name = $post->name; |
36
|
7 |
|
} |
37
|
|
|
|
38
|
|
|
public function getUri () { |
39
|
4 |
|
return "?page=".parent::PAGE_PUBLISHER_DETAIL."&id=$this->id"; |
40
|
4 |
|
} |
41
|
|
|
|
42
|
4 |
|
public function getEntryId () { |
43
|
4 |
|
return self::ALL_PUBLISHERS_ID.":".$this->id; |
44
|
4 |
|
} |
45
|
4 |
|
|
46
|
|
|
public static function getCount() { |
47
|
|
|
// str_format (localize("publishers.alphabetical", count(array)) |
48
|
|
|
return parent::getCountGeneric ("publishers", self::ALL_PUBLISHERS_ID, parent::PAGE_ALL_PUBLISHERS); |
|
|
|
|
49
|
|
|
} |
50
|
1 |
|
|
51
|
1 |
|
public static function getPublisherByBookId ($bookId) { |
52
|
1 |
|
$result = parent::getDb ()->prepare('select publishers.id as id, name |
|
|
|
|
53
|
1 |
|
from books_publishers_link, publishers |
54
|
1 |
|
where publishers.id = publisher and book = ?'); |
55
|
1 |
|
$result->execute (array ($bookId)); |
56
|
|
|
if ($post = $result->fetchObject ()) { |
57
|
|
|
return new Publisher ($post); |
58
|
|
|
} |
59
|
|
|
return NULL; |
60
|
2 |
|
} |
61
|
2 |
|
|
62
|
|
|
public static function getPublisherById ($publisherId) { |
63
|
|
|
$result = parent::getDb ()->prepare('select id, name |
|
|
|
|
64
|
23 |
|
from publishers where id = ?'); |
65
|
23 |
|
$result->execute (array ($publisherId)); |
66
|
|
|
if ($post = $result->fetchObject ()) { |
67
|
|
|
return new Publisher ($post); |
68
|
|
|
} |
69
|
|
|
return NULL; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public static function getAllPublishers() { |
73
|
|
|
return Base::getEntryArrayWithBookNumber (self::SQL_ALL_PUBLISHERS, array (), "Publisher"); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public static function getAllPublishersByQuery($query) { |
77
|
|
|
return Base::getEntryArrayWithBookNumber (self::SQL_PUBLISHERS_FOR_SEARCH, array ('%' . $query . '%'), "Publisher"); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.