2017 © Pedro PelĆ”ez
 

symfony-bundle redactor-bundle

Symfony Redactor WYSIWYG Form Type

image

kraksoft/redactor-bundle

Symfony Redactor WYSIWYG Form Type

  • Monday, September 22, 2014
  • by kraksoft
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,490 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3 % Grown

The README.md

Disclaimer

This is an unlinked fork of https://github.com/AStepanov/RedactorBundle/. True author is Andrey Stepanov, here is only a little bit changed version., (*1)

RedactorBundle

Bundle is destined to add Redactor WYSIWYG editor to your Symfony2 project., (*2)

This bundle does not include original Redactor JavaScript library, for using it you should get it from official website http://imperavi.com/redactor/download/, (*3)

Installation for Symfony 2.1

composer.json

"require": {
    ...
    "kraksoft/redactor-bundle": "dev-master"
    ...
},
"repositories": [
    {
        "url": "https://github.com/AStepanov/RedactorBundle.git",
        "type": "vcs"
    }
],

app/AppKernel.php

<?php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Stp\RedactorBundle\StpRedactorBundle(),
    );
}

run the command, (*4)

php app/console assets:install web

app/config/confug.yml

# Twig Configuration
twig:
    # ...
    form:
        resources:
            - 'StpRedactorBundle:Redactor:fields.html.twig'

To allow uploading files add the following lines to app/config/routing.yml

stp_redactor:
    resource: "@StpRedactorBundle/Controller/"
    type:     annotation
    prefix:   /redactor/

How to configure

RedactorBundle provide opportunity to configure some different options of using (e.g. admin, comments, blog), (*5)

Run the command for check all config options, (*6)

php app/console config:dump-reference stp_redactor

Example:

#app/config/config.yml
stp_redactor:
    admin:
        upload_file:
            dir: "%kernel.root_dir%/../web/uploads/content/files"
            maxSize: 10M
            mimeTypes:
                - image/png
                - image/jpeg
        upload_image:
            dir: "%kernel.root_dir%/../web/uploads/content/images"
            maxSize: 5M
            minWidth: 100
            maxWidth: 900
            minHeight: 300
            maxHeight: 900
        role: [ROLE_ADMIN]
    blog:
        upload_image:
            dir: "%kernel.root_dir%/../web/uploads/blog/images"
        role: [IS_AUTHENTICATED_FULLY]
    comments:
        role: [IS_AUTHENTICATED_ANONYMOUSLY]
        settings:
            lang: en

How to use

Use in Form Type

{# template_with_redactor.html.twig #}

{% block javascripts %}
    {{ parent() }}
    
    <script type="text/javascript" src="/path_to_original_redactor/js/redactor.js"></script>
    <script type="text/javascript" src="{{ asset('bundles/stpredactor/js/script.js') }}"></script>
{% endblock %}

{% block stylesheets %}
    {{ parent() }}
    <link rel="stylesheet" href="/path_to_original_redactor/css/redactor.css" type="text/css" media="screen" />
{% endblock %}
<?php
//BlogPostType.php
namespace Stp\BlogBundle\Form;

use Symfony\Component\Form\FormBuilderInterface,
    Symfony\Component\Form\AbstractType;

class BlogPostType extends AbstractType
{
    /**
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);
        $builder->add('description', 'redactor', array('redactor' => 'blog'));
    }
}

Use in SonataAdminBundle

Create new SonataAdmin layout

{# app/Resources/views/admin_layout.html.twig #}

{% extends 'SonataAdminBundle::standard_layout.html.twig' %}

{% block stylesheets %}
    {{ parent() }}
    <link rel="stylesheet" href="/path_to_original_redactor/css/redactor.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="{{ asset('bundles/stpredactor/css/sonata.css') }}" type="text/css" media="screen" />
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    
    <script type="text/javascript" src="{{ asset('bundles/stpredactor/js/script.js') }}"></script>
{% endblock %}

Set path to you layout

# app/config/config.yml
sonata_admin:
    templates:
        layout: ::admin_layout.html.twig

The Versions

22/09 2014

dev-master

9999999-dev https://github.com/kraksoft/RedactorBundle

Symfony Redactor WYSIWYG Form Type

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Andrey Stepanov

form bundle editor sonata wysiwyg redactor

22/09 2014

1.0.2

1.0.2.0 https://github.com/kraksoft/RedactorBundle

Symfony Redactor WYSIWYG Form Type

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Andrey Stepanov

form bundle editor sonata wysiwyg redactor

22/09 2014

1.0.0

1.0.0.0 https://github.com/kraksoft/RedactorBundle

Symfony Redactor WYSIWYG Form Type

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Andrey Stepanov

form bundle editor sonata wysiwyg redactor

22/09 2014

1.0.1

1.0.1.0 https://github.com/kraksoft/RedactorBundle

Symfony Redactor WYSIWYG Form Type

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

by Andrey Stepanov

form bundle editor sonata wysiwyg redactor