本文整理汇总了PHP中CRow::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP CRow::setAttribute方法的具体用法?PHP CRow::setAttribute怎么用?PHP CRow::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRow
的用法示例。
在下文中一共展示了CRow::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeRow
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;
}
示例2: CSpan
$numSpan->addClass('rowNum');
$numSpan->setAttribute('id', 'current_step_' . $stepid);
$name = new CSpan($step['name'], 'link');
$name->setAttribute('id', 'name_' . $stepid);
$name->setAttribute('name_step', $stepid);
$name->onClick('return PopUp("popup_httpstep.php?dstfrm=' . $httpForm->getName() . '&list_name=steps&stepid="+jQuery(this).attr("name_step")+"' . url_param($step['name'], false, 'name') . url_param($step['timeout'], false, 'timeout') . url_param($step['url'], false, 'url') . url_param($step['posts'], false, 'posts') . url_param($step['required'], false, 'required') . url_param($step['status_codes'], false, 'status_codes') . '", 600, 410);');
if (zbx_strlen($step['url']) > 70) {
$url = new CSpan(substr($step['url'], 0, 35) . SPACE . '...' . SPACE . substr($step['url'], zbx_strlen($step['url']) - 25, 25));
$url->setHint($step['url']);
} else {
$url = $step['url'];
}
$removeButton = new CButton('remove_' . $stepid, _('Remove'), 'javascript: removeStep(this);', 'link_menu');
$removeButton->setAttribute('remove_step', $stepid);
$row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $name, $step['timeout'] . SPACE . _('sec'), $url, htmlspecialchars($step['required']), $step['status_codes'], $removeButton), 'sortable');
$row->setAttribute('id', 'steps_' . $stepid);
$stepsTable->addRow($row);
}
$tmpColumn = new CCol(new CButton('add_step', _('Add'), 'return PopUp("popup_httpstep.php?dstfrm=' . $httpForm->getName() . '", 600, 410);', 'link_menu'), null, 8);
$tmpColumn->setAttribute('style', 'vertical-align: middle;');
$stepsTable->addRow(new CRow($tmpColumn));
$httpStepFormList->addRow(_('Steps'), new CDiv($stepsTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// append tabs to form
$httpTab = new CTabView(array('remember' => true));
if (!$this->data['form_refresh']) {
$httpTab->setSelected(0);
}
$httpTab->addTab('scenarioTab', _('Scenario'), $httpFormList);
$httpTab->addTab('stepTab', _('Steps'), $httpStepFormList);
$httpForm->addItem($httpTab);
// append buttons to form
示例3: CCheckBox
$ack = SPACE;
}
}
if ($row_event['acknowledged'] == 0 && $row_event['value'] == TRIGGER_VALUE_TRUE) {
$ack_cb = new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']);
} else {
$ack_cb = SPACE;
}
$clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $row_event['eventid']);
$next_clock = isset($trigger['events'][$enum - 1]) ? $trigger['events'][$enum - 1]['clock'] : time();
$empty_col = new CCol(SPACE);
$empty_col->setColSpan(3);
$ack_cb_col = new CCol($ack_cb);
$ack_cb_col->setColSpan(2);
$row = new CRow(array(SPACE, $config['event_ack_enable'] ? $ack_cb_col : null, $status, $clock, zbx_date2age($row_event['clock']), zbx_date2age($next_clock, $row_event['clock']), $config['event_ack_enable'] ? $ack : NULL, is_show_all_nodes() ? SPACE : null, $empty_col), 'odd_row');
$row->setAttribute('data-parentid', $trigger['triggerid']);
$row->addStyle('display: none;');
$table->addRow($row);
if ($i > $config['event_show_max']) {
break;
}
}
}
}
//----- GO ------
$footer = null;
if ($config['event_ack_enable']) {
$goBox = new CComboBox('go');
$goBox->addItem('bulkacknowledge', S_BULK_ACKNOWLEDGE);
// goButton name is necessary!!!
$goButton = new CButton('goButton', S_GO . ' (0)');
示例4: CRow
} else {
$row = new CRow(['', $checkbox, $hostColumn, (new CCol($item['name_expanded']))->addClass($state_css), (new CCol($lastClock))->addClass($state_css), (new CCol($lastValue))->addClass($state_css), (new CCol($change))->addClass($state_css), $actions]);
}
$hosts[$item['hostid']]['item_cnt']++;
$tab_rows[$item['hostid']][] = $row;
}
foreach ($hosts as $hostId => $dbHost) {
$host = $hosts[$dbHost['hostid']];
if (!isset($tab_rows[$hostId])) {
continue;
}
$appRows = $tab_rows[$hostId];
$open_state = CProfile::get('web.latest.toggle_other', null, $host['hostid']);
$hostName = null;
if (!$singleHostSelected) {
$hostName = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $hostScripts[$host['hostid']]));
if ($host['status'] == HOST_STATUS_NOT_MONITORED) {
$hostName->addClass(ZBX_STYLE_RED);
}
}
// add toggle row
$table->addRow([(new CDiv())->addClass(ZBX_STYLE_TREEVIEW)->addClass('app-list-toggle')->setAttribute('data-host-id', $host['hostid'])->setAttribute('data-open-state', $open_state)->addItem(new CSpan()), '', $hostName, (new CCol([bold('- ' . 'other' . ' -'), ' (' . _n('%1$s Item', '%1$s Items', $dbHost['item_cnt']) . ')']))->setColSpan($filter['showDetails'] ? 10 : 5)]);
// add toggle sub rows
foreach ($appRows as $row) {
$row->setAttribute('parent_host_id', $host['hostid']);
$table->addRow($row);
}
}
$form->addItem([$table, new CActionButtonList('graphtype', 'itemids', [GRAPH_TYPE_STACKED => ['name' => _('Display stacked graph')], GRAPH_TYPE_NORMAL => ['name' => _('Display graph')]])]);
$widget->addItem($form)->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例5: CFormList
$groupList = new CFormList('grouplist');
// existing groups
$groups = array();
foreach ($data['groups'] as $group) {
$groups[] = array('id' => $group['groupid'], 'name' => $group['name']);
}
$groupList->addRow(_('Groups'), new CMultiSelect(array('name' => 'group_links[]', 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL)), 'data' => $groups, 'disabled' => (bool) $hostPrototype['templateid'])));
// new group prototypes
$customGroupTable = new CTable(SPACE, 'formElementTable');
$customGroupTable->setAttribute('id', 'tbl_group_prototypes');
// buttons
$addButton = new CButton('group_prototype_add', _('Add'), null, 'link_menu');
$buttonColumn = new CCol($addButton);
$buttonColumn->setAttribute('colspan', 5);
$buttonRow = new CRow();
$buttonRow->setAttribute('id', 'row_new_group_prototype');
$buttonRow->addItem($buttonColumn);
$customGroupTable->addRow($buttonRow);
$groupDiv = new CDiv($customGroupTable, 'objectgroup border_dotted ui-corner-all group-prototypes');
$groupList->addRow(_('Group prototypes'), $groupDiv);
$divTabs->addTab('groupTab', _('Groups'), $groupList);
// templates
$tmplList = new CFormList('tmpllist');
// create linked template table
$linkedTemplateTable = new CTable(_('No templates linked.'), 'formElementTable');
$linkedTemplateTable->attr('id', 'linkedTemplateTable');
$linkedTemplateTable->attr('style', 'min-width: 400px;');
$linkedTemplateTable->setHeader(array(_('Name'), _('Action')));
$ignoreTemplates = array();
if ($hostPrototype['templates']) {
foreach ($hostPrototype['templates'] as $template) {
示例6: CRow
$col->setAttribute('colspan', 6);
$buttonRow = new CRow(array($buttonCol, $col));
$buttonRow->setAttribute('id', 'JMXIterfacesFooter');
$ifTab->addRow($buttonRow);
$hostList->addRow(_('JMX interfaces'), new CDiv($ifTab, 'border_dotted objectgroup inlineblock 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');
$helpTextWhenDragInterfaceIPMI = new CSpan(_('Drag here to change the type of the interface to "IPMI" type.'));
$helpTextWhenDragInterfaceIPMI->addClass('dragHelpText');
$buttonCol = new CCol(new CButton('addIPMIInterface', _('Add'), null, 'link_menu'), 'interface-add-control');
$col = new CCol($helpTextWhenDragInterfaceIPMI);
$col->setAttribute('colspan', 6);
$buttonRow = new CRow(array($buttonCol, $col));
$buttonRow->setAttribute('id', 'IPMIIterfacesFooter');
$ifTab->addRow($buttonRow);
$hostList->addRow(_('IPMI interfaces'), new CDiv($ifTab, 'border_dotted objectgroup inlineblock interface-group'), false, null, 'interface-row');
} else {
$interfaces = array();
$existingInterfaceTypes = array();
foreach ($dbHost['interfaces'] as $interface) {
$interface['locked'] = true;
$existingInterfaceTypes[$interface['type']] = true;
$interfaces[$interface['interfaceid']] = $interface;
}
zbx_add_post_js('hostInterfacesManager.add(' . CJs::encodeJson($interfaces) . ');');
zbx_add_post_js('hostInterfacesManager.disable()');
// table for agent interfaces with footer
$ifTab = new CTable(null, 'formElementTable');
$ifTab->setAttribute('id', 'agentInterfaces');
示例7: CSpan
$del_url = new CSpan(_('Delete'), 'link');
$del_url->setAttribute('onclick', 'javascript: if(confirm("' . _('Delete expression?') . '")) remove_expression("logtr' . $id . '"); return false;');
$row = new CRow(array(htmlspecialchars($expr['view']), $expr['type'] == REGEXP_INCLUDE ? _('Include') : _('Exclude'), array($imgup, SPACE, $imgdn), $del_url));
$row->setAttribute('id', 'logtr' . $id);
$table->addRow($row);
$frmTRLog->addVar('expressions[' . $id . '][value]', $expr['value']);
$frmTRLog->addVar('expressions[' . $id . '][type]', $expr['type']);
$frmTRLog->addVar('expressions[' . $id . '][view]', $expr['view']);
$maxid = $maxid < $id ? $id : $maxid;
}
zbx_add_post_js('logexpr_count=' . ($maxid + 1));
$maxid = 0;
foreach ($keys as $id => $val) {
$del_url = new CLink(_('Delete'), '#', 'action', 'javascript: if(confirm("' . _('Delete keyword?') . '")) remove_keyword("keytr' . $id . '"); return false;');
$row = new CRow(array(htmlspecialchars($val['value']), $val['type'], $del_url));
$row->setAttribute('id', 'keytr' . $id);
$keyTable->addRow($row);
$frmTRLog->addVar('keys[' . $id . '][value]', $val['value']);
$frmTRLog->addVar('keys[' . $id . '][type]', $val['type']);
$maxid = $maxid < $id ? $id : $maxid;
}
zbx_add_post_js('key_count=' . ($maxid + 1));
$frmTRLog->addRow(SPACE, $keyTable);
$frmTRLog->addRow(SPACE, $table);
$sev_select = new CComboBox('priority', $priority);
$sev_select->addItems(getSeverityCaption());
$frmTRLog->addRow(_('Severity'), $sev_select);
$frmTRLog->addRow(_('Comments'), new CTextArea('comments', $comments));
$frmTRLog->addRow(_('URL'), new CTextBox('url', $url, 80));
$frmTRLog->addRow(_('Disabled'), new CCheckBox('status', $status == TRIGGER_STATUS_DISABLED ? 'yes' : 'no', null, 1));
$frmTRLog->addItemToBottomRow(new CSubmit('save_trigger', _('Save'), 'javascript: document.forms[0].action += \'?saction=1\';'));
示例8: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$output = array();
$stime = zbxDateToTime($this->timeline['stime']);
$iv_string = array(ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1);
$iv_numeric = array(ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1);
if ($this->action == 'showvalues' || $this->action == 'showlatest') {
$options = array('history' => $this->item['value_type'], 'itemids' => array_keys($this->items), 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN);
if ($this->action == 'showlatest') {
$options['limit'] = 500;
} elseif ($this->action == 'showvalues') {
$config = select_config();
$options['time_from'] = $stime - 10;
// some seconds to allow script to execute
$options['time_till'] = $stime + $this->timeline['period'];
$options['limit'] = $config['search_limit'];
}
// text log
if (isset($iv_string[$this->item['value_type']])) {
$isManyItems = count($this->items) > 1;
$useLogItem = $this->item['value_type'] == ITEM_VALUE_TYPE_LOG;
$useEventLogItem = strpos($this->item['key_'], 'eventlog[') === 0;
if (empty($this->plaintext)) {
$historyTable = new CTableInfo(_('No values found.'));
$historyTable->setHeader(array(_('Timestamp'), $isManyItems ? _('Item') : null, $useLogItem ? _('Local time') : null, $useEventLogItem && $useLogItem ? _('Source') : null, $useEventLogItem && $useLogItem ? _('Severity') : null, $useEventLogItem && $useLogItem ? _('Event ID') : null, _('Value')), 'header');
}
if (!zbx_empty($this->filter) && in_array($this->filterTask, array(FILTER_TASK_SHOW, FILTER_TASK_HIDE))) {
$options['search'] = array('value' => $this->filter);
if ($this->filterTask == FILTER_TASK_HIDE) {
$options['excludeSearch'] = 1;
}
}
$options['sortfield'] = 'id';
$historyData = API::History()->get($options);
foreach ($historyData as $data) {
$data['value'] = encode_log(trim($data['value'], "\r\n"));
if (empty($this->plaintext)) {
$item = $this->items[$data['itemid']];
$host = reset($item['hosts']);
$color = null;
if (isset($this->filter) && !zbx_empty($this->filter)) {
$contain = zbx_stristr($data['value'], $this->filter);
if ($contain && $this->filterTask == FILTER_TASK_MARK) {
$color = $this->markColor;
}
if (!$contain && $this->filterTask == FILTER_TASK_INVERT_MARK) {
$color = $this->markColor;
}
switch ($color) {
case MARK_COLOR_RED:
$color = 'red';
break;
case MARK_COLOR_GREEN:
$color = 'green';
break;
case MARK_COLOR_BLUE:
$color = 'blue';
break;
}
}
$row = array(nbsp(zbx_date2str(_('Y.M.d H:i:s'), $data['clock'])));
if ($isManyItems) {
$row[] = $host['name'] . NAME_DELIMITER . $item['name_expanded'];
}
if ($useLogItem) {
$row[] = $data['timestamp'] == 0 ? '-' : zbx_date2str(HISTORY_LOG_LOCALTIME_DATE_FORMAT, $data['timestamp']);
// if this is a eventLog item, showing additional info
if ($useEventLogItem) {
$row[] = zbx_empty($data['source']) ? '-' : $data['source'];
$row[] = $data['severity'] == 0 ? '-' : new CCol(get_item_logtype_description($data['severity']), get_item_logtype_style($data['severity']));
$row[] = $data['logeventid'] == 0 ? '-' : $data['logeventid'];
}
}
$row[] = new CCol($data['value'], 'pre');
$newRow = new CRow($row);
if (!is_null($color)) {
$newRow->setAttribute('class', $color);
}
$historyTable->addRow($newRow);
} else {
$output[] = zbx_date2str(HISTORY_LOG_ITEM_PLAINTEXT, $data['clock']);
$output[] = "\t" . $data['clock'] . "\t" . htmlspecialchars($data['value']) . "\n";
}
}
if (empty($this->plaintext)) {
$output[] = $historyTable;
}
} else {
if (empty($this->plaintext)) {
$historyTable = new CTableInfo(_('No values found.'));
$historyTable->setHeader(array(_('Timestamp'), _('Value')));
}
$options['sortfield'] = array('itemid', 'clock');
$historyData = API::History()->get($options);
foreach ($historyData as $data) {
//.........这里部分代码省略.........
示例9: CCol
if ($eventLogItem) {
$row[] = zbx_empty($data['source']) ? '-' : $data['source'];
$row[] = $data['severity'] == 0 ? '-' : new CCol(get_item_logtype_description($data['severity']), get_item_logtype_style($data['severity']));
$row[] = $data['logeventid'] == 0 ? '-' : $data['logeventid'];
}
}
$data['value'] = encode_log(trim($data['value'], "\r\n"));
$row[] = new CCol($data['value'], 'pre');
$crow = new CRow($row);
if (is_null($color_style)) {
$min_color = 0x98;
$max_color = 0xf8;
$int_color = ($max_color - $min_color) / count($_REQUEST['itemid']);
$int_color *= array_search($data['itemid'], $_REQUEST['itemid']);
$int_color += $min_color;
$crow->setAttribute('style', 'background-color: ' . sprintf("#%X%X%X", $int_color, $int_color, $int_color));
} else {
if (!is_null($color_style)) {
$crow->setClass($color_style);
}
}
$table->addRow($crow);
// Plain Text
if (!isset($_REQUEST['plaintext'])) {
continue;
}
$ptData['body'][] = zbx_date2str(S_HISTORY_LOG_ITEM_PLAINTEXT, $data['clock']);
$ptData['body'][] = "\t" . $data['clock'] . "\t" . htmlspecialchars($data['value']) . "\n";
}
} else {
// NUMERIC, FLOAT
示例10: CComboBox
$numSpan->addClass('rowNum');
$profileLinksComboBox = new CComboBox('iconmap[mappings][#{iconmappingid}][inventory_link]');
$profileLinksComboBox->addItems($this->data['inventoryList']);
$profileLinksComboBox->setAttribute('disabled', 'disabled');
$expressionTextBox = new CTextBox('iconmap[mappings][#{iconmappingid}][expression]');
$expressionTextBox->setAttribute('maxlength', 64);
$expressionTextBox->setAttribute('disabled', 'disabled');
$iconsComboBox = new CComboBox('iconmap[mappings][#{iconmappingid}][iconid]', $firstIconId);
$iconsComboBox->addClass('mappingIcon');
$iconsComboBox->addItems($this->data['iconList']);
$iconsComboBox->setAttribute('disabled', 'disabled');
$iconPreviewImage = new CImg('imgstore.php?iconid=' . $firstIconId . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null, 'pointer preview');
$iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $firstIconId);
// row template
$hiddenRowTemplate = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), $numSpan, $profileLinksComboBox, $expressionTextBox, $iconsComboBox, $iconPreviewImage, new CButton('remove', _('Remove'), '', 'link_menu removeMapping')), 'hidden');
$hiddenRowTemplate->setAttribute('id', 'rowTpl');
$iconMapTable->addRow($hiddenRowTemplate);
// add row button
$iconMapTable->addRow(new CCol(new CButton('addMapping', _('Add'), '', 'link_menu'), null, 7));
// <default icon row>
$numSpan = new CSpan($i++ . ':');
$numSpan->addClass('rowNum');
$iconsComboBox = new CComboBox('iconmap[default_iconid]', $this->data['iconmap']['default_iconid']);
$iconsComboBox->addClass('mappingIcon');
$iconsComboBox->addItems($this->data['iconList']);
$iconPreviewImage = new CImg('imgstore.php?iconid=' . $this->data['iconmap']['default_iconid'] . '&width=' . ZBX_ICON_PREVIEW_WIDTH . '&height=' . ZBX_ICON_PREVIEW_HEIGHT, _('Preview'), null, null, 'pointer preview');
$iconPreviewImage->setAttribute('data-image-full', 'imgstore.php?iconid=' . $this->data['iconmap']['default_iconid']);
$iconMapTable->addRow(array(new CCol(_('Default'), null, 4), $iconsComboBox, $iconPreviewImage));
// </default icon row>
$iconMapTab->addRow(_('Mappings'), new CDiv($iconMapTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
$iconMapView = new CTabView();
示例11: CTextBox
$cmbWeekTo->AddItem($day_num, $day_str);
}
$time_param->AddRow(array(S_FROM, $cmbWeekFrom, new CTextBox('new_service_time[from]', 'H:i', 9)));
$time_param->AddRow(array(S_TILL, $cmbWeekTo, new CTextBox('new_service_time[to]', 'H:i', 9)));
$frmService->AddVar('new_service_time[note]', '');
}
$frmService->AddRow(S_NEW_SERVICE_TIME, array($cmbTimeType, BR(), $time_param, new CButton('add_service_time', 'add', 'javascript: document.forms[0].action += \'?sform=1\'; submit();')));
//trigger
$frmService->AddRow(S_LINK_TO_TRIGGER_Q, new CCheckBox("linktrigger", $linktrigger, "javascript: display_element('trigger_name');", 1));
if ($triggerid > 0) {
$trigger = expand_trigger_description($triggerid);
} else {
$trigger = "";
}
$row = new CRow(array(new CCol(S_TRIGGER, 'form_row_l'), new CCol(array(new CTextBox("trigger", $trigger, 64, 'yes'), new CButton("btn1", S_SELECT, "return PopUp('popup.php?" . "dstfrm=" . $frmService->GetName() . "&dstfld1=triggerid&dstfld2=trigger" . "&srctbl=triggers&srcfld1=triggerid&srcfld2=description&real_hosts=1');", 'T')), 'form_row_r')));
$row->setAttribute('id', 'trigger_name');
$row->setAttribute('style', $linktrigger == 1 ? '' : 'display: none;');
$frmService->AddRow($row);
$frmService->AddVar("triggerid", $triggerid);
//---------
//sortorder
$frmService->AddRow(S_SORT_ORDER_0_999, new CTextBox("sortorder", $sortorder, 3));
//---------
$frmService->AddItemToBottomRow(new CButton("save_service", S_SAVE, 'javascript: document.forms[0].action += \'?saction=1\';'));
if (isset($service["serviceid"])) {
$frmService->AddItemToBottomRow(SPACE);
$frmService->AddItemToBottomRow(new CButtonDelete("Delete selected service?", url_param("form") . url_param("serviceid") . '&saction=1'));
}
$frmService->AddItemToBottomRow(SPACE);
$cb = new CButton('cancel', S_CANCEL);
$cb->SetType('button');
示例12: 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) {
//.........这里部分代码省略.........
示例13: makeRow
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;
}
示例14: CDiv
$openState = CProfile::get('web.latest.toggle_other', null, $host['hostid']);
$toggle = new CDiv(null, 'app-list-toggle icon-plus-9x9');
if ($openState) {
$toggle->addClass('icon-minus-9x9');
}
$toggle->setAttribute('data-app-id', '0_' . $host['hostid']);
$toggle->setAttribute('data-open-state', $openState);
$hostName = null;
if (!$singleHostSelected) {
$hostName = new CSpan($host['name'], 'link_menu menu-host' . ($host['status'] == HOST_STATUS_NOT_MONITORED ? ' not-monitored' : ''));
$hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $hostScripts[$host['hostid']]));
}
// add toggle row
$table->addRow(array($toggle, '', $hostName, new CCol(array(bold('- ' . 'other' . ' -'), ' (' . _n('%1$s Item', '%1$s Items', $dbHost['item_cnt']) . ')'), null, $filter['showDetails'] ? 10 : 5)), 'odd_row');
// add toggle sub rows
foreach ($appRows as $row) {
$row->setAttribute('parent_app_id', '0_' . $host['hostid']);
$row->addClass('odd_row');
if (!$openState) {
$row->addClass('hidden');
}
$table->addRow($row);
}
}
$goBox = new CComboBox('graphtype', GRAPH_TYPE_STACKED, null, array(GRAPH_TYPE_STACKED => _('Display stacked graph'), GRAPH_TYPE_NORMAL => _('Display graph')));
$goBox->setAttribute('id', 'action');
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$form->addItem(array($table, get_table_header(array($goBox, $goButton))));
$latestWidget->addItem($form);
$latestWidget->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例15: makeRow
private function makeRow($id)
{
$table = new CTable();
$table->setCellSpacing(0);
$table->setCellPadding(0);
$table->setAttribute('border', '0');
$table->setAttribute('height', '100%');
$tr = $this->makeSImgStr($id);
$td = new CCol($this->tree[$id]['caption']);
$td->setAttribute('style', 'height: 100%; vertical-align: top; white-space: normal; padding-right: 10px; padding-left: 2px;');
$tr->addItem($td);
$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) {
$td = new CCol($this->tree[$id][$value]);
$td->setAttribute('style', ' padding-right: 10px; padding-left: 2px;');
$tr->addItem($td);
}
return $tr;
}