public function addItem($value) { if (is_object($value) && zbx_strtolower(get_class($value)) != 'carea') { return $this->error('Incorrect value for addItem "' . $value . '".'); } return parent::addItem($value); }
public function addItem($value, $caption = '', $selected = null, $enabled = true, $class = null) { if ($value instanceof CComboItem || $value instanceof COptGroup) { parent::addItem($value); } else { if (is_null($selected)) { $selected = 'no'; if (is_array($this->value)) { if (str_in_array($value, $this->value)) { $selected = 'yes'; } } elseif (strcmp($value, $this->value) == 0) { $selected = 'yes'; } } else { $selected = 'yes'; } $citem = new CComboItem($value, $caption, $selected, $enabled); if ($class !== null) { $citem->addClass($class); } parent::addItem($citem); } return $this; }
public function addItem($value) { if (strtolower(get_class($value)) != 'carea') { return $this->error('Incorrect value for addItem [' . $value . ']'); } return parent::addItem($value); }
public function addItem($value, $class = null, $id = null) { if (!is_null($value) && $this->emptyList) { $this->emptyList = false; $this->items = array(); } parent::addItem($this->prepareItem($value, $class, $id)); }
public function addItemsInGroup($label, $items) { $group = new COptGroup($label); foreach ($items as $value => $caption) { $selected = (int) ($value == $this->value); $group->addItem(new CComboItem($value, $caption, $selected)); } parent::addItem($group); }
public function addItem($value, $class = null) { if (is_array($value)) { foreach ($value as $el) { parent::addItem($this->prepareItem($el, $class)); } } else { parent::addItem($this->prepareItem($value, $class)); } }
public function addItem($value, $class = null, $id = null) { if (!is_null($value) && $this->emptyList) { $this->emptyList = false; $this->items = []; } if ($value instanceof CListItem) { parent::addItem($value); } else { parent::addItem($this->prepareItem($value, $class, $id)); } return $this; }
public function addItem($item) { if (is_object($item) && strtolower(get_class($item)) === 'ccol') { parent::addItem($item); } elseif (is_array($item)) { foreach ($item as $el) { if (is_object($el) && strtolower(get_class($el)) === 'ccol') { parent::addItem($el); } elseif (!is_null($el)) { parent::addItem(new CCol($el)); } } } elseif (!is_null($item)) { parent::addItem(new CCol($item)); } }
function italic($str) { if (is_array($str)) { foreach ($str as $key => $val) { if (is_string($val)) { $em = new CTag('em', true); $em->addItem($val); $str[$key] = $em; } } } elseif (is_string($str)) { $em = new CTag('em', true, ''); $em->addItem($str); $str = $em; } return $str; }
public function __construct($tagname = NULL, $paired = 'no', $body = NULL, $class = null) { parent::__construct(); $this->options = array(); if (!is_string($tagname)) { return $this->error('Incorrect tagname for CTag [' . $tagname . ']'); } $this->tagname = $tagname; $this->paired = $paired; $this->tag_start = $this->tag_end = $this->tag_body_start = $this->tag_body_end = ''; if (is_null($body)) { $this->tag_end = $this->tag_body_start = "\n"; } else { CTag::addItem($body); } $this->setClass($class); }
function bold($str) { if (is_array($str)) { foreach ($str as $key => $val) { if (is_string($val)) { $b = new CTag('strong', 'yes'); $b->addItem($val); $str[$key] = $b; } } } else { $b = new CTag('strong', 'yes', ''); $b->addItem($str); $str = $b; } return $str; }
public function addItem($value, $caption = '', $selected = NULL, $enabled = 'yes') { // if($enabled=='no') return; /* disable item method 1 */ if (strtolower(get_class($value)) == 'ccomboitem') { parent::addItem($value); } else { if (is_null($selected)) { $selected = 'no'; if (is_array($this->value)) { if (str_in_array($value, $this->value)) { $selected = 'yes'; } } else { if (strcmp($value, $this->value) == 0) { $selected = 'yes'; } } } parent::addItem(new CComboItem($value, $caption, $selected, $enabled)); } }
function explode_exp($expression, $html, $template = false) { // echo "EXPRESSION:",$expression,"<Br>"; $functionid = ''; if (0 == $html) { $exp = ''; } else { $exp = array(); } $state = ''; for ($i = 0, $max = strlen($expression); $i < $max; $i++) { if ($expression[$i] == '{') { $functionid = ''; $state = 'FUNCTIONID'; continue; } if ($expression[$i] == '}') { $state = ''; if ($functionid == "TRIGGER.VALUE") { if (0 == $html) { $exp .= '{' . $functionid . '}'; } else { array_push($exp, '{' . $functionid . '}'); } } else { if (is_numeric($functionid) && ($function_data = DBfetch(DBselect('SELECT h.host,i.key_,f.function,f.parameter,i.itemid,i.value_type' . ' FROM items i,functions f,hosts h' . ' WHERE f.functionid=' . $functionid . ' AND i.itemid=f.itemid ' . ' AND h.hostid=i.hostid')))) { if ($template) { $function_data["host"] = '{HOSTNAME}'; } if ($html == 0) { $exp .= '{' . $function_data['host'] . ':' . $function_data['key_'] . '.' . $function_data['function'] . '(' . $function_data['parameter'] . ')}'; } else { $link = new CLink($function_data['host'] . ':' . $function_data['key_'], 'history.php?action=' . ($function_data['value_type'] == ITEM_VALUE_TYPE_FLOAT || $function_data['value_type'] == ITEM_VALUE_TYPE_UINT64 ? 'showgraph' : 'showvalues') . '&itemid=' . $function_data['itemid']); array_push($exp, array('{', $link, '.', bold($function_data['function'] . '('), $function_data['parameter'], bold(')'), '}')); } } else { if (1 == $html) { $font = new CTag('font', 'yes'); $font->addOption('color', '#AA0000'); $font->addItem('*ERROR*'); array_push($exp, $font); } else { $exp .= '*ERROR*'; } } } continue; } if ($state == "FUNCTIONID") { $functionid = $functionid . $expression[$i]; continue; } if (1 == $html) { array_push($exp, $expression[$i]); } else { $exp .= $expression[$i]; } } # echo "EXP:",$exp,"<Br>"; return $exp; }
$profileIdx = 'web.item.graph'; $profileIdx2 = reset($this->data['itemids']); $updateProfile = $this->data['action'] != HISTORY_BATCH_GRAPH; } // create history screen $screen = CScreenBuilder::getScreen(array('resourcetype' => SCREEN_RESOURCE_HISTORY, 'action' => $this->data['action'], 'items' => $this->data['items'], 'profileIdx' => $profileIdx, 'profileIdx2' => $profileIdx2, 'updateProfile' => $updateProfile, 'period' => $this->data['period'], 'stime' => $this->data['stime'], 'filter' => getRequest('filter'), 'filter_task' => getRequest('filter_task'), 'mark_color' => getRequest('mark_color'), 'plaintext' => $this->data['plaintext'], 'graphtype' => $this->data['graphtype'])); // append plaintext to widget if ($this->data['plaintext']) { $plaintextSpan = new CSpan(null, 'textblackwhite'); foreach ($headerPlaintext as $text) { $plaintextSpan->addItem(array(new CJsScript($text), BR())); } $screen = $screen->get(); $pre = new CTag('pre', true); foreach ($screen as $text) { $pre->addItem(new CJsScript($text)); } $plaintextSpan->addItem($pre); $historyWidget->addItem($plaintextSpan); } else { $right = new CTable(); $right->addRow($header['right']); $historyWidget->addPageHeader($header['left'], $right); $historyWidget->addItem(BR()); if (isset($this->data['iv_string'][$this->data['value_type']])) { $historyWidget->addFlicker($filterForm, CProfile::get('web.history.filter.state', 1)); } $historyTable = new CTable(null, 'maxwidth'); $historyTable->addRow($screen->get()); $historyWidget->addItem($historyTable); if (in_array($this->data['action'], array(HISTORY_VALUES, HISTORY_GRAPH, HISTORY_BATCH_GRAPH))) {
public function addItem($value, $caption = '', $selected = null, $enabled = 'yes') { if ($value instanceof CComboItem || $value instanceof COptGroup) { parent::addItem($value); } else { $title = false; // if caption is too long ( > 44 symbols), we add new class - 'selectShorten', // so that the select box would not stretch if (zbx_strlen($caption) > 44 && !$this->hasClass('selectShorten')) { $this->setAttribute('class', $this->getAttribute('class') . ' selectShorten'); $title = true; } if (is_null($selected)) { $selected = 'no'; if (is_array($this->value)) { if (str_in_array($value, $this->value)) { $selected = 'yes'; } } elseif (strcmp($value, $this->value) == 0) { $selected = 'yes'; } } else { $selected = 'yes'; } $citem = new CComboItem($value, $caption, $selected, $enabled); if ($title) { $citem->setTitle($caption); } parent::addItem($citem); } }
private function makeSImgStr($id) { $tr = new CRow(); $count = isset($this->tree[$id]['nodeimg']) ? strlen($this->tree[$id]['nodeimg']) : 0; for ($i = 0; $i < $count; $i++) { $td = new CCol(); $img = null; switch ($this->tree[$id]['nodeimg'][$i]) { case 'O': $img = new CImg('images/general/tree/zero.gif', 'o', '22', '14'); break; case 'I': $td->setAttribute('style', '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'); $div = new CTag('div', 'yes'); $div->setAttribute('style', 'height: 10px; 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', $this->treename . '.closeSNodeX("' . $id . '", this);'); $img->setAttribute('id', 'idi_' . $id); $img->setAttribute('class', 'pointer'); } 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', 'background-image: url(images/general/tree/pointc.gif);'); $img = new CImg('images/general/tree/plus.gif', 't', '22', '14'); $img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '", this);'); $img->setAttribute('id', 'idi_' . $id); $img->setAttribute('class', 'pointer'); $img->setAttribute('style', 'top: 1px; position: relative;'); } else { $td->setAttribute('style', '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); } return $tr; }
$table->addRow(array($show_event_col ? SPACE : NULL, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row['value'])), $value, $clock, get_node_name_by_elid($row['triggerid']), $host, $tr_desc, $actions, $show_event_col ? SPACE : NULL, new CLink(zbx_empty($row['comments']) ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $row['triggerid'], 'action'))); $event_limit = 0; foreach ($row['events'] as $eventid => $row_event) { $value = new CSpan(trigger_value2str($row_event['value']), get_trigger_value_style($row_event['value'])); if ($config['event_ack_enable']) { if ($row_event['acknowledged'] == 1) { $acks_cnt = DBfetch(DBselect('SELECT COUNT(*) as cnt FROM acknowledges WHERE eventid=' . $row_event['eventid'])); $ack = array(new CSpan(S_YES, 'off'), SPACE . '(' . $acks_cnt['cnt'] . SPACE, new CLink(S_SHOW, 'acknow.php?eventid=' . $row_event['eventid'], 'action'), ')'); } else { $ack = new CLink(S_NOT_ACKNOWLEDGED, 'acknow.php?eventid=' . $row_event['eventid'], 'on'); } } $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT); $font = new CTag('font', 'yes'); $font->setAttribute('color', '#808080'); $font->addItem(array(' - ', $description)); $description = $font; $description = new CCol($description); $description->setAttribute('style', 'white-space: normal; width: 90%;'); $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row_event['eventid'], 'action'); $table->addRow(array($config['event_ack_enable'] ? $row_event['acknowledged'] == 1 ? SPACE : new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']) : NULL, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row_event['value'])), $value, $clock, get_node_name_by_elid($row['triggerid']), $host, $description, $actions, $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, new CLink($row['comments'] == '' ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $row['triggerid'], 'action'))); $event_limit++; if ($event_limit >= $config['event_show_max']) { break; } } unset($row, $description, $actions); } //----- GO ------ if ($config['event_ack_enable']) { $goBox = new CComboBox('go');
$row['value'] = $row['value']->load(); } else { $row['value'] = ''; } } if ($row['valuemapid'] > 0) { $value = replace_value_by_map($row['value'], $row['valuemapid']); } else { $value = $row['value']; } $new_row = array(date('Y.M.d H:i:s', $row['clock'])); if (str_in_array($item_type, array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64))) { array_push($new_row, $value); } else { $pre = new CTag('pre', 'yes'); $pre->addItem($value); array_push($new_row, $pre); } if (!isset($_REQUEST['plaintext'])) { $table->ShowRow($new_row); } else { echo date('Y-m-d H:i:s', $row['clock']); echo "\t" . $row['clock'] . "\t" . htmlspecialchars($row['value']) . "\n"; } } if (!isset($_REQUEST['plaintext'])) { $table->ShowEnd(); // to solve memory leak we call 'Show' method by steps echo SBR; } else { echo '</pre></span>';
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; }
$hosts = reset($trigger['hosts']); $menu_trigger_conf = 'null'; if ($admin_links) { $menu_trigger_conf = "['" . S_CONFIGURATION_OF_TRIGGERS . "',\"javascript:\n\t\t\t\tredirect('triggers.php?form=update&triggerid=" . $trigger['triggerid'] . '&switch_node=' . id2nodeid($trigger['triggerid']) . "')\",\n\t\t\t\tnull, {'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]"; } $menu_trigger_url = 'null'; if (!zbx_empty($trigger['url'])) { $menu_trigger_url = "['" . S_URL . "',\"javascript: window.location.href='" . $trigger['url'] . "'\",\n\t\t\t\tnull, {'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]"; } $description->addAction('onclick', "javascript: create_mon_trigger_menu(event, new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $trigger['lastchange'] . "'}, " . $menu_trigger_conf . ", " . $menu_trigger_url . ")," . zbx_jsvalue($items, true) . ");"); // }}} trigger description js menu if ($_REQUEST['show_details']) { $font = new CTag('font', 'yes'); $font->setAttribute('color', '#000'); $font->setAttribute('size', '-2'); $font->addItem(explode_exp($trigger['expression'], 1, false, true)); $description = array($description, BR(), $font); } // DEPENDENCIES {{{ if (!empty($trigger['dependencies'])) { $dep_table = new CTableInfo(); $dep_table->setAttribute('style', 'width: 200px;'); $dep_table->addRow(bold(S_DEPENDS_ON . ':')); foreach ($trigger['dependencies'] as $dep) { $dep_table->addRow(' - ' . expand_trigger_description($dep['triggerid'])); } $img = new Cimg('images/general/down_icon.png', 'DEP_UP'); $img->setAttribute('style', 'vertical-align: middle; border: 0px;'); $img->setHint($dep_table); $description = array($img, SPACE, $description); }
$filterForm->addRow(_('Selected'), $tasks); $filterForm->addItemToBottomRow(new CSubmit('select', _('Filter'))); } } // create history screen $screen = CScreenBuilder::getScreen(array('resourcetype' => SCREEN_RESOURCE_HISTORY, 'action' => $this->data['action'], 'items' => $this->data['items'], 'item' => $this->data['item'], 'itemids' => $this->data['itemids'], 'profileIdx' => 'web.item.graph', 'profileIdx2' => reset($this->data['itemids']), 'period' => $this->data['period'], 'stime' => $this->data['stime'], 'filter' => get_request('filter'), 'filter_task' => get_request('filter_task'), 'mark_color' => get_request('mark_color'), 'plaintext' => $this->data['plaintext'])); // append plaintext to widget if ($this->data['plaintext']) { $plaintextSpan = new CSpan(null, 'textblackwhite'); foreach ($headerPlaintext as $text) { $plaintextSpan->addItem(array(new CJSscript($text), BR())); } $screen = $screen->get(); $pre = new CTag('pre', true); foreach ($screen as $text) { $pre->addItem(new CJSscript($text)); } $plaintextSpan->addItem($pre); $historyWidget->addItem($plaintextSpan); } else { $right = new CTable(); $right->addRow($header['right']); $historyWidget->addPageHeader($header['left'], $right); $historyWidget->addItem(SPACE); if (isset($this->data['iv_string'][$this->data['item']['value_type']])) { $historyWidget->addFlicker($filterForm, CProfile::get('web.history.filter.state', 1)); } $historyTable = new CTable(null, 'maxwidth'); $historyTable->addRow($screen->get()); $historyWidget->addItem($historyTable); if ($this->data['action'] == 'showvalues' || $this->data['action'] == 'showgraph') {