Completed
Push — master ( a0df01...3bc277 )
by cam
04:49
created
ecrire/inc/plonger.php 2 patches
Indentation   +81 added lines, -81 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/texte');
@@ -19,98 +19,98 @@  discard block
 block discarded – undo
19 19
 // https://code.spip.net/@inc_plonger_dist
20 20
 function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $exclu = 0, $do = 'aff') {
21 21
 
22
-	if ($list) {
23
-		$id_rubrique = $list[$col - 1];
24
-	}
22
+    if ($list) {
23
+        $id_rubrique = $list[$col - 1];
24
+    }
25 25
 
26
-	$ret = '';
26
+    $ret = '';
27 27
 
28
-	# recherche les filles et petites-filles de la rubrique donnee
29
-	# en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
30
-	# deplace une rubrique, on peut la deplacer partout a partir de la
31
-	# racine... sauf vers elle-meme ou sa propre branche)
32
-	$ordre = array();
33
-	$rub = array();
28
+    # recherche les filles et petites-filles de la rubrique donnee
29
+    # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
30
+    # deplace une rubrique, on peut la deplacer partout a partir de la
31
+    # racine... sauf vers elle-meme ou sa propre branche)
32
+    $ordre = array();
33
+    $rub = array();
34 34
 
35
-	$res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant",
36
-		"spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)",
37
-		"rub1.id_parent = " . sql_quote($id_rubrique) . "
35
+    $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant",
36
+        "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)",
37
+        "rub1.id_parent = " . sql_quote($id_rubrique) . "
38 38
 			AND rub1.id_rubrique!=" . sql_quote($exclu) . "
39 39
 			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu) . ")", "", "0+rub1.titre,rub1.titre");
40 40
 
41
-	while ($row = sql_fetch($res)) {
42
-		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
43
-			$rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
44
-			if ($row['id_parent'] == $id_rubrique) {
45
-				$t = trim(typo(supprimer_numero($row['titre'])));
46
-				if ($row['langue_choisie'] != 'oui') {
47
-					$t .= ' <small title="'
48
-						. traduire_nom_langue($row['lang'])
49
-						. '">[' . $row['lang'] . ']</small>';
50
-				}
51
-				$ordre[$row['id_rubrique']] = $t;
52
-			}
53
-		}
54
-	}
55
-	$next = isset($list[$col]) ? $list[$col] : 0;
56
-	if ($ordre) {
57
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
58
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
59
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
41
+    while ($row = sql_fetch($res)) {
42
+        if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
43
+            $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
44
+            if ($row['id_parent'] == $id_rubrique) {
45
+                $t = trim(typo(supprimer_numero($row['titre'])));
46
+                if ($row['langue_choisie'] != 'oui') {
47
+                    $t .= ' <small title="'
48
+                        . traduire_nom_langue($row['lang'])
49
+                        . '">[' . $row['lang'] . ']</small>';
50
+                }
51
+                $ordre[$row['id_rubrique']] = $t;
52
+            }
53
+        }
54
+    }
55
+    $next = isset($list[$col]) ? $list[$col] : 0;
56
+    if ($ordre) {
57
+        $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
58
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
59
+        $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
60 60
 
61
-		foreach ($ordre as $id => $titrebrut) {
62
-			$titre = supprimer_numero($titrebrut);
61
+        foreach ($ordre as $id => $titrebrut) {
62
+            $titre = supprimer_numero($titrebrut);
63 63
 
64
-			$classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur";
65
-			if (isset($rub[$id]["enfants"])) {
66
-				$classe2 = " class='rub-ouverte'";
67
-				$url = "\nhref='$rec&amp;id=$id'";
68
-			} else {
69
-				$classe2 = $url = '';
70
-				$url = "\nhref='javascript:void(0)'";
71
-			}
64
+            $classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur";
65
+            if (isset($rub[$id]["enfants"])) {
66
+                $classe2 = " class='rub-ouverte'";
67
+                $url = "\nhref='$rec&amp;id=$id'";
68
+            } else {
69
+                $classe2 = $url = '';
70
+                $url = "\nhref='javascript:void(0)'";
71
+            }
72 72
 
73
-			$js_func = $do . '_selection_titre';
74
-			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
75
-				. (!is_array($list) ? ' false'
76
-					: "aff_selection_provisoire($id,$args)")
73
+            $js_func = $do . '_selection_titre';
74
+            $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
75
+                . (!is_array($list) ? ' false'
76
+                    : "aff_selection_provisoire($id,$args)")
77 77
 # ce lien provoque la selection (directe) de la rubrique cliquee
78 78
 # et l'affichage de son titre dans le bandeau
79
-				. "\"\nondblclick=\""
80
-				. "$js_func(this."
81
-				. "firstChild.nodeValue,"
82
-				. $id
83
-				. ",'selection_rubrique','id_parent');"
84
-				. "\nreturn aff_selection_provisoire($id,$args);"
85
-				. "\"";
79
+                . "\"\nondblclick=\""
80
+                . "$js_func(this."
81
+                . "firstChild.nodeValue,"
82
+                . $id
83
+                . ",'selection_rubrique','id_parent');"
84
+                . "\nreturn aff_selection_provisoire($id,$args);"
85
+                . "\"";
86 86
 
87
-			$ret .= "<div class='"
88
-				. (($id == $next) ? "item on" : "item")
89
-				. "'><div class='"
90
-				. $classe1
91
-				. "'><div$classe2><a"
92
-				. $url
93
-				. $click
94
-				. ">"
95
-				. $titre
96
-				. "</a></div></div></div>";
97
-		}
98
-	}
87
+            $ret .= "<div class='"
88
+                . (($id == $next) ? "item on" : "item")
89
+                . "'><div class='"
90
+                . $classe1
91
+                . "'><div$classe2><a"
92
+                . $url
93
+                . $click
94
+                . ">"
95
+                . $titre
96
+                . "</a></div></div></div>";
97
+        }
98
+    }
99 99
 
100
-	$idom2 = $idom . "_col_" . ($col + 1);
101
-	$left = ($col * 150);
100
+    $idom2 = $idom . "_col_" . ($col + 1);
101
+    $left = ($col * 150);
102 102
 
103
-	return http_img_pack("loader.svg", "",
104
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": "
105
-		. ($left - 30)
106
-		. "px; top: 2px; z-index: 2;' id='img_$idom2'")
107
-	. "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": "
108
-	. ($left - 150)
109
-	. "px;'>"
110
-	. $ret
111
-	. "\n</div>\n<div id='$idom2'>"
112
-	. ($next
113
-		? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
114
-		: "")
115
-	. "\n</div>";
103
+    return http_img_pack("loader.svg", "",
104
+        "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": "
105
+        . ($left - 30)
106
+        . "px; top: 2px; z-index: 2;' id='img_$idom2'")
107
+    . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": "
108
+    . ($left - 150)
109
+    . "px;'>"
110
+    . $ret
111
+    . "\n</div>\n<div id='$idom2'>"
112
+    . ($next
113
+        ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
114
+        : "")
115
+    . "\n</div>";
116 116
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 
35 35
 	$res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant",
36 36
 		"spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)",
37
-		"rub1.id_parent = " . sql_quote($id_rubrique) . "
38
-			AND rub1.id_rubrique!=" . sql_quote($exclu) . "
39
-			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu) . ")", "", "0+rub1.titre,rub1.titre");
37
+		"rub1.id_parent = ".sql_quote($id_rubrique)."
38
+			AND rub1.id_rubrique!=" . sql_quote($exclu)."
39
+			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu).")", "", "0+rub1.titre,rub1.titre");
40 40
 
41 41
 	while ($row = sql_fetch($res)) {
42 42
 		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 				if ($row['langue_choisie'] != 'oui') {
47 47
 					$t .= ' <small title="'
48 48
 						. traduire_nom_langue($row['lang'])
49
-						. '">[' . $row['lang'] . ']</small>';
49
+						. '">['.$row['lang'].']</small>';
50 50
 				}
51 51
 				$ordre[$row['id_rubrique']] = $t;
52 52
 			}
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 	$next = isset($list[$col]) ? $list[$col] : 0;
56 56
 	if ($ordre) {
57
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
57
+		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1));
58 58
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
59
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
59
+		$args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event";
60 60
 
61 61
 		foreach ($ordre as $id => $titrebrut) {
62 62
 			$titre = supprimer_numero($titrebrut);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 				$url = "\nhref='javascript:void(0)'";
71 71
 			}
72 72
 
73
-			$js_func = $do . '_selection_titre';
73
+			$js_func = $do.'_selection_titre';
74 74
 			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
75 75
 				. (!is_array($list) ? ' false'
76 76
 					: "aff_selection_provisoire($id,$args)")
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 		}
98 98
 	}
99 99
 
100
-	$idom2 = $idom . "_col_" . ($col + 1);
100
+	$idom2 = $idom."_col_".($col + 1);
101 101
 	$left = ($col * 150);
102 102
 
103 103
 	return http_img_pack("loader.svg", "",
104
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": "
104
+		"class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].": "
105 105
 		. ($left - 30)
106 106
 		. "px; top: 2px; z-index: 2;' id='img_$idom2'")
107
-	. "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": "
107
+	. "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].": "
108 108
 	. ($left - 150)
109 109
 	. "px;'>"
110 110
 	. $ret
Please login to merge, or discard this patch.
ecrire/inc/headers.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -38,132 +38,132 @@  discard block
 block discarded – undo
38 38
  * @param int $status Code de redirection (301 ou 302)
39 39
  **/
