123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- function render_artwork_images() {
- global $artwork, $settings;
- if ($artwork->pageCount == 1) {
- render_artwork_image(
- $artwork->urls->original, $artwork->urls->regular,
- $artwork->width, $artwork->height,
- sprintf(get_string('artwork.image-alt'), '1', '1')
- );
- return;
- }
- list($artwork_pages, $error) = get_artwork_pages($artwork->id);
- if ($error) {
- for ($p = 0; $p < $artwork->pageCount; $p ++) {
- $artwork_pages[$p] = [
- 'urls' => [
- 'regular' => str_replace('_p0', '_p' . $p, $artwork->urls->original),
- 'original' => str_replace('_p0', '_p' . $p, $artwork->urls->regular)
- ],
- 'width' => false,
- 'height' => false
- ];
- }
- }
- else {
- $artwork_pages = $artwork_pages['body'];
- }
- if ($settings['collapse-pages'] == 'off') {
- for ($p = 0; $p < $artwork->pageCount; $p ++) {
- render_artwork_image(
- $artwork_pages[$p]['urls']['original'], $artwork_pages[$p]['urls']['regular'],
- $artwork_pages[$p]['width'], $artwork_pages[$p]['height'],
- sprintf(get_string('artwork.image-alt'), $p + 1, $artwork->pageCount)
- );
- }
- return;
- }
- render_collapsed_content(
- 2, get_string('artwork.images-show-all'),
- function($page) use ($artwork, $artwork_pages) {
- for ($p = $page; $p < ($page == 0 ? 1 : $artwork->pageCount); $p ++) {
- render_artwork_image(
- $artwork_pages[$p]['urls']['original'], $artwork_pages[$p]['urls']['regular'],
- $artwork_pages[$p]['width'], $artwork_pages[$p]['height'],
- sprintf(get_string('artwork.image-alt'), $p + 1, $artwork->pageCount)
- );
- }
- }
- );
- }
- function render_artwork_image($original_url, $regular_url, $width, $height, $alt) { ?>
- <a target="_blank" href="<?= get_proxy_url($original_url) ?>">
- <img
- loading="lazy"
- alt="<?= $alt ?>" title="<?= $alt ?>"
- src="<?= get_proxy_url($regular_url) ?>"
- width="<?= $width ?>" height="<?= $height ?>"
- >
- </a><?php
- }
- function render_artwork_comments() {
- require_once __DIR__ . '/comments.php';
- global $artwork; ?>
- <h2><?= sprintf(get_string('artwork.comments'), $artwork->commentCount) ?></h2><?php
- if ($artwork->commentOff == 1) { ?>
- <p><?= get_string('artwork.comments-off') ?></p><?php
- return;
- }
- if ($artwork->commentCount == 0) { ?>
- <p><?= get_string('artwork.no-comments') ?></p><?php
- return;
- }
- list($comments, $error) = get_artwork_comments($artwork->id, 0, COMMENTS_PREVIEW + 1);
- if ($error) { ?>
- <p><?= get_string($error) ?></p><?php
- return;
- }
- $comments = $comments->body->comments;
- render_comment_list(array_slice($comments, 0, COMMENTS_PREVIEW));
- if (count($comments) > COMMENTS_PREVIEW) { ?>
- <p class="center">
- <a class="button" target="_blank" href="comments.php?id=<?= $artwork->id ?>">
- <?= get_string('artwork.show-more')?>
- </a>
- </p><?php
- }
- }
- function render_artwork_related() {
- require_once __DIR__ . '/artworks_grid.php';
- global $artwork; ?>
- <h2><?= get_string('artwork.related') ?></h2><?php
- list($related, $error) = get_artwork_related($artwork->id);
- if ($error) { ?>
- <p><?= get_string($error) ?></p><?php
- return;
- }
- $related = $related->body->illusts;
- render_artworks_grid($related, true, true);
- }
|