| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare API - Graphical * 4 * This file written by Lars Kneschke <lars@kneschke.de> * 5 * Allows the creation of graphical buttons * 6 * Copyright (C) 2001 Lars Kneschke * 7 * -------------------------------------------------------------------------* 8 * This library is part of the eGroupWare API * 9 * http://www.egroupware.org/api * 10 * ------------------------------------------------------------------------ * 11 * This library is free software; you can redistribute it and/or modify it * 12 * under the terms of the GNU Lesser General Public License as published by * 13 * the Free Software Foundation; either version 2.1 of the License, * 14 * or any later version. * 15 * This library is distributed in the hope that it will be useful, but * 16 * WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 18 * See the GNU Lesser General Public License for more details. * 19 * You should have received a copy of the GNU Lesser General Public License * 20 * along with this library; if not, write to the Free Software Foundation, * 21 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 22 \**************************************************************************/ 23 24 /* $Id: class.graphics.inc.php 16309 2004-08-09 13:20:26Z reinerj $ */ 25 26 class graphics 27 { 28 /* put a valid font here */ 29 var $font="/opt/future-project/src/management-server/ttf/arial.ttf"; 30 31 function createImage($_text, $_fontsize=11) 32 { 33 /* create filename */ 34 $filename = 'button_' . md5($_text) . '.png'; 35 $filename = strtolower($filename); 36 37 /* see if file exists already, we cache it */ 38 if (file_exists(PHPGW_IMAGES_FILEDIR.'/'.$filename)) 39 { 40 return $filename; 41 } 42 43 $size = imagettfbbox($_fontsize,0,$this->font,$_text); 44 $dx = abs($size[2]-$size[0]); 45 $dy = abs($size[5]-$size[3]); 46 $xpad=9; 47 $ypad=9; 48 $im = imagecreate($dx+$xpad,$dy+$ypad); 49 $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF); 50 $black = ImageColorAllocate($im, 0,0,0); 51 $white = ImageColorAllocate($im, 255,255,255); 52 ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black); 53 ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white); 54 ImageTTFText($im, $_fontsize, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), -$black, $this->font, $_text); 55 ImageTTFText($im, $_fontsize, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, -$white, $this->font, $_text); 56 ImagePNG($im,PHPGW_IMAGES_FILEDIR.'/'.$filename); 57 ImageDestroy($im); 58 59 return $filename; 60 } 61 62 function createInputButton($_text, $_name, $_mode='graphic') 63 { 64 if ($_mode == 'graphic' && extension_loaded('gd')) 65 { 66 return '<input type="image" src="/egroupware/phpgwapi/templates/default/images/'.$this->createImage($_text).'" border="0" name="'.$_name.'">'; 67 } 68 else 69 { 70 return '<input type="submit" value="'.$_text.'" name="'.$_name.'">'; 71 } 72 } 73 74 // this function checks, if there is a variable $aaa_x and $aaa_y 75 // if so, it will create a new variable $aaa 76 function parseHTTPPostVars() 77 { 78 // execute only if libgd support is enabled 79 if (!extension_loaded('gd')) 80 { 81 return; 82 } 83 84 global $HTTP_POST_VARS; 85 86 if (is_array($HTTP_POST_VARS)) 87 { 88 while( list($key, $val) = each($HTTP_POST_VARS)) 89 { 90 if (ereg("(.*)_x",$key,$varName) && $HTTP_POST_VARS[$varName[1]."_y"]) 91 { 92 $name = $varName[1]; 93 global $$name; 94 $$name = "content generated by parseHTTPPostVars()"; 95 } 96 } 97 } 98 } 99 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |