yii-elFinder2 / ElFinderConnectorAction.php

 * @author Bogdan Savluk <savluk.bogdan@gmail.com>
class ElFinderConnectorAction extends CAction
     * https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
     * @var array
    public $settings = array();

    public function run()
        error_reporting(0); // Set E_ALL for debuging

        include_once dirname(__FILE__) . '/php/elFinderConnector.class.php';
        include_once dirname(__FILE__) . '/php/elFinder.class.php';
        include_once dirname(__FILE__) . '/php/elFinderVolumeDriver.class.php';
        //include_once dirname(__FILE__) . '/php/elFinderVolumeLocalFileSystem.class.php';
        // Required for MySQL storage connector
        // include_once dirname(__FILE__).'/php/elFinderVolumeMySQL.class.php';
        // Required for FTP connector support
        // include_once dirname(__FILE__).'/php/elFinderVolumeFTP.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
         * @param $data
         * @param $volume
         * @return bool|null
        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
                : null; // else elFinder decide it itself

        $opts = $this->settings;
        foreach ($opts['roots'] as &$r) {
            switch ($r['driver']) {
                case 'LocalFileSystem':
                    include_once dirname(__FILE__) . '/php/elFinderVolumeLocalFileSystem.class.php';
                case 'MySQL':
                    include_once dirname(__FILE__) . '/php/elFinderVolumeMySQL.class.php';
                case 'FTP':
                    include_once dirname(__FILE__) . '/php/elFinderVolumeFTP.class.php';
            $r['accessControl'] = 'access'; // disable and hide dot starting files (OPTIONAL)
        $connector = new elFinderConnector(new elFinder($opts));

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.