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$widget = (new CWidget()) 22 ->setTitle(_('Images')) 23 ->setControls((new CForm()) 24 ->cleanItems() 25 ->setAttribute('aria-label', _('Main filter')) 26 ->addItem((new CList()) 27 ->addItem(makeAdministrationGeneralMenu('adm.images.php')) 28 ) 29 ); 30 31$imageForm = (new CForm('post', null, 'multipart/form-data')) 32 ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) 33 ->addVar('form', $this->data['form']); 34if (isset($this->data['imageid'])) { 35 $imageForm->addVar('imageid', $this->data['imageid']); 36} 37$imageForm->addVar('imagetype', $this->data['imagetype']); 38 39// append form list 40$imageFormList = (new CFormList('imageFormList')) 41 ->addRow( 42 (new CLabel(_('Name'), 'name'))->setAsteriskMark(), 43 (new CTextBox('name', $this->data['imagename'], false, 64)) 44 ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) 45 ->setAttribute('autofocus', 'autofocus') 46 ->setAriaRequired() 47 ) 48 ->addRow( 49 (new CLabel(_('Upload'), 'image'))->setAsteriskMark(), 50 (new CFile('image'))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) 51 ->setAriaRequired() 52 ); 53 54if (isset($this->data['imageid'])) { 55 if ($this->data['imagetype'] == IMAGE_TYPE_BACKGROUND) { 56 $imageFormList->addRow(_('Image'), new CLink(new CImg('imgstore.php?width=200&height=200&iconid='.$this->data['imageid'], 'no image'), 'image.php?imageid='.$this->data['imageid'])); 57 } 58 else { 59 $imageFormList->addRow(_('Image'), new CImg('imgstore.php?iconid='.$this->data['imageid'], 'no image', null)); 60 } 61} 62 63// append tab 64$imageTab = (new CTabView()) 65 ->addTab('imageTab', ($this->data['imagetype'] == IMAGE_TYPE_ICON) ? _('Icon') : _('Background'), $imageFormList); 66 67// append buttons 68if (isset($this->data['imageid'])) { 69 $imageTab->setFooter(makeFormFooter( 70 new CSubmit('update', _('Update')), 71 [ 72 new CButtonDelete(_('Delete selected image?'), url_param('form').url_param('imageid'). 73 url_param($data['imagetype'], false, 'imagetype') 74 ), 75 new CButtonCancel(url_param($data['imagetype'], false, 'imagetype')) 76 ] 77 )); 78} 79else { 80 $imageTab->setFooter(makeFormFooter( 81 new CSubmit('add', _('Add')), 82 [new CButtonCancel(url_param($data['imagetype'], false, 'imagetype'))] 83 )); 84} 85 86$imageForm->addItem($imageTab); 87 88$widget->addItem($imageForm); 89 90return $widget; 91