40 40
 function redirige_par_entete($url, $equiv = '', $status = 302) {
41
-	if (!in_array($status, array(301, 302))) {
42
-		$status = 302;
43
-	}
44
-
45
-	$url = trim(strtr($url, "\n\r", "  "));
46
-	# si l'url de redirection est relative, on la passe en absolue
47
-	if (!preg_match(",^(\w+:)?//,", $url)) {
48
-		include_spip("inc/filtres_mini");
49
-		$url = url_absolue($url);
50
-	}
51
-
52
-	if (defined('_AJAX') and _AJAX) {
53
-		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
54
-	}
55
-
56
-	// ne pas laisser passer n'importe quoi dans l'url
57
-	$url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
58
-	$url = str_replace(array("\r", "\n", ' '), array('%0D', '%0A', '%20'), $url);
59
-	while (strpos($url, '%0A') !== false) {
60
-		$url = str_replace('%0A', '', $url);
61
-	}
62
-	// interdire les url inline avec des pseudo-protocoles :
63
-	if (
64
-		(preg_match(",data:,i", $url) and preg_match("/base64\s*,/i", $url))
65
-		or preg_match(",(javascript|mailto):,i", $url)
66
-	) {
67
-		$url = "./";
68
-	}
69
-
70
-	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
71
-	include_spip('inc/cookie');
72
-	if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) {
73
-		define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)');
74
-	}
75
-	if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) {
76
-		define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx');
77
-	}
78
-	if ((!$equiv and !spip_cookie_envoye()) or (
79
-			   (!empty($_SERVER['SERVER_SOFTWARE'])
80
-				   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
81
-				   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SOFTWARE']))
82
-			or (!empty($_SERVER['SERVER_SIGNATURE'])
83
-				   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
84
-				   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SIGNATURE']))
85
-			or function_exists('apache_getenv')
86
-			or defined('_SERVER_APACHE')
87
-		)
88
-	) {
89
-		@header("Location: " . $url);
90
-		$equiv = "";
91
-	} else {
92
-		@header("Refresh: 0; url=" . $url);
93
-		if (isset($GLOBALS['meta']['charset'])) {
94
-			@header("Content-Type: text/html; charset=" . $GLOBALS['meta']['charset']);
95
-		}
96
-		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
97
-	}
98
-	include_spip('inc/lang');
99
-	if ($status != 302) {
100
-		http_status($status);
101
-	}
102
-	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n",
103
-	html_lang_attributes(), '
41
+    if (!in_array($status, array(301, 302))) {
42
+        $status = 302;
43
+    }
44
+
45
+    $url = trim(strtr($url, "\n\r", "  "));
46
+    # si l'url de redirection est relative, on la passe en absolue
47
+    if (!preg_match(",^(\w+:)?//,", $url)) {
48
+        include_spip("inc/filtres_mini");
49
+        $url = url_absolue($url);
50
+    }
51
+
52
+    if (defined('_AJAX') and _AJAX) {
53
+        $url = parametre_url($url, 'var_ajax_redir', 1, '&');
54
+    }
55
+
56
+    // ne pas laisser passer n'importe quoi dans l'url
57
+    $url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
58
+    $url = str_replace(array("\r", "\n", ' '), array('%0D', '%0A', '%20'), $url);
59
+    while (strpos($url, '%0A') !== false) {
60
+        $url = str_replace('%0A', '', $url);
61
+    }
62
+    // interdire les url inline avec des pseudo-protocoles :
63
+    if (
64
+        (preg_match(",data:,i", $url) and preg_match("/base64\s*,/i", $url))
65
+        or preg_match(",(javascript|mailto):,i", $url)
66
+    ) {
67
+        $url = "./";
68
+    }
69
+
70
+    // Il n'y a que sous Apache que setcookie puis redirection fonctionne
71
+    include_spip('inc/cookie');
72
+    if (!defined('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE')) {
73
+        define('_SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE', '^(Apache|Cherokee|nginx)');
74
+    }
75
+    if (!defined('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE')) {
76
+        define('_SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE', 'Apache|Cherokee|nginx');
77
+    }
78
+    if ((!$equiv and !spip_cookie_envoye()) or (
79
+                (!empty($_SERVER['SERVER_SOFTWARE'])
80
+                   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
81
+                   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SOFTWARE']))
82
+            or (!empty($_SERVER['SERVER_SIGNATURE'])
83
+                   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
84
+                   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SIGNATURE']))
85
+            or function_exists('apache_getenv')
86
+            or defined('_SERVER_APACHE')
87
+        )
88
+    ) {
89
+        @header("Location: " . $url);
90
+        $equiv = "";
91
+    } else {
92
+        @header("Refresh: 0; url=" . $url);
93
+        if (isset($GLOBALS['meta']['charset'])) {
94
+            @header("Content-Type: text/html; charset=" . $GLOBALS['meta']['charset']);
95
+        }
96
+        $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
97
+    }
98
+    include_spip('inc/lang');
99
+    if ($status != 302) {
100
+        http_status($status);
101
+    }
102
+    echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">', "\n",
103
+    html_lang_attributes(), '
104 104
 <head>',
105
-	$equiv, '
105
+    $equiv, '
106 106
 <title>HTTP ' . $status . '</title>
107 107
 ' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . '
108 108
 </head>
109 109
 <body>
110 110
 <h1>HTTP ' . $status . '</h1>
111 111
 <a href="',
112
-	quote_amp($url),
113
-	'">',
114
-	_T('navigateur_pas_redirige'),
115
-	'</a></body></html>';
112
+    quote_amp($url),
113
+    '">',
114
+    _T('navigateur_pas_redirige'),
115
+    '</a></body></html>';
116 116
 
117
-	spip_log("redirige $status: $url");
117
+    spip_log("redirige $status: $url");
118 118
 
119
-	exit;
119
+    exit;
120 120
 }
121 121
 
122 122
 // https://code.spip.net/@redirige_formulaire
123 123
 function redirige_formulaire($url, $equiv = '', $format = 'message') {
124
-	if (!_AJAX
125
-		and !headers_sent()
126
-		and !_request('var_ajax')
127
-	) {
128
-		redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
129
-	} // si c'est une ancre, fixer simplement le window.location.hash
130
-	elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
131
-		return array(
132
-			// on renvoie un lien masque qui sera traite par ajaxCallback.js
133
-			"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
134
-			// et rien dans le message ok
135
-			''
136
-		);
137
-	} else {
138
-		// ne pas laisser passer n'importe quoi dans l'url
139
-		$url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
140
-
141
-		$url = strtr($url, "\n\r", "  ");
142
-		# en theorie on devrait faire ca tout le temps, mais quand la chaine
143
-		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
144
-		if ($url[0] == '?') {
145
-			$url = url_de_base() . $url;
146
-		}
147
-		$url = str_replace('&amp;', '&', $url);
148
-		spip_log("redirige formulaire ajax: $url");
149
-		include_spip('inc/filtres');
150
-		if ($format == 'ajaxform') {
151
-			return array(
152
-				// on renvoie un lien masque qui sera traite par ajaxCallback.js
153
-				'<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
154
-				// et un message au cas ou
155
-				'<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
156
-			);
157
-		} else // format message texte, tout en js inline
158
-		{
159
-			return
160
-				// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
161
-				"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
162
-				. http_img_pack('loader.svg', '', " class='loader'")
163
-				. '<br />'
164
-				. '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
165
-		}
166
-	}
124
+    if (!_AJAX
125
+        and !headers_sent()
126
+        and !_request('var_ajax')
127
+    ) {
128
+        redirige_par_entete(str_replace('&amp;', '&', $url), $equiv);
129
+    } // si c'est une ancre, fixer simplement le window.location.hash
130
+    elseif ($format == 'ajaxform' and preg_match(',^#[0-9a-z\-_]+$,i', $url)) {
131
+        return array(
132
+            // on renvoie un lien masque qui sera traite par ajaxCallback.js
133
+            "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
134
+            // et rien dans le message ok
135
+            ''
136
+        );
137
+    } else {
138
+        // ne pas laisser passer n'importe quoi dans l'url
139
+        $url = str_replace(array('<', '"'), array('&lt;', '&quot;'), $url);
140
+
141
+        $url = strtr($url, "\n\r", "  ");
142
+        # en theorie on devrait faire ca tout le temps, mais quand la chaine
143
+        # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
144
+        if ($url[0] == '?') {
145
+            $url = url_de_base() . $url;
146
+        }
147
+        $url = str_replace('&amp;', '&', $url);
148
+        spip_log("redirige formulaire ajax: $url");
149
+        include_spip('inc/filtres');
150
+        if ($format == 'ajaxform') {
151
+            return array(
152
+                // on renvoie un lien masque qui sera traite par ajaxCallback.js
153
+                '<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
154
+                // et un message au cas ou
155
+                '<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
156
+            );
157
+        } else // format message texte, tout en js inline
158
+        {
159
+            return
160
+                // ie poste les formulaires dans une iframe, il faut donc rediriger son parent
161
+                "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
162
+                . http_img_pack('loader.svg', '', " class='loader'")
163
+                . '<br />'
164
+                . '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
165
+        }
166
+    }
167 167
 }
168 168
 
169 169
 /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
  * @return void
185 185
  **/
186 186
 function redirige_url_ecrire($script = '', $args = '', $equiv = '') {
187
-	return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
187
+    return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
188 188
 }
189 189
 
190 190
 /**
@@ -199,50 +199,50 @@  discard block
 block discarded – undo
199 199
  **/
200 200
 function http_status($status) {
201 201
 
202
-	static $status_string = array(
203
-		200 => '200 OK',
204
-		204 => '204 No Content',
205
-		301 => '301 Moved Permanently',
206
-		302 => '302 Found',
207
-		304 => '304 Not Modified',
208
-		400 => '400 Bad Request',
209
-		401 => '401 Unauthorized',
210
-		403 => '403 Forbidden',
211
-		404 => '404 Not Found',
212
-		503 => '503 Service Unavailable'
213
-	);
214
-
215
-	if (!empty($GLOBALS['REDIRECT_STATUS']) && $GLOBALS['REDIRECT_STATUS'] == $status) {
216
-		return;
217
-	}
218
-
219
-	$php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
220
-	if ($php_cgi) {
221
-		header("Status: " . $status_string[$status]);
222
-	} else {
223
-		header("HTTP/1.0 " . $status_string[$status]);
224
-	}
202
+    static $status_string = array(
203
+        200 => '200 OK',
204
+        204 => '204 No Content',
205
+        301 => '301 Moved Permanently',
206
+        302 => '302 Found',
207
+        304 => '304 Not Modified',
208
+        400 => '400 Bad Request',
209
+        401 => '401 Unauthorized',
210
+        403 => '403 Forbidden',
211
+        404 => '404 Not Found',
212
+        503 => '503 Service Unavailable'
213
+    );
214
+
215
+    if (!empty($GLOBALS['REDIRECT_STATUS']) && $GLOBALS['REDIRECT_STATUS'] == $status) {
216
+        return;
217
+    }
218
+
219
+    $php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
220
+    if ($php_cgi) {
221
+        header("Status: " . $status_string[$status]);
222
+    } else {
223
+        header("HTTP/1.0 " . $status_string[$status]);
224
+    }
225 225
 }
226 226
 
227 227
 // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
228 228
 // https://code.spip.net/@http_no_cache
229 229
 function http_no_cache() {
230
-	if (headers_sent()) {
231
-		spip_log("http_no_cache arrive trop tard");
232
-
233
-		return;
234
-	}
235
-	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
236
-
237
-	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
238
-	// il faudrait aussi pour Safari
239
-	// header("Cache-Control: post-check=0, pre-check=0", false)
240
-	// mais ca ne respecte pas
241
-	// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
242
-
243
-	header("Content-Type: text/html; charset=$charset");
244
-	header("Expires: 0");
245
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
246
-	header("Cache-Control: no-cache, must-revalidate");
247
-	header("Pragma: no-cache");
230
+    if (headers_sent()) {
231
+        spip_log("http_no_cache arrive trop tard");
232
+
233
+        return;
234
+    }
235
+    $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
236
+
237
+    // selon http://developer.apple.com/internet/safari/faq.html#anchor5
238
+    // il faudrait aussi pour Safari
239
+    // header("Cache-Control: post-check=0, pre-check=0", false)
240
+    // mais ca ne respecte pas
241
+    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
242
+
243
+    header("Content-Type: text/html; charset=$charset");
244
+    header("Expires: 0");
245
+    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
246
+    header("Cache-Control: no-cache, must-revalidate");
247
+    header("Pragma: no-cache");
248 248
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	if ((!$equiv and !spip_cookie_envoye()) or (
79 79
 			   (!empty($_SERVER['SERVER_SOFTWARE'])
80 80
 				   and _SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE
81
-				   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SOFTWARE']))
81
+				   and preg_match("/"._SERVEUR_SOFTWARE_ACCEPTE_LOCATION_APRES_COOKIE."/i", $_SERVER['SERVER_SOFTWARE']))
82 82
 			or (!empty($_SERVER['SERVER_SIGNATURE'])
83 83
 				   and _SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE
84
-				   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i",$_SERVER['SERVER_SIGNATURE']))
84
+				   and preg_match("/"._SERVEUR_SIGNATURE_ACCEPTE_LOCATION_APRES_COOKIE."/i", $_SERVER['SERVER_SIGNATURE']))
85 85
 			or function_exists('apache_getenv')
86 86
 			or defined('_SERVER_APACHE')
87 87
 		)
88 88
 	) {
89
-		@header("Location: " . $url);
89
+		@header("Location: ".$url);
90 90
 		$equiv = "";
91 91
 	} else {
92
-		@header("Refresh: 0; url=" . $url);
92
+		@header("Refresh: 0; url=".$url);
93 93
 		if (isset($GLOBALS['meta']['charset'])) {
94
-			@header("Content-Type: text/html; charset=" . $GLOBALS['meta']['charset']);
94
+			@header("Content-Type: text/html; charset=".$GLOBALS['meta']['charset']);
95 95
 		}
96 96
 		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
97 97
 	}
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	html_lang_attributes(), '
104 104
 <head>',
105 105
 	$equiv, '
106
-<title>HTTP ' . $status . '</title>
107
-' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset=' . $GLOBALS['meta']['charset'] . '">' : '') . '
106
+<title>HTTP ' . $status.'</title>
107
+' . ((isset($GLOBALS['meta']['charset'])) ? '<meta http-equiv="Content-Type" content="text/html;charset='.$GLOBALS['meta']['charset'].'">' : '').'
108 108
 </head>
109 109
 <body>
110
-<h1>HTTP ' . $status . '</h1>
110
+<h1>HTTP ' . $status.'</h1>
111 111
 <a href="',
112 112
 	quote_amp($url),
113 113
 	'">',
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		# en theorie on devrait faire ca tout le temps, mais quand la chaine
143 143
 		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
144 144
 		if ($url[0] == '?') {
145
-			$url = url_de_base() . $url;
145
+			$url = url_de_base().$url;
146 146
 		}
147 147
 		$url = str_replace('&amp;', '&', $url);
148 148
 		spip_log("redirige formulaire ajax: $url");
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 		if ($format == 'ajaxform') {
151 151
 			return array(
152 152
 				// on renvoie un lien masque qui sera traite par ajaxCallback.js
153
-				'<a href="' . quote_amp($url) . '" name="ajax_redirect"  style="display:none;">' . _T('navigateur_pas_redirige') . '</a>',
153
+				'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
154 154
 				// et un message au cas ou
155
-				'<br /><a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>'
155
+				'<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
156 156
 			);
157 157
 		} else // format message texte, tout en js inline
158 158
 		{
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
162 162
 				. http_img_pack('loader.svg', '', " class='loader'")
163 163
 				. '<br />'
164
-				. '<a href="' . quote_amp($url) . '">' . _T('navigateur_pas_redirige') . '</a>';
164
+				. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
165 165
 		}
166 166
 	}
167 167
 }
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
 	$php_cgi = ($GLOBALS['flag_sapi_name'] and preg_match(",cgi,i", @php_sapi_name()));
220 220
 	if ($php_cgi) {
221
-		header("Status: " . $status_string[$status]);
221
+		header("Status: ".$status_string[$status]);
222 222
 	} else {
223
-		header("HTTP/1.0 " . $status_string[$status]);
223
+		header("HTTP/1.0 ".$status_string[$status]);
224 224
 	}
225 225
 }
226 226
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 	header("Content-Type: text/html; charset=$charset");
244 244
 	header("Expires: 0");
245
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
245
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
246 246
 	header("Cache-Control: no-cache, must-revalidate");
247 247
 	header("Pragma: no-cache");
248 248
 }
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/filtres');
@@ -46,47 +46,47 @@  discard block
 block discarded – undo
46 46
  **/
47 47
 function inc_selectionner_dist($sel, $idom = "", $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
48 48
 
49
-	if ($recur) {
50
-		$recur = mini_hier($sel);
51
-	} else {
52
-		$sel = 0;
53
-	}
49
+    if ($recur) {
50
+        $recur = mini_hier($sel);
51
+    } else {
52
+        $sel = 0;
53
+    }
54 54
 
55
-	if ($aff_racine) {
56
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
57
-		$idom3 = $idom . "_selection";
55
+    if ($aff_racine) {
56
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
57
+        $idom3 = $idom . "_selection";
58 58
 
59
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
60 60
 
61
-		$ondbClick = strtr(str_replace("'", "&#8217;",
62
-			str_replace('"', "&#34;",
63
-				textebrut(_T('info_racine_site')))),
64
-			"\n\r", "  ");
61
+        $ondbClick = strtr(str_replace("'", "&#8217;",
62
+            str_replace('"', "&#34;",
63
+                textebrut(_T('info_racine_site')))),
64
+            "\n\r", "  ");
65 65
 
66
-		$js_func = $do . '_selection_titre';
67
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
66
+        $js_func = $do . '_selection_titre';
67
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
68 68
 
69
-		$aff_racine = "<div class='petite-racine item'>"
70
-			. "<a href='#'"
71
-			. "onclick=\""
72
-			. $onClick
73
-			. "\"\nondbclick=\""
74
-			. $ondbClick
75
-			. $onClick
76
-			. "\">"
77
-			. _T("info_racine_site")
78
-			. "</a></div>";
79
-	}
69
+        $aff_racine = "<div class='petite-racine item'>"
70
+            . "<a href='#'"
71
+            . "onclick=\""
72
+            . $onClick
73
+            . "\"\nondbclick=\""
74
+            . $ondbClick
75
+            . $onClick
76
+            . "\">"
77
+            . _T("info_racine_site")
78
+            . "</a></div>";
79
+    }
80 80
 
81
-	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
81
+    $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
82 82
 
83
-	$plonger = charger_fonction('plonger', 'inc');
84
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
83
+    $plonger = charger_fonction('plonger', 'inc');
84
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
85 85
 
86
-	// url completee par la fonction JS onkeypress_rechercher
87
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
86
+    // url completee par la fonction JS onkeypress_rechercher
87
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
88 88
 
89
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
89
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
90 90
 }
91 91
 
92 92
 /**
@@ -104,55 +104,55 @@  discard block
 block discarded – undo
104 104
  **/
105 105
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
106 106
 
107
-	$idom1 = $idom . "_champ_recherche";
108
-	$idom2 = $idom . "_principal";
109
-	$idom3 = $idom . "_selection";
110
-	$idom4 = $idom . "_col_1";
111
-	$idom5 = 'img_' . $idom4;
112
-	$idom6 = $idom . "_fonc";
113
-
114
-	return "<div id='$idom'>"
115
-	. "<a id='$idom6' style='visibility: hidden;'"
116
-	. ($url_init ? "\nhref='$url_init'" : '')
117
-	. "></a>"
118
-	. "<div class='recherche_rapide_parent'>"
119
-	. http_img_pack("loader.svg", "",
120
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'")
121
-	. ""
122
-	. "<input style='width: 100px;float:" . $GLOBALS['spip_lang_right'] . ";' type='search' id='$idom1'"
123
-	// eliminer Return car il provoque la soumission (balise unique)
124
-	// et eliminer Tab pour la navigation au clavier
125
-	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
126
-	// resultats retournes par la recherche
127
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
128
-	// lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
129
-	. "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
130
-	// la destination de la recherche
131
-	. "'$idom4'"
107
+    $idom1 = $idom . "_champ_recherche";
108
+    $idom2 = $idom . "_principal";
109
+    $idom3 = $idom . "_selection";
110
+    $idom4 = $idom . "_col_1";
111
+    $idom5 = 'img_' . $idom4;
112
+    $idom6 = $idom . "_fonc";
113
+
114
+    return "<div id='$idom'>"
115
+    . "<a id='$idom6' style='visibility: hidden;'"
116
+    . ($url_init ? "\nhref='$url_init'" : '')
117
+    . "></a>"
118
+    . "<div class='recherche_rapide_parent'>"
119
+    . http_img_pack("loader.svg", "",
120
+        "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'")
121
+    . ""
122
+    . "<input style='width: 100px;float:" . $GLOBALS['spip_lang_right'] . ";' type='search' id='$idom1'"
123
+    // eliminer Return car il provoque la soumission (balise unique)
124
+    // et eliminer Tab pour la navigation au clavier
125
+    // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
126
+    // resultats retournes par la recherche
127
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
128
+    // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
129
+    . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
130
+    // la destination de la recherche
131
+    . "'$idom4'"
132 132
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
133
-	. ",'"
134
-	// l'url effectuant la recherche
135
-	. $url
136
-	. "',"
137
-	// le noeud contenant un gif anime
138
-	// . "'idom5'"
139
-	. "this.parentNode.previousSibling.firstChild"
140
-	. ",'"
141
-	// la valeur de l'attribut Name a remplir
142
-	. $name
143
-	. "','"
144
-	// noeud invisible memorisant l'URL initiale (pour re-initialisation)
145
-	. $idom6
146
-	. "')\""
147
-	. " />"
148
-	. "\n</div>"
149
-	. ($racine ? "<div>$racine</div>" : "")
150
-	. "<div id='"
151
-	. $idom2
152
-	. "'><div id='$idom4'"
153
-	. " class=''>"
154
-	. $liste
155
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
133
+    . ",'"
134
+    // l'url effectuant la recherche
135
+    . $url
136
+    . "',"
137
+    // le noeud contenant un gif anime
138
+    // . "'idom5'"
139
+    . "this.parentNode.previousSibling.firstChild"
140
+    . ",'"
141
+    // la valeur de l'attribut Name a remplir
142
+    . $name
143
+    . "','"
144
+    // noeud invisible memorisant l'URL initiale (pour re-initialisation)
145
+    . $idom6
146
+    . "')\""
147
+    . " />"
148
+    . "\n</div>"
149
+    . ($racine ? "<div>$racine</div>" : "")
150
+    . "<div id='"
151
+    . $idom2
152
+    . "'><div id='$idom4'"
153
+    . " class=''>"
154
+    . $liste
155
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
156 156
 }
157 157
 
158 158
 /**
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
  **/
165 165
 function mini_hier($id_rubrique) {
166 166
 
167
-	$liste = $id_rubrique;
168
-	$id_rubrique = intval($id_rubrique);
169
-	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) {
170
-		$liste = $id_rubrique . ",$liste";
171
-	}
167
+    $liste = $id_rubrique;
168
+    $id_rubrique = intval($id_rubrique);
169
+    while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) {
170
+        $liste = $id_rubrique . ",$liste";
171
+    }
172 172
 
173
-	return explode(',', "0,$liste");
173
+    return explode(',', "0,$liste");
174 174
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 	if ($aff_racine) {
56 56
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
57
-		$idom3 = $idom . "_selection";
57
+		$idom3 = $idom."_selection";
58 58
 
59 59
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 				textebrut(_T('info_racine_site')))),
64 64
 			"\n\r", "  ");
65 65
 
66
-		$js_func = $do . '_selection_titre';
66
+		$js_func = $do.'_selection_titre';
67 67
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
68 68
 
69 69
 		$aff_racine = "<div class='petite-racine item'>"
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
  **/
105 105
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
106 106
 
107
-	$idom1 = $idom . "_champ_recherche";
108
-	$idom2 = $idom . "_principal";
109
-	$idom3 = $idom . "_selection";
110
-	$idom4 = $idom . "_col_1";
111
-	$idom5 = 'img_' . $idom4;
112
-	$idom6 = $idom . "_fonc";
107
+	$idom1 = $idom."_champ_recherche";
108
+	$idom2 = $idom."_principal";
109
+	$idom3 = $idom."_selection";
110
+	$idom4 = $idom."_col_1";
111
+	$idom5 = 'img_'.$idom4;
112
+	$idom6 = $idom."_fonc";
113 113
 
114 114
 	return "<div id='$idom'>"
115 115
 	. "<a id='$idom6' style='visibility: hidden;'"
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	. "></a>"
118 118
 	. "<div class='recherche_rapide_parent'>"
119 119
 	. http_img_pack("loader.svg", "",
120
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'")
120
+		"class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'")
121 121
 	. ""
122
-	. "<input style='width: 100px;float:" . $GLOBALS['spip_lang_right'] . ";' type='search' id='$idom1'"
122
+	. "<input style='width: 100px;float:".$GLOBALS['spip_lang_right'].";' type='search' id='$idom1'"
123 123
 	// eliminer Return car il provoque la soumission (balise unique)
124 124
 	// et eliminer Tab pour la navigation au clavier
125 125
 	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 
167 167
 	$liste = $id_rubrique;
168 168
 	$id_rubrique = intval($id_rubrique);
169
-	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) {
170
-		$liste = $id_rubrique . ",$liste";
169
+	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = ".$id_rubrique)) {
170
+		$liste = $id_rubrique.",$liste";
171 171
 	}
172 172
 
173 173
 	return explode(',', "0,$liste");
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 if (!defined('_SPIP_SELECT_RUBRIQUES')) {
25
-	/**
26
-	 * @var int Nombre de rubriques maximum du sélecteur de rubriques. 
27
-	 * Au delà, on bascule sur un sélecteur ajax.
28
-	 * mettre 100000 pour desactiver ajax 
29
-	 */
30
-	define('_SPIP_SELECT_RUBRIQUES', 20); 
25
+    /**
26
+     * @var int Nombre de rubriques maximum du sélecteur de rubriques. 
27
+     * Au delà, on bascule sur un sélecteur ajax.
28
+     * mettre 100000 pour desactiver ajax 
29
+     */
30
+    define('_SPIP_SELECT_RUBRIQUES', 20); 
31 31
 }
32 32
 
33 33
 /**
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
  *     Code HTML du sélecteur
56 56
  **/
57 57
 function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
58
-	if (sql_countsel('spip_rubriques') < 1) {
59
-		return '';
60
-	}
61
-
62
-	// Mode sans Ajax :
63
-	// - soit parce que le cookie ajax n'est pas la
64
-	// - soit parce qu'il y a peu de rubriques
65
-	if (_SPIP_AJAX < 1
66
-		or $type == 'breve'
67
-		or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
-	) {
69
-		return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
-	} else {
71
-		return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
-	}
58
+    if (sql_countsel('spip_rubriques') < 1) {
59
+        return '';
60
+    }
61
+
62
+    // Mode sans Ajax :
63
+    // - soit parce que le cookie ajax n'est pas la
64
+    // - soit parce qu'il y a peu de rubriques
65
+    if (_SPIP_AJAX < 1
66
+        or $type == 'breve'
67
+        or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
+    ) {
69
+        return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
+    } else {
71
+        return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
+    }
73 73
 
74 74
 }
75 75
 
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
  **/
88 88
 function style_menu_rubriques($i) {
89 89
 
90
-	$espace = '';
91
-	$style = '';
92
-	for ($count = 1; $count <= $i; $count++) {
93
-		$espace .= "&nbsp;&nbsp;&nbsp;&nbsp;";
94
-	}
95
-	if ($i == 1) {
96
-		$espace = "";
97
-	}
98
-	$class = "niveau_$i";
99
-
100
-	return array($class, $style, $espace);
90
+    $espace = '';
91
+    $style = '';
92
+    for ($count = 1; $count <= $i; $count++) {
93
+        $espace .= "&nbsp;&nbsp;&nbsp;&nbsp;";
94
+    }
95
+    if ($i == 1) {
96
+        $espace = "";
97
+    }
98
+    $class = "niveau_$i";
99
+
100
+    return array($class, $style, $espace);
101 101
 }
102 102
 
103 103
 /**
@@ -121,52 +121,52 @@  discard block
 block discarded – undo
121 121
  *     Code HTML du sélecteur
122 122
  **/
123 123
 function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) {
124
-	static $decalage_secteur;
125
-
126
-	// Si on a demande l'exclusion ne pas descendre dans la rubrique courante
127
-	if ($exclus > 0
128
-		and $root == $exclus
129
-	) {
130
-		return '';
131
-	}
132
-
133
-	// en fonction du niveau faire un affichage plus ou moins kikoo
134
-
135
-	// selected ?
136
-	$selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
137
-
138
-	// le style en fonction de la profondeur
139
-	list($class, $style, $espace) = style_menu_rubriques($niv);
140
-
141
-	$class .= " selec_rub";
142
-
143
-	// creer l'<option> pour la rubrique $root
144
-
145
-	if (isset($data[$root])) # pas de racine sauf pour les rubriques
146
-	{
147
-		$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148
-			. $data[$root]
149
-			. '</option>' . "\n";
150
-	} else {
151
-		$r = '';
152
-	}
153
-
154
-	// et le sous-menu pour ses enfants
155
-	$sous = '';
156
-	if (isset($enfants[$root])) {
157
-		foreach ($enfants[$root] as $sousrub) {
158
-			$sous .= sous_menu_rubriques($id_rubrique, $sousrub,
159
-				$niv + 1, $data, $enfants, $exclus, $restreint, $type);
160
-		}
161
-	}
162
-
163
-	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
164
-	if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) {
165
-		return $sous;
166
-	}
167
-
168
-	// et voila le travail
169
-	return $r . $sous;
124
+    static $decalage_secteur;
125
+
126
+    // Si on a demande l'exclusion ne pas descendre dans la rubrique courante
127
+    if ($exclus > 0
128
+        and $root == $exclus
129
+    ) {
130
+        return '';
131
+    }
132
+
133
+    // en fonction du niveau faire un affichage plus ou moins kikoo
134
+
135
+    // selected ?
136
+    $selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
137
+
138
+    // le style en fonction de la profondeur
139
+    list($class, $style, $espace) = style_menu_rubriques($niv);
140
+
141
+    $class .= " selec_rub";
142
+
143
+    // creer l'<option> pour la rubrique $root
144
+
145
+    if (isset($data[$root])) # pas de racine sauf pour les rubriques
146
+    {
147
+        $r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148
+            . $data[$root]
149
+            . '</option>' . "\n";
150
+    } else {
151
+        $r = '';
152
+    }
153
+
154
+    // et le sous-menu pour ses enfants
155
+    $sous = '';
156
+    if (isset($enfants[$root])) {
157
+        foreach ($enfants[$root] as $sousrub) {
158
+            $sous .= sous_menu_rubriques($id_rubrique, $sousrub,
159
+                $niv + 1, $data, $enfants, $exclus, $restreint, $type);
160
+        }
161
+    }
162
+
163
+    // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
164
+    if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) {
165
+        return $sous;
166
+    }
167
+
168
+    // et voila le travail
169
+    return $r . $sous;
170 170
 }
171 171
 
172 172
 /**
@@ -187,67 +187,67 @@  discard block
 block discarded – undo
187 187
  *     Code HTML du sélecteur
188 188
  **/
189 189
 function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
