public function setDoubleHeader($left, $right) { $table = new CTable(); $table->addStyle('width: 100%;'); $lCol = new CCol($left); $lCol->addStyle('text-align: left; border: 0;'); $rCol = new CCol($right); $rCol->addStyle('text-align: right; border: 0;'); $table->addRow(array($lCol, $rCol)); $this->_header = new CDiv(null, 'nowrap ui-corner-all ui-widget-header ' . $this->css_class); $this->_header->addItem($table); return $this->_header; }
public function get($caption_l = null, $caption_r = null) { if (empty($caption_l)) { $caption_l = _('In'); } if (empty($caption_r)) { $caption_r = _('Other'); } $grp_tab = new CTable(); $grp_tab->attr('name', $this->name); $grp_tab->attr('id', zbx_formatDomId($this->name)); $grp_tab->setCellSpacing(0); $grp_tab->setCellPadding(0); if (!is_null($caption_l) || !is_null($caption_r)) { $grp_tab->addRow(array($caption_l, SPACE, $caption_r)); } $add_btn = new CButton('add', ' « ', null, 'formlist'); $add_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_r . '", "' . $this->id_l . '", "add");'); $rmv_btn = new CButton('remove', ' » ', null, 'formlist'); $rmv_btn->setAttribute('onclick', 'javascript: moveListBoxSelectedItem("' . $this->form->getName() . '", "' . $this->varname . '", "' . $this->id_l . '", "' . $this->id_r . '", "rmv");'); $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox)); return $grp_tab; }
private function makeRow($id) { $table = new CTable(); $tr = $this->makeSImgStr($id); $tr->addItem($this->tree[$id]['caption']); $table->addRow($tr); $tr = new CRow(); $tr->addItem($table); $tr->setAttribute('id', 'id_' . $id); $tr->setAttribute('style', $this->tree[$id]['parentid'] != '0' ? 'display: none;' : ''); foreach ($this->fields as $value) { $tr->addItem($this->makeCol($id, $value)); } return $tr; }
public function get($caption_l = S_IN, $caption_r = S_OTHER) { $grp_tab = new CTable(); $grp_tab->addOption('name', $this->name); $grp_tab->addOption('id', $this->name); $grp_tab->setCellSpacing(0); $grp_tab->setCellPadding(0); if (!is_null($caption_l) || !is_null($caption_r)) { $grp_tab->addRow(array($caption_l, SPACE, $caption_r)); } $add_btn = new CButton('add', ' « '); //S_ADD);// $add_btn->setType('button'); $add_btn->setAction('javascript: moveListBoxSelectedItem("' . $this->form->GetName() . '","' . $this->varname . '","' . $this->id_r . '","' . $this->id_l . '","add");'); $rmv_btn = new CButton('remove', ' » '); //S_REMOVE);// $rmv_btn->setType('button'); $rmv_btn->setAction('javascript: moveListBoxSelectedItem("' . $this->form->GetName() . '","' . $this->varname . '","' . $this->id_l . '","' . $this->id_r . '","rmv");'); $grp_tab->addRow(array($this->lbox, new CCol(array($add_btn, BR(), $rmv_btn), 'top'), $this->rbox)); return $grp_tab; }
private function makeRow($id) { $table = new CTable(); $tr = $this->makeSImgStr($id); $tr->addItem($this->tree[$id]['caption']); $table->addRow($tr); $tr = new CRow(); $tr->addItem($table); $tr->setAttribute('id', 'id_' . $id); $tr->setAttribute('style', $this->tree[$id]['parentid'] != '0' ? 'display: none;' : ''); foreach ($this->fields as $key => $value) { $style = null; if ($value == 'status' && $this->tree[$id]['serviceid'] > 0) { switch ($this->tree[$id][$value]) { case TRIGGER_SEVERITY_DISASTER: $this->tree[$id][$value] = S_DISASTER; $style = 'disaster'; break; case TRIGGER_SEVERITY_HIGH: $this->tree[$id][$value] = S_HIGH; $style = 'high'; break; case TRIGGER_SEVERITY_AVERAGE: $this->tree[$id][$value] = S_AVERAGE; $style = 'average'; break; case TRIGGER_SEVERITY_WARNING: $this->tree[$id][$value] = S_WARNING; $style = 'warning'; break; case TRIGGER_SEVERITY_INFORMATION: default: $this->tree[$id][$value] = new CSpan(S_OK_BIG, 'green'); break; } } $tr->addItem(new CCol($this->tree[$id][$value], $style)); } return $tr; }
/** * Process screen with particular screen objects. * * @return CTable */ public function show() { if (empty($this->screen)) { return new CTableInfo(_('No screens defined.')); } $skipedFields = array(); $screenitems = array(); $emptyScreenColumns = array(); // calculate table columns and rows foreach ($this->screen['screenitems'] as $screenitem) { $screenitems[] = $screenitem; for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) { for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) { if ($i != 0 || $j != 0) { if (!isset($skipedFields[$screenitem['y'] + $i])) { $skipedFields[$screenitem['y'] + $i] = array(); } $skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1; } } } } // create screen table $screenTable = new CTable(); $screenTable->setAttribute('class', in_array($this->mode, array(SCREEN_MODE_PREVIEW, SCREEN_MODE_SLIDESHOW)) ? 'screen_view' : 'screen_edit'); $screenTable->setAttribute('id', 'iframe'); // action top row if ($this->mode == SCREEN_MODE_EDIT) { $newColumns = array(new CCol(new CImg('images/general/zero.png', 'zero', 1, 1))); for ($i = 0, $size = $this->screen['hsize'] + 1; $i < $size; $i++) { $icon = new CImg('images/general/plus.png', null, null, null, 'pointer'); $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_col=' . $i . '";'); array_push($newColumns, new CCol($icon)); } $screenTable->addRow($newColumns); } for ($r = 0; $r < $this->screen['vsize']; $r++) { $newColumns = array(); $emptyScreenRow = true; // action left cell if ($this->mode == SCREEN_MODE_EDIT) { $icon = new CImg('images/general/plus.png', null, null, null, 'pointer'); $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_row=' . $r . '";'); array_push($newColumns, new CCol($icon)); } for ($c = 0; $c < $this->screen['hsize']; $c++) { if (isset($skipedFields[$r][$c])) { continue; } // screen item $isEditForm = false; $screenitem = array(); foreach ($screenitems as $tmprow) { if ($tmprow['x'] == $c && $tmprow['y'] == $r) { $screenitem = $tmprow; break; } } if (empty($screenitem)) { $screenitem = array('screenitemid' => 0, 'resourcetype' => 0, 'resourceid' => 0, 'width' => 0, 'height' => 0, 'colspan' => 1, 'rowspan' => 1, 'elements' => 0, 'valign' => VALIGN_DEFAULT, 'halign' => HALIGN_DEFAULT, 'style' => 0, 'url' => '', 'dynamic' => 0, 'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC); } if (!empty($screenitem['screenitemid'])) { $emptyScreenRow = false; $emptyScreenColumns[$c] = 1; } // action if ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] != 0) { $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid']; } elseif ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] == 0) { $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r; } else { $action = null; } // edit form cell if ($this->mode == SCREEN_MODE_EDIT && (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update') && (isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r || isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0)) { $screenView = new CView('configuration.screen.constructor.edit', array('screen' => $this->screen)); $item = $screenView->render(); $isEditForm = true; } elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) { $screenBase = CScreenBuilder::getScreen(array('isFlickerfree' => $this->isFlickerfree, 'pageFile' => $this->pageFile, 'mode' => $this->mode, 'timestamp' => $this->timestamp, 'hostid' => $this->hostid, 'profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'timeline' => $this->timeline, 'resourcetype' => $screenitem['resourcetype'], 'screenitem' => $screenitem)); if (!empty($screenBase)) { if ($this->mode == SCREEN_MODE_EDIT && !empty($screenitem['screenitemid'])) { $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid']; } elseif ($this->mode == SCREEN_MODE_EDIT && empty($screenitem['screenitemid'])) { $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r; } $item = $screenBase->get(); } else { $item = null; } } else { $item = array(SPACE); if ($this->mode == SCREEN_MODE_EDIT) { array_push($item, BR(), new CLink(_('Change'), $action, 'empty_change_link')); } } // align $halign = 'def'; if ($screenitem['halign'] == HALIGN_CENTER) { $halign = 'cntr'; } if ($screenitem['halign'] == HALIGN_LEFT) { $halign = 'left'; } if ($screenitem['halign'] == HALIGN_RIGHT) { $halign = 'right'; } $valign = 'def'; if ($screenitem['valign'] == VALIGN_MIDDLE) { $valign = 'mdl'; } if ($screenitem['valign'] == VALIGN_TOP) { $valign = 'top'; } if ($screenitem['valign'] == VALIGN_BOTTOM) { $valign = 'bttm'; } if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) { $item = new CDiv($item, 'draggable'); $item->setAttribute('id', 'position_' . $r . '_' . $c); $item->setAttribute('data-xcoord', $c); $item->setAttribute('data-ycoord', $r); } // colspan/rowspan $newColumn = new CCol($item, $halign . '_' . $valign . ' screenitem'); if (!empty($screenitem['colspan'])) { $newColumn->setColSpan($screenitem['colspan']); } if (!empty($screenitem['rowspan'])) { $newColumn->setRowSpan($screenitem['rowspan']); } array_push($newColumns, $newColumn); } // action right cell if ($this->mode == SCREEN_MODE_EDIT) { $icon = new CImg('images/general/minus.png', null, null, null, 'pointer'); if ($emptyScreenRow) { $removeRowLink = 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '";'; } else { $removeRowLink = 'javascript: if (Confirm("' . _('This screen-row is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '"; }'; } $icon->addAction('onclick', $removeRowLink); array_push($newColumns, new CCol($icon)); } $screenTable->addRow(new CRow($newColumns)); } // action bottom row if ($this->mode == SCREEN_MODE_EDIT) { $icon = new CImg('images/general/plus.png', null, null, null, 'pointer'); $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&add_row=' . $this->screen['vsize'] . '";'); $newColumns = array(new CCol($icon)); for ($i = 0; $i < $this->screen['hsize']; $i++) { $icon = new CImg('images/general/minus.png', null, null, null, 'pointer'); if (isset($emptyScreenColumns[$i])) { $removeColumnLink = 'javascript: if (Confirm("' . _('This screen-column is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '"; }'; } else { $removeColumnLink = 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '";'; } $icon->addAction('onclick', $removeColumnLink); array_push($newColumns, new CCol($icon)); } array_push($newColumns, new CCol(new CImg('images/general/zero.png', 'zero', 1, 1))); $screenTable->addRow($newColumns); } return $screenTable; }
// append permissions table to form list $permissionsTable = new CTable(null, 'right_table'); $permissionsTable->setHeader(array(_('Read-write'), _('Read only'), _('Deny')), 'header'); $lstWrite = new CListBox('right_to_del[read_write][]', null, 20); $lstRead = new CListBox('right_to_del[read_only][]', null, 20); $lstDeny = new CListBox('right_to_del[deny][]', null, 20); foreach ($this->data['group_rights'] as $id => $rights) { if ($rights['permission'] == PERM_DENY) { $lstDeny->addItem($id, $rights['name']); } elseif ($rights['permission'] == PERM_READ) { $lstRead->addItem($id, $rights['name']); } elseif ($rights['permission'] == PERM_READ_WRITE) { $lstWrite->addItem($id, $rights['name']); } } $permissionsTable->addRow(array(new CCol($lstWrite, 'read_write'), new CCol($lstRead, 'read_only'), new CCol($lstDeny, 'deny'))); $permissionsTable->addRow(array(array(new CButton('add_read_write', _('Add'), "return PopUp('popup_right.php?dstfrm=" . $userGroupForm->getName() . '&permission=' . PERM_READ_WRITE . "', 450, 450);", 'formlist'), new CSubmit('del_read_write', _('Delete selected'), null, 'formlist')), array(new CButton('add_read_only', _('Add'), "return PopUp('popup_right.php?dstfrm=" . $userGroupForm->getName() . '&permission=' . PERM_READ . "', 450, 450);", 'formlist'), new CSubmit('del_read_only', _('Delete selected'), null, 'formlist')), array(new CButton('add_deny', _('Add'), "return PopUp('popup_right.php?dstfrm=" . $userGroupForm->getName() . '&permission=' . PERM_DENY . "', 450, 450);", 'formlist'), new CSubmit('del_deny', _('Delete selected'), null, 'formlist')))); $permissionsFormList->addRow(_('Composing permissions'), $permissionsTable); $permissionsFormList->addRow(_('Calculated permissions'), ''); $permissionsFormList = getPermissionsFormList($this->data['group_rights'], null, $permissionsFormList); // append form lists to tab $userGroupTab = new CTabView(); if (!$this->data['form_refresh']) { $userGroupTab->setSelected(0); } $userGroupTab->addTab('userGroupTab', _('User group'), $userGroupFormList); $userGroupTab->addTab('permissionsTab', _('Permissions'), $permissionsFormList); // append tab to form $userGroupForm->addItem($userGroupTab); // append buttons to form if (isset($this->data['usrgrpid'])) {
// append delay flex to form list $delayFlexTable = new CTable(_('No flexible intervals defined.'), 'formElementTable'); $delayFlexTable->setAttribute('style', 'min-width: 310px;'); $delayFlexTable->setAttribute('id', 'delayFlexTable'); $delayFlexTable->setHeader(array(_('Interval'), _('Period'), _('Action'))); $i = 0; $this->data['maxReached'] = false; foreach ($this->data['delay_flex'] as $delayFlex) { if (!isset($delayFlex['delay']) && !isset($delayFlex['period'])) { continue; } $itemForm->addVar('delay_flex[' . $i . '][delay]', $delayFlex['delay']); $itemForm->addVar('delay_flex[' . $i . '][period]', $delayFlex['period']); $row = new CRow(array($delayFlex['delay'], $delayFlex['period'], new CButton('remove', _('Remove'), 'javascript: removeDelayFlex(' . $i . ');', 'link_menu'))); $row->setAttribute('id', 'delayFlex_' . $i); $delayFlexTable->addRow($row); // limit count of intervals, 7 intervals by 30 symbols = 210 characters, db storage field is 256 $i++; if ($i == 7) { $this->data['maxReached'] = true; break; } } $itemFormList->addRow(_('Flexible intervals'), new CDiv($delayFlexTable, 'objectgroup inlineblock border_dotted ui-corner-all'), false, 'row_flex_intervals'); // append new flexible interval to form list $newFlexInt = new CSpan(array(_('Interval (in sec)'), SPACE, new CNumericBox('new_delay_flex[delay]', $this->data['new_delay_flex']['delay'], 5, 'no', false, false), SPACE, _('Period'), SPACE, new CTextBox('new_delay_flex[period]', $this->data['new_delay_flex']['period'], 20), SPACE, new CButton('add_delay_flex', _('Add'), null, 'formlist'))); $newFlexInt->setAttribute('id', 'row-new-delay-flex-fields'); $maxFlexMsg = new CSpan(_('Maximum number of flexible intervals added'), 'red'); $maxFlexMsg->setAttribute('id', 'row-new-delay-flex-max-reached'); $maxFlexMsg->setAttribute('style', 'display: none;'); $itemFormList->addRow(_('New flexible interval'), array($newFlexInt, $maxFlexMsg), false, 'row_new_delay_flex', 'new');
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); } }
CArrayHelper::sort($linkedTemplates, array('name')); // templates for normal hosts if (!$isDiscovered) { $linkedTemplateTable->setHeader(array(_('Name'), _('Action'))); $ignoredTemplates = array(); foreach ($linkedTemplates as $template) { $tmplList->addVar('templates[]', $template['templateid']); $linkedTemplateTable->addRow(array($template['name'], array(new CSubmit('unlink[' . $template['templateid'] . ']', _('Unlink'), null, 'link_menu'), SPACE, SPACE, isset($original_templates[$template['templateid']]) ? new CSubmit('unlink_and_clear[' . $template['templateid'] . ']', _('Unlink and clear'), null, 'link_menu') : SPACE)), null, 'conditions_' . $template['templateid']); $ignoredTemplates[$template['templateid']] = $template['name']; } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); // create new linked template table $newTemplateTable = new CTable(null, 'formElementTable'); $newTemplateTable->attr('id', 'newTemplateTable'); $newTemplateTable->attr('style', 'min-width: 400px;'); $newTemplateTable->addRow(array(new CMultiSelect(array('name' => 'add_templates[]', 'objectName' => 'templates', 'ignored' => $ignoredTemplates)))); $newTemplateTable->addRow(array(new CSubmit('add_template', _('Add'), null, 'link_menu'))); $tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); } else { $linkedTemplateTable->setHeader(array(_('Name'))); foreach ($linkedTemplates as $template) { $linkedTemplateTable->addRow(array($template['name']), null, 'conditions_' . $template['templateid']); } $tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all')); } $divTabs->addTab('templateTab', _('Templates'), $tmplList); /* * IPMI */ $ipmiList = new CFormList('ipmilist'); // normal hosts
public function bodyToString() { $res = parent::bodyToString(); $tbl = new CTable(null, $this->tableclass); $tbl->setCellSpacing(0); $tbl->setCellPadding(1); $tbl->setAlign($this->align); // add first row if (!is_null($this->title)) { $col = new CCol(null, 'form_row_first'); $col->setColSpan(2); if (isset($this->help)) { $col->addItem($this->help); } if (isset($this->title)) { $col->addItem($this->title); } $tbl->setHeader($col); } // add last row $tbl->setFooter($this->bottom_items); // add center rows foreach ($this->center_items as $item) { $tbl->addRow($item); } return $res . $tbl->toString(); }
$frmPd->addVar('config', $config); $frmPd->addVar('report_timesince', $report_timesince); $frmPd->addVar('report_timetill', $report_timetill); if (isset($_REQUEST['period_id'])) { $frmPd->addVar('period_id', $_REQUEST['period_id']); } $frmPd->addRow(array(new CVisibilityBox('caption_visible', !zbx_empty($caption), 'caption', S_DEFAULT), S_CAPTION), new CTextBox('caption', $caption, 10)); // $frmPd->addRow(S_CAPTION, new CTextBox('caption',$caption,10)); //* $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer'); $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);"); $reporttimetab = new CTable(null, 'calendar'); $reporttimetab->setAttribute('width', '10%'); $reporttimetab->setCellPadding(0); $reporttimetab->setCellSpacing(0); $reporttimetab->addRow(array(S_FROM, new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2), $clndr_icon)); zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");'); $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);"); $reporttimetab->addRow(array(S_TILL, new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2), $clndr_icon)); zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");'); $frmPd->addRow(S_PERIOD, $reporttimetab); //*/ if ($config != 1) { $frmPd->addRow(S_COLOR, new CColor('color', $color)); } else { $frmPd->addVar('color', $color); } $frmPd->addItemToBottomRow(new CButton('save', isset($_REQUEST['period_id']) ? S_UPDATE : S_ADD)); $frmPd->addItemToBottomRow(new CButtonCancel(null, 'close_window();')); $frmPd->Show(); }
function get_event_actions_stat_hints($eventid) { $actions = new CTable(' - '); $sql = 'SELECT COUNT(a.alertid) as cnt ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')'; $alerts = DBfetch(DBselect($sql)); if (isset($alerts['cnt']) && $alerts['cnt'] > 0) { $sql = 'SELECT COUNT(a.alertid) as sent ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND a.status=' . ALERT_STATUS_SENT; $alerts = DBfetch(DBselect($sql)); $alert_cnt = new CSpan($alerts['sent'], 'green'); if ($alerts['sent']) { $hint = get_actions_hint_by_eventid($eventid, ALERT_STATUS_SENT); $alert_cnt->SetHint($hint); } $tdl = new CCol($alerts['sent'] ? $alert_cnt : SPACE); $tdl->addOption('width', '10'); $sql = 'SELECT COUNT(a.alertid) as inprogress ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND a.status=' . ALERT_STATUS_NOT_SENT; $alerts = DBfetch(DBselect($sql)); $alert_cnt = new CSpan($alerts['inprogress'], 'orange'); if ($alerts['inprogress']) { $hint = get_actions_hint_by_eventid($eventid, ALERT_STATUS_NOT_SENT); $alert_cnt->setHint($hint); } $tdc = new CCol($alerts['inprogress'] ? $alert_cnt : SPACE); $tdc->addOption('width', '10'); $sql = 'SELECT COUNT(a.alertid) as failed ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND a.status=' . ALERT_STATUS_FAILED; $alerts = DBfetch(DBselect($sql)); $alert_cnt = new CSpan($alerts['failed'], 'red'); if ($alerts['failed']) { $hint = get_actions_hint_by_eventid($eventid, ALERT_STATUS_FAILED); $alert_cnt->setHint($hint); } $tdr = new CCol($alerts['failed'] ? $alert_cnt : SPACE); $tdr->addOption('width', '10'); $actions->addRow(array($tdl, $tdc, $tdr)); } return $actions; }
} $left_tab = new CTable(); $left_tab->setCellPadding(3); $left_tab->setCellSpacing(3); $left_tab->setAttribute('border', 0); $left_tab->addRow(create_hat(S_MAINTENANCE, get_maintenance_form(), null, 'hat_maintenance')); $left_tab->addRow(create_hat(S_MAINTENANCE_PERIODS, get_maintenance_periods(), null, 'hat_timeperiods')); if (isset($_REQUEST['new_timeperiod'])) { $new_timeperiod = $_REQUEST['new_timeperiod']; $left_tab->addRow(create_hat(is_array($new_timeperiod) && isset($new_timeperiod['id']) ? S_EDIT_MAINTENANCE_PERIOD : S_NEW_MAINTENANCE_PERIOD, get_timeperiod_form(), null, 'hat_new_timeperiod')); } $right_tab = new CTable(); $right_tab->setCellPadding(3); $right_tab->setCellSpacing(3); $right_tab->setAttribute('border', 0); $right_tab->addRow(create_hat(S_HOSTS_IN_MAINTENANCE, get_maintenance_hosts_form($frmMaintenance), null, 'hat_host_link')); $right_tab->addRow(create_hat(S_GROUPS_IN_MAINTENANCE, get_maintenance_groups_form($frmMaintenance), null, 'hat_group_link')); $td_l = new CCol($left_tab); $td_l->setAttribute('valign', 'top'); $td_r = new CCol($right_tab); $td_r->setAttribute('valign', 'top'); $outer_table = new CTable(); $outer_table->setAttribute('border', 0); $outer_table->setCellPadding(1); $outer_table->setCellSpacing(1); $outer_table->addRow(array($td_l, $td_r)); $frmMaintenance->additem($outer_table); show_messages(); $frmMaintenance->show(); // insert_maintenance_form(); } else {
} $logo = new CLink(new CDiv(SPACE, 'zabbix_logo'), 'http://www.zabbix.com/', 'image', null, 'nosid'); $logo->setTarget('_blank'); $td_r = new CCol($page_header_r_col, 'page_header_r'); $td_r->setAttribute('width', '100%'); $top_page_row = array(new CCol($logo, 'page_header_l'), $td_r); unset($logo, $page_header_r_col, $help, $support); $table = new CTable(NULL, 'page_header'); $table->setCellSpacing(0); $table->setCellPadding(5); $table->addRow($top_page_row); $table->show(); $menu_table = new CTable(NULL, 'menu'); $menu_table->setCellSpacing(0); $menu_table->setCellPadding(5); $menu_table->addRow($main_menu); $node_form = null; if (ZBX_DISTRIBUTED && !defined('ZBX_HIDE_NODE_SELECTION')) { insert_js_function('check_all'); $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_DATA_ARRAY); $available_nodes = get_tree_by_parentid($ZBX_LOCALNODEID, $available_nodes, 'masterid'); //remove parent nodes if (!empty($available_nodes)) { $node_form = new CForm(); $node_form->setMethod('get'); $node_form->setAttribute('id', 'node_form'); // +++ create Combo Box with selected nodes +++ $combo_node_list = null; if (count($ZBX_VIEWED_NODES['nodes']) > 0) { $combo_node_list = new CComboBox('switch_node', $ZBX_VIEWED_NODES['selected'], 'submit()'); foreach ($ZBX_VIEWED_NODES['nodes'] as $nodeid => $nodedata) {
require_once dirname(__FILE__) . '/include/services.inc.php'; $page['title'] = _('IT services'); $page['file'] = 'srv_status.php'; $page['hist_arg'] = array(); define('ZBX_PAGE_DO_REFRESH', 1); require_once dirname(__FILE__) . '/include/page_header.php'; $periods = array('today' => _('Today'), 'week' => _('This week'), 'month' => _('This month'), 'year' => _('This year'), 24 => _('Last 24 hours'), 24 * 7 => _('Last 7 days'), 24 * 30 => _('Last 30 days'), 24 * DAY_IN_YEAR => _('Last 365 days')); // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('serviceid' => array(T_ZBX_INT, O_OPT, P_SYS | P_NZERO, DB_ID, null), 'showgraph' => array(T_ZBX_INT, O_OPT, P_SYS, IN('1'), 'isset({serviceid})'), 'period' => array(T_ZBX_STR, O_OPT, P_SYS, IN('"' . implode('","', array_keys($periods)) . '"'), null), 'fullscreen' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null)); check_fields($fields); if (isset($_REQUEST['serviceid']) && isset($_REQUEST['showgraph'])) { $service = API::Service()->get(array('output' => array('serviceid'), 'serviceids' => getRequest('serviceid'))); $service = reset($service); if ($service) { $table = new CTable(null, 'chart'); $table->addRow(new CImg('chart5.php?serviceid=' . $service['serviceid'] . url_param('path'))); $table->show(); } else { access_deny(); } } else { $period = getRequest('period', 7 * 24); $period_end = time(); switch ($period) { case 'today': $period_start = mktime(0, 0, 0, date('n'), date('j'), date('Y')); break; case 'week': $period_start = strtotime('last sunday'); break; case 'month':
function get_timeperiod_form() { $tblPeriod = new CTable(null, 'formElementTable'); // init new_timeperiod variable $new_timeperiod = getRequest('new_timeperiod', array()); $new = is_array($new_timeperiod); if (is_array($new_timeperiod)) { if (isset($new_timeperiod['id'])) { $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id'])); } if (isset($new_timeperiod['timeperiodid'])) { $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid'])); } } if (!is_array($new_timeperiod)) { $new_timeperiod = array(); $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME; } if (!isset($new_timeperiod['every'])) { $new_timeperiod['every'] = 1; } if (!isset($new_timeperiod['day'])) { $new_timeperiod['day'] = 1; } if (!isset($new_timeperiod['hour'])) { $new_timeperiod['hour'] = 12; } if (!isset($new_timeperiod['minute'])) { $new_timeperiod['minute'] = 0; } if (!isset($new_timeperiod['start_date'])) { $new_timeperiod['start_date'] = 0; } if (!isset($new_timeperiod['period_days'])) { $new_timeperiod['period_days'] = 0; } if (!isset($new_timeperiod['period_hours'])) { $new_timeperiod['period_hours'] = 1; } if (!isset($new_timeperiod['period_minutes'])) { $new_timeperiod['period_minutes'] = 0; } if (!isset($new_timeperiod['month_date_type'])) { $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day']; } // start time if (isset($new_timeperiod['start_time'])) { $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR); $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN); } // period if (isset($new_timeperiod['period'])) { $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY); $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR); $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN); } // daysofweek $dayofweek = ''; $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1'; $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1'; if (isset($new_timeperiod['dayofweek'])) { $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true); } $new_timeperiod['dayofweek_mo'] = $dayofweek[0]; $new_timeperiod['dayofweek_tu'] = $dayofweek[1]; $new_timeperiod['dayofweek_we'] = $dayofweek[2]; $new_timeperiod['dayofweek_th'] = $dayofweek[3]; $new_timeperiod['dayofweek_fr'] = $dayofweek[4]; $new_timeperiod['dayofweek_sa'] = $dayofweek[5]; $new_timeperiod['dayofweek_su'] = $dayofweek[6]; // months $month = ''; $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_may']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1'; $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1'; if (isset($new_timeperiod['month'])) { $month = zbx_num2bitstr($new_timeperiod['month'], true); } $new_timeperiod['month_jan'] = $month[0]; $new_timeperiod['month_feb'] = $month[1]; $new_timeperiod['month_mar'] = $month[2]; $new_timeperiod['month_apr'] = $month[3]; $new_timeperiod['month_may'] = $month[4]; $new_timeperiod['month_jun'] = $month[5]; $new_timeperiod['month_jul'] = $month[6]; $new_timeperiod['month_aug'] = $month[7]; $new_timeperiod['month_sep'] = $month[8]; $new_timeperiod['month_oct'] = $month[9]; $new_timeperiod['month_nov'] = $month[10]; $new_timeperiod['month_dec'] = $month[11]; $bit_dayofweek = strrev($dayofweek); $bit_month = strrev($month); $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()'); $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only')); $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily')); $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly')); $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly')); $tblPeriod->addRow(array(_('Period type'), $cmbType)); if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) { $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month))); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3))); } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) { $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month))); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2))); $tabDays = new CTable(); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday'))); $tblPeriod->addRow(array(_('Day of week'), $tabDays)); } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) { $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tabMonths = new CTable(); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November'))); $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December'))); $tblPeriod->addRow(array(_('Month'), $tabMonths)); $tblPeriod->addRow(array(_('Date'), array(new CRadioButton('new_timeperiod[month_date_type]', '0', null, null, !$new_timeperiod['month_date_type'], 'submit()'), _('Day'), SPACE, new CRadioButton('new_timeperiod[month_date_type]', '1', null, null, $new_timeperiod['month_date_type'], 'submit()'), _('Day of week')))); if ($new_timeperiod['month_date_type'] > 0) { $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'])); $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']); $cmbCount->addItem(1, _('First')); $cmbCount->addItem(2, _('Second')); $cmbCount->addItem(3, _('Third')); $cmbCount->addItem(4, _('Fourth')); $cmbCount->addItem(5, _('Last')); $td = new CCol($cmbCount); $td->setColSpan(2); $tabDays = new CTable(); $tabDays->addRow($td); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday'))); $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday'))); $tblPeriod->addRow(array(_('Day of week'), $tabDays)); } else { $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2))); } } else { $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp')); $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date'])); $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type'])); $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek))); if (isset($_REQUEST['add_timeperiod'])) { $date = array('y' => getRequest('new_timeperiod_start_date_year'), 'm' => getRequest('new_timeperiod_start_date_month'), 'd' => getRequest('new_timeperiod_start_date_day'), 'h' => getRequest('new_timeperiod_start_date_hour'), 'i' => getRequest('new_timeperiod_start_date_minute')); } else { $date = zbxDateToTime($new_timeperiod['start_date'] ? $new_timeperiod['start_date'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time())); } $tblPeriod->addRow(array(_('Date'), createDateSelector('new_timeperiod_start_date', $date))); } if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) { $tblPeriod->addRow(array(_('At (hour:minute)'), array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2)))); } $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours'], null, range(0, 23)); $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes'], null, range(0, 59)); $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, _('Hours') . SPACE . SPACE, $perMinutes, _('Minutes')))); return $tblPeriod; }
$dependenciesTable->setHeader(array(_('Name'), _('Action'))); foreach ($this->data['dependencies'] as $dependency) { $triggersForm->addVar('dependencies[]', $dependency['triggerid'], 'dependencies_' . $dependency['triggerid']); $hostNames = array(); foreach ($dependency['hosts'] as $host) { $hostNames[] = CHtml::encode($host['name']); $hostNames[] = ', '; } array_pop($hostNames); if ($dependency['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $description = new CLink(array($hostNames, NAME_DELIMITER, CHtml::encode($dependency['description'])), 'triggers.php?form=update&hostid=' . $dependency['hostid'] . '&triggerid=' . $dependency['triggerid']); $description->setAttribute('target', '_blank'); } else { $description = array($hostNames, NAME_DELIMITER, $dependency['description']); } $row = new CRow(array($description, new CButton('remove', _('Remove'), 'javascript: removeDependency(\'' . $dependency['triggerid'] . '\');', 'link_menu'))); $row->setAttribute('id', 'dependency_' . $dependency['triggerid']); $dependenciesTable->addRow($row); } $dependenciesDiv = new CDiv(array($dependenciesTable, new CButton('btn1', _('Add'), 'return PopUp("popup.php?' . 'dstfrm=massupdate' . '&dstact=add_dependency' . '&reference=deptrigger' . '&dstfld1=new_dependency' . '&srctbl=triggers' . '&objname=triggers' . '&srcfld1=triggerid' . '&multiselect=1' . '&with_triggers=1", 1000, 700);', 'link_menu')), 'objectgroup inlineblock border_dotted ui-corner-all'); $dependenciesDiv->setAttribute('id', 'dependencies_div'); $triggersFormList->addRow(array(_('Replace dependencies'), SPACE, new CVisibilityBox('visible[dependencies]', isset($this->data['visible']['dependencies']), 'dependencies_div', _('Original'))), $dependenciesDiv); } // append tabs to form $triggersTab = new CTabView(); $triggersTab->addTab('triggersTab', _('Mass update'), $triggersFormList); $triggersForm->addItem($triggersTab); // append buttons to form $triggersForm->addItem(makeFormFooter(new CSubmit('massupdate', _('Update')), new CButtonCancel(url_params(array('groupid', 'hostid', 'parent_discoveryid'))))); $triggersWidget->addItem($triggersForm); return $triggersWidget;
$hintTable->addRow(array(new CCol(SPACE, 'normal'), _('OK'))); } for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) { $hintTable->addRow(array(getSeverityCell($i), _('PROBLEM'))); } $config = select_config(); if ($this->data['type'] == SHOW_TRIGGERS) { // blinking preview in help popup (only if blinking is enabled) if ($config['blink_period'] > 0) { $row = new CRow(null); $row->addItem(new CCol(SPACE, 'normal')); for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) { $row->addItem(new CCol(SPACE, getSeverityStyle($i))); } $col = new CTable('', 'blink overview-mon-severities'); $col->addRow($row); // double div necassary for FireFox $col = new CCol(new CDiv(new CDiv($col), 'overview-mon-severities-container')); $hintTable->addRow(array($col, _s('Age less than %s', convertUnitsS($config['blink_period'])))); } $hintTable->addRow(array(new CCol(SPACE), _('No trigger'))); } else { $hintTable->addRow(array(new CCol(SPACE), _('OK or no trigger'))); } $help = new CHelp('web.view.php', 'right'); $help->setHint($hintTable, '', '', true, false); // header right $overviewWidget->addPageHeader(_('OVERVIEW'), array(get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen'])), SPACE, $help)); // header left $styleComboBox = new CComboBox('view_style', $this->data['view_style'], 'submit()'); $styleComboBox->addItem(STYLE_TOP, _('Top'));
$res_table->setOddRowClass('even_row'); $res_table->setEvenRowClass('even_row'); $res_table->setHeader(array(_('Expression'), _('Result'))); ksort($rplcts, SORT_NUMERIC); foreach ($eHTMLTree as $e) { $result = '-'; if ($allowedTesting && $test && isset($e['expression'])) { $result = evalExpressionData($e['expression']['value'], $macrosData, $octet); } $style = 'text-align: center;'; if ($result != '-') { $style = $result == 'TRUE' ? 'background-color: #ccf; color: #00f;' : 'background-color: #fcc; color: #f00;'; } $col = new CCol($result); $col->setAttribute('style', $style); $res_table->addRow(new CRow(array($e['list'], $col))); } $result = '-'; if ($allowedTesting && $test) { $result = evalExpressionData($expression, $macrosData, $octet); } $style = 'text-align: center;'; if ($result != '-') { $style = $result == 'TRUE' ? 'background-color: #ccf; color: #00f;' : 'background-color: #fcc; color: #f00;'; } $col = new CCol($result); $col->setAttribute('style', $style); $res_table->setFooter(array($outline, $col), $res_table->headerClass); $frm_test->addRow(_('Result'), $res_table); // action buttons $btn_test = new CSubmit('test_expression', _('Test'));
$rForm = new CForm('get'); $rForm->addItem(array(_('Group'), SPACE, $this->data['pageFilter']->getGroupsCB())); $hostInventoryWidget->addPageHeader(_('HOST INVENTORY'), SPACE); $hostInventoryWidget->addHeader(_('Hosts'), $rForm); $filterTable = new CTable('', 'filter filter-center'); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('filter_field', $this->data['filterField']); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title']); } $exactComboBox = new CComboBox('filter_exact', $this->data['filterExact']); $exactComboBox->addItem('0', _('like')); $exactComboBox->addItem('1', _('exactly')); $filterTable->addRow(array(array(array(bold(_('Field')), SPACE, $inventoryFieldsComboBox), array($exactComboBox, new CTextBox('filter_field_value', $this->data['filterFieldValue'], 20)))), 'host-inventories'); $filter = new CSubmit('filter_set', _('Filter')); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset')); $reset->useJQueryStyle(); $divButtons = new CDiv(array($filter, SPACE, $reset)); $divButtons->setAttribute('style', 'padding: 4px 0px;'); $footerCol = new CCol($divButtons, 'controls'); $filterTable->addRow($footerCol); $filterForm = new CForm('get'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterForm->addItem($filterTable); $hostInventoryWidget->addFlicker($filterForm, CProfile::get('web.hostinventories.filter.state', 0)); $hostInventoryWidget->addHeaderRowNumber(); $table = new CTableInfo(_('No hosts found.'));
$groups_count = CHostGroup::get($params); $overalCount = $groups_count['rowscount']; $viewCount = count($hostGroups); $header = array(is_show_all_nodes() ? new CCol(S_NODE) : null, new CCol(S_HOST_GROUP), new CCol(S_LATEST_DATA), new CCol(S_TRIGGERS), new CCol(S_EVENTS), $admin ? new CCol(S_EDIT) : null); $table = new CTableInfo(); $table->setHeader($header); foreach ($hostGroups as $num => $group) { $hostgroupid = $group['groupid']; $caption = make_decoration($group['name'], $search); $admin_link = $admin ? new CLink(S_GO, 'hosts.php?config=1&groupid=' . $hostgroupid . '&hostid=0') : null; $table->addRow(array(get_node_name_by_elid($hostgroupid), $caption, new CLink(S_GO, 'latest.php?groupid=' . $hostgroupid . '&hostid=0'), new CLink(S_GO, 'tr_status.php?groupid=' . $hostgroupid . '&hostid=0'), new CLink(S_GO, 'events.php?groupid=' . $hostgroupid . '&hostid=0'), $admin_link)); } $table->setFooter(new CCol(S_DISPLAYING . SPACE . $viewCount . SPACE . S_OF_SMALL . SPACE . $overalCount . SPACE . S_FOUND_SMALL)); $wdgt_hgroups = new CWidget('search_hostgroup', $table); $wdgt_hgroups->addHeader(S_HOST_GROUPS, SPACE); $right_tab->addRow($wdgt_hgroups); //---------------- // FIND Templates if ($admin) { $params = array('nodeid' => get_current_nodeid(), 'extendoutput' => 1, 'pattern' => $search, 'limit' => $rows_per_page, 'order' => 'host', 'editable' => 1); $db_templates = CTemplate::get($params); $templates = selectByPattern($db_templates, 'host', $search, $rows_per_page); $templateids = array_keys($templates); $hostsgroups = array(); $sql = 'SELECT * FROM hosts_groups hg WHERE ' . DBcondition('hg.hostid', $templateids); $res = DBselect($sql); while ($templategroup = DBfetch($res)) { $hostsgroups[$templategroup['hostid']] = $templategroup['groupid']; } $params = array('nodeids' => get_current_nodeid(), 'pattern' => $search, 'count' => 1, 'editable' => 1); $hosts_count = CTemplate::get($params);
$proxyFormList = new CFormList('proxyFormList'); $nameTextBox = new CTextBox('host', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 64); $nameTextBox->attr('autofocus', 'autofocus'); $proxyFormList->addRow(_('Proxy name'), $nameTextBox); // append status to form list $statusBox = new CComboBox('status', $this->data['status'], 'submit()'); $statusBox->addItem(HOST_STATUS_PROXY_ACTIVE, _('Active')); $statusBox->addItem(HOST_STATUS_PROXY_PASSIVE, _('Passive')); $proxyFormList->addRow(_('Proxy mode'), $statusBox); if ($this->data['status'] == HOST_STATUS_PROXY_PASSIVE) { if (isset($this->data['interface']['interfaceid'])) { $proxyForm->addVar('interface[interfaceid]', $this->data['interface']['interfaceid']); $proxyForm->addVar('interface[hostid]', $this->data['interface']['hostid']); } $interfaceTable = new CTable(null, 'formElementTable'); $interfaceTable->addRow(array(_('IP address'), _('DNS name'), _('Connect to'), _('Port'))); $connectByComboBox = new CRadioButtonList('interface[useip]', $this->data['interface']['useip']); $connectByComboBox->addValue(_('IP'), 1); $connectByComboBox->addValue(_('DNS'), 0); $connectByComboBox->useJQueryStyle(); $interfaceTable->addRow(array(new CTextBox('interface[ip]', $this->data['interface']['ip'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), new CTextBox('interface[dns]', $this->data['interface']['dns'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), $connectByComboBox, new CTextBox('interface[port]', $this->data['interface']['port'], 18, 'no', 64))); $proxyFormList->addRow(_('Interface'), new CDiv($interfaceTable, 'objectgroup inlineblock border_dotted ui-corner-all')); } // append hosts to form list $hostsTweenBox = new CTweenBox($proxyForm, 'hosts', $this->data['hosts']); foreach ($this->data['dbHosts'] as $host) { // show only normal hosts, and discovered hosts monitored by the current proxy // for new proxies display only normal hosts if ($this->data['proxyid'] && idcmp($this->data['proxyid'], $host['proxy_hostid']) || $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) { $hostsTweenBox->addItem($host['hostid'], $host['name'], null, empty($host['proxy_hostid']) || !empty($this->data['proxyid']) && bccomp($host['proxy_hostid'], $this->data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL); }
foreach ($allowedOpConditions as $opcondition) { $conditionTypeComboBox->addItem($opcondition, condition_type2str($opcondition)); } array_push($rowCondition, $conditionTypeComboBox); $operationConditionComboBox = new CComboBox('new_opcondition[operator]'); foreach (get_operators_by_conditiontype($new_opcondition['conditiontype']) as $operationCondition) { $operationConditionComboBox->addItem($operationCondition, condition_operator2str($operationCondition)); } array_push($rowCondition, $operationConditionComboBox); if ($new_opcondition['conditiontype'] == CONDITION_TYPE_EVENT_ACKNOWLEDGED) { $operationConditionValueComboBox = new CComboBox('new_opcondition[value]', $new_opcondition['value']); $operationConditionValueComboBox->addItem(0, _('Not Ack')); $operationConditionValueComboBox->addItem(1, _('Ack')); $rowCondition[] = $operationConditionValueComboBox; } $newOperationConditionTable->addRow($rowCondition); $newOperationConditionFooter = array(new CSubmit('add_opcondition', _('Add'), null, 'link_menu'), SPACE . SPACE, new CSubmit('cancel_new_opcondition', _('Cancel'), null, 'link_menu')); $newOperationsTable->addRow(array(_('Operation condition'), new CDiv(array($newOperationConditionTable, $newOperationConditionFooter), 'objectgroup inlineblock border_dotted ui-corner-all'))); } $footer = array(new CSubmit('add_operation', $this->data['new_operation']['action'] == 'update' ? _('Update') : _('Add'), null, 'link_menu'), SPACE . SPACE, new CSubmit('cancel_new_operation', _('Cancel'), null, 'link_menu')); $operationFormList->addRow(_('Operation details'), new CDiv(array($newOperationsTable, $footer), 'objectgroup inlineblock border_dotted ui-corner-all')); } // append tabs to form $actionTabs = new CTabView(); if (!isset($_REQUEST['form_refresh'])) { $actionTabs->setSelected(0); } $actionTabs->addTab('actionTab', _('Action'), $actionFormList); $actionTabs->addTab('conditionTab', _('Conditions'), $conditionFormList); $actionTabs->addTab('operationTab', _('Operations'), $operationFormList); $actionForm->addItem($actionTabs);
function stage5() { $dbType = $this->getConfig('DB_TYPE'); $frontendSetup = new FrontendSetup(); $databases = $frontendSetup->getSupportedDatabases(); $table = new CTable(null, 'requirements'); $table->setAlign('center'); $table->addRow(array(new CCol(_('Database type'), 'header'), $databases[$dbType])); switch ($dbType) { case ZBX_DB_SQLITE3: $table->addRow(array(new CCol(_('Database file'), 'header'), $this->getConfig('DB_DATABASE'))); break; default: $table->addRow(array(new CCol(_('Database server'), 'header'), $this->getConfig('DB_SERVER'))); $dbPort = $this->getConfig('DB_PORT'); $table->addRow(array(new CCol(_('Database port'), 'header'), $dbPort == 0 ? _('default') : $dbPort)); $table->addRow(array(new CCol(_('Database name'), 'header'), $this->getConfig('DB_DATABASE'))); $table->addRow(array(new CCol(_('Database user'), 'header'), $this->getConfig('DB_USER'))); $table->addRow(array(new CCol(_('Database password'), 'header'), preg_replace('/./', '*', $this->getConfig('DB_PASSWORD')))); if ($dbType == ZBX_DB_DB2) { $table->addRow(array(new CCol(_('Database schema'), 'header'), $this->getConfig('DB_SCHEMA'))); } break; } $table->addRow(BR()); $table->addRow(array(new CCol(_('Zabbix server'), 'header'), $this->getConfig('ZBX_SERVER'))); $table->addRow(array(new CCol(_('Zabbix server port'), 'header'), $this->getConfig('ZBX_SERVER_PORT'))); $table->addRow(array(new CCol(_('Zabbix server name'), 'header'), $this->getConfig('ZBX_SERVER_NAME'))); return array('Please check configuration parameters.', BR(), 'If all is correct, press "Next" button, or "Previous" button to change configuration parameters.', BR(), BR(), $table); }
private function createFlicker($col1, $col2 = null) { $table = new CTable(null, 'textwhite maxwidth middle flicker'); $table->setCellSpacing(0); $table->setCellPadding(1); if (!is_null($col2)) { $td_r = new CCol($col2, 'flicker_r'); $td_r->setAttribute('align', 'right'); $table->addRow(array(new CCol($col1, 'flicker_l'), $td_r)); } else { $td_c = new CCol($col1, 'flicker_c'); $td_c->setAttribute('align', 'center'); $table->addRow($td_c); } return $table; }
$fs_icon = new CDiv(SPACE, 'fullscreen'); $fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN); $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';")); //------- $left_tab = new CTable(); $left_tab->setCellPadding(3); $left_tab->setCellSpacing(3); $left_tab->addOption('border', 0); $left_tab->addRow(create_hat(S_EVENT . SPACE . S_SOURCE . SPACE . S_DETAILS, make_trigger_details($_REQUEST['triggerid'], $trigger_data), null, 'hat_triggerdetails')); $left_tab->addRow(create_hat(S_EVENT_DETAILS, make_event_details($_REQUEST['eventid']), null, 'hat_eventdetails')); $right_tab = new CTable(); $right_tab->setCellPadding(3); $right_tab->setCellSpacing(3); $right_tab->addOption('border', 0); $right_tab->addRow(create_hat(S_ACKNOWLEDGES, make_acktab_by_eventid($_REQUEST['eventid']), null, 'hat_eventack', get_profile('web.tr_events.hats.hat_eventack.state', 1))); $right_tab->addRow(create_hat(S_MESSAGE_ACTIONS, get_action_msgs_for_event($_REQUEST['eventid']), null, 'hat_eventactionmsgs', get_profile('web.tr_events.hats.hat_eventactionmsgs.state', 1))); $right_tab->addRow(create_hat(S_COMMAND_ACTIONS, get_action_cmds_for_event($_REQUEST['eventid']), null, 'hat_eventactioncmds', get_profile('web.tr_events.hats.hat_eventactioncmds.state', 1))); $right_tab->addRow(create_hat(S_EVENTS . SPACE . S_LIST . SPACE . '[' . S_LAST . ' 20]', make_small_eventlist($_REQUEST['triggerid'], $trigger_data), null, 'hat_eventlist', get_profile('web.tr_events.hats.hat_eventlist.state', 1))); $td_l = new CCol($left_tab); $td_l->addOption('valign', 'top'); $td_r = new CCol($right_tab); $td_r->addOption('valign', 'top'); $outer_table = new CTable(); $outer_table->addOption('border', 0); $outer_table->setCellPadding(1); $outer_table->setCellSpacing(1); $outer_table->addRow(array($td_l, $td_r)); $p_elements[] = $outer_table; $latest_hat = create_hat($text, $p_elements, array($fs_icon), 'hat_tr_events', get_profile('web.tr_events.hats.hat_tr_events.state', 1)); $latest_hat->show(); include_once 'include/page_footer.php';
$this->data['widget']->addHeader(_('Images'), $imageComboBoxForm); // form $imageForm = new CForm(); $imageForm->setName('imageForm'); $imageForm->addItem(BR()); $imageTable = new CTable(_('No images found.'), 'header_wide padding_standard'); $count = 0; $imageRow = new CRow(); foreach ($this->data['images'] as $image) { $img = $image['imagetype'] == IMAGE_TYPE_BACKGROUND ? new CLink(new CImg('imgstore.php?width=200&height=200&iconid=' . $image['imageid'], 'no image'), 'image.php?imageid=' . $image['imageid']) : new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image'); $nodeName = $this->data['displayNodes'] ? new CSpan($image['nodename'], 'unknown') : null; $name = new CLink($image['name'], 'adm.images.php?form=update&imageid=' . $image['imageid']); $imgColumn = new CCol(); $imgColumn->setAttribute('align', 'center'); $imgColumn->addItem(array($img, BR(), $nodeName, $name), 'center'); $imageRow->addItem($imgColumn); $count++; if ($count % 4 == 0) { $imageTable->addRow($imageRow); $imageRow = new CRow(); } } if ($count > 0) { while ($count % 4 != 0) { $imageRow->addItem(SPACE); $count++; } $imageTable->addRow($imageRow); } $imageForm->addItem($imageTable); return $imageForm;
$_REQUEST['filter_field'] = CProfile::get('web.hostinventories.filter_field'); $_REQUEST['filter_field_value'] = CProfile::get('web.hostinventories.filter_field_value'); $_REQUEST['filter_exact'] = CProfile::get('web.hostinventories.filter_exact'); } $filter_table = new CTable('', 'filter'); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('filter_field', $_REQUEST['filter_field']); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title']); } $exactComboBox = new CComboBox('filter_exact', $_REQUEST['filter_exact']); $exactComboBox->addItem('0', _('like')); $exactComboBox->addItem('1', _('exactly')); $filter_table->addRow(array(array(array(bold(_('Field:')), $inventoryFieldsComboBox), array($exactComboBox, new CTextBox('filter_field_value', $_REQUEST['filter_field_value'], 20))))); $filter = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $filter->useJQueryStyle('main'); $reset = new CButton('reset', _('Reset'), "javascript: clearAllForm('zbx_filter');"); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer_col = new CCol($div_buttons, 'controls'); $filter_table->addRow($footer_col); $filter_form = new CForm('get'); $filter_form->setAttribute('name', 'zbx_filter'); $filter_form->setAttribute('id', 'zbx_filter'); $filter_form->addItem($filter_table); $hostinvent_wdgt->addFlicker($filter_form, CProfile::get('web.hostinventories.filter.state', 0)); $hostinvent_wdgt->addHeaderRowNumber(); $table = new CTableInfo(_('No hosts defined.'));
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); } }