Skip to content
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
* [shutosg](https://github.com/shutosg)
* [simon816](https://github.com/simon816)
* [Simounet](https://github.com/Simounet)
* [sij-ai](https://github.com/sij-ai)
* [somini](https://github.com/somini)
* [SpangleLabs](https://github.com/SpangleLabs)
* [SqrtMinusOne](https://github.com/SqrtMinusOne)
Expand Down
2 changes: 1 addition & 1 deletion actions/FindfeedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function getParameterName($bridge, $context, $key)
{
if (isset($bridge::PARAMETERS[$context][$key]['name'])) {
$name = $bridge::PARAMETERS[$context][$key]['name'];
} else if (isset($bridge::PARAMETERS['global'][$key]['name'])) {
} elseif (isset($bridge::PARAMETERS['global'][$key]['name'])) {
$name = $bridge::PARAMETERS['global'][$key]['name'];
} else {
$name = 'Variable "' . $key . '" (No name provided)';
Expand Down
2 changes: 1 addition & 1 deletion bridges/CssSelectorBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ protected function expandEntryWithSelector($entry_url, $content_selector, $conte
$article_content = defaultLinkTo($article_content, $entry_url);
$article_content = $this->cleanArticleContent($article_content, $content_cleanup);
$item['content'] = $article_content;
} else if (!empty($item['content'])) {
} elseif (!empty($item['content'])) {
$item['content'] .= '<br /><p><em>Could not extract full content, selector may need to be updated.</em></p>';
}

Expand Down
12 changes: 6 additions & 6 deletions bridges/IdealoBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ private function getPriceTrend($NewPrice, $OldPrice)
// In case there is no old Price, then show no trend
if ($OldPrice === null || $OldPrice == 0) {
$trend = '';
} else if ($NewPrice > $OldPrice) {
} elseif ($NewPrice > $OldPrice) {
$trend = '&#x2197;';
} else if ($NewPrice == $OldPrice) {
} elseif ($NewPrice == $OldPrice) {
$trend = '&#x27A1;';
} else if ($NewPrice < $OldPrice) {
} elseif ($NewPrice < $OldPrice) {
$trend = '&#x2198;';
}
return $trend;
Expand Down Expand Up @@ -159,11 +159,11 @@ public function collectData()
$PriceNew = $ActualNewPrice->find('strong', 0)->plaintext;
// Save current price
$this->saveCacheValue($KeyNEW, $PriceNew);
} else if ($altPrice) {
} elseif ($altPrice) {
// Get price from first List item if no New/used Buttons available
$PriceNew = trim($altPrice->plaintext);
$this->saveCacheValue($KeyNEW, $PriceNew);
} else if (($ActualNewPrice === null || $altPrice === null) && $ActualUsedPrice !== null) {
} elseif (($ActualNewPrice === null || $altPrice === null) && $ActualUsedPrice !== null) {
// In case there is no actual New Price and a Used Price exists, then delete the previous value in the cache
$this->cache->delete($this->getShortName() . '_' . $KeyNEW);
}
Expand All @@ -173,7 +173,7 @@ public function collectData()
$PriceUsed = $ActualUsedPrice->find('strong', 0)->plaintext;
// Save current price
$this->saveCacheValue($KeyUSED, $PriceUsed);
} else if ($ActualUsedPrice === null && ($ActualNewPrice !== null || $altPrice !== null)) {
} elseif ($ActualUsedPrice === null && ($ActualNewPrice !== null || $altPrice !== null)) {
// In case there is no actual Used Price and a New Price exists, then delete the previous value in the cache
$this->cache->delete($this->getShortName() . '_' . $KeyUSED);
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/LeagueOfLegendsNewsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function getSiteUrl()

if ($onlyPatchNotes) {
return $url . '/tags/patch-notes';
} else if ($category === 'all') {
} elseif ($category === 'all') {
return $url;
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/NextInkBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function collectData()
$url = $url . '?category=' . $category;
}
$this->collectArticlesFromHtmlListing($url, $limit);
} else if ($feed === 'free') {
} elseif ($feed === 'free') {
// Expand Free RSS feed
$url = self::URI . 'feed/free';
$this->collectExpandableDatas($url, $limit);
Expand Down
4 changes: 2 additions & 2 deletions bridges/OpenCVEBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ private function formatCVSSLabel($score, $version, $critical_thr, $high_thr, $me
if ($score >= $critical_thr) {
$importance = 'CRITICAL';
$class = 'cvss-crit-color';
} else if ($score >= $high_thr) {
} elseif ($score >= $high_thr) {
$importance = 'HIGH';
$class = 'cvss-high-color';
} else if ($score >= $medium_thr) {
} elseif ($score >= $medium_thr) {
$importance = 'MEDIUM';
$class = 'cvss-medium-color';
} else {
Expand Down
2 changes: 1 addition & 1 deletion bridges/PepperBridgeAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private function getGroupURI()
// This permit to keep the existing Feed to work
if ($order == $this->i8n('context-hot')) {
$sortBy = 'temp';
} else if ($order == $this->i8n('context-new')) {
} elseif ($order == $this->i8n('context-new')) {
$sortBy = 'new';
}

Expand Down
6 changes: 3 additions & 3 deletions bridges/ScientificAmericanBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ private function updateItem($item)
} else {
$res .= $block->outertext;
}
} else if ($block->tag == 'h2') {
} elseif ($block->tag == 'h2') {
$res .= '<h3>' . $block->innertext . '</h3>';
} else if ($block->tag == 'blockquote') {
} elseif ($block->tag == 'blockquote') {
$res .= $block->outertext;
} else if ($block->tag == 'hr' && $block->getAttribute('data-block') == 'sciam/raw_html') {
} elseif ($block->tag == 'hr' && $block->getAttribute('data-block') == 'sciam/raw_html') {
$res .= '<hr />';
}
}
Expand Down
2 changes: 1 addition & 1 deletion bridges/TrelloBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public function detectParameters($url)
if (preg_match($regex, $url, $matches) > 0) {
if ($matches[2] == 'b') {
$context = 'Board';
} else if ($matches[2] == 'c') {
} elseif ($matches[2] == 'c') {
$context = 'Card';
}
return [
Expand Down
2 changes: 1 addition & 1 deletion bridges/TwitterBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public function collectData()
$medias = [];
if (isset($realtweet->extended_entities->media)) {
$medias = $realtweet->extended_entities->media;
} else if (isset($realtweet->mediaDetails)) {
} elseif (isset($realtweet->mediaDetails)) {
$medias = $realtweet->mediaDetails;
}

Expand Down
2 changes: 1 addition & 1 deletion bridges/Vk2Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ protected function api($method, array $params, $expected_error_codes = [])
if (isset($r['error']) && !in_array($r['error']['error_code'], $expected_error_codes)) {
if ($r['error']['error_code'] == 6) {
$this->cache->set($this->rateLimitCacheKey, true, 5);
} else if ($r['error']['error_code'] == 29) {
} elseif ($r['error']['error_code'] == 29) {
// wall.get has limit of 5000 requests per day
// if that limit is hit, VK returns error 29
$this->cache->set($this->rateLimitCacheKey, true, 60 * 30);
Expand Down
6 changes: 3 additions & 3 deletions bridges/VkBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,22 @@ public function collectData()
$doc_link = $sa_href;
$content_suffix .= "<br>Doc: <a href='$doc_link'>$doc_title</a> ($doc_size)";
$sa->outertext = '';
} else if (str_starts_with($sa_href, 'https://vk.com/@')) {
} elseif (str_starts_with($sa_href, 'https://vk.com/@')) {
// article
$article_title = $sa->find('.SecondaryAttachment__childrenText', 0)->innertext;
$article_author = explode('Article · from ', $sa->find('.SecondaryAttachmentSubhead', 0)->innertext)[1];
$article_link = $sa_href;
$content_suffix .= "<br>Article: <a href='$article_link'>$article_title ($article_author)</a>";
$sa->outertext = '';
} else if ($sa_task_click == 'SecondaryAttachment/playAudio') {
} elseif ($sa_task_click == 'SecondaryAttachment/playAudio') {
// audio
$audio_json = json_decode(html_entity_decode($sa->getAttribute('data-audio')));
$audio_link = $audio_json->url;
$audio_title = $sa->find('.SecondaryAttachment__childrenText', 0)->innertext;
$audio_author = $sa->find('.SecondaryAttachmentSubhead', 0)->innertext;
$content_suffix .= "<br>Audio: <a href='$audio_link'>$audio_title ($audio_author)</a>";
$sa->outertext = '';
} else if ($sa_task_click == 'SecondaryAttachment/playPlaylist') {
} elseif ($sa_task_click == 'SecondaryAttachment/playPlaylist') {
// playlist link
$playlist_title = $sa->find('.SecondaryAttachment__childrenText', 0)->innertext;
$playlist_link = $sa->find('.SecondaryAttachment__link', 0)->getAttribute('href');
Expand Down
12 changes: 12 additions & 0 deletions bridges/WhiteHouseExecutiveOrdersBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once __DIR__ . '/../lib/WhiteHouseBridge.php';

class WhiteHouseExecutiveOrdersBridge extends WhiteHouseBridge
{
const MAINTAINER = 'sij-ai';
const NAME = 'White House Executive Orders';
const URI = 'https://www.whitehouse.gov/presidential-actions/executive-orders/';
const DESCRIPTION = 'Returns Executive Orders from The White House.';
const CACHE_TIMEOUT = 7200; // 2 hours
}
12 changes: 12 additions & 0 deletions bridges/WhiteHouseMemorandaBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once __DIR__ . '/../lib/WhiteHouseBridge.php';

class WhiteHouseMemorandaBridge extends WhiteHouseBridge
{
const MAINTAINER = 'sij-ai';
const NAME = 'White House Presidential Memoranda';
const URI = 'https://www.whitehouse.gov/presidential-actions/presidential-memoranda/';
const DESCRIPTION = 'Returns Presidential Memoranda from The White House.';
const CACHE_TIMEOUT = 7200; // 2 hours
}
12 changes: 12 additions & 0 deletions bridges/WhiteHouseNominationsBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once __DIR__ . '/../lib/WhiteHouseBridge.php';

class WhiteHouseNominationsBridge extends WhiteHouseBridge
{
const MAINTAINER = 'sij-ai';
const NAME = 'White House Nominations & Appointments';
const URI = 'https://www.whitehouse.gov/presidential-actions/nominations-appointments/';
const DESCRIPTION = 'Returns Nominations & Appointments from The White House.';
const CACHE_TIMEOUT = 7200; // 2 hours
}
12 changes: 12 additions & 0 deletions bridges/WhiteHousePresidentialActionsBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once __DIR__ . '/../lib/WhiteHouseBridge.php';

class WhiteHousePresidentialActionsBridge extends WhiteHouseBridge
{
const MAINTAINER = 'sij-ai';
const NAME = 'White House Presidential Actions (All)';
const URI = 'https://www.whitehouse.gov/presidential-actions/';
const DESCRIPTION = 'Returns all Presidential Actions from The White House.';
const CACHE_TIMEOUT = 3600; // 1 hour
}
12 changes: 12 additions & 0 deletions bridges/WhiteHouseProclamationsBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

require_once __DIR__ . '/../lib/WhiteHouseBridge.php';

class WhiteHouseProclamationsBridge extends WhiteHouseBridge
{
const MAINTAINER = 'sij-ai';
const NAME = 'White House Proclamations';
const URI = 'https://www.whitehouse.gov/presidential-actions/proclamations/';
const DESCRIPTION = 'Returns Proclamations from The White House.';
const CACHE_TIMEOUT = 7200; // 2 hours
}
2 changes: 1 addition & 1 deletion bridges/YorushikaBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function collectData()
$categories = [];
if ($this->queriedContext == 'All categories') {
array_push($categories, 'all');
} else if ($this->queriedContext == 'Only selected categories') {
} elseif ($this->queriedContext == 'Only selected categories') {
if ($this->getInput('yorushika')) {
array_push($categories, 'ヨルシカ');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/TwitterClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function fetchListTweets($query, $operation = '')
throw $e;
}
}
} else if ($operation == 'By list ID') {
} elseif ($operation == 'By list ID') {
$id = $query['listId'];
} else {
throw new \Exception('Unknown operation to make list tweets');
Expand Down
43 changes: 43 additions & 0 deletions lib/WhiteHouseBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

abstract class WhiteHouseBridge extends BridgeAbstract
{
// This is the core scraping logic that will be shared by all White House bridges.
public function collectData()
{
$html = getSimpleHTMLDOM($this->getURI());

$articles = $html->find('ul.wp-block-post-template li.wp-block-post');

foreach ($articles as $article) {
$item = [];

$titleElement = $article->find('h2.wp-block-post-title a', 0);
if (!$titleElement) {
continue;
}

$item['title'] = trim($titleElement->plaintext);
$item['uri'] = $titleElement->href;

$dateElement = $article->find('div.wp-block-post-date time', 0);
if ($dateElement && !empty($dateElement->datetime)) {
$item['timestamp'] = strtotime($dateElement->datetime);
}

// Add categories from the meta tags for better filtering
$categories = [];
foreach ($article->find('div.taxonomy-category a') as $categoryLink) {
$categories[] = trim($categoryLink->plaintext);
}
if (!empty($categories)) {
$item['categories'] = $categories;
}

$item['content'] = '<p><a href="' . $item['uri'] . '">' . $item['title'] . '</a></p>';
$item['uid'] = $item['uri'];

$this->items[] = $item;
}
}
}
8 changes: 4 additions & 4 deletions lib/seotags.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function html_find_seo_metadata($html)
$element = null;
if ($field === 'canonical') {
$element = $html->find('link[rel=canonical]');
} else if ($field === 'time') {
} elseif ($field === 'time') {
$element = $html->find('time[datetime]');
} else {
$element = $html->find("meta[property=$field], meta[name=$field]");
Expand All @@ -96,15 +96,15 @@ function html_find_seo_metadata($html)
$field_value = '';
if ($field === 'canonical') {
$field_value = $element->href;
} else if ($field === 'time') {
} elseif ($field === 'time') {
$field_value = $element->datetime;
} else {
$field_value = $element->content;
}
if (!empty($field_value)) {
if ($field === 'article:author:first_name' || $field === 'profile:first_name') {
$author_first_name = $field_value;
} else if ($field === 'article:author:last_name' || $field === 'profile:last_name') {
} elseif ($field === 'article:author:last_name' || $field === 'profile:last_name') {
$author_last_name = $field_value;
} else {
$item[$property] = $field_value;
Expand Down Expand Up @@ -230,7 +230,7 @@ function html_find_seo_metadata($html)
}
}
// JSON item that holds an ld+json Author object (or a variant)
} else if ($ldjson_is_of_type($json, $ldjson_author_types)) {
} elseif ($ldjson_is_of_type($json, $ldjson_author_types)) {
if (isset($json['@id']) && isset($json['name'])) {
$ldjson_author_mappings[$json['@id']] = $json['name'];
}
Expand Down