[ 'name' => 'Language', 'type' => 'list', 'values' => [ 'English' => 'en-US', 'لعربية' => 'ar', 'Deutsch' => 'de', 'Español (Spain)' => 'es-ES', 'Español (LA)' => 'es-MX', 'Français' => 'fr', 'Italiano' => 'it', '日本語' => 'ja', '한국어' => 'ko', 'Polski' => 'pl', 'Português (Brasil)' => 'pt-BR', 'Русский' => 'ru', 'Türkçe' => 'tr', '简体中文' => 'zh-CN', ], 'defaultValue' => self::DEFAULT_LOCALE, ] ] ]; public function collectData() { $html = getSimpleHTMLDOM(self::getURI()); $data = json_decode($html->find('#__NEXT_DATA__', 0)->innertext); foreach ($data->props->pageProps->newsList as $newsItem) { $headerDescription = property_exists($newsItem->header, 'description') ? $newsItem->header->description : ''; $headerImage = $newsItem->header->image->src; $contentImages = [$headerImage]; $content = <<{$headerDescription}

HTML; foreach ($newsItem->content->items as $contentItem) { if (property_exists($contentItem, 'articleCopy')) { if (property_exists($contentItem->articleCopy, 'title')) { $title = $contentItem->articleCopy->title; $content .= <<{$title} HTML; } $text = $contentItem->articleCopy->copy; $content .= <<{$text}

HTML; } elseif (property_exists($contentItem, 'articleImage')) { $image = $contentItem->articleImage->imageSrc; if ($image != $headerImage) { $contentImages[] = $image; $content .= <<

HTML; } } elseif (property_exists($contentItem, 'embeddedVideo')) { $mediaOptions = $contentItem->embeddedVideo->mediaOptions; $mainContentOptions = $contentItem->embeddedVideo->mainContentOptions; if (count($mediaOptions) == count($mainContentOptions)) { for ($i = 0; $i < count($mediaOptions); $i++) { if (property_exists($mediaOptions[$i], 'youtubeVideo')) { $videoUrl = 'https://youtu.be/' . $mediaOptions[$i]->youtubeVideo->contentId; $image = $mainContentOptions[$i]->image->src ?? ''; $content .= '

'; if ($image != $headerImage) { $contentImages[] = $image; $content .= <<
HTML; } $content .= <<(Video: {$videoUrl}) HTML; $content .= '

'; } } } } } $item = [ 'uid' => $newsItem->_id, 'uri' => self::getURI() . '/' . $newsItem->_slug, 'title' => $newsItem->_title, 'timestamp' => $newsItem->lastModified, 'content' => $content, 'enclosures' => $contentImages, ]; $this->items[] = $item; } } public function getURI() { $locale = $this->getInput('locale') ?? self::DEFAULT_LOCALE; return self::BASE_URI . '/' . $locale . '/news'; } public function getIcon() { return self::BASE_URI . '/favicon.ico'; } }