8 $cachePath =
"medialib/";
10 public static function Init(){}
11 public static function GetOperations($collectionId, $menu =
false)
17 $userGroups =
$USER->GetUserGroupArray();
18 $key = $collectionId.
'|'.implode(
'-', $userGroups);
20 if (!is_array($arOp[
$key] ??
null))
25 if (!is_array($oCollections))
27 $res = CMedialib::GetCollectionTree(
array(
'menu' => $menu));
28 $oCollections =
$res[
'Collections'];
31 $userGroups =
$USER->GetUserGroupArray();
32 $res = CMedialib::GetAccessPermissionsArray($collectionId, $oCollections);
35 foreach (
$res as $group_id => $task_id)
37 if (in_array($group_id, $userGroups))
44 public static function CanDoOperation($operation, $collectionId=0,
$userId =
false, $menu =
false)
49 $arOp = CMedialib::GetOperations($collectionId, $menu);
50 return in_array($operation, $arOp);
53 public static function GetAccessPermissionsArray($collectionId = 0, $oCollections =
false)
56 if (is_array($arAllTasks[$collectionId] ??
null))
57 return $arAllTasks[$collectionId];
59 $col = $oCollections[$collectionId] ?? [];
60 $col[
'PARENT_ID'] = $col[
'PARENT_ID'] ??
null;
64 if ($col || $collectionId == 0)
67 if (intval($col[
'PARENT_ID']) > 0)
70 while($col_ && intval($col_[
'PARENT_ID']) > 0)
73 $col_ = $oCollections[$col_[
'PARENT_ID']];
77 $arPerm = CMedialib::_GetAccessPermissions(
$arCols);
82 if (is_array($arPerm[$colId] ??
null))
84 for ($j = 0,
$n =
count($arPerm[$colId]); $j <
$n; $j++)
85 $resTask[$arPerm[$colId][$j][
'GROUP_ID']] = $arPerm[$colId][$j][
'TASK_ID'];
90 if (!is_array($arAllTasks))
91 $arAllTasks =
array();
92 $arAllTasks[$collectionId] = $resTask;
97 public static function _GetAccessPermissions(
$arCols =
array())
106 FROM b_group_collection_task GCT
107 WHERE GCT.COLLECTION_ID in ('.$s.
')';
114 $colid =
$arRes[
'COLLECTION_ID'];
115 if (!is_array(
$arResult[$colid] ??
null))
118 unset(
$arRes[
'COLLECTION_ID']);
125 public static function getMaximumFileUploadSize()
127 return min(CUtil::Unformat(ini_get(
'post_max_size')), CUtil::Unformat(ini_get(
'upload_max_filesize')));
130 public static function ShowDialogScript($arConfig =
array())
137 $arConfig[
'bReadOnly'] =
false;
138 $arConfig[
'lang'] = LANGUAGE_ID;
141 if (isset($arConfig[
'event']))
142 $event = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $arConfig[
'event']);
147 $bDest = is_array($arConfig[
'arResultDest']);
150 if (isset($arConfig[
'arResultDest'][
"FUNCTION_NAME"]))
152 $arConfig[
'arResultDest'][
"FUNCTION_NAME"] = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $arConfig[
'arResultDest'][
"FUNCTION_NAME"]);
153 $bDest = $arConfig[
'arResultDest'][
"FUNCTION_NAME"] <>
'';
154 $resultDest =
"FUNCTION";
156 elseif (isset($arConfig[
'arResultDest'][
"FORM_NAME"], $arConfig[
'arResultDest'][
"FORM_ELEMENT_NAME"]))
158 $arConfig[
'arResultDest'][
"FORM_NAME"] = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $arConfig[
'arResultDest'][
"FORM_NAME"]);
159 $arConfig[
'arResultDest'][
"FORM_ELEMENT_NAME"] = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $arConfig[
'arResultDest'][
"FORM_ELEMENT_NAME"]);
160 $bDest = $arConfig[
'arResultDest'][
"FORM_NAME"] <>
'' && $arConfig[
'arResultDest'][
"FORM_ELEMENT_NAME"] <>
'';
161 $resultDest =
"FORM";
163 elseif (isset($arConfig[
'arResultDest'][
"ELEMENT_ID"]))
165 $arConfig[
'arResultDest'][
"ELEMENT_ID"] = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $arConfig[
'arResultDest'][
"ELEMENT_ID"]);
166 $bDest = $arConfig[
'arResultDest'][
"ELEMENT_ID"] <>
'';
181 if (!window.BX &&
top.BX)
184 <?CMedialib::AppendLangMessages();?>
185 window.<?= $arConfig[
'event']?> =
function(bLoadJS)
187 if (window.oBXMedialib && window.oBXMedialib.bOpened)
190 <?
if(!CMedialib::CanDoOperation(
'medialib_view_collection', 0)):?>
191 return alert(ML_MESS.AccessDenied);
194 if (!window.BXMediaLib)
196 if (bLoadJS !==
false)
199 BX.loadCSS(
"/bitrix/js/fileman/medialib/medialib.css");
202 if (!window.jsAjaxUtil)
203 arJS.push(
"/bitrix/js/main/ajax.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT
"].'/bitrix/js/main/ajax.js')?>");
205 arJS.push(
"/bitrix/js/main/utils.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT
"].'/bitrix/js/main/utils.js')?>");
206 if (!window.CHttpRequest)
207 arJS.push(
"/bitrix/js/main/admin_tools.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT
"].'/bitrix/js/main/admin_tools.js')?>");
209 arJS.push(
"/bitrix/js/fileman/medialib/common.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT
"].'/bitrix/js/fileman/medialib/common.js')?>");
210 arJS.push(
"/bitrix/js/fileman/medialib/core.js?v=<?= filemtime($_SERVER["DOCUMENT_ROOT
"].'/bitrix/js/fileman/medialib/core.js')?>");
213 return setTimeout(
function(){<?=$arConfig[
'event']?>(
false)}, 50);
216 <?CMedialib::ShowJS()?>
218 $arSet = explode(
',' , CUserOptions::GetOption(
"fileman",
"medialib_user_set",
'600,450,0'));
219 $width = $arSet[0] ? intval($arSet[0]) : 600;
220 $height = $arSet[1] ? intval($arSet[1]) : 450;
221 $coll_id = $arSet[2] ? intval($arSet[2]) : 0;
223 window._mlUserSettings = window._mlUserSettings || {
width: <?=
$width?>,
height: <?=$height?>, coll_id: <?=$coll_id?>}
227 sessid:
"<?=bitrix_sessid()?>",
230 userSettings : window._mlUserSettings,
231 resType:
"<?= $resultDest?>",
235 new_col:
'<?= CMedialib::CanDoOperation('medialib_new_collection
', 0)?>',
236 edit:
'<?= CMedialib::CanDoOperation('medialib_edit_collection
', 0)?>',
237 del:
'<?= CMedialib::CanDoOperation('medialib_del_collection
', 0)?>',
238 new_item:
'<?= CMedialib::CanDoOperation('medialib_new_item
', 0)?>',
239 edit_item:
'<?= CMedialib::CanDoOperation('medialib_edit_item
', 0)?>',
240 del_item:
'<?= CMedialib::CanDoOperation('medialib_del_item
', 0)?>',
241 access:
'<?= CMedialib::CanDoOperation('medialib_access
', 0)?>'
243 bCanUpload: <?=
$USER->CanDoOperation(
'fileman_upload_files') ?
'true' :
'false'?>,
244 bCanViewStructure: <?=
$USER->CanDoOperation(
'fileman_view_file_structure') ?
'true' :
'false'?>,
245 strExt :
"<?= CUtil::JSEscape(CMedialib::GetMediaExtentions())?>",
246 lang :
"<?= $arConfig['lang']?>",
247 description_id :
'<?= CUtil::JSEscape($arConfig['description_id
'] ?? null)?>'
250 window.oBXMedialib =
new BXMediaLib(oConfig);
259 echo
'<font color="#FF0000">'.htmlspecialcharsbx($strWarn).
'</font>';
263 public static function AttachJSScripts()
265 if(!defined(
"BX_B_MEDIALIB_SCRIPT_LOADED"))
267 define(
"BX_B_MEDIALIB_SCRIPT_LOADED",
true);
269BX.loadScript(
"/bitrix/js/main/file_dialog.js?v=<?=@filemtime($_SERVER['DOCUMENT_ROOT'].'/bitrix/js/main/file_dialog.js')?>");
274 public static function AppendLangMessages()
277if (typeof ML_MESS ===
"undefined")
281 AccessDenied :
'<?= GetMessageJS('ML_ACCESS_DENIED
')?>',
282 SessExpired :
'<?= GetMessageJS('ML_SESS_EXPIRED
')?>',
283 DelCollection :
'<?= GetMessageJS('ML_DEL_COLLECTION
')?>',
284 DelItem :
'<?= GetMessageJS('ML_DEL_ITEM
')?>',
285 DelCollectionConf :
'<?= GetMessageJS('ML_DEL_COLLECTION_CONFIRM
')?>',
286 DelItemConf :
'<?= GetMessageJS('ML_DEL_ITEM_CONFIRM
')?>',
287 EditCollection :
'<?= GetMessageJS('ML_EDIT_COLLECTION
')?>',
288 EditItem :
'<?= GetMessageJS('ML_EDIT_ITEM
')?>',
289 NewCollection :
'<?= GetMessageJS('ML_NEW_COLLECTION
')?>',
290 Collection :
'<?= GetMessageJS('ML_COLLECTION
')?>',
291 ColLocEr :
'<?= GetMessageJS('ML_COL_LOC_ER
')?>',
292 ColLocEr2 :
'<?= GetMessageJS('ML_COL_LOC_ER2
')?>',
293 Item :
'<?= GetMessageJS('ML_ITEM
')?>',
294 NewItem :
'<?= GetMessageJS('ML_NEW_ITEM
')?>',
295 DelColFromItem :
'<?= GetMessageJS('ML_DEL_COL2ITEM
')?>',
296 ItemNoColWarn :
'<?= GetMessageJS('ML_COL2ITEM_WARN
')?>',
297 DateModified :
'<?= GetMessageJS('ML_DATE_MODIFIED
')?>',
298 FileSize :
'<?= GetMessageJS('ML_FILE_SIZE
')?>',
299 ImageSize :
'<?= GetMessageJS('ML_IMAGE_SIZE
')?>',
300 CheckedColTitle :
'<?= GetMessageJS('ML_CHECKED_COL_TITLE
')?>',
301 ItSourceError :
'<?= GetMessageJS('ML_SOURCE_ERROR
')?>',
302 ItFileSizeError :
'<?= GetMessageJS('ML_FILESIZE_ERROR
')?>',
303 ItNameError :
'<?= GetMessageJS('ML_NAME_ERROR
')?>',
304 ItCollsError :
'<?= GetMessageJS('ML_COLLS_ERROR
')?>',
305 ColNameError :
'<?= GetMessageJS('ML_COL_NAME_ERROR
')?>',
306 DelItConfTxt :
'<?= GetMessageJS('ML_DEL_CONF_TEXT
')?>',
307 DelItB1 :
'<?= GetMessageJS('ML_DEL_IT_B1
')?>',
308 DelItB2 :
'<?= GetMessageJS('ML_DEL_IT_B2
')?>',
309 CollAccessDenied :
'<?= GetMessageJS('ML_COLL_ACCESS_DENIED
')?>',
310 CollAccessDenied2 :
'<?= GetMessageJS('ML_COLL_ACCESS_DENIED2
')?>',
311 CollAccessDenied3:
'<?= GetMessageJS('ML_COLL_ACCESS_DENIED3
')?>',
312 CollAccessDenied4:
'<?= GetMessageJS('ML_COLL_ACCESS_DENIED4
')?>',
313 BadSubmit:
'<?= GetMessageJS('ML_BAD_SUBMIT
')?>',
314 ItemExtError:
'<?= GetMessageJS('ML_ITEM_EXT_ERROR
')?>',
315 EditItemError:
'<?= GetMessageJS('ML_EDIT_ITEM_ERROR
')?>',
316 SearchResultEx:
'<?= GetMessageJS('ML_SEARCH_RESULT_EX
')?>',
317 DelElConfirm:
'<?= GetMessageJS('ML_DEL_EL_CONFIRM
')?>',
318 DelElConfirmYes:
'<?= GetMessageJS('ML_DEL_EL_CONFIRM_YES
')?>',
319 SearchDef:
'<?= GetMessageJS('ML_SEARCH_DEF
')?>',
320 NoResult:
'<?= GetMessageJS('ML_SEARCH_NO_RESULT
')?>',
321 ViewItem :
'<?= GetMessageJS('ML_VIEW_ITEM
')?>',
322 FileExt :
'<?= GetMessageJS('ML_FILE_EXT
')?>',
323 CheckExtTypeConf :
'<?= GetMessageJS('ML_CHECK_TYPE_EXT_CONF
')?>'
329 public static function AppendLangMessagesEx()
332ML_MESS.Edit =
'<?= GetMessageJS('ML_EDIT
')?>';
333ML_MESS.Delete =
'<?= GetMessageJS('ML_DELETE
')?>';
334ML_MESS.Access =
'<?= GetMessageJS('ML_ACCESS
')?>';
335ML_MESS.AccessTitle =
'<?= GetMessageJS('ML_ACCESS_TITLE
')?>';
337ML_MESS.AddElement =
'<?= GetMessageJS('ML_ADD_ELEMENT
')?>';
338ML_MESS.AddElementTitle =
'<?= GetMessageJS('ML_ADD_ELEMENT_TITLE
')?>';
339ML_MESS.AddCollection =
'<?= GetMessageJS('ML_ADD_COLLECTION
')?>';
340ML_MESS.AddCollectionTitle =
'<?= GetMessageJS('ML_ADD_COLLECTION_TITLE
')?>';
341ML_MESS.MultiDelConfirm =
'<?= GetMessageJS('ML_MULTI_DEL_CONFIRM
')?>';
342ML_MESS.Decreased =
'<?= GetMessageJS('ML_DECREASED
')?>';
344ML_MESS.ChangeType =
'<?= GetMessageJS('ML_CHANGE_TYPE
')?>';
345ML_MESS.ChangeTypeTitle =
'<?= GetMessageJS('ML_CHANGE_TYPE_TITLE
')?>';
346ML_MESS.ChangeTypeError =
'<?= GetMessageJS('ML_CHANGE_TYPE_ERROR
')?>';
347ML_MESS.ChangeTypeChildConf =
'<?= GetMessageJS('ML_CHANGE_TYPE_CHILD_CONF
')?>';
348ML_MESS.Save =
'<?= GetMessageJS('ML_SAVE
')?>';
352 public static function Start($Params)
354 $Params[
'bReadOnly'] =
false;
355 CMedialib::BuildDialog($Params);
358 ?>#ML_SUBDIALOGS_BEGIN#<?
359 CMedialib::BuildAddCollectionDialog($Params);
360 CMedialib::BuildAddItemDialog($Params);
361 CMedialib::BuildConfirmDialog($Params);
362 CMedialib::BuildViewItemDialog($Params);
363 $exParams =
array(
'types' => $Params[
'types']);
364 ?>#ML_SUBDIALOGS_END#
366 <script><?CMedialib::GetCollections($exParams);?></script>
370 public static function BuildDialog($Params)
373 #ML_MAIN_DIALOG_BEGIN#
374 <form name=
"medialib_form"><table
id=
"ml_frame" class=
"ml-frame"><tr>
375 <td
class=
"ml-title-cell">
376 <table onmousedown=
"jsFloatDiv.StartDrag(arguments[0], document.getElementById('bxmedialib'));"><tr><td
style=
"width: 10px; padding-left: 3px;"><img
class=
"ml-iconkit ml-dd-dot" src=
"/bitrix/images/1.gif" /></td><td
class=
"ml-diad-title" id=
"ml_diag_title"><?=
GetMessage(
'ML_MEDIALIB')?></td><td
id=
"bxml_close" class=
"ml-close" title=
"<?=GetMessage('ML_CLOSE')?>"><img src=
"/bitrix/images/1.gif"></td></tr></table>
378 <tr><td
class=
"ml-content-cell">
379 <div
class=
"ml-head-cont" id=
"ml_head_cont">
380 <table><tr><td
class=
"ml-left">
381 <div
class=
"ml-breadcrumbs" id=
"ml_breadcrumbs"></div>
382 </td><td
class=
"ml-right">
383 <input
class=
"ml-search ml-search-empty" id=
"medialib_search" type=
"text" value=
"<?=GetMessage('ML_SEARCH_DEF')?>"/>
386 <div
class=
"ml-left-sec" id=
"ml_left_cont">
387 <div
id=
"ml_type_cont" class=
"ml-type-cont"></div>
388 <div
class=
"ml-collect-cont" id=
"ml_coll_cont"><div
class=
"ml-no-colls"> - <?=
GetMessage(
'ML_NO_COLS')?> - </div></div>
390 <div
class=
"ml-right-sec" id=
"ml_right_cont">
391 <div
class=
"ml-list-cont" id=
"ml_list_cont"><div
class=
"ml-list-noitems"> - <?=
GetMessage(
'ML_NO_ITEMS')?> - </div></div>
392 <div
class=
"ml-info-cont" id=
"ml_info_wnd">
393 <div
class=
"ml-info-noinfo"> - <?=
GetMessage(
'ML_NO_ITEM_INFO')?> - </div>
394 <table
class=
"ml-info-tbl">
397 <div
class=
"ml-info-name" id=
"ml_info_name"></div>
398 <div
class=
"ml-info-collections" id=
"ml_info_colls"></div>
402 <td
style=
"width: 50%;">
404 <span
id=
"ml_info_keys"></span>
406 <td rowSpan=
"2" style=
"width: 50%; vertical-align: top;">
408 <div
class=
"ml-info-desc" id=
"ml_info_desc"></div>
412 <td
style=
"vertical-align: top;">
413 <div
class=
"ml-info-details" id=
"ml_info_details"></div>
419 <div
class=
"ml-buttons-cont" id=
"ml_but_cont">
422 <?
if (!$Params[
'bReadOnly']):?>
423 <a
id=
"ml_add_collection" href=
"javascript:void(0)" title=
"<?=GetMessage('ML_ADD_COLLECTION_TITLE')?>" class=
"ml-add-el-link"><img src=
"/bitrix/images/1.gif" /><?=
GetMessage(
'ML_ADD_COLLECTION')?></a>
425 <a
id=
"ml_add_item" href=
"javascript:void(0)" title=
"<?=GetMessage('ML_ADD_ELEMENT_TITLE')?>" class=
"ml-add-el-link"><img src=
"/bitrix/images/1.gif" /><?=
GetMessage(
'ML_ADD_ELEMENT')?></a>
427 </td><td
class=
"ml-right">
428 <input
id=
"medialib_but_save" type=
"button" value=
"<?=GetMessage('ML_SELECT')?>" />
429 <input
id=
"medialib_but_cancel" type=
"button" value=
"<?=GetMessage('ML_CANCEL')?>" />
435 <div
id=
"bxml_resizer" class=
"ml-resizer"></div>
440 public static function BuildAddCollectionDialogAdmin($Params)
443 <div
id=
"mlsd_coll" class=
"mlsd_admin">
445 <tr><td><b><?=
GetMessage(
'ML_NAME')?>:</b></td><td><input type=
"text" id=
"mlsd_coll_name" /></td></tr>
446 <tr><td
style=
"vertical-align: top;"><?=
GetMessage(
'ML_DESC')?>:</td><td><textarea
id=
"mlsd_coll_desc" rows=
"2" cols=
"21" style=
"resize: vertical;"></textarea></td></tr>
447 <tr><td><?=
GetMessage(
'ML_KEYWORDS')?>:</td><td><input type=
"text" id=
"mlsd_coll_keywords" /></td></tr>
449 <td><
select id=
"mlsd_coll_parent" style=
"width: 190px;"><option value=
"0"><?=
GetMessage(
'ML_UPPER_LEVEL')?></option></
select></td></tr>
455 public static function BuildAddCollectionDialog($Params)
458 <div
id=
"mlsd_coll" class=
"mlsd"><table
class=
"mlsd-frame"><tr>
459 <td
class=
"ml-title-cell">
460 <table onmousedown=
"jsFloatDiv.StartDrag(arguments[0], document.getElementById('mlsd_coll'));"><tr><td
style=
"width: 10px; padding-left: 3px;"><img
class=
"ml-iconkit ml-dd-dot" src=
"/bitrix/images/1.gif" /></td><td
class=
"ml-diad-title"><span
id=
"mlsd_coll_title"></span></td><td
id=
"mlsd_coll_close" class=
"ml-close" title=
"<?=GetMessage('ML_CLOSE')?>"><img src=
"/bitrix/images/1.gif"></td></tr></table>
462 <tr><td
class=
"ml-content-cell">
463 <table
class=
"mlsd-fields-tbl">
464 <tr><td><b><?=
GetMessage(
'ML_NAME')?>:</b></td><td><input type=
"text" id=
"mlsd_coll_name" /></td></tr>
465 <tr><td
style=
"vertical-align: top;"><?=
GetMessage(
'ML_DESC')?>:</td><td><textarea
id=
"mlsd_coll_desc" rows=
"2" cols=
"21" style=
"resize: vertical;"></textarea></td></tr>
466 <tr><td><?=
GetMessage(
'ML_KEYWORDS')?>:</td><td><input type=
"text" id=
"mlsd_coll_keywords" /></td></tr>
468 <td><
select id=
"mlsd_coll_parent" style=
"width: 190px;"><option value=
"0"><?=
GetMessage(
'ML_UPPER_LEVEL')?></option></
select></td></tr>
471 <tr><td
class=
"ml-buttons-cell">
472 <input
id=
"mlsd_coll_save" type=
"button" value=
"<?=GetMessage('ML_SAVE')?>">
473 <input
id=
"mlsd_coll_cancel" type=
"button" value=
"<?=GetMessage('ML_CANCEL')?>">
480 public static function BuildAddItemDialogAdmin($Params)
483 <div
id=
"mlsd_item" class=
"mlsd_admin">
485 <tr><td
class=
"ml-content-cell">
486<form name=
"ml_item_form" action=
"/bitrix/admin/fileman_medialib.php?action=edit_item&<?=bitrix_sessid_get()?>" onsubmit=
"return parent.oBXMediaLib.EditItemDialogOnsubmit();" method=
"post" enctype=
"multipart/form-data"><table
class=
"mlsd-ifrm-tbl">
488 <div
id=
"mlsd_fname_cont">
489 <b><?=
GetMessage(
'ML_FILE')?>:</b><span
style=
"padding: 0px 15px" id=
"ml_file_name"></span>
491 <div
id=
"mlsd_load_cont">
492 <b><label
for=
"ml_load_file"><?=
GetMessage(
'ML_FILE')?>:</label></b>
493 <input
id=
"ml_load_file" type=
"file" name=
"load_file" style=
"margin-left: 15px; max-width:250px;">
495 <div
id=
"mlsd_select_cont" style=
"display: none;">
496 <b><label
for=
"mlsd_item_path"><?=
GetMessage(
'ML_FILE')?>:</label></b>
497 <input type=
"text" size=
"25" value=
"" id=
"mlsd_item_path" style=
"margin-left: 15px; width: 280px;" name=
"item_path">
498 <input type=
"button" id=
"mlsd_open_fd" value=
"..." style=
"width: 30px;">
500 <div
style=
"text-align: right; padding-right: 20px;">
501 <div
style=
"float: left; text-align: left; margin-top: -2px;">
502 <a
id=
"mlsd_fname_change" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_CHANGE_FILE_TITLE')?>">(<?=
GetMessage(
'ML_CHANGE')?>)</a>
503 <a
id=
"mlsd_fname_change_back" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_CHANGE_UNDO_TITLE')?>">(<?=
GetMessage(
'ML_CHANGE_UNDO')?>)</a>
505 <a
id=
"mlsd_select_fd" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_SELECT_FILE_TITLE')?>"><?=
GetMessage(
'ML_SELECT_FILE')?></a>
506 <a
id=
"mlsd_select_pc" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_LOAD_FILE_TITLE')?>" style=
"display: none;"><?=
GetMessage(
'ML_LOAD_FILE')?></a>
509 <tr><td><b><label
for=
"mlsd_item_name"><?=
GetMessage(
'ML_NAME')?>:</label></b><br /><input type=
"text" id=
"mlsd_item_name" name=
"item_name"/></td>
510 <td rowSpan=
"3" style=
"padding-top: 10px;">
511 <div
class=
"mlsd-prev-cont"><span
id=
"mlsd_no_preview"><?=
GetMessage(
'ML_NO_PREVIEW')?></span><img
id=
"mlsd_item_thumb" src=
"/bitrix/images/1.gif" /></div>
512 <div
class=
"mlsd-size-cont" id=
"mlsd_item_size" title=
"<?=GetMessage('ML_SIZE_IN_PX')?>"></div>
515 <td
style=
"vertical-align: top;"><label
for=
"mlsd_item_desc"><?=
GetMessage(
'ML_DESC')?>:</label><br />
516 <textarea
id=
"mlsd_item_desc" rows=
"2" cols=
"26" name=
"item_desc"></textarea></td>
518 <tr><td><label
for=
"mlsd_item_keywords"><?=
GetMessage(
'ML_KEYWORDS')?>:<br /></label><input type=
"text" id=
"mlsd_item_keywords" name=
"item_keywords"/></td></tr>
520 <div
class=
"mlsd-col-cont">
521 <div
class=
"mlsd-col-label"><label
for=
"mlsd_coll_sel"><?=
GetMessage(
'ML_COLLECTIONS')?>:</label></div>
522 <div
class=
"mlsd-col-sel"><
select title=
"<?= GetMessage('ML_ADD_COL2ITEM')?>" id=
"mlsd_coll_sel"><option value=
"0"><?=
GetMessage(
'ML_COL_SELECT')?></option></
select></div>
528 <input
id=
"mlsd_item_collections" type=
"hidden" name=
"item_collections" value=
"">
529 <input
id=
"mlsd_item_id" type=
"hidden" name=
"id" value=
"">
530 <input
id=
"mlsd_source_type" type=
"hidden" name=
"source_type" value=
"PC">
538 "event" =>
"mlOpenFileDialog",
539 "arResultDest" => Array(
"FUNCTION_NAME" =>
"mlOnFileDialogSave"),
543 "showUploadTab" =>
true,
544 "showAddToMenuTab" =>
false,
545 "fileFilter" => CMedialib::GetMediaExtentions(),
546 "allowAllFiles" =>
false,
552 public static function BuildAddItemDialog($Params)
555 <div
id=
"mlsd_item" class=
"mlsd"><table
class=
"mlsd-frame"><tr>
556 <td
class=
"ml-title-cell">
557 <table onmousedown=
"jsFloatDiv.StartDrag(arguments[0], document.getElementById('mlsd_item'));"><tr><td
style=
"width: 10px; padding-left: 3px;"><img
class=
"ml-iconkit ml-dd-dot" src=
"/bitrix/images/1.gif" /></td><td
class=
"ml-diad-title"><span
id=
"mlsd_item_title"></span></td><td
id=
"mlsd_item_close" class=
"ml-close" title=
"<?=GetMessage('ML_CLOSE')?>"><img src=
"/bitrix/images/1.gif"></td></tr></table>
559 <tr><td
class=
"ml-content-cell">
560 <div
id=
"mlsd_item_upload" style=
"overflow: hidden;"><iframe
class=
"mlsd-iframe" id=
"mlsd_iframe_upload" src=
"javascript:''" frameborder=
"0"></iframe></div>
562 <tr><td
class=
"ml-buttons-cell">
563 <input
id=
"mlsd_item_save" type=
"button" value=
"<?=GetMessage('ML_SAVE')?>">
564 <input
id=
"mlsd_item_cancel" type=
"button" value=
"<?=GetMessage('ML_CANCEL')?>">
571 "event" =>
"mlOpenFileDialog",
572 "arResultDest" => Array(
"FUNCTION_NAME" =>
"mlOnFileDialogSave"),
576 "showUploadTab" =>
true,
577 "showAddToMenuTab" =>
false,
578 "fileFilter" => CMedialib::GetMediaExtentions(),
579 "allowAllFiles" =>
false,
585 public static function ShowUploadForm($Params)
591 body {margin:0px !important;
overflow: hidden;}
592 body *{font-family:Verdana,Arial,Helvetica,sans-serif; font-
size: 13px;
color: #000;}
593 form {margin:0px !important;}
594 table.mlsd-ifrm-tbl {
width: 400px;
height: 265px; margin: 3px;}
595 a.mlsd-up-link{text-decoration: none;
color: #6E8C9B; font-
size: 11px;}
596 table.mlsd-ifrm-tbl input{
width: 220px;}
597 div.mlsd-col-cont{
height: 70px;}
598 div.mlsd-col-label, div.mlsd-col-sel{font-weight: bold; float:
left; padding: 2px; margin: 2px;}
600 div.mlsd-ch-col{float:
left; border: 1px solid #6E8C9B;
width: 80px;
height: 20px; padding: 0px;
overflow: hidden; margin: 2px;
position: relative; background: url(/bitrix/images/fileman/medialib/group_bg.gif)
repeat-x scroll
left top;}
601 div.mlsd-ch-col span{white-
space: nowrap; font-
size: 12px !important;
display: block; margin: 2px 0 0 2px;}
602 div.mlsd-ch-col img.ml-col-del{
width: 17px;
height: 18px; background-image: url(/bitrix/images/fileman/medialib/iconkit.gif);
position: absolute;
display: none; background-
position: 0px -60px;
top: 1px;
right: 1px; cursor: pointer;}
603 div.col-over img.ml-col-del{
display: block !important;}
604 div.mlsd-prev-cont{
width: 150px;
height: 140px; border: 1px solid #6E8C9B; text-
align: center;}
605 div.mlsd-prev-cont img{margin: 2px;}
606 div.mlsd-prev-cont span{
color: #6E8C9B; font-
size: 11px;
display: block; padding: 2px;}
607 select option.opt-checked{
color: #808080; font-weight: bold; background-
color: #F2F6F8;}
611<BODY
style=
"margin:0px !important;">
612<form name=
"ml_item_form" action=
"/bitrix/admin/fileman_medialib.php?action=edit_item&<?=bitrix_sessid_get()?>" onsubmit=
"return parent.oBXMediaLib.EditItemDialogOnsubmit();" method=
"post" enctype=
"multipart/form-data"><table
class=
"mlsd-ifrm-tbl">
614 <div
id=
"mlsd_fname_cont">
615 <b><?=
GetMessage(
'ML_FILE')?>:</b><span
style=
"padding: 0px 15px" id=
"ml_file_name"></span>
617 <div
id=
"mlsd_load_cont">
618 <b><label
for=
"ml_load_file"><?=
GetMessage(
'ML_FILE')?>:</label></b>
619 <input
id=
"ml_load_file" type=
"file" name=
"load_file" style=
"margin-left: 15px; max-width:250px;">
620 <input
id=
"ml_load_max_size" type=
"hidden" name=
"ml_load_max_size" value=
"<?=CMedialib::getMaximumFileUploadSize()?>">
622 <div
id=
"mlsd_select_cont" style=
"display: none;">
623 <b><label
for=
"mlsd_item_path"><?=
GetMessage(
'ML_FILE')?>:</label></b>
624 <input type=
"text" size=
"25" value=
"" id=
"mlsd_item_path" style=
"margin-left: 15px; width: 280px;" name=
"item_path">
625 <input type=
"button" id=
"mlsd_open_fd" value=
"..." style=
"width: 30px;">
627 <div
style=
"text-align: right; padding-right: 20px;">
628 <div
style=
"float: left; text-align: left; margin-top: -2px;">
629 <a
id=
"mlsd_fname_change" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_CHANGE_FILE_TITLE')?>">(<?=
GetMessage(
'ML_CHANGE')?>)</a>
630 <a
id=
"mlsd_fname_change_back" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_CHANGE_UNDO_TITLE')?>">(<?=
GetMessage(
'ML_CHANGE_UNDO')?>)</a>
632 <a
id=
"mlsd_select_fd" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_SELECT_FILE_TITLE')?>"><?=
GetMessage(
'ML_SELECT_FILE')?></a>
633 <a
id=
"mlsd_select_pc" href=
"javascript:void(0)" class=
"mlsd-up-link" title=
"<?=GetMessage('ML_LOAD_FILE_TITLE')?>" style=
"display: none;"><?=
GetMessage(
'ML_LOAD_FILE')?></a>
636 <tr><td><b><label
for=
"mlsd_item_name"><?=
GetMessage(
'ML_NAME')?>:</label></b><br /><input type=
"text" id=
"mlsd_item_name" name=
"item_name"/></td>
637 <td rowSpan=
"3" style=
"padding-top: 10px;">
638 <div
class=
"mlsd-prev-cont"><span
id=
"mlsd_no_preview"><?=
GetMessage(
'ML_NO_PREVIEW')?></span><img
id=
"mlsd_item_thumb" src=
"/bitrix/images/1.gif" /></div>
639 <div
class=
"mlsd-size-cont" id=
"mlsd_item_size" title=
"<?=GetMessage('ML_SIZE_IN_PX')?>"></div>
642 <td
style=
"vertical-align: top;"><label
for=
"mlsd_item_desc"><?=
GetMessage(
'ML_DESC')?>:</label><br />
643 <textarea
id=
"mlsd_item_desc" rows=
"2" cols=
"26" name=
"item_desc"></textarea></td>
645 <tr><td><label
for=
"mlsd_item_keywords"><?=
GetMessage(
'ML_KEYWORDS')?>:<br /></label><input type=
"text" id=
"mlsd_item_keywords" name=
"item_keywords"/></td></tr>
647 <div
class=
"mlsd-col-cont">
648 <div
class=
"mlsd-col-label"><label
for=
"mlsd_coll_sel"><?=
GetMessage(
'ML_COLLECTIONS')?>:</label></div>
649 <div
class=
"mlsd-col-sel"><
select title=
"<?= GetMessage('ML_ADD_COL2ITEM')?>" id=
"mlsd_coll_sel"><option value=
"0"><?=
GetMessage(
'ML_COL_SELECT')?></option></
select></div>
655 <input
id=
"mlsd_item_collections" type=
"hidden" name=
"item_collections" value=
"">
656 <input
id=
"mlsd_item_id" type=
"hidden" name=
"id" value=
"">
657 <input
id=
"mlsd_source_type" type=
"hidden" name=
"source_type" value=
"PC">
664 public static function BuildConfirmDialog($Params)
667 <div
id=
"ml_colfirm_dialog" class=
"mlsd mlsd-confirm">
668 <div
id=
"ml_confd_text" class=
"ml-confd-text"></div>
669 <input
id=
"ml_confd_b1" type=
"button" value=
"b1" />
670 <input
id=
"ml_confd_b2" type=
"button" value=
"b2" />
671 <input
id=
"ml_confd_cancel" type=
"button" value=
"<?=GetMessage('ML_CANCEL')?>" />
676 public static function BuildViewItemDialog($Params)
679 <div
id=
"mlsd_view_item" class=
"mlsd"><table
class=
"mlsd-frame"><tr>
680 <td
class=
"ml-title-cell">
681 <table onmousedown=
"jsFloatDiv.StartDrag(arguments[0], document.getElementById('mlsd_view_item'));"><tr><td
style=
"width: 10px; padding-left: 3px;"><img
class=
"ml-iconkit ml-dd-dot" src=
"/bitrix/images/1.gif" /></td><td
class=
"ml-diad-title"><?=
GetMessage(
'ML_VIEW_ITEM')?></td><td
id=
"mlsd_viewit_close" class=
"ml-close" title=
"<?=GetMessage('ML_CLOSE')?>"><img src=
"/bitrix/images/1.gif"></td></tr></table>
683 <tr><td
class=
"ml-content-cell">
684 <div
id=
"mlsd_info_cont" class=
"mlvi-info-cnt">
685 <table
class=
"mlvi-info-tbl">
686 <tr><td><div
class=
"mlvi-info-name" id=
"mlvi_info_name"></div></td></tr>
687 <tr><td><a
id=
"mlvi_info_link" href=
"javascript: void(0);" title=
"<?= GetMessage("ML_DOWNLOAD_LINK
")?>"><?=
GetMessage(
'ML_DOWNLOAD_LINK')?></a></td></tr>
688 <tr><td><a
id=
"mlvi_info_copy_link" href=
"javascript: void(0);" title=
"<?= GetMessage("ML_DOWNLOAD_LINK_TITLE
")?>"><?=
GetMessage(
"ML_DOWNLOAD_LINK_TITLE")?></a></td></tr>
689 <tr><td><input
style=
"display:none;" id=
"mlvi_info_copy_input" value></td></tr>
690 <tr><td
class=
"mlvi-new-row">
691 <div
class=
"mlvi-info-details" id=
"mlvi_info_details"></div>
693 <tr><td
class=
"small-grey" id=
"mlvi_info_colls">
694 <span><?=
GetMessage(
'ML_COLLECTIONS')?>: </span>
697 <td
class=
"small-grey" ><span><?=
GetMessage(
'ML_KEYWORDS')?>:</span>
698 <span
id=
"mlvi_info_keys"></span></td>
700 <tr><td
class=
"mlvi-new-row">
701 <span
style=
"font-size: 11px !important;"><?=
GetMessage(
'ML_DESC')?>:</span>
702 <div
class=
"ml-info-desc" id=
"mlvi_info_desc"></div>
706 <div
id=
"mlsd_item_cont" class=
"mlvi-img-cnt"><??></div>
708 <tr><td
class=
"ml-buttons-cell">
709 <input
id=
"mlsd_viewit_del" type=
"button" value=
"<?=GetMessage('ML_DELETE')?>">
710 <input
id=
"mlsd_viewit_edit" type=
"button" value=
"<?=GetMessage('ML_EDIT')?>">
711 <input
id=
"mlsd_viewit_cancel" type=
"button" value=
"<?=GetMessage('ML_CANCEL')?>">
718 public static function BuildChangeType($Params)
721 <div
id=
"mlsd_change_type" class=
"mlsd"><table
class=
"mlsd-frame"><tr>
722 <td
class=
"ml-title-cell">
723 <table onmousedown=
"jsFloatDiv.StartDrag(arguments[0], document.getElementById('mlsd_change_type'));"><tr><td
style=
"width: 10px; padding-left: 3px;"><img
class=
"ml-iconkit ml-dd-dot" src=
"/bitrix/images/1.gif" /></td><td
class=
"ml-diad-title"><?=
GetMessage(
'ML_CHANGE_TYPE_DIALOG')?></td><td
id=
"mlsd_chtype_close" class=
"ml-close" title=
"<?=GetMessage('ML_CLOSE')?>"><img src=
"/bitrix/images/1.gif"></td></tr></table>
725 <tr><td
class=
"ml-content-cell">
726 <table
class=
"mlsd-fields-tbl">
728 <td><b><?=
GetMessage(
'ML_CHOOSE_TYPE')?>:</b></td>
729 <td><
select id=
"mlsd_chtype_type" style=
"width: 190px;"><option value=
"none">- <?=
GetMessage(
'ML_COL_SELECT')?> -</option></
select></td>
733 <td><
select id=
"mlsd_chtype_parent" style=
"width: 190px;"><option value=
"0"><?=
GetMessage(
'ML_UPPER_LEVEL')?></option></
select></td>
737 <tr><td
class=
"ml-buttons-cell">
738 <input
id=
"mlsd_chtype_save" type=
"button" value=
"<?=GetMessage('ML_SAVE')?>">
739 <input
id=
"mlsd_chtype_cancel" type=
"button" value=
"<?=GetMessage('ML_CANCEL')?>">
746 public static function ShowJS()
749 BX.loadCSS(
"/bitrix/js/fileman/medialib/medialib.css");
750 if (!window.jsUtils &&
top.jsUtils)
751 window.jsUtils =
top.jsUtils;
753 BX.loadScript(
'/bitrix/js/main/utils.js?v=<?=@filemtime($_SERVER['DOCUMENT_ROOT
'].'/bitrix/js/main/utils.js
')?>');
755 if (!window.CHttpRequest &&
top.CHttpRequest)
756 window.CHttpRequest =
top.CHttpRequest;
757 if (!window.CHttpRequest)
758 BX.loadScript(
'/bitrix/js/main/admin_tools.js?v=<?=@filemtime($_SERVER['DOCUMENT_ROOT
'].'/bitrix/js/main/admin_tools.js
')?>');
760 if (!window.jsAjaxUtil &&
top.jsAjaxUtil)
761 window.jsAjaxUtil =
top.jsAjaxUtil;
762 if (!window.jsAjaxUtil)
763 BX.loadScript(
'/bitrix/js/main/ajax.js?v=<?=@filemtime($_SERVER['DOCUMENT_ROOT
'].'/bitrix/js/main/ajax.js
')?>');
767 public static function GetCollections(&$exParams)
769 $bCountPermissions = isset($exParams[
'bCountPermissions']) && $exParams[
'bCountPermissions'] ===
true;
770 $exParams[
'arCountPerm'] =
array(
'new_col' => 0,
'edit' => 0,
'del' => 0,
'new_item' => 0,
'edit_item' => 0,
'del_item' => 0,
'access' => 0);
772 ?>window.MLCollections = [<?
773 $arCol = CMedialibCollection::GetList(
array(
'arFilter' =>
776 'TYPES' => $exParams[
'types']
780 $commonItemEdit =
false;
784 if (!CMedialibCollection::IsViewable($arCol[
$i], $arCol))
787 $id = $arCol[
$i][
'ID'];
788 $arCol[
$i][
'PERMISSIONS'] =
array(
789 'new_col' => CMedialib::CanDoOperation(
'medialib_new_collection', $arCol[
$i][
'ID']),
790 'edit' => CMedialib::CanDoOperation(
'medialib_edit_collection', $arCol[
$i][
'ID']),
791 'del' => CMedialib::CanDoOperation(
'medialib_del_collection', $arCol[
$i][
'ID']),
792 'new_item' => CMedialib::CanDoOperation(
'medialib_new_item', $arCol[
$i][
'ID']),
793 'edit_item' => CMedialib::CanDoOperation(
'medialib_edit_item', $arCol[
$i][
'ID']),
794 'del_item' => CMedialib::CanDoOperation(
'medialib_del_item', $arCol[
$i][
'ID']),
795 'access' => CMedialib::CanDoOperation(
'medialib_access', $arCol[
$i][
'ID'])
799 foreach($exParams[
'arCountPerm'] as
$key => $el)
801 if ($bCountPermissions)
802 $exParams[
'arCountPerm'][
$key] += intval($arCol[
$i][
'PERMISSIONS'][
$key]);
803 $accStr .=
$key.
": '".$arCol[
$i][
'PERMISSIONS'][
$key].
"', ";
805 $accStr = rtrim($accStr,
' ,');
808 id: <?= $arCol[
$i][
'ID']?>,
809 name:
'<?= CMedialib::Escape($arCol[$i]['NAME
'])?>',
810 desc:
'<?= CMedialib::Escape($arCol[$i]['DESCRIPTION
'])?>',
811 date:
'<?= $arCol[$i]['DATE_UPDATE
']?>',
812 keywords:
'<?= CMedialib::Escape($arCol[$i]['KEYWORDS
'])?>',
813 parent: <?= intval($arCol[
$i][
'PARENT_ID']) > 0 ? intval($arCol[
$i][
'PARENT_ID']) :
'0'?>,
814 access: {<?= $accStr?>},
815 type:
'<?= $arCol[$i]['ML_TYPE
']?>'
820 $arResCol[] = $arCol[
$i];
826 public static function DelCollection($id, $arIds = [])
828 if (!CMedialib::CanDoOperation(
'medialib_del_collection', $id))
833 if (is_array($arIds))
837 if (CMedialib::CanDoOperation(
'medialib_del_collection', $arIds[
$i]))
839 CMedialibCollection::Delete($arIds[
$i],
false);
844 return CMedialibCollection::Delete($id);
847 public static function EditCollection($Params)
849 if ($Params[
'id'] && !CMedialib::CanDoOperation(
'medialib_edit_collection', $Params[
'id']) ||
850 !$Params[
'id'] && !CMedialib::CanDoOperation(
'medialib_new_collection', $Params[
'parent']))
853 return CMedialibCollection::Edit(
array(
855 'ID' => $Params[
'id'],
856 'NAME' => $Params[
'name'],
857 'DESCRIPTION' => $Params[
'desc'],
858 'OWNER_ID' =>
$GLOBALS[
'USER']->GetId(),
859 'PARENT_ID' => $Params[
'parent'],
860 'KEYWORDS' => $Params[
'keywords'],
862 'ML_TYPE' => $Params[
'type']
867 public static function EditItem($Params)
869 $bOpName = $Params[
'id'] ?
'medialib_edit_item' :
'medialib_new_item';
870 $arCols_ = explode(
',', $Params[
'item_collections']);
874 if (intval($arCols_[
$i]) > 0 && CMedialib::CanDoOperation($bOpName, $arCols_[
$i]))
880 if ($Params[
'source_type'] ==
'PC')
881 $Params[
'path'] =
false;
882 else if($Params[
'source_type'] ==
'FD')
883 $Params[
'file'] =
false;
886 'file' => $Params[
'file'],
887 'path' => $Params[
'path'],
889 'ID' => $Params[
'id'],
890 'NAME' => $Params[
'name'],
891 'DESCRIPTION' => $Params[
'desc'],
892 'KEYWORDS' => $Params[
'keywords']
899 if (!isset(
$res[
'DATE_UPDATE']) && isset(
$res[
'TIMESTAMP_X']))
900 $res[
'DATE_UPDATE'] =
$res[
'TIMESTAMP_X'];
904 id: <?=intval(
$res[
'ID'])?>,
905 name:
'<?= CMedialib::Escape($res['NAME
'])?>',
906 desc:
'<?= CMedialib::Escape($res['DESCRIPTION
'])?>',
907 keywords:
'<?= CMedialib::Escape($res['KEYWORDS
'])?>',
908 <?
if (isset(
$res[
'FILE_NAME'])):?>file_name:
'<?= CMedialib::Escape($res['FILE_NAME
'])?>',<?
endif;?>
909 <?
if (isset(
$res[
'DATE_UPDATE'])):?>date_mod:
'<?= CMedialib::GetUsableDate($res['DATE_UPDATE
'])?>',<?
endif;?>
910 <?
if (isset(
$res[
'FILE_SIZE'])):?>file_size:
'<?= CMedialib::GetUsableSize($res['FILE_SIZE
'])?>',<?
endif;?>
911 <?
if (isset(
$res[
'THUMB_PATH'])):?>thumb_path:
'<?= CMedialib::Escape($res['THUMB_PATH
'])?>',<?
endif;?>
912 <?
if (isset(
$res[
'PATH'])):?>
path:
'<?= CMedialib::Escape($res['PATH
'])?>',<?
endif;?>
913 <?
if (isset(
$res[
'TYPE'])):?>type:
'<?= $res['TYPE
']?>',<?
endif;?>
918 top._ml_items_colls = [<?
924 <script>
top.bx_req_res =
false;</script>
929 public static function GetCollectionTree($Params =
array())
931 $arColTree =
array();
932 $arColTemp =
array();
933 $Collections =
array();
934 $arCol = ($Params[
'menu'] ??
null) ? CMedialibCollection::GetList(
array(
'arFilter' =>
array(
'ACTIVE' =>
'Y',
'PARENT_ID' => 0))) : CMedialibCollection::GetList(
array(
'arFilter' =>
array(
'ACTIVE' =>
'Y')));
939 if (isset($Params[
'CheckAccessFunk']) && !call_user_func($Params[
'CheckAccessFunk'], $arCol[
$i][
'ID']))
942 if (!CMedialib::_buildCollection($arCol[
$i],
$i, $arColTree, $Collections, $Params))
946 while(
count($arColTemp) > 0 && $iter < 50)
951 if (isset($Params[
'CheckAccessFunk']) && !call_user_func($Params[
'CheckAccessFunk'], $arCol[
$i][
'ID']))
954 if (!CMedialib::_buildCollection($arColTemp[
$i][0], $arColTemp[
$i][1], $arColTree, $Collections, $Params))
955 $newAr[] = $arColTemp[
$i];
961 if (($Params[
'checkByType'] ??
null) && $Params[
'typeId'] > 0)
963 $arType = CMedialib::GetTypeById($Params[
'typeId']);
966 foreach ($Collections as $id => $col)
969 if (!CMedialib::CompareTypesEx($Collections[$id][
'ML_TYPE'], $arType))
970 unset($Collections[$id]);
975 return array(
'arColTree' => $arColTree,
'Collections' => $Collections);
978 public static function _buildCollection($Col, $ind, &$arColTree, &$Collections, $Params =
array())
980 if (($Params[
'CHECK_ACCESS'] ??
null) ===
true && !CMedialib::CanDoOperation(
'medialib_view_collection', $Col[
'ID']))
983 if (!$Col[
'PARENT_ID'])
984 $arColTree[] =
array(
'id' => $Col[
'ID'],
'child' =>
array());
985 else if ($Collections[$Col[
'PARENT_ID']])
986 CMedialib::_findChildInColTree($arColTree, $Col[
'PARENT_ID'], $Col[
'ID']);
990 $Collections[$Col[
'ID']] = $Col;
994 public static function _findChildInColTree(&
$arr, $id, $colId)
998 if (
$arr[
$i][
'id'] == $id)
1005 if (CMedialib::_findChildInColTree(
$arr[
$i][
'child'], $id, $colId))
1012 public static function _BuildCollectionsSelectOptions($Collections =
false, $arColTree =
false, $level = 0, $selected =
false)
1014 if ($Collections ===
false && $arColTree ===
false)
1016 $res = CMedialib::GetCollectionTree();
1017 $Collections =
$res[
'Collections'];
1018 $arColTree =
$res[
'arColTree'];
1025 $col = $Collections[$arColTree[
$i][
'id']] ??
null;
1026 if (!is_array($col))
1028 $html = str_repeat(
" . ", $level);
1029 $s = ($selected !==
false && $selected == $arColTree[
$i][
'id']) ?
' selected' :
'';
1030 $str .=
'<option value="'.$arColTree[
$i][
'id'].
'"'.$s.
'>'.$html.htmlspecialcharsex($col[
'NAME']).
'</option>';
1032 if (
count($arColTree[
$i][
'child']))
1033 $str .= CMedialib::_BuildCollectionsSelectOptions($Collections, $arColTree[
$i][
'child'], $level + 1, $selected);
1038 public static function GetItems($Params)
1040 $arCollections =
array();
1041 if (!CMedialib::CanDoOperation(
'medialib_view_collection', $Params[
'collectionId']))
1044 if (isset($Params[
'collectionId']) && $Params[
'collectionId'] > 0)
1045 $arCollections[] = $Params[
'collectionId'];
1047 $arItems = CMedialibItem::GetList(
array(
1048 'arCollections' => $arCollections
1053 window.MLItems[<?=$Params[
'collectionId']?>] = [<?
1058 id: <?=intval($arItems[
$i][
'ID'])?>,
1059 name:
'<?= CMedialib::Escape($arItems[$i]['NAME
'])?>',
1060 desc:
'<?= CMedialib::Escape($arItems[$i]['DESCRIPTION
'])?>',
1061 keywords:
'<?= CMedialib::Escape($arItems[$i]['KEYWORDS
'])?>',
1062 file_name:
'<?= CMedialib::Escape($arItems[$i]['FILE_NAME
'])?>',
1063 date_mod:
'<?= CMedialib::GetUsableDate($arItems[$i]['DATE_UPDATE2
'])?>',
1064 height: <?= ($arItems[
$i][
'HEIGHT'] ? $arItems[
$i][
'HEIGHT'] :
'0')?>,
1065 width: <?= ($arItems[
$i][
'WIDTH'] ? $arItems[
$i][
'WIDTH'] :
'0')?>,
1066 file_size:
'<?= CMedialib::GetUsableSize($arItems[$i]['FILE_SIZE
'])?>',
1067 thumb_path:
'<?= CMedialib::Escape($arItems[$i]['THUMB_PATH
'] ?? '')?>',
1068 path:
'<?= CMedialib::Escape($arItems[$i]['PATH
'])?>',
1069 path_external:
'<?= CMedialib::Escape($arItems[$i]['PATH_EXTERNAL
'])?>',
1070 type:
'<?= $arItems[$i]['TYPE
']?>'
1081 public static function DelItem($id, $bCurrent =
false, $colId =
false)
1083 return CMedialibItem::Delete($id, $bCurrent, $colId);
1086 public static function DeleteThumbnails()
1088 CFileman::DeleteEx(BX_PERSONAL_ROOT.
"/tmp/medialibrary");
1091 public static function GetItemCollectionList($Params)
1093 if(!CMedialib::CanDoOperation(
'medialib_view_collection', 0))
1096 $ar = CMedialibItem::GetItemCollections($Params);
1099 window._ml_items_colls = [<?
1107 public static function SaveUserSettings($Params)
1109 if (
$GLOBALS[
"USER"]->IsAuthorized())
1110 CUserOptions::SetOption(
"fileman",
"medialib_user_set", intval($Params[
'width']).
','.intval($Params[
'height']).
','.intval($Params[
'coll_id']));
1113 public static function SaveAccessPermissions($colId, $arTaskPerm)
1116 $DB->Query(
"DELETE FROM b_group_collection_task WHERE COLLECTION_ID=".intval($colId));
1118 foreach($arTaskPerm as $group_id => $task_id)
1120 $arInsert =
$DB->PrepareInsert(
"b_group_collection_task",
array(
"GROUP_ID" => $group_id,
"TASK_ID" => $task_id,
"COLLECTION_ID" => intval($colId)));
1121 $strSql =
"INSERT INTO b_group_collection_task(".$arInsert[0].
") VALUES(".$arInsert[1].
")";
1122 $DB->Query($strSql );
1126 public static function MultiActionDelete($Params =
array())
1130 if (is_array($Params[
'Cols']) &&
count($Params[
'Cols']) > 0)
1135 $colId = $Params[
'Cols'][
$i];
1136 if (CMedialib::CanDoOperation(
'medialib_del_collection', $colId))
1138 $strCols .=
",".intval($colId);
1142 if ($strCols !=
"0")
1144 $strSql =
"DELETE FROM b_medialib_collection WHERE ID in (".$strCols.
")";
1145 $z =
$DB->Query($strSql);
1147 $strSql =
"DELETE FROM b_medialib_collection_item WHERE COLLECTION_ID in (".$strCols.
")";
1148 $z =
$DB->Query($strSql);
1152 if (is_array($Params[
'Items']) &&
count($Params[
'Items']) > 0)
1154 foreach($Params[
'Items'] as $colId => $arItems)
1156 if (!CMedialib::CanDoOperation(
'medialib_del_item', $colId))
1164 $strItems .=
",".intval($arItems[
$i]);
1167 $strSql =
"DELETE FROM b_medialib_collection_item WHERE ITEM_ID IN (".$strItems.
") AND COLLECTION_ID=".intval($colId);
1168 $z =
$DB->Query($strSql);
1172 CMedialibItem::DeleteEmpty();
1176 public static function ShowBrowseButton($Params =
array())
1178 $value = isset($Params[
'value']) ? $Params[
'value'] :
'...';
1179 $buttonId = isset($Params[
'button_id']) ? $Params[
'button_id'] :
'';
1180 $inputId = isset($Params[
'id']) ? $Params[
'id'] :
'';
1181 $title = isset($Params[
'title']) ? $Params[
'title'] :
'';
1182 $event = $Params[
'event'];
1183 $mode = isset($Params[
'mode']) ? $Params[
'mode'] :
'';
1185 if (!isset($Params[
'useMLDefault']))
1188 $useMLDefault = $Params[
'useMLDefault'];
1190 if ($mode ==
'file_dialog' || COption::GetOptionString(
'fileman',
"use_medialib",
"Y") ==
"N" || !CMedialib::CanDoOperation(
'medialib_view_collection', 0))
1191 $mode =
'file_dialog';
1192 else if ($mode ==
'medialib' || !
$GLOBALS[
"USER"]->CanDoOperation(
'fileman_view_file_structure'))
1197 if (($Params[
'bReturnResult'] ??
null))
1200 if ($mode ==
'medialib' || $mode ==
'select')
1202 $arMLConfig = $Params[
'MedialibConfig'];
1203 if (!isset($arMLConfig[
'event']))
1204 $arMLConfig[
'event'] =
'BXOpenMLEvent';
1205 CMedialib::ShowDialogScript($arMLConfig);
1208 if ($mode ==
'medialib')
1210 $title = isset($Params[
'title']) ? $Params[
'title'] :
GetMessage(
'ML_BR_BUT_ML_TITLE');
1212 <input
id=
"<?= 'bx_ml_'.$inputId?>" type=
"button" value=
"<?= $value?>" title=
"<?= $title?>" onclick=
"<?= $arMLConfig['event']?>();"/>
1215 elseif ($mode ==
'file_dialog')
1217 $title = isset($Params[
'title']) ? $Params[
'title'] :
GetMessage(
'ML_BR_BUT_FD_TITLE');
1218 ?><input type=
"button" class=
"adm-btn" style=
"float:left;" value=
"<?= $value?>" id=
"<?= $inputId?>" title=
"<?= $title?>" onclick=
"<?= $Params['event']?>();"/><?
1222 $cid =
'bxmlbut'.$inputId;
1226<? self::AttachJSScripts();?>
1227if (!window.<?= $cid?>_onclick)
1229 window.<?= $cid?>_onclick =
function (pEl)
1234 pEl.OPENER =
new BX.COpener({
1238 {ICONCLASS :
'bxml-empty-icon', DEFAULT: <?= $useMLDefault ?
'true' :
'false'?>, TEXT :
'<?= GetMessageJS('ML_BR_BUT_ML
')?>', TITLE:
'<?= GetMessageJS('ML_BR_BUT_ML_TITLE
')?>', ONCLICK:
'<?= $arMLConfig['event']?>();'},
1239 {ICONCLASS :
'bxml-empty-icon', DEFAULT: <?= $useMLDefault ?
'false' :
'true'?>, TEXT :
'<?= GetMessageJS('ML_BR_BUT_FD
')?>',TITLE:
'<?= GetMessageJS('ML_BR_BUT_FD_TITLE
')?>', ONCLICK:
'<?= $event?>();'}
1243 pEl.OPENER.Toggle();
1248<div
id=
"<?= $buttonId?>" class=
"bx-ml-pnbutton">
1249<div
class=
"bx-pn1" title=
"<?= GetMessage('ML_BR_BUT_ML_TITLE')?>" onclick=
"<?= ($useMLDefault ? $arMLConfig['event'] : $event)?>();"></div>
1250<div
class=
"bx-pn2" title=
"<?= GetMessage('ML_BR_BUT_SEL')?>" onclick=
"<?= $cid?>_onclick(this);"></div>
1255 if (($Params[
'bReturnResult'] ??
null))
1257 $s = ob_get_contents();
1263 public static function GetUsableSize($size = 0)
1265 $size = intval($size);
1269 $size = round($size / 1024);
1273 $size = round($size / 1024);
1280 public static function GetUsableDate($date =
'')
1285 public static function GetMediaExtentions($bStr =
true)
1289 $arExt_ = explode(
',', $strExt);
1293 $arExt_ = array_merge($arExt_, explode(
',',
$arTypes[
$i][
"ext"]));
1298 $ext = mb_strtolower(trim($arExt_[
$i],
' .'));
1299 if ($ext <>
'' && !in_array($ext, $arExt))
1304 return implode(
",", $arExt);
1309 public static function GetDefaultMediaExtentions()
1311 return 'jpg,jpeg,gif,png,flv,mp4,wmv,wma,mp3,ppt';
1314 public static function CheckFileExtention($strPath =
'', $arExt =
false)
1317 $arExt = CMedialib::GetMediaExtentions(
false);
1318 $ext = mb_strtolower(CFileman::GetFileExtension($strPath));
1319 return in_array($ext, $arExt);
1322 public static function Escape(
$str, $bHtmlSpCh =
true)
1327 public static function SearchItems($Params)
1329 if (!CModule::IncludeModule(
"search"))
1332 $arQuery = array_keys(
stemming($Params[
'query'], LANGUAGE_ID));
1333 $arItems = CMedialibItem::Search($arQuery, $Params[
'types']);
1336window.MLSearchResult = [
1342 id: <?=intval($arItems[
$i][
'ID'])?>,
1343 name:
'<?= CMedialib::Escape($arItems[$i]['NAME
'])?>',
1344 desc:
'<?= CMedialib::Escape($arItems[$i]['DESCRIPTION
'])?>',
1345 keywords:
'<?= CMedialib::Escape($arItems[$i]['KEYWORDS
'])?>',
1346 file_name:
'<?= CMedialib::Escape($arItems[$i]['FILE_NAME
'])?>',
1347 height: <?= ($arItems[
$i][
'HEIGHT'] ? $arItems[
$i][
'HEIGHT'] :
'0')?>,
1348 width: <?= ($arItems[
$i][
'WIDTH'] ? $arItems[
$i][
'WIDTH'] :
'0')?>,
1349 file_size:
'<?= CMedialib::GetUsableSize($arItems[$i]['FILE_SIZE
'])?>',
1350 date_mod:
'<?= CMedialib::GetUsableDate($arItems[$i]['DATE_UPDATE2
'])?>',
1351 thumb_path:
'<?= CMedialib::Escape($arItems[$i]['THUMB_PATH
'] ?? '')?>',
1352 path:
'<?= CMedialib::Escape($arItems[$i]['PATH
'])?>',
1353 type:
'<?= $arItems[$i]['TYPE
']?>',
1354 perm: {edit: <?= $arItems[
$i][
'perm'][
'edit'] ?
'true' :
'false'?>, del: <?= $arItems[
$i][
'perm'][
'del'] ?
'true' :
'false'?>},
1355 collections: <?=
count($arItems[
$i][
'collections']) == 1 ?
"['".$arItems[
$i][
'collections'][0].
"']" :
CUtil::PhpToJSObject($arItems[
$i][
'collections'])?>
1415 public static function InputFile(
1432 'upload' => $fileInput,
1433 'medialib' => $pathInput,
1434 'file_dialog' => $servInput,
1435 'cloud' => $cloudInput,
1437 'description' => $descInput
1442 public static function GetTypeById($id,
$arMLTypes =
false)
1454 public static function GetTypes($arConfigTypes =
array(), $bGetEmpties =
false)
1460 $cache =
new CPHPCache;
1461 $cacheId =
'medialib_types_'.$bGetEmpties;
1462 $cachePath = self::$cachePath.
'types';
1464 if ($cache->InitCache(self::$cacheTime, $cacheId, $cachePath))
1466 $res = $cache->GetVars();
1474 $q =
"SELECT MT.*, MC.ML_TYPE FROM b_medialib_type MT LEFT JOIN b_medialib_collection MC ON (MT.ID=MC.ML_TYPE)";
1476 $q =
"SELECT * FROM b_medialib_type";
1480 $arMLTypesInd =
array();
1484 if ($arMLTypesInd[
$arRes[
"ID"]] ??
false)
1487 $typeIcon =
"/bitrix/images/fileman/medialib/type_".mb_strtolower(
$arRes[
"CODE"]).
".gif";
1488 if (!file_exists(
$_SERVER[
'DOCUMENT_ROOT'].$typeIcon))
1489 $typeIcon =
"/bitrix/images/fileman/medialib/type_default.gif";
1491 if (
$arRes[
"SYSTEM"] ==
"Y")
1497 $arMLTypesInd[
$arRes[
"ID"]] =
true;
1501 "code" =>
$arRes[
"CODE"],
1502 "name" =>
$arRes[
"NAME"],
1504 "system" =>
$arRes[
"SYSTEM"] ==
"Y",
1505 "desc" =>
$arRes[
"DESCRIPTION"],
1506 "type_icon" => $typeIcon,
1507 "empty" => !(
$arRes[
'ML_TYPE'] ??
null) && (
$arRes[
"CODE"] !=
"image" ||
$arRes[
"SYSTEM"] !=
"Y")
1513 $cache->StartDataCache(self::$cacheTime, $cacheId, $cachePath);
1514 $cache->EndDataCache(
array(
1521 if (is_array($arConfigTypes) &&
count($arConfigTypes) > 0)
1525 if (in_array(mb_strtolower(
$type[
"code"]), $arConfigTypes))
1572 "UPDATE b_medialib_type SET ".
1576 $DB->QueryBind($strSql,
1582 self::ClearCache(
array(
"types"));
1585 public static function DelTypes($arIds =
array())
1587 if (
count($arIds) == 0)
1593 $strItems .=
",".intval($arIds[
$i]);
1595 $res =
$DB->Query(
"DELETE FROM b_medialib_type WHERE ID in (".$strItems.
")");
1597 self::ClearCache(
array(
"types"));
1602 public static function GetItemViewHTML($itemId)
1604 $arItem = CMedialibItem::GetList(
array(
'id' => $itemId));
1605 if (is_array($arItem) &&
count($arItem) > 0)
1609 while($arEvent = $events->Fetch())
1624 $videoExt =
array(
'flv',
'mp4',
'wmv',
'avi');
1625 $soundExt =
array(
'aac',
'mp3',
'wma');
1627 if ($item[
'TYPE'] ==
'image' || mb_strpos($item[
'CONTENT_TYPE'],
'image') !==
false)
1629 if(mb_substr($item[
'PATH'], 0, 1) !==
'/' || $item[
'PATH'] !== $item[
'PATH_EXTERNAL'])
1631 $src = $item[
'PATH_EXTERNAL'];
1635 $src = $item[
'PATH'];
1640 "html" =>
"<img src=\"".htmlspecialcharsex($src).
"\" width=\"".intval($item[
'WIDTH']).
"\" height=\"".intval($item[
'HEIGHT']).
"\" title=\"".htmlspecialcharsex($item[
'NAME']).
"\" />",
1641 "width" => intval($item[
'WIDTH']),
1642 "height" => intval($item[
'HEIGHT'])
1645 else if (mb_strpos($item[
'CONTENT_TYPE'],
'video') !==
false || in_array($ext, $videoExt))
1648 $item[
'WIDTH'] = 400;
1649 $item[
'HEIGHT'] = 300;
1656 "PLAYER_TYPE" =>
"auto",
1657 "PATH" => $item[
'PATH'],
1658 "WIDTH" => $item[
'WIDTH'],
1659 "HEIGHT" => $item[
'HEIGHT'],
1660 "FILE_TITLE" => $item[
'NAME'],
1661 "FILE_DESCRIPTION" =>
"",
1664 "WMODE" =>
"transparent",
1665 "WMODE_WMV" =>
"windowless",
1666 "SHOW_CONTROLS" =>
"Y",
1667 "BUFFER_LENGTH" =>
"3",
1671 array(
'HIDE_ICONS' =>
'Y')
1673 $s = ob_get_contents();
1678 "width" => $item[
'WIDTH'],
1679 "height" => $item[
'HEIGHT']
1682 else if (mb_strpos($item[
'CONTENT_TYPE'],
'audio') !==
false || in_array($ext, $soundExt))
1685 $item[
'WIDTH'] = 300;
1686 $item[
'HEIGHT'] = 24;
1693 "PROVIDER" =>
"sound",
1694 "PLAYER_TYPE" =>
"auto",
1695 "PATH" => $item[
'PATH'],
1696 "WIDTH" => $item[
'WIDTH'],
1697 "HEIGHT" => $item[
'HEIGHT'],
1698 "FILE_TITLE" => $item[
'NAME'],
1699 "FILE_DESCRIPTION" =>
"",
1700 "WMODE" =>
"transparent",
1701 "WMODE_WMV" =>
"windowless",
1702 "SHOW_CONTROLS" =>
"Y",
1703 "BUFFER_LENGTH" =>
"3",
1707 array(
'HIDE_ICONS' =>
'Y')
1709 $s =
"<div style='margin-top: 10px;'>".ob_get_contents().
"</div>";
1713 "width" => $item[
'WIDTH'],
1714 "height" => $item[
'HEIGHT']
1720window.bx_req_res = {
1721 html:
'<?= CUtil::JSEscape($arRes['html
'])?>',
1724 bReplaceAll: <?= (
$arRes[
'bReplaceAll'] ??
null) ===
true ?
'true' :
'false'?>
1730 public static function ChangeColType($Params)
1733 CMedialib::CanDoOperation(
'medialib_edit_collection', $Params[
'col']) &&
1734 CMedialib::CanDoOperation(
'medialib_edit_collection', $Params[
'parent']) &&
1735 $Params[
'col'] > 0 && $Params[
'type'] > 0
1741 if (intval($Params[
'childCols'][
$i]) > 0 &&
1742 CMedialib::CanDoOperation(
'medialib_edit_collection', $Params[
'childCols'][
$i]))
1743 $arChild[] = intval($Params[
'childCols'][
$i]);
1745 $Params[
'childCols'] = $arChild;
1747 CMedialibCollection::ChangeType($Params);
1748 ?><script>
top.bx_req_res =
true;</script><?
1752 ?><script>
top.bx_req_res =
false;</script><?
1756 public static function CompareTypesEx($typeMix, $arType)
1758 if ($typeMix == $arType[
'id'] || (!$typeMix && $arType[
'code'] ==
'image' && $arType[
'system']))
1764 public static function ClearCache(
$arPath =
false)
1773 $cache =
new CPHPCache;
1776 $cache->CleanDir(self::$cachePath.
$path);
1780 public static function AutosaveImage($file =
false)
1782 $res = CMedialibCollection::GetList(
array(
1783 'arFilter' =>
array(
1785 'NAME' =>
GetMessage(
'ML_AUTOSAVE_DEFAULT_COL')
1792 $colId = CMedialibCollection::Edit(
array(
1793 'arFields' =>
array(
1794 'NAME' =>
GetMessage(
'ML_AUTOSAVE_DEFAULT_COL'),
1795 'DESCRIPTION' =>
GetMessage(
'ML_AUTOSAVE_DEFAULT_COL_DEF'),
1796 'OWNER_ID' =>
$GLOBALS[
'USER']->GetId(),
1799 'ML_TYPE' =>
'image'
1805 $colId =
$res[0][
'ID'];
1808 if ($colId && $file)
1813 'arFields' =>
array(
1814 'NAME' => $file[
'name']
1816 'arCollections' =>
array($colId)
1821 $item = CMedialibItem::GetList(
array(
'id' =>
$res[
'ID']));
1822 if (is_array($item) &&
count($item) > 0)
1833class CMedialibCollection
1835 public static function GetList($Params =
array())
1839 $arOrder = isset($Params[
'arOrder']) ? $Params[
'arOrder'] : Array(
'ID' =>
'asc');
1842 "ID" => Array(
"FIELD_NAME" =>
"MLC.ID",
"FIELD_TYPE" =>
"int"),
1843 "NAME" => Array(
"FIELD_NAME" =>
"MLC.NAME",
"FIELD_TYPE" =>
"string"),
1844 "ACTIVE" => Array(
"FIELD_NAME" =>
"MLC.ACTIVE",
"FIELD_TYPE" =>
"string"),
1845 "DATE_UPDATE" => Array(
"FIELD_NAME" =>
"MLC.DATE_UPDATE",
"FIELD_TYPE" =>
"date"),
1846 "KEYWORDS" => Array(
"FIELD_NAME" =>
"MLC.KEYWORDS",
"FIELD_TYPE" =>
"string"),
1847 "DESCRIPTION" => Array(
"FIELD_NAME" =>
"MLC.DESCRIPTION",
"FIELD_TYPE" =>
"string"),
1848 "OWNER_ID" => Array(
"FIELD_NAME" =>
"MLC.OWNER_ID",
"FIELD_TYPE" =>
"int"),
1849 "PARENT_ID" => Array(
"FIELD_NAME" =>
"MLC.PARENT_ID",
"FIELD_TYPE" =>
"int"),
1850 "ML_TYPE" => Array(
"FIELD_NAME" =>
"MLC.ML_TYPE",
"FIELD_TYPE" =>
"string")
1853 $arSqlSearch =
array();
1860 $n = mb_strtoupper($filter_keys[
$i]);
1862 if((is_string(
$val) &&
$val ==
'') || (!is_array(
$val) && (
string)
$val===
"NOT_REF"))
1864 if (
$n ==
'ID' ||
$n ==
'PARENT_ID' ||
$n ==
'OWNER_ID')
1872 foreach($arOrder as $by=>
$order)
1873 if(isset(
$arFields[mb_strtoupper($by)]))
1874 $strOrderBy .=
$arFields[mb_strtoupper($by)][
"FIELD_NAME"].
' '.(mb_strtolower(
$order) ==
'desc'?
'desc'.($DB->type ==
"ORACLE"?
" NULLS LAST":
""):
'asc'.(
$DB->type ==
"ORACLE"?
" NULLS FIRST":
"")).
',';
1876 if($strOrderBy <>
'')
1877 $strOrderBy =
"ORDER BY ".rtrim($strOrderBy,
",");
1885 $strSqlSearch .=
"\n AND ML_TYPE in (".trim($strTypes,
", ").
")";
1892 b_medialib_collection MLC
1905 public static function CheckFields(
$arFields)
1924 public static function Edit($Params)
1930 $arFields[
'~DATE_UPDATE'] =
$DB->CurrentTimeFunction();
1932 if(!CMedialibCollection::CheckFields(
$arFields))
1948 $strUpdate =
$DB->PrepareUpdate(
"b_medialib_collection",
$arFields);
1950 "UPDATE b_medialib_collection SET ".
1952 " WHERE ID=".intval(
$ID);
1954 $DB->QueryBind($strSql,
1961 public static function Delete(
$ID, $bDelEmpty =
true)
1966 $strSql =
"DELETE FROM b_medialib_collection WHERE ID=".$ID;
1967 $z =
$DB->Query($strSql);
1969 $strSql =
"DELETE FROM b_medialib_collection_item WHERE COLLECTION_ID=".$ID;
1970 $z =
$DB->Query($strSql);
1973 CMedialibItem::DeleteEmpty();
1978 public static function IsViewable($oCol, $arCol=
false)
1981 $arCol = CMedialibCollection::GetList(
array(
'arFilter' =>
array(
'ACTIVE' =>
'Y')));
1983 if (!CMedialib::CanDoOperation(
'medialib_view_collection', $oCol[
'ID']))
1987 if ($oCol[
'PARENT_ID'])
1989 $parId = $oCol[
'PARENT_ID'];
1990 while(intval($parId) > 0)
1995 if ($arCol[
$i][
'ID'] == $parId)
1997 if (!CMedialib::CanDoOperation(
'medialib_view_collection', $arCol[
$i][
'ID']))
1999 $parId = $arCol[
$i][
'PARENT_ID'];
2011 public static function ChangeType($Params)
2015 'ML_TYPE' => $Params[
'type'],
2016 'PARENT_ID' => $Params[
'parent']
2019 $strUpdate =
$DB->PrepareUpdate(
"b_medialib_collection",
$arFields);
2021 "UPDATE b_medialib_collection SET ".
2023 " WHERE ID=".intval($Params[
'col']);
2027 if (
count($Params[
'childCols']) > 0 &&
$res)
2031 $strIds .=
",".intval($Params[
'childCols'][
$i]);
2033 $strUpdate =
$DB->PrepareUpdate(
"b_medialib_collection",
array(
'ML_TYPE' => $Params[
'type']));
2035 "UPDATE b_medialib_collection SET ".
2037 " WHERE ID in (".$strIds.
")";
2048 public static function CheckFields(
$arFields)
2056 public static function GetList($Params)
2061 if (is_array($Params[
'arCollections'] ??
null))
2063 if (
count($Params[
'arCollections']) == 1)
2065 $q =
'WHERE MCI.COLLECTION_ID='.intval($Params[
'arCollections'][0]);
2069 $strCollections =
"0";
2071 $strCollections .=
",".intval($Params[
'arCollections'][
$i]);
2072 $q =
'WHERE MCI.COLLECTION_ID in ('.$strCollections.
')';
2076 if (isset($Params[
'id']) && $Params[
'id'] > 0)
2077 $q =
'WHERE MI.ID='.intval($Params[
'id']);
2079 if (isset($Params[
'minId']) && $Params[
'minId'] > 0)
2082 $q = trim($q).
" AND MI.ID>=".intval($Params[
'minId']);
2084 $q .=
"WHERE MI.ID>=".intval($Params[
'minId']);
2088 MI.*,MCI.COLLECTION_ID, F.HEIGHT, F.WIDTH, F.FILE_SIZE, F.CONTENT_TYPE, F.SUBDIR, F.FILE_NAME, F.HANDLER_ID,
2089 ".$DB->DateToCharFunction(
"MI.DATE_UPDATE").
" as DATE_UPDATE2
2090 FROM b_medialib_collection_item MCI
2091 INNER JOIN b_medialib_item MI ON (MI.ID=MCI.ITEM_ID)
2092 INNER JOIN b_file F ON (F.ID=MI.SOURCE_ID) ".$q;
2102 CMedialibItem::GenerateThumbnail(
$arRes,
array(
'rootPath' => $rootPath,
'width' => $tmbW,
'height' => $tmbH));
2112 public static function Edit($Params)
2119 $Params[
'path'] ??=
null;
2120 $Params[
'file'] ??=
null;
2121 $bFile_FD = $Params[
'path'] && $Params[
'path'] <>
'';
2122 $bFile_PC = $Params[
'file'] && $Params[
'file'][
'name'] <>
'' && $Params[
'file'][
'size'] > 0;
2126 if ($bFile_FD || $bFile_PC)
2131 $tmp_name = $DocRoot.$Params[
'path'];
2133 if (
$io->FileExists($tmp_name))
2135 $flTmp =
$io->GetFile($tmp_name);
2136 $file_name = mb_substr($Params[
'path'], mb_strrpos($Params[
'path'],
'/') + 1);
2138 "name" => $file_name,
2139 "size" => $flTmp->GetFileSize(),
2140 "tmp_name" => $tmp_name,
2141 "type" => CFile::IsImage($file_name) ?
'image' :
'file'
2147 $arFile = $Params[
'file'];
2150 if (!CMedialib::CheckFileExtention($arFile[
"name"]))
2155 $arFile[
"old_file"] = CMedialibItem::GetSourceId(
$arFields[
'ID']);
2156 $arFile[
"del"] =
"Y";
2160 if (CFile::IsImage($arFile[
"name"]))
2163 'width' => COption::GetOptionInt(
'fileman',
"ml_max_width", 1024),
2164 'height' => COption::GetOptionInt(
'fileman',
"ml_max_height", 1024)
2169 $arFile[
"MODULE_ID"] =
"fileman";
2175 if ($arFile = $r->Fetch())
2177 if (CFile::IsImage($arFile[
'FILE_NAME']))
2178 CMedialibItem::GenerateThumbnail($arFile,
array(
'width' => COption::GetOptionInt(
'fileman',
"ml_thumb_width", 140),
'height' => COption::GetOptionInt(
'fileman',
"ml_thumb_height", 105)));
2180 $arFile[
'PATH'] = CMedialibItem::GetFullPath($arFile);
2186 if ($bNew && !$source_id)
2191 $arFields[
'~DATE_UPDATE'] =
$DB->CurrentTimeFunction();
2193 if(!CMedialibItem::CheckFields(
$arFields))
2196 if (CModule::IncludeModule(
"search"))
2199 if (
count($arStem) > 0)
2200 $arFields[
'SEARCHABLE_CONTENT'] =
'{'.implode(
'}{', array_keys($arStem)).
'}';
2220 $strUpdate =
$DB->PrepareUpdate(
"b_medialib_item",
$arFields);
2222 "UPDATE b_medialib_item SET ".
2224 " WHERE ID=".intval(
$ID);
2226 $DB->QueryBind($strSql,
2228 "DESCRIPTION" =>
$arFields[
"DESCRIPTION"],
2229 "SEARCHABLE_CONTENT" =>
$arFields[
"SEARCHABLE_CONTENT"]
2236 $strSql =
"DELETE FROM b_medialib_collection_item WHERE ITEM_ID=".intval(
$ID);
2237 $DB->Query($strSql);
2240 $strCollections =
"0";
2243 $strCollections .=
",".intval($Params[
'arCollections'][
$i]);
2246 "INSERT INTO b_medialib_collection_item(ITEM_ID, COLLECTION_ID) ".
2247 "SELECT ".intval(
$ID).
", ID ".
2248 "FROM b_medialib_collection ".
2249 "WHERE ID in (".$strCollections.
")";
2262 public static function GenerateThumbnail(&$arFile, $Params =
array())
2265 if (CFile::IsImage($arFile[
'FILE_NAME']))
2269 $arFile[
'THUMB_PATH'] = $arResized[
'src'];
2270 $arFile[
'TYPE'] =
'image';
2273 $arFile[
'TYPE'] =
'file';
2276 public static function GetItemCollections($Params)
2279 $strSql =
'SELECT MCI.COLLECTION_ID
2280 FROM b_medialib_collection_item MCI
2281 WHERE MCI.ITEM_ID='.intval($Params[
'ID']);
2290 public static function Delete(
$ID, $bCurrent, $colId)
2295 if (!CMedialib::CanDoOperation(
'medialib_del_item', $colId))
2297 $strSql =
"DELETE FROM b_medialib_collection_item WHERE ITEM_ID=".intval(
$ID).
" AND COLLECTION_ID=".intval($colId);
2298 $z =
$DB->Query($strSql);
2305 if (!CMedialib::CanDoOperation(
'medialib_del_item',
$arCols[
$i]))
2308 $strSql =
"DELETE FROM b_medialib_collection_item WHERE ITEM_ID=".intval(
$ID);
2309 $z =
$DB->Query($strSql);
2312 CMedialibItem::DeleteEmpty();
2317 public static function DeleteEmpty()
2321 $strSql =
'SELECT MI.*,MCI.COLLECTION_ID
2322 FROM b_medialib_item MI
2323 LEFT JOIN b_medialib_collection_item MCI ON (MI.ID=MCI.ITEM_ID)
2324 WHERE MCI.COLLECTION_ID is null';
2330 $strItems .=
",".intval(
$arRes[
'ID']);
2332 if (
$arRes[
'SOURCE_ID'] > 0)
2337 if ($strItems !=
"0")
2338 $DB->Query(
"DELETE FROM b_medialib_item WHERE ID in (".$strItems.
")");
2341 public static function GetThumbPath($arImage)
2343 return BX_PERSONAL_ROOT.
"/tmp/".$arImage[
'SUBDIR'].
'/'.$arImage[
'FILE_NAME'];
2346 public static function GetFullPath($arImage, $upload_dir =
false)
2351 public static function GetSourceId($id)
2354 $strSql =
'SELECT SOURCE_ID
2355 FROM b_medialib_item
2356 WHERE ID='.intval($id);
2357 $r =
$DB->Query($strSql);
2358 if (
$res = $r->Fetch())
2359 return $res[
'SOURCE_ID'];
2369 MI.*, MI.*,MCI.COLLECTION_ID, F.HEIGHT, F.WIDTH, F.FILE_SIZE, F.CONTENT_TYPE, F.SUBDIR, F.FILE_NAME, F.HANDLER_ID,
2370 ".$DB->DateToCharFunction(
"MI.DATE_UPDATE").
" as DATE_UPDATE2
2371 FROM b_medialib_item MI
2372 INNER JOIN b_medialib_collection_item MCI ON (MI.ID=MCI.ITEM_ID)
2373 INNER JOIN b_file F ON (F.ID=MI.SOURCE_ID)
2381 $strSql .=
" AND MI.SEARCHABLE_CONTENT LIKE '%".
$DB->ForSql($arQuery[
$i]).
"%'";
2383 $strSql .=
" ORDER BY MI.ID DESC";
2391 $elId2Index =
array();
2392 $colId2Index =
array();
2393 $arCol = CMedialibCollection::GetList(
array(
'arFilter' =>
array(
'ACTIVE' =>
'Y',
"TYPES" =>
$arTypes)));
2396 $colId2Index[$arCol[
$i][
'ID']] =
$i;
2400 $colId =
$arRes[
'COLLECTION_ID'];
2401 if (!isset($colId2Index[$colId]) || !CMedialibCollection::IsViewable($arCol[$colId2Index[$colId]], $arCol))
2404 if (isset($elId2Index[
$arRes[
'ID']]))
2418 CMedialibItem::GenerateThumbnail(
$arRes,
array(
'rootPath' => $rootPath,
'width' => $tmbW,
'height' => $tmbH));
2429class CMedialibTabControl
2431 public static function ShowScript()
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static ShowScript($arConfig)
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
static GetOptionInt($module_id, $name, $def="", $site=false)
static GetSiteDocRoot($site)
static GetOperations($ID, $return_names=false)
static ResizeImageGet($file, $arSize, $resizeType=BX_RESIZE_IMAGE_PROPORTIONAL, $bInitSizes=false, $arFilters=false, $bImmediate=false, $jpgQuality=false)
static SaveFile($arFile, $strSavePath, $forceRandom=false, $skipExtension=false, $dirAdd='')
static GetFileSRC($file, $uploadDir=false, $external=true)
static ResizeImage(&$arFile, $arSize, $resizeType=BX_RESIZE_IMAGE_PROPORTIONAL)
static GetByID($fileId, $realId=false)
static SetOption($category, $name, $value, $bCommon=false, $user_id=false)
static InitJSCore($arExt=[], $bReturn=false)
static PhpToJSObject($arData, $bWS=false, $bSkipTilda=false, $bExtType=false)
hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> height
bx popup label bx width30 PAGE_NEW_MENU_NAME text width
bx popup label bx hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> bx_view_property_<?=$propertyIndex?> overflow
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
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
$_SERVER["DOCUMENT_ROOT"]
if( $adminSidePanelHelper->isSidePanel())
ConvertDateTime($datetime, $to_format=false, $from_site=false, $bSearchInSitesOnly=false)
ExecuteModuleEventEx($arEvent, $arParams=[])
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
<? endif;?> window document title
if(empty($signedUserToken)) $key
</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."%"
stemming($sText, $sLang='ru', $bIgnoreStopWords=false, $bReturnPositions=false)
$GLOBALS['_____370096793']
adm detail iblock types adm detail iblock list tr_SITE_ID display