checkboxes_name = $checkboxes_name; $this->name_prefix = $name_prefix; foreach ($buttons_data as $action => $button_data) { if (array_key_exists('content', $button_data)) { $button = $button_data['content']; } else { $button = (new CSubmit($action_name, $button_data['name'])) ->addClass(ZBX_STYLE_BTN_ALT) ->removeAttribute('id'); if (array_key_exists('redirect', $button_data)) { $button // Removing parameters not to conflict with the redirecting URL. ->removeAttribute('name') ->removeAttribute('value') ->onClick('var $_form = jQuery(this).closest("form");'. // Save the original form action. 'if (!$_form.data("action")) {'. '$_form.data("action", $_form.attr("action"));'. '}'. '$_form.attr("action", '.json_encode($button_data['redirect']).');' ); } else { $button ->setAttribute('value', $action) ->onClick('var $_form = jQuery(this).closest("form");'. // Restore the original form action, if previously saved. 'if ($_form.data("action")) {'. '$_form.attr("action", $_form.data("action"));'. '}' ); } if (array_key_exists('disabled', $button_data)) { $button ->setEnabled(!$button_data['disabled']) ->setAttribute('data-disabled', $button_data['disabled']); } if (array_key_exists('confirm', $button_data)) { $button->setAttribute('confirm', $button_data['confirm']); } } $this->buttons[$action] = $button; } } /** * Returns current element for showing how many checkboxes are selected. If currently no * element exists, constructs and returns default one. * * @return CObject */ public function getSelectedCountElement() { if (!$this->selected_count_element) { $this->selected_count_element = (new CSpan('0 '._('selected'))) ->setId('selected_count') ->addClass(ZBX_STYLE_SELECTED_ITEM_COUNT); } return $this->selected_count_element; } /** * Gets string representation of action button list. * * @param bool $destroy * * @return string */ public function toString($destroy = true) { zbx_add_post_js('chkbxRange.pageGoName = '.json_encode($this->checkboxes_name).';'); zbx_add_post_js('chkbxRange.prefix = '.json_encode($this->name_prefix).';'); $this->items[] = (new CDiv([$this->getSelectedCountElement(), $this->buttons])) ->setId('action_buttons') ->addClass(ZBX_STYLE_ACTION_BUTTONS); return parent::toString($destroy); } }