kitpages/file-bundle

FileBundle manages uploads and manipulations of files for the Kitpages CMS Bundle

Installs: 27 703

Dependents: 1

Suggesters: 0

Security: 0

Stars: 8

Watchers: 9

Forks: 3

Open Issues: 0

Language:JavaScript

Type:symfony-bundle

v3.0.7 2017-11-22 16:15 UTC

README

This is an ajax upload system for symfony.

author : Philippe Le Van (@plv)

Installation

hum... as usual...

put the code in vendors/Kitpages/FileBundle

add vendors/ in the app/autoload.php

add the new Bundle in app/appKernel.php

You need to create a table in the database : launch command: php app/console doctrine:schema:update

Add a field file upload in a form

In form Class $builder->add( 'fileId', 'hidden', array( "label" => "File" ) );

In file Twig

<script type="text/javascript" src="{{ asset ("bundles/kitpagesfile/uploadify/jquery.uploadify.min.js") }}"></script>

{% include 'KitpagesFileBundle:Upload:pluginJs.html.twig' ignore missing %}

<form class="standard-form" {{ form_enctype(form) }} method="POST">
    <div id="form">
        {{ form_row(
        form.title
        ) }}
        <div>
            <label>Image</label>
            {{ form_widget(form.file) }}
            {% render 'KitpagesFileBundle:Upload:widget' with {'fieldId': 'form_fileId', 'itemClass': 'AppSiteBundle:Document', 'itemId': form.vars.value.id, parameterList:{'multi': false, 'publishParent': false} } %}
        </div>
        {{ form_widget(form) }}
    </div>
    <input type="submit" value="Save"/>
</form>

Attention fieldId = the attribute ID of input generate by "{{ form_widget(form.fileId) }}" in the form

UPDATE DATABASE IF EXISTS

updates an existing database in version1.2.0

Installation ImagineBundle and kitpagesFileSystemBundle

Step1: add the following entries to the deps in the root of your project file:

[Imagine] git=http://github.com/avalanche123/Imagine.git target=imagine

[KitpagesFileSystemBundle] git=http://github.com/kitpages/KitpagesFileSystemBundle.git target=Kitpages/FileSystemBundle

Step2: Configure the autoloader

Add the following entries to your autoloader:

registerNamespaces(array( // ... 'Imagine' => __DIR__.'/../vendor/imagine/lib', )); Step3: AppKernel.php Add the following entries to your autoloader: $bundles = array( ... new Kitpages\FileSystemBundle\KitpagesFileSystemBundle(), ); Step4: Configuration example ===================== kitpages_file: tmp_dir: %kernel.root_dir%/data/tmp type_list: image: resize: form: 'kit_file.image.resize.form' form_twig: 'KitpagesFileBundle:ActionOnFile:Image/Resize/form.html.twig' handler_form: 'kit_file.image.resize.form.handler' library: 'imagine.gd' kitpages_file_system: file_system_list: kitpagesFile: local: directory_public: %kernel.root_dir%/../web directory_private: %kernel.root_dir% base_url: %base_url% Step5: php bin/vendors update Step6: launch command: php app/console kitFile:updateDatabase Extend entity ============ see entity File create a entity - class Extendentity extends FileBase create a repository - class ExtendentityRepository extends FileBaseRepository { CONST entity = 'AppSiteBundle:Extendentity'; } complete config.yml entity_file_name_list: default : class: Kitpages\FileBundle\Entity\File data_dir_prefix: /default Extendentity : class: App\SiteBundle\Entity\Extendentity data_dir_prefix: /ExtendentityDir