public function toString($destroy = true) { if (count($this->tabs) == 1) { $this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget'); $header = reset($this->headers); $header = new CDiv($header); $header->addClass('ui-corner-all ui-widget-header header'); $header->setAttribute('id', 'tab_' . key($this->headers)); $this->addItem($header); $tab = reset($this->tabs); $tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget'); $this->addItem($tab); } else { $headersList = new CList(); foreach ($this->headers as $id => $header) { $tabLink = new CLink($header, '#' . $id, null, null, false); $tabLink->setAttribute('id', 'tab_' . $id); $headersList->addItem($tabLink); } $this->addItem($headersList); $this->addItem($this->tabs); $options = array(); if (!is_null($this->selectedTab)) { $options['selected'] = $this->selectedTab; } if ($this->rememberTab) { $options['cookie'] = array(); } zbx_add_post_js('jQuery("#' . $this->id . '").tabs(' . zbx_jsvalue($options, true) . ').show();'); } return parent::toString($destroy); }
public function toString($destroy = true) { if (count($this->tabs) == 1) { $this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget'); $header = reset($this->headers); $header = new CDiv($header); $header->addClass('ui-corner-all ui-widget-header header'); $header->setAttribute('id', 'tab_' . key($this->headers)); $this->addItem($header); $tab = reset($this->tabs); $tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget'); $this->addItem($tab); } else { $headersList = new CList(); foreach ($this->headers as $id => $header) { $tabLink = new CLink($header, '#' . $id, null, null, false); $tabLink->setAttribute('id', 'tab_' . $id); $headersList->addItem($tabLink); } $this->addItem($headersList); $this->addItem($this->tabs); if ($this->selectedTab === null) { $activeTab = get_cookie('tab', 0); $createEvent = ''; } else { $activeTab = $this->selectedTab; $createEvent = 'create: function() { jQuery.cookie("tab", ' . $this->selectedTab . '); },'; } $disabledTabs = $this->disabledTabs === null ? '' : 'disabled: ' . CJs::encodeJson($this->disabledTabs) . ','; zbx_add_post_js(' jQuery("#' . $this->id . '").tabs({ ' . $createEvent . ' ' . $disabledTabs . ' active: ' . $activeTab . ', activate: function(event, ui) { jQuery.cookie("tab", ui.newTab.index().toString()); } }) .css("visibility", "visible");'); } return parent::toString($destroy); }
/** * @param string $options['name'] * @param int $options['value'] (optional) Default: TRIGGER_SEVERITY_NOT_CLASSIFIED * @param bool $options['all'] (optional) */ public function __construct(array $options = []) { parent::__construct(); $id = zbx_formatDomId($options['name']); $this->addClass(ZBX_STYLE_RADIO_SEGMENTED); $this->setId($id); if (!array_key_exists('value', $options)) { $options['value'] = TRIGGER_SEVERITY_NOT_CLASSIFIED; } $severity_from = array_key_exists('all', $options) && $options['all'] ? -1 : TRIGGER_SEVERITY_NOT_CLASSIFIED; $config = select_config(); for ($severity = $severity_from; $severity < TRIGGER_SEVERITY_COUNT; $severity++) { $name = $severity == -1 ? _('all') : getSeverityName($severity, $config); $class = $severity == -1 ? null : getSeverityStyle($severity); $radio = (new CInput('radio', $options['name'], $severity))->setId(zbx_formatDomId($options['name'] . '_' . $severity)); if ($severity === $options['value']) { $radio->setAttribute('checked', 'checked'); } parent::addItem((new CListItem([$radio, new CLabel($name, $options['name'] . '_' . $severity)]))->addClass($class)); } }
public function toString($destroy = true) { if ($this->modern) { $this->addClass(ZBX_STYLE_RADIO_SEGMENTED); } else { $this->addClass($this->orientation == self::ORIENTATION_HORIZONTAL ? ZBX_STYLE_LIST_HOR_CHECK_RADIO : ZBX_STYLE_LIST_CHECK_RADIO); } foreach ($this->values as $key => $value) { if ($value['id'] === null) { $value['id'] = zbx_formatDomId($this->name) . '_' . $key; } $radio = (new CInput('radio', $this->name, $value['value']))->setEnabled($this->enabled)->onChange($value['on_change'])->setId($value['id']); if ($value['value'] === $this->value) { $radio->setAttribute('checked', 'checked'); } if ($this->modern) { parent::addItem([$radio, new CLabel($value['name'], $value['id'])]); } else { parent::addItem(new CLabel([$radio, $value['name']], $value['id'])); } } return parent::toString($destroy); }
/** * Create CDiv with host/template information and references to it's elements * * @param string $currentElement * @param int $hostid * @param int $discoveryid * * @return object */ function get_header_host_table($currentElement, $hostid, $discoveryid = null) { $elements = array('items' => 'items', 'triggers' => 'triggers', 'graphs' => 'graphs', 'applications' => 'applications', 'screens' => 'screens', 'discoveries' => 'discoveries'); if (!empty($discoveryid)) { unset($elements['applications'], $elements['screens'], $elements['discoveries']); } $options = array('hostids' => $hostid, 'output' => API_OUTPUT_EXTEND, 'templated_hosts' => true); if (isset($elements['items'])) { $options['selectItems'] = API_OUTPUT_COUNT; } if (isset($elements['triggers'])) { $options['selectTriggers'] = API_OUTPUT_COUNT; } if (isset($elements['graphs'])) { $options['selectGraphs'] = API_OUTPUT_COUNT; } if (isset($elements['applications'])) { $options['selectApplications'] = API_OUTPUT_COUNT; } if (isset($elements['screens'])) { $options['selectScreens'] = API_OUTPUT_COUNT; } if (isset($elements['discoveries'])) { $options['selectDiscoveries'] = API_OUTPUT_COUNT; } // get hosts $dbHost = API::Host()->get($options); $dbHost = reset($dbHost); // get discoveries if (!empty($discoveryid)) { $options['itemids'] = $discoveryid; $options['output'] = array('name'); unset($options['hostids'], $options['templated_hosts']); $dbDiscovery = API::DiscoveryRule()->get($options); $dbDiscovery = reset($dbDiscovery); } /* * Back */ $list = new CList(null, 'objectlist'); if ($dbHost['status'] == HOST_STATUS_TEMPLATE) { $list->addItem(array('« ', new CLink(_('Template list'), 'templates.php?templateid=' . $dbHost['hostid'] . url_param('groupid')))); } else { $list->addItem(array('« ', new CLink(_('Host list'), 'hosts.php?hostid=' . $dbHost['hostid'] . url_param('groupid')))); } /* * Name */ $description = ''; if ($dbHost['proxy_hostid']) { $proxy = get_host_by_hostid($dbHost['proxy_hostid']); $description .= $proxy['host'] . ': '; } $description .= $dbHost['name']; if ($dbHost['status'] == HOST_STATUS_TEMPLATE) { $list->addItem(array(bold(_('Template') . ': '), new CLink($description, 'templates.php?form=update&templateid=' . $dbHost['hostid']))); } else { switch ($dbHost['status']) { case HOST_STATUS_MONITORED: $status = new CSpan(_('Monitored'), 'off'); break; case HOST_STATUS_NOT_MONITORED: $status = new CSpan(_('Not monitored'), 'on'); break; default: $status = _('Unknown'); break; } $list->addItem(array(bold(_('Host') . ': '), new CLink($description, 'hosts.php?form=update&hostid=' . $dbHost['hostid']))); $list->addItem($status); $list->addItem(getAvailabilityTable($dbHost)); } if (!empty($dbDiscovery)) { $list->addItem(array('« ', new CLink(_('Discovery list'), 'host_discovery.php?hostid=' . $dbHost['hostid'] . url_param('groupid')))); $list->addItem(array(bold(_('Discovery') . ': '), new CLink($dbDiscovery['name'], 'host_discovery.php?form=update&itemid=' . $dbDiscovery['itemid']))); } /* * Rowcount */ if (isset($elements['applications'])) { if ($currentElement == 'applications') { $list->addItem(_('Applications') . ' (' . $dbHost['applications'] . ')'); } else { $list->addItem(array(new CLink(_('Applications'), 'applications.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['applications'] . ')')); } } if (isset($elements['items'])) { if (!empty($dbDiscovery)) { if ($currentElement == 'items') { $list->addItem(_('Item prototypes') . ' (' . $dbDiscovery['items'] . ')'); } else { $list->addItem(array(new CLink(_('Item prototypes'), 'disc_prototypes.php?hostid=' . $dbHost['hostid'] . '&parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['items'] . ')')); } } else { if ($currentElement == 'items') { $list->addItem(_('Items') . ' (' . $dbHost['items'] . ')'); } else { $list->addItem(array(new CLink(_('Items'), 'items.php?filter_set=1&hostid=' . $dbHost['hostid']), ' (' . $dbHost['items'] . ')')); } } } if (isset($elements['triggers'])) { if (!empty($dbDiscovery)) { if ($currentElement == 'triggers') { $list->addItem(_('Trigger prototypes') . ' (' . $dbDiscovery['triggers'] . ')'); } else { $list->addItem(array(new CLink(_('Trigger prototypes'), 'trigger_prototypes.php?hostid=' . $dbHost['hostid'] . '&parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['triggers'] . ')')); } } else { if ($currentElement == 'triggers') { $list->addItem(_('Triggers') . ' (' . $dbHost['triggers'] . ')'); } else { $list->addItem(array(new CLink(_('Triggers'), 'triggers.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['triggers'] . ')')); } } } if (isset($elements['graphs'])) { if (!empty($dbDiscovery)) { if ($currentElement == 'graphs') { $list->addItem(_('Graph prototypes') . ' (' . $dbDiscovery['graphs'] . ')'); } else { $list->addItem(array(new CLink(_('Graph prototypes'), 'graphs.php?hostid=' . $dbHost['hostid'] . '&parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['graphs'] . ')')); } } else { if ($currentElement == 'graphs') { $list->addItem(_('Graphs') . ' (' . $dbHost['graphs'] . ')'); } else { $list->addItem(array(new CLink(_('Graphs'), 'graphs.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['graphs'] . ')')); } } } if (isset($elements['screens']) && $dbHost['status'] == HOST_STATUS_TEMPLATE) { if ($currentElement == 'screens') { $list->addItem(_('Screens') . ' (' . $dbHost['screens'] . ')'); } else { $list->addItem(array(new CLink(_('Screens'), 'screenconf.php?templateid=' . $dbHost['hostid']), ' (' . $dbHost['screens'] . ')')); } } if (isset($elements['discoveries'])) { if ($currentElement == 'discoveries') { $list->addItem(_('Discovery rules') . ' (' . $dbHost['discoveries'] . ')'); } else { $list->addItem(array(new CLink(_('Discovery rules'), 'host_discovery.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['discoveries'] . ')')); } } return new CDiv($list, 'objectgroup top ui-widget-content ui-corner-all'); }
function getList() { $list = new CList(); foreach ($this->stage as $id => $data) { if ($id < $this->getStep()) { $style = 'completed'; } else { if ($id == $this->getStep()) { $style = 'current'; } else { $style = null; } } $list->addItem($data['title'], $style); } return $list; }
/** * Creates nodes that can be used to display the SLA report tree using the CTree class. * * @see CTree * * @param array $services an array of services to display in the tree * @param array $slaData sla report data, see CService::getSla() * @param $period * @param array $parentService * @param array $service * @param array $dependency * @param array $tree */ function createServiceMonitoringTree(array $services, array $slaData, $period, &$tree, array $parentService = array(), array $service = array(), array $dependency = array()) { // if no parent service is given, start from the root if (!$service) { $serviceNode = array('id' => 0, 'parentid' => 0, 'caption' => _('root'), 'status' => SPACE, 'sla' => SPACE, 'sla2' => SPACE, 'trigger' => array(), 'reason' => SPACE, 'graph' => SPACE); $service = $serviceNode; $service['serviceid'] = 0; $service['dependencies'] = array(); $service['trigger'] = array(); // add all top level services as children of "root" foreach ($services as $topService) { if (!$topService['parent']) { $service['dependencies'][] = array('servicedownid' => $topService['serviceid'], 'soft' => 0, 'linkid' => 0); } } $tree = array($serviceNode); } else { $serviceSla = $slaData[$service['serviceid']]; $slaValues = reset($serviceSla['sla']); // caption // remember the selected time period when following the bar link $periods = array('today' => 'daily', 'week' => 'weekly', 'month' => 'monthly', 'year' => 'yearly', 24 => 'daily', 24 * 7 => 'weekly', 24 * 30 => 'monthly', 24 * DAY_IN_YEAR => 'yearly'); $caption = array(new CLink(array(get_node_name_by_elid($service['serviceid'], null, ': '), $service['name']), 'report3.php?serviceid=' . $service['serviceid'] . '&year=' . date('Y') . '&period=' . $periods[$period])); $trigger = $service['trigger']; if ($trigger) { $url = new CLink($trigger['description'], 'events.php?source=' . EVENT_SOURCE_TRIGGERS . '&triggerid=' . $trigger['triggerid']); $caption[] = ' - '; $caption[] = $url; } // reason $problemList = '-'; if ($serviceSla['problems']) { $problemList = new CList(null, 'service-problems'); foreach ($serviceSla['problems'] as $problemTrigger) { $problemList->addItem(new CLink($problemTrigger['description'], 'events.php?source=' . EVENT_SOURCE_TRIGGERS . '&triggerid=' . $problemTrigger['triggerid'])); } } // sla $sla = '-'; $sla2 = '-'; if ($service['showsla'] && $slaValues['sla'] !== null) { $slaGood = $slaValues['sla']; $slaBad = 100 - $slaValues['sla']; $p = min($slaBad, 20); $width = 160; $widthRed = $width * $p / 20; $widthGreen = $width - $widthRed; $chart1 = null; if ($widthGreen > 0) { $chart1 = new CDiv(null, 'sla-bar-part sla-green'); $chart1->setAttribute('style', 'width: ' . $widthGreen . 'px;'); } $chart2 = null; if ($widthRed > 0) { $chart2 = new CDiv(null, 'sla-bar-part sla-red'); $chart2->setAttribute('style', 'width: ' . $widthRed . 'px;'); } $bar = new CLink(array($chart1, $chart2, new CDiv('80%', 'sla-bar-legend sla-bar-legend-start'), new CDiv('100%', 'sla-bar-legend sla-bar-legend-end')), 'srv_status.php?serviceid=' . $service['serviceid'] . '&showgraph=1' . url_param('path')); $bar = new CDiv($bar, 'sla-bar'); $bar->setAttribute('title', _s('Only the last 20%% of the indicator is displayed.')); $slaBar = array($bar, new CSpan(sprintf('%.4f', $slaBad), 'sla-value ' . ($service['goodsla'] > $slaGood ? 'red' : 'green'))); $sla = new CDiv($slaBar, 'invisible'); $sla2 = array(new CSpan(sprintf('%.4f', $slaGood), 'sla-value ' . ($service['goodsla'] > $slaGood ? 'red' : 'green')), '/', new CSpan(sprintf('%.4f', $service['goodsla']), 'sla-value')); } $serviceNode = array('id' => $service['serviceid'], 'caption' => $caption, 'description' => $service['trigger'] ? $service['trigger']['description'] : _('None'), 'reason' => $problemList, 'sla' => $sla, 'sla2' => $sla2, 'parentid' => $parentService ? $parentService['serviceid'] : 0, 'status' => $serviceSla['status'] !== null ? $serviceSla['status'] : '-'); } // hard dependencies and dependencies for the "root" node if (!$dependency || $dependency['soft'] == 0) { $tree[$serviceNode['id']] = $serviceNode; foreach ($service['dependencies'] as $dependency) { $childService = $services[$dependency['servicedownid']]; createServiceMonitoringTree($services, $slaData, $period, $tree, $service, $childService, $dependency); } } else { $serviceNode['caption'] = new CSpan($serviceNode['caption'], 'service-caption-soft'); $tree[$serviceNode['id'] . '.' . $dependency['linkid']] = $serviceNode; } }
/** * Get favourite screens and slide shows. * * @return CList */ function getFavouriteScreens() { $data = getFavouriteScreensData(); $favourites = new CList(null, 'favorites', _('No screens added.')); if ($data['screens']) { foreach ($data['screens'] as $screen) { $favourites->addItem(new CLink($screen['label'], 'screens.php?elementid=' . $screen['id']), 'nowrap'); } } if ($data['slideshows']) { foreach ($data['slideshows'] as $slideshow) { $favourites->addItem(new CLink($slideshow['label'], 'slides.php?elementid=' . $slideshow['id']), 'nowrap'); } } return $favourites; }
** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $this->addJSfile('js/class.pmaster.js'); $dashboard = (new CWidget())->setTitle(_('Dashboard'))->setControls((new CForm())->cleanItems()->addItem((new CList())->addItem(get_icon('dashconf', ['enabled' => $data['filter_enabled']]))->addItem(get_icon('fullscreen', ['fullscreen' => $data['fullscreen']])))); /* * Dashboard grid */ $dashboardGrid = [[], [], []]; $widgetRefreshParams = []; $widgets = [WIDGET_FAVOURITE_GRAPHS => ['id' => 'favouriteGraphs', 'menu_popup' => ['CMenuPopupHelper', 'getFavouriteGraphs'], 'data' => $data['favourite_graphs'], 'header' => _('Favourite graphs'), 'links' => [['name' => _('Graphs'), 'url' => 'charts.php']], 'defaults' => ['col' => 0, 'row' => 0]], WIDGET_FAVOURITE_SCREENS => ['id' => 'favouriteScreens', 'menu_popup' => ['CMenuPopupHelper', 'getFavouriteScreens'], 'data' => $data['favourite_screens'], 'header' => _('Favourite screens'), 'links' => [['name' => _('Screens'), 'url' => 'screens.php'], ['name' => _('Slide shows'), 'url' => 'slides.php']], 'defaults' => ['col' => 0, 'row' => 1]], WIDGET_FAVOURITE_MAPS => ['id' => 'favouriteMaps', 'menu_popup' => ['CMenuPopupHelper', 'getFavouriteMaps'], 'data' => $data['favourite_maps'], 'header' => _('Favourite maps'), 'links' => [['name' => _('Maps'), 'url' => 'zabbix.php?action=map.view']], 'defaults' => ['col' => 0, 'row' => 2]]]; foreach ($widgets as $widgetid => $widget) { $icon = (new CButton(null))->addClass(ZBX_STYLE_BTN_WIDGET_ACTION)->setTitle(_('Action'))->setId($widget['id'])->setMenuPopup(call_user_func($widget['menu_popup'])); $footer = new CList(); foreach ($widget['links'] as $link) { $footer->addItem(new CLink($link['name'], $link['url'])); } $col = CProfile::get('web.dashboard.widget.' . $widgetid . '.col', $widget['defaults']['col']); $row = CProfile::get('web.dashboard.widget.' . $widgetid . '.row', $widget['defaults']['row']); $dashboardGrid[$col][$row] = (new CCollapsibleUiWidget($widgetid, $widget['data']))->setExpanded((bool) CProfile::get('web.dashboard.widget.' . $widgetid . '.state', true))->setHeader($widget['header'], [$icon], true, 'zabbix.php?action=dashboard.widget')->setFooter($footer); } $widgets = [WIDGET_SYSTEM_STATUS => ['action' => 'widget.system.view', 'header' => _('System status'), 'defaults' => ['col' => 1, 'row' => 1]], WIDGET_HOST_STATUS => ['action' => 'widget.hosts.view', 'header' => _('Host status'), 'defaults' => ['col' => 1, 'row' => 2]], WIDGET_LAST_ISSUES => ['action' => 'widget.issues.view', 'header' => _n('Last %1$d issue', 'Last %1$d issues', DEFAULT_LATEST_ISSUES_CNT), 'defaults' => ['col' => 1, 'row' => 3]], WIDGET_WEB_OVERVIEW => ['action' => 'widget.web.view', 'header' => _('Web monitoring'), 'defaults' => ['col' => 1, 'row' => 4]]]; if ($data['show_status_widget']) { $widgets[WIDGET_ZABBIX_STATUS] = ['action' => 'widget.status.view', 'header' => _('Status of Zabbix'), 'defaults' => ['col' => 1, 'row' => 0]]; } if ($data['show_discovery_widget']) { $widgets[WIDGET_DISCOVERY_STATUS] = ['action' => 'widget.discovery.view', 'header' => _('Discovery status'), 'defaults' => ['col' => 1, 'row' => 5]]; } foreach ($widgets as $widgetid => $widget) { $profile = 'web.dashboard.widget.' . $widgetid; $rate = CProfile::get($profile . '.rf_rate', 60);
function show_messages($bool = TRUE, $okmsg = NULL, $errmsg = NULL) { global $page, $ZBX_MESSAGES; if (!defined('PAGE_HEADER_LOADED')) { return; } if (defined('ZBX_API_REQUEST')) { return; } if (!isset($page['type'])) { $page['type'] = PAGE_TYPE_HTML; } $message = array(); $width = 0; $height = 0; $img_space = null; if (!$bool && !is_null($errmsg)) { $msg = S_CONFIG_ERROR_HEAD . ': ' . $errmsg; } else { if ($bool && !is_null($okmsg)) { $msg = $okmsg; } } $api_errors = CZBXAPI::resetErrors(); if (!empty($api_errors)) { error($api_errors); } if (isset($msg)) { switch ($page['type']) { case PAGE_TYPE_IMAGE: array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2)); $width = max($width, ImageFontWidth(2) * zbx_strlen($msg) + 1); $height += imagefontheight(2) + 1; break; case PAGE_TYPE_XML: echo htmlspecialchars($msg) . "\n"; break; // case PAGE_TYPE_JS: break; // case PAGE_TYPE_JS: break; case PAGE_TYPE_HTML: default: $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr'); $msg_tab->setCellPadding(0); $msg_tab->setCellSpacing(0); $row = array(); $msg_col = new CCol(bold($msg), 'msg_main msg'); $msg_col->setAttribute('id', 'page_msg'); $row[] = $msg_col; if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { $msg_details = new CDiv(S_DETAILS, 'blacklink'); $msg_details->setAttribute('onclick', "javascript: ShowHide('msg_messages', IE?'block':'table');"); $msg_details->setAttribute('title', S_MAXIMIZE . '/' . S_MINIMIZE); array_unshift($row, new CCol($msg_details, 'clr')); } $msg_tab->addRow($row); $msg_tab->show(); $img_space = new CImg('images/general/tree/zero.gif', 'space', '100', '2'); break; } } if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { if ($page['type'] == PAGE_TYPE_IMAGE) { $msg_font = 2; foreach ($ZBX_MESSAGES as $msg) { if ($msg['type'] == 'error') { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font)); } else { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font)); } $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1); $height += imagefontheight($msg_font) + 1; } } else { if ($page['type'] == PAGE_TYPE_XML) { foreach ($ZBX_MESSAGES as $msg) { echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n"; } } else { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); $bool = $bool && 'error' != zbx_strtolower($msg['type']); } //message scroll if needed $msg_show = 6; $msg_count = count($ZBX_MESSAGES); if ($msg_count > $msg_show) { $msg_count = $msg_show; $msg_count = $msg_count * 16; $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;'); } $tab = new CTable(null, $bool ? 'msgok' : 'msgerr'); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('id', 'msg_messages'); $tab->setAttribute('style', 'width: 100%;'); if (isset($msg_tab) && $bool) { $tab->setAttribute('style', 'display: none;'); } $tab->addRow(new CCol($lst_error, 'msg')); $tab->Show(); //--- } } $ZBX_MESSAGES = null; } if (!is_null($img_space)) { print unpack_object($img_space); } if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) { $width += 2; $height += 2; $canvas = imagecreate($width, $height); imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255)); foreach ($message as $id => $msg) { $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0); $message[$id]['h'] = imagefontheight($msg['font']); imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B'])); $previd = $id; } imageOut($canvas); imagedestroy($canvas); } }
/* * Header */ $triggerData = isset($_REQUEST['triggerid']) ? API::Trigger()->get(['triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_EXTEND, 'expandDescription' => true]) : null; $reportWidget = (new CWidget())->setTitle(_('Availability report')); if ($triggerData) { $triggerData = reset($triggerData); $host = reset($triggerData['hosts']); $triggerData['hostid'] = $host['hostid']; $triggerData['hostname'] = $host['name']; $reportWidget->setControls((new CList())->addItem(new CLink($triggerData['hostname'], '?filter_groupid=' . $_REQUEST['filter_groupid']))->addItem($triggerData['description'])); $table = (new CTableInfo())->addRow(new CImg('chart4.php?triggerid=' . $_REQUEST['triggerid'])); $reportWidget->addItem(BR())->addItem($table)->show(); } elseif (isset($_REQUEST['filter_hostid'])) { $controls = new CList(); $controls->addItem([_('Mode') . SPACE, new CComboBox('mode', $availabilityReportMode, 'submit()', [AVAILABILITY_REPORT_BY_HOST => _('By host'), AVAILABILITY_REPORT_BY_TEMPLATE => _('By trigger template')])]); $headerForm = (new CForm('get'))->addItem($controls); $reportWidget->setControls($headerForm); $triggerOptions = ['output' => ['triggerid', 'description', 'expression', 'value'], 'expandDescription' => true, 'monitored' => true, 'selectHosts' => ['name'], 'filter' => [], 'hostids' => null, 'limit' => $config['search_limit'] + 1]; /* * Filter */ $filterForm = (new CFilter('web.avail_report.filter.state'))->addVar('config', $availabilityReportMode)->addVar('filter_timesince', date(TIMESTAMP_FORMAT, $_REQUEST['filter_timesince']))->addVar('filter_timetill', date(TIMESTAMP_FORMAT, $_REQUEST['filter_timetill'])); $filterColumn1 = new CFormList(); $filterColumn2 = new CFormList(); // report by template if ($availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE) { // trigger options if (!empty($_REQUEST['filter_hostid'])) { $hosts = API::Host()->get(['output' => ['hostid'], 'templateids' => $_REQUEST['filter_hostid']]); $triggerOptions['hostids'] = zbx_objectValues($hosts, 'hostid');
function getList() { $list = new CList(); foreach ($this->stage as $id => $data) { $list->addItem($data['title'], $id <= $this->getStep() ? ZBX_STYLE_SETUP_LEFT_CURRENT : null); } return $list; }
** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $screenWidget = new CWidget(); $form = (new CFilter('web.hostscreen.filter.state'))->addNavigator(); $screenWidget->addItem($form); if (empty($this->data['screen']) || empty($this->data['host'])) { $screenWidget->setTitle(_('Screens'))->addItem(new CTableInfo()); $screenBuilder = new CScreenBuilder(); CScreenBuilder::insertScreenStandardJs(['timeline' => $screenBuilder->timeline]); } else { $screenWidget->setTitle([$this->data['screen']['name'], SPACE, _('on'), SPACE, (new CSpan($this->data['host']['name']))->addClass(ZBX_STYLE_ORANGE)]); $controls = new CList(); // host screen list if (!empty($this->data['screens'])) { $screenComboBox = new CComboBox('screenList', 'host_screen.php?hostid=' . $this->data['hostid'] . '&screenid=' . $this->data['screenid'], 'javascript: redirect(this.options[this.selectedIndex].value);'); foreach ($this->data['screens'] as $screen) { $screenComboBox->addItem('host_screen.php?hostid=' . $this->data['hostid'] . '&screenid=' . $screen['screenid'], $screen['name']); } $controls->addItem($screenComboBox)->addItem(get_icon('fullscreen', ['fullscreen' => $this->data['fullscreen']])); $screenWidget->setControls($controls); } // append screens to widget $screenBuilder = new CScreenBuilder(['screen' => $this->data['screen'], 'mode' => SCREEN_MODE_PREVIEW, 'hostid' => $this->data['hostid'], 'period' => $this->data['period'], 'stime' => $this->data['stime'], 'profileIdx' => 'web.screens', 'profileIdx2' => $this->data['screen']['screenid']]); $screenWidget->addItem((new CDiv($screenBuilder->show()))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)); CScreenBuilder::insertScreenStandardJs(['timeline' => $screenBuilder->timeline, 'profileIdx' => $screenBuilder->profileIdx]); } return $screenWidget;
** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $widget = (new CWidget())->setTitle(_('Screens')); $controls = new CList(); if (!$data['templateid']) { $controls->addItem(new CComboBox('config', 'screens.php', 'redirect(this.options[this.selectedIndex].value);', ['screens.php' => _('Screens'), 'slides.php' => _('Slide shows')])); } $controls->addItem(new CSubmit('form', _('Create screen'))); $createForm = (new CForm('get'))->cleanItems(); if ($data['templateid']) { $createForm->addVar('templateid', $data['templateid']); $widget->addItem(get_header_host_table('screens', $data['templateid'])); } else { $controls->addItem((new CButton('form', _('Import')))->onClick('redirect("screen.import.php?rules_preset=screen")')); } $createForm->addItem($controls); $widget->setControls($createForm); // filter if (!$data['templateid']) { $widget->addItem((new CFilter('web.screenconf.filter.state'))->addColumn((new CFormList())->addRow(_('Name like'), (new CTextBox('filter_name', $data['filter']['name']))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)))); }
$minYear = date('Y', $firstAlert['clock']); } else { $minYear = date('Y'); } $form = (new CForm())->setMethod('get'); $controls = new CList(); $cmbMedia = new CComboBox('media_type', $media_type, 'submit()'); $cmbMedia->addItem(0, _('all')); foreach ($media_types as $media_type_id => $media_type_description) { $cmbMedia->addItem($media_type_id, $media_type_description); // we won't need other media types in the future, if only one was selected if ($media_type > 0 && $media_type != $media_type_id) { unset($media_types[$media_type_id]); } } $controls->addItem([_('Media type'), SPACE, $cmbMedia]); $controls->addItem([_('Period'), SPACE, new CComboBox('period', $period, 'submit()', ['daily' => _('Daily'), 'weekly' => _('Weekly'), 'monthly' => _('Monthly'), 'yearly' => _('Yearly')])]); if ($period != 'yearly') { $cmbYear = new CComboBox('year', $year, 'submit();'); for ($y = $minYear; $y <= date('Y'); $y++) { $cmbYear->addItem($y, $y); } $controls->addItem([_('Year'), SPACE, $cmbYear]); } $form->addItem($controls); $widget->setControls($form); $header = []; $users = []; $db_users = DBselect('SELECT u.userid,u.alias,u.name,u.surname FROM users u ORDER BY u.alias,u.userid'); while ($user_data = DBfetch($db_users)) { $header[] = (new CColHeader(getUserFullname($user_data)))->addClass('vertical_rotation');
$frmForm->addVar('groupid', $pageFilter->groupid, 'groupid_csv'); $frmForm->addVar('hostid', $pageFilter->hostid, 'hostid_csv'); if ($triggerId) { $frmForm->addVar('triggerid', $triggerId, 'triggerid_csv'); } } $frmForm->addVar('fullscreen', getRequest('fullscreen')); $frmForm->addVar('stime', $stime); $frmForm->addVar('period', $period); $controls = new CList(); // add host and group filters to the form if ($source == EVENT_SOURCE_TRIGGERS) { if (getRequest('triggerid') != 0) { $frmForm->addVar('triggerid', getRequest('triggerid'), 'triggerid_filter'); } $controls->addItem([_('Group'), SPACE, $pageFilter->getGroupsCB()]); $controls->addItem([_('Host'), SPACE, $pageFilter->getHostsCB()]); } if ($allow_discovery) { $controls->addItem([_('Source'), SPACE, new CComboBox('source', $source, 'submit()', [EVENT_SOURCE_TRIGGERS => _('Trigger'), EVENT_SOURCE_DISCOVERY => _('Discovery')])]); } $controls->addItem(new CSubmit('csv_export', _('Export to CSV'))); $controls->addItem(get_icon('fullscreen', ['fullscreen' => getRequest('fullscreen')])); $frmForm->addItem($controls); $eventsWidget->setControls($frmForm); $filterForm = (new CFilter('web.events.filter.state'))->addVar('fullscreen', getRequest('fullscreen')); if ($source == EVENT_SOURCE_TRIGGERS) { $filterForm->addVar('triggerid', $triggerId)->addVar('stime', $stime)->addVar('period', $period); $filterForm->addVar('groupid', $pageFilter->groupid); $filterForm->addVar('hostid', $pageFilter->hostid); if ($triggerId > 0) {
function show_messages($bool = true, $okmsg = null, $errmsg = null) { global $page, $ZBX_MESSAGES; if (!defined('PAGE_HEADER_LOADED')) { return null; } if (defined('ZBX_API_REQUEST')) { return null; } if (!isset($page['type'])) { $page['type'] = PAGE_TYPE_HTML; } $message = array(); $width = 0; $height = 0; if (!$bool && !is_null($errmsg)) { $msg = _('ERROR') . ': ' . $errmsg; } elseif ($bool && !is_null($okmsg)) { $msg = $okmsg; } if (isset($msg)) { switch ($page['type']) { case PAGE_TYPE_IMAGE: array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2)); $width = max($width, imagefontwidth(2) * zbx_strlen($msg) + 1); $height += imagefontheight(2) + 1; break; case PAGE_TYPE_XML: echo htmlspecialchars($msg) . "\n"; break; case PAGE_TYPE_HTML: default: $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr'); $msg_tab->setCellPadding(0); $msg_tab->setCellSpacing(0); $row = array(); $msg_col = new CCol(bold($msg), 'msg_main msg'); $msg_col->setAttribute('id', 'page_msg'); $row[] = $msg_col; if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { $msg_details = new CDiv(_('Details'), 'blacklink'); $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");'); $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize')); array_unshift($row, new CCol($msg_details, 'clr')); } $msg_tab->addRow($row); $msg_tab->show(); break; } } if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { if ($page['type'] == PAGE_TYPE_IMAGE) { $msg_font = 2; foreach ($ZBX_MESSAGES as $msg) { if ($msg['type'] == 'error') { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font)); } else { array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font)); } $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1); $height += imagefontheight($msg_font) + 1; } } elseif ($page['type'] == PAGE_TYPE_XML) { foreach ($ZBX_MESSAGES as $msg) { echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n"; } } else { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); $bool = $bool && 'error' != zbx_strtolower($msg['type']); } $msg_show = 6; $msg_count = count($ZBX_MESSAGES); if ($msg_count > $msg_show) { $msg_count = $msg_show * 16; $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;'); } $tab = new CTable(null, $bool ? 'msgok' : 'msgerr'); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('id', 'msg_messages'); $tab->setAttribute('style', 'width: 100%;'); if (isset($msg_tab) && $bool) { $tab->setAttribute('style', 'display: none;'); } $tab->addRow(new CCol($lst_error, 'msg')); $tab->show(); } $ZBX_MESSAGES = null; } if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) { $width += 2; $height += 2; $canvas = imagecreate($width, $height); imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255)); foreach ($message as $id => $msg) { $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0); $message[$id]['h'] = imagefontheight($msg['font']); imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B'])); $previd = $id; } imageOut($canvas); imagedestroy($canvas); } }
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; }
function stage3() { $table = new CTable(null, 'requirements'); $table->setAlign('center'); $DB['TYPE'] = $this->getConfig('DB_TYPE'); $cmbType = new CComboBox('type', $DB['TYPE'], 'this.form.submit();'); $frontendSetup = new FrontendSetup(); $databases = $frontendSetup->getSupportedDatabases(); foreach ($databases as $id => $name) { $cmbType->addItem($id, $name); } $table->addRow(array(new CCol(_('Database type'), 'header'), $cmbType)); switch ($DB['TYPE']) { case ZBX_DB_SQLITE3: $database = new CTextBox('database', $this->getConfig('DB_DATABASE', 'zabbix')); $database->attr('onchange', "disableSetupStepButton('#next_2')"); $table->addRow(array(new CCol(_('Database file'), 'header'), $database)); break; default: $server = new CTextBox('server', $this->getConfig('DB_SERVER', 'localhost')); $server->attr('onchange', "disableSetupStepButton('#next_2')"); $table->addRow(array(new CCol(_('Database host'), 'header'), $server)); $port = new CNumericBox('port', $this->getConfig('DB_PORT', '0'), 5, 'no', false, false); $port->attr('style', ''); $port->attr('onchange', "disableSetupStepButton('#next_2'); validateNumericBox(this, 'false', 'false');"); $table->addRow(array(new CCol(_('Database port'), 'header'), array($port, ' 0 - use default port'))); $database = new CTextBox('database', $this->getConfig('DB_DATABASE', 'zabbix')); $database->attr('onchange', "disableSetupStepButton('#next_2')"); $table->addRow(array(new CCol(_('Database name'), 'header'), $database)); if ($DB['TYPE'] == ZBX_DB_DB2) { $schema = new CTextBox('schema', $this->getConfig('DB_SCHEMA', '')); $schema->attr('onchange', "disableSetupStepButton('#next_2')"); $table->addRow(array(new CCol(_('Database schema'), 'header'), $schema)); } $user = new CTextBox('user', $this->getConfig('DB_USER', 'root')); $user->attr('onchange', "disableSetupStepButton('#next_2')"); $table->addRow(array(new CCol(_('User'), 'header'), $user)); $password = new CPassBox('password', $this->getConfig('DB_PASSWORD', '')); $password->attr('onchange', "disableSetupStepButton('#next_2')"); $table->addRow(array(new CCol(_('Password'), 'header'), $password)); break; } global $ZBX_MESSAGES; if (!empty($ZBX_MESSAGES)) { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); } $table = array($table, $lst_error); } return array(new CDiv(new CDiv(array('Please create database manually, and set the configuration parameters for connection to this database.', BR(), BR(), 'Press "Test connection" button when done.', BR(), $table), 'vertical_center'), 'table_wraper'), new CDiv(array(isset($_REQUEST['retry']) ? !$this->DISABLE_NEXT_BUTTON ? new CSpan(array(_('OK'), BR()), 'ok') : new CSpan(array(_('Fail'), BR()), 'fail') : null, new CSubmit('retry', 'Test connection')), 'info_bar')); }
/** * Create CDiv with host/template information and references to it's elements * * @param string $currentElement * @param int $hostid * @param int $discoveryid * * @return object */ function get_header_host_table($currentElement, $hostid, $discoveryid = null) { // LLD rule header if ($discoveryid) { $elements = array('items' => 'items', 'triggers' => 'triggers', 'graphs' => 'graphs', 'hosts' => 'hosts'); } else { $elements = array('items' => 'items', 'triggers' => 'triggers', 'graphs' => 'graphs', 'applications' => 'applications', 'screens' => 'screens', 'discoveries' => 'discoveries', 'web' => 'web'); } $options = array('hostids' => $hostid, 'output' => API_OUTPUT_EXTEND, 'templated_hosts' => true, 'selectHostDiscovery' => array('ts_delete')); if (isset($elements['items'])) { $options['selectItems'] = API_OUTPUT_COUNT; } if (isset($elements['triggers'])) { $options['selectTriggers'] = API_OUTPUT_COUNT; } if (isset($elements['graphs'])) { $options['selectGraphs'] = API_OUTPUT_COUNT; } if (isset($elements['applications'])) { $options['selectApplications'] = API_OUTPUT_COUNT; } if (isset($elements['discoveries'])) { $options['selectDiscoveries'] = API_OUTPUT_COUNT; } if (isset($elements['web'])) { $options['selectHttpTests'] = API_OUTPUT_COUNT; } if (isset($elements['hosts'])) { $options['selectHostPrototypes'] = API_OUTPUT_COUNT; } // get hosts $dbHost = API::Host()->get($options); $dbHost = reset($dbHost); if (!$dbHost) { return null; } // get discoveries if (!empty($discoveryid)) { $options['itemids'] = $discoveryid; $options['output'] = array('name'); unset($options['hostids'], $options['templated_hosts']); $dbDiscovery = API::DiscoveryRule()->get($options); $dbDiscovery = reset($dbDiscovery); } /* * Back */ $list = new CList(null, 'objectlist'); if ($dbHost['status'] == HOST_STATUS_TEMPLATE) { $list->addItem(array('« ', new CLink(_('Template list'), 'templates.php?templateid=' . $dbHost['hostid'] . url_param('groupid')))); $dbHost['screens'] = API::TemplateScreen()->get(array('editable' => true, 'countOutput' => true, 'groupCount' => true, 'templateids' => $dbHost['hostid'])); $dbHost['screens'] = isset($dbHost['screens'][0]['rowscount']) ? $dbHost['screens'][0]['rowscount'] : 0; } else { $list->addItem(array('« ', new CLink(_('Host list'), 'hosts.php?hostid=' . $dbHost['hostid'] . url_param('groupid')))); } /* * Name */ $proxyName = ''; if ($dbHost['proxy_hostid']) { $proxy = get_host_by_hostid($dbHost['proxy_hostid']); $proxyName = CHtml::encode($proxy['host']) . NAME_DELIMITER; } $name = get_node_name_by_elid($dbHost['hostid'], true, NAME_DELIMITER) . $proxyName . CHtml::encode($dbHost['name']); if ($dbHost['status'] == HOST_STATUS_TEMPLATE) { $list->addItem(array(bold(_('Template') . NAME_DELIMITER), new CLink($name, 'templates.php?form=update&templateid=' . $dbHost['hostid']))); } else { switch ($dbHost['status']) { case HOST_STATUS_MONITORED: if ($dbHost['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) { $status = new CSpan(_('In maintenance'), 'orange'); } else { $status = new CSpan(_('Monitored'), 'enabled'); } break; case HOST_STATUS_NOT_MONITORED: $status = new CSpan(_('Not monitored'), 'on'); break; default: $status = _('Unknown'); break; } $list->addItem(array(bold(_('Host') . NAME_DELIMITER), new CLink($name, 'hosts.php?form=update&hostid=' . $dbHost['hostid']))); $list->addItem($status); $list->addItem(getAvailabilityTable($dbHost)); } if (!empty($dbDiscovery)) { $list->addItem(array('« ', new CLink(_('Discovery list'), 'host_discovery.php?hostid=' . $dbHost['hostid'] . url_param('groupid')))); $list->addItem(array(bold(_('Discovery') . NAME_DELIMITER), new CLink(CHtml::encode($dbDiscovery['name']), 'host_discovery.php?form=update&itemid=' . $dbDiscovery['itemid']))); } /* * Rowcount */ if (isset($elements['applications'])) { if ($currentElement == 'applications') { $list->addItem(_('Applications') . ' (' . $dbHost['applications'] . ')'); } else { $list->addItem(array(new CLink(_('Applications'), 'applications.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['applications'] . ')')); } } if (isset($elements['items'])) { if (!empty($dbDiscovery)) { if ($currentElement == 'items') { $list->addItem(_('Item prototypes') . ' (' . $dbDiscovery['items'] . ')'); } else { $list->addItem(array(new CLink(_('Item prototypes'), 'disc_prototypes.php?hostid=' . $dbHost['hostid'] . '&parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['items'] . ')')); } } else { if ($currentElement == 'items') { $list->addItem(_('Items') . ' (' . $dbHost['items'] . ')'); } else { $list->addItem(array(new CLink(_('Items'), 'items.php?filter_set=1&hostid=' . $dbHost['hostid']), ' (' . $dbHost['items'] . ')')); } } } if (isset($elements['triggers'])) { if (!empty($dbDiscovery)) { if ($currentElement == 'triggers') { $list->addItem(_('Trigger prototypes') . ' (' . $dbDiscovery['triggers'] . ')'); } else { $list->addItem(array(new CLink(_('Trigger prototypes'), 'trigger_prototypes.php?hostid=' . $dbHost['hostid'] . '&parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['triggers'] . ')')); } } else { if ($currentElement == 'triggers') { $list->addItem(_('Triggers') . ' (' . $dbHost['triggers'] . ')'); } else { $list->addItem(array(new CLink(_('Triggers'), 'triggers.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['triggers'] . ')')); } } } if (isset($elements['graphs'])) { if (!empty($dbDiscovery)) { if ($currentElement == 'graphs') { $list->addItem(_('Graph prototypes') . ' (' . $dbDiscovery['graphs'] . ')'); } else { $list->addItem(array(new CLink(_('Graph prototypes'), 'graphs.php?hostid=' . $dbHost['hostid'] . '&parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['graphs'] . ')')); } } else { if ($currentElement == 'graphs') { $list->addItem(_('Graphs') . ' (' . $dbHost['graphs'] . ')'); } else { $list->addItem(array(new CLink(_('Graphs'), 'graphs.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['graphs'] . ')')); } } } if (isset($elements['hosts']) && $dbHost['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { if ($currentElement == 'hosts') { $list->addItem(_('Host prototypes') . ' (' . $dbDiscovery['hostPrototypes'] . ')'); } else { $list->addItem(array(new CLink(_('Host prototypes'), 'host_prototypes.php?parent_discoveryid=' . $dbDiscovery['itemid']), ' (' . $dbDiscovery['hostPrototypes'] . ')')); } } if (isset($elements['screens']) && $dbHost['status'] == HOST_STATUS_TEMPLATE) { if ($currentElement == 'screens') { $list->addItem(_('Screens') . ' (' . $dbHost['screens'] . ')'); } else { $list->addItem(array(new CLink(_('Screens'), 'screenconf.php?templateid=' . $dbHost['hostid']), ' (' . $dbHost['screens'] . ')')); } } if (isset($elements['discoveries'])) { if ($currentElement == 'discoveries') { $list->addItem(_('Discovery rules') . ' (' . $dbHost['discoveries'] . ')'); } else { $list->addItem(array(new CLink(_('Discovery rules'), 'host_discovery.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['discoveries'] . ')')); } } if (isset($elements['web'])) { if ($currentElement == 'web') { $list->addItem(_('Web scenarios') . ' (' . $dbHost['httpTests'] . ')'); } else { $list->addItem(array(new CLink(_('Web scenarios'), 'httpconf.php?hostid=' . $dbHost['hostid']), ' (' . $dbHost['httpTests'] . ')')); } } return new CDiv($list, 'objectgroup top ui-widget-content ui-corner-all'); }
function make_favorite_maps() { $favList = new CList(null, 'favorites', _('No maps added.')); $fav_sysmaps = CFavorite::get('web.favorite.sysmapids'); if (!$fav_sysmaps) { return $favList; } $sysmapids = array(); foreach ($fav_sysmaps as $favorite) { $sysmapids[$favorite['value']] = $favorite['value']; } $sysmaps = API::Map()->get(array('sysmapids' => $sysmapids, 'output' => array('sysmapid', 'name'))); foreach ($sysmaps as $sysmap) { $sysmapid = $sysmap['sysmapid']; $link = new CLink(get_node_name_by_elid($sysmapid, null, NAME_DELIMITER) . $sysmap['name'], 'maps.php?sysmapid=' . $sysmapid); $link->setTarget('blank'); $favList->addItem($link, 'nowrap'); } return $favList; }
$filter['inventory'][] = ['field' => $field, 'value' => CProfile::get('web.tr_status.filter.inventory.value', null, $i)]; } /* * Page sorting */ $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'lastchange')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_DOWN)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); /* * Display */ $triggerWidget = (new CWidget())->setTitle(_('Status of triggers')); $rightForm = (new CForm('get'))->addVar('fullscreen', $_REQUEST['fullscreen']); $controls = new CList(); $controls->addItem([_('Group') . SPACE, $pageFilter->getGroupsCB()]); $controls->addItem([_('Host') . SPACE, $pageFilter->getHostsCB()]); $controls->addItem(get_icon('fullscreen', ['fullscreen' => $_REQUEST['fullscreen']])); $rightForm->addItem($controls); $triggerWidget->setControls($rightForm); // filter $filterFormView = new CView('common.filter.trigger', ['overview' => false, 'filter' => ['filterid' => 'web.tr_status.filter.state', 'showTriggers' => $showTriggers, 'ackStatus' => $ackStatus, 'showEvents' => $showEvents, 'showSeverity' => $showSeverity, 'statusChange' => $showChange, 'statusChangeDays' => $statusChangeBydays, 'showDetails' => $showDetails, 'txtSelect' => $txtSelect, 'application' => $filter['application'], 'inventory' => $filter['inventory'], 'showMaintenance' => $showMaintenance, 'hostId' => getRequest('hostid'), 'groupId' => getRequest('groupid'), 'fullScreen' => getRequest('fullscreen')], 'config' => $config]); $filterForm = $filterFormView->render(); $triggerWidget->addItem($filterForm); /* * Form */ $triggerForm = (new CForm('get', 'zabbix.php'))->setName('tr_status')->addVar('backurl', $page['file'])->addVar('acknowledge_type', ZBX_ACKNOWLEDGE_PROBLEM); /* * Table */
function show_messages($bool = true, $okmsg = null, $errmsg = null) { global $page, $ZBX_MESSAGES; if (!defined('PAGE_HEADER_LOADED')) { return null; } if (defined('ZBX_API_REQUEST')) { return null; } if (!isset($page['type'])) { $page['type'] = PAGE_TYPE_HTML; } $imageMessages = array(); if (!$bool && !is_null($errmsg)) { $msg = _('ERROR') . ': ' . $errmsg; } elseif ($bool && !is_null($okmsg)) { $msg = $okmsg; } if (isset($msg)) { switch ($page['type']) { case PAGE_TYPE_IMAGE: // save all of the messages in an array to display them later in an image $imageMessages[] = array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68)); break; case PAGE_TYPE_XML: echo htmlspecialchars($msg) . "\n"; break; case PAGE_TYPE_HTML: default: $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr'); $msg_tab->setCellPadding(0); $msg_tab->setCellSpacing(0); $row = array(); $msg_col = new CCol(bold($msg), 'msg_main msg'); $msg_col->setAttribute('id', 'page_msg'); $row[] = $msg_col; if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { $msg_details = new CDiv(_('Details'), 'blacklink'); $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");'); $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize')); array_unshift($row, new CCol($msg_details, 'clr')); } $msg_tab->addRow($row); $msg_tab->show(); break; } } if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) { if ($page['type'] == PAGE_TYPE_IMAGE) { foreach ($ZBX_MESSAGES as $msg) { // save all of the messages in an array to display them later in an image if ($msg['type'] == 'error') { $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55)); } else { $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55)); } } } elseif ($page['type'] == PAGE_TYPE_XML) { foreach ($ZBX_MESSAGES as $msg) { echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n"; } } else { $lst_error = new CList(null, 'messages'); foreach ($ZBX_MESSAGES as $msg) { $lst_error->addItem($msg['message'], $msg['type']); $bool = $bool && 'error' !== strtolower($msg['type']); } $msg_show = 6; $msg_count = count($ZBX_MESSAGES); if ($msg_count > $msg_show) { $msg_count = $msg_show * 16; $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;'); } $tab = new CTable(null, $bool ? 'msgok' : 'msgerr'); $tab->setCellPadding(0); $tab->setCellSpacing(0); $tab->setAttribute('id', 'msg_messages'); $tab->setAttribute('style', 'width: 100%;'); if (isset($msg_tab) && $bool) { $tab->setAttribute('style', 'display: none;'); } $tab->addRow(new CCol($lst_error, 'msg')); $tab->show(); } $ZBX_MESSAGES = null; } // draw an image with the messages if ($page['type'] == PAGE_TYPE_IMAGE && count($imageMessages) > 0) { $imageFontSize = 8; // calculate the size of the text $imageWidth = 0; $imageHeight = 0; foreach ($imageMessages as &$msg) { $size = imageTextSize($imageFontSize, 0, $msg['text']); $msg['height'] = $size['height'] - $size['baseline']; // calculate the total size of the image $imageWidth = max($imageWidth, $size['width']); $imageHeight += $size['height'] + 1; } unset($msg); // additional padding $imageWidth += 2; $imageHeight += 2; // create the image $canvas = imagecreate($imageWidth, $imageHeight); imagefilledrectangle($canvas, 0, 0, $imageWidth, $imageHeight, imagecolorallocate($canvas, 255, 255, 255)); // draw each message $y = 1; foreach ($imageMessages as $msg) { $y += $msg['height']; imageText($canvas, $imageFontSize, 0, 1, $y, imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']), $msg['text']); } imageOut($canvas); imagedestroy($canvas); } }