File: CScreenBuilder.php

package info (click to toggle)
zabbix 1%3A4.0.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 83,104 kB
  • sloc: php: 162,280; ansic: 154,778; sql: 96,479; sh: 5,281; makefile: 1,340; java: 1,068; cpp: 227; perl: 41; xml: 29
file content (703 lines) | stat: -rw-r--r-- 18,746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
<?php
/*
** Zabbix
** Copyright (C) 2001-2019 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/


class CScreenBuilder {

	/**
	 * Switch on/off flicker-free screens auto refresh.
	 *
	 * @var boolean
	 */
	public $isFlickerfree;

	/**
	 * Page file.
	 *
	 * @var string
	 */
	public $pageFile;

	/**
	 * Screen data
	 *
	 * @var array
	 */
	public $screen;

	/**
	 * Display mode
	 *
	 * @var int
	 */
	public $mode;

	/**
	 * @see Request timestamp
	 */
	public $timestamp;

	/**
	 * Host id
	 *
	 * @var string
	 */
	public $hostid;

	/**
	 * Profile table entity name #1
	 *
	 * @var string
	 */
	public $profileIdx;

	/**
	 * Profile table record id belongs to #1
	 *
	 * @var int
	 */
	public $profileIdx2;

	/**
	 * Time control timeline
	 *
	 * @var array
	 */
	public $timeline;

	/**
	 * Init screen data.
	 *
	 * @param array		$options
	 * @param boolean	$options['isFlickerfree']
	 * @param string	$options['pageFile']
	 * @param int		$options['mode']
	 * @param int		$options['timestamp']
	 * @param int		$options['hostid']
	 * @param string	$options['profileIdx']      Profile idx value.
	 * @param int		$options['profileIdx2']     Profile idx2 value.
	 * @param string	$options['from']            Start time of selected time period.
	 * @param string	$options['to']              End time of selected time period.
	 * @param array		$options['screen']
	 */
	public function __construct(array $options = []) {
		$this->isFlickerfree = isset($options['isFlickerfree']) ? $options['isFlickerfree'] : true;
		$this->mode = isset($options['mode']) ? $options['mode'] : SCREEN_MODE_SLIDESHOW;
		$this->timestamp = !empty($options['timestamp']) ? $options['timestamp'] : time();
		$this->hostid = !empty($options['hostid']) ? $options['hostid'] : null;

		// get page file
		if (!empty($options['pageFile'])) {
			$this->pageFile = $options['pageFile'];
		}
		else {
			global $page;
			$this->pageFile = $page['file'];
		}

		// get screen
		if (!empty($options['screen'])) {
			$this->screen = $options['screen'];
		}
		elseif (array_key_exists('screenid', $options) && $options['screenid'] > 0) {
			$this->screen = API::Screen()->get([
				'screenids' => $options['screenid'],
				'output' => API_OUTPUT_EXTEND,
				'selectScreenItems' => API_OUTPUT_EXTEND,
				'editable' => ($this->mode == SCREEN_MODE_EDIT)
			]);

			if (!empty($this->screen)) {
				$this->screen = reset($this->screen);
			}
			else {
				access_deny();
			}
		}

		// calculate time
		$this->profileIdx = !empty($options['profileIdx']) ? $options['profileIdx'] : '';
		$this->profileIdx2 = !empty($options['profileIdx2']) ? $options['profileIdx2'] : null;

		$this->timeline = getTimeSelectorPeriod([
			'profileIdx' => $this->profileIdx,
			'profileIdx2' => $this->profileIdx2,
			'from' => array_key_exists('from', $options) ? $options['from'] : null,
			'to' => array_key_exists('to', $options) ? $options['to'] : null
		]);
	}

	/**
	 * Get particular screen object.
	 *
	 * @static
	 *
	 * @param array		$options
	 * @param int		$options['resourcetype']
	 * @param int		$options['screenitemid']
	 * @param int		$options['hostid']
	 * @param array		$options['screen']
	 * @param int		$options['screenid']
	 *
	 * @return CScreenBase
	 */
	public static function getScreen(array $options = []) {
		if (!array_key_exists('resourcetype', $options)) {
			$options['resourcetype'] = null;

			// get resourcetype from screenitem
			if (!array_key_exists('screenitem', $options) && array_key_exists('screenitemid', $options)) {
				if (array_key_exists('hostid', $options) && $options['hostid'] > 0) {
					$options['screenitem'] = API::TemplateScreenItem()->get([
						'screenitemids' => $options['screenitemid'],
						'hostids' => $options['hostid'],
						'output' => API_OUTPUT_EXTEND
					]);
				}
				else {
					$options['screenitem'] = API::ScreenItem()->get([
						'screenitemids' => $options['screenitemid'],
						'output' => API_OUTPUT_EXTEND
					]);
				}
				$options['screenitem'] = reset($options['screenitem']);
			}

			if (is_array($options['screenitem']) && array_key_exists('screenitem', $options)
					&& array_key_exists('resourcetype', $options['screenitem'])) {
				$options['resourcetype'] = $options['screenitem']['resourcetype'];
			}
			else {
				return null;
			}
		}

		if ($options['resourcetype'] === null) {
			return null;
		}

		// get screen
		switch ($options['resourcetype']) {
			case SCREEN_RESOURCE_GRAPH:
				return new CScreenGraph($options);

			case SCREEN_RESOURCE_SIMPLE_GRAPH:
				return new CScreenSimpleGraph($options);

			case SCREEN_RESOURCE_MAP:
				return new CScreenMap($options);

			case SCREEN_RESOURCE_PLAIN_TEXT:
				return new CScreenPlainText($options);

			case SCREEN_RESOURCE_HOST_INFO:
				return new CScreenHostsInfo($options);

			case SCREEN_RESOURCE_TRIGGER_INFO:
				return new CScreenTriggersInfo($options);

			case SCREEN_RESOURCE_SERVER_INFO:
				return new CScreenServerInfo($options);

			case SCREEN_RESOURCE_CLOCK:
				return new CScreenClock($options);

			case SCREEN_RESOURCE_SCREEN:
				return new CScreenScreen($options);

			case SCREEN_RESOURCE_TRIGGER_OVERVIEW:
				return new CScreenTriggersOverview($options);

			case SCREEN_RESOURCE_DATA_OVERVIEW:
				return new CScreenDataOverview($options);

			case SCREEN_RESOURCE_URL:
				$options = self::appendTemplatedScreenOption($options);
				return new CScreenUrl($options);

			case SCREEN_RESOURCE_ACTIONS:
				return new CScreenActions($options);

			case SCREEN_RESOURCE_EVENTS:
				return new CScreenEvents($options);

			case SCREEN_RESOURCE_HOSTGROUP_TRIGGERS:
				return new CScreenHostgroupTriggers($options);

			case SCREEN_RESOURCE_SYSTEM_STATUS:
				return new CScreenSystemStatus($options);

			case SCREEN_RESOURCE_HOST_TRIGGERS:
				return new CScreenHostTriggers($options);

			case SCREEN_RESOURCE_HISTORY:
				return new CScreenHistory($options);

			case SCREEN_RESOURCE_CHART:
				return new CScreenChart($options);

			case SCREEN_RESOURCE_LLD_GRAPH:
				$options = self::appendTemplatedScreenOption($options);
				return new CScreenLldGraph($options);

			case SCREEN_RESOURCE_LLD_SIMPLE_GRAPH:
				$options = self::appendTemplatedScreenOption($options);
				return new CScreenLldSimpleGraph($options);

			case SCREEN_RESOURCE_HTTPTEST_DETAILS:
				return new CScreenHttpTestDetails($options);

			case SCREEN_RESOURCE_DISCOVERY:
				return new CScreenDiscovery($options);

			case SCREEN_RESOURCE_HTTPTEST:
				return new CScreenHttpTest($options);

			case SCREEN_RESOURCE_PROBLEM:
				return new CScreenProblem($options);

			default:
				return null;
		}
	}

	/**
	 * Appends boolean option 'isTemplatedScreen' to ouput options.
	 *
	 * @param array $options
	 *
	 * @return array
	 */
	protected static function appendTemplatedScreenOption(array $options) {
		if (array_key_exists('screen', $options)) {
			$options['isTemplatedScreen'] = (bool) $options['screen']['templateid'];
		}
		elseif (array_key_exists('screenid', $options) && $options['screenid'] > 0) {
			$options['isTemplatedScreen'] = (bool) API::TemplateScreen()->get([
				'screenids' => [$options['screenid']],
				'output' => []
			]);
		}

		return $options;
	}

	/**
	 * Process screen with particular screen objects.
	 *
	 * @return CTable
	 */
	public function show() {
		if (empty($this->screen)) {
			return new CTableInfo();
		}

		$skipedFields = [];
		$screenitems = [];
		$emptyScreenColumns = [];

		// calculate table columns and rows
		foreach ($this->screen['screenitems'] as $screenitem) {
			$screenitems[] = $screenitem;

			for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) {
				for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) {
					if ($i != 0 || $j != 0) {
						if (!isset($skipedFields[$screenitem['y'] + $i])) {
							$skipedFields[$screenitem['y'] + $i] = [];
						}
						$skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1;
					}
				}
			}
		}

		// create screen table
		$screenTable = (new CTable())
			->setId(self::makeScreenTableId($this->screen['screenid']))
			->addClass(ZBX_STYLE_SCREEN_TABLE);

		if ($this->mode == SCREEN_MODE_EDIT) {
			$screenTable->addClass(ZBX_STYLE_DASHED_BORDER);
		}

		// action top row
		if ($this->mode == SCREEN_MODE_EDIT) {
			$newColumns = [(new CCol())->addClass(ZBX_STYLE_CELL_WIDTH)];

			for ($i = 0, $size = $this->screen['hsize']; $i < $size; $i++) {
				if ($this->screen['hsize'] >= SCREEN_MAX_SIZE) {
					$link = (new CDiv('+'))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addClass(ZBX_STYLE_DISABLED);
				}
				else {
					$link = (new CLink('+', 'screenedit.php?screenid='.$this->screen['screenid'].
						url_param('templateid').'&add_col='.$i
					))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addSID();
				}

				$newColumns[] = (new CCol($link))
					->addClass(ZBX_STYLE_CENTER)
					->addClass(ZBX_STYLE_MIDDLE);
			}

			if ($this->screen['hsize'] >= SCREEN_MAX_SIZE) {
				$link = (new CDiv('+'))
					->addClass(ZBX_STYLE_TREEVIEW_PLUS)
					->addClass(ZBX_STYLE_DISABLED);
			}
			else {
				$link = (new CLink('+', 'screenedit.php?screenid='.$this->screen['screenid'].url_param('templateid').
					'&add_col='.$this->screen['hsize']
				))
					->addClass(ZBX_STYLE_TREEVIEW_PLUS)
					->addSID();
			}

			$newColumns[] = (new CCol($link))
				->addClass(ZBX_STYLE_CENTER)
				->addClass(ZBX_STYLE_MIDDLE)
				->addClass(ZBX_STYLE_CELL_WIDTH);

			$screenTable->addRow($newColumns);
		}

		for ($r = 0; $r < $this->screen['vsize']; $r++) {
			$newColumns = [];
			$emptyScreenRow = true;

			// action left cell
			if ($this->mode == SCREEN_MODE_EDIT) {
				if ($this->screen['vsize'] >= SCREEN_MAX_SIZE) {
					$link = (new CDiv('+'))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addClass(ZBX_STYLE_DISABLED);
				}
				else {
					$link = (new CLink('+', 'screenedit.php?screenid='.$this->screen['screenid'].
						url_param('templateid').'&add_row='.$r
					))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addSID();
				}

				$newColumns[] = (new CCol($link))
					->addClass(ZBX_STYLE_CENTER)
					->addClass(ZBX_STYLE_MIDDLE);
			}

			for ($c = 0; $c < $this->screen['hsize']; $c++) {
				if (isset($skipedFields[$r][$c])) {
					continue;
				}

				// screen item
				$isEditForm = false;
				$screenitem = [];

				foreach ($screenitems as $tmprow) {
					if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
						$screenitem = $tmprow;
						break;
					}
				}

				if (empty($screenitem)) {
					$screenitem = [
						'screenitemid' => 0,
						'resourcetype' => 0,
						'resourceid' => 0,
						'width' => 0,
						'height' => 0,
						'colspan' => 1,
						'rowspan' => 1,
						'elements' => 0,
						'valign' => VALIGN_DEFAULT,
						'halign' => HALIGN_DEFAULT,
						'style' => 0,
						'url' => '',
						'dynamic' => 0,
						'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC
					];
				}

				if (!empty($screenitem['screenitemid'])) {
					$emptyScreenRow = false;
					$emptyScreenColumns[$c] = true;
				}

				// action
				if ($this->mode == SCREEN_MODE_EDIT) {
					if ($screenitem['screenitemid'] != 0) {
						$action = 'screenedit.php?form=update'.url_params(['screenid', 'templateid']).
							'&screenitemid='.$screenitem['screenitemid'];
					}
					else {
						$action = 'screenedit.php?form=update'.url_params(['screenid', 'templateid']).'&x='.$c.'&y='.$r;
					}
				}
				else {
					$action = null;
				}

				// edit form cell
				if ($this->mode == SCREEN_MODE_EDIT
						&& (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update')
						&& ((isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r)
								|| (isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0))) {
					$screenView = new CView('monitoring.screen.constructor.edit', ['screen' => $this->screen]);
					$item = $screenView->render();
					$isEditForm = true;
				}
				// screen cell
				elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) {
					$screenBase = CScreenBuilder::getScreen([
						'screen' => $this->screen,
						'screenid' => $this->screen['screenid'],
						'isFlickerfree' => $this->isFlickerfree,
						'pageFile' => $this->pageFile,
						'mode' => $this->mode,
						'timestamp' => $this->timestamp,
						'hostid' => $this->hostid,
						'profileIdx' => $this->profileIdx,
						'profileIdx2' => $this->profileIdx2,
						'timeline' => $this->timeline,
						'resourcetype' => $screenitem['resourcetype'],
						'screenitem' => $screenitem
					]);

					if (!empty($screenBase)) {
						$screenBase->action = $action;

						$item = $screenBase->get();
					}
					else {
						$item = null;
					}
				}
				// change/empty cell
				elseif ($this->mode == SCREEN_MODE_EDIT) {
					$item =[
						(new CDiv(
							(new CLink(_x('Change', 'verb'), $action))->addClass('empty_change_link')
						))->addClass(ZBX_STYLE_CENTER)
					];
				}
				else {
					$item = null;
				}

				if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) {
					$item = (new CDiv($item))
						->addClass('draggable')
						->setId('position_'.$r.'_'.$c)
						->setAttribute('data-xcoord', $c)
						->setAttribute('data-ycoord', $r);
				}

				// colspan/rowspan
				$newColumn = (new CCol($item))->addClass('screenitem');

				if ($screenitem['halign'] == HALIGN_CENTER || $isEditForm) {
					$newColumn->addClass(ZBX_STYLE_CENTER);
				}
				elseif ($screenitem['halign'] == HALIGN_LEFT) {
					$newColumn->addClass(ZBX_STYLE_LEFT);
				}
				elseif ($screenitem['halign'] == HALIGN_RIGHT) {
					$newColumn->addClass(ZBX_STYLE_RIGHT);
				}

				if ($screenitem['valign'] == VALIGN_MIDDLE || $isEditForm) {
					$newColumn->addClass(ZBX_STYLE_MIDDLE);
				}
				elseif ($screenitem['valign'] == VALIGN_TOP) {
					$newColumn->addClass(ZBX_STYLE_TOP);
				}
				elseif ($screenitem['valign'] == VALIGN_BOTTOM) {
					$newColumn->addClass(ZBX_STYLE_BOTTOM);
				}

				if ($screenitem['colspan'] > 1) {
					$newColumn->setColSpan($screenitem['colspan']);
				}
				if ($screenitem['rowspan'] > 1) {
					$newColumn->setRowSpan($screenitem['rowspan']);
				}
				$newColumns[] = $newColumn;
			}

			// action right cell
			if ($this->mode == SCREEN_MODE_EDIT) {
				if ($this->screen['vsize'] == SCREEN_MIN_SIZE) {
					$link = (new CDiv('−'))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addClass(ZBX_STYLE_DISABLED);
				}
				else {
					$link = (new CLink('−', 'screenedit.php?screenid='.$this->screen['screenid'].
						url_param('templateid').'&rmv_row='.$r
					))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addSID();
					if (!$emptyScreenRow) {
						$link->addConfirmation(_('This screen row is not empty. Delete it?'));
					}
				}

				$newColumns[] = (new CCol($link))
					->addClass(ZBX_STYLE_CENTER)
					->addClass(ZBX_STYLE_MIDDLE);
			}
			$screenTable->addRow(new CRow($newColumns));
		}

		// action bottom row
		if ($this->mode == SCREEN_MODE_EDIT) {
			if ($this->screen['vsize'] >= SCREEN_MAX_SIZE) {
				$link = (new CDiv('+'))
					->addClass(ZBX_STYLE_TREEVIEW_PLUS)
					->addClass(ZBX_STYLE_DISABLED);
			}
			else {
				$link = (new CLink('+', 'screenedit.php?screenid='.$this->screen['screenid'].url_param('templateid').
					'&add_row='.$this->screen['vsize']
				))
					->addClass(ZBX_STYLE_TREEVIEW_PLUS)
					->addSID();
			}

			$newColumns = [
				(new CCol($link))
					->addClass(ZBX_STYLE_CENTER)
					->addClass(ZBX_STYLE_MIDDLE)
			];

			for ($i = 0; $i < $this->screen['hsize']; $i++) {
				if ($this->screen['hsize'] == SCREEN_MIN_SIZE) {
					$link = (new CDiv('−'))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addClass(ZBX_STYLE_DISABLED);
				}
				else {
					$link = (new CLink('−', 'screenedit.php?screenid='.$this->screen['screenid'].
						url_param('templateid').'&rmv_col='.$i
					))
						->addClass(ZBX_STYLE_TREEVIEW_PLUS)
						->addSID();

					if (array_key_exists($i, $emptyScreenColumns)) {
						$link->addConfirmation(_('This screen column is not empty. Delete it?'));
					}
				}

				$newColumns[] = (new CCol($link))
					->addClass(ZBX_STYLE_CENTER)
					->addClass(ZBX_STYLE_MIDDLE);
			}

			$newColumns[] = '';
			$screenTable->addRow($newColumns);
		}

		return $screenTable;
	}

	/**
	 * Insert javascript to create scroll in time control.
	 *
	 * @static
	 *
	 * @param array $timeline
	 */
	private static function insertScreenScrollJs(array $timeline) {
		$obj_data = [
			'id' => 'scrollbar',
			'mainObject' => 1
		];

		zbx_add_post_js('timeControl.addObject("scrollbar", '.zbx_jsvalue($timeline).', '.zbx_jsvalue($obj_data).');');
	}

	/**
	 * Insert javascript to make time control synchronizes with NOW!
	 *
	 * @static
	 */
	public static function insertScreenRefreshTimeJs() {
		zbx_add_post_js('timeControl.useTimeRefresh('.CWebUser::getRefresh().');');
	}

	/**
	 * Insert javascript to init screens.
	 *
	 * @static
	 *
	 * @param string $screenid
	 */
	public static function insertInitScreenJs($screenid) {
		zbx_add_post_js('init_screen("'.$screenid.'", "'.self::makeScreenTableId($screenid).'", "'.$screenid.'");');
	}

	/**
	 * Insert javascript to start time control rendering.
	 *
	 * @static
	 */
	public static function insertProcessObjectsJs() {
		zbx_add_post_js('timeControl.processObjects();');
	}

	/**
	 * Insert javascript to clean all screen items.
	 *
	 * @static
	 */
	public static function insertScreenCleanJs() {
		zbx_add_post_js('window.flickerfreeScreen.cleanAll();');
	}

	/**
	 * Insert javascript for standard screens.
	 *
	 * @param array $timeline
	 *
	 * @static
	 */
	public static function insertScreenStandardJs(array $timeline) {
		CScreenBuilder::insertScreenScrollJs($timeline);
		CScreenBuilder::insertScreenRefreshTimeJs();
		CScreenBuilder::insertProcessObjectsJs();
	}

	/**
	 * Creates a string for screen table ID attribute.
	 *
	 * @param string $screenId
	 *
	 * @return string
	 */
	protected static function makeScreenTableId($screenId) {
		return 'screentable_'.$screenId;
	}
}