PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_acymailing/views/file/tmpl/select.php

https://bitbucket.org/rippleau/nrm-org-au
PHP | 210 lines | 185 code | 18 blank | 7 comment | 26 complexity | 915cdb762a85c47045c2bed589ecc9e8 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, 0BSD, MIT, LGPL-2.1
  1. <?php
  2. /**
  3. * @package AcyMailing for Joomla!
  4. * @version 5.9.1
  5. * @author acyba.com
  6. * @copyright (C) 2009-2018 ACYBA S.A.R.L. All rights reserved.
  7. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
  8. */
  9. defined('_JEXEC') or die('Restricted access');
  10. ?><div id="maincontent" style="border: 1px solid rgb(233, 233, 233);">
  11. <form action="<?php echo acymailing_completeLink('file', true); ?>" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data" style="margin:0px;">
  12. <div id="folderarea" style="box-shadow: 0px 4px 4px -4px rgba(0, 0, 0, 0.3);padding:15px;">
  13. <button style="float: right;" class="btn" onclick="changeDisplay(event);" id="btn_change_display" title="<?php echo acymailing_translation('ACY_DISPLAY_NOICON'); ?>"><i id="iconTypeDisplay" class="acyicon-list_view"></i></button>
  14. <?php
  15. $folders = acymailing_generateArborescence($this->uploadFolders);
  16. $filetreeType = acymailing_get('type.filetree');
  17. $filetreeType->display($folders, $this->uploadFolder, 'currentFolder', 'changeFolder(path)');
  18. ?>
  19. </div>
  20. <script type="text/javascript">
  21. var clickedDel = false;
  22. document.addEventListener("DOMContentLoaded", function(){
  23. display(document.getElementById('displayType').value);
  24. });
  25. function changeFolder(folderName){
  26. var url = window.location.href;
  27. if (url.indexOf('?') > -1){
  28. var lastParam = url.substring(url.lastIndexOf('&') + 1);
  29. if(url.indexOf('pictName') > -1){
  30. var temp = url.split('&');
  31. for(var i=0;i<temp.length;i++){
  32. if(temp[i].indexOf('pictName') > -1){
  33. temp.splice(i, 1);
  34. i--;
  35. }
  36. }
  37. url = temp.join('&');
  38. lastParam = url.substring(url.lastIndexOf('&') + 1);
  39. }
  40. if(lastParam == 'task=createFolder')url = url.replace(lastParam,'task=browse&e_name=ACY_NAME_AREA');
  41. lastParam = lastParam.split('=');
  42. if(lastParam=='selected_folder')
  43. url = url.replace(lastParam, 'selected_folder='+folderName);
  44. else
  45. url += '&currentFolder='+folderName;
  46. }else{
  47. url += '?currentFolder='+folderName;
  48. }
  49. window.location.href = url;
  50. }
  51. function changeDisplay(event){
  52. event.preventDefault();
  53. if(document.getElementById('displayPict').style.display == ''){
  54. display('list');
  55. }else{
  56. display('icons');
  57. }
  58. }
  59. function display(type){
  60. if(type == 'list'){
  61. document.getElementById('displayPict').style.display = 'none';
  62. document.getElementById('displayLine').style.display = '';
  63. document.getElementById('btn_change_display').title = '<?php echo acymailing_translation('ACY_DISPLAY_ICON'); ?>';
  64. document.getElementById('iconTypeDisplay').className = 'acyicon-image_view';
  65. document.getElementById('displayType').value = 'list';
  66. }else{
  67. document.getElementById('displayPict').style.display = '';
  68. document.getElementById('displayLine').style.display = 'none';
  69. document.getElementById('btn_change_display').title = '<?php echo acymailing_translation('ACY_DISPLAY_NOICON'); ?>';
  70. document.getElementById('iconTypeDisplay').className = 'acyicon-list_view';
  71. document.getElementById('displayType').value = 'icons';
  72. }
  73. }
  74. function diplayDeleteBtn(id, action){
  75. if(action == 'display'){
  76. document.getElementById('acy_attachment_delete_' + id + '').style.display = '';
  77. }else{
  78. document.getElementById('acy_attachment_delete_' + id + '').style.display = 'none';
  79. }
  80. }
  81. function confirmDeleteFile(event, fileName){
  82. event.preventDefault();
  83. clickedDel = true;
  84. var divText = document.getElementById('confirmTxtAttach');
  85. divText.innerHTML = '<?php echo acymailing_translation('ACY_VALIDDELETEITEMS'); ?>' + '<br /><span class="acy_folder_name">(' + fileName + ')</span><br />';
  86. var divDelete = document.getElementById('confirmOkAttach');
  87. divDelete.onclick = function(event){
  88. event.preventDefault();
  89. deleteFile(fileName);
  90. };
  91. var divConfirm = document.getElementById('confirmBoxAttach');
  92. divConfirm.style.display = 'inline';
  93. }
  94. function deleteFile(fileName){
  95. var urlFile = window.location.href;
  96. if(urlFile.lastIndexOf('#') == urlFile.length - 1){
  97. urlFile = urlFile.substr(0, urlFile.length - 1);
  98. }
  99. var lastParam = urlFile.substring(urlFile.lastIndexOf('&') + 1);
  100. if(lastParam.indexOf('filename=') > -1){
  101. urlFile = urlFile.substring(0, urlFile.indexOf('filename=') - 1);
  102. }
  103. if(urlFile.indexOf('?') > -1){
  104. window.location.href = urlFile + '&task=<?php echo acymailing_getVar('cmd', 'task', ''); ?>&id=<?php echo acymailing_getVar('cmd', 'id', ''); ?>&filename=' + fileName;
  105. }else{
  106. window.location.href = urlFile + '?task=<?php echo acymailing_getVar('cmd', 'task', ''); ?>&id=<?php echo acymailing_getVar('cmd', 'id', ''); ?>&filename=' + fileName;
  107. }
  108. }
  109. </script>
  110. <div id="filesarea" style="width:100%;height:460px;overflow-x: hidden;text-align: center;">
  111. <?php
  112. if(file_exists($this->uploadPath)) $files = acymailing_getFiles($this->uploadPath);
  113. $imageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'ico', 'bmp');
  114. if(in_array($this->map, array('thumb', 'readmore'))){
  115. $allowedExtensions = $imageExtensions;
  116. }else{
  117. $allowedExtensions = explode(',', $this->config->get('allowedfiles'));
  118. $allowedExtensions = array_merge($allowedExtensions, $imageExtensions);
  119. }
  120. $displayList = '<div id="displayLine" style="display: none; text-align: left;">';
  121. echo '<div id="displayPict">';
  122. if(!empty($files)){
  123. $k = 0;
  124. $displayList .= '<table class="acymailing_smalltable">';
  125. foreach($files as $file){
  126. if(strrpos($file, '.') === false) continue;
  127. $ext = strtolower(substr($file, strrpos($file, '.') + 1));
  128. if(!in_array($ext, $allowedExtensions)) continue;
  129. $filesFound = true;
  130. echo '<div style="float: left; text-align: center; position: relative;">';
  131. $linkStart = '<a href="#" style="text-decoration:none;" onclick="if(clickedDel == false){';
  132. $linkStart .= "parent.document.getElementById('".$this->map."').value = '".str_replace(DS, '/', $this->uploadFolder)."/$file';";
  133. if(in_array($this->map, array('thumb', 'readmore'))){
  134. $linkStart .= "parent.document.getElementById('".$this->map."preview').src = '".acymailing_rootURI().str_replace(DS, '/', $this->uploadFolder)."/$file'; ";
  135. }else{
  136. $linkStart .= "parent.document.getElementById('".$this->map."selection').innerHTML = '$file'; ";
  137. $linkStart .= "parent.document.getElementById('".$this->map."suppr').style.display = 'inline';";
  138. }
  139. $linkStart .= 'window.parent.acymailing.closeBox();}">';
  140. echo $linkStart;
  141. $structPict = '<div onmouseover="diplayDeleteBtn('.$k.', \'display\');" onmouseout="diplayDeleteBtn('.$k.', \'hide\');">';
  142. $structPict .= '<div style="width: 160px;height: 160px;margin: 14px;border: 1px solid rgb(233, 233, 233);border-radius:4px;overflow: hidden;" onmouseover="this.style.opacity = 0.5;" onmouseout="this.style.opacity = 1;" title="'.$file.'">';
  143. if(strlen($file) > 20){
  144. $structPict .= '<span title="'.str_replace('"', '', $file).'">'.substr(rtrim($file, $ext), 0, 17).'...'.$ext.'</span>';
  145. }else{
  146. $structPict .= $file;
  147. }
  148. if(in_array($ext, $imageExtensions)){
  149. $imgPath = ACYMAILING_LIVE.$this->uploadFolder.'/'.$file;
  150. }else{
  151. $imgPath = ACYMAILING_LIVE.ACYMAILING_MEDIA_FOLDER.'/images/file.png';
  152. }
  153. $structPict .= '<br /><img src="'.$imgPath.'" style="margin-top:5px;max-width:150px;"/>';
  154. $structPict .= '</div>';
  155. $structPict .= '<img class="acy_attachment_delete" id="acy_attachment_delete_'.$k.'" src="'.ACYMAILING_LIVE.ACYMAILING_MEDIA_FOLDER.DS.'images'.DS.'editor'.DS.'delete.png" onclick="confirmDeleteFile(event, \''.$file.'\')" style="display: none;"/>';
  156. $structPict .= '</div>';
  157. echo $structPict;
  158. echo '</a></div>';
  159. $displayList .= '<tr><td width="30" style="padding-left: 10px;">'.$linkStart.'<img src="'.$imgPath.'" style="max-width:24px;"/></a></td>';
  160. $displayList .= '<td>'.$linkStart.$file.'</a></td>';
  161. $displayList .= '<td><img class="acy_attachment_delete" src="'.ACYMAILING_LIVE.ACYMAILING_MEDIA_FOLDER.DS.'images'.DS.'editor'.DS.'delete.png" onclick="confirmDeleteFile(event, \''.$file.'\')"/></td></tr>';
  162. $k++;
  163. }
  164. $displayList .= '</table>';
  165. }
  166. echo '</div>';
  167. $displayList .= '</div>';
  168. echo $displayList;
  169. if(empty($filesFound)) acymailing_display(acymailing_translation('NO_FILE_FOUND'), 'warning');
  170. ?>
  171. <div class="confirmBoxAttach" id="confirmBoxAttach" style="display: none;">
  172. <div id="acy_popup_content">
  173. <span class="confirmTxtAttach" id="confirmTxtAttach"></span><br/>
  174. <button class="acymailing_button" id="confirmCancelAttach" onclick="event.preventDefault(); clickedDel=false; document.getElementById('confirmBoxAttach').style.display='none';" style="padding: 6px 15px 6px 10px;">
  175. <i class="acyicon-cancel" style="margin-right: 5px; font-size: 16px;top: 2px; position: relative;"></i><?php echo acymailing_translation('ACY_CANCEL'); ?>
  176. </button>
  177. <button class="acymailing_button acymailing_button_delete" id="confirmOkAttach" style="padding: 8px 15px 6px 10px;">
  178. <i class="acyicon-delete" style="margin-right: 5px; font-size: 12px;"></i><?php echo acymailing_translation('ACY_DELETE'); ?>
  179. </button>
  180. </div>
  181. </div>
  182. </div>
  183. <div id="uploadarea" style="text-align: center;box-shadow: 0px -4px 4px -4px rgba(0, 0, 0, 0.3);padding: 10px 0px 10px 0px;">
  184. <input type="file" style="width:auto;" name="uploadedFile"/><br/>
  185. <input type="hidden" id="displayType" name="displayType" value="<?php echo $this->displayType; ?>"/>
  186. <input type="hidden" name="currentFolder" value="<?php echo htmlspecialchars($this->uploadFolder, ENT_COMPAT, 'UTF-8'); ?>"/>
  187. <input type="hidden" name="id" value="<?php echo htmlspecialchars($this->map, ENT_COMPAT, 'UTF-8'); ?>"/>
  188. <?php acymailing_formOptions(); ?>
  189. <button class="acymailing_button_grey" type="button" onclick="document.adminForm.task.value='select';submit();"> <?php echo acymailing_translation('IMPORT'); ?> </button>
  190. </div>
  191. </form>
  192. </div>