190
-	$data = array();
191
-	if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) {
192
-		$data[0] = _T('info_racine_site');
193
-	}
194
-	# premier choix = neant
195
-	# si auteur (rubriques restreintes)
196
-	# ou si creation avec id_rubrique=0
197
-	elseif ($type == 'auteur' or !$id_rubrique) {
198
-		$data[0] = '&nbsp;';
199
-	}
200
-
201
-	//
202
-	// creer une structure contenant toute l'arborescence
203
-	//
204
-
205
-	include_spip('base/abstract_sql');
206
-	$q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques",
207
-		($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre");
208
-	while ($r = sql_fetch($q)) {
209
-		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
210
-			// titre largeur maxi a 50
211
-			$titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50);
212
-			if ($GLOBALS['meta']['multi_rubriques'] == 'oui'
213
-				and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0)
214
-			) {
215
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
216
-			}
217
-			$data[$r['id_rubrique']] = $titre;
218
-			$enfants[$r['id_parent']][] = $r['id_rubrique'];
219
-			if ($id_rubrique == $r['id_rubrique']) {
220
-				$id_parent = $r['id_parent'];
221
-			}
222
-		}
223
-	}
224
-
225
-	// si une seule rubrique comme choix possible,
226
-	// inutile de mettre le selecteur sur un choix vide par defaut
227
-	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
228
-	if (count($data) == 2
229
-		and isset($data[0])
230
-		and !in_array($type, array('auteur', 'rubrique'))
231
-		and !$id_rubrique
232
-	) {
233
-		unset($data[0]);
234
-	}
235
-
236
-
237
-	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
238
-	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
239
-
240
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
241
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
242
-	} else {
243
-		$r = "<select" . $att . " size='1'>\n$opt</select>\n";
244
-	}
245
-
246
-	# message pour neuneus (a supprimer ?)
190
+    $data = array();
191
+    if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) {
192
+        $data[0] = _T('info_racine_site');
193
+    }
194
+    # premier choix = neant
195
+    # si auteur (rubriques restreintes)
196
+    # ou si creation avec id_rubrique=0
197
+    elseif ($type == 'auteur' or !$id_rubrique) {
198
+        $data[0] = '&nbsp;';
199
+    }
200
+
201
+    //
202
+    // creer une structure contenant toute l'arborescence
203
+    //
204
+
205
+    include_spip('base/abstract_sql');
206
+    $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques",
207
+        ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre");
208
+    while ($r = sql_fetch($q)) {
209
+        if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
210
+            // titre largeur maxi a 50
211
+            $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50);
212
+            if ($GLOBALS['meta']['multi_rubriques'] == 'oui'
213
+                and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0)
214
+            ) {
215
+                $titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
216
+            }
217
+            $data[$r['id_rubrique']] = $titre;
218
+            $enfants[$r['id_parent']][] = $r['id_rubrique'];
219
+            if ($id_rubrique == $r['id_rubrique']) {
220
+                $id_parent = $r['id_parent'];
221
+            }
222
+        }
223
+    }
224
+
225
+    // si une seule rubrique comme choix possible,
226
+    // inutile de mettre le selecteur sur un choix vide par defaut
227
+    // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
228
+    if (count($data) == 2
229
+        and isset($data[0])
230
+        and !in_array($type, array('auteur', 'rubrique'))
231
+        and !$id_rubrique
232
+    ) {
233
+        unset($data[0]);
234
+    }
235
+
236
+
237
+    $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
238
+    $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
239
+
240
+    if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
241
+        $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
242
+    } else {
243
+        $r = "<select" . $att . " size='1'>\n$opt</select>\n";
244
+    }
245
+
246
+    # message pour neuneus (a supprimer ?)
247 247
 #	if ($type != 'auteur' AND $type != 'breve')
248 248
 #		$r .= "\n<br />"._T('texte_rappel_selection_champs');
249 249
 
250
-	return $r;
250
+    return $r;
251 251
 }
252 252
 
253 253
 /**
@@ -281,26 +281,26 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
283 283
 
284
-	if ($id_rubrique) {
285
-		$titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
286
-	} else {
287
-		if ($type == 'auteur') {
288
-			$titre = '&nbsp;';
289
-		} else {
290
-			$titre = _T('info_racine_site');
291
-		}
292
-	}
284
+    if ($id_rubrique) {
285
+        $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
286
+    } else {
287
+        if ($type == 'auteur') {
288
+            $titre = '&nbsp;';
289
+        } else {
290
+            $titre = _T('info_racine_site');
291
+        }
292
+    }
293 293
 
294
-	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
295
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
294
+    $titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
295
+    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
296 296
 
297
-	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
298
-		. (!$idem ? '' : "&exclus=$idem")
299
-		. ($restreint ? "" : "&racine=oui")
300
-		. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
297
+    $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
298
+        . (!$idem ? '' : "&exclus=$idem")
299
+        . ($restreint ? "" : "&racine=oui")
300
+        . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
301 301
 
302 302
 
303
-	return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
303
+    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
304 304
 }
305 305
 
306 306
 /**
@@ -330,26 +330,26 @@  discard block
 block discarded – undo
330 330
  *     Code HTML du sélecteur de rubrique AJAX
331 331
  **/
332 332
 function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
333
-	$icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
334
-
335
-	return
336
-		"<div class='rubrique_actuelle'><a href='#' onclick=\""
337
-		. $js
338
-		. "return charger_node_url_si_vide('"
339
-		. $url
340
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'><img src='"
341
-		. chemin_image($icone)
342
-		. "'\nstyle='vertical-align: middle;' alt='" . attribut_html(_T('titre_image_selecteur')) . "' /></a><img src='"
343
-		. chemin_image('loader.svg')
344
-		. "' class='loader' id='img_"
345
-		. $idom
346
-		. "'\nstyle='visibility: hidden;' alt='*' />"
347
-		. "<input id='titreparent' name='titreparent'"
348
-		. $init
349
-		. " />"
350
-		. "<input type='hidden' id='$name' name='$name' value='"
351
-		. $id
352
-		. "' /><div class='nettoyeur'></div></div><div id='"
353
-		. $idom
354
-		. "'\nstyle='display: none;'></div>";
333
+    $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png';
334
+
335
+    return
336
+        "<div class='rubrique_actuelle'><a href='#' onclick=\""
337
+        . $js
338
+        . "return charger_node_url_si_vide('"
339
+        . $url
340
+        . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'><img src='"
341
+        . chemin_image($icone)
342
+        . "'\nstyle='vertical-align: middle;' alt='" . attribut_html(_T('titre_image_selecteur')) . "' /></a><img src='"
343
+        . chemin_image('loader.svg')
344
+        . "' class='loader' id='img_"
345
+        . $idom
346
+        . "'\nstyle='visibility: hidden;' alt='*' />"
347
+        . "<input id='titreparent' name='titreparent'"
348
+        . $init
349
+        . " />"
350
+        . "<input type='hidden' id='$name' name='$name' value='"
351
+        . $id
352
+        . "' /><div class='nettoyeur'></div></div><div id='"
353
+        . $idom
354
+        . "'\nstyle='display: none;'></div>";
355 355
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	{
147 147
 		$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
148 148
 			. $data[$root]
149
-			. '</option>' . "\n";
149
+			. '</option>'."\n";
150 150
 	} else {
151 151
 		$r = '';
152 152
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	// et voila le travail
169
-	return $r . $sous;
169
+	return $r.$sous;
170 170
 }
171 171
 
172 172
 /**
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	while ($r = sql_fetch($q)) {
209 209
 		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
210 210
 			// titre largeur maxi a 50
211
-			$titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50);
211
+			$titre = couper(supprimer_tags(typo($r['titre']))." ", 50);
212 212
 			if ($GLOBALS['meta']['multi_rubriques'] == 'oui'
213 213
 				and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0)
214 214
 			) {
215
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
215
+				$titre .= ' ['.traduire_nom_langue($r['lang']).']';
216 216
 			}
217 217
 			$data[$r['id_rubrique']] = $titre;
218 218
 			$enfants[$r['id_parent']][] = $r['id_rubrique'];
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
239 239
 
240 240
 	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
241
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
241
+		$r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
242 242
 	} else {
243
-		$r = "<select" . $att . " size='1'>\n$opt</select>\n";
243
+		$r = "<select".$att." size='1'>\n$opt</select>\n";
244 244
 	}
245 245
 
246 246
 	# message pour neuneus (a supprimer ?)
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
283 283
 
284 284
 	if ($id_rubrique) {
285
-		$titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
285
+		$titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique));
286 286
 	} else {
287 287
 		if ($type == 'auteur') {
288 288
 			$titre = '&nbsp;';
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	}
293 293
 
294 294
 	$titre = str_replace('&amp;', '&', entites_html(textebrut(typo($titre))));
295
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
295
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
296 296
 
297 297
 	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
298 298
 		. (!$idem ? '' : "&exclus=$idem")
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 		. $js
338 338
 		. "return charger_node_url_si_vide('"
339 339
 		. $url
340
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'><img src='"
340
+		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'><img src='"
341 341
 		. chemin_image($icone)
342
-		. "'\nstyle='vertical-align: middle;' alt='" . attribut_html(_T('titre_image_selecteur')) . "' /></a><img src='"
342
+		. "'\nstyle='vertical-align: middle;' alt='".attribut_html(_T('titre_image_selecteur'))."' /></a><img src='"
343 343
 		. chemin_image('loader.svg')
344 344
 		. "' class='loader' id='img_"
345 345
 		. $idom
Please login to merge, or discard this patch.
ecrire/base/upgrade.php 2 patches
Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 if (!defined('_UPGRADE_TIME_OUT')) {
24
-	/**
25
-	 * Durée en secondes pour relancer les scripts de mises à jour, x secondes
26
-	 * avant que la durée d'exécution du script provoque un timeout
27
-	 *
28
-	 * @var int
29
-	 **/
30
-	define('_UPGRADE_TIME_OUT', 20);
24
+    /**
25
+     * Durée en secondes pour relancer les scripts de mises à jour, x secondes
26
+     * avant que la durée d'exécution du script provoque un timeout
27
+     *
28
+     * @var int
29
+     **/
30
+    define('_UPGRADE_TIME_OUT', 20);
31 31
 }
32 32
 
33 33
 /**
@@ -50,40 +50,40 @@  discard block
 block discarded – undo
50 50
  * @return void
51 51
  */
52 52
 function base_upgrade_dist($titre = '', $reprise = '') {
53
-	if (!$titre) {
54
-		return;
55
-	} // anti-testeur automatique
56
-	if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57
-		if (!is_numeric(_request('reinstall'))) {
58
-			include_spip('base/create');
59
-			spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
60
-			creer_base();
61
-		}
62
-
63
-		// quand on rentre par ici, c'est toujours une mise a jour de SPIP
64
-		// lancement de l'upgrade SPIP
65
-		$res = maj_base();
66
-
67
-		if ($res) {
68
-			// on arrete tout ici !
69
-			exit;
70
-		}
71
-	}
72
-	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
73
-
74
-	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75
-	@spip_unlink(_CACHE_RUBRIQUES);
76
-	@spip_unlink(_CACHE_PIPELINES);
77
-	@spip_unlink(_CACHE_PLUGINS_PATH);
78
-	@spip_unlink(_CACHE_PLUGINS_OPT);
79
-	@spip_unlink(_CACHE_PLUGINS_FCT);
80
-	@spip_unlink(_CACHE_CHEMIN);
81
-	@spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
82
-
83
-	include_spip('inc/auth');
84
-	auth_synchroniser_distant();
85
-	$config = charger_fonction('config', 'inc');
86
-	$config();
53
+    if (!$titre) {
54
+        return;
55
+    } // anti-testeur automatique
56
+    if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57
+        if (!is_numeric(_request('reinstall'))) {
58
+            include_spip('base/create');
59
+            spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
60
+            creer_base();
61
+        }
62
+
63
+        // quand on rentre par ici, c'est toujours une mise a jour de SPIP
64
+        // lancement de l'upgrade SPIP
65
+        $res = maj_base();
66
+
67
+        if ($res) {
68
+            // on arrete tout ici !
69
+            exit;
70
+        }
71
+    }
72
+    spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
73
+
74
+    // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75
+    @spip_unlink(_CACHE_RUBRIQUES);
76
+    @spip_unlink(_CACHE_PIPELINES);
77
+    @spip_unlink(_CACHE_PLUGINS_PATH);
78
+    @spip_unlink(_CACHE_PLUGINS_OPT);
79
+    @spip_unlink(_CACHE_PLUGINS_FCT);
80
+    @spip_unlink(_CACHE_CHEMIN);
81
+    @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
82
+
83
+    include_spip('inc/auth');
84
+    auth_synchroniser_distant();
85
+    $config = charger_fonction('config', 'inc');
86
+    $config();
87 87
 }
