headline = $headline; $this->img = $img; $this->url = $url; $this->source = $source; $this->via = $via; $this->timestamp = $timestamp; if (is_null($category)) { $this->category = new NewsCategory(NewsCategory::GENERAL); } else { $this->category = $category; } } function getImage(): string { return $this->img; } function getURL(): string { return $this->url; } function getHeadline(): string { return $this->headline; } function getSource(): string { return $this->source; } function getVia(): string { return $this->via; } function getTimestamp(): int { return $this->timestamp; } function getCategory(): \NewsCategory { return $this->category; } /** * Generate a HTML card for a grid layout * @return string */ function generateGridCard(bool $lazyload = false): string { $category = $this->getCategory()->toString(); $url = $this->getURL(); $headline = htmlentities($this->getHeadline()); $source = $this->getSource(); $imghtml = ""; if (!empty($this->getImage())) { $imghtml = ''; if (strpos($this->getImage(), "preview.redd.it") !== false) { $imgurl = $this->getImage(); } else { $imgurl = Thumbnail::getThumbnailCacheURL($this->getImage(), 500); } if ($lazyload) { $imghtml .= ''; $imghtml .= ''; } else { $imghtml .= ''; } $imghtml .= ''; } $html = <<
$imghtml

$headline

$source

END; return $html; } }