Completed
Push — master ( 611ffb...3357a0 )
by cam
01:15
created
ecrire/inc/presenter_enfants.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/autoriser');
@@ -30,80 +30,80 @@  discard block
 block discarded – undo
30 30
  *  Un tableau des sous rubriques
31 31
  */
32 32
 function enfant_rub($collection, $debut = 0, $limite = 500) {
33
-	$voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
34
-	$logo = '';
35
-
36
-	if ($voir_logo) {
37
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
38
-		include_spip('inc/filtres_images_mini');
39
-	}
40
-
41
-	$res = [];
42
-
43
-	$result = sql_select(
44
-		'id_rubrique, id_parent, titre, descriptif, lang',
45
-		'spip_rubriques',
46
-		'id_parent=' . intval($collection),
47
-		'',
48
-		'0+titre,titre',
49
-		"$debut,$limite"
50
-	);
51
-	while ($row = sql_fetch($result)) {
52
-		$id_rubrique = $row['id_rubrique'];
53
-		$id_parent = $row['id_parent'];
54
-		// pour etre sur de passer par tous les traitements
55
-		$titre = generer_objet_info($id_rubrique, 'rubrique', 'titre');
56
-		if ('' !== ($rang = recuperer_numero($row['titre']))) {
57
-			$rang = "<span class='rang'>$rang.</span> ";
58
-		}
59
-
60
-		if (autoriser('voir', 'rubrique', $id_rubrique)) {
61
-			$les_sous_enfants = sous_enfant_rub($id_rubrique);
62
-
63
-			changer_typo($row['lang']);
64
-			$lang_dir = lang_dir($row['lang']);
65
-			$descriptif = propre($row['descriptif']);
66
-
67
-			if ($voir_logo) {
68
-				if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
69
-					[$fid, $dir, $nom, $format] = $logo;
70
-					$logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
71
-					if ($logo) {
72
-						$logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
73
-					}
74
-				}
75
-			}
76
-
77
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
-					http_img_pack(
79
-						'auteur-0minirezo-16.png',
80
-						'',
81
-						" width='16' height='16'",
82
-						_T('image_administrer_rubrique')
83
-					)) .
84
-				" <a class='titremlien' dir='$lang_dir'" .
85
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
-				" href='" .
87
-				generer_objet_url($id_rubrique, 'rubrique') .
88
-				"'><span class='titre'>" .
89
-				$rang . $titre
90
-				. '</span>'
91
-				. (is_string($logo) ? $logo : '')
92
-				. '</a>';
93
-
94
-			$titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95
-				. (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
96
-				;
97
-
98
-			$res[] =
99
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
-				$les_sous_enfants .
101
-				fin_cadre_sous_rub();
102
-		}
103
-	}
104
-
105
-	changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
-	return $res;
33
+    $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
34
+    $logo = '';
35
+
36
+    if ($voir_logo) {
37
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
38
+        include_spip('inc/filtres_images_mini');
39
+    }
40
+
41
+    $res = [];
42
+
43
+    $result = sql_select(
44
+        'id_rubrique, id_parent, titre, descriptif, lang',
45
+        'spip_rubriques',
46
+        'id_parent=' . intval($collection),
47
+        '',
48
+        '0+titre,titre',
49
+        "$debut,$limite"
50
+    );
51
+    while ($row = sql_fetch($result)) {
52
+        $id_rubrique = $row['id_rubrique'];
53
+        $id_parent = $row['id_parent'];
54
+        // pour etre sur de passer par tous les traitements
55
+        $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre');
56
+        if ('' !== ($rang = recuperer_numero($row['titre']))) {
57
+            $rang = "<span class='rang'>$rang.</span> ";
58
+        }
59
+
60
+        if (autoriser('voir', 'rubrique', $id_rubrique)) {
61
+            $les_sous_enfants = sous_enfant_rub($id_rubrique);
62
+
63
+            changer_typo($row['lang']);
64
+            $lang_dir = lang_dir($row['lang']);
65
+            $descriptif = propre($row['descriptif']);
66
+
67
+            if ($voir_logo) {
68
+                if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
69
+                    [$fid, $dir, $nom, $format] = $logo;
70
+                    $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
71
+                    if ($logo) {
72
+                        $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
73
+                    }
74
+                }
75
+            }
76
+
77
+            $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
+                    http_img_pack(
79
+                        'auteur-0minirezo-16.png',
80
+                        '',
81
+                        " width='16' height='16'",
82
+                        _T('image_administrer_rubrique')
83
+                    )) .
84
+                " <a class='titremlien' dir='$lang_dir'" .
85
+                ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
+                " href='" .
87
+                generer_objet_url($id_rubrique, 'rubrique') .
88
+                "'><span class='titre'>" .
89
+                $rang . $titre
90
+                . '</span>'
91
+                . (is_string($logo) ? $logo : '')
92
+                . '</a>';
93
+
94
+            $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95
+                . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
96
+                ;
97
+
98
+            $res[] =
99
+                debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
+                $les_sous_enfants .
101
+                fin_cadre_sous_rub();
102
+        }
103
+    }
104
+
105
+    changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
+    return $res;
107 107
 }
