[SPIP] ~maj v2.1.25-->2.1.26
[velocampus/web/www.git] / www / plugins / auto / fullcalendar / exec / fullcalendar_add.php
1 <?php
2
3 /* * * * * * * * * * * * * * * * * * * *
4 *
5 * - FullCalendar pour SPIP -
6 *
7 * Formulaires d'ajout et modification
8 *
9 * Auteur : Grégory PASCAL - ngombe at gmail dot com
10 * Modifs : 10/10/2011
11 *
12 */
13
14 function exec_fullcalendar_add(){
15 include_spip("inc/presentation");
16 // vérifier les droits
17 global $connect_statut;
18 global $connect_toutes_rubriques;
19 if ($connect_statut != '0minirezo' OR !$connect_toutes_rubriques) {
20 print _T('avis_non_acces_page');
21 exit;
22 }
23
24 $HTML=$INFO="";
25
26 # Ajout d'un calendrier
27
28 if(
29 isset($_POST['ajouter'])
30 && $_POST['action_to_take']=='add'
31 && strlen($_POST['CalName'])
32 ){
33 sql_insert("spip_fullcalendar_main","(type, nom)","(".sql_quote($_POST['CalSource']).", ".sql_quote($_POST['CalName']).")");
34 $INFO="<center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/ok.png'> &nbsp; "._T('fullcalendar:calendar_add').".</center><br/>";
35 }
36
37 # Modification d'un calendrier
38
39 if(
40 isset($_POST['enregistrer'])
41 && $_POST['action_to_take']=='update'
42 && strlen($_POST['CalName'])
43 ){
44 sql_update('spip_fullcalendar_main', array('nom' => sql_quote($_POST['CalName'])), "id_fullcalendar=".sql_quote(intval($_POST['id_calendrier'])) );
45 $INFO="<center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/ok.png'> &nbsp; "._T('fullcalendar:calendar_edit').".</center><br/>";
46 }
47
48 # Effacer un calendrier
49
50 if(
51 isset($_POST['action_to_take'])
52 && $_POST['action_to_take']=='del'
53 &&isset($_POST['id_calendrier'])
54 && $_POST['id_calendrier']
55 ){
56 sql_delete("spip_fullcalendar_events", "id_fullcalendar=".$_POST['id_calendrier']);
57 $INFO=_T('fullcalendar:calendar_del_events')." ".$_POST['id_calendrier']."<br/><br/>";
58 sql_delete("spip_fullcalendar_main", "id_fullcalendar=".$_POST['id_calendrier']);
59 $INFO.=_T('fullcalendar:calendar_del_events')." ".$_POST['id_calendrier']."<br/><br/>";
60 }
61
62 # Création par défaut
63
64 $NOM='';
65 $BUTTON='<input type="submit" name="ajouter" value=" '._T('fullcalendar:add').' " class="fondo" />';
66 $SOURCE='<select name="CalSource" id="CalSource">
67 <option value="mysql">'._T('fullcalendar:source_mysql').'</option>
68 <option value="article">'._T('fullcalendar:source_art').'</option>
69 <option value="rub">'._T('fullcalendar:source_rub').'</option>
70 <option value="google">'._T('fullcalendar:source_google').'</option>
71 </select>';
72 $ACTION='add';
73 $TEXT=_T('fullcalendar:calendar_add');
74 $ID='';
75
76 # Récupère les calendriers
77
78 $res = sql_select('*', 'spip_fullcalendar_main');
79 $num_calendar = sql_count($res);
80
81 if(!$num_calendar) $INFO="
82 <b>"._T('fullcalendar:welcome_title')."</b><br/>
83 <br/>"._T('fullcalendar:welcome_text')."</center><br/>
84 ";
85 else {
86 $LISTE='<br/>';
87 $class='row_odd';
88 $INFO.= "<center>"._T('fullcalendar:vous_avez')." ".$num_calendar." ";
89 $INFO.=($num_calendar==1)?_T('fullcalendar:calendar'):_T('fullcalendar:calendars');
90 $INFO.="</center><br/>";
91 $HTML = "
92
93 <script type=\"text/javascript\">
94 //<!--
95 function EffacerCalendrier(id){
96 if(!document.getElementById) return false;
97 if(confirm('"._T('fullcalendar:calendar_del')." ?')){
98 document.Formulaire.id_calendrier.value=id;
99 document.Formulaire.action_to_take.value='del';
100 document.Formulaire.submit();
101 return true;
102 }
103 }
104
105 function ModifierCalendrier(id){
106 if(!document.getElementById) return false;
107 document.Formulaire.id_calendrier.value=id;
108 document.Formulaire.action_to_take.value='edit';
109 document.Formulaire.submit();
110 return true;
111 }
112
113 //-->
114 </script>
115
116
117 <table class='spip' style='width:100%'>
118 <tr class='row_first'>
119 <th>"._T('fullcalendar:calendar')."</th>
120 <th>Source</th>
121 <th>"._T('fullcalendar:shortcut')."</th>
122 <th>&nbsp;</th>
123 </tr>";
124
125 $icons['mysql']="<img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/mysql-24.png'>";
126 $icons['google']="<img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/google-24.png'>";
127 $icons['rub']='<img src="../prive/images/rubrique-24.gif">';
128 $icons['article']='<img src="../prive/images/mot-cle-24.gif">';
129
130 while ($row = sql_fetch($res)) {
131
132 $id = $row['id_fullcalendar'];
133 $type = $row['type'];
134 $icon=$icons[$type];
135 $nom = $row['nom'];
136
137 if(
138 $_POST['action_to_take']=='edit'
139 && $id==$_POST['id_calendrier']
140 ){
141 $NOM=$nom;
142 $BUTTON='<input type="submit" name="enregistrer" value=" '._T('bouton_enregistrer').' " class="fondo" />
143 <input type="submit" name="cancel" value=" '._T('bouton_annuler').' " class="fondo" />';
144 $SOURCE='<b>'.$type.'</b>';
145 $ACTION='update';
146 $ID=$id;
147 $TEXT=_T('fullcalendar:calendar_edit');
148 }
149
150 $LISTE .= "<center class='formulaire_spip'><a href=\"?exec=fullcalendar_edit&id=".$id."\">".$nom."</a></center><br/>";
151 $nom = "<a href=\"?exec=fullcalendar_edit&id=".$id."\">".$nom."</a>";
152 $HTML.="
153 <tr class='".$class."'>
154 <td style='text-align:center'><b>".$nom."</b></td>
155 <td style='text-align:center'>".$icon."</td>
156 <td style='text-align:center'><b>&lt;fullcalendar".$id."&gt;</b></td>
157 <td style='text-align:center;width:44px;'>
158 <a href=\"javascript:ModifierCalendrier('".$id."')\"><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/calendar_edit.png'></a> &nbsp;
159 <a href=\"javascript:EffacerCalendrier('".$id."')\"><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/calendar_remove.png'></a>
160 </td>
161 </tr>";
162 $class=($class=='row_odd')?'row_even':'row_odd';
163 }
164 sql_free($res);
165 $HTML.="</table>";
166 }
167
168 $commencer_page = charger_fonction('commencer_page', 'inc');
169 print $commencer_page(_T('fullcalendar:fullcalendar'), "", "") ;
170 print "<br/><br/>";
171 print gros_titre(_T('fullcalendar:fullcalendar')." : "._T('fullcalendar:gestion_calendriers'),'',false);
172 print debut_gauche ("",true);
173
174 print debut_boite_info(true);
175 print "<center><b>"._T('fullcalendar:fullcalendar')."</b></center>";
176 print "<br/><center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/fullcalendar.jpg'></center><br/>";
177 print $INFO;
178 print fin_boite_info(true);
179
180 print debut_cadre_enfonce('',true,'','','');
181 print "<table class=\"cellule-h-table\" style=\"vertical-align: middle;\" cellpadding=\"0\"><tbody><tr>
182 <td><a href=\"?exec=cfg&cfg=fullcalendar\" class=\"cellule-h\"><span class=\"cell-i\"><img src='../plugins/cfg/cfg-22.png' alt=\"CFG : "._T('fullcalendar:configuration')."\"></span></a></td>
183 <td class=\"cellule-h-lien\"><a href=\"?exec=cfg&cfg=fullcalendar\" class=\"cellule-h\">CFG - "._T('fullcalendar:configuration')."</a></td>
184 </tr></tbody></table>";
185 print fin_cadre_enfonce(true);
186
187 print debut_cadre_enfonce('',true,'','','');
188 print "<table class=\"cellule-h-table\" style=\"vertical-align: middle;\" cellpadding=\"0\"><tbody><tr>
189 <td><a href=\"?exec=fullcalendar_css\" class=\"cellule-h\"><span class=\"cell-i\"><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/edit_css.png' alt=\"CSS : "._T('fullcalendar:configuration')."\"></span></a></td>
190 <td class=\"cellule-h-lien\"><a href=\"?exec=fullcalendar_css\" class=\"cellule-h\">CSS - "._T('fullcalendar:configuration')."</a></td>
191 </tr></tbody></table>";
192 print fin_cadre_enfonce(true);
193
194 if(strlen($LISTE)){
195 print debut_cadre_enfonce('',true,'',_T('fullcalendar:vos_calendriers'),'');
196 print $LISTE;
197 print fin_cadre_enfonce(true);
198 }
199
200 print creer_colonne_droite('',true);
201 print debut_droite("", true);
202 print debut_cadre_trait_couleur("", true, "", $titre=_T('fullcalendar:plugin_name'),"","");
203
204 # INTERFACE D'AJOUT
205
206 print '
207 <div class="formulaire_spip formulaire_config">
208 <div class="cadre_padding">
209 <form action="#" name="Formulaire" method="POST">
210 <input type="hidden" name="action_to_take" value="'.$ACTION.'">
211 <input type="hidden" name="id_calendrier" value="'.$ID.'">
212 <p><label>'.$TEXT.' : <input type="text" name="CalName" style="width:60%" value="'.$NOM.'"></label></p>
213 <p><label>'._T('fullcalendar:source_select').' : '.$SOURCE.'</label>
214 </p>
215 </div>
216 <div class="boutons">'.$BUTTON.'</div>
217 </form>
218 </div>
219 ';
220
221 # GESTION DES CALENDRIERS
222
223 if(strlen($HTML)){
224 print debut_cadre_relief("", false,"", $titre = _T('Vos calendriers'));
225 print $HTML;
226 print fin_cadre_relief(false);
227 }
228
229 print fin_cadre_trait_couleur(true);
230 print fin_gauche();
231 print fin_page();
232
233 }
234 ?>