All Projects → helios-ag → Fmbbcodebundle

helios-ag / Fmbbcodebundle

Licence: other
🔠 BBCode bundle for Symfony projects

Projects that are alternatives of or similar to Fmbbcodebundle

Phone Number Bundle
Integrates libphonenumber into your Symfony2-Symfony4 application
Stars: ✭ 446 (+696.43%)
Mutual labels:  bundle, symfony, symfony-bundle, twig-extension
Twig Bundle
The Twig Bundle provides configuration for using Twig in your applications.
Stars: ✭ 2,150 (+3739.29%)
Mutual labels:  bundle, twig, symfony, symfony-bundle
Twigextensionsbundle
Useful Twig extensions for your Symfony project.
Stars: ✭ 75 (+33.93%)
Mutual labels:  bundle, symfony, symfony-bundle, twig-extension
breadcrumb-bundle
Symfony bundle for easy breadcrumbs management
Stars: ✭ 26 (-53.57%)
Mutual labels:  twig, twig-extension, bundle, symfony-bundle
Web Profiler Bundle
The WebProfilerBundle provides detailed technical information about each request execution and displays it in both the web debug toolbar and the profiler.
Stars: ✭ 1,905 (+3301.79%)
Mutual labels:  bundle, twig, symfony, symfony-bundle
Twig Extra Bundle
The Twig bundle for official extra extensions
Stars: ✭ 389 (+594.64%)
Mutual labels:  twig, symfony, symfony-bundle, twig-extension
Easy Deploy Bundle
The easiest way to deploy your Symfony applications
Stars: ✭ 446 (+696.43%)
Mutual labels:  bundle, symfony, symfony-bundle
Foscommentbundle
Threaded comments for Symfony
Stars: ✭ 451 (+705.36%)
Mutual labels:  bundle, symfony, symfony-bundle
Liipurlautoconverterbundle
[DEPRECATED] This bundle will add a Twig Extension for templates with a new filter for automatically converting urls and emails in a string to html links
Stars: ✭ 53 (-5.36%)
Mutual labels:  bundle, symfony, symfony-bundle
Entityauditbundle
Audit for Doctrine Entities
Stars: ✭ 546 (+875%)
Mutual labels:  bundle, symfony, symfony-bundle
Jwtrefreshtokenbundle
Implements a Refresh Token system over Json Web Tokens in Symfony
Stars: ✭ 425 (+658.93%)
Mutual labels:  bundle, symfony, symfony-bundle
Sensiodistributionbundle
Base bundle for Symfony Distributions
Stars: ✭ 501 (+794.64%)
Mutual labels:  bundle, symfony, symfony-bundle
Ismaambrosigeneratorbundle
Generates Symfony2 documents, forms and CRUD for MongoDB documents
Stars: ✭ 27 (-51.79%)
Mutual labels:  bundle, symfony, symfony-bundle
Beelabrecaptcha2bundle
💻 Symfony bundle for Google Recaptcha2
Stars: ✭ 47 (-16.07%)
Mutual labels:  bundle, symfony, symfony-bundle
Liipmonitorbundle
Integrates the LiipMonitor library into Symfony
Stars: ✭ 445 (+694.64%)
Mutual labels:  bundle, symfony, symfony-bundle
Webfactoryicutranslationbundle
Enables ICU message formatting for translations in Symfony applications.
Stars: ✭ 27 (-51.79%)
Mutual labels:  bundle, symfony, symfony-bundle
Sentry Symfony
The official Symfony SDK for Sentry (sentry.io)
Stars: ✭ 515 (+819.64%)
Mutual labels:  bundle, symfony, symfony-bundle
Knpgaufrettebundle
Easily use Gaufrette in your Symfony projects.
Stars: ✭ 646 (+1053.57%)
Mutual labels:  bundle, symfony, symfony-bundle
Sensiogeneratorbundle
Generates Symfony bundles, entities, forms, CRUD, and more...
Stars: ✭ 634 (+1032.14%)
Mutual labels:  bundle, symfony, symfony-bundle
Sncredisbundle
A Redis bundle for Symfony supporting Predis and PhpRedis
Stars: ✭ 980 (+1650%)
Mutual labels:  bundle, symfony, symfony-bundle

FMBBCodeBundle

PHP-Decoda integration in Symfony2

A lightweight lexical string parser for BBCode styled markup.

Contributors

Code Quality Assurance

SLInsight Travis CI Gitter Coverage StyleCI
SensioLabsInsight Build Status Join the chat at https://gitter.im/helios-ag/FMBbCodeBundle Coverage Status StyleCI
Deps Status Version Downloads
Dependency Status Latest Stable Version Total Downloads

Installation

To install this bundle, you'll need both the Decoda library and this bundle. Installation depends on how your project is setup:

Step 1: Installation

Using Composer, just add the following configuration to your composer.json:

Or you can use composer to install this bundle:

For symfony <3.0, use latest ~6 version

composer require helios-ag/fm-bbcode-bundle:~6

for Symfony 3

composer require helios-ag/fm-bbcode-bundle

or

composer require helios-ag/fm-bbcode-bundle:~7

Step 2: Enable the bundle

Finally, enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FM\BbcodeBundle\FMBbcodeBundle(),
    );
}

