Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Oct 29, 2023
1 parent 807272b commit c33ea7a
Show file tree
Hide file tree
Showing 11 changed files with 358 additions and 343 deletions.
32 changes: 16 additions & 16 deletions lam/templates/config/confImportExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2020 - 2022 Roland Gruber
Copyright (C) 2020 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -123,7 +123,7 @@
</a>
</div>
<?php
if (is_dir(dirname(__FILE__) . '/../../docs/manual')) {
if (is_dir(__DIR__ . '/../../docs/manual')) {
?>
<a class="lam-header-right lam-menu-icon hide-on-tablet" href="javascript:void(0);" class="icon" onclick="window.lam.topmenu.toggle();">
<img class="align-middle" width="16" height="16" alt="menu" src="../../graphics/menu.svg">
Expand Down Expand Up @@ -161,22 +161,22 @@
function showLoginDialog($message = null): void {
$content = new htmlResponsiveRow();
$loginContent = new htmlResponsiveRow();
$loginContent->setCSSClasses(array('maxrow fullwidth roundedShadowBox spacing5'));
$loginContent->setCSSClasses(['maxrow fullwidth roundedShadowBox spacing5']);
if ($message !== null) {
$loginContent->add($message, 12);
}
$pwdInput = new htmlResponsiveInputField(_("Master password"), 'password', '', '236');
$pwdInput->setIsPassword(true);
$pwdInput->setCSSClasses(array('lam-initial-focus'));
$pwdInput->setCSSClasses(['lam-initial-focus']);
$loginContent->add($pwdInput, 12);
$loginContent->addLabel(new htmlOutputText('&nbsp;', false));
$loginButton = new htmlButton('submitLogin', _("Ok"));
$loginButton->setCSSClasses(array('lam-primary'));
$loginButton->setCSSClasses(['lam-primary']);
$loginContent->addField($loginButton);

$content->add($loginContent, 12);

parseHtml(null, $content, array(), false, null);
parseHtml(null, $content, [], false, null);
renderBackLink();
}

Expand All @@ -188,7 +188,7 @@ function renderBackLink(): void {
$content->addVerticalSpacer('2rem');
$content->add(new htmlLink(_('Back to login'), '../login.php'), 12);
$content->addVerticalSpacer('1rem');
parseHtml(null, $content, array(), false, null);
parseHtml(null, $content, [], false, null);
}

/**
Expand All @@ -215,13 +215,13 @@ function displayImportExport(): void {

$content->add(new htmlSubTitle(_('Export')), 12);
$exportButton = new htmlButton('exportConfig', _('Export'));
$exportButton->setCSSClasses(array('lam-primary'));
$exportButton->setCSSClasses(['lam-primary']);
$content->add($exportButton);

$content->add(new htmlSubTitle(_('Import')), 12);
renderImportPart($content);

parseHtml(null, $content, array(), false, null);
parseHtml(null, $content, [], false, null);
renderBackLink();
}

Expand All @@ -232,7 +232,7 @@ function displayImportExport(): void {
*/
function renderImportPart($content): void {
$validUpload = false;
$importSteps = array();
$importSteps = [];
if (isset($_POST['importConfig'])) {
try {
if (empty($_FILES['import-file']['tmp_name'])) {
Expand All @@ -254,7 +254,7 @@ function renderImportPart($content): void {
if ($handle === false) {
throw new LAMException(_('Unable to read import file.'));
}
$data = fread($handle, 100000000);
$data = fread($handle, 100_000_000);
if ($data === false) {
throw new LAMException(_('Unable to read import file.'));
}
Expand All @@ -279,7 +279,7 @@ function renderImportPart($content): void {
if (!isset($_POST['importConfigConfirm']) && !$validUpload) {
$content->add(new htmlInputFileUpload('import-file'), 12);
$submitButton = new htmlButton('importConfig', _('Submit'));
$submitButton->setCSSClasses(array('lam-secondary'));
$submitButton->setCSSClasses(['lam-secondary']);
$content->add($submitButton);
}
elseif (isset($_POST['importConfig'])) {
Expand All @@ -288,8 +288,8 @@ function renderImportPart($content): void {
$stepKey = 'step_' . $importStep->getKey();
$stepCheckbox = new htmlResponsiveInputCheckbox($stepKey, true, $importStep->getLabel());
$stepCheckbox->setLabelAfterCheckbox();
$stepCheckbox->setCSSClasses(array('bold'));
$subStepIds = array();
$stepCheckbox->setCSSClasses(['bold']);
$subStepIds = [];
$content->add($stepCheckbox);
$content->addVerticalSpacer('0.3rem');
foreach ($importStep->getSubSteps() as $subStep) {
Expand All @@ -304,7 +304,7 @@ function renderImportPart($content): void {
}
$buttonGroup = new htmlGroup();
$importButton = new htmlButton('importConfigConfirm', _('Import'));
$importButton->setCSSClasses(array('lam-secondary'));
$importButton->setCSSClasses(['lam-secondary']);
$buttonGroup->addElement($importButton);
$buttonGroup->addElement(new htmlButton('importCancel', _('Cancel')));
$content->add($buttonGroup);
Expand All @@ -315,7 +315,7 @@ function renderImportPart($content): void {
if ($handle === false) {
throw new LAMException(_('Unable to read import file.'));
}
$data = fread($handle, 100000000);
$data = fread($handle, 100_000_000);
if ($data === false) {
throw new LAMException(_('Unable to read import file.'));
}
Expand Down
20 changes: 10 additions & 10 deletions lam/templates/config/conflogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2021 Roland Gruber
Copyright (C) 2003 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -49,7 +49,7 @@

// start session
if (isFileBasedSession()) {
session_save_path(dirname(__FILE__) . '/../../sess');
session_save_path(__DIR__ . '/../../sess');
}
lam_start_session();
session_regenerate_id(true);
Expand All @@ -65,13 +65,13 @@
// remove settings from session
$sessionKeys = array_keys($_SESSION);
for ($i = 0; $i < sizeof($sessionKeys); $i++) {
if (substr($sessionKeys[$i], 0, 5) == "conf_") unset($_SESSION[$sessionKeys[$i]]);
if (str_starts_with($sessionKeys[$i], "conf_")) unset($_SESSION[$sessionKeys[$i]]);
}

echo $_SESSION['header'];

$serverProfilePersistenceManager = new ServerProfilePersistenceManager();
$files = array();
$files = [];
try {
$files = $serverProfilePersistenceManager->getProfiles();
}
Expand Down Expand Up @@ -101,7 +101,7 @@
</a>
</div>
<?php
if (is_dir(dirname(__FILE__) . '/../../docs/manual')) {
if (is_dir(__DIR__ . '/../../docs/manual')) {
?>
<a class="lam-header-right lam-menu-icon hide-on-tablet" href="javascript:void(0);" class="icon" onclick="window.lam.topmenu.toggle();">
<img class="align-middle" width="16" height="16" alt="menu" src="../../graphics/menu.svg">
Expand Down Expand Up @@ -133,7 +133,7 @@
$box->add(new htmlOutputText(_("Please enter your password to change the server preferences:")), 12);
$box->addVerticalSpacer('1.5rem');
$conf = new LAMCfgMain();
$selectedProfile = array();
$selectedProfile = [];
$profilesExisting = false;
$profiles = $files;
if (!empty($_COOKIE["lam_default_profile"]) && in_array($_COOKIE["lam_default_profile"], $files)) {
Expand All @@ -145,11 +145,11 @@
$box->add(new htmlResponsiveSelect('filename', $profiles, $selectedProfile, _('Profile name')), 12);
$passwordInput = new htmlResponsiveInputField(_('Password'), 'passwd', '', '200');
$passwordInput->setIsPassword(true);
$passwordInput->setCSSClasses(array('lam-initial-focus'));
$passwordInput->setCSSClasses(['lam-initial-focus']);
$box->add($passwordInput, 12);
$box->addVerticalSpacer('1rem');
$button = new htmlButton('submit', _("Ok"));
$button->setCSSClasses(array('lam-primary'));
$button->setCSSClasses(['lam-primary']);
$box->addLabel($button);
$box->add(new htmlOutputText(''), 0, 6);
$box->addVerticalSpacer('1.5rem');
Expand All @@ -160,15 +160,15 @@
$box->add($manageLink, 12, 12, 12, 'text-center');

$boxDiv = new htmlDiv(null, $box);
$boxDiv->setCSSClasses(array('roundedShadowBox', 'limitWidth', 'text-center'));
$boxDiv->setCSSClasses(['roundedShadowBox', 'limitWidth', 'text-center']);
$row->add($boxDiv, 12);

// back link
$row->addVerticalSpacer('2rem');
$backLink = new htmlLink(_("Back to login"), '../login.php');
$row->add($backLink, 12, 12, 12, 'text-left');

parseHtml(null, new htmlDiv(null, $row, array('centeredTable')), array(), false, 'user');
parseHtml(null, new htmlDiv(null, $row, ['centeredTable']), [], false, 'user');

?>
</form>
Expand Down
Loading

0 comments on commit c33ea7a

Please sign in to comment.