mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-17 02:41:02 +01:00
Formatting
This commit is contained in:
parent
375750ea7e
commit
a2c0d12173
@ -23,76 +23,77 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
class graphics
|
class graphics
|
||||||
{
|
|
||||||
// put a valid font here
|
|
||||||
var $font="/opt/future-project/src/management-server/ttf/arial.ttf";
|
|
||||||
|
|
||||||
function createImage($_text, $_fontsize=11)
|
|
||||||
{
|
{
|
||||||
// create filename
|
/* put a valid font here */
|
||||||
$filename="button_".md5($_text).".png";
|
var $font="/opt/future-project/src/management-server/ttf/arial.ttf";
|
||||||
$filename=strtolower($filename);
|
|
||||||
|
|
||||||
// see if file exists already, we cache it
|
|
||||||
if (file_exists(PHPGW_IMAGES_FILEDIR.'/'.$filename)) return $filename;
|
|
||||||
|
|
||||||
$size = imagettfbbox($_fontsize,0,$this->font,$_text);
|
|
||||||
$dx = abs($size[2]-$size[0]);
|
|
||||||
$dy = abs($size[5]-$size[3]);
|
|
||||||
$xpad=9;
|
|
||||||
$ypad=9;
|
|
||||||
$im = imagecreate($dx+$xpad,$dy+$ypad);
|
|
||||||
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
|
|
||||||
$black = ImageColorAllocate($im, 0,0,0);
|
|
||||||
$white = ImageColorAllocate($im, 255,255,255);
|
|
||||||
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
|
|
||||||
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
|
|
||||||
ImageTTFText($im, $_fontsize, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), -$black, $this->font, $_text);
|
|
||||||
ImageTTFText($im, $_fontsize, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, -$white, $this->font, $_text);
|
|
||||||
ImagePNG($im,PHPGW_IMAGES_FILEDIR.'/'.$filename);
|
|
||||||
ImageDestroy($im);
|
|
||||||
|
|
||||||
return $filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createInputButton($_text, $_name, $_mode='graphic')
|
function createImage($_text, $_fontsize=11)
|
||||||
{
|
|
||||||
if ($_mode == 'graphic' && extension_loaded("gd"))
|
|
||||||
{
|
{
|
||||||
return '<input type="image" src="/phpgroupware/phpgwapi/templates/default/images/'.$this->createImage($_text).'" border="0" name="'.$_name.'">';
|
/* create filename */
|
||||||
|
$filename = 'button_' . md5($_text) . '.png';
|
||||||
|
$filename = strtolower($filename);
|
||||||
|
|
||||||
|
/* see if file exists already, we cache it */
|
||||||
|
if (file_exists(PHPGW_IMAGES_FILEDIR.'/'.$filename))
|
||||||
|
{
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
$size = imagettfbbox($_fontsize,0,$this->font,$_text);
|
||||||
|
$dx = abs($size[2]-$size[0]);
|
||||||
|
$dy = abs($size[5]-$size[3]);
|
||||||
|
$xpad=9;
|
||||||
|
$ypad=9;
|
||||||
|
$im = imagecreate($dx+$xpad,$dy+$ypad);
|
||||||
|
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
|
||||||
|
$black = ImageColorAllocate($im, 0,0,0);
|
||||||
|
$white = ImageColorAllocate($im, 255,255,255);
|
||||||
|
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
|
||||||
|
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
|
||||||
|
ImageTTFText($im, $_fontsize, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), -$black, $this->font, $_text);
|
||||||
|
ImageTTFText($im, $_fontsize, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, -$white, $this->font, $_text);
|
||||||
|
ImagePNG($im,PHPGW_IMAGES_FILEDIR.'/'.$filename);
|
||||||
|
ImageDestroy($im);
|
||||||
|
|
||||||
|
return $filename;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
function createInputButton($_text, $_name, $_mode='graphic')
|
||||||
{
|
{
|
||||||
return '<input type="submit" value="'.$_text.'" name="'.$_name.'">';
|
if ($_mode == 'graphic' && extension_loaded('gd'))
|
||||||
|
{
|
||||||
|
return '<input type="image" src="/phpgroupware/phpgwapi/templates/default/images/'.$this->createImage($_text).'" border="0" name="'.$_name.'">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return '<input type="submit" value="'.$_text.'" name="'.$_name.'">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this function checks, if there is a variable $aaa_x and $aaa_y
|
||||||
|
// if so, it will create a new variable $aaa
|
||||||
|
function parseHTTPPostVars()
|
||||||
|
{
|
||||||
|
// execute only if libgd support is enabled
|
||||||
|
if (!extension_loaded('gd'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $HTTP_POST_VARS;
|
||||||
|
|
||||||
|
if (is_array($HTTP_POST_VARS))
|
||||||
|
{
|
||||||
|
while( list($key, $val) = each($HTTP_POST_VARS))
|
||||||
|
{
|
||||||
|
if (ereg("(.*)_x",$key,$varName) && $HTTP_POST_VARS[$varName[1]."_y"])
|
||||||
|
{
|
||||||
|
$name = $varName[1];
|
||||||
|
global $$name;
|
||||||
|
$$name = "content generated by parseHTTPPostVars()";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function checks, if there is a variable $aaa_x and $aaa_y
|
|
||||||
// if so, it will create a new variable $aaa
|
|
||||||
function parseHTTPPostVars()
|
|
||||||
{
|
|
||||||
// execute only if libgd support is enabled
|
|
||||||
if (!extension_loaded("gd")) return;
|
|
||||||
|
|
||||||
global $HTTP_POST_VARS;
|
|
||||||
|
|
||||||
if (is_array($HTTP_POST_VARS))
|
|
||||||
{
|
|
||||||
while( list($key, $val) = each($HTTP_POST_VARS))
|
|
||||||
{
|
|
||||||
if (ereg("(.*)_x",$key,$varName) && $HTTP_POST_VARS[$varName[1]."_y"])
|
|
||||||
{
|
|
||||||
$name = $varName[1];
|
|
||||||
global $$name;
|
|
||||||
$$name = "content generated by parseHTTPPostVars()";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user