~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to lib/smarty/plugins/function.html_checkboxes.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 *           - options    (optional) - associative array
21
21
 *           - checked    (optional) - array default not set
22
22
 *           - separator  (optional) - ie <br> or &nbsp;
23
 
 *           - output     (optional) - without this one the buttons don't have names
 
23
 *           - output     (optional) - the output next to each checkbox
 
24
 *           - assign     (optional) - assign the output as an array to this variable
24
25
 * Examples:
25
26
 * <pre>
26
27
 * {html_checkboxes values=$ids output=$names}
30
31
 * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
31
32
 *      (Smarty online manual)
32
33
 * @author     Christopher Kvarme <christopher.kvarme@flashjab.com>
33
 
 * @author credits to Monte Ohrt <monte@ispi.net>
 
34
 * @author credits to Monte Ohrt <monte at ohrt dot com>
34
35
 * @version    1.0
35
36
 * @param array
36
37
 * @param Smarty
81
82
                $options = (array)$_val;
82
83
                break;
83
84
 
 
85
            case 'assign':
 
86
                break;
 
87
 
84
88
            default:
85
89
                if(!is_array($_val)) {
86
90
                    $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
95
99
        return ''; /* raise error here? */
96
100
 
97
101
    settype($selected, 'array');
98
 
    $_html_result = '';
 
102
    $_html_result = array();
99
103
 
100
 
    if (is_array($options)) {
 
104
    if (isset($options)) {
101
105
 
102
106
        foreach ($options as $_key=>$_val)
103
 
            $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
 
107
            $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
104
108
 
105
109
 
106
110
    } else {
107
111
        foreach ($values as $_i=>$_key) {
108
112
            $_val = isset($output[$_i]) ? $output[$_i] : '';
109
 
            $_html_result .= smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
 
113
            $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
110
114
        }
111
115
 
112
116
    }
113
117
 
114
 
    return $_html_result;
 
118
    if(!empty($params['assign'])) {
 
119
        $smarty->assign($params['assign'], $_html_result);
 
120
    } else {
 
121
        return implode("\n",$_html_result);
 
122
    }
115
123
 
116
124
}
117
125
 
127
135
    }
128
136
    $_output .= $extra . ' />' . $output;
129
137
    if ($labels) $_output .= '</label>';
130
 
    $_output .=  $separator . "\n";
 
138
    $_output .=  $separator;
131
139
 
132
140
    return $_output;
133
141
}