yiidecoda decoda integration

  1. Usage
  2. Examples
  3. Resources
  4. Versions

Decoda is a lightweight class that extracts and parses a custom markup language; based on the concept of BB code. Decoda supports all the basic HTML tags and manages special features for making links and emails auto-clickable, using shorthand emails and links, and finally allowing the user to add their own code tags.

Usage

Download and unpack source into protected/extensions/ folder.

Set component in config

'components'=>array(
	'decoda' => array(
		'class' => 'ext.decoda.YiiDecoda',
		'defaults' => true,
	),

Parsing string

<?php
$string = '[b]BB Code[/b]';
$parsedString = Yii::app()->decoda->parse($string);
echo $parsedString; // <b>BB Code</b>

You can use DecodaValidator or filter for your model

public function rules()
{
    return array(
		// DecodaValidator
        array('content', 'ext.decoda.DecodaValidator', 
          'errorTypes' => array(Decoda::ERROR_NESTING, Decoda::ERROR_SCOPE), 
          'useParsed' => true),
		//filter
		array('content', 'filter', 'filter' => array(Yii::app()->decoda, 'parse')),

Examples

Configuration example with all available properties (values ​​are initialized in the order in which they are listed here)

'components'=>array(
	'decoda' => array(
		'class' => 'ext.decoda.YiiDecoda',
		'vendorPath' => 'ext.decoda.vendors.decoda',
		'defaults' => true,

		'addFilters' => array('Code', 'Default', 'List', 'Quote'),
		'removeFilters' => array('Code', 'Default'),
		'disableFilters' => false,

		'addHooks' => array('Emoticon', 'Clickable'),
		'removeHooks' => array('Censor'),
		'disableHooks' => false,

		'brackets' => array('{', '}'),
		'locale' => 'en-us',
		'shorthandLinks' => true,
		'useXHTML' => false,
		'whitelistTags' => array('code', 'b'),
		'convertWhitespaces' => true,
		'disableParsing' => false,
	),

Resources

Versions

1.1

  • update decoda, version 3.3.1
  • removed "useTextHighlighterForCode" property
  • added "convertWhitespaces" property

1.0

  • initial version
4 0
15 followers
708 downloads
Yii Version: 1.1
License: MIT
Category: Others
Developed by: fantgeass
Created on: Jan 27, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions