SVN Alba r6216 - in prosistem/alba/trunk/alba/plugins/albaToolsPlugin: . lib lib/helper modules/albaTools/actions modules/albaTools/templates
Author: ftoledo Date: 2009-06-01 18:59:00 -0300 (Mon, 01 Jun 2009) New Revision: 6216 Added: prosistem/alba/trunk/alba/plugins/albaToolsPlugin/lib/ prosistem/alba/trunk/alba/plugins/albaToolsPlugin/lib/helper/ prosistem/alba/trunk/alba/plugins/albaToolsPlugin/lib/helper/AlbaToolsHelper.php prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/templates/indexSuccess.php Modified: prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/actions/actions.class.php Log: nuevo plugin de alba para con un par de herramientas Added: prosistem/alba/trunk/alba/plugins/albaToolsPlugin/lib/helper/AlbaToolsHelper.php =================================================================== --- prosistem/alba/trunk/alba/plugins/albaToolsPlugin/lib/helper/AlbaToolsHelper.php (rev 0) +++ prosistem/alba/trunk/alba/plugins/albaToolsPlugin/lib/helper/AlbaToolsHelper.php 2009-06-01 21:59:00 UTC (rev 6216) @@ -0,0 +1,25 @@ +<?php + +/* + * This file is part of the Alba package. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * AlbaToolsHelper. + * + * @package symfony + * @subpackage helper + * @author Fernando Toledo <[email protected]> + * @version SVN: $Id: NumberHelper.php 7757 2008-03-07 10:55:22Z fabien $ + */ + +function text2img($texto) +{ + if (is_null($texto)){ + return null; + } + return tag('img', array('alt'=> $texto, 'src'=>'albaTools/text2img?texto=' . $texto)); +} Modified: prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/actions/actions.class.php =================================================================== --- prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/actions/actions.class.php 2009-06-01 21:54:47 UTC (rev 6215) +++ prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/actions/actions.class.php 2009-06-01 21:59:00 UTC (rev 6216) @@ -1,13 +1,41 @@ <?php class albaToolsActions extends sfActions { - public function executeConvert() + + /** + * Convierte un texto a imagen + * @param string $texto + */ + public function executeText2img(sfWebRequest $request) { - return $this->renderText("hola"); + //fuente por defecto + $this->font = 2; + //obtengo el texto + $texto = $request->getParameter('texto'); + //seteo el header + $this->setLayout(false); + $this->getResponse()->clearHttpHeaders(); + $this->getResponse()->setContentType("Content-type: image/png"); + + // calculo el alto + $alto = strlen($texto) * imagefontwidth($this->font) + imagefontwidth($this->font); + + $img_handle = imagecreatetruecolor (imagefontheight($this->font), $alto) or die ("Cannot Create image"); + + // ImageColorAllocate (image, red, green, blue) + $back_color = ImageColorAllocate ($img_handle, 255, 255,255 ); + $txt_color = ImageColorAllocate ($img_handle, 0, 0, 0); + ImageFill($img_handle,0,0, $back_color); + ImageStringUp ($img_handle, $this->font, 0,$alto - (imagefontwidth($this->font)/2), $texto, $txt_color); + ImagePng ($img_handle); + ImageDestroy($img_handle); + return sfView::NONE; } + + /* demostracion delas utilidades */ public function executeIndex() { - + } } Added: prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/templates/indexSuccess.php =================================================================== --- prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/templates/indexSuccess.php (rev 0) +++ prosistem/alba/trunk/alba/plugins/albaToolsPlugin/modules/albaTools/templates/indexSuccess.php 2009-06-01 21:59:00 UTC (rev 6216) @@ -0,0 +1,5 @@ +<?php use_helper('AlbaTools')?> +<h1>Herramientas para Alba</h1> + +<p>Imagen vertical</p> +<?php echo text2img('hola')?> \ No newline at end of file
participants (1)
-
commits@pressenter.com.ar