20 private const PREFIX_ID =
'iblock_grid_action_';
36 'SECTION_CHOOSER' => Iblock\IblockTable::SECTION_CHOOSER_SELECT
54 $this->entityId =
$options[
'ENTITY_ID'];
55 $this->iblockId =
$options[
'IBLOCK_ID'];
63 $this->request = Main\Context::getCurrent()->getRequest();
74 public function getList(?array $actions =
null): array
78 $actions ??= array_keys($this->actionHandlers);
82 foreach ($actions as $code => $params)
84 if (is_string($params))
89 if (is_string($code) && is_array($params))
91 $row = $this->
get($code, $params);
94 $result[$code] = $row;
98 unset($row, $code, $params);
109 public function get(
string $code, array $params = [])
112 if ($code ===
'' || !isset($this->actionHandlers[$code]))
117 $method =
'action'.$this->actionHandlers[$code].
'Panel';
118 if (is_callable([$this, $method]))
120 return call_user_func_array([$this, $method], [$params]);
133 if ($code ===
'' || !isset($this->actionHandlers[$code]))
138 $method =
'action'.$this->actionHandlers[$code].
'Request';
139 if (is_callable([$this, $method]))
141 return call_user_func_array([$this, $method], []);
176 $iterator = Iblock\IblockTable::getList([
180 'SECTIONS' =>
'TYPE.SECTIONS'
182 'filter' => [
'=ID' => $this->iblockId],
184 $row = $iterator->fetch();
187 $this->iblockConfig[
'SECTIONS'] = $row[
'SECTIONS'];
188 $this->iblockConfig[
'SECTION_CHOOSER'] = $row[
'SECTION_CHOOSER'];
190 unset($row, $iterator);
208 $value === self::GRID_TYPE_UI
209 || $value === self::GRID_TYPE_LIST
210 || $value === self::GRID_TYPE_SUBLIST
213 $this->gridType = $value;
240 $result[Iblock\Grid\ActionType::EDIT] =
'Edit';
241 $result[Iblock\Grid\ActionType::SELECT_ALL] =
'SelectAll';
242 $result[Iblock\Grid\ActionType::DELETE] =
'Delete';
243 $result[Iblock\Grid\ActionType::ACTIVATE] =
'Activate';
244 $result[Iblock\Grid\ActionType::DEACTIVATE] =
'Deactivate';
245 $result[Iblock\Grid\ActionType::CLEAR_COUNTER] =
'ClearCounter';
246 $result[Iblock\Grid\ActionType::CODE_TRANSLIT] =
'CodeTranslit';
247 $result[Iblock\Grid\ActionType::MOVE_TO_SECTION] =
'AdjustSection';
248 $result[Iblock\Grid\ActionType::ADD_TO_SECTION] =
'AddSection';
249 $result[Iblock\Grid\ActionType::ELEMENT_UNLOCK] =
'ElementUnlock';
250 $result[Iblock\Grid\ActionType::ELEMENT_LOCK] =
'ElementLock';
251 $result[Iblock\Grid\ActionType::ELEMENT_WORKFLOW_STATUS] =
'ElementWorkflowStatus';
261 return [
'JS' =>
"BX.adminUiList.SendSelected('{$this->getEntityId()}')"];
270 return self::PREFIX_ID.$this->getEntityId().
'_'.strtolower($id);
279 $result = $this->mainSnippet->getApplyButton([]);
280 $result[
'id'] = $this->
getElementId($params[
'APPLY_BUTTON_ID']);
281 $this->mainSnippet->setButtonActions(
285 'ACTION' => Main\Grid\Panel\Actions::CALLBACK,
301 $confirmMessage =
null;
303 isset($params[
'CONFIRM_MESSAGE'])
304 && is_string($params[
'CONFIRM_MESSAGE'])
305 && $params[
'CONFIRM_MESSAGE'] !==
''
308 $confirmMessage = $params[
'CONFIRM_MESSAGE'];
311 isset($params[
'DEFAULT_CONFIRM_MESSAGE'])
312 && is_string($params[
'DEFAULT_CONFIRM_MESSAGE'])
313 && $params[
'DEFAULT_CONFIRM_MESSAGE'] !==
''
316 $confirmMessage = $params[
'DEFAULT_CONFIRM_MESSAGE'];
319 $result = $this->mainSnippet->getApplyButton([]);
320 $result[
'id'] = $this->
getElementId($params[
'APPLY_BUTTON_ID']);
321 $this->mainSnippet->setButtonActions(
325 'ACTION' => Main\Grid\Panel\Actions::CALLBACK,
327 'CONFIRM_MESSAGE' => $confirmMessage,
343 if ($this->sections ===
null)
345 $this->sections = [];
346 if ($this->iblockId > 0)
348 $iterator = \CIBlockSection::getTreeList(
349 [
'IBLOCK_ID' => $this->iblockId],
350 [
'ID',
'NAME',
'DEPTH_LEVEL',
'LEFT_MARGIN']
352 while ($row = $iterator->Fetch())
354 $this->sections[] = [
355 'NAME' => str_repeat(
' . ', $row[
'DEPTH_LEVEL']).$row[
'NAME'],
356 'VALUE' => $row[
'ID']
359 unset($row, $iterator);
374 $result = array_merge(
377 'NAME' =>
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_MESS_SECTION_TOP_LEVEL'),
394 'name' => $action[
'NAME'],
395 'type' =>
'multicontrol',
398 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS,
401 'ACTION' => Main\Grid\Panel\Actions::CREATE,
404 'TYPE' => Main\Grid\Panel\Types::DROPDOWN,
405 'ID' => $this->
getElementId($action[
'SECTION_LIST_ID']),
406 'NAME' =>
'section_to_move',
423 'name' => $action[
'NAME'],
424 'type' =>
'multicontrol',
427 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS,
430 'ACTION' => Main\Grid\Panel\Actions::CREATE,
433 'TYPE' => Main\Grid\Panel\Types::TEXT,
444 'TYPE' => Main\Grid\Panel\Types::BUTTON,
462 'name' => $action[
'NAME'],
463 'type' =>
'multicontrol',
466 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS
469 'ACTION' => Main\Grid\Panel\Actions::CREATE,
472 'TYPE' => Main\Grid\Panel\Types::DROPDOWN,
473 'ID' => $this->
getElementId($action[
'SECTION_LIST_ID']),
474 'NAME' =>
'section_to_move',
490 return (isset($params[
'NAME']) && $params[
'NAME'] !=
''
511 return (isset($params[
'NAME']) && $params[
'NAME'] !=
''
523 return (isset($params[
'NAME']) && $params[
'NAME'] !=
''
535 return (isset($params[
'NAME']) && $params[
'NAME'] !=
''
547 $name = (isset($params[
'NAME']) && $params[
'NAME'] !==
''
552 $params[
'APPLY_BUTTON_ID'] =
'clear_counter_confirm';
553 $params[
'DEFAULT_CONFIRM_MESSAGE'] =
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CLEAR_COUNTER_CONFIRM');
559 'type' =>
'multicontrol',
562 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS
565 'ACTION' => Main\Grid\Panel\Actions::CREATE,
583 $name = (isset($params[
'NAME']) && $params[
'NAME'] !==
''
585 :
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CODE_TRANSLITERATION_MSGVER_1')
588 $params[
'APPLY_BUTTON_ID'] =
'code_translit_confirm';
589 $params[
'DEFAULT_CONFIRM_MESSAGE'] =
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_CODE_TRANSLITERATION_CONFIRM');
595 'type' =>
'multicontrol',
598 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS,
601 'ACTION' => Main\Grid\Panel\Actions::CREATE,
623 if ($this->iblockConfig[
'SECTIONS'] !=
'Y')
627 if (!isset($params[
'NAME']) || $params[
'NAME'] ==
'')
629 $params[
'NAME'] =
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_ADJUST_SECTION');
632 $params[
'APPLY_BUTTON_ID'] =
'send_adjust_list';
635 $params[
'SECTION_LIST_ID'] =
'set_sections';
640 $params[
'SECTION_LIST_ID'] =
'set_sections';
650 $sectionId = $this->request->get(
'section_to_move');
651 return (is_string($sectionId) ? [
'SECTION_ID' => $sectionId] :
null);
664 if ($this->iblockConfig[
'SECTIONS'] !=
'Y')
668 if (!isset($params[
'NAME']) || $params[
'NAME'] ===
'')
670 $params[
'NAME'] =
Loc::getMessage(
'IBLOCK_GRID_PANEL_ACTION_ADD_SECTION');
673 $params[
'APPLY_BUTTON_ID'] =
'send_add_list';
676 $params[
'SECTION_LIST_ID'] =
'additional_sections';
681 $params[
'SECTION_LIST_ID'] =
'additional_sections';
691 $sectionId = $this->request->get(
'section_to_move');
693 return (is_string($sectionId) ? [
'SECTION_ID' => $sectionId] :
null);
702 return (isset($params[
'NAME']) && $params[
'NAME'] !==
''
714 return (isset($params[
'NAME']) && $params[
'NAME'] !==
''
726 if (!Loader::includeModule(
'workflow'))
731 $name = (isset($params[
'NAME']) && $params[
'NAME'] !==
''
737 $iterator = \CWorkflowStatus::getDropDownList(
'N',
'desc');
738 while ($row = $iterator->Fetch())
741 'NAME' => $row[
'REFERENCE'],
742 'VALUE' => $row[
'REFERENCE_ID'],
745 unset($row, $iterator);
746 if (empty($statusList))
751 $params[
'APPLY_BUTTON_ID'] =
'send_workflow_status';
754 'TYPE' => Main\Grid\Panel\Types::DROPDOWN,
756 'NAME' =>
'wf_status_id',
757 'ITEMS' => $statusList,
766 'type' =>
'multicontrol',
769 'ACTION' => Main\Grid\Panel\Actions::RESET_CONTROLS,
772 'ACTION' => Main\Grid\Panel\Actions::CREATE,
784 $result = $this->request->get(
'wf_status_id');
786 return (is_string($result) ? [
'WF_STATUS_ID' => $result] :
null);
getSections(bool $addTop=false)
actionElementWorkflowStatusRequest()
actionElementLockPanel(array $params=[])
getAddSectionList(array $action)
__construct(array $options)
actionDeactivatePanel(array $params=[])
getApplyButton(array $params)
actionAddSectionPanel(array $params=[])
actionSelectAllPanel(array $params=[])
actionActivatePanel(array $params=[])
getAdjustSectionList(array $action)
actionElementWorkflowStatusPanel(array $params=[])
actionDeletePanel(array $params=[])
actionClearCounterPanel(array $params=[])
actionAddSectionRequest()
actionEditPanel(array $params=[])
getApplyButtonWithConfirm(array $params)
getList(?array $actions=null)
actionCodeTranslitPanel(array $params=[])
actionAdjustSectionPanel(array $params=[])
getAddSectionDialog(array $action)
setGridType(string $value)
actionAdjustSectionRequest()
actionElementUnlockPanel(array $params=[])
const SECTION_CHOOSER_PATH
static getMessage($code, $replace=null, $language=null)