PageRenderTime 49ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

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