setId($this->id.'_icon') ->onClick('changeWidgetState(this, "'.$this->id.'", "'.$idx.'");'); if ($this->expanded) { $icon ->addClass(ZBX_STYLE_BTN_WIDGET_COLLAPSE) ->setTitle(_('Collapse')); } else { $icon ->addClass(ZBX_STYLE_BTN_WIDGET_EXPAND) ->setTitle(_('Expand')); } $controls[] = $icon; parent::setHeader($caption, $controls); return $this; } /** * Display the widget in expanded or collapsed state. */ protected function build() { $body = (new CDiv($this->body)) ->addClass('body') ->setId($this->id); if (!$this->expanded) { $body->setAttribute('style', 'display: none;'); if ($this->footer) { $this->footer->setAttribute('style', 'display: none;'); } } $this->cleanItems(); $this->addItem($this->header); $this->addItem($body); $this->addItem($this->footer); return $this; } /** * Sets expanded or collapsed state of the widget. * * @param bool */ public function setExpanded($expanded) { $this->expanded = $expanded; return $this; } }