1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
properties.php
См. документацию.
1<?php
2
4
6
7$GLOBALS['YANDEX_MAP_PROPERTY'] = array();
8
10{
11 protected const VALUE_SEPARATOR = ',';
12 abstract public static function GetUserTypeDescription();
13
14 abstract public static function GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName);
15
16 public static function GetAdminListViewHTML($arProperty, $value, $strHTMLControlName)
17 {
18 return $value['VALUE'] ?? null;
19 }
20
21 abstract public static function GetPublicViewHTML($arProperty, $value, $strHTMLControlName);
22
23 public static function ConvertFromDB($arProperty, $value)
24 {
25 $arResult = ['VALUE' => ''];
26
27 $value['VALUE'] ??= null;
28 if (!is_string($value['VALUE']))
29 {
30 $value['VALUE'] = '';
31 }
32 if ($value['VALUE'] !== '')
33 {
34 $arCoords = explode(self::VALUE_SEPARATOR, $value['VALUE'], 2);
35
36 $lat = (float)($arCoords[0] ?? 0);
37 $lng = (float)($arCoords[1] ?? 0);
38
39 if ($lat && $lng)
40 {
41 $arResult['VALUE'] = $lat . self::VALUE_SEPARATOR . $lng;
42 }
43 }
44
45 return $arResult;
46 }
47
48 public static function ConvertToDB($arProperty, $value)
49 {
50 $arResult = ['VALUE' => ''];
51
52 $value['VALUE'] ??= null;
53 if (!is_string($value['VALUE']))
54 {
55 $value['VALUE'] = '';
56 }
57 if ($value['VALUE'] !== '')
58 {
59 $arCoords = explode(self::VALUE_SEPARATOR, $value['VALUE'], 2);
60
61 $lat = (float)($arCoords[0] ?? 0);
62 $lng = (float)($arCoords[1] ?? 0);
63
64 if ($lat && $lng)
65 {
66 $arResult['VALUE'] = $lat . self::VALUE_SEPARATOR . $lng;
67 }
68 }
69
70 return $arResult;
71 }
72
73 public static function _GetMapKey($map_type, &$strDomain)
74 {
75 $MAP_KEY = '';
76 $strMapKeys = COPtion::GetOptionString('fileman', 'map_'.$map_type.'_keys');
77
78 $strDomain = $_SERVER['HTTP_HOST'];
79 $wwwPos = mb_strpos($strDomain, 'www.');
80 if ($wwwPos === 0)
81 $strDomain = mb_substr($strDomain, 4);
82
83 if ($strMapKeys)
84 {
85 $arMapKeys = unserialize($strMapKeys, ['allowed_classes' => false]);
86
87 if (array_key_exists($strDomain, $arMapKeys))
88 $MAP_KEY = $arMapKeys[$strDomain];
89 }
90
91 return $MAP_KEY;
92 }
93}
94
96{
97 public static function GetUserTypeDescription()
98 {
99 return array(
100 "PROPERTY_TYPE" => "S",
101 "USER_TYPE" => "map_google",
102 "DESCRIPTION" => GetMessage("IBLOCK_PROP_MAP_GOOGLE"),
103 "GetPropertyFieldHtml" => array(__CLASS__,"GetPropertyFieldHtml"),
104 "GetPublicViewHTML" => array(__CLASS__,"GetPublicViewHTML"),
105 "ConvertToDB" => array(__CLASS__,"ConvertToDB"),
106 "ConvertFromDB" => array(__CLASS__,"ConvertFromDB"),
107 "GetSettingsHTML" => array(__CLASS__, "GetSettingsHTML"),
108 "PrepareSettings" => array(__CLASS__, "PrepareSettings"),
109 'GetUIEntityEditorProperty' => array(__CLASS__, 'GetUIEntityEditorProperty'),
110 'GetUIEntityEditorPropertyEditHtml' => array(__CLASS__, 'GetUIEntityEditorPropertyEditHtml'),
111 'GetUIEntityEditorPropertyViewHtml' => array(__CLASS__, 'GetUIEntityEditorPropertyViewHtml'),
112 );
113 }
114
115 public static function GetSettingsHTML($arProperty, $strHTMLControlName, &$arPropertyFields)
116 {
117 $arPropertyFields = array(
118 'HIDE' => array('ROW_COUNT', 'COL_COUNT', 'SMART_FILTER', 'FILTRABLE', 'SEARCHABLE', 'WITH_DESCRIPTION'),
119 'SET' => array('SMART_FILTER' => 'N', 'FILTRABLE' => 'N', 'SEARCHABLE' => 'N')
120 );
121
123 $settings = $settings['USER_TYPE_SETTINGS'];
124 $apiKey = isset($settings['API_KEY']) ? htmlspecialcharsbx($settings['API_KEY']) : '';
125
126 return '
127 <tr>
128 <td>'.GetMessage('IBLOCK_PROP_G_MAP_API_KEY').':</td>
129 <td>
130 <input name="'.$strHTMLControlName['NAME'].'[API_KEY]" value="'.$apiKey.'">
131 </td>
132 </tr>';
133 }
134
135 public static function PrepareSettings($arProperty)
136 {
137 $arProperty['SMART_FILTER'] = 'N';
138 $arProperty['FILTRABLE'] = 'N';
139 $arProperty['SEARCHABLE'] = 'N';
140 $arProperty['USER_TYPE_SETTINGS'] = array(
141 'API_KEY' => isset($arProperty['USER_TYPE_SETTINGS']['API_KEY']) ? $arProperty['USER_TYPE_SETTINGS']['API_KEY'] : ''
142 );
143 return $arProperty;
144 }
145
146 public static function GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
147 {
148 global $APPLICATION;
149
150 static $googleMapLastNumber = 0;
151 static $googleMapID = '';
152
153 if (($arProperty['MULTIPLE'] == 'Y' && $googleMapID !== $arProperty['ID']) || $arProperty['MULTIPLE'] == 'N')
154 $googleMapLastNumber = 0;
155
156 if ($arProperty['MULTIPLE'] == 'Y')
157 $googleMapID = $arProperty['ID'];
158
159 $apiKey = isset($arProperty['USER_TYPE_SETTINGS']['API_KEY']) ? $arProperty['USER_TYPE_SETTINGS']['API_KEY'] : '';
160
161 $value['VALUE'] ??= null;
162 if ($strHTMLControlName["MODE"] != "FORM_FILL")
163 return '<input type="text" name="'.htmlspecialcharsbx($strHTMLControlName['VALUE']).'" value="'.htmlspecialcharsbx($value['VALUE']).'" />';
164
165 if ($value['VALUE'] <> '')
166 {
167 list($POINT_LAT, $POINT_LON) = explode(',', $value['VALUE'], 2);
168 $bHasValue = true;
169 }
170 else
171 {
172 $POINT_LAT = doubleval(GetMessage('IBLOCK_PROP_MAP_GOOGLE_INIT_LAT'));
173 $POINT_LON = doubleval(GetMessage('IBLOCK_PROP_MAP_GOOGLE_INIT_LON'));
174 $bHasValue = false;
175 }
176
177 ob_start();
178
179 if ($arProperty['MULTIPLE'] == 'Y' && isset($GLOBALS['GOOGLE_MAP_PROPERTY'][$arProperty['ID']]))
180 {
181 // property is multimple and map is already showed
182
183 $MAP_ID = $GLOBALS['GOOGLE_MAP_PROPERTY'][$arProperty['ID']];
184 }
185 else
186 {
187 $MAP_ID = 'map_google_'.$arProperty['CODE'].$arProperty['ID'];
188 $GLOBALS['GOOGLE_MAP_PROPERTY'][$arProperty['ID']] = $MAP_ID;
189
190?>
191<div id="bx_map_hint_<?echo $MAP_ID?>" style="display: none;">
192 <div id="bx_map_hint_value_<?echo $MAP_ID?>" style="display: <?echo $bHasValue ? 'block' : 'none'?>;">
193<?
194 echo GetMessage('IBLOCK_PROP_MAP_GOOGLE_INSTR_VALUE').'<br /><br />';
195?>
196 </div>
197 <div id="bx_map_hint_novalue_<?echo $MAP_ID?>" style="display: <?echo $bHasValue ? 'none' : 'block'?>;">
198<?
199 echo GetMessage('IBLOCK_PROP_MAP_GOOGLE_INSTR').'<br /><br />';
200?>
201 </div>
202</div>
203<?
204 $APPLICATION->IncludeComponent(
205 'bitrix:map.google.system',
206 '',
207 array(
208 'INIT_MAP_TYPE' => 'NORMAL',
209 'INIT_MAP_LON' => $POINT_LON ? $POINT_LON : 37.64,
210 'INIT_MAP_LAT' => $POINT_LAT ? $POINT_LAT : 55.76,
211 'INIT_MAP_SCALE' => 10,
212 'OPTIONS' => array('ENABLE_SCROLL_ZOOM', 'ENABLE_DRAGGING'),
213 'CONTROLS' => array('LARGE_MAP_CONTROL', 'HTYPECONTROL', 'MINIMAP', 'SCALELINE', 'SMALL_ZOOM_CONTROL'),
214 'MAP_WIDTH' => '95%',
215 'MAP_HEIGHT' => 400,
216 'MAP_ID' => $MAP_ID,
217 'DEV_MODE' => 'Y',
218 'API_KEY' => $apiKey
219 ),
220 false, array('HIDE_ICONS' => 'Y')
221 );
222
223//http://jabber.bx/view.php?id=17908
224?>
225<script>
226 BX.ready(function(){
227 var tabArea = BX.findParent(BX("BX_GMAP_<?=$MAP_ID?>"), {className: "adm-detail-content"});
228 if (tabArea && tabArea.id)
229 {
230 var tabButton = BX("tab_cont_" + tabArea.id);
231 BX.bind(tabButton, "click", function() { BXMapGoogleAfterShow("<?=$MAP_ID?>"); });
232 }
233 });
234
235 <?if($arProperty['MULTIPLE'] == 'N'):?>
236 function setPointValue_<?echo $MAP_ID?>(obPoint)
237 {
238 if (null == window.obPoint_<?echo $MAP_ID?>__n0_)
239 {
240 window.obPoint_<?echo $MAP_ID?>__n0_ = new google.maps.Marker({
241 position: obPoint.latLng,
242 map: window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'],
243 draggable:true
244 });
245
246 google.maps.event.addListener(window.obPoint_<?echo $MAP_ID?>__n0_, "dragend", updatePointPosition_<?echo $MAP_ID?>__n0_);
247 }
248 else
249 {
250 window.obPoint_<?echo $MAP_ID?>__n0_.setPosition(obPoint.latLng);
251 }
252
253 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
254 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
255 BX('point_control_<?echo $MAP_ID?>__n0_').style.display = 'inline-block';
256
257 updatePointPosition_<?echo $MAP_ID?>__n0_(obPoint);
258 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(obPoint_<?echo $MAP_ID?>__n0_.getPosition());
259 }
260 <?else:?>
261 function setPointValue_<?echo $MAP_ID?>(obPoint)
262 {
263 var i = 0, point = [], k = [];
264 while (BX('point_<?echo $MAP_ID?>__n' + i + '_lat'))
265 {
266 if(BX('point_<?echo $MAP_ID?>__n' + i + '_lat').value == ''
267 && BX('point_<?echo $MAP_ID?>__n' + i + '_lon')
268 && BX('point_<?echo $MAP_ID?>__n' + i + '_lon').value == '')
269 {
270 k.push(i);
271 }
272 i++;
273 }
274 if (k.length <= 1)
275 {
276 window.addNewRow(BX('point_<?echo $MAP_ID?>__n0_lat').parentNode.parentNode.parentNode.parentNode.id);
277 }
278 k = (k.length) ? Math.min.apply(null, k) : i;
279 var obPnt = 'obPoint_<?echo $MAP_ID?>__n'+k+'_',
280 updPP = 'updatePointPosition_<?echo $MAP_ID?>__n'+k+'_';
281 if(window[updPP])
282 {
283 window[obPnt] = null;
284
285 window[obPnt] = new google.maps.Marker({
286 position: obPoint.latLng,
287 map: window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'],
288 draggable:true
289 });
290 google.maps.event.addListener(window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_, "dragend", updatePointPosition_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_);
291 window[updPP](obPoint);
292 }
293
294 BX('point_control_<?echo $MAP_ID?>__n'+k+'_').style.display = 'inline-block';
295
296 updateMapHint_<?echo $MAP_ID?>();
297 }
298 <?endif;?>
299
300 function updateMapHint_<?echo $MAP_ID?>()
301 {
302 var noValue = true,
303 i = 0;
304 while (BX('point_<?echo $MAP_ID?>__n' + i + '_lat'))
305 {
306 if (BX('point_<?echo $MAP_ID?>__n' + i + '_lat').value !== '' || !BX('point_<?echo $MAP_ID?>__n' + i + '_lon') || BX('point_<?echo $MAP_ID?>__n' + i + '_lon').value !=='')
307 noValue = false;
308 i++;
309 }
310 if (noValue)
311 {
312 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'block';
313 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'none';
314 }
315 else
316 {
317 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
318 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
319 }
320 }
321</script>
322
323<div id="bx_address_search_control_<?echo $MAP_ID?>" style="display: none;margin-top:15px;"><?echo GetMessage('IBLOCK_PROP_MAP_GOOGLE_SEARCH')?><input type="text" name="bx_address_<?echo $MAP_ID?>" id="bx_address_<?echo $MAP_ID?>" value="" style="width: 300px;" autocomplete="off" /></div>
324<br />
325<?
326 }
327?>
328<input type="text" style="width:125px;margin:0 0 4px" name="point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lat" id="point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lat" onchange="setInputPointValue_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()" />, <input type="text" style="width:125px;margin:0 15px 4px 0;" name="point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lon" id="point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lon" onchange="setInputPointValue_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()" />
329<div id="point_control_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_" style="display:none;margin:0 0 4px"><a href="javascript:void(0);" onclick="findPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()"><?echo GetMessage('IBLOCK_PROP_MAP_GOOGLE_GOTO_POINT')?></a> | <a href="javascript:void(0);" onclick="if (confirm('<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_GOOGLE_REMOVE_POINT_CONFIRM'))?>')) removePoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()"><?echo GetMessage('IBLOCK_PROP_MAP_GOOGLE_REMOVE_POINT')?></a></div><br />
330<input type="text" style="display:none;" id="value_<?echo $MAP_ID;?>__n<?=$googleMapLastNumber?>_" name="<?=htmlspecialcharsbx($strHTMLControlName["VALUE"])?>" value="<?=htmlspecialcharsEx($value["VALUE"])?>" />
331<script>
332 window.jsAdminGoogleMess = {
333 nothing_found: '<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_GOOGLE_NOTHING_FOUND'))?>'
334 }
335 BX.loadCSS('/bitrix/components/bitrix/map.google.view/settings/settings.css');
336
337 function BXWaitForMap_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()
338 {
339 if (!window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'])
340 setTimeout(BXWaitForMap_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_, 300);
341 else
342 {
343 if(!window.markersBounds_<?echo $MAP_ID?>)
344 window.markersBounds_<?echo $MAP_ID?> = new google.maps.LatLngBounds();
345 window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_ = null;
346
347 google.maps.event.clearListeners(window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'], 'dblclick');
348 google.maps.event.addListener(window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'], 'dblclick', window.setPointValue_<?echo $MAP_ID?>);
349
350 var searchInput = BX('bx_address_<?echo $MAP_ID?>');
351 BX.bind(searchInput,"keydown", jsGoogleCESearch_<?echo $MAP_ID;?>.setTypingStarted);
352 BX.bind(searchInput,"contextmenu", jsGoogleCESearch_<?echo $MAP_ID;?>.setTypingStarted);
353 BX('point_control_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_').style.display = 'none';
354
355 <?if ($bHasValue):?>
356 setPointValue_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_({latLng: new google.maps.LatLng(<?echo $POINT_LAT?>, <?echo $POINT_LON?>)});
357 window.markersBounds_<?echo $MAP_ID?>.extend(new google.maps.LatLng(<?echo $POINT_LAT?>, <?echo $POINT_LON?>));
358 if (<?=$googleMapLastNumber?> > 0)
359 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].setCenter(window.markersBounds_<?echo $MAP_ID?>.getCenter(), window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].fitBounds(window.markersBounds_<?echo $MAP_ID?>));
360 <?endif;?>
361
362 BX('bx_address_search_control_<?echo $MAP_ID?>').style.display = 'block';
363 BX('bx_map_hint_<?echo $MAP_ID?>').style.display = 'block';
364 }
365 }
366
367
368function findPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()
369{
370 if (null != window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_)
371 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_.getPosition());
372}
373
374function removePoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()
375{
376 window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_.setMap(null);
377 window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_ = null;
378
379 BX('point_control_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_').style.display = 'none';
380
381 updatePointPosition_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_();
382
383 updateMapHint_<?echo $MAP_ID?>();
384}
385
386function setPointValue_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_(obEvent)
387{
388 var obPoint = BX.type.isArray(obEvent) ? {latLng: new google.maps.LatLng(obEvent[0], obEvent[1])} : {latLng: new google.maps.LatLng(obEvent.latLng.lat(), obEvent.latLng.lng())};
389
390 if (null == window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_)
391 {
392 window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_ = new google.maps.Marker({
393 position: obPoint.latLng,
394 map: window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'],
395 draggable:true
396 });
397 google.maps.event.addListener(window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_, "dragend", updatePointPosition_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_);
398 }
399 else
400 {
401 window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_.setPosition(obPoint.latLng);
402 }
403
404 BX('point_control_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_').style.display = 'inline-block';
405 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
406 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
407
408 updatePointPosition_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_(obPoint);
409 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_.getPosition());
410}
411
412function setInputPointValue_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_()
413{
414 var vv = [BX('point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lat').value, BX('point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lon').value];
415 if (vv[0] == '' && vv[1] == '')
416 {
417 removePoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_();
418 }
419 var v = [parseFloat(BX('point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lat').value), parseFloat(BX('point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lon').value)];
420 if (!isNaN(v[0]) && !isNaN(v[1]))
421 {
422 setPointValue_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_(v);
423 }
424}
425
426function updatePointPosition_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_(obPoint)
427{
428 var obP = [];
429 if (!!obPoint && !!obPoint.latLng)
430 obP.push(obPoint.latLng.lat(), obPoint.latLng.lng());
431 else if (!!window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_)
432 obP.push(window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_.latLng.lat(), window.obPoint_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_.latLng.lng());
433 else
434 obP = null;
435 var obInput = BX('value_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_');
436 obInput.value = null == obP ? '' : obP[0] + ',' + obP[1];
437 BX('point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lat').value = obP ? obP[0] : '';
438 BX('point_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_lon').value = obP ? obP[1] : '';
439 if (obPoint.pixel)
440 {
441 BX.onCustomEvent(window, 'onAddGoogleMapPoint');
442 }
443}
444
445BX.ready(function() {
446 setTimeout(BXWaitForMap_<?echo $MAP_ID?>__n<?=$googleMapLastNumber?>_, 100);
447});
448
449var jsGoogleCESearch_<?echo $MAP_ID;?> = {
450 bInited: false,
451
452 map: null,
453 geocoder: null,
454 obInput: null,
455 timerID: null,
456 timerDelay: 1000,
457
458 arSearchResults: [],
459
460 obOut: null,
461
462 __init: function(input)
463 {
464 if (jsGoogleCESearch_<?echo $MAP_ID;?>.bInited) return;
465
466 jsGoogleCESearch_<?echo $MAP_ID;?>.map = window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'];
467 jsGoogleCESearch_<?echo $MAP_ID;?>.obInput = input;
468
469 //input.form.onsubmit = function() {jsGoogleCESearch_<?echo $MAP_ID;?>.doSearch(); return false;}
470
471 input.onfocus = jsGoogleCESearch_<?echo $MAP_ID;?>.showResults;
472 input.onblur = jsGoogleCESearch_<?echo $MAP_ID;?>.hideResults;
473
474 jsGoogleCESearch_<?echo $MAP_ID;?>.bInited = true;
475 },
476
477 setTypingStarted: function(e)
478 {
479 if (null == e)
480 e = window.event;
481
482 if (e.keyCode == 13)
483 {
484 jsGoogleCESearch_<?echo $MAP_ID;?>.doSearch();
485 return false;
486 }
487 else
488 {
489
490 if (!jsGoogleCESearch_<?echo $MAP_ID;?>.bInited)
491 jsGoogleCESearch_<?echo $MAP_ID;?>.__init(this);
492
493 if (e.type=="contextmenu")
494 jsGoogleCESearch_<?echo $MAP_ID;?>.timerDelay=3000;
495 else
496 jsGoogleCESearch_<?echo $MAP_ID;?>.timerDelay=1000;
497
498 jsGoogleCESearch_<?echo $MAP_ID;?>.hideResults();
499
500 if (null != jsGoogleCESearch_<?echo $MAP_ID;?>.timerID)
501 clearTimeout(jsGoogleCESearch_<?echo $MAP_ID;?>.timerID);
502
503 jsGoogleCESearch_<?echo $MAP_ID;?>.timerID = setTimeout(jsGoogleCESearch_<?echo $MAP_ID;?>.doSearch, jsGoogleCESearch_<?echo $MAP_ID;?>.timerDelay);
504 }
505 },
506
507 doSearch: function()
508 {
509 var value = jsUtils.trim(jsGoogleCESearch_<?echo $MAP_ID;?>.obInput.value);
510 if (value.length > 1)
511 {
512 if (null == jsGoogleCESearch_<?echo $MAP_ID;?>.geocoder)
513 jsGoogleCESearch_<?echo $MAP_ID;?>.geocoder = new google.maps.Geocoder();
514
515 jsGoogleCESearch_<?echo $MAP_ID;?>.geocoder.geocode({
516 address: value,
517 language: '<?=LANGUAGE_ID?>'
518 }, jsGoogleCESearch_<?echo $MAP_ID;?>.__searchResultsLoad);
519 }
520 },
521
522 handleError: function()
523 {
524 alert(jsGoogleCE.jsMess.mess_error);
525 },
526
527 setResultsCoordinates: function()
528 {
529 var obPos = jsUtils.GetRealPos(jsGoogleCESearch_<?echo $MAP_ID;?>.obInput);
530 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut.style.top = (obPos.bottom + 2) + 'px';
531 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut.style.left = obPos.left + 'px';
532 },
533
534 __generateOutput: function()
535 {
536 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut = document.body.appendChild(document.createElement('UL'));
537 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut.className = 'bx-google-address-search-results';
538 jsGoogleCESearch_<?echo $MAP_ID;?>.setResultsCoordinates();
539 },
540
541 __searchResultsLoad: function(obResult, status)
542 {
543 var _this = jsGoogleCESearch_<?echo $MAP_ID;?>;
544
545 if (status != google.maps.GeocoderStatus.OK && status != google.maps.GeocoderStatus.ZERO_RESULTS)
546 {
547 _this.handleError({message: status});
548 return;
549 }
550
551 if (!obResult)
552 {
553 _this.handleError();
554 }
555 else
556 {
557 if (null == _this.obOut)
558 _this.__generateOutput();
559
560 _this.obOut.innerHTML = '';
561 _this.clearSearchResults();
562
563 var len = 0;
564 if (status == google.maps.GeocoderStatus.OK)
565 {
566 len = obResult.length;
567 var obList = null;
568 }
569
570 if (len > 0)
571 {
572 for (var i = 0; i < len; i++)
573 {
574 _this.arSearchResults[i] = obResult[i].geometry;
575
576 var lnk_text = '';
577 for (var j = 0; j < obResult[i].address_components.length; j++)
578 {
579 lnk_text += (lnk_text.length > 0 ? ', ' : '') + obResult[i].address_components[j].long_name;
580 }
581
582 _this.obOut.appendChild(BX.create('LI', {
583 attrs: {className: i == 0 ? 'bx-google-first' : ''},
584 children: [
585 BX.create('A', {
586 attrs: {href: "javascript:void(0)"},
587 props: {BXSearchIndex: i},
588 events: {click: _this.__showSearchResult},
589 children: [
590 BX.create('SPAN', {
591 text: lnk_text
592 })
593 ]
594 })
595 ]
596 }));
597 }
598 }
599 else
600 {
601 _this.obOut.innerHTML = '<li class="bx-google-notfound">' + window.jsAdminGoogleMess.nothing_found + '</li>';
602 }
603
604 _this.showResults();
605 }
606 },
607
608 __showSearchResult: function()
609 {
610 if (null !== this.BXSearchIndex)
611 {
612 jsGoogleCESearch_<?echo $MAP_ID;?>.map.setCenter(jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults[this.BXSearchIndex].location);
613 if (jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults[this.BXSearchIndex].viewport)
614 jsGoogleCESearch_<?echo $MAP_ID;?>.map.fitBounds(jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults[this.BXSearchIndex].viewport);
615 }
616 },
617
618 showResults: function()
619 {
620 if (null != jsGoogleCESearch_<?echo $MAP_ID;?>.obOut)
621 {
622 jsGoogleCESearch_<?echo $MAP_ID;?>.setResultsCoordinates();
623 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut.style.display = 'block';
624 }
625 },
626
627 hideResults: function()
628 {
629 if (null != jsGoogleCESearch_<?echo $MAP_ID;?>.obOut)
630 {
631 setTimeout("jsGoogleCESearch_<?echo $MAP_ID;?>.obOut.style.display = 'none'", 300);
632 }
633 },
634
635 clearSearchResults: function()
636 {
637 for (var i = 0; i < jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults.length; i++)
638 {
639 delete jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults[i];
640 }
641
642 jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults = [];
643 },
644
645 clear: function()
646 {
647 if (!jsGoogleCESearch_<?echo $MAP_ID;?>.bInited)
648 return;
649
650 jsGoogleCESearch_<?echo $MAP_ID;?>.bInited = false;
651 if (null != jsGoogleCESearch_<?echo $MAP_ID;?>.obOut)
652 {
653 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut.parentNode.removeChild(jsGoogleCESearch_<?echo $MAP_ID;?>.obOut);
654 jsGoogleCESearch_<?echo $MAP_ID;?>.obOut = null;
655 }
656
657 jsGoogleCESearch_<?echo $MAP_ID;?>.arSearchResults = [];
658 jsGoogleCESearch_<?echo $MAP_ID;?>.map = null;
659 jsGoogleCESearch_<?echo $MAP_ID;?>.geocoder = null;
660 jsGoogleCESearch_<?echo $MAP_ID;?>.obInput = null;
661 jsGoogleCESearch_<?echo $MAP_ID;?>.timerID = null;
662 }
663}
664</script>
665<?
666 $out = ob_get_contents();
667 ob_end_clean();
668
669 if ($arProperty['MULTIPLE'] == 'Y')
670 $googleMapLastNumber++;
671
672 return $out;
673 }
674
675 public static function GetPublicViewHTML($arProperty, $value, $arParams)
676 {
677 $s = '';
678 $value['VALUE'] ??= null;
679 if($value["VALUE"] <> '')
680 {
681 $value = parent::ConvertFromDB($arProperty, $value);
682 if (($arParams['MODE'] ?? null) == 'CSV_EXPORT')
683 {
684 $s = $value["VALUE"];
685 }
686 else
687 {
688 $googleMapLastNumber = 0;
689 $apiKey = isset($arProperty['USER_TYPE_SETTINGS']['API_KEY']) ? $arProperty['USER_TYPE_SETTINGS']['API_KEY'] : '';
690 $arCoords = explode(',', $value['VALUE']);
691 ob_start();
692 $GLOBALS['APPLICATION']->IncludeComponent(
693 'bitrix:map.google.view',
694 '',
695 array(
696 'MAP_DATA' => serialize(array(
697 'google_lat' => $arCoords[0],
698 'google_lon' => $arCoords[1],
699 'PLACEMARKS' => array(
700 array(
701 'LON' => $arCoords[1],
702 'LAT' => $arCoords[0],
703 ),
704 ),
705 )),
706 'MAP_WIDTH' => $arParams['WIDTH'] ?? null,
707 'MAP_HEIGHT' => $arParams['HEIGHT'] ?? null,
708 'MAP_ID' => 'MAP_GOOGLE_VIEW_'.$arProperty['IBLOCK_ID'].'_'.$arProperty['ID'].'__n'.$googleMapLastNumber.'_',
709 'DEV_MODE' => 'Y',
710 'API_KEY' => $apiKey
711 ),
712 false, array('HIDE_ICONS' => 'Y')
713 );
714
715 $s .= ob_get_contents();
716 ob_end_clean();
717 }
718 }
719
720 return $s;
721 }
722 public static function GetUIEntityEditorProperty($settings, $value)
723 {
724 return [
725 'type' => 'custom'
726 ];
727 }
728
729 public static function GetUIEntityEditorPropertyEditHtml(array $params = []) : string
730 {
731 $settings = $params['SETTINGS'] ?? [];
732 $paramsHTMLControl = [
733 'VALUE' => $params['FIELD_NAME'] ?? '',
734 'MODE' => 'FORM_FILL',
735 ];
736 if ($settings['MULTIPLE'] === 'Y')
737 {
738 $value = [];
739 if (is_array($params['VALUE']))
740 {
741 foreach ($params['VALUE'] as $element)
742 {
743 $value[] = ['VALUE' => $element];
744 }
745 }
746 }
747 else
748 {
749 $value = [
750 'VALUE' => $params['VALUE'] ?? ''
751 ];
752 }
753
754 return static::GetPropertyFieldHtml($settings, $value, $paramsHTMLControl);
755 }
756
757 public static function GetUIEntityEditorPropertyViewHtml(array $params = []) : string
758 {
759 $settings = $params['SETTINGS'] ?? [];
760 $paramsHTMLControl = [
761 'VALUE' => $params['FIELD_NAME'] ?? '',
762 ];
763
764 if (isset($params['WIDTH']))
765 {
766 $paramsHTMLControl['WIDTH'] = $params['WIDTH'];
767 }
768 if (isset($params['HEIGHT']))
769 {
770 $paramsHTMLControl['HEIGHT'] = $params['HEIGHT'];
771 }
772
773 if ($settings['MULTIPLE'] === 'Y')
774 {
775 $multipleResult = '';
776 if (is_array($params['VALUE']))
777 {
778 foreach ($params['VALUE'] as $element)
779 {
780 $value = ['VALUE' => $element];
781 $multipleResult .= static::GetPublicViewHTML($settings, $value, $paramsHTMLControl) . '<br>';
782 }
783 }
784 return $multipleResult;
785 }
786 else
787 {
788 $value = [
789 'VALUE' => $params['VALUE'] ?? ''
790 ];
791 }
792
793 return static::GetPublicViewHTML($settings, $value, $paramsHTMLControl);
794 }
795}
796
798{
799 public static function GetUserTypeDescription()
800 {
801 // This property should be disabled in Ukraine
802 if (Loader::includeModule('bitrix24'))
803 {
804 $licensePrefix = \CBitrix24::getLicensePrefix();
805 if ($licensePrefix === 'ua' || $licensePrefix === 'ur')
806 {
807 return [];
808 }
809 }
810 elseif (Loader::includeModule('intranet'))
811 {
812 $portalZone = \CIntranetUtils::getPortalZone();
813 if ($portalZone === 'ua')
814 {
815 return [];
816 }
817 }
818 else
819 {
821 'select' => ['ID'],
822 'filter' => ['=ID' => 'ru', '=ACTIVE' => 'Y']
823 ]);
824 $row = $languageIterator->fetch();
825 unset($languageIterator);
826 if (!empty($row))
827 {
829 'select' => ['ID'],
830 'filter' => [
831 '=ID' => 'ua',
832 '=ACTIVE' => 'Y',
833 ],
834 'limit' => 1
835 ]);
836 $row = $languageIterator->fetch();
837 unset($languageIterator);
838 if (!empty($row))
839 {
840 return [];
841 }
842 }
843 }
844
845 return [
846 "PROPERTY_TYPE" => "S",
847 "USER_TYPE" => "map_yandex",
848 "DESCRIPTION" => GetMessage("IBLOCK_PROP_MAP_YANDEX"),
849 "GetPropertyFieldHtml" => array(__CLASS__, "GetPropertyFieldHtml"),
850 "GetPublicViewHTML" => array(__CLASS__, "GetPublicViewHTML"),
851 "GetPublicEditHTML" => array(__CLASS__, "GetPublicEditHTML"),
852 "ConvertToDB" => array(__CLASS__, "ConvertToDB"),
853 "ConvertFromDB" => array(__CLASS__, "ConvertFromDB"),
854 "GetSettingsHTML" => array(__CLASS__, "GetSettingsHTML"),
855 "PrepareSettings" => array(__CLASS__, "PrepareSettings"),
856 'GetUIEntityEditorProperty' => array(__CLASS__, 'GetUIEntityEditorProperty'),
857 'GetUIEntityEditorPropertyEditHtml' => array(__CLASS__, 'GetUIEntityEditorPropertyEditHtml'),
858 'GetUIEntityEditorPropertyViewHtml' => array(__CLASS__, 'GetUIEntityEditorPropertyViewHtml'),
859 ];
860 }
861
862 public static function _DrawKeyInputControl($MAP_ID, $strDomain)
863 {
864 echo BeginNote();
865?>
866<div id="key_input_control_<?echo $MAP_ID?>">
867 <?echo str_replace('#DOMAIN#', $strDomain, GetMessage('IBLOCK_PROP_MAP_YANDEX_NO_KEY_MESSAGE'))?><br /><br />
868 <?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_NO_KEY')?><input type="text" name="map_yandex_key_<?echo $MAP_ID?>" id="map_yandex_key_<?echo $MAP_ID?>" /> <input type="button" value="<?echo htmlspecialcharsbx(GetMessage('IBLOCK_PROP_MAP_YANDEX_NO_KEY_BUTTON'))?>" onclick="setYandexKey('<?echo $strDomain?>', 'map_yandex_key_<?echo $MAP_ID?>')" /> <input type="button" value="<?echo htmlspecialcharsbx(GetMessage('IBLOCK_PROP_MAP_YANDEX_SAVE_KEY_BUTTON'))?>" onclick="saveYandexKey('<?echo $strDomain?>', 'map_yandex_key_<?echo $MAP_ID?>')" />
869</div>
870<div id="key_input_message_<?echo $MAP_ID?>" style="display: none;"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_NO_KEY_OKMESSAGE')?></div>
871<?
872 echo EndNote();
873?>
874<script>
875function setYandexKey(domain, input)
876{
877 LoadMap_<?echo $MAP_ID?>(document.getElementById(input).value);
878}
879
880function saveYandexKey(domain, input)
881{
882 var value = document.getElementById(input).value;
883
884 CHttpRequest.Action = function(result)
885 {
886 CloseWaitWindow();
887 if (result == 'OK')
888 {
889 document.getElementById('key_input_control_<?echo $MAP_ID?>').style.display = 'none';
890 document.getElementById('key_input_message_<?echo $MAP_ID?>').style.display = 'block';
891 if (!window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'])
892 setYandexKey(domain, input);
893 }
894 else
895 alert('<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_YANDEX_NO_KEY_ERRORMESSAGE'))?>');
896 }
897
898 var data = 'key_type=yandex&domain=' + domain + '&key=' + value + '&<?echo bitrix_sessid_get()?>';
899 ShowWaitWindow();
900 CHttpRequest.Post('/bitrix/admin/settings.php?lang=<?echo LANGUAGE_ID?>&mid=fileman&save_map_key=Y', data);
901}
902</script>
903<?
904 } // _DrawKeyInputControl()
905
906 public static function GetSettingsHTML($arProperty, $strHTMLControlName, &$arPropertyFields)
907 {
908 $arPropertyFields = array(
909 'HIDE' => array('ROW_COUNT', 'COL_COUNT', 'SMART_FILTER', 'FILTRABLE', 'SEARCHABLE', 'WITH_DESCRIPTION'),
910 'SET' => array('SMART_FILTER' => 'N', 'FILTRABLE' => 'N', 'SEARCHABLE' => 'N')
911 );
912
913 return '';
914 }
915
916 public static function PrepareSettings($arProperty)
917 {
918 $arProperty['SMART_FILTER'] = 'N';
919 $arProperty['FILTRABLE'] = 'N';
920 $arProperty['SEARCHABLE'] = 'N';
921 $arProperty['USER_TYPE_SETTINGS'] = array();
922 return $arProperty;
923 }
924
925 public static function GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
926 {
927 global $APPLICATION;
928
929 static $yandexMapLastNumber = 0;
930 static $yandexMapID = '';
931
932 if (($arProperty['MULTIPLE'] == 'Y' && $yandexMapID !== $arProperty['ID']) || $arProperty['MULTIPLE'] == 'N')
933 $yandexMapLastNumber = 0;
934
935 if ($arProperty['MULTIPLE'] == 'Y')
936 $yandexMapID = $arProperty['ID'];
937
938 // TODO: remove this later to use in property default value setting
939 $value['VALUE'] ??= null;
940 if ($strHTMLControlName["MODE"] != "FORM_FILL")
941 return '<input type="text" name="'.htmlspecialcharsbx($strHTMLControlName['VALUE']).'" value="'.htmlspecialcharsbx($value['VALUE']).'" />';
942
943 if ($value['VALUE'] <> '')
944 {
945 list($POINT_LAT, $POINT_LON) = explode(',', $value['VALUE'], 2);
946 $bHasValue = true;
947 }
948 else
949 {
950 $POINT_LAT = doubleval(GetMessage('IBLOCK_PROP_MAP_YANDEX_INIT_LAT'));
951 $POINT_LON = doubleval(GetMessage('IBLOCK_PROP_MAP_YANDEX_INIT_LON'));
952 $bHasValue = false;
953 }
954 ob_start();
955
956 if ($arProperty['MULTIPLE'] == 'Y' && isset($GLOBALS['YANDEX_MAP_PROPERTY'][$arProperty['ID']]))
957 {
958 // property is multimple and map is already showed
959
960 $MAP_ID = $GLOBALS['YANDEX_MAP_PROPERTY'][$arProperty['ID']];
961 }
962 else
963 {
964 $MAP_ID = 'map_yandex_'.$arProperty['CODE'].'_'.$arProperty['ID'];
965 $GLOBALS['YANDEX_MAP_PROPERTY'][$arProperty['ID']] = $MAP_ID;
966
967
968?>
969<div id="bx_map_hint_<?echo $MAP_ID?>" style="display: none;">
970 <div id="bx_map_hint_value_<?echo $MAP_ID?>" style="display: <?echo $bHasValue ? 'block' : 'none'?>;">
971<?
972 echo GetMessage('IBLOCK_PROP_MAP_YANDEX_INSTR_VALUE').'<br /><br />';
973?>
974 </div>
975 <div id="bx_map_hint_novalue_<?echo $MAP_ID?>" style="display: <?echo $bHasValue ? 'none' : 'block'?>;">
976<?
977 echo GetMessage('IBLOCK_PROP_MAP_YANDEX_INSTR').'<br /><br />';
978?>
979 </div>
980</div>
981<?
982 $APPLICATION->IncludeComponent(
983 'bitrix:map.yandex.system',
984 '',
985 array(
986 'INIT_MAP_TYPE' => 'MAP',
987 'INIT_MAP_LON' => $POINT_LON ? $POINT_LON : 37.64,
988 'INIT_MAP_LAT' => $POINT_LAT ? $POINT_LAT : 55.76,
989 'INIT_MAP_SCALE' => 10,
990 'OPTIONS' => array('ENABLE_SCROLL_ZOOM', 'ENABLE_DRAGGING'),
991 'CONTROLS' => array('ZOOM', 'MINIMAP', 'TYPECONTROL', 'SCALELINE'),
992 'MAP_WIDTH' => '95%',
993 'MAP_HEIGHT' => 400,
994 'MAP_ID' => $MAP_ID,
995 'DEV_MODE' => 'Y',
996 //'ONMAPREADY' => 'BXWaitForMap_'.$MAP_ID
997 ),
998 false, array('HIDE_ICONS' => 'Y')
999 );
1000
1001//http://jabber.bx/view.php?id=17908
1002?>
1003<script>
1004 BX.ready(function(){
1005 var tabArea = BX.findParent(BX("BX_YMAP_<?=$MAP_ID?>"), {className: "adm-detail-content"});
1006 if (tabArea && tabArea.id)
1007 {
1008 var tabButton = BX("tab_cont_" + tabArea.id);
1009 BX.bind(tabButton, "click", function() { BXMapYandexAfterShow("<?=$MAP_ID?>"); });
1010 }
1011 });
1012
1013 <?if($arProperty['MULTIPLE'] == 'N'):?>
1014 function setPointValue_<?echo $MAP_ID?>(obEvent)
1015 {
1016 var obPoint = BX.type.isArray(obEvent) ? obEvent : obEvent.get("coordPosition");
1017
1018 if (null == window.obPoint_<?echo $MAP_ID?>__n0_)
1019 {
1020 window.obPoint_<?echo $MAP_ID?>__n0_ = new ymaps.Placemark(obPoint, {}, {draggable:true});
1021 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.add(window.obPoint_<?echo $MAP_ID?>__n0_);
1022 window.obPoint_<?echo $MAP_ID?>__n0_.events.add('dragend', updatePointPosition_<?echo $MAP_ID?>__n0_);
1023 }
1024 else
1025 {
1026 window.obPoint_<?echo $MAP_ID?>__n0_.geometry.setCoordinates(obPoint);
1027 }
1028
1029 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
1030 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
1031 BX('point_control_<?echo $MAP_ID?>__n0_').style.display = 'inline-block';
1032
1033 updatePointPosition_<?echo $MAP_ID?>__n0_(obPoint);
1034 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(obPoint_<?echo $MAP_ID?>__n0_.geometry.getCoordinates(), {delay:0});
1035 }
1036 <?else:?>
1037 function setPointValue_<?echo $MAP_ID?>(obEvent)
1038 {
1039 var obPoint = BX.type.isArray(obEvent) ? obEvent : obEvent.get("coordPosition");
1040 var i = 0, point = [], k = [];
1041 while (BX('point_<?echo $MAP_ID?>__n' + i + '_lat'))
1042 {
1043 if(BX('point_<?echo $MAP_ID?>__n' + i + '_lat').value == ''
1044 && BX('point_<?echo $MAP_ID?>__n' + i + '_lon')
1045 && BX('point_<?echo $MAP_ID?>__n' + i + '_lon').value == '')
1046 {
1047 k.push(i);
1048 }
1049 i++;
1050 }
1051 if (k.length <= 1)
1052 {
1053 BX.IBlock.Tools.addNewRow(BX('point_<?echo $MAP_ID?>__n0_lat').parentNode.parentNode.parentNode.parentNode.id)
1054 }
1055 k = (k.length) ? Math.min.apply(null, k) : i;
1056 var obPnt = 'obPoint_<?echo $MAP_ID?>__n'+k+'_',
1057 updPP = 'updatePointPosition_<?echo $MAP_ID?>__n'+k+'_';
1058 if(window[updPP])
1059 {
1060 window[obPnt] = null;
1061 window[obPnt] = new ymaps.Placemark(obPoint, {}, {draggable:true});
1062 window.GLOBAL_arMapObjects["<?echo $MAP_ID?>"].geoObjects.add(window[obPnt]);
1063 window[obPnt].events.add("dragend", window[updPP]);
1064 window[updPP](obPoint);
1065 }
1066
1067 BX('point_control_<?echo $MAP_ID?>__n'+k+'_').style.display = 'inline-block';
1068
1069 updateMapHint_<?echo $MAP_ID?>();
1070 }
1071 <?endif;?>
1072
1073 function setDefaultPreset_<?echo $MAP_ID?>()
1074 {
1075 if(window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects)
1076 {
1077 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.each(function (geoObject) {
1078 geoObject.options.set({preset: 'twirl#blueIcon'});
1079 });
1080 }
1081 }
1082
1083 function updateMapHint_<?echo $MAP_ID?>()
1084 {
1085 var noValue = true,
1086 i = 0;
1087 while (BX('point_<?echo $MAP_ID?>__n' + i + '_lat'))
1088 {
1089 if (BX('point_<?echo $MAP_ID?>__n' + i + '_lat').value !== '' || !BX('point_<?echo $MAP_ID?>__n' + i + '_lon') || BX('point_<?echo $MAP_ID?>__n' + i + '_lon').value !=='')
1090 noValue = false;
1091 i++;
1092 }
1093 if (noValue)
1094 {
1095 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'block';
1096 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'none';
1097 }
1098 else
1099 {
1100 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
1101 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
1102 }
1103 }
1104</script>
1105
1106<div id="bx_address_search_control_<?echo $MAP_ID?>" style="display: none;margin-top:15px;"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_SEARCH')?><input type="text" name="bx_address_<?echo $MAP_ID?>" id="bx_address_<?echo $MAP_ID?>" value="" style="width: 300px;" autocomplete="off" /></div>
1107<br />
1108<?
1109 }
1110?>
1111<input type="text" style="width:125px;margin:0 0 4px" name="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat" id="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat" onchange="setInputPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()" />, <input type="text" style="width:125px;margin:0 15px 4px 0;" name="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon" id="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon" onchange="setInputPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()" />
1112<div id="point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_" style="display:none;margin:0 0 4px"><a href="javascript:void(0);" onclick="findPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_GOTO_POINT')?></a> | <a href="javascript:void(0);" onclick="if (confirm('<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_YANDEX_REMOVE_POINT_CONFIRM'))?>')) removePoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_REMOVE_POINT')?></a></div><br />
1113<input type="text" style="display:none;" id="value_<?echo $MAP_ID;?>__n<?=$yandexMapLastNumber?>_" name="<?=htmlspecialcharsbx($strHTMLControlName["VALUE"])?>" value="<?=htmlspecialcharsEx($value["VALUE"])?>" />
1114<script>
1115 window.jsAdminYandexMess = {
1116 nothing_found: '<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_YANDEX_NOTHING_FOUND'))?>'
1117 }
1118 jsUtils.loadCSSFile('/bitrix/components/bitrix/map.yandex.view/settings/settings.css');
1119
1120 function BXWaitForMap_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1121 {
1122 if (!window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'])
1123 setTimeout(BXWaitForMap_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_, 300);
1124 else
1125 {
1126 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_ = null;
1127
1128 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].events.remove('dblclick', window.setPointValue_<?echo $MAP_ID?>);
1129 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].events.add('dblclick', window.setPointValue_<?echo $MAP_ID?>);
1130 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].events.add('click', window.setDefaultPreset_<?echo $MAP_ID?>);
1131 var searchInput = BX('bx_address_<?echo $MAP_ID?>');
1132 <?if (\Bitrix\Main\Config\Option::get('fileman', 'yandex_map_api_key', '')):?>
1133 BX.bind(searchInput, "keydown", jsYandexCESearch_<?echo $MAP_ID;?>.setTypingStarted);
1134 BX.bind(searchInput, "contextmenu", jsYandexCESearch_<?echo $MAP_ID;?>.setTypingStarted);
1135 <?else:?>
1136 searchInput.disabled = true;
1137 searchInput.title = '<?=CUtil::JSEscape(GetMessage("IBLOCK_PROP_MAP_YANDEX_SEARCH_KEY_REQUIRED"))?>';
1138 <?endif;?>
1139 BX('point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_').style.display = 'none';
1140
1141 <?if ($bHasValue):?>
1142 setPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_([<?echo $POINT_LAT?>, <?echo $POINT_LON?>]);
1143 if (<?=$yandexMapLastNumber?> > 0)
1144 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].setBounds(window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.getBounds(), {checkZoomRange: true});
1145 <?endif;?>
1146
1147 BX('bx_address_search_control_<?echo $MAP_ID?>').style.display = 'block';
1148 BX('bx_map_hint_<?echo $MAP_ID?>').style.display = 'block';
1149
1150 }
1151 }
1152
1153 function findPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1154 {
1155 if (null != window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_)
1156 {
1157 window.setDefaultPreset_<?echo $MAP_ID?>();
1158 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.getCoordinates(),{delay:0});
1159 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.options.set({preset: 'twirl#redIcon'});
1160
1161 }
1162 }
1163
1164 function removePoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1165 {
1166 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.remove(window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_);
1167 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_ = null;
1168
1169 BX('point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_').style.display = 'none';
1170
1171 updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_();
1172
1173 updateMapHint_<?echo $MAP_ID?>();
1174 }
1175
1176 function setPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(obEvent)
1177 {
1178 var obPoint = BX.type.isArray(obEvent) ? obEvent : obEvent.get("coordPosition");
1179
1180 if (null == window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_)
1181 {
1182 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_ = new ymaps.Placemark(obPoint, {}, {draggable:true});
1183 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.add(window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_);
1184 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.events.add('dragend', updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_);
1185 }
1186 else
1187 {
1188 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.setCoordinates(obPoint);
1189 }
1190
1191 BX('point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_').style.display = 'inline-block';
1192 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
1193 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
1194
1195 updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(obPoint);
1196 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.getCoordinates(),{delay:0});
1197 }
1198
1199 function setInputPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1200 {
1201 var vv = [BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat').value, BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon').value];
1202 if (vv[0] == '' && vv[1] == '')
1203 {
1204 removePoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_();
1205 }
1206 var v = [parseFloat(BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat').value), parseFloat(BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon').value)];
1207 if (!isNaN(v[0]) && !isNaN(v[1]))
1208 {
1209 setPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(v);
1210 }
1211 }
1212
1213 function updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(obPoint)
1214 {
1215 //var obPosition = obPoint.getGeoPoint();
1216 if (!!obPoint && !!obPoint.geometry)
1217 obPoint = obPoint.geometry.getCoordinates();
1218 else if (!!window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_)
1219 obPoint = window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.getCoordinates();
1220 else
1221 obPoint = null;
1222
1223 var obInput = BX('value_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_');
1224 obInput.value = null == obPoint ? '' : obPoint[0] + ',' + obPoint[1];
1225
1226 BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat').value = obPoint ? obPoint[0] : '';
1227 BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon').value = obPoint ? obPoint[1] : '';
1228 }
1229
1230 BX.ready(function() {
1231 setTimeout(BXWaitForMap_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_, 100);
1232 });
1233
1234 var jsYandexCESearch_<?echo $MAP_ID;?> = {
1235
1236 bInited: false,
1237
1238 map: null,
1239 geocoder: null,
1240 obInput: null,
1241 timerID: null,
1242 timerDelay: 1000,
1243
1244 arSearchResults: [],
1245 strLastSearch: null,
1246
1247 obOut: null,
1248
1249 __init: function(input)
1250 {
1251 if (jsYandexCESearch_<?echo $MAP_ID;?>.bInited) return;
1252
1253 jsYandexCESearch_<?echo $MAP_ID;?>.map = window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'];
1254 jsYandexCESearch_<?echo $MAP_ID;?>.obInput = input;
1255
1256 input.onfocus = jsYandexCESearch_<?echo $MAP_ID;?>.showResults;
1257 input.onblur = jsYandexCESearch_<?echo $MAP_ID;?>.hideResults;
1258
1259 jsYandexCESearch_<?echo $MAP_ID;?>.bInited = true;
1260 },
1261
1262 setTypingStarted: function(e)
1263 {
1264 if (null == e)
1265 e = window.event;
1266
1267 jsYandexCESearch_<?echo $MAP_ID;?>.hideResults();
1268
1269 if (e.keyCode == 13 )
1270 {
1271 jsYandexCESearch_<?echo $MAP_ID;?>.doSearch();
1272 return false;
1273 }
1274 else
1275 {
1276 if (!jsYandexCESearch_<?echo $MAP_ID;?>.bInited)
1277 jsYandexCESearch_<?echo $MAP_ID;?>.__init(this);
1278
1279 if (e.type=="contextmenu")
1280 jsYandexCESearch_<?echo $MAP_ID;?>.timerDelay=3000;
1281 else
1282 jsYandexCESearch_<?echo $MAP_ID;?>.timerDelay=1000;
1283
1284 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.timerID)
1285 clearTimeout(jsYandexCESearch_<?echo $MAP_ID;?>.timerID);
1286
1287 jsYandexCESearch_<?echo $MAP_ID;?>.timerID = setTimeout(jsYandexCESearch_<?echo $MAP_ID;?>.doSearch, jsYandexCESearch_<?echo $MAP_ID;?>.timerDelay);
1288 }
1289 },
1290
1291 doSearch: function()
1292 {
1293 this.strLastSearch = jsUtils.trim(jsYandexCESearch_<?echo $MAP_ID;?>.obInput.value);
1294
1295 if (this.strLastSearch.length > 1)
1296 {
1297 ymaps.geocode(this.strLastSearch).then(
1298 jsYandexCESearch_<?echo $MAP_ID;?>.__searchResultsLoad,
1299 jsYandexCESearch_<?echo $MAP_ID;?>.handleError
1300 );
1301 }
1302 },
1303
1304 handleError: function(error)
1305 {
1306 alert(window.jsAdminYandexMess.mess_error + ': ' + error.message);
1307 },
1308
1309 setResultsCoordinates: function()
1310 {
1311 var obPos = jsUtils.GetRealPos(jsYandexCESearch_<?echo $MAP_ID;?>.obInput);
1312 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.top = (obPos.bottom + 2) + 'px';
1313 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.left = obPos.left + 'px';
1314 },
1315
1316 __generateOutput: function()
1317 {
1318 jsYandexCESearch_<?echo $MAP_ID;?>.obOut = document.body.appendChild(document.createElement('UL'));
1319 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.className = 'bx-yandex-address-search-results';
1320 },
1321
1322 __searchResultsLoad: function(res)
1323 {
1324 var _this = jsYandexCESearch_<?echo $MAP_ID;?>;
1325
1326 if (null == _this.obOut)
1327 _this.__generateOutput();
1328
1329 _this.obOut.innerHTML = '';
1330 _this.clearSearchResults();
1331
1332 var len = res.geoObjects.getLength();
1333 if (len > 0)
1334 {
1335 for (var i = 0; i < len; i++)
1336 {
1337 _this.arSearchResults[i] = res.geoObjects.get(i);
1338
1339 var obListElement = document.createElement('LI');
1340
1341 if (i == 0)
1342 obListElement.className = 'bx-yandex-first';
1343
1344 var obLink = document.createElement('A');
1345 obLink.href = "javascript:void(0)";
1346 var obText = obLink.appendChild(document.createElement('SPAN'));
1347 obText.appendChild(document.createTextNode(
1348 jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults[i].properties.get('metaDataProperty').GeocoderMetaData.text
1349 ));
1350
1351 obLink.BXSearchIndex = i;
1352 obLink.onclick = _this.__showSearchResult;
1353
1354 obListElement.appendChild(obLink);
1355 _this.obOut.appendChild(obListElement);
1356 }
1357 }
1358 else
1359 {
1360 //var str = _this.jsMess.mess_search_empty;
1361 _this.obOut.innerHTML = '<li class="bx-yandex-notfound">' + window.jsAdminYandexMess.nothing_found + '</li>';
1362 }
1363
1364 _this.showResults();
1365 },
1366
1367 __showSearchResult: function()
1368 {
1369 if (null !== this.BXSearchIndex)
1370 {
1371 var bounds = jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults[this.BXSearchIndex].properties.get('boundedBy');
1372 jsYandexCESearch_<?echo $MAP_ID;?>.map.setBounds(bounds, { checkZoomRange: true });
1373 }
1374 },
1375
1376 showResults: function()
1377 {
1378 if(this.strLastSearch!=jsUtils.trim(jsYandexCESearch_<?echo $MAP_ID;?>.obInput.value))
1379 jsYandexCESearch_<?echo $MAP_ID;?>.doSearch();
1380
1381 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.obOut)
1382 {
1383 jsYandexCESearch_<?echo $MAP_ID;?>.setResultsCoordinates();
1384 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.display = 'block';
1385 }
1386 },
1387
1388 hideResults: function()
1389 {
1390 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.obOut)
1391 {
1392 setTimeout("jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.display = 'none'", 300);
1393 }
1394 },
1395
1396 clearSearchResults: function()
1397 {
1398 for (var i = 0; i < jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults.length; i++)
1399 {
1400 delete jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults[i];
1401 }
1402
1403 jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults = [];
1404 },
1405
1406 clear: function()
1407 {
1408 if (!jsYandexCESearch_<?echo $MAP_ID;?>.bInited)
1409 return;
1410
1411 jsYandexCESearch_<?echo $MAP_ID;?>.bInited = false;
1412 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.obOut)
1413 {
1414 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.parentNode.removeChild(jsYandexCESearch_<?echo $MAP_ID;?>.obOut);
1415 jsYandexCESearch_<?echo $MAP_ID;?>.obOut = null;
1416 }
1417
1418 jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults = [];
1419 jsYandexCESearch_<?echo $MAP_ID;?>.map = null;
1420 jsYandexCESearch_<?echo $MAP_ID;?>.geocoder = null;
1421 jsYandexCESearch_<?echo $MAP_ID;?>.obInput = null;
1422 jsYandexCESearch_<?echo $MAP_ID;?>.timerID = null;
1423 }
1424 }
1425
1426</script>
1427<?
1428 $out = ob_get_contents();
1429 ob_end_clean();
1430
1431 if ($arProperty['MULTIPLE'] == 'Y')
1432 $yandexMapLastNumber++;
1433
1434 return $out;
1435 }
1436
1437 public static function GetPublicEditHTML($arProperty, $value, $strHTMLControlName)
1438 {
1439 global $APPLICATION;
1440
1441 static $yandexMapLastNumber = 0;
1442 static $yandexMapID = '';
1443
1444 if (($arProperty['MULTIPLE'] == 'Y' && $yandexMapID !== $arProperty['ID']) || $arProperty['MULTIPLE'] == 'N')
1445 $yandexMapLastNumber = 0;
1446
1447 if ($arProperty['MULTIPLE'] == 'Y')
1448 $yandexMapID = $arProperty['ID'];
1449
1450 $value['VALUE'] ??= null;
1451 if ($value['VALUE'] <> '')
1452 {
1453 [$POINT_LAT, $POINT_LON] = explode(',', $value['VALUE'], 2);
1454 $bHasValue = true;
1455 }
1456 else
1457 {
1458 $POINT_LAT = doubleval(GetMessage('IBLOCK_PROP_MAP_YANDEX_INIT_LAT'));
1459 $POINT_LON = doubleval(GetMessage('IBLOCK_PROP_MAP_YANDEX_INIT_LON'));
1460 $bHasValue = false;
1461 }
1462 ob_start();?>
1463 <div>
1464 <?
1465 if ($arProperty['MULTIPLE'] == 'Y' && isset($GLOBALS['YANDEX_MAP_PROPERTY'][$arProperty['ID']]))
1466 {
1467 $MAP_ID = $GLOBALS['YANDEX_MAP_PROPERTY'][$arProperty['ID']];
1468 }
1469 else
1470 {
1471 $MAP_ID = 'map_yandex_'.$arProperty['CODE'].'_'.$arProperty['ID'];
1472 $GLOBALS['YANDEX_MAP_PROPERTY'][$arProperty['ID']] = $MAP_ID;
1473
1474
1475?>
1476<div id="bx_map_hint_<?echo $MAP_ID?>" style="display: none;">
1477 <div id="bx_map_hint_value_<?echo $MAP_ID?>" style="display: <?echo $bHasValue ? 'block' : 'none'?>;">
1478<?
1479 echo GetMessage('IBLOCK_PROP_MAP_YANDEX_INSTR_VALUE').'<br /><br />';
1480?>
1481 </div>
1482 <div id="bx_map_hint_novalue_<?echo $MAP_ID?>" style="display: <?echo $bHasValue ? 'none' : 'block'?>;">
1483<?
1484 echo GetMessage('IBLOCK_PROP_MAP_YANDEX_INSTR').'<br /><br />';
1485?>
1486 </div>
1487</div>
1488<?
1489 $APPLICATION->IncludeComponent(
1490 'bitrix:map.yandex.system',
1491 '',
1492 array(
1493 'INIT_MAP_TYPE' => 'MAP',
1494 'INIT_MAP_LON' => $POINT_LON ? $POINT_LON : 37.64,
1495 'INIT_MAP_LAT' => $POINT_LAT ? $POINT_LAT : 55.76,
1496 'INIT_MAP_SCALE' => 10,
1497 'OPTIONS' => array('ENABLE_SCROLL_ZOOM', 'ENABLE_DRAGGING'),
1498 'CONTROLS' => array('ZOOM', 'MINIMAP', 'TYPECONTROL', 'SCALELINE'),
1499 'MAP_WIDTH' => 450,
1500 'MAP_HEIGHT' => 400,
1501 'MAP_ID' => $MAP_ID,
1502 'DEV_MODE' => 'Y'
1503 ),
1504 false, array('HIDE_ICONS' => 'Y')
1505 );
1506?>
1507<script>
1508 BX.ready(function(){
1509 var tabArea = BX.findParent(BX("BX_YMAP_<?=$MAP_ID?>"), {className: "adm-detail-content"});
1510 if (tabArea && tabArea.id)
1511 {
1512 var tabButton = BX("tab_cont_" + tabArea.id);
1513 BX.bind(tabButton, "click", function() { BXMapYandexAfterShow("<?=$MAP_ID?>"); });
1514 }
1515 });
1516
1517 <?if($arProperty['MULTIPLE'] == 'N'):?>
1518 function setPointValue_<?echo $MAP_ID?>(obEvent)
1519 {
1520 var obPoint = BX.type.isArray(obEvent) ? obEvent : obEvent.get("coordPosition");
1521
1522 if (null == window.obPoint_<?echo $MAP_ID?>__n0_)
1523 {
1524 window.obPoint_<?echo $MAP_ID?>__n0_ = new ymaps.Placemark(obPoint, {}, {draggable:true});
1525 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.add(window.obPoint_<?echo $MAP_ID?>__n0_);
1526 window.obPoint_<?echo $MAP_ID?>__n0_.events.add('dragend', updatePointPosition_<?echo $MAP_ID?>__n0_);
1527 }
1528 else
1529 {
1530 window.obPoint_<?echo $MAP_ID?>__n0_.geometry.setCoordinates(obPoint);
1531 }
1532
1533 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
1534 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
1535 BX('point_control_<?echo $MAP_ID?>__n0_').style.display = 'inline-block';
1536
1537 updatePointPosition_<?echo $MAP_ID?>__n0_(obPoint);
1538 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(obPoint_<?echo $MAP_ID?>__n0_.geometry.getCoordinates(), {delay:0});
1539 }
1540 <?else:?>
1541 function setPointValue_<?echo $MAP_ID?>(obEvent)
1542 {
1543 var obPoint = BX.type.isArray(obEvent) ? obEvent : obEvent.get("coordPosition");
1544 var i = 0, point = [], k = [];
1545 while (BX('point_<?echo $MAP_ID?>__n' + i + '_lat'))
1546 {
1547 if(BX('point_<?echo $MAP_ID?>__n' + i + '_lat').value == ''
1548 && BX('point_<?echo $MAP_ID?>__n' + i + '_lon')
1549 && BX('point_<?echo $MAP_ID?>__n' + i + '_lon').value == '')
1550 {
1551 k.push(i);
1552 }
1553 i++;
1554 }
1555 if (k.length <= 1)
1556 {
1557 BX('point_<?echo $MAP_ID?>__n0_lat').parentNode.parentNode.id = '<?echo $MAP_ID?>';
1558 addNewRow_<?echo $MAP_ID?>(BX('point_<?echo $MAP_ID?>__n0_lat').parentNode.parentNode.id);
1559 }
1560 k = (k.length) ? Math.min.apply(null, k) : i;
1561 var obPnt = 'obPoint_<?echo $MAP_ID?>__n'+k+'_',
1562 updPP = 'updatePointPosition_<?echo $MAP_ID?>__n'+k+'_';
1563 if(window[updPP])
1564 {
1565 window[obPnt] = null;
1566 window[obPnt] = new ymaps.Placemark(obPoint, {}, {draggable:true});
1567 window.GLOBAL_arMapObjects["<?echo $MAP_ID?>"].geoObjects.add(window[obPnt]);
1568 window[obPnt].events.add("dragend", window[updPP]);
1569 window[updPP](obPoint);
1570 }
1571
1572 BX('point_control_<?echo $MAP_ID?>__n'+k+'_').style.display = 'inline-block';
1573
1574 updateMapHint_<?echo $MAP_ID?>();
1575 }
1576 <?endif;?>
1577
1578 function addNewRow_<?echo $MAP_ID?>(tdID, row_to_clone)
1579 {
1580 var TD = document.getElementById(tdID);
1581 var cnt = BX.findChildren(TD, {tag : 'DIV'}, false).length;
1582 var sHTML = BX.findChildren(TD, {tag : 'DIV'}, false)[cnt-1].innerHTML;
1583 var oDiv = TD.appendChild(document.createElement('div'));
1584 oDiv.parentNode.appendChild(document.createElement('br'));
1585
1586 var s, e, n, p;
1587 p = 0;
1588 while(true)
1589 {
1590 s = sHTML.indexOf('[n',p);
1591 if(s<0)break;
1592 e = sHTML.indexOf(']',s);
1593 if(e<0)break;
1594 n = parseInt(sHTML.substr(s+2,e-s));
1595 sHTML = sHTML.substr(0, s)+'[n'+(++n)+']'+sHTML.substr(e+1);
1596 p=s+1;
1597 }
1598 p = 0;
1599 while(true)
1600 {
1601 s = sHTML.indexOf('__n',p);
1602 if(s<0)break;
1603 e = sHTML.indexOf('_',s+2);
1604 if(e<0)break;
1605 n = parseInt(sHTML.substr(s+3,e-s));
1606 sHTML = sHTML.substr(0, s)+'__n'+(++n)+'_'+sHTML.substr(e+1);
1607 p=e+1;
1608 }
1609 p = 0;
1610 while(true)
1611 {
1612 s = sHTML.indexOf('__N',p);
1613 if(s<0)break;
1614 e = sHTML.indexOf('__',s+2);
1615 if(e<0)break;
1616 n = parseInt(sHTML.substr(s+3,e-s));
1617 sHTML = sHTML.substr(0, s)+'__N'+(++n)+'__'+sHTML.substr(e+2);
1618 p=e+2;
1619 }
1620 oDiv.innerHTML = sHTML;
1621
1622 var inputName = document.getElementById('value_<?echo $MAP_ID;?>__n<?=$yandexMapLastNumber?>_').name;
1623 p = 0;
1624 s = inputName.indexOf('][',p);
1625 e = inputName.indexOf(']',s+1);
1626 inputName = inputName.substr(0, s)+']['+(++n)+']'+inputName.substr(e+1);
1627 document.getElementById('value_<?echo $MAP_ID;?>__n' + --n + '_').name = inputName;
1628
1629 var patt = new RegExp ("<"+"script"+">[^\000]*?<"+"\/"+"script"+">", "ig");
1630 var code = sHTML.match(patt);
1631 if(code)
1632 {
1633 for(var i = 0; i < code.length; i++)
1634 {
1635 if(code[i] != '')
1636 {
1637 s = code[i].substring(8, code[i].length-9);
1638 jsUtils.EvalGlobal(s);
1639 }
1640 }
1641 }
1642
1643 if (BX && BX.adminPanel)
1644 {
1645 BX.adminPanel.modifyFormElements(oDiv);
1646 BX.onCustomEvent('onAdminTabsChange');
1647 }
1648
1649 setTimeout(function() {
1650 var r = BX.findChildren(oDiv, {tag: /^(input|select|textarea)$/i});
1651 if (r && r.length > 0)
1652 {
1653 for (var i=0,l=r.length;i<l;i++)
1654 {
1655 if (r[i].form && r[i].form.BXAUTOSAVE)
1656 r[i].form.BXAUTOSAVE.RegisterInput(r[i]);
1657 else
1658 break;
1659 }
1660 }
1661 }, 10);
1662 }
1663
1664 function setDefaultPreset_<?echo $MAP_ID?>()
1665 {
1666 if(window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects)
1667 {
1668 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.each(function (geoObject) {
1669 geoObject.options.set({preset: 'twirl#blueIcon'});
1670 });
1671 }
1672 }
1673
1674 function updateMapHint_<?echo $MAP_ID?>()
1675 {
1676 var noValue = true,
1677 i = 0;
1678 while (BX('point_<?echo $MAP_ID?>__n' + i + '_lat'))
1679 {
1680 if (BX('point_<?echo $MAP_ID?>__n' + i + '_lat').value !== '' || !BX('point_<?echo $MAP_ID?>__n' + i + '_lon') || BX('point_<?echo $MAP_ID?>__n' + i + '_lon').value !=='')
1681 noValue = false;
1682 i++;
1683 }
1684 if (noValue)
1685 {
1686 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'block';
1687 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'none';
1688 }
1689 else
1690 {
1691 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
1692 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
1693 }
1694 }
1695</script>
1696
1697<div id="bx_address_search_control_<?echo $MAP_ID?>" style="display: none;margin-top:15px;"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_SEARCH')?><input type="text" name="bx_address_<?echo $MAP_ID?>" id="bx_address_<?echo $MAP_ID?>" value="" style="width: 300px;" autocomplete="off" /></div>
1698<br />
1699<?
1700 }
1701?>
1702<input type="text" style="width:125px;margin:0 0 4px" name="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat" id="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat" onchange="setInputPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()" />, <input type="text" style="width:125px;margin:0 15px 4px 0;" name="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon" id="point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon" onchange="setInputPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()" />
1703<div id="point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_" style="display:none;margin:0 0 4px;font-size: 12px"><a href="javascript:void(0);" onclick="findPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_GOTO_POINT')?></a> | <a href="javascript:void(0);" onclick="if (confirm('<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_YANDEX_REMOVE_POINT_CONFIRM'))?>')) removePoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()"><?echo GetMessage('IBLOCK_PROP_MAP_YANDEX_REMOVE_POINT')?></a></div><br />
1704<input type="text" style="display:none;" id="value_<?echo $MAP_ID;?>__n<?=$yandexMapLastNumber?>_" name="<?=htmlspecialcharsbx($strHTMLControlName["VALUE"])?>" value="<?=htmlspecialcharsEx($value["VALUE"])?>" />
1705<script>
1706 window.jsAdminYandexMess = {
1707 nothing_found: '<?echo CUtil::JSEscape(GetMessage('IBLOCK_PROP_MAP_YANDEX_NOTHING_FOUND'))?>'
1708 }
1709 jsUtils.loadCSSFile('/bitrix/components/bitrix/map.yandex.view/settings/settings.css');
1710
1711 function BXWaitForMap_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1712 {
1713 if (!window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'])
1714 setTimeout(BXWaitForMap_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_, 300);
1715 else
1716 {
1717 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_ = null;
1718
1719 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].events.remove('dblclick', window.setPointValue_<?echo $MAP_ID?>);
1720 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].events.add('dblclick', window.setPointValue_<?echo $MAP_ID?>);
1721 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].events.add('click', window.setDefaultPreset_<?echo $MAP_ID?>);
1722 var searchInput = BX('bx_address_<?echo $MAP_ID?>');
1723 <?if (\Bitrix\Main\Config\Option::get('fileman', 'yandex_map_api_key', '')):?>
1724 BX.bind(searchInput, "keydown", jsYandexCESearch_<?echo $MAP_ID;?>.setTypingStarted);
1725 BX.bind(searchInput, "contextmenu", jsYandexCESearch_<?echo $MAP_ID;?>.setTypingStarted);
1726 <?else:?>
1727 searchInput.disabled = true;
1728 searchInput.title = '<?=CUtil::JSEscape(GetMessage("IBLOCK_PROP_MAP_YANDEX_SEARCH_KEY_REQUIRED"))?>';
1729 <?endif;?>
1730 BX('point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_').style.display = 'none';
1731 <?if ($bHasValue):?>
1732 setPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_([<?echo $POINT_LAT?>, <?echo $POINT_LON?>]);
1733 if (<?=$yandexMapLastNumber?> > 0)
1734 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].setBounds(window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.getBounds(), {checkZoomRange: true});
1735 <?endif;?>
1736
1737 BX('bx_address_search_control_<?echo $MAP_ID?>').style.display = 'block';
1738 BX('bx_map_hint_<?echo $MAP_ID?>').style.display = 'block';
1739
1740 }
1741 }
1742
1743 function findPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1744 {
1745 if (null != window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_)
1746 {
1747 window.setDefaultPreset_<?echo $MAP_ID?>();
1748 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.getCoordinates(),{delay:0});
1749 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.options.set({preset: 'twirl#redIcon'});
1750
1751 }
1752 }
1753
1754 function removePoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1755 {
1756 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.remove(window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_);
1757 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_ = null;
1758
1759 BX('point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_').style.display = 'none';
1760
1761 updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_();
1762
1763 updateMapHint_<?echo $MAP_ID?>();
1764 }
1765
1766 function setPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(obEvent)
1767 {
1768 var obPoint = BX.type.isArray(obEvent) ? obEvent : obEvent.get("coordPosition");
1769
1770 if (null == window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_)
1771 {
1772 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_ = new ymaps.Placemark(obPoint, {}, {draggable:true});
1773 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].geoObjects.add(window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_);
1774 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.events.add('dragend', updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_);
1775 }
1776 else
1777 {
1778 window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.setCoordinates(obPoint);
1779 }
1780
1781 BX('point_control_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_').style.display = 'inline-block';
1782 BX('bx_map_hint_novalue_<?echo $MAP_ID?>').style.display = 'none';
1783 BX('bx_map_hint_value_<?echo $MAP_ID?>').style.display = 'block';
1784
1785 updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(obPoint);
1786 window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'].panTo(obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.getCoordinates(),{delay:0});
1787 }
1788
1789 function setInputPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_()
1790 {
1791 var vv = [BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat').value, BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon').value];
1792 if (vv[0] == '' && vv[1] == '')
1793 {
1794 removePoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_();
1795 }
1796 var v = [parseFloat(BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat').value), parseFloat(BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon').value)];
1797 if (!isNaN(v[0]) && !isNaN(v[1]))
1798 {
1799 setPointValue_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(v);
1800 }
1801 }
1802
1803 function updatePointPosition_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_(obPoint)
1804 {
1805 if (!!obPoint && !!obPoint.geometry)
1806 obPoint = obPoint.geometry.getCoordinates();
1807 else if (!!window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_)
1808 obPoint = window.obPoint_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_.geometry.getCoordinates();
1809 else
1810 obPoint = null;
1811
1812 var obInput = BX('value_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_');
1813 obInput.value = null == obPoint ? '' : obPoint[0] + ',' + obPoint[1];
1814
1815 BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lat').value = obPoint ? obPoint[0] : '';
1816 BX('point_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_lon').value = obPoint ? obPoint[1] : '';
1817 }
1818
1819 BX.ready(function() {
1820 setTimeout(BXWaitForMap_<?echo $MAP_ID?>__n<?=$yandexMapLastNumber?>_, 100);
1821 });
1822
1823 var jsYandexCESearch_<?echo $MAP_ID;?> = {
1824
1825 bInited: false,
1826
1827 map: null,
1828 geocoder: null,
1829 obInput: null,
1830 timerID: null,
1831 timerDelay: 1000,
1832
1833 arSearchResults: [],
1834 strLastSearch: null,
1835
1836 obOut: null,
1837
1838 __init: function(input)
1839 {
1840 if (jsYandexCESearch_<?echo $MAP_ID;?>.bInited) return;
1841
1842 jsYandexCESearch_<?echo $MAP_ID;?>.map = window.GLOBAL_arMapObjects['<?echo $MAP_ID?>'];
1843 jsYandexCESearch_<?echo $MAP_ID;?>.obInput = input;
1844
1845 input.onfocus = jsYandexCESearch_<?echo $MAP_ID;?>.showResults;
1846 input.onblur = jsYandexCESearch_<?echo $MAP_ID;?>.hideResults;
1847
1848 jsYandexCESearch_<?echo $MAP_ID;?>.bInited = true;
1849 },
1850
1851 setTypingStarted: function(e)
1852 {
1853 if (null == e)
1854 e = window.event;
1855
1856 jsYandexCESearch_<?echo $MAP_ID;?>.hideResults();
1857
1858 if (e.keyCode == 13 )
1859 {
1860 jsYandexCESearch_<?echo $MAP_ID;?>.doSearch();
1861 return false;
1862 }
1863 else
1864 {
1865 if (!jsYandexCESearch_<?echo $MAP_ID;?>.bInited)
1866 jsYandexCESearch_<?echo $MAP_ID;?>.__init(this);
1867
1868 if (e.type=="contextmenu")
1869 jsYandexCESearch_<?echo $MAP_ID;?>.timerDelay=3000;
1870 else
1871 jsYandexCESearch_<?echo $MAP_ID;?>.timerDelay=1000;
1872
1873 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.timerID)
1874 clearTimeout(jsYandexCESearch_<?echo $MAP_ID;?>.timerID);
1875
1876 jsYandexCESearch_<?echo $MAP_ID;?>.timerID = setTimeout(jsYandexCESearch_<?echo $MAP_ID;?>.doSearch, jsYandexCESearch_<?echo $MAP_ID;?>.timerDelay);
1877 }
1878 },
1879
1880 doSearch: function()
1881 {
1882 this.strLastSearch = jsUtils.trim(jsYandexCESearch_<?echo $MAP_ID;?>.obInput.value);
1883
1884 if (this.strLastSearch.length > 1)
1885 {
1886 ymaps.geocode(this.strLastSearch).then(
1887 jsYandexCESearch_<?echo $MAP_ID;?>.__searchResultsLoad,
1888 jsYandexCESearch_<?echo $MAP_ID;?>.handleError
1889 );
1890 }
1891 },
1892
1893 handleError: function(error)
1894 {
1895 alert(window.jsAdminYandexMess.mess_error + ': ' + error.message);
1896 },
1897
1898 setResultsCoordinates: function()
1899 {
1900 var obPos = jsUtils.GetRealPos(jsYandexCESearch_<?echo $MAP_ID;?>.obInput);
1901 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.top = (obPos.bottom + 2) + 'px';
1902 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.left = obPos.left + 'px';
1903 },
1904
1905 __generateOutput: function()
1906 {
1907 jsYandexCESearch_<?echo $MAP_ID;?>.obOut = document.body.appendChild(document.createElement('UL'));
1908 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.className = 'bx-yandex-address-search-results';
1909 },
1910
1911 __searchResultsLoad: function(res)
1912 {
1913 var _this = jsYandexCESearch_<?echo $MAP_ID;?>;
1914
1915 if (null == _this.obOut)
1916 _this.__generateOutput();
1917
1918 _this.obOut.innerHTML = '';
1919 _this.clearSearchResults();
1920
1921 var len = res.geoObjects.getLength();
1922 if (len > 0)
1923 {
1924 for (var i = 0; i < len; i++)
1925 {
1926 _this.arSearchResults[i] = res.geoObjects.get(i);
1927
1928 var obListElement = document.createElement('LI');
1929
1930 if (i == 0)
1931 obListElement.className = 'bx-yandex-first';
1932
1933 var obLink = document.createElement('A');
1934 obLink.href = "javascript:void(0)";
1935 var obText = obLink.appendChild(document.createElement('SPAN'));
1936 obText.appendChild(document.createTextNode(
1937 jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults[i].properties.get('metaDataProperty').GeocoderMetaData.text
1938 ));
1939
1940 obLink.BXSearchIndex = i;
1941 obLink.onclick = _this.__showSearchResult;
1942
1943 obListElement.appendChild(obLink);
1944 _this.obOut.appendChild(obListElement);
1945 }
1946 }
1947 else
1948 {
1949 _this.obOut.innerHTML = '<li class="bx-yandex-notfound">' + window.jsAdminYandexMess.nothing_found + '</li>';
1950 }
1951
1952 _this.showResults();
1953 },
1954
1955 __showSearchResult: function()
1956 {
1957 if (null !== this.BXSearchIndex)
1958 {
1959 var bounds = jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults[this.BXSearchIndex].properties.get('boundedBy');
1960 jsYandexCESearch_<?echo $MAP_ID;?>.map.setBounds(bounds, { checkZoomRange: true });
1961 }
1962 },
1963
1964 showResults: function()
1965 {
1966 if(this.strLastSearch!=jsUtils.trim(jsYandexCESearch_<?echo $MAP_ID;?>.obInput.value))
1967 jsYandexCESearch_<?echo $MAP_ID;?>.doSearch();
1968
1969 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.obOut)
1970 {
1971 jsYandexCESearch_<?echo $MAP_ID;?>.setResultsCoordinates();
1972 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.display = 'block';
1973 }
1974 },
1975
1976 hideResults: function()
1977 {
1978 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.obOut)
1979 {
1980 setTimeout("jsYandexCESearch_<?echo $MAP_ID;?>.obOut.style.display = 'none'", 300);
1981 }
1982 },
1983
1984 clearSearchResults: function()
1985 {
1986 for (var i = 0; i < jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults.length; i++)
1987 {
1988 delete jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults[i];
1989 }
1990
1991 jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults = [];
1992 },
1993
1994 clear: function()
1995 {
1996 if (!jsYandexCESearch_<?echo $MAP_ID;?>.bInited)
1997 return;
1998
1999 jsYandexCESearch_<?echo $MAP_ID;?>.bInited = false;
2000 if (null != jsYandexCESearch_<?echo $MAP_ID;?>.obOut)
2001 {
2002 jsYandexCESearch_<?echo $MAP_ID;?>.obOut.parentNode.removeChild(jsYandexCESearch_<?echo $MAP_ID;?>.obOut);
2003 jsYandexCESearch_<?echo $MAP_ID;?>.obOut = null;
2004 }
2005
2006 jsYandexCESearch_<?echo $MAP_ID;?>.arSearchResults = [];
2007 jsYandexCESearch_<?echo $MAP_ID;?>.map = null;
2008 jsYandexCESearch_<?echo $MAP_ID;?>.geocoder = null;
2009 jsYandexCESearch_<?echo $MAP_ID;?>.obInput = null;
2010 jsYandexCESearch_<?echo $MAP_ID;?>.timerID = null;
2011 }
2012 }
2013
2014</script>
2015
2016 </div>
2017
2018 <?$out = ob_get_contents();
2019 ob_end_clean();
2020
2021 if ($arProperty['MULTIPLE'] == 'Y')
2022 $yandexMapLastNumber++;
2023
2024 return $out;
2025 }
2026
2027 public static function GetPublicViewHTML($arProperty, $value, $arParams)
2028 {
2029 $s = '';
2030 $value['VALUE'] ??= null;
2031 if (($arParams['MODE'] ?? null) == 'CSV_EXPORT')
2032 {
2033 if ($value["VALUE"] <> '')
2034 {
2035 $coordValue = parent::ConvertFromDB($arProperty, $value);
2036 $s = $coordValue["VALUE"];
2037
2038 }
2039 }
2040 else
2041 {
2042 if($value["VALUE"] <> '')
2043 {
2044 $value = parent::ConvertFromDB($arProperty, $value);
2045 $arCoords = explode(',', $value['VALUE']);
2046 ob_start();
2047 $GLOBALS['APPLICATION']->IncludeComponent(
2048 'bitrix:map.yandex.view',
2049 '',
2050 array(
2051 'MAP_DATA' => serialize(array(
2052 'yandex_lat' => $arCoords[0],
2053 'yandex_lon' => $arCoords[1],
2054 'PLACEMARKS' => array(
2055 array(
2056 'LON' => $arCoords[1],
2057 'LAT' => $arCoords[0],
2058 ),
2059 ),
2060 )),
2061 'MAP_ID' => 'MAP_YANDEX_VIEW_'.$arProperty['IBLOCK_ID'].'_'.$arProperty['ID'].'_'.rand(),
2062 'DEV_MODE' => 'Y',
2063 ),
2064 false, array('HIDE_ICONS' => 'Y')
2065 );
2066
2067 $s = ob_get_contents();
2068 ob_end_clean();
2069 }
2070 }
2071
2072 return $s;
2073 }
2074
2075 public static function GetUIEntityEditorProperty($settings, $value)
2076 {
2077 return [
2078 'type' => 'custom'
2079 ];
2080 }
2081
2082 public static function GetUIEntityEditorPropertyEditHtml(array $params = []) : string
2083 {
2084 $settings = $params['SETTINGS'] ?? [];
2085 $paramsHTMLControl = [
2086 'VALUE' => $params['FIELD_NAME'] ?? '',
2087 'MODE' => 'FORM_FILL'
2088 ];
2089 if ($settings['MULTIPLE'] === 'Y')
2090 {
2091 $value = [];
2092 if (is_array($params['VALUE']))
2093 {
2094 foreach ($params['VALUE'] as $element)
2095 {
2096 $value[] = ['VALUE' => $element];
2097 }
2098 }
2099 }
2100 else
2101 {
2102 $value = [
2103 'VALUE' => $params['VALUE'] ?? ''
2104 ];
2105 }
2106
2107 return static::GetPublicEditHTML($settings, $value, $paramsHTMLControl);
2108 }
2109
2110 public static function GetUIEntityEditorPropertyViewHtml(array $params = []) : string
2111 {
2112 $settings = $params['SETTINGS'] ?? [];
2113 $paramsHTMLControl = [
2114 'VALUE' => $params['FIELD_NAME'] ?? '',
2115 ];
2116
2117 if ($settings['MULTIPLE'] === 'Y')
2118 {
2119 $multipleResult = '';
2120 if (is_array($params['VALUE']))
2121 {
2122 foreach ($params['VALUE'] as $element)
2123 {
2124 $value = ['VALUE' => $element];
2125 $multipleResult .= static::GetPublicViewHTML($settings, $value, $paramsHTMLControl) . '<br>';
2126 }
2127 }
2128 return $multipleResult;
2129 }
2130 else
2131 {
2132 $value = [
2133 'VALUE' => $params['VALUE'] ?? ''
2134 ];
2135 }
2136
2137 return static::GetPublicViewHTML($settings, $value, $paramsHTMLControl);
2138 }
2139}
2140
2141//AddEventHandler("iblock", "OnIBlockPropertyBuildList", array("CIBlockPropertyFileMan", "GetUserTypeDescription"));
2142//RegisterModuleDependences('iblock', 'OnIBlockPropertyBuildList', 'fileman', 'CIBlockPropertyMapGoogle', 'GetUserTypeDescription');
2143//RegisterModuleDependences('iblock', 'OnIBlockPropertyBuildList', 'fileman', 'CIBlockPropertyMapYandex', 'GetUserTypeDescription');
2144
2145// ##########################
2146// ####### VIDEO PROPERTIES ######
2147// ##########################
2148
2149// ### Base class ###
2150class CVideoProperty
2151{
2152 public static function BasePrepareSettings($arProperty, $key = "SETTINGS")
2153 {
2154 $arSet = array(
2155 "BUFFER_LENGTH" => "10",
2156 "CONTROLBAR" => "bottom",
2157 "AUTOSTART" => "N",
2158 "VOLUME" => "90",
2159 "SKIN" => "",
2160 "FLASHVARS" => "",
2161 "WMODE_FLV" => "transparent",
2162 "BGCOLOR" => "FFFFFF",
2163 "COLOR" => "000000",
2164 "OVER_COLOR" => "000000",
2165 "SCREEN_COLOR" => "000000",
2166 "SILVERVARS" => "",
2167 "WMODE_WMV" => "windowless",
2168 "WIDTH" => "400",
2169 "HEIGHT" => "300",
2170 );
2171
2172 if(is_array($arProperty[$key]))
2173 {
2174 if (isset($arProperty[$key]["BUFFER_LENGTH"]))
2175 $arSet["BUFFER_LENGTH"] = intval($arProperty[$key]["BUFFER_LENGTH"]);
2176
2177 if (isset($arProperty[$key]["CONTROLBAR"]))
2178 $arSet["CONTROLBAR"] = $arProperty[$key]["CONTROLBAR"];
2179
2180 if (isset($arProperty[$key]["AUTOSTART"]))
2181 $arSet["AUTOSTART"] = $arProperty[$key]["AUTOSTART"] == "Y" ? "Y" : "N";
2182
2183 if (isset($arProperty[$key]["VOLUME"]))
2184 $arSet["VOLUME"] = intval($arProperty[$key]["VOLUME"]);
2185
2186 if (isset($arProperty[$key]["SKIN"]))
2187 $arSet["SKIN"] = $arProperty[$key]["SKIN"];
2188
2189 if (isset($arProperty[$key]["FLASHVARS"]))
2190 $arSet["FLASHVARS"] = $arProperty[$key]["FLASHVARS"];
2191
2192 if (isset($arProperty[$key]["WMODE_FLV"]))
2193 $arSet["WMODE_FLV"] = $arProperty[$key]["WMODE_FLV"];
2194
2195 if (isset($arProperty[$key]["BGCOLOR"]))
2196 $arSet["BGCOLOR"] = $arProperty[$key]["BGCOLOR"];
2197 if (isset($arProperty[$key]["COLOR"]))
2198 $arSet["COLOR"] = $arProperty[$key]["COLOR"];
2199 if (isset($arProperty[$key]["OVER_COLOR"]))
2200 $arSet["OVER_COLOR"] = $arProperty[$key]["OVER_COLOR"];
2201 if (isset($arProperty[$key]["SCREEN_COLOR"]))
2202 $arSet["SCREEN_COLOR"] = $arProperty[$key]["SCREEN_COLOR"];
2203
2204 if (isset($arProperty[$key]["SILVERVARS"]))
2205 $arSet["SILVERVARS"] = $arProperty[$key]["SILVERVARS"];
2206
2207 if (isset($arProperty[$key]["WMODE_WMV"]))
2208 $arSet["WMODE_WMV"] = $arProperty[$key]["WMODE_WMV"];
2209
2210 if (isset($arProperty[$key]["WIDTH"]))
2211 $arSet["WIDTH"] = $arProperty[$key]["WIDTH"];
2212 if (isset($arProperty[$key]["HEIGHT"]))
2213 $arSet["HEIGHT"] = $arProperty[$key]["HEIGHT"];
2214 }
2215 return $arSet;
2216 }
2217
2218 public static function BaseGetSettingsHTML($name, $val)
2219 {
2220 $arSkins = GetSkinsEx(CUserTypeVideo::GetSkinPath());
2222 ob_start();
2223?>
2224<tr><td colSpan="2">
2225<style>
2226tr.bx-prop-sub-title td{background: #E2E1E0! important; color: #525355! important; font-weight: bold! important; text-align: left! important; padding-left: 10px;}
2227</style>
2228</td></tr>
2229<tr class="heading"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_BOTH_SET')?></td></tr>
2230<tr>
2231 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_BUFFER')?>:</td>
2232 <td>
2233 <input type="text" name="<?= $name?>[BUFFER_LENGTH]" size="10" value="<?= intval($val["BUFFER_LENGTH"])?>"/>
2234 </td>
2235</tr>
2236<tr>
2237 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_CONTROLBAR')?>:</td>
2238 <td>
2239 <select name="<?= $name?>[CONTROLBAR]">
2240 <option value="bottom" <? if($val["CONTROLBAR"] == 'bottom') echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_CONTROLBAR_DOWN')?></option>
2241 <option value="none" <? if($val["CONTROLBAR"] == 'none') echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_CONTROLBAR_NONE')?></option>
2242 </select>
2243 </td>
2244</tr>
2245<tr>
2246 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_AUTOSTART')?>:</td>
2247 <td>
2248 <input value="Y" type="checkbox" name="<?= $name?>[AUTOSTART]" <? if($val["AUTOSTART"] == 'Y') echo 'checked="checked"';?>/>
2249 </td>
2250</tr>
2251<tr>
2252 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_VOLUME')?>:</td>
2253 <td>
2254 <input type="text" name="<?= $name?>[VOLUME]" size="10" value="<?= intval($val["VOLUME"])?>"/>
2255 </td>
2256</tr>
2257<tr>
2258 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SIZE')?></td>
2259 <td>
2260 <input type="text" name="<?= $name?>[WIDTH]" style="width: 70px;" size="10" value="<?= intval($val["WIDTH"])?>"/>
2261 x
2262 <input type="text" name="<?= $name?>[HEIGHT]" style="width: 70px;" size="10" value="<?= intval($val["HEIGHT"])?>"/>
2263 </td>
2264</tr>
2265<tr class="heading"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_FLV_SET')?></td></tr>
2266<tr>
2267 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_SKIN')?>:</td>
2268 <td id="bx_player_skin_cell">
2269 <input id="bx_player_skin_input" type="hidden" name="<?= $name?>[SKIN]" value="<?= htmlspecialcharsbx($val["SKIN"])?>" />
2270<script>
2271jsUtils.loadCSSFile("/bitrix/components/bitrix/player/js/skin_selector.css");
2272jsUtils.loadJSFile("/bitrix/components/bitrix/player/js/prop_skin_selector.js", function()
2273{
2274 if (!window.ComponentPropsSkinSelector || !window.BXSkinSelector)
2275 return;
2276
2277 // Try to imitate CUSTOM-parameter in component params dialog
2278 ComponentPropsSkinSelector({
2279 propertyID : "SKIN",
2280 getElements : function(){return {SKIN_PATH: {value: "<?= CVideoProperty::GetSkinPath()?>"}};},
2281 oInput : document.getElementById("bx_player_skin_input"),
2282 oCont : document.getElementById("bx_player_skin_cell"),
2283 data : '<?= CUtil::JSEscape(CUtil::PhpToJSObject(array($arSkins, array('NoPreview' => GetMessage("IBLOCK_PROP_VIDEO_NO_PREVIEW"))))) ?>'
2284 });
2285});
2286</script>
2287 </td>
2288</tr>
2289<tr>
2290 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_FLASHVARS')?>:</td>
2291 <td>
2292 <textarea cols="25" name="<?= $name?>[FLASHVARS]"><?= htmlspecialcharsbx($val["FLASHVARS"])?></textarea>
2293 </td>
2294</tr>
2295<tr>
2296 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_FLV')?>:</td>
2297 <td>
2298 <select name="<?= $name?>[WMODE_FLV]">
2299 <option value="window" <? if($val["WMODE_FLV"] == 'window' || !$val["WMODE_FLV"]) echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_WINDOW')?></option>
2300 <option value="opaque" <? if($val["WMODE_FLV"] == 'opaque') echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_OPAQUE')?></option>
2301 <option value="transparent" <? if($val["WMODE_FLV"] == 'transparent') echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_TRANSPARENT')?></option>
2302 </select>
2303 </td>
2304</tr>
2305<tr class="heading"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_WMV_SET')?></td></tr>
2306<tr>
2307 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_BGCOLOR')?>:</td>
2308 <td><input type="text" name="<?= $name?>[BGCOLOR]" size="10" value="<?= htmlspecialcharsbx($val["BGCOLOR"])?>"/></td>
2309</tr>
2310<tr>
2311 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_COLOR')?>:</td>
2312 <td><input type="text" name="<?= $name?>[COLOR]" size="10" value="<?= htmlspecialcharsbx($val["COLOR"])?>"/></td>
2313</tr>
2314<tr>
2315 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_OVER_COLOR')?>:</td>
2316 <td><input type="text" name="<?= $name?>[OVER_COLOR]" size="10" value="<?= htmlspecialcharsbx($val["OVER_COLOR"])?>"/></td>
2317</tr>
2318<tr>
2319 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_SCREEN_COLOR')?>:</td>
2320 <td><input type="text" name="<?= $name?>[SCREEN_COLOR]" size="10" value="<?= htmlspecialcharsbx($val["SCREEN_COLOR"])?>"/ ></td>
2321</tr>
2322<tr>
2323 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_SILVERVARS')?>:</td>
2324 <td>
2325 <textarea cols="25" name="<?= $name?>[SILVERVARS]"><?= htmlspecialcharsbx($val["SILVERVARS"])?></textarea>
2326 </td>
2327</tr>
2328<tr>
2329 <td><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_WMV')?>:</td>
2330 <td>
2331 <select name="<?= $name?>[WMODE_WMV]">
2332 <option value="window" <? if($val["WMODE_WMV"] == 'window') echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_WINDOW')?></option>
2333 <option value="windowless" <? if($val["WMODE_WMV"] == 'windowless') echo 'selected';?>><?= GetMessage('IBLOCK_PROP_VIDEO_SET_WMODE_TRANSPARENT')?></option>
2334 </select>
2335 </td>
2336</tr>
2337<?
2338 $result = ob_get_contents();
2339 ob_end_clean();
2340 return $result;
2341 }
2342
2343 public static function BaseGetEditFormHTML($set, $val, $name, $controlMode=false)
2344 {
2345 global $APPLICATION;
2346 $id = str_replace(array("[","]",":"), "_", $name);
2347 $path = $val["path"];
2349
2350 if (intval($val['width']) <= 0)
2351 $val['width'] = intval($set['WIDTH']);
2352 if (intval($val['height']) <= 0)
2353 $val['height'] = intval($set['HEIGHT']);
2354
2355 ob_start();
2356?>
2357<div style="padding: 5px;">
2358<style>
2359table.bx-video-prop-tbl{border-collapse: collapse! important; border: 1px solid #E0E4F1;}
2360table.bx-video-prop-tbl td{padding: 3px 5px! important; border-bottom: 1px dotted #BABABA !important;}
2361table.bx-video-prop-tbl tr.bx-prop-main-title td{background: #E0E4F1! important; color: #525355! important; font-weight: bold! important; text-align: center! important; border-bottom-width: 0px !important; padding: 5px! important;}
2362table.bx-video-prop-tbl tr.bx-prop-sub-title td{background: #E2E1E0! important; color: #525355! important; font-weight: bold! important; text-align: left! important; border-bottom-width: 0px !important;}
2363table.bx-video-prop-tbl td.bx-pr-title{text-align: right! important; vertical-align: top! important; padding-top: 8px !important;}
2364div.bx-path-div a{float: right !important;}
2365div.bx-path-div a.bx-leave{display: none;}
2366div.bx-path-div-changed a.bx-leave{display: block !important;}
2367div.bx-path-div-changed a.bx-change{display: none !important;}
2368div.bx-path-div input.bx-path{color: #525355 !important;}
2369div.bx-path-div-changed input.bx-path{text-decoration: line-through !important;}
2370table.bx-video-prop-tbl img.spacer{display:block;float:left;height:1px;margin-top:-2px;width:220px;}
2371</style>
2372
2373<table class="bx-video-prop-tbl">
2374 <tr class="bx-prop-main-title"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_PARAMS_TITLE')?></td></tr>
2375 <? if ($controlMode != "iblock_element_admin"): ?>
2376 <? if($path <> ''):?>
2377 <tr class="heading"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_PARAMS_TITLE_VIEW')?></td></tr>
2378 <tr>
2379 <td colSpan="2" style="text-align: center;">
2380 <?$APPLICATION->IncludeComponent(
2381 "bitrix:player",
2382 "",
2383 array(
2384 "PLAYER_TYPE" => "auto",
2385 "PATH" => $path,
2386 "WIDTH" => $val['width'],
2387 "HEIGHT" => $val['height'],
2388 "FILE_TITLE" => $val['title'],
2389 "FILE_DURATION" => intval($val['duration']),
2390 "FILE_AUTHOR" => $val['author'],
2391 "FILE_DATE" => $val['date'],
2392 "FILE_DESCRIPTION" => $val['desc'],
2393 "SKIN_PATH" => CVideoProperty::GetSkinPath(),
2394 "SKIN" => $set["SKIN"],
2395 "CONTROLBAR" => $set["CONTROLBAR"],
2396 "WMODE" => $set["WMODE_FLV"],
2397 "WMODE_WMV" => $set["WMODE_WMV"],
2398 "SHOW_CONTROLS" => $set["CONTROLBAR"] != 'none' ? "Y" : "N",
2399 "CONTROLS_BGCOLOR" => $set["CONTROLS_BGCOLOR"],
2400 "CONTROLS_COLOR" => $set["CONTROLS_COLOR"],
2401 "CONTROLS_OVER_COLOR" => $set["CONTROLS_OVER_COLOR"],
2402 "SCREEN_COLOR" => $set["SCREEN_COLOR"],
2403 "AUTOSTART" => $set["AUTOSTART"],
2404 "VOLUME" => $set["VOLUME"],
2405 "ADDITIONAL_FLASHVARS" => $set["FLASHVARS"],
2406 "BUFFER_LENGTH" => $set["BUFFER_LENGTH"],
2407 "ADDITIONAL_WMVVARS" => $set["SILVERVARS"],
2408 "ALLOW_SWF" => "N",
2409 "LOGO_POSITION" => "none"
2410 ),
2411 false,
2412 array('HIDE_ICONS' => 'Y')
2413 ); ?>
2414 </td>
2415 </tr>
2416 <?endif;?>
2417
2418 <tr><td class="bx-pr-title" style="width: 300px;"></td><td style="width: 240px;"></td></tr>
2419
2420 <tr class="heading"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_PARAMS_TITLE_MAIN')?></td></tr>
2421
2422 <? if($path <> ''):?>
2423 <tr>
2424 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_FILE')?>:</td>
2425 <td>
2426 <div id="bx_video_path_div_<?= $id?>" class="bx-path-div">
2427 <input type="hidden" value="<?= htmlspecialcharsEx($path)?>" name= "<?= $name?>[CUR_PATH]" />
2428 <input id="bx_video_b_new_file_<?= $id?>" type="hidden" value="N" name= "<?= $name?>[B_NEW_FILE]" />
2429 <input class="bx-path" readonly="readonly" value="<?= htmlspecialcharsex($path)?>" size="30" />
2430 <br />
2431 <a href="javascript: void(0)" onclick="return ChangeOrLeaveFile<?=$id?>(true);" class="bx-change" id="bx-change"><?= GetMessage('IBLOCK_PROP_VIDEO_FILE_CHANGE')?></a>
2432 <a href="javascript: void(0)" onclick="return ChangeOrLeaveFile<?=$id?>(false);" class="bx-leave"><?= GetMessage('IBLOCK_PROP_VIDEO_FILE_LEAVE')?></a>
2433 </div>
2434 </td>
2435 </tr>
2436 <? if(CVideoProperty::CheckFileInUploadDir($path)):?>
2437 <tr id="bx_video_del_row_<?= $id?>" style="display: none;">
2438 <td class="bx-pr-title"></td>
2439 <td>
2440 <input type="checkbox" value="Y" id="bx_video_del_<?= $id?>" checked="checked" name= "<?= $name?>[DEL_CUR_FILE]" /><label for="bx_video_del_<?= $id?>"><?= GetMessage('IBLOCK_PROP_VIDEO_DEL_FILE')?></label>
2441 </td>
2442 </tr>
2443 <?endif;?>
2444 <?endif;?>
2445
2446 <tr id="bx_video_new_path_row_<?= $id?>" <?if ($path <> ''){ echo 'style="display: none;"'; }?>>
2447 <td class="bx-pr-title" style="width: 300px;"><?= GetMessage($path <> '' ? 'IBLOCK_PROP_VIDEO_PATH_NEW' : 'IBLOCK_PROP_VIDEO_PATH')?>:</td>
2448 <td style="width: 240px;">
2449 <img src="/bitrix/images/1.gif" class="spacer" />
2450 <div id="bx_video_path_cont1_<?= $id?>" style="display: none;">
2451 <input type="text" size="30" value="" id="bx_video_path_<?= $id?>" style="float:left;" name= "<?= $name?>[PATH]" />
2452 <?
2454 (
2455 "event" => "OpenFileBrowser_".$id,
2456 "arResultDest" => Array("FUNCTION_NAME" => "SetVideoPath".$id),
2457 "arPath" => Array(),
2458 "select" => 'F',// F - file only, D - folder only
2459 "operation" => 'O',// O - open, S - save
2460 "showUploadTab" => false,
2461 "showAddToMenuTab" => false,
2462 "fileFilter" => 'flv,mp4,mp3,wmv',
2463 "allowAllFiles" => true,
2464 "SaveConfig" => true
2465 )
2466 );
2467
2468 CMedialib::ShowBrowseButton(
2469 array(
2470 "id" => 'OpenFileBrowser_but_'.$id,
2471 "event" => "OpenFileBrowser_".$id,
2472 'MedialibConfig' => array(
2473 "event" => "OpenFileBrowser_ml_".$id,
2474 "arResultDest" => array("FUNCTION_NAME" => "SetVideoPath".$id)
2475 )
2476 ));?>
2477 <br />
2478 <a href="javascript: void(0)" onclick="return DisplayCont('bx_video_path_cont2_<?= $id?>', 'bx_video_path_cont1_<?= $id?>');" style="float: right;"><?= GetMessage('IBLOCK_PROP_VIDEO_PATH_FROM_PC')?></a>
2479 </div>
2480 <div id="bx_video_path_cont2_<?= $id?>">
2481 <input type="file" value="" id="bx_video_file_<?= $id?>" name= "<?= $name?>[FILE]" />
2482 <br />
2483 <a href="javascript: void(0)" onclick="return DisplayCont('bx_video_path_cont1_<?= $id?>', 'bx_video_path_cont2_<?= $id?>');" style="float: right;"><?= GetMessage('IBLOCK_PROP_VIDEO_PATH_FROM_FD')?></a>
2484 </div>
2485 </td>
2486 </tr>
2487 <?else:?>
2488 <tr>
2489 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_FILE')?>:</td>
2490 <td>
2491 <div id="bx_video_path_div_<?= $id?>" class="bx-path-div">
2492 <input type="text" size="25" value="<?= htmlspecialcharsex($path)?>" size="30" name="<?= $name?>[PATH]"/>
2493 </div>
2494 </td>
2495 </tr>
2496 <?endif;?>
2497
2498 <tr>
2499 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_SIZE')?>:</td>
2500 <td>
2501 <input id="bx_video_width_<?= $id?>" type="text" size="10" style="width: 70px;" value="<?= htmlspecialcharsbx($val['width'])?>" name= "<?= $name?>[WIDTH]" />
2502 x
2503 <input id="bx_video_height_<?= $id?>" type="text" size="10" style="width: 70px;" value="<?= htmlspecialcharsbx($val['height'])?>" name= "<?= $name?>[HEIGHT]" />
2504 </td>
2505 </tr>
2506 <tr class="heading"><td colSpan="2"><?= GetMessage('IBLOCK_PROP_VIDEO_PARAMS_TITLE_INFO')?></td></tr>
2507 <tr>
2508 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_TITLE')?>:</td>
2509 <td><input id="bx_video_title_<?= $id?>" type="text" size="30" value="<?= htmlspecialcharsbx($val['title'])?>" name="<?= $name?>[TITLE]" /></td>
2510 </tr>
2511 <tr>
2512 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_DURATION')?>:</td>
2513 <td><input id="bx_video_duration_<?= $id?>" type="text" size="30" value="<?= htmlspecialcharsbx($val['duration'])?>" name="<?= $name?>[DURATION]"/></td>
2514 </tr>
2515 <tr>
2516 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_AUTHOR')?>:</td>
2517 <td><input id="bx_video_author_<?= $id?>" type="text" size="30" value="<?= htmlspecialcharsbx($val['author'])?>" name="<?= $name?>[AUTHOR]"/></td>
2518 </tr>
2519 <tr>
2520 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_DATE')?>:</td>
2521 <td><input id="bx_video_date_<?= $id?>" type="text" size="30" value="<?= htmlspecialcharsbx($val['date'])?>" name="<?= $name?>[DATE]" /></td>
2522 </tr>
2523 <tr>
2524 <td class="bx-pr-title"><?= GetMessage('IBLOCK_PROP_VIDEO_DESC')?>:</td>
2525 <td><input id="bx_video_desc_<?= $id?>" type="text" size="30" value="<?= htmlspecialcharsbx($val['desc'])?>" name="<?= $name?>[DESC]"/></td>
2526 </tr>
2527</table>
2528<script>
2529function DisplayCont(id1, id2)
2530{
2531 var
2532 el1 = document.getElementById(id1),
2533 el2 = document.getElementById(id2);
2534
2535 if (el1 && el2)
2536 {
2537 el1.style.display = "block";
2538 el2.style.display = "none";
2539 }
2540 return false;
2541}
2542
2543function SetVideoPath<?= $id?>(filename, path, site)
2544{
2545 var
2546 url,
2547 srcInput = document.getElementById("bx_video_path_<?= $id?>");
2548
2549 if (typeof filename == 'object') // Using medialibrary
2550 {
2551 url = filename.src;
2552 document.getElementById("bx_video_title_<?= $id?>").value = filename.name || '';
2553 document.getElementById("bx_video_desc_<?= $id?>").value = filename.description || '';
2554 }
2555 else // Using file dialog
2556 {
2557 url = (path == '/' ? '' : path) + '/'+filename;
2558 }
2559
2560 srcInput.value = url;
2561 if(srcInput.onchange)
2562 srcInput.onchange();
2563 srcInput.focus();
2564 srcInput.select();
2565}
2566
2567function ChangeOrLeaveFile<?= $id?>(bChange)
2568{
2569 var
2570 pDiv = document.getElementById("bx_video_path_div_<?= $id?>"),
2571 pDelRow = document.getElementById("bx_video_del_row_<?= $id?>"),
2572 pBNewFile = document.getElementById("bx_video_b_new_file_<?= $id?>"),
2573 pNewFileRow = document.getElementById("bx_video_new_path_row_<?= $id?>"),
2574 _display = jsUtils.IsIE() ? "inline" : "table-row";
2575
2576 if (pBNewFile)
2577 pBNewFile.value = bChange ? "Y" : "N";
2578
2579 if (pDelRow)
2580 pDelRow.style.display = bChange ? _display : 'none';
2581
2582 if (pNewFileRow)
2583 pNewFileRow.style.display = bChange ? _display : 'none';
2584
2585 pDiv.className = bChange ? "bx-path-div bx-path-div-changed" : "bx-path-div";
2586
2587 return false;
2588}
2589</script>
2590</div>
2591<?
2592 $s = ob_get_contents();
2593 ob_end_clean();
2594 return $s;
2595 }
2596
2597 public static function BaseConvertToDB($value)
2598 {
2600
2601 $arRes = array("path" => "");
2602 if (!is_array($value))
2603 $value = array();
2604
2605 //In case of DB value just serialize it
2606 if (implode("|", array_keys($value)) === 'path|width|height|title|duration|author|date|desc')
2607 return serialize($value);
2608
2609 if ($value["B_NEW_FILE"] != "N") // New video or replacing old
2610 {
2611 if ($value["CUR_PATH"] <> '' && $value["DEL_CUR_FILE"] == "Y" && CIBlockPropertyVideo::CheckFileInUploadDir($value["CUR_PATH"]))
2612 {
2613 // del current file
2614 $cur_path_ = $_SERVER["DOCUMENT_ROOT"].Rel2Abs("/", $value["CUR_PATH"]);
2615 $flTmp = $io->GetFile($cur_path_);
2616 $flSzTmp = $flTmp->GetFileSize();
2617 if($io->Delete($cur_path_))
2618 {
2619 // Quota
2620 if(COption::GetOptionInt("main", "disk_space") > 0)
2621 CDiskQuota::updateDiskQuota("file", $flSzTmp, "delete");
2622 }
2623 }
2624
2625 // Get video
2626 if ($value["PATH"] <> '' )
2627 {
2628 $arRes["path"] = $value["PATH"];
2629 }
2630 else if (isset($value["FILE"]) && $value["FILE"]["tmp_name"] <> '')
2631 {
2632 $pathToDir = CIBlockPropertyVideo::GetUploadDirPath();
2633 if (!$io->DirectoryExists($_SERVER["DOCUMENT_ROOT"].$pathToDir))
2634 CFileMan::CreateDir($pathToDir);
2635
2636 // 1. Convert name
2637 $name = preg_replace("/[^a-zA-Z0-9_:\.]/is", "_", $value["FILE"]["name"]);
2638 $baseNamePart = mb_substr($name, 0, mb_strrpos($name, '.'));
2639 $ext = GetFileExtension($name);
2640
2641 if($ext <> '' && !HasScriptExtension($name) && mb_substr($name, 0, 1) != ".")
2642 {
2643 $ind = 0;
2644 // 2. Check if file already exists
2645 while($io->FileExists($_SERVER["DOCUMENT_ROOT"].Rel2Abs($pathToDir, $name)))
2646 $name = $baseNamePart."_(".++$ind.").".$ext; // 3. Rename
2647
2648 $pathto = Rel2Abs($pathToDir, $name);
2649 if (is_uploaded_file($value["FILE"]["tmp_name"])
2650 && $io->Copy($value["FILE"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"].$pathto))
2651 {
2652 $arRes["path"] = Rel2Abs("/", $pathto);
2653 // Quota
2654 if(COption::GetOptionInt("main", "disk_space") > 0)
2655 CDiskQuota::updateDiskQuota("file", $value["FILE"]["size"], "add");
2656 }
2657 }
2658 }
2659 }
2660 elseif ($value["CUR_PATH"] <> '') // save current file
2661 {
2662 if(preg_match("/^(http|https):\\/\\//", $value["CUR_PATH"]))
2663 $arRes["path"] = $value["CUR_PATH"];
2664 else
2665 $arRes["path"] = Rel2Abs("/", $value["CUR_PATH"]);
2666 }
2667
2668 // Width & height
2669 $arRes["width"] = intval($value["WIDTH"]);
2670 $arRes["height"] = intval($value["HEIGHT"]);
2671 if ($arRes["width"] < 0)
2672 $arRes["width"] = 400;
2673 if ($arRes["height"] < 0)
2674 $arRes["height"] = 300;
2675
2676 // Video info
2677 $arRes["title"] = $value["TITLE"];
2678 $arRes["duration"] = $value["DURATION"];
2679 $arRes["author"] = $value["AUTHOR"];
2680 $arRes["date"] = $value["DATE"];
2681 $arRes["desc"] = $value["DESC"];
2682
2683 $strRes = serialize($arRes);
2684 if ($arRes["path"] == "" && $arRes["title"] == "" && $arRes["author"] == "")
2685 return "";
2686
2687 return $strRes;
2688 }
2689
2690 public static function BaseConvertFromDB($val = "")
2691 {
2692 if (!is_array($val) && $val <> '')
2693 {
2694 $val = unserialize($val, ['allowed_classes' => false]);
2695 }
2696 return $val ? $val : array();
2697 }
2698
2699 public static function BaseCheckFields($val)
2700 {
2701 if (!is_array($val))
2702 return [];
2703
2704 $errors = [];
2705
2706 if ($val["B_NEW_FILE"] != "N" && isset($val["FILE"]) && $val['DEL_CUR_FILE'] != 'Y')
2707 {
2708 if(!empty($val["FILE"]["error"])) // !UPLOAD_ERR_OK
2709 {
2710 $fileName = isset($val["FILE"]["name"]) ? $val["FILE"]["name"] : '';
2711
2712 if($val["FILE"]["error"] === UPLOAD_ERR_INI_SIZE || $val["FILE"]["error"] === UPLOAD_ERR_FORM_SIZE)
2713 {
2714 $errors[] = GetMessage("IBLOCK_PROP_VIDEO_SIZE_ERROR", Array('#FILE_NAME#' => $fileName));
2715 }
2716 elseif($val["FILE"]["error"] !== UPLOAD_ERR_NO_FILE)
2717 {
2718 $errors[] = GetMessage("IBLOCK_PROP_VIDEO_UPLOAD_ERROR");
2719 }
2720 }
2721
2722 if($val["FILE"]["tmp_name"] <> '')
2723 {
2724 $name = $val["FILE"]["name"];
2725 $name = preg_replace("/[^a-zA-Z0-9_:\.]/is", "_", $name);
2726 $ext = GetFileExtension($name);
2727
2728 if($ext == '' || HasScriptExtension($name) || mb_substr($name, 0, 1) == ".")
2729 {
2730 $errors[] = GetMessage("IBLOCK_PROP_VIDEO_INCORRECT_EXT", array("#EXT#" => mb_strtoupper($ext)));
2731 }
2732 elseif (!is_uploaded_file($val["FILE"]["tmp_name"]))
2733 {
2734 $errors[] = GetMessage("IBLOCK_PROP_VIDEO_UPLOAD_ERROR");
2735 }
2736 else
2737 {
2738
2739 $quota = new CDiskQuota();
2740
2741 if (!$quota->checkDiskQuota(array("FILE_SIZE" => $val["FILE"]["size"])))
2742 {
2743 $errors[] = GetMessage("IBLOCK_PROP_VIDEO_QUOTE_ERROR");
2744 }
2745 }
2746 }
2747 }
2748
2749 return $errors;
2750 }
2751
2752 public static function BaseGetAdminListViewHTML($val)
2753 {
2754 if (!is_array($val) || $val["path"] == '')
2755 return '';
2756 return '<span style="white-space: nowrap;" title="'.htmlspecialcharsbx($val["path"]).'">'.GetMessage("IBLOCK_PROP_VIDEO").' ['.htmlspecialcharsex($val["path"]).']</span>';
2757 }
2758
2759 public static function BaseGetPublicHTML($set, $val)
2760 {
2761 if ($val["path"] == '')
2762 return '';
2763
2764 global $APPLICATION;
2765 ob_start();
2766 $title = $val['title'] <> '' ? $val['title'] : "";
2767?>
2768<div title="<?= addslashes($title)?>">
2769<?$APPLICATION->IncludeComponent(
2770 "bitrix:player",
2771 "",
2772 array(
2773 "PLAYER_TYPE" => "auto",
2774 "PATH" => $val["path"],
2775 "WIDTH" => $val['width'],
2776 "HEIGHT" => $val['height'],
2777 "FILE_TITLE" => $val['title'],
2778 "FILE_DURATION" => intval($val['duration']),
2779 "FILE_AUTHOR" => $val['author'],
2780 "FILE_DATE" => $val['date'],
2781 "FILE_DESCRIPTION" => $val['desc'],
2782 "SKIN_PATH" => CIBlockPropertyVideo::GetSkinPath(),
2783 "SKIN" => $set["SKIN"],
2784 "CONTROLBAR" => $set["CONTROLBAR"],
2785 "WMODE" => $set["WMODE_FLV"],
2786 "WMODE_WMV" => $set["WMODE_WMV"],
2787 "SHOW_CONTROLS" => $set["CONTROLBAR"] != 'none' ? "Y" : "N",
2788 "CONTROLS_BGCOLOR" => $set["CONTROLS_BGCOLOR"],
2789 "CONTROLS_COLOR" => $set["CONTROLS_COLOR"],
2790 "CONTROLS_OVER_COLOR" => $set["CONTROLS_OVER_COLOR"],
2791 "SCREEN_COLOR" => $set["SCREEN_COLOR"],
2792 "AUTOSTART" => $set["AUTOSTART"],
2793 "VOLUME" => $set["VOLUME"],
2794 "ADDITIONAL_FLASHVARS" => $set["FLASHVARS"],
2795 "BUFFER_LENGTH" => $set["BUFFER_LENGTH"],
2796 "ADDITIONAL_WMVVARS" => $set["SILVERVARS"],
2797 "ALLOW_SWF" => "N",
2798 "LOGO_POSITION" => "none"
2799 ),
2800 $APPLICATION->getCurrentIncludedComponent(),
2801 array('HIDE_ICONS' => 'Y')
2802); ?>
2803</div>
2804<?
2805 $s = ob_get_contents();
2806 ob_end_clean();
2807 return $s;
2808 }
2809
2810 public static function BaseOnSearchContent($val)
2811 {
2812 if(!is_array($val) && is_string($val))
2813 {
2814 $val = unserialize($val, ['allowed_classes' => false]);
2815 }
2816
2817 if(!is_array($val))
2818 {
2819 return '';
2820 }
2821
2822 $str = '';
2823
2824 if (!empty($val['path']))
2825 {
2826 if (!empty($val['title']))
2827 $str .= $val['title']." \n";
2828
2829 if (!empty($val['author']))
2830 $str .= $val['author']." \n";
2831
2832 if (!empty($val['desc']))
2833 $str .= $val['desc']." \n";
2834 }
2835
2836 return $str;
2837 }
2838
2839 public static function CheckFileInUploadDir($path = '')
2840 {
2841 $pathToDir = CVideoProperty::GetUploadDirPath();
2842 return mb_substr($path, 0, mb_strlen($pathToDir)) == $pathToDir;
2843 }
2844
2845 public static function GetUploadDirPath()
2846 {
2847 return "/upload/video/";
2848 }
2849
2850 public static function GetSkinPath()
2851 {
2852 return "/bitrix/components/bitrix/player/mediaplayer/skins";
2853 }
2854
2855}
2856
2857if (!function_exists('getSkinsEx'))
2858{
2859 function getSkinsEx($path)
2860 {
2861 $basePath = $_SERVER["DOCUMENT_ROOT"].Rel2Abs("/", $path);
2862 $arSkins = Array();
2863
2864 if (!is_dir($basePath)) // Not valid folder
2865 return $arSkins;
2866
2867 $arSkins = getSkinsFromDir($path);
2868
2869 $handle = @opendir($basePath);
2870
2871 while(false !== ($skinDir = @readdir($handle)))
2872 {
2873
2874 if(!is_dir($basePath.'/'.$skinDir) || $skinDir == "." || $skinDir == ".." )
2875 continue;
2876
2877 $arSkins = array_merge($arSkins,getSkinsFromDir($path.'/'.$skinDir));
2878 }
2879 return $arSkins;
2880 }
2881
2882 function getSkinsFromDir($path) //http://jabber.bx/view.php?id=28856
2883 {
2884 $basePath = $_SERVER["DOCUMENT_ROOT"].Rel2Abs("/", $path);
2885 $arSkinExt = array('swf', 'zip', 'css');
2886 $arPreviewExt = array('png', 'gif', 'jpg', 'jpeg');
2887 $prExtCnt = count($arPreviewExt);
2888 $arSkins = Array();
2889 $handle = @opendir($basePath);
2890
2891 while(false !== ($f = @readdir($handle)))
2892 {
2893 if($f == "." || $f == ".." || $f == ".htaccess" || !is_file($basePath.'/'.$f))
2894 continue;
2895
2896 $ext = mb_strtolower(GetFileExtension($f));
2897 if (in_array($ext, $arSkinExt)) // We find skin
2898 {
2899 $name = mb_substr($f, 0, -mb_strlen($ext) - 1); // name of the skin
2900 if ($name == '')
2901 continue;
2902
2903 if (mb_strpos($name, '.min') !== false)
2904 continue;
2905
2906 $Skin = array('filename' => $f);
2907 $Skin['name'] = mb_strtoupper(mb_substr($name, 0, 1)).mb_strtolower(mb_substr($name, 1));
2908 $Skin['the_path'] = $path;
2909
2910 // Try to find preview
2911 for ($i = 0; $i < $prExtCnt; $i++)
2912 {
2913 if (file_exists($basePath.'/'.$name.'.'.$arPreviewExt[$i]))
2914 {
2915 $Skin['preview'] = $name.'.'.$arPreviewExt[$i];
2916 break;
2917 }
2918 }
2919 $arSkins[] = $Skin;
2920 }
2921 }
2922
2923 return $arSkins;
2924 }
2925}
2926
2927// ### Iblock property ###
2928class CIBlockPropertyVideo extends CVideoProperty
2929{
2930 public static function GetUserTypeDescription()
2931 {
2932 if (Loader::includeModule("bitrix24"))
2933 {
2934 return [];
2935 }
2936
2937 return array(
2938 "PROPERTY_TYPE" => "S",
2939 "USER_TYPE" => "video",
2940 "DESCRIPTION" => GetMessage("IBLOCK_PROP_VIDEO"),
2941 "GetPropertyFieldHtml" => array(__CLASS__, "GetPropertyFieldHtml"),
2942 "GetPublicViewHTML" => array(__CLASS__, "GetPublicViewHTML"),
2943 "ConvertToDB" => array(__CLASS__, "ConvertToDB"),
2944 "ConvertFromDB" => array(__CLASS__, "ConvertFromDB"),
2945 "CheckFields" => array(__CLASS__, "CheckFields"),
2946 "GetSearchContent" => array(__CLASS__, "GetSearchContent"),
2947 "GetSettingsHTML" => array(__CLASS__, "GetSettingsHTML"),
2948 "PrepareSettings" => array(__CLASS__, "PrepareSettings"),
2949 "GetAdminListViewHTML" => array(__CLASS__, "GetAdminListViewHTML"),
2950 "GetLength" => array(__CLASS__, "GetLength"),
2951 'GetUIEntityEditorProperty' => array(__CLASS__, 'GetUIEntityEditorProperty'),
2952 'GetUIEntityEditorPropertyEditHtml' => array(__CLASS__, 'GetUIEntityEditorPropertyEditHtml'),
2953 'GetUIEntityEditorPropertyViewHtml' => array(__CLASS__, 'GetUIEntityEditorPropertyViewHtml'),
2954 );
2955 }
2956
2957 public static function GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
2958 {
2959 $dbVal = CUserTypeVideo::BaseConvertToDB($value["VALUE"]);
2960 $val = CUserTypeVideo::BaseConvertFromDB($dbVal);
2961 return CIBlockPropertyVideo::BaseGetEditFormHTML($arProperty["USER_TYPE_SETTINGS"], $val, $strHTMLControlName["VALUE"], $strHTMLControlName["MODE"]);
2962 }
2963
2964 public static function GetAdminListViewHTML($arProperty, $value, $strHTMLControlName)
2965 {
2966 return CIBlockPropertyVideo::BaseGetAdminListViewHTML($value["VALUE"]);
2967 }
2968
2969 public static function GetPublicViewHTML($arProperty, $value, $strHTMLControlName)
2970 {
2971 $pathExist = (isset($value['VALUE']['path']) && $value['VALUE']['path'] != '');
2972 if (isset($strHTMLControlName['MODE']) && $strHTMLControlName['MODE'] == 'CSV_EXPORT')
2973 return ($pathExist ? $value['VALUE']['path'] : '');
2974 elseif (isset($strHTMLControlName['MODE']) && $strHTMLControlName['MODE'] == 'SIMPLE_TEXT')
2975 return ($pathExist ? $value['VALUE']['path'] : '');
2976 else
2977 return CIBlockPropertyVideo::BaseGetPublicHTML($arProperty["USER_TYPE_SETTINGS"], $value["VALUE"]);
2978 }
2979
2980 public static function ConvertFromDB($arProperty, $value)
2981 {
2982 $value['VALUE'] = CIBlockPropertyVideo::BaseConvertFromDB($value['VALUE'] ?? null) ?: '';
2983 return $value;
2984 }
2985
2986 public static function ConvertToDB($arProperty, $value)
2987 {
2988 return ["VALUE" => CIBlockPropertyVideo::BaseConvertToDB($value["VALUE"])];
2989 }
2990
2991 public static function CheckFields($arProperty, $value)
2992 {
2993 return CIBlockPropertyVideo::BaseCheckFields($value["VALUE"]);
2994 }
2995
2996 public static function GetLength($arProperty, $value)
2997 {
2998 if(
2999 is_array($value)
3000 && array_key_exists("VALUE", $value)
3001 && is_array($value["VALUE"])
3002 )
3003 {
3004 if(
3005 array_key_exists("PATH", $value["VALUE"])
3006 && trim($value["VALUE"]["PATH"]) <> ''
3007 )
3008 return 1;
3009
3010 if(
3011 array_key_exists("FILE", $value["VALUE"])
3012 && is_array($value["VALUE"]["FILE"])
3013 && $value["VALUE"]["FILE"]["error"] === 0
3014 )
3015 return 1;
3016
3017 if(
3018 array_key_exists("CUR_PATH", $value["VALUE"])
3019 && mb_strlen(trim($value["VALUE"]["CUR_PATH"]))
3020 && !($value["VALUE"]["B_NEW_FILE"] === "Y" && $value["VALUE"]["DEL_CUR_FILE"] === "Y")
3021 )
3022 return 1;
3023 }
3024
3025 return 0;
3026 }
3027
3028 public static function PrepareSettings($arProperty)
3029 {
3030 $arResult = CUserTypeVideo::BasePrepareSettings($arProperty, "USER_TYPE_SETTINGS");
3031 $arFields['SMART_FILTER'] = 'N';
3032 $arFields['FILTRABLE'] = 'N';
3033 $arFields['USER_TYPE_SETTINGS'] = $arResult;
3034
3035 return $arFields;
3036 }
3037
3038 public static function GetSettingsHTML($arProperty, $strHTMLControlName, &$arPropertyFields)
3039 {
3040 $arPropertyFields = array(
3041 "HIDE" => array("FILTRABLE", "ROW_COUNT", "COL_COUNT", "DEFAULT_VALUE", "SMART_FILTER"), //will hide the field
3042 "SET" => array("FILTRABLE" => "N", "SMART_FILTER" => "N"), //if set then hidden field will get this value
3043 "USER_TYPE_SETTINGS_TITLE" => GetMessage("IBLOCK_PROP_VIDEO_SET_NAME")
3044 );
3045
3046 $arSettings = CIBlockPropertyVideo::PrepareSettings($arProperty);
3047 if (isset($arSettings['USER_TYPE_SETTINGS']))
3048 $arSettings = $arSettings['USER_TYPE_SETTINGS'];
3049
3050 return CIBlockPropertyVideo::BaseGetSettingsHTML($strHTMLControlName["NAME"], $arSettings);
3051 }
3052
3053 public static function GetSearchContent($arProperty, $value, $strHTMLControlName)
3054 {
3055 return CIBlockPropertyVideo::BaseOnSearchContent($value["VALUE"]);
3056 }
3057
3058 public static function GetUIEntityEditorProperty($settings, $value)
3059 {
3060 return [
3061 'type' => 'custom'
3062 ];
3063 }
3064
3065 public static function GetUIEntityEditorPropertyEditHtml(array $params = []) : string
3066 {
3067 $settings = $params['SETTINGS'] ?? [];
3068
3069 if ($settings['MULTIPLE'] === 'Y')
3070 {
3071 if (is_array($params['VALUE']))
3072 {
3073 $editor = '';
3074
3075 for($index = 0; $index < $params['SETTINGS']['MULTIPLE_CNT']; $index++)
3076 {
3077 $value = [
3078 'VALUE' => $params['VALUE'][$index] ?? []
3079 ];
3080 $paramsHTMLControl = [
3081 'VALUE' => $params['FIELD_NAME'] . '[' . $index . ']' ?? '[' . $index . ']',
3082 ];
3083 $editor .= static::GetPropertyFieldHtml($settings, $value, $paramsHTMLControl);
3084 }
3085
3086 return $editor;
3087 }
3088 }
3089
3090 $value = [
3091 'VALUE' => $params['VALUE'] ?? []
3092 ];
3093 $paramsHTMLControl = [
3094 'VALUE' => $params['FIELD_NAME'] ?? '',
3095 ];
3096
3097 return static::GetPropertyFieldHtml($settings, $value, $paramsHTMLControl);
3098 }
3099
3100 public static function GetUIEntityEditorPropertyViewHtml(array $params = []) : string
3101 {
3102 $settings = $params['SETTINGS'] ?? [];
3103 $paramsHTMLControl = [
3104 'VALUE' => $params['FIELD_NAME'] ?? '',
3105 ];
3106
3107 if ($settings['MULTIPLE'] === 'Y')
3108 {
3109 $multipleResult = '';
3110 if (is_array($params['VALUE']))
3111 {
3112 foreach ($params['VALUE'] as $element)
3113 {
3114 $value = [
3115 'VALUE' => empty($element) ? [] : $element
3116 ];
3117 $multipleResult .= static::GetPublicViewHTML($settings, $value, $paramsHTMLControl) . '<br>';
3118 }
3119 }
3120 return $multipleResult;
3121 }
3122 else
3123 {
3124 $value = [
3125 'VALUE' => empty($params['VALUE']) ? [] : $params['VALUE']
3126 ];
3127 }
3128
3129 return static::GetPublicViewHTML($settings, $value, $paramsHTMLControl);
3130 }
3131}
3132
3133// ### UserType for main module ###
3134class CUserTypeVideo extends CVideoProperty
3135{
3136 public static function GetUserTypeDescription()
3137 {
3138 return array(
3139 "USER_TYPE_ID" => "video",
3140 "CLASS_NAME" => "CUserTypeVideo",
3141 "DESCRIPTION" => GetMessage("IBLOCK_PROP_VIDEO"),
3142 "BASE_TYPE" => "string"
3143 );
3144 }
3145
3146 public static function GetDBColumnType($arUserField)
3147 {
3148 $connection = \Bitrix\Main\Application::getConnection();
3149 $helper = $connection->getSqlHelper();
3150 return $helper->getColumnTypeByField(new \Bitrix\Main\ORM\Fields\TextField('x'));
3151 }
3152
3153 public static function PrepareSettings($arProperty)
3154 {
3155 return CUserTypeVideo::BasePrepareSettings($arProperty, "SETTINGS");
3156 }
3157
3158 public static function GetSettingsHTML($arUserField, $arHtmlControl, $bVarsFromForm)
3159 {
3160 if(!is_array($arUserField))
3161 $arUserField = array();
3162
3163 $arUserField["SETTINGS"] = $bVarsFromForm ? $GLOBALS[$arHtmlControl["NAME"]] : CUserTypeVideo::PrepareSettings($arUserField);
3164 return CUserTypeVideo::BaseGetSettingsHTML($arHtmlControl["NAME"], $arUserField["SETTINGS"]);
3165 }
3166
3167 public static function GetEditFormHTML($arUserField, $arHtmlControl)
3168 {
3169 $val = CUserTypeVideo::BaseConvertFromDB(htmlspecialcharsback($arHtmlControl["VALUE"])); // Unserialize array
3170 return CUserTypeVideo::BaseGetEditFormHTML($arUserField["SETTINGS"], $val, $arHtmlControl["NAME"]);
3171 }
3172
3173 public static function OnBeforeSave($arUserField, $value)
3174 {
3175 return CUserTypeVideo::BaseConvertToDB($value);
3176 }
3177
3178 public static function GetAdminListViewHTML($arUserField, $arHtmlControl)
3179 {
3180 $val = CUserTypeVideo::BaseConvertFromDB(htmlspecialcharsback($arHtmlControl["VALUE"])); // Unserialize array
3181 return CUserTypeVideo::BaseGetAdminListViewHTML($val);
3182 }
3183
3184 public static function CheckFields($arUserField, $value)
3185 {
3186 $result = CUserTypeVideo::BaseCheckFields($value);
3187
3188 if(!empty($result) && is_array($result))
3189 {
3190 foreach($result as $idx => $message)
3191 {
3192 $result[$idx] = ['text' => $message];
3193 }
3194 }
3195
3196 return $result;
3197 }
3198
3199 public static function OnSearchIndex($arUserField)
3200 {
3201 return CIBlockPropertyVideo::BaseOnSearchContent($arUserField["VALUE"]);
3202 }
3203
3204 public static function GetPublicViewHTML($arUserField, $arHtmlControl)
3205 {
3206 $val = CUserTypeVideo::BaseConvertFromDB(htmlspecialcharsback($arHtmlControl["VALUE"])); // Unserialize array
3207 return CUserTypeVideo::BaseGetPublicHTML($arUserField["SETTINGS"], $val);
3208 }
3209
3210 public static function canUseArrayValueForSingleField(): bool
3211 {
3212 return true;
3213 }
3214}
return[Dependency::CONTAINER=> Container::class, Dependency::IBLOCK_INFO=> IblockInfo::class, Dependency::PRODUCT_CONVERTER=> ProductConverter::class, Dependency::REPOSITORY_FACADE=> Repository::class, Dependency::PRODUCT_FACTORY=> ProductFactory::class, Dependency::PRODUCT_REPOSITORY=> ProductRepository::class, ProductFactory::PRODUCT=> Product::class, Dependency::SECTION_FACTORY=> SectionFactory::class, Dependency::SECTION_REPOSITORY=> SectionRepository::class, SectionFactory::SECTION=> Section::class, SectionFactory::SECTION_COLLECTION=> SectionCollection::class, Dependency::SKU_FACTORY=> SkuFactory::class, Dependency::SKU_REPOSITORY=> SkuRepository::class, SkuFactory::SIMPLE_SKU=> SimpleSku::class, SkuFactory::SKU=> Sku::class, SkuFactory::SKU_COLLECTION=> SkuCollection::class, Dependency::PROPERTY_FACTORY=> PropertyFactory::class, Dependency::PROPERTY_REPOSITORY=> PropertyRepository::class, PropertyFactory::PROPERTY=> Property::class, PropertyFactory::PROPERTY_COLLECTION=> PropertyCollection::class, Dependency::PROPERTY_VALUE_FACTORY=> PropertyValueFactory::class, PropertyValueFactory::PROPERTY_VALUE=> PropertyValue::class, PropertyValueFactory::PROPERTY_VALUE_COLLECTION=> PropertyValueCollection::class, Dependency::PROPERTY_FEATURE_FACTORY=> PropertyFeatureFactory::class, Dependency::PROPERTY_FEATURE_REPOSITORY=> PropertyFeatureRepository::class, PropertyFeatureFactory::PROPERTY_FEATURE=> PropertyFeature::class, PropertyFeatureFactory::PROPERTY_FEATURE_COLLECTION=> PropertyFeatureCollection::class, Dependency::PRICE_FACTORY=> PriceFactory::class, Dependency::PRICE_REPOSITORY=> PriceRepository::class, PriceFactory::SIMPLE_PRICE=> SimplePrice::class, PriceFactory::QUANTITY_DEPENDENT_PRICE=> QuantityDependentPrice::class, PriceFactory::PRICE_COLLECTION=> PriceCollection::class, Dependency::IMAGE_FACTORY=> ImageFactory::class, Dependency::IMAGE_REPOSITORY=> ImageRepository::class, ImageFactory::DETAIL_IMAGE=> DetailImage::class, ImageFactory::PREVIEW_IMAGE=> PreviewImage::class, ImageFactory::MORE_PHOTO_IMAGE=> MorePhotoImage::class, ImageFactory::IMAGE_COLLECTION=> ImageCollection::class, Dependency::MEASURE_RATIO_FACTORY=> MeasureRatioFactory::class, Dependency::MEASURE_RATIO_REPOSITORY=> MeasureRatioRepository::class, MeasureRatioFactory::SIMPLE_MEASURE_RATIO=> SimpleMeasureRatio::class, MeasureRatioFactory::MEASURE_RATIO_COLLECTION=> MeasureRatioCollection::class, Dependency::BARCODE_FACTORY=> BarcodeFactory::class, Dependency::BARCODE_REPOSITORY=> BarcodeRepository::class, BarcodeFactory::BARCODE=> Barcode::class, BarcodeFactory::BARCODE_COLLECTION=> BarcodeCollection::class, Dependency::STORE_PRODUCT_FACTORY=> StoreProductFactory::class, Dependency::STORE_PRODUCT_REPOSITORY=> StoreProductRepository::class, StoreProductFactory::STORE_PRODUCT=> StoreProduct::class, StoreProductFactory::STORE_PRODUCT_COLLECTION=> StoreProductCollection::class, 'sku.tree'=> SkuTree::class, 'integration.seo.facebook.facade'=> FacebookFacade::class, 'integration.seo.facebook.product.processor'=> FacebookProductProcessor::class, 'integration.seo.facebook.product.repository'=> FacebookProductRepository::class,]
Определения .container.php:139
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
return select
Определения access_edit.php:440
$connection
Определения actionsdefinitions.php:38
$basePath
Определения include.php:41
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
Определения loader.php:13
static getList(array $parameters=array())
Определения datamanager.php:431
static ShowScript($arConfig)
Определения file_dialog.php:9
static GetInstance()
Определения virtual_io.php:60
static CreateDir($path)
Определения fileman.php:348
static GetUIEntityEditorPropertyEditHtml(array $params=[])
Определения properties.php:729
static PrepareSettings($arProperty)
Определения properties.php:135
static GetSettingsHTML($arProperty, $strHTMLControlName, &$arPropertyFields)
Определения properties.php:115
static GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
Определения properties.php:146
static GetUserTypeDescription()
Определения properties.php:97
static GetUIEntityEditorPropertyViewHtml(array $params=[])
Определения properties.php:757
static GetUIEntityEditorProperty($settings, $value)
Определения properties.php:722
static GetPublicViewHTML($arProperty, $value, $arParams)
Определения properties.php:675
static _GetMapKey($map_type, &$strDomain)
Определения properties.php:73
static GetPublicViewHTML($arProperty, $value, $strHTMLControlName)
static GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
static GetAdminListViewHTML($arProperty, $value, $strHTMLControlName)
Определения properties.php:16
static ConvertFromDB($arProperty, $value)
Определения properties.php:23
static ConvertToDB($arProperty, $value)
Определения properties.php:48
const VALUE_SEPARATOR
Определения properties.php:11
static GetUIEntityEditorPropertyEditHtml(array $params=[])
Определения properties.php:2082
static PrepareSettings($arProperty)
Определения properties.php:916
static GetSettingsHTML($arProperty, $strHTMLControlName, &$arPropertyFields)
Определения properties.php:906
static GetPublicEditHTML($arProperty, $value, $strHTMLControlName)
Определения properties.php:1437
static GetPropertyFieldHtml($arProperty, $value, $strHTMLControlName)
Определения properties.php:925
static GetUserTypeDescription()
Определения properties.php:799
static GetUIEntityEditorPropertyViewHtml(array $params=[])
Определения properties.php:2110
static GetUIEntityEditorProperty($settings, $value)
Определения properties.php:2075
static _DrawKeyInputControl($MAP_ID, $strDomain)
Определения properties.php:862
static GetPublicViewHTML($arProperty, $value, $arParams)
Определения properties.php:2027
$str
Определения commerceml2.php:63
$f
Определения component_props.php:52
$arFields
Определения dblapprove.php:5
collapse(node)
Определения ebay_mip_setup.php:316
$bVarsFromForm
Определения file_edit.php:44
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
Определения file_new.php:759
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
Определения file_new.php:677
background position
Определения file_new.php:745
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
background color
Определения file_new.php:745
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
hidden mSiteList<?=htmlspecialcharsbx(serialize( $siteList))?><?=htmlspecialcharsbx( $siteList[ $j]["ID"])?> _Propery<? if(((COption::GetOptionString( $module_id, "different_set", "N")=="Y") &&( $j !=0))||(COption::GetOptionString( $module_id, "different_set", "N")=="N")) echo "display: none;"?> top adm detail content cell l top adm detail content cell r heading center center ID left
Определения options.php:768
EndNote()
Определения filter_tools.php:601
BeginNote($sParams='', $sMessParams='')
Определения filter_tools.php:589
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
$portalZone
Определения .description.php:14
$licensePrefix
Определения .description.php:15
$errors
Определения iblock_catalog_edit.php:74
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
if(preg_match('/^ else[a-z0-9_]{2}$/i', $siteID)===1)
Определения cron_frame.php:23
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
handleError($rcpt, $rcptErrors)
Определения mail_entry.php:20
GetFileExtension($path)
Определения tools.php:2972
htmlspecialcharsback($str)
Определения tools.php:2693
HasScriptExtension($check_name)
Определения tools.php:2956
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
Rel2Abs($curdir, $relpath)
Определения tools.php:3297
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$name
Определения menu_edit.php:35
$value
Определения Param.php:39
$message
Определения payment.php:8
$settings
Определения product_settings.php:43
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
$GLOBALS['YANDEX_MAP_PROPERTY']
Определения properties.php:7
$fileName
Определения quickway.php:305
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
font style
Определения invoice.php:442
font size
Определения invoice.php:442
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
text align
Определения template.php:556
$title
Определения pdf.php:123
$val
Определения options.php:1793
margin right
Определения options_user_settings.php:273
$arRes
Определения options.php:104
path
Определения template_copy.php:201
$GLOBALS['_____370096793']
Определения update_client.php:1
adm detail iblock types adm detail iblock list tr_SITE_ID display
Определения yandex_setup.php:388