1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-10 10:34:15 +02:00

Reformat codebase v4 (#2872)

Reformat code base to PSR12

Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
Dag
2022-07-01 15:10:30 +02:00
committed by GitHub
parent 66568e3a39
commit 4f75591060
398 changed files with 58607 additions and 56442 deletions

View File

@@ -1,41 +1,44 @@
<?php
class ElsevierBridge extends BridgeAbstract {
const MAINTAINER = 'dvikan';
const NAME = 'Elsevier journals recent articles';
const URI = 'https://www.journals.elsevier.com/';
const CACHE_TIMEOUT = 43200; //12h
const DESCRIPTION = 'Returns the recent articles published in Elsevier journals';
class ElsevierBridge extends BridgeAbstract
{
const MAINTAINER = 'dvikan';
const NAME = 'Elsevier journals recent articles';
const URI = 'https://www.journals.elsevier.com/';
const CACHE_TIMEOUT = 43200; //12h
const DESCRIPTION = 'Returns the recent articles published in Elsevier journals';
const PARAMETERS = array( array(
'j' => array(
'name' => 'Journal name',
'required' => true,
'exampleValue' => 'academic-pediatrics',
'title' => 'Insert html-part of your journal'
)
));
const PARAMETERS = [ [
'j' => [
'name' => 'Journal name',
'required' => true,
'exampleValue' => 'academic-pediatrics',
'title' => 'Insert html-part of your journal'
]
]];
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);
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();
}
$this->items[] = $item;
}
}
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();
}
$this->items[] = $item;
}
}
public function getIcon(): string {
return 'https://cdn.elsevier.io/verona/includes/favicons/favicon-32x32.png';
}
public function getIcon(): string
{
return 'https://cdn.elsevier.io/verona/includes/favicons/favicon-32x32.png';
}
}