| 1 |
<?php |
| 2 |
/** |
| 3 |
* Radio.php |
| 4 |
* |
| 5 |
* Radio button form field. |
| 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 |
/** |
| 17 |
* @var Radio $radio |
| 18 |
*/ |
| 19 |
|
| 20 |
use UserAccessManager\Form\Input; |
| 21 |
use UserAccessManager\Form\Radio; |
| 22 |
use UserAccessManager\Form\Select; |
| 23 |
use UserAccessManager\Form\Textarea; |
| 24 |
|
| 25 |
?> |
| 26 |
<th scope="row"><?php echo $radio->getLabel(); ?></th> |
| 27 |
<td> |
| 28 |
<?php |
| 29 |
$possibleValues = $radio->getPossibleValues(); |
| 30 |
|
| 31 |
foreach ($possibleValues as $possibleValue) { |
| 32 |
$rawValue = $possibleValue->getValue(); |
| 33 |
$formValue = (is_bool($rawValue) === true) ? |
| 34 |
(($rawValue === true) ? 'true' : 'false') : $rawValue; |
| 35 |
|
| 36 |
?> |
| 37 |
<label for="uam_<?php echo $radio->getId() . '_' . $formValue; ?>"> |
| 38 |
<input id="uam_<?php echo $radio->getId() . '_' . $formValue; ?>" |
| 39 |
type="radio" |
| 40 |
name="config_parameters[<?php echo $radio->getId(); ?>]" |
| 41 |
value="<?php echo $formValue; ?>" |
| 42 |
<?php |
| 43 |
if ($radio->getValue() === $possibleValue->getValue()) { |
| 44 |
echo 'checked="checked"'; |
| 45 |
} |
| 46 |
?> |
| 47 |
/> |
| 48 |
<?php echo $possibleValue->getLabel(); ?> |
| 49 |
</label> |
| 50 |
<?php |
| 51 |
$subElement = $possibleValue->getSubElement(); |
| 52 |
|
| 53 |
if ($subElement !== null) { |
| 54 |
if ($subElement instanceof Input) { |
| 55 |
?> |
| 56 |
<input id="uam_<?php echo $subElement->getId(); ?>" |
| 57 |
name="config_parameters[<?php echo $subElement->getId(); ?>]" |
| 58 |
value="<?php echo $subElement->getValue(); ?>"/> |
| 59 |
<?php |
| 60 |
} elseif ($subElement instanceof Textarea) { |
| 61 |
?> |
| 62 |
<textarea id="uam_<?php echo $subElement->getId(); ?>" |
| 63 |
style="width:100%;min-height:120px;" |
| 64 |
name="config_parameters[<?php echo $subElement->getId(); ?>]"><?php |
| 65 |
echo htmlentities($subElement->getValue()); |
| 66 |
?></textarea> |
| 67 |
<?php |
| 68 |
} elseif ($subElement instanceof Select) { |
| 69 |
?> |
| 70 |
<select id="uam_<?php echo $subElement->getId(); ?>" |
| 71 |
name="config_parameters[<?php echo $subElement->getId(); ?>]"> |
| 72 |
<?php |
| 73 |
$subPossibleValues = $subElement->getPossibleValues(); |
| 74 |
|
| 75 |
foreach ($subPossibleValues as $subPossibleValue) { |
| 76 |
?> |
| 77 |
<option value="<?php echo $subPossibleValue->getValue(); ?>" <?php |
| 78 |
if ($subElement->getValue() === $subPossibleValue->getValue()) { |
| 79 |
echo 'selected="selected"'; |
| 80 |
} |
| 81 |
?> > |
| 82 |
<?php echo $subPossibleValue->getLabel(); ?> |
| 83 |
</option> |
| 84 |
<?php |
| 85 |
} |
| 86 |
?> |
| 87 |
</select> |
| 88 |
<?php |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
?> |
| 93 |
<br/> |
| 94 |
<p><?php echo $radio->getDescription(); ?></p> |
| 95 |
</td> |