blog-preview.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. if ($is_preview) {
  3. $readmore_pos = strpos($blog['content'], '<!-- readmore -->');
  4. if ($readmore_pos !== false) {
  5. $content = substr($blog['content'], 0, $readmore_pos).'<p><a href="'.HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id']).'">阅读更多……</a></p>';
  6. } else {
  7. $content = $blog['content'];
  8. }
  9. $blog_href = HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id']);
  10. } else {
  11. $content = $blog['content'];
  12. $blog_href = null;
  13. }
  14. $extra_text = $blog['is_hidden'] ? '<span class="text-muted">[已隐藏]</span> ' : '';
  15. $blog_type = $blog['type'] == 'B' ? 'post' : 'slide';
  16. $poster = queryUser($blog['poster']);
  17. $avatar_addr = HTML::avatar_addr($poster, 100);
  18. $profile_href = HTML::url('/user/profile/'.$blog['poster']);
  19. ?>
  20. <div class="blog-item">
  21. <?php // Paginated post view (?page=N): the title stands alone, there is no body to merge it into. ?>
  22. <?php if (!$is_preview && !$show_content_only && $show_title_only): ?>
  23. <div class="card mb-4 shadow">
  24. <div class="card-body">
  25. <h3 class="blog-title wyoj-blog-detail-title mb-3"><?= $blog['title'] ?></h3>
  26. <div class="wyoj-blog-meta d-flex align-items-center flex-wrap">
  27. <a href="<?= $profile_href ?>" class="d-inline-flex align-items-center mr-2">
  28. <img class="wyoj-blog-meta-avatar rounded-circle" src="<?= $avatar_addr ?>" alt="avatar" />
  29. </a>
  30. <?= getUserLink($blog['poster']) ?>
  31. <span class="text-muted ml-3"><?= $blog['post_time'] ?></span>
  32. </div>
  33. </div>
  34. </div>
  35. <?php endif ?>
  36. <?php if (!$show_title_only): ?>
  37. <div class="card shadow mb-4">
  38. <div class="card-body blog-content">
  39. <?php // The title and meta live inside the body card on every page, so a
  40. // post renders as one card instead of a title card stacked on a
  41. // content card. Only the size differs: list vs. detail. ?>
  42. <?php if (!$show_content_only): ?>
  43. <h3 class="blog-title <?= $is_preview ? 'wyoj-blog-list-title' : 'wyoj-blog-detail-title' ?> mb-2"><?php if ($is_preview): ?><a href="<?= $blog_href ?>"><?= $blog['title'] ?></a><?php else: ?><?= $blog['title'] ?><?php endif ?></h3>
  44. <div class="wyoj-blog-meta d-flex align-items-center flex-wrap mb-3">
  45. <a href="<?= $profile_href ?>" class="d-inline-flex align-items-center mr-2">
  46. <img class="wyoj-blog-meta-avatar rounded-circle" src="<?= $avatar_addr ?>" alt="avatar" />
  47. </a>
  48. <?= getUserLink($blog['poster']) ?>
  49. <span class="text-muted ml-3"><?= $blog['post_time'] ?></span>
  50. <?php if ($is_preview): ?>
  51. <span class="ml-auto"><?= getClickZanBlock('B', $blog['id'], $blog['zan']) ?></span>
  52. <?php endif ?>
  53. </div>
  54. <?php endif ?>
  55. <?php if ($blog_type == 'post'): ?>
  56. <article class="blog-content-orig"><?= $content ?></article>
  57. <article class="blog-content-summary"></article>
  58. <?php elseif ($blog_type == 'slide'): ?>
  59. <article>
  60. <div class="embed-responsive embed-responsive-16by9">
  61. <iframe class="embed-responsive-item" src="<?= HTML::blog_url(UOJContext::userid(), '/slide/'.$blog['id']) ?>"></iframe>
  62. </div>
  63. <div class="text-right top-buffer-sm">
  64. <a class="btn btn-secondary btn-md" href="<?= HTML::blog_url(UOJContext::userid(), '/slide/'.$blog['id']) ?>"><span class="glyphicon glyphicon-fullscreen"></span> 全屏</a>
  65. </div>
  66. </article>
  67. <?php endif ?>
  68. </div>
  69. <div class="card-footer text-right blog-footer">
  70. <ul class="list-inline bot-buffer-no">
  71. <li class="list-inline-item">
  72. <?php foreach (queryBlogTags($blog['id']) as $tag): ?>
  73. <?php echoBlogTag($tag) ?>
  74. <?php endforeach ?>
  75. </li>
  76. <?php if ($is_preview): ?>
  77. <li class="list-inline-item"><a href="<?= HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id']) ?>">阅读全文</a></li>
  78. <?php endif ?>
  79. <?php if (!$outside_blog_domain && Auth::check() && (isSuperUser(Auth::user()) || Auth::id() == $blog['poster'])): ?>
  80. <li class="list-inline-item"><a href="<?=HTML::blog_url(UOJContext::userid(), '/'.$blog_type.'/'.$blog['id'].'/write')?>">修改</a></li>
  81. <li class="list-inline-item"><a href="<?=HTML::blog_url(UOJContext::userid(), '/post/'.$blog['id'].'/delete')?>">删除</a></li>
  82. <?php endif ?>
  83. <?php if (!$is_preview): ?>
  84. <li class="list-inline-item"><?= getClickZanBlock('B', $blog['id'], $blog['zan']) ?></li>
  85. <?php endif ?>
  86. </ul>
  87. </div>
  88. </div></div>
  89. <?php endif ?>