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