1<?php 2 3namespace dokuwiki\Ui\Media; 4 5use dokuwiki\Utf8\PhpString; 6 7/** 8 * Display a MediaFile in the Media Popup 9 */ 10class DisplayRow extends DisplayTile 11{ 12 /** @inheritDoc */ 13 public function show() 14 { 15 global $lang; 16 // FIXME Zebra classes have been dropped and need to be readded via CSS 17 18 $id = $this->mediaFile->getId(); 19 $class = 'select mediafile mf_' . $this->mediaFile->getIcoClass(); 20 $info = trim($this->formatDimensions('') . ' ' . $this->formatDate() . ' ' . $this->formatFileSize()); 21 $jump = $this->scrollIntoView ? 'id="scroll__here"' : ''; 22 23 echo '<div title="' . $id . '" ' . $jump . '>'; 24 echo '<a id="h_:' . $id . '" class="' . $class . '">' . 25 $this->formatDisplayName() . 26 '</a> '; 27 echo '<span class="info">(' . $info . ')</span>' . NL; 28 29 // view button 30 $link = ml($id, '', true); 31 echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 32 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>'; 33 34 // mediamanager button 35 $link = wl('', ['do' => 'media', 'image' => $id, 'ns' => getNS($id)]); 36 echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/mediamanager.png" ' . 37 'alt="' . $lang['btn_media'] . '" title="' . $lang['btn_media'] . '" class="btn" /></a>'; 38 39 // delete button 40 if ($this->mediaFile->isWritable() && $this->mediaFile->userPermission() >= AUTH_DELETE) { 41 $link = DOKU_BASE . 'lib/exe/mediamanager.php?delete=' . rawurlencode($id) . 42 '&sectok=' . getSecurityToken(); 43 echo ' <a href="' . $link . '" class="btn_media_delete" title="' . $id . '">' . 44 '<img src="' . DOKU_BASE . 'lib/images/trash.png" alt="' . $lang['btn_delete'] . '" ' . 45 'title="' . $lang['btn_delete'] . '" class="btn" /></a>'; 46 } 47 48 echo '<div class="example" id="ex_' . str_replace(':', '_', $id) . '">'; 49 echo $lang['mediausage'] . ' <code>{{:' . $id . '}}</code>'; 50 echo '</div>'; 51 if ($this->mediaFile->isImage()) $this->showDetails(); 52 echo '<div class="clearer"></div>' . NL; 53 echo '</div>' . NL; 54 } 55 56 /** 57 * Show Thumbnail and EXIF data 58 */ 59 protected function showDetails() 60 { 61 $id = $this->mediaFile->getId(); 62 63 echo '<div class="detail">'; 64 echo '<div class="thumb">'; 65 echo '<a id="d_:' . $id . '" class="select">'; 66 echo $this->getPreviewHtml(120, 120); 67 echo '</a>'; 68 echo '</div>'; 69 70 // read EXIF/IPTC data 71 $t = $this->mediaFile->getMeta()->getField(['IPTC.Headline', 'xmp.dc:title']); 72 $d = $this->mediaFile->getMeta()->getField([ 73 'IPTC.Caption', 74 'EXIF.UserComment', 75 'EXIF.TIFFImageDescription', 76 'EXIF.TIFFUserComment' 77 ]); 78 if (PhpString::strlen($d) > 250) $d = PhpString::substr($d, 0, 250) . '...'; 79 $k = $this->mediaFile->getMeta()->getField(['IPTC.Keywords', 'IPTC.Category', 'xmp.dc:subject']); 80 81 // print EXIF/IPTC data 82 if ($t || $d || $k) { 83 echo '<p>'; 84 if ($t) echo '<strong>' . hsc($t) . '</strong><br />'; 85 if ($d) echo hsc($d) . '<br />'; 86 if ($t) echo '<em>' . hsc($k) . '</em>'; 87 echo '</p>'; 88 } 89 echo '</div>'; 90 } 91} 92