Completed
Push — master ( ab9620...37f24f )
by cam
09:07 queued 05:07
created
ecrire/inc/presenter_enfants.php 1 patch
Indentation   +174 added lines, -174 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,80 +31,80 @@  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 = "<span class='rang'>$rang.</span> ";
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_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
72
-					if ($logo) {
73
-						$logo = wrap(inserer_attribut($logo, 'class', 'logo'),'<span class="logo-carre">');
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 class='titremlien' dir='$lang_dir'" .
86
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
87
-				" href='" .
88
-				generer_url_entite($id_rubrique, 'rubrique') .
89
-				"'><span class='titre'>" .
90
-				$rang . $titre
91
-				. '</span>'
92
-				. (is_string($logo) ? $logo : '')
93
-				. '</a>';
94
-
95
-			$titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
96
-				. (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
97
-				;
98
-
99
-			$res[] =
100
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
101
-				$les_sous_enfants .
102
-				fin_cadre_sous_rub(true);
103
-		}
104
-	}
105
-
106
-	changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
107
-	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 = "<span class='rang'>$rang.</span> ";
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_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
72
+                    if ($logo) {
73
+                        $logo = wrap(inserer_attribut($logo, 'class', 'logo'),'<span class="logo-carre">');
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 class='titremlien' dir='$lang_dir'" .
86
+                ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
87
+                " href='" .
88
+                generer_url_entite($id_rubrique, 'rubrique') .
89
+                "'><span class='titre'>" .
90
+                $rang . $titre
91
+                . '</span>'
92
+                . (is_string($logo) ? $logo : '')
93
+                . '</a>';
94
+
95
+            $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
96
+                . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
97
+                ;
98
+
99
+            $res[] =
100
+                debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
101
+                $les_sous_enfants .
102
+                fin_cadre_sous_rub(true);
103
+        }
104
+    }
105
+
106
+    changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
107
+    return $res;
108 108
 }
109 109
 
110 110
 /**
@@ -117,65 +117,65 @@  discard block
 block discarded – undo
117 117
  *  Le contenu du bloc dépliable
118 118
  */
119 119
 function sous_enfant_rub($collection2) {
120
-	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2));
121
-
122
-	$retour = '';
123
-	$pagination = '';
124
-	$debut = 0;
125
-	$limite = 500;
126
-
127
-	/**
128
-	 * On ne va afficher que 500 résultats max
129
-	 * Si > 500 on affiche une pagination
130
-	 */
131
-	if ($nb > $limite) {
132
-		$debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut;
133
-		$pagination = chercher_filtre('pagination');
134
-		$pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true,
135
-				'prive') . '</p>';
136
-		$limite = $debut + $limite;
137
-	}
138
-
139
-	$result = sql_select(
140
-		'id_rubrique, id_parent, titre, lang',
141
-		'spip_rubriques',
142
-		'id_parent='.intval($collection2),
143
-		'',
144
-		'0+titre,titre',
145
-		"$debut,$limite"
146
-	);
147
-
148
-	while ($row = sql_fetch($result)) {
149
-		$id_rubrique2 = $row['id_rubrique'];
150
-		$titre2 = generer_info_entite(
151
-			$id_rubrique2,
152
-			'rubrique',
153
-			'titre'
154
-		); // pour etre sur de passer par tous les traitements
155
-		if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
156
-			$rang2 = "<span class='rang'>$rang2.</span> ";
157
-		}
158
-
159
-		changer_typo($row['lang']);
160
-		$lang_dir = lang_dir($row['lang']);
161
-		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
162
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
163
-				$id_rubrique2,
164
-				'rubrique'
165
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
166
-		}
167
-	}
168
-
169
-	$retour = $pagination . $retour . $pagination;
170
-
171
-	if (!$retour) {
172
-		return '';
173
-	}
174
-
175
-	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
176
-	. "\n<ul class='liste-items sous-sous-rub'>\n"
177
-	. $retour
178
-	. "</ul>\n" . fin_block() . "\n\n";
120
+    $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2));
121
+
122
+    $retour = '';
123
+    $pagination = '';
124
+    $debut = 0;
125
+    $limite = 500;
126
+
127
+    /**
128
+     * On ne va afficher que 500 résultats max
129
+     * Si > 500 on affiche une pagination
130
+     */
131
+    if ($nb > $limite) {
132
+        $debut = _request('debut_rubrique' . $collection2) ? _request('debut_rubrique' . $collection2) : $debut;
133
+        $pagination = chercher_filtre('pagination');
134
+        $pagination = '<p class="pagination">' . $pagination($nb, '_rubrique' . $collection2, $debut, $limite, true,
135
+                'prive') . '</p>';
136
+        $limite = $debut + $limite;
137
+    }
138
+
139
+    $result = sql_select(
140
+        'id_rubrique, id_parent, titre, lang',
141
+        'spip_rubriques',
142
+        'id_parent='.intval($collection2),
143
+        '',
144
+        '0+titre,titre',
145
+        "$debut,$limite"
146
+    );
147
+
148
+    while ($row = sql_fetch($result)) {
149
+        $id_rubrique2 = $row['id_rubrique'];
150
+        $titre2 = generer_info_entite(
151
+            $id_rubrique2,
152
+            'rubrique',
153
+            'titre'
154
+        ); // pour etre sur de passer par tous les traitements
155
+        if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
156
+            $rang2 = "<span class='rang'>$rang2.</span> ";
157
+        }
158
+
159
+        changer_typo($row['lang']);
160
+        $lang_dir = lang_dir($row['lang']);
161
+        if (autoriser('voir', 'rubrique', $id_rubrique2)) {
162
+            $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_url_entite(
163
+                $id_rubrique2,
164
+                'rubrique'
165
+            ) . "'>" . $rang2 . $titre2 . "</a></li>\n";
166
+        }
167
+    }
168
+
169
+    $retour = $pagination . $retour . $pagination;
170
+
171
+    if (!$retour) {
172
+        return '';
173
+    }
174
+
175
+    return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
176
+    . "\n<ul class='liste-items sous-sous-rub'>\n"
177
+    . $retour
178
+    . "</ul>\n" . fin_block() . "\n\n";
179 179
 }
180 180
 
181 181
 /**
@@ -190,44 +190,44 @@  discard block
 block discarded – undo
190 190
  *  Le contenu textuel affiché, la liste des sous rubriques
191 191
  */
192 192
 function afficher_enfant_rub($id_rubrique = 0) {
193
-	$pagination = '';
194
-	$debut = 0;
195
-	$limite = 500;
196
-
197
-	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
198
-
199
-	if ($nb > $limite) {
200
-		$debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut;
201
-		$pagination = chercher_filtre('pagination');
202
-		$pagination = '<br class="nettoyeur"><p class="pagination">' .
203
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
204
-		'</p>';
205
-	}
206
-
207
-	$les_enfants = enfant_rub($id_rubrique, $debut, $limite);
208
-
209
-	if (!$n = count($les_enfants)) {
210
-		return '';
211
-	}
212
-
213
-	if ($n == 1) {
214
-		$les_enfants = reset($les_enfants);
215
-		$les_enfants2 = '';
216
-	} else {
217
-		$n = ceil($n / 2);
218
-		$les_enfants2 = implode('', array_slice($les_enfants, $n));
219
-		$les_enfants = implode('', array_slice($les_enfants, 0, $n));
220
-	}
221
-
222
-	$res =
223
-		$pagination
224
-		. "<div class='gauche'>"
225
-		. $les_enfants
226
-		. '</div>'
227
-		. "<div class='droite'>"
228
-		. $les_enfants2
229
-		. '</div>'
230
-		. $pagination;
231
-
232
-	return $res;
193
+    $pagination = '';
194
+    $debut = 0;
195
+    $limite = 500;
196
+
197
+    $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
198
+
199
+    if ($nb > $limite) {
200
+        $debut = _request('debut_rubrique' . $id_rubrique) ? _request('debut_rubrique' . $id_rubrique) : $debut;
201
+        $pagination = chercher_filtre('pagination');
202
+        $pagination = '<br class="nettoyeur"><p class="pagination">' .
203
+            $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
204
+        '</p>';
205
+    }
206
+
207
+    $les_enfants = enfant_rub($id_rubrique, $debut, $limite);
208
+
209
+    if (!$n = count($les_enfants)) {
210
+        return '';
211
+    }
212
+
213
+    if ($n == 1) {
214
+        $les_enfants = reset($les_enfants);
215
+        $les_enfants2 = '';
216
+    } else {
217
+        $n = ceil($n / 2);
218
+        $les_enfants2 = implode('', array_slice($les_enfants, $n));
219
+        $les_enfants = implode('', array_slice($les_enfants, 0, $n));
220
+    }
221
+
222
+    $res =
223
+        $pagination
224
+        . "<div class='gauche'>"
225
+        . $les_enfants
226
+        . '</div>'
227
+        . "<div class='droite'>"
228
+        . $les_enfants2
229
+        . '</div>'
230
+        . $pagination;
231
+
232
+    return $res;
233 233
 }
Please login to merge, or discard this patch.