1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22class CTableInfo extends CTable { 23 24 protected $message; 25 26 public function __construct() { 27 parent::__construct(); 28 29 $this->addClass(ZBX_STYLE_LIST_TABLE); 30 $this->setNoDataMessage(_('No data found.')); 31 $this->addMakeVerticalRotationJs = false; 32 } 33 34 public function toString($destroy = true) { 35 $tableid = $this->getId(); 36 37 if (!$tableid) { 38 $tableid = uniqid('t', true); 39 $tableid = str_replace('.', '', $tableid); 40 $this->setId($tableid); 41 } 42 43 $string = parent::toString($destroy); 44 45 if ($this->addMakeVerticalRotationJs) { 46 $string .= get_js( 47 'var makeVerticalRotationForTable = function() {'. 48 'jQuery("#'.$tableid.'").makeVerticalRotation();'. 49 '}'. 50 "\n". 51 'if (!jQuery.isReady) {'. 52 'jQuery(document).ready(makeVerticalRotationForTable);'. 53 '}'. 54 'else {'. 55 'makeVerticalRotationForTable();'. 56 '}', 57 true 58 ); 59 } 60 61 return $string; 62 } 63 64 public function setNoDataMessage($message) { 65 $this->message = $message; 66 67 return $this; 68 } 69 70 /** 71 * Rotate table header text vertical. 72 * Cells must be marked with "vertical_rotation" class. 73 */ 74 public function makeVerticalRotation() { 75 $this->addMakeVerticalRotationJs = true; 76 77 return $this; 78 } 79 80 protected function endToString() { 81 $ret = ''; 82 if ($this->rownum == 0 && $this->message !== null) { 83 $ret .= $this->prepareRow(new CCol($this->message), ZBX_STYLE_NOTHING_TO_SHOW)->toString(); 84 } 85 $ret .= parent::endToString(); 86 87 return $ret; 88 } 89} 90