[SPIP] ~maj v2.1.25-->2.1.26
[velocampus/web/www.git] / www / ecrire / exec / sites.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
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 include_spip('inc/presentation');
15 include_spip('inc/date');
16 include_spip('inc/config');
17
18 // http://doc.spip.org/@exec_sites_dist
19 function exec_sites_dist()
20 {
21 exec_sites_args(intval(_request('id_syndic')));
22 }
23
24 // http://doc.spip.org/@exec_sites_args
25 function exec_sites_args($id_syndic)
26 {
27 if (!autoriser('voir','site',$id_syndic)
28 OR (!$row = sql_fetsel("*", "spip_syndic", "id_syndic=$id_syndic"))) {
29 include_spip('inc/minipres');
30 echo minipres(_T('public:aucun_site'));
31 } else {
32
33 $id_rubrique = $row["id_rubrique"];
34 $nom_site = $row["nom_site"];
35 $titre_page = "&laquo; $nom_site &raquo;";
36 pipeline('exec_init',array('args'=>array('exec'=>'sites','id_syndic'=>$id_syndic),'data'=>''));
37
38 $commencer_page = charger_fonction('commencer_page', 'inc');
39 echo $commencer_page("$titre_page","naviguer","sites", $id_rubrique);
40 afficher_site($id_syndic, $id_rubrique, $nom_site, $row);
41 echo fin_gauche();
42 echo fin_page();
43 }
44 }
45
46
47 // http://doc.spip.org/@afficher_site
48 function afficher_site($id_syndic, $id_rubrique, $nom_site, $row){
49
50 global $spip_lang_right;
51
52 $cherche_mot = _request('cherche_mot');
53 $select_groupe = _request('select_groupe');
54 $id_secteur = $row["id_secteur"];
55 $url_site = $row["url_site"];
56 $url_syndic = $row["url_syndic"];
57 $syndication = $row["syndication"];
58 $statut = $row["statut"];
59 $date_heure = $row["date"];
60 $date_syndic = $row['date_syndic'];
61
62 $flag_administrable = autoriser('modifier','site',$id_syndic);
63 $flag_editable = ($flag_administrable OR ($GLOBALS['meta']["proposer_sites"] > 0 AND ($statut == 'prop')));
64
65 $meme_rubrique = charger_fonction('meme_rubrique', 'inc');
66 $iconifier = charger_fonction('iconifier', 'inc');
67 if ($flag_editable AND ($statut == 'publie'))
68 $dater = charger_fonction('dater', 'inc');
69 $editer_mots = charger_fonction('editer_mots', 'inc');
70 if ($flag_administrable)
71 $instituer_site = charger_fonction('instituer_site','inc');
72
73 echo debut_grand_cadre(true);
74 echo afficher_hierarchie($id_rubrique);
75 echo fin_grand_cadre(true);
76
77 echo debut_gauche('', true);
78 echo debut_boite_info(true);
79 echo pipeline ('boite_infos', array('data' => '',
80 'args' => array(
81 'type'=>'site',
82 'id' => $id_syndic,
83 'row' => $row
84 )
85 ));
86 echo fin_boite_info(true);
87 echo $iconifier('id_syndic', $id_syndic, 'sites', false, $flag_administrable);
88
89 echo pipeline('affiche_gauche',array('args'=>array('exec'=>'sites','id_syndic'=>$id_syndic),'data'=>''));
90
91 echo creer_colonne_droite('', true);
92 echo $meme_rubrique($id_rubrique, $id_syndic, 'syndic');
93 echo pipeline('affiche_droite',array('args'=>array('exec'=>'sites','id_syndic'=>$id_syndic),'data'=>''));
94
95 echo bloc_des_raccourcis(
96 icone_horizontale(_T('icone_voir_sites_references'), generer_url_ecrire("sites_tous",""), "site-24.gif","rien.gif", false)
97 );
98
99
100 echo debut_droite('', true);
101
102 if ($syndication == 'off' OR $syndication == 'sus')
103 $droit = $id_rubrique;
104 else $droit = 0;
105
106 $url_affichee = $url_site;
107 if (strlen($url_affichee) > 40) $url_affichee = substr($url_affichee, 0, 30)."...";
108
109 $actions =
110 ($flag_editable ? icone_inline(_T('icone_modifier_site'), generer_url_ecrire('sites_edit',"id_syndic=$id_syndic"), "site-24.gif", "edit.gif",$spip_lang_right) : "");
111
112 $haut =
113 "<div class='bandeau_actions'>$actions</div>".
114 gros_titre($nom_site?$nom_site:"("._T('info_sans_titre_2').")", '' , false)
115 . "<a href='$url_site' class='url_site'>$url_affichee</a>";
116
117 $type = 'site';
118 $contexte = array('id'=>$id_syndic,'id_rubrique'=>$id_rubrique);
119 $fond = recuperer_fond("prive/contenu/$type",$contexte);
120 // permettre aux plugin de faire des modifs ou des ajouts
121 $fond = pipeline('afficher_contenu_objet',
122 array(
123 'args'=>array(
124 'type'=>$type,
125 'id_objet'=>$id_syndic,
126 'contexte'=>$contexte),
127 'data'=> $fond));
128
129 $fond = "<div id='wysiwyg'>$fond</div>";
130
131 $onglet_contenu =
132 (_INTERFACE_ONGLETS?
133 ($statut == 'prop' ? "<p class='site_prop'>"._T('info_site_propose')." <b>".affdate($date_heure)."&nbsp;</b></p>" : "")
134 . $fond:"")
135
136 . (($syndication == "oui" OR $syndication == "off" OR $syndication == "sus") ?
137 "<p class='site_syndique'><a href='".htmlspecialchars($url_syndic)."'>"
138 . http_img_pack('feed.png', 'RSS'). '</a>'._T('info_site_syndique').'</p>'
139
140 . (($syndication == "off" OR $syndication=="sus") ?
141 "<div class='site_syndique_probleme'>" . _T('avis_site_syndique_probleme', array('url_syndic' => quote_amp($url_syndic)))
142 . redirige_action_auteur('editer_site', $id_syndic, 'sites', '',
143 "<input type='hidden' name='reload' value='oui' />
144 <input type='submit' value=\""
145 . attribut_html(_T('lien_nouvelle_recuperation'))
146 . "\" class='spip_xx-small' />")
147 . "</div>"
148 : "")
149
150 . afficher_objets('syndic_article',_T('titre_articles_syndiques'), array('FROM' => 'spip_syndic_articles', 'WHERE' => "id_syndic=$id_syndic", 'ORDER BY' => "date DESC"), $id_syndic)
151
152 . ($date_syndic ? "<div class='date_syndic'>" . _T('info_derniere_syndication').' '.affdate_heure($date_syndic) .".</div>" : "")
153 . "<div class='mise_a_jour_syndic'>"
154 . redirige_action_post('editer_site', $id_syndic, 'sites', "id_syndic=$id_syndic",
155 "<input type='hidden' name='reload' value='oui' />
156 <input type='submit' value=\""
157 . attribut_html(_T('lien_mise_a_jour_syndication'))
158 . "\" class='spip_xx-small' />")
159 . "</div>"
160
161 : choix_feed($id_syndic, $id_rubrique, $nom_site, $row))
162 . (_INTERFACE_ONGLETS?"":($flag_administrable ? options_moderation($row) : ""))
163
164 ;
165
166 $onglet_proprietes =
167 (_INTERFACE_ONGLETS?"":
168 $fond
169 . ($statut == 'prop' ? "<p class='site_prop'>"._T('info_site_propose')." <b>".affdate($date_heure)."&nbsp;</b></p>" : "")
170 )
171 . afficher_site_rubrique($id_syndic, $id_rubrique, $id_secteur)
172 . ($dater ? $dater($id_syndic, $flag_editable, $statut, 'syndic', 'sites', $date_heure) : "")
173 . $editer_mots('syndic', $id_syndic, $cherche_mot, $select_groupe, $flag_editable, true, 'sites')
174 . (_INTERFACE_ONGLETS?($flag_administrable ? options_moderation($row) : ""):"")
175 . pipeline('affiche_milieu',array('args'=>array('exec'=>'sites','id_syndic'=>$id_syndic),'data'=>''))
176 ;
177
178 $discuter = charger_fonction('discuter', 'inc');
179 $onglet_discuter = $discuter($id_syndic, 'sites', 'id_syndic');
180 $onglet_documents = "" ;
181 $onglet_interactivite = "";
182
183 echo
184 "<div class='fiche_objet'>"
185 . $haut
186 . afficher_onglets_pages(array(
187 'voir' => _T('onglet_contenu'),
188 'props' => _T('onglet_proprietes'),
189 'docs' => _T('onglet_documents'),
190 'interactivite' => _T('onglet_interactivite'),
191 'discuter' => _T('onglet_discuter')),
192 _INTERFACE_ONGLETS?
193 array(
194 'voir'=>$onglet_contenu,
195 'props'=>$onglet_proprietes,
196 'docs'=>$onglet_documents,
197 'interactivite'=>$onglet_interactivite,
198 'discuter'=>$onglet_discuter)
199 :array(
200 'props'=>$onglet_proprietes,
201 'voir'=>$onglet_contenu )
202 )
203 . "</div>"
204 . (_INTERFACE_ONGLETS?"":$onglet_discuter);
205 }
206
207 // http://doc.spip.org/@options_moderation
208 function options_moderation($row) {
209
210 global $spip_lang_left;
211
212 if ($row['syndication'] == 'non' or $row['syndication'] == '') return '';
213
214 $id_syndic = $row['id_syndic'];
215 $moderation = $row['moderation'];
216 if ($moderation != 'oui') $moderation='non';
217
218 $res = "<div style='text-align: ".$GLOBALS['spip_lang_left']."'>".
219 _T('syndic_choix_moderation')
220 . "<div style='padding-$spip_lang_left: 40px;'>"
221 . afficher_choix('moderation', $moderation,
222 array(
223 'non' => _T('info_publier') .' ('._T('bouton_radio_modere_posteriori').')',
224 'oui' => _T('info_bloquer') .' ('._T('bouton_radio_modere_priori').')' ))
225 . "</div></div>\n";
226
227 // Oublier les vieux liens ?
228 // Depublier les liens qui ne figurent plus ?
229
230 $res .= "\n<div>&nbsp;</div>"
231 . "\n<div style='text-align:".$GLOBALS['spip_lang_left']."'>"._T('syndic_choix_oublier'). '</div>'
232 . "\n<ul style='text-align:".$GLOBALS['spip_lang_left']."'>\n";
233
234 $on = array('oui' => _T('item_oui'), 'non' => _T('item_non'));
235 if (!$miroir = $row['miroir'])
236 $miroir = 'non';
237
238 $res .= "\n<li>"._T('syndic_option_miroir').' '
239 . afficher_choix('miroir', $miroir, $on, " &nbsp; ")
240 . "</li>\n";
241
242 if (!$oubli = $row['oubli'])
243 $oubli = 'non';
244 $res .= "\n<li>"
245 . _T('syndic_option_oubli', array('mois' => 2)).' '
246 . afficher_choix('oubli', $oubli, $on," &nbsp; ")
247 . "</li>\n"
248 . "</ul>\n";
249
250 // Prendre les resumes ou le texte integral ?
251 if (!$resume = $row['resume'])
252 $resume = 'oui';
253
254 $res .= "\n<div style='text-align: $spip_lang_left'>"
255 . _T('syndic_choix_resume')
256 . "\n<div style='padding-$spip_lang_left: 40px;'>"
257 . afficher_choix('resume', $resume,
258 array( 'oui' => _T('syndic_option_resume_oui'),
259 'non' => _T('syndic_option_resume_non') ))
260 . "</div></div>\n";
261
262 // Bouton "Valider"
263 $res .= "\n<div style='text-align:".$GLOBALS['spip_lang_right'].";'><input type='submit' value='"._T('bouton_valider')."' /></div>\n";
264
265 return
266 debut_cadre_relief('feed.png', true, "", _T('syndic_options').aide('artsyn'))
267 . redirige_action_post('editer_site', "options/$id_syndic", 'sites', '', $res)
268 . fin_cadre_relief(true);
269 }
270
271 // Site pour lesquels feedfinder a un ou plusieurs flux,
272 // et l'on propose de choisir
273
274 // http://doc.spip.org/@choix_feed
275 function choix_feed($id_syndic, $id_rubrique, $nom_site, $row) {
276
277 global $spip_lang_left, $spip_lang_right;
278
279 if (!preg_match(',^\s*select: (.*),', $row['url_syndic'], $regs))
280 return '';
281
282 $res = "";
283
284 foreach (array('id_rubrique', 'nom_site', 'url_site', 'descriptif', 'statut') as $var) {
285 $res .= "<input type='hidden' name='$var' value=\"".entites_html($$var)."\" />\n";
286 }
287 $res .= "<div style='text-align: $spip_lang_left'>\n";
288 $res .= "<div><input type='radio' name='syndication' value='non' id='syndication_non' checked='checked' />";
289 $res .= " <b><label for='syndication_non'>"._T('bouton_radio_non_syndication')."</label></b></div>\n";
290 $res .= "<div><input type='radio' name='syndication' value='oui' id='syndication_oui' />";
291 $res .= " <label for='syndication_oui'>"._T('bouton_radio_syndication')."</label></div>\n";
292
293 $res .= "<select name='url_syndic' id='url_syndic'>\n";
294 foreach (explode(' ',$regs[1]) as $feed) {
295 $res .= '<option value="'.entites_html($feed).'">'.$feed."</option>\n";
296 }
297 $res .= "</select>\n";
298 $res .= aide("rubsyn");
299 $res .= "<div style='text-align: $spip_lang_right'><input type='submit' value='"._T('bouton_valider')."' /></div>\n";
300 $res .= "</div>\n";
301
302 $res = redirige_action_post('editer_site', $id_syndic, 'sites','', $res);
303
304 return debut_cadre_relief('', true) . $res . fin_cadre_relief(true);
305 }
306
307 // http://doc.spip.org/@afficher_site_rubrique
308 function afficher_site_rubrique($id_syndic, $id_rubrique, $id_secteur)
309 {
310 global $spip_lang_right;
311
312 if (!_INTERFACE_ONGLETS) return "";
313
314 $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
315
316 $form = $chercher_rubrique($id_rubrique, 'site', false);
317 if (strpos($form,'<select')!==false) {
318 $form .= "<div style='text-align: $spip_lang_right;'>"
319 . '<input type="submit" value="'._T('bouton_choisir').'"/>'
320 . "</div>";
321 }
322
323 $msg = _T('titre_cadre_interieur_rubrique');
324
325 $form = "<input type='hidden' name='editer_article' value='oui' />\n" . $form;
326 $form = redirige_action_post("editer_site", $id_syndic, 'sites', $form, " class='submit_plongeur'");
327
328 if ($id_rubrique == 0) $logo = "racine-site-24.gif";
329 elseif ($id_secteur == $id_rubrique) $logo = "secteur-24.gif";
330 else $logo = "rubrique-24.gif";
331
332 return debut_cadre_couleur($logo, true, "", $msg) . $form .fin_cadre_couleur(true);
333 }
334 ?>