aboutsummaryrefslogtreecommitdiff
path: root/views/default/input
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-12 06:56:19 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-12 06:56:19 +0000
commitd5c85494392d8a12e8331a8a52174e75f85e1efd (patch)
tree4dc30efd217d942749ccca4acaa98039f0c4f8f2 /views/default/input
parent606ae57ee7a245736367068db7827849215b9e07 (diff)
downloadelgg-d5c85494392d8a12e8331a8a52174e75f85e1efd.tar.gz
elgg-d5c85494392d8a12e8331a8a52174e75f85e1efd.tar.bz2
Refs #2143: DRYed up input/access -- wow, that feels good
git-svn-id: http://code.elgg.org/elgg/trunk@8147 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/input')
-rw-r--r--views/default/input/access.php41
1 files changed, 8 insertions, 33 deletions
diff --git a/views/default/input/access.php b/views/default/input/access.php
index 79807cedd..ea4654be6 100644
--- a/views/default/input/access.php
+++ b/views/default/input/access.php
@@ -14,40 +14,15 @@
*
*/
-$class = "elgg-input-access";
-if (isset($vars['class'])) {
- $class = $vars['class'];
-}
+$defaults = array(
+ 'class' => 'elgg-input-access',
+ 'disabled' => FALSE,
+ 'value' => get_default_access(),
+ 'options' => get_write_access_array(),
+);
-$disabled = false;
-if (isset($vars['disabled'])) {
- $disabled = $vars['disabled'];
-}
-
-if (!array_key_exists('value', $vars) || $vars['value'] == ACCESS_DEFAULT) {
- $vars['value'] = get_default_access();
-}
-
-if ((!isset($vars['options'])) || (!is_array($vars['options']))) {
- $vars['options'] = array();
- $vars['options'] = get_write_access_array();
-}
+$vars = array_merge($defaults, $vars);
if (is_array($vars['options']) && sizeof($vars['options']) > 0) {
- ?>
-
- <select <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ($disabled) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
- <?php
-
- foreach($vars['options'] as $key => $option) {
- if ($key != $vars['value']) {
- echo "<option value=\"{$key}\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
- } else {
- echo "<option value=\"{$key}\" selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
- }
- }
-
- ?>
- </select>
- <?php
+ echo elgg_view('input/dropdown', $vars);
} \ No newline at end of file