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 | ||
043bbacf SJ |
22 | function applis_options($current=0) |
23 | { | |
24 | $html = '<option value = "-1"></option>'; | |
25 | $res = XDB::iterator("SELECT * | |
26 | FROM profile_education_enum | |
27 | ORDER BY name"); | |
eaf30d86 | 28 | while ($arr_appli = $res->next()) { |
043bbacf SJ |
29 | $html .= '<option value="' . $arr_appli["id"] . '"'; |
30 | if ($arr_appli["id"]==$current) { | |
31 | $html .= " selected='selected'"; | |
32 | } | |
33 | $html .= '>' . htmlspecialchars($arr_appli["name"]) . "</option>\n"; | |
0337d704 | 34 | } |
35 | return $html; | |
36 | } | |
043bbacf | 37 | |
0337d704 | 38 | /** pour appeller applis_options depuis smarty |
39 | */ | |
043bbacf SJ |
40 | function _applis_options_smarty($params) |
41 | { | |
42 | if(!isset($params['selected'])) { | |
b34046e9 | 43 | $params['selected'] = 0; |
043bbacf | 44 | } |
0337d704 | 45 | return applis_options($params['selected']); |
46 | } | |
043bbacf | 47 | Platal::page()->register_function('applis_options', '_applis_options_smarty'); |
0337d704 | 48 | |
49 | /** affiche un Array javascript contenant les types de chaque appli | |
50 | */ | |
043bbacf SJ |
51 | function applis_type() |
52 | { | |
0337d704 | 53 | $html = ""; |
043bbacf SJ |
54 | $res = XDB::iterRow("SELECT eduid, degreeid |
55 | FROM profile_education_degree AS d | |
56 | INNER JOIN profile_education_enum AS e ON (e.id = d.eduid) | |
57 | ORDER BY e.name"); | |
58 | if ($appli_type = $res->next()) { | |
59 | $eduid = $appli_type['0']; | |
60 | $html .= "["; | |
61 | $html .= $appli_type['1']; | |
62 | $appli_type = $res->next(); | |
63 | while ($appli_type['0'] == $eduid) { | |
64 | $html .= "," . $appli_type['1']; | |
65 | $appli_type = $res->next(); | |
66 | } | |
67 | $html .= "]"; | |
0337d704 | 68 | } |
043bbacf SJ |
69 | while ($appli_type) { |
70 | $eduid = $appli_type['0']; | |
71 | $html .= ",\n["; | |
72 | $html .= $appli_type['1']; | |
73 | $appli_type = $res->next(); | |
74 | while ($appli_type['0'] == $eduid) { | |
75 | $html .= "," . $appli_type['1']; | |
76 | $appli_type = $res->next(); | |
77 | } | |
78 | $html .= "]"; | |
0337d704 | 79 | } |
80 | return $html; | |
81 | } | |
043bbacf | 82 | Platal::page()->register_function('applis_type', 'applis_type'); |
0337d704 | 83 | |
84 | /** affiche tous les types possibles d'applis | |
85 | */ | |
043bbacf SJ |
86 | function applis_type_all() |
87 | { | |
88 | $html = ""; | |
89 | $res = XDB::query("SELECT id | |
90 | FROM profile_education_degree_enum | |
91 | ORDER BY id"); | |
92 | return implode(',', $res->fetchColumn()); | |
93 | } | |
94 | Platal::page()->register_function('applis_type_all', 'applis_type_all'); | |
95 | ||
96 | /** affiche les noms de tous les types possibles d'applis | |
97 | */ | |
98 | function applis_type_name() | |
99 | { | |
100 | $html = ""; | |
101 | $res = XDB::query("SELECT degree | |
102 | FROM profile_education_degree_enum | |
103 | ORDER BY id"); | |
104 | return '\'' . implode('\',\'', $res->fetchColumn()) . '\''; | |
0337d704 | 105 | } |
043bbacf | 106 | Platal::page()->register_function('applis_type_name', 'applis_type_name'); |
0337d704 | 107 | |
108 | /** formatte une ecole d'appli pour l'affichage | |
109 | */ | |
043bbacf SJ |
110 | function applis_fmt($name, $url, $degree, $grad_year, $field, $sexe, $long) |
111 | { | |
112 | $field = strtolower($field); | |
113 | $txt = ""; | |
114 | ||
115 | if ($grad_year || $field) { | |
116 | $txt .= "<span title=\"("; | |
117 | if ($grad_year) { | |
118 | if ($sexe) { | |
119 | $txt .= "diplômée en $grad_year"; | |
120 | } else { | |
121 | $txt .= "diplômé en $grad_year"; | |
122 | } | |
123 | if ($field) { | |
124 | $txt .= ", "; | |
125 | } | |
126 | } | |
127 | if ($field) { | |
128 | $txt .= "domaine : $field)\">"; | |
129 | } | |
b34046e9 | 130 | } |
043bbacf SJ |
131 | |
132 | if (($degree != "Licence") || ($long)) { | |
133 | if (($degree != "Ingénieur") && ($degree != "Diplôme")) { | |
134 | $txt .= $degree; | |
135 | } | |
136 | if ($name != "Université") { | |
137 | if ($name) { | |
138 | $txt .= ' '; | |
139 | } | |
140 | if ($url != ' ') { | |
141 | $txt .= "<a href=\"$url\" onclick=\"return popup(this)\">$name</a>"; | |
142 | } else { | |
143 | $txt .= $name; | |
144 | } | |
145 | } | |
0337d704 | 146 | } |
043bbacf SJ |
147 | $txt .= "</span>"; |
148 | ||
0337d704 | 149 | return $txt; |
150 | } | |
043bbacf SJ |
151 | |
152 | function _applis_fmt($params, &$smarty) | |
153 | { | |
0337d704 | 154 | extract($params); |
043bbacf | 155 | return applis_fmt($name, $url, $degree, $grad_year, $field, $sexe, $long); |
0337d704 | 156 | } |
043bbacf | 157 | Platal::page()->register_function('applis_fmt', '_applis_fmt'); |
0337d704 | 158 | |
a7de4ef7 | 159 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 160 | ?> |