2016-06-26 11:52:54 +02:00
|
|
|
<?php
|
2017-02-11 16:16:56 +01:00
|
|
|
class ElsevierBridge extends BridgeAbstract {
|
|
|
|
|
2022-03-31 09:49:30 +02:00
|
|
|
const MAINTAINER = 'dvikan';
|
2016-08-30 11:23:55 +02:00
|
|
|
const NAME = 'Elsevier journals recent articles';
|
2019-10-16 19:34:28 +00:00
|
|
|
const URI = 'https://www.journals.elsevier.com/';
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 43200; //12h
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = 'Returns the recent articles published in Elsevier journals';
|
2016-06-26 11:52:54 +02:00
|
|
|
|
2017-02-11 16:16:56 +01:00
|
|
|
const PARAMETERS = array( array(
|
|
|
|
'j' => array(
|
|
|
|
'name' => 'Journal name',
|
|
|
|
'required' => true,
|
2022-03-25 03:42:05 +01:00
|
|
|
'exampleValue' => 'academic-pediatrics',
|
2017-02-11 16:16:56 +01:00
|
|
|
'title' => 'Insert html-part of your journal'
|
|
|
|
)
|
|
|
|
));
|
2016-06-26 11:52:54 +02:00
|
|
|
|
2022-03-31 09:49:30 +02:00
|
|
|
public function collectData(){
|
|
|
|
// Not all journals have the /recent-articles page
|
|
|
|
$url = sprintf('https://www.journals.elsevier.com/%s/recent-articles/', $this->getInput('j'));
|
|
|
|
$html = getSimpleHTMLDOM($url);
|
|
|
|
|
|
|
|
foreach($html->find('article') as $recentArticle) {
|
|
|
|
$item = [];
|
|
|
|
$item['uri'] = $recentArticle->find('a', 0)->getAttribute('href');
|
|
|
|
$item['title'] = $recentArticle->find('h2', 0)->plaintext;
|
|
|
|
$item['author'] = $recentArticle->find('p > span', 0)->plaintext;
|
|
|
|
$publicationDateString = trim($recentArticle->find('p > span', 1)->plaintext);
|
|
|
|
$publicationDate = DateTimeImmutable::createFromFormat('F d, Y', $publicationDateString);
|
|
|
|
if ($publicationDate) {
|
|
|
|
$item['timestamp'] = $publicationDate->getTimestamp();
|
2016-08-02 21:40:22 +02:00
|
|
|
}
|
2022-03-31 09:49:30 +02:00
|
|
|
$this->items[] = $item;
|
2016-08-02 21:40:22 +02:00
|
|
|
}
|
|
|
|
}
|
2016-08-02 21:35:13 +02:00
|
|
|
|
2022-03-31 09:49:30 +02:00
|
|
|
public function getIcon(): string {
|
2018-10-26 18:07:34 +02:00
|
|
|
return 'https://cdn.elsevier.io/verona/includes/favicons/favicon-32x32.png';
|
|
|
|
}
|
2016-06-26 11:52:54 +02:00
|
|
|
}
|