SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/file_selector_popup.php

  1. <?php
  2. /*
  3.  * kate: tab-width 4; indent-width 4; space-indent on; word-wrap off; word-wrap-column 120;
  4.  * :tabSize=4:indentSize=4:noTabs=true:wrap=false:maxLineLen=120:mode=php:
  5.  *
  6.  * Copyright (C) 2015 Karmabunny Pty Ltd.
  7.  *
  8.  * This file is a part of SproutCMS.
  9.  *
  10.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  11.  * of the GNU General Public License as published by the Free Software Foundation, either
  12.  * version 3 of the License, or (at your option) any later version.
  13.  *
  14.  * For more information, visit <http://getsproutcms.com>.
  15.  */
  16. use Sprout\Helpers\Csrf;
  17. use Sprout\Helpers\Form;
  18. use Sprout\Helpers\Needs;
  19.  
  20. Needs::fileGroup('sprout/file_selector_popup');
  21. Needs::fileGroup('drag_drop_upload');
  22. echo Needs::dynamicNeedsLoader();
  23. ?>
  24.  
  25. <script type="text/javascript">
  26. $(document).ready(function(){
  27. initTabs();
  28. });
  29. </script>
  30.  
  31. <div class="main-tabs">
  32. <?php if ($browse and $upload): ?>
  33. <ul>
  34. <li><a href="#tab-select-file">Select</a></li>
  35. <li><a href="#tab-upload-file">Upload</a></li>
  36. </ul>
  37. <?php endif; ?>
  38.  
  39. <div class="tab" id="tab-select-file">
  40.  
  41. <?php if ($browse): ?>
  42.  
  43. <!-- Search existing -->
  44. <form action="SITE/admin/call/file/selectorPopupSearch" method="get" id="file-selector-search">
  45. <input type="hidden" name="f_type" value="<?php echo $f_type; ?>">
  46. <input type="hidden" name="page" value="0" id="file-selector-page">
  47.  
  48. <h3 class="popup-subtitle">Search existing files</h3>
  49.  
  50. <div class="field-elements-inline">
  51. <?php
  52. Form::nextFieldDetails('Category', false);
  53. echo Form::dropdown('category_id', ['-dropdown-top' => 'All', '-wrapper-class' => 'white'], $cats);
  54. ?>
  55.  
  56. <?php
  57. Form::nextFieldDetails('Name', false);
  58. echo Form::text('name', ['-wrapper-class' => 'white', 'placeholder' => 'Enter a name']);
  59. ?>
  60.  
  61. <div class="field-element field-element--button">
  62. <button type="submit" class="button icon-after icon-search button-green button-regular">Search</button>
  63. </div>
  64. </div>
  65.  
  66. </form>
  67.  
  68. <?php endif; ?>
  69.  
  70. <div class="file-selector-search-wrapper">
  71. <div id="file-selector-preview"><p class="preview-title">Preview image</p><div class="preview-box"></div></div>
  72. <div id="file-selector-stats"></div>
  73. <div id="file-selector-result-wrap">
  74. <div id="file-selector-results"></div>
  75. </div>
  76. <div id="file-selector-paginate" class="-clearfix"></div>
  77. </div>
  78.  
  79. </div>
  80. <div class="tab" id="tab-upload-file">
  81.  
  82. <?php if ($upload): ?>
  83.  
  84. <h2 class="popup-title">Select a file</h2>
  85. <!-- Upload -->
  86. <form action="SITE/admin/call/file/quickUpload" method="post" target="quick-upload" id="file-selector-upload" data-type="<?php echo $f_type; ?>">
  87. <?= Csrf::token(); ?>
  88.  
  89. <h3 class="popup-subtitle">Upload</h3>
  90. <?php
  91. Form::nextFieldDetails('File', true);
  92. echo Form::chunkedUpload('file', [], ['sess_key' => 'admin_quick_upload']);
  93. ?>
  94.  
  95. <div class="field-elements-inline">
  96.  
  97. <?php
  98. if ($cat_create) {
  99. $cats = ['_new' => '- New category -'] + $cats;
  100. }
  101. Form::nextFieldDetails('Category', (bool) $req_category);
  102. echo Form::dropdown('category_id', ['-dropdown-top' => 'Select a file category', '-wrapper-class' => 'white select-category'], $cats);
  103. ?>
  104.  
  105. <?php
  106. Form::nextFieldDetails('New file category', true);
  107. echo Form::text('category_new', ['-wrapper-class' => 'white new-category', 'placeholder' => 'Enter a category name']);
  108. ?>
  109.  
  110. <?php
  111. Form::nextFieldDetails('Name', true);
  112. echo Form::text('name', ['-wrapper-class' => 'white', 'placeholder' => 'Enter a name']);
  113. ?>
  114.  
  115. <div class="field-element field-element--button">
  116. <button type="submit" class="button icon-after icon-file_upload button-green button-regular">Upload</button>
  117. </div>
  118. </div>
  119.  
  120. </form>
  121.  
  122. <iframe name="quick-upload" id="quick-upload" style="display: none;"></iframe>
  123.  
  124. <?php endif; ?>
  125.  
  126. </div>
  127. </div>
  128.  
  129. <script>init_fileselector_popup();</script>
  130.