responsive

This commit is contained in:
Roland Gruber 2019-08-25 11:59:53 +02:00
parent 8c7d06e4ae
commit 99c4130435
1 changed files with 24 additions and 47 deletions

View File

@ -475,49 +475,30 @@ class fixed_ip extends baseModule {
$pcs[] = $this->fixed_ip[$id]['cn']; $pcs[] = $this->fixed_ip[$id]['cn'];
// MAC address // MAC address
$macError = ""; if ($this->processed && $this->check_mac($this->fixed_ip[$id]['mac'])) {
if (!$this->processed) { $messages[] = new htmlStatusMessage('ERROR', _("Invalid MAC address."), htmlspecialchars($this->fixed_ip[$id]['mac']));
$macError = "";
}
elseif ($this->check_mac($this->fixed_ip[$id]['mac'])) {
$macError = _("Invalid MAC address.");
} }
// descripton // descripton
$descriptionError = ""; if ($this->processed && !get_preg($this->fixed_ip[$id]['description'], 'ascii')) {
if (!$this->processed) { $messages[] = new htmlStatusMessage('ERROR', _("Invalid description."), htmlspecialchars($this->fixed_ip[$id]['description']));
$descriptionError = "";
}
elseif (!get_preg($this->fixed_ip[$id]['description'], 'ascii')) {
$descriptionError = _("Invalid description.");
} }
// fixed ip // fixed ip
$ipError = ""; if ($this->processed && !empty($this->fixed_ip[$id]['ip'])) {
if (!$this->processed || ($this->fixed_ip[$id]['ip'] == '')) { if (!check_ip($this->fixed_ip[$id]['ip'])) {
$ipError = ""; $messages[] = new htmlStatusMessage('ERROR', _("The IP address is invalid."), htmlspecialchars($this->fixed_ip[$id]['ip']));
}
elseif (!check_ip($this->fixed_ip[$id]['ip'])) {
$ipError = _("The IP address is invalid.");
} }
elseif (!range::check_subnet_range($this->fixed_ip[$id]['ip'], elseif (!range::check_subnet_range($this->fixed_ip[$id]['ip'],
$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0], $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0],
$this->getAccountContainer()->getAccountModule('dhcp_settings')->getDHCPOption('subnet-mask'))) { $this->getAccountContainer()->getAccountModule('dhcp_settings')->getDHCPOption('subnet-mask'))) {
$ipError = _("The IP address does not match the subnet."); $messages[] = new htmlStatusMessage('ERROR', _("The IP address does not match the subnet."), htmlspecialchars($this->fixed_ip[$id]['ip']));
} }
elseif (!$this->isNotOverlapedIp($this->fixed_ip[$id]['ip'])) { elseif (!$this->isNotOverlapedIp($this->fixed_ip[$id]['ip'])) {
$ipError = _("The IP address is already in use."); $messages[] = new htmlStatusMessage('ERROR', _("The IP address is already in use."), htmlspecialchars($this->fixed_ip[$id]['ip']));
} }
$error = '';
if ($macError != '') {
$error .= ' ' . $macError;
}
if ($ipError != '') {
$error .= ' ' . $ipError;
}
if ($descriptionError != '') {
$error .= ' ' . $descriptionError;
} }
$return->addElement(new htmlInputField('ip_'.$id, $this->fixed_ip[$id]['ip'], 20)); $return->addElement(new htmlInputField('ip_'.$id, $this->fixed_ip[$id]['ip'], 20));
$pcInput = new htmlInputField('pc_'.$id, $this->fixed_ip[$id]['cn'], 20); $pcInput = new htmlInputField('pc_'.$id, $this->fixed_ip[$id]['cn'], 20);
if (!empty($autoNames)) { if (!empty($autoNames)) {
@ -527,8 +508,7 @@ class fixed_ip extends baseModule {
$return->addElement(new htmlInputField('mac_'.$id, $this->fixed_ip[$id]['mac'], 20)); $return->addElement(new htmlInputField('mac_'.$id, $this->fixed_ip[$id]['mac'], 20));
$return->addElement(new htmlInputField('description_'.$id, $this->fixed_ip[$id]['description'], 20)); $return->addElement(new htmlInputField('description_'.$id, $this->fixed_ip[$id]['description'], 20));
$return->addElement(new htmlInputCheckbox('active_'.$id, $this->fixed_ip[$id]['active'])); $return->addElement(new htmlInputCheckbox('active_'.$id, $this->fixed_ip[$id]['active']));
$return->addElement(new htmlButton('drop_ip_'.$id, 'del.png', true)); $return->addElement(new htmlButton('drop_ip_'.$id, 'del.png', true), true);
$return->addElement(new htmlOutputText($error), true);
} }
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addElement(new htmlSpacer(null, '10px'), true);
// add host // add host
@ -612,7 +592,7 @@ class fixed_ip extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
public function display_html_addHost() { public function display_html_addHost() {
$return = new htmlTable(); $return = new htmlResponsiveRow();
$this->initCache(); $this->initCache();
$hostNames = array(); $hostNames = array();
$spacer = '####'; $spacer = '####';
@ -634,15 +614,12 @@ class fixed_ip extends baseModule {
$hostNames[$host['cn'][0]] = $val; $hostNames[$host['cn'][0]] = $val;
} }
} }
$select = new htmlTableExtendedSelect('host', $hostNames, array(), _('Host')); $select = new htmlResponsiveSelect('host', $hostNames, array(), _('Host'));
$select->setHasDescriptiveElements(true); $select->setHasDescriptiveElements(true);
$return->addElement($select, true); $return->add($select, 12);
$return->addVerticalSpace('20px'); $return->addVerticalSpacer('2rem');
$buttonContainer = new htmlTable(); $return->addLabel(new htmlAccountPageButton(get_class($this), 'attributes', 'addHost', _('Add')));
$buttonContainer->colspan = 3; $return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'addHost', _('Add')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$return->addElement($buttonContainer, true);
return $return; return $return;
} }