text-field-img Replace Textfield by image to prevent data crawing bot

  1. Requirements
  2. Usage
  3. Resources

Create image text field helping prevent information crawing bot.

Field images should be auto created once in first view time, and be removed when data object updated.

Requirements

php_gd

Usage

attach behavior and call to creating in actionView, and removing in actionUpdate.

/* attach behavior */
public function behaviors() {
    return array(
        'fieldImg' => array(
            'class' => 'FieldImgBehavior',
            'prefix' => 'c',
            'protectFields' => array('address', 'address2', 'tel', 'fax', 'establishment'),
            'imgDir' => Yii::app()->params['companyImgFieldsDir'],
        ),
    );
}

/* base image object handle will be company */
$this->setObjBaseDir( $model->company_id );

/* Company's branches address fields with 'branch' model name */
$branches = Branches::model()->findAllByAttributes(array('company_id' => $model->company_id));
$this->genFieldsImage($branches , 'id', 'branch');
...
/* Company's address field with 'default' model name */
$this->genFieldsImage($model, 'company_id');

....
/* remove */
removeAllImgFields( $model->company_id )

...
/* in view.php */
<!-- address of company -->
<?php echo $this->getFieldImageTag('address', $model->company_id); ?>
<!-- address of branches -->
<?php foreach ($branches as $branch): ?>
     <?php echo $this->getFieldImageTag('address', $branch->id, 'branch');?>
....

Resources

Check the address field.

1 0
6 followers
449 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: Security
Developed by: ngonhan
Created on: Jul 3, 2013
Last updated: 4 years ago

Downloads

show all

Related Extensions