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)  

html.php
Go to the documentation of this file.
1 <?php
2 
27 function html_tag( $tag, // Tag to output
28  $val = '', // Value between tags
29  $align = '', // Alignment
30  $bgcolor = '', // Back color
31  $xtra = '' ) { // Extra options
32 
34 
35  $align = strtolower( $align );
36  $bgc = '';
37  $tag = strtolower( $tag );
38 
39  if ( isset( $languages[$squirrelmail_language]['DIR']) ) {
40  $dir = $languages[$squirrelmail_language]['DIR'];
41  } else {
42  $dir = 'ltr';
43  }
44 
45  if ( $dir == 'ltr' ) {
46  $rgt = 'right';
47  $lft = 'left';
48  } else {
49  $rgt = 'left';
50  $lft = 'right';
51  }
52 
53  if ( $bgcolor <> '' ) {
54  $bgc = " bgcolor=\"$bgcolor\"";
55  }
56 
57  switch ( $align ) {
58  case '':
59  $alg = '';
60  break;
61  case 'right':
62  $alg = " align=\"$rgt\"";
63  break;
64  case 'left':
65  $alg = " align=\"$lft\"";
66  break;
67  default:
68  $alg = " align=\"$align\"";
69  break;
70  }
71 
72  $ret = "<$tag";
73 
74  if ( $dir <> 'ltr' ) {
75  $ret .= " dir=\"$dir\"";
76  }
77  $ret .= $bgc . $alg;
78 
79  if ( $xtra <> '' ) {
80  $ret .= " $xtra";
81  }
82 
83  if ( $val <> '' ) {
84  $ret .= ">$val</$tag>\n";
85  } else {
86  $ret .= '>' . "\n";
87  }
88 
89  return( $ret );
90  }
91 
109 function set_url_var($url, $var, $val=null, $link=true) {
110  $url = str_replace('&amp;','&',$url);
111 
112  if (strpos($url, '?') === false) {
113  $url .= '?';
114  }
115 
116  list($uri, $params) = explode('?', $url, 2);
117 
118  $newpar = array();
119  $params = explode('&', $params);
120 
121  foreach ($params as $p) {
122  if (trim($p)) {
123  $p = explode('=', $p);
124  $newpar[$p[0]] = (isset($p[1]) ? $p[1] : '');
125  }
126  }
127 
128  if (is_null($val)) {
129  unset($newpar[$var]);
130  } else {
131  $newpar[$var] = $val;
132  }
133 
134  if (!count($newpar)) {
135  return $uri;
136  }
137 
138  $url = $uri . '?';
139  foreach ($newpar as $name => $value) {
140  $url .= "$name=$value&";
141  }
142 
143  $url = substr($url, 0, -1);
144  if ($link) {
145  $url = str_replace('&','&amp;',$url);
146  }
147 
148  return $url;
149 }
150 
151  /* Temporary test function to proces template vars with formatting.
152  * I use it for viewing the message_header (view_header.php) with
153  * a sort of template.
154  */
155  function echo_template_var($var, $format_ar = array() ) {
156  $frm_last = count($format_ar) -1;
157 
158  if (isset($format_ar[0])) echo $format_ar[0];
159  $i = 1;
160 
161  switch (true) {
162  case (is_string($var)):
163  echo $var;
164  break;
165  case (is_array($var)):
166  $frm_a = array_slice($format_ar,1,$frm_last-1);
167  foreach ($var as $a_el) {
168  if (is_array($a_el)) {
169  echo_template_var($a_el,$frm_a);
170  } else {
171  echo $a_el;
172  if (isset($format_ar[$i])) {
173  echo $format_ar[$i];
174  }
175  $i++;
176  }
177  }
178  break;
179  default:
180  break;
181  }
182  if (isset($format_ar[$frm_last]) && $frm_last>$i ) {
183  echo $format_ar[$frm_last];
184  }
185  }
$ret
$ret
Definition: webmail.php:172
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
set_url_var
set_url_var($url, $var, $val=null, $link=true)
Definition: html.php:109
$url
$url
Definition: mailto.php:81
$languages
global $languages
Definition: i18n.php:774
echo_template_var
echo_template_var($var, $format_ar=array())
Definition: html.php:155
$xtra
for($i=1; $i< $count; $i++) $xtra
Definition: message_details_bottom.php:253
$squirrelmail_language
global $squirrelmail_language
Definition: i18n.php:774