本文整理汇总了PHP中CDiv::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP CDiv::addItem方法的具体用法?PHP CDiv::addItem怎么用?PHP CDiv::addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDiv
的用法示例。
在下文中一共展示了CDiv::addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setHeader
/**
* Set widget header.
*
* @param string|array|CTag $caption
* @param string|array|CTag $icons
*/
public function setHeader($caption = null, $icons = SPACE)
{
zbx_value2array($icons);
if ($caption === null && $icons !== null) {
$caption = SPACE;
}
$this->header = new CDiv(null, 'nowrap ui-corner-all ui-widget-header header');
$this->header->addItem(array($icons, $caption));
}
示例2: setHeader
/**
* Set widget header.
*
* @param string $caption
* @param arrayi $controls
*/
public function setHeader($caption, array $controls = [], $cursor_move = false)
{
$this->header = (new CDiv())->addClass('dashbrd-widget-head')->addItem((new CTag('h4', true, $caption))->setId($this->id . '_header'));
if ($cursor_move) {
$this->header->addClass(ZBX_STYLE_CURSOR_MOVE);
}
if ($controls) {
$this->header->addItem(new CList($controls));
}
return $this;
}
示例3: __construct
public function __construct($header, $messages = [], $buttons = [])
{
parent::__construct($header);
$this->addClass(ZBX_STYLE_MSG_BAD);
$this->addClass('msg-global');
if ($messages) {
parent::addItem((new CDiv((new CList($messages))->addClass(ZBX_STYLE_MSG_DETAILS_BORDER)))->addClass(ZBX_STYLE_MSG_DETAILS));
}
parent::addItem((new CDiv($buttons))->addClass('msg-buttons'));
}
示例4: addValue
public function addValue($name, $value, $checked = null)
{
$this->count++;
$id = str_replace(array('[', ']'), array('_'), $this->name) . '_' . $this->count;
$radio = new CInput('radio', $this->name, $value);
$radio->attr('id', zbx_formatDomId($id));
if (strcmp($value, $this->value) == 0 || !is_null($checked) || $checked) {
$radio->attr('checked', 'checked');
}
$label = new CLabel($name, $id);
$outerDiv = new CDiv(array($radio, $label));
if ($this->orientation == self::ORIENTATION_HORIZONTAL) {
$outerDiv->addClass('inlineblock');
}
parent::addItem($outerDiv);
}
示例5: get
public function get()
{
$this->cleanItems();
parent::addItem($this->_header);
if (is_null($this->state)) {
$this->state = true;
}
$div = new CDiv($this->_body, 'body');
$div->setAttribute('id', $this->domid);
if (!$this->state) {
$div->setAttribute('style', 'display: none;');
if ($this->_footer) {
$this->_footer->setAttribute('style', 'display: none;');
}
}
parent::addItem($div);
parent::addItem($this->_footer);
return $this;
}
示例6: CCol
$maintenancePeriodTable->addRow(array(new CCol(timeperiod_type2str($timeperiod['timeperiod_type']), 'nowrap'), new CCol(shedule2str($timeperiod), 'wraptext'), new CCol(zbx_date2age(0, $timeperiod['period']), 'nowrap'), new CCol(array(new CSubmit('edit_timeperiodid[' . $id . ']', _('Edit'), null, 'link_menu'), SPACE . SPACE, new CSubmit('del_timeperiodid[' . $id . ']', _('Remove'), null, 'link_menu')), 'nowrap')));
if (isset($timeperiod['timeperiodid'])) {
$maintenanceForm->addVar('timeperiods[' . $id . '][timeperiodid]', $timeperiod['timeperiodid']);
}
$maintenanceForm->addVar('timeperiods[' . $id . '][timeperiod_type]', $timeperiod['timeperiod_type']);
$maintenanceForm->addVar('timeperiods[' . $id . '][every]', $timeperiod['every']);
$maintenanceForm->addVar('timeperiods[' . $id . '][month]', $timeperiod['month']);
$maintenanceForm->addVar('timeperiods[' . $id . '][dayofweek]', $timeperiod['dayofweek']);
$maintenanceForm->addVar('timeperiods[' . $id . '][day]', $timeperiod['day']);
$maintenanceForm->addVar('timeperiods[' . $id . '][start_time]', $timeperiod['start_time']);
$maintenanceForm->addVar('timeperiods[' . $id . '][start_date]', $timeperiod['start_date']);
$maintenanceForm->addVar('timeperiods[' . $id . '][period]', $timeperiod['period']);
}
$periodsDiv = new CDiv($maintenancePeriodTable, 'objectgroup inlineblock border_dotted');
if (!isset($_REQUEST['new_timeperiod'])) {
$periodsDiv->addItem(new CSubmit('new_timeperiod', _('New'), null, 'link_menu'));
}
$maintenancePeriodFormList->addRow(_('Periods'), $periodsDiv);
if (isset($_REQUEST['new_timeperiod'])) {
if (is_array($_REQUEST['new_timeperiod']) && isset($_REQUEST['new_timeperiod']['id'])) {
$saveLabel = _('Save');
} else {
$saveLabel = _('Add');
}
$footer = array(new CSubmit('add_timeperiod', $saveLabel, null, 'link_menu'), SPACE . SPACE, new CSubmit('cancel_new_timeperiod', _('Cancel'), null, 'link_menu'));
$maintenancePeriodFormList->addRow(_('Maintenance period'), new CDiv(array(get_timeperiod_form(), $footer), 'objectgroup inlineblock border_dotted'));
}
/*
* Hosts & groups tab
*/
$hostsAndGroupsFormList = new CFormList('hostsAndGroupsFormList');
示例7: getAvailabilityTable
/**
* Returns zbx, snmp, jmx, ipmi availability status icons.
*
* @param type $host
*
* @return CDiv
*/
function getAvailabilityTable($host)
{
$arr = array('zbx', 'snmp', 'jmx', 'ipmi');
// for consistency in foreach loop
$host['zbx_available'] = $host['available'];
$host['zbx_error'] = $host['error'];
$ad = new CDiv(null, 'invisible');
foreach ($arr as $val) {
switch ($host[$val . '_available']) {
case HOST_AVAILABLE_TRUE:
$ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'available');
break;
case HOST_AVAILABLE_FALSE:
$ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unavailable');
$ai->setHint($host[$val . '_error'], '', 'on');
break;
case HOST_AVAILABLE_UNKNOWN:
$ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unknown');
break;
}
$ad->addItem($ai);
}
return $ad;
}
示例8: getAvailabilityTable
/**
* Returns zbx, snmp, jmx, ipmi availability status icons and the discovered host lifetime indicator.
*
* @param type $host
*
* @return CDiv
*/
function getAvailabilityTable($host)
{
$arr = array('zbx', 'snmp', 'jmx', 'ipmi');
// for consistency in foreach loop
$host['zbx_available'] = $host['available'];
$host['zbx_error'] = $host['error'];
$ad = new CDiv(null, 'invisible');
foreach ($arr as $val) {
switch ($host[$val . '_available']) {
case HOST_AVAILABLE_TRUE:
$ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'available');
break;
case HOST_AVAILABLE_FALSE:
$ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unavailable');
$ai->setHint($host[$val . '_error'], '', 'on');
break;
case HOST_AVAILABLE_UNKNOWN:
$ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unknown');
break;
}
$ad->addItem($ai);
}
// discovered host lifetime indicator
if ($host['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $host['hostDiscovery']['ts_delete']) {
$deleteError = new CDiv(SPACE, 'status_icon status_icon_extra iconwarning');
$deleteError->setHint(_s('The host is not discovered anymore and will be deleted in %1$s (on %2$s at %3$s).', zbx_date2age($host['hostDiscovery']['ts_delete']), zbx_date2str(_('d M Y'), $host['hostDiscovery']['ts_delete']), zbx_date2str(_('H:i:s'), $host['hostDiscovery']['ts_delete'])));
$ad->addItem($deleteError);
}
return $ad;
}
示例9: show
/**
* Output profiling data.
*/
public function show()
{
global $DB;
$debug_str = '<a name="debug"></a>';
$debug_str .= '******************** ' . _('Script profiler') . ' ********************' . '<br>';
$totalScriptTime = $this->stopTime - $this->startTime;
$totalTimeStr = _s('Total time: %s', round($totalScriptTime, 6));
if ($totalTimeStr > $this->slowScriptTime) {
$totalTimeStr = '<b>' . $totalTimeStr . '</b>';
}
$debug_str .= $totalTimeStr . '<br>';
$sqlTotalTimeStr = _s('Total SQL time: %s', $this->sqlTotalTime);
if ($sqlTotalTimeStr > $this->slowTotalSqlTime) {
$sqlTotalTimeStr = '<b>' . $sqlTotalTimeStr . '</b>';
}
$debug_str .= $sqlTotalTimeStr . '<br>';
if (isset($DB) && isset($DB['SELECT_COUNT'])) {
$debug_str .= _s('SQL count: %s (selects: %s | executes: %s)', count($this->sqlQueryLog), $DB['SELECT_COUNT'], $DB['EXECUTE_COUNT']) . '<br>';
}
$debug_str .= _s('Peak memory usage: %s', mem2str($this->getMemoryPeak())) . '<br>';
$debug_str .= _s('Memory limit: %s', ini_get('memory_limit')) . '<br>';
$debug_str .= '<br>';
foreach ($this->apiLog as $i => $apiCall) {
$debug_str .= '<div style="border-bottom: 1px dotted gray; margin-bottom: 20px;">';
list($class, $method, $params, $result, $file, $line) = $apiCall;
// api method
$debug_str .= '<div style="padding-bottom: 10px;">';
$debug_str .= $i + 1 . '. <b>' . $class . '->' . $method . '</b> [' . $file . ':' . $line . ']';
$debug_str .= '</div>';
// parameters
$debug_str .= '<table><tr><td style="width: 300px" valign="top">Parameters:';
foreach ($params as $p) {
$debug_str .= '<pre>' . print_r(CHtml::encode($p), true) . '</pre>';
}
$debug_str .= '</td>';
// result
$debug_str .= '<td valign="top">Result:<pre>' . print_r(CHtml::encode($result), true) . '</pre></td>';
$debug_str .= '</tr></table>';
$debug_str .= '</div>';
}
$debug_str .= '<br>';
foreach ($this->sqlQueryLog as $query) {
$time = $query[0];
$sql = htmlspecialchars($query[1], ENT_QUOTES, 'UTF-8');
if (strpos($sql, 'SELECT ') !== false) {
$sqlString = '<span style="color: green; font-size: 1.2em;">' . $sql . '</span>';
} else {
$sqlString = '<span style="color: blue; font-size: 1.2em;">' . $sql . '</span>';
}
$sqlString = 'SQL (' . $time . '): ' . $sqlString . '<br>';
if ($time > $this->slowSqlQueryTime) {
$sqlString = '<b>' . $sqlString . '</b>';
}
$debug_str .= $sqlString;
$callStackString = '<span style="font-style: italic;">' . $this->formatCallStack($query[2]) . '</span>' . '<br>' . '<br>';
$debug_str .= rtrim($callStackString, '-> ') . '</span>' . '<br>' . '<br>';
}
$debug = new CDiv(null, 'textcolorstyles');
$debug->attr('name', 'zbx_debug_info');
$debug->attr('style', 'display: none; overflow: auto; width: 95%; border: 1px #777777 solid; margin: 4px; padding: 4px;');
$debug->addItem(array(BR(), new CJSscript($debug_str), BR()));
$debug->show();
}
示例10: CTable
$graph_params_tbl = new CTable();
$graph_params_tbl->attr('class', 'formtable');
$graph_params_tbl->addStyle("width: 100%; align: left; border-width: 0 0 0 0;");
$graph_params_tbl->setCellPadding(0);
$graph_params_tbl->setCellSpacing(0);
$graph_params_tbl1 = new CTable();
$graph_params_tbl1->attr('class', 'formtable');
$graph_params_tbl1->addStyle("width: 100%; align: left; border-width: 0 0 0 0;");
$graph_params_tbl1->addRow(array(_('Create graph'), $graphCreate, _('Name') . ':', $graphName, _('Width') . ':', $graphWidth, _('Height') . ':', $graphHeight, _('Graph type') . ':', $cmbGraphType));
$graph_params_tbl2 = new CTable();
$graph_params_tbl2->attr('class', 'formtable');
$graph_params_tbl2->addStyle("width: 100%; align: left; border-width: 0 0 0 0;");
$graph_params_tbl2->addRow(array(_('Function') . ':', $cmbGraphFunc, _('Draw style') . ':', $cmbDrawType, _('Y axis side') . ':', $cmbYaxisside));
$graph_params_tbl->addRow($graph_params_tbl1);
$graph_params_tbl->addRow($graph_params_tbl2);
$graph_params_div->addItem($graph_params_tbl);
$graph_params_w->addItem($graph_params_div);
$right_tab->addRow($empty_row);
$right_tab->addRow($graph_params_w);
//Mib selector
$cmbMibs = new CComboBox('mib', $mib, 'javascript: submit();');
//Action srow
$action_w = new CWidget();
$action_w->setClass('header');
$action_w->addHeader(array(new CButton('save', _('Save'), 'onSaveItems()'), SPACE, new CButton('clear', _('Clear'), 'onClearItems()')));
$right_tab->addRow($empty_row);
$right_tab->addRow($action_w);
// Left panel
$td_l = new CCol($left_tab);
$td_l->setAttribute('valign', 'top');
$td_l->setAttribute('width', $left_widget_width);
示例11: CSpan
$tr_desc = new CSpan($description);
// host JS menu {{{
$hosts_list = array();
foreach ($trigger['hosts'] as $trigger_host) {
$host = $hosts[$trigger_host['hostid']];
$hosts_span = new CDiv(null, 'floatleft');
// fetch scripts for the host JS menu
$menuScripts = array();
if (isset($scripts_by_hosts[$trigger_host['hostid']])) {
foreach ($scripts_by_hosts[$trigger_host['hostid']] as $script) {
$menuScripts[] = array('scriptid' => $script['scriptid'], 'confirmation' => $script['confirmation'], 'name' => $script['name']);
}
}
$hosts_name = new CSpan($trigger_host['name'], 'link_menu menu-host');
$hosts_name->setAttribute('data-menu', array('scripts' => $menuScripts, 'hostid' => $trigger_host['hostid'], 'hasScreens' => (bool) $host['screens'], 'hasInventory' => (bool) $host['inventory']));
$hosts_span->addItem($hosts_name);
// add maintenance icon with hint if host is in maintenance
if ($trigger_host['maintenance_status']) {
$mntIco = new CDiv(null, 'icon-maintenance-inline');
$maintenances = API::Maintenance()->get(array('maintenanceids' => $trigger_host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
if ($maintenance = reset($maintenances)) {
$hint = $maintenance['name'] . ' [' . ($trigger_host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
if (isset($maintenance['description'])) {
// double quotes mandatory
$hint .= "\n" . $maintenance['description'];
}
$mntIco->setHint($hint);
$mntIco->addClass('pointer');
}
$hosts_span->addItem($mntIco);
}
示例12: make_sorting_header
function make_sorting_header($obj, $tabfield, $url = '')
{
global $page;
$sortorder = $_REQUEST['sort'] == $tabfield && $_REQUEST['sortorder'] == ZBX_SORT_UP ? ZBX_SORT_DOWN : ZBX_SORT_UP;
$link = new Curl($url);
if (empty($url)) {
$link->formatGetArguments();
}
$link->setArgument('sort', $tabfield);
$link->setArgument('sortorder', $sortorder);
$url = $link->getUrl();
if ($page['type'] != PAGE_TYPE_HTML && defined('ZBX_PAGE_MAIN_HAT')) {
$script = "javascript: return updater.onetime_update('" . ZBX_PAGE_MAIN_HAT . "','" . $url . "');";
} else {
$script = "javascript: redirect('" . $url . "');";
}
zbx_value2array($obj);
$div = new CDiv();
$div->setAttribute('style', 'float:left;');
foreach ($obj as $enum => $el) {
if (is_object($el) || $el === SPACE) {
$div->addItem($el);
} else {
$div->addItem(new CSpan($el, 'underline'));
}
}
$div->addItem(SPACE);
$img = null;
if (isset($_REQUEST['sort']) && $tabfield == $_REQUEST['sort']) {
if ($sortorder == ZBX_SORT_UP) {
$img = new CDiv(SPACE, 'icon_sortdown');
} else {
$img = new CDiv(SPACE, 'icon_sortup');
}
$img->setAttribute('style', 'float: left;');
}
$col = new CCol(array($div, $img), 'nowrap hover_grey');
$col->setAttribute('onclick', $script);
return $col;
}
示例13: make_popup_eventlist
/**
* Create table with trigger description and events.
*
* @param array $trigger An array of trigger data.
* @param string $trigger['triggerid'] Trigger ID to select events.
* @param string $trigger['description'] Trigger description.
* @param string $trigger['url'] Trigger URL.
* @param string $trigger['lastEvent']['eventid'] Last event ID
* @param string $backurl URL to return to.
*
* @return CDiv
*/
function make_popup_eventlist($trigger, $backurl)
{
// Show trigger description and URL.
$div = new CDiv();
if ($trigger['comments'] !== '') {
$div->addItem((new CDiv())->addItem(zbx_str2links($trigger['comments']))->addClass(ZBX_STYLE_OVERLAY_DESCR));
}
if ($trigger['url'] !== '') {
$div->addItem((new CDiv())->addItem(new CLink($trigger['url'], $trigger['url']))->addClass(ZBX_STYLE_OVERLAY_DESCR_URL));
}
// Select and show events.
$config = select_config();
$table = new CTableInfo();
// If acknowledges are turned on, we show 'ack' column.
if ($config['event_ack_enable']) {
$table->setHeader([_('Time'), _('Status'), _('Duration'), _('Age'), _('Ack')]);
} else {
$table->setHeader([_('Time'), _('Status'), _('Duration'), _('Age')]);
}
if ($trigger['lastEvent']) {
$events = API::Event()->get(['source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'output' => API_OUTPUT_EXTEND, 'objectids' => [$trigger['triggerid']], 'eventid_till' => $trigger['lastEvent']['eventid'], 'select_acknowledges' => API_OUTPUT_COUNT, 'sortfield' => ['clock', 'eventid'], 'sortorder' => ZBX_SORT_DOWN, 'limit' => ZBX_WIDGET_ROWS]);
$lclock = time();
foreach ($events as $event) {
$duration = zbx_date2age($lclock, $event['clock']);
$lclock = $event['clock'];
$eventStatusSpan = new CSpan(trigger_value2str($event['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($eventStatusSpan, $event['value'], $event['clock'], $event['acknowledged']);
$table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), $eventStatusSpan, $duration, zbx_date2age($event['clock']), $config['event_ack_enable'] ? getEventAckState($event, $backurl) : null]);
}
}
$div->addItem($table);
return $div;
}
示例14: bodyToString
function bodyToString($destroy = true)
{
$left = new CDiv(null, 'left');
$left->addItem(new CDiv(null, 'setup_logo'));
$left->addItem(new CDiv(ZABBIX_VERSION, 'setup_version'));
$left->addItem(new CDiv($this->getList(), 'left_menu'));
$link1 = new CLink('www.zabbix.com', 'http://www.zabbix.com/', null, null, true);
$link1->setAttribute('target', '_blank');
$link2 = new CLink('GPL v2', 'http://www.zabbix.com/license.php', null, null, true);
$link2->setAttribute('target', '_blank');
$licence = new CDiv(array($link1, BR(), ' Licensed under ', $link2), 'setup_wizard_licence');
$left->addItem($licence);
$right = new CDiv(null, 'right');
if ($this->getStep() == 0) {
$right->addItem(new CDiv(null, 'blank_title'));
$right->addItem(new CDiv($this->getState(), 'blank_under_title'));
$container = new CDiv(array($left, $right), 'setup_wizard setup_wizard_welcome');
} else {
$right->addItem(new CDiv($this->stage[$this->getStep()]['title'], 'setup_title'));
$right->addItem(new CDiv($this->getState(), 'under_title'));
$container = new CDiv(array($left, $right), 'setup_wizard');
}
if (isset($this->stage[$this->getStep() + 1])) {
$next = new CSubmit('next[' . $this->getStep() . ']', _('Next') . ' >>');
} else {
$next = new CSubmit('finish', _('Finish'));
}
if (isset($this->HIDE_CANCEL_BUTTON) && $this->HIDE_CANCEL_BUTTON) {
$cancel = null;
} else {
$cancel = new CDiv(new CSubmit('cancel', _('Cancel')), 'footer_left');
}
if ($this->DISABLE_NEXT_BUTTON) {
$next->setEnabled(false);
}
$footer = new CDiv(array($cancel, new CDiv(array($this->getStep() != 0 ? new CSubmit('back[' . $this->getStep() . ']', '<< ' . _('Previous')) : null, $next), 'footer_right')), 'footer');
$container->addItem($footer);
return parent::bodyToString($destroy) . $container->ToString();
}
示例15: bodyToString
function bodyToString($destroy = true)
{
$left = new CDiv(null, 'left');
$left->addItem(new CDiv($this->getList(), 'left_menu'));
$link1 = new CLink('www.zabbix.com', 'http://www.zabbix.com/', null, null, true);
$link1->setAttribute('target', '_blank');
$link2 = new CLink('GPL v2', 'http://www.zabbix.com/license.php', null, null, true);
$link2->setAttribute('target', '_blank');
$licence = new CDiv(array($link1, BR(), ' Licensed under ', $link2), 'setup_wizard_licence');
$left->addItem($licence);
$right = new CDiv(null, 'right');
if ($this->getStep() == 0) {
$right->addItem(new CDiv(null, 'blank_title'));
$right->addItem(new CDiv($this->getState(), 'blank_under_title'));
$container = new CDiv(array($left, $right), 'setup_wizard setup_wizard_welcome');
} else {
$right->addItem(new CDiv($this->stage[$this->getStep()]['title'], 'setup_title'));
$right->addItem(new CDiv($this->getState(), 'under_title'));
$container = new CDiv(array($left, $right), 'setup_wizard');
}
if (isset($this->stage[$this->getStep() + 1])) {
$next = new CSubmit('next[' . $this->getStep() . ']', _('Next') . SPACE . '»');
} else {
$next = new CSubmit('finish', _('Finish'));
}
if (isset($this->HIDE_CANCEL_BUTTON) && $this->HIDE_CANCEL_BUTTON) {
$cancel = null;
} else {
$cancel = new CDiv(new CSubmit('cancel', _('Cancel')), 'footer_left');
}
if ($this->DISABLE_NEXT_BUTTON) {
$next->setEnabled(false);
}
// if the user is not logged in (first setup run) hide the "previous" button on the final step
if ($this->getStep() && (CWebUser::$data && CWebUser::getType() == USER_TYPE_SUPER_ADMIN || $this->getStep() < 5)) {
$back = new CSubmit('back[' . $this->getStep() . ']', '«' . SPACE . _('Previous'));
} else {
$back = null;
}
$footer = new CDiv(array($cancel, new CDiv(array($back, $next), 'footer_right')), 'footer');
$container->addItem($footer);
return parent::bodyToString($destroy) . $container->ToString();
}