mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 10:56:46 -04:00
Add support for tag browsing and collection browsing
This commit is contained in:
parent
f5d7d4e02a
commit
cfa54122d6
8 changed files with 181 additions and 14 deletions
|
@ -12,6 +12,7 @@ class Ebook{
|
|||
public $GitCommits = [];
|
||||
public $Tags = [];
|
||||
public $LocTags = [];
|
||||
public $Collections = [];
|
||||
public $Identifier;
|
||||
public $UrlSafeIdentifier;
|
||||
public $HeroImageUrl;
|
||||
|
@ -149,7 +150,12 @@ class Ebook{
|
|||
|
||||
// Get SE tags
|
||||
foreach($xml->xpath('/package/metadata/meta[@property="se:subject"]') ?: [] as $tag){
|
||||
$this->Tags[] = (string)$tag;
|
||||
$this->Tags[] = new Tag($tag);
|
||||
}
|
||||
|
||||
// Get SE collections
|
||||
foreach($xml->xpath('/package/metadata/meta[@property="se:collection"]') ?: [] as $collection){
|
||||
$this->Collections[] = new Collection($collection);
|
||||
}
|
||||
|
||||
// Get LoC tags
|
||||
|
@ -337,7 +343,7 @@ class Ebook{
|
|||
}
|
||||
|
||||
foreach($this->Tags as $tag){
|
||||
$searchString .= ' ' . $tag;
|
||||
$searchString .= ' ' . $tag->Name;
|
||||
}
|
||||
|
||||
foreach($this->LocTags as $tag){
|
||||
|
@ -502,5 +508,25 @@ class Ebook{
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function HasTag(string $tag): bool{
|
||||
foreach($this->Tags as $t){
|
||||
if(strtolower($t->Name) == strtolower($tag)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function IsInCollection(string $collection): bool{
|
||||
foreach($this->Collections as $c){
|
||||
if(strtolower($c->Name) == strtolower($collection)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue