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 CImg extends CTag { 23 24 public $preloader; 25 26 public function __construct($src, $name = null, $width = null, $height = null) { 27 if (is_null($name)) { 28 $name = 'image'; 29 } 30 31 parent::__construct('img'); 32 $this->setAttribute('border', 0); 33 $this->setName($name); 34 $this->setAltText($name); 35 $this->setSrc($src); 36 $this->setWidth($width); 37 $this->setHeight($height); 38 } 39 40 public function setSrc($value) { 41 $this->setAttribute('src', $value); 42 return $this; 43 } 44 45 public function setAltText($value = null) { 46 $this->setAttribute('alt', $value); 47 return $this; 48 } 49 50 public function setMap($value = null) { 51 if (is_null($value)) { 52 $this->deleteOption('usemap'); 53 } 54 else { 55 $value = '#'.ltrim($value, '#'); 56 $this->setAttribute('usemap', $value); 57 } 58 return $this; 59 } 60 61 public function setWidth($value = null) { 62 if (is_null($value)) { 63 $this->removeAttribute('width'); 64 } 65 else { 66 $this->setAttribute('width', $value); 67 } 68 return $this; 69 } 70 71 public function setHeight($value = null) { 72 if (is_null($value)) { 73 $this->removeAttribute('height'); 74 } 75 else { 76 $this->setAttribute('height', $value); 77 } 78 return $this; 79 } 80} 81