From f5f3f205e97c2a3219897dd14de7d57659ce1181 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 2 Jul 2011 09:21:30 -0400 Subject: Fixes #3624 input views use class extending rather than overriding --- views/default/input/checkboxes.php | 99 +++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 45 deletions(-) (limited to 'views/default/input/checkboxes.php') diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php index c78fe4db0..985858b85 100644 --- a/views/default/input/checkboxes.php +++ b/views/default/input/checkboxes.php @@ -15,68 +15,77 @@ * @package Elgg * @subpackage Core * - * @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' + * @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['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. Single value or array. 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; +$defaults = array( + 'align' => 'vertical', + 'value' => array(), + 'default' => 0, + 'disabled' => false, + 'options' => array(), + 'name' => '', +); -$id = (isset($vars['id'])) ? $vars['id'] : ''; -$disabled = (isset($vars['disabled'])) ? $vars['disabled'] : FALSE; -$js = (isset($vars['js'])) ? $vars['js'] : ''; +$vars = array_merge($defaults, $vars); -$class = "elgg-input-checkboxes elgg-$align"; -if ($additional_class) { - $class = " $additional_class"; +$class = "elgg-input-checkboxes elgg-{$vars['align']}"; +if (isset($vars['class'])) { + $class .= " {$vars['class']}"; + unset($vars['class']); } -if ($options && count($options) > 0) { +$id = ''; +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; + unset($vars['id']); + unset($vars['internalid']); +} + +if (is_array($vars['value'])) { + $values = array_map('elgg_strtolower', $vars['value']); +} else { + $values = array(elgg_strtolower($vars['value'])); +} + +$input_vars = $vars; +$input_vars['default'] = false; +if ($vars['name']) { + $input_vars['name'] = "{$vars['name']}[]"; +} +unset($input_vars['align']); +unset($input_vars['options']); + +if (count($vars['options']) > 0) { // include a default value so if nothing is checked 0 will be passed. - if ($name && $default !== FALSE) { - echo ""; + if ($vars['name'] && $vars['default'] !== false) { + echo ""; } - echo "