2018-07-16 13:02:41 +03:00
|
|
|
<?php
|
2022-04-13 00:37:30 +03:00
|
|
|
|
2018-07-16 13:02:41 +03:00
|
|
|
class ZenodoBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'theradialactive';
|
|
|
|
const NAME = 'Zenodo';
|
|
|
|
const URI = 'https://zenodo.org';
|
|
|
|
const CACHE_TIMEOUT = 10;
|
|
|
|
const DESCRIPTION = 'Returns the newest content of Zenodo';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-07-16 13:02:41 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI());
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-06-14 16:44:26 +03:00
|
|
|
foreach ($html->find('div.record-elem.row') as $element) {
|
2018-07-16 13:02:41 +03:00
|
|
|
$item = [];
|
2022-06-14 16:44:26 +03:00
|
|
|
$item['uri'] = self::URI . $element->find('h4 > a', 0)->href;
|
|
|
|
$item['title'] = trim(htmlspecialchars_decode($element->find('h4 > a', 0)->innertext, ENT_QUOTES));
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-06-14 16:44:26 +03:00
|
|
|
$authors = $element->find('p', 0);
|
|
|
|
if ($authors) {
|
|
|
|
$item['author'] = $authors->plaintext;
|
2022-04-13 00:37:30 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-06-14 16:44:26 +03:00
|
|
|
$summary = $element->find('p.hidden-xs > a', 0);
|
|
|
|
if ($summary) {
|
|
|
|
$content = $summary->innertext . '<br>';
|
2022-04-13 00:37:30 +03:00
|
|
|
} else {
|
2022-06-14 16:44:26 +03:00
|
|
|
$content = 'No content';
|
2018-07-16 13:02:41 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-07-16 13:02:41 +03:00
|
|
|
$type = '<br>Type: ' . $element->find('span.label-default', 0)->innertext;
|
2022-06-14 16:44:26 +03:00
|
|
|
$item['categories'] = [$element->find('span.label-default', 0)->innertext];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-07-16 13:02:41 +03:00
|
|
|
$raw_date = $element->find('small.text-muted', 0)->innertext;
|
2022-06-14 16:44:26 +03:00
|
|
|
$clean_date = str_replace('Uploaded on ', '', $raw_date);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-06-14 16:44:26 +03:00
|
|
|
$content = $content . $raw_date;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-06-14 16:44:26 +03:00
|
|
|
$item['timestamp'] = $clean_date;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-07-16 13:02:41 +03:00
|
|
|
$access = '';
|
2022-06-14 16:44:26 +03:00
|
|
|
if ($element->find('span.label-success', 0)) {
|
2018-07-16 13:02:41 +03:00
|
|
|
$access = 'Open Access';
|
2022-06-14 16:44:26 +03:00
|
|
|
} elseif ($element->find('span.label-warning', 0)) {
|
2018-07-16 13:02:41 +03:00
|
|
|
$access = 'Embargoed Access';
|
|
|
|
} else {
|
|
|
|
$access = $element->find('span.label-error', 0)->innertext;
|
|
|
|
}
|
|
|
|
$access = '<br>Access: ' . $access;
|
|
|
|
$publication = '<br>Publication Date: ' . $element->find('span.label-info', 0)->innertext;
|
|
|
|
$item['content'] = $content . $type . $access . $publication;
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|