@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -19,199 +19,199 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) { |
| 21 | 21 | |
| 22 | - // Prefix des tables : |
|
| 23 | - // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 24 | - // a partir de ce qui est envoye a l'installation |
|
| 25 | - if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 26 | - $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 27 | - ? $GLOBALS['table_prefix'] |
|
| 28 | - : preparer_prefixe_tables(_request('tprefix')); |
|
| 29 | - // S'il est vide on remet spip |
|
| 30 | - if (!$table_prefix) { |
|
| 31 | - $table_prefix = 'spip'; |
|
| 32 | - } |
|
| 33 | - } else { |
|
| 34 | - $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 38 | - [, $adresse_db, $port] = $r; |
|
| 39 | - } else { |
|
| 40 | - $port = ''; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $GLOBALS['connexions'][$server_db] |
|
| 44 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 45 | - |
|
| 46 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 47 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 48 | - |
|
| 49 | - $fquery = sql_serveur('query', $server_db); |
|
| 50 | - if ($choix_db == 'new_spip') { |
|
| 51 | - $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 52 | - if (preg_match($re, $sel_db)) { |
|
| 53 | - $ok = sql_create_base($sel_db, $server_db); |
|
| 54 | - if (!$ok) { |
|
| 55 | - $re = "Impossible de creer la base $re"; |
|
| 56 | - spip_log($re); |
|
| 57 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 58 | - } |
|
| 59 | - } else { |
|
| 60 | - $re = "Le nom de la base doit correspondre a $re"; |
|
| 61 | - spip_log($re); |
|
| 62 | - |
|
| 63 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 68 | - // un sql_mode |
|
| 69 | - install_mode_appel($server_db, false); |
|
| 70 | - $GLOBALS['connexions'][$server_db] |
|
| 71 | - = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 72 | - |
|
| 73 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 74 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 75 | - |
|
| 76 | - // Completer le tableau decrivant la connexion |
|
| 77 | - |
|
| 78 | - $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 79 | - $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 80 | - |
|
| 81 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 82 | - if ($old) { |
|
| 83 | - $old = sql_fetch($old, $server_db); |
|
| 84 | - } |
|
| 85 | - if (!$old) { |
|
| 86 | - // Si possible, demander au serveur d'envoyer les textes |
|
| 87 | - // dans le codage std de SPIP, |
|
| 88 | - $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 89 | - |
|
| 90 | - if ($charset) { |
|
| 91 | - sql_set_charset($charset['charset'], $server_db); |
|
| 92 | - $GLOBALS['meta']['charset_sql_base'] = |
|
| 93 | - $charset['charset']; |
|
| 94 | - $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 95 | - $charset['collation']; |
|
| 96 | - $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 97 | - $charset['charset']; |
|
| 98 | - $charsetbase = $charset['charset']; |
|
| 99 | - } else { |
|
| 100 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 101 | - $charsetbase = 'standard'; |
|
| 102 | - } |
|
| 103 | - spip_log("Creation des tables. Codage $charsetbase"); |
|
| 104 | - creer_base($server_db); // AT LAST |
|
| 105 | - // memoriser avec quel charset on l'a creee |
|
| 106 | - |
|
| 107 | - if ($charset) { |
|
| 108 | - $t = [ |
|
| 109 | - 'nom' => 'charset_sql_base', |
|
| 110 | - 'valeur' => $charset['charset'], |
|
| 111 | - 'impt' => 'non' |
|
| 112 | - ]; |
|
| 113 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 114 | - $t['nom'] = 'charset_collation_sql_base'; |
|
| 115 | - $t['valeur'] = $charset['collation']; |
|
| 116 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 117 | - $t['nom'] = 'charset_sql_connexion'; |
|
| 118 | - $t['valeur'] = $charset['charset']; |
|
| 119 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 120 | - } |
|
| 121 | - $t = [ |
|
| 122 | - 'nom' => 'version_installee', |
|
| 123 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 124 | - 'impt' => 'non' |
|
| 125 | - ]; |
|
| 126 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 127 | - $t['nom'] = 'nouvelle_install'; |
|
| 128 | - $t['valeur'] = 1; |
|
| 129 | - @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 130 | - // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 131 | - if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 132 | - @sql_insertq( |
|
| 133 | - 'spip_meta', |
|
| 134 | - ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 135 | - '', |
|
| 136 | - $server_db |
|
| 137 | - ); |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - // pour recreer les tables disparues au besoin |
|
| 141 | - spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 142 | - creer_base($server_db); |
|
| 143 | - $fupdateq = sql_serveur('updateq', $server_db); |
|
| 144 | - |
|
| 145 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 146 | - |
|
| 147 | - if ($r) { |
|
| 148 | - $r = sql_fetch($r, $server_db); |
|
| 149 | - } |
|
| 150 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 151 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 152 | - $fupdateq( |
|
| 153 | - 'spip_meta', |
|
| 154 | - ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 155 | - "nom='version_installee'", |
|
| 156 | - '', |
|
| 157 | - $server_db |
|
| 158 | - ); |
|
| 159 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 160 | - } |
|
| 161 | - // eliminer la derniere operation d'admin mal terminee |
|
| 162 | - // notamment la mise a jour |
|
| 163 | - @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // recuperer le charset de la connexion dans les meta |
|
| 167 | - $charset = ''; |
|
| 168 | - $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 169 | - if ($r) { |
|
| 170 | - $r = sql_fetch($r, $server_db); |
|
| 171 | - } |
|
| 172 | - if ($r) { |
|
| 173 | - $charset = $r['valeur']; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $ligne_rappel = install_mode_appel($server_db); |
|
| 177 | - |
|
| 178 | - $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 179 | - if (!$result_ok) { |
|
| 180 | - return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - if ($chmod_db) { |
|
| 184 | - install_fichier_connexion( |
|
| 185 | - _FILE_CHMOD_TMP, |
|
| 186 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // si ce fichier existe a cette etape c'est qu'il provient |
|
| 191 | - // d'une installation qui ne l'a pas cree correctement. |
|
| 192 | - // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 193 | - |
|
| 194 | - if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 195 | - spip_unlink(_FILE_CONNECT); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - install_fichier_connexion( |
|
| 199 | - _FILE_CONNECT_TMP, |
|
| 200 | - $ligne_rappel |
|
| 201 | - . install_connexion( |
|
| 202 | - $adresse_db, |
|
| 203 | - $port, |
|
| 204 | - $login_db, |
|
| 205 | - $pass_db, |
|
| 206 | - $sel_db, |
|
| 207 | - $server_db, |
|
| 208 | - $table_prefix, |
|
| 209 | - '', |
|
| 210 | - $charset |
|
| 211 | - ) |
|
| 212 | - ); |
|
| 213 | - |
|
| 214 | - return ''; |
|
| 22 | + // Prefix des tables : |
|
| 23 | + // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer |
|
| 24 | + // a partir de ce qui est envoye a l'installation |
|
| 25 | + if (!defined('_INSTALL_TABLE_PREFIX')) { |
|
| 26 | + $table_prefix = ($GLOBALS['table_prefix'] != 'spip') |
|
| 27 | + ? $GLOBALS['table_prefix'] |
|
| 28 | + : preparer_prefixe_tables(_request('tprefix')); |
|
| 29 | + // S'il est vide on remet spip |
|
| 30 | + if (!$table_prefix) { |
|
| 31 | + $table_prefix = 'spip'; |
|
| 32 | + } |
|
| 33 | + } else { |
|
| 34 | + $table_prefix = _INSTALL_TABLE_PREFIX; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 38 | + [, $adresse_db, $port] = $r; |
|
| 39 | + } else { |
|
| 40 | + $port = ''; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $GLOBALS['connexions'][$server_db] |
|
| 44 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
|
| 45 | + |
|
| 46 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 47 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 48 | + |
|
| 49 | + $fquery = sql_serveur('query', $server_db); |
|
| 50 | + if ($choix_db == 'new_spip') { |
|
| 51 | + $re = ',^[a-z_][a-z_0-9-]*$,i'; |
|
| 52 | + if (preg_match($re, $sel_db)) { |
|
| 53 | + $ok = sql_create_base($sel_db, $server_db); |
|
| 54 | + if (!$ok) { |
|
| 55 | + $re = "Impossible de creer la base $re"; |
|
| 56 | + spip_log($re); |
|
| 57 | + return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 58 | + } |
|
| 59 | + } else { |
|
| 60 | + $re = "Le nom de la base doit correspondre a $re"; |
|
| 61 | + spip_log($re); |
|
| 62 | + |
|
| 63 | + return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // on rejoue la connexion apres avoir teste si il faut lui indiquer |
|
| 68 | + // un sql_mode |
|
| 69 | + install_mode_appel($server_db, false); |
|
| 70 | + $GLOBALS['connexions'][$server_db] |
|
| 71 | + = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
|
| 72 | + |
|
| 73 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 74 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 75 | + |
|
| 76 | + // Completer le tableau decrivant la connexion |
|
| 77 | + |
|
| 78 | + $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
|
| 79 | + $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
|
| 80 | + |
|
| 81 | + $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 82 | + if ($old) { |
|
| 83 | + $old = sql_fetch($old, $server_db); |
|
| 84 | + } |
|
| 85 | + if (!$old) { |
|
| 86 | + // Si possible, demander au serveur d'envoyer les textes |
|
| 87 | + // dans le codage std de SPIP, |
|
| 88 | + $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db); |
|
| 89 | + |
|
| 90 | + if ($charset) { |
|
| 91 | + sql_set_charset($charset['charset'], $server_db); |
|
| 92 | + $GLOBALS['meta']['charset_sql_base'] = |
|
| 93 | + $charset['charset']; |
|
| 94 | + $GLOBALS['meta']['charset_collation_sql_base'] = |
|
| 95 | + $charset['collation']; |
|
| 96 | + $GLOBALS['meta']['charset_sql_connexion'] = |
|
| 97 | + $charset['charset']; |
|
| 98 | + $charsetbase = $charset['charset']; |
|
| 99 | + } else { |
|
| 100 | + spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 101 | + $charsetbase = 'standard'; |
|
| 102 | + } |
|
| 103 | + spip_log("Creation des tables. Codage $charsetbase"); |
|
| 104 | + creer_base($server_db); // AT LAST |
|
| 105 | + // memoriser avec quel charset on l'a creee |
|
| 106 | + |
|
| 107 | + if ($charset) { |
|
| 108 | + $t = [ |
|
| 109 | + 'nom' => 'charset_sql_base', |
|
| 110 | + 'valeur' => $charset['charset'], |
|
| 111 | + 'impt' => 'non' |
|
| 112 | + ]; |
|
| 113 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 114 | + $t['nom'] = 'charset_collation_sql_base'; |
|
| 115 | + $t['valeur'] = $charset['collation']; |
|
| 116 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 117 | + $t['nom'] = 'charset_sql_connexion'; |
|
| 118 | + $t['valeur'] = $charset['charset']; |
|
| 119 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 120 | + } |
|
| 121 | + $t = [ |
|
| 122 | + 'nom' => 'version_installee', |
|
| 123 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 124 | + 'impt' => 'non' |
|
| 125 | + ]; |
|
| 126 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 127 | + $t['nom'] = 'nouvelle_install'; |
|
| 128 | + $t['valeur'] = 1; |
|
| 129 | + @sql_insertq('spip_meta', $t, '', $server_db); |
|
| 130 | + // positionner la langue par defaut du site si un cookie de lang a ete mis |
|
| 131 | + if (isset($_COOKIE['spip_lang_ecrire'])) { |
|
| 132 | + @sql_insertq( |
|
| 133 | + 'spip_meta', |
|
| 134 | + ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']], |
|
| 135 | + '', |
|
| 136 | + $server_db |
|
| 137 | + ); |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + // pour recreer les tables disparues au besoin |
|
| 141 | + spip_log('Table des Meta deja la. Verification des autres.'); |
|
| 142 | + creer_base($server_db); |
|
| 143 | + $fupdateq = sql_serveur('updateq', $server_db); |
|
| 144 | + |
|
| 145 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db); |
|
| 146 | + |
|
| 147 | + if ($r) { |
|
| 148 | + $r = sql_fetch($r, $server_db); |
|
| 149 | + } |
|
| 150 | + $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 151 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 152 | + $fupdateq( |
|
| 153 | + 'spip_meta', |
|
| 154 | + ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'], |
|
| 155 | + "nom='version_installee'", |
|
| 156 | + '', |
|
| 157 | + $server_db |
|
| 158 | + ); |
|
| 159 | + spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 160 | + } |
|
| 161 | + // eliminer la derniere operation d'admin mal terminee |
|
| 162 | + // notamment la mise a jour |
|
| 163 | + @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR nom='admin'", $server_db); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + // recuperer le charset de la connexion dans les meta |
|
| 167 | + $charset = ''; |
|
| 168 | + $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db); |
|
| 169 | + if ($r) { |
|
| 170 | + $r = sql_fetch($r, $server_db); |
|
| 171 | + } |
|
| 172 | + if ($r) { |
|
| 173 | + $charset = $r['valeur']; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $ligne_rappel = install_mode_appel($server_db); |
|
| 177 | + |
|
| 178 | + $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db); |
|
| 179 | + if (!$result_ok) { |
|
| 180 | + return "<!--\nvielle = $old rappel= $ligne_rappel\n-->"; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + if ($chmod_db) { |
|
| 184 | + install_fichier_connexion( |
|
| 185 | + _FILE_CHMOD_TMP, |
|
| 186 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 187 | + ); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // si ce fichier existe a cette etape c'est qu'il provient |
|
| 191 | + // d'une installation qui ne l'a pas cree correctement. |
|
| 192 | + // Le supprimer pour que _FILE_CONNECT_TMP prime. |
|
| 193 | + |
|
| 194 | + if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) { |
|
| 195 | + spip_unlink(_FILE_CONNECT); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + install_fichier_connexion( |
|
| 199 | + _FILE_CONNECT_TMP, |
|
| 200 | + $ligne_rappel |
|
| 201 | + . install_connexion( |
|
| 202 | + $adresse_db, |
|
| 203 | + $port, |
|
| 204 | + $login_db, |
|
| 205 | + $pass_db, |
|
| 206 | + $sel_db, |
|
| 207 | + $server_db, |
|
| 208 | + $table_prefix, |
|
| 209 | + '', |
|
| 210 | + $charset |
|
| 211 | + ) |
|
| 212 | + ); |
|
| 213 | + |
|
| 214 | + return ''; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -226,166 +226,166 @@ discard block |
||
| 226 | 226 | * @return string Le préfixe corrigé |
| 227 | 227 | */ |
| 228 | 228 | function preparer_prefixe_tables($prefixe) { |
| 229 | - return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 229 | + return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe)))); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | function install_propose_ldap() { |
| 233 | - return generer_form_ecrire('install', ( |
|
| 234 | - fieldset( |
|
| 235 | - _T('info_authentification_externe'), |
|
| 236 | - [ |
|
| 237 | - 'etape' => [ |
|
| 238 | - 'label' => _T('texte_annuaire_ldap_1'), |
|
| 239 | - 'valeur' => 'ldap1', |
|
| 240 | - 'hidden' => true |
|
| 241 | - ] |
|
| 242 | - ], |
|
| 243 | - bouton_suivant(_T('bouton_acces_ldap')) |
|
| 244 | - ))); |
|
| 233 | + return generer_form_ecrire('install', ( |
|
| 234 | + fieldset( |
|
| 235 | + _T('info_authentification_externe'), |
|
| 236 | + [ |
|
| 237 | + 'etape' => [ |
|
| 238 | + 'label' => _T('texte_annuaire_ldap_1'), |
|
| 239 | + 'valeur' => 'ldap1', |
|
| 240 | + 'hidden' => true |
|
| 241 | + ] |
|
| 242 | + ], |
|
| 243 | + bouton_suivant(_T('bouton_acces_ldap')) |
|
| 244 | + ))); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 249 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 250 | - info_etape( |
|
| 251 | - _T('info_informations_personnelles'), |
|
| 252 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 253 | - aider('install5', true) . |
|
| 254 | - '<p>' . |
|
| 255 | - ($auteur_obligatoire ? |
|
| 256 | - '' |
|
| 257 | - : |
|
| 258 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 259 | - ) |
|
| 260 | - ) |
|
| 261 | - . generer_form_ecrire('install', ( |
|
| 262 | - "\n<input type='hidden' name='etape' value='3b' />" |
|
| 263 | - . $hidden |
|
| 264 | - . fieldset( |
|
| 265 | - _T('info_identification_publique'), |
|
| 266 | - [ |
|
| 267 | - 'nom' => [ |
|
| 268 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 269 | - 'valeur' => $nom, |
|
| 270 | - 'required' => $auteur_obligatoire, |
|
| 271 | - ], |
|
| 272 | - 'email' => [ |
|
| 273 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 274 | - 'valeur' => $email, |
|
| 275 | - ] |
|
| 276 | - ] |
|
| 277 | - ) |
|
| 278 | - |
|
| 279 | - . fieldset( |
|
| 280 | - _T('entree_identifiants_connexion'), |
|
| 281 | - [ |
|
| 282 | - 'login' => [ |
|
| 283 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 284 | - 'info_login_trop_court_car_pluriel', |
|
| 285 | - ['nb' => _LOGIN_TROP_COURT] |
|
| 286 | - ) . "\n", |
|
| 287 | - 'valeur' => $login, |
|
| 288 | - 'required' => $auteur_obligatoire, |
|
| 289 | - ], |
|
| 290 | - 'pass' => [ |
|
| 291 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 292 | - 'info_passe_trop_court_car_pluriel', |
|
| 293 | - ['nb' => _PASS_LONGUEUR_MINI] |
|
| 294 | - ) . "\n", |
|
| 295 | - 'valeur' => $pass, |
|
| 296 | - 'required' => $auteur_obligatoire, |
|
| 297 | - ], |
|
| 298 | - 'pass_verif' => [ |
|
| 299 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 300 | - 'valeur' => $pass, |
|
| 301 | - 'required' => $auteur_obligatoire, |
|
| 302 | - ] |
|
| 303 | - ] |
|
| 304 | - ) |
|
| 305 | - . bouton_suivant())); |
|
| 249 | + return info_progression_etape(3, 'etape_', 'install/') . |
|
| 250 | + info_etape( |
|
| 251 | + _T('info_informations_personnelles'), |
|
| 252 | + '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 253 | + aider('install5', true) . |
|
| 254 | + '<p>' . |
|
| 255 | + ($auteur_obligatoire ? |
|
| 256 | + '' |
|
| 257 | + : |
|
| 258 | + _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 259 | + ) |
|
| 260 | + ) |
|
| 261 | + . generer_form_ecrire('install', ( |
|
| 262 | + "\n<input type='hidden' name='etape' value='3b' />" |
|
| 263 | + . $hidden |
|
| 264 | + . fieldset( |
|
| 265 | + _T('info_identification_publique'), |
|
| 266 | + [ |
|
| 267 | + 'nom' => [ |
|
| 268 | + 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 269 | + 'valeur' => $nom, |
|
| 270 | + 'required' => $auteur_obligatoire, |
|
| 271 | + ], |
|
| 272 | + 'email' => [ |
|
| 273 | + 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 274 | + 'valeur' => $email, |
|
| 275 | + ] |
|
| 276 | + ] |
|
| 277 | + ) |
|
| 278 | + |
|
| 279 | + . fieldset( |
|
| 280 | + _T('entree_identifiants_connexion'), |
|
| 281 | + [ |
|
| 282 | + 'login' => [ |
|
| 283 | + 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 284 | + 'info_login_trop_court_car_pluriel', |
|
| 285 | + ['nb' => _LOGIN_TROP_COURT] |
|
| 286 | + ) . "\n", |
|
| 287 | + 'valeur' => $login, |
|
| 288 | + 'required' => $auteur_obligatoire, |
|
| 289 | + ], |
|
| 290 | + 'pass' => [ |
|
| 291 | + 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 292 | + 'info_passe_trop_court_car_pluriel', |
|
| 293 | + ['nb' => _PASS_LONGUEUR_MINI] |
|
| 294 | + ) . "\n", |
|
| 295 | + 'valeur' => $pass, |
|
| 296 | + 'required' => $auteur_obligatoire, |
|
| 297 | + ], |
|
| 298 | + 'pass_verif' => [ |
|
| 299 | + 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 300 | + 'valeur' => $pass, |
|
| 301 | + 'required' => $auteur_obligatoire, |
|
| 302 | + ] |
|
| 303 | + ] |
|
| 304 | + ) |
|
| 305 | + . bouton_suivant())); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | function install_etape_3_dist() { |
| 309 | - $ldap_present = _request('ldap_present'); |
|
| 310 | - |
|
| 311 | - if (!$ldap_present) { |
|
| 312 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 313 | - ? _INSTALL_HOST_DB |
|
| 314 | - : _request('adresse_db'); |
|
| 315 | - |
|
| 316 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 317 | - ? _INSTALL_USER_DB |
|
| 318 | - : _request('login_db'); |
|
| 319 | - |
|
| 320 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 321 | - ? _INSTALL_PASS_DB |
|
| 322 | - : _request('pass_db'); |
|
| 323 | - |
|
| 324 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 325 | - ? _INSTALL_SERVER_DB |
|
| 326 | - : _request('server_db'); |
|
| 327 | - |
|
| 328 | - $chmod_db = defined('_SPIP_CHMOD') |
|
| 329 | - ? _SPIP_CHMOD |
|
| 330 | - : _request('chmod'); |
|
| 331 | - |
|
| 332 | - $choix_db = defined('_INSTALL_NAME_DB') |
|
| 333 | - ? _INSTALL_NAME_DB |
|
| 334 | - : _request('choix_db'); |
|
| 335 | - |
|
| 336 | - $sel_db = ($choix_db == 'new_spip') |
|
| 337 | - ? _request('table_new') : $choix_db; |
|
| 338 | - |
|
| 339 | - $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 340 | - |
|
| 341 | - if ($res) { |
|
| 342 | - $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 343 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 344 | - . $res |
|
| 345 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 346 | - . '</div>'; |
|
| 347 | - } |
|
| 348 | - } else { |
|
| 349 | - $res = ''; |
|
| 350 | - [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 351 | - $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - if (!$res) { |
|
| 355 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 356 | - include(_FILE_CONNECT_TMP); |
|
| 357 | - } else { |
|
| 358 | - redirige_url_ecrire('install'); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 362 | - include(_FILE_CHMOD_TMP); |
|
| 363 | - } else { |
|
| 364 | - redirige_url_ecrire('install'); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 368 | - . (defined('_INSTALL_NAME_DB') ? '' |
|
| 369 | - : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 370 | - |
|
| 371 | - $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 372 | - |
|
| 373 | - $res = "<div class='success'><b>" |
|
| 374 | - . _T('info_base_installee') |
|
| 375 | - . '</b></div>' |
|
| 376 | - . install_premier_auteur( |
|
| 377 | - _request('email'), |
|
| 378 | - _request('login'), |
|
| 379 | - _request('nom'), |
|
| 380 | - _request('pass'), |
|
| 381 | - $hidden, |
|
| 382 | - $auteur_obligatoire |
|
| 383 | - ) |
|
| 384 | - . (($ldap_present or !function_exists('ldap_connect')) |
|
| 385 | - ? '' : install_propose_ldap()); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - echo install_debut_html(); |
|
| 389 | - echo $res; |
|
| 390 | - echo install_fin_html(); |
|
| 309 | + $ldap_present = _request('ldap_present'); |
|
| 310 | + |
|
| 311 | + if (!$ldap_present) { |
|
| 312 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 313 | + ? _INSTALL_HOST_DB |
|
| 314 | + : _request('adresse_db'); |
|
| 315 | + |
|
| 316 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 317 | + ? _INSTALL_USER_DB |
|
| 318 | + : _request('login_db'); |
|
| 319 | + |
|
| 320 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 321 | + ? _INSTALL_PASS_DB |
|
| 322 | + : _request('pass_db'); |
|
| 323 | + |
|
| 324 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 325 | + ? _INSTALL_SERVER_DB |
|
| 326 | + : _request('server_db'); |
|
| 327 | + |
|
| 328 | + $chmod_db = defined('_SPIP_CHMOD') |
|
| 329 | + ? _SPIP_CHMOD |
|
| 330 | + : _request('chmod'); |
|
| 331 | + |
|
| 332 | + $choix_db = defined('_INSTALL_NAME_DB') |
|
| 333 | + ? _INSTALL_NAME_DB |
|
| 334 | + : _request('choix_db'); |
|
| 335 | + |
|
| 336 | + $sel_db = ($choix_db == 'new_spip') |
|
| 337 | + ? _request('table_new') : $choix_db; |
|
| 338 | + |
|
| 339 | + $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db); |
|
| 340 | + |
|
| 341 | + if ($res) { |
|
| 342 | + $res = info_progression_etape(2, 'etape_', 'install/', true) |
|
| 343 | + . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 344 | + . $res |
|
| 345 | + . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 346 | + . '</div>'; |
|
| 347 | + } |
|
| 348 | + } else { |
|
| 349 | + $res = ''; |
|
| 350 | + [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP); |
|
| 351 | + $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db); |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + if (!$res) { |
|
| 355 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 356 | + include(_FILE_CONNECT_TMP); |
|
| 357 | + } else { |
|
| 358 | + redirige_url_ecrire('install'); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 362 | + include(_FILE_CHMOD_TMP); |
|
| 363 | + } else { |
|
| 364 | + redirige_url_ecrire('install'); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) |
|
| 368 | + . (defined('_INSTALL_NAME_DB') ? '' |
|
| 369 | + : "\n<input type='hidden' name='sel_db' value='$sel_db' />"); |
|
| 370 | + |
|
| 371 | + $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db)); |
|
| 372 | + |
|
| 373 | + $res = "<div class='success'><b>" |
|
| 374 | + . _T('info_base_installee') |
|
| 375 | + . '</b></div>' |
|
| 376 | + . install_premier_auteur( |
|
| 377 | + _request('email'), |
|
| 378 | + _request('login'), |
|
| 379 | + _request('nom'), |
|
| 380 | + _request('pass'), |
|
| 381 | + $hidden, |
|
| 382 | + $auteur_obligatoire |
|
| 383 | + ) |
|
| 384 | + . (($ldap_present or !function_exists('ldap_connect')) |
|
| 385 | + ? '' : install_propose_ldap()); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + echo install_debut_html(); |
|
| 389 | + echo $res; |
|
| 390 | + echo install_fin_html(); |
|
| 391 | 391 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db); |
| 45 | 45 | |
| 46 | 46 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 47 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 47 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 48 | 48 | |
| 49 | 49 | $fquery = sql_serveur('query', $server_db); |
| 50 | 50 | if ($choix_db == 'new_spip') { |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | if (!$ok) { |
| 55 | 55 | $re = "Impossible de creer la base $re"; |
| 56 | 56 | spip_log($re); |
| 57 | - return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->"; |
|
| 57 | + return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->"; |
|
| 58 | 58 | } |
| 59 | 59 | } else { |
| 60 | 60 | $re = "Le nom de la base doit correspondre a $re"; |
| 61 | 61 | spip_log($re); |
| 62 | 62 | |
| 63 | - return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->"; |
|
| 63 | + return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->"; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db); |
| 72 | 72 | |
| 73 | 73 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 74 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 74 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 75 | 75 | |
| 76 | 76 | // Completer le tableau decrivant la connexion |
| 77 | 77 | |
| 78 | 78 | $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix; |
| 79 | 79 | $GLOBALS['connexions'][$server_db]['db'] = $sel_db; |
| 80 | 80 | |
| 81 | - $old = sql_showbase($table_prefix . '_meta', $server_db); |
|
| 81 | + $old = sql_showbase($table_prefix.'_meta', $server_db); |
|
| 82 | 82 | if ($old) { |
| 83 | 83 | $old = sql_fetch($old, $server_db); |
| 84 | 84 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $charset['charset']; |
| 98 | 98 | $charsetbase = $charset['charset']; |
| 99 | 99 | } else { |
| 100 | - spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL'); |
|
| 100 | + spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL'); |
|
| 101 | 101 | $charsetbase = 'standard'; |
| 102 | 102 | } |
| 103 | 103 | spip_log("Creation des tables. Codage $charsetbase"); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | if ($r) { |
| 148 | 148 | $r = sql_fetch($r, $server_db); |
| 149 | 149 | } |
| 150 | - $version_installee = !$r ? 0 : (double)$r['valeur']; |
|
| 150 | + $version_installee = !$r ? 0 : (double) $r['valeur']; |
|
| 151 | 151 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 152 | 152 | $fupdateq( |
| 153 | 153 | 'spip_meta', |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | '', |
| 157 | 157 | $server_db |
| 158 | 158 | ); |
| 159 | - spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']); |
|
| 159 | + spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']); |
|
| 160 | 160 | } |
| 161 | 161 | // eliminer la derniere operation d'admin mal terminee |
| 162 | 162 | // notamment la mise a jour |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | if ($chmod_db) { |
| 184 | 184 | install_fichier_connexion( |
| 185 | 185 | _FILE_CHMOD_TMP, |
| 186 | - "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n" |
|
| 186 | + "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n" |
|
| 187 | 187 | ); |
| 188 | 188 | } |
| 189 | 189 | |
@@ -246,16 +246,16 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) { |
| 249 | - return info_progression_etape(3, 'etape_', 'install/') . |
|
| 249 | + return info_progression_etape(3, 'etape_', 'install/'). |
|
| 250 | 250 | info_etape( |
| 251 | 251 | _T('info_informations_personnelles'), |
| 252 | - '<b>' . _T('texte_informations_personnelles_1') . '</b>' . |
|
| 253 | - aider('install5', true) . |
|
| 254 | - '<p>' . |
|
| 252 | + '<b>'._T('texte_informations_personnelles_1').'</b>'. |
|
| 253 | + aider('install5', true). |
|
| 254 | + '<p>'. |
|
| 255 | 255 | ($auteur_obligatoire ? |
| 256 | 256 | '' |
| 257 | 257 | : |
| 258 | - _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides') |
|
| 258 | + _T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides') |
|
| 259 | 259 | ) |
| 260 | 260 | ) |
| 261 | 261 | . generer_form_ecrire('install', ( |
@@ -265,12 +265,12 @@ discard block |
||
| 265 | 265 | _T('info_identification_publique'), |
| 266 | 266 | [ |
| 267 | 267 | 'nom' => [ |
| 268 | - 'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n", |
|
| 268 | + 'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n", |
|
| 269 | 269 | 'valeur' => $nom, |
| 270 | 270 | 'required' => $auteur_obligatoire, |
| 271 | 271 | ], |
| 272 | 272 | 'email' => [ |
| 273 | - 'label' => '<b>' . _T('entree_adresse_email') . "</b>\n", |
|
| 273 | + 'label' => '<b>'._T('entree_adresse_email')."</b>\n", |
|
| 274 | 274 | 'valeur' => $email, |
| 275 | 275 | ] |
| 276 | 276 | ] |
@@ -280,23 +280,23 @@ discard block |
||
| 280 | 280 | _T('entree_identifiants_connexion'), |
| 281 | 281 | [ |
| 282 | 282 | 'login' => [ |
| 283 | - 'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T( |
|
| 283 | + 'label' => '<b>'._T('entree_login')."</b><br />\n"._T( |
|
| 284 | 284 | 'info_login_trop_court_car_pluriel', |
| 285 | 285 | ['nb' => _LOGIN_TROP_COURT] |
| 286 | - ) . "\n", |
|
| 286 | + )."\n", |
|
| 287 | 287 | 'valeur' => $login, |
| 288 | 288 | 'required' => $auteur_obligatoire, |
| 289 | 289 | ], |
| 290 | 290 | 'pass' => [ |
| 291 | - 'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T( |
|
| 291 | + 'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T( |
|
| 292 | 292 | 'info_passe_trop_court_car_pluriel', |
| 293 | 293 | ['nb' => _PASS_LONGUEUR_MINI] |
| 294 | - ) . "\n", |
|
| 294 | + )."\n", |
|
| 295 | 295 | 'valeur' => $pass, |
| 296 | 296 | 'required' => $auteur_obligatoire, |
| 297 | 297 | ], |
| 298 | 298 | 'pass_verif' => [ |
| 299 | - 'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n", |
|
| 299 | + 'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n", |
|
| 300 | 300 | 'valeur' => $pass, |
| 301 | 301 | 'required' => $auteur_obligatoire, |
| 302 | 302 | ] |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | if ($res) { |
| 342 | 342 | $res = info_progression_etape(2, 'etape_', 'install/', true) |
| 343 | - . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>' |
|
| 343 | + . "<div class='error'><h3>"._T('avis_operation_echec').'</h3>' |
|
| 344 | 344 | . $res |
| 345 | - . '<p>' . _T('texte_operation_echec') . '</p>' |
|
| 345 | + . '<p>'._T('texte_operation_echec').'</p>' |
|
| 346 | 346 | . '</div>'; |
| 347 | 347 | } |
| 348 | 348 | } else { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Pile complétée du code compilé |
| 43 | 43 | **/ |
| 44 | 44 | function balise_FORMULAIRE_ADMIN($p) { |
| 45 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 45 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * - chaîne vide sinon. |
| 60 | 60 | */ |
| 61 | 61 | function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) { |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -84,66 +84,66 @@ discard block |
||
| 84 | 84 | **/ |
| 85 | 85 | function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') { |
| 86 | 86 | |
| 87 | - static $dejafait = false; |
|
| 87 | + static $dejafait = false; |
|
| 88 | 88 | |
| 89 | - if (empty($_COOKIE['spip_admin'])) { |
|
| 90 | - return ''; |
|
| 91 | - } |
|
| 89 | + if (empty($_COOKIE['spip_admin'])) { |
|
| 90 | + return ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - if (!is_array($debug)) { |
|
| 94 | - if ($dejafait) { |
|
| 95 | - return ''; |
|
| 96 | - } |
|
| 97 | - } else { |
|
| 98 | - if ($dejafait) { |
|
| 99 | - if (empty($debug['sourcefile'])) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - foreach ($debug['sourcefile'] as $k => $v) { |
|
| 103 | - if (strpos($v, 'administration.') !== false) { |
|
| 104 | - if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | - return $debug['resultat'][$k . 'tout']; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 93 | + if (!is_array($debug)) { |
|
| 94 | + if ($dejafait) { |
|
| 95 | + return ''; |
|
| 96 | + } |
|
| 97 | + } else { |
|
| 98 | + if ($dejafait) { |
|
| 99 | + if (empty($debug['sourcefile'])) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + foreach ($debug['sourcefile'] as $k => $v) { |
|
| 103 | + if (strpos($v, 'administration.') !== false) { |
|
| 104 | + if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | + return $debug['resultat'][$k . 'tout']; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return ''; |
|
| 111 | - } |
|
| 112 | - } |
|
| 110 | + return ''; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - include_spip('inc/autoriser'); |
|
| 115 | - include_spip('base/abstract_sql'); |
|
| 114 | + include_spip('inc/autoriser'); |
|
| 115 | + include_spip('base/abstract_sql'); |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - $dejafait = true; |
|
| 118 | + $dejafait = true; |
|
| 119 | 119 | |
| 120 | - // Preparer le #ENV des boutons |
|
| 120 | + // Preparer le #ENV des boutons |
|
| 121 | 121 | |
| 122 | - $env = admin_objet(); |
|
| 122 | + $env = admin_objet(); |
|
| 123 | 123 | |
| 124 | - // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 125 | - if (!$env) { |
|
| 126 | - $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 127 | - } |
|
| 124 | + // Pas de "modifier ce..." ? -> donner "acces a l'espace prive" |
|
| 125 | + if (!$env) { |
|
| 126 | + $env['ecrire'] = _DIR_RESTREINT_ABS; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - $env['divclass'] = $float; |
|
| 130 | - $env['lang'] = admin_lang(); |
|
| 131 | - $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 132 | - $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 133 | - $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 134 | - $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : ''); |
|
| 129 | + $env['divclass'] = $float; |
|
| 130 | + $env['lang'] = admin_lang(); |
|
| 131 | + $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul'); |
|
| 132 | + $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug()); |
|
| 133 | + $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider(); |
|
| 134 | + $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : ''); |
|
| 135 | 135 | |
| 136 | - if (empty($GLOBALS['use_cache'])) { |
|
| 137 | - $env['use_cache'] = ' *'; |
|
| 138 | - } |
|
| 136 | + if (empty($GLOBALS['use_cache'])) { |
|
| 137 | + $env['use_cache'] = ' *'; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - if (isset($debug['validation'])) { |
|
| 141 | - $env['xhtml_error'] = $debug['validation']; |
|
| 142 | - } |
|
| 140 | + if (isset($debug['validation'])) { |
|
| 141 | + $env['xhtml_error'] = $debug['validation']; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - $env['_pipelines']['formulaire_admin'] = []; |
|
| 144 | + $env['_pipelines']['formulaire_admin'] = []; |
|
| 145 | 145 | |
| 146 | - return ['formulaires/administration', 0, $env]; |
|
| 146 | + return ['formulaires/administration', 0, $env]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -161,47 +161,47 @@ discard block |
||
| 161 | 161 | * Tableau de l'environnement calculé |
| 162 | 162 | **/ |
| 163 | 163 | function admin_objet() { |
| 164 | - include_spip('inc/urls'); |
|
| 165 | - $env = []; |
|
| 166 | - |
|
| 167 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 168 | - $objets = urls_liste_objets(false); |
|
| 169 | - $objets = array_diff($objets, ['rubrique']); |
|
| 170 | - $objets = array_reverse($objets); |
|
| 171 | - array_unshift($objets, 'rubrique'); |
|
| 172 | - foreach ($objets as $obj) { |
|
| 173 | - $type = $obj; |
|
| 174 | - if ( |
|
| 175 | - $type == objet_type($type, false) |
|
| 176 | - and $_id_type = id_table_objet($type) |
|
| 177 | - and isset($GLOBALS['contexte'][$_id_type]) |
|
| 178 | - and $id = $GLOBALS['contexte'][$_id_type] |
|
| 179 | - and !is_array($id) |
|
| 180 | - and $id = intval($id) |
|
| 181 | - and $desc = $trouver_table(table_objet_sql($type)) |
|
| 182 | - ) { |
|
| 183 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 184 | - if ($id) { |
|
| 185 | - $env[$_id_type] = $id; |
|
| 186 | - $env['objet'] = $type; |
|
| 187 | - $env['id_objet'] = $id; |
|
| 188 | - $env['voir_' . $obj] = |
|
| 189 | - str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
|
| 190 | - if ( |
|
| 191 | - isset($desc['field']['id_rubrique']) |
|
| 192 | - and $type != 'rubrique' |
|
| 193 | - ) { |
|
| 194 | - unset($env['id_rubrique']); |
|
| 195 | - unset($env['voir_rubrique']); |
|
| 196 | - if (admin_preview($type, $id, $desc)) { |
|
| 197 | - $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - return $env; |
|
| 164 | + include_spip('inc/urls'); |
|
| 165 | + $env = []; |
|
| 166 | + |
|
| 167 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 168 | + $objets = urls_liste_objets(false); |
|
| 169 | + $objets = array_diff($objets, ['rubrique']); |
|
| 170 | + $objets = array_reverse($objets); |
|
| 171 | + array_unshift($objets, 'rubrique'); |
|
| 172 | + foreach ($objets as $obj) { |
|
| 173 | + $type = $obj; |
|
| 174 | + if ( |
|
| 175 | + $type == objet_type($type, false) |
|
| 176 | + and $_id_type = id_table_objet($type) |
|
| 177 | + and isset($GLOBALS['contexte'][$_id_type]) |
|
| 178 | + and $id = $GLOBALS['contexte'][$_id_type] |
|
| 179 | + and !is_array($id) |
|
| 180 | + and $id = intval($id) |
|
| 181 | + and $desc = $trouver_table(table_objet_sql($type)) |
|
| 182 | + ) { |
|
| 183 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 184 | + if ($id) { |
|
| 185 | + $env[$_id_type] = $id; |
|
| 186 | + $env['objet'] = $type; |
|
| 187 | + $env['id_objet'] = $id; |
|
| 188 | + $env['voir_' . $obj] = |
|
| 189 | + str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
|
| 190 | + if ( |
|
| 191 | + isset($desc['field']['id_rubrique']) |
|
| 192 | + and $type != 'rubrique' |
|
| 193 | + ) { |
|
| 194 | + unset($env['id_rubrique']); |
|
| 195 | + unset($env['voir_rubrique']); |
|
| 196 | + if (admin_preview($type, $id, $desc)) { |
|
| 197 | + $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&'); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + return $env; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -219,30 +219,30 @@ discard block |
||
| 219 | 219 | * - Tableau d'un élément sinon. |
| 220 | 220 | **/ |
| 221 | 221 | function admin_preview($type, $id, $desc = null) { |
| 222 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) { |
|
| 223 | - return ''; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - if (!$desc) { |
|
| 227 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 228 | - $desc = $trouver_table(table_objet_sql($type)); |
|
| 229 | - } |
|
| 230 | - if (!$desc or !isset($desc['field']['statut'])) { |
|
| 231 | - return ''; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - include_spip('inc/autoriser'); |
|
| 235 | - if (!autoriser('previsualiser')) { |
|
| 236 | - return ''; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 240 | - |
|
| 241 | - if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 242 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 222 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) { |
|
| 223 | + return ''; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + if (!$desc) { |
|
| 227 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 228 | + $desc = $trouver_table(table_objet_sql($type)); |
|
| 229 | + } |
|
| 230 | + if (!$desc or !isset($desc['field']['statut'])) { |
|
| 231 | + return ''; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + include_spip('inc/autoriser'); |
|
| 235 | + if (!autoriser('previsualiser')) { |
|
| 236 | + return ''; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $notpub = sql_in('statut', ['prop', 'prive']); |
|
| 240 | + |
|
| 241 | + if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
|
| 242 | + $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -253,25 +253,25 @@ discard block |
||
| 253 | 253 | * Code de langue |
| 254 | 254 | **/ |
| 255 | 255 | function admin_lang() { |
| 256 | - $alang = ''; |
|
| 257 | - if (!empty($_COOKIE['spip_admin'])) { |
|
| 258 | - $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
|
| 259 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 260 | - if (!$alang) { |
|
| 261 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - if (!$alang) { |
|
| 265 | - return ''; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $l = lang_select($alang); |
|
| 269 | - $alang = $GLOBALS['spip_lang']; |
|
| 270 | - if ($l) { |
|
| 271 | - lang_select(); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - return $alang; |
|
| 256 | + $alang = ''; |
|
| 257 | + if (!empty($_COOKIE['spip_admin'])) { |
|
| 258 | + $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
|
| 259 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 260 | + if (!$alang) { |
|
| 261 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + if (!$alang) { |
|
| 265 | + return ''; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $l = lang_select($alang); |
|
| 269 | + $alang = $GLOBALS['spip_lang']; |
|
| 270 | + if ($l) { |
|
| 271 | + lang_select(); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + return $alang; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | **/ |
| 282 | 282 | function admin_valider() { |
| 283 | 283 | |
| 284 | - return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
|
| 285 | - (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 286 | - . '&var_mode_affiche=validation') : |
|
| 287 | - ('http://validator.w3.org/check?uri=' |
|
| 288 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 284 | + return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
|
| 285 | + (parametre_url(self(), 'var_mode', 'debug', '&') |
|
| 286 | + . '&var_mode_affiche=validation') : |
|
| 287 | + ('http://validator.w3.org/check?uri=' |
|
| 288 | + . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | * @return string |
| 295 | 295 | **/ |
| 296 | 296 | function admin_debug() { |
| 297 | - return (( |
|
| 298 | - (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug']) |
|
| 299 | - or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug']) |
|
| 300 | - or ( |
|
| 301 | - defined('_VAR_MODE') and _VAR_MODE == 'debug' |
|
| 302 | - and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug'] |
|
| 303 | - ) |
|
| 304 | - ) and autoriser('debug') |
|
| 305 | - ) |
|
| 306 | - ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 297 | + return (( |
|
| 298 | + (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug']) |
|
| 299 | + or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug']) |
|
| 300 | + or ( |
|
| 301 | + defined('_VAR_MODE') and _VAR_MODE == 'debug' |
|
| 302 | + and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug'] |
|
| 303 | + ) |
|
| 304 | + ) and autoriser('debug') |
|
| 305 | + ) |
|
| 306 | + ? parametre_url(self(), 'var_mode', 'debug', '&') : ''; |
|
| 307 | 307 | } |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | foreach ($debug['sourcefile'] as $k => $v) { |
| 103 | 103 | if (strpos($v, 'administration.') !== false) { |
| 104 | - if (isset($debug['resultat'][$k . 'tout'])) { |
|
| 105 | - return $debug['resultat'][$k . 'tout']; |
|
| 104 | + if (isset($debug['resultat'][$k.'tout'])) { |
|
| 105 | + return $debug['resultat'][$k.'tout']; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | and $id = intval($id) |
| 181 | 181 | and $desc = $trouver_table(table_objet_sql($type)) |
| 182 | 182 | ) { |
| 183 | - $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id)); |
|
| 183 | + $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".intval($id)); |
|
| 184 | 184 | if ($id) { |
| 185 | 185 | $env[$_id_type] = $id; |
| 186 | 186 | $env['objet'] = $type; |
| 187 | 187 | $env['id_objet'] = $id; |
| 188 | - $env['voir_' . $obj] = |
|
| 188 | + $env['voir_'.$obj] = |
|
| 189 | 189 | str_replace('&', '&', generer_objet_url($id, $obj, '', '', false)); |
| 190 | 190 | if ( |
| 191 | 191 | isset($desc['field']['id_rubrique']) |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | $notpub = sql_in('statut', ['prop', 'prive']); |
| 240 | 240 | |
| 241 | 241 | if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') { |
| 242 | - $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')'; |
|
| 242 | + $notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).')'; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)"); |
|
| 245 | + return sql_fetsel('1', table_objet_sql($type), id_table_objet($type).'='.$id." AND ($notpub)"); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | $alang = ''; |
| 257 | 257 | if (!empty($_COOKIE['spip_admin'])) { |
| 258 | 258 | $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']); |
| 259 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login)); |
|
| 259 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'email='.sql_quote($email_or_login)); |
|
| 260 | 260 | if (!$alang) { |
| 261 | - $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login)); |
|
| 261 | + $alang = sql_getfetsel('lang', 'spip_auteurs', 'login='.sql_quote($email_or_login)); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | if (!$alang) { |
@@ -283,9 +283,8 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ? |
| 285 | 285 | (parametre_url(self(), 'var_mode', 'debug', '&') |
| 286 | - . '&var_mode_affiche=validation') : |
|
| 287 | - ('http://validator.w3.org/check?uri=' |
|
| 288 | - . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri()))); |
|
| 286 | + . '&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri=' |
|
| 287 | + . rawurlencode('http://'.$_SERVER['HTTP_HOST'].nettoyer_uri()))); |
|
| 289 | 288 | } |
| 290 | 289 | |
| 291 | 290 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -40,29 +40,29 @@ discard block |
||
| 40 | 40 | * Pile complétée par le code à générer |
| 41 | 41 | */ |
| 42 | 42 | function balise_INFO__dist($p) { |
| 43 | - $info = $p->nom_champ; |
|
| 44 | - $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | - $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | - if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | - $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | - erreur_squelette($msg, $p); |
|
| 49 | - $p->interdire_scripts = true; |
|
| 43 | + $info = $p->nom_champ; |
|
| 44 | + $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | + $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | + if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | + $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | + erreur_squelette($msg, $p); |
|
| 49 | + $p->interdire_scripts = true; |
|
| 50 | 50 | |
| 51 | - return $p; |
|
| 52 | - } else { |
|
| 53 | - // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | - $_params = '['; |
|
| 55 | - $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | - for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | - } |
|
| 59 | - $_params .= ']'; |
|
| 51 | + return $p; |
|
| 52 | + } else { |
|
| 53 | + // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | + $_params = '['; |
|
| 55 | + $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | + for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | + $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | + } |
|
| 59 | + $_params .= ']'; |
|
| 60 | 60 | |
| 61 | - $info_sql = strtolower(substr($info, 5)); |
|
| 62 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | - $p->code = champ_sql($info, $p, $code); |
|
| 64 | - $p->interdire_scripts = true; |
|
| 61 | + $info_sql = strtolower(substr($info, 5)); |
|
| 62 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | + $p->code = champ_sql($info, $p, $code); |
|
| 64 | + $p->interdire_scripts = true; |
|
| 65 | 65 | |
| 66 | - return $p; |
|
| 67 | - } |
|
| 66 | + return $p; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -54,12 +54,12 @@ |
||
| 54 | 54 | $_params = '['; |
| 55 | 55 | $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
| 56 | 56 | for ($i = 3; $i < $nb_params; $i++) { |
| 57 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 57 | + $_params .= interprete_argument_balise($i, $p).','; |
|
| 58 | 58 | } |
| 59 | 59 | $_params .= ']'; |
| 60 | 60 | |
| 61 | 61 | $info_sql = strtolower(substr($info, 5)); |
| 62 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 62 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', ".($p->etoile ? _q($p->etoile) : "''").", $_params)"; |
|
| 63 | 63 | $p->code = champ_sql($info, $p, $code); |
| 64 | 64 | $p->interdire_scripts = true; |
| 65 | 65 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -37,23 +37,23 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string { |
| 39 | 39 | |
| 40 | - if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 41 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 42 | - // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 43 | - // une url vide est une url vide, ne rien faire de plus |
|
| 44 | - if (!is_null($url)) { |
|
| 45 | - return $url; |
|
| 46 | - } |
|
| 47 | - } |
|
| 40 | + if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 41 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 42 | + // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 43 | + // une url vide est une url vide, ne rien faire de plus |
|
| 44 | + if (!is_null($url)) { |
|
| 45 | + return $url; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 50 | - . $id . \_terminaison_urls_page; |
|
| 49 | + $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 50 | + . $id . \_terminaison_urls_page; |
|
| 51 | 51 | |
| 52 | - if ($args) { |
|
| 53 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 54 | - } |
|
| 52 | + if ($args) { |
|
| 53 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 56 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -69,27 +69,27 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array { |
| 71 | 71 | |
| 72 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 73 | - if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 74 | - return [[], '404']; |
|
| 75 | - } |
|
| 72 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 73 | + if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 74 | + return [[], '404']; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - include_spip('inc/urls'); |
|
| 78 | - $r = nettoyer_url_page($url, $contexte); |
|
| 79 | - if ($r) { |
|
| 80 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 81 | - return $r; |
|
| 82 | - } |
|
| 77 | + include_spip('inc/urls'); |
|
| 78 | + $r = nettoyer_url_page($url, $contexte); |
|
| 79 | + if ($r) { |
|
| 80 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 81 | + return $r; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /* |
|
| 84 | + /* |
|
| 85 | 85 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 86 | 86 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 87 | 87 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 88 | 88 | * et votre .htaccess |
| 89 | 89 | */ |
| 90 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 91 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 92 | - $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 93 | - return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 94 | - /* Fin du bloc compatibilite url-propres */ |
|
| 90 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 91 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 92 | + $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 93 | + return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 94 | + /* Fin du bloc compatibilite url-propres */ |
|
| 95 | 95 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite |
| 24 | 24 | define('_separateur_urls_page', ''); |
| 25 | 25 | # on peut indiquer '' si on a installe le .htaccess |
| 26 | -define('_debut_urls_page', get_spip_script('./') . '?'); |
|
| 26 | +define('_debut_urls_page', get_spip_script('./').'?'); |
|
| 27 | 27 | ####### |
| 28 | 28 | |
| 29 | 29 | |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 50 | - . $id . \_terminaison_urls_page; |
|
| 49 | + $url = \_debut_urls_page.$objet.\_separateur_urls_page |
|
| 50 | + . $id.\_terminaison_urls_page; |
|
| 51 | 51 | |
| 52 | 52 | if ($args) { |
| 53 | 53 | $args = strpos($url, '?') ? "&$args" : "?$args"; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 56 | + return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : ''); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/autoriser'); |
@@ -30,80 +30,80 @@ discard block |
||
| 30 | 30 | * Un tableau des sous rubriques |
| 31 | 31 | */ |
| 32 | 32 | function enfant_rub($collection, $debut = 0, $limite = 500) { |
| 33 | - $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
|
| 34 | - $logo = ''; |
|
| 35 | - |
|
| 36 | - if ($voir_logo) { |
|
| 37 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 38 | - include_spip('inc/filtres_images_mini'); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $res = []; |
|
| 42 | - |
|
| 43 | - $result = sql_select( |
|
| 44 | - 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 45 | - 'spip_rubriques', |
|
| 46 | - 'id_parent=' . intval($collection), |
|
| 47 | - '', |
|
| 48 | - '0+titre,titre', |
|
| 49 | - "$debut,$limite" |
|
| 50 | - ); |
|
| 51 | - while ($row = sql_fetch($result)) { |
|
| 52 | - $id_rubrique = $row['id_rubrique']; |
|
| 53 | - $id_parent = $row['id_parent']; |
|
| 54 | - // pour etre sur de passer par tous les traitements |
|
| 55 | - $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre'); |
|
| 56 | - if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 57 | - $rang = "<span class='rang'>$rang.</span> "; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 61 | - $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 62 | - |
|
| 63 | - changer_typo($row['lang']); |
|
| 64 | - $lang_dir = lang_dir($row['lang']); |
|
| 65 | - $descriptif = propre($row['descriptif']); |
|
| 66 | - |
|
| 67 | - if ($voir_logo) { |
|
| 68 | - if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
|
| 69 | - [$fid, $dir, $nom, $format] = $logo; |
|
| 70 | - $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70); |
|
| 71 | - if ($logo) { |
|
| 72 | - $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">'); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 78 | - http_img_pack( |
|
| 79 | - 'auteur-0minirezo-16.png', |
|
| 80 | - '', |
|
| 81 | - " width='16' height='16'", |
|
| 82 | - _T('image_administrer_rubrique') |
|
| 83 | - )) . |
|
| 84 | - " <a class='titremlien' dir='$lang_dir'" . |
|
| 85 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 86 | - " href='" . |
|
| 87 | - generer_objet_url($id_rubrique, 'rubrique') . |
|
| 88 | - "'><span class='titre'>" . |
|
| 89 | - $rang . $titre |
|
| 90 | - . '</span>' |
|
| 91 | - . (is_string($logo) ? $logo : '') |
|
| 92 | - . '</a>'; |
|
| 93 | - |
|
| 94 | - $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique") |
|
| 95 | - . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") |
|
| 96 | - ; |
|
| 97 | - |
|
| 98 | - $res[] = |
|
| 99 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 100 | - $les_sous_enfants . |
|
| 101 | - fin_cadre_sous_rub(); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 106 | - return $res; |
|
| 33 | + $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non'); |
|
| 34 | + $logo = ''; |
|
| 35 | + |
|
| 36 | + if ($voir_logo) { |
|
| 37 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 38 | + include_spip('inc/filtres_images_mini'); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $res = []; |
|
| 42 | + |
|
| 43 | + $result = sql_select( |
|
| 44 | + 'id_rubrique, id_parent, titre, descriptif, lang', |
|
| 45 | + 'spip_rubriques', |
|
| 46 | + 'id_parent=' . intval($collection), |
|
| 47 | + '', |
|
| 48 | + '0+titre,titre', |
|
| 49 | + "$debut,$limite" |
|
| 50 | + ); |
|
| 51 | + while ($row = sql_fetch($result)) { |
|
| 52 | + $id_rubrique = $row['id_rubrique']; |
|
| 53 | + $id_parent = $row['id_parent']; |
|
| 54 | + // pour etre sur de passer par tous les traitements |
|
| 55 | + $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre'); |
|
| 56 | + if ('' !== ($rang = recuperer_numero($row['titre']))) { |
|
| 57 | + $rang = "<span class='rang'>$rang.</span> "; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 61 | + $les_sous_enfants = sous_enfant_rub($id_rubrique); |
|
| 62 | + |
|
| 63 | + changer_typo($row['lang']); |
|
| 64 | + $lang_dir = lang_dir($row['lang']); |
|
| 65 | + $descriptif = propre($row['descriptif']); |
|
| 66 | + |
|
| 67 | + if ($voir_logo) { |
|
| 68 | + if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) { |
|
| 69 | + [$fid, $dir, $nom, $format] = $logo; |
|
| 70 | + $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70); |
|
| 71 | + if ($logo) { |
|
| 72 | + $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">'); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 78 | + http_img_pack( |
|
| 79 | + 'auteur-0minirezo-16.png', |
|
| 80 | + '', |
|
| 81 | + " width='16' height='16'", |
|
| 82 | + _T('image_administrer_rubrique') |
|
| 83 | + )) . |
|
| 84 | + " <a class='titremlien' dir='$lang_dir'" . |
|
| 85 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 86 | + " href='" . |
|
| 87 | + generer_objet_url($id_rubrique, 'rubrique') . |
|
| 88 | + "'><span class='titre'>" . |
|
| 89 | + $rang . $titre |
|
| 90 | + . '</span>' |
|
| 91 | + . (is_string($logo) ? $logo : '') |
|
| 92 | + . '</a>'; |
|
| 93 | + |
|
| 94 | + $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique") |
|
| 95 | + . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>") |
|
| 96 | + ; |
|
| 97 | + |
|
| 98 | + $res[] = |
|
| 99 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 100 | + $les_sous_enfants . |
|
| 101 | + fin_cadre_sous_rub(); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite |
|
| 106 | + return $res; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -116,71 +116,71 @@ discard block |
||
| 116 | 116 | * Le contenu du bloc dépliable |
| 117 | 117 | */ |
| 118 | 118 | function sous_enfant_rub($collection2) { |
| 119 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2)); |
|
| 120 | - |
|
| 121 | - $retour = ''; |
|
| 122 | - $pagination = ''; |
|
| 123 | - $debut = 0; |
|
| 124 | - $limite = 500; |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * On ne va afficher que 500 résultats max |
|
| 128 | - * Si > 500 on affiche une pagination |
|
| 129 | - */ |
|
| 130 | - if ($nb > $limite) { |
|
| 131 | - $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 132 | - $pagination = chercher_filtre('pagination'); |
|
| 133 | - $pagination = '<p class="pagination">' . $pagination( |
|
| 134 | - $nb, |
|
| 135 | - '_rubrique' . $collection2, |
|
| 136 | - $debut, |
|
| 137 | - $limite, |
|
| 138 | - true, |
|
| 139 | - 'prive' |
|
| 140 | - ) . '</p>'; |
|
| 141 | - $limite = $debut + $limite; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $result = sql_select( |
|
| 145 | - 'id_rubrique, id_parent, titre, lang', |
|
| 146 | - 'spip_rubriques', |
|
| 147 | - 'id_parent=' . intval($collection2), |
|
| 148 | - '', |
|
| 149 | - '0+titre,titre', |
|
| 150 | - "$debut,$limite" |
|
| 151 | - ); |
|
| 152 | - |
|
| 153 | - while ($row = sql_fetch($result)) { |
|
| 154 | - $id_rubrique2 = $row['id_rubrique']; |
|
| 155 | - $titre2 = generer_objet_info( |
|
| 156 | - $id_rubrique2, |
|
| 157 | - 'rubrique', |
|
| 158 | - 'titre' |
|
| 159 | - ); // pour etre sur de passer par tous les traitements |
|
| 160 | - if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 161 | - $rang2 = "<span class='rang'>$rang2.</span> "; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - changer_typo($row['lang']); |
|
| 165 | - $lang_dir = lang_dir($row['lang']); |
|
| 166 | - if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 167 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 168 | - $id_rubrique2, |
|
| 169 | - 'rubrique' |
|
| 170 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $retour = $pagination . $retour . $pagination; |
|
| 175 | - |
|
| 176 | - if (!$retour) { |
|
| 177 | - return ''; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
|
| 181 | - . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 182 | - . $retour |
|
| 183 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 119 | + $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2)); |
|
| 120 | + |
|
| 121 | + $retour = ''; |
|
| 122 | + $pagination = ''; |
|
| 123 | + $debut = 0; |
|
| 124 | + $limite = 500; |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * On ne va afficher que 500 résultats max |
|
| 128 | + * Si > 500 on affiche une pagination |
|
| 129 | + */ |
|
| 130 | + if ($nb > $limite) { |
|
| 131 | + $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 132 | + $pagination = chercher_filtre('pagination'); |
|
| 133 | + $pagination = '<p class="pagination">' . $pagination( |
|
| 134 | + $nb, |
|
| 135 | + '_rubrique' . $collection2, |
|
| 136 | + $debut, |
|
| 137 | + $limite, |
|
| 138 | + true, |
|
| 139 | + 'prive' |
|
| 140 | + ) . '</p>'; |
|
| 141 | + $limite = $debut + $limite; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $result = sql_select( |
|
| 145 | + 'id_rubrique, id_parent, titre, lang', |
|
| 146 | + 'spip_rubriques', |
|
| 147 | + 'id_parent=' . intval($collection2), |
|
| 148 | + '', |
|
| 149 | + '0+titre,titre', |
|
| 150 | + "$debut,$limite" |
|
| 151 | + ); |
|
| 152 | + |
|
| 153 | + while ($row = sql_fetch($result)) { |
|
| 154 | + $id_rubrique2 = $row['id_rubrique']; |
|
| 155 | + $titre2 = generer_objet_info( |
|
| 156 | + $id_rubrique2, |
|
| 157 | + 'rubrique', |
|
| 158 | + 'titre' |
|
| 159 | + ); // pour etre sur de passer par tous les traitements |
|
| 160 | + if ('' !== ($rang2 = recuperer_numero($row['titre']))) { |
|
| 161 | + $rang2 = "<span class='rang'>$rang2.</span> "; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + changer_typo($row['lang']); |
|
| 165 | + $lang_dir = lang_dir($row['lang']); |
|
| 166 | + if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
|
| 167 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 168 | + $id_rubrique2, |
|
| 169 | + 'rubrique' |
|
| 170 | + ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $retour = $pagination . $retour . $pagination; |
|
| 175 | + |
|
| 176 | + if (!$retour) { |
|
| 177 | + return ''; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
|
| 181 | + . "\n<ul class='liste-items sous-sous-rub'>\n" |
|
| 182 | + . $retour |
|
| 183 | + . "</ul>\n" . fin_block() . "\n\n"; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -195,44 +195,44 @@ discard block |
||
| 195 | 195 | * Le contenu textuel affiché, la liste des sous rubriques |
| 196 | 196 | */ |
| 197 | 197 | function afficher_enfant_rub($id_rubrique = 0) { |
| 198 | - $pagination = ''; |
|
| 199 | - $debut = 0; |
|
| 200 | - $limite = 500; |
|
| 201 | - |
|
| 202 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique)); |
|
| 203 | - |
|
| 204 | - if ($nb > $limite) { |
|
| 205 | - $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 206 | - $pagination = chercher_filtre('pagination'); |
|
| 207 | - $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 208 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 209 | - '</p>'; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 213 | - |
|
| 214 | - if (!$n = count($les_enfants)) { |
|
| 215 | - return ''; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if ($n == 1) { |
|
| 219 | - $les_enfants = reset($les_enfants); |
|
| 220 | - $les_enfants2 = ''; |
|
| 221 | - } else { |
|
| 222 | - $n = ceil($n / 2); |
|
| 223 | - $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 224 | - $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $res = |
|
| 228 | - $pagination |
|
| 229 | - . "<div class='gauche'>" |
|
| 230 | - . $les_enfants |
|
| 231 | - . '</div>' |
|
| 232 | - . "<div class='droite'>" |
|
| 233 | - . $les_enfants2 |
|
| 234 | - . '</div>' |
|
| 235 | - . $pagination; |
|
| 236 | - |
|
| 237 | - return $res; |
|
| 198 | + $pagination = ''; |
|
| 199 | + $debut = 0; |
|
| 200 | + $limite = 500; |
|
| 201 | + |
|
| 202 | + $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique)); |
|
| 203 | + |
|
| 204 | + if ($nb > $limite) { |
|
| 205 | + $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 206 | + $pagination = chercher_filtre('pagination'); |
|
| 207 | + $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 208 | + $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 209 | + '</p>'; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $les_enfants = enfant_rub($id_rubrique, $debut, $limite); |
|
| 213 | + |
|
| 214 | + if (!$n = count($les_enfants)) { |
|
| 215 | + return ''; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if ($n == 1) { |
|
| 219 | + $les_enfants = reset($les_enfants); |
|
| 220 | + $les_enfants2 = ''; |
|
| 221 | + } else { |
|
| 222 | + $n = ceil($n / 2); |
|
| 223 | + $les_enfants2 = implode('', array_slice($les_enfants, $n)); |
|
| 224 | + $les_enfants = implode('', array_slice($les_enfants, 0, $n)); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $res = |
|
| 228 | + $pagination |
|
| 229 | + . "<div class='gauche'>" |
|
| 230 | + . $les_enfants |
|
| 231 | + . '</div>' |
|
| 232 | + . "<div class='droite'>" |
|
| 233 | + . $les_enfants2 |
|
| 234 | + . '</div>' |
|
| 235 | + . $pagination; |
|
| 236 | + |
|
| 237 | + return $res; |
|
| 238 | 238 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $result = sql_select( |
| 44 | 44 | 'id_rubrique, id_parent, titre, descriptif, lang', |
| 45 | 45 | 'spip_rubriques', |
| 46 | - 'id_parent=' . intval($collection), |
|
| 46 | + 'id_parent='.intval($collection), |
|
| 47 | 47 | '', |
| 48 | 48 | '0+titre,titre', |
| 49 | 49 | "$debut,$limite" |
@@ -74,19 +74,18 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : |
|
| 78 | - http_img_pack( |
|
| 77 | + $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : http_img_pack( |
|
| 79 | 78 | 'auteur-0minirezo-16.png', |
| 80 | 79 | '', |
| 81 | 80 | " width='16' height='16'", |
| 82 | 81 | _T('image_administrer_rubrique') |
| 83 | - )) . |
|
| 84 | - " <a class='titremlien' dir='$lang_dir'" . |
|
| 85 | - ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') . |
|
| 86 | - " href='" . |
|
| 87 | - generer_objet_url($id_rubrique, 'rubrique') . |
|
| 88 | - "'><span class='titre'>" . |
|
| 89 | - $rang . $titre |
|
| 82 | + )). |
|
| 83 | + " <a class='titremlien' dir='$lang_dir'". |
|
| 84 | + ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : ''). |
|
| 85 | + " href='". |
|
| 86 | + generer_objet_url($id_rubrique, 'rubrique'). |
|
| 87 | + "'><span class='titre'>". |
|
| 88 | + $rang.$titre |
|
| 90 | 89 | . '</span>' |
| 91 | 90 | . (is_string($logo) ? $logo : '') |
| 92 | 91 | . '</a>'; |
@@ -96,8 +95,8 @@ discard block |
||
| 96 | 95 | ; |
| 97 | 96 | |
| 98 | 97 | $res[] = |
| 99 | - debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) . |
|
| 100 | - $les_sous_enfants . |
|
| 98 | + debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre). |
|
| 99 | + $les_sous_enfants. |
|
| 101 | 100 | fin_cadre_sous_rub(); |
| 102 | 101 | } |
| 103 | 102 | } |
@@ -116,7 +115,7 @@ discard block |
||
| 116 | 115 | * Le contenu du bloc dépliable |
| 117 | 116 | */ |
| 118 | 117 | function sous_enfant_rub($collection2) { |
| 119 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2)); |
|
| 118 | + $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2)); |
|
| 120 | 119 | |
| 121 | 120 | $retour = ''; |
| 122 | 121 | $pagination = ''; |
@@ -128,23 +127,23 @@ discard block |
||
| 128 | 127 | * Si > 500 on affiche une pagination |
| 129 | 128 | */ |
| 130 | 129 | if ($nb > $limite) { |
| 131 | - $debut = _request('debut_rubrique' . $collection2) ?: $debut; |
|
| 130 | + $debut = _request('debut_rubrique'.$collection2) ?: $debut; |
|
| 132 | 131 | $pagination = chercher_filtre('pagination'); |
| 133 | - $pagination = '<p class="pagination">' . $pagination( |
|
| 132 | + $pagination = '<p class="pagination">'.$pagination( |
|
| 134 | 133 | $nb, |
| 135 | - '_rubrique' . $collection2, |
|
| 134 | + '_rubrique'.$collection2, |
|
| 136 | 135 | $debut, |
| 137 | 136 | $limite, |
| 138 | 137 | true, |
| 139 | 138 | 'prive' |
| 140 | - ) . '</p>'; |
|
| 139 | + ).'</p>'; |
|
| 141 | 140 | $limite = $debut + $limite; |
| 142 | 141 | } |
| 143 | 142 | |
| 144 | 143 | $result = sql_select( |
| 145 | 144 | 'id_rubrique, id_parent, titre, lang', |
| 146 | 145 | 'spip_rubriques', |
| 147 | - 'id_parent=' . intval($collection2), |
|
| 146 | + 'id_parent='.intval($collection2), |
|
| 148 | 147 | '', |
| 149 | 148 | '0+titre,titre', |
| 150 | 149 | "$debut,$limite" |
@@ -164,14 +163,14 @@ discard block |
||
| 164 | 163 | changer_typo($row['lang']); |
| 165 | 164 | $lang_dir = lang_dir($row['lang']); |
| 166 | 165 | if (autoriser('voir', 'rubrique', $id_rubrique2)) { |
| 167 | - $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url( |
|
| 166 | + $retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_objet_url( |
|
| 168 | 167 | $id_rubrique2, |
| 169 | 168 | 'rubrique' |
| 170 | - ) . "'>" . $rang2 . $titre2 . "</a></li>\n"; |
|
| 169 | + )."'>".$rang2.$titre2."</a></li>\n"; |
|
| 171 | 170 | } |
| 172 | 171 | } |
| 173 | 172 | |
| 174 | - $retour = $pagination . $retour . $pagination; |
|
| 173 | + $retour = $pagination.$retour.$pagination; |
|
| 175 | 174 | |
| 176 | 175 | if (!$retour) { |
| 177 | 176 | return ''; |
@@ -180,7 +179,7 @@ discard block |
||
| 180 | 179 | return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2") |
| 181 | 180 | . "\n<ul class='liste-items sous-sous-rub'>\n" |
| 182 | 181 | . $retour |
| 183 | - . "</ul>\n" . fin_block() . "\n\n"; |
|
| 182 | + . "</ul>\n".fin_block()."\n\n"; |
|
| 184 | 183 | } |
| 185 | 184 | |
| 186 | 185 | /** |
@@ -199,13 +198,13 @@ discard block |
||
| 199 | 198 | $debut = 0; |
| 200 | 199 | $limite = 500; |
| 201 | 200 | |
| 202 | - $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique)); |
|
| 201 | + $nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)); |
|
| 203 | 202 | |
| 204 | 203 | if ($nb > $limite) { |
| 205 | - $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut; |
|
| 204 | + $debut = _request('debut_rubrique'.$id_rubrique) ?: $debut; |
|
| 206 | 205 | $pagination = chercher_filtre('pagination'); |
| 207 | - $pagination = '<br class="nettoyeur"><p class="pagination">' . |
|
| 208 | - $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') . |
|
| 206 | + $pagination = '<br class="nettoyeur"><p class="pagination">'. |
|
| 207 | + $pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive'). |
|
| 209 | 208 | '</p>'; |
| 210 | 209 | } |
| 211 | 210 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/autoriser'); |
@@ -35,42 +35,42 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function action_menu_rubriques_dist() { |
| 37 | 37 | |
| 38 | - // si pas acces a ecrire, pas acces au menu |
|
| 39 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | - if (!autoriser('ecrire')) { |
|
| 41 | - $retour = |
|
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 48 | - '</ul>'; |
|
| 49 | - include_spip('inc/actions'); |
|
| 50 | - ajax_retour($retour); |
|
| 51 | - exit; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($date = intval(_request('date'))) { |
|
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $r = gen_liste_rubriques(); |
|
| 59 | - if ( |
|
| 60 | - !$r |
|
| 61 | - and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | - ) { |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | - http_response_code(304); |
|
| 67 | - exit; |
|
| 68 | - } else { |
|
| 69 | - include_spip('inc/actions'); |
|
| 70 | - $ret = menu_rubriques(); |
|
| 71 | - ajax_retour($ret); |
|
| 72 | - exit; |
|
| 73 | - } |
|
| 38 | + // si pas acces a ecrire, pas acces au menu |
|
| 39 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | + if (!autoriser('ecrire')) { |
|
| 41 | + $retour = |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | + '</a>' . |
|
| 47 | + '</li>' . |
|
| 48 | + '</ul>'; |
|
| 49 | + include_spip('inc/actions'); |
|
| 50 | + ajax_retour($retour); |
|
| 51 | + exit; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($date = intval(_request('date'))) { |
|
| 55 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $r = gen_liste_rubriques(); |
|
| 59 | + if ( |
|
| 60 | + !$r |
|
| 61 | + and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | + ) { |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | + http_response_code(304); |
|
| 67 | + exit; |
|
| 68 | + } else { |
|
| 69 | + include_spip('inc/actions'); |
|
| 70 | + $ret = menu_rubriques(); |
|
| 71 | + ajax_retour($ret); |
|
| 72 | + exit; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -84,44 +84,44 @@ discard block |
||
| 84 | 84 | * Code HTML présentant la liste des rubriques |
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | - . '</a>' |
|
| 91 | - . '</li>'; |
|
| 92 | - |
|
| 93 | - if (!$complet) { |
|
| 94 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | - gen_liste_rubriques(); |
|
| 99 | - } |
|
| 100 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | - |
|
| 102 | - $total_lignes = $i = sizeof($arr_low); |
|
| 103 | - |
|
| 104 | - if ($i > 0) { |
|
| 105 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | - if ($nb_col <= 1) { |
|
| 107 | - $nb_col = ceil($total_lignes / 10); |
|
| 108 | - } |
|
| 109 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | - $i++; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | - . $ret |
|
| 119 | - . "\n</ul>\n"; |
|
| 120 | - } else { |
|
| 121 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $ret; |
|
| 87 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | + . '</a>' |
|
| 91 | + . '</li>'; |
|
| 92 | + |
|
| 93 | + if (!$complet) { |
|
| 94 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | + gen_liste_rubriques(); |
|
| 99 | + } |
|
| 100 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | + |
|
| 102 | + $total_lignes = $i = sizeof($arr_low); |
|
| 103 | + |
|
| 104 | + if ($i > 0) { |
|
| 105 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | + if ($nb_col <= 1) { |
|
| 107 | + $nb_col = ceil($total_lignes / 10); |
|
| 108 | + } |
|
| 109 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | + $i++; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | + . $ret |
|
| 119 | + . "\n</ul>\n"; |
|
| 120 | + } else { |
|
| 121 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $ret; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,48 +142,48 @@ discard block |
||
| 142 | 142 | * Code HTML présentant la liste des rubriques |
| 143 | 143 | **/ |
| 144 | 144 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 145 | - static $zmax = 6; |
|
| 146 | - $profondeur_next = $profondeur + 1; |
|
| 147 | - |
|
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | - . "</a>\n"; |
|
| 151 | - |
|
| 152 | - // Limiter volontairement le nombre de sous-menus |
|
| 153 | - if (!(--$zmax)) { |
|
| 154 | - $zmax++; |
|
| 155 | - |
|
| 156 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | - $i = sizeof($arr_rub); |
|
| 161 | - if (!$i) { |
|
| 162 | - $zmax++; |
|
| 163 | - |
|
| 164 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - $nb_col = 1; |
|
| 169 | - if ($nb_rub = count($arr_rub)) { |
|
| 170 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | - } |
|
| 172 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | - . $nav |
|
| 175 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | - $i++; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $ret .= "</ul></li>\n"; |
|
| 184 | - $zmax++; |
|
| 185 | - |
|
| 186 | - return $ret; |
|
| 145 | + static $zmax = 6; |
|
| 146 | + $profondeur_next = $profondeur + 1; |
|
| 147 | + |
|
| 148 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | + . "</a>\n"; |
|
| 151 | + |
|
| 152 | + // Limiter volontairement le nombre de sous-menus |
|
| 153 | + if (!(--$zmax)) { |
|
| 154 | + $zmax++; |
|
| 155 | + |
|
| 156 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | + $i = sizeof($arr_rub); |
|
| 161 | + if (!$i) { |
|
| 162 | + $zmax++; |
|
| 163 | + |
|
| 164 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + $nb_col = 1; |
|
| 169 | + if ($nb_rub = count($arr_rub)) { |
|
| 170 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | + } |
|
| 172 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | + . $nav |
|
| 175 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | + $i++; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $ret .= "</ul></li>\n"; |
|
| 184 | + $zmax++; |
|
| 185 | + |
|
| 186 | + return $ret; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 202 | 202 | **/ |
| 203 | 203 | function extraire_article($id_p, $t) { |
| 204 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 204 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,42 +217,42 @@ discard block |
||
| 217 | 217 | **/ |
| 218 | 218 | function gen_liste_rubriques() { |
| 219 | 219 | |
| 220 | - $cache = null; |
|
| 221 | - include_spip('inc/config'); |
|
| 222 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | - if ($date == $last) { |
|
| 227 | - return false; |
|
| 228 | - } // c'etait en cache :-) |
|
| 229 | - } |
|
| 230 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | - |
|
| 232 | - $where = sql_in_select( |
|
| 233 | - 'id_rubrique', |
|
| 234 | - 'id_rubrique', |
|
| 235 | - 'spip_rubriques', |
|
| 236 | - '', |
|
| 237 | - '', |
|
| 238 | - 'id_parent=0 DESC, date DESC', |
|
| 239 | - _CACHE_RUBRIQUES_MAX |
|
| 240 | - ); |
|
| 241 | - |
|
| 242 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | - |
|
| 244 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | - |
|
| 246 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | - // car on met le resultat en cache, commun a tout le monde |
|
| 248 | - $GLOBALS['db_art_cache'] = []; |
|
| 249 | - while ($r = sql_fetch($res)) { |
|
| 250 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | - |
|
| 257 | - return true; |
|
| 220 | + $cache = null; |
|
| 221 | + include_spip('inc/config'); |
|
| 222 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | + if ($date == $last) { |
|
| 227 | + return false; |
|
| 228 | + } // c'etait en cache :-) |
|
| 229 | + } |
|
| 230 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | + |
|
| 232 | + $where = sql_in_select( |
|
| 233 | + 'id_rubrique', |
|
| 234 | + 'id_rubrique', |
|
| 235 | + 'spip_rubriques', |
|
| 236 | + '', |
|
| 237 | + '', |
|
| 238 | + 'id_parent=0 DESC, date DESC', |
|
| 239 | + _CACHE_RUBRIQUES_MAX |
|
| 240 | + ); |
|
| 241 | + |
|
| 242 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | + |
|
| 244 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | + |
|
| 246 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | + // car on met le resultat en cache, commun a tout le monde |
|
| 248 | + $GLOBALS['db_art_cache'] = []; |
|
| 249 | + while ($r = sql_fetch($res)) { |
|
| 250 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | 258 | } |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
| 40 | 40 | if (!autoriser('ecrire')) { |
| 41 | 41 | $retour = |
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">'. |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">'. |
|
| 44 | + '<a class="deroulant__lien" href="'.generer_url_ecrire('accueil').'" data-profondeur="1">'. |
|
| 45 | + '<span class="libelle">'._T('public:lien_connecter').'</span>'. |
|
| 46 | + '</a>'. |
|
| 47 | + '</li>'. |
|
| 48 | 48 | '</ul>'; |
| 49 | 49 | include_spip('inc/actions'); |
| 50 | 50 | ajax_retour($retour); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | if ($date = intval(_request('date'))) { |
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT'); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $r = gen_liste_rubriques(); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
| 63 | 63 | ) { |
| 64 | 64 | include_spip('inc/headers'); |
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | + header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']); |
|
| 66 | 66 | http_response_code(304); |
| 67 | 67 | exit; |
| 68 | 68 | } else { |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | 87 | $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 88 | + . '<a class="deroulant__lien" href="'.generer_url_ecrire('plan').'" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">'._T('info_tout_site').'</span>' |
|
| 90 | 90 | . '</a>' |
| 91 | 91 | . '</li>'; |
| 92 | 92 | |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | static $zmax = 6; |
| 146 | 146 | $profondeur_next = $profondeur + 1; |
| 147 | 147 | |
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 148 | + $nav = '<a class="deroulant__lien" href="'.generer_objet_url($id_rubrique, 'rubrique', '', '', false)."\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">'.supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)).'</span>' |
|
| 150 | 150 | . "</a>\n"; |
| 151 | 151 | |
| 152 | 152 | // Limiter volontairement le nombre de sous-menus |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | * ``` |
| 37 | 37 | **/ |
| 38 | 38 | function action_redirect_dist() { |
| 39 | - $type = _request('type'); |
|
| 40 | - $id = intval(_request('id')); |
|
| 41 | - $page = false; |
|
| 39 | + $type = _request('type'); |
|
| 40 | + $id = intval(_request('id')); |
|
| 41 | + $page = false; |
|
| 42 | 42 | |
| 43 | - // verifier le type ou page transmis |
|
| 44 | - if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | - $page = _request('page'); |
|
| 46 | - if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + // verifier le type ou page transmis |
|
| 44 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | + $page = _request('page'); |
|
| 46 | + if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($var_mode = _request('var_mode')) { |
|
| 52 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | - if (!defined('_VAR_URLS')) { |
|
| 54 | - define('_VAR_URLS', true); |
|
| 55 | - } |
|
| 56 | - } |
|
| 51 | + if ($var_mode = _request('var_mode')) { |
|
| 52 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | + if (!defined('_VAR_URLS')) { |
|
| 54 | + define('_VAR_URLS', true); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if ($page) { |
|
| 59 | - $url = generer_url_public($page, '', true); |
|
| 60 | - } else { |
|
| 61 | - $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | - } |
|
| 58 | + if ($page) { |
|
| 59 | + $url = generer_url_public($page, '', true); |
|
| 60 | + } else { |
|
| 61 | + $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $status = '302'; |
|
| 65 | - if ($url) { |
|
| 66 | - if ($var_mode) { |
|
| 67 | - $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | - } |
|
| 64 | + $status = '302'; |
|
| 65 | + if ($url) { |
|
| 66 | + if ($var_mode) { |
|
| 67 | + $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( |
|
| 71 | - $var_mode == 'preview' |
|
| 72 | - and defined('_PREVIEW_TOKEN') |
|
| 73 | - and _PREVIEW_TOKEN |
|
| 74 | - and autoriser('previsualiser') |
|
| 75 | - ) { |
|
| 76 | - include_spip('inc/securiser_action'); |
|
| 77 | - $token = calculer_token_previsu($url); |
|
| 78 | - $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | - } |
|
| 70 | + if ( |
|
| 71 | + $var_mode == 'preview' |
|
| 72 | + and defined('_PREVIEW_TOKEN') |
|
| 73 | + and _PREVIEW_TOKEN |
|
| 74 | + and autoriser('previsualiser') |
|
| 75 | + ) { |
|
| 76 | + include_spip('inc/securiser_action'); |
|
| 77 | + $token = calculer_token_previsu($url); |
|
| 78 | + $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (_request('status') and _request('status') == '301') { |
|
| 82 | - $status = '301'; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $url = generer_url_public('404', '', true); |
|
| 86 | - } |
|
| 81 | + if (_request('status') and _request('status') == '301') { |
|
| 82 | + $status = '301'; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $url = generer_url_public('404', '', true); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 88 | + redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | * @return string|null |
| 101 | 101 | */ |
| 102 | 102 | function calculer_url_redirect_entite($type, $id, $var_mode) { |
| 103 | - $desc = null; |
|
| 104 | - $publie = null; |
|
| 105 | - $url = null; |
|
| 106 | - // invalider le cache à chaque modif en bdd |
|
| 107 | - $date = 0; |
|
| 108 | - if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | - $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | - } |
|
| 111 | - $key = "url-$date-$type-$id"; |
|
| 103 | + $desc = null; |
|
| 104 | + $publie = null; |
|
| 105 | + $url = null; |
|
| 106 | + // invalider le cache à chaque modif en bdd |
|
| 107 | + $date = 0; |
|
| 108 | + if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | + $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | + } |
|
| 111 | + $key = "url-$date-$type-$id"; |
|
| 112 | 112 | |
| 113 | - // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | - if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | - [$url, $publie] = $desc; |
|
| 116 | - } |
|
| 117 | - // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | - if (empty($desc) or $var_mode) { |
|
| 119 | - $publie = objet_test_si_publie($type, $id); |
|
| 120 | - $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | - if (function_exists('cache_set')) { |
|
| 122 | - cache_set($key, [$url, $publie], 3600); |
|
| 123 | - } |
|
| 124 | - } |
|
| 113 | + // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | + if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | + [$url, $publie] = $desc; |
|
| 116 | + } |
|
| 117 | + // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | + if (empty($desc) or $var_mode) { |
|
| 119 | + $publie = objet_test_si_publie($type, $id); |
|
| 120 | + $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | + if (function_exists('cache_set')) { |
|
| 122 | + cache_set($key, [$url, $publie], 3600); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | - if ($publie) { |
|
| 128 | - return $url; |
|
| 129 | - } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | - return $url; |
|
| 131 | - } |
|
| 126 | + // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | + if ($publie) { |
|
| 128 | + return $url; |
|
| 129 | + } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | + return $url; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return; |
|
| 133 | + return; |
|
| 134 | 134 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('base/objets'); |
| 23 | 23 | |
@@ -57,106 +57,106 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | 59 | function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) { |
| 60 | - static $current_base = null; |
|
| 60 | + static $current_base = null; |
|
| 61 | 61 | |
| 62 | - // les anciennes fonctions modifient directement les globales |
|
| 63 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | - $save = [ |
|
| 65 | - $GLOBALS['fond'] ?? null, |
|
| 66 | - $GLOBALS['contexte'] ?? null, |
|
| 67 | - $_SERVER['REDIRECT_url_propre'] ?? null, |
|
| 68 | - $_ENV['url_propre'] ?? null, |
|
| 69 | - $GLOBALS['profondeur_url'] |
|
| 70 | - ]; |
|
| 62 | + // les anciennes fonctions modifient directement les globales |
|
| 63 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | + $save = [ |
|
| 65 | + $GLOBALS['fond'] ?? null, |
|
| 66 | + $GLOBALS['contexte'] ?? null, |
|
| 67 | + $_SERVER['REDIRECT_url_propre'] ?? null, |
|
| 68 | + $_ENV['url_propre'] ?? null, |
|
| 69 | + $GLOBALS['profondeur_url'] |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | - if (is_null($current_base)) { |
|
| 73 | - include_spip('inc/filtres_mini'); |
|
| 74 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | - $current_base = url_absolue(_DIR_RACINE ?: './'); |
|
| 76 | - } |
|
| 77 | - if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | - $url = substr($url, strlen($current_base)); |
|
| 79 | - } |
|
| 72 | + if (is_null($current_base)) { |
|
| 73 | + include_spip('inc/filtres_mini'); |
|
| 74 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | + $current_base = url_absolue(_DIR_RACINE ?: './'); |
|
| 76 | + } |
|
| 77 | + if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | + $url = substr($url, strlen($current_base)); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // si on est en train d'assembler la page principale, |
|
| 82 | - // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | - // sinon extraire la bonne portion d'url |
|
| 84 | - if ($assembler) { |
|
| 85 | - if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | - $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | - } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | - $url = $_ENV['url_propre']; |
|
| 89 | - } else { |
|
| 90 | - $qs = explode('?', $url); |
|
| 91 | - // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | - $url = ltrim($qs[0], '/'); |
|
| 93 | - $url = explode('/', $url); |
|
| 94 | - while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | - array_shift($url); |
|
| 96 | - } |
|
| 97 | - $qs[0] = implode('/', $url); |
|
| 98 | - $url = implode('?', $qs); |
|
| 99 | - } |
|
| 100 | - } |
|
| 81 | + // si on est en train d'assembler la page principale, |
|
| 82 | + // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | + // sinon extraire la bonne portion d'url |
|
| 84 | + if ($assembler) { |
|
| 85 | + if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | + $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | + } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | + $url = $_ENV['url_propre']; |
|
| 89 | + } else { |
|
| 90 | + $qs = explode('?', $url); |
|
| 91 | + // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | + $url = ltrim($qs[0], '/'); |
|
| 93 | + $url = explode('/', $url); |
|
| 94 | + while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | + array_shift($url); |
|
| 96 | + } |
|
| 97 | + $qs[0] = implode('/', $url); |
|
| 98 | + $url = implode('?', $qs); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | - unset($_ENV['url_propre']); |
|
| 104 | - include_spip('inc/filtres_mini'); |
|
| 105 | - if (strpos($url, '://') === false) { |
|
| 106 | - $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | - } else { |
|
| 108 | - $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | - } |
|
| 102 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | + unset($_ENV['url_propre']); |
|
| 104 | + include_spip('inc/filtres_mini'); |
|
| 105 | + if (strpos($url, '://') === false) { |
|
| 106 | + $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | + } else { |
|
| 108 | + $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - $url_redirect = ''; |
|
| 112 | - $decoder = charger_fonction_url('decoder'); |
|
| 113 | - if ($decoder) { |
|
| 114 | - $a = $decoder($url, $fond, $contexte); |
|
| 115 | - if (is_array($a)) { |
|
| 116 | - [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null); |
|
| 117 | - $url_redirect ??= ''; |
|
| 118 | - if ($url_redirect === $url) { |
|
| 119 | - $url_redirect = ''; |
|
| 120 | - } // securite pour eviter une redirection infinie |
|
| 121 | - if ($assembler and strlen($url_redirect)) { |
|
| 122 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 123 | - include_spip('inc/headers'); |
|
| 124 | - redirige_par_entete($url_redirect, '', 301); |
|
| 125 | - } |
|
| 126 | - if (isset($nfond)) { |
|
| 127 | - $fond = $nfond; |
|
| 128 | - } else { |
|
| 129 | - if ( |
|
| 130 | - $fond == '' |
|
| 131 | - or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 132 | - ) { |
|
| 133 | - $fond = $type; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - if (isset($ncontexte)) { |
|
| 137 | - $contexte = $ncontexte; |
|
| 138 | - } |
|
| 139 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 140 | - $contexte['type'] = $type; |
|
| 141 | - } |
|
| 142 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 143 | - $contexte['type-page'] = $type; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 111 | + $url_redirect = ''; |
|
| 112 | + $decoder = charger_fonction_url('decoder'); |
|
| 113 | + if ($decoder) { |
|
| 114 | + $a = $decoder($url, $fond, $contexte); |
|
| 115 | + if (is_array($a)) { |
|
| 116 | + [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null); |
|
| 117 | + $url_redirect ??= ''; |
|
| 118 | + if ($url_redirect === $url) { |
|
| 119 | + $url_redirect = ''; |
|
| 120 | + } // securite pour eviter une redirection infinie |
|
| 121 | + if ($assembler and strlen($url_redirect)) { |
|
| 122 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 123 | + include_spip('inc/headers'); |
|
| 124 | + redirige_par_entete($url_redirect, '', 301); |
|
| 125 | + } |
|
| 126 | + if (isset($nfond)) { |
|
| 127 | + $fond = $nfond; |
|
| 128 | + } else { |
|
| 129 | + if ( |
|
| 130 | + $fond == '' |
|
| 131 | + or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 132 | + ) { |
|
| 133 | + $fond = $type; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + if (isset($ncontexte)) { |
|
| 137 | + $contexte = $ncontexte; |
|
| 138 | + } |
|
| 139 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 140 | + $contexte['type'] = $type; |
|
| 141 | + } |
|
| 142 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 143 | + $contexte['type-page'] = $type; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - // retablir les globales |
|
| 149 | - [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save; |
|
| 148 | + // retablir les globales |
|
| 149 | + [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save; |
|
| 150 | 150 | |
| 151 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 152 | - // d'inversion url => objet |
|
| 153 | - // maintenir pour compat ? |
|
| 154 | - #if ($assembler) { |
|
| 155 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 156 | - # unset($_ENV['url_propre']); |
|
| 157 | - #} |
|
| 151 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 152 | + // d'inversion url => objet |
|
| 153 | + // maintenir pour compat ? |
|
| 154 | + #if ($assembler) { |
|
| 155 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 156 | + # unset($_ENV['url_propre']); |
|
| 157 | + #} |
|
| 158 | 158 | |
| 159 | - return [$fond, $contexte, $url_redirect]; |
|
| 159 | + return [$fond, $contexte, $url_redirect]; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,20 +169,20 @@ discard block |
||
| 169 | 169 | * @return array|false|string |
| 170 | 170 | */ |
| 171 | 171 | function urls_transition_retrouver_anciennes_url_propres(string $url_propre, string $entite, array $contexte = []): array { |
| 172 | - if ($url_propre) { |
|
| 173 | - if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 174 | - $urls_anciennes = charger_fonction_url('decoder', 'propres'); |
|
| 175 | - } else { |
|
| 176 | - $urls_anciennes = charger_fonction_url('decoder', 'arbo'); |
|
| 177 | - } |
|
| 172 | + if ($url_propre) { |
|
| 173 | + if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 174 | + $urls_anciennes = charger_fonction_url('decoder', 'propres'); |
|
| 175 | + } else { |
|
| 176 | + $urls_anciennes = charger_fonction_url('decoder', 'arbo'); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - if ($urls_anciennes) { |
|
| 180 | - $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte); |
|
| 181 | - } |
|
| 182 | - return $urls_anciennes ?: []; |
|
| 183 | - } |
|
| 179 | + if ($urls_anciennes) { |
|
| 180 | + $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte); |
|
| 181 | + } |
|
| 182 | + return $urls_anciennes ?: []; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return []; |
|
| 185 | + return []; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -195,41 +195,41 @@ discard block |
||
| 195 | 195 | * @return array|false|string |
| 196 | 196 | */ |
| 197 | 197 | function urls_transition_retrouver_anciennes_url_html(string $url, string $entite, array $contexte = []): array { |
| 198 | - // Migration depuis anciennes URLs ? |
|
| 199 | - // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23 |
|
| 200 | - if ( |
|
| 201 | - $url |
|
| 202 | - and $GLOBALS['profondeur_url'] <= 0 |
|
| 203 | - ) { |
|
| 204 | - $r = nettoyer_url_page($url, $contexte); |
|
| 205 | - if ($r) { |
|
| 206 | - [$contexte, $type, , , $suite] = $r; |
|
| 207 | - $_id = id_table_objet($type); |
|
| 208 | - $id_objet = $contexte[$_id]; |
|
| 209 | - $url_propre = generer_objet_url($id_objet, $type); |
|
| 210 | - if ( |
|
| 211 | - strlen($url_propre) |
|
| 212 | - and !strstr($url, (string) $url_propre) |
|
| 213 | - and ( |
|
| 214 | - objet_test_si_publie($type, $id_objet) |
|
| 215 | - or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet)) |
|
| 216 | - ) |
|
| 217 | - ) { |
|
| 218 | - [, $hash] = array_pad(explode('#', $url_propre), 2, null); |
|
| 219 | - $args = []; |
|
| 220 | - foreach (array_filter(explode('&', $suite)) as $fragment) { |
|
| 221 | - if ($fragment != "$_id=$id_objet") { |
|
| 222 | - $args[] = $fragment; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash); |
|
| 198 | + // Migration depuis anciennes URLs ? |
|
| 199 | + // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23 |
|
| 200 | + if ( |
|
| 201 | + $url |
|
| 202 | + and $GLOBALS['profondeur_url'] <= 0 |
|
| 203 | + ) { |
|
| 204 | + $r = nettoyer_url_page($url, $contexte); |
|
| 205 | + if ($r) { |
|
| 206 | + [$contexte, $type, , , $suite] = $r; |
|
| 207 | + $_id = id_table_objet($type); |
|
| 208 | + $id_objet = $contexte[$_id]; |
|
| 209 | + $url_propre = generer_objet_url($id_objet, $type); |
|
| 210 | + if ( |
|
| 211 | + strlen($url_propre) |
|
| 212 | + and !strstr($url, (string) $url_propre) |
|
| 213 | + and ( |
|
| 214 | + objet_test_si_publie($type, $id_objet) |
|
| 215 | + or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet)) |
|
| 216 | + ) |
|
| 217 | + ) { |
|
| 218 | + [, $hash] = array_pad(explode('#', $url_propre), 2, null); |
|
| 219 | + $args = []; |
|
| 220 | + foreach (array_filter(explode('&', $suite)) as $fragment) { |
|
| 221 | + if ($fragment != "$_id=$id_objet") { |
|
| 222 | + $args[] = $fragment; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash); |
|
| 226 | 226 | |
| 227 | - return [$contexte, $type, $url_redirect, $type]; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - /* Fin compatibilite anciennes urls */ |
|
| 232 | - return []; |
|
| 227 | + return [$contexte, $type, $url_redirect, $type]; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + /* Fin compatibilite anciennes urls */ |
|
| 232 | + return []; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -242,24 +242,24 @@ discard block |
||
| 242 | 242 | * @return string|array |
| 243 | 243 | */ |
| 244 | 244 | function urls_liste_objets($preg = true) { |
| 245 | - static $url_objets = null; |
|
| 246 | - if (is_null($url_objets)) { |
|
| 247 | - $url_objets = []; |
|
| 248 | - // recuperer les tables_objets_sql declarees |
|
| 249 | - $tables_objets = lister_tables_objets_sql(); |
|
| 250 | - foreach ($tables_objets as $t => $infos) { |
|
| 251 | - if ($infos['page']) { |
|
| 252 | - $url_objets[] = $infos['type']; |
|
| 253 | - $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 257 | - } |
|
| 258 | - if (!$preg) { |
|
| 259 | - return $url_objets; |
|
| 260 | - } |
|
| 245 | + static $url_objets = null; |
|
| 246 | + if (is_null($url_objets)) { |
|
| 247 | + $url_objets = []; |
|
| 248 | + // recuperer les tables_objets_sql declarees |
|
| 249 | + $tables_objets = lister_tables_objets_sql(); |
|
| 250 | + foreach ($tables_objets as $t => $infos) { |
|
| 251 | + if ($infos['page']) { |
|
| 252 | + $url_objets[] = $infos['type']; |
|
| 253 | + $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 257 | + } |
|
| 258 | + if (!$preg) { |
|
| 259 | + return $url_objets; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - return implode('|', array_map('preg_quote', $url_objets)); |
|
| 262 | + return implode('|', array_map('preg_quote', $url_objets)); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -273,26 +273,26 @@ discard block |
||
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | 275 | function nettoyer_url_page($url, $contexte = []) { |
| 276 | - $url_objets = urls_liste_objets(); |
|
| 277 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 276 | + $url_objets = urls_liste_objets(); |
|
| 277 | + $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | + $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 280 | 280 | |
| 281 | - if ( |
|
| 282 | - preg_match($raccourci_url_page_html, $url, $regs) |
|
| 283 | - or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 284 | - or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 285 | - ) { |
|
| 286 | - $regs = array_pad($regs, 4, null); |
|
| 287 | - $type = objet_type($regs[1]); |
|
| 288 | - $_id = id_table_objet($type); |
|
| 289 | - $contexte[$_id] = $regs[2]; |
|
| 290 | - $suite = $regs[3]; |
|
| 281 | + if ( |
|
| 282 | + preg_match($raccourci_url_page_html, $url, $regs) |
|
| 283 | + or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 284 | + or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 285 | + ) { |
|
| 286 | + $regs = array_pad($regs, 4, null); |
|
| 287 | + $type = objet_type($regs[1]); |
|
| 288 | + $_id = id_table_objet($type); |
|
| 289 | + $contexte[$_id] = $regs[2]; |
|
| 290 | + $suite = $regs[3]; |
|
| 291 | 291 | |
| 292 | - return [$contexte, $type, null, $type, $suite]; |
|
| 293 | - } |
|
| 292 | + return [$contexte, $type, null, $type, $suite]; |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | - return []; |
|
| 295 | + return []; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -310,38 +310,38 @@ discard block |
||
| 310 | 310 | * @return string |
| 311 | 311 | */ |
| 312 | 312 | function generer_objet_url_ecrire($id, string $objet, string $args = '', string $ancre = '', ?bool $public = null, string $connect = ''): string { |
| 313 | - static $furls = []; |
|
| 314 | - $id = intval($id); |
|
| 315 | - if (!isset($furls[$objet])) { |
|
| 316 | - if ( |
|
| 317 | - function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 318 | - // ou definie par un plugin |
|
| 319 | - or $f = charger_fonction($f, 'urls', true) |
|
| 320 | - // deprecated |
|
| 321 | - or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | - ) { |
|
| 323 | - $furls[$objet] = $f; |
|
| 324 | - } else { |
|
| 325 | - $furls[$objet] = ''; |
|
| 326 | - } |
|
| 327 | - } |
|
| 328 | - if ($furls[$objet]) { |
|
| 329 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 330 | - } |
|
| 331 | - // si pas de flag public fourni |
|
| 332 | - // le calculer en fonction de la declaration de statut |
|
| 333 | - if (is_null($public) and !$connect) { |
|
| 334 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 335 | - } |
|
| 336 | - if ($public or $connect) { |
|
| 337 | - return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect); |
|
| 338 | - } |
|
| 339 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 340 | - if (!function_exists('objet_info')) { |
|
| 341 | - include_spip('inc/filtres'); |
|
| 342 | - } |
|
| 313 | + static $furls = []; |
|
| 314 | + $id = intval($id); |
|
| 315 | + if (!isset($furls[$objet])) { |
|
| 316 | + if ( |
|
| 317 | + function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 318 | + // ou definie par un plugin |
|
| 319 | + or $f = charger_fonction($f, 'urls', true) |
|
| 320 | + // deprecated |
|
| 321 | + or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | + ) { |
|
| 323 | + $furls[$objet] = $f; |
|
| 324 | + } else { |
|
| 325 | + $furls[$objet] = ''; |
|
| 326 | + } |
|
| 327 | + } |
|
| 328 | + if ($furls[$objet]) { |
|
| 329 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 330 | + } |
|
| 331 | + // si pas de flag public fourni |
|
| 332 | + // le calculer en fonction de la declaration de statut |
|
| 333 | + if (is_null($public) and !$connect) { |
|
| 334 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 335 | + } |
|
| 336 | + if ($public or $connect) { |
|
| 337 | + return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect); |
|
| 338 | + } |
|
| 339 | + $a = id_table_objet($objet) . '=' . intval($id); |
|
| 340 | + if (!function_exists('objet_info')) { |
|
| 341 | + include_spip('inc/filtres'); |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 344 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -349,5 +349,5 @@ discard block |
||
| 349 | 349 | * @see generer_objet_url_ecrire |
| 350 | 350 | */ |
| 351 | 351 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, string $connect = '') { |
| 352 | - return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect); |
|
| 352 | + return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect); |
|
| 353 | 353 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ) { |
| 204 | 204 | $r = nettoyer_url_page($url, $contexte); |
| 205 | 205 | if ($r) { |
| 206 | - [$contexte, $type, , , $suite] = $r; |
|
| 206 | + [$contexte, $type,,, $suite] = $r; |
|
| 207 | 207 | $_id = id_table_objet($type); |
| 208 | 208 | $id_objet = $contexte[$_id]; |
| 209 | 209 | $url_propre = generer_objet_url($id_objet, $type); |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | function nettoyer_url_page($url, $contexte = []) { |
| 276 | 276 | $url_objets = urls_liste_objets(); |
| 277 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 277 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 278 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 279 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,'; |
|
| 280 | 280 | |
| 281 | 281 | if ( |
| 282 | 282 | preg_match($raccourci_url_page_html, $url, $regs) |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | $id = intval($id); |
| 315 | 315 | if (!isset($furls[$objet])) { |
| 316 | 316 | if ( |
| 317 | - function_exists($f = 'generer_' . $objet . '_url_ecrire') |
|
| 317 | + function_exists($f = 'generer_'.$objet.'_url_ecrire') |
|
| 318 | 318 | // ou definie par un plugin |
| 319 | 319 | or $f = charger_fonction($f, 'urls', true) |
| 320 | 320 | // deprecated |
| 321 | - or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true) |
|
| 321 | + or function_exists($f = 'generer_url_ecrire_'.$objet) or $f = charger_fonction($f, 'urls', true) |
|
| 322 | 322 | ) { |
| 323 | 323 | $furls[$objet] = $f; |
| 324 | 324 | } else { |
@@ -336,12 +336,12 @@ discard block |
||
| 336 | 336 | if ($public or $connect) { |
| 337 | 337 | return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect); |
| 338 | 338 | } |
| 339 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 339 | + $a = id_table_objet($objet).'='.intval($id); |
|
| 340 | 340 | if (!function_exists('objet_info')) { |
| 341 | 341 | include_spip('inc/filtres'); |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 344 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : ''); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/charsets'); |
| 17 | 17 | |
@@ -27,90 +27,90 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function plugins_afficher_liste_dist( |
| 30 | - $url_page, |
|
| 31 | - $liste_plugins, |
|
| 32 | - $liste_plugins_checked, |
|
| 33 | - $liste_plugins_actifs, |
|
| 34 | - $dir_plugins = _DIR_PLUGINS, |
|
| 35 | - $afficher_un = 'afficher_plugin' |
|
| 30 | + $url_page, |
|
| 31 | + $liste_plugins, |
|
| 32 | + $liste_plugins_checked, |
|
| 33 | + $liste_plugins_actifs, |
|
| 34 | + $dir_plugins = _DIR_PLUGINS, |
|
| 35 | + $afficher_un = 'afficher_plugin' |
|
| 36 | 36 | ) { |
| 37 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 37 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 39 | 39 | |
| 40 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 40 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 41 | 41 | |
| 42 | - $all_infos = pipeline( |
|
| 43 | - 'filtrer_liste_plugins', |
|
| 44 | - [ |
|
| 45 | - 'args' => [ |
|
| 46 | - 'liste_plugins' => $liste_plugins, |
|
| 47 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | - 'dir_plugins' => $dir_plugins |
|
| 50 | - ], |
|
| 51 | - 'data' => $all_infos |
|
| 52 | - ] |
|
| 53 | - ); |
|
| 42 | + $all_infos = pipeline( |
|
| 43 | + 'filtrer_liste_plugins', |
|
| 44 | + [ |
|
| 45 | + 'args' => [ |
|
| 46 | + 'liste_plugins' => $liste_plugins, |
|
| 47 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | + 'dir_plugins' => $dir_plugins |
|
| 50 | + ], |
|
| 51 | + 'data' => $all_infos |
|
| 52 | + ] |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $liste_plugins = array_flip($liste_plugins); |
|
| 56 | - foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | - if (isset($all_infos[$chemin])) { |
|
| 59 | - $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | - } else { |
|
| 61 | - unset($liste_plugins[$chemin]); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - asort($liste_plugins); |
|
| 65 | - $exposed = urldecode(_request('plugin') ?? ''); |
|
| 55 | + $liste_plugins = array_flip($liste_plugins); |
|
| 56 | + foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | + if (isset($all_infos[$chemin])) { |
|
| 59 | + $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | + } else { |
|
| 61 | + unset($liste_plugins[$chemin]); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + asort($liste_plugins); |
|
| 65 | + $exposed = urldecode(_request('plugin') ?? ''); |
|
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | - $fast_liste_plugins_actifs = []; |
|
| 69 | - $fast_liste_plugins_checked = []; |
|
| 70 | - if (is_array($liste_plugins_actifs)) { |
|
| 71 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | - } |
|
| 73 | - if (is_array($liste_plugins_checked)) { |
|
| 74 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | - } |
|
| 67 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | + $fast_liste_plugins_actifs = []; |
|
| 69 | + $fast_liste_plugins_checked = []; |
|
| 70 | + if (is_array($liste_plugins_actifs)) { |
|
| 71 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | + } |
|
| 73 | + if (is_array($liste_plugins_checked)) { |
|
| 74 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $res = ''; |
|
| 78 | - $block = ''; |
|
| 79 | - $initiale = ''; |
|
| 80 | - $block_actif = false; |
|
| 81 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | - $initiale = $i; |
|
| 85 | - $block = ''; |
|
| 86 | - $block_actif = false; |
|
| 87 | - } |
|
| 88 | - // le rep suivant |
|
| 89 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | - $block_actif = $block_actif | $actif; |
|
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | - $dir_plugins, |
|
| 94 | - strlen(_DIR_RACINE) |
|
| 95 | - ) . $plug)); |
|
| 96 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | - } |
|
| 98 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | - $class = basename($dir_plugins); |
|
| 77 | + $res = ''; |
|
| 78 | + $block = ''; |
|
| 79 | + $initiale = ''; |
|
| 80 | + $block_actif = false; |
|
| 81 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | + $initiale = $i; |
|
| 85 | + $block = ''; |
|
| 86 | + $block_actif = false; |
|
| 87 | + } |
|
| 88 | + // le rep suivant |
|
| 89 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | + $block_actif = $block_actif | $actif; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | + $dir_plugins, |
|
| 94 | + strlen(_DIR_RACINE) |
|
| 95 | + ) . $plug)); |
|
| 96 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | + } |
|
| 98 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | + $class = basename($dir_plugins); |
|
| 100 | 100 | |
| 101 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 101 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 106 | - if (strlen($block)) { |
|
| 107 | - return "<li class='item'>" |
|
| 108 | - . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | - . debut_block_depliable($block_actif) |
|
| 110 | - . "<ul>$block</ul>" |
|
| 111 | - . fin_block() |
|
| 112 | - . '</li>'; |
|
| 113 | - } |
|
| 106 | + if (strlen($block)) { |
|
| 107 | + return "<li class='item'>" |
|
| 108 | + . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | + . debut_block_depliable($block_actif) |
|
| 110 | + . "<ul>$block</ul>" |
|
| 111 | + . fin_block() |
|
| 112 | + . '</li>'; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - return ''; |
|
| 115 | + return ''; |
|
| 116 | 116 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | asort($liste_plugins); |
| 65 | 65 | $exposed = urldecode(_request('plugin') ?? ''); |
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | + $block_par_lettre = false; //count($liste_plugins)>10; |
|
| 68 | 68 | $fast_liste_plugins_actifs = []; |
| 69 | 69 | $fast_liste_plugins_checked = []; |
| 70 | 70 | if (is_array($liste_plugins_actifs)) { |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | $actif = isset($fast_liste_plugins_actifs[$plug]); |
| 90 | 90 | $checked = isset($fast_liste_plugins_checked[$plug]); |
| 91 | 91 | $block_actif = $block_actif | $actif; |
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr( |
|
| 93 | 93 | $dir_plugins, |
| 94 | 94 | strlen(_DIR_RACINE) |
| 95 | - ) . $plug)); |
|
| 96 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 95 | + ).$plug)); |
|
| 96 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins)."\n"; |
|
| 97 | 97 | } |
| 98 | 98 | $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
| 99 | 99 | $class = basename($dir_plugins); |