<?php
class CControllerWidgetGraphView extends CControllerWidget {
public function __construct() {
parent::__construct();
$this->setType(WIDGET_GRAPH);
$this->setValidationRules([
'name' => 'string',
'edit_mode' => 'in 0,1',
'dashboardid' => 'db dashboard.dashboardid',
'fields' => 'json',
'dynamic_hostid' => 'db hosts.hostid',
'content_width' => 'int32',
'content_height' => 'int32'
]);
}
protected function doAction() {
$fields = $this->getForm()->getFieldsData();
$edit_mode = (int) $this->getInput('edit_mode', 0);
$width = (int) $this->getInput('content_width', 100);
$height = (int) $this->getInput('content_height', 100);
$dynamic_hostid = $this->getInput('dynamic_hostid', 0);
$resourceid = null;
$profileIdx = 'web.dashboard.filter';
$profileIdx2 = $this->getInput('dashboardid', 0);
$is_resource_available = true;
$header_name = $this->getDefaultName();
if ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_GRAPH && $fields['graphid']) {
$resource_type = SCREEN_RESOURCE_GRAPH;
$resourceid = reset($fields['graphid']);
$graph_dims = getGraphDims($resourceid);
$graph_dims['graphHeight'] = $height;
$graph_dims['width'] = $width;
}
elseif ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_SIMPLE_GRAPH && $fields['itemid']) {
$resource_type = SCREEN_RESOURCE_SIMPLE_GRAPH;
$resourceid = $fields['itemid'][0];
$graph_dims = getGraphDims();
$graph_dims['graphHeight'] = $height;
$graph_dims['width'] = $width;
}
else {
$resource_type = null;
$graph_dims = getGraphDims();
}
$graph_dims['shiftYtop'] = CLineGraphDraw::DEFAULT_TOP_BOTTOM_PADDING;
$time_control_data = [
'id' => '',
'containerid' => '',
'objDims' => $graph_dims,
'loadSBox' => 0,
'loadImage' => 1,
'reloadOnAdd' => 1
];
$flickerfreescreen_data = [
'id' => '',
'interval' => CWebUser::getRefresh(),
'timeline' => [],
'resourcetype' => $resource_type,
'profileIdx' => $profileIdx,
'profileIdx2' => $profileIdx2
];
$is_template_dashboard = ($this->getContext() === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD);