{php} /** * 文章列表项组件 */ $cid = $post['cid']; $ptpuser = $post['ptpuser']; $ptpimg = getUserAvatar($ptpuser); $isAnonymousPost = isFlag($post['is_anonymous'] ?? 0) === 1; $displayName = $isAnonymousPost ? '匿名用户' : getUserDisplayName($ptpuser); if ($isAnonymousPost) { $ptpimg = '/assets/img/tx.png'; } $ptptext = renderArticleEmojis(cleanArticleHtml($post['ptptext'])); $ptpimag = $post['ptpimag']; $ptpvideo = $post['ptpvideo']; $ptpmusic = $post['ptpmusic']; $ptplx = $post['ptplx']; $ptpdw = $post['ptpdw']; $ptptime = $post['ptptime']; $ptpgg = isFlag($post['ptpgg'] ?? 0); $ptpggurl = $post['ptpggurl']; $ptpys = isFlag($post['ptpys'] ?? 1, 1); $commauth = isFlag($post['commauth'] ?? 1, 1); $ptpaud = isFlag($post['ptpaud'] ?? 1, 1); $tagsEnabled = \app\service\ContentFeatureService::tagsEnabled(); $tagList = $tagsEnabled ? array_values(array_filter(array_map('trim', explode(',', $post['tags'] ?? '')))) : []; $postLikes = $postLikes ?? []; $postComments = $postComments ?? []; $postLikedMap = $postLikedMap ?? []; $musicSource = ''; $topIds = !empty($siteConfig['topes']) ? array_filter(array_map('trim', explode("\n", $siteConfig['topes']))) : []; $isAdminPinned = in_array((string)$cid, $topIds, true); $isUserPinned = !empty($post['user_top']); $isPinned = $isAdminPinned || $isUserPinned; $isLongArticle = $ptplx === 'article'; $articleTitle = trim((string)($post['article_title'] ?? '')); $articleCover = assetUrl($post['article_cover'] ?? '/assets/img/thumbnailbg.svg'); if ($articleTitle === '') { $articleTitle = strCut(strip_tags($post['ptptext'] ?? ''), 30, ''); } // 封面色调 $coverColor = trim((string)($post['cover_color'] ?? '')); $coverColorStyle = ''; if ($coverColor !== '') { $hex = ltrim($coverColor, '#'); if (strlen($hex) === 3) { $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; } $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); $luma = 0.299 * $r + 0.587 * $g + 0.114 * $b; $textColor = $luma > 160 ? 'rgba(0,0,0,.78)' : 'rgba(255,255,255,.78)'; $titleColor = $luma > 160 ? '#111' : '#fff'; $coverColorStyle = 'background:rgb(' . $r . ',' . $g . ',' . $b . ');color:' . $textColor; } // 视频处理 $videoParts = explode("|", $ptpvideo); $ptpvideo = $videoParts[0]; $ptpvideofm = assetUrl($videoParts[1] ?? ''); // 图片处理 $imgArr = array_map('assetUrl', explode("(+@+)", $ptpimag)); $thumbArr = array_map('thumbUrl', $imgArr); $imgCount = count($imgArr); // 广告文章:用第一张图替换头像,图片网格中移除 if ($ptpgg === 1 && $imgCount > 0) { $ptpimg = $imgArr[0]; array_shift($imgArr); array_shift($thumbArr); $imgCount = count($imgArr); } // 图片网格样式 if ($imgCount === 1) { $gridStyle = "grid-template-columns:1fr;width: 55%;"; } elseif ($imgCount === 4 || $imgCount === 2) { $gridStyle = "grid-template-columns:1fr 1fr;width: 55%;"; } else { $gridStyle = "grid-template-columns:1fr 1fr 1fr;"; } // 广告样式 if ($ptpgg === 1) { $adStyle = "display: flex;"; $adUrl = '
'; $gps = ''; } else { $adStyle = "display: none;"; $adUrl = ''; $gps = ''; } $pinStyle = 'background: var(--themetm);' . ($ptpgg === 1 ? 'margin-right: 5px;' : ''); // 时间处理 $time = strtotime($ptptime); $friendlyTime = formatFriendlyDate($time); // 用户链接 if ($isAnonymousPost) { $userUrl = ''; } else { $userUrl = 'onclick="location.href=\'/user/' . md5(md5($ptpuser)) . '\'"'; } // 内容截断 $contentText = preg_replace("/{$displayName}
{if condition="$isPinned || $ptpgg === 1"}置顶
广告