Step 3: Dump emoticons (optional)

To enable emoticons via emoticon hook, use the following command to copy emoticons images to public folder (web/emoticons)

    ./app/console bbcode:dump

Basic configuration

Make the Twig extensions available by updating your configuration:

By default only "default" filter enabled, which provide support
for [b], [i], [u], [s], [sub], [sup], [abbr], [br], [hr], [time]
BBCodes

Examples to use the extension in your Twig template

Define BBCode filter in your config.yml:

    fm_bbcode:
      filter_sets:
        my_default_filter:
          strict: false # if you want to parse attr values without quotes
          locale: ru
          xhtml: true
          filters: [ default ]

And you can do the following:

     {{'[b]Bold text[/b]'|bbcode_filter('my_default_filter')}}
     {{'[u]Underlined text[/u]'|bbcode_filter('my_default_filter')}}
     {{'[i]Italic text[/i]'|bbcode_filter('my_default_filter')}}
    fm_bbcode:
      filter_sets:
        my_default_filter:
          locale: ru
          xhtml: true
          filters: [ default, quote ]
          whitelist: [ b, quote ]

After enabling "quote" filter, you can do such things:

      {{'[quote="helios"]My quote[/quote]'|bbcode_filter('my_default_filter')}}

Also you can define multiple filter sets under filter_sets parameter like this:

    fm_bbcode:
      filter_sets:
        my_forum_filter:
          locale: ru
          xhtml: true
          filters: [ default, quote ]
          whitelist: [ b, quote ]
        my_comment_filter:
          locale: ru
          xhtml: true
          filters: [ default, block, code, email, image, list, quote, text, url, video ]
      {{'[quote="helios"]My quote[/quote]'|bbcode_filter('my_forum_filter')}}
      {{'[code]My source code[/code]'|bbcode_filter('my_comment_filter')}}

Please keep in mind, that whitelist tags suppress tags, that applied by filters configuration.

Strip filter

To clear text from any bbcodes use bbcode_clean filter: example:

{{'[b]some text[/b]'|bbcode_clean}}

This filter will eliminate any known to decoda tags

Escaping and line breaks

Escaping and line breaks can be controlled via "escaping" and "line_breaks" parameters under filter configuration. Default configuration for them is 'true'. If you wish to pipeline filters, set escaping to false.

Advanced configuration

Overriding messages

Some templates and hooks, use text strings, that can be translated into different languages, the original file located under decoda/config directory, but content of this file can be overriden with messages option, under messages: node. File should be json formatted.

fm_bbcode:
    config:
      messages: @SomeBundle/Resources/config/messages.json

Adding own templates

Your own templates can be defined at templates node, the example below shows how:

    fm_bbcode:
        config:
          templates:
            - path: @SomeBundle/Resources/views/templates

Template examples can be found inside decoda library

Adding own filter

To enable a custom filter, add it as a regular service in one of your configuration, and tag it with fm_bbcode.decoda.filter:

services:
  acme_demo.decoda.filter.your_filter_name:
    class: Fully\Qualified\Filter\Class\Name
    tags:
      - { name: fm_bbcode.decoda.filter, id: your_filter_name }

Your service must implement the Decoda\Filter interface.

If your service is created by a factory, you MUST correctly set the class parameter for this tag to work correctly.

Adding own hook

To enable a custom hook, add it as a regular service in one of your configuration, and tag it with fm_bbcode.decoda.hook:

services:
  acme_demo.decoda.hook.your_hook_name:
    class: Fully\Qualified\Hook\Class\Name
    tags:
      - { name: fm_bbcode.decoda.hook, id: your_hook_name }

Your service must implement the Decoda\Hook interface.

If your service is created by a factory, you MUST correctly set the class parameter for this tag to work correctly.

Then enable it in your configuration:

    fm_bbcode:
      filter_sets:
        my_default_filter:
          filters: [ default ]
          hooks: [ your_hook_name ]

Customize your own emoticons

Your own emoticons can be defined at emoticon node, the example below shows how:

fm_bbcode:
  emoticon:
    resource: path/to/emoticons.yml
# path/to/emoticons.yml
imports:
  - { resource: path/to/another/emoticons.yml }

emoticons:
  my_emoticon:
    url:   # Default: %fm_bbcode.emoticon.path%/my_emoticon.png
    html:  # Default: <img src="%fm_bbcode.emoticon.path%/my_emoticon.png" alt="" >
    xHtml: # Default: <img src="%fm_bbcode.emoticon.path%/my_emoticon.png" alt="" />
    smilies:
      - ":my_emoticon:"

How to automatically dump emoticons on each deploy

Add the following commands to you projects composer.json:

# composer.json
    "scripts": {
        "post-install-cmd": [
            "FM\\BbcodeBundle\\Composer\\ScriptHandler::installEmoticons"
        ],
        "post-update-cmd": [
            "FM\\BbcodeBundle\\Composer\\ScriptHandler::installEmoticons"
        ]
    }

To customize emoticons assets folders, use path and folder node configuration:

# app/config.yml

fm_bbcode:
  emoticon:
    path:   # Default: /emoticons
    folder: # Default: %kernel.root_dir%/../vendor/mjohnson/decoda/emoticons%
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].