Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defined('_JEXEC') or die;
- require_once dirname(__FILE__) . '/helper.php';
- if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
- $filefinder = new FileFinder(JFactory::getApplication()->input->post->getString('path'));
- require JModuleHelper::getLayoutPath('mod_filefinder');
- class FileFinder
- {
- public $currentdirectory = "";
- public $subdirectories = array();
- public $js = "";
- public $html = "";
- function __construct($path = null)
- {
- if (!$path) {
- chdir('../');
- $this->currentdirectory = basename(JPATH_BASE);
- $this->subdirectories = glob($this->currentdirectory.DS."*", GLOB_ONLYDIR);
- $this->html = "container";
- $this->js = "
- jQuery(function($) {
- $('#path').on('change', function() {
- var path = $(this).val();
- console.log({path: path});
- $.ajax({
- url: 'index.php?option=com_ajax&module=filefinder&method=FileFinder&format=raw', // &ignoreMessages
- type: 'POST',
- async: true,
- cache: false,
- data: {path: path},
- success: function(response){
- console.log(response);
- }
- });
- });
- $('#path').trigger('change');
- });
- ";
- } else {
- $this->currentdirectory = $path;
- $this->subdirectories = glob($this->currentdirectory.DS."*", GLOB_ONLYDIR);
- }
- }
- public function FileFinderAjax() {
- ?><script>console.log('hello');</script><?php
- echo "hello"; // how do I get Ajax to get in here?!?
- }
- }
- defined('_JEXEC') or die;
- if ($filefinder->html == "container") { // provide container with default contents
- echo "<div id="filefinder_container">";
- echo "<span>", JTEXT::_("Current Directory"), " ", $filefinder->currentdirectory, "</span>";
- echo "<select id="path"><option value="">Select a Subdirectory</option>";
- foreach ($filefinder->subdirectories as $subdirectory) {
- echo "<option>$subdirectory</option>"; // value="$filefinder->currentdirectory".DS."$subdirectory"
- }
- echo "</select>";
- echo "</div>";
- } else { // return only the new contents to be inserted into old container
- echo "<span>", JTEXT::_("Current Directory"), " ", $filefinder->currentdirectory, "</span>";
- echo "<select id="path"><option value="">Select a Subdirectory</option>";
- foreach ($filefinder->subdirectories as $subdirectory) {
- echo "<option>$subdirectory</option>"; // value="$filefinder->currentdirectory".DS."$subdirectory"
- }
- echo "</select>";
- }
- if ($filefinder->js) {
- JHtml::_('jquery.framework');
- $document = JFactory::getDocument();
- $document->addScriptDeclaration($filefinder->js);
- }
- {path: "administratorcache"}
- 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