2019-11-09 20:50:08 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class ComicsKingdomBridge extends BridgeAbstract
|
|
|
|
{
|
2024-03-10 17:18:50 +03:00
|
|
|
const MAINTAINER = 'TReKiE';
|
|
|
|
// const MAINTAINER = 'stjohnjohnson';
|
2022-07-01 16:10:30 +03:00
|
|
|
const NAME = 'Comics Kingdom Unofficial RSS';
|
2024-03-10 17:18:50 +03:00
|
|
|
const URI = 'https://wp.comicskingdom.com/wp-json/wp/v2/ck_comic';
|
2022-07-01 16:10:30 +03:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
|
|
const DESCRIPTION = 'Comics Kingdom Unofficial RSS';
|
|
|
|
const PARAMETERS = [ [
|
|
|
|
'comicname' => [
|
2024-03-10 17:18:50 +03:00
|
|
|
'name' => 'Name of comic',
|
2022-07-01 16:10:30 +03:00
|
|
|
'type' => 'text',
|
|
|
|
'exampleValue' => 'mutts',
|
|
|
|
'title' => 'The name of the comic in the URL after https://comicskingdom.com/',
|
|
|
|
'required' => true
|
2024-03-10 17:18:50 +03:00
|
|
|
],
|
|
|
|
'limit' => [
|
|
|
|
'name' => 'Limit',
|
|
|
|
'type' => 'number',
|
|
|
|
'title' => 'The number of recent comics to get',
|
|
|
|
'defaultValue' => 10
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]];
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2024-03-10 17:18:50 +03:00
|
|
|
protected $comicName;
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2024-03-10 17:18:50 +03:00
|
|
|
$json = getContents($this->getURI());
|
|
|
|
$data = json_decode($json, false);
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2024-03-10 17:18:50 +03:00
|
|
|
if (isset($data[0]->_embedded->{'wp:term'}[0][0])) {
|
|
|
|
$this->comicName = $data[0]->_embedded->{'wp:term'}[0][0]->name;
|
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2024-03-10 17:18:50 +03:00
|
|
|
foreach ($data as $comicitem) {
|
2022-07-01 16:10:30 +03:00
|
|
|
$item = [];
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2024-03-10 17:18:50 +03:00
|
|
|
$item['id'] = $comicitem->id;
|
|
|
|
$item['uri'] = $comicitem->yoast_head_json->og_url;
|
|
|
|
$item['author'] = str_ireplace('By ', '', $comicitem->ck_comic_byline);
|
|
|
|
$item['title'] = $comicitem->yoast_head_json->title;
|
|
|
|
$item['timestamp'] = $comicitem->date;
|
|
|
|
$item['content'] = '<img src="' . $comicitem->yoast_head_json->og_image[0]->url . '" />';
|
2022-07-01 16:10:30 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('comicname'))) {
|
2024-03-10 17:18:50 +03:00
|
|
|
$params = [
|
|
|
|
'ck_feature' => $this->getInput('comicname'),
|
|
|
|
'per_page' => $this->getInput('limit'),
|
|
|
|
'date_inclusive' => 'true',
|
|
|
|
'order' => 'desc',
|
|
|
|
'page' => '1',
|
|
|
|
'_embed' => 'true'
|
|
|
|
];
|
|
|
|
|
|
|
|
return self::URI . '?' . http_build_query($params);
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return parent::getURI();
|
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
2024-03-10 17:18:50 +03:00
|
|
|
if ($this->comicName) {
|
|
|
|
return $this->comicName . ' - Comics Kingdom';
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return parent::getName();
|
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
}
|