summaryrefslogtreecommitdiffstats
path: root/inc/Ui/Media/DisplayTile.php
blob: aff294b9b70b05e73938cfe05a4998db329e6fdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

namespace dokuwiki\Ui\Media;

use dokuwiki\File\MediaFile;

/**
 * Display a MediaFile in the FullScreen MediaManager
 */
class DisplayTile extends Display
{
    /** @var string URL to open this file in the media manager */
    protected $mmUrl;

    /** @inheritDoc */
    public function __construct(MediaFile $mediaFile)
    {
        parent::__construct($mediaFile);

        // FIXME we may want to integrate this function here or in another class
        $this->mmUrl = media_managerURL([
            'image' => $this->mediaFile->getId(),
            'ns' => getNS($this->mediaFile->getId()),
            'tab_details' => 'view',
        ]);
    }

    /**
     * Display the tile
     */
    public function show()
    {
        $jump = $this->scrollIntoView ? 'id="scroll__here"' : '';

        echo '<dl title="' . $this->mediaFile->getDisplayName() . '"' . $jump . '>';
        echo '<dt>';
        echo '<a id="l_:' . $this->mediaFile->getId() . '" class="image thumb" href="' . $this->mmUrl . '">';
        echo $this->getPreviewHtml(90, 90);
        echo '</a>';
        echo '</dt>';

        echo '<dd class="name">';
        echo '<a href="' . $this->mmUrl . '" id="h_:' . $this->mediaFile->getId() . '">' .
            $this->formatDisplayName() .
            '</a>';
        echo '</dd>';

        echo '<dd class="size">' . $this->formatDimensions() . '</dd>';
        echo '<dd class="date">' . $this->formatDate() . '</dd>';
        echo '<dd class="filesize">' . $this->formatFileSize() . '</dd>';

        echo '</dl>';
    }
}