88 88
 
89 89
 /**
@@ -104,80 +104,80 @@  discard block
 block discarded – undo
104 104
  */
105 105
 function maj_base($version_cible = 0, $redirect = '', $debut_page = true) {
106 106
 
107
-	$version_installee = @$GLOBALS['meta']['version_installee'];
108
-	//
109
-	// Si version nulle ou inexistante, c'est une nouvelle installation
110
-	//   => ne pas passer par le processus de mise a jour.
111
-	// De meme en cas de version superieure: ca devait etre un test,
112
-	// il y a eu le message d'avertissement il doit savoir ce qu'il fait
113
-	//
114
-	// version_installee = 1.702; quand on a besoin de forcer une MAJ
115
-
116
-	spip_log(
117
-		"Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
118
-		'maj.' . _LOG_INFO_IMPORTANTE
119
-	);
120
-	if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
121
-		sql_replace(
122
-			'spip_meta',
123
-			array(
124
-				'nom' => 'version_installee',
125
-				'valeur' => $GLOBALS['spip_version_base'],
126
-				'impt' => 'non'
127
-			)
128
-		);
129
-		return false;
130
-	}
131
-	if (!upgrade_test()) {
132
-		return true;
133
-	}
134
-
135
-	$cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']);
136
-
137
-	if ($version_installee <= 1.926) {
138
-		$n = floor($version_installee * 10);
139
-		while ($n < 19) {
140
-			$nom = sprintf('v%03d', $n);
141
-			$f = charger_fonction($nom, 'maj/legacy', true);
142
-			if ($f) {
143
-				spip_log("$f repercute les modifications de la version " . ($n / 10), 'maj.' . _LOG_INFO_IMPORTANTE);
144
-				$f($version_installee, $GLOBALS['spip_version_base']);
145
-			} else {
146
-				spip_log("pas de fonction pour la maj $n $nom", 'maj.' . _LOG_INFO_IMPORTANTE);
147
-			}
148
-			$n++;
149
-		}
150
-		include_spip('maj/legacy/v019_pre193');
151
-		maj_legacy_v019_pre193($version_installee, $version_cible);
152
-	}
153
-	if ($version_installee < 2000) {
154
-		if ($version_installee < 2) {
155
-			$version_installee = $version_installee * 1000;
156
-		}
157
-		include_spip('maj/legacy/v019');
158
-	}
159
-	if ($cible < 2) {
160
-		$cible = $cible * 1000;
161
-	}
162
-
163
-	if ($version_installee < 2021010100) {
164
-		include_spip('maj/legacy/svn10000');
165
-	}
166
-
167
-	include_spip('maj/2021');
168
-
169
-	ksort($GLOBALS['maj']);
170
-	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
171
-	if ($res) {
172
-		if (!is_array($res)) {
173
-			spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
174
-		} else {
175
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
176
-			echo install_fin_html();
177
-		}
178
-	}
179
-
180
-	return $res;
107
+    $version_installee = @$GLOBALS['meta']['version_installee'];
108
+    //
109
+    // Si version nulle ou inexistante, c'est une nouvelle installation
110
+    //   => ne pas passer par le processus de mise a jour.
111
+    // De meme en cas de version superieure: ca devait etre un test,
112
+    // il y a eu le message d'avertissement il doit savoir ce qu'il fait
113
+    //
114
+    // version_installee = 1.702; quand on a besoin de forcer une MAJ
115
+
116
+    spip_log(
117
+        "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
118
+        'maj.' . _LOG_INFO_IMPORTANTE
119
+    );
120
+    if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
121
+        sql_replace(
122
+            'spip_meta',
123
+            array(
124
+                'nom' => 'version_installee',
125
+                'valeur' => $GLOBALS['spip_version_base'],
126
+                'impt' => 'non'
127
+            )
128
+        );
129
+        return false;
130
+    }
131
+    if (!upgrade_test()) {
132
+        return true;
133
+    }
134
+
135
+    $cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']);
136
+
137
+    if ($version_installee <= 1.926) {
138
+        $n = floor($version_installee * 10);
139
+        while ($n < 19) {
140
+            $nom = sprintf('v%03d', $n);
141
+            $f = charger_fonction($nom, 'maj/legacy', true);
142
+            if ($f) {
143
+                spip_log("$f repercute les modifications de la version " . ($n / 10), 'maj.' . _LOG_INFO_IMPORTANTE);
144
+                $f($version_installee, $GLOBALS['spip_version_base']);
145
+            } else {
146
+                spip_log("pas de fonction pour la maj $n $nom", 'maj.' . _LOG_INFO_IMPORTANTE);
147
+            }
148
+            $n++;
149
+        }
150
+        include_spip('maj/legacy/v019_pre193');
151
+        maj_legacy_v019_pre193($version_installee, $version_cible);
152
+    }
153
+    if ($version_installee < 2000) {
154
+        if ($version_installee < 2) {
155
+            $version_installee = $version_installee * 1000;
156
+        }
157
+        include_spip('maj/legacy/v019');
158
+    }
159
+    if ($cible < 2) {
160
+        $cible = $cible * 1000;
161
+    }
162
+
163
+    if ($version_installee < 2021010100) {
164
+        include_spip('maj/legacy/svn10000');
165
+    }
166
+
167
+    include_spip('maj/2021');
168
+
169
+    ksort($GLOBALS['maj']);
170
+    $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
171
+    if ($res) {
172
+        if (!is_array($res)) {
173
+            spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
174
+        } else {
175
+            echo _T('avis_operation_echec') . ' ' . join(' ', $res);
176
+            echo install_fin_html();
177
+        }
178
+    }
179
+
180
+    return $res;
181 181
 }
182 182
 
183 183
 /**
@@ -219,52 +219,52 @@  discard block
 block discarded – undo
219 219
  */
220 220
 function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') {
221 221
 
222
-	if ($table_meta !== 'meta') {
223
-		installer_table_meta($table_meta);
224
-	}
225
-
226
-	$current_version = null;
227
-
228
-	if ((!isset($GLOBALS[$table_meta][$nom_meta_base_version]))
229
-		|| (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '='))
230
-	) {
231
-		// $maj['create'] contient les directives propres a la premiere creation de base
232
-		// c'est une operation derogatoire qui fait aboutir directement dans la version_cible
233
-		if (isset($maj['create'])) {
234
-			if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
235
-				// installation : on ne fait que l'operation create
236
-				$maj = array('init' => $maj['create']);
237
-				// et on lui ajoute un appel a inc/config
238
-				// pour creer les metas par defaut
239
-				$config = charger_fonction('config', 'inc');
240
-				$maj[$version_cible] = array(array($config));
241
-			}
242
-			// dans tous les cas enlever cet index du tableau
243
-			unset($maj['create']);
244
-		}
245
-		// si init, deja dans le bon ordre
246
-		if (!isset($maj['init'])) {
247
-			include_spip('inc/plugin'); // pour spip_version_compare
248
-			uksort($maj, 'spip_version_compare');
249
-		}
250
-
251
-		// la redirection se fait par defaut sur la page d'administration des plugins
252
-		// sauf lorsque nous sommes sur l'installation de SPIP
253
-		// ou define _REDIRECT_MAJ_PLUGIN
254
-		$redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin'));
255
-		if (defined('_ECRIRE_INSTALL')) {
256
-			$redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
257
-		}
258
-
259
-		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
260
-		if ($res) {
261
-			if (!is_array($res)) {
262
-				spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
263
-			} else {
264
-				echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
265
-			}
266
-		}
267
-	}
222
+    if ($table_meta !== 'meta') {
223
+        installer_table_meta($table_meta);
224
+    }
225
+
226
+    $current_version = null;
227
+
228
+    if ((!isset($GLOBALS[$table_meta][$nom_meta_base_version]))
229
+        || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '='))
230
+    ) {
231
+        // $maj['create'] contient les directives propres a la premiere creation de base
232
+        // c'est une operation derogatoire qui fait aboutir directement dans la version_cible
233
+        if (isset($maj['create'])) {
234
+            if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) {
235
+                // installation : on ne fait que l'operation create
236
+                $maj = array('init' => $maj['create']);
237
+                // et on lui ajoute un appel a inc/config
238
+                // pour creer les metas par defaut
239
+                $config = charger_fonction('config', 'inc');
240
+                $maj[$version_cible] = array(array($config));
241
+            }
242
+            // dans tous les cas enlever cet index du tableau
243
+            unset($maj['create']);
244
+        }
245
+        // si init, deja dans le bon ordre
246
+        if (!isset($maj['init'])) {
247
+            include_spip('inc/plugin'); // pour spip_version_compare
248
+            uksort($maj, 'spip_version_compare');
249
+        }
250
+
251
+        // la redirection se fait par defaut sur la page d'administration des plugins
252
+        // sauf lorsque nous sommes sur l'installation de SPIP
253
+        // ou define _REDIRECT_MAJ_PLUGIN
254
+        $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin'));
255
+        if (defined('_ECRIRE_INSTALL')) {
256
+            $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape'));
257
+        }
258
+
259
+        $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
260
+        if ($res) {
261
+            if (!is_array($res)) {
262
+                spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
263
+            } else {
264
+                echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
265
+            }
266
+        }
267
+    }
268 268
 }
269 269
 
270 270
 /**
@@ -281,17 +281,17 @@  discard block
 block discarded – undo
281 281
  * @return void
282 282
  */
