1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
templates.php
См. документацию.
1
<?php
2
3
class
CTemplates
4
{
5
public
static
function
GetList
(
$arFilter
=
array
(), $arCurrentValues =
array
(), $template_id =
array
())
6
{
7
if
(!
is_set
(
$arFilter
,
"FOLDER"
))
8
{
9
$arr
=
CTemplates::GetFolderList
();
10
$arFilter
[
"FOLDER"
] = array_keys(
$arr
);
11
}
12
13
$arTemplates =
array
();
14
foreach
(
$arFilter
[
"FOLDER"
] as $folder)
15
{
16
$folder =
_normalizePath
($folder);
17
$arTemplates[$folder] =
array
();
18
$arPath
=
array
(
19
"/bitrix/modules/"
.$folder.
"/install/templates/"
,
20
BX_PERSONAL_ROOT.
"/templates/.default/"
,
21
);
22
23
if
(is_array($template_id))
24
{
25
foreach
($template_id as $v)
26
$arPath
[] = BX_PERSONAL_ROOT.
"/templates/"
.
_normalizePath
($v).
"/"
;
27
}
28
elseif
($template_id <>
''
)
29
{
30
$arPath
[] = BX_PERSONAL_ROOT.
"/templates/"
.
_normalizePath
($template_id).
"/"
;
31
}
32
33
foreach
(
$arPath
as
$path
)
34
CTemplates::__FindTemplates
(
$path
, $arTemplates[$folder], $arCurrentValues, $folder);
35
36
if
(empty($arTemplates[$folder]))
37
{
38
unset($arTemplates[$folder]);
39
}
40
else
41
{
42
$arTemplate
= $arTemplates[$folder];
43
$arTemplateTemp =
array
();
44
$arSeparators =
array
();
45
foreach
(
$arTemplate
as
$k
=>
$val
)
46
if
(
$val
[
"SEPARATOR"
]==
"Y"
)
47
$arSeparators[
$k
] =
$val
;
48
49
foreach
($arSeparators as $sep_id=>$val_sep)
50
{
51
$arTemplateTemp[$sep_id] = $val_sep;
52
reset(
$arTemplate
);
53
while
(list(
$k
,
$val
) = current(
$arTemplate
))
54
{
55
next(
$arTemplate
);
56
57
if
(
$val
===
false
)
58
continue
;
59
60
if
(
$k
==$sep_id)
61
{
62
while
(list(
$k
,
$val
) = current(
$arTemplate
))
63
{
64
next(
$arTemplate
);
65
66
if
(
$val
===
false
)
67
continue
;
68
if
(
$val
[
"SEPARATOR"
]==
"Y"
)
69
break
;
70
if
(
$val
[
"PARENT"
] <>
''
&&
$val
[
"PARENT"
]!=$sep_id)
71
continue
;
72
73
$arTemplateTemp[
$k
] =
$val
;
74
$arTemplate
[
$k
] =
false
;
75
}
76
//continue;
77
}
78
if
(
$val
[
"PARENT"
]==$sep_id)
79
{
80
$arTemplateTemp[
$k
] =
$val
;
81
$arTemplate
[
$k
] =
false
;
82
}
83
}
84
}
85
86
$bW =
true
;
87
foreach
(
$arTemplate
as
$k
=>
$val
)
88
{
89
if
(
$val
===
false
||
$val
[
"SEPARATOR"
] ==
"Y"
)
90
continue
;
91
if
($bW)
92
{
93
if
(!empty($arSeparators))
94
$arTemplateTemp[md5(uniqid(rand(),
true
))] =
array
(
"NAME"
=>
"----------------------------"
,
"SEPARATOR"
=>
"Y"
);
95
$bW =
false
;
96
}
97
$arTemplateTemp[
$k
] =
$val
;
98
$arTemplate
[
$k
] =
false
;
99
}
100
101
$arTemplates[$folder] = $arTemplateTemp;
102
}
103
}
104
return
$arTemplates;
105
}
106
107
public
static
function
GetByID
($id, $arCurrentValues =
array
(),
$templateID
=
array
())
108
{
109
$folder = mb_substr($id, 0, mb_strpos($id,
"/"
));
110
$arRes
=
CTemplates::GetList
(
array
(
"FOLDER"
=>
array
($folder)), $arCurrentValues,
$templateID
);
111
$all_templates =
$arRes
[$folder];
112
if
(
is_set
($all_templates, $id))
113
return
$all_templates[$id];
114
return
false
;
115
}
116
117
public
static
function
__FindTemplates
($root, &$arTemplates, $arCurrentValues=
array
(), $init=
""
)
118
{
119
if
(is_dir(
$_SERVER
[
'DOCUMENT_ROOT'
].$root.$init))
120
{
121
$arTemplateDescription =
array
();
122
if
(file_exists(
$_SERVER
[
'DOCUMENT_ROOT'
].$root.$init.
"/.description.php"
))
123
{
124
include(
$_SERVER
[
'DOCUMENT_ROOT'
].$root.$init.
"/.description.php"
);
125
foreach
($arTemplateDescription as
$path
=>
$desc
)
126
{
127
$desc
[
"REAL_PATH"
] = $root.$init.
"/"
.
$path
;
128
if
(
$desc
[
"PARENT"
] <>
''
)
129
$desc
[
"PARENT"
] = $init.
"/"
.
$desc
[
"PARENT"
];
130
$arTemplates[$init.
"/"
.
$path
] =
$desc
;
131
}
132
}
133
134
if
(
$handle
= @opendir(
$_SERVER
[
"DOCUMENT_ROOT"
].$root.$init))
135
{
136
while
(($file = readdir(
$handle
)) !==
false
)
137
{
138
if
($file ==
"."
|| $file ==
".."
)
continue
;
139
CTemplates::__FindTemplates
($root, $arTemplates, $arCurrentValues, $init.
"/"
.$file);
140
}
141
}
142
}
143
}
144
145
public
static
function
GetFolderList
($template_id =
false
)
146
{
147
$arTemplateFolders =
array
();
148
$arTemplateFoldersSort =
array
();
149
$path
=
"/bitrix/modules"
;
150
if
(
$handle
= @opendir(
$_SERVER
[
"DOCUMENT_ROOT"
].
$path
))
151
{
152
while
(($module_name = readdir(
$handle
)) !==
false
)
153
{
154
if
($module_name ==
"."
|| $module_name ==
".."
)
continue
;
155
if
(is_dir(
$_SERVER
[
"DOCUMENT_ROOT"
].
$path
.
"/"
.$module_name))
156
{
157
$path_mod =
$path
.
"/"
.$module_name.
"/install/templates"
;
158
if
(file_exists(
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod))
159
{
160
if
($handle_mod = @opendir(
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod))
161
{
162
while
(($file_templ = readdir($handle_mod)) !==
false
)
163
{
164
if
($file_templ ==
"."
|| $file_templ ==
".."
|| $file_templ==
"lang"
)
165
continue
;
166
if
(is_dir(
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod.
"/"
.$file_templ))
167
{
168
$sSectionName
=
false
;
169
$iSort = 500;
170
if
(file_exists(
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod.
"/"
.$file_templ.
"/.description.php"
))
171
{
172
if
(file_exists(($fname =
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod.
"/lang/"
.
LangSubst
(LANGUAGE_ID).
"/"
.$module_name.
"/.description.php"
)))
173
__IncludeLang
($fname);
174
if
(LANGUAGE_ID <>
"ru"
&& file_exists(($fname =
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod.
"/lang/"
.LANGUAGE_ID.
"/"
.$module_name.
"/.description.php"
)))
175
__IncludeLang
($fname);
176
include(
$_SERVER
[
"DOCUMENT_ROOT"
].$path_mod.
"/"
.$file_templ.
"/.description.php"
);
177
}
178
if
(
$sSectionName
)
179
{
180
$arTemplateFolders[$module_name] =
$sSectionName
;
181
$arTemplateFoldersSort[$module_name] = $iSort;
182
}
183
}
184
}
185
@closedir($handle_mod);
186
}
187
}
188
}
189
}
190
@closedir(
$handle
);
191
}
192
193
$arPath
=
array
(BX_PERSONAL_ROOT.
"/templates/.default"
);
194
if
($template_id)
195
$arPath
[] = BX_PERSONAL_ROOT.
"/templates/"
.$template_id;
196
197
foreach
(
$arPath
as
$path
)
198
{
199
if
(
$handle
= @opendir(
$_SERVER
[
"DOCUMENT_ROOT"
].
$path
))
200
{
201
while
(($folder_name = readdir(
$handle
)) !==
false
)
202
{
203
if
($folder_name ==
"."
|| $folder_name ==
".."
|| $folder_name==
"lang"
)
204
continue
;
205
if
(is_dir(
$_SERVER
[
"DOCUMENT_ROOT"
].
$path
.
"/"
.$folder_name))
206
{
207
$sSectionName
=
false
;
208
$iSort = 500;
209
if
(file_exists(
$_SERVER
[
"DOCUMENT_ROOT"
].
$path
.
"/"
.$folder_name.
"/.description.php"
))
210
include(
$_SERVER
[
"DOCUMENT_ROOT"
].
$path
.
"/"
.$folder_name.
"/.description.php"
);
211
if
(
$sSectionName
)
212
{
213
$arTemplateFolders[$folder_name] =
$sSectionName
;
214
$arTemplateFoldersSort[$folder_name] = $iSort;
215
}
216
}
217
}
218
@closedir(
$handle
);
219
}
220
}
221
array_multisort($arTemplateFoldersSort, $arTemplateFolders);
222
223
return
$arTemplateFolders;
224
}
225
}
$path
$path
Определения
access_edit.php:21
CTemplates
Определения
templates.php:4
CTemplates\GetFolderList
static GetFolderList($template_id=false)
Определения
templates.php:145
CTemplates\GetList
static GetList($arFilter=array(), $arCurrentValues=array(), $template_id=array())
Определения
templates.php:5
CTemplates\__FindTemplates
static __FindTemplates($root, &$arTemplates, $arCurrentValues=array(), $init="")
Определения
templates.php:117
CTemplates\GetByID
static GetByID($id, $arCurrentValues=array(), $templateID=array())
Определения
templates.php:107
$arTemplate
$arTemplate
Определения
component_props.php:26
$arPath
$arPath
Определения
file_edit.php:72
$arr
$arr
Определения
file_new.php:624
$templateID
$templateID
Определения
file_new.php:121
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$handle
$handle
Определения
include.php:55
$_SERVER
$_SERVER["DOCUMENT_ROOT"]
Определения
cron_frame.php:9
LangSubst
LangSubst($lang)
Определения
tools.php:3854
is_set
is_set($a, $k=false)
Определения
tools.php:2133
_normalizePath
_normalizePath($strPath)
Определения
tools.php:3341
__IncludeLang
__IncludeLang($path, $bReturnArray=false, $bFileChecked=false)
Определения
tools.php:3477
$desc
if(mb_strlen($order)< 6) $desc
Определения
payment.php:44
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$sSectionName
$sSectionName
Определения
.section.php:2
$val
$val
Определения
options.php:1793
$arRes
$arRes
Определения
options.php:104
$k
$k
Определения
template_pdf.php:567
$arFilter
$arFilter
Определения
user_search.php:106
bitrix
modules
main
classes
general
templates.php
Создано системой
1.14.0