Completed
Push — master ( 2299ed...1847b1 )
by cam
04:13
created
ecrire/inc/presenter_enfants.php 2 patches
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 if (!defined('_ECRIRE_INC_VERSION')) {
15
-	return;
15
+    return;
16 16
 }
17 17
 
18 18
 include_spip('inc/autoriser');
@@ -31,79 +31,79 @@  discard block
 block discarded – undo
31 31
  *  Un tableau des sous rubriques
32 32
  */
33 33
 function enfant_rub($collection, $debut = 0, $limite = 500) {
34
-	$voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
35
-	$logo = '';
36
-
37
-	if ($voir_logo) {
38
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
39
-		include_spip('inc/filtres_images_mini');
40
-	}
41
-
42
-	$res = array();
43
-
44
-	$result = sql_select(
45
-		'id_rubrique, id_parent, titre, descriptif, lang',
46
-		'spip_rubriques',
47
-		'id_parent='.intval($collection),
48
-		'',
49
-		'0+titre,titre',
50
-		"$debut,$limite"
51
-	);
52
-	while ($row = sql_fetch($result)) {
53
-		$id_rubrique = $row['id_rubrique'];
54
-		$id_parent = $row['id_parent'];
55
-		// pour etre sur de passer par tous les traitements
56
-		$titre = generer_info_entite($id_rubrique, 'rubrique', 'titre');
57
-		if ('' !== ($rang = recuperer_numero($row['titre']))) {
58
-			$rang = "$rang. ";
59
-		}
60
-
61
-		if (autoriser('voir', 'rubrique', $id_rubrique)) {
62
-			$les_sous_enfants = sous_enfant_rub($id_rubrique);
63
-
64
-			changer_typo($row['lang']);
65
-			$lang_dir = lang_dir($row['lang']);
66
-			$descriptif = propre($row['descriptif']);
67
-
68
-			if ($voir_logo) {
69
-				if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
70
-					list($fid, $dir, $nom, $format) = $logo;
71
-					$logo = image_reduire("<img src='$fid' alt='' />", 70, 70);
72
-					if ($logo) {
73
-						$logo = inserer_attribut($logo, 'class', 'logo');
74
-					}
75
-				}
76
-			}
77
-
78
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
79
-					http_img_pack(
80
-						'auteur-0minirezo-16.png',
81
-						'',
82
-						" width='16' height='16'",
83
-						_T('image_administrer_rubrique')
84
-					)) .
85
-				" <a dir='$lang_dir'" .
86
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
87
-				" href='" .
88
-				generer_url_entite($id_rubrique, 'rubrique') .
89
-				"'>" .
90
-				$rang . $titre .
91
-				'</a>';
92
-
93
-			$titre = (is_string($logo) ? $logo : '') .
94
-				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(true);
102
-		}
103
-	}
104
-
105
-	changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
-	return $res;
34
+    $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
35
+    $logo = '';
36
+
37
+    if ($voir_logo) {
38
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
39
+        include_spip('inc/filtres_images_mini');
40
+    }
41
+
42
+    $res = array();
43
+
44
+    $result = sql_select(
45
+        'id_rubrique, id_parent, titre, descriptif, lang',
46
+        'spip_rubriques',
47
+        'id_parent='.intval($collection),
48
+        '',
49
+        '0+titre,titre',
50
+        "$debut,$limite"
51
+    );
52
+    while ($row = sql_fetch($result)) {
53
+        $id_rubrique = $row['id_rubrique'];
54
+        $id_parent = $row['id_parent'];
55
+        // pour etre sur de passer par tous les traitements
56
+        $titre = generer_info_entite($id_rubrique, 'rubrique', 'titre');
57
+        if ('' !== ($rang = recuperer_numero($row['titre']))) {
58
+            $rang = "$rang. ";
59
+        }
60
+
61
+        if (autoriser('voir', 'rubrique', $id_rubrique)) {
62
+            $les_sous_enfants = sous_enfant_rub($id_rubrique);
63
+
64
+            changer_typo($row['lang']);
65
+            $lang_dir = lang_dir($row['lang']);
66
+            $descriptif = propre($row['descriptif']);
67
+
68
+            if ($voir_logo) {
69
+                if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
70
+                    list($fid, $dir, $nom, $format) = $logo;
71
+                    $logo = image_reduire("<img src='$fid' alt='' />", 70, 70);
72
+                    if ($logo) {
73
+                        $logo = inserer_attribut($logo, 'class', 'logo');
74
+                    }
75
+                }
76
+            }
77
+
78
+            $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
79
+                    http_img_pack(
80
+                        'auteur-0minirezo-16.png',
81
+                        '',
82
+                        " width='16' height='16'",
83
+                        _T('image_administrer_rubrique')
84
+                    )) .
85
+                " <a dir='$lang_dir'" .
86
+                ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
87
+                " href='" .
88
+                generer_url_entite($id_rubrique, 'rubrique') .
89
+                "'>" .
90
+                $rang . $titre .
91
+                '</a>';
92
+
93
+            $titre = (is_string($logo) ? $logo : '') .
94
+                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(true);
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,65 +116,65 @@  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) ? _request('debut_rubrique' . $collection2) : $debut;
132
-		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true,
134
-				'prive') . '</p>';
135
-		$limite = $debut + $limite;
136
-	}
137
-
138
-	$result = sql_select(
139
-		'id_rubrique, id_parent, titre, lang',
140
-		'spip_rubriques',
141
-		'id_parent='.intval($collection2),
142
-		'',
143
-		'0+titre,titre',
144
-		"$debut,$limite"
145
-	);
146
-
147
-	while ($row = sql_fetch($result)) {
148
-		$id_rubrique2 = $row['id_rubrique'];
149
-		$titre2 = generer_info_entite(
150
-			$id_rubrique2,
151
-			'rubrique',
152
-			'titre'
153
-		); // pour etre sur de passer par tous les traitements
154
-		if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
155
-			$rang2 = "$rang2. ";
156
-		}
157
-
158
-		changer_typo($row['lang']);
159
-		$lang_dir = lang_dir($row['lang']);
160
-		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
161
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
162
-				$id_rubrique2,
163
-				'rubrique'
164
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
165
-		}
166
-	}
167
-
168
-	$retour = $pagination . $retour . $pagination;
169
-
170
-	if (!$retour) {
171
-		return '';
172
-	}
173
-
174
-	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
175
-	. "\n<ul class='liste-items sous-sous-rub'>\n"
176
-	. $retour
177
-	. "</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) ? _request('debut_rubrique' . $collection2) : $debut;
132
+        $pagination = chercher_filtre('pagination');
133
+        $pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true,
134
+                'prive') . '</p>';
135
+        $limite = $debut + $limite;
136
+    }
137
+
138
+    $result = sql_select(
139
+        'id_rubrique, id_parent, titre, lang',
140
+        'spip_rubriques',
141
+        'id_parent='.intval($collection2),
142
+        '',
143
+        '0+titre,titre',
144
+        "$debut,$limite"
145
+    );
146
+
147
+    while ($row = sql_fetch($result)) {
148
+        $id_rubrique2 = $row['id_rubrique'];
149
+        $titre2 = generer_info_entite(
150
+            $id_rubrique2,
151
+            'rubrique',
152
+            'titre'
153
+        ); // pour etre sur de passer par tous les traitements
154
+        if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
155
+            $rang2 = "$rang2. ";
156
+        }
157
+
158
+        changer_typo($row['lang']);
159
+        $lang_dir = lang_dir($row['lang']);
160
+        if (autoriser('voir', 'rubrique', $id_rubrique2)) {
161
+            $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
162
+                $id_rubrique2,
163
+                'rubrique'
164
+            ) . "'>" . $rang2 . $titre2 . "</a></li>\n";
165
+        }
166
+    }
167
+
168
+    $retour = $pagination . $retour . $pagination;
169
+
170
+    if (!$retour) {
171
+        return '';
172
+    }
173
+
174
+    return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
175
+    . "\n<ul class='liste-items sous-sous-rub'>\n"
176
+    . $retour
177
+    . "</ul>\n" . fin_block() . "\n\n";
178 178
 }