283 283
 function relance_maj($meta, $table, $redirect = '') {
284
-	include_spip('inc/headers');
285
-	if (!$redirect) {
286
-		// recuperer la valeur installee en cours
287
-		// on la tronque numeriquement, elle ne sert pas reellement
288
-		// sauf pour verifier que ce n'est pas oui ou non
289
-		// sinon is_numeric va echouer sur un numero de version 1.2.3
290
-		$installee = intval($GLOBALS[$table][$meta]);
291
-		$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
292
-	}
293
-	echo redirige_formulaire($redirect);
294
-	exit();
284
+    include_spip('inc/headers');
285
+    if (!$redirect) {
286
+        // recuperer la valeur installee en cours
287
+        // on la tronque numeriquement, elle ne sert pas reellement
288
+        // sauf pour verifier que ce n'est pas oui ou non
289
+        // sinon is_numeric va echouer sur un numero de version 1.2.3
290
+        $installee = intval($GLOBALS[$table][$meta]);
291
+        $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
292
+    }
293
+    echo redirige_formulaire($redirect);
294
+    exit();
295 295
 }
296 296
 
297 297
 /**
@@ -304,26 +304,26 @@  discard block
 block discarded – undo
304 304
  * @return void
305 305
  */
306 306
 function maj_debut_page($installee, $meta, $table) {
307
-	static $done = false;
308
-	if ($done) {
309
-		return;
310
-	}
311
-	include_spip('inc/minipres');
312
-	@ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure
313
-	$timeout = _UPGRADE_TIME_OUT * 2;
314
-	$titre = _T('titre_page_upgrade');
315
-	$balise_img = charger_filtre('balise_img');
316
-	$titre .= $balise_img(chemin_image('loader.svg'),'','loader');
317
-	echo(install_debut_html($titre));
318
-	// script de rechargement auto sur timeout
319
-	$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
320
-	echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
321
-	echo "<div style='text-align: left'>\n";
322
-	if (ob_get_level()) {
323
-		ob_flush();
324
-	}
325
-	flush();
326
-	$done = true;
307
+    static $done = false;
308
+    if ($done) {
309
+        return;
310
+    }
311
+    include_spip('inc/minipres');
312
+    @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure
313
+    $timeout = _UPGRADE_TIME_OUT * 2;
314
+    $titre = _T('titre_page_upgrade');
315
+    $balise_img = charger_filtre('balise_img');
316
+    $titre .= $balise_img(chemin_image('loader.svg'),'','loader');
317
+    echo(install_debut_html($titre));
318
+    // script de rechargement auto sur timeout
319
+    $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
320
+    echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
321
+    echo "<div style='text-align: left'>\n";
322
+    if (ob_get_level()) {
323
+        ob_flush();
324
+    }
325
+    flush();
326
+    $done = true;
327 327
 }
328 328
 
329 329
 
@@ -367,63 +367,63 @@  discard block
 block discarded – undo
367 367
  *    - tableau vide sinon.
368 368
  */
369 369
 function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) {
370
-	# inclusions pour que les procedures d'upgrade disposent des fonctions de base
371
-	include_spip('base/create');
372
-	include_spip('base/abstract_sql');
373
-	$trouver_table = charger_fonction('trouver_table', 'base');
374
-	include_spip('inc/plugin'); // pour spip_version_compare
375
-	$n = 0;
376
-	$time = time();
377
-
378
-	if (!defined('_TIME_OUT')) {
379
-		/**
380
-		 * Définir le timeout qui peut-être utilisé dans les fonctions
381
-		 * de mises à jour qui durent trop longtemps
382
-		 *
383
-		 * À utiliser tel que : `if (time() >= _TIME_OUT)`
384
-		 *
385
-		 * @var int
386
-		 */
387
-		define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
388
-	}
389
-
390
-	foreach ($maj as $v => $operations) {
391
-		// si une maj pour cette version
392
-		if ($v == 'init' or
393
-			(spip_version_compare($v, $installee, '>')
394
-				and spip_version_compare($v, $cible, '<='))
395
-		) {
396
-			if ($debut_page) {
397
-				maj_debut_page($v, $meta, $table);
398
-			}
399
-			echo "MAJ $v";
400
-			$etape = serie_alter($v, $operations, $meta, $table, $redirect);
401
-			$trouver_table(''); // vider le cache des descriptions de table
402
-			# echec sur une etape en cours ?
403
-			# on sort
404
-			if ($etape) {
405
-				return array($v, $etape);
406
-			}
407
-			$n = time() - $time;
408
-			spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
409
-			if ($meta) {
410
-				ecrire_meta($meta, $installee = $v, 'oui', $table);
411
-			}
412
-			echo '<br />';
413
-		}
414
-		if (time() >= _TIME_OUT) {
415
-			relance_maj($meta, $table, $redirect);
416
-		}
417
-	}
418
-	$trouver_table(''); // vider le cache des descriptions de table
419
-	// indispensable pour les chgt de versions qui n'ecrivent pas en base
420
-	// tant pis pour la redondance eventuelle avec ci-dessus
421
-	if ($meta) {
422
-		ecrire_meta($meta, $cible, 'oui', $table);
423
-	}
424
-	spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
425
-
426
-	return array();
370
+    # inclusions pour que les procedures d'upgrade disposent des fonctions de base
371
+    include_spip('base/create');
372
+    include_spip('base/abstract_sql');
373
+    $trouver_table = charger_fonction('trouver_table', 'base');
374
+    include_spip('inc/plugin'); // pour spip_version_compare
375
+    $n = 0;
376
+    $time = time();
377
+
378
+    if (!defined('_TIME_OUT')) {
379
+        /**
380
+         * Définir le timeout qui peut-être utilisé dans les fonctions
381
+         * de mises à jour qui durent trop longtemps
382
+         *
383
+         * À utiliser tel que : `if (time() >= _TIME_OUT)`
384
+         *
385
+         * @var int
386
+         */
387
+        define('_TIME_OUT', $time + _UPGRADE_TIME_OUT);
388
+    }
389
+
390
+    foreach ($maj as $v => $operations) {
391
+        // si une maj pour cette version
392
+        if ($v == 'init' or
393
+            (spip_version_compare($v, $installee, '>')
394
+                and spip_version_compare($v, $cible, '<='))
395
+        ) {
396
+            if ($debut_page) {
397
+                maj_debut_page($v, $meta, $table);
398
+            }
399
+            echo "MAJ $v";
400
+            $etape = serie_alter($v, $operations, $meta, $table, $redirect);
401
+            $trouver_table(''); // vider le cache des descriptions de table
402
+            # echec sur une etape en cours ?
403
+            # on sort
404
+            if ($etape) {
405
+                return array($v, $etape);
406
+            }
407
+            $n = time() - $time;
408
+            spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
409
+            if ($meta) {
410
+                ecrire_meta($meta, $installee = $v, 'oui', $table);
411
+            }
412
+            echo '<br />';
413
+        }
414
+        if (time() >= _TIME_OUT) {
415
+            relance_maj($meta, $table, $redirect);
416
+        }
417
+    }
418
+    $trouver_table(''); // vider le cache des descriptions de table
419
+    // indispensable pour les chgt de versions qui n'ecrivent pas en base
420
+    // tant pis pour la redondance eventuelle avec ci-dessus
421
+    if ($meta) {
422
+        ecrire_meta($meta, $cible, 'oui', $table);
423
+    }
424
+    spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
425
+
426
+    return array();
427 427
 }
428 428
 
429 429
 /**
@@ -446,52 +446,52 @@  discard block
 block discarded – undo
446 446
  * @return int
447 447
  */
448 448
 function serie_alter($serie, $q = array(), $meta = '', $table = 'meta', $redirect = '') {
449
-	$meta2 = $meta . '_maj_' . $serie;
450
-	$etape = 0;
451
-	if (isset($GLOBALS[$table][$meta2])) {
452
-		$etape = intval($GLOBALS[$table][$meta2]);
453
-	}
454
-	foreach ($q as $i => $r) {
455
-		if ($i >= $etape) {
456
-			$msg = "maj $table $meta2 etape $i";
457
-			if (is_array($r)
458
-				and function_exists($f = array_shift($r))
459
-			) {
460
-				// note: $r (arguments de la fonction $f) peut avoir des données tabulaires
461
-				spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
462
-				// pour les fonctions atomiques sql_xx
463
-				// on enregistre le meta avant de lancer la fonction,
464
-				// de maniere a eviter de boucler sur timeout
465
-				// mais pour les fonctions complexes,
466
-				// il faut les rejouer jusqu'a achevement.
467
-				// C'est a elle d'assurer qu'elles progressent a chaque rappel
468
-				if (strncmp($f, 'sql_', 4) == 0) {
469
-					ecrire_meta($meta2, $i + 1, 'non', $table);
470
-				}
471
-				echo " <span title='$i'>.</span>";
472
-				call_user_func_array($f, $r);
473
-				// si temps imparti depasse, on relance sans ecrire en meta
474
-				// car on est peut etre sorti sur timeout si c'est une fonction longue
475
-				if (time() >= _TIME_OUT) {
476
-					relance_maj($meta, $table, $redirect);
477
-				}
478
-				ecrire_meta($meta2, $i + 1, 'non', $table);
479
-				spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
480
-			} else {
481
-				if (!is_array($r)) {
482
-					spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
483
-				} else {
484
-					spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
485
-				}
486
-				// en cas d'erreur serieuse, on s'arrete
487
-				// mais on permet de passer par dessus en rechargeant la page.
488
-				return $i + 1;
489
-			}
490
-		}
491
-	}
492
-	effacer_meta($meta2, $table);
493
-
494
-	return 0;
449
+    $meta2 = $meta . '_maj_' . $serie;
450
+    $etape = 0;
451
+    if (isset($GLOBALS[$table][$meta2])) {
452
+        $etape = intval($GLOBALS[$table][$meta2]);
453
+    }
454
+    foreach ($q as $i => $r) {
455
+        if ($i >= $etape) {
456
+            $msg = "maj $table $meta2 etape $i";
457
+            if (is_array($r)
458
+                and function_exists($f = array_shift($r))
459
+            ) {
460
+                // note: $r (arguments de la fonction $f) peut avoir des données tabulaires
461
+                spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
462
+                // pour les fonctions atomiques sql_xx
463
+                // on enregistre le meta avant de lancer la fonction,
464
+                // de maniere a eviter de boucler sur timeout
465
+                // mais pour les fonctions complexes,
466
+                // il faut les rejouer jusqu'a achevement.
467
+                // C'est a elle d'assurer qu'elles progressent a chaque rappel
468
+                if (strncmp($f, 'sql_', 4) == 0) {
469
+                    ecrire_meta($meta2, $i + 1, 'non', $table);
470
+                }
471
+                echo " <span title='$i'>.</span>";
472
+                call_user_func_array($f, $r);
473
+                // si temps imparti depasse, on relance sans ecrire en meta
474
+                // car on est peut etre sorti sur timeout si c'est une fonction longue
475
+                if (time() >= _TIME_OUT) {
476
+                    relance_maj($meta, $table, $redirect);
477
+                }
478
+                ecrire_meta($meta2, $i + 1, 'non', $table);
479
+                spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
480
+            } else {
481
+                if (!is_array($r)) {
482
+                    spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
483
+                } else {
484
+                    spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
485
+                }
486
+                // en cas d'erreur serieuse, on s'arrete
487
+                // mais on permet de passer par dessus en rechargeant la page.
488
+                return $i + 1;
489
+            }
490
+        }
491
+    }
492
+    effacer_meta($meta2, $table);
493
+
494
+    return 0;
495 495
 }