108 108
 
109 109
 /**
@@ -116,71 +116,71 @@  discard block
 block discarded – undo
116 116
  *  Le contenu du bloc dépliable
117 117
  */
118 118
 function sous_enfant_rub($collection2) {
119
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
120
-
121
-	$retour = '';
122
-	$pagination = '';
123
-	$debut = 0;
124
-	$limite = 500;
125
-
126
-	/**
127
-	 * On ne va afficher que 500 résultats max
128
-	 * Si > 500 on affiche une pagination
129
-	 */
130
-	if ($nb > $limite) {
131
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
132
-		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<nav class="pagination">' . $pagination(
134
-			$nb,
135
-			'_rubrique' . $collection2,
136
-			$debut,
137
-			$limite,
138
-			true,
139
-			'prive'
140
-		) . '</nav>';
141
-		$limite = $debut + $limite;
142
-	}
143
-
144
-	$result = sql_select(
145
-		'id_rubrique, id_parent, titre, lang',
146
-		'spip_rubriques',
147
-		'id_parent=' . intval($collection2),
148
-		'',
149
-		'0+titre,titre',
150
-		"$debut,$limite"
151
-	);
152
-
153
-	while ($row = sql_fetch($result)) {
154
-		$id_rubrique2 = $row['id_rubrique'];
155
-		$titre2 = generer_objet_info(
156
-			$id_rubrique2,
157
-			'rubrique',
158
-			'titre'
159
-		); // pour etre sur de passer par tous les traitements
160
-		if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
161
-			$rang2 = "<span class='rang'>$rang2.</span> ";
162
-		}
163
-
164
-		changer_typo($row['lang']);
165
-		$lang_dir = lang_dir($row['lang']);
166
-		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
168
-				$id_rubrique2,
169
-				'rubrique'
170
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
171
-		}
172
-	}
173
-
174
-	$retour = $pagination . $retour . $pagination;
175
-
176
-	if (!$retour) {
177
-		return '';
178
-	}
179
-
180
-	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181
-	. "\n<ul class='liste-items sous-sous-rub'>\n"
182
-	. $retour
183
-	. "</ul>\n" . fin_block() . "\n\n";
119
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
120
+
121
+    $retour = '';
122
+    $pagination = '';
123
+    $debut = 0;
124
+    $limite = 500;
125
+
126
+    /**
127
+     * On ne va afficher que 500 résultats max
128
+     * Si > 500 on affiche une pagination
129
+     */
130
+    if ($nb > $limite) {
131
+        $debut = _request('debut_rubrique' . $collection2) ?: $debut;
132
+        $pagination = chercher_filtre('pagination');
133
+        $pagination = '<nav class="pagination">' . $pagination(
134
+            $nb,
135
+            '_rubrique' . $collection2,
136
+            $debut,
137
+            $limite,
138
+            true,
139
+            'prive'
140
+        ) . '</nav>';
141
+        $limite = $debut + $limite;
142
+    }
143
+
144
+    $result = sql_select(
145
+        'id_rubrique, id_parent, titre, lang',
146
+        'spip_rubriques',
147
+        'id_parent=' . intval($collection2),
148
+        '',
149
+        '0+titre,titre',
150
+        "$debut,$limite"
151
+    );
152
+
153
+    while ($row = sql_fetch($result)) {
154
+        $id_rubrique2 = $row['id_rubrique'];
155
+        $titre2 = generer_objet_info(
156
+            $id_rubrique2,
157
+            'rubrique',
158
+            'titre'
159
+        ); // pour etre sur de passer par tous les traitements
160
+        if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
161
+            $rang2 = "<span class='rang'>$rang2.</span> ";
162
+        }
163
+
164
+        changer_typo($row['lang']);
165
+        $lang_dir = lang_dir($row['lang']);
166
+        if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
+            $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
168
+                $id_rubrique2,
169
+                'rubrique'
170
+            ) . "'>" . $rang2 . $titre2 . "</a></li>\n";
171
+        }
172
+    }
173
+
174
+    $retour = $pagination . $retour . $pagination;
175
+
176
+    if (!$retour) {
177
+        return '';
178
+    }
179
+
180
+    return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181
+    . "\n<ul class='liste-items sous-sous-rub'>\n"
182
+    . $retour
183
+    . "</ul>\n" . fin_block() . "\n\n";
184 184
 }
