aboutsummaryrefslogtreecommitdiff
path: root/bridges/HardwareInfoBridge.php
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/HardwareInfoBridge.php')
-rw-r--r--bridges/HardwareInfoBridge.php101
1 files changed, 51 insertions, 50 deletions
diff --git a/bridges/HardwareInfoBridge.php b/bridges/HardwareInfoBridge.php
index ae79e0fd..e295984c 100644
--- a/bridges/HardwareInfoBridge.php
+++ b/bridges/HardwareInfoBridge.php
@@ -1,66 +1,67 @@
<?php
+
class HardwareInfoBridge extends FeedExpander
{
- const NAME = 'Hardware Info Bridge';
- const URI = 'https://nl.hardware.info/';
- const DESCRIPTION = 'Tech news from hardware.info (Dutch)';
- const MAINTAINER = 't0stiman';
-
- public function collectData()
- {
- $this->collectExpandableDatas('https://nl.hardware.info/updates/all.rss', 20);
- }
-
- protected function parseItem($feedItem)
- {
- $item = parent::parseItem($feedItem);
+ const NAME = 'Hardware Info Bridge';
+ const URI = 'https://nl.hardware.info/';
+ const DESCRIPTION = 'Tech news from hardware.info (Dutch)';
+ const MAINTAINER = 't0stiman';
- //get full article
- $articlePage = getSimpleHTMLDOMCached($feedItem->link);
+ public function collectData()
+ {
+ $this->collectExpandableDatas('https://nl.hardware.info/updates/all.rss', 20);
+ }
- $article = $articlePage->find('div.article__content', 0);
+ protected function parseItem($feedItem)
+ {
+ $item = parent::parseItem($feedItem);
- //everything under the social bar is not part of the article, remove it
- $reachedEndOfArticle = false;
+ //get full article
+ $articlePage = getSimpleHTMLDOMCached($feedItem->link);
- foreach($article->find('*') as $child) {
+ $article = $articlePage->find('div.article__content', 0);
- if(!$reachedEndOfArticle && isset($child->attr['class'])
- && $child->attr['class'] == 'article__content__social-bar') {
- $reachedEndOfArticle = true;
- }
+ //everything under the social bar is not part of the article, remove it
+ $reachedEndOfArticle = false;
- if($reachedEndOfArticle) {
- $child->outertext = '';
- }
- }
+ foreach ($article->find('*') as $child) {
+ if (
+ !$reachedEndOfArticle && isset($child->attr['class'])
+ && $child->attr['class'] == 'article__content__social-bar'
+ ) {
+ $reachedEndOfArticle = true;
+ }
- //get rid of some more elements we don't need
- $to_remove_selectors = array(
- 'script',
- 'div.incontent',
- 'div.article__content__social-bar',
- 'div#revealNewsTip',
- 'div.article__previous_next'
- );
+ if ($reachedEndOfArticle) {
+ $child->outertext = '';
+ }
+ }
- foreach($to_remove_selectors as $selector) {
- foreach($article->find($selector) as $found) {
- $found->outertext = '';
- }
- }
+ //get rid of some more elements we don't need
+ $to_remove_selectors = [
+ 'script',
+ 'div.incontent',
+ 'div.article__content__social-bar',
+ 'div#revealNewsTip',
+ 'div.article__previous_next'
+ ];
- // convert iframes to links. meant for embedded YouTube videos.
- foreach($article->find('iframe') as $found) {
+ foreach ($to_remove_selectors as $selector) {
+ foreach ($article->find($selector) as $found) {
+ $found->outertext = '';
+ }
+ }
- $iframeUrl = $found->getAttribute('src');
+ // convert iframes to links. meant for embedded YouTube videos.
+ foreach ($article->find('iframe') as $found) {
+ $iframeUrl = $found->getAttribute('src');
- if ($iframeUrl) {
- $found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>';
- }
- }
+ if ($iframeUrl) {
+ $found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>';
+ }
+ }
- $item['content'] = $article;
- return $item;
- }
+ $item['content'] = $article;
+ return $item;
+ }
}