index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. require_once __DIR__ . '/../include/utils.php';
  3. require_once __DIR__ . '/../include/artwork_sections.php';
  4. require_once __DIR__ . '/../include/truncated_text.php';
  5. if (!isset($_GET['id']) || !ctype_digit($_GET['id'])) {
  6. die_with_message(400, get_string('illegal-id'));
  7. }
  8. list($artwork, $error) = get_artwork_info($_GET['id']);
  9. if ($error) {
  10. die_with_message(500, get_string($error));
  11. }
  12. $artwork = $artwork->body;
  13. $type = artwork_is_hidden($artwork);
  14. if ($type) {
  15. die_with_message(418, get_string('artwork.hidden-' . $type));
  16. }
  17. render_page_header($artwork->title);
  18. ?>
  19. <div class="container container-card">
  20. <div class="artwork-images">
  21. <?php render_artwork_images() ?>
  22. </div>
  23. <div class="artwork-info">
  24. <h1><?= htmlspecialchars($artwork->title) ?></h1>
  25. <div class="description"><?= render_truncated_text($artwork->description) ?></div>
  26. <div class="tags"><?php
  27. $restrict_type = get_xrestrict_string($artwork->xRestrict);
  28. if ($restrict_type) { ?>
  29. <a class="warning" href="<?= BASE_URL ?>/tags/<?= $restrict_type ?>">
  30. <b><?= $restrict_type ?></b>
  31. </a><?php
  32. }
  33. if ($artwork->aiType == 2) { ?>
  34. <a href="<?= BASE_URL ?>/tags/AI-generated">
  35. <span><b><?= get_string('artwork.aigc') ?></b></span>
  36. </a><?php
  37. }
  38. foreach ($artwork->tags->tags as $tag) {
  39. if ($restrict_type && ($tag->tag == $restrict_type)) continue;
  40. $tag_ja = htmlspecialchars($tag->tag);
  41. $tag_translated = '';
  42. if (!empty($tag->translation->en))
  43. $tag_translated = htmlspecialchars($tag->translation->en);
  44. else if (!empty($tag->romaji))
  45. $tag_translated = htmlspecialchars($tag->romaji); ?>
  46. <a href="<?= BASE_URL ?>/tags/<?= $tag_ja ?>">
  47. <span><?= $tag_ja ?></span><?php
  48. if ($tag_translated) { ?>
  49. <small><?= $tag_translated ?></small><?php
  50. } ?>
  51. </a><?php
  52. } ?>
  53. </div>
  54. <div class="stats">
  55. <div><?= sprintf(get_string('artwork.likes'), $artwork->likeCount) ?></div>
  56. <div><?= sprintf(get_string('artwork.bookmarks'), $artwork->bookmarkCount) ?></div>
  57. <div><?= sprintf(get_string('artwork.views'), $artwork->viewCount) ?></div>
  58. </div>
  59. <p><?= format_date($artwork->createDate); ?></p>
  60. <?php
  61. $pfp_url = '';
  62. foreach ($artwork->userIllusts as $v) {
  63. if (isset($v->profileImageUrl)) {
  64. $pfp_url = get_proxy_url($v->profileImageUrl);
  65. }
  66. } ?>
  67. <p><a class="img-with-text" href="<?= BASE_URL ?>/users/<?= $artwork->userId ?>">
  68. <img loading="lazy" class="avatar" src="<?= $pfp_url ?>" alt=" ">
  69. <span><b><?= htmlspecialchars($artwork->userName) ?></b></span>
  70. </a></p>
  71. </div><?php
  72. if ($settings['load-comments'] == 'on') { ?>
  73. <hr>
  74. <div class="comments">
  75. <?php render_artwork_comments() ?>
  76. </div><?php
  77. } ?>
  78. </div><?php
  79. if ($settings['load-related'] == 'on') { ?>
  80. <div class="container container-big">
  81. <?php render_artwork_related() ?>
  82. </div><?php
  83. } ?>
  84. <?php
  85. render_page_footer();