|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Formulář pro vyber pismene Disku windows |
| 5 | + * |
| 6 | + * @package IcingaEditor |
| 7 | + * @subpackage plugins |
| 8 | + * @author Vitex <vitex@hippy.cz> |
| 9 | + * @copyright 2014 Vitex@hippy.cz (G) |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Icinga\Editor\modules; |
| 13 | + |
| 14 | +/** |
| 15 | + * Description of ping |
| 16 | + * |
| 17 | + * @author vitex |
| 18 | + */ |
| 19 | +class DriveLetter extends \Icinga\Editor\UI\ServiceConfigurator { |
| 20 | + |
| 21 | + /** |
| 22 | + * |
| 23 | + */ |
| 24 | + public function form() { |
| 25 | + $config = [ |
| 26 | + 'Drive' => null |
| 27 | + ]; |
| 28 | + foreach (explode(' ', $this->commandParams[0]) as $cfg) { |
| 29 | + if (strstr($cfg, '=')) { |
| 30 | + list($key, $value) = explode('=', $cfg); |
| 31 | + $config[$key] = $value; |
| 32 | + } else { |
| 33 | + $config[$cfg] = null; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + $drives = array_combine(range('a', 'z'), range('A', 'Z')); |
| 38 | + |
| 39 | + unset($drives[1]); |
| 40 | + foreach ($drives as $did => $dname) { |
| 41 | + $drives[$did] = $drives[$did] . ':'; |
| 42 | + } |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + if (strstr($config['Drive'], '\\\\')) { |
| 47 | + $this->form->addInput(new \Ease\Html\Select('Drive', $drives, '\\\\'), _('Disk'), 'X:', _('Volba písmene sledované diskové jednotky')); |
| 48 | + } else { |
| 49 | + $this->form->addInput(new \Ease\Html\Select('Drive', $drives, str_replace(':', '', $config['Drive'])), _('Disk'), 'X:', _('Volba písmene sledované diskové jednotky')); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Zpracování formuláře |
| 55 | + * |
| 56 | + * @return boolean |
| 57 | + */ |
| 58 | + public function reconfigureService() { |
| 59 | + $config = []; |
| 60 | + $page = \Ease\Shared::webPage(); |
| 61 | + |
| 62 | + foreach ($page->getRequestValues() as $key => $value) { |
| 63 | + switch ($key) { |
| 64 | + case 'Drive': |
| 65 | + |
| 66 | + if (strlen(trim($value)) && ($value != '\\\\')) { |
| 67 | + $config['Drive'] = $value . ':'; |
| 68 | + $this->tweaker->service->setDataValue($this->tweaker->service->nameColumn, _('Disk') . ' ' . strtoupper($value) . ':'); |
| 69 | + $this->tweaker->service->setDataValue('display_name', sprintf(_('Volné místo disku %s: '), strtoupper($value))); |
| 70 | + } |
| 71 | + |
| 72 | + break; |
| 73 | + |
| 74 | + default: |
| 75 | + break; |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + if (count($config)) { |
| 82 | + |
| 83 | + $this->tweaker->service->setDataValue('check_command-params', implode(' ', $config)); |
| 84 | + |
| 85 | + return parent::reconfigureService(); |
| 86 | + } |
| 87 | + |
| 88 | + return FALSE; |
| 89 | + } |
| 90 | + |
| 91 | +} |
0 commit comments