squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

forms.php
Go to the documentation of this file.
1 <?php
2 
24 function addInputField($type, $name = null, $value = null, $attributes = '') {
25  return '<input type="'.$type.'"'.
26  ($name !== null ? ' name="'.htmlspecialchars($name).'"' : '').
27  ($value !== null ? ' value="'.htmlspecialchars($value).'"' : '').
28  $attributes . " />\n";
29 }
30 
34 function addPwField($name , $value = null, $extra_attributes='') {
35  return addInputField('password', $name , $value, $extra_attributes);
36 }
37 
38 
42 function addCheckBox($name, $checked = false, $value = null, $extra_attributes='') {
43  return addInputField('checkbox', $name, $value,
44  ($checked ? ' checked="checked"' : '') . $extra_attributes);
45 }
46 
50 function addRadioBox($name, $checked = false, $value = null) {
51  return addInputField('radio', $name, $value,
52  ($checked ? ' checked="checked"' : ''));
53 }
54 
58 function addHidden($name, $value) {
59  return addInputField('hidden', $name, $value);
60 }
61 
65 function addInput($name, $value = '', $size = 0, $maxlength = 0, $extra_attributes='') {
66 
67  if ($size) {
68  $extra_attributes .= ' size="'.(int)$size.'"';
69  }
70  if ($maxlength) {
71  $extra_attributes .= ' maxlength="'.(int)$maxlength .'"';
72  }
73 
74  return addInputField('text', $name, $value, $extra_attributes);
75 }
76 
77 
86 function addSelect($name, $values, $default = null, $usekeys = false)
87 {
88  // only one element
89  if(count($values) == 1) {
90  $k = key($values); $v = array_pop($values);
91  return addHidden($name, ($usekeys ? $k:$v)).
92  htmlspecialchars($v) . "\n";
93  }
94 
95  $ret = '<select name="'.htmlspecialchars($name) . "\">\n";
96  foreach ($values as $k => $v) {
97  if(!$usekeys) $k = $v;
98  $ret .= '<option value="' .
99  htmlspecialchars( $k ) . '"' .
100  (($default == $k) ? ' selected="selected"' : '') .
101  '>' . htmlspecialchars($v) ."</option>\n";
102  }
103  $ret .= "</select>\n";
104 
105  return $ret;
106 }
107 
112 function addSubmit($value, $name = null, $extra_attributes='') {
113  return addInputField('submit', $name, $value, $extra_attributes);
114 }
118 function addReset($value) {
119  return addInputField('reset', null, $value);
120 }
121 
125 function addTextArea($name, $text = '', $cols = 40, $rows = 10, $attr = '') {
126  return '<textarea name="'.htmlspecialchars($name).'" '.
127  'rows="'.(int)$rows .'" cols="'.(int)$cols.'" '.
128  $attr . '>'.htmlspecialchars($text) ."</textarea>\n";
129 }
130 
150 function addForm($action, $method = 'post', $name = '', $enctype = '', $charset = '', $extra = '', $add_token = FALSE)
151 {
152  if($name) {
153  $name = ' name="'.$name.'"';
154  }
155  if($enctype) {
156  $enctype = ' enctype="'.$enctype.'"';
157  }
158  if($charset) {
159  $charset = ' accept-charset="'.htmlspecialchars($charset).'"';
160  }
161 
162  $form_string = '<form action="'. $action .'" method="'. $method .'"'.
163  $enctype . $name . $charset . ' ' . $extra . " >\n";
164 
165  if($add_token) {
166  $form_string .= '<input type="hidden" value="' . sm_generate_security_token()
167  . '" name="' . (is_string($add_token) ? $add_token : 'smtoken')
168  . "\" />\n";
169  }
170 
171  return $form_string;
172 }
173 
$attributes
$attributes
Definition: search.php:281
$ret
$ret
Definition: webmail.php:172
addTextArea
addTextArea($name, $text='', $cols=40, $rows=10, $attr='')
Definition: forms.php:125
$charset
$charset
Definition: view_text.php:67
addForm
addForm($action, $method='post', $name='', $enctype='', $charset='', $extra='', $add_token=FALSE)
Definition: forms.php:150
addInput
addInput($name, $value='', $size=0, $maxlength=0, $extra_attributes='')
Definition: forms.php:65
addSelect
addSelect($name, $values, $default=null, $usekeys=false)
Definition: forms.php:86
$values
if(!isset($passed_ent_id)) if(!isset($passed_id)) if(!isset($mailbox)) if(!isset($action)) $values
Definition: compose.php:661
addRadioBox
addRadioBox($name, $checked=false, $value=null)
Definition: forms.php:50
addInputField
addInputField($type, $name=null, $value=null, $attributes='')
Definition: forms.php:24
addSubmit
addSubmit($value, $name=null, $extra_attributes='')
Definition: forms.php:112
sm_generate_security_token
sm_generate_security_token()
Definition: strings.php:1340
addHidden
addHidden($name, $value)
Definition: forms.php:58
$action
$action
Definition: options.php:34
addPwField
addPwField($name, $value=null, $extra_attributes='')
Definition: forms.php:34
addCheckBox
addCheckBox($name, $checked=false, $value=null, $extra_attributes='')
Definition: forms.php:42
addReset
addReset($value)
Definition: forms.php:118