Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
TextWatermark.php
1
<?php
9
namespace
Bitrix\Main\File\Image
;
10
11
use
Bitrix\Main
;
12
13
class
TextWatermark
extends
Watermark
14
{
15
protected
16
$text
,
17
$width
,
18
$font
,
19
$color
,
20
$copyright
=
false
,
21
$padding
= 5;
22
29
public
function
__construct
(
$text
,
$font
,
Color
$color
=
null
)
30
{
31
parent::__construct();
32
33
$this->text =
$text
;
34
$this->font =
$font
;
35
36
if
(
$color
!==
null
)
37
{
38
$this->color =
$color
;
39
}
40
else
41
{
42
$this->color =
new
Color
();
43
}
44
}
45
49
public
function
getText
()
50
{
51
return
($this->copyright? chr(169).
" "
:
""
).$this->text;
52
}
53
57
public
function
getUtfText
()
58
{
59
$text
= $this->
getText
();
60
61
$culture = Main\Context::getCurrent()->getCulture();
62
if
($culture)
63
{
64
$text
= Main\Text\Encoding::convertEncoding(
$text
, $culture->getCharset(),
"UTF-8"
);
65
}
66
67
return
$text
;
68
}
69
74
public
function
setText
(
$text
)
75
{
76
$this->text =
$text
;
77
return
$this;
78
}
79
83
public
function
getWidth
()
84
{
85
return
$this->width
;
86
}
87
92
public
function
setWidth
(
$width
)
93
{
94
$this->width = (int)
$width
;
95
return
$this;
96
}
97
101
public
function
getFont
()
102
{
103
return
$this->font
;
104
}
105
110
public
function
setFont
(
$font
)
111
{
112
$this->font =
$font
;
113
return
$this;
114
}
115
119
public
function
getColor
():
Color
120
{
121
return
$this->color
;
122
}
123
128
public
function
setColor
(
Color
$color
)
129
{
130
$this->color =
$color
;
131
return
$this;
132
}
133
137
public
function
isCopyright
()
138
{
139
return
$this->copyright
;
140
}
141
146
public
function
setCopyright
(
$copyright
)
147
{
148
$this->copyright = (bool)
$copyright
;
149
return
$this;
150
}
151
155
public
function
getRatio
()
156
{
157
if
($this->ratio ===
null
)
158
{
159
if
($this->size == static::SIZE_BIG)
160
{
161
return
7;
162
}
163
if
($this->size == static::SIZE_SMALL)
164
{
165
return
2;
166
}
167
//static::SIZE_MEDIUM
168
return
4;
169
}
170
return
$this->ratio
;
171
}
172
177
public
function
getFontSize
(
$width
)
178
{
179
$length = mb_strlen($this->
getText
());
180
181
$fontSize =
$width
* ($this->
getRatio
() / 100.0);
182
183
if
(($fontSize * $length * 0.7) >
$width
)
184
{
185
$fontSize =
$width
/ ($length * 0.7);
186
}
187
188
return
$fontSize;
189
}
190
}
Bitrix\Main\File\Image\Color
Definition
Color.php:12
Bitrix\Main\File\Image\TextWatermark
Definition
TextWatermark.php:14
Bitrix\Main\File\Image\TextWatermark\setFont
setFont($font)
Definition
TextWatermark.php:110
Bitrix\Main\File\Image\TextWatermark\setCopyright
setCopyright($copyright)
Definition
TextWatermark.php:146
Bitrix\Main\File\Image\TextWatermark\$width
$width
Definition
TextWatermark.php:17
Bitrix\Main\File\Image\TextWatermark\getUtfText
getUtfText()
Definition
TextWatermark.php:57
Bitrix\Main\File\Image\TextWatermark\getRatio
getRatio()
Definition
TextWatermark.php:155
Bitrix\Main\File\Image\TextWatermark\$padding
$padding
Definition
TextWatermark.php:21
Bitrix\Main\File\Image\TextWatermark\isCopyright
isCopyright()
Definition
TextWatermark.php:137
Bitrix\Main\File\Image\TextWatermark\getText
getText()
Definition
TextWatermark.php:49
Bitrix\Main\File\Image\TextWatermark\$copyright
$copyright
Definition
TextWatermark.php:20
Bitrix\Main\File\Image\TextWatermark\$font
$font
Definition
TextWatermark.php:18
Bitrix\Main\File\Image\TextWatermark\getColor
getColor()
Definition
TextWatermark.php:119
Bitrix\Main\File\Image\TextWatermark\$color
$color
Definition
TextWatermark.php:19
Bitrix\Main\File\Image\TextWatermark\getFontSize
getFontSize($width)
Definition
TextWatermark.php:177
Bitrix\Main\File\Image\TextWatermark\setWidth
setWidth($width)
Definition
TextWatermark.php:92
Bitrix\Main\File\Image\TextWatermark\$text
$text
Definition
TextWatermark.php:16
Bitrix\Main\File\Image\TextWatermark\__construct
__construct($text, $font, Color $color=null)
Definition
TextWatermark.php:29
Bitrix\Main\File\Image\TextWatermark\getWidth
getWidth()
Definition
TextWatermark.php:83
Bitrix\Main\File\Image\TextWatermark\setText
setText($text)
Definition
TextWatermark.php:74
Bitrix\Main\File\Image\TextWatermark\setColor
setColor(Color $color)
Definition
TextWatermark.php:128
Bitrix\Main\File\Image\TextWatermark\getFont
getFont()
Definition
TextWatermark.php:101
Bitrix\Main\File\Image\Watermark
Definition
Watermark.php:12
Bitrix\Main\File\Image\Watermark\$ratio
$ratio
Definition
Watermark.php:30
Bitrix\Main\File\Image
Definition
Color.php:9
Bitrix\Main
modules
main
lib
File
Image
TextWatermark.php
Создано системой
1.10.0