|
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 Sébastien Lucas <[email protected]> |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
class Entry |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
public $title; |
|
12
|
|
|
public $id; |
|
13
|
|
|
public $content; |
|
14
|
|
|
public $numberOfElement; |
|
15
|
|
|
public $contentType; |
|
16
|
|
|
public $linkArray; |
|
17
|
|
|
public $localUpdated; |
|
18
|
|
|
public $className; |
|
19
|
|
|
private static $updated = NULL; |
|
20
|
|
|
|
|
21
|
|
|
public static $icons = array( |
|
22
|
|
|
Author::ALL_AUTHORS_ID => 'images/author.png', |
|
23
|
|
|
Serie::ALL_SERIES_ID => 'images/serie.png', |
|
24
|
|
|
Book::ALL_RECENT_BOOKS_ID => 'images/recent.png', |
|
25
|
|
|
Tag::ALL_TAGS_ID => 'images/tag.png', |
|
26
|
|
|
Language::ALL_LANGUAGES_ID => 'images/language.png', |
|
27
|
|
|
CustomColumnType::ALL_CUSTOMS_ID => 'images/custom.png', |
|
28
|
|
|
Rating::ALL_RATING_ID => 'images/rating.png', |
|
29
|
|
|
"cops:books$" => 'images/allbook.png', |
|
|
|
|
|
|
30
|
|
|
"cops:books:letter" => 'images/allbook.png', |
|
|
|
|
|
|
31
|
|
|
Publisher::ALL_PUBLISHERS_ID => 'images/publisher.png' |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
|
|
public function getUpdatedTime () { |
|
35
|
|
|
if (!is_null ($this->localUpdated)) { |
|
36
|
|
|
return date (DATE_ATOM, $this->localUpdated); |
|
37
|
|
|
} |
|
38
|
|
|
if (is_null (self::$updated)) { |
|
39
|
|
|
self::$updated = time(); |
|
40
|
|
|
} |
|
41
|
|
|
return date (DATE_ATOM, self::$updated); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
7 |
View Code Duplication |
public function getNavLink () { |
|
|
|
|
|
|
45
|
7 |
|
foreach ($this->linkArray as $link) { |
|
46
|
|
|
/* @var $link LinkNavigation */ |
|
47
|
|
|
|
|
48
|
7 |
|
if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; } |
|
49
|
|
|
|
|
50
|
7 |
|
return $link->hrefXhtml (); |
|
51
|
|
|
} |
|
52
|
|
|
return "#"; |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
109 |
|
public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0) { |
|
|
|
|
|
|
56
|
109 |
|
global $config; |
|
|
|
|
|
|
57
|
109 |
|
$this->title = $ptitle; |
|
58
|
109 |
|
$this->id = $pid; |
|
59
|
109 |
|
$this->content = $pcontent; |
|
60
|
109 |
|
$this->contentType = $pcontentType; |
|
61
|
109 |
|
$this->linkArray = $plinkArray; |
|
62
|
109 |
|
$this->className = $pclass; |
|
63
|
109 |
|
$this->numberOfElement = $pcount; |
|
64
|
|
|
|
|
65
|
109 |
|
if ($config['cops_show_icons'] == 1) |
|
66
|
109 |
|
{ |
|
67
|
109 |
|
foreach (self::$icons as $reg => $image) |
|
68
|
|
|
{ |
|
69
|
109 |
|
if (preg_match ("/" . $reg . "/", $pid)) { |
|
|
|
|
|
|
70
|
69 |
|
array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE)); |
|
|
|
|
|
|
71
|
69 |
|
break; |
|
72
|
|
|
} |
|
73
|
109 |
|
} |
|
74
|
109 |
|
} |
|
75
|
|
|
|
|
76
|
109 |
|
if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id); |
|
|
|
|
|
|
77
|
109 |
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.