Subversion Repositories Sites.tela-botanica.org

Rev

Rev 609 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
<?php
2
# ***** BEGIN LICENSE BLOCK *****
3
# This file is part of DotClear.
4
# Copyright (c) 2004 Olivier Meunier and contributors. All rights
5
# reserved.
6
#
7
# DotClear is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
11
#
12
# DotClear is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with DotClear; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
#
21
# ***** END LICENSE BLOCK *****
22
 
23
class form
24
{
25
	function combo($name,$arryData,$default='',$class='',$id='',$tabindex='')
26
	{
27
		$res = '<select name="'.$name.'" ';
28
 
29
		if($class != '')
30
			$res .= 'class="'.$class.'" ';
31
 
32
		if($tabindex != '')
33
			$res .= 'tabindex="'.$tabindex.'" ';
34
 
35
		if($id != '')
36
			$res .= 'id="'.$id.'" ';
37
		else
38
			$res .= 'id="'.$name.'" ';
39
 
40
		$res .= '>'."\n";
41
 
42
		foreach($arryData as $k => $v)
43
		{
44
			$res .= '<option value="'.$v.'"';
45
 
46
			if($v == $default)
47
				$res .= ' selected="selected"';
48
 
49
			$res .= '>'.$k.'</option>'."\n";
50
		}
51
 
52
		$res .= '</select>'."\n";
53
 
54
		return $res;
55
	}
56
 
57
	function radio($name, $value, $checked='', $class='', $id='')
58
	{
59
		$res = '<input type="radio" name="'.$name.'" value="'.$value.'" ';
60
 
61
		if($class != '') {
62
			$res .= 'class="'.$class.'" ';
63
		}
64
 
65
		if($id != '') {
66
			$res .= 'id="'.$id.'" ';
67
		}
68
 
69
		if (($checked === 0) or $checked >= 1) {
70
			$res .= 'checked="checked" ';
71
		}
72
 
73
		$res .= '/>'."\n";
74
 
75
		return $res;
76
	}
77
 
78
	function checkbox($name, $value, $checked='', $class='', $id='')
79
	{
80
		$res = '<input type="checkbox" name="'.$name.'" value="'.$value.'"';
81
 
82
		if($class != '')
83
			$res .= 'class="'.$class.'" ';
84
 
85
		if($id != '') {
86
			$res .= 'id="'.$id.'" ';
87
		}
88
 
89
		if($checked != '') {
90
			$res.='checked="checked"';
91
		}
92
 
93
		$res .= ' />'."\n";
94
 
95
		return $res;
96
	}
97
 
98
	function field($id,$size,$max,$default='',$tabindex='',$html='')
99
	{
100
		if (is_array($id)) {
101
			$name = $id[0];
102
			$id = isset($id[1]) ? $id[1] : '';
103
		} else {
104
			$name = $id;
105
		}
106
 
107
		$res = '<input type="text" size="'.$size.'" name="'.$name.'" ';
108
 
109
		$res .= ($id != '') ? 'id="'.$id.'" ' : '';
110
		$res .= ($max != '') ? 'maxlength="'.$max.'" ' : '';
111
		$res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
112
		$res .= ($default != '') ? 'value="'.$default.'" ' : '';
113
		$res .= $html;
114
 
115
		$res .= ' />';
116
 
117
		return $res;
118
	}
119
 
120
	function textArea($id,$cols,$rows,$default='',$tabindex='',$html='')
121
	{
122
		$res = '<textarea cols="'.$cols.'" rows="'.$rows.'" ';
123
		$res .= 'name="'.$id.'" id="'.$id.'" ';
124
		$res .= ($tabindex != '') ? 'tabindex="'.$tabindex.'" ' : '';
125
		$res .= $html.'>';
126
		$res .= $default;
127
		$res .= '</textarea>';
128
 
129
		return $res;
130
	}
131
 
132
	function hidden($id,$value)
133
	{
134
		return '<input type="hidden" name="'.$id.'" value="'.$value.'" />';
135
	}
136
}
137
?>