1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
TextWatermark.php
См. документацию.
1
<?php
8
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
Определения
Color.php:12
Bitrix\Main\File\Image\TextWatermark
Определения
TextWatermark.php:14
Bitrix\Main\File\Image\TextWatermark\setFont
setFont($font)
Определения
TextWatermark.php:110
Bitrix\Main\File\Image\TextWatermark\setCopyright
setCopyright($copyright)
Определения
TextWatermark.php:146
Bitrix\Main\File\Image\TextWatermark\$width
$width
Определения
TextWatermark.php:17
Bitrix\Main\File\Image\TextWatermark\getUtfText
getUtfText()
Определения
TextWatermark.php:57
Bitrix\Main\File\Image\TextWatermark\getRatio
getRatio()
Определения
TextWatermark.php:155
Bitrix\Main\File\Image\TextWatermark\$padding
$padding
Определения
TextWatermark.php:21
Bitrix\Main\File\Image\TextWatermark\isCopyright
isCopyright()
Определения
TextWatermark.php:137
Bitrix\Main\File\Image\TextWatermark\getText
getText()
Определения
TextWatermark.php:49
Bitrix\Main\File\Image\TextWatermark\$copyright
$copyright
Определения
TextWatermark.php:20
Bitrix\Main\File\Image\TextWatermark\$font
$font
Определения
TextWatermark.php:18
Bitrix\Main\File\Image\TextWatermark\getColor
getColor()
Определения
TextWatermark.php:119
Bitrix\Main\File\Image\TextWatermark\$color
$color
Определения
TextWatermark.php:19
Bitrix\Main\File\Image\TextWatermark\getFontSize
getFontSize($width)
Определения
TextWatermark.php:177
Bitrix\Main\File\Image\TextWatermark\setWidth
setWidth($width)
Определения
TextWatermark.php:92
Bitrix\Main\File\Image\TextWatermark\$text
$text
Определения
TextWatermark.php:16
Bitrix\Main\File\Image\TextWatermark\__construct
__construct($text, $font, Color $color=null)
Определения
TextWatermark.php:29
Bitrix\Main\File\Image\TextWatermark\getWidth
getWidth()
Определения
TextWatermark.php:83
Bitrix\Main\File\Image\TextWatermark\setText
setText($text)
Определения
TextWatermark.php:74
Bitrix\Main\File\Image\TextWatermark\setColor
setColor(Color $color)
Определения
TextWatermark.php:128
Bitrix\Main\File\Image\TextWatermark\getFont
getFont()
Определения
TextWatermark.php:101
Bitrix\Main\File\Image\Watermark
Определения
Watermark.php:12
Bitrix\Main\File\Image\Watermark\$ratio
$ratio
Определения
Watermark.php:30
Bitrix\Main\Text\Encoding\convertEncoding
static convertEncoding($data, $charsetFrom, $charsetTo)
Определения
encoding.php:17
width
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения
file_new.php:677
color
background color
Определения
file_new.php:745
$culture
$culture
Определения
include.php:61
size
font size
Определения
invoice.php:442
$fontSize
$fontSize
Определения
pdf.php:30
bitrix
modules
main
lib
File
Image
TextWatermark.php
Создано системой
1.14.0