Разрешение на - в названии файла
This commit is contained in:
parent
6173eb4892
commit
958033a057
3 changed files with 75 additions and 76 deletions
|
|
@ -7,14 +7,14 @@ class Tools_TemplateImage
|
|||
{
|
||||
static $listfiles = array('jpg' => 'jpeg', 'gif' => 'gif', 'png' => 'png', 'bmp' => 'wbmp');
|
||||
static $listfonts = array(
|
||||
'georgia' => 'georgia.ttf',
|
||||
'georgiabd' => 'georgiab.ttf',
|
||||
'georgiaz' => 'georgiaz.ttf',
|
||||
'times' => 'times.ttf',
|
||||
'timesbd' => 'timesbd.ttf',
|
||||
'arial' => 'arial.ttf',
|
||||
'arialbd' => 'arialbd.ttf',
|
||||
'tahoma' => 'tahoma.ttf',
|
||||
'georgia' => 'georgia.ttf',
|
||||
'georgiabd' => 'georgiab.ttf',
|
||||
'georgiaz' => 'georgiaz.ttf',
|
||||
'times' => 'times.ttf',
|
||||
'timesbd' => 'timesbd.ttf',
|
||||
'arial' => 'arial.ttf',
|
||||
'arialbd' => 'arialbd.ttf',
|
||||
'tahoma' => 'tahoma.ttf',
|
||||
'calibri' => 'calibri.ttf',
|
||||
'calibribd' => 'calibrib.ttf',
|
||||
'calibrii' => 'calibrii.ttf',
|
||||
|
|
@ -59,14 +59,14 @@ class Tools_TemplateImage
|
|||
/**
|
||||
* Путь у шрифтам
|
||||
*/
|
||||
function fontPath($path)
|
||||
function fontPath($path)
|
||||
{
|
||||
assert(is_string($path));
|
||||
|
||||
$this->base = $path;
|
||||
}
|
||||
|
||||
function set($name, $value)
|
||||
|
||||
function set($name, $value)
|
||||
{
|
||||
assert(is_string($name));
|
||||
|
||||
|
|
@ -87,11 +87,11 @@ class Tools_TemplateImage
|
|||
/**
|
||||
* Создает изображение из файла
|
||||
*/
|
||||
function imagefromfile($file)
|
||||
function imagefromfile($file)
|
||||
{
|
||||
assert(is_string($file));
|
||||
|
||||
$suffix = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$suffix = pathinfo($file, PATHINFO_EXTENSION);
|
||||
if (array_key_exists($suffix, self::$listfiles)) {
|
||||
return call_user_func('imagecreatefrom' . self::$listfiles[$suffix], $file);
|
||||
}
|
||||
|
|
@ -99,12 +99,12 @@ class Tools_TemplateImage
|
|||
}
|
||||
|
||||
function getFontFile($name)
|
||||
{
|
||||
{
|
||||
assert(is_string($name));
|
||||
|
||||
if(array_key_exists(strtolower($name), self::$listfonts)) {
|
||||
return $this->base . self::$listfonts[$name];
|
||||
}
|
||||
}
|
||||
return $this->base . 'arial.ttf';
|
||||
}
|
||||
|
||||
|
|
@ -127,23 +127,23 @@ class Tools_TemplateImage
|
|||
$fontfile = $this->getFontFile($value->fontFamily . $this->fontSuffix($value->fontStyle));
|
||||
|
||||
$color = intval(substr($value->color, 1), 16);
|
||||
if ($value->align[0]) {
|
||||
if ($value->align[0]) {
|
||||
$align = Tools_Drawing::ALIGN_LEFT;
|
||||
} elseif ($value->align[2]) {
|
||||
} elseif ($value->align[2]) {
|
||||
$align = Tools_Drawing::ALIGN_RIGHT;
|
||||
} else {
|
||||
$align = Tools_Drawing::ALIGN_CENTER;
|
||||
}
|
||||
|
||||
if ($value->valign[0]) {
|
||||
if ($value->valign[0]) {
|
||||
$valign = Tools_Drawing::ALIGN_TOP;
|
||||
} elseif ($value->valign[1]) {
|
||||
} elseif ($value->valign[1]) {
|
||||
$valign = Tools_Drawing::ALIGN_CENTER;
|
||||
} else {
|
||||
$valign = Tools_Drawing::ALIGN_BOTTOM;
|
||||
}
|
||||
|
||||
Tools_Drawing::imagettftextbox($this->image, $size, 0, $value->left, $value->top, $color, $fontfile, $text,
|
||||
Tools_Drawing::imagettftextbox($this->image, $size, 0, $value->left, $value->top, $color, $fontfile, $text,
|
||||
$value->width, $value->height,
|
||||
$align, $valign);
|
||||
}
|
||||
|
|
@ -158,8 +158,8 @@ class Tools_TemplateImage
|
|||
}
|
||||
|
||||
function setSize($new_width, $new_height)
|
||||
{
|
||||
$width = imagesx($this->image);
|
||||
{
|
||||
$width = imagesx($this->image);
|
||||
$height = imagesy($this->image);
|
||||
if($new_height == false) {
|
||||
$new_height = ceil($height * $new_width / $width);
|
||||
|
|
@ -170,7 +170,7 @@ class Tools_TemplateImage
|
|||
imagecopyresampled($image_p, $this->image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
// imagecopyresized($image_p, $this->image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||
$this->image = $image_p;
|
||||
}
|
||||
}
|
||||
|
||||
function prepare() {
|
||||
if($this->prepare) {
|
||||
|
|
@ -201,4 +201,3 @@ class Tools_TemplateImage
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue