password.php 1.78 KB
Newer Older
1
2
<?php
/**
3
4
 * Pieforms: Advanced web forms made easy
 * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
5
 *
6
7
8
9
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
10
 *
11
12
13
14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
15
 *
16
17
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
20
 * @package    pieform
 * @subpackage element
21
22
 * @author     Nigel McNie <nigel@catalyst.net.nz>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
23
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
24
25
26
27
28
 *
 */

/**
 * Renders a password field
29
 *
30
31
32
 * @param array    $element The element to render
 * @param Pieform  $form    The form to render the element for
 * @return string           The HTML for the element
33
 */
34
function pieform_element_password(Pieform $form, $element) {/*{{{*/
35
    return '<input type="password"'
36
        . $form->element_attributes($element)
37
        . ' value="' . Pieform::hsc($form->get_value($element)) . '">';
38
}/*}}}*/
39

40
function pieform_element_password_get_value(Pieform $form, $element) {/*{{{*/
Nigel McNie's avatar
Nigel McNie committed
41
    $global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
42
43
44
    if (isset($global[$element['name']])) {
        return $global[$element['name']];
    }
45
    if ($form->is_submitted() && isset($element['value'])) {
46
47
48
        return $element['value'];
    }
    return null;
49
}/*}}}*/
50

51
?>