$graphForm->addVar('graphid', $this->data['graphid']);
}
$graphForm->addVar('ymin_itemid', $this->data['ymin_itemid']);
$graphForm->addVar('ymax_itemid', $this->data['ymax_itemid']);
// create form list
$graphFormList = new CFormList('graphFormList');
if (!empty($this->data['templates'])) {
    $graphFormList->addRow(_('Parent graphs'), $this->data['templates']);
}
$nameTextBox = new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE);
$nameTextBox->attr('autofocus', 'autofocus');
$graphFormList->addRow(_('Name'), $nameTextBox);
$graphFormList->addRow(_('Width'), new CNumericBox('width', $this->data['width'], 5));
$graphFormList->addRow(_('Height'), new CNumericBox('height', $this->data['height'], 5));
$graphTypeComboBox = new CComboBox('graphtype', $this->data['graphtype'], 'submit()');
$graphTypeComboBox->addItems(graphType());
$graphFormList->addRow(_('Graph type'), $graphTypeComboBox);
// append legend to form list
$graphFormList->addRow(_('Show legend'), new CCheckBox('show_legend', $this->data['show_legend'], null, 1));
// append graph types to form list
if ($this->data['graphtype'] == GRAPH_TYPE_NORMAL || $this->data['graphtype'] == GRAPH_TYPE_STACKED) {
    $graphFormList->addRow(_('Show working time'), new CCheckBox('show_work_period', $this->data['show_work_period'], null, 1));
    $graphFormList->addRow(_('Show triggers'), new CCheckBox('show_triggers', $this->data['show_triggers'], null, 1));
    if ($this->data['graphtype'] == GRAPH_TYPE_NORMAL) {
        // percent left
        $percentLeftTextBox = new CTextBox('percent_left', $this->data['percent_left'], 6, false, 7);
        $percentLeftCheckbox = new CCheckBox('visible[percent_left]', 1, 'javascript: showHideVisible("percent_left");', 1);
        if (isset($this->data['visible']) && isset($this->data['visible']['percent_left'])) {
            $percentLeftTextBox->attr('style', '');
            $percentLeftCheckbox->setChecked(1);
        } elseif ($this->data['percent_left'] == 0) {
Example #2
0
    $sortfield = getPageSortField('name');
    $sortorder = getPageSortOrder();
    // get graphs
    $options = array('hostids' => $data['hostid'] ? $data['hostid'] : null, 'groupids' => !$data['hostid'] && $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'discoveryids' => empty($_REQUEST['parent_discoveryid']) ? null : get_request('parent_discoveryid'), 'editable' => true, 'output' => array('graphid', 'name', 'graphtype'), 'limit' => $config['search_limit'] + 1);
    $data['graphs'] = empty($_REQUEST['parent_discoveryid']) ? API::Graph()->get($options) : API::GraphPrototype()->get($options);
    if ($sortfield == 'graphtype') {
        foreach ($data['graphs'] as $gnum => $graph) {
            $data['graphs'][$gnum]['graphtype'] = graphType($graph['graphtype']);
        }
    }
    order_result($data['graphs'], $sortfield, $sortorder);
    $data['paging'] = getPagingLine($data['graphs'], array('graphid'), array('hostid' => get_request('hostid'), 'parent_discoveryid' => get_request('parent_discoveryid')));
    // get graphs after paging
    $options = array('graphids' => zbx_objectValues($data['graphs'], 'graphid'), 'output' => array('graphid', 'name', 'templateid', 'graphtype', 'width', 'height'), 'selectDiscoveryRule' => array('itemid', 'name'), 'selectHosts' => $data['hostid'] ? null : array('name'), 'selectTemplates' => $data['hostid'] ? null : array('name'));
    $data['graphs'] = empty($_REQUEST['parent_discoveryid']) ? API::Graph()->get($options) : API::GraphPrototype()->get($options);
    foreach ($data['graphs'] as $gnum => $graph) {
        $data['graphs'][$gnum]['graphtype'] = graphType($graph['graphtype']);
    }
    // nodes
    if ($data['displayNodes']) {
        foreach ($data['graphs'] as $key => $graph) {
            $data['graphs'][$key]['nodename'] = get_node_name_by_elid($graph['graphid'], true);
        }
    }
    order_result($data['graphs'], $sortfield, $sortorder);
    // render view
    $graphView = new CView('configuration.graph.list', $data);
    $graphView->render();
    $graphView->show();
}
require_once dirname(__FILE__) . '/include/page_footer.php';
}
// create form
$graphForm = (new CForm())->setName('graphForm')->addVar('form', $this->data['form'])->addVar('hostid', $this->data['hostid'])->addVar('ymin_itemid', $this->data['ymin_itemid'])->addVar('ymax_itemid', $this->data['ymax_itemid']);
if (!empty($this->data['parent_discoveryid'])) {
    $graphForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']);
}
if (!empty($this->data['graphid'])) {
    $graphForm->addVar('graphid', $this->data['graphid']);
}
// create form list
$graphFormList = new CFormList('graphFormList');
$is_templated = (bool) $this->data['templates'];
if ($is_templated) {
    $graphFormList->addRow(_('Parent graphs'), $this->data['templates']);
}
$graphFormList->addRow(_('Name'), (new CTextBox('name', $this->data['name'], $is_templated))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAttribute('autofocus', 'autofocus'))->addRow(_('Width'), (new CNumericBox('width', $this->data['width'], 5, $is_templated))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH))->addRow(_('Height'), (new CNumericBox('height', $this->data['height'], 5, $is_templated))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH))->addRow(_('Graph type'), (new CComboBox('graphtype', $this->data['graphtype'], 'submit()', graphType()))->setEnabled(!$is_templated))->addRow(_('Show legend'), (new CCheckBox('show_legend'))->setChecked($this->data['show_legend'] == 1)->setEnabled(!$is_templated));
// append graph types to form list
if ($this->data['graphtype'] == GRAPH_TYPE_NORMAL || $this->data['graphtype'] == GRAPH_TYPE_STACKED) {
    $graphFormList->addRow(_('Show working time'), (new CCheckBox('show_work_period'))->setChecked($this->data['show_work_period'] == 1)->setEnabled(!$is_templated));
    $graphFormList->addRow(_('Show triggers'), (new CCheckbox('show_triggers'))->setchecked($this->data['show_triggers'] == 1)->setEnabled(!$is_templated));
    if ($this->data['graphtype'] == GRAPH_TYPE_NORMAL) {
        // percent left
        $percentLeftTextBox = (new CTextBox('percent_left', $this->data['percent_left'], $is_templated, 7))->setWidth(ZBX_TEXTAREA_TINY_WIDTH);
        $percentLeftCheckbox = (new CCheckBox('visible[percent_left]'))->setChecked(true)->onClick('javascript: showHideVisible("percent_left");')->setEnabled(!$is_templated);
        if (isset($this->data['visible']) && isset($this->data['visible']['percent_left'])) {
            $percentLeftCheckbox->setChecked(true);
        } elseif ($this->data['percent_left'] == 0) {
            $percentLeftTextBox->addStyle('visibility: hidden;');
            $percentLeftCheckbox->setChecked(false);
        }
        $graphFormList->addRow(_('Percentile line (left)'), [$percentLeftCheckbox, SPACE, $percentLeftTextBox]);