Developed with love by KnpLabs Hire us for your project!
28

ElFinderBundle

by alphalemon

This project has been moved to https://github.com/redkite-labs/ElFinderBundle

ElFinderBundle

The ElFinderBundle encapsulates the elFinder file manager to be used in Symfony2.

Installation

Clone this bundle in the vendor/bundles/AlphaLemon directory:

git clone git://github.com/alphalemon/ElFinderBundle.git vendor/bundles/AlphaLemon/ElFinderBundle

OR (if you're using deps file)

Add the following to the deps file:

[ElFinderBundle]
    git=git://github.com/alphalemon/ElFinderBundle.git
    target=bundles/AlphaLemon/ElFinderBundle

Now use the vendors script to clone the newly added repositories into your project:

php bin/vendors install

Configure the ElFinderBundle

Open the AppKernel configuration file and add the bundle to the registerBundles() method:

public function registerBundles()
{
    $bundles = array(
        ...
        new AlphaLemon\ElFinderBundle\AlphaLemonElFinderBundle(),
    )
}

Register the ElFinderBundle namespaces in app/autoload.php:

$loader->registerNamespaces(array(
    ...
    'AlphaLemon'                     => __DIR__.'/../vendor/bundles',
));

Import the routing configuration into the routing.yml file:

_AlphaLemonElFinderBundle:
    resource: "@AlphaLemonElFinderBundle/Resources/config/routing.yml"

Register the bundle into the Assetic bundles in config.yml:

# Assetic Configuration
assetic:
    bundles: [ "AlphaLemonElFinderBundle" ]

Initialize submodules grabbing the ElFinder vendor library. Move inside the ElFinder folder than give this commands:

git submodule init
git submodule update

To complete the bundle configuration you must install assets as follows:

app/console assets:install web
app/console assetic:dump

Using the object

AlphaLemonElFinderBundle provides a ready to use controller to display the ElFinder:

http://[yoursite]/al_showElFinder

Customize elFinder

The default connector has a very minimal configuration, so you would like to configure it on your needs. The elFinder object is loaded into the show.html.twig
template, where all the required assets and initial jquery script are added. To change the configuration you shoud create a new twig template that extends the
base one:

/path/to/your/twig/template

{% extends 'AlphaLemonElFinderBundle:ElFinder:show.html.twig' %}

This template has four blocks you may override:

{% block stylesheet_files %}{% endblock %}

{% block javascript_files %}{% endblock %}

{% block init_script %}{% endblock %}

{% block elfinder_html %}{% endblock %}

The names speak themselves, so if you need to change the init script, you just have to override the init_script block:

{% block init_script %}
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $('<div/>').dialogelfinder({
                url : '/al_elFinderMediaConnect',
                lang : 'en',
                width : 840,
                destroyOnClose : true
        }).dialogelfinder('instance');
    });
</script>
{% endblock %}

Read the elFinder documentation to learn more on the available options

The connector

The url option declares the connector to use. It is the class where are defined the elFinder options, like the folder where are saved the files and so on.
In the example above the al_elFinderMediaConnect route is called and the action implementstion might be:

public function connectMediaAction()
{
    $connector = $this->container->get('el_finder_media_connector');
    $connector->connect();
}

You may notice that the connector has been injected into the Dependency Injector Container, and its implementation is:

<parameters>
    <parameter key="el_finder.media_connector">Path\To\AlphaLemonElFinderMediaConnector</parameter>
</parameters>

<services>
    <service id="el_finder_connector" class="%el_finder.media_connector%">
        <argument type="service" id="service_container" />
    </service>
</services>

The class AlphaLemonElFinderMediaConnector is instantiated into the DIC. Follows a sample of its implementation:

namespace Path\To\AlphaLemonElFinderMediaConnector;

use AlphaLemon\ElFinderBundle\Core\Connector\AlphaLemonElFinderBaseConnector;

class AlphaLemonElFinderMediaConnector extends AlphaLemonElFinderBaseConnector
{
    protected function configure()
    {
        $request = $this->container->get('request');

        $options = array(
            'roots' => array(
                array(
                    'driver'        => 'LocalFileSystem',   // driver for accessing file system (REQUIRED)
                    'path'          => 'bundles/alphalemonelfinder/files/',         // path to files (REQUIRED)
                    'URL'           => $request->getScheme().'://'.$request->getHttpHost() . '/bundles/alphalemonelfinder/files/', // URL to files (REQUIRED)
                    'accessControl' => 'access'             // disable and hide dot starting files (OPTIONAL)
                )
            )
        );

        return $options;
    }
}

The connector extends the AlphaLemonElFinderBaseConnector which requires the derived class to implement a configure() method where the elFinder connector's options
must be declared. This function must return an array of options.

Copyright (c) since 2011 AlphaLemon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
alpha_lemon_el_finder:  []
  • updatec composer.json
    By invalid-email-address, 6 years ago
  • upgraded ElFinder library
    By invalid-email-address, 6 years ago
  • Merge pull request #9 from franmomu/fix_javascript
    By alphalemon, 6 years ago
  • Fix javascripts
    By franmomu, 6 years ago
  • updated composer.json
    By invalid-email-address, 6 years ago
  • added jquery-ui images
    By invalid-email-address, 7 years ago
  • added ElFinder RC1 library
    By invalid-email-address, 7 years ago
  • ElFinder added statically
    By invalid-email-address, 7 years ago
  • removed submodule
    By invalid-email-address, 7 years ago
  • updated to symfony 2.1 stable
    By invalid-email-address, 7 years ago
  • added assets one by one when folder where they are placed contains another folder, due to assetic bug
    By alphalemon, 7 years ago
  • Merge pull request #7 from dmitrydims/master
    By alphalemon, 7 years ago
  • Fixed mistype (new new Class())
    By Semenyk Dmitriy, 7 years ago
  • Added "how to install this bundle using deps file"
    By Semenyk Dmitriy, 7 years ago
  • added ActionManager to install submodules
    By alphalemon, 7 years ago
  • added config to enable bundle for assetic
    By alphalemon, 7 years ago
  • updated composer.json to work with latest Symfony2 release
    By alphalemon, 7 years ago
  • added minimum-stability flag
    By alphalemon, 7 years ago
  • declared symfony 2.1 dependencies explicitely
    By alphalemon, 7 years ago
  • Merge branch 'master' of github.com:alphalemon/ElFinderBundle
    By alphalemon, 7 years ago
  • fixed docblock author
    By alphalemon, 7 years ago
  • changed var options visibility to protected
    By alphalemon, 7 years ago
  • updated to work with symfony 2.1
    By alphalemon, 7 years ago
  • Merge pull request #5 from terokaisti/patch-1
    By alphalemon, 7 years ago
  • Update README.md
    By Tero Kaisti, 7 years ago
  • Merge branch 'master' of github.com:alphalemon/ElFinderBundle
    By alphalemon, 7 years ago
  • added missing Process using declaration
    By alphalemon, 7 years ago
  • Valorized the event listener success param, according with the operation result
    By alphalemon, 7 years ago
  • added use directive for Process class
    By alphalemon, 7 years ago
  • Update README.md
    By alphalemon, 7 years ago