1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
schema.php
См. документацию.
1
<?php
2
3
class
CPerfomanceSchema
4
{
5
public
$data_relations
=
null
;
6
public
$data_actions
=
null
;
7
public
$data_attributes
=
null
;
8
9
public
function
addModuleSchema
(
array
$arModuleSchema)
10
{
11
foreach
($arModuleSchema as
$module_id
=> $arModuleTables)
12
{
13
if
(!array_key_exists(
$module_id
, $this->data_relations))
14
{
15
$this->data_relations[
$module_id
] = [];
16
}
17
18
foreach
($arModuleTables as $parent_table_name => $arParentColumns)
19
{
20
if
(!array_key_exists($parent_table_name, $this->data_relations[
$module_id
]))
21
{
22
$this->data_relations[
$module_id
][$parent_table_name] = [];
23
}
24
25
foreach
($arParentColumns as $parent_column => $arChildren)
26
{
27
if
($parent_column ===
'~actions'
)
28
{
29
if
(!array_key_exists(
$module_id
, $this->data_actions))
30
{
31
$this->data_actions[
$module_id
] = [];
32
}
33
if
(!array_key_exists($parent_table_name, $this->data_actions[
$module_id
]))
34
{
35
$this->data_actions[
$module_id
][$parent_table_name] = [];
36
}
37
$this->data_actions[
$module_id
][$parent_table_name] = array_merge(
38
$this->data_actions[
$module_id
][$parent_table_name],
39
$arChildren
40
);
41
}
42
else
43
{
44
if
(!array_key_exists($parent_column, $this->data_relations[
$module_id
][$parent_table_name]))
45
{
46
$this->data_relations[
$module_id
][$parent_table_name][$parent_column] = [];
47
}
48
49
foreach
($arChildren as $child_table_name => $child_column)
50
{
51
if
(preg_match(
'#^~(.+)$#'
, $child_table_name, $m))
52
{
53
$this->data_attributes[
$module_id
][$parent_table_name][$parent_column][$m[1]] = $child_column;
54
}
55
else
56
{
57
$this->data_relations[
$module_id
][$parent_table_name][$parent_column][$child_table_name] = $child_column;
58
}
59
}
60
}
61
}
62
}
63
}
64
}
65
66
public
function
Init
()
67
{
68
if
(!isset($this->data_relations))
69
{
70
$this->data_relations = [];
71
$this->data_actions = [];
72
$this->data_attributes = [];
73
foreach
(
GetModuleEvents
(
'perfmon'
,
'OnGetTableSchema'
,
true
) as $arEvent)
74
{
75
$arModuleSchema =
ExecuteModuleEventEx
($arEvent);
76
if
(is_array($arModuleSchema))
77
{
78
$this->
addModuleSchema
($arModuleSchema);
79
}
80
}
81
}
82
}
83
84
public
function
GetAttributes
($table_name)
85
{
86
$this->
Init
();
87
foreach
($this->data_attributes as $arModuleTables)
88
{
89
if
(isset($arModuleTables[$table_name]))
90
{
91
return
$arModuleTables[$table_name];
92
}
93
}
94
return
[];
95
}
96
97
public
function
GetRowActions
($table_name)
98
{
99
$this->
Init
();
100
foreach
($this->data_actions as $arModuleTables)
101
{
102
if
(isset($arModuleTables[$table_name]))
103
{
104
return
$arModuleTables[$table_name];
105
}
106
}
107
return
[];
108
}
109
110
public
function
GetChildren
($table_name)
111
{
112
$this->
Init
();
113
$result
= [];
114
foreach
($this->data_relations as $arModuleTables)
115
{
116
if
(array_key_exists($table_name, $arModuleTables))
117
{
118
$key
= $table_name;
119
}
120
elseif
(array_key_exists(mb_strtolower($table_name), $arModuleTables))
121
{
122
$key
= mb_strtolower($table_name);
123
}
124
elseif
(array_key_exists(mb_strtoupper($table_name), $arModuleTables))
125
{
126
$key
= mb_strtoupper($table_name);
127
}
128
else
129
{
130
$key
=
''
;
131
}
132
133
if
(
$key
)
134
{
135
foreach
($arModuleTables[
$key
] as $parent_column => $arChildren)
136
{
137
foreach
($arChildren as $child_table_name => $child_column)
138
{
139
$result
[] = [
140
'PARENT_COLUMN'
=> $parent_column,
141
'CHILD_TABLE'
=> trim($child_table_name,
'^'
),
142
'CHILD_COLUMN'
=> $child_column,
143
];
144
}
145
}
146
}
147
}
148
149
uasort(
$result
, [
'CPerfomanceSchema'
,
'_sort'
]);
150
return
$result
;
151
}
152
153
public
function
GetParents
($table_name)
154
{
155
$this->
Init
();
156
$result
= [];
157
foreach
($this->data_relations as $arModuleTables)
158
{
159
foreach
($arModuleTables as $parent_table_name => $arParentColumns)
160
{
161
foreach
($arParentColumns as $parent_column => $arChildren)
162
{
163
foreach
($arChildren as $child_table_name => $child_column)
164
{
165
$child_table_name = trim($child_table_name,
'^'
);
166
if
(
167
$child_table_name === $table_name
168
|| $child_table_name === mb_strtolower($table_name)
169
|| $child_table_name === mb_strtoupper($table_name)
170
)
171
{
172
$result
[$child_column] = [
173
'PARENT_TABLE'
=> $parent_table_name,
174
'PARENT_COLUMN'
=> $parent_column,
175
];
176
}
177
}
178
}
179
}
180
}
181
182
uasort(
$result
, [
'CPerfomanceSchema'
,
'_sort'
]);
183
return
$result
;
184
}
185
186
private
function
_sort(
$a
, $b)
187
{
188
if
(isset(
$a
[
'CHILD_TABLE'
]))
189
{
190
return
strcmp(
$a
[
'CHILD_TABLE'
], $b[
'CHILD_TABLE'
]);
191
}
192
else
193
{
194
return
strcmp(
$a
[
'PARENT_TABLE'
], $b[
'PARENT_TABLE'
]);
195
}
196
}
197
}
$module_id
$module_id
Определения
options.php:6
CPerfomanceSchema
Определения
schema.php:4
CPerfomanceSchema\addModuleSchema
addModuleSchema(array $arModuleSchema)
Определения
schema.php:9
CPerfomanceSchema\$data_actions
$data_actions
Определения
schema.php:6
CPerfomanceSchema\$data_attributes
$data_attributes
Определения
schema.php:7
CPerfomanceSchema\GetParents
GetParents($table_name)
Определения
schema.php:153
CPerfomanceSchema\Init
Init()
Определения
schema.php:66
CPerfomanceSchema\GetRowActions
GetRowActions($table_name)
Определения
schema.php:97
CPerfomanceSchema\$data_relations
$data_relations
Определения
schema.php:5
CPerfomanceSchema\GetChildren
GetChildren($table_name)
Определения
schema.php:110
CPerfomanceSchema\GetAttributes
GetAttributes($table_name)
Определения
schema.php:84
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
ExecuteModuleEventEx
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения
tools.php:5214
GetModuleEvents
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения
tools.php:5177
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$a
else $a
Определения
template.php:137
bitrix
modules
perfmon
classes
general
schema.php
Создано системой
1.14.0