DisplayRow.php 3.4 KB

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