1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
favicon.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing\Hook\Page;
3
4
use \Bitrix\Landing\Field;
5
use \Bitrix\Landing\File;
6
use \Bitrix\Landing\Manager;
7
use \Bitrix\Landing\PublicAction;
8
use \Bitrix\Main\Localization\Loc;
9
10
Loc::loadMessages(__FILE__);
11
12
class
Favicon
extends
\Bitrix\Landing\Hook\Page
13
{
18
protected
function
getMap
()
19
{
20
return
array
(
21
'PICTURE'
=>
new
Field
\
Hidden
(
'PICTURE'
,
array
(
22
'title'
=> Loc::getMessage(
'LANDING_HOOK_FI_PICTURE'
),
23
'fetch_data_modification'
=>
function
($value)
24
{
25
if
(PublicAction::restApplication())
26
{
27
if
($value > 0)
28
{
29
$path
=
File::getFilePath
($value);
30
if
(
$path
)
31
{
32
$path
=
Manager::getUrlFromFile
(
$path
);
33
return
$path
;
34
}
35
}
36
}
37
return
$value;
38
}
39
))
40
);
41
}
42
47
public
function
getTitle
()
48
{
49
return
Loc::getMessage(
'LANDING_HOOK_FI_PICTURE'
);
50
}
51
56
public
function
enabledInEditMode
()
57
{
58
return
false
;
59
}
60
65
public
function
enabled
()
66
{
67
if
($this->
issetCustomExec
())
68
{
69
return
true
;
70
}
71
72
return
$this->fields[
'PICTURE'
]->getValue() > 0;
73
}
74
79
public
function
exec
()
80
{
81
if
($this->
execCustom
())
82
{
83
return
;
84
}
85
86
$picture = intval($this->fields[
'PICTURE'
]->getValue());
87
88
if
($picture > 0)
89
{
90
$icons =
"\n"
;
91
// first simple favicons
92
$sizes = [
'16x16'
,
'32x32'
,
'96x96'
];
93
foreach
($sizes as $size)
94
{
95
list($w, $h) = explode(
'x'
, $size);
96
$file = \CFile::resizeImageGet(
97
\
Bitrix
\
Landing
\
File::getFileArray
($picture),
98
array
(
99
'width'
=> $w,
100
'height'
=> $h
101
),
102
BX_RESIZE_IMAGE_EXACT
103
);
104
if
($file)
105
{
106
$srcExplode = explode(
'.'
, $file[
'src'
]);
107
$ext = array_pop($srcExplode);
108
$icons .=
'<link rel="icon" type="image/'
. $ext .
109
'" href="'
. $file[
'src'
] .
'" sizes="'
. $size .
'">'
.
"\n"
;
110
}
111
}
112
// apple icons
113
$sizes =
array
(
'120x120'
,
'180x180'
,
'152x152'
,
'167x167'
);
114
foreach
($sizes as $size)
115
{
116
list($w, $h) = explode(
'x'
, $size);
117
$file = \CFile::resizeImageGet(
118
\
Bitrix
\
Landing
\
File::getFileArray
($picture),
119
array
(
120
'width'
=> $w,
121
'height'
=> $h
122
),
123
BX_RESIZE_IMAGE_EXACT
124
);
125
if
($file)
126
{
127
$icons .=
'<link rel="apple-touch-icon"'
.
128
' href="'
. $file[
'src'
] .
'" sizes="'
. $size .
'">'
.
"\n"
;
129
}
130
}
131
if
($icons)
132
{
133
Manager::setPageView
(
134
'BeforeHeadClose'
,
135
$icons,
136
true
137
);
138
}
139
}
140
}
141
}
$path
$path
Определения
access_edit.php:21
Bitrix\Landing\Field\Hidden
Определения
hidden.php:5
Bitrix\Landing\File\getFileArray
static getFileArray($fileId)
Определения
file.php:580
Bitrix\Landing\File\getFilePath
static getFilePath($fileId)
Определения
file.php:600
Bitrix\Landing\Hook\Page\Favicon
Определения
favicon.php:13
Bitrix\Landing\Hook\Page\Favicon\getMap
getMap()
Определения
favicon.php:18
Bitrix\Landing\Hook\Page\Favicon\getTitle
getTitle()
Определения
favicon.php:47
Bitrix\Landing\Hook\Page\Favicon\enabledInEditMode
enabledInEditMode()
Определения
favicon.php:56
Bitrix\Landing\Hook\Page\Favicon\enabled
enabled()
Определения
favicon.php:65
Bitrix\Landing\Hook\Page\Favicon\exec
exec()
Определения
favicon.php:79
Bitrix\Landing\Hook\Page\issetCustomExec
issetCustomExec()
Определения
page.php:253
Bitrix\Landing\Hook\Page\execCustom
execCustom()
Определения
page.php:262
Bitrix\Landing\Manager\getUrlFromFile
static getUrlFromFile($file)
Определения
manager.php:1082
Bitrix\Landing\Manager\setPageView
static setPageView(string $marker, string $content, bool $skipTrim=false)
Определения
manager.php:470
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
BX_RESIZE_IMAGE_EXACT
const BX_RESIZE_IMAGE_EXACT
Определения
constants.php:12
Bitrix\Landing\Field
Определения
checkbox.php:2
Bitrix\Landing\Hook\Page
Определения
b24button.php:2
Bitrix\Landing
Определения
agent.php:3
Bitrix
bitrix
modules
landing
lib
hook
page
favicon.php
Создано системой
1.14.0