[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / exec / brouteur_frame.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
15 include_spip('inc/presentation');
16
17 // http://doc.spip.org/@exec_brouteur_frame_dist
18 function exec_brouteur_frame_dist() {
19 global $connect_id_auteur, $spip_ecran, $spip_lang_left;
20
21 $id_rubrique = is_numeric(_request('rubrique')) ? intval(_request('rubrique')) : "";
22 $frame = _request('frame');
23 $effacer_suivant = _request('effacer_suivant');
24 $special = _request('special');
25 $peutpub = autoriser('publierdans','rubrique');
26
27 include_spip('inc/headers');
28 http_no_cache();
29
30 $profile = _request('var_profile') ? "&var_profile=1" : '';
31
32 echo _DOCTYPE_ECRIRE
33 . html_lang_attributes()
34 . pipeline('header_prive',
35 "<head>\n"
36 . "<title>brouteur_frame</title>\n"
37 . "<meta http-equiv='Content-Type' content='text/html"
38 . (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '')
39 . "' />\n"
40 . envoi_link(_T('info_mon_site_spip'))
41 . http_script('jQuery(function(){
42 jQuery("a.iframe").click(function(){
43 window.open(this.href,"iframe"+this.rel);
44 return false;
45 });
46 });')
47 . "</head>\n")
48 ."<body>";
49
50 if ($spip_ecran == "large") {
51 $nb_col = 4;
52 } else {
53 $nb_col = 3;
54 }
55
56 if ($effacer_suivant == "oui" && $frame < $nb_col) {
57 $res = '';
58 for ($i = $frame+1; $i < $nb_col; $i++) {
59 $res .= "\nparent.iframe$i.location.href='" . generer_url_ecrire('brouteur_frame',"frame=$i$profile") . "'";
60 }
61 echo http_script($res);
62 }
63 echo "\n<div class='arial2'>";
64
65 if ($special == "redac") {
66 $result=sql_select("articles.id_article, articles.id_rubrique, articles.titre, articles.statut", "spip_articles AS articles LEFT JOIN spip_auteurs_articles AS lien ON articles.id_article=lien.id_article", "articles.statut = 'prepa' AND lien.id_auteur = $connect_id_auteur ", " id_article ", " articles.date DESC");
67 $res = '';
68 while($row=sql_fetch($result)){
69 $id_article=$row['id_article'];
70 if (autoriser('voir','article',$id_article)){
71 $titre = typo($row['titre']);
72 $statut = $row['statut'];
73 $h = generer_url_ecrire('articles',"id_article=$id_article");
74 $res .= "<a class='$statut'\nhref='javascript:window.parent.location=\"$h\"'>$titre</a>";
75 }
76 }
77 if ($res) {
78 echo "\n<div style='padding-top: 6px; padding-bottom: 3px;'><b class='verdana2'>"._T("info_cours_edition")."</b></div>";
79 echo "\n<div class='plan-articles'>", $res, "</div>";
80 }
81
82 } else if ($special == "valider") {
83 $result=sql_select("id_article, id_rubrique, titre, statut", "spip_articles", "statut = 'prop'", "", "date DESC");
84 $res = '';
85 while($row=sql_fetch($result)){
86 $id_article=$row['id_article'];
87 if (autoriser('voir','article',$id_article)){
88 $titre = typo($row['titre']);
89 $statut = $row['statut'];
90 $h = generer_url_ecrire('articles',"id_article=$id_article");
91 $res .= "<a class='$statut' href='javascript:window.parent.location=\"$h\"'>$titre</a>";
92 }
93 }
94
95 if ($res) {
96 echo "\n<div style='padding-top: 6px; padding-bottom: 3px;'><b class='verdana2'>"._T("info_articles_proposes")."</b></div>";
97 echo "\n<div class='plan-articles'>", $res, "</div>";
98 }
99
100 $result=sql_select("*", "spip_breves", "statut = 'prop'", "", "date_heure DESC", "20");
101 $res = '';
102 while($row=sql_fetch($result)){
103 $id_breve=$row['id_breve'];
104 if (autoriser('voir','breve',$id_breve)){
105 $titre = typo($row['titre']);
106 $statut = $row['statut'];
107 $h = generer_url_ecrire('breves_voir',"id_breve=$id_breve");
108 $res .= "<a class='$statut' href='javascript:window.parent.location=\"$h\"'>$titre</a>";
109 }
110 }
111 if ($res) {
112 echo "\n<div style='padding-top: 6px;'><b class='verdana2'>"._T("info_breves_valider")."</b></div>";
113 echo "\n<div class='plan-articles'>", $res, "</div>";
114 }
115
116 }
117 else {
118 if ($id_rubrique !== "" AND autoriser('voir','rubrique',$id_rubrique)) {
119
120 $row = sql_fetsel("id_rubrique, titre, id_parent", "spip_rubriques", "id_rubrique=$id_rubrique",'', '0+titre,titre');
121
122 if ($row){
123 $titre = typo($row['titre']);
124 $id_parent=$row['id_parent'];
125
126 if ($id_parent == 0) $icone = "secteur-24.gif";
127 else $icone = "rubrique-24.gif";
128
129 echo "\n<div style='background-color: #cccccc; border: 1px solid #444444;'>";
130 echo icone_horizontale($titre, "javascript:window.parent.location=\"" . generer_url_ecrire('naviguer',"id_rubrique=$id_rubrique") .'"', $icone, "", false);
131 echo "</div>";
132 } else if ($frame == 0) {
133 echo "\n<div style='background-color: #cccccc; border: 1px solid #444444;'>";
134 echo icone_horizontale(_T('info_racine_site'), "javascript:window.parent.location=\"" . generer_url_ecrire('naviguer') . '"', "racine-site-24.gif","", false);
135 echo "</div>";
136 }
137
138 $result = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", "id_parent=$id_rubrique",'', '0+titre,titre');
139
140 while($row=sql_fetch($result)){
141 $ze_rubrique=$row['id_rubrique'];
142 if (autoriser('voir','rubrique',$ze_rubrique)){
143 $titre = typo($row['titre']);
144 $id_parent=$row['id_parent'];
145
146 echo "\n<div class='brouteur_rubrique'
147 onmouseover=\"changeclass(this, 'brouteur_rubrique_on');\"
148 onmouseout=\"changeclass(this, 'brouteur_rubrique');\">";
149
150 if ($id_parent == '0') {
151 echo "\n<div style='", frame_background_image("secteur-24.gif"), ";'><a href='", generer_url_ecrire('brouteur_frame', "rubrique=$ze_rubrique&frame=".($frame+1)."&effacer_suivant=oui$profile"), "' class='iframe' rel='", ($frame+1), "'>",
152 $titre,
153 "</a></div>";
154 }
155 else {
156 if ($frame+1 < $nb_col)
157 echo "\n<div style='",
158 frame_background_image("rubrique-24.gif"), ";'><a href='", generer_url_ecrire('brouteur_frame', "rubrique=$ze_rubrique&frame=".($frame+1)."&effacer_suivant=oui$profile"), "' class='iframe' rel='",
159 ($frame+1),
160 "'>$titre</a></div>";
161 else echo "\n<div style='",
162 frame_background_image("rubrique-24.gif"), ";'><a href='javascript:window.parent.location=\"" . generer_url_ecrire('brouteur',"id_rubrique=$ze_rubrique$profile")."\"'>",$titre,"</a></div>";
163 }
164 echo "</div>\n";
165 }
166 }
167
168
169 if ($id_rubrique > 0) {
170 if ($peutpub)
171 $result = sql_select("id_article, id_rubrique, titre, statut", "spip_articles", "id_rubrique=$id_rubrique", "", "date DESC");
172 else
173 $result = sql_select("articles.id_article, articles.id_rubrique, articles.titre, articles.statut", "spip_articles AS articles, spip_auteurs_articles AS lien", "articles.id_rubrique=$id_rubrique AND (articles.statut = 'publie' OR articles.statut = 'prop' OR (articles.statut = 'prepa' AND articles.id_article = lien.id_article AND lien.id_auteur = $connect_id_auteur)) ", " id_article ", " articles.date DESC");
174 $res = '';
175 while($row=sql_fetch($result)){
176 $id_article=$row['id_article'];
177 if (autoriser('voir','article',$id_article)){
178 $titre = typo($row['titre']);
179 $statut = $row['statut'];
180 $h = generer_url_ecrire('articles',"id_article=$id_article");
181 $res .= "<a class='$statut' href='javascript:window.parent.location=\"$h\"'>$titre</a>";
182 }
183 }
184 if ($res) {
185 echo "\n<div style='padding-top: 6px; padding-bottom: 3px;'><b class='verdana2'>"._T('info_articles')."</b></div>";
186 echo "\n<div class='plan-articles'>", $res, "</div>";
187 }
188
189 $result=sql_select("*", "spip_breves", "id_rubrique=$id_rubrique", "", "date_heure DESC", "20");
190 $res = '';
191 while($row=sql_fetch($result)){
192 $id_breve=$row['id_breve'];
193 if (autoriser('voir','breve',$id_breve)){
194 $titre = typo($row['titre']);
195 $statut = $row['statut'];
196 $h = generer_url_ecrire('breves_voir',"id_breve=$id_breve");
197 $res .= "<a class='$statut' href='javascript:window.parent.location=\"$h\"'>$titre</a>";
198 }
199 }
200 if ($res) {
201 echo "\n<div style='padding-top: 6px;'><b class='verdana2'>"._T('info_breves_02')."</b></div>";
202 echo "\n<div class='plan-articles'>", $res, "</div>";
203
204 }
205
206 $result=sql_select("*", "spip_syndic", "id_rubrique=$id_rubrique AND statut!='refuse'", "", "nom_site");
207 $res = '';
208 while($row=sql_fetch($result)){
209 $id_syndic=$row['id_syndic'];
210 if (autoriser('voir','site',$id_syndic)){
211 $titre = typo($row['nom_site']);
212 $statut = $row['statut'];
213 $h = generer_url_ecrire('sites',"id_syndic=$id_syndic");
214 $res .= "\n<div class='brouteur_icone_site'><b><a href='javascript:window.parent.location=\"$h\"'>$titre</a></b></div>";
215 }
216 }
217 if ($res)
218 echo "\n<div style='padding-top: 6px;'><b class='verdana2'>"._T('icone_sites_references')."</b></div>", $res;
219 }
220
221 // en derniere colonne, afficher articles et breves
222 if ($frame == 0 AND $id_rubrique==0) {
223
224 $cpt = sql_fetsel('A.id_article', "spip_auteurs_articles AS A LEFT JOIN spip_articles AS L ON A.id_article = L.id_article", "L.statut = 'prepa' AND A.id_auteur=$connect_id_auteur", "A.id_article");
225
226 if ($cpt) {
227
228 echo "\n<div class='brouteur_icone_article'><b class='verdana2'><a href='", generer_url_ecrire('brouteur_frame', "special=redac&frame=".($frame+1)."&effacer_suivant=oui$profile"), "' class='iframe' rel='",($frame+1),"'>",
229 _T("info_cours_edition"),"</a></b></div>";
230 }
231
232 $cpt = sql_countsel("spip_articles AS articles", "articles.statut = 'prop'");
233 if (!$cpt)
234 $cpt = sql_countsel("spip_breves", "statut = 'prop'");
235 if ($cpt)
236 echo "\n<div class='brouteur_icone_article'><b class='verdana2'><a href='", generer_url_ecrire('brouteur_frame', "special=valider&frame=".($frame+1)."&effacer_suivant=oui$profile"), "' class='iframe' rel='",
237 ($frame+1)."'>",
238 _T("info_articles_proposes"),
239 " / "._T("info_breves_valider")."</a></b></div>";
240 }
241 }
242 }
243 echo "</div>";
244
245 echo "</body></html>";
246 }
247
248 // http://doc.spip.org/@frame_background_image
249 function frame_background_image($f)
250 {
251 return "background-image: url(" .
252 chemin_image($f) .
253 ")";
254 }
255 ?>