viewfiles.html.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <style>
  2. .card-container {display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 20px; background-color: unset;}
  3. .card {position: relative; border-radius: 4px;}
  4. .card::before {content: ' '; display: block; padding-bottom: 56.25%;}
  5. .con {display: flex; justify-content: center; align-items: center; position: absolute; top: 0; bottom: 0; left: 0; right: 0;}
  6. .title {color: white; display: inline-block; text-align: left; padding: 0 20px; max-height: 100%; overflow: hidden; text-overflow: ellipsis;}
  7. .card-container li {list-style-type: none;}
  8. .item li.file {padding-left: 6px;}
  9. </style>
  10. <div class="card-container cards cards-borderless">
  11. <?php foreach($files as $file):?>
  12. <div class="item">
  13. <div class="card bg-primary">
  14. <div class="con">
  15. <h2 id=<?php echo 'cardContent' . $file->id?> class="title">
  16. <?php
  17. $fileTitle = $file->title;
  18. if(strpos($file->title, ".{$file->extension}") === false && $file->extension != 'txt') $fileTitle .= ".{$file->extension}";
  19. $fileName = substr($fileTitle, 0, strrpos($fileTitle, '.', 0));
  20. echo $fileName;
  21. ?>
  22. </h2>
  23. </div>
  24. </div>
  25. <div>
  26. <?php
  27. $uploadDate = $lang->file->uploadDate . substr($file->addedDate, 0, 10);
  28. $imageWidth = 0;
  29. if(stripos('jpg|jpeg|gif|png|bmp', $file->extension) !== false)
  30. {
  31. $imageSize = $this->loadModel('file')->getImageSize($file);
  32. $imageWidth = $imageSize[0];
  33. }
  34. $fileSize = 0;
  35. /* Show size info. */
  36. if($file->size < 1024)
  37. {
  38. $fileSize = $file->size . 'B';
  39. }
  40. elseif($file->size < 1024 * 1024)
  41. {
  42. $file->size = round($file->size / 1024, 2);
  43. $fileSize = $file->size . 'K';
  44. }
  45. elseif($file->size < 1024 * 1024 * 1024)
  46. {
  47. $file->size = round($file->size / (1024 * 1024), 2);
  48. $fileSize = $file->size . 'M';
  49. }
  50. else
  51. {
  52. $file->size = round($file->size / (1024 * 1024 * 1024), 2);
  53. $fileSize = $file->size . 'G';
  54. }
  55. $downloadLink = $this->createLink('file', 'download', "fileID=$file->id");
  56. $previewLink = $this->createLink('file', 'preview', "fileID=$file->id");
  57. $objectType = zget($this->config->file->objectType, $file->objectType);
  58. if(common::hasPriv($objectType, 'view', $object))
  59. {
  60. echo "<span class='right-icon invisible'>";
  61. /* Determines whether the file supports preview. */
  62. if($file->extension == 'txt')
  63. {
  64. $extension = 'txt';
  65. if(($postion = strrpos($file->title, '.')) !== false) $extension = substr($file->title, $postion + 1);
  66. if($extension != 'txt') $mode = 'down';
  67. $file->extension = $extension;
  68. }
  69. /* For the open source version of the file judgment. */
  70. if(stripos('txt|jpg|jpeg|gif|png|bmp', $file->extension) !== false and common::hasPriv('file', 'preview'))
  71. {
  72. echo html::a($previewLink, "<i class='icon icon-eye'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->preview}' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title', 'preview')\"");
  73. }
  74. /* For the max version of the file judgment. */
  75. 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'))
  76. {
  77. $officeTypes = 'doc|docx|xls|xlsx|ppt|pptx|pdf';
  78. if(stripos($officeTypes, $file->extension) !== false)
  79. {
  80. echo html::a($previewLink, "<i class='icon icon-eye'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->preview}' onclick=\"return downloadFile($file->id, '$file->extension', $imageWidth, '$file->title', 'preview')\"");
  81. }
  82. }
  83. if(common::hasPriv($objectType, 'edit', $object))
  84. {
  85. if($showEdit and common::hasPriv('file', 'edit')) echo 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='{$lang->file->edit}'");
  86. }
  87. common::printLink('file', 'download', "fileID=$file->id", "<i class='icon icon-download'></i>", '_blank', "class='fileAction btn btn-link text-primary' title='{$lang->file->downloadFile}'");
  88. if(common::hasPriv($objectType, 'edit', $object))
  89. {
  90. if($showDelete and common::hasPriv('file', 'delete')) echo html::a('###', "<i class='icon icon-trash'></i>", '', "class='fileAction btn btn-link text-primary' onclick='deleteFile($file->id, this)' title='$lang->delete'");
  91. }
  92. echo '</span>';
  93. }
  94. ?>
  95. <li class='file hidden'>
  96. <div>
  97. <?php
  98. if(strrpos($file->title, '.') !== false)
  99. {
  100. /* Fix the file name exe.exe */
  101. $title = explode('.', $file->title);
  102. $extension = end($title);
  103. if($file->extension == 'txt' && $extension != $file->extension) $file->extension = $extension;
  104. array_pop($title);
  105. $file->title = join('.', $title);
  106. }
  107. ?>
  108. <div class='renameFile w-300px' id='renameBox<?php echo $file->id;?>'>
  109. <div class='input-group'>
  110. <input type="text" id="<?php echo 'fileName' . $file->id?>" value="<?php echo $file->title;?>" class='form-control'/>
  111. <input type="hidden" id="extension<?php echo $file->id?>" value="<?php echo $file->extension;?>"/>
  112. <strong class='input-group-addon'>.<?php echo $file->extension;?></strong>
  113. </div>
  114. <div class="input-group-btn">
  115. <button type="button" class="btn btn-success file-name-confirm" onclick="setFileName(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-check"></i></button>
  116. <button type="button" class="btn btn-gray file-name-cancel" onclick="showFile(<?php echo $file->id;?>)" style="border-radius: 0px 2px 2px 0px; border-left-color: transparent;"><i class="icon icon-close"></i></button>
  117. </div>
  118. </div>
  119. </div>
  120. </li>
  121. </div>
  122. </div>
  123. <?php endforeach;?>
  124. </div>
  125. <div id="showError" style="display: none"></div>