本文整理匯總了PHP中CDiv::addClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP CDiv::addClass方法的具體用法?PHP CDiv::addClass怎麽用?PHP CDiv::addClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CDiv
的用法示例。
在下文中一共展示了CDiv::addClass方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: toString
public function toString($destroy = true)
{
if (count($this->tabs) == 1) {
$this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget');
$header = reset($this->headers);
$header = new CDiv($header);
$header->addClass('ui-corner-all ui-widget-header header');
$header->setAttribute('id', 'tab_' . key($this->headers));
$this->addItem($header);
$tab = reset($this->tabs);
$tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget');
$this->addItem($tab);
} else {
$headersList = new CList();
foreach ($this->headers as $id => $header) {
$tabLink = new CLink($header, '#' . $id, null, null, false);
$tabLink->setAttribute('id', 'tab_' . $id);
$headersList->addItem($tabLink);
}
$this->addItem($headersList);
$this->addItem($this->tabs);
$options = array();
if (!is_null($this->selectedTab)) {
$options['selected'] = $this->selectedTab;
}
if ($this->rememberTab) {
$options['cookie'] = array();
}
zbx_add_post_js('jQuery("#' . $this->id . '").tabs(' . zbx_jsvalue($options, true) . ').show();');
}
return parent::toString($destroy);
}
示例2: 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);
}
示例3: toString
public function toString($destroy = true)
{
if (count($this->tabs) == 1) {
$this->setAttribute('class', 'min-width ui-tabs ui-widget ui-widget-content ui-corner-all widget');
$header = reset($this->headers);
$header = new CDiv($header);
$header->addClass('ui-corner-all ui-widget-header header');
$header->setAttribute('id', 'tab_' . key($this->headers));
$this->addItem($header);
$tab = reset($this->tabs);
$tab->addClass('ui-tabs ui-tabs-panel ui-widget ui-widget-content ui-corner-all widget');
$this->addItem($tab);
} else {
$headersList = new CList();
foreach ($this->headers as $id => $header) {
$tabLink = new CLink($header, '#' . $id, null, null, false);
$tabLink->setAttribute('id', 'tab_' . $id);
$headersList->addItem($tabLink);
}
$this->addItem($headersList);
$this->addItem($this->tabs);
if ($this->selectedTab === null) {
$activeTab = get_cookie('tab', 0);
$createEvent = '';
} else {
$activeTab = $this->selectedTab;
$createEvent = 'create: function() { jQuery.cookie("tab", ' . $this->selectedTab . '); },';
}
$disabledTabs = $this->disabledTabs === null ? '' : 'disabled: ' . CJs::encodeJson($this->disabledTabs) . ',';
zbx_add_post_js('
jQuery("#' . $this->id . '").tabs({
' . $createEvent . '
' . $disabledTabs . '
active: ' . $activeTab . ',
activate: function(event, ui) {
jQuery.cookie("tab", ui.newTab.index().toString());
}
})
.css("visibility", "visible");');
}
return parent::toString($destroy);
}
示例4: make_latest_issues
/**
* Create DIV with latest problem triggers.
*
* If no sortfield and sortorder are defined, the sort indicater in the column name will not be displayed.
*
* @param array $filter['screenid']
* @param array $filter['groupids']
* @param array $filter['hostids']
* @param array $filter['maintenance']
* @param int $filter['extAck']
* @param int $filter['severity']
* @param int $filter['limit']
* @param string $filter['sortfield']
* @param string $filter['sortorder']
* @param string $filter['backUrl']
*
* @return CDiv
*/
function make_latest_issues(array $filter = array())
{
// hide the sort indicator if no sortfield and sortorder are given
$showSortIndicator = isset($filter['sortfield']) || isset($filter['sortorder']);
if (!isset($filter['sortfield'])) {
$filter['sortfield'] = 'lastchange';
}
if (!isset($filter['sortorder'])) {
$filter['sortorder'] = ZBX_SORT_DOWN;
}
$options = array('groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE));
$triggers = API::Trigger()->get(array_merge($options, array('withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'output' => array('triggerid', 'state', 'error', 'url', 'expression', 'description', 'priority', 'lastchange'), 'selectHosts' => array('hostid', 'name'), 'selectLastEvent' => array('eventid', 'acknowledged', 'objectid', 'clock', 'ns'), 'sortfield' => $filter['sortfield'], 'sortorder' => $filter['sortorder'], 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT)));
// don't use withLastEventUnacknowledged and skipDependent because of performance issues
$triggersTotalCount = API::Trigger()->get(array_merge($options, array('countOutput' => true)));
// get acknowledges
$eventIds = array();
foreach ($triggers as $trigger) {
if ($trigger['lastEvent']) {
$eventIds[] = $trigger['lastEvent']['eventid'];
}
}
if ($eventIds) {
$eventAcknowledges = API::Event()->get(array('eventids' => $eventIds, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true));
}
foreach ($triggers as $tnum => $trigger) {
// if trigger is lost (broken expression) we skip it
if (empty($trigger['hosts'])) {
unset($triggers[$tnum]);
continue;
}
$host = reset($trigger['hosts']);
$trigger['hostid'] = $host['hostid'];
$trigger['hostname'] = $host['name'];
if ($trigger['lastEvent']) {
$trigger['lastEvent']['acknowledges'] = isset($eventAcknowledges[$trigger['lastEvent']['eventid']]) ? $eventAcknowledges[$trigger['lastEvent']['eventid']]['acknowledges'] : null;
}
$triggers[$tnum] = $trigger;
}
$hostIds = zbx_objectValues($triggers, 'hostid');
// get hosts
$hosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'), 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
// actions
$actions = getEventActionsStatHints($eventIds);
// ack params
$ackParams = isset($filter['screenid']) ? array('screenid' => $filter['screenid']) : array();
$config = select_config();
// indicator of sort field
if ($showSortIndicator) {
$sortDiv = new CDiv(SPACE, $filter['sortorder'] === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
$sortDiv->addStyle('float: left');
$hostHeaderDiv = new CDiv(array(_('Host'), SPACE));
$hostHeaderDiv->addStyle('float: left');
$issueHeaderDiv = new CDiv(array(_('Issue'), SPACE));
$issueHeaderDiv->addStyle('float: left');
$lastChangeHeaderDiv = new CDiv(array(_('Time'), SPACE));
$lastChangeHeaderDiv->addStyle('float: left');
}
$table = new CTableInfo(_('No events found.'));
$table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $showSortIndicator && $filter['sortfield'] === 'hostname' ? array($hostHeaderDiv, $sortDiv) : _('Host'), $showSortIndicator && $filter['sortfield'] === 'priority' ? array($issueHeaderDiv, $sortDiv) : _('Issue'), $showSortIndicator && $filter['sortfield'] === 'lastchange' ? array($lastChangeHeaderDiv, $sortDiv) : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
$scripts = API::Script()->getScriptsByHosts($hostIds);
// triggers
foreach ($triggers as $trigger) {
$host = $hosts[$trigger['hostid']];
$hostName = new CSpan($host['name'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
// add maintenance icon with hint if host is in maintenance
$maintenanceIcon = null;
if ($host['maintenance_status']) {
$maintenanceIcon = new CDiv(null, 'icon-maintenance-abs');
// get maintenance
$maintenances = API::Maintenance()->get(array('maintenanceids' => $host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
if ($maintenance = reset($maintenances)) {
$hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
if (isset($maintenance['description'])) {
// double quotes mandatory
$hint .= "\n" . $maintenance['description'];
}
$maintenanceIcon->setHint($hint);
$maintenanceIcon->addClass('pointer');
}
$hostName->addClass('left-to-icon-maintenance-abs');
}
//.........這裏部分代碼省略.........
示例5: CRow
} else {
$row = new CRow(array('', $checkbox, $hostColumn, new CCol(new CSpan($item['name_expanded'], $stateCss . ' item')), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), new CCol($actions, $stateCss)));
}
$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];
$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) {
示例6: setFooter
/**
* Set widget footer.
*
* @param string|array|CTag $footer
* @param bool $right
*/
public function setFooter($list)
{
$this->footer = $list;
$this->footer->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
return $this;
}
示例7: CSpan
}
$hostName = new CSpan($triggerHost['name'], 'link_menu');
$hostName->setMenuPopup(getMenuPopupHost($hosts[$triggerHost['hostid']], $scripts));
$hostDiv = new CDiv($hostName);
// add maintenance icon with hint if host is in maintenance
if ($triggerHost['maintenance_status']) {
$maintenanceIcon = new CDiv(null, 'icon-maintenance-inline');
$maintenances = API::Maintenance()->get(array('maintenanceids' => $triggerHost['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
if ($maintenance = reset($maintenances)) {
$hint = $maintenance['name'] . ' [' . ($triggerHost['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
if (isset($maintenance['description'])) {
// double quotes mandatory
$hint .= "\n" . $maintenance['description'];
}
$maintenanceIcon->setHint($hint);
$maintenanceIcon->addClass('pointer');
}
$hostDiv->addItem($maintenanceIcon);
}
// add comma after hosts, except last
if (next($trigger['hosts'])) {
$hostDiv->addItem(',' . SPACE);
}
$hostList[] = $hostDiv;
}
// host
$hostColumn = new CCol($hostList);
$hostColumn->addStyle('white-space: normal;');
// status
$statusSpan = new CSpan(trigger_value2str($trigger['value']));
// add colors and blinking to span depending on configuration and trigger parameters
示例8: CSpan
}
$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);
}
// add comma after hosts, except last
if (next($trigger['hosts'])) {
$hosts_span->addItem(',' . SPACE);
}
$hosts_list[] = $hosts_span;
}
$host = new CCol($hosts_list);
$host->addStyle('white-space: normal;');
// }}} host JS menu
$statusSpan = new CSpan(trigger_value2str($trigger['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($statusSpan, $trigger['value'], $trigger['lastchange'], $config['event_ack_enable'] ? $trigger['event_count'] == 0 : false);