PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/concrete/single_pages/dashboard/files/sets.php

http://github.com/concrete5/concrete5
PHP | 266 lines | 210 code | 55 blank | 1 comment | 20 complexity | 975e9c60e0cb5d71939598eb968250ee MD5 | raw file
Possible License(s): MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. <?php defined('C5_EXECUTE') or die("Access Denied.");
  2. $ih = Core::make('helper/concrete/ui');
  3. $dh = Core::make('helper/date');
  4. ?>
  5. <?php if ($this->controller->getTask() == 'view_detail') {
  6. ?>
  7. <script type="text/javascript">
  8. deleteFileSet = function () {
  9. if (confirm('<?=t('Are you sure you want to permanently remove this file set?')?>')) {
  10. location.href = "<?=$view->url('/dashboard/files/sets', 'delete', $fs->getFileSetID(),
  11. Core::make('helper/validation/token')->generate('delete_file_set'))?>";
  12. }
  13. }
  14. </script>
  15. <div class="ccm-dashboard-header-buttons">
  16. <button class="btn btn-danger" onclick="deleteFileSet()"><?= t('Delete Set') ?></button>
  17. </div>
  18. <form method="post" class="form-horizontal" id="file_sets_edit"
  19. action="<?= $view->url('/dashboard/files/sets', 'file_sets_edit') ?>">
  20. <?= $validation_token->output('file_sets_edit');
  21. ?>
  22. <div class="form-group">
  23. <?= $form->label('file_set_name', t('Name')) ?>
  24. <?= $form->text('file_set_name', $fs->fsName, array('class' => 'span5'));
  25. ?>
  26. </div>
  27. <?= $form->hidden('fsID', $fs->getFileSetID()); ?>
  28. <?php
  29. $fl = new FileList();
  30. $fl->filterBySet($fs);
  31. $fl->sortByFileSetDisplayOrder();
  32. $files = $fl->get();
  33. if (count($files) > 0) {
  34. ?>
  35. <span
  36. class="help-block"><?= t('Click and drag to reorder the files in this set. New files added to this set will automatically be appended to the end.') ?></span>
  37. <div class="ccm-spacer">&nbsp;</div>
  38. <div class="table-responsive">
  39. <table class="ccm-search-results-table compact-results">
  40. <thead>
  41. <tr>
  42. <th></th>
  43. <th><span><?= t('Thumbnail') ?></span></th>
  44. <th><a href="javascript:void(0)" class="sort-link" data-sort="type"><?= t('Type') ?></a></th>
  45. <th><a href="javascript:void(0)" class="sort-link" data-sort="title"><?= t('Title') ?></a></th>
  46. <th><a href="javascript:void(0)" class="sort-link"
  47. data-sort="filename"><?= t('File name') ?></a></th>
  48. <th><a href="javascript:void(0)" class="sort-link" data-sort="added"><?= t('Added') ?></a></th>
  49. </tr>
  50. </thead>
  51. <tbody class="ccm-file-set-file-list">
  52. <?php foreach ($files as $f) {
  53. ?>
  54. <tr id="fID_<?= $f->getFileID() ?>" class="">
  55. <td><i class="fa fa-arrows-v"></i></td>
  56. <td class="ccm-file-manager-search-results-thumbnail"><?= $f->getListingThumbnailImage() ?>
  57. <input type="hidden" name="fsDisplayOrder[]" value="<?= $f->getFileID() ?>"/></td>
  58. <td data-key="type"><?= $f->getGenericTypetext() ?>/<?= $f->getType() ?></td>
  59. <td data-key="title"><?= h($f->getTitle()) ?></td>
  60. <td data-key="filename"><?= h($f->getFileName()) ?></td>
  61. <td data-key="added"
  62. data-sort="<?= $f->getDateAdded()->getTimestamp() ?>"><?= $dh->formatDateTime($f->getDateAdded()->getTimestamp()) ?></td>
  63. </tr>
  64. <?php
  65. }
  66. ?>
  67. </tbody>
  68. </table>
  69. </div>
  70. <?php
  71. } else {
  72. ?>
  73. <div class="alert alert-info"><?= t('There are no files in this set.') ?></div>
  74. <?php
  75. }
  76. ?>
  77. <div class="ccm-dashboard-form-actions-wrapper">
  78. <div class="ccm-dashboard-form-actions">
  79. <a href="<?= View::url('/dashboard/files/sets') ?>"
  80. class="btn btn-default pull-left"><?= t('Cancel') ?></a>
  81. <?= Core::make("helper/form")->submit('save', t('Save'),
  82. array('class' => 'btn btn-primary pull-right')) ?>
  83. </div>
  84. </div>
  85. </form>
  86. <script>
  87. $(function () {
  88. var baseClass = "ccm-results-list-active-sort-"; // asc desc
  89. function ccmFileSetResetSortIcons() {
  90. $(".ccm-search-results-table thead tr th").removeClass(baseClass + 'asc');
  91. $(".ccm-search-results-table thead tr th").removeClass(baseClass + 'desc');
  92. $(".ccm-search-results-table thead tr th a").css("color", "#999");
  93. }
  94. function ccmFileSetDoSort() {
  95. var $this = $(this);
  96. var $parent = $(this).parent();
  97. var asc = $parent.hasClass(baseClass + 'asc');
  98. var key = $this.attr('data-sort');
  99. ccmFileSetResetSortIcons();
  100. var sortableList = $('.ccm-file-set-file-list');
  101. var listItems = $('tr', sortableList);
  102. if (asc) {
  103. $parent.addClass(baseClass + 'desc');
  104. $(".ccm-search-results-table thead tr th." + baseClass + "desc a").css("color", "#333");
  105. } else {
  106. $parent.addClass(baseClass + 'asc');
  107. $(".ccm-search-results-table thead tr th." + baseClass + "asc a").css("color", "#333");
  108. }
  109. listItems.sort(function (a, b) {
  110. var aTD = $('td[data-key=' + key + ']', $(a));
  111. var bTD = $('td[data-key=' + key + ']', $(b));
  112. var aVal = typeof( aTD.attr('data-sort') ) == 'undefined' ? aTD.text().toUpperCase() : parseInt(aTD.attr('data-sort'));
  113. var bVal = typeof( bTD.attr('data-sort') ) == 'undefined' ? bTD.text().toUpperCase() : parseInt(bTD.attr('data-sort'));
  114. if (asc) {
  115. return bVal < aVal ? -1 : 1;
  116. } else {
  117. return aVal < bVal ? -1 : 1;
  118. }
  119. });
  120. sortableList.append(listItems);
  121. }
  122. $('.ccm-search-results-table thead th a.sort-link').click(ccmFileSetDoSort);
  123. $(".ccm-file-set-file-list").sortable({
  124. cursor: 'move',
  125. opacity: 0.5,
  126. axis: 'y',
  127. helper: function (evt, elem) {
  128. var ret = $(elem).clone();
  129. var i;
  130. // copy the actual width of the elements
  131. ret.width(elem.outerWidth());
  132. retChilds = $(ret.children());
  133. elemChilds = $(elem.children());
  134. for (i = 0; i < elemChilds.length; i++)
  135. $(retChilds[i]).width($(elemChilds[i]).outerWidth());
  136. return ret;
  137. },
  138. placeholder: "ccm-file-set-file-placeholder",
  139. stop: function (e, ui) {
  140. ccmFileSetResetSortIcons();
  141. }
  142. });
  143. });
  144. </script>
  145. <style type="text/css">
  146. .ccm-file-set-file-list:hover {
  147. cursor: move
  148. }
  149. .ccm-file-set-file-placeholder {
  150. background-color: #ffd !important;
  151. }
  152. .ccm-file-set-file-placeholder td {
  153. background: transparent !important;
  154. }
  155. </style>
  156. <?php
  157. } else {
  158. ?>
  159. <?php if (count($fileSets) > 0) { ?>
  160. <div class="ccm-dashboard-content-full">
  161. <div class="table-responsive">
  162. <table class="ccm-search-results-table">
  163. <thead>
  164. <tr>
  165. <th class="ccm-results-list-active-sort-asc"><a><?= t('Set Name') ?></a></th>
  166. </tr>
  167. </thead>
  168. <tbody>
  169. <?php foreach ($fileSets as $fs) { ?>
  170. <tr data-details-url="<?= $view->url('/dashboard/files/sets/', 'view_detail',
  171. $fs->getFileSetID()) ?>">
  172. <td>
  173. <?= $fs->getFileSetDisplayName() ?>
  174. </td>
  175. </tr>
  176. <?php
  177. }
  178. ?>
  179. </tbody>
  180. </table>
  181. </div>
  182. <?php if ($fsl->requiresPaging()) {
  183. ?>
  184. <?php $fsl->displayPagingV2();
  185. ?>
  186. <?php } ?>
  187. </div>
  188. <?php
  189. } else { ?>
  190. <section>
  191. <p><?= t('No file sets found.') ?></p>
  192. </section>
  193. <?php } ?>
  194. <div class="ccm-dashboard-header-buttons">
  195. <form class="form-inline" method="get" action="#">
  196. <input type="text" class="form-control" autocomplete="off" name="fsKeywords"
  197. value="<?= isset($_REQUEST['fsKeywords']) ? h($_REQUEST['fsKeywords']) : '' ?>" placeholder="<?= t('Search') ?>">
  198. <select data-select="bootstrap" name="fsType">
  199. <option
  200. value="<?= FileSet::TYPE_PUBLIC ?>" <?php if ($fsType != FileSet::TYPE_PRIVATE) { ?> selected <?php } ?>><?= t('Public Sets') ?></option>
  201. <option
  202. value="<?= FileSet::TYPE_PRIVATE ?>" <?php if ($fsType == FileSet::TYPE_PRIVATE) { ?> selected <?php } ?>><?= t('My Sets') ?></option>
  203. </select>
  204. <button class="btn btn-info" type="submit"><i class="fa fa-search"></i></button>
  205. <ul class="ccm-header-search-navigation">
  206. <li><a href="<?= View::url('/dashboard/files/add_set') ?>" class="link-primary"><i
  207. class="fa fa-plus"></i> <?= t('Add File Set') ?></a></li>
  208. </ul>
  209. </form>
  210. </div>
  211. <?php } ?>