| 1 |
<?php |
| 2 |
|
| 3 |
namespace LAM\CONFIG; |
| 4 |
/* |
| 5 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 6 |
Copyright (C) 2017 - 2026 Roland Gruber |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program; if not, write to the Free Software |
| 20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 |
*/ |
| 22 |
|
| 23 |
use LAMConfig; |
| 24 |
|
| 25 |
|
| 26 |
/** |
| 27 |
* Common functions for configuration pages. |
| 28 |
* |
| 29 |
* @package configuration |
| 30 |
* @author Roland Gruber |
| 31 |
*/ |
| 32 |
|
| 33 |
/** |
| 34 |
* List of tabs. |
| 35 |
* |
| 36 |
* @author Roland Gruber |
| 37 |
*/ |
| 38 |
class ConfigurationPageTab { |
| 39 |
|
| 40 |
/** general settings */ |
| 41 |
const GENERAL = 'general'; |
| 42 |
/** account types */ |
| 43 |
const TYPES = 'types'; |
| 44 |
/** account modules */ |
| 45 |
const MODULES = 'modules'; |
| 46 |
/** module settings */ |
| 47 |
const MODULE_SETTINGS = 'moduleSettings'; |
| 48 |
/** jobs */ |
| 49 |
const JOBS = 'jobs'; |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
/** |
| 55 |
* Prints the header bar. |
| 56 |
* |
| 57 |
* @param LAMConfig $conf configuration object |
| 58 |
*/ |
| 59 |
function printConfigurationPageHeaderBar(LAMConfig $conf): void { |
| 60 |
?> |
| 61 |
<div id="lam-topnav" class="lam-header"> |
| 62 |
<div class="lam-header-left lam-menu-stay"> |
| 63 |
<a href="https://www.ldap-account-manager.org/" target="new_window"> |
| 64 |
<img class="align-middle" width="24" height="24" alt="help" src="../../graphics/logo.svg"> |
| 65 |
<span class="hide-on-mobile"> |
| 66 |
<?php |
| 67 |
echo getLAMVersionText(); |
| 68 |
?> |
| 69 |
</span> |
| 70 |
</a> |
| 71 |
<span class="lam-margin-small"> |
| 72 |
<span class="hide-on-mobile"> |
| 73 |
<?php echo _('Server profile') . ': '; ?> |
| 74 |
</span> |
| 75 |
<?php echo $conf->getName(); ?> |
| 76 |
</span> |
| 77 |
</div> |
| 78 |
<?php |
| 79 |
if (is_dir(__DIR__ . '/../docs/manual')) { |
| 80 |
?> |
| 81 |
<a class="lam-header-right lam-menu-icon hide-on-tablet" href="javascript:void(0);" class="icon" |
| 82 |
onclick="window.lam.topmenu.toggle();"> |
| 83 |
<img class="align-middle" width="16" height="16" alt="menu" src="../../graphics/menu.svg"> |
| 84 |
<span class="padding0"> </span> |
| 85 |
</a> |
| 86 |
<a class="lam-header-right lam-menu-entry" target="_blank" href="../../docs/manual/index.html"> |
| 87 |
<span class="padding0"><?php echo _("Help") ?></span> |
| 88 |
</a> |
| 89 |
<?php |
| 90 |
} |
| 91 |
?> |
| 92 |
</div> |
| 93 |
<br> |
| 94 |
<?php |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Prints the tab list. |
| 99 |
* |
| 100 |
* @param string $active active tab |
| 101 |
*/ |
| 102 |
function printConfigurationPageTabs(string $active): void { |
| 103 |
$tabs = [ |
| 104 |
ConfigurationPageTab::GENERAL => [ |
| 105 |
'id' => 'generalSettingsButton', |
| 106 |
'icon' => 'configure.svg', |
| 107 |
'label' => _('General settings') |
| 108 |
], |
| 109 |
ConfigurationPageTab::TYPES => [ |
| 110 |
'id' => 'edittypes', |
| 111 |
'icon' => 'types.svg', |
| 112 |
'label' => _('Account types') |
| 113 |
], |
| 114 |
ConfigurationPageTab::MODULES => [ |
| 115 |
'id' => 'editmodules', |
| 116 |
'icon' => 'modules.svg', |
| 117 |
'label' => _('Modules') |
| 118 |
], |
| 119 |
ConfigurationPageTab::MODULE_SETTINGS => [ |
| 120 |
'id' => 'moduleSettings', |
| 121 |
'icon' => 'gears.svg', |
| 122 |
'label' => _('Module settings') |
| 123 |
], |
| 124 |
]; |
| 125 |
if (isLAMProVersion()) { |
| 126 |
$tabs[ConfigurationPageTab::JOBS] = [ |
| 127 |
'id' => 'jobs', |
| 128 |
'icon' => 'clock.svg', |
| 129 |
'label' => _('Jobs') |
| 130 |
]; |
| 131 |
} |
| 132 |
// hidden submit buttons which are clicked by tabs |
| 133 |
?> |
| 134 |
<div style="display: none;"> |
| 135 |
<input name="generalSettingsButton" type="submit" value=" "> |
| 136 |
<input name="edittypes" type="submit" value=" "> |
| 137 |
<input name="editmodules" type="submit" value=" "> |
| 138 |
<input name="moduleSettings" type="submit" value=" "> |
| 139 |
<input name="jobs" type="submit" value=" "> |
| 140 |
</div> |
| 141 |
<?php |
| 142 |
|
| 143 |
// tabs |
| 144 |
?> |
| 145 |
<div class="lam-tab-container"> |
| 146 |
<ul class="lam-tab-navigation"> |
| 147 |
<?php |
| 148 |
foreach ($tabs as $tab => $settings) { |
| 149 |
$isActive = ($tab === $active); |
| 150 |
$liClasses = 'lam-tab'; |
| 151 |
if ($isActive) { |
| 152 |
$liClasses .= ' lam-tab-active'; |
| 153 |
} |
| 154 |
echo '<li id="' . $settings['id'] . '" class="' . $liClasses . '">'; |
| 155 |
echo '<a class="lam-tab-anchor" href="#" onclick="document.getElementsByName(\'' . $settings['id'] . '\')[0].click();"><img src="../../graphics/' . $settings['icon'] . '" alt=""> '; |
| 156 |
echo '<span class="hide-on-mobile">' . $settings['label'] . '</span>'; |
| 157 |
echo '</a>'; |
| 158 |
echo '</li>'; |
| 159 |
} |
| 160 |
?> |
| 161 |
</ul> |
| 162 |
<div class="lam-tab-content lam-tab-active"> |
| 163 |
<?php |
| 164 |
} |