Skip to content

Latest commit

 

History

History
441 lines (334 loc) · 14.5 KB

README.md

File metadata and controls

441 lines (334 loc) · 14.5 KB

Zf2 Module for ElFinder

This package is no longer supported. Maybe look for other options or forks.

This module attempts to provide an integration layer between Zend Framework 2 and ElFinder.

Currently this module provides the configuration for routing to elfinder through the following path http://yourdomain.com/elfinder and the connector is located by default at http://yourdomain.com/elfinder/connector. All of this can be changed via configuration.

Also included are the needed hooks for CKEditor and TinyMce.

##IMPORTANT SECURITY NOTICE This module DOES NOT provide any user authentication and if used on it's own will grant anyone access to your public file system! It is expected that through ZF2 you will be setting up your own authentication and user management system. For that reason this module has no plans for including any. But if you need authentication you may want to check out the ZfUser module and see if that works for you.

Change Log

v2.0.2

  • Fixed BC break from upstream. Js and Css are now already merged
  • Added pulling configs from the Service Locator for more complex configurations. See docs below

v2.0.1

  • Removed the @dev dependancy on ElFinder.

v2.0.0-alpha

  • Added composer definition to use upstream ElFinder package instead of using our own.
  • Added Asset Manager module as a dependency to handle building the needed JS and CSS files.
  • Cleaned up views

Please report any bugs you find.

Requirements

PHP 5.4+ Zend Framework 2

Installation

This package uses composer to install.

Installation steps

  1. Install the composer package: composer require reliv/elfinder

  2. Add 'Reliv\ElFinder' to your list of modules in [zf2 project folder]/config/application.config.php

  3. (Optional) Configure the module for use in your project (see configuration below)

  4. (Optional) Add ElFinder finder to your views that need it.

  5. Test it out and report any bugs or issues back to the project.

  6. Tell others about it.

Adding ElFinder to your project

Stand Alone

If just wanting to test out or use ElFinder as a standalone File Manager, simply navigate your browser to the standalone route for ElFinder. If your using the defaults this URL is http://yourdomain.com/elfinder/standalone

CkEditor

To add ElFinder to CKEditor add the route to the explore window to CkEditors config. This can be done when your initializing your editor or simply by adding this to the CkEditor's global config file. By default the config file is located in CkEditors main folder path/to/ckeditor/config.js.

Add the following lines to CkEditor's config

    filebrowserBrowseUrl : '/elfinder/ckeditor',
    filebrowserImageBrowseUrl : '/elfinder/ckeditor/images',

Note: If you've changed the default routes to ElFinder, be sure to point the code above to the correct place.

Optionally you can customize CkEditors popup window size to fit your needs by adding the following line to CkEditors config and adjusting to your taste.

    filebrowserWindowHeight : '400',
    filebrowserWindowWidth : '800'

TinyMce

To add ElFinder to TinyMce copy the 'public/tinymce/plugins/elfinder' to your TinyMce instance plugins folder.

Register the plugin with TinyMce.

    tinymce.init({
        ....
        plugins: 'elfinder',
        ....
    });

Using in your own application

This module can be used as a file uploader or to pick an existing file from existing mount points. In order to do that your program will need to open up a popup window that points to the ElFinder's explorer window. In addition to that, the calling window MUST have a global javascript function defined.

The following is an example that you might add to your page:

<script type="javascript">
function elFinderFileSelected(filePath) {
    // Do something with the file path returned.
}

function showElFinder(elFinderExplorerPath, windowWidth, windowHeight) {
    window.open(
        elFinderExplorerPath,
        '',
        'resizable=yes,
        location=no,
        menubar=no,
        scrollbars=yes,
        status=no,
        toolbar=no,
        fullscreen=no,
        dependent=no,
        width=windowWidth,
        height=windowHeight,
        status'
    );
}
</script>

Configuration (Optional)

This module uses basic ZF2 configuration and passes this information on to ElFinder. All server connector options are available to you but because there's not a one size fits all to this we've extended this just a little so you can have additional or specific settings based on your needs.

This module comes with some pre-defined configuration to get you up and running as quickly as possible. *Please Note: To use default configuration the contents of the public folder for this modules must be located in [project home]/public/modules/el-finder. In other words modules/el-finder must be publicly accessible.

####Configuring Mount Points

By default the system sets up two default mount points for you, [project home]/public/modules/el-finder/files and [project home]/public/modules/el-finder/files/images however there is no limit to how many mount points you can define.

To add a new mount point simply open up your application config or projects global config file and add your mount points like so.

return array(
    'elfinder' => array(
        'mounts' => array(
            'defaults' => array(
                'myNewMountPoint' => array (
                    //Mount point definition goes here.
                    //Minimum config below.  See ElFinders "Connector
                    //configuration options" for more info
                    'roots' => array(
                        'driver' => 'LocalFileSystem',
                        'path'   => '/path/to/files/',
                        'URL'    => 'http://localhost/to/files/'
                    ),
                ),
            ),
        ),
    ),
);

