Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
179afa7f | 3 | * Copyright (C) 2003-2008 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 | { |
58acfe8b | 24 | $html = '<option value="-1"></option>'; |
a5e30e55 SJ |
25 | $res = XDB::iterator("SELECT e.id AS id, e.name AS name, g.pays AS country |
26 | FROM profile_education_enum AS e | |
c7eac294 SJ |
27 | LEFT JOIN geoloc_pays AS g ON (e.country = g.a2) |
28 | WHERE EXISTS (SELECT * | |
29 | FROM profile_education_degree AS d | |
30 | WHERE e.id = d.eduid) | |
a5e30e55 SJ |
31 | ORDER BY g.pays, e.name"); |
32 | $country = ""; | |
f711b03f | 33 | while ($arr_edu = $res->next()) { |
a5e30e55 SJ |
34 | if ($arr_edu["country"] != $country) { |
35 | $country = $arr_edu["country"]; | |
36 | $html .= "<optgroup label=" . $country . ">"; | |
37 | } | |
f711b03f | 38 | $html .= '<option value="' . $arr_edu["id"] . '"'; |
58acfe8b | 39 | if ($arr_edu["id"] == $current) { |
043bbacf SJ |
40 | $html .= " selected='selected'"; |
41 | } | |
f711b03f | 42 | $html .= '>' . htmlspecialchars($arr_edu["name"]) . "</option>\n"; |
0337d704 | 43 | } |
44 | return $html; | |
45 | } | |
043bbacf | 46 | |
f711b03f | 47 | /** pour appeller education_options depuis smarty |
0337d704 | 48 | */ |
f711b03f | 49 | function _education_options_smarty($params) |
043bbacf SJ |
50 | { |
51 | if(!isset($params['selected'])) { | |
b34046e9 | 52 | $params['selected'] = 0; |
043bbacf | 53 | } |
f711b03f | 54 | return education_options($params['selected']); |
0337d704 | 55 | } |
f711b03f | 56 | Platal::page()->register_function('education_options', '_education_options_smarty'); |
0337d704 | 57 | |
f711b03f | 58 | /** affiche un Array javascript contenant les diplômes de chaque formation |
0337d704 | 59 | */ |
f711b03f | 60 | function education_degree() |
043bbacf | 61 | { |
0337d704 | 62 | $html = ""; |
c7eac294 SJ |
63 | $res = XDB::iterRow("SELECT d.eduid, d.degreeid |
64 | FROM profile_education_enum AS e | |
65 | INNER JOIN profile_education_degree AS d ON (e.id = d.eduid) | |
66 | LEFT JOIN geoloc_pays AS g ON (e.country = g.a2) | |
a5e30e55 | 67 | ORDER BY g.pays, e.name"); |
f711b03f SJ |
68 | if ($edu_degree = $res->next()) { |
69 | $eduid = $edu_degree['0']; | |
043bbacf | 70 | $html .= "["; |
f711b03f SJ |
71 | $html .= $edu_degree['1']; |
72 | $edu_degree = $res->next(); | |
73 | while ($edu_degree['0'] == $eduid) { | |
74 | $html .= "," . $edu_degree['1']; | |
75 | $edu_degree = $res->next(); | |
043bbacf SJ |
76 | } |
77 | $html .= "]"; | |
0337d704 | 78 | } |
f711b03f SJ |
79 | while ($edu_degree) { |
80 | $eduid = $edu_degree['0']; | |
043bbacf | 81 | $html .= ",\n["; |
f711b03f SJ |
82 | $html .= $edu_degree['1']; |
83 | $edu_degree = $res->next(); | |
84 | while ($edu_degree['0'] == $eduid) { | |
85 | $html .= "," . $edu_degree['1']; | |
86 | $edu_degree = $res->next(); | |
043bbacf SJ |
87 | } |
88 | $html .= "]"; | |
0337d704 | 89 | } |
90 | return $html; | |
91 | } | |
f711b03f | 92 | Platal::page()->register_function('education_degree', 'education_degree'); |
0337d704 | 93 | |
f711b03f | 94 | /** affiche tous les types possibles de diplômes |
0337d704 | 95 | */ |
f711b03f | 96 | function education_degree_all() |
043bbacf | 97 | { |
043bbacf SJ |
98 | $res = XDB::query("SELECT id |
99 | FROM profile_education_degree_enum | |
100 | ORDER BY id"); | |
101 | return implode(',', $res->fetchColumn()); | |
102 | } | |
f711b03f | 103 | Platal::page()->register_function('education_degree_all', 'education_degree_all'); |
043bbacf | 104 | |
f711b03f | 105 | /** affiche les noms de tous les diplômes possibles |
043bbacf | 106 | */ |
f711b03f | 107 | function education_degree_name() |
043bbacf | 108 | { |
043bbacf | 109 | $res = XDB::query("SELECT degree |
c7eac294 SJ |
110 | FROM profile_education_degree_enum |
111 | ORDER BY id"); | |
112 | return '"' . implode('","', $res->fetchColumn()) . '"'; | |
0337d704 | 113 | } |
f711b03f | 114 | Platal::page()->register_function('education_degree_name', 'education_degree_name'); |
0337d704 | 115 | |
f711b03f | 116 | /** formatte une formation pour l'affichage |
0337d704 | 117 | */ |
1504ac45 | 118 | function education_fmt($name, $url, $degree, $grad_year, $field, $program, $sexe, $long) |
043bbacf SJ |
119 | { |
120 | $field = strtolower($field); | |
121 | $txt = ""; | |
122 | ||
1504ac45 | 123 | if ($grad_year || $field || $program) { |
58acfe8b | 124 | $txt .= "<span title=\"("; |
1504ac45 SJ |
125 | if ($program) { |
126 | $txt .= $program; | |
127 | if ($grad_year || $field) { | |
128 | $txt .= ", "; | |
129 | } | |
130 | } | |
043bbacf SJ |
131 | if ($grad_year) { |
132 | if ($sexe) { | |
133 | $txt .= "diplômée en $grad_year"; | |
134 | } else { | |
135 | $txt .= "diplômé en $grad_year"; | |
136 | } | |
137 | if ($field) { | |
138 | $txt .= ", "; | |
139 | } | |
140 | } | |
141 | if ($field) { | |
142 | $txt .= "domaine : $field)\">"; | |
143 | } | |
b34046e9 | 144 | } |
043bbacf | 145 | |
c7eac294 SJ |
146 | if (($degree != "Lic.") || ($long)) { |
147 | if (($degree != "Ing.") && ($degree != "Dipl.")) { | |
043bbacf SJ |
148 | $txt .= $degree; |
149 | } | |
c7eac294 SJ |
150 | if ($name) { |
151 | $txt .= ' '; | |
152 | } | |
153 | if ($url != ' ') { | |
154 | $txt .= "<a href=\"$url\" onclick=\"return popup(this)\">$name</a>"; | |
155 | } else { | |
156 | $txt .= $name; | |
043bbacf | 157 | } |
0337d704 | 158 | } |
043bbacf SJ |
159 | $txt .= "</span>"; |
160 | ||
0337d704 | 161 | return $txt; |
162 | } | |
043bbacf | 163 | |
f711b03f | 164 | function _education_fmt($params, &$smarty) |
043bbacf | 165 | { |
0337d704 | 166 | extract($params); |
1504ac45 | 167 | return education_fmt($name, $url, $degree, $grad_year, $field, $program, $sexe, $long); |
0337d704 | 168 | } |
f711b03f | 169 | Platal::page()->register_function('education_fmt', '_education_fmt'); |
0337d704 | 170 | |
a7de4ef7 | 171 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 172 | ?> |