本文整理汇总了PHP中CRow::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP CRow::addItem方法的具体用法?PHP CRow::addItem怎么用?PHP CRow::addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRow
的用法示例。
在下文中一共展示了CRow::addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getContent
public function _getContent($refresh = false)
{
if (!isset($this->config['sql'])) {
return "SQL not set";
}
$table = new CTableInfo($this->emptyText);
$resultSet = DBselect($this->config['sql']);
$result = DbFetchArray($resultSet);
if (!empty($this->columns)) {
$headers = array();
foreach ($this->columns as $column) {
$headers[] = !empty($column['name']) ? $column['name'] : $column['field'];
}
} else {
if (isset($result[0])) {
foreach ($result[0] as $key => $value) {
$headers[] = $key;
$column = array('eval' => false, 'evalClass' => false, 'class' => null, 'width' => null, 'name' => $key, 'value' => $key);
$this->columns[] = $column;
}
} else {
$headers[] = "Empty Table";
}
}
if ($this->headers) {
$table->setHeader($headers);
}
$index = 0;
foreach ($result as $row) {
$row['index'] = $index++;
$crow = new CRow(null, $this->getRowClass($row));
foreach ($this->columns as $column) {
$cell = new CCol($this->getValue($column, $row), $this->getClass($column, $row));
$crow->addItem($cell);
}
$table->addRow($crow);
}
return $table;
}
示例2: CForm
$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;
示例3: getPermissionsFormList
function getPermissionsFormList($rights = array(), $user_type = USER_TYPE_ZABBIX_USER, $rightsFormList = null)
{
// group
$lists['group']['label'] = _('Host groups');
$lists['group']['read_write'] = new CListBox('groups_write', null, 15);
$lists['group']['read_only'] = new CListBox('groups_read', null, 15);
$lists['group']['deny'] = new CListBox('groups_deny', null, 15);
$groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY);
foreach ($groups as $group) {
switch ($group['permission']) {
case PERM_READ:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
}
$lists['group'][$list_name]->addItem($group['groupid'], $group['name']);
}
unset($groups);
// host
$lists['host']['label'] = _('Hosts');
$lists['host']['read_write'] = new CListBox('hosts_write', null, 15);
$lists['host']['read_only'] = new CListBox('hosts_read', null, 15);
$lists['host']['deny'] = new CListBox('hosts_deny', null, 15);
$hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY);
foreach ($hosts as $host) {
switch ($host['permission']) {
case PERM_READ:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
}
if (HOST_STATUS_PROXY_ACTIVE == $host['status'] || HOST_STATUS_PROXY_PASSIVE == $host['status']) {
$host['host_name'] = $host['host'];
}
$lists['host'][$list_name]->addItem($host['hostid'], $host['host_name']);
}
unset($hosts);
// display
if (empty($rightsFormList)) {
$rightsFormList = new CFormList('rightsFormList');
}
$isHeaderDisplayed = false;
foreach ($lists as $list) {
$sLabel = '';
$row = new CRow();
foreach ($list as $class => $item) {
if (is_string($item)) {
$sLabel = $item;
} else {
$row->addItem(new CCol($item, $class));
}
}
$table = new CTable(_('No accessible resources'), 'right_table calculated');
if (!$isHeaderDisplayed) {
$table->setHeader(array(_('Read-write'), _('Read only'), _('Deny')), 'header');
$isHeaderDisplayed = true;
}
$table->addRow($row);
$rightsFormList->addRow($sLabel, $table);
}
return $rightsFormList;
}
示例4: CRow
}
if (!isset($hosts_data[$group['groupid']])) {
$hosts_data[$group['groupid']] = ['problematic' => 0, 'ok' => 0, 'lastUnack' => 0];
}
if (!isset($problematic_host_list[$host['hostid']])) {
$hosts_data[$group['groupid']]['ok']++;
}
}
}
foreach ($groups as $group) {
if (!isset($hosts_data[$group['groupid']])) {
continue;
}
$group_row = new CRow();
$name = new CLink($group['name'], 'tr_status.php?filter_set=1&groupid=' . $group['groupid'] . '&hostid=0' . '&show_triggers=' . TRIGGERS_OPTION_RECENT_PROBLEM);
$group_row->addItem($name);
$group_row->addItem((new CCol($hosts_data[$group['groupid']]['ok']))->addClass(ZBX_STYLE_NORMAL_BG));
if ($data['filter']['extAck']) {
if ($hosts_data[$group['groupid']]['lastUnack']) {
$table_inf = new CTableInfo();
// set trigger severities as table header starting from highest severity
$header = [];
for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
$header[] = $data['filter']['severity'] === null || isset($data['filter']['severity'][$severity]) ? getSeverityName($severity, $data['config']) : null;
}
krsort($header);
array_unshift($header, _('Host'));
$table_inf->setHeader($header);
$popup_rows = 0;
foreach ($group['hosts'] as $host) {
$hostid = $host['hostid'];
示例5: CRow
$ifTab->setAttribute('id', 'JMXInterfaces');
$ifTab->setAttribute('data-type', 'jmx');
$row = new CRow(null, null, 'JMXIterfacesFooter');
if (!isset($existingInterfaceTypes[INTERFACE_TYPE_JMX])) {
$row->addItem(new CCol(null, 'interface-drag-control'));
$row->addItem(new CCol(_('No JMX interfaces found.'), null, 5));
}
$ifTab->addRow($row);
$hostList->addRow(_('JMX interfaces'), new CDiv($ifTab, 'border_dotted objectgroup interface-group'), false, null, 'interface-row');
// table for IPMI interfaces with footer
$ifTab = new CTable(null, 'formElementTable');
$ifTab->setAttribute('id', 'IPMIInterfaces');
$ifTab->setAttribute('data-type', 'ipmi');
$row = new CRow(null, null, 'IPMIIterfacesFooter');
if (!isset($existingInterfaceTypes[INTERFACE_TYPE_IPMI])) {
$row->addItem(new CCol(null, 'interface-drag-control'));
$row->addItem(new CCol(_('No IPMI interfaces found.'), null, 5));
}
$ifTab->addRow($row);
$hostList->addRow(_('IPMI interfaces'), new CDiv($ifTab, 'border_dotted objectgroup interface-group'), false, null, 'interface-row interface-row-last');
}
// Proxy
if (!$isDiscovered) {
$proxyControl = new CComboBox('proxy_hostid', $proxy_hostid);
$proxyControl->addItem(0, _('(no proxy)'));
$db_proxies = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND));
order_result($db_proxies, 'host');
foreach ($db_proxies as $proxy) {
$proxyControl->addItem($proxy['proxyid'], $proxy['host']);
}
} else {
示例6: CTextBox
$text2 = new CTextBox('macros[' . $i . '][value]', $macro['value'], 40, $readonly, 255);
$text2->setAttribute('placeholder', _('value'));
$span = new CSpan('⇒');
$span->addStyle('vertical-align:top;');
$deleteButtonCell = null;
if (!$readonly) {
$deleteButtonCell = array(new CButton('macros_' . $i . '_remove', _('Remove'), null, 'link_menu element-table-remove'));
if (isset($macro['globalmacroid'])) {
$deleteButtonCell[] = new CVar('macros[' . $i . '][globalmacroid]', $macro['globalmacroid'], 'macros_' . $i . '_id');
}
if (isset($macro['hostmacroid'])) {
$deleteButtonCell[] = new CVar('macros[' . $i . '][hostmacroid]', $macro['hostmacroid'], 'macros_' . $i . '_id');
}
}
$row = array($text1, $span, $text2, $deleteButtonCell);
$macrosTable->addRow($row, 'form_row');
}
// buttons
if (!$readonly) {
$addButton = new CButton('macro_add', _('Add'), null, 'link_menu element-table-add');
$buttonColumn = new CCol($addButton);
$buttonColumn->setAttribute('colspan', 5);
$buttonRow = new CRow();
$buttonRow->setAttribute('id', 'row_new_macro');
$buttonRow->addItem($buttonColumn);
$macrosTable->addRow($buttonRow);
}
// form list
$macrosFormList = new CFormList('macrosFormList');
$macrosFormList->addRow($macrosTable);
return $macrosFormList;
示例7: get_macros_widget
function get_macros_widget($hostid = null)
{
if (isset($_REQUEST['form_refresh'])) {
$macros = get_request('macros', array());
} else {
if ($hostid > 0) {
$macros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'hostids' => $hostid));
order_result($macros, 'macro');
} else {
if ($hostid === null) {
$macros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'globalmacro' => 1));
order_result($macros, 'macro');
} else {
$macros = array();
}
}
}
if (empty($macros)) {
$macros = array(0 => array('macro' => '', 'value' => ''));
}
$macros_tbl = new CTable(SPACE, 'formElementTable');
$macros_tbl->setAttribute('id', 'tbl_macros');
$macros_tbl->addRow(array(SPACE, S_MACRO, SPACE, S_VALUE));
insert_js('
function addMacroRow(){
if(typeof(addMacroRow.macro_count) == "undefined"){
addMacroRow.macro_count = ' . count($macros) . ';
}
var tr = document.createElement("tr");
tr.className = (addMacroRow.macro_count % 2) ? "form_even_row" : "form_odd_row";
var td1 = document.createElement("td");
tr.appendChild(td1);
var cb = document.createElement("input");
cb.setAttribute("type", "checkbox");
cb.className = "checkbox";
td1.appendChild(cb);
td1.appendChild(document.createTextNode(" "));
var td2 = document.createElement("td");
tr.appendChild(td2);
var text1 = document.createElement("input");
text1.setAttribute("type", "text");
text1.setAttribute("name", "macros["+addMacroRow.macro_count+"][macro]");
text1.className = "biginput";
text1.setAttribute("size",30);
text1.setAttribute("placeholder","{$MACRO}");
td2.appendChild(text1);
td2.appendChild(document.createTextNode(" "));
var td3 = document.createElement("td");
tr.appendChild(td3);
var span = document.createElement("span");
span.innerHTML = "⇒";
span.setAttribute("style", "vertical-align:top;");
td3.appendChild(span);
var td4 = document.createElement("td");
tr.appendChild(td4);
var text2 = document.createElement("input");
text2.setAttribute("type", "text");
text2.setAttribute("placeholder","<' . S_VALUE . '>");
text2.setAttribute("name","macros["+addMacroRow.macro_count+"][value]");
text2.className = "biginput";
text2.setAttribute("size",40);
td4.appendChild(text2);
var sd = $("row_new_macro").insert({before : tr});
addMacroRow.macro_count++;
}
');
$macros = array_values($macros);
foreach ($macros as $macroid => $macro) {
$text1 = new CTextBox('macros[' . $macroid . '][macro]', $macro['macro'], 30);
$text1->setAttribute('placeholder', '{$MACRO}');
$text2 = new CTextBox('macros[' . $macroid . '][value]', $macro['value'], 40);
$text2->setAttribute('placeholder', '<' . S_VALUE . '>');
$span = new CSpan(RARR);
$span->addStyle('vertical-align:top;');
$macros_tbl->addRow(array(new CCheckBox(), $text1, $span, $text2));
}
$script = '$$("#tbl_macros input:checked").each(function(obj){ $(obj.parentNode.parentNode).remove(); if (typeof(deleted_macro_cnt) == \'undefined\') deleted_macro_cnt=1; else deleted_macro_cnt++; });';
$delete_btn = new CButton('macros_del', S_DELETE_SELECTED, $script);
$delete_btn->setType('button');
$add_button = new CButton('macro_add', S_ADD, 'javascript: addMacroRow()');
$add_button->setType('button');
$buttonRow = new CRow();
$buttonRow->setAttribute('id', 'row_new_macro');
$col = new CCol(array($add_button, SPACE, $delete_btn));
$col->setAttribute('colspan', 4);
$buttonRow->addItem($col);
$macros_tbl->addRow($buttonRow);
$footer = null;
if ($hostid === null) {
//.........这里部分代码省略.........
示例8: make_hoststat_summary
//.........这里部分代码省略.........
if (!isset($hosts_data[$group['groupid']]['hostids_all'][$host['hostid']])) {
$hosts_data[$group['groupid']]['hostids_all'][$host['hostid']] = $host['hostid'];
$hosts_data[$group['groupid']]['problematic']++;
}
}
}
}
foreach ($hosts as $host) {
foreach ($host['groups'] as $group) {
if (!isset($groups[$group['groupid']])) {
continue;
}
if (!isset($groups[$group['groupid']]['hosts'])) {
$groups[$group['groupid']]['hosts'] = array();
}
$groups[$group['groupid']]['hosts'][$host['hostid']] = array('hostid' => $host['hostid']);
if (!isset($highest_severity[$group['groupid']])) {
$highest_severity[$group['groupid']] = 0;
}
if (!isset($hosts_data[$group['groupid']])) {
$hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0);
}
if (!isset($problematic_host_list[$host['hostid']])) {
$hosts_data[$group['groupid']]['ok']++;
}
}
}
foreach ($groups as $group) {
if (!isset($hosts_data[$group['groupid']])) {
continue;
}
$group_row = new CRow();
if (is_show_all_nodes()) {
$group_row->addItem($group['nodename']);
}
$name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=0&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
$group_row->addItem($name);
$group_row->addItem(new CCol($hosts_data[$group['groupid']]['ok'], 'normal'));
if ($filter['extAck']) {
if ($hosts_data[$group['groupid']]['lastUnack']) {
$table_inf = new CTableInfo();
$table_inf->setAttribute('style', 'width: 400px;');
$table_inf->setHeader(array(_('Host'), is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? getSeverityCaption(TRIGGER_SEVERITY_DISASTER) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? getSeverityCaption(TRIGGER_SEVERITY_HIGH) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? getSeverityCaption(TRIGGER_SEVERITY_AVERAGE) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? getSeverityCaption(TRIGGER_SEVERITY_WARNING) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? getSeverityCaption(TRIGGER_SEVERITY_INFORMATION) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED) : null));
$popup_rows = 0;
foreach ($group['hosts'] as $host) {
$hostid = $host['hostid'];
if (!isset($lastUnack_host_list[$hostid])) {
continue;
}
if ($popup_rows >= ZBX_WIDGET_ROWS) {
break;
}
$popup_rows++;
$host_data = $lastUnack_host_list[$hostid];
$r = new CRow();
$r->addItem(new CLink($host_data['host'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=' . $hostid . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE));
foreach ($lastUnack_host_list[$host['hostid']]['severities'] as $severity => $trigger_count) {
if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
continue;
}
$r->addItem(new CCol($trigger_count, getSeverityStyle($severity, $trigger_count)));
}
$table_inf->addRow($r);
}
$lastUnack_count = new CSpan($hosts_data[$group['groupid']]['lastUnack'], 'pointer red bold');
$lastUnack_count->setHint($table_inf);
示例9: get_rights_of_elements_table
function get_rights_of_elements_table($rights = array(), $user_type = USER_TYPE_ZABBIX_USER)
{
global $ZBX_LOCALNODEID;
$table = new CTable('S_NO_ACCESSIBLE_RESOURCES', 'right_table');
$table->SetHeader(array(SPACE, S_READ_WRITE, S_READ_ONLY, S_DENY), 'header');
if (ZBX_DISTRIBUTED) {
$lst['node']['label'] = S_NODES;
$lst['node']['read_write'] = new CListBox('nodes_write', null, 10);
$lst['node']['read_only'] = new CListBox('nodes_read', null, 10);
$lst['node']['deny'] = new CListBox('nodes_deny', null, 10);
$nodes = get_accessible_nodes_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY);
foreach ($nodes as $node) {
switch ($node['permission']) {
case PERM_READ_ONLY:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
break;
}
$lst['node'][$list_name]->addItem($node['nodeid'], $node['name']);
}
unset($nodes);
}
$lst['group']['label'] = S_HOST_GROUPS;
$lst['group']['read_write'] = new CListBox('groups_write', null, 15);
$lst['group']['read_only'] = new CListBox('groups_read', null, 15);
$lst['group']['deny'] = new CListBox('groups_deny', null, 15);
$groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
foreach ($groups as $group) {
switch ($group['permission']) {
case PERM_READ_ONLY:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
}
$lst['group'][$list_name]->addItem($group['groupid'], $group['node_name'] . ':' . $group['name']);
}
unset($groups);
$lst['host']['label'] = S_HOSTS;
$lst['host']['read_write'] = new CListBox('hosts_write', null, 15);
$lst['host']['read_only'] = new CListBox('hosts_read', null, 15);
$lst['host']['deny'] = new CListBox('hosts_deny', null, 15);
$hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
foreach ($hosts as $host) {
switch ($host['permission']) {
case PERM_READ_ONLY:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
break;
}
$lst['host'][$list_name]->addItem($host['hostid'], $host['node_name'] . ':' . $host['host']);
}
unset($hosts);
foreach ($lst as $name => $lists) {
$row = new CRow();
foreach ($lists as $class => $list_obj) {
$row->addItem(new CCol($list_obj, $class));
}
$table->addRow($row);
}
unset($lst);
return $table;
}
示例10: make_trigger_table
function make_trigger_table($triggers, $host_name)
{
$table = new CTableInfo();
$table->setHeader(array(_('Host'), _('Problem'), _('Age')));
foreach ($triggers as $trigger) {
$description = $trigger["description"];
$r = new CRow();
$r->addItem($host_name);
$r->addItem(new CCol($description, getSeverityStyle($trigger['priority'])));
$r->addItem(zbx_date2age($trigger['lastchange']));
$table->addRow($r);
}
return $table;
}
示例11: makeSImgStr
private function makeSImgStr($id)
{
$tr = new CRow();
$td = new CCol();
$count = isset($this->tree[$id]['nodeimg']) ? strlen($this->tree[$id]['nodeimg']) : 0;
for ($i = 0; $i < $count; $i++) {
switch ($this->tree[$id]['nodeimg'][$i]) {
case 'O':
$td->setAttribute('style', 'width: 22px');
$img = new CImg('images/general/tree/zero.gif', 'o', '22', '14');
break;
case 'I':
$td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
$img = new CImg('images/general/tree/zero.gif', 'i', '22', '14');
break;
case 'L':
$td->setAttribute('valign', 'top');
// $td->setAttribute('style','width:22px; background-image:url(images/general/tree/pointc.gif);');
$div = new CTag('div', 'yes');
$div->setAttribute('style', 'height: 10px; width:22px; background-image:url(images/general/tree/pointc.gif);');
if ($this->tree[$id]['nodetype'] == 2) {
$img = new CImg('images/general/tree/plus.gif', 'y', '22', '14');
$img->setAttribute('onclick', 'javascript: ' . $this->treename . '.closeSNodeX(' . $id . ',this);' . " showPopupDiv('div_node_tree','select_iframe');");
// IE6 Fix
$img->setAttribute('id', 'idi_' . $id);
$img->setClass('imgnode');
} else {
$img = new CImg('images/general/tree/pointl.gif', 'y', '22', '14');
}
$div->addItem($img);
$img = $div;
break;
case 'T':
$td->setAttribute('valign', 'top');
if ($this->tree[$id]['nodetype'] == 2) {
$td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
$img = new CImg('images/general/tree/plus.gif', 't', '22', '14');
$img->setAttribute('onclick', 'javascript: ' . $this->treename . '.closeSNodeX(' . $id . ',this);' . " showPopupDiv('div_node_tree','select_iframe');");
// IE6 Fix
$img->setAttribute('id', 'idi_' . $id);
$img->setClass('imgnode');
} else {
$td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
$img = new CImg('images/general/tree/pointl.gif', 't', '22', '14');
}
break;
}
$td->addItem($img);
$tr->addItem($td);
$td = new CCol();
}
// echo $txt.' '.$this->tree[$id]['Name'].'<br />';
return $tr;
}
示例12: make_awsstat_summary
function make_awsstat_summary($preloading = false)
{
$table = new CTableInfo();
$table->setHeader(array(is_show_all_nodes() ? S_NODE : null, _('Account name'), _('PoweredOn'), _('PoweredOff'), _('Billing/Month')));
$script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},ec2,{HOST.HOST}]';
$aws_accounts = get_aws_accounts();
if (empty($aws_accounts)) {
return null;
}
foreach ($aws_accounts as $host) {
if (!$preloading) {
if (is_script_success($host['hostid'], $script_itemkey)) {
$instances = get_instances($host['hostid']);
$instances = filter_instances($instances);
$r = new CRow();
// Account name
$col = new CCol($host['host']);
$r->addItem($col);
// Poweron (running + pending)
$poweron_vms = array_merge($instances["running"], $instances["pending"]);
$poweron_count = new CSpan(count($poweron_vms), 'pointer');
if (!empty($poweron_vms)) {
$poweron_count->setHint(make_ec2_table('ec2_poweron', $poweron_vms));
}
$r->addItem(new CCol($poweron_count));
// Poweroff (stopped + terminated + stopping + shutting-down)
$poweroff_vms = $instances["stopped"];
$poweroff_count = new CSpan(count($poweroff_vms), 'pointer');
if (!empty($poweroff_vms)) {
$poweroff_count->setHint(make_ec2_table('ec2_poweroff', $poweroff_vms));
}
$r->addItem(new CCol($poweroff_count));
// AWS Charges
$item = get_item_by_key('get_aws_charges.py[{$KEY},{$SECRET}]', $host["host"]);
if (array_key_exists('lastvalue', $item)) {
$r->addItem(new CLink($item["lastvalue"], "history.php?action=showgraph&itemid={$item["itemid"]}"));
} else {
$r->addItem(new CCol(_('No data')));
}
$table->addRow($r);
zbx_add_post_js('chkbxRange.pageGoName = "vms";');
} else {
$r = new CRow();
$r->addItem($host['host']);
$r->addItem(new CCol(_('script failed'), "high"));
$r->addItem(array("-"));
$table->addRow($r);
}
} else {
$r = new CRow();
$r->addItem($host['host']);
$r->addItem(new CCol(_('loading...')));
$r->addItem(array("-"));
$table->addRow($r);
}
}
$script = new CJSScript(get_js("jQuery('#hat_awsstat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
return new CDiv(array($table, $script));
}
示例13: make_hoststat_summary
//.........这里部分代码省略.........
if (!isset($hosts_data[$group['groupid']])) {
$hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
}
if (!isset($hosts_data[$group['groupid']]['hostids_all'][$host['hostid']])) {
$hosts_data[$group['groupid']]['hostids_all'][$host['hostid']] = $host['hostid'];
$hosts_data[$group['groupid']]['problematic']++;
}
}
}
}
foreach ($hosts as $hnum => $host) {
foreach ($host['groups'] as $gnum => $group) {
if (!isset($groups[$group['groupid']]['hosts'])) {
$groups[$group['groupid']]['hosts'] = array();
}
$groups[$group['groupid']]['hosts'][$host['hostid']] = array('hostid' => $host['hostid']);
if (!isset($highest_severity[$group['groupid']])) {
$highest_severity[$group['groupid']] = 0;
}
if (!isset($hosts_data[$group['groupid']])) {
$hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0);
}
if (!isset($problematic_host_list[$host['hostid']])) {
$hosts_data[$group['groupid']]['ok']++;
}
}
}
foreach ($groups as $gnum => $group) {
if (!isset($hosts_data[$group['groupid']])) {
continue;
}
$group_row = new CRow();
if (is_show_all_nodes()) {
$group_row->addItem(get_node_name_by_elid($group['groupid']));
}
$name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=0&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
$group_row->addItem($name);
$group_row->addItem(new CCol($hosts_data[$group['groupid']]['ok'], 'normal'));
if ($filter['extAck']) {
if ($hosts_data[$group['groupid']]['lastUnack']) {
$table_inf = new CTableInfo();
$table_inf->setAttribute('style', 'width: 400px;');
$table_inf->setHeader(array(S_HOST, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? S_DISASTER : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? S_HIGH : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? S_AVERAGE : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? S_WARNING : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? S_INFORMATION : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? S_NOT_CLASSIFIED : null));
$popup_rows = 0;
foreach ($group['hosts'] as $hnum => $host) {
$hostid = $host['hostid'];
if (!isset($lastUnack_host_list[$hostid])) {
continue;
}
if ($popup_rows >= ZBX_WIDGET_ROWS) {
break;
}
$popup_rows++;
$host_data = $lastUnack_host_list[$hostid];
$r = new CRow();
$r->addItem(new CLink($host_data['host'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=' . $hostid . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE));
foreach ($lastUnack_host_list[$host['hostid']]['severities'] as $severity => $trigger_count) {
if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
continue;
}
$r->addItem(new CCol($trigger_count, get_severity_style($severity, $trigger_count)));
}
$table_inf->addRow($r);
}
$lastUnack_count = new CSpan($hosts_data[$group['groupid']]['lastUnack'], 'pointer red bold');
$lastUnack_count->setHint($table_inf);
示例14: getPermissionsFormList
function getPermissionsFormList($rights = array(), $user_type = USER_TYPE_ZABBIX_USER, $rightsFormList = null)
{
// nodes
if (ZBX_DISTRIBUTED) {
$lists['node']['label'] = _('Nodes');
$lists['node']['read_write'] = new CListBox('nodes_write', null, 10);
$lists['node']['read_only'] = new CListBox('nodes_read', null, 10);
$lists['node']['deny'] = new CListBox('nodes_deny', null, 10);
$lists['node']['read_write']->setAttribute('style', 'background: #EBEFF2;');
$lists['node']['read_only']->setAttribute('style', 'background: #EBEFF2;');
$lists['node']['deny']->setAttribute('style', 'background: #EBEFF2;');
$nodes = get_accessible_nodes_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY);
foreach ($nodes as $node) {
switch ($node['permission']) {
case PERM_READ_ONLY:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
}
$lists['node'][$list_name]->addItem($node['nodeid'], $node['name']);
}
unset($nodes);
}
// group
$lists['group']['label'] = _('Host groups');
$lists['group']['read_write'] = new CListBox('groups_write', null, 15);
$lists['group']['read_only'] = new CListBox('groups_read', null, 15);
$lists['group']['deny'] = new CListBox('groups_deny', null, 15);
$lists['group']['read_write']->setAttribute('style', 'background: #EBEFF2;');
$lists['group']['read_only']->setAttribute('style', 'background: #EBEFF2;');
$lists['group']['deny']->setAttribute('style', 'background: #EBEFF2;');
$groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
foreach ($groups as $group) {
switch ($group['permission']) {
case PERM_READ_ONLY:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
}
$lists['group'][$list_name]->addItem($group['groupid'], (empty($group['node_name']) ? '' : $group['node_name'] . ':') . $group['name']);
}
unset($groups);
// host
$lists['host']['label'] = _('Hosts');
$lists['host']['read_write'] = new CListBox('hosts_write', null, 15);
$lists['host']['read_only'] = new CListBox('hosts_read', null, 15);
$lists['host']['deny'] = new CListBox('hosts_deny', null, 15);
$lists['host']['read_write']->setAttribute('style', 'background: #EBEFF2;');
$lists['host']['read_only']->setAttribute('style', 'background: #EBEFF2;');
$lists['host']['deny']->setAttribute('style', 'background: #EBEFF2;');
$hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
foreach ($hosts as $host) {
switch ($host['permission']) {
case PERM_READ_ONLY:
$list_name = 'read_only';
break;
case PERM_READ_WRITE:
$list_name = 'read_write';
break;
default:
$list_name = 'deny';
}
if (HOST_STATUS_PROXY_ACTIVE == $host['status'] || HOST_STATUS_PROXY_PASSIVE == $host['status']) {
$host['host_name'] = $host['host'];
}
$lists['host'][$list_name]->addItem($host['hostid'], (empty($host['node_name']) ? '' : $host['node_name'] . ':') . $host['host_name']);
}
unset($hosts);
// display
if (empty($rightsFormList)) {
$rightsFormList = new CFormList('rightsFormList');
}
$isHeaderDisplayed = false;
foreach ($lists as $list) {
$sLabel = '';
$row = new CRow();
foreach ($list as $class => $item) {
if (is_string($item)) {
$sLabel = $item;
} else {
$row->addItem(new CCol($item, $class));
}
}
$table = new CTable(_('No accessible resources'), 'right_table');
if (!$isHeaderDisplayed) {
$table->setHeader(array(_('Read-write'), _('Read only'), _('Deny')), 'header');
$isHeaderDisplayed = true;
}
$table->addRow($row);
$rightsFormList->addRow($sLabel, $table);
}
return $rightsFormList;
//.........这里部分代码省略.........
示例15: make_system_summary
function make_system_summary($args = array())
{
global $USER_DETAILS;
$config = select_config();
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
$available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY);
if (isset($args['hosts']) && !empty($args['hosts'])) {
$available_hosts = zbx_uint_array_intersect($args['hosts'], $available_hosts);
}
if (isset($args['groups']) && !empty($args['groups'])) {
$available_groups = zbx_uint_array_intersect($args['groups'], $available_groups);
}
$sql_where = '';
if (isset($args['severity']) && ctype_digit($args['severity'])) {
$sql_where = ' AND t.priority>=' . $args['severity'];
}
$table = new CTableInfo();
$table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST_GROUP, S_DISASTER, S_HIGH, S_AVERAGE, S_WARNING, S_INFORMATION, S_NOT_CLASSIFIED));
$sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g, hosts_groups hg, hosts h, items i, functions f, triggers t ' . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND ' . DBcondition('g.groupid', $available_groups) . ' AND hg.groupid=g.groupid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' ORDER BY g.name';
$gr_result = DBselect($sql);
while ($group = DBFetch($gr_result)) {
$group_row = new CRow();
if (is_show_all_nodes()) {
$group_row->addItem(get_node_name_by_elid($group['groupid']));
}
$name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
$name->setTarget('blank');
$group_row->addItem($name);
$tab_priority[TRIGGER_SEVERITY_DISASTER] = 0;
$tab_priority[TRIGGER_SEVERITY_HIGH] = 0;
$tab_priority[TRIGGER_SEVERITY_AVERAGE] = 0;
$tab_priority[TRIGGER_SEVERITY_WARNING] = 0;
$tab_priority[TRIGGER_SEVERITY_INFORMATION] = 0;
$tab_priority[TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
$sql = 'SELECT count(DISTINCT t.triggerid) as tr_cnt,t.priority ' . ' FROM hosts h,items i,hosts_groups hg, functions f, triggers t ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND hg.hostid=h.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' GROUP BY t.priority';
//SDI($sql);
$tr_result = DBSelect($sql);
while ($group_stat = DBFetch($tr_result)) {
$tab_priority[$group_stat['priority']] = $group_stat['tr_cnt'];
}
foreach ($tab_priority as $key => $value) {
$tr_count = 0;
if ($value) {
//* trigger list
$table_inf = new CTableInfo();
$table_inf->setAttribute('style', 'width: 400px;');
$table_inf->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
$sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.priority=' . $key . ' ORDER BY t.lastchange DESC';
$result = DBselect($sql);
while ($row_inf = DBfetch($result)) {
// Check for dependencies
if (trigger_dependent($row_inf["triggerid"])) {
continue;
}
$tr_count++;
if ($tr_count > 30) {
continue;
}
$host = new CSpan($row_inf['host']);
$event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row_inf['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
if ($row_inf_event = DBfetch(DBselect($event_sql, 1))) {
if ($config['event_ack_enable']) {
if ($row_inf_event['acknowledged'] == 1) {
$ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'action');
} else {
$ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'on');
}
}
$description = expand_trigger_description_by_data(array_merge($row_inf, array('clock' => $row_inf_event['clock'])), ZBX_FLAG_EVENT);
//actions
$actions = get_event_actions_status($row_inf_event['eventid']);
//--------
} else {
$description = expand_trigger_description_by_data($row_inf, ZBX_FLAG_EVENT);
$ack = '-';
$actions = S_NO_DATA_SMALL;
$row_inf_event['clock'] = $row_inf['clock'];
}
$table_inf->addRow(array(get_node_name_by_elid($row_inf['triggerid']), $host, new CCol($description, get_severity_style($row_inf['priority'])), zbx_date2age($row_inf_event['clock']), $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, $actions));
unset($row_inf, $description, $actions);
}
$value = new CSpan($tr_count, 'pointer');
$value->setHint($table_inf);
//-------------*/
}
$group_row->AddItem(new CCol($value, get_severity_style($key, $tr_count)));
unset($table_inf);
}
$table->addRow($group_row);
}
$table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time())));
return $table;
}