| 1 |
<?php |
| 2 |
/** |
| 3 |
* AdminSettings.php |
| 4 |
* |
| 5 |
* Shows the settings page at the admin panel. |
| 6 |
* |
| 7 |
* PHP versions 5 |
| 8 |
* |
| 9 |
* @author Alexander Schneider <alexanderschneider85@gmail.com> |
| 10 |
* @copyright 2008-2017 Alexander Schneider |
| 11 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 |
| 12 |
* @version SVN: $id$ |
| 13 |
* @link http://wordpress.org/extend/plugins/user-access-manager/ |
| 14 |
*/ |
| 15 |
|
| 16 |
use UserAccessManager\Controller\Backend\SettingsController; |
| 17 |
use UserAccessManager\Form\Form; |
| 18 |
use UserAccessManager\Form\Input; |
| 19 |
use UserAccessManager\Form\Radio; |
| 20 |
use UserAccessManager\Form\Select; |
| 21 |
use UserAccessManager\Form\Textarea; |
| 22 |
|
| 23 |
/** |
| 24 |
* @var SettingsController $controller |
| 25 |
* @var string $currentGroupKey |
| 26 |
*/ |
| 27 |
|
| 28 |
if ($controller->hasUpdateMessage()) { |
| 29 |
?> |
| 30 |
<div class="updated"> |
| 31 |
<p><strong><?php echo $controller->getUpdateMessage(); ?></strong></p> |
| 32 |
</div> |
| 33 |
<?php |
| 34 |
} |
| 35 |
?> |
| 36 |
<div class="wrap"> |
| 37 |
<h2><?php echo TXT_UAM_SETTINGS; ?></h2> |
| 38 |
<div class="uam_sidebar"> |
| 39 |
<?php include 'InfoBox.php'; ?> |
| 40 |
</div> |
| 41 |
<div class="uam_main"> |
| 42 |
<?php include 'TabList.php'; ?> |
| 43 |
<form method="post" action="<?php echo $controller->getRequestUrl(); ?>"> |
| 44 |
<?php $controller->createNonceField('uamUpdateSettings'); ?> |
| 45 |
<input type="hidden" name="uam_action" value="update_settings"/> |
| 46 |
<?php |
| 47 |
$currentSectionKey = $controller->getCurrentTabGroupSection(); |
| 48 |
$groupForms = $controller->getCurrentGroupForms(); |
| 49 |
$form = $groupForms[$currentSectionKey] ?? reset($groupForms); |
| 50 |
$cssClass = ($currentGroupKey === 'post_types') ? " uam_settings_group_post_type $currentSectionKey" : ''; |
| 51 |
$cssClass .= ($currentGroupKey === 'taxonomies') ? " uam_settings_group_taxonomies $currentSectionKey" : ''; |
| 52 |
?> |
| 53 |
<h3><?php echo $controller->getText($currentSectionKey); ?></h3> |
| 54 |
<p><?php echo $controller->getText($currentSectionKey, true); ?></p> |
| 55 |
<table id="uam_settings_group_<?php echo $currentSectionKey; ?>" |
| 56 |
class="form-table<?php echo $cssClass; ?>"> |
| 57 |
<tbody> |
| 58 |
<?php |
| 59 |
if ($form instanceof Form) { |
| 60 |
$formElements = $form->getElements(); |
| 61 |
|
| 62 |
foreach ($formElements as $formElement) { |
| 63 |
?> |
| 64 |
<tr valign="top"> |
| 65 |
<?php |
| 66 |
if ($formElement instanceof Input) { |
| 67 |
$input = $formElement; |
| 68 |
include 'AdminForm/Input.php'; |
| 69 |
} elseif ($formElement instanceof Textarea) { |
| 70 |
$textarea = $formElement; |
| 71 |
include 'AdminForm/Textarea.php'; |
| 72 |
} elseif ($formElement instanceof Select) { |
| 73 |
$select = $formElement; |
| 74 |
include 'AdminForm/Select.php'; |
| 75 |
} elseif ($formElement instanceof Radio) { |
| 76 |
$radio = $formElement; |
| 77 |
include 'AdminForm/Radio.php'; |
| 78 |
} |
| 79 |
?> |
| 80 |
</tr> |
| 81 |
<?php |
| 82 |
} |
| 83 |
} elseif (is_string($form) === true) { |
| 84 |
echo $form; |
| 85 |
} |
| 86 |
?> |
| 87 |
</tbody> |
| 88 |
</table> |
| 89 |
<div class="submit"> |
| 90 |
<input type="submit" value="<?php echo TXT_UAM_UPDATE_SETTING; ?>"/> |
| 91 |
</div> |
| 92 |
</form> |
| 93 |
</div> |
| 94 |
</div> |