1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
element.php
См. документацию.
1
<?php
2
3
$GLOBALS
[
"UF_GALLERY_SIZE"
] =
array
();
4
5
if
(!is_array(
$GLOBALS
[
"PHOTOGALLERY_VARS"
]))
6
{
7
$GLOBALS
[
"PHOTOGALLERY_VARS"
] =
array
(
8
"arSections"
=>
array
(),
9
"arGalleriesID"
=>
array
(),
10
"arGalleries"
=>
array
(),
11
"arIBlock"
=>
array
());
12
}
13
14
class
CPhotogalleryElement
15
{
16
// static $arSections = array();
17
// static $arGalleries = array();
18
// static $arIBlock = array();
19
20
public
static
function
CheckElement
(
$ID
, &$arElement, &$arSection, &$arGallery)
21
{
22
$ID
= doubleval(
$ID
);
23
24
if
(
$ID
<= 0)
25
return
false
;
26
$arSelect =
array
(
27
"ID"
,
28
"IBLOCK_ID"
,
29
"IBLOCK_SECTION_ID"
);
30
$db_res
= CIBlockElement::GetList(
array
(),
array
(
"ID"
=>
$ID
),
false
,
false
, $arSelect);
31
if
(!(
$db_res
&& $arElement =
$db_res
->Fetch()))
32
{
33
return
false
;
34
}
35
elseif
(doubleval($arElement[
"IBLOCK_SECTION_ID"
]) <= 0)
36
{
37
return
false
;
38
}
39
$tmp_db_res = CIBlockElement::GetProperty($arElement[
"IBLOCK_ID"
],
$ID
, $by =
"sort"
,
$order
=
"asc"
,
array
(
"CODE"
=>
"REAL_PICTURE"
));
40
if
($tmp_db_res && $tmp_res = $tmp_db_res->Fetch())
41
{
42
$arElement[
"PROPERTY_REAL_PICTURE_VALUE"
] = $tmp_res[
"VALUE"
];
43
$arElement[
"PROPERTY_REAL_PICTURE_VALUE_ID"
] = $tmp_res[
"PROPERTY_VALUE_ID"
];
44
}
45
46
if
(!
is_set
(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arIBlock"
], $arElement[
"IBLOCK_ID"
]))
47
{
48
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arIBlock"
][$arElement[
"IBLOCK_ID"
]] =
false
;
49
$db_res
= CUserTypeEntity::GetList(
array
($by=>
$order
),
array
(
"ENTITY_ID"
=>
"IBLOCK_"
.$arElement[
"IBLOCK_ID"
].
"_SECTION"
,
"FIELD_NAME"
=>
"UF_GALLERY_SIZE"
));
50
if
(
$db_res
&&
$res
=
$db_res
->Fetch())
51
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arIBlock"
][$arElement[
"IBLOCK_ID"
]] =
true
;
52
}
53
if
(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arIBlock"
][$arElement[
"IBLOCK_ID"
]] ===
false
)
54
{
55
return
false
;
56
}
57
$arElement[
"FILE"
] = CFile::GetFileArray($arElement[
"PROPERTY_REAL_PICTURE_VALUE"
]);
58
if
($arElement[
"FILE"
])
59
$arElement[
"FILE"
][
"FILE_SIZE"
] = doubleval($arElement[
"FILE"
][
"FILE_SIZE"
]);
60
else
61
return
false
;
62
63
if
(empty(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arSections"
][$arElement[
"IBLOCK_SECTION_ID"
]]))
64
{
65
$db_res
= CIBlockSection::GetList(
66
array
(),
67
array
(
"ID"
=> $arElement[
"IBLOCK_SECTION_ID"
]),
68
false
,
69
array
(
"ID"
,
"NAME"
,
"CREATED_BY"
,
"IBLOCK_SECTION_ID"
,
"RIGHT_MARGIN"
,
"LEFT_MARGIN"
));
70
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arSections"
][$arElement[
"IBLOCK_SECTION_ID"
]] =
$db_res
->Fetch();
71
}
72
$arSection =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arSections"
][$arElement[
"IBLOCK_SECTION_ID"
]];
73
74
$iGalleryID = 0;
75
if
(!empty(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleriesID"
][$arSection[
"ID"
]]))
76
{
77
$iGalleryID =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleriesID"
][$arSection[
"ID"
]];
78
}
79
elseif
(!empty(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
]))
80
{
81
foreach
(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
] as $id =>
$val
)
82
{
83
if
(doubleval(
$val
[
"RIGHT_MARGIN"
]) > doubleval($arSection[
"RIGHT_MARGIN"
]) &&
84
doubleval(
$val
[
"LEFT_MARGIN"
]) < doubleval($arSection[
"LEFT_MARGIN"
]))
85
{
86
$iGalleryID =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleriesID"
][$arSection[
"ID"
]] = $id;
87
break
;
88
}
89
}
90
}
91
if
($iGalleryID <= 0)
92
{
93
$arFilter
=
array
(
94
"IBLOCK_ID"
=> $arElement[
"IBLOCK_ID"
],
95
"SECTION_ID"
=> 0);
96
if
(doubleval($arSection[
"IBLOCK_SECTION_ID"
]) > 0)
97
{
98
$arFilter
+=
array
(
99
"!LEFT_MARGIN"
=> $arSection[
"LEFT_MARGIN"
],
100
"!RIGHT_MARGIN"
=> $arSection[
"RIGHT_MARGIN"
],
101
"!ID"
=> $arSection[
"ID"
]);
102
}
103
else
104
{
105
$arFilter
[
"ID"
] = $arSection[
"ID"
];
106
}
107
108
$db_res
= CIBlockSection::GetList(
109
array
(),
110
$arFilter
,
111
false
,
112
array
(
"ID"
,
"NAME"
,
"CREATED_BY"
,
"RIGHT_MARGIN"
,
"LEFT_MARGIN"
,
"UF_GALLERY_SIZE"
,
"UF_GALLERY_RECALC"
));
113
if
(
$db_res
&&
$res
=
$db_res
->Fetch())
114
{
115
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][
$res
[
"ID"
]] =
$res
;
116
$iGalleryID =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleriesID"
][$arSection[
"ID"
]] = intval(
$res
[
"ID"
]);
117
}
118
}
119
$arGallery =
array
();
120
$iGalleryID = intval($iGalleryID);
121
if
($iGalleryID > 0)
122
{
123
if
(empty(
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][$iGalleryID]))
124
{
125
$db_res
= CIBlockSection::GetList(
array
(),
array
(
"ID"
=> $iGalleryID),
false
,
126
array
(
"ID"
,
"NAME"
,
"CREATED_BY"
,
"RIGHT_MARGIN"
,
"LEFT_MARGIN"
,
"UF_GALLERY_SIZE"
,
"UF_GALLERY_RECALC"
));
127
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][$iGalleryID] =
$db_res
->Fetch();
128
}
129
$arGallery =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][$iGalleryID];
130
}
131
return
true
;
132
}
133
134
public
static
function
OnBeforeIBlockElementDelete
(
$ID
)
135
{
136
$ID
= doubleval(
$ID
);
137
if
(
CPhotogalleryElement::CheckElement
(
$ID
, $arElement, $arSection, $arGallery))
138
{
139
$arGallery[
"UF_GALLERY_SIZE"
] = (doubleval($arGallery[
"UF_GALLERY_SIZE"
]) - $arElement[
"FILE"
][
"FILE_SIZE"
]);
140
$GLOBALS
[
"UF_GALLERY_SIZE"
] = ($arGallery[
"UF_GALLERY_SIZE"
] <= 0 ? 0 : $arGallery[
"UF_GALLERY_SIZE"
]);
141
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][$arGallery[
"ID"
]][
"UF_GALLERY_SIZE"
] =
$GLOBALS
[
"UF_GALLERY_SIZE"
];
142
$arFields
=
array
(
143
"IBLOCK_ID"
=> $arElement[
"IBLOCK_ID"
],
144
"UF_GALLERY_SIZE"
=>
$GLOBALS
[
"UF_GALLERY_SIZE"
]);
145
$bs =
new
CIBlockSection;
146
$GLOBALS
[
"USER_FIELD_MANAGER"
]->EditFormAddFields(
"IBLOCK_"
.$arElement[
"IBLOCK_ID"
].
"_SECTION"
,
$arFields
);
147
$res
= $bs->Update($arGallery[
"ID"
],
$arFields
,
false
,
false
);
148
}
149
return
true
;
150
}
151
152
public
static
function
OnRecalcGalleries
(
$ID
, $INDEX)
153
{
154
$ID
= doubleval(
$ID
);
155
156
if
(
CPhotogalleryElement::CheckElement
(
$ID
, $arElement, $arSection, $arGallery))
157
{
158
$arFields
=
array
(
159
"IBLOCK_ID"
=> $arElement[
"IBLOCK_ID"
],
160
"UF_GALLERY_SIZE"
=> $arGallery[
"UF_GALLERY_SIZE"
]);
161
if
(doubleval($arGallery[
"UF_GALLERY_SIZE"
]) > 0 && $arGallery[
"UF_GALLERY_RECALC"
] != $INDEX)
162
{
163
$arGallery[
"UF_GALLERY_SIZE"
] = 0;
164
$GLOBALS
[
"UF_GALLERY_RECALC"
] =
$arFields
[
"UF_GALLERY_RECALC"
] = $INDEX;
165
}
166
$arFields
[
"UF_GALLERY_SIZE"
] =
$GLOBALS
[
"UF_GALLERY_SIZE"
] =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][$arGallery[
"ID"
]][
"UF_GALLERY_SIZE"
] =(doubleval($arGallery[
"UF_GALLERY_SIZE"
]) + $arElement[
"FILE"
][
"FILE_SIZE"
]);
167
$bs =
new
CIBlockSection;
168
$GLOBALS
[
"USER_FIELD_MANAGER"
]->EditFormAddFields(
"IBLOCK_"
.$arElement[
"IBLOCK_ID"
].
"_SECTION"
,
$arFields
);
169
$res
= $bs->Update($arGallery[
"ID"
],
$arFields
,
false
,
false
);
170
}
171
return
true
;
172
}
173
174
public
static
function
OnAfterRecalcGalleries
(
$IBLOCK_ID
, $INDEX)
175
{
176
if
(
$IBLOCK_ID
<= 0)
177
return
false
;
178
$arFilters =
array
(
179
array
(
"IBLOCK_ID"
=>
$IBLOCK_ID
,
"SECTION_ID"
=> 0,
">UF_GALLERY_SIZE"
=> 0,
"!UF_GALLERY_RECALC"
=> $INDEX.
""
),
180
array
(
"IBLOCK_ID"
=>
$IBLOCK_ID
,
"SECTION_ID"
=> 0,
">UF_GALLERY_SIZE"
=> 0,
"UF_GALLERY_RECALC"
=>
false
));
181
$bs =
new
CIBlockSection;
182
foreach
($arFilters as
$arFilter
)
183
{
184
$db_res
= CIBlockSection::GetList(
array
(
"ID"
=>
"ASC"
),
$arFilter
);
185
if
(
$db_res
&&
$res
=
$db_res
->Fetch())
186
{
187
188
do
189
{
190
$arFields
=
array
(
191
"IBLOCK_ID"
=>
$IBLOCK_ID
,
192
"UF_GALLERY_SIZE"
=> 0);
193
$GLOBALS
[
"UF_GALLERY_SIZE"
] = 0;
194
$GLOBALS
[
"USER_FIELD_MANAGER"
]->EditFormAddFields(
"IBLOCK_"
.
$IBLOCK_ID
.
"_SECTION"
,
$arFields
);
195
$bs->Update(
$res
[
"ID"
],
$arFields
,
false
,
false
);
196
}
while
(
$res
=
$db_res
->Fetch());
197
}
198
}
199
}
200
201
public
static
function
OnAfterIBlockElementAdd
(
$res
)
202
{
203
$ID
= doubleval(
$res
[
"ID"
] ??
null
);
204
if
(
CPhotogalleryElement::CheckElement
(
$ID
, $arElement, $arSection, $arGallery))
205
{
206
$GLOBALS
[
"UF_GALLERY_SIZE"
] =
$GLOBALS
[
"PHOTOGALLERY_VARS"
][
"arGalleries"
][$arGallery[
"ID"
]][
"UF_GALLERY_SIZE"
] = (doubleval($arGallery[
"UF_GALLERY_SIZE"
]) + $arElement[
"FILE"
][
"FILE_SIZE"
]);
207
$arFields
=
array
(
208
"IBLOCK_ID"
=> $arElement[
"IBLOCK_ID"
],
209
"UF_GALLERY_SIZE"
=>
$GLOBALS
[
"UF_GALLERY_SIZE"
]);
210
$bs =
new
CIBlockSection;
211
$GLOBALS
[
"USER_FIELD_MANAGER"
]->EditFormAddFields(
"IBLOCK_"
.$arElement[
"IBLOCK_ID"
].
"_SECTION"
,
$arFields
);
212
$res
= $bs->Update($arGallery[
"ID"
],
$arFields
,
false
,
false
);
213
}
214
return
true
;
215
}
216
}
$db_res
$db_res
Определения
options_user_settings.php:8
CPhotogalleryElement
Определения
element.php:15
CPhotogalleryElement\OnBeforeIBlockElementDelete
static OnBeforeIBlockElementDelete($ID)
Определения
element.php:134
CPhotogalleryElement\OnRecalcGalleries
static OnRecalcGalleries($ID, $INDEX)
Определения
element.php:152
CPhotogalleryElement\CheckElement
static CheckElement($ID, &$arElement, &$arSection, &$arGallery)
Определения
element.php:20
CPhotogalleryElement\OnAfterRecalcGalleries
static OnAfterRecalcGalleries($IBLOCK_ID, $INDEX)
Определения
element.php:174
CPhotogalleryElement\OnAfterIBlockElementAdd
static OnAfterIBlockElementAdd($res)
Определения
element.php:201
$arFields
$arFields
Определения
dblapprove.php:5
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$ID
if($ajaxMode) $ID
Определения
get_user.php:27
$IBLOCK_ID
$IBLOCK_ID
Определения
csv_new_run.php:168
is_set
is_set($a, $k=false)
Определения
tools.php:2133
$order
$order
Определения
payment.php:8
$GLOBALS
$GLOBALS["UF_GALLERY_SIZE"]
Определения
element.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$val
$val
Определения
options.php:1793
$GLOBALS
$GLOBALS['_____370096793']
Определения
update_client.php:1
$arFilter
$arFilter
Определения
user_search.php:106
bitrix
modules
photogallery
classes
general
element.php
Создано системой
1.14.0