diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d27421aa969..27688e7d829 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -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) diff --git a/actions/FindfeedAction.php b/actions/FindfeedAction.php index e18c3e1db55..67b843a6fbd 100644 --- a/actions/FindfeedAction.php +++ b/actions/FindfeedAction.php @@ -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)'; diff --git a/bridges/CssSelectorBridge.php b/bridges/CssSelectorBridge.php index d82dbdf2782..60fcac6910a 100644 --- a/bridges/CssSelectorBridge.php +++ b/bridges/CssSelectorBridge.php @@ -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'] .= '

Could not extract full content, selector may need to be updated.

'; } diff --git a/bridges/IdealoBridge.php b/bridges/IdealoBridge.php index 05a2ebb89c8..1b32bc01a47 100644 --- a/bridges/IdealoBridge.php +++ b/bridges/IdealoBridge.php @@ -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 = '↗'; - } else if ($NewPrice == $OldPrice) { + } elseif ($NewPrice == $OldPrice) { $trend = '➡'; - } else if ($NewPrice < $OldPrice) { + } elseif ($NewPrice < $OldPrice) { $trend = '↘'; } return $trend; @@ -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); } @@ -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); } diff --git a/bridges/LeagueOfLegendsNewsBridge.php b/bridges/LeagueOfLegendsNewsBridge.php index 57e4f792172..acbdcf8942b 100644 --- a/bridges/LeagueOfLegendsNewsBridge.php +++ b/bridges/LeagueOfLegendsNewsBridge.php @@ -98,7 +98,7 @@ private function getSiteUrl() if ($onlyPatchNotes) { return $url . '/tags/patch-notes'; - } else if ($category === 'all') { + } elseif ($category === 'all') { return $url; } diff --git a/bridges/NextInkBridge.php b/bridges/NextInkBridge.php index d9410d514ce..48ec7a95c63 100644 --- a/bridges/NextInkBridge.php +++ b/bridges/NextInkBridge.php @@ -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); diff --git a/bridges/OpenCVEBridge.php b/bridges/OpenCVEBridge.php index 1e528322a41..a2c8dda8f7a 100644 --- a/bridges/OpenCVEBridge.php +++ b/bridges/OpenCVEBridge.php @@ -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 { diff --git a/bridges/PepperBridgeAbstract.php b/bridges/PepperBridgeAbstract.php index 43dbe82906e..a835001f53f 100644 --- a/bridges/PepperBridgeAbstract.php +++ b/bridges/PepperBridgeAbstract.php @@ -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'; } diff --git a/bridges/ScientificAmericanBridge.php b/bridges/ScientificAmericanBridge.php index 51cdc0d9f2e..15d01b7f234 100644 --- a/bridges/ScientificAmericanBridge.php +++ b/bridges/ScientificAmericanBridge.php @@ -155,11 +155,11 @@ private function updateItem($item) } else { $res .= $block->outertext; } - } else if ($block->tag == 'h2') { + } elseif ($block->tag == 'h2') { $res .= '

' . $block->innertext . '

'; - } 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 .= '
'; } } diff --git a/bridges/TrelloBridge.php b/bridges/TrelloBridge.php index 42651fd13fc..0325482eeb9 100644 --- a/bridges/TrelloBridge.php +++ b/bridges/TrelloBridge.php @@ -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 [ diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 800fd63ca82..cf9a9801fb5 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -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; } diff --git a/bridges/Vk2Bridge.php b/bridges/Vk2Bridge.php index f52850ced98..f838ce09d31 100644 --- a/bridges/Vk2Bridge.php +++ b/bridges/Vk2Bridge.php @@ -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); diff --git a/bridges/VkBridge.php b/bridges/VkBridge.php index 54b2897ad51..816cd4a1d3b 100644 --- a/bridges/VkBridge.php +++ b/bridges/VkBridge.php @@ -337,14 +337,14 @@ public function collectData() $doc_link = $sa_href; $content_suffix .= "
Doc: $doc_title ($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 .= "
Article: $article_title ($article_author)"; $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; @@ -352,7 +352,7 @@ public function collectData() $audio_author = $sa->find('.SecondaryAttachmentSubhead', 0)->innertext; $content_suffix .= "
Audio: $audio_title ($audio_author)"; $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'); diff --git a/bridges/WhiteHouseExecutiveOrdersBridge.php b/bridges/WhiteHouseExecutiveOrdersBridge.php new file mode 100644 index 00000000000..72f5a205777 --- /dev/null +++ b/bridges/WhiteHouseExecutiveOrdersBridge.php @@ -0,0 +1,12 @@ +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, 'ヨルシカ'); } diff --git a/lib/TwitterClient.php b/lib/TwitterClient.php index f71e842c7c5..b13c770129f 100644 --- a/lib/TwitterClient.php +++ b/lib/TwitterClient.php @@ -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'); diff --git a/lib/WhiteHouseBridge.php b/lib/WhiteHouseBridge.php new file mode 100644 index 00000000000..eb080c3a51d --- /dev/null +++ b/lib/WhiteHouseBridge.php @@ -0,0 +1,43 @@ +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'] = '

' . $item['title'] . '

'; + $item['uid'] = $item['uri']; + + $this->items[] = $item; + } + } +} diff --git a/lib/seotags.php b/lib/seotags.php index 52657ff99fd..b59d86840f4 100644 --- a/lib/seotags.php +++ b/lib/seotags.php @@ -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]"); @@ -96,7 +96,7 @@ 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; @@ -104,7 +104,7 @@ function html_find_seo_metadata($html) 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; @@ -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']; }