[SPIP] +2.1.12
[velocampus/web/www.git] / www / plugins / auto / fullcalendar / exec / fullcalendar_css.php
1 <?php
2
3 /* * * * * * * * * * * * * * * * * * * *
4 *
5 * - FullCalendar pour SPIP -
6 *
7 * Gestion des CSS pour les évènements
8 *
9 * Auteur : Grégory PASCAL - ngombe at gmail dot com
10 * Modifs : 10/10/2011
11 *
12 */
13
14 function exec_fullcalendar_css(){
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=$LISTE="";
25
26 # Ajout d'un style
27
28 if(
29 isset($_POST['ajouter'])
30 && $_POST['action_to_take']=='AddStyle'
31 && strlen($_POST['StyleName'])
32 && strlen($_POST['bordercolor'])
33 && strlen($_POST['bgcolor'])
34 && strlen($_POST['textcolor'])
35 ){
36 $INFO="<center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/ok.png'> &nbsp; "._T('fullcalendar:style_add').".</center><br/>";
37 sql_insert("spip_fullcalendar_styles",
38 "(titre, bordercolor, bgcolor, textcolor)",
39 "(
40 ".sql_quote($_POST['StyleName']).",
41 ".sql_quote($_POST['bordercolor']).",
42 ".sql_quote($_POST['bgcolor']).",
43 ".sql_quote($_POST['textcolor'])."
44 )");
45
46 }
47
48 # Modification d'un style
49
50 if(
51 isset($_POST['enregistrer'])
52 && $_POST['action_to_take']=='UpdateStyle'
53 && strlen($_POST['StyleName'])
54 && strlen($_POST['bordercolor'])
55 && strlen($_POST['bgcolor'])
56 && strlen($_POST['textcolor'])
57 && $_POST['id_style']
58 ){
59 $INFO="<center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/ok.png'> &nbsp; "._T('fullcalendar:style_edit').".</center><br/>";
60 sql_update('spip_fullcalendar_styles',
61 array(
62 'titre' => sql_quote($_POST['StyleName']),
63 'bordercolor' => sql_quote($_POST['bordercolor']),
64 'bgcolor' => sql_quote($_POST['bgcolor']),
65 'textcolor' => sql_quote($_POST['textcolor'])
66 ),
67 "id_style=".sql_quote(intval($_POST['id_style']))
68 );
69 }
70
71 # Effacer un style
72
73 if(
74 $_POST['action_to_take']=='del'
75 && $_POST['id_style']
76 ){
77 $INFO.="<center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/ok.png'> &nbsp; "._T('fullcalendar:style_del')." ".$_POST['id_style']."</center><br/>";
78 sql_delete('spip_fullcalendar_styles', "id_style=".$_POST['id_style']);
79 }
80
81 # Récupère les calendriers
82
83 $res = sql_select('*', 'spip_fullcalendar_main');
84 if(sql_count($res)){
85 $LISTE='<br/>';
86 while ($row = sql_fetch($res))
87 $LISTE .= "<center class='formulaire_spip'><a href=\"?exec=fullcalendar_edit&id=".$row['id_fullcalendar']."\">".$row['nom']."</a></center><br/>";
88 }
89
90 # Style par défaut pour la création
91
92 $ACTION='AddStyle';
93 $ID_STYLE='';
94 $NOM='';
95 $BORDER='#0042c7';
96 $TEXT='#141666';
97 $BG='#becde9';
98 $BUTTON='<input type="submit" name="ajouter" value=" '._T('fullcalendar:add').' " class="fondo" />';
99
100 # Récupère les styles
101
102 $res = sql_select('*', 'spip_fullcalendar_styles');
103 $num_style = sql_count($res);
104 if(!$num_style) $INFO="<b>"._T('fullcalendar:style_welcome')."</b><br/><br/>"._T('fullcalendar:style_info');
105 else {
106
107 $INFO.= "<center>"._T('fullcalendar:vous_avez')." ".$num_style." "._T('fullcalendar:styles')."</center><br/>";
108 $HTML = "
109
110 <script type=\"text/javascript\">
111 //<!--
112 function EffacerStyle(id){
113 if(!document.getElementById) return false;
114 if(confirm('Effacer ce style ?')){
115 document.Formulaire.id_style.value=id;
116 document.Formulaire.action_to_take.value='del';
117 document.Formulaire.submit();
118 return true;
119 }
120 }
121
122 function ModifierStyle(id){
123 if(!document.getElementById) return false;
124 document.Formulaire.id_style.value=id;
125 document.Formulaire.action_to_take.value='edit';
126 document.Formulaire.submit();
127 return true;
128 }
129 //-->
130 </script>";
131
132 while ($row = sql_fetch($res)) {
133
134 $id = $row['id_style'];
135 $nom = $row['titre'];
136 $border = $row['bordercolor'];
137 $bg = $row['bgcolor'];
138 $text = $row['textcolor'];
139
140 # Modification d'un style ?
141
142 if(
143 $_POST['action_to_take']=='edit'
144 && $id==$_POST['id_style']
145 ){
146 $ACTION='UpdateStyle';
147 $ID_STYLE=$id;
148 $NOM=$nom;
149 $BORDER=$border;
150 $TEXT=$text;
151 $BG=$bg;
152 $BUTTON='<input type="submit" name="enregistrer" value=" '._T('bouton_enregistrer').' " class="fondo" />';
153 }
154
155 $rs = sql_select('id_event', 'spip_fullcalendar_events', 'id_style = '.$id);
156 $rw = sql_count($rs);
157
158 if(!$rw) $DELETE="<a href=\"javascript:EffacerStyle('".$id."')\"><img style=\"margin-left:10px;\" src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/css_remove.png' align='right'></a>";
159 else {
160 $DELETE="&nbsp;&nbsp;"._T('fullcalendar:linked_to')." ".$rw." "._T('fullcalendar:event');
161 $DELETE.=($rw>1)?'s.':'.';
162 }
163 sql_free($rs);
164
165 $HTML.="
166 <div style=\"padding:5px;border:1px solid ".$border.";color:".$text.";background-color:".$bg."\">
167 <b>".$nom."</b>
168 ".$DELETE."
169 <a href=\"javascript:ModifierStyle('".$id."')\">&nbsp;<img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/css_edit.png' align='right'></a>
170 </div><br/>";
171
172 }
173 sql_free($res);
174 }
175
176 $commencer_page = charger_fonction('commencer_page', 'inc');
177 print $commencer_page(_T('fullcalendar:fullcalendar'), "documents", "forms") ;
178 print "<br/><br/>";
179 print gros_titre(_T('fullcalendar:gestion_styles'),'',false);
180 print debut_gauche ("",true);
181
182 print debut_boite_info(true);
183 print "<center><b>"._T('fullcalendar:fullcalendar')."</b></center>";
184 print "<br/><center><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/fullcalendar.jpg'></center><br/>";
185 print $INFO;
186 print fin_boite_info(true);
187
188 print debut_cadre_enfonce('',true,'','','');
189 print "<table class=\"cellule-h-table\" style=\"vertical-align: middle;\" cellpadding=\"0\"><tbody><tr>
190 <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>
191 <td class=\"cellule-h-lien\"><a href=\"?exec=cfg&cfg=fullcalendar\" class=\"cellule-h\">CFG - "._T('fullcalendar:configuration')."</a></td>
192 </tr></tbody></table>";
193 print fin_cadre_enfonce(true);
194
195 print debut_cadre_enfonce('',true,'','','');
196 print "<table class=\"cellule-h-table\" style=\"vertical-align: middle;\" cellpadding=\"0\"><tbody><tr>
197 <td><a href=\"?exec=fullcalendar_add\" class=\"cellule-h\"><span class=\"cell-i\"><img src='"._DIR_PLUGIN_FULLCALENDAR."prive/themes/spip/images/calendar.png' alt=\""._T('fullcalendar:fullcalendar')." : "._T('fullcalendar:gestion')."\"></span></a></td>
198 <td class=\"cellule-h-lien\"><a href=\"?exec=fullcalendar_add\" class=\"cellule-h\">FullCalendar - "._T('fullcalendar:gestion')."</a></td>
199 </tr></tbody></table>";
200 print fin_cadre_enfonce(true);
201
202 if(strlen($LISTE)){
203 print debut_cadre_enfonce('',true,'',_T('fullcalendar:vos_calendriers'),'');
204 print $LISTE;
205 print fin_cadre_enfonce(true);
206 }
207
208 print creer_colonne_droite('',true);
209 print debut_droite("", true);
210 print debut_cadre_trait_couleur("", true, "", $titre=_T('fullcalendar:style_title'),"","");
211
212 # INTERFACE D'AJOUT
213
214 print '
215 <div class="formulaire_spip formulaire_config">
216 <div class="cadre_padding">
217 <form action="#" name="Formulaire" method="POST">
218 <input type="hidden" name="action_to_take" value="'.$ACTION.'">
219 <input type="hidden" name="id_style" value="'.$ID_STYLE.'">
220 <p><label>'._T('fullcalendar:style_name').' : <input type="text" name="StyleName" style="width:60%" value="'.$NOM.'"></label></p>
221 <p><label>'._T('fullcalendar:style_border').' : <input type="text" name="bordercolor" class="palette" id="_ir_bordercolor" size="7" value="'.$BORDER.'" /></label></p>
222 <p><label>'._T('fullcalendar:style_background').' : <input type="text" name="bgcolor" class="palette" id="_ir_bgcolor" size="7" value="'.$BG.'" /></label></p>
223 <p><label>'._T('fullcalendar:style_text').' : <input type="text" name="textcolor" class="palette" id="_ir_textcolor" size="7" value="'.$TEXT.'" /></label></p>
224 </div>
225 <div class="boutons">'.$BUTTON.'</div>
226 </form>
227 </div>
228 ';
229
230 # GESTION DES STYLES
231
232 if(strlen($HTML)){
233 print debut_cadre_relief("", false,"", $titre = _T('fullcalendar:vos_styles'));
234 print $HTML;
235 print fin_cadre_relief(false);
236 }
237
238 print fin_cadre_trait_couleur(true);
239 print fin_gauche();
240 print fin_page();
241
242 }
243 ?>