chinaphp 2011-04-19 02:08:32 3791次浏览 1条回复 0 0 0

http://www.yiiframework.com/extension/etextimage/ 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
#638report it00
Path issues
by danaluther	 at 2010/04/02 01:37pm
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 ) ,''); }

没看明白具体怎么用? 请教

您需要登录后才可以回复。登录 | 立即注册