aboutsummaryrefslogtreecommitdiff
path: root/bridges/AstrophysicsDataSystemBridge.php
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/AstrophysicsDataSystemBridge.php')
-rw-r--r--bridges/AstrophysicsDataSystemBridge.php89
1 files changed, 47 insertions, 42 deletions
diff --git a/bridges/AstrophysicsDataSystemBridge.php b/bridges/AstrophysicsDataSystemBridge.php
index b287b52b..e971cad4 100644
--- a/bridges/AstrophysicsDataSystemBridge.php
+++ b/bridges/AstrophysicsDataSystemBridge.php
@@ -1,48 +1,53 @@
<?php
-class AstrophysicsDataSystemBridge extends BridgeAbstract {
- const NAME = 'SAO/NASA Astrophysics Data System';
- const DESCRIPTION = 'Returns the latest publications from a query';
- const URI = 'https://ui.adsabs.harvard.edu';
- const PARAMETERS = array(
- 'Publications' => array(
- 'query' => array(
- 'name' => 'query',
- 'title' => 'Same format as the search bar on the website',
- 'exampleValue' => 'author:"huchra, john"',
- 'required' => true
- )
- ));
- private $feedTitle;
+class AstrophysicsDataSystemBridge extends BridgeAbstract
+{
+ const NAME = 'SAO/NASA Astrophysics Data System';
+ const DESCRIPTION = 'Returns the latest publications from a query';
+ const URI = 'https://ui.adsabs.harvard.edu';
+ const PARAMETERS = [
+ 'Publications' => [
+ 'query' => [
+ 'name' => 'query',
+ 'title' => 'Same format as the search bar on the website',
+ 'exampleValue' => 'author:"huchra, john"',
+ 'required' => true
+ ]
+ ]];
- public function getName() {
- if ($this->queriedContext === 'Publications') {
- return $this->feedTitle;
- }
- return parent::getName();
- }
+ private $feedTitle;
- public function getURI() {
- if ($this->queriedContext === 'Publications') {
- return self::URI . '/search/?q=' . urlencode($this->getInput('query'));
- }
- return parent::getURI();
- }
+ public function getName()
+ {
+ if ($this->queriedContext === 'Publications') {
+ return $this->feedTitle;
+ }
+ return parent::getName();
+ }
- public function collectData() {
- $headers = array (
- 'Cookie: core=always;'
- );
- $html = str_get_html(defaultLinkTo(getContents($this->getURI(), $headers), self::URI));
- $this->feedTitle = html_entity_decode($html->find('title', 0)->plaintext);
- foreach($html->find('div.row > ul > li') as $pub) {
- $item = array();
- $item['title'] = $pub->find('h3.s-results-title', 0)->plaintext;
- $item['content'] = $pub->find('div.s-results-links', 0);
- $item['uri'] = $pub->find('a.abs-redirect-link', 0)->href;
- $item['author'] = rtrim($pub->find('li.article-author', 0)->plaintext, ' ;');
- $item['timestamp'] = $pub->find('div[aria-label="date published"]', 0)->plaintext;
- $this->items[] = $item;
- }
- }
+ public function getURI()
+ {
+ if ($this->queriedContext === 'Publications') {
+ return self::URI . '/search/?q=' . urlencode($this->getInput('query'));
+ }
+ return parent::getURI();
+ }
+
+ public function collectData()
+ {
+ $headers = [
+ 'Cookie: core=always;'
+ ];
+ $html = str_get_html(defaultLinkTo(getContents($this->getURI(), $headers), self::URI));
+ $this->feedTitle = html_entity_decode($html->find('title', 0)->plaintext);
+ foreach ($html->find('div.row > ul > li') as $pub) {
+ $item = [];
+ $item['title'] = $pub->find('h3.s-results-title', 0)->plaintext;
+ $item['content'] = $pub->find('div.s-results-links', 0);
+ $item['uri'] = $pub->find('a.abs-redirect-link', 0)->href;
+ $item['author'] = rtrim($pub->find('li.article-author', 0)->plaintext, ' ;');
+ $item['timestamp'] = $pub->find('div[aria-label="date published"]', 0)->plaintext;
+ $this->items[] = $item;
+ }
+ }
}