@@ 37-55 (lines=19) @@ | ||
34 | * @param CBitrixComponentTemplate $template |
|
35 | * @param $element |
|
36 | */ |
|
37 | public static function editIBlockElement($template, $element) |
|
38 | { |
|
39 | if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) { |
|
40 | return; |
|
41 | } |
|
42 | ||
43 | if (is_numeric($element)) { |
|
44 | $element = static::prepareIBlockElementArrayById($element); |
|
45 | } |
|
46 | if (!$element["IBLOCK_ID"] || !$element['ID']) { |
|
47 | throw new InvalidArgumentException('Element must include ID and IBLOCK_ID'); |
|
48 | } |
|
49 | ||
50 | $buttons = static::getIBlockElementPanelButtons($element); |
|
51 | $link = $buttons["edit"]["edit_element"]["ACTION_URL"]; |
|
52 | ||
53 | $template->AddEditAction('iblock_element_' . $element['ID'], $link, CIBlock::GetArrayByID($element["IBLOCK_ID"], "ELEMENT_EDIT")); |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * @param CBitrixComponentTemplate $template |
|
58 | * @param $element |
|
@@ 61-79 (lines=19) @@ | ||
58 | * @param $element |
|
59 | * @param string $confirm |
|
60 | */ |
|
61 | public static function deleteIBlockElement($template, $element, $confirm = 'Вы уверены, что хотите удалить элемент?') |
|
62 | { |
|
63 | if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) { |
|
64 | return; |
|
65 | } |
|
66 | ||
67 | if (is_numeric($element)) { |
|
68 | $element = static::prepareIBlockElementArrayById($element); |
|
69 | } |
|
70 | ||
71 | if (!$element["IBLOCK_ID"] || !$element['ID']) { |
|
72 | throw new InvalidArgumentException('Element must include ID and IBLOCK_ID'); |
|
73 | } |
|
74 | ||
75 | $buttons = static::getIBlockElementPanelButtons($element); |
|
76 | $link = $buttons["edit"]["delete_element"]["ACTION_URL"]; |
|
77 | ||
78 | $template->AddDeleteAction('iblock_element_' . $element['ID'], $link, CIBlock::GetArrayByID($element["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => $confirm)); |
|
79 | } |
|
80 | ||
81 | /** |
|
82 | * @param CBitrixComponentTemplate $template |
|
@@ 105-123 (lines=19) @@ | ||
102 | * @param CBitrixComponentTemplate $template |
|
103 | * @param $section |
|
104 | */ |
|
105 | public static function editIBlockSection($template, $section) |
|
106 | { |
|
107 | if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) { |
|
108 | return; |
|
109 | } |
|
110 | ||
111 | if (is_numeric($section)) { |
|
112 | $section = static::prepareIBlockSectionArrayById($section); |
|
113 | } |
|
114 | ||
115 | if (!$section["IBLOCK_ID"] || !$section['ID']) { |
|
116 | throw new InvalidArgumentException('Section must include ID and IBLOCK_ID'); |
|
117 | } |
|
118 | ||
119 | $buttons = static::getIBlockSectionPanelButtons($section); |
|
120 | $link = $buttons["edit"]["edit_section"]["ACTION_URL"]; |
|
121 | ||
122 | $template->AddEditAction('iblock_section_' . $section['ID'], $link, CIBlock::GetArrayByID($section["IBLOCK_ID"], "SECTION_EDIT")); |
|
123 | } |
|
124 | ||
125 | /** |
|
126 | * @param CBitrixComponentTemplate $template |
|
@@ 130-148 (lines=19) @@ | ||
127 | * @param $section |
|
128 | * @param string $confirm |
|
129 | */ |
|
130 | public static function deleteIBlockSection($template, $section, $confirm = 'Вы уверены, что хотите удалить раздел?') |
|
131 | { |
|
132 | if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) { |
|
133 | return; |
|
134 | } |
|
135 | ||
136 | if (is_numeric($section)) { |
|
137 | $section = static::prepareIBlockSectionArrayById($section); |
|
138 | } |
|
139 | ||
140 | if (!$section["IBLOCK_ID"] || !$section['ID']) { |
|
141 | throw new InvalidArgumentException('Section must include ID and IBLOCK_ID'); |
|
142 | } |
|
143 | ||
144 | $buttons = static::getIBlockSectionPanelButtons($section); |
|
145 | $link = $buttons["edit"]["delete_section"]["ACTION_URL"]; |
|
146 | ||
147 | $template->AddDeleteAction('iblock_section_' . $section['ID'], $link, CIBlock::GetArrayByID($section["IBLOCK_ID"], "SECTION_DELETE"), array("CONFIRM" => $confirm)); |
|
148 | } |
|
149 | ||
150 | /** |
|
151 | * @param CBitrixComponentTemplate $template |