| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2004 Polytechnique.org * |
| 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 | |
| 22 | global $page; |
| 23 | |
| 24 | function applis_options($current=0) { |
| 25 | global $globals; |
| 26 | $html = '<option value="-1"></option>'; |
| 27 | $res = $globals->xdb->iterator("select * from applis_def order by text"); |
| 28 | while ($arr_appli = $res->next()) { |
| 29 | $html .= '<option value="'.$arr_appli["id"].'"'; |
| 30 | if ($arr_appli["id"]==$current) $html .= " selected='selected'"; |
| 31 | $html .= '>'.htmlspecialchars($arr_appli["text"])."</option>\n"; |
| 32 | } |
| 33 | return $html; |
| 34 | } |
| 35 | /** pour appeller applis_options depuis smarty |
| 36 | */ |
| 37 | function _applis_options_smarty($params){ |
| 38 | if(!isset($params['selected'])) |
| 39 | $params['selected'] = 0; |
| 40 | return applis_options($params['selected']); |
| 41 | } |
| 42 | $page->register_function('applis_options','_applis_options_smarty'); |
| 43 | |
| 44 | |
| 45 | /** affiche un Array javascript contenant les types de chaque appli |
| 46 | */ |
| 47 | function applis_type(){ |
| 48 | global $globals; |
| 49 | $html = ""; |
| 50 | $res=$globals->xdb->iterRow("select type from applis_def order by text"); |
| 51 | if (list($appli_type) = $res->next()) { |
| 52 | $html .= "new Array('".str_replace(",","','",$appli_type)."')"; |
| 53 | } |
| 54 | while (list($appli_type) = $res->next()) { |
| 55 | $html .= ",\nnew Array('".str_replace(",","','",$appli_type)."')"; |
| 56 | } |
| 57 | return $html; |
| 58 | } |
| 59 | $page->register_function('applis_type','applis_type'); |
| 60 | |
| 61 | /** affiche tous les types possibles d'applis |
| 62 | */ |
| 63 | function applis_type_all(){ |
| 64 | global $globals; |
| 65 | $res = $globals->xdb->query("show columns from applis_def like 'type'"); |
| 66 | $arr_appli = $res->fetchOneAssoc(); |
| 67 | return str_replace(")","",str_replace("set(","",$arr_appli["Type"])); |
| 68 | } |
| 69 | $page->register_function('applis_type_all','applis_type_all'); |
| 70 | |
| 71 | /** formatte une ecole d'appli pour l'affichage |
| 72 | */ |
| 73 | function applis_fmt($type, $text, $url) { |
| 74 | $txt=""; |
| 75 | if (($type!="Ingénieur")&&($type!="Diplôme")) |
| 76 | $txt .= $type; |
| 77 | if ($text!="Université") { |
| 78 | if ($txt) $txt .= " "; |
| 79 | if ($url) |
| 80 | $txt .= "<a href=\"$url\" onclick=\"return popup(this)\">$text</a>"; |
| 81 | else |
| 82 | $txt .= $text; |
| 83 | } |
| 84 | return $txt; |
| 85 | } |
| 86 | function _applis_fmt($params, &$smarty) { |
| 87 | extract($params); |
| 88 | return applis_fmt($type, $text, $url); |
| 89 | } |
| 90 | $page->register_function('applis_fmt','_applis_fmt'); |
| 91 | |
| 92 | ?> |