185 185
 
186 186
 /**
@@ -195,44 +195,44 @@  discard block
 block discarded – undo
195 195
  *  Le contenu textuel affiché, la liste des sous rubriques
196 196
  */
197 197
 function afficher_enfant_rub($id_rubrique = 0) {
198
-	$pagination = '';
199
-	$debut = 0;
200
-	$limite = 500;
201
-
202
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
203
-
204
-	if ($nb > $limite) {
205
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
206
-		$pagination = chercher_filtre('pagination');
207
-		$pagination = '<br class="nettoyeur"><nav class="pagination">' .
208
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
209
-		'</nav>';
210
-	}
211
-
212
-	$les_enfants = enfant_rub($id_rubrique, $debut, $limite);
213
-
214
-	if (!$n = count($les_enfants)) {
215
-		return '';
216
-	}
217
-
218
-	if ($n == 1) {
219
-		$les_enfants = reset($les_enfants);
220
-		$les_enfants2 = '';
221
-	} else {
222
-		$n = ceil($n / 2);
223
-		$les_enfants2 = implode('', array_slice($les_enfants, $n));
224
-		$les_enfants = implode('', array_slice($les_enfants, 0, $n));
225
-	}
226
-
227
-	$res =
228
-		$pagination
229
-		. "<div class='gauche'>"
230
-		. $les_enfants
231
-		. '</div>'
232
-		. "<div class='droite'>"
233
-		. $les_enfants2
234
-		. '</div>'
235
-		. $pagination;
236
-
237
-	return $res;
198
+    $pagination = '';
199
+    $debut = 0;
200
+    $limite = 500;
201
+
202
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
203
+
204
+    if ($nb > $limite) {
205
+        $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
206
+        $pagination = chercher_filtre('pagination');
207
+        $pagination = '<br class="nettoyeur"><nav class="pagination">' .
208
+            $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
209
+        '</nav>';
210
+    }
211
+
212
+    $les_enfants = enfant_rub($id_rubrique, $debut, $limite);
213
+
214
+    if (!$n = count($les_enfants)) {
215
+        return '';
216
+    }
217
+
218
+    if ($n == 1) {
219
+        $les_enfants = reset($les_enfants);
220
+        $les_enfants2 = '';
221
+    } else {
222
+        $n = ceil($n / 2);
223
+        $les_enfants2 = implode('', array_slice($les_enfants, $n));
224
+        $les_enfants = implode('', array_slice($les_enfants, 0, $n));
225
+    }
226
+
227
+    $res =
228
+        $pagination
229
+        . "<div class='gauche'>"
230
+        . $les_enfants
231
+        . '</div>'
232
+        . "<div class='droite'>"
233
+        . $les_enfants2
234
+        . '</div>'
235
+        . $pagination;
236
+
237
+    return $res;
238 238
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	$result = sql_select(
44 44
 		'id_rubrique, id_parent, titre, descriptif, lang',
45 45
 		'spip_rubriques',
46
-		'id_parent=' . intval($collection),
46
+		'id_parent='.intval($collection),
47 47
 		'',
48 48
 		'0+titre,titre',
49 49
 		"$debut,$limite"
@@ -74,19 +74,18 @@  discard block
 block discarded – undo
74 74
 				}
75 75
 			}
76 76
 
