m.printfiles.html.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * The print files mobile view file of file module of RanZhi.
  4. *
  5. * @copyright Copyright 2009-2015 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Hao Sun <sunhao@cnezsoft.com>
  8. * @package file
  9. * @version $Id: buildform.html.php 7417 2013-12-23 07:51:50Z wwccss $
  10. * @link http://www.ranzhico.com
  11. */
  12. if(empty($files)) return;
  13. $sessionString = session_name() . '=' . session_id();
  14. ?>
  15. <?php if($fieldset == 'true'):?>
  16. <?php $filesUID = 'files-' . uniqid(); ?>
  17. <div class='heading gray'>
  18. <div class='title'><strong><?php echo $lang->file->common;?></strong></div>
  19. </div>
  20. <div class='list files' id='#<?php echo $filesUID ?>'>
  21. <?php endif;?>
  22. <?php foreach ($files as $file):?>
  23. <div class='item item-file' data-file-id='<?php echo $file->id ?>'>
  24. <div class='content'>
  25. <span class='text-link'><?php echo (preg_match("/\.{$file->extension}$/", $file->title)) ? $file->title : $file->title . '.' . $file->extension;?></span>
  26. <span class='muted small'>
  27. <?php
  28. /* Show size info. */
  29. if($file->size < 1024)
  30. {
  31. echo "<span>(" . $file->size . 'B' . ")</span>";
  32. }
  33. elseif($file->size < 1024 * 1024)
  34. {
  35. $file->size = round($file->size / 1024, 2);
  36. echo "<span>(" . $file->size . 'K' . ")</span>";
  37. }
  38. elseif($file->size < 1024 * 1024 * 1024)
  39. {
  40. $file->size = round($file->size / (1024 * 1024), 2);
  41. echo "<span>(" . $file->size . 'M' . ")</span>";
  42. }
  43. else
  44. {
  45. $file->size = round($file->size / (1024 * 1024 * 1024), 2);
  46. echo "<span>(" . $file->size . 'G' . ")</span>";
  47. }
  48. ?>
  49. </span>
  50. </div>
  51. <?php 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}'");?>
  52. <a class='btn edit-file' data-stop-propagation='true' data-placement='bottom' data-display='modal' data-remote='<?php echo $this->createLink('file', 'edit', "fileID=$file->id") ?>'><i class='icon-pencil text-link'></i></a>
  53. <a class='btn delete-file text-danger' href='<?php echo $this->createLink('file', 'delete', "fileID=$file->id") ?>' target='hiddenwin'><i class='icon-trash'></i></a>
  54. </div>
  55. <?php endforeach;?>
  56. <?php if($fieldset == 'true'):?>
  57. </div>
  58. <script>
  59. $(function()
  60. {
  61. var $files = $('#<?php echo $filesUID ?>');
  62. if($files.parent().hasClass('modal'))
  63. {
  64. $files.listenScroll({container: 'parent'}).prev('.heading').addClass('divider').find('.nav').append('<a data-dismiss="display"><i class="icon icon-remove muted"></i></a>');
  65. }
  66. });
  67. </script>
  68. <?php endif;?>
  69. <script>
  70. $(function()
  71. {
  72. var $body = $('body');
  73. if(!$body.data('bindDownloadFile'))
  74. {
  75. $body.on($.TapName, '.item-file[data-file-id] > .avatar, .item-file[data-file-id] > .content', function()
  76. {
  77. <?php
  78. $downloadLink = $this->createLink('file', 'download', "fileID={0}");
  79. $downloadLink .= strpos($downloadLink, '?') === false ? '?' : '&';
  80. $downloadLink .= $sessionString;
  81. ?>
  82. var url = '<?php echo $downloadLink;?>';
  83. window.open($.format(url, $(this).parent().data('fileId')), '_blank');
  84. }).data('bindDownloadFile', true);
  85. }
  86. });
  87. </script>