diff options
Diffstat (limited to 'views/installation/input')
-rw-r--r-- | views/installation/input/checkbox.php | 37 | ||||
-rw-r--r-- | views/installation/input/checkboxes.php | 64 | ||||
-rw-r--r-- | views/installation/input/combo.php | 19 | ||||
-rw-r--r-- | views/installation/input/form.php | 4 | ||||
-rw-r--r-- | views/installation/input/hidden.php | 10 | ||||
-rw-r--r-- | views/installation/input/text.php | 22 |
6 files changed, 52 insertions, 104 deletions
diff --git a/views/installation/input/checkbox.php b/views/installation/input/checkbox.php index 898fe8458..378eae6fd 100644 --- a/views/installation/input/checkbox.php +++ b/views/installation/input/checkbox.php @@ -2,32 +2,29 @@ /** * Elgg checkbox input * Displays a checkbox input tag - * - * @package Elgg - * @subpackage Core * - * - * Pass input tag attributes as key value pairs. For a list of allowable - * attributes, see http://www.w3schools.com/tags/tag_input.asp - * - * @uses mixed $vars['default'] The default value to submit if not checked. - * Optional, defaults to 0. Set to false for no default. + * @uses $var['name'] + * @uses $vars['value'] + * @uses $vars['id'] + * @uses $vars['class'] */ -$defaults = array( - 'class' => 'elgg-input-checkbox', - 'default' => 0, -); - -$vars = array_merge($defaults, $vars); +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; +} else { + $id = ''; +} -$default = $vars['default']; -unset($vars['default']); +if (isset($vars['class'])) { + $id = "class=\"{$vars['class']}\""; +} else { + $id = ''; +} -if (isset($vars['name']) && $default !== false) { - echo "<input type=\"hidden\" name=\"{$vars['name']}\" value=\"$default\"/>"; +if (!isset($vars['value'])) { + $vars['value'] = $vars['name']; } ?> -<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> />
\ No newline at end of file +<input type="checkbox" <?php echo $id; ?> <?php echo $class; ?> name="<?php echo $vars['name']; ?>" value="<?php echo $vars['value']; ?>" />
\ No newline at end of file diff --git a/views/installation/input/checkboxes.php b/views/installation/input/checkboxes.php deleted file mode 100644 index 026ff04ba..000000000 --- a/views/installation/input/checkboxes.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/** - * Elgg checkbox input - * Displays a checkbox input field - * - * - * @uses string $vars['name'] The name of the input fields - * (Forced to an array by appending []) - * @uses array $vars['options'] An array of strings representing the - * label => option for the each checkbox field - * @uses string $vars['id'] The id for each input field. Optional. - * (Only use this with a single value.) - * @uses string $vars['default'] The default value to send if nothing is checked. - * Optional, defaults to 0. Set to FALSE for no default. - * @uses bool $vars['disabled'] Make all input elements disabled. Optional. - * @uses string $vars['value'] The current value. Optional. - * @uses string $vars['class'] Additional class of the list. Optional. - * @uses string $vars['align'] 'horizontal' or 'vertical' Default: 'vertical' - * - */ - -$additional_class = elgg_extract('class', $vars); -$align = elgg_extract('align', $vars, 'vertical'); -$value = (isset($vars['value'])) ? $vars['value'] : NULL; -$value_array = (is_array($value)) ? array_map('elgg_strtolower', $value) : array(elgg_strtolower($value)); -$name = (isset($vars['name'])) ? $vars['name'] : ''; -$options = (isset($vars['options']) && is_array($vars['options'])) ? $vars['options'] : array(); -$default = (isset($vars['default'])) ? $vars['default'] : 0; - -$id = (isset($vars['id'])) ? $vars['id'] : ''; -$disabled = (isset($vars['disabled'])) ? $vars['disabled'] : FALSE; - -$class = "elgg-input-checkboxes elgg-$align"; -if ($additional_class) { - $class = " $additional_class"; -} - -if ($options && count($options) > 0) { - // include a default value so if nothing is checked 0 will be passed. - if ($name && $default !== FALSE) { - echo "<input type=\"hidden\" name=\"$name\" value=\"$default\" />"; - } - - echo "<ul class=\"$class\">"; - foreach ($options as $label => $option) { - - $input_vars = array( - 'checked' => in_array(elgg_strtolower($option), $value_array), - 'value' => $option, - 'disabled' => $disabled, - 'id' => $id, - 'default' => false, - ); - - if ($name) { - $input_vars['name'] = "{$name}[]"; - } - - $input = elgg_view('input/checkbox', $input_vars); - - echo "<li><label>{$input}{$label}</label></li>"; - } - echo '</ul>'; -}
\ No newline at end of file diff --git a/views/installation/input/combo.php b/views/installation/input/combo.php new file mode 100644 index 000000000..508dbcd01 --- /dev/null +++ b/views/installation/input/combo.php @@ -0,0 +1,19 @@ +<?php +/** + * Combination of text box and check box. When the checkbox is checked, the + * text field is cleared and disabled. + * + */ + +$label = elgg_echo('install:label:combo:' . $vars['name']); + +$vars['class'] = "elgg-combo-text"; +echo elgg_view('input/text', $vars); + +$vars['class'] = "elgg-combo-checkbox"; +$vars['value'] = "{$vars['name']}-checkbox"; +echo elgg_view('input/checkbox', $vars); + +echo "<label class=\"elgg-combo-label\">$label</label>"; + +echo '<div class="clearfloat"></div>';
\ No newline at end of file diff --git a/views/installation/input/form.php b/views/installation/input/form.php index d48d5fed8..f8730b4f5 100644 --- a/views/installation/input/form.php +++ b/views/installation/input/form.php @@ -10,12 +10,12 @@ */ if (isset($vars['id'])) { - $id = "id = \"{$vars['id']}\""; + $id = "id=\"{$vars['id']}\""; } else { $id = ''; } if (isset($vars['name'])) { - $name = "name = \"{$vars['name']}\""; + $name = "name=\"{$vars['name']}\""; } else { $name = ''; } diff --git a/views/installation/input/hidden.php b/views/installation/input/hidden.php deleted file mode 100644 index 139ff03d7..000000000 --- a/views/installation/input/hidden.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -/** - * Create a hidden data field - * - * @uses $vars['value'] The current value, if any - * @uses $vars['name'] The name of the input field - * - */ -?> -<input type="hidden" name="<?php echo $vars['name']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" />
\ No newline at end of file diff --git a/views/installation/input/text.php b/views/installation/input/text.php index 2caf547b6..ec8233461 100644 --- a/views/installation/input/text.php +++ b/views/installation/input/text.php @@ -3,17 +3,23 @@ * Elgg text input * Displays a text input field * - * * @uses $vars['value'] The current value, if any - * @uses $vars['name'] The name of the input field - * @uses $vars['disabled'] If true then control is read-only - * @uses $vars['class'] Class override + * @uses $vars['name'] The name of the input field + * @uses $vars['class'] CSS class + * @uses $vars['id'] CSS id */ -$class = $vars['class']; -if (!$class) { - $class = "input-text"; +if (isset($vars['class'])) { + $class = "class=\"{$vars['class']}\""; +} else { + $class = ""; +} + +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; +} else { + $id = ''; } ?> -<input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> name="<?php echo $vars['name']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/>
\ No newline at end of file +<input type="text" name="<?php echo $vars['name']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" <?php echo $class; ?> <?php echo $id; ?>/>
\ No newline at end of file |