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

  1. Requirements
  2. Set-Up
  3. Usage
  4. Installation
  5. Credit

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/

1 0
2 followers
398 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: Validation
Developed by: Cozumel
Created on: Jul 23, 2013
Last updated: 11 years ago

Downloads

show all

Related Extensions