Giter VIP home page Giter VIP logo

elfinderbundle's Introduction

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.

elfinderbundle's People

Contributors

alphalemon avatar franmomu avatar gilles-g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elfinderbundle's Issues

Missing files (js, css etc)

Hi! When I run the assetic:dump command the /bundles/alphalemonelfinder/vendor/ElFinder is still empty and all the files of the plugin (javascript and css files) are missing.

Error. Invalid backend response. Data is empty

Hi,

Everytime I try to load this url : http://[yoursite]/al_showElFinder
I've got this error : Error. Invalid backend response. Data is empty. (nothing is visible on the chrome's console)
I followed step by step your installation guide but it didn't worked for me. Maybe I did something wrong...

Please, can you help me ?

Thanks

Email

I answered your mail but it bounced back from dreamhost, so here is a copy:

which I think it is correct to try to fetch the bundle without that
library, but the result is the same. So I wonder if there is delay from
when the composer is updated on github and if it is, how long is this
delay?

I forced an update of your bundle, so it should be up to date now.
Usually it takes up to 1hour, until we build a github hook to get almost
instant updates..

At last I'd like to ask you if you could you give me a hint how to make
work the composer with the external library, which must be placed inside
Resources/public/vendor/ElFinder?

The right way to do this is to have your bundle require that ElFinder
library, and have the library as well on github. Look at Geocoder for
example which has a bundle and a library, the bundle depends on the
library: http://packagist.org/search/?search_query%5Bquery%5D=geocoder

That way you will have in your project:

  • vendor/alphalemon/elfinder-bundle
  • vendor/alphalemon/elfinder

And both should be autoloadable which means the exact location of it
won't matter.

Now I guess if you want them in Resources/public/ it's probably a JS lib
so I have been saying stupid things. For JS stuff, there is no good
solution yet, and I don't know if there ever will be. Either you copy
the files in your bundle, or you just write down in the instructions
that this library should be dropped somewhere in the public dir.. Or
alternatively you can also have a Sf2 console Command class that
downloads the ElFinder libs in the right place, then you tell people
that after downloading they should run app/console elfinder:download or
something. It's not super nice but allows updates outside of the release
cycle of your bundle at least.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.