4 |
jpm |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
// This library is free software; you can redistribute it and/or
|
|
|
4 |
// modify it under the terms of the GNU Lesser General Public
|
|
|
5 |
// License as published by the Free Software Foundation; either
|
|
|
6 |
// version 2.1 of the License, or (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// This library is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
11 |
// Lesser General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU Lesser General Public
|
|
|
14 |
// License along with this library; if not, write to the Free Software
|
|
|
15 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
16 |
//------------------------------------------------------------------------------
|
|
|
17 |
|
|
|
18 |
//==============================================================================
|
|
|
19 |
// gs_hex2bin ($data)
|
|
|
20 |
// $data : hex data (string) to be converted to binary.
|
|
|
21 |
//
|
|
|
22 |
// Convert hex value into binary value.
|
|
|
23 |
//==============================================================================
|
|
|
24 |
|
|
|
25 |
function gs_hex2bin ($data) {
|
|
|
26 |
$len = strlen ($data);
|
|
|
27 |
|
|
|
28 |
return pack ("H$len", $data);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
//==============================================================================
|
|
|
32 |
// gs_localizeTimestamp ($ts, $locale)
|
|
|
33 |
// $ts : unix time stamp
|
|
|
34 |
// $locale : locale code
|
|
|
35 |
//
|
|
|
36 |
// Convert an unix time stamp in respect with locale (en, fr, sp).
|
|
|
37 |
//==============================================================================
|
|
|
38 |
|
|
|
39 |
function gs_localizeTimestamp ($ts, $locale) {
|
|
|
40 |
$format = 'Y/m/d H:m:s';
|
|
|
41 |
|
|
|
42 |
if ($locale == 'fr') $format = 'd/m/Y H:m:s';
|
|
|
43 |
if ($locale == 'sp') $format = 'd/m/Y H:m:s';
|
|
|
44 |
|
|
|
45 |
return date ($format, $ts);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
//==============================================================================
|
|
|
49 |
// gs_localizeDate ($date, $locale)
|
|
|
50 |
// $date : date (MySQL format: YYYY-MM-DD)
|
|
|
51 |
// $locale : locale code
|
|
|
52 |
//
|
|
|
53 |
// Convert a MySQL date in respect with locale (en, fr, sp).
|
|
|
54 |
//==============================================================================
|
|
|
55 |
|
|
|
56 |
function gs_localizeDate ($date, $locale) {
|
|
|
57 |
$dateArray = explode ('-', $date);
|
|
|
58 |
|
|
|
59 |
$y = $dateArray[0];
|
|
|
60 |
$m = $dateArray[1];
|
|
|
61 |
$d = $dateArray[2];
|
|
|
62 |
|
|
|
63 |
if ($locale == 'en') return "$y/$m/$d";
|
|
|
64 |
if ($locale == 'fr') return "$d/$m/$y";
|
|
|
65 |
if ($locale == 'sp') return "$d/$m/$y";
|
|
|
66 |
|
|
|
67 |
return $date;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
//==============================================================================
|
|
|
71 |
// gs_localizeDateTime ($date, $locale)
|
|
|
72 |
// $datetime : datetime field (MySQL format: YYYY-MM-DD HH:MM:SS)
|
|
|
73 |
// $locale : locale code
|
|
|
74 |
//
|
|
|
75 |
// Convert a MySQL date in respect with locale (en, fr, sp).
|
|
|
76 |
//==============================================================================
|
|
|
77 |
|
|
|
78 |
function gs_localizeDateTime ($datetime, $locale) {
|
|
|
79 |
$date = substr ($datetime, 0, 10);
|
|
|
80 |
$time = substr ($datetime, 11, 8);
|
|
|
81 |
|
|
|
82 |
return gs_localizeDate ($date, $locale).' - '.$time;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
//==============================================================================
|
|
|
86 |
// gs_localizeDate2MySQL ($date, $locale)
|
|
|
87 |
// $date : date (following locale)
|
|
|
88 |
// $locale : locale code
|
|
|
89 |
//
|
|
|
90 |
// Convert a date to MySQL format in respect with locale (en, fr, sp).
|
|
|
91 |
//==============================================================================
|
|
|
92 |
|
|
|
93 |
function gs_localizeDate2MySQL ($date, $locale) {
|
|
|
94 |
$dateArray = explode ('/', $date);
|
|
|
95 |
|
|
|
96 |
if ($locale == 'en') return "$dateArray[0]-$dateArray[1]-$dateArray[2]";
|
|
|
97 |
if ($locale == 'fr') return "$dateArray[2]-$dateArray[1]-$dateArray[0]";
|
|
|
98 |
if ($locale == 'sp') return "$dateArray[2]-$dateArray[1]-$dateArray[0]";
|
|
|
99 |
|
|
|
100 |
return $date;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
//==============================================================================
|
|
|
104 |
// gs_getLabel ($db, $link, $ident, $locale, $appl, $entities)
|
|
|
105 |
// $db : database name
|
|
|
106 |
// $link : database link
|
|
|
107 |
// $ident : label name
|
|
|
108 |
// $locale : locale code
|
|
|
109 |
// $appl : application name
|
|
|
110 |
// $entities : htmlentities transformation ?
|
|
|
111 |
//
|
|
|
112 |
// Get localized label. If the label appears into a JavaScript string, $entities
|
|
|
113 |
// MUST be false.
|
|
|
114 |
//==============================================================================
|
|
|
115 |
|
|
|
116 |
function gs_getLabel ($dbname, $link, $ident, $locale, $appl = '', $entities = true) {
|
|
|
117 |
static $labelsCache = array ();
|
|
|
118 |
|
|
|
119 |
$tag = "$ident $locale $appl";
|
|
|
120 |
|
|
|
121 |
if (isset ($labelsCache[$tag])) {
|
|
|
122 |
return ($entities ? htmlentities ($labelsCache[$tag]) : $labelsCache[$tag]);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
$query =
|
|
|
126 |
"select L_TRANSLATION from $dbname.LABELS".
|
|
|
127 |
" where L_IDENT='$ident' and L_LOCALE='$locale' and L_APPL='$appl'";
|
|
|
128 |
|
|
|
129 |
$result = mysql_query ($query, $link);
|
|
|
130 |
|
|
|
131 |
if (! $result) {
|
|
|
132 |
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
if (mysql_num_rows ($result) == 0) {
|
|
|
136 |
mysql_free_result ($result);
|
|
|
137 |
return "($ident)";
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
$row = mysql_fetch_object ($result);
|
|
|
141 |
|
|
|
142 |
mysql_free_result ($result);
|
|
|
143 |
|
|
|
144 |
$labelsCache[$tag] = $row->L_TRANSLATION;
|
|
|
145 |
|
|
|
146 |
return ($entities ? htmlentities ($row->L_TRANSLATION) : $row->L_TRANSLATION);
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
//==============================================================================
|
|
|
150 |
// gs_buildControlAndPages ($db, $link, $locale, $url, $first, $max, $numItems,
|
|
|
151 |
// $noResponse, $oneResponse, $responses,
|
|
|
152 |
// $width, $style, $imgdir)
|
|
|
153 |
// $db : database name
|
|
|
154 |
// $link : database link
|
|
|
155 |
// $locale : locale code
|
|
|
156 |
// $url : URL to show datas, without first and max limits
|
|
|
157 |
// $first : in the result set, the index of the first item to show
|
|
|
158 |
// $max : max count of results by page
|
|
|
159 |
// $numItems : results count
|
|
|
160 |
// $noResponse : label (if no responses)
|
|
|
161 |
// $oneResponse : label (if only one response)
|
|
|
162 |
// $responses : label (if more than one response)
|
|
|
163 |
// $width : table widh (if equal to zero, 100%)
|
|
|
164 |
// $style : style used into the images control cells
|
|
|
165 |
// $imgdir : the image set used for the control buttons
|
|
|
166 |
//
|
|
|
167 |
// Generation of control buttons (first, previous, next, last) and pages numbers
|
|
|
168 |
// (search result, for example).
|
|
|
169 |
//==============================================================================
|
|
|
170 |
|
|
|
171 |
function gs_buildControlAndPages ($db, $link, $locale,
|
|
|
172 |
$url,
|
|
|
173 |
$first, $max, $numItems,
|
|
|
174 |
$noResponse = null,
|
|
|
175 |
$oneResponse = null,
|
|
|
176 |
$responses = null,
|
|
|
177 |
$width = null,
|
|
|
178 |
$style = null,
|
|
|
179 |
$imgdir = null,
|
|
|
180 |
$appl = 'gsite') {
|
|
|
181 |
//----------------------------------------------------------------------------
|
|
|
182 |
// Manage default values.
|
|
|
183 |
|
|
|
184 |
if (empty ($noResponse)) $noResponse = 'ctrl_no_response';
|
|
|
185 |
if (empty ($oneResponse)) $oneResponse = 'ctrl_one_response';
|
|
|
186 |
if (empty ($responses)) $responses = 'ctrl_responses';
|
|
|
187 |
if (empty ($width)) $width = '100%';
|
|
|
188 |
if (empty ($style)) $style = 'line';
|
|
|
189 |
if (empty ($imgdir)) $imgdir = 'dft';
|
|
|
190 |
|
|
|
191 |
//----------------------------------------------------------------------------
|
|
|
192 |
// Build style.
|
|
|
193 |
|
|
|
194 |
global $GS_GLOBAL;
|
|
|
195 |
|
|
|
196 |
$STYLErow = $GS_GLOBAL['style_row'];
|
|
|
197 |
|
|
|
198 |
$fontStyle =
|
|
|
199 |
"font-family:$STYLErow->S_FONT_FAMILY;".
|
|
|
200 |
"font-size:$STYLErow->S_FONT_SIZE_SMALL;".
|
|
|
201 |
"color:$STYLErow->S_COLOR_TEXT;".
|
|
|
202 |
"font-style:normal;".
|
|
|
203 |
"font-weight:bold;";
|
|
|
204 |
|
|
|
205 |
$anchorStyle = "";
|
|
|
206 |
// "text-decoration:none;".
|
|
|
207 |
// "color:$STYLErow->S_COLOR_TEXT;";
|
|
|
208 |
|
|
|
209 |
//----------------------------------------------------------------------------
|
|
|
210 |
// Get labels.
|
|
|
211 |
|
|
|
212 |
$pageLabel = gs_getLabel ($db, $link, 'ctrl_page', $locale, $appl);
|
|
|
213 |
$numresLabel0 = gs_getLabel ($db, $link, $noResponse, $locale, $appl);
|
|
|
214 |
$numresLabel1 = gs_getLabel ($db, $link, $oneResponse, $locale, $appl);
|
|
|
215 |
$numresLabel = gs_getLabel ($db, $link, $responses, $locale, $appl);
|
|
|
216 |
|
|
|
217 |
//----------------------------------------------------------------------------
|
|
|
218 |
// Build labels, switch number of results.
|
|
|
219 |
|
|
|
220 |
$responses = '';
|
|
|
221 |
if ($numItems == 0) {
|
|
|
222 |
$responses = $numresLabel0;
|
|
|
223 |
|
|
|
224 |
} else if ($numItems == 1) {
|
|
|
225 |
$responses = $numresLabel1;
|
|
|
226 |
|
|
|
227 |
} else {
|
|
|
228 |
$responses = $numresLabel.' : '.$numItems;
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
//----------------------------------------------------------------------------
|
|
|
232 |
// Build pages count.
|
|
|
233 |
|
|
|
234 |
if ($numItems > $max) {
|
|
|
235 |
//-- More than one page.
|
|
|
236 |
$count = $pageLabel.' :';
|
|
|
237 |
$pgcount = 1;
|
|
|
238 |
|
|
|
239 |
//-- For all sets of items.
|
|
|
240 |
|
|
|
241 |
$current = 0;
|
|
|
242 |
$blockArray = array ();
|
|
|
243 |
|
|
|
244 |
for ($i = 0; $i < $numItems; $i += $max) {
|
|
|
245 |
if ($first == $i) {
|
|
|
246 |
//-- This is the current set.
|
|
|
247 |
$current = $pgcount;
|
|
|
248 |
$tag = '['.$pgcount.']';
|
|
|
249 |
|
|
|
250 |
} else {
|
|
|
251 |
//-- Another set: [$i, $i+$max]
|
|
|
252 |
$href = $url.'&first='.$i.'&max='.$max;
|
|
|
253 |
$tag = ('<A href="'.$href.'" style="'.$anchorStyle.'">'.$pgcount.'</A>');
|
|
|
254 |
}
|
|
|
255 |
|
|
|
256 |
$blockArray[$pgcount] = $tag;
|
|
|
257 |
|
|
|
258 |
$pgcount++;
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
$firstTag = ($current - 5 > 0 ? $current - 5 : 1);
|
|
|
262 |
$lastTag = $firstTag + 10;
|
|
|
263 |
|
|
|
264 |
if ($firstTag > 1) $count .= ' ... ';
|
|
|
265 |
|
|
|
266 |
while (list ($k, $v) = each ($blockArray)) {
|
|
|
267 |
if (($k >= $firstTag) && ($k <= $lastTag)) {
|
|
|
268 |
$count .= ' '.$v;
|
|
|
269 |
}
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
if ($lastTag + 1 < $pgcount) $count .= ' ... ';
|
|
|
273 |
|
|
|
274 |
} else {
|
|
|
275 |
//-- Zero or one page.
|
|
|
276 |
$count = ' ';
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
//----------------------------------------------------------------------------
|
|
|
280 |
// Build table.
|
|
|
281 |
|
|
|
282 |
$str = '';
|
|
|
283 |
$str .= "\n".' <TABLE width="'.$width.'" border="0" cellspacing="0" cellpadding="0" summary="">';
|
|
|
284 |
$str .= "\n".' <TR>';
|
|
|
285 |
$str .= "\n".' <TD width="25%" align="left">'.gs_buildControl ($url, $first, $max, $numItems, $style, $imgdir).'</TD>';
|
|
|
286 |
$str .= "\n".' <TD width="50%" align="center"><SPAN style="'.$fontStyle.'">'.$responses.'</SPAN></TD>';
|
|
|
287 |
$str .= "\n".' <TD width="25%" style="'.$fontStyle.'" align="right"><SPAN style="'.$fontStyle.'">'.$count.'</SPAN></TD>';
|
|
|
288 |
$str .= "\n".' </TR>';
|
|
|
289 |
$str .= "\n".' </TABLE>';
|
|
|
290 |
|
|
|
291 |
return $str;
|
|
|
292 |
}
|
|
|
293 |
|
|
|
294 |
//==============================================================================
|
|
|
295 |
// gs_buildControl ($url, $first, $max, $numItems, $style = 'line', $imgdir = 'dft')
|
|
|
296 |
// $url : URL to show datas, without first and max limits
|
|
|
297 |
// $first : in the result set, the index of the first item to show
|
|
|
298 |
// $max : max count of results by page
|
|
|
299 |
// $numItems : results count
|
|
|
300 |
// $style : style used into the images control cells
|
|
|
301 |
// $imgdir : the image set used for the control buttons
|
|
|
302 |
//
|
|
|
303 |
// Generation of control buttons (first, previous, next, last) for search
|
|
|
304 |
// result, for example.
|
|
|
305 |
//==============================================================================
|
|
|
306 |
|
|
|
307 |
function gs_buildControl ($url,
|
|
|
308 |
$first, $max, $numItems,
|
|
|
309 |
$style = 'line',
|
|
|
310 |
$imgdir = 'dft') {
|
|
|
311 |
//----------------------------------------------------------------------------
|
|
|
312 |
// Compute index of last set.
|
|
|
313 |
|
|
|
314 |
if ($numItems == 0) {
|
|
|
315 |
$last = 0;
|
|
|
316 |
|
|
|
317 |
} else {
|
|
|
318 |
$last = ($numItems % $max == 0 ?
|
|
|
319 |
((int)($numItems / $max) - 1) * $max :
|
|
|
320 |
((int)($numItems / $max)) * $max);
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
//----------------------------------------------------------------------------
|
|
|
324 |
// Build infos for gs_control.
|
|
|
325 |
|
|
|
326 |
$ctrlParam = array (
|
|
|
327 |
'style' => $style,
|
|
|
328 |
'imgdir' => $imgdir,
|
|
|
329 |
'begin' => $url.'&first=0&max='.$max,
|
|
|
330 |
'last' => $url.'&first='.$last.'&max='.$max
|
|
|
331 |
);
|
|
|
332 |
|
|
|
333 |
if ($first > 0) {
|
|
|
334 |
$ctrlParam['prev'] = $url.'&first='.($first - $max).'&max='.$max;
|
|
|
335 |
}
|
|
|
336 |
|
|
|
337 |
if ($first + $max < $numItems) {
|
|
|
338 |
$ctrlParam['next'] = $url.'&first='.($first + $max).'&max='.$max;
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
//----------------------------------------------------------------------------
|
|
|
342 |
// Build control.
|
|
|
343 |
|
|
|
344 |
return gs_control ($ctrlParam);
|
|
|
345 |
}
|
|
|
346 |
|
|
|
347 |
//==============================================================================
|
|
|
348 |
// gs_control ($param)
|
|
|
349 |
// $param : (...)
|
|
|
350 |
//
|
|
|
351 |
// Dump a table containing images for first, prev, next, last navigation,
|
|
|
352 |
// according to $param parameters array.
|
|
|
353 |
//
|
|
|
354 |
// $param is an array, with the following items:
|
|
|
355 |
// - style : style used for the table cells
|
|
|
356 |
// - imgdir : the directory of the control images set (Local/controls/$imgdir)
|
|
|
357 |
// - begin : URL to the first set
|
|
|
358 |
// - prev : URL to the previous set
|
|
|
359 |
// - next : URL to the next set
|
|
|
360 |
// - last : URL to the last set
|
|
|
361 |
//==============================================================================
|
|
|
362 |
|
|
|
363 |
function gs_control ($param) {
|
|
|
364 |
$imgdir = (empty ($param['imgdir']) ? 'dft' : $param['imgdir']);
|
|
|
365 |
|
|
|
366 |
$icon1 = "Local/controls/$imgdir/01$imgdir.gif";
|
|
|
367 |
$icon2 = "Local/controls/$imgdir/02$imgdir.gif";
|
|
|
368 |
$icon3 = "Local/controls/$imgdir/03$imgdir.gif";
|
|
|
369 |
$icon4 = "Local/controls/$imgdir/04$imgdir.gif";
|
|
|
370 |
$icon5 = "Local/controls/$imgdir/05$imgdir.gif";
|
|
|
371 |
$icon6 = "Local/controls/$imgdir/06$imgdir.gif";
|
|
|
372 |
|
|
|
373 |
$beginImg = '<IMG src="'.$icon2.'" border="0" alt="">';
|
|
|
374 |
$prevImg = '<IMG src="'.$icon3.'" border="0" alt="">';
|
|
|
375 |
$nextImg = '<IMG src="'.$icon4.'" border="0" alt="">';
|
|
|
376 |
$lastImg = '<IMG src="'.$icon5.'" border="0" alt="">';
|
|
|
377 |
|
|
|
378 |
$style = (empty ($param['style']) ? '' : ' class="'.$param['style'].'"');
|
|
|
379 |
$beginImg = (empty ($param['begin']) ? $beginImg : '<A href="'.$param['begin'].'">'.$beginImg.'</A>');
|
|
|
380 |
$prevImg = (empty ($param['prev']) ? $prevImg : '<A href="'.$param['prev'].'">'.$prevImg.'</A>');
|
|
|
381 |
$nextImg = (empty ($param['next']) ? $nextImg : '<A href="'.$param['next'].'">'.$nextImg.'</A>');
|
|
|
382 |
$lastImg = (empty ($param['last']) ? $lastImg : '<A href="'.$param['last'].'">'.$lastImg.'</A>');
|
|
|
383 |
|
|
|
384 |
$str = '';
|
|
|
385 |
$str .= "\n".'<TABLE border="0" cellspacing="0" cellpadding="0" summary="">';
|
|
|
386 |
$str .= "\n".' <TR>';
|
|
|
387 |
$str .= "\n".' <TD><IMG src="'.$icon1.'" border="0" alt=""></TD>';
|
|
|
388 |
$str .= "\n".' <TD'.$style.'>'.$beginImg.'</TD>';
|
|
|
389 |
$str .= "\n".' <TD'.$style.'>'.$prevImg.'</TD>';
|
|
|
390 |
$str .= "\n".' <TD'.$style.'>'.$nextImg.'</TD>';
|
|
|
391 |
$str .= "\n".' <TD'.$style.'>'.$lastImg.'</TD>';
|
|
|
392 |
$str .= "\n".' <TD><IMG src="'.$icon6.'" border="0" alt=""></TD>';
|
|
|
393 |
$str .= "\n".' </TR>';
|
|
|
394 |
$str .= "\n".'</TABLE>';
|
|
|
395 |
|
|
|
396 |
return $str;
|
|
|
397 |
}
|
|
|
398 |
|
|
|
399 |
//==============================================================================
|
|
|
400 |
// gs_buildOptionInVar ($db, $link, $query, $current, $valueFieldName, $labelFieldName, $locale, $appl, $isLabel)
|
|
|
401 |
// $db : database name
|
|
|
402 |
// $link : database link
|
|
|
403 |
// $query : query to perform
|
|
|
404 |
// $current : current expected value of the select (option SELECTED)
|
|
|
405 |
// $valueFieldName : in the query, the field name of the value
|
|
|
406 |
// $labelFieldName : in the query, the field name of the text
|
|
|
407 |
// $locale : current locale, in case of labelled text
|
|
|
408 |
// $name : name of application, for labels
|
|
|
409 |
// $isLabel : true if $labelFieldName field is a label name.
|
|
|
410 |
//
|
|
|
411 |
// According to the result of the query $query, build SELECT options. The result
|
|
|
412 |
// is a string.
|
|
|
413 |
//==============================================================================
|
|
|
414 |
|
|
|
415 |
function gs_buildOptionInVar ($db, $query, $current, $valueFieldName, $labelFieldName, $locale = '', $appl= '', $isLabel = false) {
|
|
|
416 |
//----------------------------------------------------------------------------
|
|
|
417 |
// Perform query.
|
|
|
418 |
|
|
|
419 |
$res = $db->query ($query);
|
|
|
420 |
|
|
|
421 |
if (DB::isError($res)) {
|
|
|
422 |
die ("Unable to perform query ($query / " . $res->getMessage() . ")");
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
//----------------------------------------------------------------------------
|
|
|
426 |
// Build options.
|
|
|
427 |
|
|
|
428 |
$str = '';
|
|
|
429 |
|
|
|
430 |
while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
431 |
//-- Option label. If $isLabel is true, the field named $labelFieldName is
|
|
|
432 |
//-- used as a label. Otherwise, it's only a string.
|
|
|
433 |
|
|
|
434 |
$label = htmlentities ($row[$labelFieldName]);
|
|
|
435 |
|
|
|
436 |
//-- The value: field $valueFieldName of the result set.
|
|
|
437 |
$value = $row[$valueFieldName];
|
|
|
438 |
|
|
|
439 |
//-- If the value if equal to $current, this option is selected.
|
|
|
440 |
$selected = ($current == $value ? ' selected' : '');
|
|
|
441 |
|
|
|
442 |
//-- Build option.
|
|
|
443 |
|
|
|
444 |
$str .= "\n".'<OPTION value="'.$value.'"'.$selected.'>'.$label.'</OPTION>';
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
$res->free();
|
|
|
448 |
|
|
|
449 |
return $str;
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
//==============================================================================
|
|
|
453 |
// gs_localePutLanguagesFlagsInVar ($dbname, $dblink, $project)
|
|
|
454 |
// $dbname : database name
|
|
|
455 |
// $dblink : database link
|
|
|
456 |
// $project : project name
|
|
|
457 |
//
|
|
|
458 |
// Dump array of flags, one for each language supported by the project.
|
|
|
459 |
// Images are taken from Local/flags directory.
|
|
|
460 |
//==============================================================================
|
|
|
461 |
|
|
|
462 |
function gs_localePutLanguagesFlagsInVar ($dbname, $dblink, $project) {
|
|
|
463 |
//----------------------------------------------------------------------------
|
|
|
464 |
// List of all the languages supported by project.
|
|
|
465 |
|
|
|
466 |
$query =
|
|
|
467 |
"select * from $dbname.LOCALE, $dbname.LOCALE_PRJ".
|
|
|
468 |
" where LP_PROJECT='$project' and LP_CODE=L_CODE".
|
|
|
469 |
" order by LP_ORDER";
|
|
|
470 |
|
|
|
471 |
$result = mysql_query ($query, $dblink);
|
|
|
472 |
|
|
|
473 |
if (! $result) {
|
|
|
474 |
die ("Unable to perform query (" . mysql_error ($dblink) . ")");
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
//----------------------------------------------------------------------------
|
|
|
478 |
// Only one language ? Do nothing.
|
|
|
479 |
|
|
|
480 |
if (mysql_num_rows ($result) <= 1) {
|
|
|
481 |
mysql_free_result ($result);
|
|
|
482 |
return;
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
//----------------------------------------------------------------------------
|
|
|
486 |
// Dump array of flags.
|
|
|
487 |
|
|
|
488 |
$outputText = '';
|
|
|
489 |
|
|
|
490 |
$outputText .= "\n".'<TABLE summary="" cellspacing="3" cellpadding="0" border="0">';
|
|
|
491 |
$outputText .= "\n".' <TR>';
|
|
|
492 |
|
|
|
493 |
while ($row = mysql_fetch_object ($result)) {
|
|
|
494 |
//--------------------------------------------------------------------------
|
|
|
495 |
// The flags images are taken from Local/flags.
|
|
|
496 |
|
|
|
497 |
$url = "index.php?project=$project&locale=$row->LP_CODE";
|
|
|
498 |
$img = "Local/flags/$row->L_FLAG";
|
|
|
499 |
$alt = htmlentities ($row->L_DESCRIPTION);
|
|
|
500 |
|
|
|
501 |
$outputText .= "\n".'<TD>';
|
|
|
502 |
$outputText .= '<A target="_top" href="'.$url.'">';
|
|
|
503 |
$outputText .= '<IMG border="0" src="'.$img.'" alt="'.$alt.'">';
|
|
|
504 |
$outputText .= '</A>';
|
|
|
505 |
$outputText .= '</TD>';
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
$outputText .= "\n".' </TR>';
|
|
|
509 |
$outputText .= "\n".'</TABLE>';
|
|
|
510 |
|
|
|
511 |
mysql_free_result ($result);
|
|
|
512 |
|
|
|
513 |
return $outputText;
|
|
|
514 |
}
|
|
|
515 |
|
|
|
516 |
//==============================================================================
|
|
|
517 |
// FUNCTION gs_putAmount ($frf, $euro)
|
|
|
518 |
//
|
|
|
519 |
// Convert an amount into euro.
|
|
|
520 |
//
|
|
|
521 |
// NOTE: must be move into project module.
|
|
|
522 |
//==============================================================================
|
|
|
523 |
|
|
|
524 |
function gs_putAmount ($frf, $euro) {
|
|
|
525 |
if ($euro == 0) {
|
|
|
526 |
$euro = $frf / 6.55957;
|
|
|
527 |
$euro = (round ($euro * 100)) / 100;
|
|
|
528 |
}
|
|
|
529 |
|
|
|
530 |
if ($euro == 0) return ' ';
|
|
|
531 |
if ($euro >= 150000) return 'A ( >= 150 000 € )';
|
|
|
532 |
if ($euro >= 45000) return 'B ( < 150 000 €, >= 45 000 € )';
|
|
|
533 |
if ($euro >= 15000) return 'C ( < 45 000 €, >= 15 000 € )';
|
|
|
534 |
|
|
|
535 |
return 'D ( < 15 000 €)';
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
|
540 |
/** function includeFile () Inclue des fichiers en essayant dans divers lieux
|
|
|
541 |
*
|
|
|
542 |
* @param mixed Un tableau contenant les fichiers à inclure
|
|
|
543 |
* @param string Un message d'erreur
|
|
|
544 |
* return boolean true en cas de succès
|
|
|
545 |
*/
|
|
|
546 |
|
|
|
547 |
function includeFile($incFiles, $msg) {
|
|
|
548 |
if (! isset ($incFiles)) die ('Bad include path');
|
|
|
549 |
if (! is_array ($incFiles)) die ('Bad include path');
|
|
|
550 |
|
|
|
551 |
$searchPath = '';
|
|
|
552 |
|
|
|
553 |
for ($i = 0; $i < count ($incFiles); $i++) {
|
|
|
554 |
$searchPath .= $incFiles[$i].'<BR>'."\n";
|
|
|
555 |
|
|
|
556 |
if (file_exists ($incFiles[$i])) {
|
|
|
557 |
include_once ($incFiles[$i]);
|
|
|
558 |
return;
|
|
|
559 |
}
|
|
|
560 |
}
|
|
|
561 |
|
|
|
562 |
die ("$msg<BR>\nSearch path:<BR>\n$searchPath");
|
|
|
563 |
}
|
|
|
564 |
|
|
|
565 |
//==============================================================================
|
|
|
566 |
// FUNCTION gs_getUser ($db, $link, $annu, $userid)
|
|
|
567 |
//
|
|
|
568 |
// Returns an array with user informations.
|
|
|
569 |
//==============================================================================
|
|
|
570 |
|
|
|
571 |
function gs_getUser ($db, $link, $annu, $userid) {
|
|
|
572 |
$query =
|
|
|
573 |
"select * from $db.annu_USERS".
|
|
|
574 |
" where U_ID=$userid".
|
|
|
575 |
" and U_ANNU_NAME='$annu'";
|
|
|
576 |
|
|
|
577 |
$result = mysql_query ($query, $link);
|
|
|
578 |
|
|
|
579 |
if (! $result) {
|
|
|
580 |
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
|
|
|
581 |
}
|
|
|
582 |
|
|
|
583 |
$row = mysql_fetch_object ($result);
|
|
|
584 |
if (! $row) return false;
|
|
|
585 |
|
|
|
586 |
$userInfo['login'] = $row->U_LOGIN;
|
|
|
587 |
$userInfo['name'] = $row->U_NAME;
|
|
|
588 |
$userInfo['surname'] = $row->U_SURNAME;
|
|
|
589 |
$userInfo['row'] = $row;
|
|
|
590 |
|
|
|
591 |
mysql_free_result ($result);
|
|
|
592 |
|
|
|
593 |
return $userInfo;
|
|
|
594 |
}
|
|
|
595 |
|
|
|
596 |
//==============================================================================
|
|
|
597 |
//==============================================================================
|
|
|
598 |
|
|
|
599 |
//==============================================================================
|
|
|
600 |
//==============================================================================
|
|
|
601 |
|
|
|
602 |
|
|
|
603 |
//==============================================================================
|
|
|
604 |
// FUNCTION messageTo ($project, $locale, $to)
|
|
|
605 |
//
|
|
|
606 |
// Dump an icon to send a message.
|
|
|
607 |
//==============================================================================
|
|
|
608 |
|
|
|
609 |
function messageTo ($project, $locale, $to) {
|
|
|
610 |
$args = "'$project', '$locale', $to";
|
|
|
611 |
$icon = '<IMG src="Local/icons/newmsg.gif" alt="" width="16" height="16" border="0">';
|
|
|
612 |
|
|
|
613 |
return
|
|
|
614 |
'<A href="javascript:openMessenger ('.$args.')">'.
|
|
|
615 |
$icon.
|
|
|
616 |
'</A>';
|
|
|
617 |
}
|
|
|
618 |
|
|
|
619 |
//==============================================================================
|
|
|
620 |
//==============================================================================
|
|
|
621 |
|
|
|
622 |
function gs_print ($item) {
|
|
|
623 |
ob_start ();
|
|
|
624 |
print_r ($item);
|
|
|
625 |
$p = ob_get_contents ();
|
|
|
626 |
ob_end_clean ();
|
|
|
627 |
|
|
|
628 |
echo '<PRE>'.htmlentities ($p).'</PRE>';
|
|
|
629 |
}
|
|
|
630 |
|
|
|
631 |
//==============================================================================
|
|
|
632 |
|
|
|
633 |
|
|
|
634 |
?>
|