noalyss
Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
include
lib
itext.class.php
Go to the documentation of this file.
1
<?php
2
/*
3
* This file is part of NOALYSS.
4
*
5
* NOALYSS is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* NOALYSS is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with NOALYSS; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*/
19
20
// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
/*!
22
* \file
23
* \brief Html Input Text
24
*/
25
/*!
26
* \class IText
27
* \brief Html Input Text
28
* member :
29
* - placeholder (string) placeholder
30
* - title (string) title of the HTML ELT
31
* - autofocus (bool) true to have an autofocus
32
* - css_size (string) size in the specified unit ex: 20%
33
* - pattern (string) pattern for HTML
34
* - maxlength (int) max length of the fied
35
* - size (int) size without unit
36
* - require (bool) is element require
37
*/
38
class
IText
extends
HtmlInput
39
{
40
var
$title
;
41
var
$autofocus
;
42
var
$css_size
;
43
var
$pattern
;
/*!< $pattern HTML pattern */
44
var
$maxlength
;
/*!< HTML maxlength */
45
var
$require
;
/*!< $require (bool)*/
46
protected
$datalist
;
/*!< $datalist (double array)
47
* each row has a key (value) and a label used with make_datalist */
48
49
function
__construct
(
$name
=
''
,
$value
=
''
,
$p_id
=
""
)
50
{
51
parent::__construct(
$name
,
$value
,
$p_id
);
52
$this->
title
=
""
;
53
$this->
placeholder
=
""
;
54
$this->
extra
=
""
;
55
$this->
style
=
' class="input_text" '
;
56
$this->autofocus=
false
;
57
$this->require=
false
;
58
$this->
css_size
=
""
;
59
$this->pattern=
""
;
60
$this->maxlength=
""
;
61
$this->datalist=
null
;
62
}
63
/*!
64
\brief show the html input of the widget
65
*/
66
public
function
input
($p_name=
null
,$p_value=
null
)
67
{
68
$this->
name
=($p_name==
null
)?$this->
name
:$p_name;
69
$this->
value
=($p_value==
null
)?$this->
value
:$p_value;
70
if
( $this->
readOnly
==
true
)
return
$this->
display
();
71
$this->
id
=($this->
id
==
""
)?$this->
name
:
$this->id
;
72
73
// Double quote makes troubles
74
$this->
value
=
noalyss_str_replace
(
'"'
,
''
,$this->
value
);
75
76
// compute attribute used by javascript
77
$strAttribute=$this->
get_node_attribute
();
78
$t
=
'title="'
.$this->title.
'" '
;
79
$autofocus
=(
$this->autofocus
)?
" autofocus "
:
""
;
80
$require
=(
$this->require
)?
"required"
:
""
;
81
82
// var $pattern regex to match the INPUT TEXT
83
$pattern
=
""
;
84
if
($this->pattern !=
""
) {
85
$pattern
= sprintf(
'pattern="%s"'
,$this->pattern);
86
}
87
88
// var maxlength HTML attribute
89
$maxlength
=
""
;
90
if
($this->maxlength !=
""
) {
91
$maxlength
=sprintf(
' maxlength="%s" '
,$this->maxlength);
92
}
93
$datalist
=(empty($this->datalist ))?
""
:sprintf(
'list="dl_%s"'
,$this->
id
);
94
if
( ! isset ($this->
css_size
) || empty ($this->
css_size
))
95
{
96
97
$r
= sprintf(
'<INPUT TYPE="TEXT" %s id="%s" name="%s" value="%s" placeholder="%s" title="%s"
98
size="%s" %s %s %s %s %s %s %s %s>
99
'
,$this->
style
,
100
$this->
id
,
101
$this->
name
,
102
htmlentities($this->
value
, ENT_COMPAT|
ENT_QUOTES
,
"UTF-8"
),
103
$this->
placeholder
,
104
$this->
title
,
105
$this->
size
,
106
$this->
javascript
,
107
$this->
extra
,
108
$autofocus
,
109
$require
,
110
$strAttribute,
111
$pattern
,
112
$maxlength
,
113
$datalist
114
);
115
}
else
{
116
$r
= sprintf(
'<INPUT TYPE="TEXT" %s id="%s" name="%s" value="%s" placeholder="%s" title="%s"
117
style="width:%s ;" %s %s %s %s %s %s>
118
'
,$this->
style
,
119
$this->
id
,
120
$this->
name
,
121
htmlentities($this->
value
, ENT_COMPAT|
ENT_QUOTES
,
"UTF-8"
),
122
$this->
placeholder
,
123
$this->
title
,
124
$this->
css_size
,
125
$this->
javascript
,
126
$this->
extra
,
127
$autofocus
,
128
$require
,
129
$strAttribute,
130
$pattern
,
131
$maxlength
,
132
$datalist
133
);
134
}
135
136
/* add tag for column if inside a table */
137
if
( $this->
table
== 1 )
$r
=
'<td>'
.$r.
'</td>'
;
138
$r
.=$this->
make_datalist
();
139
return
$r
;
140
141
}
142
public
function
get_datalist
() {
143
return
$this->datalist
;
144
}
145
146
public
function
set_datalist
(
$datalist
) {
147
$this->datalist =
$datalist
;
148
return
$this;
149
}
150
151
/*!\brief print in html the readonly value of the widget*/
152
public
function
display
()
153
{
154
$t
= ((isset($this->
title
)))?
'title="'
.$this->
title
.
'" '
:
' '
;
155
156
$extra
=(isset($this->
extra
))?$this->
extra
:
""
;
157
$strAttribute=$this->
get_node_attribute
();
158
$readonly
=
" readonly "
;
159
$this->
value
=htmlentities($this->
value
??
""
, ENT_COMPAT|
ENT_QUOTES
,
"UTF-8"
);
160
$this->
style
=
' class="input_text_ro" '
;
161
if
( ! isset ($this->
css_size
))
162
{
163
$r
=
'<INPUT '
.$this->style.
' TYPE="TEXT" id="'
.
164
$this->
id
.
'"'
.
$t
.
165
'NAME="'
.$this->name.
'" VALUE="'
.$this->
value
.
'" '
.
166
'SIZE="'
.$this->size.
'" '
.$this->
javascript
.
" $readonly $this->extra $strAttribute>"
;
167
}
else
{
168
$r
=
'<INPUT '
.$this->style.
' TYPE="TEXT" id="'
.
169
$this->
id
.
'"'
.
$t
.
170
'NAME="'
.$this->name.
'" VALUE="'
.$this->
value
.
'" '
.
171
' style="width:'
.$this->css_size.
'" '
.$this->
javascript
.
" $readonly $this->extra $strAttribute>"
;
172
}
173
174
/* add tag for column if inside a table */
175
if
($this->
table
== 1) {
176
$r
=
'<td>'
.
$r
.
'</td>'
;
177
}
178
179
return
$r
;
180
181
}
182
function
set_require
($p_boolean)
183
{
184
$this->require=$p_boolean;
185
}
186
static
public
function
test_me
()
187
{
188
}
189
/**
190
* @brief add a datalist
191
* @param $array (double array) each row has 2 keys 0 => stored value 1=>label
192
* @return string
193
*/
194
protected
function
make_datalist
()
195
{
196
if
( empty($this->datalist))
return
""
;
197
$r
=sprintf(
'<datalist id="dl_%s"">'
,$this->
id
);
198
foreach
($this->datalist as $item) {
199
$r
.=sprintf(
'<option value="%s">%s %s</option>'
200
,$item[0],$item[1]
201
,htmlentities($item[1]));
202
}
203
$r
.=
'</datalist>'
;
204
return
$r
;
205
}
206
}
noalyss_str_replace
noalyss_str_replace($search, $replace, $string)
Definition
ac_common.php:1665
$p_id
$p_id
Definition
ajax_accounting.php:33
value
$q value
Definition
ajax_add_concerned_card.php:59
$r
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
Definition
ajax_add_concerned_card.php:53
javascript
$ret javascript
Definition
ajax_display_letter.php:53
style
$opd_description style
Definition
ajax_mod_predf_op.php:52
size
$name size
Definition
ajax_mod_predf_op.php:49
name
$from_poste name
Definition
balance.inc.php:163
HtmlInput\$value
$value
Definition
html_input.class.php:59
HtmlInput\get_node_attribute
get_node_attribute()
Insert attribute inside a INPUT TYPE, these attribute can be retrieved in javascript with element....
Definition
html_input.class.php:1253
HtmlInput\$id
$id
Definition
html_input.class.php:76
HtmlInput\$name
$name
Definition
html_input.class.php:58
HtmlInput\$extra
$extra
Definition
html_input.class.php:66
IText
Html Input Text member :
Definition
itext.class.php:39
IText\$maxlength
$maxlength
Definition
itext.class.php:44
IText\$require
$require
Definition
itext.class.php:45
IText\$datalist
$datalist
Definition
itext.class.php:46
IText\input
input($p_name=null, $p_value=null)
show the html input of the widget
Definition
itext.class.php:66
IText\get_datalist
get_datalist()
Definition
itext.class.php:142
IText\$pattern
$pattern
Definition
itext.class.php:43
IText\$autofocus
$autofocus
Definition
itext.class.php:41
IText\set_datalist
set_datalist($datalist)
Definition
itext.class.php:146
IText\test_me
static test_me()
Definition
itext.class.php:186
IText\$title
$title
Definition
itext.class.php:40
IText\make_datalist
make_datalist()
add a datalist
Definition
itext.class.php:194
IText\set_require
set_require($p_boolean)
Definition
itext.class.php:182
IText\$css_size
$css_size
Definition
itext.class.php:42
IText\__construct
__construct($name='', $value='', $p_id="")
Definition
itext.class.php:49
IText\display
display()
print in html the readonly value of the widget
Definition
itext.class.php:152
table
$all table
Definition
company.inc.php:151
placeholder
$anc_filter placeholder
Definition
company.inc.php:120
title
$anc_filter title
Definition
company.inc.php:121
$t
$t
Definition
compute.php:46
readOnly
$icard readOnly
Definition
follow_up_detail_display.php:69
$readonly
$readonly
Definition
follow_up_detail_display.php:34
extra
$poste extra
Definition
lettering.card.inc.php:40
ENT_QUOTES
ENT_QUOTES
Definition
message_javascript.php:92
css_size
$name css_size
Definition
stock_cfg.inc.php:124
Generated on Thu Jan 15 2026 10:14:39 for noalyss by
1.13.2