77
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
-					http_img_pack(
77
+			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : http_img_pack(
79 78
 						'auteur-0minirezo-16.png',
80 79
 						'',
81 80
 						" width='16' height='16'",
82 81
 						_T('image_administrer_rubrique')
83
-					)) .
84
-				" <a class='titremlien' dir='$lang_dir'" .
85
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
-				" href='" .
87
-				generer_objet_url($id_rubrique, 'rubrique') .
88
-				"'><span class='titre'>" .
89
-				$rang . $titre
82
+					)).
83
+				" <a class='titremlien' dir='$lang_dir'".
84
+				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : '').
85
+				" href='".
86
+				generer_objet_url($id_rubrique, 'rubrique').
87
+				"'><span class='titre'>".
88
+				$rang.$titre
90 89
 				. '</span>'
91 90
 				. (is_string($logo) ? $logo : '')
92 91
 				. '</a>';
@@ -96,8 +95,8 @@  discard block
 block discarded – undo
96 95
 				;
97 96
 
98 97
 			$res[] =
99
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
-				$les_sous_enfants .
98
+				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre).
99
+				$les_sous_enfants.
101 100
 				fin_cadre_sous_rub();
102 101
 		}
103 102
 	}
@@ -116,7 +115,7 @@  discard block
 block discarded – undo
116 115
  *  Le contenu du bloc dépliable
117 116
  */
118 117
 function sous_enfant_rub($collection2) {
119
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
118
+	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2));
120 119
 
121 120
 	$retour = '';
122 121
 	$pagination = '';
@@ -128,23 +127,23 @@  discard block
 block discarded – undo
128 127
 	 * Si > 500 on affiche une pagination
129 128
 	 */
130 129
 	if ($nb > $limite) {
131
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
130
+		$debut = _request('debut_rubrique'.$collection2) ?: $debut;
132 131
 		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<nav class="pagination">' . $pagination(
132
+		$pagination = '<nav class="pagination">'.$pagination(
134 133
 			$nb,
135
-			'_rubrique' . $collection2,
134
+			'_rubrique'.$collection2,
136 135
 			$debut,
137 136
 			$limite,
138 137
 			true,
139 138
 			'prive'
140
-		) . '</nav>';
139
+		).'</nav>';
141 140
 		$limite = $debut + $limite;
142 141
 	}
143 142
 
144 143
 	$result = sql_select(
145 144
 		'id_rubrique, id_parent, titre, lang',
146 145
 		'spip_rubriques',
147
-		'id_parent=' . intval($collection2),
146
+		'id_parent='.intval($collection2),
148 147
 		'',
149 148
 		'0+titre,titre',
150 149
 		"$debut,$limite"
@@ -164,14 +163,14 @@  discard block
 block discarded – undo
164 163
 		changer_typo($row['lang']);
165 164
 		$lang_dir = lang_dir($row['lang']);
166 165
 		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
166
+			$retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_objet_url(
168 167
 				$id_rubrique2,
169 168
 				'rubrique'
170
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
169
+			)."'>".$rang2.$titre2."</a></li>\n";
171 170
 		}
172 171
 	}
173 172
 
174
-	$retour = $pagination . $retour . $pagination;
173
+	$retour = $pagination.$retour.$pagination;
175 174
 
176 175
 	if (!$retour) {
177 176
 		return '';
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181 180
 	. "\n<ul class='liste-items sous-sous-rub'>\n"
182 181
 	. $retour
183
-	. "</ul>\n" . fin_block() . "\n\n";
182
+	. "</ul>\n".fin_block()."\n\n";
184 183
 }
185 184
 
186 185
 /**
@@ -199,13 +198,13 @@  discard block
 block discarded – undo
199 198
 	$debut = 0;
200 199
 	$limite = 500;
201 200
 
202
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
201
+	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
203 202
 
204 203
 	if ($nb > $limite) {
205
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
204
+		$debut = _request('debut_rubrique'.$id_rubrique) ?: $debut;
206 205
 		$pagination = chercher_filtre('pagination');
207
-		$pagination = '<br class="nettoyeur"><nav class="pagination">' .
208
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
206
+		$pagination = '<br class="nettoyeur"><nav class="pagination">'.
207
+			$pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive').
209 208
 		'</nav>';
210 209
 	}
211 210
 
Please login to merge, or discard this patch.