1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
langasset.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Web\WebPacker\Resource;
4
5
use Bitrix\Main;
6
use Bitrix\Main\Localization\Loc;
7
13
class
LangAsset
extends
Asset
14
{
15
protected
$type
= self::LANG;
16
protected
$useAllLangs
=
false
;
17
23
public
function
getContent
()
24
{
25
if
(is_array($this->content) && !empty($this->content))
26
{
27
return
[Loc::getCurrentLang() =>
$this->content
];
28
}
29
elseif
($this->
path
)
30
{
31
$languages = $this->
useAllLangs
32
?
self::getLanguages
()
33
: [Loc::getCurrentLang()];
34
35
$result
= [];
36
foreach
($languages as $language)
37
{
38
$messages
= Loc::loadLanguageFile(
39
self::getAbsolutePath($this->
path
),
40
$language
41
);
42
if
(!empty(
$messages
))
43
{
44
$result
[$language] =
$messages
;
45
}
46
}
47
48
return
$result
;
49
}
50
51
return
[];
52
}
53
60
public
function
useAllLangs
($use)
61
{
62
$this->
useAllLangs
= (bool) $use;
63
return
$this;
64
}
65
72
public
static
function
toCamelCase
(
array
$messages
)
73
{
74
foreach
(
$messages
as
$code
=> $value)
75
{
76
unset(
$messages
[
$code
]);
77
$code
= str_replace(
'_'
,
' '
, mb_strtolower(
$code
));
78
$code
= str_replace(
' '
,
''
, ucwords(
$code
));
79
$code
= lcfirst(
$code
);
80
$messages
[
$code
] = $value;
81
}
82
83
return
$messages
;
84
}
85
93
public
static
function
deletePrefixes
(
array
$messages
,
array
$prefixes)
94
{
95
foreach
(
$messages
as
$code
=> $value)
96
{
97
foreach
($prefixes as $prefix)
98
{
99
if
(!str_starts_with(
$code
, $prefix))
100
{
101
continue
;
102
}
103
104
unset(
$messages
[
$code
]);
105
$code
= mb_substr(
$code
, mb_strlen($prefix));
106
$messages
[
$code
] = $value;
107
}
108
}
109
110
return
$messages
;
111
}
112
119
public
static
function
isExists
(
$path
)
120
{
121
return
true
;
122
}
123
124
protected
static
function
getLanguages
()
125
{
126
static
$list =
null
;
127
if
($list !==
null
)
128
{
129
return
$list;
130
}
131
132
$langDir =
Main\Application::getDocumentRoot
() .
'/bitrix/modules/main/lang/'
;
133
$dir
=
new
Main\IO\Directory
($langDir);
134
if
(
$dir
->isExists())
135
{
136
foreach
(
$dir
->getChildren() as $childDir)
137
{
138
if
(!$childDir->isDirectory())
139
{
140
continue
;
141
}
142
143
$list[] = $childDir->getName();
144
}
145
}
146
147
return
$list;
148
}
149
}
Bitrix\Main\Application\getDocumentRoot
static getDocumentRoot()
Определения
application.php:736
Bitrix\Main\IO\Directory
Определения
directory.php:6
Bitrix\Main\Web\WebPacker\Resource\Asset
Определения
asset.php:16
Bitrix\Main\Web\WebPacker\Resource\Asset\$path
$path
Определения
asset.php:25
Bitrix\Main\Web\WebPacker\Resource\Asset\$content
$content
Определения
asset.php:29
Bitrix\Main\Web\WebPacker\Resource\LangAsset
Определения
langasset.php:14
Bitrix\Main\Web\WebPacker\Resource\LangAsset\isExists
static isExists($path)
Определения
langasset.php:119
Bitrix\Main\Web\WebPacker\Resource\LangAsset\getContent
getContent()
Определения
langasset.php:23
Bitrix\Main\Web\WebPacker\Resource\LangAsset\$type
$type
Определения
langasset.php:15
Bitrix\Main\Web\WebPacker\Resource\LangAsset\getLanguages
static getLanguages()
Определения
langasset.php:124
Bitrix\Main\Web\WebPacker\Resource\LangAsset\toCamelCase
static toCamelCase(array $messages)
Определения
langasset.php:72
Bitrix\Main\Web\WebPacker\Resource\LangAsset\$useAllLangs
$useAllLangs
Определения
langasset.php:16
Bitrix\Main\Web\WebPacker\Resource\LangAsset\useAllLangs
useAllLangs($use)
Определения
langasset.php:60
Bitrix\Main\Web\WebPacker\Resource\LangAsset\deletePrefixes
static deletePrefixes(array $messages, array $prefixes)
Определения
langasset.php:93
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$code
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения
options.php:195
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$dir
$dir
Определения
quickway.php:303
$messages
$messages
Определения
template.php:8
path
path
Определения
template_copy.php:201
bitrix
modules
main
lib
web
webpacker
resource
langasset.php
Создано системой
1.14.0