/** * Editor k přidávání členů skupiny * * @param string $fieldName název políčka formuláře * @param string $fieldCaption popisek políčka * @param IEcfg $dataSource editovaný objekt */ public function __construct($fieldName, $fieldCaption, $dataSource, $members) { $iDColumn = $dataSource->keywordsInfo[$fieldName]['refdata']['idcolumn']; $nameColumn = $dataSource->keywordsInfo[$fieldName]['refdata']['captioncolumn']; $sTable = $dataSource->keywordsInfo[$fieldName]['refdata']['table']; if (isset($dataSource->keywordsInfo[$fieldName]['refdata']['condition'])) { $conditions = $dataSource->keywordsInfo[$fieldName]['refdata']['condition']; } else { $conditions = array(); } if (isset($dataSource->keywordsInfo[$fieldName]['refdata']['public']) && intval($dataSource->keywordsInfo[$fieldName]['refdata']['public'])) { $sqlConds = " ( " . $dataSource->myDbLink->prepSelect(array_merge($conditions, array($dataSource->userColumn => EaseShared::user()->getUserID()))) . " ) OR ( " . $dataSource->myDbLink->prepSelect(array_merge($conditions, array('public' => 1))) . ") "; } else { $sqlConds = $dataSource->myDbLink->prepSelect(array_merge($conditions, array($dataSource->userColumn => EaseShared::user()->getUserID()))); } $initialContent = new EaseTWBPanel($fieldCaption); $initialContent->setTagCss(array('width' => '100%')); if (is_null($dataSource->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { if ($sTable == $dataSource->myTable) { $tmpKey = $dataSource->getMyKey(); if ($tmpKey) { $members[$tmpKey] = true; } } if ($members && count($members)) { $aviavbleCond = 'AND ' . $iDColumn . ' NOT IN (' . join(',', array_keys($members)) . ') '; } else { $aviavbleCond = ''; } $membersAviableArray = EaseShared::myDbLink()->queryToArray('SELECT ' . $nameColumn . ', ' . $iDColumn . ' ' . 'FROM `' . $sTable . '` ' . 'WHERE (' . $sqlConds . ') ' . $aviavbleCond . 'ORDER BY ' . $nameColumn, $iDColumn); if ($sTable == $dataSource->myTable) { unset($members[$dataSource->getMyKey()]); } $addText = _('Přiřadit'); $delText = _('Odebrat'); if (count($membersAviableArray)) { foreach ($membersAviableArray as $memberID => $memberName) { $reftable = $dataSource->keywordsInfo[$fieldName]['refdata']['table']; $initialContent->addItem(new EaseTWBButtonDropdown($memberName[$nameColumn], 'inverse', 'xs', array(new EaseHtmlATag($reftable . '.php?' . $reftable . '_id=' . $memberID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag(null, EaseTWBPart::GlyphIcon('plus-sign') . ' ' . $addText, array('onClick' => "addGroupMember('" . get_class($dataSource) . "','" . $dataSource->getId() . "','" . $fieldName . "','" . $memberName[$nameColumn] . "','" . $memberID . "')", 'class' => 'handle', 'data-addtext' => $addText, 'data-deltext' => $delText))), array('id' => get_class($dataSource) . '_' . $fieldName . '_' . $memberID, 'style' => 'margin: 1px;'))); } } if ($members && count($members)) { $initialContent->addItem('</br>'); foreach ($members as $memberID => $memberName) { $reftable = $dataSource->keywordsInfo[$fieldName]['refdata']['table']; $initialContent->addItem(new EaseTWBButtonDropdown($memberName, 'success', 'xs', array(new EaseHtmlATag($reftable . '.php?' . $reftable . '_id=' . $memberID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag(null, EaseTWBPart::GlyphIcon('remove') . ' ' . _('Odebrat'), array('onClick' => "delGroupMember('" . get_class($dataSource) . "','" . $dataSource->getId() . "','" . $fieldName . "','" . $memberName . "','" . $memberID . "')", 'class' => 'handle', 'data-addtext' => $addText, 'data-deltext' => $delText))), array('id' => get_class($dataSource) . '_' . $fieldName . '_' . $memberID, 'style' => 'margin: 1px;'))); } } } parent::__construct($initialContent); }
/** * Editor k přidávání členů skupiny * * @param IEServices $service */ public function __construct($service) { $hostsAssigned = array(); parent::__construct(); $fieldName = $this->getmyKeyColumn(); $initialContent = new EaseTWBPanel(_('Sledované hosty služby'), 'default'); $initialContent->setTagCss(array('width' => '100%')); if (is_null($service->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $serviceName = $service->getName(); $host = new IEHost(); if (EaseShared::user()->getSettingValue('admin')) { $allHosts = $host->getAllFromMySQL(NULL, array($host->myKeyColumn, $host->nameColumn, 'platform', 'register'), null, $host->nameColumn, $host->myKeyColumn); } else { $allHosts = $host->getListing(null, true, array('platform', 'register')); } if ($service->getDataValue('host_name')) { foreach ($service->getDataValue('host_name') as $hostId => $hostName) { if (isset($allHosts[$hostId])) { $hostsAssigned[$hostId] = $allHosts[$hostId]; } } } foreach ($allHosts as $hostID => $hostInfo) { if ($hostInfo['register'] != 1) { unset($allHosts[$hostID]); } if ($hostInfo['platform'] != 'generic' && $hostInfo['platform'] != $service->getDataValue('platform')) { unset($allHosts[$hostID]); } } foreach ($hostsAssigned as $hostID => $hostInfo) { unset($allHosts[$hostID]); } if (count($allHosts)) { foreach ($allHosts as $hostID => $hostInfo) { $initialContent->addItem(new EaseTWBButtonDropdown($hostInfo[$host->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('host.php?host_id=' . $hostID . '&service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addhost=' . $hostInfo[$host->nameColumn] . '&host_id=' . $hostID . '&' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&' . $service->nameColumn . '=' . $service->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat'))))); } } if (count($hostsAssigned)) { $initialContent->addItem('<br/>'); foreach ($hostsAssigned as $hostID => $hostInfo) { $initialContent->addItem(new EaseTWBButtonDropdown($hostInfo[$host->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delhost=' . $hostInfo[$host->nameColumn] . '&host_id=' . $hostID . '&' . $service->getmyKeyColumn() . '=' . $service->getMyKey() . '&' . $service->nameColumn . '=' . $service->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('host.php?host_id=' . $hostID . '&service_id=' . $service->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'))))); } } } $this->addItem($initialContent); }
/** * Vytvoří editační formulář podle CFG objektu * * @param IECfg $this->ObjectEdited * @param string $onlyColumn Vrací editační pole jen pro sloupec daného jména */ public function __construct($cfgObject, $onlyColumn = null) { parent::__construct(); $this->objectEdited =& $cfgObject; if ($onlyColumn) { $this->insertWidget($this, $onlyColumn, $this->objectEdited->getDataValue($onlyColumn)); } else { if (EaseShared::user()->getSettingValue('admin')) { $this->fullEditor(); } else { $this->lightEditor(); } if ($cfgObject->getId()) { $this->addItem(new EaseHtmlInputHiddenTag($cfgObject->getmyKeyColumn(), $cfgObject->getMyKey(), array('class' => 'keyId'))); } $this->addItem(new EaseHtmlInputHiddenTag('class', get_class($cfgObject))); } }
/** * Editor k přidávání členů skupiny * * @param IEService|IEHost $holder */ public function __construct($holder) { $contactsAssigned = array(); parent::__construct(); $fieldName = $this->getmyKeyColumn(); $initialContent = new EaseTWBPanel(_('Cíle notifikací')); $initialContent->setTagCss(array('width' => '100%')); if (is_null($holder->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $serviceName = $holder->getName(); $contact = new IEContact(); $allContacts = $contact->getListing(null, true, array('alias', 'parent_id')); foreach ($holder->getDataValue('contacts') as $contactId => $contactName) { if (isset($allContacts[$contactId])) { $contactsAssigned[$contactId] = $allContacts[$contactId]; } } foreach ($allContacts as $contactID => $contactInfo) { if ($contactInfo['register'] != 1) { unset($allContacts[$contactID]); } if (!$contactInfo['parent_id']) { unset($allContacts[$contactID]); } } foreach ($contactsAssigned as $contactID => $contactInfo) { unset($allContacts[$contactID]); } if (count($allContacts)) { foreach ($allContacts as $contactID => $contactInfo) { $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'inverse', 'xs', array(new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')), new EaseHtmlATag('?addcontact=' . $contactInfo[$contact->nameColumn] . '&contact_id=' . $contactID . '&' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít obesílat'))))); } } if (count($contactsAssigned)) { $initialContent->addItem('<br/>'); foreach ($contactsAssigned as $contactID => $contactInfo) { $initialContent->addItem(new EaseTWBButtonDropdown($contactInfo[$contact->nameColumn], 'success', 'xs', array(new EaseHtmlATag('?delcontact=' . $contactInfo[$contact->nameColumn] . '&contact_id=' . $contactID . '&' . $holder->getmyKeyColumn() . '=' . $holder->getMyKey() . '&' . $holder->nameColumn . '=' . $holder->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat obesílat')), new EaseHtmlATag('contacttweak.php?contact_id=' . $contactInfo['parent_id'] . '&service_id=' . $holder->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'))))); } } } $this->addItem($initialContent); }
/** * Editor k přidávání členů skupiny * * @param IEHost $host */ public function __construct($host) { parent::__construct(); $fieldName = $host->getmyKeyColumn(); $initialContent = new EaseTWBPanel(_('rodiče hostu')); $addparentForm = $initialContent->addItem(new EaseTWBForm('addparent')); $addparentForm->addItem(new EaseTWBFormGroup(_('IP nebo Hostname'), new EaseHtmlInputTextTag('newparent'))); $addparentForm->addItem(new EaseHtmlInputHiddenTag($fieldName, $host->getId())); $addparentForm->addItem(new EaseTWSubmitButton(_('Přidat rodiče'), 'success')); $initialContent->setTagCss(array('width' => '100%')); if (is_null($host->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $allParents = $host->getListing(); unset($allParents[$host->getID()]); //Nenabízet sám sebe jako rodiče foreach ($allParents as $parentID => $parentInfo) { if ($parentInfo['register'] != 1) { unset($allParents[$parentID]); } } $parentsAssigned = array(); foreach ($host->getDataValue('parents') as $parentAssigned) { $parentID = EaseShared::myDbLink()->queryToValue('SELECT `' . $host->myKeyColumn . '` FROM ' . $host->myTable . ' WHERE `' . $host->nameColumn . '` = \'' . addSlashes($parentAssigned) . '\''); $parentsAssigned[$parentID][$host->nameColumn] = $parentAssigned; $parentsAssigned[$parentID][$host->myKeyColumn] = $parentID; unset($allParents[$parentID]); } if (count($allParents)) { foreach ($allParents as $parentID => $parentInfo) { $initialContent->addItem($this->parentButton($parentInfo, 'plus', $host)); } } if (count($parentsAssigned)) { $initialContent->addItem('</br>'); foreach ($parentsAssigned as $parentID => $parentInfo) { $initialContent->addItem($this->parentButton($parentInfo, 'remove', $host)); } } } $this->addItem($initialContent); }
/** * Editor k přidávání členů skupiny * * @param IEHosts $Host */ public function __construct($Host) { $FieldName = 'parents'; $InitialContent = new EaseTWBPanel(_('Potomci')); $InitialContent->setTagCss(array('width' => '100%')); if (is_null($Host->getMyKey())) { $InitialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $Service = new IEService(); $ServicesAssigned = $Service->myDbLink->queryToArray('SELECT ' . $Service->myKeyColumn . ',' . $Service->nameColumn . ' FROM ' . $Service->myTable . ' WHERE ' . $FieldName . ' LIKE \'%"' . $Host->getName() . '"%\'', $Service->myKeyColumn); $AllServices = $Service->getListing(); foreach ($AllServices as $ServiceID => $ServiceInfo) { if ($ServiceInfo['register'] != 1) { unset($AllServices[$ServiceID]); } } foreach ($ServicesAssigned as $ServiceID => $ServiceInfo) { unset($AllServices[$ServiceID]); } if (count($AllServices)) { foreach ($AllServices as $ServiceID => $ServiceInfo) { $Jellybean = new EaseHtmlSpanTag($ServiceInfo[$Service->nameColumn], null, array('class' => 'jellybean gray')); $Jellybean->addItem(new EaseHtmlATag('?addservice=' . $ServiceInfo[$Service->nameColumn] . '&service_id=' . $ServiceID . '&' . $Host->getmyKeyColumn() . '=' . $Host->getMyKey() . '&' . $Host->nameColumn . '=' . $Host->getName(), $ServiceInfo[$Service->nameColumn])); $InitialContent->addItem($Jellybean); } } if (count($ServicesAssigned)) { $InitialContent->addItem('</br>'); foreach ($ServicesAssigned as $ServiceID => $ServiceInfo) { $Jellybean = new EaseHtmlSpanTag($ServiceInfo[$Service->nameColumn], null, array('class' => 'jellybean')); $Jellybean->addItem($ServiceInfo[$Service->nameColumn]); $Jellybean->addItem(new EaseHtmlATag('?delservice=' . $ServiceInfo[$Service->nameColumn] . '&service_id=' . $ServiceID . '&' . $Host->getmyKeyColumn() . '=' . $Host->getMyKey() . '&' . $Host->nameColumn . '=' . $Host->getName(), EaseTWBPart::GlyphIcon('remove'))); $InitialContent->addItem($Jellybean); } } } parent::__construct($InitialContent); }
/** * Stav senzoru a jeho nastavení * * @param IEHost $host */ public function __construct($host) { $commonWell = new EaseTWBWell(); $commonRow = new EaseTWBRow(); $hostColumn = $commonRow->addColumn(6, new EaseHtmlATag('host.php?host_id=' . $host->getId(), new EaseHtmlH1Tag($host->getName()))); $hostColumn->addItem($host); $hostColumn->addItem($host->sensorStatusLabel()); $commonWell->addItem($commonRow); $commonRow->addColumn(4, new EaseTWBPanel(_('Ruční nastavení stavu senzoru'), 'info', new IESensorConfirmForm($host))); $sensorTabs = new EaseTWBTabs('sensorTabs'); switch ($host->getDataValue('platform')) { case 'windows': $pltIco = 'logos/base/win40.gif'; $cfgGenerator = new IENSCPConfigGenerator($host); if ($host->getCfgValue('active_checks_enabled')) { $windowsActiveTab = $sensorTabs->addTab(_('Windows NRPE')); $windowsActiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('aktivní NRPE pro NSC++'))); $windowsActiveTab->addItem(new EaseTWBLinkButton('http://www.nsclient.org/download/', ' NSC++ ' . EaseTWBPart::GlyphIcon('download'), 'success', array('style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ", 'title' => 'Download'))); $windowsActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');"))); $windowsActiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.bat ' . EaseTWBPart::GlyphIcon('download'), 'success')); $windowsActiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed'))); } if ($host->getCfgValue('passive_checks_enabled')) { $windowsPassiveTab = $sensorTabs->addTab(_('Windows NSCA')); $windowsPassiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('pasivní NSCA pro NSC++'))); $windowsPassiveTab->addItem(new EaseTWBLinkButton('http://www.nsclient.org/download/', ' NSC++ ' . EaseTWBPart::GlyphIcon('download'), 'success', array('style' => "background-image:url('img/nscpp.png'); width: 212px; height: 60px; ", 'title' => 'Download'))); $windowsPassiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.bat ' . EaseTWBPart::GlyphIcon('download'), 'success')); $windowsPassiveTab->addItem(new EaseTWBWell('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false), ENT_QUOTES) . '</pre>', array('font-face' => 'fixed'))); } break; case 'linux': $pltIco = 'logos/base/linux40.gif'; $preferences = new IEPreferences(); $prefs = $preferences->getPrefs(); if ($host->getCfgValue('active_checks_enabled')) { $nrpe_cfgGenerator = new IENRPEConfigGenerator($host); $linuxActiveTab = $sensorTabs->addTab(_('Linux NRPE')); $linuxActiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('aktivní NRPE pro NRPE Server'))); $linuxActiveTab->addItem(new EaseHtmlPTag(_('Nainstalujte nejprve senzor tímto příkazem') . ':')); $linuxActiveTab->addItem(new EaseHtmlDiv('<pre>sudo aptitude -y install nagios-nrpe-server</pre>', array('class' => 'code'))); $linuxActiveTab->addItem(new EaseTWBLinkButton('nrpecfggen.php?host_id=' . $host->getId(), $host->getName() . '_nrpe.sh ' . EaseTWBPart::GlyphIcon('download'), 'success')); $linuxActiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($nrpe_cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed'))); $linuxActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');"))); } if ($host->getCfgValue('passive_checks_enabled')) { $linuxPassiveTab = $sensorTabs->addTab(_('Linux NSCA')); $linuxPassiveTab->addItem(new EaseHtmlH1Tag('<img src="' . $pltIco . '">' . _('pasivní NSCA pro NSCP Senzor'))); $linuxPassiveTab->addItem(new EaseTWBLinkButton('nscpcfggen.php?host_id=' . $host->getId(), $host->getName() . '_nscp.sh ' . EaseTWBPart::GlyphIcon('download'), 'success')); $cfgGenerator = new IENSCPConfigGenerator($host); $linuxPassiveTab->addItem(new EaseTWBContainer('<pre>' . htmlspecialchars($cfgGenerator->getCfg(false)) . '</pre>', array('font-face' => 'fixed'))); } break; default: $pltIco = 'logos/unknown.gif'; if ($host->getCfgValue('active_checks_enabled')) { $genericActiveTab = $sensorTabs->addTab(_('Generic Active')); $genericActiveTab->addItem(new EaseTWBLinkButton('host.php?action=populate&host_id=' . $host->getID(), _('Oskenovat a sledovat služby'), null, array('onClick' => "\$('#preload').css('visibility', 'visible');"))); } if ($host->getCfgValue('passive_checks_enabled')) { $genericPassiveTab = $sensorTabs->addTab(_('Generic Passive')); } break; } parent::__construct($commonWell); $this->addItem($sensorTabs); }
/** * Editor k přidávání členů skupiny * * @param IEHost $host */ public function __construct($host) { parent::__construct(); $fieldName = $this->getmyKeyColumn(); if ($host->getDataValue('platform') == 'generic') { $note = '<small><span class="label label-info">Tip:</span> ' . _('Další sledovatelné služby budou nabídnuty po nastavení platformy hosta a vzdáleného senzoru.') . '</small>'; } else { $note = array(); } $initialContent = new EaseTWBPanel(_('Sledované služby'), 'default', null, $note); $initialContent->setTagCss(array('width' => '100%')); if (is_null($host->getMyKey())) { $initialContent->addItem(_('Nejprve je potřeba uložit záznam')); } else { $hostName = $host->getName(); $service = new IEService(); $parentServUsed = array(); $host_active = (bool) $host->getCfgValue('active_checks_enabled'); $host_passive = (bool) $host->getCfgValue('passive_checks_enabled'); $servicesAssigned = $service->myDbLink->queryToArray('SELECT ' . $service->myKeyColumn . ',display_name,' . $service->nameColumn . ' FROM ' . $service->myTable . ' WHERE ' . $fieldName . ' LIKE \'%"' . $host->getName() . '"%\'', $service->myKeyColumn); $allServices = $service->getListing(null, true, array('platform', 'parent_id', 'passive_checks_enabled', 'active_checks_enabled', 'display_name')); foreach ($allServices as $serviceID => $serviceInfo) { $servicePassive = (bool) $serviceInfo['passive_checks_enabled']; $serviceActive = (bool) $serviceInfo['active_checks_enabled']; if ($serviceInfo['register'] != 1) { unset($allServices[$serviceID]); continue; } if ($serviceInfo['platform'] != 'generic' && $serviceInfo['platform'] != $host->getDataValue('platform')) { unset($allServices[$serviceID]); continue; } if ((!$host_passive || !$servicePassive) && (!$host_active || !$serviceActive)) { unset($allServices[$serviceID]); continue; } } foreach ($servicesAssigned as $serviceID => $serviceInfo) { if (isset($allServices[$serviceID]) && isset($parentServUsed[$allServices[$serviceID]['parent_id']])) { $parentServUsed[$allServices[$serviceID]['parent_id']] = $allServices[$serviceID]['parent_id']; } unset($allServices[$serviceID]); } if (count($allServices)) { foreach ($allServices as $serviceID => $serviceInfo) { if (isset($parentServUsed[$serviceInfo['parent_id']])) { continue; } $unchMenu = array(); if (intval($serviceInfo['parent_id'])) { $unchMenu[] = new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID, EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace')); } $unchMenu[] = new EaseHtmlATag('?addservice=' . $serviceInfo[$service->nameColumn] . '&service_id=' . $serviceID . '&' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('plus') . ' ' . _('Začít sledovat')); if (strlen($serviceInfo['display_name'])) { $serviceName = $serviceInfo['display_name']; } else { $serviceName = $serviceInfo[$service->nameColumn]; } $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'inverse', 'xs', $unchMenu)); } } if (count($servicesAssigned)) { $saveAsTemplateButton = new EaseTWBLinkButton('stemplate.php?action=copyhost&host_id=' . $host->getId(), _('Uložit jako předlohu'), 'success'); $initialContent->footer($saveAsTemplateButton); $initialContent->addItem('</br>'); foreach ($servicesAssigned as $serviceID => $serviceInfo) { if (strlen($serviceInfo['display_name'])) { $serviceName = $serviceInfo['display_name']; } else { $serviceName = $serviceInfo[$service->nameColumn]; } $initialContent->addItem(new EaseTWBButtonDropdown($serviceName, 'success', 'xs', array(new EaseHtmlATag('?delservice=' . $serviceInfo[$service->nameColumn] . '&service_id=' . $serviceID . '&' . $host->getmyKeyColumn() . '=' . $host->getMyKey() . '&' . $host->nameColumn . '=' . $host->getName(), EaseTWBPart::GlyphIcon('remove') . ' ' . _('Přestat sledovat')), new EaseHtmlATag('servicetweak.php?service_id=' . $serviceID . '&host_id=' . $host->getId(), EaseTWBPart::GlyphIcon('wrench') . ' ' . _('Editace'))))); } } else { $presetSelForm = new EaseTWBForm('presetSelForm'); $presetSelForm->addItem(new EaseHtmlInputHiddenTag($host->getmyKeyColumn(), $host->getId())); $presetSelForm->addItem(new EaseHtmlInputHiddenTag('action', 'applystemplate')); $presetSelForm->addItem(new IEStemplateSelect('stemplate_id')); $presetSelForm->addItem(new EaseTWSubmitButton(_('Aplikovat předlohu'), 'success')); $presetSelForm->setTagClass('form-inline'); $initialContent->footer($presetSelForm); } } $this->addItem($initialContent); }
/** * Volba ikony pro host * * @param IEHost $host */ public function __construct($host) { parent::__construct(); EaseJQueryPart::jQueryze($this); $icodirs = array('' => ''); $icoBox = $this->addItem(new EaseTWBPanel(_('Vyber Ikonu'))); $icoBox->setTagCss('width: 100%;'); $icodir = self::$webdir . self::$icodir; $d = dir($icodir); if (is_object($d)) { while (false !== ($entry = $d->read())) { if (is_dir(self::$webdir . self::$icodir . '/' . $entry)) { if ($entry[0] == '.') { continue; } $icodirs[$entry] = $entry; } } $d->close(); } $iconTabs = $icoBox->addItem(new EaseTWBTabs('IconTabs')); foreach ($icodirs as $subicodir) { $default = false; $icons = new EaseContainer(); $customIcos = self::$webdir . self::$icodir . $subicodir; $d = dir($customIcos); if (is_object($d)) { while (false !== ($entry = $d->read())) { if (!is_dir($customIcos . '/' . $entry)) { if (strstr($entry, '.gd2') || $entry[0] == '.') { continue; } if ($entry == 'custom') { list($userid, $imgname) = explode('-', $entry); if ($userid != $host->owner->getId()) { continue; } $default = true; } $hostIcon = new EaseHtmlImgTag(self::$webprefix . self::$icodir . '/' . $subicodir . '/' . $entry); $hostIcon->setTagClass('host_icon'); if ($host->getDataValue('icon_image') == 'custom/' . $entry) { $hostIcon->setTagCss('border: 3px red solid;'); } $icons->addItem(new EaseHtmlATag('?action=newicon&host_id=' . $host->getId() . '&newicon=' . $subicodir . '/' . $entry, $hostIcon)); } } $d->close(); } if (!$subicodir) { $subicodir = 'ico'; } $iconTabs->addTab($subicodir, $icons, $default); } $uplBox = $this->addItem(new EaseTWBPanel(_('Nahraj vlastní'), 'info')); $uplBox->setTagCss('width: 100%;'); $icoupform = $uplBox->addItem(new EaseTWBForm('icoUp', null, 'POST', null, array('enctype' => 'multipart/form-data'))); $icoupform->addItem(new EaseHtmlEmTag(_('Obrázek typu GIF,PNG nebo JPG, nejlépe 40x40 px'))); $icoupform->addItem(new EaseTWBFormGroup(_('Ikona ze souboru'), new EaseHtmlInputFileTag('icofile'), '', _('Soubor v počítači'))); $icoupform->addItem(new EaseTWBFormGroup(_('Ikona z adresy'), new EaseHtmlInputTextTag('icourl'), '', _('Soubor na internetu'))); $icoupform->addItem(new EaseTWBFormGroup(_('Titulek obrázku'), new EaseHtmlInputTextTag('icon_image_alt'), '', _('nepovinné'))); $icoupform->addItem(new EaseTWSubmitButton(_('Odeslat'))); $icoupform->addItem(new EaseHtmlInputHiddenTag('host_id', $host->getId())); }