@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | unset($erreurs['new_login']); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 173 | + $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur='.intval($id_auteur)); |
|
| 174 | 174 | $auth_methode = ($auth_methode ?: 'spip'); |
| 175 | 175 | include_spip('inc/auth'); |
| 176 | 176 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?']) |
| 187 | 187 | and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
| 188 | 188 | and !strlen(trim($email)) |
| 189 | - and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 189 | + and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($id_auteur))) |
|
| 190 | 190 | ) { |
| 191 | 191 | $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
| 192 | 192 | } else { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | #Nouvel auteur |
| 202 | 202 | if (intval($id_auteur) == 0) { |
| 203 | 203 | #Un auteur existe deja avec cette adresse ? |
| 204 | - if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) { |
|
| 204 | + if (sql_countsel('spip_auteurs', 'email='.sql_quote($email)) > 0) { |
|
| 205 | 205 | $erreurs['email'] = _T('erreur_email_deja_existant'); |
| 206 | 206 | } |
| 207 | 207 | } else { |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | if ( |
| 210 | 210 | (sql_countsel( |
| 211 | 211 | 'spip_auteurs', |
| 212 | - 'email=' . sql_quote($email) |
|
| 212 | + 'email='.sql_quote($email) |
|
| 213 | 213 | ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel( |
| 214 | 214 | 'id_auteur', |
| 215 | 215 | 'spip_auteurs', |
| 216 | - 'email=' . sql_quote($email) |
|
| 216 | + 'email='.sql_quote($email) |
|
| 217 | 217 | ))) |
| 218 | 218 | ) { |
| 219 | 219 | $erreurs['email'] = _T('erreur_email_deja_existant'); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | // corriger un cas si frequent : www.example.org sans le http:// qui precede |
| 232 | 232 | if ($url = _request('url_site') and !tester_url_absolue($url)) { |
| 233 | 233 | if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) { |
| 234 | - $url = 'http://' . $url; |
|
| 234 | + $url = 'http://'.$url; |
|
| 235 | 235 | set_request('url_site', $url); |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | elseif ( |
| 250 | 250 | ($login = _request('new_login')) and |
| 251 | - $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
|
| 251 | + $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur)) |
|
| 252 | 252 | ) { |
| 253 | 253 | // on verifie la meme chose que dans auteurs_edit_config() |
| 254 | 254 | if ( |
| 255 | - ! auth_autoriser_modifier_login($auth_methode) |
|
| 255 | + !auth_autoriser_modifier_login($auth_methode) |
|
| 256 | 256 | or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true]) |
| 257 | 257 | // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
| 258 | 258 | or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true]) |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | if ( |
| 360 | 360 | $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
| 361 | 361 | and $email_nouveau != |
| 362 | - ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 362 | + ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($id_auteur))) |
|
| 363 | 363 | ) { |
| 364 | 364 | $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
| 365 | 365 | $texte = _T( |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | if (isset($erreurs['message_ok'])) { |
| 394 | 394 | if (!isset($res['message_ok'])) { $res['message_ok'] = ''; |
| 395 | 395 | } |
| 396 | - $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']); |
|
| 396 | + $res['message_ok'] = trim($res['message_ok'].' '.$erreurs['message_ok']); |
|
| 397 | 397 | } |
| 398 | 398 | if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) { |
| 399 | 399 | if (!isset($res['message_erreur'])) { $res['message_erreur'] = ''; |
| 400 | 400 | } |
| 401 | - $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']); |
|
| 401 | + $res['message_erreur'] = trim($res['message_erreur'].' '.$erreurs['message_erreur']); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | |
| 427 | 427 | function auteur_reset_password($id_auteur, $erreurs = []) { |
| 428 | - $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 428 | + $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($id_auteur)); |
|
| 429 | 429 | $config = auteurs_edit_config($auteur); |
| 430 | 430 | |
| 431 | 431 | if ($config['edit_pass']) { |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | include_spip('action/editer_auteur'); |
| 461 | 461 | auteur_modifier($id_auteur, $set); |
| 462 | 462 | |
| 463 | - $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 463 | + $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($id_auteur)); |
|
| 464 | 464 | include_spip('inc/filtres'); |
| 465 | 465 | if ( |
| 466 | 466 | $notifier |
@@ -245,8 +245,7 @@ discard block |
||
| 245 | 245 | if (_request('login')) { |
| 246 | 246 | // on n'est jamais cense poster le name 'login' |
| 247 | 247 | $erreurs['login'] = _T('info_non_modifiable'); |
| 248 | - } |
|
| 249 | - elseif ( |
|
| 248 | + } elseif ( |
|
| 250 | 249 | ($login = _request('new_login')) and |
| 251 | 250 | $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
| 252 | 251 | ) { |
@@ -483,8 +482,7 @@ discard block |
||
| 483 | 482 | if (!isset($contexte['lang']) or !$contexte['lang']) { |
| 484 | 483 | if (isset($row['lang']) and $row['lang']) { |
| 485 | 484 | $contexte['lang'] = $row['lang']; |
| 486 | - } |
|
| 487 | - else { |
|
| 485 | + } else { |
|
| 488 | 486 | $contexte['lang'] = $GLOBALS['meta']['langue_site']; |
| 489 | 487 | } |
| 490 | 488 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/actions'); |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | * Environnement du formulaire |
| 39 | 39 | **/ |
| 40 | 40 | function formulaires_editer_auteur_charger_dist( |
| 41 | - $id_auteur = 'new', |
|
| 42 | - $retour = '', |
|
| 43 | - $associer_objet = '', |
|
| 44 | - $config_fonc = 'auteurs_edit_config', |
|
| 45 | - $row = [], |
|
| 46 | - $hidden = '' |
|
| 41 | + $id_auteur = 'new', |
|
| 42 | + $retour = '', |
|
| 43 | + $associer_objet = '', |
|
| 44 | + $config_fonc = 'auteurs_edit_config', |
|
| 45 | + $row = [], |
|
| 46 | + $hidden = '' |
|
| 47 | 47 | ) { |
| 48 | - $valeurs = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 49 | - $valeurs['new_login'] = $valeurs['login']; |
|
| 48 | + $valeurs = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 49 | + $valeurs['new_login'] = $valeurs['login']; |
|
| 50 | 50 | |
| 51 | - // S'il n'y a pas la langue, on prend la langue du site |
|
| 52 | - $valeurs['langue'] = $valeurs['langue'] ?: $GLOBALS['meta']['langue_site']; |
|
| 51 | + // S'il n'y a pas la langue, on prend la langue du site |
|
| 52 | + $valeurs['langue'] = $valeurs['langue'] ?: $GLOBALS['meta']['langue_site']; |
|
| 53 | 53 | |
| 54 | - if (!autoriser('modifier', 'auteur', intval($id_auteur))) { |
|
| 55 | - $valeurs['editable'] = ''; |
|
| 56 | - } |
|
| 54 | + if (!autoriser('modifier', 'auteur', intval($id_auteur))) { |
|
| 55 | + $valeurs['editable'] = ''; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return $valeurs; |
|
| 58 | + return $valeurs; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * Hash du formulaire |
| 80 | 80 | */ |
| 81 | 81 | function formulaires_editer_auteur_identifier_dist( |
| 82 | - $id_auteur = 'new', |
|
| 83 | - $retour = '', |
|
| 84 | - $associer_objet = '', |
|
| 85 | - $config_fonc = 'auteurs_edit_config', |
|
| 86 | - $row = [], |
|
| 87 | - $hidden = '' |
|
| 82 | + $id_auteur = 'new', |
|
| 83 | + $retour = '', |
|
| 84 | + $associer_objet = '', |
|
| 85 | + $config_fonc = 'auteurs_edit_config', |
|
| 86 | + $row = [], |
|
| 87 | + $hidden = '' |
|
| 88 | 88 | ) { |
| 89 | - return serialize([intval($id_auteur), $associer_objet]); |
|
| 89 | + return serialize([intval($id_auteur), $associer_objet]); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -100,27 +100,27 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function auteurs_edit_config(array $row): array { |
| 102 | 102 | |
| 103 | - $config = []; |
|
| 104 | - $config['lignes'] = 8; |
|
| 105 | - $config['langue'] = $GLOBALS['spip_lang']; |
|
| 106 | - |
|
| 107 | - // pour instituer_auteur |
|
| 108 | - $config['auteur'] = $row; |
|
| 109 | - |
|
| 110 | - //$config['restreint'] = ($row['statut'] == 'publie'); |
|
| 111 | - $auth_methode = $row['source']; |
|
| 112 | - include_spip('inc/auth'); |
|
| 113 | - $config['edit_login'] = |
|
| 114 | - (auth_autoriser_modifier_login($auth_methode) |
|
| 115 | - and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['login' => true]) |
|
| 116 | - // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 117 | - and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['email' => true]) |
|
| 118 | - ); |
|
| 119 | - $config['edit_pass'] = |
|
| 120 | - (auth_autoriser_modifier_pass($auth_methode) |
|
| 121 | - and autoriser('modifier', 'auteur', $row['id_auteur'])); |
|
| 122 | - |
|
| 123 | - return $config; |
|
| 103 | + $config = []; |
|
| 104 | + $config['lignes'] = 8; |
|
| 105 | + $config['langue'] = $GLOBALS['spip_lang']; |
|
| 106 | + |
|
| 107 | + // pour instituer_auteur |
|
| 108 | + $config['auteur'] = $row; |
|
| 109 | + |
|
| 110 | + //$config['restreint'] = ($row['statut'] == 'publie'); |
|
| 111 | + $auth_methode = $row['source']; |
|
| 112 | + include_spip('inc/auth'); |
|
| 113 | + $config['edit_login'] = |
|
| 114 | + (auth_autoriser_modifier_login($auth_methode) |
|
| 115 | + and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['login' => true]) |
|
| 116 | + // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 117 | + and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['email' => true]) |
|
| 118 | + ); |
|
| 119 | + $config['edit_pass'] = |
|
| 120 | + (auth_autoriser_modifier_pass($auth_methode) |
|
| 121 | + and autoriser('modifier', 'auteur', $row['id_auteur'])); |
|
| 122 | + |
|
| 123 | + return $config; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -150,143 +150,143 @@ discard block |
||
| 150 | 150 | * Erreurs des saisies |
| 151 | 151 | **/ |
| 152 | 152 | function formulaires_editer_auteur_verifier_dist( |
| 153 | - $id_auteur = 'new', |
|
| 154 | - $retour = '', |
|
| 155 | - $associer_objet = '', |
|
| 156 | - $config_fonc = 'auteurs_edit_config', |
|
| 157 | - $row = [], |
|
| 158 | - $hidden = '' |
|
| 153 | + $id_auteur = 'new', |
|
| 154 | + $retour = '', |
|
| 155 | + $associer_objet = '', |
|
| 156 | + $config_fonc = 'auteurs_edit_config', |
|
| 157 | + $row = [], |
|
| 158 | + $hidden = '' |
|
| 159 | 159 | ) { |
| 160 | - // auto-renseigner le nom si il n'existe pas, sans couper |
|
| 161 | - titre_automatique('nom', ['email', 'login'], 255); |
|
| 162 | - |
|
| 163 | - $oblis = ['nom']; |
|
| 164 | - // si on veut renvoyer des identifiants il faut un email et un login |
|
| 165 | - if (_request('reset_password')) { |
|
| 166 | - $oblis[] = 'email'; |
|
| 167 | - $oblis[] = 'new_login'; |
|
| 168 | - } |
|
| 169 | - // mais il reste obligatoire si on a rien trouve |
|
| 170 | - $erreurs = formulaires_editer_objet_verifier('auteur', $id_auteur, $oblis); |
|
| 171 | - if (isset($erreurs['new_login'])) { |
|
| 172 | - $erreurs['login'] = $erreurs['new_login']; |
|
| 173 | - unset($erreurs['new_login']); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 177 | - $auth_methode = ($auth_methode ?: 'spip'); |
|
| 178 | - include_spip('inc/auth'); |
|
| 179 | - |
|
| 180 | - if (!nom_acceptable(_request('nom'))) { |
|
| 181 | - $erreurs['nom'] = _T('info_nom_pas_conforme'); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ($email = _request('email')) { |
|
| 185 | - include_spip('inc/filtres'); |
|
| 186 | - include_spip('inc/autoriser'); |
|
| 187 | - // un redacteur qui modifie son email n'a pas le droit de le vider si il y en avait un |
|
| 188 | - if ( |
|
| 189 | - !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?']) |
|
| 190 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 191 | - and !strlen(trim($email)) |
|
| 192 | - and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 193 | - ) { |
|
| 194 | - $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 195 | - } else { |
|
| 196 | - if (!email_valide($email)) { |
|
| 197 | - $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - # Ne pas autoriser d'avoir deux auteurs avec le même email |
|
| 201 | - # cette fonctionalité nécessite que la base soit clean à l'activation : pas de |
|
| 202 | - # doublon sur la requête select email,count(*) from spip_auteurs group by email ; |
|
| 203 | - if (defined('_INTERDIRE_AUTEUR_MEME_EMAIL')) { |
|
| 204 | - #Nouvel auteur |
|
| 205 | - if (intval($id_auteur) == 0) { |
|
| 206 | - #Un auteur existe deja avec cette adresse ? |
|
| 207 | - if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) { |
|
| 208 | - $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 209 | - } |
|
| 210 | - } else { |
|
| 211 | - #Un auteur existe deja avec cette adresse ? et n'est pas le user courant. |
|
| 212 | - if ( |
|
| 213 | - (sql_countsel( |
|
| 214 | - 'spip_auteurs', |
|
| 215 | - 'email=' . sql_quote($email) |
|
| 216 | - ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel( |
|
| 217 | - 'id_auteur', |
|
| 218 | - 'spip_auteurs', |
|
| 219 | - 'email=' . sql_quote($email) |
|
| 220 | - ))) |
|
| 221 | - ) { |
|
| 222 | - $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // quand c'est un auteur existant on fait le reset password ici |
|
| 229 | - if (!(is_countable($erreurs) ? count($erreurs) : 0) and _request('reset_password') and intval($id_auteur)) { |
|
| 230 | - $erreurs = auteur_reset_password($id_auteur, $erreurs); |
|
| 231 | - return $erreurs; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - // corriger un cas si frequent : www.example.org sans le http:// qui precede |
|
| 235 | - if ($url = _request('url_site') and !tester_url_absolue($url)) { |
|
| 236 | - if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) { |
|
| 237 | - $url = 'http://' . $url; |
|
| 238 | - set_request('url_site', $url); |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - // traiter les liens implicites avant de tester l'url |
|
| 242 | - include_spip('inc/lien'); |
|
| 243 | - if ($url = calculer_url(_request('url_site')) and !tester_url_absolue($url)) { |
|
| 244 | - $erreurs['url_site'] = _T('info_url_site_pas_conforme'); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - $erreurs['message_erreur'] = ''; |
|
| 248 | - if (_request('login')) { |
|
| 249 | - // on n'est jamais cense poster le name 'login' |
|
| 250 | - $erreurs['login'] = _T('info_non_modifiable'); |
|
| 251 | - } |
|
| 252 | - elseif ( |
|
| 253 | - ($login = _request('new_login')) and |
|
| 254 | - $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
|
| 255 | - ) { |
|
| 256 | - // on verifie la meme chose que dans auteurs_edit_config() |
|
| 257 | - if ( |
|
| 258 | - ! auth_autoriser_modifier_login($auth_methode) |
|
| 259 | - or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true]) |
|
| 260 | - // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 261 | - or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true]) |
|
| 262 | - ) { |
|
| 263 | - $erreurs['login'] = _T('info_non_modifiable'); |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (empty($erreurs['login'])) { |
|
| 268 | - if ($err = auth_verifier_login($auth_methode, _request('new_login'), $id_auteur)) { |
|
| 269 | - $erreurs['login'] = $err; |
|
| 270 | - $erreurs['message_erreur'] .= $err; |
|
| 271 | - } else { |
|
| 272 | - // pass trop court ou confirmation non identique |
|
| 273 | - if ($p = _request('new_pass')) { |
|
| 274 | - if ($p != _request('new_pass2')) { |
|
| 275 | - $erreurs['new_pass'] = _T('info_passes_identiques'); |
|
| 276 | - $erreurs['message_erreur'] .= _T('info_passes_identiques'); |
|
| 277 | - } elseif ($err = auth_verifier_pass($auth_methode, _request('new_login'), $p, $id_auteur)) { |
|
| 278 | - $erreurs['new_pass'] = $err; |
|
| 279 | - $erreurs['message_erreur'] .= $err; |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - if (!$erreurs['message_erreur']) { |
|
| 286 | - unset($erreurs['message_erreur']); |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - return $erreurs; |
|
| 160 | + // auto-renseigner le nom si il n'existe pas, sans couper |
|
| 161 | + titre_automatique('nom', ['email', 'login'], 255); |
|
| 162 | + |
|
| 163 | + $oblis = ['nom']; |
|
| 164 | + // si on veut renvoyer des identifiants il faut un email et un login |
|
| 165 | + if (_request('reset_password')) { |
|
| 166 | + $oblis[] = 'email'; |
|
| 167 | + $oblis[] = 'new_login'; |
|
| 168 | + } |
|
| 169 | + // mais il reste obligatoire si on a rien trouve |
|
| 170 | + $erreurs = formulaires_editer_objet_verifier('auteur', $id_auteur, $oblis); |
|
| 171 | + if (isset($erreurs['new_login'])) { |
|
| 172 | + $erreurs['login'] = $erreurs['new_login']; |
|
| 173 | + unset($erreurs['new_login']); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 177 | + $auth_methode = ($auth_methode ?: 'spip'); |
|
| 178 | + include_spip('inc/auth'); |
|
| 179 | + |
|
| 180 | + if (!nom_acceptable(_request('nom'))) { |
|
| 181 | + $erreurs['nom'] = _T('info_nom_pas_conforme'); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ($email = _request('email')) { |
|
| 185 | + include_spip('inc/filtres'); |
|
| 186 | + include_spip('inc/autoriser'); |
|
| 187 | + // un redacteur qui modifie son email n'a pas le droit de le vider si il y en avait un |
|
| 188 | + if ( |
|
| 189 | + !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?']) |
|
| 190 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 191 | + and !strlen(trim($email)) |
|
| 192 | + and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 193 | + ) { |
|
| 194 | + $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 195 | + } else { |
|
| 196 | + if (!email_valide($email)) { |
|
| 197 | + $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email')); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + # Ne pas autoriser d'avoir deux auteurs avec le même email |
|
| 201 | + # cette fonctionalité nécessite que la base soit clean à l'activation : pas de |
|
| 202 | + # doublon sur la requête select email,count(*) from spip_auteurs group by email ; |
|
| 203 | + if (defined('_INTERDIRE_AUTEUR_MEME_EMAIL')) { |
|
| 204 | + #Nouvel auteur |
|
| 205 | + if (intval($id_auteur) == 0) { |
|
| 206 | + #Un auteur existe deja avec cette adresse ? |
|
| 207 | + if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) { |
|
| 208 | + $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 209 | + } |
|
| 210 | + } else { |
|
| 211 | + #Un auteur existe deja avec cette adresse ? et n'est pas le user courant. |
|
| 212 | + if ( |
|
| 213 | + (sql_countsel( |
|
| 214 | + 'spip_auteurs', |
|
| 215 | + 'email=' . sql_quote($email) |
|
| 216 | + ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel( |
|
| 217 | + 'id_auteur', |
|
| 218 | + 'spip_auteurs', |
|
| 219 | + 'email=' . sql_quote($email) |
|
| 220 | + ))) |
|
| 221 | + ) { |
|
| 222 | + $erreurs['email'] = _T('erreur_email_deja_existant'); |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // quand c'est un auteur existant on fait le reset password ici |
|
| 229 | + if (!(is_countable($erreurs) ? count($erreurs) : 0) and _request('reset_password') and intval($id_auteur)) { |
|
| 230 | + $erreurs = auteur_reset_password($id_auteur, $erreurs); |
|
| 231 | + return $erreurs; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + // corriger un cas si frequent : www.example.org sans le http:// qui precede |
|
| 235 | + if ($url = _request('url_site') and !tester_url_absolue($url)) { |
|
| 236 | + if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) { |
|
| 237 | + $url = 'http://' . $url; |
|
| 238 | + set_request('url_site', $url); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + // traiter les liens implicites avant de tester l'url |
|
| 242 | + include_spip('inc/lien'); |
|
| 243 | + if ($url = calculer_url(_request('url_site')) and !tester_url_absolue($url)) { |
|
| 244 | + $erreurs['url_site'] = _T('info_url_site_pas_conforme'); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + $erreurs['message_erreur'] = ''; |
|
| 248 | + if (_request('login')) { |
|
| 249 | + // on n'est jamais cense poster le name 'login' |
|
| 250 | + $erreurs['login'] = _T('info_non_modifiable'); |
|
| 251 | + } |
|
| 252 | + elseif ( |
|
| 253 | + ($login = _request('new_login')) and |
|
| 254 | + $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)) |
|
| 255 | + ) { |
|
| 256 | + // on verifie la meme chose que dans auteurs_edit_config() |
|
| 257 | + if ( |
|
| 258 | + ! auth_autoriser_modifier_login($auth_methode) |
|
| 259 | + or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true]) |
|
| 260 | + // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email |
|
| 261 | + or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true]) |
|
| 262 | + ) { |
|
| 263 | + $erreurs['login'] = _T('info_non_modifiable'); |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (empty($erreurs['login'])) { |
|
| 268 | + if ($err = auth_verifier_login($auth_methode, _request('new_login'), $id_auteur)) { |
|
| 269 | + $erreurs['login'] = $err; |
|
| 270 | + $erreurs['message_erreur'] .= $err; |
|
| 271 | + } else { |
|
| 272 | + // pass trop court ou confirmation non identique |
|
| 273 | + if ($p = _request('new_pass')) { |
|
| 274 | + if ($p != _request('new_pass2')) { |
|
| 275 | + $erreurs['new_pass'] = _T('info_passes_identiques'); |
|
| 276 | + $erreurs['message_erreur'] .= _T('info_passes_identiques'); |
|
| 277 | + } elseif ($err = auth_verifier_pass($auth_methode, _request('new_login'), $p, $id_auteur)) { |
|
| 278 | + $erreurs['new_pass'] = $err; |
|
| 279 | + $erreurs['message_erreur'] .= $err; |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + if (!$erreurs['message_erreur']) { |
|
| 286 | + unset($erreurs['message_erreur']); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + return $erreurs; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | |
@@ -323,154 +323,154 @@ discard block |
||
| 323 | 323 | * Retour des traitements |
| 324 | 324 | **/ |
| 325 | 325 | function formulaires_editer_auteur_traiter_dist( |
| 326 | - $id_auteur = 'new', |
|
| 327 | - $retour = '', |
|
| 328 | - $associer_objet = '', |
|
| 329 | - $config_fonc = 'auteurs_edit_config', |
|
| 330 | - $row = [], |
|
| 331 | - $hidden = '' |
|
| 326 | + $id_auteur = 'new', |
|
| 327 | + $retour = '', |
|
| 328 | + $associer_objet = '', |
|
| 329 | + $config_fonc = 'auteurs_edit_config', |
|
| 330 | + $row = [], |
|
| 331 | + $hidden = '' |
|
| 332 | 332 | ) { |
| 333 | - if (_request('saisie_webmestre') or _request('webmestre')) { |
|
| 334 | - set_request('webmestre', _request('webmestre') ?: 'non'); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - // si il y a des modifs sensibles (statut, mot de passe), on refuse le traitement en ajax |
|
| 338 | - // le formulaire ne peut être traité depuis une XMLHttpRequest |
|
| 339 | - $prev = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 340 | - if ( |
|
| 341 | - _request('new_pass') // nouveau mot de passe |
|
| 342 | - or empty($prev['statut']) // creation auteur |
|
| 343 | - or (_request('email') and $prev['email'] !== _request('email')) // modification email |
|
| 344 | - or (_request('statut') === '0minirezo' and $prev['statut'] !== '0minirezo') // promotion 0minirezo |
|
| 345 | - or (_request('statut') and intval(_request('statut')) < intval($prev['statut'])) // promotion de statut |
|
| 346 | - or (_request('webmestre') and _request('webmestre') !== 'non' and $prev['webmestre'] !== 'oui') // promotion webmestre |
|
| 347 | - ) { |
|
| 348 | - refuser_traiter_formulaire_ajax(); |
|
| 349 | - // si on arrive là encore en ajax c'est pas OK, on genere une erreur |
|
| 350 | - if (_AJAX or !empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
|
| 351 | - return [ |
|
| 352 | - 'message_erreur' => _T('erreur_technique_ajaxform') |
|
| 353 | - ]; |
|
| 354 | - } |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - $id_objet = null; |
|
| 358 | - $retour = parametre_url($retour, 'email_confirm', ''); |
|
| 359 | - |
|
| 360 | - if ($restreintes = _request('restreintes')) { |
|
| 361 | - foreach ($restreintes as $k => $v) { |
|
| 362 | - if (strpos($v, 'rubrique|') === 0) { |
|
| 363 | - $restreintes[$k] = substr($v, 9); |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - set_request('restreintes', $restreintes); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - set_request( |
|
| 370 | - 'email', |
|
| 371 | - email_valide(_request('email')) |
|
| 372 | - ); // eviter d'enregistrer les cas qui sont acceptés par email_valide dans le verifier : |
|
| 373 | - // "[email protected] " ou encore "Marie Toto <[email protected]>" |
|
| 374 | - |
|
| 375 | - include_spip('inc/autoriser'); |
|
| 376 | - if (!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])) { |
|
| 377 | - $email_nouveau = _request('email'); |
|
| 378 | - set_request('email'); // vider la saisie car l'auteur n'a pas le droit de modifier cet email |
|
| 379 | - // mais si c'est son propre profil on lui envoie un email à l'adresse qu'il a indique |
|
| 380 | - // pour qu'il confirme qu'il possede bien cette adresse |
|
| 381 | - // son clic sur l'url du message permettre de confirmer le changement |
|
| 382 | - // et de revenir sur son profil |
|
| 383 | - if ( |
|
| 384 | - $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 385 | - and $email_nouveau != |
|
| 386 | - ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 387 | - ) { |
|
| 388 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 389 | - $texte = _T( |
|
| 390 | - 'form_auteur_mail_confirmation', |
|
| 391 | - [ |
|
| 392 | - 'url' => generer_action_auteur( |
|
| 393 | - 'confirmer_email', |
|
| 394 | - $email_nouveau, |
|
| 395 | - parametre_url($retour, 'email_modif', 'ok') |
|
| 396 | - ) |
|
| 397 | - ] |
|
| 398 | - ); |
|
| 399 | - $envoyer_mail($email_nouveau, _T('form_auteur_confirmation'), $texte); |
|
| 400 | - set_request('email_confirm', $email_nouveau); |
|
| 401 | - if ($email_ancien) { |
|
| 402 | - $envoyer_mail( |
|
| 403 | - $email_ancien, |
|
| 404 | - _T('form_auteur_confirmation'), |
|
| 405 | - _T('form_auteur_envoi_mail_confirmation', ['email' => $email_nouveau]) |
|
| 406 | - ); |
|
| 407 | - } |
|
| 408 | - $retour = parametre_url($retour, 'email_confirm', $email_nouveau); |
|
| 409 | - } |
|
| 410 | - } |
|
| 333 | + if (_request('saisie_webmestre') or _request('webmestre')) { |
|
| 334 | + set_request('webmestre', _request('webmestre') ?: 'non'); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + // si il y a des modifs sensibles (statut, mot de passe), on refuse le traitement en ajax |
|
| 338 | + // le formulaire ne peut être traité depuis une XMLHttpRequest |
|
| 339 | + $prev = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 340 | + if ( |
|
| 341 | + _request('new_pass') // nouveau mot de passe |
|
| 342 | + or empty($prev['statut']) // creation auteur |
|
| 343 | + or (_request('email') and $prev['email'] !== _request('email')) // modification email |
|
| 344 | + or (_request('statut') === '0minirezo' and $prev['statut'] !== '0minirezo') // promotion 0minirezo |
|
| 345 | + or (_request('statut') and intval(_request('statut')) < intval($prev['statut'])) // promotion de statut |
|
| 346 | + or (_request('webmestre') and _request('webmestre') !== 'non' and $prev['webmestre'] !== 'oui') // promotion webmestre |
|
| 347 | + ) { |
|
| 348 | + refuser_traiter_formulaire_ajax(); |
|
| 349 | + // si on arrive là encore en ajax c'est pas OK, on genere une erreur |
|
| 350 | + if (_AJAX or !empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
|
| 351 | + return [ |
|
| 352 | + 'message_erreur' => _T('erreur_technique_ajaxform') |
|
| 353 | + ]; |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + $id_objet = null; |
|
| 358 | + $retour = parametre_url($retour, 'email_confirm', ''); |
|
| 359 | + |
|
| 360 | + if ($restreintes = _request('restreintes')) { |
|
| 361 | + foreach ($restreintes as $k => $v) { |
|
| 362 | + if (strpos($v, 'rubrique|') === 0) { |
|
| 363 | + $restreintes[$k] = substr($v, 9); |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + set_request('restreintes', $restreintes); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + set_request( |
|
| 370 | + 'email', |
|
| 371 | + email_valide(_request('email')) |
|
| 372 | + ); // eviter d'enregistrer les cas qui sont acceptés par email_valide dans le verifier : |
|
| 373 | + // "[email protected] " ou encore "Marie Toto <[email protected]>" |
|
| 374 | + |
|
| 375 | + include_spip('inc/autoriser'); |
|
| 376 | + if (!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])) { |
|
| 377 | + $email_nouveau = _request('email'); |
|
| 378 | + set_request('email'); // vider la saisie car l'auteur n'a pas le droit de modifier cet email |
|
| 379 | + // mais si c'est son propre profil on lui envoie un email à l'adresse qu'il a indique |
|
| 380 | + // pour qu'il confirme qu'il possede bien cette adresse |
|
| 381 | + // son clic sur l'url du message permettre de confirmer le changement |
|
| 382 | + // et de revenir sur son profil |
|
| 383 | + if ( |
|
| 384 | + $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 385 | + and $email_nouveau != |
|
| 386 | + ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))) |
|
| 387 | + ) { |
|
| 388 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 389 | + $texte = _T( |
|
| 390 | + 'form_auteur_mail_confirmation', |
|
| 391 | + [ |
|
| 392 | + 'url' => generer_action_auteur( |
|
| 393 | + 'confirmer_email', |
|
| 394 | + $email_nouveau, |
|
| 395 | + parametre_url($retour, 'email_modif', 'ok') |
|
| 396 | + ) |
|
| 397 | + ] |
|
| 398 | + ); |
|
| 399 | + $envoyer_mail($email_nouveau, _T('form_auteur_confirmation'), $texte); |
|
| 400 | + set_request('email_confirm', $email_nouveau); |
|
| 401 | + if ($email_ancien) { |
|
| 402 | + $envoyer_mail( |
|
| 403 | + $email_ancien, |
|
| 404 | + _T('form_auteur_confirmation'), |
|
| 405 | + _T('form_auteur_envoi_mail_confirmation', ['email' => $email_nouveau]) |
|
| 406 | + ); |
|
| 407 | + } |
|
| 408 | + $retour = parametre_url($retour, 'email_confirm', $email_nouveau); |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - // Trafic de langue pour enregistrer la bonne |
|
| 413 | - if ($langue = _request('langue')) { |
|
| 414 | - set_request('lang', $langue); |
|
| 415 | - } |
|
| 412 | + // Trafic de langue pour enregistrer la bonne |
|
| 413 | + if ($langue = _request('langue')) { |
|
| 414 | + set_request('lang', $langue); |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | - $res = formulaires_editer_objet_traiter('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 418 | - |
|
| 419 | - if (_request('reset_password') and !intval($id_auteur) and intval($res['id_auteur'])) { |
|
| 420 | - $erreurs = []; |
|
| 421 | - $erreurs = auteur_reset_password($res['id_auteur'], $erreurs); |
|
| 422 | - if (isset($erreurs['message_ok'])) { |
|
| 423 | - if (!isset($res['message_ok'])) { $res['message_ok'] = ''; |
|
| 424 | - } |
|
| 425 | - $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']); |
|
| 426 | - } |
|
| 427 | - if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) { |
|
| 428 | - if (!isset($res['message_erreur'])) { $res['message_erreur'] = ''; |
|
| 429 | - } |
|
| 430 | - $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - // Un lien auteur a prendre en compte ? |
|
| 435 | - if ($associer_objet and $id_auteur = $res['id_auteur']) { |
|
| 436 | - $objet = ''; |
|
| 437 | - if (intval($associer_objet)) { |
|
| 438 | - $objet = 'article'; |
|
| 439 | - $id_objet = intval($associer_objet); |
|
| 440 | - } elseif (preg_match(',^\w+\|[0-9]+$,', $associer_objet)) { |
|
| 441 | - [$objet, $id_objet] = explode('|', $associer_objet); |
|
| 442 | - } |
|
| 443 | - if ($objet and $id_objet and autoriser('modifier', $objet, $id_objet)) { |
|
| 444 | - include_spip('action/editer_auteur'); |
|
| 445 | - auteur_associer($id_auteur, [$objet => $id_objet]); |
|
| 446 | - if (isset($res['redirect'])) { |
|
| 447 | - $res['redirect'] = parametre_url($res['redirect'], 'id_lien_ajoute', $id_auteur, '&'); |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - return $res; |
|
| 417 | + $res = formulaires_editer_objet_traiter('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden); |
|
| 418 | + |
|
| 419 | + if (_request('reset_password') and !intval($id_auteur) and intval($res['id_auteur'])) { |
|
| 420 | + $erreurs = []; |
|
| 421 | + $erreurs = auteur_reset_password($res['id_auteur'], $erreurs); |
|
| 422 | + if (isset($erreurs['message_ok'])) { |
|
| 423 | + if (!isset($res['message_ok'])) { $res['message_ok'] = ''; |
|
| 424 | + } |
|
| 425 | + $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']); |
|
| 426 | + } |
|
| 427 | + if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) { |
|
| 428 | + if (!isset($res['message_erreur'])) { $res['message_erreur'] = ''; |
|
| 429 | + } |
|
| 430 | + $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + // Un lien auteur a prendre en compte ? |
|
| 435 | + if ($associer_objet and $id_auteur = $res['id_auteur']) { |
|
| 436 | + $objet = ''; |
|
| 437 | + if (intval($associer_objet)) { |
|
| 438 | + $objet = 'article'; |
|
| 439 | + $id_objet = intval($associer_objet); |
|
| 440 | + } elseif (preg_match(',^\w+\|[0-9]+$,', $associer_objet)) { |
|
| 441 | + [$objet, $id_objet] = explode('|', $associer_objet); |
|
| 442 | + } |
|
| 443 | + if ($objet and $id_objet and autoriser('modifier', $objet, $id_objet)) { |
|
| 444 | + include_spip('action/editer_auteur'); |
|
| 445 | + auteur_associer($id_auteur, [$objet => $id_objet]); |
|
| 446 | + if (isset($res['redirect'])) { |
|
| 447 | + $res['redirect'] = parametre_url($res['redirect'], 'id_lien_ajoute', $id_auteur, '&'); |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + return $res; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
| 456 | 456 | function auteur_reset_password($id_auteur, $erreurs = []) { |
| 457 | - $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 458 | - $config = auteurs_edit_config($auteur); |
|
| 459 | - |
|
| 460 | - if ($config['edit_pass']) { |
|
| 461 | - if ($email = auteur_regenerer_identifiants($id_auteur)) { |
|
| 462 | - $erreurs['message_ok'] = _T('message_nouveaux_identifiants_ok', ['email' => $email]); |
|
| 463 | - $erreurs['message_erreur'] = ''; |
|
| 464 | - } elseif ($email === false) { |
|
| 465 | - $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec_envoi'); |
|
| 466 | - } else { |
|
| 467 | - $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 468 | - } |
|
| 469 | - } else { |
|
| 470 | - $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - return $erreurs; |
|
| 457 | + $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 458 | + $config = auteurs_edit_config($auteur); |
|
| 459 | + |
|
| 460 | + if ($config['edit_pass']) { |
|
| 461 | + if ($email = auteur_regenerer_identifiants($id_auteur)) { |
|
| 462 | + $erreurs['message_ok'] = _T('message_nouveaux_identifiants_ok', ['email' => $email]); |
|
| 463 | + $erreurs['message_erreur'] = ''; |
|
| 464 | + } elseif ($email === false) { |
|
| 465 | + $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec_envoi'); |
|
| 466 | + } else { |
|
| 467 | + $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 468 | + } |
|
| 469 | + } else { |
|
| 470 | + $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec'); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + return $erreurs; |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -481,53 +481,53 @@ discard block |
||
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | 483 | function auteur_regenerer_identifiants($id_auteur, $notifier = true, $contexte = []) { |
| 484 | - if ($id_auteur) { |
|
| 485 | - $set = []; |
|
| 486 | - include_spip('inc/access'); |
|
| 487 | - $set['pass'] = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16)); |
|
| 488 | - |
|
| 489 | - include_spip('action/editer_auteur'); |
|
| 490 | - auteur_modifier($id_auteur, $set); |
|
| 491 | - |
|
| 492 | - $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 493 | - include_spip('inc/filtres'); |
|
| 494 | - if ( |
|
| 495 | - $notifier |
|
| 496 | - and $row['email'] |
|
| 497 | - and email_valide($row['email']) |
|
| 498 | - and trouver_fond($fond = 'modeles/mail_nouveaux_identifiants') |
|
| 499 | - ) { |
|
| 500 | - // envoyer l'email avec login/pass |
|
| 501 | - $c = [ |
|
| 502 | - 'id_auteur' => $id_auteur, |
|
| 503 | - 'nom' => $row['nom'], |
|
| 504 | - 'mode' => $row['statut'], |
|
| 505 | - 'email' => $row['email'], |
|
| 506 | - 'pass' => $set['pass'], |
|
| 507 | - ]; |
|
| 508 | - // on merge avec les champs fournit en appel, qui sont passes au modele de notification donc |
|
| 509 | - $contexte = array_merge($contexte, $c); |
|
| 510 | - // si pas de langue explicitement demandee, prendre celle de l'auteur si on la connait, ou a defaut celle du site |
|
| 511 | - // plutot que celle de l'admin qui vient de cliquer sur le bouton |
|
| 512 | - if (!isset($contexte['lang']) or !$contexte['lang']) { |
|
| 513 | - if (isset($row['lang']) and $row['lang']) { |
|
| 514 | - $contexte['lang'] = $row['lang']; |
|
| 515 | - } |
|
| 516 | - else { |
|
| 517 | - $contexte['lang'] = $GLOBALS['meta']['langue_site']; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - lang_select($contexte['lang']); |
|
| 521 | - $message = recuperer_fond($fond, $contexte); |
|
| 522 | - include_spip('inc/notifications'); |
|
| 523 | - notifications_envoyer_mails($row['email'], $message); |
|
| 524 | - lang_select(); |
|
| 525 | - |
|
| 526 | - return $row['email']; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return false; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - return ''; |
|
| 484 | + if ($id_auteur) { |
|
| 485 | + $set = []; |
|
| 486 | + include_spip('inc/access'); |
|
| 487 | + $set['pass'] = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16)); |
|
| 488 | + |
|
| 489 | + include_spip('action/editer_auteur'); |
|
| 490 | + auteur_modifier($id_auteur, $set); |
|
| 491 | + |
|
| 492 | + $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)); |
|
| 493 | + include_spip('inc/filtres'); |
|
| 494 | + if ( |
|
| 495 | + $notifier |
|
| 496 | + and $row['email'] |
|
| 497 | + and email_valide($row['email']) |
|
| 498 | + and trouver_fond($fond = 'modeles/mail_nouveaux_identifiants') |
|
| 499 | + ) { |
|
| 500 | + // envoyer l'email avec login/pass |
|
| 501 | + $c = [ |
|
| 502 | + 'id_auteur' => $id_auteur, |
|
| 503 | + 'nom' => $row['nom'], |
|
| 504 | + 'mode' => $row['statut'], |
|
| 505 | + 'email' => $row['email'], |
|
| 506 | + 'pass' => $set['pass'], |
|
| 507 | + ]; |
|
| 508 | + // on merge avec les champs fournit en appel, qui sont passes au modele de notification donc |
|
| 509 | + $contexte = array_merge($contexte, $c); |
|
| 510 | + // si pas de langue explicitement demandee, prendre celle de l'auteur si on la connait, ou a defaut celle du site |
|
| 511 | + // plutot que celle de l'admin qui vient de cliquer sur le bouton |
|
| 512 | + if (!isset($contexte['lang']) or !$contexte['lang']) { |
|
| 513 | + if (isset($row['lang']) and $row['lang']) { |
|
| 514 | + $contexte['lang'] = $row['lang']; |
|
| 515 | + } |
|
| 516 | + else { |
|
| 517 | + $contexte['lang'] = $GLOBALS['meta']['langue_site']; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + lang_select($contexte['lang']); |
|
| 521 | + $message = recuperer_fond($fond, $contexte); |
|
| 522 | + include_spip('inc/notifications'); |
|
| 523 | + notifications_envoyer_mails($row['email'], $message); |
|
| 524 | + lang_select(); |
|
| 525 | + |
|
| 526 | + return $row['email']; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return false; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + return ''; |
|
| 533 | 533 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if ($objet == 'rubrique') { |
| 115 | 115 | // si c'est une rubrique-secteur contenant des breves, demander la |
| 116 | 116 | // confirmation du deplacement |
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique='.intval($id_objet)); |
|
| 118 | 118 | |
| 119 | 119 | if ($contient_breves > 0) { |
| 120 | 120 | $scb = ($contient_breves > 1 ? 's' : ''); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | ); |
| 128 | 128 | $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
| 129 | 129 | . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
| 130 | - . $scb . |
|
| 130 | + . $scb. |
|
| 131 | 131 | "</label></div></div>\n"; |
| 132 | 132 | } else { |
| 133 | 133 | $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | $form .= $confirm; |
| 137 | 137 | if ($actionable) { |
| 138 | 138 | if (strpos($form, '<select') !== false) { |
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 139 | + $form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 141 | 141 | . '</div>'; |
| 142 | 142 | } |
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form; |
|
| 144 | 144 | if ($action = charger_fonction("editer_$objet", 'action', true)) { |
| 145 | 145 | $form = generer_action_auteur( |
| 146 | 146 | "editer_$objet", |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | include_spip('inc/presentation'); |
| 168 | 168 | |
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | if ($statut == 'nouveau') { |
| 243 | 243 | if ($attente) { |
| 244 | 244 | $statut = $attente; |
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 245 | + $plus = ' ('._T('info_statut_auteur_a_confirmer').')'; |
|
| 246 | 246 | } else { |
| 247 | 247 | return _T('info_statut_auteur_a_confirmer'); |
| 248 | 248 | } |
@@ -255,16 +255,16 @@ discard block |
||
| 255 | 255 | '5poubelle' => _T('texte_statut_poubelle'), // bouh |
| 256 | 256 | ]; |
| 257 | 257 | if (isset($recom[$statut])) { |
| 258 | - return $recom[$statut] . $plus; |
|
| 258 | + return $recom[$statut].$plus; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | // retrouver directement par le statut sinon |
| 262 | 262 | if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
| 263 | 263 | if (isset($recom[$t])) { |
| 264 | - return $recom[$t] . $plus; |
|
| 264 | + return $recom[$t].$plus; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - return _T($t) . $plus; |
|
| 267 | + return _T($t).$plus; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // si on a pas reussi a le traduire, retournons la chaine telle quelle |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
| 389 | 389 | $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
| 390 | 390 | ? '' |
| 391 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 391 | + : (' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 392 | 392 | |
| 393 | 393 | // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
| 394 | 394 | if ($objet == 'rubrique') { |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | return ''; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - return propre('[->' . $virtuel . ']'); |
|
| 425 | + return propre('[->'.$virtuel.']'); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
| 450 | 450 | |
| 451 | 451 | $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
| 452 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 452 | + return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | ); |
| 526 | 526 | |
| 527 | 527 | if ($alertes = array_filter($alertes)) { |
| 528 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 528 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 529 | 529 | join(' | ', $alertes) |
| 530 | 530 | . '</div></div>'; |
| 531 | 531 | } |
@@ -559,13 +559,13 @@ discard block |
||
| 559 | 559 | */ |
| 560 | 560 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 561 | 561 | $titre = attribut_html($titre); |
| 562 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 563 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>". |
|
| 563 | + http_img_pack('information-16.png', $titre).'</a>'; |
|
| 564 | 564 | |
| 565 | 565 | if (!$titre_lien) { |
| 566 | 566 | return $icone; |
| 567 | 567 | } else { |
| 568 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + return $icone."\n<a href='$lien'>$titre_lien</a>"; |
|
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,91 +82,91 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | - |
|
| 119 | - if ($contient_breves > 0) { |
|
| 120 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | - $scb = _T( |
|
| 122 | - 'avis_deplacement_rubrique', |
|
| 123 | - [ |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - ] |
|
| 127 | - ); |
|
| 128 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | - . $scb . |
|
| 131 | - "</label></div></div>\n"; |
|
| 132 | - } else { |
|
| 133 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $form .= $confirm; |
|
| 137 | - if ($actionable) { |
|
| 138 | - if (strpos($form, '<select') !== false) { |
|
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | - . '</div>'; |
|
| 142 | - } |
|
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | - $form = generer_action_auteur( |
|
| 146 | - "editer_$objet", |
|
| 147 | - $id_objet, |
|
| 148 | - self(), |
|
| 149 | - $form, |
|
| 150 | - " method='post' class='submit_plongeur'" |
|
| 151 | - ); |
|
| 152 | - } else { |
|
| 153 | - $form = generer_action_auteur( |
|
| 154 | - 'editer_objet', |
|
| 155 | - "$objet/$id_objet", |
|
| 156 | - self(), |
|
| 157 | - $form, |
|
| 158 | - " method='post' class='submit_plongeur'" |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ($retour_sans_cadre) { |
|
| 164 | - return $form; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - include_spip('inc/presentation'); |
|
| 168 | - |
|
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | + |
|
| 119 | + if ($contient_breves > 0) { |
|
| 120 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | + $scb = _T( |
|
| 122 | + 'avis_deplacement_rubrique', |
|
| 123 | + [ |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + ] |
|
| 127 | + ); |
|
| 128 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | + . $scb . |
|
| 131 | + "</label></div></div>\n"; |
|
| 132 | + } else { |
|
| 133 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $form .= $confirm; |
|
| 137 | + if ($actionable) { |
|
| 138 | + if (strpos($form, '<select') !== false) { |
|
| 139 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + . '</div>'; |
|
| 142 | + } |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | + $form = generer_action_auteur( |
|
| 146 | + "editer_$objet", |
|
| 147 | + $id_objet, |
|
| 148 | + self(), |
|
| 149 | + $form, |
|
| 150 | + " method='post' class='submit_plongeur'" |
|
| 151 | + ); |
|
| 152 | + } else { |
|
| 153 | + $form = generer_action_auteur( |
|
| 154 | + 'editer_objet', |
|
| 155 | + "$objet/$id_objet", |
|
| 156 | + self(), |
|
| 157 | + $form, |
|
| 158 | + " method='post' class='submit_plongeur'" |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ($retour_sans_cadre) { |
|
| 164 | + return $form; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + include_spip('inc/presentation'); |
|
| 168 | + |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | 182 | function avoir_visiteurs($past = false, $accepter = true) { |
| 183 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | - return true; |
|
| 185 | - } |
|
| 186 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (!$past) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return sql_countsel( |
|
| 197 | - 'spip_auteurs', |
|
| 198 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 183 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | + return true; |
|
| 185 | + } |
|
| 186 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (!$past) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return sql_countsel( |
|
| 197 | + 'spip_auteurs', |
|
| 198 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 199 | 199 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 200 | - ); |
|
| 200 | + ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function statuts_articles_visibles($statut_auteur) { |
| 216 | - static $auth = []; |
|
| 217 | - if (!isset($auth[$statut_auteur])) { |
|
| 218 | - $auth[$statut_auteur] = []; |
|
| 219 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | - foreach ($statuts as $s) { |
|
| 221 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | - $auth[$statut_auteur][] = $s; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $auth[$statut_auteur]; |
|
| 216 | + static $auth = []; |
|
| 217 | + if (!isset($auth[$statut_auteur])) { |
|
| 218 | + $auth[$statut_auteur] = []; |
|
| 219 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | + foreach ($statuts as $s) { |
|
| 221 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | + $auth[$statut_auteur][] = $s; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $auth[$statut_auteur]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -238,38 +238,38 @@ discard block |
||
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | 240 | function traduire_statut_auteur($statut, $attente = '') { |
| 241 | - $plus = ''; |
|
| 242 | - if ($statut == 'nouveau') { |
|
| 243 | - if ($attente) { |
|
| 244 | - $statut = $attente; |
|
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | - } else { |
|
| 247 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $recom = [ |
|
| 252 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | - ]; |
|
| 257 | - if (isset($recom[$statut])) { |
|
| 258 | - return $recom[$statut] . $plus; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // retrouver directement par le statut sinon |
|
| 262 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | - if (isset($recom[$t])) { |
|
| 264 | - return $recom[$t] . $plus; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return _T($t) . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | - // c'est toujours plus informatif que rien du tout |
|
| 272 | - return $statut; |
|
| 241 | + $plus = ''; |
|
| 242 | + if ($statut == 'nouveau') { |
|
| 243 | + if ($attente) { |
|
| 244 | + $statut = $attente; |
|
| 245 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | + } else { |
|
| 247 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $recom = [ |
|
| 252 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | + ]; |
|
| 257 | + if (isset($recom[$statut])) { |
|
| 258 | + return $recom[$statut] . $plus; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // retrouver directement par le statut sinon |
|
| 262 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | + if (isset($recom[$t])) { |
|
| 264 | + return $recom[$t] . $plus; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return _T($t) . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | + // c'est toujours plus informatif que rien du tout |
|
| 272 | + return $statut; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,29 +280,29 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet): string { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - include_spip('inc/config'); |
|
| 289 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | - return $qui[$objet][$id_objet] = ''; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - include_spip('inc/drapeau_edition'); |
|
| 294 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | - if (!$modif) { |
|
| 296 | - return $qui[$objet][$id_objet] = ''; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - include_spip('base/objets'); |
|
| 300 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | - if (isset($infos['texte_signale_edition'])) { |
|
| 302 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 283 | + static $qui = []; |
|
| 284 | + if (isset($qui[$objet][$id_objet])) { |
|
| 285 | + return $qui[$objet][$id_objet]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + include_spip('inc/config'); |
|
| 289 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | + return $qui[$objet][$id_objet] = ''; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + include_spip('inc/drapeau_edition'); |
|
| 294 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | + if (!$modif) { |
|
| 296 | + return $qui[$objet][$id_objet] = ''; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + include_spip('base/objets'); |
|
| 300 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | + if (isset($infos['texte_signale_edition'])) { |
|
| 302 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -320,53 +320,53 @@ discard block |
||
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | 322 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 323 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - switch ($quoi) { |
|
| 328 | - case 'redacteurs': |
|
| 329 | - $statut = AUTEURS_MIN_REDAC; |
|
| 330 | - $statut = explode(',', $statut); |
|
| 331 | - if ($en_base) { |
|
| 332 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | - $retire = array_diff($statut, $check); |
|
| 334 | - $statut = array_diff($statut, $retire); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return array_unique($statut); |
|
| 338 | - |
|
| 339 | - case 'visiteurs': |
|
| 340 | - $statut = []; |
|
| 341 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | - $exclus = explode(',', $exclus); |
|
| 343 | - if (!$en_base) { |
|
| 344 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | - } |
|
| 347 | - $s_complement = array_column( |
|
| 348 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | - 'statut' |
|
| 350 | - ); |
|
| 351 | - |
|
| 352 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | - |
|
| 354 | - default: |
|
| 355 | - case 'tous': |
|
| 356 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | - $s_complement = array_column( |
|
| 358 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | - 'statut' |
|
| 360 | - ); |
|
| 361 | - $statut = array_merge($statut, $s_complement); |
|
| 362 | - if ($en_base) { |
|
| 363 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | - $retire = array_diff($statut, $check); |
|
| 365 | - $statut = array_diff($statut, $retire); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - return array_unique($statut); |
|
| 369 | - } |
|
| 323 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + switch ($quoi) { |
|
| 328 | + case 'redacteurs': |
|
| 329 | + $statut = AUTEURS_MIN_REDAC; |
|
| 330 | + $statut = explode(',', $statut); |
|
| 331 | + if ($en_base) { |
|
| 332 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | + $retire = array_diff($statut, $check); |
|
| 334 | + $statut = array_diff($statut, $retire); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return array_unique($statut); |
|
| 338 | + |
|
| 339 | + case 'visiteurs': |
|
| 340 | + $statut = []; |
|
| 341 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | + $exclus = explode(',', $exclus); |
|
| 343 | + if (!$en_base) { |
|
| 344 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | + } |
|
| 347 | + $s_complement = array_column( |
|
| 348 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | + 'statut' |
|
| 350 | + ); |
|
| 351 | + |
|
| 352 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | + |
|
| 354 | + default: |
|
| 355 | + case 'tous': |
|
| 356 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | + $s_complement = array_column( |
|
| 358 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | + 'statut' |
|
| 360 | + ); |
|
| 361 | + $statut = array_merge($statut, $s_complement); |
|
| 362 | + if ($en_base) { |
|
| 363 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | + $retire = array_diff($statut, $check); |
|
| 365 | + $statut = array_diff($statut, $retire); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + return array_unique($statut); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,28 +382,28 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 384 | 384 | |
| 385 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | - ? '' |
|
| 388 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | - |
|
| 390 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | - if ($objet == 'rubrique') { |
|
| 392 | - $id_rubrique = 0; |
|
| 393 | - } else { |
|
| 394 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $id_rubrique; |
|
| 385 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | + ? '' |
|
| 388 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | + |
|
| 390 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | + if ($objet == 'rubrique') { |
|
| 392 | + $id_rubrique = 0; |
|
| 393 | + } else { |
|
| 394 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $id_rubrique; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | 416 | function lien_article_virtuel($virtuel) { |
| 417 | - include_spip('inc/lien'); |
|
| 418 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | - return ''; |
|
| 420 | - } |
|
| 417 | + include_spip('inc/lien'); |
|
| 418 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | + return ''; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - return propre('[->' . $virtuel . ']'); |
|
| 422 | + return propre('[->' . $virtuel . ']'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -442,11 +442,11 @@ discard block |
||
| 442 | 442 | * @filtre |
| 443 | 443 | */ |
| 444 | 444 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 445 | - include_spip('inc/acces'); |
|
| 446 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 445 | + include_spip('inc/acces'); |
|
| 446 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 447 | 447 | |
| 448 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 448 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | |
@@ -458,76 +458,76 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function alertes_auteur($id_auteur): string { |
| 460 | 460 | |
| 461 | - $alertes = []; |
|
| 462 | - |
|
| 463 | - if ( |
|
| 464 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | - ) { |
|
| 467 | - include_spip('genie/maintenance'); |
|
| 468 | - if ($msg = message_crash_tables()) { |
|
| 469 | - $alertes[] = $msg; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - if ( |
|
| 474 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | - ) { |
|
| 479 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | - if ( |
|
| 485 | - $a |
|
| 486 | - and is_array($a = unserialize($a)) |
|
| 487 | - and count($a) |
|
| 488 | - ) { |
|
| 489 | - $update = false; |
|
| 490 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | - $update = true; |
|
| 494 | - } |
|
| 495 | - if (isset($a[''])) { |
|
| 496 | - $alertes = array_merge($alertes, $a['']); |
|
| 497 | - unset($a['']); |
|
| 498 | - $update = true; |
|
| 499 | - } |
|
| 500 | - if ($update) { |
|
| 501 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - if ( |
|
| 506 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | - ) { |
|
| 509 | - include_spip('inc/plugin'); |
|
| 510 | - $alertes[] = plugin_donne_erreurs(); |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - $alertes = pipeline( |
|
| 514 | - 'alertes_auteur', |
|
| 515 | - [ |
|
| 516 | - 'args' => [ |
|
| 517 | - 'id_auteur' => $id_auteur, |
|
| 518 | - 'exec' => _request('exec'), |
|
| 519 | - ], |
|
| 520 | - 'data' => $alertes |
|
| 521 | - ] |
|
| 522 | - ); |
|
| 523 | - |
|
| 524 | - if ($alertes = array_filter($alertes)) { |
|
| 525 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | - join(' | ', $alertes) |
|
| 527 | - . '</div></div>'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return ''; |
|
| 461 | + $alertes = []; |
|
| 462 | + |
|
| 463 | + if ( |
|
| 464 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | + ) { |
|
| 467 | + include_spip('genie/maintenance'); |
|
| 468 | + if ($msg = message_crash_tables()) { |
|
| 469 | + $alertes[] = $msg; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + if ( |
|
| 474 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | + ) { |
|
| 479 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | + if ( |
|
| 485 | + $a |
|
| 486 | + and is_array($a = unserialize($a)) |
|
| 487 | + and count($a) |
|
| 488 | + ) { |
|
| 489 | + $update = false; |
|
| 490 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | + $update = true; |
|
| 494 | + } |
|
| 495 | + if (isset($a[''])) { |
|
| 496 | + $alertes = array_merge($alertes, $a['']); |
|
| 497 | + unset($a['']); |
|
| 498 | + $update = true; |
|
| 499 | + } |
|
| 500 | + if ($update) { |
|
| 501 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + if ( |
|
| 506 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | + ) { |
|
| 509 | + include_spip('inc/plugin'); |
|
| 510 | + $alertes[] = plugin_donne_erreurs(); |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + $alertes = pipeline( |
|
| 514 | + 'alertes_auteur', |
|
| 515 | + [ |
|
| 516 | + 'args' => [ |
|
| 517 | + 'id_auteur' => $id_auteur, |
|
| 518 | + 'exec' => _request('exec'), |
|
| 519 | + ], |
|
| 520 | + 'data' => $alertes |
|
| 521 | + ] |
|
| 522 | + ); |
|
| 523 | + |
|
| 524 | + if ($alertes = array_filter($alertes)) { |
|
| 525 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | + join(' | ', $alertes) |
|
| 527 | + . '</div></div>'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return ''; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | 539 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 540 | - include_spip('inc/presenter_enfants'); |
|
| 540 | + include_spip('inc/presenter_enfants'); |
|
| 541 | 541 | |
| 542 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -557,15 +557,15 @@ discard block |
||
| 557 | 557 | * @return string |
| 558 | 558 | */ |
| 559 | 559 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 560 | - $titre = attribut_html($titre); |
|
| 561 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | - |
|
| 564 | - if (!$titre_lien) { |
|
| 565 | - return $icone; |
|
| 566 | - } else { |
|
| 567 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | - } |
|
| 560 | + $titre = attribut_html($titre); |
|
| 561 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | + |
|
| 564 | + if (!$titre_lien) { |
|
| 565 | + return $icone; |
|
| 566 | + } else { |
|
| 567 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + } |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -584,22 +584,22 @@ discard block |
||
| 584 | 584 | * @return array |
| 585 | 585 | */ |
| 586 | 586 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 587 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | - return []; |
|
| 590 | - } |
|
| 591 | - $r = reset($res); |
|
| 592 | - if (isset($r['rang_lien'])) { |
|
| 593 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | - asort($l); |
|
| 595 | - $l = array_keys($l); |
|
| 596 | - } else { |
|
| 597 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | - // Sinon c'est dans "id_objet" |
|
| 599 | - $l = array_column( |
|
| 600 | - $res, |
|
| 601 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | - ); |
|
| 603 | - } |
|
| 604 | - return $l; |
|
| 587 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | + return []; |
|
| 590 | + } |
|
| 591 | + $r = reset($res); |
|
| 592 | + if (isset($r['rang_lien'])) { |
|
| 593 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | + asort($l); |
|
| 595 | + $l = array_keys($l); |
|
| 596 | + } else { |
|
| 597 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | + // Sinon c'est dans "id_objet" |
|
| 599 | + $l = array_column( |
|
| 600 | + $res, |
|
| 601 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | + ); |
|
| 603 | + } |
|
| 604 | + return $l; |
|
| 605 | 605 | } |
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function trier_rss($texte) { |
| 8 | - if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | - $placeholder = '<!--REINSERT-->'; |
|
| 10 | - $items = []; |
|
| 11 | - foreach ($matches as $match) { |
|
| 12 | - if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | - $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | - $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | - } |
|
| 16 | - } |
|
| 17 | - krsort($items); |
|
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | - } |
|
| 8 | + if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | + $placeholder = '<!--REINSERT-->'; |
|
| 10 | + $items = []; |
|
| 11 | + foreach ($matches as $match) { |
|
| 12 | + if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | + $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | + $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | + krsort($items); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return $texte; |
|
| 21 | + return $texte; |
|
| 22 | 22 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | krsort($items); |
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items)."\n", $texte); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | return $texte; |
@@ -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 | /** |
@@ -31,43 +31,43 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur = '') { |
| 34 | - if ($changer_lang) { |
|
| 35 | - $table_objet_sql = table_objet_sql($objet); |
|
| 36 | - $id_table_objet = id_table_objet($objet); |
|
| 37 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 38 | - $desc = $trouver_table($table_objet_sql, $serveur); |
|
| 34 | + if ($changer_lang) { |
|
| 35 | + $table_objet_sql = table_objet_sql($objet); |
|
| 36 | + $id_table_objet = id_table_objet($objet); |
|
| 37 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 38 | + $desc = $trouver_table($table_objet_sql, $serveur); |
|
| 39 | 39 | |
| 40 | - $set = []; |
|
| 41 | - if (isset($desc['field']['langue_choisie'])) { |
|
| 42 | - $set['langue_choisie'] = 'oui'; |
|
| 43 | - } |
|
| 40 | + $set = []; |
|
| 41 | + if (isset($desc['field']['langue_choisie'])) { |
|
| 42 | + $set['langue_choisie'] = 'oui'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - if ($changer_lang != 'herit') { |
|
| 46 | - $set['lang'] = $changer_lang; |
|
| 47 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 48 | - include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
|
| 49 | - if ($table_objet_sql == 'spip_rubriques') { |
|
| 50 | - calculer_langues_rubriques(); |
|
| 51 | - } |
|
| 52 | - $langues = calculer_langues_utilisees($serveur); |
|
| 53 | - ecrire_meta('langues_utilisees', $langues); |
|
| 54 | - } else { |
|
| 55 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 56 | - if (!$langue_parent) { |
|
| 57 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 58 | - } |
|
| 59 | - $changer_lang = $langue_parent; |
|
| 60 | - $set['lang'] = $changer_lang; |
|
| 61 | - if (isset($set['langue_choisie'])) { |
|
| 62 | - $set['langue_choisie'] = 'non'; |
|
| 63 | - } |
|
| 64 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 65 | - if ($table_objet_sql == 'spip_rubriques') { |
|
| 66 | - include_spip('inc/rubriques'); |
|
| 67 | - calculer_langues_rubriques(); |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 45 | + if ($changer_lang != 'herit') { |
|
| 46 | + $set['lang'] = $changer_lang; |
|
| 47 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 48 | + include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
|
| 49 | + if ($table_objet_sql == 'spip_rubriques') { |
|
| 50 | + calculer_langues_rubriques(); |
|
| 51 | + } |
|
| 52 | + $langues = calculer_langues_utilisees($serveur); |
|
| 53 | + ecrire_meta('langues_utilisees', $langues); |
|
| 54 | + } else { |
|
| 55 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 56 | + if (!$langue_parent) { |
|
| 57 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 58 | + } |
|
| 59 | + $changer_lang = $langue_parent; |
|
| 60 | + $set['lang'] = $changer_lang; |
|
| 61 | + if (isset($set['langue_choisie'])) { |
|
| 62 | + $set['langue_choisie'] = 'non'; |
|
| 63 | + } |
|
| 64 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 65 | + if ($table_objet_sql == 'spip_rubriques') { |
|
| 66 | + include_spip('inc/rubriques'); |
|
| 67 | + calculer_langues_rubriques(); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $changer_lang; |
|
| 72 | + return $changer_lang; |
|
| 73 | 73 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | if ($changer_lang != 'herit') { |
| 46 | 46 | $set['lang'] = $changer_lang; |
| 47 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 47 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=".intval($id), [], $serveur); |
|
| 48 | 48 | include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees |
| 49 | 49 | if ($table_objet_sql == 'spip_rubriques') { |
| 50 | 50 | calculer_langues_rubriques(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $langues = calculer_langues_utilisees($serveur); |
| 53 | 53 | ecrire_meta('langues_utilisees', $langues); |
| 54 | 54 | } else { |
| 55 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 55 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 56 | 56 | if (!$langue_parent) { |
| 57 | 57 | $langue_parent = $GLOBALS['meta']['langue_site']; |
| 58 | 58 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | if (isset($set['langue_choisie'])) { |
| 62 | 62 | $set['langue_choisie'] = 'non'; |
| 63 | 63 | } |
| 64 | - sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur); |
|
| 64 | + sql_updateq($table_objet_sql, $set, "$id_table_objet=".intval($id), [], $serveur); |
|
| 65 | 65 | if ($table_objet_sql == 'spip_rubriques') { |
| 66 | 66 | include_spip('inc/rubriques'); |
| 67 | 67 | calculer_langues_rubriques(); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
| 57 | 57 | if (!is_numeric(_request('reinstall'))) { |
| 58 | 58 | include_spip('base/create'); |
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 60 | 60 | creer_base(); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | exit; |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 73 | 73 | |
| 74 | 74 | // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
| 75 | 75 | @spip_unlink(_CACHE_RUBRIQUES); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | @spip_unlink(_CACHE_PLUGINS_OPT); |
| 79 | 79 | @spip_unlink(_CACHE_PLUGINS_FCT); |
| 80 | 80 | @spip_unlink(_CACHE_CHEMIN); |
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 81 | + @spip_unlink(_DIR_TMP.'plugin_xml_cache.gz'); |
|
| 82 | 82 | |
| 83 | 83 | include_spip('inc/auth'); |
| 84 | 84 | auth_synchroniser_distant(); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
| 118 | 118 | |
| 119 | 119 | spip_log( |
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 120 | + "Version anterieure: $version_installee. Courante: ".$GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 122 | 122 | ); |
| 123 | 123 | if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
| 124 | 124 | sql_replace( |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
| 152 | 152 | if ($res) { |
| 153 | 153 | if (!is_array($res)) { |
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 155 | 155 | } else { |
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 156 | + echo _T('avis_operation_echec').' '.join(' ', $res); |
|
| 157 | 157 | echo install_fin_html(); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -241,9 +241,9 @@ discard block |
||
| 241 | 241 | $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
| 242 | 242 | if ($res) { |
| 243 | 243 | if (!is_array($res)) { |
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.'._LOG_ERREUR); |
|
| 245 | 245 | } else { |
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 246 | + echo '<p>'._T('avis_operation_echec').' '.join(' ', $res).'</p>'; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | echo(install_debut_html($titre)); |
| 300 | 300 | // script de rechargement auto sur timeout |
| 301 | 301 | $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
| 302 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 302 | + echo http_script("window.setTimeout('location.href=\"".$redirect."\";',".($timeout * 1000).')'); |
|
| 303 | 303 | echo "<div style='text-align: left'>\n"; |
| 304 | 304 | if (ob_get_level()) { |
| 305 | 305 | ob_flush(); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | return [$v, $etape]; |
| 389 | 389 | } |
| 390 | 390 | $n = time() - $time; |
| 391 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 391 | + spip_log("$table $meta: $v en $n secondes", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 392 | 392 | if ($meta) { |
| 393 | 393 | ecrire_meta($meta, $installee = $v, 'oui', $table); |
| 394 | 394 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | if ($meta) { |
| 405 | 405 | ecrire_meta($meta, $cible, 'oui', $table); |
| 406 | 406 | } |
| 407 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 407 | + spip_log("MAJ terminee. $meta: $installee", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 408 | 408 | |
| 409 | 409 | return []; |
| 410 | 410 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * @return int |
| 430 | 430 | */ |
| 431 | 431 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 432 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 432 | + $meta2 = $meta.'_maj_'.$serie; |
|
| 433 | 433 | $etape = 0; |
| 434 | 434 | if (isset($GLOBALS[$table][$meta2])) { |
| 435 | 435 | $etape = intval($GLOBALS[$table][$meta2]); |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | and function_exists($f = array_shift($r)) |
| 443 | 443 | ) { |
| 444 | 444 | // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
| 445 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 445 | + spip_log("$msg: $f ".@join(',', $r), 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 446 | 446 | // pour les fonctions atomiques sql_xx |
| 447 | 447 | // on enregistre le meta avant de lancer la fonction, |
| 448 | 448 | // de maniere a eviter de boucler sur timeout |
@@ -460,12 +460,12 @@ discard block |
||
| 460 | 460 | relance_maj($meta, $table, $redirect); |
| 461 | 461 | } |
| 462 | 462 | ecrire_meta($meta2, $i + 1, 'non', $table); |
| 463 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 463 | + spip_log("$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 464 | 464 | } else { |
| 465 | 465 | if (!is_array($r)) { |
| 466 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 466 | + spip_log("maj $i format incorrect", 'maj.'._LOG_ERREUR); |
|
| 467 | 467 | } else { |
| 468 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 468 | + spip_log("maj $i fonction $f non definie", 'maj.'._LOG_ERREUR); |
|
| 469 | 469 | } |
| 470 | 470 | // en cas d'erreur serieuse, on s'arrete |
| 471 | 471 | // mais on permet de passer par dessus en rechargeant la page. |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_UPGRADE_TIME_OUT')) { |
| 24 | - /** |
|
| 25 | - * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | - * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | - * |
|
| 28 | - * @var int |
|
| 29 | - **/ |
|
| 30 | - define('_UPGRADE_TIME_OUT', 20); |
|
| 24 | + /** |
|
| 25 | + * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | + * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | + * |
|
| 28 | + * @var int |
|
| 29 | + **/ |
|
| 30 | + define('_UPGRADE_TIME_OUT', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function base_upgrade_dist($titre = '', $reprise = '') { |
| 53 | - if (!$titre) { |
|
| 54 | - return; |
|
| 55 | - } // anti-testeur automatique |
|
| 56 | - if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | - if (!is_numeric(_request('reinstall'))) { |
|
| 58 | - include_spip('base/create'); |
|
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | - creer_base(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | - // lancement de l'upgrade SPIP |
|
| 65 | - $res = maj_base(); |
|
| 66 | - |
|
| 67 | - if ($res) { |
|
| 68 | - // on arrete tout ici ! |
|
| 69 | - exit; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | - |
|
| 74 | - // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | - @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | - @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | - @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | - @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | - @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | - |
|
| 83 | - include_spip('inc/auth'); |
|
| 84 | - auth_synchroniser_distant(); |
|
| 85 | - $config = charger_fonction('config', 'inc'); |
|
| 86 | - $config(); |
|
| 53 | + if (!$titre) { |
|
| 54 | + return; |
|
| 55 | + } // anti-testeur automatique |
|
| 56 | + if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | + if (!is_numeric(_request('reinstall'))) { |
|
| 58 | + include_spip('base/create'); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | + creer_base(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | + // lancement de l'upgrade SPIP |
|
| 65 | + $res = maj_base(); |
|
| 66 | + |
|
| 67 | + if ($res) { |
|
| 68 | + // on arrete tout ici ! |
|
| 69 | + exit; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | + |
|
| 74 | + // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | + @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | + @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | + @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | + @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | + @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | + @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | + |
|
| 83 | + include_spip('inc/auth'); |
|
| 84 | + auth_synchroniser_distant(); |
|
| 85 | + $config = charger_fonction('config', 'inc'); |
|
| 86 | + $config(); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -114,51 +114,51 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function maj_base($version_cible = 0, $redirect = '', $debut_page = true) { |
| 116 | 116 | |
| 117 | - $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | - |
|
| 119 | - spip_log( |
|
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | - ); |
|
| 123 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | - sql_replace( |
|
| 125 | - 'spip_meta', |
|
| 126 | - [ |
|
| 127 | - 'nom' => 'version_installee', |
|
| 128 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | - 'impt' => 'non' |
|
| 130 | - ] |
|
| 131 | - ); |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - if (!upgrade_test()) { |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $cible = ($version_cible ?: $GLOBALS['spip_version_base']); |
|
| 139 | - |
|
| 140 | - if ($version_installee < 2021_01_01_00) { |
|
| 141 | - include_spip('maj/legacy/v21'); |
|
| 142 | - include_spip('maj/legacy/v30'); |
|
| 143 | - include_spip('maj/legacy/v31'); |
|
| 144 | - include_spip('maj/legacy/v32'); |
|
| 145 | - include_spip('maj/legacy/v40'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - include_spip('maj/2021'); |
|
| 149 | - |
|
| 150 | - ksort($GLOBALS['maj']); |
|
| 151 | - $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | - if ($res) { |
|
| 153 | - if (!is_array($res)) { |
|
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 155 | - } else { |
|
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | - echo install_fin_html(); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $res; |
|
| 117 | + $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | + |
|
| 119 | + spip_log( |
|
| 120 | + "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | + ); |
|
| 123 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | + sql_replace( |
|
| 125 | + 'spip_meta', |
|
| 126 | + [ |
|
| 127 | + 'nom' => 'version_installee', |
|
| 128 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | + 'impt' => 'non' |
|
| 130 | + ] |
|
| 131 | + ); |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + if (!upgrade_test()) { |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $cible = ($version_cible ?: $GLOBALS['spip_version_base']); |
|
| 139 | + |
|
| 140 | + if ($version_installee < 2021_01_01_00) { |
|
| 141 | + include_spip('maj/legacy/v21'); |
|
| 142 | + include_spip('maj/legacy/v30'); |
|
| 143 | + include_spip('maj/legacy/v31'); |
|
| 144 | + include_spip('maj/legacy/v32'); |
|
| 145 | + include_spip('maj/legacy/v40'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + include_spip('maj/2021'); |
|
| 149 | + |
|
| 150 | + ksort($GLOBALS['maj']); |
|
| 151 | + $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | + if ($res) { |
|
| 153 | + if (!is_array($res)) { |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 155 | + } else { |
|
| 156 | + echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | + echo install_fin_html(); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $res; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -200,53 +200,53 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') { |
| 202 | 202 | |
| 203 | - if ($table_meta !== 'meta') { |
|
| 204 | - installer_table_meta($table_meta); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - $current_version = null; |
|
| 208 | - |
|
| 209 | - if ( |
|
| 210 | - (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | - || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | - ) { |
|
| 213 | - // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | - // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | - if (isset($maj['create'])) { |
|
| 216 | - if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | - // installation : on ne fait que l'operation create |
|
| 218 | - $maj = ['init' => $maj['create']]; |
|
| 219 | - // et on lui ajoute un appel a inc/config |
|
| 220 | - // pour creer les metas par defaut |
|
| 221 | - $config = charger_fonction('config', 'inc'); |
|
| 222 | - $maj[$version_cible] = [[$config]]; |
|
| 223 | - } |
|
| 224 | - // dans tous les cas enlever cet index du tableau |
|
| 225 | - unset($maj['create']); |
|
| 226 | - } |
|
| 227 | - // si init, deja dans le bon ordre |
|
| 228 | - if (!isset($maj['init'])) { |
|
| 229 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | - uksort($maj, 'spip_version_compare'); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | - // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | - // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | - $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | - if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | - $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | - if ($res) { |
|
| 243 | - if (!is_array($res)) { |
|
| 244 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 245 | - } else { |
|
| 246 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 203 | + if ($table_meta !== 'meta') { |
|
| 204 | + installer_table_meta($table_meta); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + $current_version = null; |
|
| 208 | + |
|
| 209 | + if ( |
|
| 210 | + (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 211 | + || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 212 | + ) { |
|
| 213 | + // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 214 | + // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 215 | + if (isset($maj['create'])) { |
|
| 216 | + if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 217 | + // installation : on ne fait que l'operation create |
|
| 218 | + $maj = ['init' => $maj['create']]; |
|
| 219 | + // et on lui ajoute un appel a inc/config |
|
| 220 | + // pour creer les metas par defaut |
|
| 221 | + $config = charger_fonction('config', 'inc'); |
|
| 222 | + $maj[$version_cible] = [[$config]]; |
|
| 223 | + } |
|
| 224 | + // dans tous les cas enlever cet index du tableau |
|
| 225 | + unset($maj['create']); |
|
| 226 | + } |
|
| 227 | + // si init, deja dans le bon ordre |
|
| 228 | + if (!isset($maj['init'])) { |
|
| 229 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 230 | + uksort($maj, 'spip_version_compare'); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 234 | + // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 235 | + // ou define _REDIRECT_MAJ_PLUGIN |
|
| 236 | + $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 237 | + if (defined('_ECRIRE_INSTALL')) { |
|
| 238 | + $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 242 | + if ($res) { |
|
| 243 | + if (!is_array($res)) { |
|
| 244 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_ERREUR); |
|
| 245 | + } else { |
|
| 246 | + echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -263,17 +263,17 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | function relance_maj($meta, $table, $redirect = '') { |
| 266 | - include_spip('inc/headers'); |
|
| 267 | - if (!$redirect) { |
|
| 268 | - // recuperer la valeur installee en cours |
|
| 269 | - // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | - // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | - // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | - $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | - } |
|
| 275 | - echo redirige_formulaire($redirect); |
|
| 276 | - exit(); |
|
| 266 | + include_spip('inc/headers'); |
|
| 267 | + if (!$redirect) { |
|
| 268 | + // recuperer la valeur installee en cours |
|
| 269 | + // on la tronque numeriquement, elle ne sert pas reellement |
|
| 270 | + // sauf pour verifier que ce n'est pas oui ou non |
|
| 271 | + // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 272 | + $installee = intval($GLOBALS[$table][$meta]); |
|
| 273 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 274 | + } |
|
| 275 | + echo redirige_formulaire($redirect); |
|
| 276 | + exit(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -286,28 +286,28 @@ discard block |
||
| 286 | 286 | * @return void |
| 287 | 287 | */ |
| 288 | 288 | function maj_debut_page($installee, $meta, $table) { |
| 289 | - static $done = false; |
|
| 290 | - if ($done) { |
|
| 291 | - return; |
|
| 292 | - } |
|
| 293 | - include_spip('inc/minipres'); |
|
| 294 | - if (function_exists('ini_set')) { |
|
| 295 | - @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 296 | - } |
|
| 297 | - $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 298 | - $titre = _T('titre_page_upgrade'); |
|
| 299 | - $balise_img = charger_filtre('balise_img'); |
|
| 300 | - $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 301 | - echo(install_debut_html($titre)); |
|
| 302 | - // script de rechargement auto sur timeout |
|
| 303 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 304 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 305 | - echo "<div style='text-align: left'>\n"; |
|
| 306 | - if (ob_get_level()) { |
|
| 307 | - ob_flush(); |
|
| 308 | - } |
|
| 309 | - flush(); |
|
| 310 | - $done = true; |
|
| 289 | + static $done = false; |
|
| 290 | + if ($done) { |
|
| 291 | + return; |
|
| 292 | + } |
|
| 293 | + include_spip('inc/minipres'); |
|
| 294 | + if (function_exists('ini_set')) { |
|
| 295 | + @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 296 | + } |
|
| 297 | + $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 298 | + $titre = _T('titre_page_upgrade'); |
|
| 299 | + $balise_img = charger_filtre('balise_img'); |
|
| 300 | + $titre .= $balise_img(chemin_image('loader.svg'), '', 'loader'); |
|
| 301 | + echo(install_debut_html($titre)); |
|
| 302 | + // script de rechargement auto sur timeout |
|
| 303 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 304 | + echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 305 | + echo "<div style='text-align: left'>\n"; |
|
| 306 | + if (ob_get_level()) { |
|
| 307 | + ob_flush(); |
|
| 308 | + } |
|
| 309 | + flush(); |
|
| 310 | + $done = true; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | |
@@ -351,64 +351,64 @@ discard block |
||
| 351 | 351 | * - tableau vide sinon. |
| 352 | 352 | */ |
| 353 | 353 | function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) { |
| 354 | - # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 355 | - include_spip('base/create'); |
|
| 356 | - include_spip('base/abstract_sql'); |
|
| 357 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 358 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 359 | - $n = 0; |
|
| 360 | - $time = time(); |
|
| 361 | - |
|
| 362 | - if (!defined('_TIME_OUT')) { |
|
| 363 | - /** |
|
| 364 | - * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 365 | - * de mises à jour qui durent trop longtemps |
|
| 366 | - * |
|
| 367 | - * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 368 | - * |
|
| 369 | - * @var int |
|
| 370 | - */ |
|
| 371 | - define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - foreach ($maj as $v => $operations) { |
|
| 375 | - // si une maj pour cette version |
|
| 376 | - if ( |
|
| 377 | - $v == 'init' or |
|
| 378 | - (spip_version_compare($v, $installee, '>') |
|
| 379 | - and spip_version_compare($v, $cible, '<=')) |
|
| 380 | - ) { |
|
| 381 | - if ($debut_page) { |
|
| 382 | - maj_debut_page($v, $meta, $table); |
|
| 383 | - } |
|
| 384 | - echo "MAJ $v"; |
|
| 385 | - $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 386 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 387 | - # echec sur une etape en cours ? |
|
| 388 | - # on sort |
|
| 389 | - if ($etape) { |
|
| 390 | - return [$v, $etape]; |
|
| 391 | - } |
|
| 392 | - $n = time() - $time; |
|
| 393 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 394 | - if ($meta) { |
|
| 395 | - ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 396 | - } |
|
| 397 | - echo (_IS_CLI ? "\n" : '<br />'); |
|
| 398 | - } |
|
| 399 | - if (time() >= _TIME_OUT) { |
|
| 400 | - relance_maj($meta, $table, $redirect); |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 404 | - // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 405 | - // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 406 | - if ($meta) { |
|
| 407 | - ecrire_meta($meta, $cible, 'oui', $table); |
|
| 408 | - } |
|
| 409 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 410 | - |
|
| 411 | - return []; |
|
| 354 | + # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 355 | + include_spip('base/create'); |
|
| 356 | + include_spip('base/abstract_sql'); |
|
| 357 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 358 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 359 | + $n = 0; |
|
| 360 | + $time = time(); |
|
| 361 | + |
|
| 362 | + if (!defined('_TIME_OUT')) { |
|
| 363 | + /** |
|
| 364 | + * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 365 | + * de mises à jour qui durent trop longtemps |
|
| 366 | + * |
|
| 367 | + * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 368 | + * |
|
| 369 | + * @var int |
|
| 370 | + */ |
|
| 371 | + define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + foreach ($maj as $v => $operations) { |
|
| 375 | + // si une maj pour cette version |
|
| 376 | + if ( |
|
| 377 | + $v == 'init' or |
|
| 378 | + (spip_version_compare($v, $installee, '>') |
|
| 379 | + and spip_version_compare($v, $cible, '<=')) |
|
| 380 | + ) { |
|
| 381 | + if ($debut_page) { |
|
| 382 | + maj_debut_page($v, $meta, $table); |
|
| 383 | + } |
|
| 384 | + echo "MAJ $v"; |
|
| 385 | + $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 386 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 387 | + # echec sur une etape en cours ? |
|
| 388 | + # on sort |
|
| 389 | + if ($etape) { |
|
| 390 | + return [$v, $etape]; |
|
| 391 | + } |
|
| 392 | + $n = time() - $time; |
|
| 393 | + spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 394 | + if ($meta) { |
|
| 395 | + ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 396 | + } |
|
| 397 | + echo (_IS_CLI ? "\n" : '<br />'); |
|
| 398 | + } |
|
| 399 | + if (time() >= _TIME_OUT) { |
|
| 400 | + relance_maj($meta, $table, $redirect); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 404 | + // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 405 | + // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 406 | + if ($meta) { |
|
| 407 | + ecrire_meta($meta, $cible, 'oui', $table); |
|
| 408 | + } |
|
| 409 | + spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 410 | + |
|
| 411 | + return []; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -431,53 +431,53 @@ discard block |
||
| 431 | 431 | * @return int |
| 432 | 432 | */ |
| 433 | 433 | function serie_alter($serie, $q = [], $meta = '', $table = 'meta', $redirect = '') { |
| 434 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 435 | - $etape = 0; |
|
| 436 | - if (isset($GLOBALS[$table][$meta2])) { |
|
| 437 | - $etape = intval($GLOBALS[$table][$meta2]); |
|
| 438 | - } |
|
| 439 | - foreach ($q as $i => $r) { |
|
| 440 | - if ($i >= $etape) { |
|
| 441 | - $msg = "maj $table $meta2 etape $i"; |
|
| 442 | - if ( |
|
| 443 | - is_array($r) |
|
| 444 | - and function_exists($f = array_shift($r)) |
|
| 445 | - ) { |
|
| 446 | - // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 447 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 448 | - // pour les fonctions atomiques sql_xx |
|
| 449 | - // on enregistre le meta avant de lancer la fonction, |
|
| 450 | - // de maniere a eviter de boucler sur timeout |
|
| 451 | - // mais pour les fonctions complexes, |
|
| 452 | - // il faut les rejouer jusqu'a achevement. |
|
| 453 | - // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 454 | - if (strncmp($f, 'sql_', 4) == 0) { |
|
| 455 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 456 | - } |
|
| 457 | - echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 458 | - $f(...$r); |
|
| 459 | - // si temps imparti depasse, on relance sans ecrire en meta |
|
| 460 | - // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 461 | - if (time() >= _TIME_OUT) { |
|
| 462 | - relance_maj($meta, $table, $redirect); |
|
| 463 | - } |
|
| 464 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 465 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 466 | - } else { |
|
| 467 | - if (!is_array($r)) { |
|
| 468 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 469 | - } else { |
|
| 470 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 471 | - } |
|
| 472 | - // en cas d'erreur serieuse, on s'arrete |
|
| 473 | - // mais on permet de passer par dessus en rechargeant la page. |
|
| 474 | - return $i + 1; |
|
| 475 | - } |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - effacer_meta($meta2, $table); |
|
| 479 | - |
|
| 480 | - return 0; |
|
| 434 | + $meta2 = $meta . '_maj_' . $serie; |
|
| 435 | + $etape = 0; |
|
| 436 | + if (isset($GLOBALS[$table][$meta2])) { |
|
| 437 | + $etape = intval($GLOBALS[$table][$meta2]); |
|
| 438 | + } |
|
| 439 | + foreach ($q as $i => $r) { |
|
| 440 | + if ($i >= $etape) { |
|
| 441 | + $msg = "maj $table $meta2 etape $i"; |
|
| 442 | + if ( |
|
| 443 | + is_array($r) |
|
| 444 | + and function_exists($f = array_shift($r)) |
|
| 445 | + ) { |
|
| 446 | + // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 447 | + spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 448 | + // pour les fonctions atomiques sql_xx |
|
| 449 | + // on enregistre le meta avant de lancer la fonction, |
|
| 450 | + // de maniere a eviter de boucler sur timeout |
|
| 451 | + // mais pour les fonctions complexes, |
|
| 452 | + // il faut les rejouer jusqu'a achevement. |
|
| 453 | + // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 454 | + if (strncmp($f, 'sql_', 4) == 0) { |
|
| 455 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 456 | + } |
|
| 457 | + echo (_IS_CLI ? '.' : " <span title='$i'>.</span>"); |
|
| 458 | + $f(...$r); |
|
| 459 | + // si temps imparti depasse, on relance sans ecrire en meta |
|
| 460 | + // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 461 | + if (time() >= _TIME_OUT) { |
|
| 462 | + relance_maj($meta, $table, $redirect); |
|
| 463 | + } |
|
| 464 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 465 | + spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 466 | + } else { |
|
| 467 | + if (!is_array($r)) { |
|
| 468 | + spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 469 | + } else { |
|
| 470 | + spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 471 | + } |
|
| 472 | + // en cas d'erreur serieuse, on s'arrete |
|
| 473 | + // mais on permet de passer par dessus en rechargeant la page. |
|
| 474 | + return $i + 1; |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + effacer_meta($meta2, $table); |
|
| 479 | + |
|
| 480 | + return 0; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -486,16 +486,16 @@ discard block |
||
| 486 | 486 | * @return bool True si possible. |
| 487 | 487 | **/ |
| 488 | 488 | function upgrade_test() { |
| 489 | - sql_drop_table('spip_test', true); |
|
| 490 | - sql_create('spip_test', ['a' => 'int']); |
|
| 491 | - sql_alter('TABLE spip_test ADD b INT'); |
|
| 492 | - sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 493 | - $result = sql_select('b', 'spip_test'); |
|
| 494 | - // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 495 | - // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 496 | - // car cette table serait alors 'verouillee' |
|
| 497 | - $result = $result ? true : false; |
|
| 498 | - sql_alter('TABLE spip_test DROP b'); |
|
| 499 | - |
|
| 500 | - return $result; |
|
| 489 | + sql_drop_table('spip_test', true); |
|
| 490 | + sql_create('spip_test', ['a' => 'int']); |
|
| 491 | + sql_alter('TABLE spip_test ADD b INT'); |
|
| 492 | + sql_insertq('spip_test', ['b' => 1], ['field' => ['b' => 'int']]); |
|
| 493 | + $result = sql_select('b', 'spip_test'); |
|
| 494 | + // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 495 | + // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 496 | + // car cette table serait alors 'verouillee' |
|
| 497 | + $result = $result ? true : false; |
|
| 498 | + sql_alter('TABLE spip_test DROP b'); |
|
| 499 | + |
|
| 500 | + return $result; |
|
| 501 | 501 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | include_spip('inc/lang'); |
| 100 | 100 | |
| 101 | 101 | if ($GLOBALS['spip_lang'] <> $default) { |
| 102 | - $opt = lang_select($default); # et remplace |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | 103 | if ($GLOBALS['spip_lang'] <> $default) { |
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | 105 | if ($opt) { |
| 106 | 106 | lang_select(); |
| 107 | 107 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | # lien a partir de / |
| 112 | 112 | $cible = parametre_url(self(), 'lang', '', '&'); |
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 113 | + $post = generer_url_action('converser', 'redirect='.rawurlencode($cible), true); |
|
| 114 | 114 | |
| 115 | 115 | return [ |
| 116 | 116 | 'formulaires/menu_lang', |
@@ -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 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG_ECRIRE($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * - string: Si pas de multilinguisme |
| 57 | 57 | */ |
| 58 | 58 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 59 | - include_spip('inc/lang'); |
|
| 60 | - if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | - return ''; |
|
| 62 | - } |
|
| 59 | + include_spip('inc/lang'); |
|
| 60 | + if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 61 | + return ''; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $args; |
|
| 64 | + return $args; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * Liste : Chemin du squelette, durée du cache, contexte |
| 78 | 78 | **/ |
| 79 | 79 | function balise_MENU_LANG_ECRIRE_dyn($opt) { |
| 80 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -97,30 +97,30 @@ discard block |
||
| 97 | 97 | * Liste : Chemin du squelette, durée du cache, contexte |
| 98 | 98 | **/ |
| 99 | 99 | function menu_lang_pour_tous($nom, $default) { |
| 100 | - include_spip('inc/lang'); |
|
| 100 | + include_spip('inc/lang'); |
|
| 101 | 101 | |
| 102 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | - $opt = lang_select($default); # et remplace |
|
| 104 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | - $default = ''; # annule tout choix par defaut |
|
| 106 | - if ($opt) { |
|
| 107 | - lang_select(); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 102 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 103 | + $opt = lang_select($default); # et remplace |
|
| 104 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 105 | + $default = ''; # annule tout choix par defaut |
|
| 106 | + if ($opt) { |
|
| 107 | + lang_select(); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - # lien a partir de / |
|
| 113 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 112 | + # lien a partir de / |
|
| 113 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 114 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), true); |
|
| 115 | 115 | |
| 116 | - return [ |
|
| 117 | - 'formulaires/menu_lang', |
|
| 118 | - 3600, |
|
| 119 | - [ |
|
| 120 | - 'nom' => $nom, |
|
| 121 | - 'url' => $post, |
|
| 122 | - 'name' => $nom, |
|
| 123 | - 'default' => $default, |
|
| 124 | - ] |
|
| 125 | - ]; |
|
| 116 | + return [ |
|
| 117 | + 'formulaires/menu_lang', |
|
| 118 | + 3600, |
|
| 119 | + [ |
|
| 120 | + 'nom' => $nom, |
|
| 121 | + 'url' => $post, |
|
| 122 | + 'name' => $nom, |
|
| 123 | + 'default' => $default, |
|
| 124 | + ] |
|
| 125 | + ]; |
|
| 126 | 126 | } |
@@ -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 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG', ['lang']); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | * string: (vide) si pas de multilinguisme |
| 57 | 57 | */ |
| 58 | 58 | function balise_MENU_LANG_stat($args, $context_compil) { |
| 59 | - if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 59 | + if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $args; |
|
| 63 | + return $args; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * Liste : Chemin du squelette, durée du cache, contexte |
| 77 | 77 | **/ |
| 78 | 78 | function balise_MENU_LANG_dyn($opt) { |
| 79 | - include_spip('balise/menu_lang_ecrire'); |
|
| 79 | + include_spip('balise/menu_lang_ecrire'); |
|
| 80 | 80 | |
| 81 | - return menu_lang_pour_tous('var_lang', $opt); |
|
| 81 | + return menu_lang_pour_tous('var_lang', $opt); |
|
| 82 | 82 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | **/ |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 25 | - return; |
|
| 25 | + return; |
|
| 26 | 26 | } |
| 27 | 27 | include_spip('inc/filtres'); |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @return string Rien. |
| 40 | 40 | **/ |
| 41 | 41 | function filtre_image_dist($t) { |
| 42 | - return ''; |
|
| 42 | + return ''; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return string Rien. |
| 53 | 53 | **/ |
| 54 | 54 | function filtre_audio_dist($t) { |
| 55 | - return ''; |
|
| 55 | + return ''; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @return string Rien. |
| 66 | 66 | **/ |
| 67 | 67 | function filtre_video_dist($t) { |
| 68 | - return ''; |
|
| 68 | + return ''; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return string Rien. |
| 79 | 79 | **/ |
| 80 | 80 | function filtre_application_dist($t) { |
| 81 | - return ''; |
|
| 81 | + return ''; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return string Rien. |
| 92 | 92 | **/ |
| 93 | 93 | function filtre_message_dist($t) { |
| 94 | - return ''; |
|
| 94 | + return ''; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return string Rien. |
| 105 | 105 | **/ |
| 106 | 106 | function filtre_multipart_dist($t) { |
| 107 | - return ''; |
|
| 107 | + return ''; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | * @return string Contenu échappé. |
| 118 | 118 | **/ |
| 119 | 119 | function filtre_text_dist($t) { |
| 120 | - static $t1 = ['&', '<', '>']; |
|
| 121 | - static $t2 = ['&', '<', '>']; |
|
| 120 | + static $t1 = ['&', '<', '>']; |
|
| 121 | + static $t2 = ['&', '<', '>']; |
|
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 123 | + return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | * Tableau (formaté en SPIP) |
| 136 | 136 | **/ |
| 137 | 137 | function filtre_text_csv_dist($t) { |
| 138 | - include_spip('inc/csv'); |
|
| 139 | - [$entete, $lignes, $caption] = analyse_csv($t); |
|
| 140 | - foreach ($lignes as &$l) { |
|
| 141 | - $l = join('|', $l); |
|
| 142 | - } |
|
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 149 | - str_replace("\n", "|\n|", $corps); |
|
| 150 | - include_spip('inc/texte'); |
|
| 151 | - |
|
| 152 | - return propre($corps); |
|
| 138 | + include_spip('inc/csv'); |
|
| 139 | + [$entete, $lignes, $caption] = analyse_csv($t); |
|
| 140 | + foreach ($lignes as &$l) { |
|
| 141 | + $l = join('|', $l); |
|
| 142 | + } |
|
| 143 | + $corps = join("\n", $lignes) . "\n"; |
|
| 144 | + $corps = $caption . |
|
| 145 | + "\n|{{" . |
|
| 146 | + join('}}|{{', $entete) . |
|
| 147 | + '}}|' . |
|
| 148 | + "\n|" . |
|
| 149 | + str_replace("\n", "|\n|", $corps); |
|
| 150 | + include_spip('inc/texte'); |
|
| 151 | + |
|
| 152 | + return propre($corps); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -163,33 +163,33 @@ discard block |
||
| 163 | 163 | * @return string Code html sécurisé ou texte échappé |
| 164 | 164 | **/ |
| 165 | 165 | function filtre_text_html_dist($t) { |
| 166 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 167 | - return appliquer_filtre($t, 'text/plain'); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - [, $h, $t] = $r; |
|
| 171 | - |
|
| 172 | - $style = ''; |
|
| 173 | - // recuperer les styles internes |
|
| 174 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 175 | - $style = join("\n", $r[1]); |
|
| 176 | - } |
|
| 177 | - // ... et externes |
|
| 178 | - |
|
| 179 | - include_spip('inc/distant'); |
|
| 180 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 181 | - foreach ($r[0] as $l) { |
|
| 182 | - preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 183 | - $page = recuperer_url($m[1]); |
|
| 184 | - $page = $page['page'] ?? ''; |
|
| 185 | - $style .= "\n/* $l */\n" |
|
| 186 | - . str_replace('<', '', $page); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 190 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 191 | - |
|
| 192 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 166 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 167 | + return appliquer_filtre($t, 'text/plain'); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + [, $h, $t] = $r; |
|
| 171 | + |
|
| 172 | + $style = ''; |
|
| 173 | + // recuperer les styles internes |
|
| 174 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 175 | + $style = join("\n", $r[1]); |
|
| 176 | + } |
|
| 177 | + // ... et externes |
|
| 178 | + |
|
| 179 | + include_spip('inc/distant'); |
|
| 180 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 181 | + foreach ($r[0] as $l) { |
|
| 182 | + preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 183 | + $page = recuperer_url($m[1]); |
|
| 184 | + $page = $page['page'] ?? ''; |
|
| 185 | + $style .= "\n/* $l */\n" |
|
| 186 | + . str_replace('<', '', $page); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 190 | + $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 191 | + |
|
| 192 | + return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return string Code HTML des balises `<param>` |
| 203 | 203 | **/ |
| 204 | 204 | function filtre_audio_x_pn_realaudio($id) { |
| 205 | - return " |
|
| 205 | + return " |
|
| 206 | 206 | <param name='controls' value='PositionSlider' /> |
| 207 | 207 | <param name='controls' value='ImageWindow' /> |
| 208 | 208 | <param name='controls' value='PlayButton' /> |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | static $t1 = ['&', '<', '>']; |
| 121 | 121 | static $t2 = ['&', '<', '>']; |
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 123 | + return '<pre>'.str_replace($t1, $t2, (string) $t).'</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | foreach ($lignes as &$l) { |
| 141 | 141 | $l = join('|', $l); |
| 142 | 142 | } |
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 143 | + $corps = join("\n", $lignes)."\n"; |
|
| 144 | + $corps = $caption. |
|
| 145 | + "\n|{{". |
|
| 146 | + join('}}|{{', $entete). |
|
| 147 | + '}}|'. |
|
| 148 | + "\n|". |
|
| 149 | 149 | str_replace("\n", "|\n|", $corps); |
| 150 | 150 | include_spip('inc/texte'); |
| 151 | 151 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
| 190 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 190 | + $t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t)); |
|
| 191 | 191 | |
| 192 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 192 | + return (!$style ? '' : "\n<style>".$style.'</style>').$t; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -2868,8 +2868,7 @@ |
||
| 2868 | 2868 | $_const = interprete_argument_balise(1, $p); |
| 2869 | 2869 | if (!strlen($_const ?? '')) { |
| 2870 | 2870 | $p->code = "''"; |
| 2871 | - } |
|
| 2872 | - else { |
|
| 2871 | + } else { |
|
| 2873 | 2872 | $p->code = "(defined($_const)?constant($_const):'')"; |
| 2874 | 2873 | } |
| 2875 | 2874 | $p->interdire_scripts = false; |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 360 | 360 | $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
| 361 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 361 | + $p->code = "_DIR_RACINE . '$code'". |
|
| 362 | 362 | $p->interdire_scripts = false; |
| 363 | 363 | |
| 364 | 364 | return $p; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | function balise_SQUELETTE_dist($p) { |
| 379 | 379 | $code = addslashes($p->descr['sourcefile']); |
| 380 | - $p->code = "'$code'" . |
|
| 380 | + $p->code = "'$code'". |
|
| 381 | 381 | $p->interdire_scripts = false; |
| 382 | 382 | |
| 383 | 383 | return $p; |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | **/ |
| 430 | 430 | function balise_NOM_SITE_dist($p) { |
| 431 | 431 | if (!$p->etoile) { |
| 432 | - $p->code = 'supprimer_numero(calculer_url(' . |
|
| 433 | - champ_sql('url_site', $p) . ',' . |
|
| 434 | - champ_sql('nom_site', $p) . |
|
| 432 | + $p->code = 'supprimer_numero(calculer_url('. |
|
| 433 | + champ_sql('url_site', $p).','. |
|
| 434 | + champ_sql('nom_site', $p). |
|
| 435 | 435 | ", 'titre', \$connect, false))"; |
| 436 | 436 | } else { |
| 437 | 437 | $p->code = champ_sql('nom_site', $p); |
@@ -582,8 +582,8 @@ discard block |
||
| 582 | 582 | * Pile complétée par le code à générer |
| 583 | 583 | **/ |
| 584 | 584 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 585 | - $p->code = 'ceil(' . |
|
| 586 | - champ_sql('popularite', $p) . |
|
| 585 | + $p->code = 'ceil('. |
|
| 586 | + champ_sql('popularite', $p). |
|
| 587 | 587 | ')'; |
| 588 | 588 | $p->interdire_scripts = false; |
| 589 | 589 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
| 665 | 665 | ; |
| 666 | 666 | if (($v = interprete_argument_balise(1, $p)) !== null) { |
| 667 | - $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 667 | + $p->code = 'table_valeur('.$p->code.', '.$v.')'; |
|
| 668 | 668 | } |
| 669 | 669 | $p->interdire_scripts = true; |
| 670 | 670 | |
@@ -804,16 +804,16 @@ discard block |
||
| 804 | 804 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 805 | 805 | if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
| 806 | 806 | if (isset($desc['field']['descriptif'])) { |
| 807 | - $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 807 | + $_ligne .= "'descriptif' => ".champ_sql('descriptif', $p).','; |
|
| 808 | 808 | } |
| 809 | 809 | if (isset($desc['field']['texte'])) { |
| 810 | - $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 810 | + $_ligne .= "'texte' => ".champ_sql('texte', $p).','; |
|
| 811 | 811 | } |
| 812 | 812 | if (isset($desc['field']['chapo'])) { |
| 813 | - $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 813 | + $_ligne .= "'chapo' => ".champ_sql('chapo', $p).','; |
|
| 814 | 814 | } |
| 815 | 815 | if (isset($desc['introduction_longueur'])) { |
| 816 | - $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 816 | + $_introduction_longueur = "'".$desc['introduction_longueur']."'"; |
|
| 817 | 817 | } |
| 818 | 818 | } |
| 819 | 819 | $_ligne .= ')'; |
@@ -909,10 +909,10 @@ discard block |
||
| 909 | 909 | $p->code = sprintf( |
| 910 | 910 | CODE_RECUPERER_FOND, |
| 911 | 911 | "'modeles/lesauteurs'", |
| 912 | - "array('objet'=>'" . $objet . |
|
| 913 | - "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 914 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 915 | - ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 912 | + "array('objet'=>'".$objet. |
|
| 913 | + "','id_objet' => ".champ_sql($id_table_objet, $p). |
|
| 914 | + ",'$id_table_objet' => ".champ_sql($id_table_objet, $p). |
|
| 915 | + ($objet == 'article' ? '' : ",'id_article' => ".champ_sql('id_article', $p)). |
|
| 916 | 916 | ')', |
| 917 | 917 | "'trim'=>true, 'compil'=>array($c)", |
| 918 | 918 | _q($connect) |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | $m = trim($m); |
| 982 | 982 | if ($m != "''") { |
| 983 | 983 | if (!preg_match(',\W,', $m)) { |
| 984 | - $m = $boucle->id_table . ".$m"; |
|
| 984 | + $m = $boucle->id_table.".$m"; |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | $m .= ' AS titre_rang'; |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | $f_pagination = chercher_filtre('pagination'); |
| 1143 | 1143 | $type = $p->boucles[$b]->modificateur['debut_nom']; |
| 1144 | 1144 | $modif = ($type[0] !== "'") ? "'debut'.$type" |
| 1145 | - : ("'debut" . substr($type, 1)); |
|
| 1145 | + : ("'debut".substr($type, 1)); |
|
| 1146 | 1146 | |
| 1147 | 1147 | $p->code = sprintf( |
| 1148 | 1148 | CODE_PAGINATION, |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
| 1286 | 1286 | erreur_squelette($msg, $p); |
| 1287 | 1287 | } else { |
| 1288 | - $p->code = 'find_in_path((string)' . $arg . ')'; |
|
| 1288 | + $p->code = 'find_in_path((string)'.$arg.')'; |
|
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | $p->interdire_scripts = false; |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
| 1321 | 1321 | erreur_squelette($msg, $p); |
| 1322 | 1322 | } else { |
| 1323 | - $p->code = 'chemin_image((string)' . $arg . ')'; |
|
| 1323 | + $p->code = 'chemin_image((string)'.$arg.')'; |
|
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | $p->interdire_scripts = false; |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | // cas de #ENV sans argument : on retourne le serialize() du tableau |
| 1375 | 1375 | // une belle fonction [(#ENV|affiche_env)] serait pratique |
| 1376 | 1376 | if ($src) { |
| 1377 | - $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1377 | + $p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")'; |
|
| 1378 | 1378 | } else { |
| 1379 | 1379 | $p->code = 'serialize($Pile[0]??[])'; |
| 1380 | 1380 | } |
@@ -1427,8 +1427,8 @@ discard block |
||
| 1427 | 1427 | $_sinon = interprete_argument_balise(2, $p); |
| 1428 | 1428 | $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
| 1429 | 1429 | |
| 1430 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1431 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1430 | + $p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','. |
|
| 1431 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')"; |
|
| 1432 | 1432 | |
| 1433 | 1433 | return $p; |
| 1434 | 1434 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
| 1521 | 1521 | $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
| 1522 | 1522 | erreur_squelette($err_b_s_a, $p); |
| 1523 | 1523 | } else { |
| 1524 | - $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1524 | + $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | $p->interdire_scripts = false; |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | ) |
| 1570 | 1570 | ) { |
| 1571 | 1571 | $p->code = /* $r[1]. */ |
| 1572 | - '(' . $r[2] . ')'; |
|
| 1572 | + '('.$r[2].')'; |
|
| 1573 | 1573 | } else { |
| 1574 | 1574 | $p->code = "eval('return '.$php.';')"; |
| 1575 | 1575 | } |
@@ -1813,9 +1813,9 @@ discard block |
||
| 1813 | 1813 | |
| 1814 | 1814 | // noter la duree du cache dans un entete proprietaire |
| 1815 | 1815 | |
| 1816 | - $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1816 | + $code = "'<'.'".'?php header("X-Spip-Cache: ' |
|
| 1817 | 1817 | . $duree |
| 1818 | - . '"); ?' . "'.'>'"; |
|
| 1818 | + . '"); ?'."'.'>'"; |
|
| 1819 | 1819 | |
| 1820 | 1820 | // Remplir le header Cache-Control |
| 1821 | 1821 | // cas #CACHE{0} |
@@ -1836,9 +1836,9 @@ discard block |
||
| 1836 | 1836 | $pa == 'cache-client' |
| 1837 | 1837 | and $duree > 0 |
| 1838 | 1838 | ) { |
| 1839 | - $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1839 | + $code .= ".'<'.'".'?php header("Cache-Control: max-age=' |
|
| 1840 | 1840 | . $duree |
| 1841 | - . '"); ?' . "'.'>'"; |
|
| 1841 | + . '"); ?'."'.'>'"; |
|
| 1842 | 1842 | // il semble logique, si on cache-client, de ne pas invalider |
| 1843 | 1843 | $pa = 'statique'; |
| 1844 | 1844 | } |
@@ -1847,7 +1847,7 @@ discard block |
||
| 1847 | 1847 | $pa == 'statique' |
| 1848 | 1848 | and $duree > 0 |
| 1849 | 1849 | ) { |
| 1850 | - $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1850 | + $code .= ".'<'.'".'?php header("X-Spip-Statique: oui"); ?'."'.'>'"; |
|
| 1851 | 1851 | } |
| 1852 | 1852 | } |
| 1853 | 1853 | } else { |
@@ -2011,9 +2011,9 @@ discard block |
||
| 2011 | 2011 | if ($p->etoile) { |
| 2012 | 2012 | $_options[] = "'etoile'=>true"; |
| 2013 | 2013 | } |
| 2014 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2014 | + $_options[] = "'compil'=>array(".memoriser_contexte_compil($p).')'; |
|
| 2015 | 2015 | |
| 2016 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2016 | + $_l = 'array('.join(",\n\t", $_contexte).')'; |
|
| 2017 | 2017 | if ($flag_env) { |
| 2018 | 2018 | $_l = "array_merge(\$Pile[0],$_l)"; |
| 2019 | 2019 | } |
@@ -2023,7 +2023,7 @@ discard block |
||
| 2023 | 2023 | $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
| 2024 | 2024 | erreur_squelette($msg, $p); |
| 2025 | 2025 | } else { |
| 2026 | - $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2026 | + $p->code = 'charge_scripts('.$_contexte[1].',false)'; |
|
| 2027 | 2027 | } |
| 2028 | 2028 | |
| 2029 | 2029 | $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
@@ -2071,7 +2071,7 @@ discard block |
||
| 2071 | 2071 | unset($_contexte[1]); |
| 2072 | 2072 | |
| 2073 | 2073 | if (preg_match("/^\s*'[^']*'/s", $nom)) { |
| 2074 | - $nom = "'modeles/" . substr($nom, 1); |
|
| 2074 | + $nom = "'modeles/".substr($nom, 1); |
|
| 2075 | 2075 | } else { |
| 2076 | 2076 | $nom = "'modeles/' . $nom"; |
| 2077 | 2077 | } |
@@ -2088,8 +2088,8 @@ discard block |
||
| 2088 | 2088 | $primary = $p->boucles[$p->id_boucle]->primary; |
| 2089 | 2089 | if (!strpos($primary, ',')) { |
| 2090 | 2090 | $id = champ_sql($primary, $p); |
| 2091 | - $_contexte[] = "'$primary'=>" . $id; |
|
| 2092 | - $_contexte[] = "'id'=>" . $id; |
|
| 2091 | + $_contexte[] = "'$primary'=>".$id; |
|
| 2092 | + $_contexte[] = "'id'=>".$id; |
|
| 2093 | 2093 | } |
| 2094 | 2094 | } |
| 2095 | 2095 | $_contexte[] = "'recurs'=>(++\$recurs)"; |
@@ -2101,11 +2101,11 @@ discard block |
||
| 2101 | 2101 | $_options = memoriser_contexte_compil($p); |
| 2102 | 2102 | $_options = "'compil'=>array($_options), 'trim'=>true"; |
| 2103 | 2103 | if (isset($_contexte['ajax'])) { |
| 2104 | - $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2104 | + $_options .= ', '.preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2105 | 2105 | unset($_contexte['ajax']); |
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2108 | + $_l = 'array('.join(",\n\t", $_contexte).')'; |
|
| 2109 | 2109 | if ($flag_env) { |
| 2110 | 2110 | $_l = "array_merge(\$Pile[0],$_l)"; |
| 2111 | 2111 | } |
@@ -2215,12 +2215,12 @@ discard block |
||
| 2215 | 2215 | function balise_DOUBLONS_dist($p) { |
| 2216 | 2216 | if ($type = interprete_argument_balise(1, $p)) { |
| 2217 | 2217 | if ($famille = interprete_argument_balise(2, $p)) { |
| 2218 | - $type .= '.' . $famille; |
|
| 2218 | + $type .= '.'.$famille; |
|
| 2219 | 2219 | } |
| 2220 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2220 | + $p->code = '(isset($doublons['.$type.']) ? $doublons['.$type.'] : "")'; |
|
| 2221 | 2221 | if (!$p->etoile) { |
| 2222 | 2222 | $p->code = 'array_filter(array_map("intval",explode(",",' |
| 2223 | - . $p->code . ')))'; |
|
| 2223 | + . $p->code.')))'; |
|
| 2224 | 2224 | } |
| 2225 | 2225 | } else { |
| 2226 | 2226 | $p->code = '$doublons'; |
@@ -2349,7 +2349,7 @@ discard block |
||
| 2349 | 2349 | $_code[] = "$_key => $_val"; |
| 2350 | 2350 | } |
| 2351 | 2351 | } while ($_key && $_val); |
| 2352 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2352 | + $p->code = 'array('.join(', ', $_code).')'; |
|
| 2353 | 2353 | $p->interdire_scripts = false; |
| 2354 | 2354 | |
| 2355 | 2355 | return $p; |
@@ -2376,7 +2376,7 @@ discard block |
||
| 2376 | 2376 | while ($_val = interprete_argument_balise($n++, $p)) { |
| 2377 | 2377 | $_code[] = $_val; |
| 2378 | 2378 | } |
| 2379 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2379 | + $p->code = 'array('.join(', ', $_code).')'; |
|
| 2380 | 2380 | $p->interdire_scripts = false; |
| 2381 | 2381 | |
| 2382 | 2382 | return $p; |
@@ -2421,10 +2421,10 @@ discard block |
||
| 2421 | 2421 | $_code[] = $_v; |
| 2422 | 2422 | } |
| 2423 | 2423 | |
| 2424 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2424 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join( |
|
| 2425 | 2425 | ', ', |
| 2426 | 2426 | $_code |
| 2427 | - ) . ')?" ":"")'; |
|
| 2427 | + ).')?" ":"")'; |
|
| 2428 | 2428 | $p->interdire_scripts = false; |
| 2429 | 2429 | |
| 2430 | 2430 | return $p; |
@@ -2457,7 +2457,7 @@ discard block |
||
| 2457 | 2457 | $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
| 2458 | 2458 | |
| 2459 | 2459 | $f = chercher_filtre('info_plugin'); |
| 2460 | - $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2460 | + $p->code = $f.'('.$plugin.', '.$type_info.')'; |
|
| 2461 | 2461 | |
| 2462 | 2462 | return $p; |
| 2463 | 2463 | } |
@@ -2689,7 +2689,7 @@ discard block |
||
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | // Différentes infos relatives au tri présentes dans les modificateurs |
| 2692 | - $_tri_nom = $boucle->modificateur['tri_nom'] ; // nom du paramètre définissant le tri |
|
| 2692 | + $_tri_nom = $boucle->modificateur['tri_nom']; // nom du paramètre définissant le tri |
|
| 2693 | 2693 | $_tri_champ = $boucle->modificateur['tri_champ']; // champ actuel utilisé le tri |
| 2694 | 2694 | $_tri_sens = $boucle->modificateur['tri_sens']; // sens de tri actuel |
| 2695 | 2695 | $_tri_liste_sens_defaut = $boucle->modificateur['tri_liste_sens_defaut']; // sens par défaut pour chaque champ |
@@ -2784,7 +2784,7 @@ discard block |
||
| 2784 | 2784 | $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | - $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2787 | + $p->code = '(objet_test_si_publie('.$_type.',intval('.$_id.'),'._q($connect).")?' ':'')"; |
|
| 2788 | 2788 | $p->interdire_scripts = false; |
| 2789 | 2789 | |
| 2790 | 2790 | return $p; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | **/ |
| 27 | 27 | |
| 28 | 28 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 29 | - return; |
|
| 29 | + return; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -48,16 +48,16 @@ discard block |
||
| 48 | 48 | * Code PHP si cet argument est présent, sinon null |
| 49 | 49 | **/ |
| 50 | 50 | function interprete_argument_balise(int $n, Champ $p): ?string { |
| 51 | - if (($p->param) && (!$p->param[0][0]) && ((is_countable($p->param[0]) ? count($p->param[0]) : 0) > $n)) { |
|
| 52 | - return calculer_liste( |
|
| 53 | - $p->param[0][$n], |
|
| 54 | - $p->descr, |
|
| 55 | - $p->boucles, |
|
| 56 | - $p->id_boucle |
|
| 57 | - ); |
|
| 58 | - } else { |
|
| 59 | - return null; |
|
| 60 | - } |
|
| 51 | + if (($p->param) && (!$p->param[0][0]) && ((is_countable($p->param[0]) ? count($p->param[0]) : 0) > $n)) { |
|
| 52 | + return calculer_liste( |
|
| 53 | + $p->param[0][$n], |
|
| 54 | + $p->descr, |
|
| 55 | + $p->boucles, |
|
| 56 | + $p->id_boucle |
|
| 57 | + ); |
|
| 58 | + } else { |
|
| 59 | + return null; |
|
| 60 | + } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | * Pile complétée par le code à générer |
| 78 | 78 | **/ |
| 79 | 79 | function balise_NOM_SITE_SPIP_dist($p) { |
| 80 | - $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 80 | + $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 81 | 81 | |
| 82 | - #$p->interdire_scripts = true; |
|
| 83 | - return $p; |
|
| 82 | + #$p->interdire_scripts = true; |
|
| 83 | + return $p; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | * Pile complétée par le code à générer |
| 97 | 97 | **/ |
| 98 | 98 | function balise_EMAIL_WEBMASTER_dist($p) { |
| 99 | - $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 99 | + $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 100 | 100 | |
| 101 | - #$p->interdire_scripts = true; |
|
| 102 | - return $p; |
|
| 101 | + #$p->interdire_scripts = true; |
|
| 102 | + return $p; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -115,10 +115,10 @@ discard block |
||
| 115 | 115 | * Pile complétée par le code à générer |
| 116 | 116 | **/ |
| 117 | 117 | function balise_DESCRIPTIF_SITE_SPIP_dist($p) { |
| 118 | - $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 118 | + $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 119 | 119 | |
| 120 | - #$p->interdire_scripts = true; |
|
| 121 | - return $p; |
|
| 120 | + #$p->interdire_scripts = true; |
|
| 121 | + return $p; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | * Pile complétée par le code à générer |
| 140 | 140 | **/ |
| 141 | 141 | function balise_CHARSET_dist($p) { |
| 142 | - $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 142 | + $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 143 | 143 | |
| 144 | - #$p->interdire_scripts = true; |
|
| 145 | - return $p; |
|
| 144 | + #$p->interdire_scripts = true; |
|
| 145 | + return $p; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | * Pile complétée par le code à générer |
| 168 | 168 | **/ |
| 169 | 169 | function balise_LANG_LEFT_dist($p) { |
| 170 | - $_lang = champ_sql('lang', $p); |
|
| 171 | - $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 172 | - $p->interdire_scripts = false; |
|
| 170 | + $_lang = champ_sql('lang', $p); |
|
| 171 | + $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 172 | + $p->interdire_scripts = false; |
|
| 173 | 173 | |
| 174 | - return $p; |
|
| 174 | + return $p; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | * Pile complétée par le code à générer |
| 192 | 192 | **/ |
| 193 | 193 | function balise_LANG_RIGHT_dist($p) { |
| 194 | - $_lang = champ_sql('lang', $p); |
|
| 195 | - $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 196 | - $p->interdire_scripts = false; |
|
| 194 | + $_lang = champ_sql('lang', $p); |
|
| 195 | + $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 196 | + $p->interdire_scripts = false; |
|
| 197 | 197 | |
| 198 | - return $p; |
|
| 198 | + return $p; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | * Pile complétée par le code à générer |
| 221 | 221 | **/ |
| 222 | 222 | function balise_LANG_DIR_dist($p) { |
| 223 | - $_lang = champ_sql('lang', $p); |
|
| 224 | - $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 225 | - $p->interdire_scripts = false; |
|
| 223 | + $_lang = champ_sql('lang', $p); |
|
| 224 | + $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 225 | + $p->interdire_scripts = false; |
|
| 226 | 226 | |
| 227 | - return $p; |
|
| 227 | + return $p; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | * Pile complétée par le code à générer |
| 242 | 242 | **/ |
| 243 | 243 | function balise_PUCE_dist($p) { |
| 244 | - $p->code = 'definir_puce()'; |
|
| 245 | - $p->interdire_scripts = false; |
|
| 244 | + $p->code = 'definir_puce()'; |
|
| 245 | + $p->interdire_scripts = false; |
|
| 246 | 246 | |
| 247 | - return $p; |
|
| 247 | + return $p; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | * Pile completée du code PHP d'exécution de la balise |
| 269 | 269 | */ |
| 270 | 270 | function balise_DATE_dist($p) { |
| 271 | - $p->code = champ_sql('date', $p); |
|
| 271 | + $p->code = champ_sql('date', $p); |
|
| 272 | 272 | |
| 273 | - return $p; |
|
| 273 | + return $p; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | |
@@ -290,10 +290,10 @@ discard block |
||
| 290 | 290 | * Pile completée du code PHP d'exécution de la balise |
| 291 | 291 | */ |
| 292 | 292 | function balise_DATE_REDAC_dist($p) { |
| 293 | - $p->code = champ_sql('date_redac', $p); |
|
| 294 | - $p->interdire_scripts = false; |
|
| 293 | + $p->code = champ_sql('date_redac', $p); |
|
| 294 | + $p->interdire_scripts = false; |
|
| 295 | 295 | |
| 296 | - return $p; |
|
| 296 | + return $p; |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | * Pile completée du code PHP d'exécution de la balise |
| 313 | 313 | */ |
| 314 | 314 | function balise_DATE_MODIF_dist($p) { |
| 315 | - $p->code = champ_sql('date_modif', $p); |
|
| 316 | - $p->interdire_scripts = false; |
|
| 315 | + $p->code = champ_sql('date_modif', $p); |
|
| 316 | + $p->interdire_scripts = false; |
|
| 317 | 317 | |
| 318 | - return $p; |
|
| 318 | + return $p; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -333,13 +333,13 @@ discard block |
||
| 333 | 333 | * Pile completée du code PHP d'exécution de la balise |
| 334 | 334 | */ |
| 335 | 335 | function balise_DATE_NOUVEAUTES_dist($p) { |
| 336 | - $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 336 | + $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 337 | 337 | AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ? |
| 338 | 338 | \$GLOBALS['meta']['dernier_envoi_neuf'] : |
| 339 | 339 | \"'0000-00-00'\")"; |
| 340 | - $p->interdire_scripts = false; |
|
| 340 | + $p->interdire_scripts = false; |
|
| 341 | 341 | |
| 342 | - return $p; |
|
| 342 | + return $p; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | * Pile completée du code PHP d'exécution de la balise |
| 358 | 358 | */ |
| 359 | 359 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 360 | - $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 361 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 362 | - $p->interdire_scripts = false; |
|
| 360 | + $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 361 | + $p->code = "_DIR_RACINE . '$code'" . |
|
| 362 | + $p->interdire_scripts = false; |
|
| 363 | 363 | |
| 364 | - return $p; |
|
| 364 | + return $p; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
@@ -376,11 +376,11 @@ discard block |
||
| 376 | 376 | * Pile completée du code PHP d'exécution de la balise |
| 377 | 377 | */ |
| 378 | 378 | function balise_SQUELETTE_dist($p) { |
| 379 | - $code = addslashes($p->descr['sourcefile']); |
|
| 380 | - $p->code = "'$code'" . |
|
| 381 | - $p->interdire_scripts = false; |
|
| 379 | + $code = addslashes($p->descr['sourcefile']); |
|
| 380 | + $p->code = "'$code'" . |
|
| 381 | + $p->interdire_scripts = false; |
|
| 382 | 382 | |
| 383 | - return $p; |
|
| 383 | + return $p; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -399,10 +399,10 @@ discard block |
||
| 399 | 399 | * Pile completée du code PHP d'exécution de la balise |
| 400 | 400 | */ |
| 401 | 401 | function balise_SPIP_VERSION_dist($p) { |
| 402 | - $p->code = 'spip_version()'; |
|
| 403 | - $p->interdire_scripts = false; |
|
| 402 | + $p->code = 'spip_version()'; |
|
| 403 | + $p->interdire_scripts = false; |
|
| 404 | 404 | |
| 405 | - return $p; |
|
| 405 | + return $p; |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | |
@@ -428,18 +428,18 @@ discard block |
||
| 428 | 428 | * Pile complétée par le code à générer |
| 429 | 429 | **/ |
| 430 | 430 | function balise_NOM_SITE_dist($p) { |
| 431 | - if (!$p->etoile) { |
|
| 432 | - $p->code = 'supprimer_numero(calculer_url(' . |
|
| 433 | - champ_sql('url_site', $p) . ',' . |
|
| 434 | - champ_sql('nom_site', $p) . |
|
| 435 | - ", 'titre', \$connect, false))"; |
|
| 436 | - } else { |
|
| 437 | - $p->code = champ_sql('nom_site', $p); |
|
| 438 | - } |
|
| 431 | + if (!$p->etoile) { |
|
| 432 | + $p->code = 'supprimer_numero(calculer_url(' . |
|
| 433 | + champ_sql('url_site', $p) . ',' . |
|
| 434 | + champ_sql('nom_site', $p) . |
|
| 435 | + ", 'titre', \$connect, false))"; |
|
| 436 | + } else { |
|
| 437 | + $p->code = champ_sql('nom_site', $p); |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - $p->interdire_scripts = true; |
|
| 440 | + $p->interdire_scripts = true; |
|
| 441 | 441 | |
| 442 | - return $p; |
|
| 442 | + return $p; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | |
@@ -456,11 +456,11 @@ discard block |
||
| 456 | 456 | * Pile complétée par le code à générer |
| 457 | 457 | **/ |
| 458 | 458 | function balise_NOTES_dist($p) { |
| 459 | - // Recuperer les notes |
|
| 460 | - $p->code = 'calculer_notes()'; |
|
| 459 | + // Recuperer les notes |
|
| 460 | + $p->code = 'calculer_notes()'; |
|
| 461 | 461 | |
| 462 | - #$p->interdire_scripts = true; |
|
| 463 | - return $p; |
|
| 462 | + #$p->interdire_scripts = true; |
|
| 463 | + return $p; |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * Pile complétée par le code à générer |
| 483 | 483 | **/ |
| 484 | 484 | function balise_RECHERCHE_dist($p) { |
| 485 | - $p->code = 'entites_html(_request("recherche"))'; |
|
| 486 | - $p->interdire_scripts = false; |
|
| 485 | + $p->code = 'entites_html(_request("recherche"))'; |
|
| 486 | + $p->interdire_scripts = false; |
|
| 487 | 487 | |
| 488 | - return $p; |
|
| 488 | + return $p; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -503,17 +503,17 @@ discard block |
||
| 503 | 503 | * Pile complétée par le code à générer |
| 504 | 504 | **/ |
| 505 | 505 | function balise_COMPTEUR_BOUCLE_dist($p) { |
| 506 | - $b = index_boucle_mere($p); |
|
| 507 | - if ($b === '') { |
|
| 508 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 509 | - erreur_squelette($msg, $p); |
|
| 510 | - } else { |
|
| 511 | - $p->code = "(\$Numrows['$b']['compteur_boucle'] ?? 0)"; |
|
| 512 | - $p->boucles[$b]->cptrows = true; |
|
| 513 | - $p->interdire_scripts = false; |
|
| 506 | + $b = index_boucle_mere($p); |
|
| 507 | + if ($b === '') { |
|
| 508 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 509 | + erreur_squelette($msg, $p); |
|
| 510 | + } else { |
|
| 511 | + $p->code = "(\$Numrows['$b']['compteur_boucle'] ?? 0)"; |
|
| 512 | + $p->boucles[$b]->cptrows = true; |
|
| 513 | + $p->interdire_scripts = false; |
|
| 514 | 514 | |
| 515 | - return $p; |
|
| 516 | - } |
|
| 515 | + return $p; |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -531,17 +531,17 @@ discard block |
||
| 531 | 531 | * Pile complétée par le code à générer |
| 532 | 532 | **/ |
| 533 | 533 | function balise_TOTAL_BOUCLE_dist($p) { |
| 534 | - $b = index_boucle_mere($p); |
|
| 535 | - if ($b === '') { |
|
| 536 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 537 | - erreur_squelette($msg, $p); |
|
| 538 | - } else { |
|
| 539 | - $p->code = "(\$Numrows['$b']['total'] ?? 0)"; |
|
| 540 | - $p->boucles[$b]->numrows = true; |
|
| 541 | - $p->interdire_scripts = false; |
|
| 542 | - } |
|
| 534 | + $b = index_boucle_mere($p); |
|
| 535 | + if ($b === '') { |
|
| 536 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 537 | + erreur_squelette($msg, $p); |
|
| 538 | + } else { |
|
| 539 | + $p->code = "(\$Numrows['$b']['total'] ?? 0)"; |
|
| 540 | + $p->boucles[$b]->numrows = true; |
|
| 541 | + $p->interdire_scripts = false; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | - return $p; |
|
| 544 | + return $p; |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * Pile complétée par le code à générer |
| 562 | 562 | **/ |
| 563 | 563 | function balise_POINTS_dist($p) { |
| 564 | - return rindex_pile($p, 'points', 'recherche'); |
|
| 564 | + return rindex_pile($p, 'points', 'recherche'); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | |
@@ -582,12 +582,12 @@ discard block |
||
| 582 | 582 | * Pile complétée par le code à générer |
| 583 | 583 | **/ |
| 584 | 584 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 585 | - $p->code = 'ceil(' . |
|
| 586 | - champ_sql('popularite', $p) . |
|
| 587 | - ')'; |
|
| 588 | - $p->interdire_scripts = false; |
|
| 585 | + $p->code = 'ceil(' . |
|
| 586 | + champ_sql('popularite', $p) . |
|
| 587 | + ')'; |
|
| 588 | + $p->interdire_scripts = false; |
|
| 589 | 589 | |
| 590 | - return $p; |
|
| 590 | + return $p; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -607,10 +607,10 @@ discard block |
||
| 607 | 607 | * Pile complétée par le code à générer |
| 608 | 608 | **/ |
| 609 | 609 | function balise_POPULARITE_SITE_dist($p) { |
| 610 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 611 | - $p->interdire_scripts = false; |
|
| 610 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 611 | + $p->interdire_scripts = false; |
|
| 612 | 612 | |
| 613 | - return $p; |
|
| 613 | + return $p; |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -631,10 +631,10 @@ discard block |
||
| 631 | 631 | * Pile complétée par le code à générer |
| 632 | 632 | **/ |
| 633 | 633 | function balise_POPULARITE_MAX_dist($p) { |
| 634 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 635 | - $p->interdire_scripts = false; |
|
| 634 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 635 | + $p->interdire_scripts = false; |
|
| 636 | 636 | |
| 637 | - return $p; |
|
| 637 | + return $p; |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | |
@@ -660,15 +660,15 @@ discard block |
||
| 660 | 660 | * Pile complétée par le code à générer |
| 661 | 661 | **/ |
| 662 | 662 | function balise_VALEUR_dist($p) { |
| 663 | - $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 664 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
|
| 663 | + $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 664 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); |
|
| 665 | 665 | ; |
| 666 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 667 | - $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 668 | - } |
|
| 669 | - $p->interdire_scripts = true; |
|
| 666 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 667 | + $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 668 | + } |
|
| 669 | + $p->interdire_scripts = true; |
|
| 670 | 670 | |
| 671 | - return $p; |
|
| 671 | + return $p; |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -697,16 +697,16 @@ discard block |
||
| 697 | 697 | * Pile complétée par le code à générer |
| 698 | 698 | **/ |
| 699 | 699 | function balise_EXPOSE_dist($p) { |
| 700 | - $on = "'on'"; |
|
| 701 | - $off = "''"; |
|
| 702 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 703 | - $on = $v; |
|
| 704 | - if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 705 | - $off = $v; |
|
| 706 | - } |
|
| 707 | - } |
|
| 700 | + $on = "'on'"; |
|
| 701 | + $off = "''"; |
|
| 702 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 703 | + $on = $v; |
|
| 704 | + if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 705 | + $off = $v; |
|
| 706 | + } |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | - return calculer_balise_expose($p, $on, $off); |
|
| 709 | + return calculer_balise_expose($p, $on, $off); |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | /** |
@@ -724,35 +724,35 @@ discard block |
||
| 724 | 724 | * Pile complétée par le code à générer |
| 725 | 725 | **/ |
| 726 | 726 | function calculer_balise_expose($p, $on, $off) { |
| 727 | - $b = index_boucle($p); |
|
| 728 | - if (empty($p->boucles[$b]->primary)) { |
|
| 729 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 730 | - erreur_squelette($msg, $p); |
|
| 731 | - } else { |
|
| 732 | - $key = $p->boucles[$b]->primary; |
|
| 733 | - $type = $p->boucles[$p->id_boucle]->primary; |
|
| 734 | - $desc = $p->boucles[$b]->show; |
|
| 735 | - $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 727 | + $b = index_boucle($p); |
|
| 728 | + if (empty($p->boucles[$b]->primary)) { |
|
| 729 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 730 | + erreur_squelette($msg, $p); |
|
| 731 | + } else { |
|
| 732 | + $key = $p->boucles[$b]->primary; |
|
| 733 | + $type = $p->boucles[$p->id_boucle]->primary; |
|
| 734 | + $desc = $p->boucles[$b]->show; |
|
| 735 | + $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 736 | 736 | |
| 737 | - // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 738 | - $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 737 | + // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 738 | + $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 739 | 739 | |
| 740 | - if (isset($desc['field']['id_parent'])) { |
|
| 741 | - $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 742 | - } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 743 | - $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 744 | - } elseif (isset($desc['field']['id_groupe'])) { |
|
| 745 | - $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 746 | - } else { |
|
| 747 | - $parent = "''"; |
|
| 748 | - } |
|
| 740 | + if (isset($desc['field']['id_parent'])) { |
|
| 741 | + $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 742 | + } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 743 | + $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 744 | + } elseif (isset($desc['field']['id_groupe'])) { |
|
| 745 | + $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 746 | + } else { |
|
| 747 | + $parent = "''"; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 751 | - } |
|
| 750 | + $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | - $p->interdire_scripts = false; |
|
| 753 | + $p->interdire_scripts = false; |
|
| 754 | 754 | |
| 755 | - return $p; |
|
| 755 | + return $p; |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | |
@@ -793,46 +793,46 @@ discard block |
||
| 793 | 793 | **/ |
| 794 | 794 | function balise_INTRODUCTION_dist($p) { |
| 795 | 795 | |
| 796 | - $type_objet = $p->type_requete; |
|
| 797 | - $cle_objet = id_table_objet($type_objet); |
|
| 798 | - $_id_objet = champ_sql($cle_objet, $p); |
|
| 799 | - |
|
| 800 | - // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo |
|
| 801 | - // ainsi que le longueur d'introduction donnée dans la description de l'objet. |
|
| 802 | - $_introduction_longueur = 'null'; |
|
| 803 | - $_ligne = 'array('; |
|
| 804 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 805 | - if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
|
| 806 | - if (isset($desc['field']['descriptif'])) { |
|
| 807 | - $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 808 | - } |
|
| 809 | - if (isset($desc['field']['texte'])) { |
|
| 810 | - $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 811 | - } |
|
| 812 | - if (isset($desc['field']['chapo'])) { |
|
| 813 | - $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 814 | - } |
|
| 815 | - if (isset($desc['introduction_longueur'])) { |
|
| 816 | - $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 817 | - } |
|
| 818 | - } |
|
| 819 | - $_ligne .= ')'; |
|
| 820 | - |
|
| 821 | - // Récupérer la longueur et la suite passés en paramètres |
|
| 822 | - $_longueur_ou_suite = 'null'; |
|
| 823 | - if (($v1 = interprete_argument_balise(1, $p)) !== null) { |
|
| 824 | - $_longueur_ou_suite = $v1; |
|
| 825 | - } |
|
| 826 | - $_suite = 'null'; |
|
| 827 | - if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 828 | - $_suite = $v2; |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - $p->code = "generer_objet_introduction($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)"; |
|
| 832 | - |
|
| 833 | - #$p->interdire_scripts = true; |
|
| 834 | - $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 835 | - return $p; |
|
| 796 | + $type_objet = $p->type_requete; |
|
| 797 | + $cle_objet = id_table_objet($type_objet); |
|
| 798 | + $_id_objet = champ_sql($cle_objet, $p); |
|
| 799 | + |
|
| 800 | + // Récupérer les valeurs sql nécessaires : descriptif, texte et chapo |
|
| 801 | + // ainsi que le longueur d'introduction donnée dans la description de l'objet. |
|
| 802 | + $_introduction_longueur = 'null'; |
|
| 803 | + $_ligne = 'array('; |
|
| 804 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 805 | + if ($desc = $trouver_table(table_objet_sql($type_objet))) { |
|
| 806 | + if (isset($desc['field']['descriptif'])) { |
|
| 807 | + $_ligne .= "'descriptif' => " . champ_sql('descriptif', $p) . ','; |
|
| 808 | + } |
|
| 809 | + if (isset($desc['field']['texte'])) { |
|
| 810 | + $_ligne .= "'texte' => " . champ_sql('texte', $p) . ','; |
|
| 811 | + } |
|
| 812 | + if (isset($desc['field']['chapo'])) { |
|
| 813 | + $_ligne .= "'chapo' => " . champ_sql('chapo', $p) . ','; |
|
| 814 | + } |
|
| 815 | + if (isset($desc['introduction_longueur'])) { |
|
| 816 | + $_introduction_longueur = "'" . $desc['introduction_longueur'] . "'"; |
|
| 817 | + } |
|
| 818 | + } |
|
| 819 | + $_ligne .= ')'; |
|
| 820 | + |
|
| 821 | + // Récupérer la longueur et la suite passés en paramètres |
|
| 822 | + $_longueur_ou_suite = 'null'; |
|
| 823 | + if (($v1 = interprete_argument_balise(1, $p)) !== null) { |
|
| 824 | + $_longueur_ou_suite = $v1; |
|
| 825 | + } |
|
| 826 | + $_suite = 'null'; |
|
| 827 | + if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 828 | + $_suite = $v2; |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + $p->code = "generer_objet_introduction($_id_objet, '$type_objet', $_ligne, $_introduction_longueur, $_longueur_ou_suite, $_suite, \$connect)"; |
|
| 832 | + |
|
| 833 | + #$p->interdire_scripts = true; |
|
| 834 | + $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 835 | + return $p; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | |
@@ -852,15 +852,15 @@ discard block |
||
| 852 | 852 | * Pile complétée par le code à générer |
| 853 | 853 | **/ |
| 854 | 854 | function balise_LANG_dist($p) { |
| 855 | - $_lang = champ_sql('lang', $p); |
|
| 856 | - if (!$p->etoile) { |
|
| 857 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 858 | - } else { |
|
| 859 | - $p->code = "spip_htmlentities($_lang)"; |
|
| 860 | - } |
|
| 861 | - $p->interdire_scripts = false; |
|
| 855 | + $_lang = champ_sql('lang', $p); |
|
| 856 | + if (!$p->etoile) { |
|
| 857 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 858 | + } else { |
|
| 859 | + $p->code = "spip_htmlentities($_lang)"; |
|
| 860 | + } |
|
| 861 | + $p->interdire_scripts = false; |
|
| 862 | 862 | |
| 863 | - return $p; |
|
| 863 | + return $p; |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -882,45 +882,45 @@ discard block |
||
| 882 | 882 | * Pile complétée par le code à générer |
| 883 | 883 | */ |
| 884 | 884 | function balise_LESAUTEURS_dist($p) { |
| 885 | - // Cherche le champ 'lesauteurs' dans la pile |
|
| 886 | - $_lesauteurs = champ_sql('lesauteurs', $p, ''); |
|
| 887 | - |
|
| 888 | - // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 889 | - // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 890 | - // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 891 | - // (cf extension sites/) |
|
| 892 | - if ($_lesauteurs) { |
|
| 893 | - $p->code = "safehtml($_lesauteurs)"; |
|
| 894 | - // $p->interdire_scripts = true; |
|
| 895 | - } else { |
|
| 896 | - if (!$p->id_boucle) { |
|
| 897 | - $connect = ''; |
|
| 898 | - $objet = 'article'; |
|
| 899 | - $id_table_objet = 'id_article'; |
|
| 900 | - } else { |
|
| 901 | - $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 902 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 903 | - $type_boucle = $p->boucles[$b]->type_requete; |
|
| 904 | - $objet = objet_type($type_boucle); |
|
| 905 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 906 | - } |
|
| 907 | - $c = memoriser_contexte_compil($p); |
|
| 908 | - |
|
| 909 | - $p->code = sprintf( |
|
| 910 | - CODE_RECUPERER_FOND, |
|
| 911 | - "'modeles/lesauteurs'", |
|
| 912 | - "array('objet'=>'" . $objet . |
|
| 913 | - "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 914 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 915 | - ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 916 | - ')', |
|
| 917 | - "'trim'=>true, 'compil'=>array($c)", |
|
| 918 | - _q($connect) |
|
| 919 | - ); |
|
| 920 | - $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 921 | - } |
|
| 922 | - |
|
| 923 | - return $p; |
|
| 885 | + // Cherche le champ 'lesauteurs' dans la pile |
|
| 886 | + $_lesauteurs = champ_sql('lesauteurs', $p, ''); |
|
| 887 | + |
|
| 888 | + // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 889 | + // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 890 | + // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 891 | + // (cf extension sites/) |
|
| 892 | + if ($_lesauteurs) { |
|
| 893 | + $p->code = "safehtml($_lesauteurs)"; |
|
| 894 | + // $p->interdire_scripts = true; |
|
| 895 | + } else { |
|
| 896 | + if (!$p->id_boucle) { |
|
| 897 | + $connect = ''; |
|
| 898 | + $objet = 'article'; |
|
| 899 | + $id_table_objet = 'id_article'; |
|
| 900 | + } else { |
|
| 901 | + $b = $p->nom_boucle ?: $p->id_boucle; |
|
| 902 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 903 | + $type_boucle = $p->boucles[$b]->type_requete; |
|
| 904 | + $objet = objet_type($type_boucle); |
|
| 905 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 906 | + } |
|
| 907 | + $c = memoriser_contexte_compil($p); |
|
| 908 | + |
|
| 909 | + $p->code = sprintf( |
|
| 910 | + CODE_RECUPERER_FOND, |
|
| 911 | + "'modeles/lesauteurs'", |
|
| 912 | + "array('objet'=>'" . $objet . |
|
| 913 | + "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 914 | + ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 915 | + ($objet == 'article' ? '' : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 916 | + ')', |
|
| 917 | + "'trim'=>true, 'compil'=>array($c)", |
|
| 918 | + _q($connect) |
|
| 919 | + ); |
|
| 920 | + $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 921 | + } |
|
| 922 | + |
|
| 923 | + return $p; |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | |
@@ -947,76 +947,76 @@ discard block |
||
| 947 | 947 | * Pile complétée par le code à générer |
| 948 | 948 | */ |
| 949 | 949 | function balise_RANG_dist($p) { |
| 950 | - $b = index_boucle($p); |
|
| 951 | - if ($b === '') { |
|
| 952 | - $msg = [ |
|
| 953 | - 'zbug_champ_hors_boucle', |
|
| 954 | - ['champ' => '#RANG'] |
|
| 955 | - ]; |
|
| 956 | - erreur_squelette($msg, $p); |
|
| 957 | - } else { |
|
| 958 | - // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 959 | - // dans la boucle immediatement englobante uniquement |
|
| 960 | - // sinon on compose le champ calcule |
|
| 961 | - $_rang = champ_sql('rang', $p, '', false); |
|
| 962 | - |
|
| 963 | - // si pas trouve de champ sql rang : |
|
| 964 | - if (!$_rang or $_rang == "''") { |
|
| 965 | - $boucle = &$p->boucles[$b]; |
|
| 966 | - |
|
| 967 | - // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 968 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 969 | - $desc = $trouver_table($boucle->id_table); |
|
| 970 | - $_titre = ''; # où extraire le numero ? |
|
| 971 | - |
|
| 972 | - if (isset($desc['titre'])) { |
|
| 973 | - $t = $desc['titre']; |
|
| 974 | - if ( |
|
| 975 | - // Soit on trouve avec la déclaration de la lang AVANT |
|
| 976 | - preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 977 | - // Soit on prend depuis le début |
|
| 978 | - or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 979 | - ) { |
|
| 980 | - $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 981 | - $m = trim($m); |
|
| 982 | - if ($m != "''") { |
|
| 983 | - if (!preg_match(',\W,', $m)) { |
|
| 984 | - $m = $boucle->id_table . ".$m"; |
|
| 985 | - } |
|
| 986 | - |
|
| 987 | - $m .= ' AS titre_rang'; |
|
| 988 | - |
|
| 989 | - $boucle->select[] = $m; |
|
| 990 | - $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 996 | - if (!$_titre) { |
|
| 997 | - $_titre = champ_sql('titre', $p); |
|
| 998 | - } |
|
| 999 | - |
|
| 1000 | - // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1001 | - // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1002 | - $type_boucle = $boucle->type_requete; |
|
| 1003 | - $objet = objet_type($type_boucle); |
|
| 1004 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 1005 | - $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1006 | - $_env = '$Pile[0]'; |
|
| 1007 | - |
|
| 1008 | - if (!$_titre) {$_titre = "''"; |
|
| 1009 | - } |
|
| 1010 | - if (!$_primary) {$_primary = "''"; |
|
| 1011 | - } |
|
| 1012 | - $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1013 | - } |
|
| 1014 | - |
|
| 1015 | - $p->code = $_rang; |
|
| 1016 | - $p->interdire_scripts = false; |
|
| 1017 | - } |
|
| 1018 | - |
|
| 1019 | - return $p; |
|
| 950 | + $b = index_boucle($p); |
|
| 951 | + if ($b === '') { |
|
| 952 | + $msg = [ |
|
| 953 | + 'zbug_champ_hors_boucle', |
|
| 954 | + ['champ' => '#RANG'] |
|
| 955 | + ]; |
|
| 956 | + erreur_squelette($msg, $p); |
|
| 957 | + } else { |
|
| 958 | + // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 959 | + // dans la boucle immediatement englobante uniquement |
|
| 960 | + // sinon on compose le champ calcule |
|
| 961 | + $_rang = champ_sql('rang', $p, '', false); |
|
| 962 | + |
|
| 963 | + // si pas trouve de champ sql rang : |
|
| 964 | + if (!$_rang or $_rang == "''") { |
|
| 965 | + $boucle = &$p->boucles[$b]; |
|
| 966 | + |
|
| 967 | + // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 968 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 969 | + $desc = $trouver_table($boucle->id_table); |
|
| 970 | + $_titre = ''; # où extraire le numero ? |
|
| 971 | + |
|
| 972 | + if (isset($desc['titre'])) { |
|
| 973 | + $t = $desc['titre']; |
|
| 974 | + if ( |
|
| 975 | + // Soit on trouve avec la déclaration de la lang AVANT |
|
| 976 | + preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 977 | + // Soit on prend depuis le début |
|
| 978 | + or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 979 | + ) { |
|
| 980 | + $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 981 | + $m = trim($m); |
|
| 982 | + if ($m != "''") { |
|
| 983 | + if (!preg_match(',\W,', $m)) { |
|
| 984 | + $m = $boucle->id_table . ".$m"; |
|
| 985 | + } |
|
| 986 | + |
|
| 987 | + $m .= ' AS titre_rang'; |
|
| 988 | + |
|
| 989 | + $boucle->select[] = $m; |
|
| 990 | + $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 996 | + if (!$_titre) { |
|
| 997 | + $_titre = champ_sql('titre', $p); |
|
| 998 | + } |
|
| 999 | + |
|
| 1000 | + // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1001 | + // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1002 | + $type_boucle = $boucle->type_requete; |
|
| 1003 | + $objet = objet_type($type_boucle); |
|
| 1004 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 1005 | + $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1006 | + $_env = '$Pile[0]'; |
|
| 1007 | + |
|
| 1008 | + if (!$_titre) {$_titre = "''"; |
|
| 1009 | + } |
|
| 1010 | + if (!$_primary) {$_primary = "''"; |
|
| 1011 | + } |
|
| 1012 | + $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + $p->code = $_rang; |
|
| 1016 | + $p->interdire_scripts = false; |
|
| 1017 | + } |
|
| 1018 | + |
|
| 1019 | + return $p; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | |
@@ -1038,12 +1038,12 @@ discard block |
||
| 1038 | 1038 | * Pile complétée par le code à générer |
| 1039 | 1039 | **/ |
| 1040 | 1040 | function balise_POPULARITE_dist($p) { |
| 1041 | - $_popularite = champ_sql('popularite', $p); |
|
| 1042 | - $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1041 | + $_popularite = champ_sql('popularite', $p); |
|
| 1042 | + $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1043 | 1043 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; |
| 1044 | - $p->interdire_scripts = false; |
|
| 1044 | + $p->interdire_scripts = false; |
|
| 1045 | 1045 | |
| 1046 | - return $p; |
|
| 1046 | + return $p; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | /** |
@@ -1054,8 +1054,8 @@ discard block |
||
| 1054 | 1054 | * l'absence peut-être due à une faute de frappe dans le contexte inclus. |
| 1055 | 1055 | */ |
| 1056 | 1056 | define( |
| 1057 | - 'CODE_PAGINATION', |
|
| 1058 | - '%s($Numrows["%s"]["grand_total"], |
|
| 1057 | + 'CODE_PAGINATION', |
|
| 1058 | + '%s($Numrows["%s"]["grand_total"], |
|
| 1059 | 1059 | %s, |
| 1060 | 1060 | isset($Pile[0][%4$s])?$Pile[0][%4$s]:intval(_request(%4$s)), |
| 1061 | 1061 | %5$s, %6$s, %7$s, %8$s, array(%9$s))' |
@@ -1092,75 +1092,75 @@ discard block |
||
| 1092 | 1092 | * Pile complétée par le code à générer |
| 1093 | 1093 | */ |
| 1094 | 1094 | function balise_PAGINATION_dist($p, $liste = 'true') { |
| 1095 | - $b = index_boucle_mere($p); |
|
| 1096 | - |
|
| 1097 | - // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1098 | - if ($b === '') { |
|
| 1099 | - $msg = [ |
|
| 1100 | - 'zbug_champ_hors_boucle', |
|
| 1101 | - ['champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION'] |
|
| 1102 | - ]; |
|
| 1103 | - erreur_squelette($msg, $p); |
|
| 1104 | - |
|
| 1105 | - return $p; |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1109 | - // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1110 | - if (!$p->boucles[$b]->mode_partie) { |
|
| 1111 | - if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1112 | - $msg = [ |
|
| 1113 | - 'zbug_pagination_sans_critere', |
|
| 1114 | - ['champ' => '#PAGINATION'] |
|
| 1115 | - ]; |
|
| 1116 | - erreur_squelette($msg, $p); |
|
| 1117 | - } |
|
| 1118 | - |
|
| 1119 | - return $p; |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - // a priori true |
|
| 1123 | - // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1124 | - // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1125 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1126 | - if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1127 | - $key = key($_contexte); |
|
| 1128 | - if (is_numeric($key)) { |
|
| 1129 | - array_shift($_contexte); |
|
| 1130 | - $__modele = interprete_argument_balise(1, $p); |
|
| 1131 | - } |
|
| 1132 | - } |
|
| 1133 | - |
|
| 1134 | - if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1135 | - $code_contexte = implode(',', $_contexte); |
|
| 1136 | - } else { |
|
| 1137 | - $code_contexte = ''; |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 1141 | - $pas = $p->boucles[$b]->total_parties; |
|
| 1142 | - $f_pagination = chercher_filtre('pagination'); |
|
| 1143 | - $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1144 | - $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1145 | - : ("'debut" . substr($type, 1)); |
|
| 1146 | - |
|
| 1147 | - $p->code = sprintf( |
|
| 1148 | - CODE_PAGINATION, |
|
| 1149 | - $f_pagination, |
|
| 1150 | - $b, |
|
| 1151 | - $type, |
|
| 1152 | - $modif, |
|
| 1153 | - $pas, |
|
| 1154 | - $liste, |
|
| 1155 | - ((isset($__modele) and $__modele) ? $__modele : "''"), |
|
| 1156 | - _q($connect), |
|
| 1157 | - $code_contexte |
|
| 1158 | - ); |
|
| 1159 | - |
|
| 1160 | - $p->boucles[$b]->numrows = true; |
|
| 1161 | - $p->interdire_scripts = false; |
|
| 1162 | - |
|
| 1163 | - return $p; |
|
| 1095 | + $b = index_boucle_mere($p); |
|
| 1096 | + |
|
| 1097 | + // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1098 | + if ($b === '') { |
|
| 1099 | + $msg = [ |
|
| 1100 | + 'zbug_champ_hors_boucle', |
|
| 1101 | + ['champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION'] |
|
| 1102 | + ]; |
|
| 1103 | + erreur_squelette($msg, $p); |
|
| 1104 | + |
|
| 1105 | + return $p; |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1109 | + // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1110 | + if (!$p->boucles[$b]->mode_partie) { |
|
| 1111 | + if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1112 | + $msg = [ |
|
| 1113 | + 'zbug_pagination_sans_critere', |
|
| 1114 | + ['champ' => '#PAGINATION'] |
|
| 1115 | + ]; |
|
| 1116 | + erreur_squelette($msg, $p); |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + return $p; |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + // a priori true |
|
| 1123 | + // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1124 | + // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1125 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1126 | + if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1127 | + $key = key($_contexte); |
|
| 1128 | + if (is_numeric($key)) { |
|
| 1129 | + array_shift($_contexte); |
|
| 1130 | + $__modele = interprete_argument_balise(1, $p); |
|
| 1131 | + } |
|
| 1132 | + } |
|
| 1133 | + |
|
| 1134 | + if (is_countable($_contexte) ? count($_contexte) : 0) { |
|
| 1135 | + $code_contexte = implode(',', $_contexte); |
|
| 1136 | + } else { |
|
| 1137 | + $code_contexte = ''; |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 1141 | + $pas = $p->boucles[$b]->total_parties; |
|
| 1142 | + $f_pagination = chercher_filtre('pagination'); |
|
| 1143 | + $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1144 | + $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1145 | + : ("'debut" . substr($type, 1)); |
|
| 1146 | + |
|
| 1147 | + $p->code = sprintf( |
|
| 1148 | + CODE_PAGINATION, |
|
| 1149 | + $f_pagination, |
|
| 1150 | + $b, |
|
| 1151 | + $type, |
|
| 1152 | + $modif, |
|
| 1153 | + $pas, |
|
| 1154 | + $liste, |
|
| 1155 | + ((isset($__modele) and $__modele) ? $__modele : "''"), |
|
| 1156 | + _q($connect), |
|
| 1157 | + $code_contexte |
|
| 1158 | + ); |
|
| 1159 | + |
|
| 1160 | + $p->boucles[$b]->numrows = true; |
|
| 1161 | + $p->interdire_scripts = false; |
|
| 1162 | + |
|
| 1163 | + return $p; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | |
@@ -1187,11 +1187,11 @@ discard block |
||
| 1187 | 1187 | * Pile complétée par le code à générer |
| 1188 | 1188 | **/ |
| 1189 | 1189 | function balise_ANCRE_PAGINATION_dist($p) { |
| 1190 | - if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1191 | - return $f($p, $liste = 'false'); |
|
| 1192 | - } else { |
|
| 1193 | - return null; |
|
| 1194 | - } // ou une erreur ? |
|
| 1190 | + if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1191 | + return $f($p, $liste = 'false'); |
|
| 1192 | + } else { |
|
| 1193 | + return null; |
|
| 1194 | + } // ou une erreur ? |
|
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | |
@@ -1212,17 +1212,17 @@ discard block |
||
| 1212 | 1212 | * Pile complétée par le code à générer |
| 1213 | 1213 | **/ |
| 1214 | 1214 | function balise_GRAND_TOTAL_dist($p) { |
| 1215 | - $b = index_boucle_mere($p); |
|
| 1216 | - if ($b === '') { |
|
| 1217 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 1218 | - erreur_squelette($msg, $p); |
|
| 1219 | - } else { |
|
| 1220 | - $p->code = "(\$Numrows['$b']['grand_total'] ?? \$Numrows['$b']['total'] ?? 0)"; |
|
| 1221 | - $p->boucles[$b]->numrows = true; |
|
| 1222 | - $p->interdire_scripts = false; |
|
| 1223 | - } |
|
| 1215 | + $b = index_boucle_mere($p); |
|
| 1216 | + if ($b === '') { |
|
| 1217 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 1218 | + erreur_squelette($msg, $p); |
|
| 1219 | + } else { |
|
| 1220 | + $p->code = "(\$Numrows['$b']['grand_total'] ?? \$Numrows['$b']['total'] ?? 0)"; |
|
| 1221 | + $p->boucles[$b]->numrows = true; |
|
| 1222 | + $p->interdire_scripts = false; |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | - return $p; |
|
| 1225 | + return $p; |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | 1228 | |
@@ -1250,10 +1250,10 @@ discard block |
||
| 1250 | 1250 | * Pile complétée par le code à générer |
| 1251 | 1251 | **/ |
| 1252 | 1252 | function balise_SELF_dist($p) { |
| 1253 | - $p->code = 'self()'; |
|
| 1254 | - $p->interdire_scripts = false; |
|
| 1253 | + $p->code = 'self()'; |
|
| 1254 | + $p->interdire_scripts = false; |
|
| 1255 | 1255 | |
| 1256 | - return $p; |
|
| 1256 | + return $p; |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | |
@@ -1280,17 +1280,17 @@ discard block |
||
| 1280 | 1280 | * Pile complétée par le code à générer |
| 1281 | 1281 | **/ |
| 1282 | 1282 | function balise_CHEMIN_dist($p) { |
| 1283 | - $arg = interprete_argument_balise(1, $p); |
|
| 1284 | - if (!$arg) { |
|
| 1285 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
|
| 1286 | - erreur_squelette($msg, $p); |
|
| 1287 | - } else { |
|
| 1288 | - $p->code = 'find_in_path((string)' . $arg . ')'; |
|
| 1289 | - } |
|
| 1283 | + $arg = interprete_argument_balise(1, $p); |
|
| 1284 | + if (!$arg) { |
|
| 1285 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN']]; |
|
| 1286 | + erreur_squelette($msg, $p); |
|
| 1287 | + } else { |
|
| 1288 | + $p->code = 'find_in_path((string)' . $arg . ')'; |
|
| 1289 | + } |
|
| 1290 | 1290 | |
| 1291 | - $p->interdire_scripts = false; |
|
| 1291 | + $p->interdire_scripts = false; |
|
| 1292 | 1292 | |
| 1293 | - return $p; |
|
| 1293 | + return $p; |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | /** |
@@ -1315,16 +1315,16 @@ discard block |
||
| 1315 | 1315 | * Pile complétée par le code à générer |
| 1316 | 1316 | **/ |
| 1317 | 1317 | function balise_CHEMIN_IMAGE_dist($p) { |
| 1318 | - $arg = interprete_argument_balise(1, $p); |
|
| 1319 | - if (!$arg) { |
|
| 1320 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
|
| 1321 | - erreur_squelette($msg, $p); |
|
| 1322 | - } else { |
|
| 1323 | - $p->code = 'chemin_image((string)' . $arg . ')'; |
|
| 1324 | - } |
|
| 1318 | + $arg = interprete_argument_balise(1, $p); |
|
| 1319 | + if (!$arg) { |
|
| 1320 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' CHEMIN_IMAGE']]; |
|
| 1321 | + erreur_squelette($msg, $p); |
|
| 1322 | + } else { |
|
| 1323 | + $p->code = 'chemin_image((string)' . $arg . ')'; |
|
| 1324 | + } |
|
| 1325 | 1325 | |
| 1326 | - $p->interdire_scripts = false; |
|
| 1327 | - return $p; |
|
| 1326 | + $p->interdire_scripts = false; |
|
| 1327 | + return $p; |
|
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | |
@@ -1362,36 +1362,36 @@ discard block |
||
| 1362 | 1362 | **/ |
| 1363 | 1363 | function balise_ENV_dist($p, $src = null) { |
| 1364 | 1364 | |
| 1365 | - // cle du tableau desiree |
|
| 1366 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1367 | - // valeur par defaut |
|
| 1368 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1365 | + // cle du tableau desiree |
|
| 1366 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1367 | + // valeur par defaut |
|
| 1368 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1369 | 1369 | |
| 1370 | - // $src est un tableau de donnees sources eventuellement transmis |
|
| 1371 | - // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1370 | + // $src est un tableau de donnees sources eventuellement transmis |
|
| 1371 | + // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1372 | 1372 | |
| 1373 | - if (!$_nom) { |
|
| 1374 | - // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1375 | - // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1376 | - if ($src) { |
|
| 1377 | - $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1378 | - } else { |
|
| 1379 | - $p->code = 'serialize($Pile[0]??[])'; |
|
| 1380 | - } |
|
| 1381 | - } else { |
|
| 1382 | - if (!$src) { |
|
| 1383 | - $src = '$Pile[0]??[]'; |
|
| 1384 | - } |
|
| 1385 | - if ($_sinon) { |
|
| 1386 | - $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1387 | - } else { |
|
| 1388 | - $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1389 | - } |
|
| 1390 | - } |
|
| 1373 | + if (!$_nom) { |
|
| 1374 | + // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1375 | + // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1376 | + if ($src) { |
|
| 1377 | + $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1378 | + } else { |
|
| 1379 | + $p->code = 'serialize($Pile[0]??[])'; |
|
| 1380 | + } |
|
| 1381 | + } else { |
|
| 1382 | + if (!$src) { |
|
| 1383 | + $src = '$Pile[0]??[]'; |
|
| 1384 | + } |
|
| 1385 | + if ($_sinon) { |
|
| 1386 | + $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1387 | + } else { |
|
| 1388 | + $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | 1391 | |
| 1392 | - #$p->interdire_scripts = true; |
|
| 1392 | + #$p->interdire_scripts = true; |
|
| 1393 | 1393 | |
| 1394 | - return $p; |
|
| 1394 | + return $p; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1421,16 +1421,16 @@ discard block |
||
| 1421 | 1421 | * Pile completée du code PHP d'exécution de la balise |
| 1422 | 1422 | */ |
| 1423 | 1423 | function balise_CONFIG_dist($p) { |
| 1424 | - if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1425 | - $arg = "''"; |
|
| 1426 | - } |
|
| 1427 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1428 | - $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
|
| 1424 | + if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1425 | + $arg = "''"; |
|
| 1426 | + } |
|
| 1427 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1428 | + $_unserialize = sinon(interprete_argument_balise(3, $p), 'false'); |
|
| 1429 | 1429 | |
| 1430 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1431 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1430 | + $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1431 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1432 | 1432 | |
| 1433 | - return $p; |
|
| 1433 | + return $p; |
|
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | |
@@ -1453,10 +1453,10 @@ discard block |
||
| 1453 | 1453 | * Pile completée du code PHP d'exécution de la balise |
| 1454 | 1454 | */ |
| 1455 | 1455 | function balise_CONNECT_dist($p) { |
| 1456 | - $p->code = '($connect ? $connect : NULL)'; |
|
| 1457 | - $p->interdire_scripts = false; |
|
| 1456 | + $p->code = '($connect ? $connect : NULL)'; |
|
| 1457 | + $p->interdire_scripts = false; |
|
| 1458 | 1458 | |
| 1459 | - return $p; |
|
| 1459 | + return $p; |
|
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | |
@@ -1484,15 +1484,15 @@ discard block |
||
| 1484 | 1484 | * Pile completée du code PHP d'exécution de la balise |
| 1485 | 1485 | **/ |
| 1486 | 1486 | function balise_SESSION_dist($p) { |
| 1487 | - $p->descr['session'] = true; |
|
| 1487 | + $p->descr['session'] = true; |
|
| 1488 | 1488 | |
| 1489 | - $f = function_exists('balise_ENV') |
|
| 1490 | - ? 'balise_ENV' |
|
| 1491 | - : 'balise_ENV_dist'; |
|
| 1489 | + $f = function_exists('balise_ENV') |
|
| 1490 | + ? 'balise_ENV' |
|
| 1491 | + : 'balise_ENV_dist'; |
|
| 1492 | 1492 | |
| 1493 | - $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); |
|
| 1493 | + $p = $f($p, '$GLOBALS["visiteur_session"]??[]'); |
|
| 1494 | 1494 | |
| 1495 | - return $p; |
|
| 1495 | + return $p; |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 | |
@@ -1515,18 +1515,18 @@ discard block |
||
| 1515 | 1515 | * Pile completée du code PHP d'exécution de la balise |
| 1516 | 1516 | **/ |
| 1517 | 1517 | function balise_SESSION_SET_dist($p) { |
| 1518 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1519 | - $_val = interprete_argument_balise(2, $p); |
|
| 1520 | - if (!$_nom or !$_val) { |
|
| 1521 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
|
| 1522 | - erreur_squelette($err_b_s_a, $p); |
|
| 1523 | - } else { |
|
| 1524 | - $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1525 | - } |
|
| 1518 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1519 | + $_val = interprete_argument_balise(2, $p); |
|
| 1520 | + if (!$_nom or !$_val) { |
|
| 1521 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SESSION_SET']]; |
|
| 1522 | + erreur_squelette($err_b_s_a, $p); |
|
| 1523 | + } else { |
|
| 1524 | + $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1525 | + } |
|
| 1526 | 1526 | |
| 1527 | - $p->interdire_scripts = false; |
|
| 1527 | + $p->interdire_scripts = false; |
|
| 1528 | 1528 | |
| 1529 | - return $p; |
|
| 1529 | + return $p; |
|
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | |
@@ -1557,30 +1557,30 @@ discard block |
||
| 1557 | 1557 | * Pile completée du code PHP d'exécution de la balise |
| 1558 | 1558 | **/ |
| 1559 | 1559 | function balise_EVAL_dist($p) { |
| 1560 | - $php = interprete_argument_balise(1, $p); |
|
| 1561 | - if ($php) { |
|
| 1562 | - # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1563 | - # attention au commentaire "// x signes" qui precede |
|
| 1564 | - if ( |
|
| 1565 | - preg_match( |
|
| 1566 | - ",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1567 | - $php, |
|
| 1568 | - $r |
|
| 1569 | - ) |
|
| 1570 | - ) { |
|
| 1571 | - $p->code = /* $r[1]. */ |
|
| 1572 | - '(' . $r[2] . ')'; |
|
| 1573 | - } else { |
|
| 1574 | - $p->code = "eval('return '.$php.';')"; |
|
| 1575 | - } |
|
| 1576 | - } else { |
|
| 1577 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' EVAL']]; |
|
| 1578 | - erreur_squelette($msg, $p); |
|
| 1579 | - } |
|
| 1580 | - |
|
| 1581 | - #$p->interdire_scripts = true; |
|
| 1582 | - |
|
| 1583 | - return $p; |
|
| 1560 | + $php = interprete_argument_balise(1, $p); |
|
| 1561 | + if ($php) { |
|
| 1562 | + # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1563 | + # attention au commentaire "// x signes" qui precede |
|
| 1564 | + if ( |
|
| 1565 | + preg_match( |
|
| 1566 | + ",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1567 | + $php, |
|
| 1568 | + $r |
|
| 1569 | + ) |
|
| 1570 | + ) { |
|
| 1571 | + $p->code = /* $r[1]. */ |
|
| 1572 | + '(' . $r[2] . ')'; |
|
| 1573 | + } else { |
|
| 1574 | + $p->code = "eval('return '.$php.';')"; |
|
| 1575 | + } |
|
| 1576 | + } else { |
|
| 1577 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' EVAL']]; |
|
| 1578 | + erreur_squelette($msg, $p); |
|
| 1579 | + } |
|
| 1580 | + |
|
| 1581 | + #$p->interdire_scripts = true; |
|
| 1582 | + |
|
| 1583 | + return $p; |
|
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | |
@@ -1610,19 +1610,19 @@ discard block |
||
| 1610 | 1610 | **/ |
| 1611 | 1611 | function balise_CHAMP_SQL_dist($p) { |
| 1612 | 1612 | |
| 1613 | - if ( |
|
| 1614 | - $p->param |
|
| 1615 | - and isset($p->param[0][1][0]) |
|
| 1616 | - and $champ = ($p->param[0][1][0]->texte) |
|
| 1617 | - ) { |
|
| 1618 | - $p->code = champ_sql($champ, $p); |
|
| 1619 | - } else { |
|
| 1620 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => ' CHAMP_SQL']]; |
|
| 1621 | - erreur_squelette($err_b_s_a, $p); |
|
| 1622 | - } |
|
| 1613 | + if ( |
|
| 1614 | + $p->param |
|
| 1615 | + and isset($p->param[0][1][0]) |
|
| 1616 | + and $champ = ($p->param[0][1][0]->texte) |
|
| 1617 | + ) { |
|
| 1618 | + $p->code = champ_sql($champ, $p); |
|
| 1619 | + } else { |
|
| 1620 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => ' CHAMP_SQL']]; |
|
| 1621 | + erreur_squelette($err_b_s_a, $p); |
|
| 1622 | + } |
|
| 1623 | 1623 | |
| 1624 | - #$p->interdire_scripts = true; |
|
| 1625 | - return $p; |
|
| 1624 | + #$p->interdire_scripts = true; |
|
| 1625 | + return $p; |
|
| 1626 | 1626 | } |
| 1627 | 1627 | |
| 1628 | 1628 | /** |
@@ -1648,13 +1648,13 @@ discard block |
||
| 1648 | 1648 | * Pile complétée par le code à générer |
| 1649 | 1649 | **/ |
| 1650 | 1650 | function balise_VAL_dist($p) { |
| 1651 | - $p->code = interprete_argument_balise(1, $p) ?? ''; |
|
| 1652 | - if (!strlen($p->code)) { |
|
| 1653 | - $p->code = "''"; |
|
| 1654 | - } |
|
| 1655 | - $p->interdire_scripts = false; |
|
| 1651 | + $p->code = interprete_argument_balise(1, $p) ?? ''; |
|
| 1652 | + if (!strlen($p->code)) { |
|
| 1653 | + $p->code = "''"; |
|
| 1654 | + } |
|
| 1655 | + $p->interdire_scripts = false; |
|
| 1656 | 1656 | |
| 1657 | - return $p; |
|
| 1657 | + return $p; |
|
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | 1660 | /** |
@@ -1683,10 +1683,10 @@ discard block |
||
| 1683 | 1683 | * Pile complétée par le code à générer |
| 1684 | 1684 | **/ |
| 1685 | 1685 | function balise_REM_dist($p) { |
| 1686 | - $p->code = "''"; |
|
| 1687 | - $p->interdire_scripts = false; |
|
| 1686 | + $p->code = "''"; |
|
| 1687 | + $p->interdire_scripts = false; |
|
| 1688 | 1688 | |
| 1689 | - return $p; |
|
| 1689 | + return $p; |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | 1692 | /** |
@@ -1696,10 +1696,10 @@ discard block |
||
| 1696 | 1696 | * @return mixed |
| 1697 | 1697 | */ |
| 1698 | 1698 | function balise_NULL_dist($p) { |
| 1699 | - $p->code = 'null'; |
|
| 1700 | - $p->interdire_scripts = false; |
|
| 1699 | + $p->code = 'null'; |
|
| 1700 | + $p->interdire_scripts = false; |
|
| 1701 | 1701 | |
| 1702 | - return $p; |
|
| 1702 | + return $p; |
|
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | 1705 | |
@@ -1723,18 +1723,18 @@ discard block |
||
| 1723 | 1723 | **/ |
| 1724 | 1724 | function balise_HTTP_HEADER_dist($p) { |
| 1725 | 1725 | |
| 1726 | - $header = interprete_argument_balise(1, $p); |
|
| 1727 | - if (!$header) { |
|
| 1728 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'HTTP_HEADER']]; |
|
| 1729 | - erreur_squelette($err_b_s_a, $p); |
|
| 1730 | - } else { |
|
| 1731 | - $p->code = "'<'.'?php header(' . _q(" |
|
| 1732 | - . $header |
|
| 1733 | - . ") . '); ?'.'>'"; |
|
| 1734 | - } |
|
| 1735 | - $p->interdire_scripts = false; |
|
| 1726 | + $header = interprete_argument_balise(1, $p); |
|
| 1727 | + if (!$header) { |
|
| 1728 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'HTTP_HEADER']]; |
|
| 1729 | + erreur_squelette($err_b_s_a, $p); |
|
| 1730 | + } else { |
|
| 1731 | + $p->code = "'<'.'?php header(' . _q(" |
|
| 1732 | + . $header |
|
| 1733 | + . ") . '); ?'.'>'"; |
|
| 1734 | + } |
|
| 1735 | + $p->interdire_scripts = false; |
|
| 1736 | 1736 | |
| 1737 | - return $p; |
|
| 1737 | + return $p; |
|
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | 1740 | |
@@ -1759,20 +1759,20 @@ discard block |
||
| 1759 | 1759 | * Pile complétée par le code à générer |
| 1760 | 1760 | **/ |
| 1761 | 1761 | function balise_FILTRE_dist($p) { |
| 1762 | - if ($p->param) { |
|
| 1763 | - $args = []; |
|
| 1764 | - foreach ($p->param as $i => $ignore) { |
|
| 1765 | - $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1766 | - } |
|
| 1767 | - $p->code = "'<' . '" |
|
| 1768 | - . '?php header("X-Spip-Filtre: \'.' |
|
| 1769 | - . join('.\'|\'.', $args) |
|
| 1770 | - . " . '\"); ?'.'>'"; |
|
| 1762 | + if ($p->param) { |
|
| 1763 | + $args = []; |
|
| 1764 | + foreach ($p->param as $i => $ignore) { |
|
| 1765 | + $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1766 | + } |
|
| 1767 | + $p->code = "'<' . '" |
|
| 1768 | + . '?php header("X-Spip-Filtre: \'.' |
|
| 1769 | + . join('.\'|\'.', $args) |
|
| 1770 | + . " . '\"); ?'.'>'"; |
|
| 1771 | 1771 | |
| 1772 | - $p->interdire_scripts = false; |
|
| 1772 | + $p->interdire_scripts = false; |
|
| 1773 | 1773 | |
| 1774 | - return $p; |
|
| 1775 | - } |
|
| 1774 | + return $p; |
|
| 1775 | + } |
|
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | 1778 | |
@@ -1808,55 +1808,55 @@ discard block |
||
| 1808 | 1808 | **/ |
| 1809 | 1809 | function balise_CACHE_dist($p) { |
| 1810 | 1810 | |
| 1811 | - if ($p->param) { |
|
| 1812 | - $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1813 | - |
|
| 1814 | - // noter la duree du cache dans un entete proprietaire |
|
| 1815 | - |
|
| 1816 | - $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1817 | - . $duree |
|
| 1818 | - . '"); ?' . "'.'>'"; |
|
| 1819 | - |
|
| 1820 | - // Remplir le header Cache-Control |
|
| 1821 | - // cas #CACHE{0} |
|
| 1822 | - if ($duree == 0) { |
|
| 1823 | - $code .= ".'<'.'" |
|
| 1824 | - . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1825 | - . "'.'><'.'" |
|
| 1826 | - . '?php header("Pragma: no-cache"); ?' |
|
| 1827 | - . "'.'>'"; |
|
| 1828 | - } |
|
| 1829 | - |
|
| 1830 | - // recuperer les parametres suivants |
|
| 1831 | - $i = 1; |
|
| 1832 | - while (isset($p->param[0][++$i])) { |
|
| 1833 | - $pa = ($p->param[0][$i][0]->texte); |
|
| 1834 | - |
|
| 1835 | - if ( |
|
| 1836 | - $pa == 'cache-client' |
|
| 1837 | - and $duree > 0 |
|
| 1838 | - ) { |
|
| 1839 | - $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1840 | - . $duree |
|
| 1841 | - . '"); ?' . "'.'>'"; |
|
| 1842 | - // il semble logique, si on cache-client, de ne pas invalider |
|
| 1843 | - $pa = 'statique'; |
|
| 1844 | - } |
|
| 1845 | - |
|
| 1846 | - if ( |
|
| 1847 | - $pa == 'statique' |
|
| 1848 | - and $duree > 0 |
|
| 1849 | - ) { |
|
| 1850 | - $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1851 | - } |
|
| 1852 | - } |
|
| 1853 | - } else { |
|
| 1854 | - $code = "''"; |
|
| 1855 | - } |
|
| 1856 | - $p->code = $code; |
|
| 1857 | - $p->interdire_scripts = false; |
|
| 1858 | - |
|
| 1859 | - return $p; |
|
| 1811 | + if ($p->param) { |
|
| 1812 | + $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1813 | + |
|
| 1814 | + // noter la duree du cache dans un entete proprietaire |
|
| 1815 | + |
|
| 1816 | + $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1817 | + . $duree |
|
| 1818 | + . '"); ?' . "'.'>'"; |
|
| 1819 | + |
|
| 1820 | + // Remplir le header Cache-Control |
|
| 1821 | + // cas #CACHE{0} |
|
| 1822 | + if ($duree == 0) { |
|
| 1823 | + $code .= ".'<'.'" |
|
| 1824 | + . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1825 | + . "'.'><'.'" |
|
| 1826 | + . '?php header("Pragma: no-cache"); ?' |
|
| 1827 | + . "'.'>'"; |
|
| 1828 | + } |
|
| 1829 | + |
|
| 1830 | + // recuperer les parametres suivants |
|
| 1831 | + $i = 1; |
|
| 1832 | + while (isset($p->param[0][++$i])) { |
|
| 1833 | + $pa = ($p->param[0][$i][0]->texte); |
|
| 1834 | + |
|
| 1835 | + if ( |
|
| 1836 | + $pa == 'cache-client' |
|
| 1837 | + and $duree > 0 |
|
| 1838 | + ) { |
|
| 1839 | + $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1840 | + . $duree |
|
| 1841 | + . '"); ?' . "'.'>'"; |
|
| 1842 | + // il semble logique, si on cache-client, de ne pas invalider |
|
| 1843 | + $pa = 'statique'; |
|
| 1844 | + } |
|
| 1845 | + |
|
| 1846 | + if ( |
|
| 1847 | + $pa == 'statique' |
|
| 1848 | + and $duree > 0 |
|
| 1849 | + ) { |
|
| 1850 | + $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1851 | + } |
|
| 1852 | + } |
|
| 1853 | + } else { |
|
| 1854 | + $code = "''"; |
|
| 1855 | + } |
|
| 1856 | + $p->code = $code; |
|
| 1857 | + $p->interdire_scripts = false; |
|
| 1858 | + |
|
| 1859 | + return $p; |
|
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | 1862 | |
@@ -1888,13 +1888,13 @@ discard block |
||
| 1888 | 1888 | * Pile complétée par le code à générer |
| 1889 | 1889 | */ |
| 1890 | 1890 | function balise_INSERT_HEAD_dist($p) { |
| 1891 | - $p->code = "'<'.'" |
|
| 1892 | - . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1893 | - . "'.'>'"; |
|
| 1894 | - $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1895 | - $p->interdire_scripts = false; |
|
| 1891 | + $p->code = "'<'.'" |
|
| 1892 | + . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1893 | + . "'.'>'"; |
|
| 1894 | + $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1895 | + $p->interdire_scripts = false; |
|
| 1896 | 1896 | |
| 1897 | - return $p; |
|
| 1897 | + return $p; |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | /** |
@@ -1912,10 +1912,10 @@ discard block |
||
| 1912 | 1912 | * Pile complétée par le code à générer |
| 1913 | 1913 | */ |
| 1914 | 1914 | function balise_INSERT_HEAD_CSS_dist($p) { |
| 1915 | - $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1916 | - $p->interdire_scripts = false; |
|
| 1915 | + $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1916 | + $p->interdire_scripts = false; |
|
| 1917 | 1917 | |
| 1918 | - return $p; |
|
| 1918 | + return $p; |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | /** |
@@ -1930,11 +1930,11 @@ discard block |
||
| 1930 | 1930 | * Pile complétée par le code à générer |
| 1931 | 1931 | **/ |
| 1932 | 1932 | function balise_INCLUDE_dist($p) { |
| 1933 | - if (function_exists('balise_INCLURE')) { |
|
| 1934 | - return balise_INCLURE($p); |
|
| 1935 | - } else { |
|
| 1936 | - return balise_INCLURE_dist($p); |
|
| 1937 | - } |
|
| 1933 | + if (function_exists('balise_INCLURE')) { |
|
| 1934 | + return balise_INCLURE($p); |
|
| 1935 | + } else { |
|
| 1936 | + return balise_INCLURE_dist($p); |
|
| 1937 | + } |
|
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | 1940 | /** |
@@ -1968,66 +1968,66 @@ discard block |
||
| 1968 | 1968 | * Pile complétée par le code à générer |
| 1969 | 1969 | **/ |
| 1970 | 1970 | function balise_INCLURE_dist($p) { |
| 1971 | - $id_boucle = $p->id_boucle; |
|
| 1972 | - // la lang n'est pas passe de facon automatique par argumenter |
|
| 1973 | - // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1974 | - // en option |
|
| 1975 | - |
|
| 1976 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1977 | - |
|
| 1978 | - // erreur de syntaxe = fond absent |
|
| 1979 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1980 | - if (!$_contexte) { |
|
| 1981 | - $contexte = []; |
|
| 1982 | - } |
|
| 1983 | - |
|
| 1984 | - if (isset($_contexte['fond'])) { |
|
| 1985 | - $f = $_contexte['fond']; |
|
| 1986 | - // toujours vrai : |
|
| 1987 | - if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1988 | - $f = $r[1]; |
|
| 1989 | - unset($_contexte['fond']); |
|
| 1990 | - } else { |
|
| 1991 | - spip_log('compilation de #INCLURE a revoir'); |
|
| 1992 | - } |
|
| 1993 | - |
|
| 1994 | - // #INCLURE{doublons} |
|
| 1995 | - if (isset($_contexte['doublons'])) { |
|
| 1996 | - $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 1997 | - } |
|
| 1998 | - |
|
| 1999 | - // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2000 | - $flag_env = false; |
|
| 2001 | - if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2002 | - $flag_env = true; |
|
| 2003 | - unset($_contexte['env']); |
|
| 2004 | - } |
|
| 2005 | - |
|
| 2006 | - $_options = []; |
|
| 2007 | - if (isset($_contexte['ajax'])) { |
|
| 2008 | - $_options[] = preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2009 | - unset($_contexte['ajax']); |
|
| 2010 | - } |
|
| 2011 | - if ($p->etoile) { |
|
| 2012 | - $_options[] = "'etoile'=>true"; |
|
| 2013 | - } |
|
| 2014 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2015 | - |
|
| 2016 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2017 | - if ($flag_env) { |
|
| 2018 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2019 | - } |
|
| 2020 | - |
|
| 2021 | - $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect') ?? ''"); |
|
| 2022 | - } elseif (!isset($_contexte[1])) { |
|
| 2023 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
|
| 2024 | - erreur_squelette($msg, $p); |
|
| 2025 | - } else { |
|
| 2026 | - $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2027 | - } |
|
| 2028 | - |
|
| 2029 | - $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2030 | - return $p; |
|
| 1971 | + $id_boucle = $p->id_boucle; |
|
| 1972 | + // la lang n'est pas passe de facon automatique par argumenter |
|
| 1973 | + // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1974 | + // en option |
|
| 1975 | + |
|
| 1976 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1977 | + |
|
| 1978 | + // erreur de syntaxe = fond absent |
|
| 1979 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1980 | + if (!$_contexte) { |
|
| 1981 | + $contexte = []; |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + if (isset($_contexte['fond'])) { |
|
| 1985 | + $f = $_contexte['fond']; |
|
| 1986 | + // toujours vrai : |
|
| 1987 | + if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1988 | + $f = $r[1]; |
|
| 1989 | + unset($_contexte['fond']); |
|
| 1990 | + } else { |
|
| 1991 | + spip_log('compilation de #INCLURE a revoir'); |
|
| 1992 | + } |
|
| 1993 | + |
|
| 1994 | + // #INCLURE{doublons} |
|
| 1995 | + if (isset($_contexte['doublons'])) { |
|
| 1996 | + $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 1997 | + } |
|
| 1998 | + |
|
| 1999 | + // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2000 | + $flag_env = false; |
|
| 2001 | + if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2002 | + $flag_env = true; |
|
| 2003 | + unset($_contexte['env']); |
|
| 2004 | + } |
|
| 2005 | + |
|
| 2006 | + $_options = []; |
|
| 2007 | + if (isset($_contexte['ajax'])) { |
|
| 2008 | + $_options[] = preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2009 | + unset($_contexte['ajax']); |
|
| 2010 | + } |
|
| 2011 | + if ($p->etoile) { |
|
| 2012 | + $_options[] = "'etoile'=>true"; |
|
| 2013 | + } |
|
| 2014 | + $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ')'; |
|
| 2015 | + |
|
| 2016 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2017 | + if ($flag_env) { |
|
| 2018 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2019 | + } |
|
| 2020 | + |
|
| 2021 | + $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect') ?? ''"); |
|
| 2022 | + } elseif (!isset($_contexte[1])) { |
|
| 2023 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' INCLURE']]; |
|
| 2024 | + erreur_squelette($msg, $p); |
|
| 2025 | + } else { |
|
| 2026 | + $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2027 | + } |
|
| 2028 | + |
|
| 2029 | + $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2030 | + return $p; |
|
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | 2033 | |
@@ -2055,69 +2055,69 @@ discard block |
||
| 2055 | 2055 | **/ |
| 2056 | 2056 | function balise_MODELE_dist($p) { |
| 2057 | 2057 | |
| 2058 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2059 | - |
|
| 2060 | - // erreur de syntaxe = fond absent |
|
| 2061 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2062 | - if (!$_contexte) { |
|
| 2063 | - $_contexte = []; |
|
| 2064 | - } |
|
| 2065 | - |
|
| 2066 | - if (!isset($_contexte[1])) { |
|
| 2067 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' MODELE']]; |
|
| 2068 | - erreur_squelette($msg, $p); |
|
| 2069 | - } else { |
|
| 2070 | - $nom = $_contexte[1]; |
|
| 2071 | - unset($_contexte[1]); |
|
| 2072 | - |
|
| 2073 | - if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2074 | - $nom = "'modeles/" . substr($nom, 1); |
|
| 2075 | - } else { |
|
| 2076 | - $nom = "'modeles/' . $nom"; |
|
| 2077 | - } |
|
| 2078 | - |
|
| 2079 | - $flag_env = false; |
|
| 2080 | - if (isset($_contexte['env'])) { |
|
| 2081 | - $flag_env = true; |
|
| 2082 | - unset($_contexte['env']); |
|
| 2083 | - } |
|
| 2084 | - |
|
| 2085 | - // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2086 | - // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2087 | - if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2088 | - $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2089 | - if (!strpos($primary, ',')) { |
|
| 2090 | - $id = champ_sql($primary, $p); |
|
| 2091 | - $_contexte[] = "'$primary'=>" . $id; |
|
| 2092 | - $_contexte[] = "'id'=>" . $id; |
|
| 2093 | - } |
|
| 2094 | - } |
|
| 2095 | - $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2096 | - $connect = ''; |
|
| 2097 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2098 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2099 | - } |
|
| 2100 | - |
|
| 2101 | - $_options = memoriser_contexte_compil($p); |
|
| 2102 | - $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2103 | - if (isset($_contexte['ajax'])) { |
|
| 2104 | - $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2105 | - unset($_contexte['ajax']); |
|
| 2106 | - } |
|
| 2107 | - |
|
| 2108 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2109 | - if ($flag_env) { |
|
| 2110 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2111 | - } |
|
| 2112 | - |
|
| 2113 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2114 | - |
|
| 2115 | - $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2116 | - |
|
| 2117 | - $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2118 | - } |
|
| 2119 | - |
|
| 2120 | - return $p; |
|
| 2058 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2059 | + |
|
| 2060 | + // erreur de syntaxe = fond absent |
|
| 2061 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2062 | + if (!$_contexte) { |
|
| 2063 | + $_contexte = []; |
|
| 2064 | + } |
|
| 2065 | + |
|
| 2066 | + if (!isset($_contexte[1])) { |
|
| 2067 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' MODELE']]; |
|
| 2068 | + erreur_squelette($msg, $p); |
|
| 2069 | + } else { |
|
| 2070 | + $nom = $_contexte[1]; |
|
| 2071 | + unset($_contexte[1]); |
|
| 2072 | + |
|
| 2073 | + if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2074 | + $nom = "'modeles/" . substr($nom, 1); |
|
| 2075 | + } else { |
|
| 2076 | + $nom = "'modeles/' . $nom"; |
|
| 2077 | + } |
|
| 2078 | + |
|
| 2079 | + $flag_env = false; |
|
| 2080 | + if (isset($_contexte['env'])) { |
|
| 2081 | + $flag_env = true; |
|
| 2082 | + unset($_contexte['env']); |
|
| 2083 | + } |
|
| 2084 | + |
|
| 2085 | + // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2086 | + // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2087 | + if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2088 | + $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2089 | + if (!strpos($primary, ',')) { |
|
| 2090 | + $id = champ_sql($primary, $p); |
|
| 2091 | + $_contexte[] = "'$primary'=>" . $id; |
|
| 2092 | + $_contexte[] = "'id'=>" . $id; |
|
| 2093 | + } |
|
| 2094 | + } |
|
| 2095 | + $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2096 | + $connect = ''; |
|
| 2097 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2098 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2099 | + } |
|
| 2100 | + |
|
| 2101 | + $_options = memoriser_contexte_compil($p); |
|
| 2102 | + $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2103 | + if (isset($_contexte['ajax'])) { |
|
| 2104 | + $_options .= ', ' . preg_replace(',=>(.*)$,ims', '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2105 | + unset($_contexte['ajax']); |
|
| 2106 | + } |
|
| 2107 | + |
|
| 2108 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2109 | + if ($flag_env) { |
|
| 2110 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2111 | + } |
|
| 2112 | + |
|
| 2113 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2114 | + |
|
| 2115 | + $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2116 | + |
|
| 2117 | + $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2118 | + } |
|
| 2119 | + |
|
| 2120 | + return $p; |
|
| 2121 | 2121 | } |
| 2122 | 2122 | |
| 2123 | 2123 | |
@@ -2141,21 +2141,21 @@ discard block |
||
| 2141 | 2141 | * Pile complétée par le code à générer |
| 2142 | 2142 | **/ |
| 2143 | 2143 | function balise_SET_dist($p) { |
| 2144 | - $_nom = interprete_argument_balise(1, $p); |
|
| 2145 | - $_val = interprete_argument_balise(2, $p); |
|
| 2144 | + $_nom = interprete_argument_balise(1, $p); |
|
| 2145 | + $_val = interprete_argument_balise(2, $p); |
|
| 2146 | 2146 | |
| 2147 | - if (!$_nom or !$_val) { |
|
| 2148 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SET']]; |
|
| 2149 | - erreur_squelette($err_b_s_a, $p); |
|
| 2150 | - } |
|
| 2151 | - // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2152 | - // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2153 | - else { |
|
| 2154 | - $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2155 | - } |
|
| 2147 | + if (!$_nom or !$_val) { |
|
| 2148 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'SET']]; |
|
| 2149 | + erreur_squelette($err_b_s_a, $p); |
|
| 2150 | + } |
|
| 2151 | + // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2152 | + // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2153 | + else { |
|
| 2154 | + $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2155 | + } |
|
| 2156 | 2156 | |
| 2157 | - $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2158 | - return $p; |
|
| 2157 | + $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2158 | + return $p; |
|
| 2159 | 2159 | } |
| 2160 | 2160 | |
| 2161 | 2161 | |
@@ -2185,12 +2185,12 @@ discard block |
||
| 2185 | 2185 | * Pile complétée par le code à générer |
| 2186 | 2186 | **/ |
| 2187 | 2187 | function balise_GET_dist($p) { |
| 2188 | - $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2189 | - if (function_exists('balise_ENV')) { |
|
| 2190 | - return balise_ENV($p, '$Pile["vars"]??[]'); |
|
| 2191 | - } else { |
|
| 2192 | - return balise_ENV_dist($p, '$Pile["vars"]??[]'); |
|
| 2193 | - } |
|
| 2188 | + $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2189 | + if (function_exists('balise_ENV')) { |
|
| 2190 | + return balise_ENV($p, '$Pile["vars"]??[]'); |
|
| 2191 | + } else { |
|
| 2192 | + return balise_ENV_dist($p, '$Pile["vars"]??[]'); |
|
| 2193 | + } |
|
| 2194 | 2194 | } |
| 2195 | 2195 | |
| 2196 | 2196 | |
@@ -2213,22 +2213,22 @@ discard block |
||
| 2213 | 2213 | * Pile complétée par le code à générer |
| 2214 | 2214 | **/ |
| 2215 | 2215 | function balise_DOUBLONS_dist($p) { |
| 2216 | - if ($type = interprete_argument_balise(1, $p)) { |
|
| 2217 | - if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2218 | - $type .= '.' . $famille; |
|
| 2219 | - } |
|
| 2220 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2221 | - if (!$p->etoile) { |
|
| 2222 | - $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2223 | - . $p->code . ')))'; |
|
| 2224 | - } |
|
| 2225 | - } else { |
|
| 2226 | - $p->code = '$doublons'; |
|
| 2227 | - } |
|
| 2216 | + if ($type = interprete_argument_balise(1, $p)) { |
|
| 2217 | + if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2218 | + $type .= '.' . $famille; |
|
| 2219 | + } |
|
| 2220 | + $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2221 | + if (!$p->etoile) { |
|
| 2222 | + $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2223 | + . $p->code . ')))'; |
|
| 2224 | + } |
|
| 2225 | + } else { |
|
| 2226 | + $p->code = '$doublons'; |
|
| 2227 | + } |
|
| 2228 | 2228 | |
| 2229 | - $p->interdire_scripts = false; |
|
| 2229 | + $p->interdire_scripts = false; |
|
| 2230 | 2230 | |
| 2231 | - return $p; |
|
| 2231 | + return $p; |
|
| 2232 | 2232 | } |
| 2233 | 2233 | |
| 2234 | 2234 | |
@@ -2251,18 +2251,18 @@ discard block |
||
| 2251 | 2251 | * Pile complétée par le code à générer |
| 2252 | 2252 | **/ |
| 2253 | 2253 | function balise_PIPELINE_dist($p) { |
| 2254 | - $_pipe = interprete_argument_balise(1, $p); |
|
| 2255 | - if (!$_pipe) { |
|
| 2256 | - $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'PIPELINE']]; |
|
| 2257 | - erreur_squelette($err_b_s_a, $p); |
|
| 2258 | - } else { |
|
| 2259 | - $_flux = interprete_argument_balise(2, $p); |
|
| 2260 | - $_flux = $_flux ?: "''"; |
|
| 2261 | - $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2262 | - $p->interdire_scripts = false; |
|
| 2263 | - } |
|
| 2254 | + $_pipe = interprete_argument_balise(1, $p); |
|
| 2255 | + if (!$_pipe) { |
|
| 2256 | + $err_b_s_a = ['zbug_balise_sans_argument', ['balise' => 'PIPELINE']]; |
|
| 2257 | + erreur_squelette($err_b_s_a, $p); |
|
| 2258 | + } else { |
|
| 2259 | + $_flux = interprete_argument_balise(2, $p); |
|
| 2260 | + $_flux = $_flux ?: "''"; |
|
| 2261 | + $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2262 | + $p->interdire_scripts = false; |
|
| 2263 | + } |
|
| 2264 | 2264 | |
| 2265 | - return $p; |
|
| 2265 | + return $p; |
|
| 2266 | 2266 | } |
| 2267 | 2267 | |
| 2268 | 2268 | |
@@ -2287,10 +2287,10 @@ discard block |
||
| 2287 | 2287 | * Pile complétée par le code à générer |
| 2288 | 2288 | **/ |
| 2289 | 2289 | function balise_EDIT_dist($p) { |
| 2290 | - $p->code = "''"; |
|
| 2291 | - $p->interdire_scripts = false; |
|
| 2290 | + $p->code = "''"; |
|
| 2291 | + $p->interdire_scripts = false; |
|
| 2292 | 2292 | |
| 2293 | - return $p; |
|
| 2293 | + return $p; |
|
| 2294 | 2294 | } |
| 2295 | 2295 | |
| 2296 | 2296 | |
@@ -2313,11 +2313,11 @@ discard block |
||
| 2313 | 2313 | * Pile complétée par le code à générer |
| 2314 | 2314 | **/ |
| 2315 | 2315 | function balise_TOTAL_UNIQUE_dist($p) { |
| 2316 | - $_famille = interprete_argument_balise(1, $p); |
|
| 2317 | - $_famille = $_famille ?: "''"; |
|
| 2318 | - $p->code = "unique('', $_famille, true)"; |
|
| 2316 | + $_famille = interprete_argument_balise(1, $p); |
|
| 2317 | + $_famille = $_famille ?: "''"; |
|
| 2318 | + $p->code = "unique('', $_famille, true)"; |
|
| 2319 | 2319 | |
| 2320 | - return $p; |
|
| 2320 | + return $p; |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | /** |
@@ -2340,19 +2340,19 @@ discard block |
||
| 2340 | 2340 | * Pile complétée par le code à générer |
| 2341 | 2341 | **/ |
| 2342 | 2342 | function balise_ARRAY_dist($p) { |
| 2343 | - $_code = []; |
|
| 2344 | - $n = 1; |
|
| 2345 | - do { |
|
| 2346 | - $_key = interprete_argument_balise($n++, $p); |
|
| 2347 | - $_val = interprete_argument_balise($n++, $p); |
|
| 2348 | - if ($_key and $_val) { |
|
| 2349 | - $_code[] = "$_key => $_val"; |
|
| 2350 | - } |
|
| 2351 | - } while ($_key && $_val); |
|
| 2352 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2353 | - $p->interdire_scripts = false; |
|
| 2343 | + $_code = []; |
|
| 2344 | + $n = 1; |
|
| 2345 | + do { |
|
| 2346 | + $_key = interprete_argument_balise($n++, $p); |
|
| 2347 | + $_val = interprete_argument_balise($n++, $p); |
|
| 2348 | + if ($_key and $_val) { |
|
| 2349 | + $_code[] = "$_key => $_val"; |
|
| 2350 | + } |
|
| 2351 | + } while ($_key && $_val); |
|
| 2352 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2353 | + $p->interdire_scripts = false; |
|
| 2354 | 2354 | |
| 2355 | - return $p; |
|
| 2355 | + return $p; |
|
| 2356 | 2356 | } |
| 2357 | 2357 | |
| 2358 | 2358 | /** |
@@ -2371,15 +2371,15 @@ discard block |
||
| 2371 | 2371 | * Pile complétée par le code à générer |
| 2372 | 2372 | */ |
| 2373 | 2373 | function balise_LISTE_dist($p) { |
| 2374 | - $_code = []; |
|
| 2375 | - $n = 1; |
|
| 2376 | - while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2377 | - $_code[] = $_val; |
|
| 2378 | - } |
|
| 2379 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2380 | - $p->interdire_scripts = false; |
|
| 2374 | + $_code = []; |
|
| 2375 | + $n = 1; |
|
| 2376 | + while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2377 | + $_code[] = $_val; |
|
| 2378 | + } |
|
| 2379 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2380 | + $p->interdire_scripts = false; |
|
| 2381 | 2381 | |
| 2382 | - return $p; |
|
| 2382 | + return $p; |
|
| 2383 | 2383 | } |
| 2384 | 2384 | |
| 2385 | 2385 | |
@@ -2413,21 +2413,21 @@ discard block |
||
| 2413 | 2413 | * Pile complétée par le code à générer |
| 2414 | 2414 | **/ |
| 2415 | 2415 | function balise_AUTORISER_dist($p) { |
| 2416 | - $_code = []; |
|
| 2417 | - $p->descr['session'] = true; // faire un cache par session |
|
| 2416 | + $_code = []; |
|
| 2417 | + $p->descr['session'] = true; // faire un cache par session |
|
| 2418 | 2418 | |
| 2419 | - $n = 1; |
|
| 2420 | - while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2421 | - $_code[] = $_v; |
|
| 2422 | - } |
|
| 2419 | + $n = 1; |
|
| 2420 | + while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2421 | + $_code[] = $_v; |
|
| 2422 | + } |
|
| 2423 | 2423 | |
| 2424 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2425 | - ', ', |
|
| 2426 | - $_code |
|
| 2427 | - ) . ')?" ":"")'; |
|
| 2428 | - $p->interdire_scripts = false; |
|
| 2424 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join( |
|
| 2425 | + ', ', |
|
| 2426 | + $_code |
|
| 2427 | + ) . ')?" ":"")'; |
|
| 2428 | + $p->interdire_scripts = false; |
|
| 2429 | 2429 | |
| 2430 | - return $p; |
|
| 2430 | + return $p; |
|
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | |
@@ -2451,15 +2451,15 @@ discard block |
||
| 2451 | 2451 | * Pile complétée par le code à générer |
| 2452 | 2452 | **/ |
| 2453 | 2453 | function balise_PLUGIN_dist($p) { |
| 2454 | - $plugin = interprete_argument_balise(1, $p); |
|
| 2455 | - $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2456 | - $type_info = interprete_argument_balise(2, $p); |
|
| 2457 | - $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2454 | + $plugin = interprete_argument_balise(1, $p); |
|
| 2455 | + $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2456 | + $type_info = interprete_argument_balise(2, $p); |
|
| 2457 | + $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2458 | 2458 | |
| 2459 | - $f = chercher_filtre('info_plugin'); |
|
| 2460 | - $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2459 | + $f = chercher_filtre('info_plugin'); |
|
| 2460 | + $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2461 | 2461 | |
| 2462 | - return $p; |
|
| 2462 | + return $p; |
|
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | 2465 | /** |
@@ -2480,9 +2480,9 @@ discard block |
||
| 2480 | 2480 | * Pile complétée par le code à générer |
| 2481 | 2481 | **/ |
| 2482 | 2482 | function balise_AIDER_dist($p) { |
| 2483 | - $_motif = interprete_argument_balise(1, $p); |
|
| 2484 | - $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')"; |
|
| 2485 | - return $p; |
|
| 2483 | + $_motif = interprete_argument_balise(1, $p); |
|
| 2484 | + $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif):'')"; |
|
| 2485 | + return $p; |
|
| 2486 | 2486 | } |
| 2487 | 2487 | |
| 2488 | 2488 | /** |
@@ -2508,16 +2508,16 @@ discard block |
||
| 2508 | 2508 | * Pile complétée par le code à générer |
| 2509 | 2509 | **/ |
| 2510 | 2510 | function balise_ACTION_FORMULAIRE($p) { |
| 2511 | - if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2512 | - $_url = "(\$Pile[0]['action'] ?? '')"; |
|
| 2513 | - } |
|
| 2514 | - if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2515 | - $_form = "(\$Pile[0]['form'] ?? '')"; |
|
| 2516 | - } |
|
| 2517 | - |
|
| 2518 | - // envoyer le nom du formulaire que l'on traite |
|
| 2519 | - // transmettre les eventuels args de la balise formulaire |
|
| 2520 | - $p->code = " '<span class=\"form-hidden\">' . |
|
| 2511 | + if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2512 | + $_url = "(\$Pile[0]['action'] ?? '')"; |
|
| 2513 | + } |
|
| 2514 | + if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2515 | + $_form = "(\$Pile[0]['form'] ?? '')"; |
|
| 2516 | + } |
|
| 2517 | + |
|
| 2518 | + // envoyer le nom du formulaire que l'on traite |
|
| 2519 | + // transmettre les eventuels args de la balise formulaire |
|
| 2520 | + $p->code = " '<span class=\"form-hidden\">' . |
|
| 2521 | 2521 | form_hidden($_url) . |
| 2522 | 2522 | '<input name=\'formulaire_action\' type=\'hidden\' |
| 2523 | 2523 | value=\'' . $_form . '\' />' . |
@@ -2528,9 +2528,9 @@ discard block |
||
| 2528 | 2528 | (\$Pile[0]['_hidden'] ?? '') . |
| 2529 | 2529 | '</span>'"; |
| 2530 | 2530 | |
| 2531 | - $p->interdire_scripts = false; |
|
| 2531 | + $p->interdire_scripts = false; |
|
| 2532 | 2532 | |
| 2533 | - return $p; |
|
| 2533 | + return $p; |
|
| 2534 | 2534 | } |
| 2535 | 2535 | |
| 2536 | 2536 | |
@@ -2571,25 +2571,25 @@ discard block |
||
| 2571 | 2571 | */ |
| 2572 | 2572 | function balise_BOUTON_ACTION_dist($p) { |
| 2573 | 2573 | |
| 2574 | - $args = []; |
|
| 2575 | - for ($k = 1; $k <= 6; $k++) { |
|
| 2576 | - $_a = interprete_argument_balise($k, $p); |
|
| 2577 | - if (!$_a) { |
|
| 2578 | - $_a = "''"; |
|
| 2579 | - } |
|
| 2580 | - $args[] = $_a; |
|
| 2581 | - } |
|
| 2582 | - // supprimer les args vides |
|
| 2583 | - while (end($args) == "''" and count($args) > 2) { |
|
| 2584 | - array_pop($args); |
|
| 2585 | - } |
|
| 2586 | - $args = implode(',', $args); |
|
| 2574 | + $args = []; |
|
| 2575 | + for ($k = 1; $k <= 6; $k++) { |
|
| 2576 | + $_a = interprete_argument_balise($k, $p); |
|
| 2577 | + if (!$_a) { |
|
| 2578 | + $_a = "''"; |
|
| 2579 | + } |
|
| 2580 | + $args[] = $_a; |
|
| 2581 | + } |
|
| 2582 | + // supprimer les args vides |
|
| 2583 | + while (end($args) == "''" and count($args) > 2) { |
|
| 2584 | + array_pop($args); |
|
| 2585 | + } |
|
| 2586 | + $args = implode(',', $args); |
|
| 2587 | 2587 | |
| 2588 | - $bouton_action = chercher_filtre('bouton_action'); |
|
| 2589 | - $p->code = "$bouton_action($args)"; |
|
| 2590 | - $p->interdire_scripts = false; |
|
| 2588 | + $bouton_action = chercher_filtre('bouton_action'); |
|
| 2589 | + $p->code = "$bouton_action($args)"; |
|
| 2590 | + $p->interdire_scripts = false; |
|
| 2591 | 2591 | |
| 2592 | - return $p; |
|
| 2592 | + return $p; |
|
| 2593 | 2593 | } |
| 2594 | 2594 | |
| 2595 | 2595 | |
@@ -2608,10 +2608,10 @@ discard block |
||
| 2608 | 2608 | * Pile complétée par le code à générer |
| 2609 | 2609 | */ |
| 2610 | 2610 | function balise_SLOGAN_SITE_SPIP_dist($p) { |
| 2611 | - $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2611 | + $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2612 | 2612 | |
| 2613 | - #$p->interdire_scripts = true; |
|
| 2614 | - return $p; |
|
| 2613 | + #$p->interdire_scripts = true; |
|
| 2614 | + return $p; |
|
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | |
@@ -2635,10 +2635,10 @@ discard block |
||
| 2635 | 2635 | * Pile complétée par le code à générer |
| 2636 | 2636 | */ |
| 2637 | 2637 | function balise_HTML5_dist($p) { |
| 2638 | - $p->code = html5_permis() ? "' '" : "''"; |
|
| 2639 | - $p->interdire_scripts = false; |
|
| 2638 | + $p->code = html5_permis() ? "' '" : "''"; |
|
| 2639 | + $p->interdire_scripts = false; |
|
| 2640 | 2640 | |
| 2641 | - return $p; |
|
| 2641 | + return $p; |
|
| 2642 | 2642 | } |
| 2643 | 2643 | |
| 2644 | 2644 | |
@@ -2664,58 +2664,58 @@ discard block |
||
| 2664 | 2664 | * Pile complétée par le code à générer |
| 2665 | 2665 | */ |
| 2666 | 2666 | function balise_TRI_dist($p, $liste = 'true') { |
| 2667 | - $b = index_boucle_mere($p); |
|
| 2668 | - // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2669 | - if ($b === '') { |
|
| 2670 | - $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 2671 | - erreur_squelette($msg, $p); |
|
| 2672 | - $p->code = "''"; |
|
| 2667 | + $b = index_boucle_mere($p); |
|
| 2668 | + // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2669 | + if ($b === '') { |
|
| 2670 | + $msg = ['zbug_champ_hors_boucle', ['champ' => zbug_presenter_champ($p)]]; |
|
| 2671 | + erreur_squelette($msg, $p); |
|
| 2672 | + $p->code = "''"; |
|
| 2673 | 2673 | |
| 2674 | - return $p; |
|
| 2675 | - } |
|
| 2676 | - $boucle = $p->boucles[$b]; |
|
| 2674 | + return $p; |
|
| 2675 | + } |
|
| 2676 | + $boucle = $p->boucles[$b]; |
|
| 2677 | 2677 | |
| 2678 | - // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2679 | - // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2680 | - if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2681 | - $msg = ['zbug_champ_hors_critere', [ |
|
| 2682 | - 'champ' => zbug_presenter_champ($p), |
|
| 2683 | - 'critere' => 'tri' |
|
| 2684 | - ]]; |
|
| 2685 | - erreur_squelette($msg, $p); |
|
| 2686 | - $p->code = "''"; |
|
| 2678 | + // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2679 | + // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2680 | + if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2681 | + $msg = ['zbug_champ_hors_critere', [ |
|
| 2682 | + 'champ' => zbug_presenter_champ($p), |
|
| 2683 | + 'critere' => 'tri' |
|
| 2684 | + ]]; |
|
| 2685 | + erreur_squelette($msg, $p); |
|
| 2686 | + $p->code = "''"; |
|
| 2687 | 2687 | |
| 2688 | - return $p; |
|
| 2689 | - } |
|
| 2688 | + return $p; |
|
| 2689 | + } |
|
| 2690 | 2690 | |
| 2691 | - // Différentes infos relatives au tri présentes dans les modificateurs |
|
| 2692 | - $_tri_nom = $boucle->modificateur['tri_nom'] ; // nom du paramètre définissant le tri |
|
| 2693 | - $_tri_champ = $boucle->modificateur['tri_champ']; // champ actuel utilisé le tri |
|
| 2694 | - $_tri_sens = $boucle->modificateur['tri_sens']; // sens de tri actuel |
|
| 2695 | - $_tri_liste_sens_defaut = $boucle->modificateur['tri_liste_sens_defaut']; // sens par défaut pour chaque champ |
|
| 2691 | + // Différentes infos relatives au tri présentes dans les modificateurs |
|
| 2692 | + $_tri_nom = $boucle->modificateur['tri_nom'] ; // nom du paramètre définissant le tri |
|
| 2693 | + $_tri_champ = $boucle->modificateur['tri_champ']; // champ actuel utilisé le tri |
|
| 2694 | + $_tri_sens = $boucle->modificateur['tri_sens']; // sens de tri actuel |
|
| 2695 | + $_tri_liste_sens_defaut = $boucle->modificateur['tri_liste_sens_defaut']; // sens par défaut pour chaque champ |
|
| 2696 | 2696 | |
| 2697 | - $_champ_ou_sens = interprete_argument_balise(1, $p); |
|
| 2698 | - // si pas de champ, renvoyer le critère de tri actuel |
|
| 2699 | - if (!$_champ_ou_sens) { |
|
| 2700 | - $p->code = $_tri_champ; |
|
| 2697 | + $_champ_ou_sens = interprete_argument_balise(1, $p); |
|
| 2698 | + // si pas de champ, renvoyer le critère de tri actuel |
|
| 2699 | + if (!$_champ_ou_sens) { |
|
| 2700 | + $p->code = $_tri_champ; |
|
| 2701 | 2701 | |
| 2702 | - return $p; |
|
| 2703 | - } |
|
| 2704 | - // forcer la jointure si besoin, et si le champ est statique |
|
| 2705 | - if (preg_match(",^'([\w.]+)'$,i", $_champ_ou_sens, $m)) { |
|
| 2706 | - index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2707 | - } |
|
| 2702 | + return $p; |
|
| 2703 | + } |
|
| 2704 | + // forcer la jointure si besoin, et si le champ est statique |
|
| 2705 | + if (preg_match(",^'([\w.]+)'$,i", $_champ_ou_sens, $m)) { |
|
| 2706 | + index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2707 | + } |
|
| 2708 | 2708 | |
| 2709 | - $_libelle = interprete_argument_balise(2, $p); |
|
| 2710 | - $_libelle = $_libelle ?: $_champ_ou_sens; |
|
| 2709 | + $_libelle = interprete_argument_balise(2, $p); |
|
| 2710 | + $_libelle = $_libelle ?: $_champ_ou_sens; |
|
| 2711 | 2711 | |
| 2712 | - $_class = interprete_argument_balise(3, $p) ?? "''"; |
|
| 2712 | + $_class = interprete_argument_balise(3, $p) ?? "''"; |
|
| 2713 | 2713 | |
| 2714 | - $p->code = "calculer_balise_tri($_champ_ou_sens, $_libelle, $_class, $_tri_nom, $_tri_champ, $_tri_sens, $_tri_liste_sens_defaut)"; |
|
| 2714 | + $p->code = "calculer_balise_tri($_champ_ou_sens, $_libelle, $_class, $_tri_nom, $_tri_champ, $_tri_sens, $_tri_liste_sens_defaut)"; |
|
| 2715 | 2715 | |
| 2716 | - $p->interdire_scripts = false; |
|
| 2716 | + $p->interdire_scripts = false; |
|
| 2717 | 2717 | |
| 2718 | - return $p; |
|
| 2718 | + return $p; |
|
| 2719 | 2719 | } |
| 2720 | 2720 | |
| 2721 | 2721 | |
@@ -2736,21 +2736,21 @@ discard block |
||
| 2736 | 2736 | * Pile complétée par le code à générer |
| 2737 | 2737 | */ |
| 2738 | 2738 | function balise_SAUTER_dist($p) { |
| 2739 | - $id_boucle = $p->id_boucle; |
|
| 2739 | + $id_boucle = $p->id_boucle; |
|
| 2740 | 2740 | |
| 2741 | - if (empty($p->boucles[$id_boucle])) { |
|
| 2742 | - $msg = ['zbug_champ_hors_boucle', ['champ' => '#SAUTER']]; |
|
| 2743 | - erreur_squelette($msg, $p); |
|
| 2744 | - } else { |
|
| 2745 | - $_saut = interprete_argument_balise(1, $p); |
|
| 2746 | - $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2747 | - $_total = "(\$Numrows['$id_boucle']['total'] ?? null)"; |
|
| 2741 | + if (empty($p->boucles[$id_boucle])) { |
|
| 2742 | + $msg = ['zbug_champ_hors_boucle', ['champ' => '#SAUTER']]; |
|
| 2743 | + erreur_squelette($msg, $p); |
|
| 2744 | + } else { |
|
| 2745 | + $_saut = interprete_argument_balise(1, $p); |
|
| 2746 | + $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2747 | + $_total = "(\$Numrows['$id_boucle']['total'] ?? null)"; |
|
| 2748 | 2748 | |
| 2749 | - $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2750 | - } |
|
| 2751 | - $p->interdire_scripts = false; |
|
| 2749 | + $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2750 | + } |
|
| 2751 | + $p->interdire_scripts = false; |
|
| 2752 | 2752 | |
| 2753 | - return $p; |
|
| 2753 | + return $p; |
|
| 2754 | 2754 | } |
| 2755 | 2755 | |
| 2756 | 2756 | |
@@ -2772,22 +2772,22 @@ discard block |
||
| 2772 | 2772 | * Pile complétée par le code à générer |
| 2773 | 2773 | */ |
| 2774 | 2774 | function balise_PUBLIE_dist($p) { |
| 2775 | - if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2776 | - $_type = _q($p->type_requete); |
|
| 2777 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2778 | - } else { |
|
| 2779 | - $_id = interprete_argument_balise(2, $p); |
|
| 2780 | - } |
|
| 2775 | + if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2776 | + $_type = _q($p->type_requete); |
|
| 2777 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2778 | + } else { |
|
| 2779 | + $_id = interprete_argument_balise(2, $p); |
|
| 2780 | + } |
|
| 2781 | 2781 | |
| 2782 | - $connect = ''; |
|
| 2783 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2784 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2785 | - } |
|
| 2782 | + $connect = ''; |
|
| 2783 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2784 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2785 | + } |
|
| 2786 | 2786 | |
| 2787 | - $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2788 | - $p->interdire_scripts = false; |
|
| 2787 | + $p->code = '(objet_test_si_publie(' . $_type . ',intval(' . $_id . '),' . _q($connect) . ")?' ':'')"; |
|
| 2788 | + $p->interdire_scripts = false; |
|
| 2789 | 2789 | |
| 2790 | - return $p; |
|
| 2790 | + return $p; |
|
| 2791 | 2791 | } |
| 2792 | 2792 | |
| 2793 | 2793 | /** |
@@ -2816,12 +2816,12 @@ discard block |
||
| 2816 | 2816 | * Pile complétée par le code à générer |
| 2817 | 2817 | */ |
| 2818 | 2818 | function balise_PRODUIRE_dist($p) { |
| 2819 | - $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2820 | - $p = $balise_inclure($p); |
|
| 2819 | + $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2820 | + $p = $balise_inclure($p); |
|
| 2821 | 2821 | |
| 2822 | - $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2822 | + $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2823 | 2823 | |
| 2824 | - return $p; |
|
| 2824 | + return $p; |
|
| 2825 | 2825 | } |
| 2826 | 2826 | |
| 2827 | 2827 | /** |
@@ -2840,13 +2840,13 @@ discard block |
||
| 2840 | 2840 | * Pile complétée par le code à générer |
| 2841 | 2841 | */ |
| 2842 | 2842 | function balise_LARGEUR_ECRAN_dist($p) { |
| 2843 | - $_class = interprete_argument_balise(1, $p); |
|
| 2844 | - if (!$_class) { |
|
| 2845 | - $_class = 'null'; |
|
| 2846 | - } |
|
| 2847 | - $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2843 | + $_class = interprete_argument_balise(1, $p); |
|
| 2844 | + if (!$_class) { |
|
| 2845 | + $_class = 'null'; |
|
| 2846 | + } |
|
| 2847 | + $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2848 | 2848 | |
| 2849 | - return $p; |
|
| 2849 | + return $p; |
|
| 2850 | 2850 | } |
| 2851 | 2851 | |
| 2852 | 2852 | |
@@ -2862,14 +2862,14 @@ discard block |
||
| 2862 | 2862 | * Pile complétée par le code à générer |
| 2863 | 2863 | **/ |
| 2864 | 2864 | function balise_CONST_dist($p) { |
| 2865 | - $_const = interprete_argument_balise(1, $p); |
|
| 2866 | - if (!strlen($_const ?? '')) { |
|
| 2867 | - $p->code = "''"; |
|
| 2868 | - } |
|
| 2869 | - else { |
|
| 2870 | - $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2871 | - } |
|
| 2872 | - $p->interdire_scripts = false; |
|
| 2873 | - |
|
| 2874 | - return $p; |
|
| 2865 | + $_const = interprete_argument_balise(1, $p); |
|
| 2866 | + if (!strlen($_const ?? '')) { |
|
| 2867 | + $p->code = "''"; |
|
| 2868 | + } |
|
| 2869 | + else { |
|
| 2870 | + $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2871 | + } |
|
| 2872 | + $p->interdire_scripts = false; |
|
| 2873 | + |
|
| 2874 | + return $p; |
|
| 2875 | 2875 | } |