Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
5e1513f6 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
0337d704 | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
58acfe8b | 22 | function education_options($current = 0) |
043bbacf | 23 | { |
9fce7016 | 24 | $html = '<option value="-1"> </option>'; |
1c305d4c | 25 | $res = XDB::iterator("SELECT e.id AS id, gc.country, |
2700a4f5 | 26 | IF(CHAR_LENGTH(e.name) > 76, e.abbreviation, e.name) AS name |
a5e30e55 | 27 | FROM profile_education_enum AS e |
e4cd7a1f | 28 | LEFT JOIN geoloc_countries AS gc ON (e.country = gc.iso_3166_1_a2) |
c7eac294 SJ |
29 | WHERE EXISTS (SELECT * |
30 | FROM profile_education_degree AS d | |
31 | WHERE e.id = d.eduid) | |
1c305d4c | 32 | ORDER BY gc.country, e.name"); |
a5e30e55 | 33 | $country = ""; |
f711b03f | 34 | while ($arr_edu = $res->next()) { |
a5e30e55 | 35 | if ($arr_edu["country"] != $country) { |
9fce7016 PC |
36 | if ($country) { |
37 | $html .= '</optgroup>'; | |
38 | } | |
a5e30e55 | 39 | $country = $arr_edu["country"]; |
9fce7016 | 40 | $html .= '<optgroup label="' . $country . '">'; |
a5e30e55 | 41 | } |
f711b03f | 42 | $html .= '<option value="' . $arr_edu["id"] . '"'; |
58acfe8b | 43 | if ($arr_edu["id"] == $current) { |
043bbacf SJ |
44 | $html .= " selected='selected'"; |
45 | } | |
f711b03f | 46 | $html .= '>' . htmlspecialchars($arr_edu["name"]) . "</option>\n"; |
0337d704 | 47 | } |
9fce7016 PC |
48 | if ($country) { |
49 | $html .= '</optgroup>'; | |
50 | } | |
0337d704 | 51 | return $html; |
52 | } | |
043bbacf | 53 | |
f711b03f | 54 | /** pour appeller education_options depuis smarty |
0337d704 | 55 | */ |
f711b03f | 56 | function _education_options_smarty($params) |
043bbacf SJ |
57 | { |
58 | if(!isset($params['selected'])) { | |
b34046e9 | 59 | $params['selected'] = 0; |
043bbacf | 60 | } |
f711b03f | 61 | return education_options($params['selected']); |
0337d704 | 62 | } |
f711b03f | 63 | Platal::page()->register_function('education_options', '_education_options_smarty'); |
0337d704 | 64 | |
f711b03f | 65 | /** affiche un Array javascript contenant les diplômes de chaque formation |
0337d704 | 66 | */ |
f711b03f | 67 | function education_degree() |
043bbacf | 68 | { |
6505acf7 SJ |
69 | $html = ''; |
70 | $res = XDB::iterRow("SELECT eduid, degreeid | |
71 | FROM profile_education_degree | |
72 | ORDER BY eduid"); | |
73 | $edu_degree = $res->next(); | |
74 | for ($eduid = 1; $edu_degree; ++$eduid) { | |
75 | $html .= '['; | |
76 | if ($edu_degree['0'] == $eduid) { | |
77 | $html .= $edu_degree['1']; | |
f711b03f | 78 | $edu_degree = $res->next(); |
6505acf7 SJ |
79 | while ($edu_degree['0'] == $eduid) { |
80 | $html .= ',' . $edu_degree['1']; | |
81 | $edu_degree = $res->next(); | |
82 | } | |
043bbacf | 83 | } |
6505acf7 SJ |
84 | $html .= ']'; |
85 | if ($edu_degree) { | |
86 | $html .= ",\n"; | |
043bbacf | 87 | } |
0337d704 | 88 | } |
89 | return $html; | |
90 | } | |
f711b03f | 91 | Platal::page()->register_function('education_degree', 'education_degree'); |
0337d704 | 92 | |
f711b03f | 93 | /** affiche tous les types possibles de diplômes |
0337d704 | 94 | */ |
f711b03f | 95 | function education_degree_all() |
043bbacf | 96 | { |
043bbacf SJ |
97 | $res = XDB::query("SELECT id |
98 | FROM profile_education_degree_enum | |
99 | ORDER BY id"); | |
100 | return implode(',', $res->fetchColumn()); | |
101 | } | |
f711b03f | 102 | Platal::page()->register_function('education_degree_all', 'education_degree_all'); |
043bbacf | 103 | |
f711b03f | 104 | /** affiche les noms de tous les diplômes possibles |
043bbacf | 105 | */ |
f711b03f | 106 | function education_degree_name() |
043bbacf | 107 | { |
043bbacf | 108 | $res = XDB::query("SELECT degree |
c7eac294 SJ |
109 | FROM profile_education_degree_enum |
110 | ORDER BY id"); | |
111 | return '"' . implode('","', $res->fetchColumn()) . '"'; | |
0337d704 | 112 | } |
f711b03f | 113 | Platal::page()->register_function('education_degree_name', 'education_degree_name'); |
0337d704 | 114 | |
a7de4ef7 | 115 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 116 | ?> |