printfiles.html.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. $reviewDesc =
  3. '<div class="detail">
  4. <div class="detail-title">' . $this->lang->file->common . ' <i class="icon icon-paper-clip icon-sm"></i></div>
  5. <div class="detail-content">
  6. <ul class="files-list">';
  7. foreach($files as $file)
  8. {
  9. $uploadDate = $this->lang->file->uploadDate . substr($file->addedDate, 0, 10);
  10. $fileTitle = "<i class='icon icon-file-text'></i> &nbsp;" . $file->title;
  11. if(strpos($file->title, ".{$file->extension}") === false && $file->extension != 'txt') $fileTitle .= ".{$file->extension}";
  12. $imageWidth = 0;
  13. if(stripos('jpg|jpeg|gif|png|bmp', $file->extension) !== false)
  14. {
  15. $imageSize = $this->file->getImageSize($file);
  16. $imageWidth = $imageSize[0];
  17. }
  18. $fileSize = 0;
  19. /* Show size info. */
  20. if($file->size < 1024)
  21. {
  22. $fileSize = $file->size . 'B';
  23. }
  24. elseif($file->size < 1024 * 1024)
  25. {
  26. $file->size = round($file->size / 1024, 2);
  27. $fileSize = $file->size . 'K';
  28. }
  29. elseif($file->size < 1024 * 1024 * 1024)
  30. {
  31. $file->size = round($file->size / (1024 * 1024), 2);
  32. $fileSize = $file->size . 'M';
  33. }
  34. else
  35. {
  36. $file->size = round($file->size / (1024 * 1024 * 1024), 2);
  37. $fileSize = $file->size . 'G';
  38. }
  39. $downloadLink = helper::createLink('file', 'download', "fileID=$file->id");
  40. $previewLink = helper::createLink('file', 'preview', "fileID=$file->id");
  41. $reviewDesc .= "<li class='file' title='{$uploadDate}'>" . html::a($downloadLink, $fileTitle . " <span class='text-muted'>({$fileSize})</span>", '_blank', "id='fileTitle$file->id' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title')\"");
  42. $reviewDesc .= "<span class='right-icon hidden'>&nbsp; ";
  43. /* Determines whether the file supports preview. */
  44. if($file->extension == 'txt')
  45. {
  46. $extension = 'txt';
  47. if(($postion = strrpos($file->title, '.')) !== false) $extension = substr($file->title, $postion + 1);
  48. if($extension != 'txt') $mode = 'down';
  49. $file->extension = $extension;
  50. }
  51. /* For the open source version of the file judgment. */
  52. if(stripos('txt|jpg|jpeg|gif|png|bmp|mp4', $file->extension) !== false and common::hasPriv('file', 'preview'))
  53. {
  54. $reviewDesc .= html::a($previewLink, "<i class='icon icon-eye'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$this->lang->file->preview}' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title', 'preview')\"");
  55. }
  56. /* For the max version of the file judgment. */
  57. if(isset($this->config->file->libreOfficeTurnon) and $this->config->file->libreOfficeTurnon == 1 and !($this->config->file->convertType == 'collabora' and $this->config->requestType == 'GET') and common::hasPriv('file', 'preview'))
  58. {
  59. $officeTypes = 'doc|docx|xls|xlsx|ppt|pptx|pdf';
  60. if(stripos($officeTypes, $file->extension) !== false)
  61. {
  62. $reviewDesc .= html::a($previewLink, "<i class='icon icon-eye'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$this->lang->file->preview}' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title', 'preview')\"");
  63. }
  64. }
  65. if(common::hasPriv('file', 'download')) $reviewDesc .= html::a($downloadLink, "<i class='icon icon-download'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$this->lang->file->downloadFile}'");
  66. if($showEdit and common::hasPriv('file', 'edit')) $reviewDesc .= html::a('###', "<i class='icon icon-pencil-alt'></i>", '', "id='renameFile$file->id' class='fileAction btn btn-link edit text-primary' onclick='showRenameBox($file->id)' title='{$this->lang->file->edit}'");
  67. if($showDelete and common::hasPriv('file', 'delete')) $reviewDesc .= html::a('###', "<i class='icon icon-trash'></i>", '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id, this)' title='{$this->lang->delete}'");
  68. $reviewDesc .= '</span>';
  69. $reviewDesc .= '</li>';
  70. $reviewDesc .= "<li class='file hidden'>
  71. <div>";
  72. if(strrpos($file->title, '.') !== false)
  73. {
  74. /* Fix the file name exe.exe */
  75. $title = explode('.', $file->title);
  76. $extension = end($title);
  77. if($file->extension == 'txt' && $extension != $file->extension) $file->extension = $extension;
  78. array_pop($title);
  79. $file->title = join('.', $title);
  80. }
  81. $reviewDesc .= " <div class='renameFile w-300px' id='renameBox$file->id'>
  82. <i class='icon icon-file-text'></i>
  83. <div class='input-group'>";
  84. $reviewDesc .= '<input type="text" id="fileName' . $file->id . '" value="' . $file->title .'" class="form-control"/>
  85. <input type="hidden" id="extension' . $file->id . '" value="' . $file->extension .'"/>
  86. <strong class="input-group-addon">.' . $file->extension . '</strong>
  87. </div>
  88. <div class="input-group-btn">
  89. <button type="button" class="btn btn-success file-name-confirm" onclick="setFileName(' . $file->id . ')" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-check"></i></button>
  90. <button type="button" class="btn btn-gray file-name-cancel" onclick="showFile(' . $file->id . ')" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-close"></i></button>
  91. </div>
  92. </div>
  93. </div>
  94. </li>';
  95. }
  96. $reviewDesc .= '</ul>
  97. </div>
  98. </div>';
  99. return $reviewDesc;