For a full list of all mount point configuration settings please see ElFinders wiki page titled Connector configuration options\

####Configuration Services

Some of the newer volume drivers require some complex configuration that can't be cached. As such you can provide your own Service Config that will be pulled out of the Service Manager instead of the config array.

These configuration services MUST implement the Reliv\ElFinder\Config\ConfigInterface and return a valid ElFinder mount config as seen in the above example. In addition this service must be able to be initiated from the Service Manager, so it will need to be defined there as well.

To define a Configuration Service for a mount point, here's a modified version of the config above.

return array(
    'elfinder' => array(
        'mounts' => array(
            'defaults' => array(
                'myNewMountPoint' => array (
                    //Service Config goes here
                    'configService' => 'MyServiceHere'
                ),
            ),
        ),
    ),
);

####Configuring the Zf2 routes

There are four routes defined by default.

`/elfinder` - Main route to open the explorer window which will pass
              back the url for the file selected to the calling window.

`/elfinder/connector` - Route to ElFinders php connector
`/elfinder/standalone` - Route to standalone window.  This has no callback
                         and can be used by itself to manage the filesystem

`/elfinder/ckeditor` - Hook for CKEditor

All of these routes can be customized based on your preferences. To overwrite these routes open up your application or project config and define the following routes as needed:

return array(
    'router' => array(
        'routes' => array (
            'elFinder' => array( // route definition goes here // ),
            'elFinderConnector' => array( // route definition goes here // ),
            'elFinderStandAlone' => array( // route definition goes here // ),
            'elFinderCkEditor' => array( // route definition goes here // ),
        ),
    ),
);

Important: Please note that if you change the route for the connector you will need to add the following lines to your application or project configuration files:

return array(
    'elfinder' => array(
        'connectorPath' => 'path/to/connector',
    )
);

####Additional Special configuration

This module is setup to understand and respect different configurations, mount points, and settings based your needs. This is done all through configuration. As an example CKEditor uses a special flag for uploading Images. So for that we have setup an images folder that only allows images to uploaded.

To setup a different configuration you'll want to open up your application or project config files and add the following:

return array(
    'elfinder' => array(
        'mounts' => array(

            //Set Name for this configuration
            'myNewFileTypeOrConfigName' => array(

                //Mount point definition goes here.
                //Minimum config below.  See ElFinders "Connector
                //configuration options" for more info

                'myNewMountPoint' => array (
                    //Mount point definition goes here.
                    //Minimum config below.  See ElFinders "Connector
                    //configuration options" for more info
                    'roots' => array(
                        'driver' => 'LocalFileSystem',
                        'path'   => '/path/to/files/',
                        'URL'    => 'http://localhost/to/files/'
                    ),
                ),

            ),
        ),
    ),
);

Once that's complete, setup your view for ElFinder as described above, with one exception. You need to add your new definition or type to the URL or route to ElFinder. If using the example above my new URL this instance of ElFinder would be /elfinder/images

##To Do Setup MySql connector to use Zend DB or at least pass in the current DB settings to ElFinders MySql connector class.

Setup MySql connector to use Doctrine ORM Module or at least pass in the current DB settings when using Doctrine.

      _ ______ _           _
     | |  ____(_)         | |
  ___| | |__   _ _ __   __| | ___ _ __
 / _ \ |  __| | | '_ \ / _` |/ _ \ '__|
|  __/ | |    | | | | | (_| |  __/ |
 \___|_|_|    |_|_| |_|\__,_|\___|_|

elFinder is an open-source file manager for web, written in JavaScript using jQuery UI. Creation is inspired by simplicity and convenience of Finder program used in Mac OS X operating system.

Features

  • All operations with files and folders on a remote server (copy, move, upload, create folder/file, rename, etc.)
  • High performance server beckend and light client UI
  • Multi-root support
  • Local file system, MySQL, FTP volume storage drivers
  • Background file upload with Drag & Drop HTML5 support
  • List and Icons view
  • Kayboard shortcuts
  • Standart methods of file/group selection using mouse or keyboard
  • Move/Copy files with Drag & Drop
  • Archives create/extract (zip, rar, 7z, tar, gzip, bzip2)
  • Rich context menu and toolbar
  • Quicklook, preview for common file types
  • Edit text files and images
  • "Places" for your favorites
  • Calculate directory sizes
  • Thumbnails for image files
  • Easy to integrate with web editors (elRTE, CKEditor, TinyMCE)
  • Flexible configuration of access rights, upload file types, user interface and other
  • Extensibility
  • Simple client-server API based on JSON

Requirements

Client

  • Modern browser. elFinder was tested in Firefox 10, Internet Explorer 8+, Safari 5, Opera 11 and Chrome 15+

Server

  • Any web server
  • PHP 5.2+ (for thumbnails - mogrify utility or GD/Imagick module)

3rd party connectors

Support

Authors

We hope our tools will be helpful for you.

License

elFinder is issued under a 3-clauses BSD license.

Copyright (c) 2009-2012, Studio 42
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the Studio 42 Ltd. nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL "STUDIO 42" BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.