[SPIP] +2.1.12
[velocampus/web/www.git] / www / ecrire / inc / config.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15
16 //
17 // Appliquer les valeurs par defaut pour les options non initialisees
18 // (pour les langues c'est fait)
19 //
20
21 // http://doc.spip.org/@inc_config_dist
22 function inc_config_dist() {
23 actualise_metas(liste_metas());
24 }
25
26 // http://doc.spip.org/@liste_metas
27 function liste_metas()
28 {
29 return pipeline('configurer_liste_metas', array(
30 'nom_site' => _T('info_mon_site_spip'),
31 'adresse_site' => preg_replace(",/$,", "", url_de_base()),
32 'descriptif_site' => '',
33 'activer_breves' => 'non',
34 'activer_logos' => 'oui',
35 'activer_logos_survol' => 'non',
36 'config_precise_groupes' => 'non',
37 'mots_cles_forums' => 'non',
38 'articles_surtitre' => 'non',
39 'articles_soustitre' => 'non',
40 'articles_descriptif' => 'non',
41 'articles_chapeau' => 'non',
42 'articles_texte' => 'oui',
43 'articles_ps' => 'non',
44 'articles_redac' => 'non',
45 'articles_mots' => 'non',
46 'post_dates' => 'non',
47 'articles_urlref' => 'non',
48 'articles_redirection' => 'non',
49 'creer_preview' => 'non',
50 'taille_preview' => 150,
51 'articles_modif' => 'non',
52
53 'rubriques_descriptif' => 'non',
54 'rubriques_texte' => 'oui',
55
56 'forums_titre' => 'oui',
57 'forums_texte' => 'oui',
58 'forums_urlref' => 'non',
59 'forums_afficher_barre' => 'oui',
60 'formats_documents_forum' => '',
61
62 'activer_sites' => 'non',
63 'proposer_sites' => 0,
64 'activer_syndic' => 'oui',
65 'moderation_sites' => 'non',
66
67 'forums_publics' => 'posteriori',
68 'accepter_inscriptions' => 'non',
69 'accepter_visiteurs' => 'non',
70 'prevenir_auteurs' => 'non',
71 'suivi_edito' => 'non',
72 'adresse_suivi' =>'',
73 'adresse_suivi_inscription' =>'',
74 'adresse_neuf' => '',
75 'jours_neuf' => '',
76 'quoi_de_neuf' => 'non',
77 'forum_prive' => 'oui', # forum global dans l'espace prive
78 'forum_prive_objets' => 'oui', # forum sous chaque article de l'espace prive
79 'forum_prive_admin' => 'non', # forum des administrateurs
80 'messagerie_agenda' => 'oui',
81
82 'articles_versions' => 'non',
83 'activer_statistiques' => 'non',
84 'activer_captures_referers' => 'non',
85
86 'documents_article' => 'non',
87 'documents_rubrique' => 'non',
88 'documents_date' => 'non',
89 'syndication_integrale' => 'oui',
90 'charset' => _DEFAULT_CHARSET,
91 'dir_img' => substr(_DIR_IMG,strlen(_DIR_RACINE)),
92
93 'multi_articles' => 'non',
94 'multi_rubriques' => 'non',
95 'multi_secteurs' => 'non',
96 'gerer_trad' => 'non',
97 'langues_multilingue' => '',
98
99 'type_urls' => 'page',
100
101 'email_envoi' => '',
102 'email_webmaster' => '',
103 'auto_compress_http'=>'non',
104 'auto_compress_js'=>'non',
105 'auto_compress_css'=>'non'
106 ));
107 }
108
109 // mets les meta a des valeurs conventionnelles quand elles sont vides
110 // et recalcule les langues
111
112 // http://doc.spip.org/@actualise_metas
113 function actualise_metas($liste_meta)
114 {
115 $meta_serveur =
116 array('version_installee','adresse_site','alea_ephemere_ancien','alea_ephemere','alea_ephemere_date','langue_site','langues_proposees','date_calcul_rubriques','derniere_modif','optimiser_table','drapeau_edition','creer_preview','taille_preview','creer_htpasswd','creer_htaccess','gd_formats_read','gd_formats',
117 'netpbm_formats','formats_graphiques','image_process','plugin_header','plugin');
118 // verifier le impt=non
119 sql_updateq('spip_meta',array('impt'=>'non'),sql_in('nom',$meta_serveur));
120
121 while (list($nom, $valeur) = each($liste_meta)) {
122 if (!$GLOBALS['meta'][$nom]) {
123 ecrire_meta($nom, $valeur);
124 }
125 }
126
127 include_spip('inc/rubriques');
128 $langues = calculer_langues_utilisees();
129 ecrire_meta('langues_utilisees', $langues);
130 }
131
132
133 // http://doc.spip.org/@avertissement_config
134 function avertissement_config() {
135 global $spip_lang_right, $spip_lang_left;
136
137 return debut_boite_info(true)
138 . "\n<div class='verdana2' style='text-align: justify'>
139 <p style='text-align: center'><b>"._T('avis_attention')."</b></p>"
140 . http_img_pack("warning.gif", (_T('avis_attention')),
141 "width='48' height='48' style='float: $spip_lang_right; padding-$spip_lang_left: 10px;'")
142 . _T('texte_inc_config')
143 . "</div>"
144 . fin_boite_info(true)
145 . "<p>&nbsp;</p>\n";
146 }
147
148
149 // http://doc.spip.org/@bouton_radio
150 function bouton_radio($nom, $valeur, $titre, $actif = false, $onClick="") {
151 static $id_label = 0;
152
153 if (strlen($onClick) > 0) $onClick = " onclick=\"$onClick\"";
154 $texte = "<input type='radio' name='$nom' value='$valeur' id='label_${nom}_${id_label}'$onClick";
155 if ($actif) {
156 $texte .= ' checked="checked"';
157 $titre = '<b>'.$titre.'</b>';
158 }
159 $texte .= " /> <label for='label_${nom}_${id_label}'>$titre</label>\n";
160 $id_label++;
161 return $texte;
162 }
163
164
165 // http://doc.spip.org/@afficher_choix
166 function afficher_choix($nom, $valeur_actuelle, $valeurs, $sep = "<br />") {
167 $choix = array();
168 while (list($valeur, $titre) = each($valeurs)) {
169 $choix[] = bouton_radio($nom, $valeur, $titre, $valeur == $valeur_actuelle);
170 }
171 return "\n".join($sep, $choix);
172 }
173
174
175 //
176 // Gestion des modifs
177 //
178
179 // http://doc.spip.org/@appliquer_modifs_config
180 function appliquer_modifs_config($purger_skel=false) {
181
182 if (($i = _request('adresse_site'))!==NULL){
183 if (!strlen($i)) {$GLOBALS['profondeur_url']=_DIR_RESTREINT?0:1;$i = url_de_base();}
184 $_POST['adresse_site'] = preg_replace(",/?\s*$,", "", $i);
185 }
186
187 // provoquer l'envoi des nouveautes en supprimant le fichier lock
188 if (_request('envoi_now')) {
189 spip_unlink(_DIR_TMP . 'mail.lock');
190 }
191
192 // Purger les squelettes si un changement de meta les affecte
193 if ($i = _request('post_dates') AND ($i != $GLOBALS['meta']["post_dates"]))
194 $purger_skel = true;
195
196 if ($accepter_forum = _request('forums_publics')
197 AND ($accepter_forum != $GLOBALS['meta']["forums_publics"])) {
198 $purger_skel = true;
199 $accepter_forum = substr($accepter_forum,0,3);
200 }
201
202 // Appliquer les changements de moderation forum
203 // forums_publics_appliquer : futur, saufnon, tous
204 if (in_array($appliquer = _request('forums_publics_appliquer'),
205 array('tous', 'saufnon')
206 )) {
207 $sauf = ($appliquer == 'saufnon')
208 ? "accepter_forum != 'non'"
209 : '';
210
211 sql_updateq('spip_articles', array('accepter_forum'=>$accepter_forum), $sauf);
212 }
213
214 if ($accepter_forum == 'abo')
215 ecrire_meta('accepter_visiteurs', 'oui');
216
217 if ($i = _request('langues_auth') AND is_array($i)) {
218 set_request('langues_multilingue', join($i, ","));
219 }
220
221 // Modification du reglage accepter_inscriptions => vider le cache
222 // (pour repercuter la modif sur le panneau de login)
223 if (($i = _request('accepter_inscriptions')
224 AND $i != $GLOBALS['meta']['accepter_inscriptions'])
225 OR ($i = _request('accepter_visiteurs')
226 AND $i != $GLOBALS['meta']['accepter_visiteurs'])) {
227 include_spip('inc/invalideur');
228 suivre_invalideur("1"); # tout effacer
229 }
230
231 foreach(liste_metas() as $i => $v) {
232 if (($x =_request($i))!==NULL)
233 ecrire_meta($i, $x);
234 elseif (!isset($GLOBALS['meta'][$i]))
235 ecrire_meta($i, $v);
236 }
237
238 if ($lang = _request('changer_langue_site')) {
239 include_spip('inc/lang');
240 // verif que la langue demandee est licite
241 if (changer_langue($lang)) {
242 ecrire_meta('langue_site', $lang);
243 }
244 // le test a defait ca:
245 utiliser_langue_visiteur();
246 }
247
248 if ($purger_skel) {
249 include_spip('inc/invalideur');
250 purger_repertoire(_DIR_SKELS);
251 }
252 }
253
254 ?>