1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
page_template.php
См. документацию.
1<?php
2
4{
5 public static function GetList($arSiteTemplates=array())
6 {
7 global $APPLICATION;
8
9 $arDirs = array("templates/.default/page_templates");
10 foreach($arSiteTemplates as $val)
11 $arDirs[] = "templates/".$val."/page_templates";
12
13 $arFiles = array();
14 foreach($arDirs as $dir)
15 {
16 $path = getLocalPath($dir, BX_PERSONAL_ROOT);
17 if($path === false)
18 continue;
19 $template_dir = $_SERVER["DOCUMENT_ROOT"].$path;
20 if($handle = opendir($template_dir))
21 {
22 while(($file = readdir($handle)) !== false)
23 {
24 if($file == "." || $file == ".." || !is_dir($template_dir."/".$file))
25 continue;
26
27 $template_file = $template_dir."/".$file."/template.php";
28 if(!file_exists($template_file))
29 continue;
30
31 if($APPLICATION->GetFileAccessPermission($path."/".$file."/template.php") < "R")
32 continue;
33
34 $arFiles[$file] = $template_file;
35 }
36 closedir($handle);
37 }
38 }
39
40 $res = array();
41 foreach($arFiles as $file=>$template_file)
42 {
44 $pageTemplate = false;
45 include_once($template_file);
46
47 if(!$pageTemplate || !is_callable(array($pageTemplate, 'GetDescription')))
48 continue;
49
50 $arRes = array(
51 "name"=>$file,
52 "description"=>"",
53 "icon"=>"",
54 "file"=>$file,
55 "sort"=>150,
56 "type"=>"",
57 );
58
59 $arDesc = $pageTemplate->GetDescription();
60
61 if(is_array($arDesc["modules"]))
62 foreach($arDesc["modules"] as $module)
63 if(!IsModuleInstalled($module))
64 continue 2;
65
66 if(is_array($arDesc))
67 {
68 foreach($arDesc as $key=>$val)
69 $arRes[$key] = $val;
70 }
71
72 $res[$file] = $arRes;
73 }
74
75 uasort($res, array('CPageTemplate', '_templ_sort'));
76 return $res;
77 }
78
79 public static function GetDescription()
80 {
81 return array();
82 }
83
84 public static function _templ_sort($a, $b)
85 {
86 if($a["sort"] < $b["sort"])
87 return -1;
88 elseif($a["sort"] > $b["sort"])
89 return 1;
90 else
91 return strcmp($a["name"], $b["name"]);
92 }
93
94 public static function GetTemplate($template, $arSiteTemplates=array())
95 {
96 global $APPLICATION;
97
98 $arDirs = array("templates/.default/page_templates");
99 foreach($arSiteTemplates as $val)
100 $arDirs[] = "templates/".$val."/page_templates";
101
103
104 $sFile = false;
105 foreach($arDirs as $dir)
106 {
107 $path = getLocalPath($dir, BX_PERSONAL_ROOT);
108 if($path === false)
109 continue;
110
111 $template_dir = $_SERVER["DOCUMENT_ROOT"].$path;
112 $template_file = $template_dir."/".$template."/template.php";
113 if(!file_exists($template_file))
114 continue;
115
116 if($APPLICATION->GetFileAccessPermission($path."/".$template."/template.php") < "R")
117 continue;
118
119 $sFile = $template_file;
120 }
121 if($sFile !== false)
122 {
123 $pageTemplate = false;
124 include_once($sFile);
125
126 if(is_object($pageTemplate))
127 return $pageTemplate;
128 }
129 return false;
130 }
131
132 public static function IncludeLangFile($filepath)
133 {
134 $file = basename($filepath);
135 $dir = dirname($filepath);
136
137 $langSubst = LangSubst(LANGUAGE_ID);
138 $fname = $dir."/lang/".$langSubst."/".$file;
140 if(LANGUAGE_ID <> "en" && LANGUAGE_ID <> "ru")
141 {
142 if(file_exists($fname))
143 {
144 __IncludeLang($fname, false, true);
145 }
146 }
147
148 $fname = $dir."/lang/".LANGUAGE_ID."/".$file;
149 $fname = \Bitrix\Main\Localization\Translation::convertLangPath($fname, LANGUAGE_ID);
150 if(file_exists($fname))
151 {
152 __IncludeLang($fname, false, true);
153 }
154 }
155}
$path
Определения access_edit.php:21
global $APPLICATION
Определения include.php:80
static convertLangPath($langFile, $language)
Определения translation.php:267
Определения page_template.php:4
static GetTemplate($template, $arSiteTemplates=array())
Определения page_template.php:94
static _templ_sort($a, $b)
Определения page_template.php:84
static GetDescription()
Определения page_template.php:79
static IncludeLangFile($filepath)
Определения page_template.php:132
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$handle
Определения include.php:55
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
IsModuleInstalled($module_id)
Определения tools.php:5301
LangSubst($lang)
Определения tools.php:3854
getLocalPath($path, $baseFolder="/bitrix")
Определения tools.php:5092
_normalizePath($strPath)
Определения tools.php:3341
__IncludeLang($path, $bReturnArray=false, $bFileChecked=false)
Определения tools.php:3477
$arFiles
Определения options.php:60
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$dir
Определения quickway.php:303
if(empty($signedUserToken)) $key
Определения quickway.php:257
else $a
Определения template.php:137
$val
Определения options.php:1793
$arRes
Определения options.php:104
$arDirs
Определения translate_tools.php:10