function makeMessageBox($good, array $messages, $title = null, $show_close_box = true, $show_details = false) { $class = $good ? ZBX_STYLE_MSG_GOOD : ZBX_STYLE_MSG_BAD; $msg_box = (new CDiv($title))->addClass($class); if ($messages) { $msg_details = (new CDiv())->addClass(ZBX_STYLE_MSG_DETAILS); if ($title !== null) { $link = (new CSpan(_('Details')))->addClass(ZBX_STYLE_LINK_ACTION)->onClick('javascript: showHide($(this).next(\'.' . ZBX_STYLE_MSG_DETAILS_BORDER . '\'));'); $msg_details->addItem($link); } $list = new CList(); if ($title !== null) { $list->addClass(ZBX_STYLE_MSG_DETAILS_BORDER); if (!$show_details) { $list->setAttribute('style', 'display: none;'); } } foreach ($messages as $message) { foreach (explode("\n", $message['message']) as $message_part) { $list->addItem($message_part); } } $msg_details->addItem($list); $msg_box->addItem($msg_details); } if ($show_close_box) { $msg_box->addItem((new CSpan())->addClass(ZBX_STYLE_OVERLAY_CLOSE_BTN)->onClick('javascript: $(this).closest(\'.' . $class . '\').remove();')->setAttribute('title', _('Close'))); } return $msg_box; }