Guest User

Untitled

a guest
Mar 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. defined('_JEXEC') or die;
  2. require_once dirname(__FILE__) . '/helper.php';
  3. if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
  4. $filefinder = new FileFinder(JFactory::getApplication()->input->post->getString('path'));
  5. require JModuleHelper::getLayoutPath('mod_filefinder');
  6.  
  7. class FileFinder
  8. {
  9. public $currentdirectory = "";
  10. public $subdirectories = array();
  11. public $js = "";
  12. public $html = "";
  13. function __construct($path = null)
  14. {
  15. if (!$path) {
  16. chdir('../');
  17. $this->currentdirectory = basename(JPATH_BASE);
  18. $this->subdirectories = glob($this->currentdirectory.DS."*", GLOB_ONLYDIR);
  19. $this->html = "container";
  20. $this->js = "
  21. jQuery(function($) {
  22. $('#path').on('change', function() {
  23. var path = $(this).val();
  24. console.log({path: path});
  25. $.ajax({
  26. url: 'index.php?option=com_ajax&module=filefinder&method=FileFinder&format=raw', // &ignoreMessages
  27. type: 'POST',
  28. async: true,
  29. cache: false,
  30. data: {path: path},
  31. success: function(response){
  32. console.log(response);
  33. }
  34. });
  35. });
  36. $('#path').trigger('change');
  37. });
  38. ";
  39. } else {
  40. $this->currentdirectory = $path;
  41. $this->subdirectories = glob($this->currentdirectory.DS."*", GLOB_ONLYDIR);
  42. }
  43. }
  44.  
  45. public function FileFinderAjax() {
  46. ?><script>console.log('hello');</script><?php
  47. echo "hello"; // how do I get Ajax to get in here?!?
  48. }
  49. }
  50.  
  51. defined('_JEXEC') or die;
  52.  
  53. if ($filefinder->html == "container") { // provide container with default contents
  54. echo "<div id="filefinder_container">";
  55. echo "<span>", JTEXT::_("Current Directory"), " ", $filefinder->currentdirectory, "</span>";
  56. echo "<select id="path"><option value="">Select a Subdirectory</option>";
  57. foreach ($filefinder->subdirectories as $subdirectory) {
  58. echo "<option>$subdirectory</option>"; // value="$filefinder->currentdirectory".DS."$subdirectory"
  59. }
  60. echo "</select>";
  61. echo "</div>";
  62. } else { // return only the new contents to be inserted into old container
  63. echo "<span>", JTEXT::_("Current Directory"), " ", $filefinder->currentdirectory, "</span>";
  64. echo "<select id="path"><option value="">Select a Subdirectory</option>";
  65. foreach ($filefinder->subdirectories as $subdirectory) {
  66. echo "<option>$subdirectory</option>"; // value="$filefinder->currentdirectory".DS."$subdirectory"
  67. }
  68. echo "</select>";
  69. }
  70. if ($filefinder->js) {
  71. JHtml::_('jquery.framework');
  72. $document = JFactory::getDocument();
  73. $document->addScriptDeclaration($filefinder->js);
  74. }
  75.  
  76. {path: "administratorcache"}
  77. POST http://localhost/jdem01/administrator/index.php?option=com_ajax&module=filefinder&method=FileFinder&format=raw 404 (Not Found)
Add Comment
Please, Sign In to add comment