25 private $isShownContext =
false;
26 private $contextSettings =
array();
33 parent::AddHeaders($aParams);
40 $gridColumns = $gridOptions->GetVisibleColumns();
43 $this->arVisibleColumns =
array();
44 $this->aVisibleHeaders =
array();
45 foreach ($gridColumns as $columnId)
47 if (isset($this->aHeaders[$columnId]) && !isset($this->aVisibleHeaders[$columnId]))
49 $this->arVisibleColumns[] = $columnId;
50 $this->aVisibleHeaders[$columnId] = $this->aHeaders[$columnId];
66 && !($this->request->get(
'clear_nav') ===
'Y')
67 && isset($this->session[
'ADMIN_PAGINATION_DATA'][$this->table_id])
70 $paginationData = $this->session[
'ADMIN_PAGINATION_DATA'][
$this->table_id];
71 if (isset($paginationData[
'PAGE_NUM']))
73 $pageNum = (int)$paginationData[
'PAGE_NUM'];
79 $nav->setCurrentPage($pageNum);
84 if (!isset($this->session[
'ADMIN_PAGINATION_DATA']))
86 $this->session[
'ADMIN_PAGINATION_DATA'] = [];
88 $this->session[
'ADMIN_PAGINATION_DATA'][
$this->table_id] = [
'PAGE_NUM' => $nav->getCurrentPage()];
96 $request = Bitrix\Main\Context::getCurrent()->getRequest();
109 require_once(
$_SERVER[
"DOCUMENT_ROOT"].
BX_ROOT.
"/modules/main/interface/admin_lib.php");
118 if ($this->isPublicMode)
124 $this->totalRowCount = $queryObject->NavRecordCount;
125 $this->enableNextPage = $queryObject->PAGEN < $queryObject->NavPageCount;
132 $this->totalRowCount = $nav->getRecordCount();
133 $this->enableNextPage = $nav->getCurrentPage() < $nav->getPageCount();
138 "bitrix:main.pagenavigation",
141 "NAV_OBJECT" => $nav,
143 "SHOW_ALWAYS" => $showAllways,
145 "TABLE_ID" => $this->table_id,
153 $this->
NavText(ob_get_clean());
162 $arParamKill = array_merge($arParamKill,
array(
"internal",
"grid_id",
"grid_action",
"bxajaxid",
"sessid"));
165 return $APPLICATION->GetCurPageParam($strParam, $arParamKill, $get_index_page);
178 $_SERVER[
"REQUEST_METHOD"] ==
"POST" &&
179 !empty(
$_REQUEST[
"action_button_".$this->table_id]) &&
180 isset($_POST[
"FIELDS"]) &&
181 is_array($_POST[
"FIELDS"]) &&
186 foreach ($arrays as
$i => &$array)
189 foreach ($array[
"FIELDS"] as $id => &
$fields)
194 foreach ($keys as
$key)
196 if (preg_match(
"/_custom/i",
$key, $match))
198 if (!is_array($arrays[
$i][
"FIELDS"][$id][
$key]))
202 foreach ($arrays[
$i][
"FIELDS"][$id][
$key] as $value)
204 if (!isset($value[
"name"]) || !isset($value[
"value"]))
208 if (preg_match_all(
"/(.*?)\[(.*?)\]/", $value[
"name"], $listMatchKeys))
210 $listPreparedKeys = [];
211 foreach ($listMatchKeys as $matchKeys)
213 foreach ($matchKeys as $matchKey)
215 if (!is_string($matchKey) || trim($matchKey) ==
'')
219 if (!str_contains($matchKey,
"[") && !str_contains($matchKey,
"]"))
221 $listPreparedKeys[] = $matchKey;
225 $listPreparedKeys[] = $value[
"value"];
226 $customFields = array_replace_recursive($customFields, $this->prepareCustomKey(
227 array_shift($listPreparedKeys), $listPreparedKeys));
230 unset($arrays[
$i][
"FIELDS"][$id][
$key]);
233 if(($c = substr(
$key, 0, 1)) ==
'~' || $c ==
'=')
235 unset($arrays[
$i][
"FIELDS"][$id][
$key]);
242 $arrays[
$i] = array_replace_recursive($arrays[
$i], $customFields);
250 private function prepareCustomKey(
$key,
array $keys)
252 return (
count($keys) == 1 ? [
$key => array_shift($keys)] :
253 [
$key => $this->prepareCustomKey(array_shift($keys), $keys)]);
303 isset(
$_REQUEST[
"action_all_rows_".$this->table_id])
304 &&
$_REQUEST[
"action_all_rows_".$this->table_id] ===
'Y'
315 foreach (
$_REQUEST[
"action"] as $actionKey => $actionValue)
318 if (!empty(
$_REQUEST[
"action_button_".$this->table_id]))
327 $listParams = explode(
"&", $add_params);
328 $addParams =
array();
331 foreach($listParams as $param)
333 $explode = explode(
"=", $param);
334 if ($explode[0] && $explode[1])
336 $addParams[$explode[0]] = $explode[1];
342 "action_button_".$this->table_id => $action_id,
351 return "BX.Main.gridManager.getById('".$this->table_id.
"').instance.reloadTable('POST', ".
357 $filterOption =
new Filter\Options($this->table_id);
359 $filterable =
array();
360 $quickSearchKey =
"";
363 if (isset($filterField[
"quickSearch"]))
365 $quickSearchKey = $filterField[
"quickSearch"].$filterField[
"id"];
367 $filterable[$filterField[
"id"]] = $filterField[
"filterable"] ??
null;
370 foreach ($filterData as $fieldId => $fieldValue)
372 if ((is_array($fieldValue) && empty($fieldValue)) || (is_string($fieldValue) && $fieldValue ==
''))
377 if (str_ends_with($fieldId,
"_from"))
379 $realFieldId = mb_substr($fieldId, 0, mb_strlen($fieldId) - 5);
380 if (!array_key_exists($realFieldId, $filterable))
384 if (str_ends_with($realFieldId,
"_1"))
390 if (!empty($filterData[$realFieldId.
"_numsel"]) && $filterData[$realFieldId.
"_numsel"] ==
"more")
393 $filterPrefix =
">=";
394 $arFilter[$filterPrefix.$realFieldId] = trim($fieldValue);
397 elseif (str_ends_with($fieldId,
"_to"))
399 $realFieldId = mb_substr($fieldId, 0, mb_strlen($fieldId) - 3);
400 if (!array_key_exists($realFieldId, $filterable))
404 if (str_ends_with($realFieldId,
"_1"))
406 $realFieldId = mb_substr($realFieldId, 0, mb_strlen($realFieldId) - 2);
407 $arFilter[$realFieldId.
"_2"] = $fieldValue;
411 if (!empty($filterData[$realFieldId.
"_numsel"]) && $filterData[$realFieldId.
"_numsel"] ==
"less")
414 $filterPrefix =
"<=";
415 $arFilter[$filterPrefix.$realFieldId] = trim($fieldValue);
420 if (array_key_exists($fieldId, $filterable))
422 $filterPrefix = $filterable[$fieldId];
423 $arFilter[$filterPrefix.$fieldId] = $fieldValue;
425 if ($fieldId ==
"FIND" && trim($fieldValue) && $quickSearchKey)
427 $arFilter[$quickSearchKey] = $fieldValue;
435 return (
bool)(
count($this->arGroupErrors));
441 foreach ($this->arGroupErrors as $groupError)
443 $error .=
" ".$groupError[0];
462 if (!empty($this->contextSettings[
"pagePath"]))
464 $pagePath = $this->contextSettings[
'pagePath'];
465 $queryString =
DeleteParam([self::MODE_FIELD_NAME]);
466 if ($queryString !==
'')
468 $pagePath .= (!str_contains($pagePath,
'?') ?
'?' :
'&') . $queryString;
470 $pageParams = static::getModeExportParam();
471 if ($this->isPublicMode)
472 $pageParams[
"public"] =
"y";
473 $uri = (
new Uri($pagePath))->addParams($pageParams);
477 $uri = (
new Uri(
$APPLICATION->GetCurPageParam()))->addParams(static::getModeExportParam());
479 $link =
$uri->deleteParams([
"apply_filter"])->getUri();
484 "GLOBAL_ICON"=>
"adm-menu-excel",
492 if (!empty($menu) || !empty($additional))
498 private function GetGroupAction()
501 $this->table_id, $this->arActions, $this->arActionsParams);
503 return $actionPanelConstructor->getActionPanel();
514 $selfFolderUrl = (defined(
"SELF_FOLDER_URL") ? SELF_FOLDER_URL :
"/bitrix/admin/");
516 if (!empty($link) && !preg_match($reqValue, $link) && preg_match(
"/\.php/i", $link))
523 $row->pList = &$this;
524 $row->bEditMode =
true;
527 $this->aRows[] = &$row;
557 if (!empty($filterPreset[
"current"]))
559 $this->currentPreset = $filterPreset;
566 $options =
new Filter\Options($this->table_id);
577 $filterParams = array_merge(
580 "FILTER_ID" => $this->table_id,
581 "GRID_ID" => $this->table_id,
583 "FILTER_PRESETS" => $this->filterPresets,
584 "ENABLE_LABEL" =>
true,
585 "ENABLE_LIVE_SEARCH" =>
true,
589 if ($this->currentPreset)
591 $options =
new Filter\Options($this->table_id, $this->filterPresets);
592 $options->setFilterSettings($this->currentPreset[
"id"] ??
'', $this->currentPreset,
true,
false);
598 $this->context->setFilterContextParam(
true);
603 \Bitrix\UI\Toolbar\Facade\Toolbar::addFilter($filterParams);
608 $APPLICATION->SetAdditionalCSS(
'/bitrix/css/main/grid/webform-button.css');
609 \Bitrix\UI\Toolbar\Facade\Toolbar::addFilter($filterParams);
610 \Bitrix\UI\Toolbar\Facade\Toolbar::hideTitle();
611 $APPLICATION->IncludeComponent(
'bitrix:ui.toolbar',
'admin');
612 $this->ShowContext();
619 BX.ready(
function () {
620 if (!window[
'filter_<?=$this->table_id?>'] ||
621 !BX.is_subclass_of(window[
'filter_<?=$this->table_id?>'], BX.adminUiFilter))
623 window[
'filter_<?=$this->table_id?>'] =
new BX.adminUiFilter(
'<?=$this->table_id?>', []);
630 private static function checkFilterField($field): bool
632 return !(empty($field) || !is_array($field));
639 [__CLASS__,
'checkFilterField']
656 if (isset($row[
'selector']) && isset($row[
'selector'][
'type']))
658 if ($row[
'selector'][
'type'] ===
'user')
660 $row[
'type'] = Filter\FieldAdapter::DEST_SELECTOR;
661 unset($row[
'selector']);
664 'context' =>
'SHOP_USER',
666 'contextCode' =>
'U',
668 'enableSonetgroups' =>
'N',
669 'allowEmailInvitation' =>
'N',
670 'allowSearchEmailUsers' =>
'N',
671 'departmentSelectDisable' =>
'Y',
686 $selfFolderUrl = (defined(
"SELF_FOLDER_URL") ? SELF_FOLDER_URL :
"/bitrix/admin/");
694 if (isset($filterField[
"selector"]) && isset($filterField[
"selector"][
"type"]))
696 switch ($filterField[
"selector"][
"type"])
701 BX.ready(
function() {
702 if (!window[
"userFilterHandler_<?=$filterField["id"]?>"])
705 filterId:
"<?=$this->table_id?>",
706 fieldId:
"<?=$filterField["id"]?>",
707 languageId:
"<?=LANGUAGE_ID?>",
708 selfFolderUrl:
"<?=$selfFolderUrl?>"
710 window[
"userFilterHandler_<?=$filterField["id"]?>"] =
711 new BX.adminUserFilterHandler(params);
714 if (typeof(SUVsetUserId_<?=$filterField[
"id"]?>) ===
"undefined")
716 function SUVsetUserId_<?=$filterField[
"id"]?>(userId)
718 if (window[
"userFilterHandler_<?=$filterField["id"]?>"])
720 var adminUserFilterHandler = window[
"userFilterHandler_<?=$filterField["id"]?>"];
721 adminUserFilterHandler.setSelected(userId);
731 BX.ready(
function() {
732 if (!window[
"productFilterHandler_<?=$filterField["id"]?>"])
735 filterId:
"<?=$this->table_id?>",
736 fieldId:
"<?=$filterField["id"]?>",
737 languageId:
"<?=LANGUAGE_ID?>",
738 publicMode:
"<?=($this->isPublicMode ? "Y
" : "N
")?>",
739 selfFolderUrl:
"<?=$selfFolderUrl?>"
741 window[
"productFilterHandler_<?=$filterField["id"]?>"] =
742 new BX.adminProductFilterHandler(params);
745 if (typeof(FillProductFields_<?=$filterField[
"id"]?>) ===
"undefined")
747 function FillProductFields_<?=$filterField[
"id"]?>(product)
749 if (window[
"productFilterHandler_<?=$filterField["id"]?>"])
751 var adminProductFilterHandler =
752 window[
"productFilterHandler_<?=$filterField["id"]?>"];
753 adminProductFilterHandler.closeProductSearchDialog();
754 adminProductFilterHandler.setSelected(product[
"id"], product[
"name"]);
772 foreach(
GetModuleEvents(
"main",
"OnAdminListDisplay",
true) as $arEvent)
776 if (!is_array($this->arActions))
778 $this->arActions = [];
780 if (!is_array($this->arActionsParams))
782 $this->arActionsParams = [];
786 foreach ($this->arFilterErrors as
$error)
789 'TYPE' => Bitrix\Main\Grid\MessageType::ERROR,
793 foreach ($this->arUpdateErrors as $arError)
796 'TYPE' => Bitrix\Main\Grid\MessageType::ERROR,
797 'TEXT' => $arError[0],
800 foreach ($this->arGroupErrors as $arError)
803 'TYPE' => Bitrix\Main\Grid\MessageType::ERROR,
804 'TEXT' => $arError[0],
808 if (Context::isValidateRequest())
813 require_once(
$_SERVER[
"DOCUMENT_ROOT"].
BX_ROOT.
"/modules/main/interface/admin_lib.php");
818 if (!empty($errorMessages))
828 if (Context::isShowpageRequest() && !empty($errorMessages))
833 require_once(
$_SERVER[
"DOCUMENT_ROOT"].
BX_ROOT.
"/modules/main/interface/admin_lib.php");
843 \Bitrix\Main\UI\Extension::load(
'ui.fonts.opensans');
844 $APPLICATION->SetAdditionalCSS(
'/bitrix/css/main/grid/webform-button.css');
848 $selfFolderUrl = (defined(
"SELF_FOLDER_URL") ? SELF_FOLDER_URL :
"/bitrix/admin/");
850 $this->ShowContext();
852 $gridParameters =
array(
853 "GRID_ID" => $this->table_id,
855 "AJAX_OPTION_JUMP" =>
"N",
856 "AJAX_OPTION_HISTORY" =>
"N",
857 "SHOW_PAGESIZE" =>
true,
858 "AJAX_ID" => CAjax::getComponentID(
"bitrix:main.ui.grid",
".default",
""),
859 "ALLOW_PIN_HEADER" =>
true,
860 "ALLOW_VALIDATE" =>
false,
861 "HANDLE_RESPONSE_ERRORS" =>
true,
862 'USE_CHECKBOX_LIST_FOR_SETTINGS_POPUP' =>
$arParams[
'USE_CHECKBOX_LIST_FOR_SETTINGS_POPUP'] ??
false,
863 'ENABLE_FIELDS_SEARCH' =>
$arParams[
'ENABLE_FIELDS_SEARCH'] ??
'N',
866 $actionPanel = (
$arParams[
"ACTION_PANEL"] ?? $this->GetGroupAction());
869 $gridParameters[
"ACTION_PANEL"] = $actionPanel;
873 $gridParameters[
"SHOW_CHECK_ALL_CHECKBOXES"] =
false;
874 $gridParameters[
"SHOW_ROW_CHECKBOXES"] =
false;
875 $gridParameters[
"SHOW_SELECTED_COUNTER"] =
false;
876 $gridParameters[
"SHOW_ACTION_PANEL"] =
false;
879 if (isset(
$arParams[
"SHOW_TOTAL_COUNTER"]))
881 $gridParameters[
"SHOW_TOTAL_COUNTER"] =
$arParams[
"SHOW_TOTAL_COUNTER"];
884 $showTotalCountHtml = (isset(
$arParams[
"SHOW_COUNT_HTML"]) &&
$arParams[
"SHOW_COUNT_HTML"] ===
true);
885 if ($showTotalCountHtml)
887 $gridParameters[
"TOTAL_ROWS_COUNT_HTML"] = $this->getTotalRowsCountHtml();
890 $gridOptions =
new Grid\Options($gridParameters[
"GRID_ID"]);
891 $defaultSort =
array();
892 if ($this->sort instanceof CAdminSorting)
894 $defaultSort =
array(
"sort" =>
array($this->sort->getField() => $this->sort->getOrder()));
896 $sorting = $gridOptions->GetSorting($defaultSort);
897 $gridParameters[
"SORT"] = !isset($_GET[$sorting[
'vars'][
'by']]) || !isset($_GET[$sorting[
'vars'][
'order']]) ? $sorting[
"sort"] : $defaultSort[
'sort'];
898 $gridParameters[
"SORT_VARS"] = $sorting[
"vars"];
899 $gridColumns = $gridOptions->getVisibleColumns();
900 if (empty($gridColumns))
901 $gridColumns = array_keys($this->aVisibleHeaders);
911 $gridParameters[
"SHOW_PAGINATION"] =
false;
914 $gridParameters[
"PAGE_SIZES"] =
array(
915 array(
"NAME" =>
"5",
"VALUE" =>
"5"),
916 array(
"NAME" =>
"10",
"VALUE" =>
"10"),
917 array(
"NAME" =>
"20",
"VALUE" =>
"20"),
918 array(
"NAME" =>
"50",
"VALUE" =>
"50"),
919 array(
"NAME" =>
"100",
"VALUE" =>
"100"),
920 array(
"NAME" =>
"200",
"VALUE" =>
"200"),
921 array(
"NAME" =>
"500",
"VALUE" =>
"500")
924 $gridParameters[
"ROWS"] =
array();
926 foreach ($this->aRows as $row)
930 "actions" => $row->getPreparedActions()
933 $gridRow[
"default_action"] =
array();
936 $gridRow[
"default_action"][
"title"] = $row->title;
939 switch ($defaultActionType)
946 $gridRow[
"default_action"][
"onclick"] =
"BX.adminSidePanel.onOpenPage('".$row->link.
"', ".$skipUrlModify.
");";
954 if ($this->isPublicMode)
956 if (!empty($row->link))
958 $row->link = str_replace(
"/bitrix/admin/",
$selfFolderUrl, $row->link);
965 if ($this->isPublicMode)
967 $skipUrlModificationEnabled = (
$arParams[
'SKIP_URL_MODIFICATION'] ??
false) ===
true;
968 $skipUrlModification = $skipUrlModificationEnabled && !str_contains($row->link,
'/bitrix/admin/')
971 $gridRow[
"default_action"][
"onclick"] =
"BX.adminSidePanel.onOpenPage('".$row->link.
"', ".$skipUrlModification.
");";
980 $gridRow[
"default_action"][
"onclick"] =
"";
985 foreach ($row->aFields as $fieldId => $field)
987 if (!empty($field[
"edit"][
"type"]))
988 $this->SetHeaderEditType($fieldId, $field);
991 $listEditable =
array();
992 foreach (array_diff_key($this->aHeaders, $row->aFields) as $fieldId => $field)
994 $listEditable[$fieldId] =
false;
997 $disableEditColumns =
array();
999 foreach ($gridColumns as $columnId)
1003 if (isset($row->aFields[$columnId]))
1005 $field = $row->aFields[$columnId];
1007 if (isset($row->arRes[$columnId]))
1009 if (!is_array($row->arRes[$columnId]))
1011 $value = trim((
string)$row->arRes[$columnId]);
1015 $value = $row->arRes[$columnId];
1020 if (isset($field[
"edit"][
"type"]))
1022 switch ($field[
"edit"][
"type"])
1025 if ($fileArray = CFile::getFileArray($value))
1026 $editValue = $fileArray[
"SRC"];
1029 $editValue = $field[
"edit"][
"value"];
1032 $moneyAttributes = $field[
"edit"][
"attributes"];
1034 'PRICE' => $moneyAttributes[
'PRICE'],
1035 'CURRENCY' => $moneyAttributes[
'CURRENCY'],
1036 'ATTRIBUTES' => $moneyAttributes[
'ATTRIBUTES'],
1039 if (is_array($moneyAttributes[
'HIDDEN']))
1041 $editValue[
'HIDDEN'] = [];
1042 foreach ($moneyAttributes[
'HIDDEN'] as $hiddenItem)
1044 $editValue[
'HIDDEN'][$hiddenItem[
'NAME']] = $hiddenItem[
'VALUE'];
1052 $disableEditColumns[$columnId] =
false;
1055 $gridRow[
"data"][$columnId] = $editValue;
1057 if (isset($field[
"view"][
"type"]))
1059 switch ($field[
"view"][
"type"])
1068 if (isset($field[
"edit"][
"values"][$value]))
1070 $value = htmlspecialcharsex($field[
"edit"][
"values"][$value]);
1072 elseif (isset($field[
"view"][
"values"][$value]))
1074 $value = htmlspecialcharsex($field[
"view"][
"values"][$value]);
1079 $field[
"view"][
"showInfo"], $field[
"view"][
"inputs"]) :
"";
1082 $value = $field[
"view"][
"value"] ??
'';
1085 $value = htmlspecialcharsex($value);
1094 $gridRow[
"columns"][$columnId] =
$value;
1096 $gridRow[
"editable"] = $listEditable;
1097 if (!empty($disableEditColumns))
1098 $gridRow[
"editableColumns"] = $disableEditColumns;
1100 $gridParameters[
"ROWS"][] = $gridRow;
1103 $gridParameters[
"COLUMNS"] =
array();
1104 foreach ($this->aHeaders as $header)
1106 $header[
"name"] = $header[
"content"];
1107 $gridParameters[
"COLUMNS"][] = $header;
1110 if (!empty($errorMessages))
1112 $gridParameters[
"MESSAGES"] = $errorMessages;
1116 "bitrix:main.ui.grid",
1119 false,
array(
"HIDE_ICONS" =>
"Y")
1126 $jsParams[
"showTotalCountHtml"] = $showTotalCountHtml;
1131 if (!window[
'<?=$this->table_id?>'] || !BX.is_subclass_of(window[
'<?=$this->table_id?>'], BX.adminUiList))
1133 window[
'<?=$this->table_id?>'] =
new BX.adminUiList(
1134 '<?=$this->table_id?>', <?= Json::encode(
$jsParams) ?>);
1136 BX.adminChain.addItems(
"<?=$this->table_id?>_navchain_div");
1141 private function getTotalRowsCountHtml()
1145 <div><?=
GetMessage(
"admin_lib_list_all_title").
": " ?>
1146 <a
id=
"<?=$this->table_id?>_show_total_count" href=
"#"><?=
GetMessage(
"admin_lib_list_show_row_count_title")?></a>
1149 return ob_get_clean();
1152 private function ShowContext()
1154 if ($this->context && !$this->isShownContext)
1156 $this->isShownContext =
true;
1157 $this->context->Show();
1161 private function SetHeaderEditType($headerId, $field)
1163 if (!isset($this->aHeaders[$headerId]))
1168 if (isset($this->aHeaders[$headerId][
"editable"]) && $this->aHeaders[$headerId][
"editable"] ===
false)
1174 switch ($field[
"edit"][
"type"])
1177 $editable =
array(
"TYPE" => Types::TEXT);
1180 $editable =
array(
"TYPE" => Types::DATE);
1183 $editable =
array(
"TYPE" => Types::CHECKBOX);
1187 "TYPE" => Types::DROPDOWN,
1188 "items" => $field[
"edit"][
"values"]
1193 "TYPE" => Types::IMAGE,
1197 $editable =
array(
"TYPE" => Types::CUSTOM);
1201 "TYPE" => Types::MONEY,
1202 "CURRENCY_LIST" => $field[
"edit"][
"attributes"][
"CURRENCY_LIST"],
1203 "HTML_ENTITY" => $field[
"edit"][
"attributes"][
"HTML_ENTITY"] ??
false,
1207 $editable =
array(
"TYPE" => Types::TEXT);
1210 $this->aHeaders[$headerId][
"editable"] = $editable;
1256 private $inputActions;
1257 private $inputActionsParams;
1262 private $gridSnippets;
1264 private $actionSections = [];
1265 private $mapTypesAndSections = [
1266 "edit" =>
"default",
1267 "delete" =>
"default",
1268 "button" =>
"button",
1270 "customjs" =>
"list",
1272 "for_all" =>
"forAll"
1274 private $mapTypesAndHandlers = [];
1278 $this->tableId = $tableId;
1279 $this->inputActions = $actions;
1280 $this->inputActionsParams = $actionsParams;
1284 $this->actionSections = [
1289 "ID" =>
"base_action_select_{$this->tableId}",
1290 "NAME" =>
"action_button_{$this->tableId}",
1293 "NAME" =>
GetMessage(
"admin_lib_list_actions"),
1294 "VALUE" =>
"default",
1312 $items = $this->getItems();
1314 $actionPanel[
"GROUPS"][] =
array(
"ITEMS" =>
$items);
1316 return $actionPanel;
1346 foreach ($listKeyForDelete as $keyForDelete)
1348 if (isset($this->actionSections[$keyForDelete]))
1350 unset($this->actionSections[$keyForDelete]);
1354 $this->actionSections = array_merge($this->actionSections, $actionSections);
1364 $this->mapTypesAndSections = array_merge($this->mapTypesAndSections, $mapTypesAndSections);
1395 $this->mapTypesAndHandlers = array_merge($this->mapTypesAndHandlers, $mapTypesAndHandlers);
1401 private function getDefaultApplyAction()
1403 return [
"JS" =>
"BX.adminUiList.SendSelected('{$this->tableId}')"];
1409 private function getItems()
1413 $actionSections = $this->getActionSections();
1415 foreach ($actionSections as $actionSection)
1417 if ($this->isAssociativeArray($actionSection))
1419 $items[] = $actionSection;
1423 foreach ($actionSection as $aSection)
1436 private function getActionSections()
1438 if (isset($this->inputActions[
"edit"]) && isset($this->actionSections[$this->mapTypesAndSections[
"edit"]]))
1440 $this->actionSections[$this->mapTypesAndSections[
"edit"]][] = $this->gridSnippets->getEditButton();
1442 if (isset($this->inputActions[
"delete"]) && isset($this->actionSections[$this->mapTypesAndSections[
"delete"]]))
1444 $this->actionSections[$this->mapTypesAndSections[
"delete"]][] = $this->gridSnippets->getRemoveButton();
1447 foreach ($this->inputActions as $actionKey =>
$action)
1449 $this->setActionSection($this->actionSections, $actionKey,
$action);
1452 if (isset($this->inputActions[
"for_all"]) && isset($this->actionSections[$this->mapTypesAndSections[
"for_all"]]))
1454 $this->actionSections[$this->mapTypesAndSections[
"for_all"]][] = $this->gridSnippets->getForAllCheckbox();
1457 if (
count($this->actionSections[
"list"][
"ITEMS"]) == 1)
1459 $this->actionSections[
"list"] = [];
1462 return $this->actionSections;
1471 private function setActionSection(
array &$actionSections, $actionKey,
$action)
1477 $actionSection = $this->mapTypesAndSections[
$type] ??
"list";
1479 $method =
"get".$type.
"ActionData";
1480 if (isset($this->mapTypesAndHandlers[
$type]) && is_callable($this->mapTypesAndHandlers[
$type]))
1482 $actionSections[$actionSection][] = $this->mapTypesAndHandlers[
$type]($actionKey,
$action);
1486 if ($actionSection ==
"list")
1488 $actionSections[
"list"][
"ITEMS"][] = $this->
$method($actionKey,
$action);
1492 $actionSections[$actionSection][] = $this->
$method($actionKey,
$action);
1498 if (!in_array($actionKey, [
"edit",
"delete",
"for_all"]))
1500 $actionSections[
"list"][
"ITEMS"][] = [
1502 "VALUE" => $actionKey,
1505 "ACTION" => Panel\Actions::RESET_CONTROLS
1507 $this->getApplyButtonCreationAction()
1519 private function getButtonActionData($actionKey,
$action)
1521 $onChange =
$action[
"action"] ? [
1522 [
"ACTION" => Panel\Actions::CALLBACK,
"DATA" => [[
"JS" =>
$action[
"action"]]]]] : [];
1526 "TYPE" => Bitrix\Main\Grid\Panel\Types::BUTTON,
1528 "ONCHANGE" => $onChange
1537 private function getSelectActionData($actionKey,
$action)
1539 $internalOnchange = [];
1540 if (!empty($this->inputActionsParams[
"internal_select_onchange"]))
1542 $internalOnchange[] = [
1543 "ACTION" => Panel\Actions::CALLBACK,
1545 [
"JS" => $this->inputActionsParams[
"internal_select_onchange"]]
1564 if (is_array(
$action[
"items"]))
1568 if (empty(
$items[
"ONCHANGE"]))
1570 $items[
"ONCHANGE"] = $internalOnchange;
1576 "ACTION" => Panel\Actions::CALLBACK,
1578 [
"JS" =>
$items[
"ONCHANGE"]]
1588 "ACTION" => Panel\Actions::RESET_CONTROLS
1591 "ACTION" => Panel\Actions::CREATE,
1594 "TYPE" => Panel\Types::DROPDOWN,
1595 "ID" =>
"selected_action_{$this->tableId}_".$action[
"controlId"],
1596 "NAME" =>
$action[
"controlName"],
1599 $this->gridSnippets->getApplyButton(
1603 "ACTION" => Panel\Actions::CALLBACK,
1605 $this->getDefaultApplyAction()
1615 if (!empty($this->inputActionsParams[
"select_onchange"]))
1618 "ACTION" => Panel\Actions::CALLBACK,
1620 [
"JS" => $this->inputActionsParams[
"select_onchange"]]
1627 "VALUE" => $actionKey,
1628 "ONCHANGE" => $onchange
1637 private function getCustomJsActionData($actionKey,
$action)
1641 "VALUE" => $actionKey,
1643 [
"ACTION" => Panel\Actions::RESET_CONTROLS],
1644 $this->getApplyButtonCreationAction(
$action[
"js"])
1654 private function getBaseActionData($actionKey,
$action)
1658 "VALUE" => $actionKey,
1660 [
"ACTION" => Panel\Actions::RESET_CONTROLS],
1661 $this->getApplyButtonCreationAction(
$action[
"action"])
1671 private function getHtmlActionData($actionKey,
$action)
1675 "TYPE" => Panel\Types::CUSTOM,
1685 private function getMultiControlActionData($actionKey,
array $action)
1689 "VALUE" => $actionKey,
1690 "ONCHANGE" =>
$action[
"action"]
1698 private function getApplyButtonCreationAction($jsCallback =
"")
1700 $action = $this->getDefaultApplyAction();
1701 if ($jsCallback !=
'')
1706 "ACTION" => Panel\Actions::CREATE,
1708 $this->gridSnippets->getApplyButton(
1712 "ACTION" => Panel\Actions::CALLBACK,
1728 private function isAssociativeArray($array)
1730 if (!is_array($array) || empty($array))
1732 return array_keys($array) !== range(0,
count($array) - 1);
1744 if (
$action[
"type"] ==
"select")
1751 if (!isset(
$action[
"controlId"]) && isset(
$action[
"controlName"]))
1962 private $isShownFilterContext =
false;
1966 $this->isShownFilterContext = $bool;
1971 foreach (
GetModuleEvents(
"main",
"OnAdminContextMenuShow",
true) as $arEvent)
1976 if (empty($this->items) && empty($this->additional_items))
1983 if ($this->isPublicMode)
1985 $this->showBaseButton(ButtonLocation::AFTER_TITLE);
1986 $this->showActionButton();
1990 $this->showActionButton();
1991 $this->showBaseButton();
1992 if (!$this->isShownFilterContext)
1995 \Bitrix\UI\Toolbar\Facade\Toolbar::hideTitle();
1996 $APPLICATION->IncludeComponent(
'bitrix:ui.toolbar',
'admin');
2001 private function showActionButton()
2003 if (!empty($this->additional_items))
2005 if ($this->isPublicMode)
2007 $menuUrl =
'BX.adminList.showPublicMenu(this.getContainer(), ' .
2012 $menuUrl =
'BX.adminList.ShowMenu(this.getContainer(), ' .
2016 $button = new \Bitrix\UI\Buttons\SettingsButton([
2017 'click' =>
new \Bitrix\UI\Buttons\JsCode($menuUrl),
2019 \Bitrix\UI\Toolbar\Facade\Toolbar::addButton($button);
2023 private function showBaseButton(
string $location = ButtonLocation::RIGHT)
2025 if (!empty($this->items))
2028 $firstItem = array_shift(
$items);
2029 if (!empty($firstItem[
'MENU']))
2033 if ($this->isPublicMode)
2035 $menuUrl =
'BX.adminList.showPublicMenu(this.getContainer(), ' .
2040 $menuUrl =
'BX.adminList.ShowMenu(this.getContainer(), ' .
2045 'color' => \Bitrix\UI\Buttons\Color::PRIMARY,
2046 'id' => !empty($firstItem[
'ID']) ? $firstItem[
'ID'] :
null,
2047 'text' => $firstItem[
'TEXT'],
2051 if (!empty($firstItem[
'ONCLICK']))
2053 $buttonParams[
'mainButton'][
'click'] = new \Bitrix\UI\Buttons\JsCode($firstItem[
'ONCLICK']);
2057 if (isset($firstItem[
'DISABLE']))
2059 $buttonParams[
'mainButton'][
'click'] = new \Bitrix\UI\Buttons\JsCode($menuUrl);
2063 $buttonParams[
'mainButton'][
'link'] = $firstItem[
'LINK'];
2066 $buttonParams[
'menuButton'][
'click'] = new \Bitrix\UI\Buttons\JsCode($menuUrl);
2067 $button =
new Bitrix\UI\Buttons\Split\Button($buttonParams);
2071 if (!empty($firstItem[
'ONCLICK']))
2073 $buttonParams[
'click'] = new \Bitrix\UI\Buttons\JsCode($firstItem[
'ONCLICK']);
2077 $buttonParams[
'link'] = $firstItem[
'LINK'];
2079 $button = new \Bitrix\UI\Buttons\Button($buttonParams);
2081 \Bitrix\UI\Toolbar\Facade\Toolbar::addButton($button,
$location);
static getString($length, $caseSensitive=false)
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)