1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
documentbutton.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\UI\Buttons;
4
5
use Bitrix\Main\Loader;
6
use Bitrix\Main\Localization\Loc;
7
use Bitrix\Main\Text;
8
use Bitrix\Main\Web\Json;
9
10
class
DocumentButton
extends
Button
11
{
12
private
array
$documentButtonConfig = [];
13
17
protected
function
getDefaultParameters
():
array
18
{
19
return
[
20
'tag'
=>
Tag::BUTTON
,
21
'color'
=>
Color::LIGHT_BORDER
,
22
'dropdown'
=>
true
,
23
'domId'
=> $this->
getUniqId
(),
24
'text'
=> Loc::getMessage(
'UI_BUTTON_DOCUMENT_TEXT'
),
25
'dataset'
=> [
26
'toolbar-collapsed-icon'
=>
Icon::LIST
,
27
],
28
];
29
}
30
31
protected
function
buildFromArray
(
$params
): void
32
{
33
if
(isset(
$params
[
'documentButtonConfig'
]) && is_array(
$params
[
'documentButtonConfig'
]))
34
{
35
$this->
setDocumentButtonConfig
(
$params
[
'documentButtonConfig'
]);
36
unset(
$params
[
'documentButtonConfig'
]);
37
}
38
parent::buildFromArray(
$params
);
39
if
(!empty(
$params
[
'domId'
]) && is_string(
$params
[
'domId'
]))
40
{
41
$this->setDomId(
$params
[
'domId'
]);
42
}
43
}
44
45
public
function
setDocumentButtonConfig
(
array
$config
): void
46
{
47
$this->documentButtonConfig =
$config
;
48
}
49
50
private
function
getDocumentButtonConfig():
array
51
{
52
return
$this->documentButtonConfig;
53
}
54
55
protected
function
listExtensions
():
array
56
{
57
return
[
58
'documentpreview'
,
59
];
60
}
61
62
protected
function
renderJavascript
(): string
63
{
64
$id
= $this->getDomId();
65
$config
= $this->getDocumentButtonConfig();
66
if
(
$id
===
''
|| empty(
$config
))
67
{
68
return
''
;
69
}
70
71
$id
=
Text\HtmlFilter::encode
(
$id
);
72
$params
= Json::encode(
$config
);
73
74
return
75
<<<JS
76
if
(BX.DocumentGenerator && BX.DocumentGenerator.Button)
77
{
78
const
button =
new
BX.DocumentGenerator.Button(
'$id'
,
$params
);
79
button.init();
80
}
81
else
82
{
83
console.warn(
'BX.DocumentGenerator.Button is not found'
);
84
}
85
JS
86
;
87
}
88
89
public
function
render
($jsInit =
true
): string
90
{
91
if
(!Loader::includeModule(
'documentgenerator'
))
92
{
93
return
''
;
94
}
95
96
return
parent::render(
true
);
97
}
98
99
private
function
setDomId(
string
$id
): void
100
{
101
$this->
getAttributeCollection
()[
'id'
] = $id;
102
}
103
104
private
function
getDomId(): string
105
{
106
return
(
string
)($this->
getAttributeCollection
()[
'id'
] ??
''
);
107
}
108
}
Bitrix\Main\Text\HtmlFilter\encode
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
htmlfilter.php:12
Bitrix\UI\Buttons\BaseButton\getUniqId
getUniqId()
Определения
basebutton.php:297
Bitrix\UI\Buttons\BaseButton\render
render($jsInit=true)
Определения
basebutton.php:176
Bitrix\UI\Buttons\BaseButton\getAttributeCollection
getAttributeCollection()
Определения
basebutton.php:472
Bitrix\UI\Buttons\BaseButton\$id
$id
Определения
basebutton.php:25
Bitrix\UI\Buttons\Button
Определения
button.php:6
Bitrix\UI\Buttons\Color\LIGHT_BORDER
const LIGHT_BORDER
Определения
color.php:17
Bitrix\UI\Buttons\DocumentButton
Определения
documentbutton.php:11
Bitrix\UI\Buttons\DocumentButton\renderJavascript
renderJavascript()
Определения
documentbutton.php:62
Bitrix\UI\Buttons\DocumentButton\buildFromArray
buildFromArray($params)
Определения
documentbutton.php:31
Bitrix\UI\Buttons\DocumentButton\listExtensions
listExtensions()
Определения
documentbutton.php:55
Bitrix\UI\Buttons\DocumentButton\setDocumentButtonConfig
setDocumentButtonConfig(array $config)
Определения
documentbutton.php:45
Bitrix\UI\Buttons\DocumentButton\getDefaultParameters
getDefaultParameters()
Определения
documentbutton.php:17
Bitrix\UI\Buttons\Icon\LIST
const LIST
Определения
icon.php:22
Bitrix\UI\Buttons\Tag\BUTTON
const BUTTON
Определения
tag.php:6
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$config
$config
Определения
quickway.php:69
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
ui
lib
buttons
documentbutton.php
Создано системой
1.14.0