v2.0.0.1
Publisium
- <?php
- declare(strict_types=1);
- function renderArticleCard(array $article): string
- {
- $html = '<article class="article-card">';
- $html .= '<a href="' . htmlspecialchars(SiteFront::articleUrl($article['slug']), ENT_QUOTES) . '">';
- if (!empty($article['cover_image_path'])) {
- $html .= '<img src="' . htmlspecialchars($article['cover_image_path']) . '" alt="" class="article-card-image">';
- }
- $html .= '<div class="article-card-body">';
- if (!empty($article['category_name'])) {
- $html .= '<span class="article-card-category">' . htmlspecialchars($article['category_name']) . '</span>';
- }
- $html .= '<h3>' . htmlspecialchars($article['title']) . '</h3>';
- $html .= '<p>' . htmlspecialchars((string) ($article['excerpt'] ?? '')) . '</p>';
- if (($article['access_type'] ?? '') === 'paid') {
- $html .= '<span class="badge-paid">' . htmlspecialchars(Language::get('article_paid_label', 'Paid article')) . '</span>';
- }
- $html .= '</div></a></article>';
- return $html;
- }
- function renderFeaturedBanner(array $articles): string
- {
- if (empty($articles)) {
- return '';
- }
- $html = '<div class="featured-banner">';
- foreach ($articles as $index => $article) {
- $sizeClass = $index === 0 ? ' featured-banner-item-large' : ' featured-banner-item-small';
- $html .= '<a class="featured-banner-item' . $sizeClass . '" href="' . htmlspecialchars(SiteFront::articleUrl($article['slug']), ENT_QUOTES) . '">';
- if (!empty($article['cover_image_path'])) {
- $html .= '<img src="' . htmlspecialchars($article['cover_image_path']) . '" alt="">';
- }
- $html .= '<span class="featured-banner-title">' . htmlspecialchars($article['title']) . '</span>';
- $html .= '</a>';
- }
- $html .= '</div>';
- return $html;
- }
-