1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
usertypeelement.php
См. документацию.
1<?php
2
6
7Loader::includeModule('iblock');
8
15{
16 private static $iblockIncluded = null;
17
18 public static function getUserTypeDescription()
19 {
20 if(self::isIblockIncluded())
21 {
22 return ElementType::getUserTypeDescription();
23 }
24
25 return [
26 'USER_TYPE_ID' => 'iblock_element',
27 'CLASS_NAME' => 'CUserTypeIBlockElement',
28 'DESCRIPTION' => Loc::getMessage('USER_TYPE_IBEL_DESCRIPTION'),
29 'BASE_TYPE' => 'int',
30 'VIEW_CALLBACK' => array(__CLASS__, 'GetPublicView'),
31 'EDIT_CALLBACK' => array(__CLASS__, 'GetPublicEdit'),
32 ];
33 }
34
35 function prepareSettings($userField)
36 {
37 if(self::isIblockIncluded())
38 {
39 return ElementType::prepareSettings($userField);
40 }
41
42 $height = (int)$userField['SETTINGS']['LIST_HEIGHT'];
43
44 $disp = $userField['SETTINGS']['DISPLAY'];
45 if($disp != 'CHECKBOX' && $disp != 'LIST')
46 {
47 $disp = 'LIST';
48 }
49
50 $iblock_id = (int)$userField['SETTINGS']['IBLOCK_ID'];
51 if($iblock_id <= 0)
52 {
53 $iblock_id = '';
54 }
55
56 $element_id = (int)$userField['SETTINGS']['DEFAULT_VALUE'];
57 if($element_id <= 0)
58 {
59 $element_id = '';
60 }
61
62 $active_filter = ($userField['SETTINGS']['ACTIVE_FILTER'] === 'Y' ? 'Y' : 'N');
63
64 return [
65 'DISPLAY' => $disp,
66 'LIST_HEIGHT' => ($height < 1 ? 1 : $height),
67 'IBLOCK_ID' => $iblock_id,
68 'DEFAULT_VALUE' => $element_id,
69 'ACTIVE_FILTER' => $active_filter,
70 ];
71 }
72
73 function getSettingsHtml($userField, $additionalParameters, $varsFromForm)
74 {
75 if(self::isIblockIncluded())
76 {
77 return ElementType::getSettingsHtml($userField, $additionalParameters, $varsFromForm);
78 }
79
80
81 $result = '';
82
83 if($varsFromForm)
84 {
85 $iblock_id = $GLOBALS[$additionalParameters['NAME']]['IBLOCK_ID'];
86 }
87 elseif(is_array($userField))
88 {
89 $iblock_id = $userField['SETTINGS']['IBLOCK_ID'];
90 }
91 else
92 {
93 $iblock_id = '';
94 }
95
96 $result .= '
97 <tr>
98 <td>' . Loc::getMessage('USER_TYPE_IBEL_DISPLAY') . ':</td>
99 <td>
100 <input type="text" size="6" name="' . $additionalParameters['NAME'] . '[IBLOCK_ID]" value="' . htmlspecialcharsbx($iblock_id) . '">
101 </td>
102 </tr>
103 ';
104
105 if($varsFromForm)
106 {
107 $ACTIVE_FILTER = ($GLOBALS[$additionalParameters['NAME']]['ACTIVE_FILTER'] === 'Y' ? 'Y' : 'N');
108 }
109 elseif(is_array($userField))
110 {
111 $ACTIVE_FILTER = ($userField['SETTINGS']['ACTIVE_FILTER'] === 'Y' ? 'Y' : 'N');
112 }
113 else
114 {
115 $ACTIVE_FILTER = 'N';
116 }
117
118 if($varsFromForm)
119 {
120 $value = $GLOBALS[$additionalParameters['NAME']]['DEFAULT_VALUE'];
121 }
122 elseif(is_array($userField))
123 {
124 $value = $userField['SETTINGS']['DEFAULT_VALUE'];
125 }
126 else
127 {
128 $value = '';
129 }
130
131 $result .= '
132 <tr>
133 <td>' . Loc::getMessage('USER_TYPE_IBEL_DEFAULT_VALUE') . ':</td>
134 <td>
135 <input type="text" size="8" name="' . $additionalParameters['NAME'] . '[DEFAULT_VALUE]" value="' . htmlspecialcharsbx($value) . '">
136 </td>
137 </tr>
138 ';
139
140 if($varsFromForm)
141 {
142 $value = $GLOBALS[$additionalParameters['NAME']]['DISPLAY'];
143 }
144 elseif(is_array($userField))
145 {
146 $value = $userField['SETTINGS']['DISPLAY'];
147 }
148 else
149 {
150 $value = 'LIST';
151 }
152 $result .= '
153 <tr>
154 <td class="adm-detail-valign-top">' . Loc::getMessage('USER_TYPE_ENUM_DISPLAY') . ':</td>
155 <td>
156 <label><input type="radio" name="' . $additionalParameters['NAME'] . '[DISPLAY]" value="LIST" ' . ("LIST" == $value ? 'checked="checked"' : '') . '>' . Loc::getMessage('USER_TYPE_IBEL_LIST') . '</label><br>
157 <label><input type="radio" name="' . $additionalParameters['NAME'] . '[DISPLAY]" value="CHECKBOX" ' . ("CHECKBOX" == $value ? 'checked="checked"' : '') . '>' . Loc::getMessage('USER_TYPE_IBEL_CHECKBOX') . '</label><br>
158 </td>
159 </tr>
160 ';
161
162 if($varsFromForm)
163 {
164 $value = (int)$GLOBALS[$additionalParameters['NAME']]['LIST_HEIGHT'];
165 }
166 elseif(is_array($userField))
167 {
168 $value = (int)$userField['SETTINGS']['LIST_HEIGHT'];
169 }
170 else
171 {
172 $value = 5;
173 }
174 $result .= '
175 <tr>
176 <td>' . Loc::getMessage('USER_TYPE_IBEL_LIST_HEIGHT') . ':</td>
177 <td>
178 <input type="text" name="' . $additionalParameters['NAME'] . '[LIST_HEIGHT]" size="10" value="' . $value . '">
179 </td>
180 </tr>
181 ';
182
183 $result .= '
184 <tr>
185 <td>' . Loc::getMessage('USER_TYPE_IBEL_ACTIVE_FILTER') . ':</td>
186 <td>
187 <input type="checkbox" name="' . $additionalParameters['NAME'] . '[ACTIVE_FILTER]" value="Y" ' . ($ACTIVE_FILTER === 'Y' ? 'checked="checked"' : '') . '>
188 </td>
189 </tr>
190 ';
191
192 return $result;
193 }
194
195 function checkFields($userField, $value)
196 {
197 if(self::isIblockIncluded())
198 {
199 return ElementType::checkFields($userField, $value);
200 }
201 return [];
202 }
203
204 public static function getList($userField)
205 {
206 if(self::isIblockIncluded())
207 {
208 return ElementType::getList($userField);
209 }
210
211 return false;
212 }
213
214 protected static function getEnumList(&$userField, $additionalParameters = array())
215 {
216 if(self::isIblockIncluded())
217 {
218 ElementType::getEnumList($userField, $additionalParameters);
219 }
220
221 return;
222 }
223
224 function onSearchIndex($userField)
225 {
226 if(self::isIblockIncluded())
227 {
228 return ElementType::onSearchIndex($userField);
229 }
230
231 return '';
232 }
233
234 public static function isIblockIncluded(): bool
235 {
236 return Loader::includeModule('iblock');
237 }
238}
239
241{
245 public static function getTreeList($iblockId, $activeFilter = 'N')
246 {
247 $result = false;
248
249 if($iblockId > 0 && Loader::includeModule('iblock'))
250 {
251 $filter = ['IBLOCK_ID' => $iblockId];
252 if($activeFilter === 'Y')
253 {
254 $filter['ACTIVE'] = 'Y';
255 }
256
257 $result = CIBlockElement::GetList(
258 ['NAME' => 'ASC', 'ID' => 'ASC'],
259 $filter,
260 false,
261 false,
262 ['ID', 'NAME']
263 );
264
265 if($result)
266 {
267 $result = new self($result);
268 }
269 }
270
271 return $result;
272 }
273
274 function getNext($textHtmlAuto = true, $useTilda = true)
275 {
276 $result = parent::getNext($textHtmlAuto, $useTilda);
277
278 if($result)
279 {
280 $result['VALUE'] = $result['NAME'];
281 }
282
283 return $result;
284 }
285}
286
288{
289 if(Loader::includeModule('iblock'))
290 {
291 static $iblockElementUrl = [];
292
293 if(isset($iblockElementUrl[$id]))
294 {
295 return $iblockElementUrl[$id];
296 }
297
298 $elements = CIBlockElement::getList([], ['=ID' => $id], false, false, ['DETAIL_PAGE_URL']);
299 $ar = $elements->GetNext();
300
301 return ($iblockElementUrl[$id] = $ar['DETAIL_PAGE_URL']);
302 }
303
304 return false;
305}
Определения loader.php:13
$result
Определения dbresult.php:16
Определения dbresult.php:88
static getTreeList($iblockId, $activeFilter='N')
Определения usertypeelement.php:245
getNext($textHtmlAuto=true, $useTilda=true)
Определения usertypeelement.php:274
Определения usertypeenum.php:18
static getUserTypeDescription()
Определения usertypeelement.php:18
static getList($userField)
Определения usertypeelement.php:204
getSettingsHtml($userField, $additionalParameters, $varsFromForm)
Определения usertypeelement.php:73
static getEnumList(&$userField, $additionalParameters=array())
Определения usertypeelement.php:214
onSearchIndex($userField)
Определения usertypeelement.php:224
static isIblockIncluded()
Определения usertypeelement.php:234
prepareSettings($userField)
Определения usertypeelement.php:35
checkFields($userField, $value)
Определения usertypeelement.php:195
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$iblockId
Определения iblock_catalog_edit.php:30
$filter
Определения iblock_catalog_list.php:54
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
$GLOBALS['_____370096793']
Определения update_client.php:1
getIblockElementLinkById($id)
Определения usertypeelement.php:287