responsive

This commit is contained in:
Roland Gruber 2019-11-02 18:51:36 +01:00
parent dbb2e8aa37
commit 00a299e80f
1 changed files with 36 additions and 56 deletions

View File

@ -390,27 +390,23 @@ class nisnetgroup extends baseModule {
$subgroups = $this->attributes['memberNisNetgroup']; $subgroups = $this->attributes['memberNisNetgroup'];
$allGroups = array_delete($subgroups, $allGroups); $allGroups = array_delete($subgroups, $allGroups);
} }
$return = new htmlTable(); $selectedGroups = array();
$return->addElement(new htmlSubTitle(_("Subgroups")), true); foreach ($subgroups as $subgroup) {
$return->addElement(new htmlOutputText(_("Selected groups"))); $selectedGroups[$subgroup] = $subgroup;
$return->addElement(new htmlOutputText('')); }
$return->addElement(new htmlOutputText(_("Available groups"))); $availableGroups = array();
$return->addNewLine(); foreach ($allGroups as $availableGroup) {
$selGroupSelect = new htmlSelect('removegroups', $subgroups, array(), 15); $availableGroups[$availableGroup] = $availableGroup;
$selGroupSelect->setMultiSelect(true); }
$return->addElement($selGroupSelect);
$buttonContainer = new htmlTable(); $return = new htmlResponsiveRow();
$buttonContainer->addElement(new htmlButton('addgroups_button', 'back.gif', true), true); $return->add(new htmlSubTitle(_("Subgroups")), 12);
$buttonContainer->addElement(new htmlButton('removegroups_button', 'forward.gif', true), true);
$buttonContainer->addElement(new htmlHelpLink('memberNisNetgroup')); $this->addDoubleSelectionArea($return, _("Selected groups"), _("Available groups"), $selectedGroups, array(), $availableGroups, array(), 'subgroup', false, true);
$return->addElement($buttonContainer);
$availGroupSelect = new htmlSelect('addgroups', $allGroups, array(), 15); $return->addVerticalSpacer('2rem');
$availGroupSelect->setMultiSelect(true);
$return->addElement($availGroupSelect);
$return->addNewLine();
$backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')); $backButton = new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back'));
$backButton->colspan = 3; $return->add($backButton, 12);
$return->addElement($backButton);
return $return; return $return;
} }
@ -421,15 +417,15 @@ class nisnetgroup extends baseModule {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_group() { function process_group() {
if (isset($_POST['addgroups']) && isset($_POST['addgroups_button'])) { // Add groups to list if (isset($_POST['subgroup_2']) && isset($_POST['subgroup_left'])) { // Add groups to list
if (!is_array($this->attributes['memberNisNetgroup'])) { if (!is_array($this->attributes['memberNisNetgroup'])) {
$this->attributes['memberNisNetgroup'] = array(); $this->attributes['memberNisNetgroup'] = array();
} }
// Add new group // Add new group
$this->attributes['memberNisNetgroup'] = @array_merge($this->attributes['memberNisNetgroup'], $_POST['addgroups']); $this->attributes['memberNisNetgroup'] = @array_merge($this->attributes['memberNisNetgroup'], $_POST['subgroup_2']);
} }
elseif (isset($_POST['removegroups']) && isset($_POST['removegroups_button'])) { // remove groups from list elseif (isset($_POST['subgroup_1']) && isset($_POST['subgroup_right'])) { // remove groups from list
$this->attributes['memberNisNetgroup'] = array_delete($_POST['removegroups'], $this->attributes['memberNisNetgroup']); $this->attributes['memberNisNetgroup'] = array_delete($_POST['subgroup_1'], $this->attributes['memberNisNetgroup']);
} }
return array(); return array();
} }
@ -440,25 +436,18 @@ class nisnetgroup extends baseModule {
* @return htmlElement meta HTML code * @return htmlElement meta HTML code
*/ */
function display_html_select() { function display_html_select() {
$return = new htmlTable(); $return = new htmlResponsiveRow();
$selectHost = true; $selectHost = true;
$postKeys = array_keys($_POST); $postKeys = array_keys($_POST);
$position = 'New'; $position = 'New';
$filterButtonName = '';
$filter = '';
if (isset($_POST['filter'])) {
$filter = $_POST['filter'];
}
for ($i = 0; $i < sizeof($postKeys); $i++) { for ($i = 0; $i < sizeof($postKeys); $i++) {
if (substr($postKeys[$i], 0, 36) == 'form_subpage_nisnetgroup_select_user') { if (substr($postKeys[$i], 0, 36) == 'form_subpage_nisnetgroup_select_user') {
$selectHost = false; $selectHost = false;
$position = substr($postKeys[$i], 36); $position = substr($postKeys[$i], 36);
$filterButtonName = $postKeys[$i];
break; break;
} }
if (substr($postKeys[$i], 0, 36) == 'form_subpage_nisnetgroup_select_host') { if (substr($postKeys[$i], 0, 36) == 'form_subpage_nisnetgroup_select_host') {
$position = substr($postKeys[$i], 36); $position = substr($postKeys[$i], 36);
$filterButtonName = $postKeys[$i];
break; break;
} }
} }
@ -468,7 +457,7 @@ class nisnetgroup extends baseModule {
$options = $this->getHostList(); $options = $this->getHostList();
$count = sizeof($options); $count = sizeof($options);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
if (!get_preg($options[$i], 'DNSname') || (($filter != '') && (strpos($options[$i], $filter) === false))) { if (!get_preg($options[$i], 'DNSname')) {
unset($options[$i]); unset($options[$i]);
} }
} }
@ -477,39 +466,30 @@ class nisnetgroup extends baseModule {
else { else {
// load list with all users // load list with all users
$options = $this->getUserList(); $options = $this->getUserList();
$count = sizeof($options);
for ($i = 0; $i < $count; $i++) {
if (($filter != '') && (strpos($options[$i], $filter) === false)) {
unset($options[$i]);
}
}
$options = array_values($options); $options = array_values($options);
} }
$return->addElement(new htmlOutputText(_('Filter'))); $return->addLabel(new htmlOutputText(_('Filter')));
$return->addElement(new htmlInputField('filter', $filter)); $filterInput = new htmlInputField('filter');
$return->addElement(new htmlButton($filterButtonName, _('Ok'))); $filterInput->filterSelectBox('selectBox');
$return->addElement(new htmlHelpLink('filter'), true); $return->addField($filterInput);
$title = _('Host name'); $title = _('Host name');
if (!$selectHost) { if (!$selectHost) {
$title = _('User name'); $title = _('User name');
} }
$return->addElement(new htmlOutputText($title)); $return->addLabel(new htmlOutputText($title));
$return->addElement(new htmlSelect('selectBox', $options), true); $return->addField(new htmlSelect('selectBox', $options));
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addVerticalSpacer('2rem');
$type = 'host'; $type = 'host';
if (!$selectHost) { if (!$selectHost) {
$type = 'user'; $type = 'user';
} }
$buttonContainer = new htmlTable(); $return->addLabel(new htmlAccountPageButton(get_class($this), 'attributes', 'select', _('Ok')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'select', _('Ok'))); $return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Cancel')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Cancel'))); $return->add(new htmlHiddenInput('host_new', $_POST['host_new']), 12);
$buttonContainer->colspan = 4; $return->add(new htmlHiddenInput('user_new', $_POST['user_new']), 12);
$return->addElement($buttonContainer, true); $return->add(new htmlHiddenInput('domain_new', $_POST['domain_new']), 12);
$return->addElement(new htmlHiddenInput('host_new', $_POST['host_new'])); $return->add(new htmlHiddenInput('type', $type), 12);
$return->addElement(new htmlHiddenInput('user_new', $_POST['user_new'])); $return->add(new htmlHiddenInput('position', $position), 12);
$return->addElement(new htmlHiddenInput('domain_new', $_POST['domain_new']));
$return->addElement(new htmlHiddenInput('type', $type));
$return->addElement(new htmlHiddenInput('position', $position));
return $return; return $return;
} }