The
beta 3 is working beautifully now.
There's still a few more things I'd like to see, such as a nice interface for configuring it and for configuring the accompanying elFinder browser. Since the browser by default starts at the web root, that makes for a very interesting browser when the site is in a subdirectory! Ideally, I suppose the controller.php file should be able to use a Media Resource to control its file access.
When I used elFinder as a stand-alone browser for a form, I put the controller.php as a snippet in a resource with no template, and used the resource URL as the URL in the initialization javascript.
$().ready(function() {
var elf = $('#elfinder').elfinder({
url : 'elfconnector.html', // connector URL (REQUIRED)
getFileCallback : function(file) {
$( "#image", window.opener.document).val(file.url);
window.close();
},
resizable: false,
onlyMimes: ["image"]
}).elfinder('instance');
});
Here's the snippet I used.
<?php
include_once 'assets/js/elfinder/php/elFinderConnector.class.php';
include_once 'assets/js/elfinder/php/elFinder.class.php';
include_once 'assets/js/elfinder/php/elFinderVolumeDriver.class.php';
include_once 'assets/js/elfinder/php/elFinderVolumeLocalFileSystem.class.php';
// Required for MySQL storage connector
// include_once 'assets/js/elfinder/php/elFinderVolumeMySQL.class.php';
/**
* Simple function to demonstrate how to control file access using "accessControl" callback.
* This method will disable accessing files/folders starting from '.' (dot)
*
* @param string $attr attribute name (read|write|locked|hidden)
* @param string $path file path relative to volume root directory started with directory separator
* @return bool
**/
function access($attr, $path, $data, $volume) {
return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot)
? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
: ($attr == 'read' || $attr == 'write'); // else set read+write to true, locked+hidden to false
}
$opts = array(
// 'debug' => true,
'roots' => array(array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => 'assets/images/events', // path to files (REQUIRED)
'URL' => 'assets/images/events', // URL to files (REQUIRED)
'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL)
'uploadAllow' => array('image'), // allow by mime type
'uploadDeny' => array('all'),
'uploadOrder' => 'deny,allow'
)),
);
// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
The kind of configuration (I suppose it would be a component at that point) that I have in mind is like the configuration for TinyMCE in Evo. The site settings has some global configuration settings, and the plugin itself has other configuration options. For example, an interface for modifying the toolbar. That should be something like the access policies so that different groups (or even users) can have different configurations.
The elFinder should be able to be fed its file path settings from Media Sources. Those are already part of the access system and can be attached to groups, so the elFinder controller should be able to get the current user's group and from there the media resource.
I'm not sure how much the javascript initializer can do, whether or not it can be given configuration options to feed to the controller as GET or POST values, a-la AJAX. If it can, then the plugin can be used to get the user and media source data and insert it into the javascript to be put on the page.
-
- 4 Posts
Congratulations to all the contributors of elRTE & elFinder i think this will be a great addon for MODX.
I have one question though for sottwell (can i call you susan)
elFinder as a stand-alone browser.Put the controller.php as a snippet in a resource with no template, and used the resource URL as the URL in the initialization javascript.
I tried this (and several different ways of doing the same thing) but keep getting error:errUnknownCmd.
If you have a minute, am i missing something?
lanceC
-
- 4 Posts
hi webmaker,
I'm a bit late, you've probably already done it, but if you havn't, or for others, this message comes when elFinder js is found, but not the php files ... elFinderConnector.class.php for example.
hope this helps
lanceC
-
- 11 Posts
lance99, thank you. But how can I fix this?
-
- 4 Posts
in connector.php,
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php';
...
include_once 'ProperPathToMyFiles' . 'eachFile.php';
lanceC