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 17 // FIXME support for jumping to file? 18 // FIXME Zebra classes have been dropped and need to be readded via CSS 19 // FIXME use of $display_namespace unclear, dropped for now -> maybe for search? 20 21 $id = $this->mediaFile->getId(); 22 $class = 'select mediafile mf_' . $this->mediaFile->getIcoClass(); 23 $info = trim($this->formatDimensions('') . ' ' . $this->formatDate() . ' ' . $this->formatFileSize()); 24 25 echo '<div title="' . $id . '">'; 26 echo '<a id="h_:' . $id . '" class="' . $class . '">' . 27 $this->mediaFile->getDisplayName() . 28 '</a> '; 29 echo '<span class="info">(' . $info . ')</span>' . NL; 30 31 // view button 32 $link = ml($id, '', true); 33 echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 34 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>'; 35 36 // mediamanager button 37 $link = wl('', array('do' => 'media', 'image' => $id, 'ns' => getNS($id))); 38 echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/mediamanager.png" ' . 39 'alt="' . $lang['btn_media'] . '" title="' . $lang['btn_media'] . '" class="btn" /></a>'; 40 41 // delete button FIXME 42 if ($this->mediaFile->isWritable() && $this->mediaFile->userPermission() >= AUTH_DELETE) { 43 $link = DOKU_BASE . 'lib/exe/mediamanager.php?delete=' . rawurlencode($id) . 44 '&sectok=' . getSecurityToken(); 45 echo ' <a href="' . $link . '" class="btn_media_delete" title="' . $id . '">' . 46 '<img src="' . DOKU_BASE . 'lib/images/trash.png" alt="' . $lang['btn_delete'] . '" ' . 47 'title="' . $lang['btn_delete'] . '" class="btn" /></a>'; 48 } 49 50 echo '<div class="example" id="ex_' . str_replace(':', '_', $id) . '">'; 51 echo $lang['mediausage'] . ' <code>{{:' . $id . '}}</code>'; 52 echo '</div>'; 53 if ($this->mediaFile->getWidth()) $this->showDetails(); 54 echo '<div class="clearer"></div>' . NL; 55 echo '</div>' . NL; 56 57 } 58 59 /** 60 * Show Thumbnail and EXIF data 61 */ 62 protected function showDetails() 63 { 64 $id = $this->mediaFile->getId(); 65 66 echo '<div class="detail">'; 67 echo '<div class="thumb">'; 68 echo '<a id="d_:' . $id . '" class="select">'; 69 echo $this->getPreviewHtml(120, 120); 70 echo '</a>'; 71 echo '</div>'; 72 73 // read EXIF/IPTC data 74 $t = $this->mediaFile->getMeta()->getField(array('IPTC.Headline', 'xmp.dc:title')); 75 $d = $this->mediaFile->getMeta()->getField(array( 76 'IPTC.Caption', 77 'EXIF.UserComment', 78 'EXIF.TIFFImageDescription', 79 'EXIF.TIFFUserComment', 80 )); 81 if (PhpString::strlen($d) > 250) $d = PhpString::substr($d, 0, 250) . '...'; 82 $k = $this->mediaFile->getMeta()->getField(array('IPTC.Keywords', 'IPTC.Category', 'xmp.dc:subject')); 83 84 // print EXIF/IPTC data 85 if ($t || $d || $k) { 86 echo '<p>'; 87 if ($t) echo '<strong>' . hsc($t) . '</strong><br />'; 88 if ($d) echo hsc($d) . '<br />'; 89 if ($t) echo '<em>' . hsc($k) . '</em>'; 90 echo '</p>'; 91 } 92 echo '</div>'; 93 } 94 95} 96