Yii 1.1: etextimage

This widget allows you to display the text as an image.
4 followers

This widget allows you to display the text as an image.

Archive does not contain fonts. Place your preferred font in the folder /protected/extensions/ETextImage/fonts

Resources

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/extensions/ETextImage

Usage

0) Place your preferred font in the folder /protected/extensions/ETextImage/fonts

1) Override CController::actions() and register an action of class ETextImageAction with ID 'textImage':

public function actions()
    {
        return array(
            'textImage'=>array(
                'class' => 'application.extensions.ETextImage.ETextImageAction',
            ),
        );
    }

2) In the controller view, insert a widget.

<?php $this->widget('application.extensions.ETextImage.ETextImage',
                        array(
                              'textImage' => "(495)1234567",
                              'fontSize' => 10,
                              'fontFile' => 'tahoma',
                              'transparent'=>false,
                              'foreColor'=>0x2040A0,
                              'backColor'=>0x55FF00,
                             )
                       );
 
$this->widget('application.extensions.ETextImage.ETextImage',
                        array(
                              'textImage' => "Super Puper Paratruper Text",
                              'fontSize' => 8,
                              'fontFile' => 'arial',
                              'transparent'=>true,
                              'foreColor'=>0x2040A0,
                              'backColor'=>0x55FF00,
                             )
                       );
?>

Change Log

March 30, 2010

  • Initial release.

Total 1 comment

#638 report it
Dana at 2010/04/02 01:37pm
Path issues

Very handy!

In the documentation, it would be good to specify the font file type required -- took me a little digging to figure out that I needed to call TTF fonts with the basename of the font and that my font needed to have a lowercase extension on it.

Also, it did not work by default with alternate path routines-- I had to alter the ETextimage.php run method as follows (now it will work no matter what configuration the application uses):

/**
 * Renders the widget.
 */
public function run()
{
    $this->textImage=urlencode(base64_encode($this->textImage));

    $base = $this->getController()->getId().'/'.$this->thisAction;
    $params = array( 'textImage'=>$this->textImage,
                     'fontSize'=>$this->fontSize,
                     'fontFile'=>$this->fontFile,
                     'backColor'=>$this->backColor,
                     'foreColor'=>$this->foreColor,
                     'transparent'=>$this->transparent,
                     'v'=>rand(0,10000)
            );

    echo CHtml::image( Yii::app()->createUrl( $base, $params )   ,'');
}

Leave a comment

Please to leave your comment.

Create extension
Downloads
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: kosenka
  • Category: Others
  • Votes: +1
  • Downloaded: 349 times
  • Created on: Mar 30, 2010
  • Last updated: Mar 30, 2010