496 496
 
497 497
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
  *
513 513
  **/
514 514
 function upgrade_types_documents() {
515
-	if (include_spip('base/medias')
516
-		and function_exists('creer_base_types_doc')
517
-	) {
518
-		creer_base_types_doc();
519
-	}
515
+    if (include_spip('base/medias')
516
+        and function_exists('creer_base_types_doc')
517
+    ) {
518
+        creer_base_types_doc();
519
+    }
520 520
 }
521 521
 
522 522
 /**
@@ -525,18 +525,18 @@  discard block
 block discarded – undo
525 525
  * @return bool True si possible.
526 526
  **/
527 527
 function upgrade_test() {
528
-	sql_drop_table('spip_test', true);
529
-	sql_create('spip_test', array('a' => 'int'));
530
-	sql_alter('TABLE spip_test ADD b INT');
531
-	sql_insertq('spip_test', array('b' => 1), array('field' => array('b' => 'int')));
532
-	$result = sql_select('b', 'spip_test');
533
-	// ne pas garder le resultat de la requete sinon sqlite3
534
-	// ne peut pas supprimer la table spip_test lors du sql_alter qui suit
535
-	// car cette table serait alors 'verouillee'
536
-	$result = $result ? true : false;
537
-	sql_alter('TABLE spip_test DROP b');
538
-
539
-	return $result;
528
+    sql_drop_table('spip_test', true);
529
+    sql_create('spip_test', array('a' => 'int'));
530
+    sql_alter('TABLE spip_test ADD b INT');
531
+    sql_insertq('spip_test', array('b' => 1), array('field' => array('b' => 'int')));
532
+    $result = sql_select('b', 'spip_test');
533
+    // ne pas garder le resultat de la requete sinon sqlite3
534
+    // ne peut pas supprimer la table spip_test lors du sql_alter qui suit
535
+    // car cette table serait alors 'verouillee'
536
+    $result = $result ? true : false;
537
+    sql_alter('TABLE spip_test DROP b');
538
+
539
+    return $result;
540 540
 }
541 541
 
542 542
 /**
@@ -551,19 +551,19 @@  discard block
 block discarded – undo
551 551
  * @return void
552 552
  **/
553 553
 function maj_version($version, $test = true) {
554
-	if ($test) {
555
-		if ($version >= 1.922) {
556
-			ecrire_meta('version_installee', $version, 'oui');
557
-		} else {
558
-			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
559
-			$GLOBALS['meta']['version_installee'] = $version;
560
-			sql_updateq('spip_meta', array('valeur' => $version), 'nom=' . sql_quote('version_installee'));
561
-		}
562
-		spip_log("mise a jour de la base en $version", 'maj.' . _LOG_INFO_IMPORTANTE);
563
-	} else {
564
-		echo _T('alerte_maj_impossible', array('version' => $version));
565
-		exit;
566
-	}
554
+    if ($test) {
555
+        if ($version >= 1.922) {
556
+            ecrire_meta('version_installee', $version, 'oui');
557
+        } else {
558
+            // on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
559
+            $GLOBALS['meta']['version_installee'] = $version;
560
+            sql_updateq('spip_meta', array('valeur' => $version), 'nom=' . sql_quote('version_installee'));
561
+        }
562
+        spip_log("mise a jour de la base en $version", 'maj.' . _LOG_INFO_IMPORTANTE);
563
+    } else {
564
+        echo _T('alerte_maj_impossible', array('version' => $version));
565
+        exit;
566
+    }
567 567
 }
568 568
 
569 569
 /**
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
  * @return bool true si la mise à jour doit se réaliser
580 580
  **/
581 581
 function upgrade_vers($version, $version_installee, $version_cible = 0) {
582
-	return ($version_installee < $version
583
-		and (($version_cible >= $version) or ($version_cible == 0))
584
-	);
582
+    return ($version_installee < $version
583
+        and (($version_cible >= $version) or ($version_cible == 0))
584
+    );
585 585
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) {
57 57
 		if (!is_numeric(_request('reinstall'))) {
58 58
 			include_spip('base/create');
59
-			spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE);
59
+			spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE);
60 60
 			creer_base();
61 61
 		}
62 62
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			exit;
70 70
 		}
71 71
 	}
72
-	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE);
72
+	spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE);
73 73
 
74 74
 	// supprimer quelques fichiers temporaires qui peuvent se retrouver invalides
75 75
 	@spip_unlink(_CACHE_RUBRIQUES);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	@spip_unlink(_CACHE_PLUGINS_OPT);
79 79
 	@spip_unlink(_CACHE_PLUGINS_FCT);
80 80
 	@spip_unlink(_CACHE_CHEMIN);
81
-	@spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz');
81
+	@spip_unlink(_DIR_TMP.'plugin_xml_cache.gz');
82 82
 
83 83
 	include_spip('inc/auth');
84 84
 	auth_synchroniser_distant();
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	// version_installee = 1.702; quand on a besoin de forcer une MAJ
115 115
 
116 116
 	spip_log(
117
-		"Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'],
118
-		'maj.' . _LOG_INFO_IMPORTANTE
117
+		"Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'],
118
+		'maj.'._LOG_INFO_IMPORTANTE
119 119
 	);
120 120
 	if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
121 121
 		sql_replace(
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 			$nom = sprintf('v%03d', $n);
141 141
 			$f = charger_fonction($nom, 'maj/legacy', true);
142 142
 			if ($f) {
143
-				spip_log("$f repercute les modifications de la version " . ($n / 10), 'maj.' . _LOG_INFO_IMPORTANTE);
143
+				spip_log("$f repercute les modifications de la version ".($n / 10), 'maj.'._LOG_INFO_IMPORTANTE);
144 144
 				$f($version_installee, $GLOBALS['spip_version_base']);
145 145
 			} else {
146
-				spip_log("pas de fonction pour la maj $n $nom", 'maj.' . _LOG_INFO_IMPORTANTE);
146
+				spip_log("pas de fonction pour la maj $n $nom", 'maj.'._LOG_INFO_IMPORTANTE);
147 147
 			}
148 148
 			$n++;
149 149
 		}
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	$res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page);
171 171
 	if ($res) {
172 172
 		if (!is_array($res)) {
173
-			spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
173
+			spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_INFO_ERREUR);
174 174
 		} else {
175
-			echo _T('avis_operation_echec') . ' ' . join(' ', $res);
175
+			echo _T('avis_operation_echec').' '.join(' ', $res);
176 176
 			echo install_fin_html();
177 177
 		}
178 178
 	}
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 		$res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect);
260 260
 		if ($res) {
261 261
 			if (!is_array($res)) {
262
-				spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR);
262
+				spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_INFO_ERREUR);
263 263
 			} else {
264
-				echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>';
264
+				echo '<p>'._T('avis_operation_echec').' '.join(' ', $res).'</p>';
265 265
 			}
266 266
 		}
267 267
 	}
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 	$timeout = _UPGRADE_TIME_OUT * 2;
314 314
 	$titre = _T('titre_page_upgrade');
315 315
 	$balise_img = charger_filtre('balise_img');
316
-	$titre .= $balise_img(chemin_image('loader.svg'),'','loader');
316
+	$titre .= $balise_img(chemin_image('loader.svg'), '', 'loader');
317 317
 	echo(install_debut_html($titre));
318 318
 	// script de rechargement auto sur timeout
319 319
 	$redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true);
320
-	echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')');
320
+	echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')');
321 321
 	echo "<div style='text-align: left'>\n";
322 322
 	if (ob_get_level()) {
323 323
 		ob_flush();
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				return array($v, $etape);
406 406
 			}
407 407
 			$n = time() - $time;
408
-			spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE);
408
+			spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE);
409 409
 			if ($meta) {
410 410
 				ecrire_meta($meta, $installee = $v, 'oui', $table);
411 411
 			}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	if ($meta) {
422 422
 		ecrire_meta($meta, $cible, 'oui', $table);
423 423
 	}
424
-	spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE);
424
+	spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE);
425 425
 
426 426
 	return array();
427 427
 }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
  * @return int
447 447
  */
448 448
 function serie_alter($serie, $q = array(), $meta = '', $table = 'meta', $redirect = '') {
449
-	$meta2 = $meta . '_maj_' . $serie;
449
+	$meta2 = $meta.'_maj_'.$serie;
450 450
 	$etape = 0;
451 451
 	if (isset($GLOBALS[$table][$meta2])) {
452 452
 		$etape = intval($GLOBALS[$table][$meta2]);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 				and function_exists($f = array_shift($r))
459 459
 			) {
460 460
 				// note: $r (arguments de la fonction $f) peut avoir des données tabulaires
461
-				spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE);
461
+				spip_log("$msg: $f ".@join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE);
462 462
 				// pour les fonctions atomiques sql_xx
463 463
 				// on enregistre le meta avant de lancer la fonction,
464 464
 				// de maniere a eviter de boucler sur timeout
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 					relance_maj($meta, $table, $redirect);
477 477
 				}
478 478
 				ecrire_meta($meta2, $i + 1, 'non', $table);
479
-				spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE);
479
+				spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE);
480 480
 			} else {
481 481
 				if (!is_array($r)) {
482
-					spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR);
482
+					spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR);
483 483
 				} else {
484
-					spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR);
484
+					spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR);
485 485
 				}
486 486
 				// en cas d'erreur serieuse, on s'arrete
487 487
 				// mais on permet de passer par dessus en rechargeant la page.
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
 		} else {
558 558
 			// on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions
559 559
 			$GLOBALS['meta']['version_installee'] = $version;
560
-			sql_updateq('spip_meta', array('valeur' => $version), 'nom=' . sql_quote('version_installee'));
560
+			sql_updateq('spip_meta', array('valeur' => $version), 'nom='.sql_quote('version_installee'));
561 561
 		}
562
-		spip_log("mise a jour de la base en $version", 'maj.' . _LOG_INFO_IMPORTANTE);
562
+		spip_log("mise a jour de la base en $version", 'maj.'._LOG_INFO_IMPORTANTE);
563 563
 	} else {
564 564
 		echo _T('alerte_maj_impossible', array('version' => $version));
565 565
 		exit;
Please login to merge, or discard this patch.