179 179
 
180 180
 /**
@@ -189,44 +189,44 @@  discard block
 block discarded – undo
189 189
  *  Le contenu textuel affiché, la liste des sous rubriques
190 190
  */
191 191
 function afficher_enfant_rub($id_rubrique = 0) {
192
-	$pagination = '';
193
-	$debut = 0;
194
-	$limite = 500;
195
-
196
-	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
197
-
198
-	if ($nb > $limite) {
199
-		$debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut;
200
-		$pagination = chercher_filtre('pagination');
201
-		$pagination = '<br class="nettoyeur"><p class="pagination">' .
202
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
203
-		'</p>';
204
-	}
205
-
206
-	$les_enfants = enfant_rub($id_rubrique, $debut, $limite);
207
-
208
-	if (!$n = count($les_enfants)) {
209
-		return '';
210
-	}
211
-
212
-	if ($n == 1) {
213
-		$les_enfants = reset($les_enfants);
214
-		$les_enfants2 = '';
215
-	} else {
216
-		$n = ceil($n / 2);
217
-		$les_enfants2 = implode('', array_slice($les_enfants, $n));
218
-		$les_enfants = implode('', array_slice($les_enfants, 0, $n));
219
-	}
220
-
221
-	$res =
222
-		$pagination
223
-		. "<div class='gauche'>"
224
-		. $les_enfants
225
-		. '</div>'
226
-		. "<div class='droite'>"
227
-		. $les_enfants2
228
-		. '</div>'
229
-		. $pagination;
230
-
231
-	return $res;
192
+    $pagination = '';
193
+    $debut = 0;
194
+    $limite = 500;
195
+
196
+    $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
197
+
198
+    if ($nb > $limite) {
199
+        $debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut;
200
+        $pagination = chercher_filtre('pagination');
201
+        $pagination = '<br class="nettoyeur"><p class="pagination">' .
202
+            $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
203
+        '</p>';
204
+    }
205
+
206
+    $les_enfants = enfant_rub($id_rubrique, $debut, $limite);
207
+
208
+    if (!$n = count($les_enfants)) {
209
+        return '';
210
+    }
211
+
212
+    if ($n == 1) {
213
+        $les_enfants = reset($les_enfants);
214
+        $les_enfants2 = '';
215
+    } else {
216
+        $n = ceil($n / 2);
217
+        $les_enfants2 = implode('', array_slice($les_enfants, $n));
218
+        $les_enfants = implode('', array_slice($les_enfants, 0, $n));
219
+    }
220
+
221
+    $res =
222
+        $pagination
223
+        . "<div class='gauche'>"
224
+        . $les_enfants
225
+        . '</div>'
226
+        . "<div class='droite'>"
227
+        . $les_enfants2
228
+        . '</div>'
229
+        . $pagination;
230
+
231
+    return $res;
232 232
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -75,29 +75,28 @@  discard block
 block discarded – undo
75 75
 				}
