Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
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
}
Bitrix\Landing\Connector\Landing
Definition
landing.php:12
Bitrix\Landing\Field\Hidden
Definition
hidden.php:5
Bitrix\Landing\Field
Definition
field.php:5
Bitrix\Landing\File\getFileArray
static getFileArray($fileId)
Definition
file.php:580
Bitrix\Landing\File\getFilePath
static getFilePath($fileId)
Definition
file.php:600
Bitrix\Landing\Hook\Page\Favicon
Definition
favicon.php:13
Bitrix\Landing\Hook\Page\Favicon\getMap
getMap()
Definition
favicon.php:18
Bitrix\Landing\Hook\Page\Favicon\getTitle
getTitle()
Definition
favicon.php:47
Bitrix\Landing\Hook\Page\Favicon\enabledInEditMode
enabledInEditMode()
Definition
favicon.php:56
Bitrix\Landing\Hook\Page\Favicon\enabled
enabled()
Definition
favicon.php:65
Bitrix\Landing\Hook\Page\Favicon\exec
exec()
Definition
favicon.php:79
Bitrix\Landing\Hook\Page
Definition
page.php:7
Bitrix\Landing\Hook\Page\issetCustomExec
issetCustomExec()
Definition
page.php:253
Bitrix\Landing\Hook\Page\execCustom
execCustom()
Definition
page.php:262
Bitrix\Landing\Manager\getUrlFromFile
static getUrlFromFile($file)
Definition
manager.php:1067
Bitrix\Landing\Manager\setPageView
static setPageView(string $marker, string $content, bool $skipTrim=false)
Definition
manager.php:465
Bitrix\Landing\PublicAction\restApplication
static restApplication()
Definition
publicaction.php:540
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Landing\Hook\Page
Definition
b24button.php:2
Bitrix
modules
landing
lib
hook
page
favicon.php
Создано системой
1.10.0