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