word-filter

This lets you replace each bad word individually with your own choice, badword1=>replace1, badword2=>replace2 etc
2 followers

Sometimes you need a fine level of control with your bad word filter. Most just swap out all words for ***, but this extension will allow you to specify what each word is replaced with.

This extension is great when you want to have fine control over a few words, but for a fully comprehensive solution I recommend using this extension too.

Requirements

Yii 1.1x

Set-Up

Open WordFilter.php and add in an array of words

$replacements = array( 
            'bad word 1'   => 'replacement 1', 
            'bad word 2' => 'replacement 2', 
            'bad word 3'   => 'replacement 3'
        );

Usage

1) In model rules()

"title" and "comment" - the names of properties in your model.

array('title, comment', 'filter', 'filter'=>array("WordFilter", "replacement")),

2) Like a method

$name = Yii::app()->WordFilter->replacement($name);

Installation

1) Copy this file to /protected/extensions/

2) Add this component in /protected/config/main.php

'components'=>array(
        .........
        'WordFilter' => array(
            'class' => 'ext.WordFilter'
        )
        .........
     ),

Credit

Thanks to the Yii community, I'm glad I can finally give something back.

Based on this extension http://www.yiiframework.com/extension/bad-words-filter/

Be the first person to leave a comment

Please to leave your comment.

Create extension
Downloads