2022-03-24 22:03:18 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class KilledbyGoogleBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2022-03-24 22:03:18 +03:00
|
|
|
const NAME = 'Killed by Google Bridge';
|
|
|
|
const URI = 'https://killedbygoogle.com';
|
|
|
|
const DESCRIPTION = 'Returns list of recently discontinued Google services, products, devices, and apps.';
|
|
|
|
const MAINTAINER = 'VerifiedJoseph';
|
|
|
|
const PARAMETERS = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
const CACHE_TIMEOUT = 3600;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2024-07-31 18:30:06 +03:00
|
|
|
$json = getContents(self::URI . '/graveyard.json');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
$this->handleJson($json);
|
|
|
|
$this->orderItems();
|
|
|
|
$this->limitItems();
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
/**
|
|
|
|
* Handle JSON
|
|
|
|
*/
|
|
|
|
private function handleJson($json)
|
|
|
|
{
|
|
|
|
$graveyard = json_decode($json, true);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
foreach ($graveyard as $tombstone) {
|
|
|
|
$item = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
$openDate = new DateTime($tombstone['dateOpen']);
|
|
|
|
$closeDate = new DateTime($tombstone['dateClose']);
|
|
|
|
$currentDate = new DateTime();
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
$yearOpened = $openDate->format('Y');
|
|
|
|
$yearClosed = $closeDate->format('Y');
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
if ($closeDate > $currentDate) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
$item['title'] = $tombstone['name'] . ' (' . $yearOpened . ' - ' . $yearClosed . ')';
|
|
|
|
$item['uid'] = $tombstone['slug'];
|
2022-06-22 19:33:48 +03:00
|
|
|
$item['uri'] = $tombstone['link'];
|
2022-03-24 22:03:18 +03:00
|
|
|
$item['timestamp'] = strtotime($tombstone['dateClose']);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
$item['content'] = <<<EOD
|
2022-06-22 19:33:48 +03:00
|
|
|
<p>{$tombstone['description']}</p><p><a href="{$tombstone['link']}">{$tombstone['link']}</a></p>
|
2022-03-24 22:03:18 +03:00
|
|
|
EOD;
|
|
|
|
|
2022-06-22 19:33:48 +03:00
|
|
|
$item['enclosures'][] = 'https://static.killedbygoogle.com/com/tombstone.svg';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
/**
|
|
|
|
* Order items by timestamp
|
|
|
|
*/
|
|
|
|
private function orderItems()
|
|
|
|
{
|
|
|
|
$sort = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
foreach ($this->items as $key => $item) {
|
|
|
|
$sort[$key] = $item['timestamp'];
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
array_multisort($sort, SORT_DESC, $this->items);
|
|
|
|
$this->items = array_slice($this->items, 0, 15);
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-03-24 22:03:18 +03:00
|
|
|
/**
|
|
|
|
* Limit items to 15
|
|
|
|
*/
|
|
|
|
private function limitItems()
|
|
|
|
{
|
|
|
|
$this->items = array_slice($this->items, 0, 15);
|
|
|
|
}
|
|
|
|
}
|