We have moved to Github. Please open tickets there.

Ticket #2143: text.php

File text.php, 1.4 KB (added by cash, 3 years ago)
Line 
1<?php
2/**
3 * Create a text input field
4 *
5 * @package Elgg
6 * @subpackage Core
7 * @author Curverider Ltd
8 * @link http://elgg.org/
9 *
10 * @uses $vars['value'] The current value, if any
11 * @uses $vars['internalname'] The name of the input field
12 * @uses $vars['internalid'] The id of the input field
13 *
14 * All other input attributes can be specified using their attribute name
15 * including event attributes such as onclick.
16 */
17
18// remove all the junk that elgg_view throws into $vars
19unset($vars['config']);
20unset($vars['url']);
21unset($vars['page_owner']);
22unset($vars['page_owner_user']);
23foreach ($_SESSION as $key=>$value) {
24    unset($vars[$key]);
25}
26
27
28// backwards compatibility code
29if (isset($vars['internalname'])) {
30    $vars['name'] = $vars['internalname'];
31    unset($vars['internalname']);
32}
33if (isset($vars['internalid'])) {
34    $vars['id'] = $vars['internalid'];
35    unset($vars['internalid']);
36}
37if (isset($vars['disabled'])) {
38    if ($vars['disabled']) {
39        $vars['disabled'] = 'disabled';
40    } else {
41        unset($vars['disabled']);
42    }
43}
44$js = '';
45if (isset($vars['js'])) {
46    $js = $vars['js'];
47    unset($vars['js']);
48}
49
50// default attributes
51$attributes = array('type' => 'text',
52                    'value' => '',
53                    'class' => 'input-text',
54                    );
55
56$attributes = array_merge($attributes, $vars);
57
58$attributes['value'] = htmlspecialchars($attributes['value'], ENT_QUOTES, 'UTF-8');
59
60echo "<input ";
61foreach ($attributes as $k=>$v) {
62    echo "$k=\"$v\" ";
63}
64echo $js;
65echo " />";