1 | <?php |
---|
2 | |
---|
3 | // exec/raper_edit.php |
---|
4 | |
---|
5 | /***************************************************** |
---|
6 | Copyright (C) 2009 Christian PAULUS |
---|
7 | cpaulus@quesaco.org - http://www.quesaco.org/ |
---|
8 | /***************************************************** |
---|
9 | |
---|
10 | This file is part of RaPer. |
---|
11 | |
---|
12 | RaPer is free software; you can redistribute it and/or modify |
---|
13 | it under the terms of the GNU General Public License as published by |
---|
14 | the Free Software Foundation; either version 2 of the License, or |
---|
15 | (at your option) any later version. |
---|
16 | |
---|
17 | RaPer is distributed in the hope that it will be useful, |
---|
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | GNU General Public License for more details. |
---|
21 | |
---|
22 | You should have received a copy of the GNU General Public License |
---|
23 | along with RaPer; if not, write to the Free Software |
---|
24 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
25 | |
---|
26 | /***************************************************** |
---|
27 | |
---|
28 | Ce fichier est un des composants de RaPer. |
---|
29 | |
---|
30 | RaPer est un programme libre, vous pouvez le redistribuer et/ou le modifier |
---|
31 | selon les termes de la Licence Publique Generale GNU publie'e par |
---|
32 | la Free Software Foundation (version 2 ou bien toute autre version ulterieure |
---|
33 | choisie par vous). |
---|
34 | |
---|
35 | RaPer est distribue' car potentiellement utile, mais SANS AUCUNE GARANTIE, |
---|
36 | ni explicite ni implicite, y compris les garanties de commercialisation ou |
---|
37 | d'adaptation dans un but spe'cifique. Reportez-vous a' la Licence Publique Ge'ne'rale GNU |
---|
38 | pour plus de details. |
---|
39 | |
---|
40 | Vous devez avoir reçu une copie de la Licence Publique Generale GNU |
---|
41 | en meme temps que ce programme ; si ce n'est pas le cas, ecrivez a' la |
---|
42 | Free Software Foundation, Inc., |
---|
43 | 59 Temple Place, Suite 330, Boston, MA 02111-1307, Etats-Unis. |
---|
44 | |
---|
45 | *****************************************************/ |
---|
46 | |
---|
47 | // $LastChangedRevision: 30253 $ |
---|
48 | // $LastChangedBy: gilles.vincent@gmail.com $ |
---|
49 | // $LastChangedDate: 2009-07-27 03:26:42 +0000 (Mon, 27 Jul 2009) $ |
---|
50 | |
---|
51 | /* |
---|
52 | * Formulaire d'édition des raccourcis |
---|
53 | */ |
---|
54 | |
---|
55 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
56 | |
---|
57 | include_spip('inc/traduire'); |
---|
58 | include_spip('inc/raper_api_globales'); |
---|
59 | include_spip('inc/raper_api_prive'); |
---|
60 | include_spip('inc/raper_api_edit'); |
---|
61 | |
---|
62 | function exec_raper_edit_dist () { |
---|
63 | |
---|
64 | global $couleur_foncee, $spip_lang; |
---|
65 | |
---|
66 | $flag_editable = autoriser_raccourcis_gerer(); |
---|
67 | |
---|
68 | if($flag_editable) { |
---|
69 | |
---|
70 | $prefs_modifiees = false; |
---|
71 | |
---|
72 | // retour de formulaire ? |
---|
73 | // modifier le raccourci demandé |
---|
74 | if ( |
---|
75 | (_request('valider')) |
---|
76 | && ($id_raccourci = _request('id_raccourci')) |
---|
77 | && ($value = _request('value')) |
---|
78 | ) { |
---|
79 | // corriger le tag si multi présent |
---|
80 | $value = raper_multi_swap_entities ($value, false); |
---|
81 | raper_raccourci_modifier($id_raccourci, $value); |
---|
82 | $prefs_modifiees = true; |
---|
83 | } |
---|
84 | // supprimer un raccourci perso |
---|
85 | else if($ii = _request('drop')) { |
---|
86 | raper_raccourci_modifier($ii, null); |
---|
87 | $prefs_modifiees = true; |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | $raper_lang = raper_lang(); |
---|
92 | |
---|
93 | $prefs = raper_lire_preferences($prefs_modifiees); |
---|
94 | |
---|
95 | $raccourcis_spip = raper_raccourcis_spip($raper_lang, $prefs); |
---|
96 | |
---|
97 | // surcharger par les prefs du raper |
---|
98 | $raccourcis_list = raper_raccourcis_fusionner($raccourcis_spip, $prefs); |
---|
99 | ksort($raccourcis_list); |
---|
100 | |
---|
101 | // retour de formulaire. Préparer le mini-edit |
---|
102 | if($id_edit = _request('edit')) { |
---|
103 | $formulaire_edit = raper_edit_form_mini_edit ($id_edit, $raccourcis_list, $prefs, $raper_lang); |
---|
104 | } |
---|
105 | |
---|
106 | $nb_spip = count($raccourcis_spip); |
---|
107 | $nb_raper = count($prefs['raccourcis']); |
---|
108 | $msg_info = raper_msg_info($nb_raper, $nb_spip); |
---|
109 | } |
---|
110 | |
---|
111 | //////////////////////////////////// |
---|
112 | // PAGE CONTENU |
---|
113 | //////////////////////////////////// |
---|
114 | |
---|
115 | $titre_page = _T('raper:edition_des_raccourcis'); |
---|
116 | $rubrique = _RAPER_PREFIX; |
---|
117 | $sous_rubrique = "raccourcis_edit"; |
---|
118 | |
---|
119 | $commencer_page = charger_fonction('commencer_page', 'inc'); |
---|
120 | echo($commencer_page(_T('raper:raper') . " - " . $titre_page, $rubrique, $sous_rubrique)); |
---|
121 | |
---|
122 | if(!$flag_editable) { |
---|
123 | die (raper_terminer_page_non_autorisee() . fin_page()); |
---|
124 | } |
---|
125 | |
---|
126 | $page_result = "" |
---|
127 | . "<br /><br /><br />\n" |
---|
128 | . raper_gros_titre($titre_page, '', true) |
---|
129 | . barre_onglets($rubrique, $sous_rubrique) |
---|
130 | . debut_gauche($rubrique, true) |
---|
131 | . raper_boite_info(_T('raper:raccourcis_perso'), $msg_info) |
---|
132 | . pipeline('affiche_gauche', array('args'=>array('exec'=>$sous_rubrique),'data'=>'')) |
---|
133 | . creer_colonne_droite($rubrique, true) |
---|
134 | . raper_boite_raccourcis($rubrique) |
---|
135 | . pipeline('affiche_droite', array('args'=>array('exec'=>$sous_rubrique),'data'=>'')) |
---|
136 | . debut_droite($rubrique, true) |
---|
137 | ; |
---|
138 | |
---|
139 | $page_result .= "" |
---|
140 | // tableau des raccourcis |
---|
141 | . "<table class='raper-table'>\n" |
---|
142 | // entete |
---|
143 | . "<tr style='background-color: $couleur_foncee; color:white;'>\n" |
---|
144 | . "<th class='verdana2 strong'>"._T('module_raccourci')."</th>\n" |
---|
145 | . "<th class='verdana2 strong'>"._T('module_texte_affiche')."</th>\n" |
---|
146 | . "<th class='verdana2 strong actions'>".trim(_T('info_action', array('action' => '')), ": ")."</th>\n" |
---|
147 | . "</tr>\n" |
---|
148 | // corps |
---|
149 | // menu multilingue si besoin |
---|
150 | . "<tr><td colspan='3'>".raper_edit_menu_langues($raper_lang)."</td></tr>\n" |
---|
151 | ; |
---|
152 | $ii = 0; |
---|
153 | foreach ($raccourcis_list as $raccourci => $value) { |
---|
154 | |
---|
155 | // alterner les couleurs des lignes |
---|
156 | $bgcolor = ((($ii++) % 2) ? 'w' : 'e'); |
---|
157 | |
---|
158 | // si dans raper, proposer de supprimer (retour à l'original) |
---|
159 | $lien_drop = (($value['raper']) ? raper_edit_creer_lien('drop', $raccourci) : ""); |
---|
160 | |
---|
161 | // si raccourci d'un local_* au skel, le signaler |
---|
162 | $sig_skel = (($value['skel']) ? "skel" : ""); |
---|
163 | |
---|
164 | // edition du bloc demandé ? afficher le mini formulaire |
---|
165 | if ($id_edit == $raccourci) { |
---|
166 | $lien_edit = ""; |
---|
167 | $value = $formulaire_edit; |
---|
168 | } |
---|
169 | // sinon, afficher le crayon |
---|
170 | else { |
---|
171 | $lien_edit = raper_edit_creer_lien('edit', $raccourci); |
---|
172 | $value = |
---|
173 | ($value['raper']) |
---|
174 | ? raper_extraire_multi($value['value'], $raper_lang) |
---|
175 | : $value['value'] |
---|
176 | ; |
---|
177 | } |
---|
178 | |
---|
179 | $page_result .= "" |
---|
180 | . "<tr id='_r_" . $raccourci . "' class='bg-$bgcolor $sig_skel'>\n" |
---|
181 | . "<td class='verdana2 strong'><:$raccourci:></td>\n" |
---|
182 | . "<td class='arial2 value'>".$value."</td>" |
---|
183 | . "<td class='arial2 actions'>".$lien_edit." ".$lien_drop."</td>" |
---|
184 | . "</tr>\n" |
---|
185 | ; |
---|
186 | if(!(($ii) % 10)) { |
---|
187 | $page_result .= "<tr><td colspan='3'>".raper_edit_menu_langues($raper_lang)."</td></tr>\n"; |
---|
188 | } |
---|
189 | } |
---|
190 | $page_result .= "" |
---|
191 | . "</table>" |
---|
192 | . "<br />\n" |
---|
193 | ; |
---|
194 | |
---|
195 | echo($page_result); |
---|
196 | |
---|
197 | echo pipeline('affiche_milieu',array('args'=>array('exec'=>$sous_rubrique),'data'=>'')) |
---|
198 | , raper_html_signature() |
---|
199 | , fin_gauche(), fin_page(); |
---|
200 | |
---|
201 | } // end exec_raper_edit_dist() |
---|
202 | |
---|
203 | /* |
---|
204 | * Menu langue en une seule ligne |
---|
205 | * @return string |
---|
206 | * @param $raper_lang string langue sélectionnée courante pour ne pas mettre un lien dessus |
---|
207 | */ |
---|
208 | function raper_edit_menu_langues ($raper_lang) { |
---|
209 | static $id_menu, $langues_array, $url, $nom_langue, $micro; |
---|
210 | |
---|
211 | // si multilingue, propose le menu eponyme |
---|
212 | if(raper_site_langues_compter() > 1) { |
---|
213 | if($id_menu === null) { |
---|
214 | $id_menu = 0; |
---|
215 | $alt = _T("raper:selectionnez_langue"); |
---|
216 | $langues_array = explode(',', raper_langues_selection()); |
---|
217 | sort($langues_array); |
---|
218 | $traduire = charger_fonction('traduire', 'inc'); |
---|
219 | $url = generer_url_ecrire("raper_edit"); |
---|
220 | foreach($langues_array as $langue) { |
---|
221 | $nom_langue[$langue] = "title='".ucwords(traduire_nom_langue($langue))."'"; |
---|
222 | } |
---|
223 | $micro = "<img src='"._DIR_IMG_PACK."langues-12.gif' alt=\"".$alt."\" title=\"".$alt."\" />\n"; |
---|
224 | } |
---|
225 | $ancre = "raper-menu-multi_$id_menu"; |
---|
226 | $menu_langues = "\n" |
---|
227 | . "<div id='$ancre' class='verdana2 raper-menu-multi'>\n" |
---|
228 | ; |
---|
229 | foreach($langues_array as $langue) { |
---|
230 | $href = parametre_url($url, 'raper_lang', $langue); |
---|
231 | $class = "class='".(($langue == $GLOBALS['spip_lang']) ? "lang-sel" : "")."'"; |
---|
232 | $menu_langues .= "" |
---|
233 | . ( |
---|
234 | ($langue != $raper_lang) |
---|
235 | ? "<a href='$href#$ancre' ".$nom_langue['langue']." lang='$langue'>[$langue]</a> \n" |
---|
236 | : "<span ".$nom_langue['langue']." lang='$langue'>[$langue]</span> \n" |
---|
237 | ) |
---|
238 | ; |
---|
239 | } |
---|
240 | $id_menu++; |
---|
241 | $menu_langues .= "" |
---|
242 | . $micro |
---|
243 | . "</div>\n" |
---|
244 | ; |
---|
245 | } |
---|
246 | else $menu_langues = ""; |
---|
247 | |
---|
248 | return($menu_langues); |
---|
249 | } |
---|
250 | |
---|
251 | |
---|
252 | ?> |
---|