PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/ZengcodeLive V1.0/files/FckAjaxFileManage/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_list.php

https://github.com/zengcode/ZengCode-PHP-Framework
PHP | 159 lines | 140 code | 7 blank | 12 comment | 14 complexity | c51e97e1e03c577474bc04a7629b5481 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * the php script used to get the list of file or folders under a specific folder
  4. * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
  5. * @link www.phpletter.com
  6. * @since 22/May/2007
  7. *
  8. */
  9. if(!isset($manager))
  10. {
  11. /**
  12. * this is part of script for processing file paste
  13. */
  14. //$_GET = $_POST;
  15. include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
  16. include_once(CLASS_MANAGER);
  17. define('URL_AJAX_FILE_MANAGER', CONFIG_URL_HOME);
  18. include_once(CLASS_SESSION_ACTION);
  19. $sessionAction = new SessionAction();
  20. include_once(DIR_AJAX_INC . "class.manager.php");
  21. $manager = new manager();
  22. $manager->setSessionAction($sessionAction);
  23. $selectedDocuments = $sessionAction->get();
  24. if(sizeof($selectedDocuments))
  25. {
  26. include_once(CLASS_FILE);
  27. $file = new file();
  28. foreach($selectedDocuments as $doc)
  29. {
  30. $sourcePath = $sessionAction->getFolder() . $doc;
  31. if($file->copyTo($sourcePath, $manager->getCurrentFolderPath()) && $sessionAction->getAction() == "cut")
  32. {//remove the souce files or folder
  33. $file->delete($sourcePath);
  34. }
  35. }
  36. $sessionAction->set(array());
  37. }
  38. $fileList = $manager->getFileList();
  39. $folderInfo = $manager->getFolderInfo();
  40. }
  41. ?><table class="tableList" id="tableList" cellpadding="0" cellspacing="0">
  42. <thead>
  43. <tr>
  44. <th width="5%"><a href="#" class="check_all" id="tickAll" title="<?php echo TIP_SELECT_ALL; ?>" onclick="checkAll('<?php echo TIP_SELECT_ALL; ?>', '<?php echo TIP_UNSELECT_ALL; ?>');">&nbsp;</a></th>
  45. <th width="6%" class="center">&nbsp;</th>
  46. <th width="48%" class="left"><?php echo LBL_NAME; ?></th>
  47. <th width="10%" class="center"><?php echo LBL_SIZE; ?></th>
  48. <th width="31%" class="center"><?php echo LBL_MODIFIED; ?></th>
  49. </tr>
  50. </thead>
  51. <tbody id="fileList">
  52. <tr class="even" id="topRow" onclick="setDocInfo('folder', '0');">
  53. <td><input type="checkbox" name="check[]" id="check0" disabled="disabled" />
  54. <input type="hidden" name="folderPath0" value="<?php echo transformFilePath($folderInfo['path']); ?>" id="folderPath0" />
  55. <input type="hidden" name="folderFile0" value="<?php echo $folderInfo['file']; ?>" id="folderFile0" />
  56. <input type="hidden" name="folderSubdir0" id="folderSubdir0" value="<?php echo $folderInfo['subdir']; ?>" />
  57. <input type="hidden" name="folderCtime0" id="folderCtime0" value="<?php echo date(DATE_TIME_FORMAT,$folderInfo['ctime']); ?>" />
  58. <input type="hidden" name="folderMtime0" id="folderMtime0" value="<?php echo date(DATE_TIME_FORMAT,$folderInfo['mtime']); ?>" />
  59. <input type="hidden" name="fileReadable0" id="folderReadable0" value="<?php echo $folderInfo['is_readable']; ?>" />
  60. <input type="hidden" name="folderWritable0" id="folderWritable0" value="<?php echo $folderInfo['is_writable']; ?>" />
  61. <input type="hidden" name="itemType0" id="itemType0" value="folder" />
  62. </td>
  63. <td>
  64. <?php
  65. if(strtolower($folderInfo['path']) == strtolower(CONFIG_SYS_ROOT_PATH))
  66. {//this is root folder
  67. ?>
  68. <span class="folderParent">&nbsp;</span>
  69. <?php
  70. }else
  71. {
  72. ?>
  73. <a href="<?php echo appendQueryString(appendQueryString(URL_AJAX_FILE_MANAGER, "path=" . getParentPath($folderInfo['path'])), makeQueryString(array('path'))); ?>" title="<?php echo TIP_FOLDER_GO_UP; ?>"><span class="folderParent">&nbsp;</span></a>
  74. <?php
  75. }
  76. ?>
  77. </td>
  78. <td class="left" id="<?php echo $folderInfo['path']; ?>">
  79. <?php
  80. if($folderInfo['path'] == CONFIG_SYS_ROOT_PATH)
  81. {
  82. echo "&nbsp;";
  83. }else
  84. {
  85. ?>
  86. <a href="<?php echo appendQueryString(appendQueryString(URL_AJAX_FILE_MANAGER, "path=" . getParentPath($folderInfo['path'])), makeQueryString(array('path'))); ?>" title="<?php echo TIP_FOLDER_GO_UP; ?>">...</a>
  87. <?php
  88. }
  89. ?>
  90. </td>
  91. <td>&nbsp;</td>
  92. <td>&nbsp;</td>
  93. </tr>
  94. <?php
  95. $count = 1;
  96. $css = "";
  97. //list all documents (files and folders) under this current folder,
  98. foreach($fileList as $file)
  99. {
  100. $css = ($css == "" || $css == "even"?"odd":"even");
  101. $strDisabled = ($file['is_writable']?"":" disabled");
  102. $strClass = ($file['is_writable']?"left":" leftDisabled");
  103. if($file['type'] == 'file')
  104. {
  105. ?>
  106. <tr class="<?php echo $css; ?>" id="row<?php echo $count; ?>" >
  107. <td onclick="setDocInfo('<?php echo $file['type']; ?>', '<?php echo $count; ?>');"><input type="checkbox" name="check[]" id="check<?php echo $count; ?>" value="<?php echo $file['name']; ?>" <?php echo $strDisabled; ?> />
  108. <input type="hidden" name="fileName<?php echo $count; ?>" value="<?php echo $file['name']; ?>" id="fileName<?php echo $count; ?>" />
  109. <input type="hidden" name="fileSize<?php echo $count; ?>" value="<?php echo transformFileSize($file['size']); ?>" id="fileSize<?php echo $count; ?>" />
  110. <input type="hidden" name="fileType<?php echo $count; ?>" value="<?php echo $file['fileType']; ?>" id="fileType<?php echo $count; ?>" />
  111. <input type="hidden" name="fileCtime<?php echo $count; ?>" id="fileCtime<?php echo $count; ?>" value="<?php echo date(DATE_TIME_FORMAT,$file['ctime']); ?>" />
  112. <input type="hidden" name="fileMtime<?php echo $count; ?>" id="fileMtime<?php echo $count; ?>" value="<?php echo date(DATE_TIME_FORMAT,$file['mtime']); ?>" />
  113. <input type="hidden" name="fileReadable<?php echo $count; ?>" id="fileReadable<?php echo $count; ?>" value="<?php echo $file['is_readable']; ?>" />
  114. <input type="hidden" name="fileWritable<?php echo $count; ?>" id="fileWritable<?php echo $count; ?>" value="<?php echo $file['is_writable']; ?>" />
  115. <input type="hidden" name="filePreview<?php echo $count; ?>" id="filePreview<?php echo $count; ?>" value="<?php echo $file['preview']; ?>" />
  116. <input type="hidden" name="filePath<?php echo $count; ?>" id="filePath<?php echo $count; ?>" value="<?php echo $file['path']; ?>" />
  117. <input type="hidden" name="fileUrl<?php echo $count; ?>" id="fileUrl<?php echo $count; ?>" value="<?php echo getFileUrl($file['path']); ?>" />
  118. <input type="hidden" name="itemType<?php echo $count; ?>" id="itemType<?php echo $count; ?>" value="file" />
  119. </td>
  120. <td><a href="<?php echo $file['path']; ?>" target="_blank"><span class="<?php echo $file['cssClass']; ?>"><span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span></span></a></td>
  121. <td class="<?php echo $strClass; ?>" id="<?php echo $file['path']; ?>"><?php echo $file['name']; ?></td>
  122. <td><?php echo transformFileSize($file['size']); ?></td>
  123. <td><?php echo date(DATE_TIME_FORMAT,$file['mtime']); ?></td>
  124. </tr>
  125. <?php
  126. }else
  127. {
  128. ?>
  129. <tr class="<?php echo $css; ?>" id="row<?php echo $count; ?>" >
  130. <td onclick="setDocInfo('folder', '<?php echo $count; ?>');"><input type="checkbox" name="check[]" id="check<?php echo $count; ?>" value="<?php echo $file['name']; ?>" <?php echo $strDisabled; ?>/>
  131. <input type="hidden" name="folderName<?php echo $count; ?>" id="folderName<?php echo $count; ?>" value="<?php echo $file['name']; ?>" />
  132. <input type="hidden" name="folderPath<?php echo $count; ?>" value="<?php echo transformFilePath($file['path']); ?>" id="folderPath<?php echo $count; ?>" />
  133. <input type="hidden" name="folderFile<?php echo $count; ?>" value="<?php echo $file['file']; ?>" id="folderFile<?php echo $count; ?>" />
  134. <input type="hidden" name="folderSubdir<?php echo $count; ?>" id="folderSubdir<?php echo $count; ?>" value="<?php echo $file['subdir']; ?>" />
  135. <input type="hidden" name="folderCtime<?php echo $count; ?>" id="folderCtime<?php echo $count; ?>" value="<?php echo date(DATE_TIME_FORMAT,$file['ctime']); ?>" />
  136. <input type="hidden" name="folderMtime<?php echo $count; ?>" id="folderMtime<?php echo $count; ?>" value="<?php echo date(DATE_TIME_FORMAT,$file['mtime']); ?>" />
  137. <input type="hidden" name="fileReadable<?php echo $count; ?>" id="folderReadable<?php echo $count; ?>" value="<?php echo $file['is_readable']; ?>" />
  138. <input type="hidden" name="folderWritable<?php echo $count; ?>" id="folderWritable<?php echo $count; ?>" value="<?php echo $file['is_writable']; ?>" />
  139. <input type="hidden" name="itemType<?php echo $count; ?>" id="itemType<?php echo $count; ?>" value="folder" />
  140. </td>
  141. <td><a href="<?php echo appendQueryString(appendQueryString(URL_AJAX_FILE_MANAGER, "path=" . $file['path']), makeQueryString(array('path'))); ?>" title="<?php echo TIP_FOLDER_GO_DOWN; ?>"><span class="<?php echo ($file['file']||$file['subdir']?$file['cssClass']:"folderEmpty"); ?>"><span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span></span></a></td>
  142. <td class="<?php echo $strClass; ?>" id="<?php echo $file['path']; ?>"><?php echo $file['name']; ?></td>
  143. <td>&nbsp;</td>
  144. <td><?php echo date(DATE_TIME_FORMAT,$file['mtime']); ?></td>
  145. </tr>
  146. <?php
  147. }
  148. $count++;
  149. }
  150. ?>
  151. </tbody>
  152. </table>