76 76
 			}
77 77
 
78
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
79
-					http_img_pack(
78
+			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : http_img_pack(
80 79
 						'auteur-0minirezo-16.png',
81 80
 						'',
82 81
 						" width='16' height='16'",
83 82
 						_T('image_administrer_rubrique')
84
-					)) .
85
-				" <a dir='$lang_dir'" .
86
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
87
-				" href='" .
88
-				generer_url_entite($id_rubrique, 'rubrique') .
89
-				"'>" .
90
-				$rang . $titre .
83
+					)).
84
+				" <a dir='$lang_dir'".
85
+				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : '').
86
+				" href='".
87
+				generer_url_entite($id_rubrique, 'rubrique').
88
+				"'>".
89
+				$rang.$titre.
91 90
 				'</a>';
92 91
 
93
-			$titre = (is_string($logo) ? $logo : '') .
92
+			$titre = (is_string($logo) ? $logo : '').
94 93
 				bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95 94
 				.(!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") 
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(true);
102 101
 		}
103 102
 	}
@@ -128,10 +127,10 @@  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) ? _request('debut_rubrique' . $collection2) : $debut;
130
+		$debut = _request('debut_rubrique'.$collection2) ? _request('debut_rubrique'.$collection2) : $debut;
132 131
 		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true,
134
-				'prive') . '</p>';
132
+		$pagination = '<p class="pagination">'.$pagination($nb, '_rubrique'.$collection2, $debut, $limite, true,
133
+				'prive').'</p>';
135 134
 		$limite = $debut + $limite;
136 135
 	}
137 136
 
@@ -158,14 +157,14 @@  discard block
 block discarded – undo
158 157
 		changer_typo($row['lang']);
159 158
 		$lang_dir = lang_dir($row['lang']);
160 159
 		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
161
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
160
+			$retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_url_entite(
162 161
 				$id_rubrique2,
163 162
 				'rubrique'
164
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
163
+			)."'>".$rang2.$titre2."</a></li>\n";
165 164
 		}
166 165
 	}
167 166
 
168
-	$retour = $pagination . $retour . $pagination;
167
+	$retour = $pagination.$retour.$pagination;
169 168
 
170 169
 	if (!$retour) {
171 170
 		return '';
@@ -174,7 +173,7 @@  discard block
 block discarded – undo
174 173
 	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
175 174
 	. "\n<ul class='liste-items sous-sous-rub'>\n"
176 175
 	. $retour
177
-	. "</ul>\n" . fin_block() . "\n\n";
176
+	. "</ul>\n".fin_block()."\n\n";
178 177
 }
179 178
 
180 179
 /**
@@ -196,10 +195,10 @@  discard block
 block discarded – undo
196 195
 	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
197 196
 
198 197
 	if ($nb > $limite) {
199
-		$debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut;
198
+		$debut = _request('debut_rubrique'.$id_rubrique) ? _request('debut_rubrique'.$id_rubrique) : $debut;
200 199
 		$pagination = chercher_filtre('pagination');
201
-		$pagination = '<br class="nettoyeur"><p class="pagination">' .
202
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
200
+		$pagination = '<br class="nettoyeur"><p class="pagination">'.
201
+			$pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive').
203 202
 		'</p>';
204 203
 	}
205 204
 
Please login to merge, or discard this patch.