@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -40,36 +40,36 @@ discard block |
||
| 40 | 40 | * Liste (identifiant de l'article, Texte d'erreur éventuel) |
| 41 | 41 | */ |
| 42 | 42 | function action_editer_article_dist($arg = null) { |
| 43 | - include_spip('inc/autoriser'); |
|
| 44 | - $err = ''; |
|
| 45 | - if (is_null($arg)) { |
|
| 46 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 47 | - $arg = $securiser_action(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // si id_article n'est pas un nombre, c'est une creation |
|
| 51 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 52 | - if (!$id_article = intval($arg)) { |
|
| 53 | - $id_parent = _request('id_parent'); |
|
| 54 | - if (!$id_parent) { |
|
| 55 | - $err = _L("creation interdite d'un article sans rubrique"); |
|
| 56 | - } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 57 | - $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 58 | - } else { |
|
| 59 | - $id_article = article_inserer($id_parent); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // Enregistre l'envoi dans la BD |
|
| 64 | - if ($id_article > 0) { |
|
| 65 | - $err = article_modifier($id_article); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if ($err) { |
|
| 69 | - spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return [$id_article, $err]; |
|
| 43 | + include_spip('inc/autoriser'); |
|
| 44 | + $err = ''; |
|
| 45 | + if (is_null($arg)) { |
|
| 46 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 47 | + $arg = $securiser_action(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // si id_article n'est pas un nombre, c'est une creation |
|
| 51 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 52 | + if (!$id_article = intval($arg)) { |
|
| 53 | + $id_parent = _request('id_parent'); |
|
| 54 | + if (!$id_parent) { |
|
| 55 | + $err = _L("creation interdite d'un article sans rubrique"); |
|
| 56 | + } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 57 | + $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 58 | + } else { |
|
| 59 | + $id_article = article_inserer($id_parent); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // Enregistre l'envoi dans la BD |
|
| 64 | + if ($id_article > 0) { |
|
| 65 | + $err = article_modifier($id_article); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if ($err) { |
|
| 69 | + spip_log("echec editeur article: $err", _LOG_ERREUR); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return [$id_article, $err]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -91,50 +91,50 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | function article_modifier($id_article, $set = null) { |
| 93 | 93 | |
| 94 | - // unifier $texte en cas de texte trop long |
|
| 95 | - trop_longs_articles(); |
|
| 96 | - |
|
| 97 | - include_spip('inc/modifier'); |
|
| 98 | - include_spip('inc/filtres'); |
|
| 99 | - $c = collecter_requests( |
|
| 100 | - // white list |
|
| 101 | - objet_info('article', 'champs_editables'), |
|
| 102 | - // black list |
|
| 103 | - ['date', 'statut', 'id_parent'], |
|
| 104 | - // donnees eventuellement fournies |
|
| 105 | - $set |
|
| 106 | - ); |
|
| 107 | - |
|
| 108 | - // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 109 | - $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 110 | - $invalideur = $indexation = false; |
|
| 111 | - if ($t == 'publie') { |
|
| 112 | - $invalideur = "id='article/$id_article'"; |
|
| 113 | - $indexation = true; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - if ( |
|
| 117 | - $err = objet_modifier_champs( |
|
| 118 | - 'article', |
|
| 119 | - $id_article, |
|
| 120 | - [ |
|
| 121 | - 'data' => $set, |
|
| 122 | - 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 123 | - 'invalideur' => $invalideur, |
|
| 124 | - 'indexation' => $indexation, |
|
| 125 | - 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 126 | - ], |
|
| 127 | - $c |
|
| 128 | - ) |
|
| 129 | - ) { |
|
| 130 | - return $err; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // Modification de statut, changement de rubrique ? |
|
| 134 | - $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 135 | - $err = article_instituer($id_article, $c); |
|
| 136 | - |
|
| 137 | - return $err; |
|
| 94 | + // unifier $texte en cas de texte trop long |
|
| 95 | + trop_longs_articles(); |
|
| 96 | + |
|
| 97 | + include_spip('inc/modifier'); |
|
| 98 | + include_spip('inc/filtres'); |
|
| 99 | + $c = collecter_requests( |
|
| 100 | + // white list |
|
| 101 | + objet_info('article', 'champs_editables'), |
|
| 102 | + // black list |
|
| 103 | + ['date', 'statut', 'id_parent'], |
|
| 104 | + // donnees eventuellement fournies |
|
| 105 | + $set |
|
| 106 | + ); |
|
| 107 | + |
|
| 108 | + // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 109 | + $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 110 | + $invalideur = $indexation = false; |
|
| 111 | + if ($t == 'publie') { |
|
| 112 | + $invalideur = "id='article/$id_article'"; |
|
| 113 | + $indexation = true; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + if ( |
|
| 117 | + $err = objet_modifier_champs( |
|
| 118 | + 'article', |
|
| 119 | + $id_article, |
|
| 120 | + [ |
|
| 121 | + 'data' => $set, |
|
| 122 | + 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 123 | + 'invalideur' => $invalideur, |
|
| 124 | + 'indexation' => $indexation, |
|
| 125 | + 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 126 | + ], |
|
| 127 | + $c |
|
| 128 | + ) |
|
| 129 | + ) { |
|
| 130 | + return $err; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // Modification de statut, changement de rubrique ? |
|
| 134 | + $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 135 | + $err = article_instituer($id_article, $c); |
|
| 136 | + |
|
| 137 | + return $err; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -170,98 +170,98 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function article_inserer($id_rubrique, $set = null) { |
| 172 | 172 | |
| 173 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 174 | - // dans la premiere rubrique racine |
|
| 175 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 176 | - $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 177 | - $id_rubrique = $row['id_rubrique']; |
|
| 178 | - } else { |
|
| 179 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 183 | - // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 184 | - $id_secteur = $row['id_secteur'] ?? 0; |
|
| 185 | - $lang_rub = $row['lang'] ?? ''; |
|
| 186 | - |
|
| 187 | - $lang = ''; |
|
| 188 | - $choisie = 'non'; |
|
| 189 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 190 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 191 | - // ou a defaut celle de la rubrique |
|
| 192 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 193 | - if ( |
|
| 194 | - !empty($GLOBALS['meta']['multi_objets']) and in_array( |
|
| 195 | - 'spip_articles', |
|
| 196 | - explode(',', $GLOBALS['meta']['multi_objets']) |
|
| 197 | - ) |
|
| 198 | - ) { |
|
| 199 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 200 | - if ( |
|
| 201 | - in_array( |
|
| 202 | - $GLOBALS['spip_lang'], |
|
| 203 | - explode(',', $GLOBALS['meta']['langues_multilingue']) |
|
| 204 | - ) |
|
| 205 | - ) { |
|
| 206 | - $lang = $GLOBALS['spip_lang']; |
|
| 207 | - $choisie = 'oui'; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if (!$lang) { |
|
| 212 | - $choisie = 'non'; |
|
| 213 | - $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $champs = [ |
|
| 217 | - 'id_rubrique' => $id_rubrique, |
|
| 218 | - 'id_secteur' => $id_secteur, |
|
| 219 | - 'statut' => 'prepa', |
|
| 220 | - 'date' => date('Y-m-d H:i:s'), |
|
| 221 | - 'lang' => $lang, |
|
| 222 | - 'langue_choisie' => $choisie |
|
| 223 | - ]; |
|
| 224 | - |
|
| 225 | - if ($set) { |
|
| 226 | - $champs = array_merge($champs, $set); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - // Envoyer aux plugins |
|
| 230 | - $champs = pipeline( |
|
| 231 | - 'pre_insertion', |
|
| 232 | - [ |
|
| 233 | - 'args' => [ |
|
| 234 | - 'table' => 'spip_articles', |
|
| 235 | - ], |
|
| 236 | - 'data' => $champs |
|
| 237 | - ] |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - $id_article = sql_insertq('spip_articles', $champs); |
|
| 241 | - |
|
| 242 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 243 | - if ($id_article > 0) { |
|
| 244 | - $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 245 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 246 | - : _request('id_auteur')); |
|
| 247 | - if ($id_auteur) { |
|
| 248 | - include_spip('action/editer_auteur'); |
|
| 249 | - auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - pipeline( |
|
| 254 | - 'post_insertion', |
|
| 255 | - [ |
|
| 256 | - 'args' => [ |
|
| 257 | - 'table' => 'spip_articles', |
|
| 258 | - 'id_objet' => $id_article |
|
| 259 | - ], |
|
| 260 | - 'data' => $champs |
|
| 261 | - ] |
|
| 262 | - ); |
|
| 263 | - |
|
| 264 | - return $id_article; |
|
| 173 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 174 | + // dans la premiere rubrique racine |
|
| 175 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 176 | + $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 177 | + $id_rubrique = $row['id_rubrique']; |
|
| 178 | + } else { |
|
| 179 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 183 | + // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 184 | + $id_secteur = $row['id_secteur'] ?? 0; |
|
| 185 | + $lang_rub = $row['lang'] ?? ''; |
|
| 186 | + |
|
| 187 | + $lang = ''; |
|
| 188 | + $choisie = 'non'; |
|
| 189 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 190 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 191 | + // ou a defaut celle de la rubrique |
|
| 192 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 193 | + if ( |
|
| 194 | + !empty($GLOBALS['meta']['multi_objets']) and in_array( |
|
| 195 | + 'spip_articles', |
|
| 196 | + explode(',', $GLOBALS['meta']['multi_objets']) |
|
| 197 | + ) |
|
| 198 | + ) { |
|
| 199 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 200 | + if ( |
|
| 201 | + in_array( |
|
| 202 | + $GLOBALS['spip_lang'], |
|
| 203 | + explode(',', $GLOBALS['meta']['langues_multilingue']) |
|
| 204 | + ) |
|
| 205 | + ) { |
|
| 206 | + $lang = $GLOBALS['spip_lang']; |
|
| 207 | + $choisie = 'oui'; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if (!$lang) { |
|
| 212 | + $choisie = 'non'; |
|
| 213 | + $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $champs = [ |
|
| 217 | + 'id_rubrique' => $id_rubrique, |
|
| 218 | + 'id_secteur' => $id_secteur, |
|
| 219 | + 'statut' => 'prepa', |
|
| 220 | + 'date' => date('Y-m-d H:i:s'), |
|
| 221 | + 'lang' => $lang, |
|
| 222 | + 'langue_choisie' => $choisie |
|
| 223 | + ]; |
|
| 224 | + |
|
| 225 | + if ($set) { |
|
| 226 | + $champs = array_merge($champs, $set); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + // Envoyer aux plugins |
|
| 230 | + $champs = pipeline( |
|
| 231 | + 'pre_insertion', |
|
| 232 | + [ |
|
| 233 | + 'args' => [ |
|
| 234 | + 'table' => 'spip_articles', |
|
| 235 | + ], |
|
| 236 | + 'data' => $champs |
|
| 237 | + ] |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + $id_article = sql_insertq('spip_articles', $champs); |
|
| 241 | + |
|
| 242 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 243 | + if ($id_article > 0) { |
|
| 244 | + $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 245 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 246 | + : _request('id_auteur')); |
|
| 247 | + if ($id_auteur) { |
|
| 248 | + include_spip('action/editer_auteur'); |
|
| 249 | + auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + pipeline( |
|
| 254 | + 'post_insertion', |
|
| 255 | + [ |
|
| 256 | + 'args' => [ |
|
| 257 | + 'table' => 'spip_articles', |
|
| 258 | + 'id_objet' => $id_article |
|
| 259 | + ], |
|
| 260 | + 'data' => $champs |
|
| 261 | + ] |
|
| 262 | + ); |
|
| 263 | + |
|
| 264 | + return $id_article; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -289,125 +289,125 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | function article_instituer($id_article, $c, $calcul_rub = true) { |
| 291 | 291 | |
| 292 | - include_spip('inc/autoriser'); |
|
| 293 | - include_spip('inc/rubriques'); |
|
| 294 | - include_spip('inc/modifier'); |
|
| 295 | - |
|
| 296 | - $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 297 | - $id_rubrique = $row['id_rubrique']; |
|
| 298 | - $statut_ancien = $statut = $row['statut']; |
|
| 299 | - $date_ancienne = $date = $row['date']; |
|
| 300 | - $champs = []; |
|
| 301 | - |
|
| 302 | - $d = $c['date'] ?? null; |
|
| 303 | - $s = $c['statut'] ?? $statut; |
|
| 304 | - |
|
| 305 | - // cf autorisations dans inc/instituer_article |
|
| 306 | - if ($s != $statut or ($d and $d != $date)) { |
|
| 307 | - if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 308 | - $statut = $champs['statut'] = $s; |
|
| 309 | - } elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') { |
|
| 310 | - $statut = $champs['statut'] = $s; |
|
| 311 | - } else { |
|
| 312 | - spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - // En cas de publication, fixer la date a "maintenant" |
|
| 316 | - // sauf si $c commande autre chose |
|
| 317 | - // ou si l'article est deja date dans le futur |
|
| 318 | - // En cas de proposition d'un article (mais pas depublication), idem |
|
| 319 | - if ( |
|
| 320 | - $champs['statut'] == 'publie' |
|
| 321 | - or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, ['publie', 'prop']))) |
|
| 322 | - ) { |
|
| 323 | - if ($d or strtotime($d = $date) > time()) { |
|
| 324 | - $champs['date'] = $date = $d; |
|
| 325 | - } else { |
|
| 326 | - $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - // Verifier que la rubrique demandee existe et est differente |
|
| 332 | - // de la rubrique actuelle |
|
| 333 | - if ( |
|
| 334 | - isset($c['id_parent']) |
|
| 335 | - and $id_parent = $c['id_parent'] |
|
| 336 | - and $id_parent != $id_rubrique |
|
| 337 | - and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 338 | - ) { |
|
| 339 | - $champs['id_rubrique'] = $id_parent; |
|
| 340 | - |
|
| 341 | - // si l'article etait publie |
|
| 342 | - // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 343 | - // repasser l'article en statut 'propose'. |
|
| 344 | - if ( |
|
| 345 | - $statut == 'publie' |
|
| 346 | - and !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 347 | - ) { |
|
| 348 | - $champs['statut'] = 'prop'; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // Envoyer aux plugins |
|
| 353 | - $champs = pipeline( |
|
| 354 | - 'pre_edition', |
|
| 355 | - [ |
|
| 356 | - 'args' => [ |
|
| 357 | - 'table' => 'spip_articles', |
|
| 358 | - 'id_objet' => $id_article, |
|
| 359 | - 'action' => 'instituer', |
|
| 360 | - 'statut_ancien' => $statut_ancien, |
|
| 361 | - 'date_ancienne' => $date_ancienne, |
|
| 362 | - ], |
|
| 363 | - 'data' => $champs |
|
| 364 | - ] |
|
| 365 | - ); |
|
| 366 | - |
|
| 367 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 368 | - return ''; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // Envoyer les modifs. |
|
| 372 | - editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 373 | - |
|
| 374 | - // Invalider les caches |
|
| 375 | - include_spip('inc/invalideur'); |
|
| 376 | - suivre_invalideur("id='article/$id_article'"); |
|
| 377 | - |
|
| 378 | - if ($date) { |
|
| 379 | - $t = strtotime($date); |
|
| 380 | - $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 381 | - if ($t > time() and (!$p or ($t < $p))) { |
|
| 382 | - ecrire_meta('date_prochain_postdate', $t); |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - // Pipeline |
|
| 387 | - pipeline( |
|
| 388 | - 'post_edition', |
|
| 389 | - [ |
|
| 390 | - 'args' => [ |
|
| 391 | - 'table' => 'spip_articles', |
|
| 392 | - 'id_objet' => $id_article, |
|
| 393 | - 'action' => 'instituer', |
|
| 394 | - 'statut_ancien' => $statut_ancien, |
|
| 395 | - 'date_ancienne' => $date_ancienne, |
|
| 396 | - ], |
|
| 397 | - 'data' => $champs |
|
| 398 | - ] |
|
| 399 | - ); |
|
| 400 | - |
|
| 401 | - // Notifications |
|
| 402 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 403 | - $notifications( |
|
| 404 | - 'instituerarticle', |
|
| 405 | - $id_article, |
|
| 406 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 407 | - ); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - return ''; // pas d'erreur |
|
| 292 | + include_spip('inc/autoriser'); |
|
| 293 | + include_spip('inc/rubriques'); |
|
| 294 | + include_spip('inc/modifier'); |
|
| 295 | + |
|
| 296 | + $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 297 | + $id_rubrique = $row['id_rubrique']; |
|
| 298 | + $statut_ancien = $statut = $row['statut']; |
|
| 299 | + $date_ancienne = $date = $row['date']; |
|
| 300 | + $champs = []; |
|
| 301 | + |
|
| 302 | + $d = $c['date'] ?? null; |
|
| 303 | + $s = $c['statut'] ?? $statut; |
|
| 304 | + |
|
| 305 | + // cf autorisations dans inc/instituer_article |
|
| 306 | + if ($s != $statut or ($d and $d != $date)) { |
|
| 307 | + if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 308 | + $statut = $champs['statut'] = $s; |
|
| 309 | + } elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') { |
|
| 310 | + $statut = $champs['statut'] = $s; |
|
| 311 | + } else { |
|
| 312 | + spip_log("editer_article $id_article refus " . join(' ', $c)); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + // En cas de publication, fixer la date a "maintenant" |
|
| 316 | + // sauf si $c commande autre chose |
|
| 317 | + // ou si l'article est deja date dans le futur |
|
| 318 | + // En cas de proposition d'un article (mais pas depublication), idem |
|
| 319 | + if ( |
|
| 320 | + $champs['statut'] == 'publie' |
|
| 321 | + or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, ['publie', 'prop']))) |
|
| 322 | + ) { |
|
| 323 | + if ($d or strtotime($d = $date) > time()) { |
|
| 324 | + $champs['date'] = $date = $d; |
|
| 325 | + } else { |
|
| 326 | + $champs['date'] = $date = date('Y-m-d H:i:s'); |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + // Verifier que la rubrique demandee existe et est differente |
|
| 332 | + // de la rubrique actuelle |
|
| 333 | + if ( |
|
| 334 | + isset($c['id_parent']) |
|
| 335 | + and $id_parent = $c['id_parent'] |
|
| 336 | + and $id_parent != $id_rubrique |
|
| 337 | + and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent))) |
|
| 338 | + ) { |
|
| 339 | + $champs['id_rubrique'] = $id_parent; |
|
| 340 | + |
|
| 341 | + // si l'article etait publie |
|
| 342 | + // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 343 | + // repasser l'article en statut 'propose'. |
|
| 344 | + if ( |
|
| 345 | + $statut == 'publie' |
|
| 346 | + and !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 347 | + ) { |
|
| 348 | + $champs['statut'] = 'prop'; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // Envoyer aux plugins |
|
| 353 | + $champs = pipeline( |
|
| 354 | + 'pre_edition', |
|
| 355 | + [ |
|
| 356 | + 'args' => [ |
|
| 357 | + 'table' => 'spip_articles', |
|
| 358 | + 'id_objet' => $id_article, |
|
| 359 | + 'action' => 'instituer', |
|
| 360 | + 'statut_ancien' => $statut_ancien, |
|
| 361 | + 'date_ancienne' => $date_ancienne, |
|
| 362 | + ], |
|
| 363 | + 'data' => $champs |
|
| 364 | + ] |
|
| 365 | + ); |
|
| 366 | + |
|
| 367 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 368 | + return ''; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // Envoyer les modifs. |
|
| 372 | + editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 373 | + |
|
| 374 | + // Invalider les caches |
|
| 375 | + include_spip('inc/invalideur'); |
|
| 376 | + suivre_invalideur("id='article/$id_article'"); |
|
| 377 | + |
|
| 378 | + if ($date) { |
|
| 379 | + $t = strtotime($date); |
|
| 380 | + $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 381 | + if ($t > time() and (!$p or ($t < $p))) { |
|
| 382 | + ecrire_meta('date_prochain_postdate', $t); |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + // Pipeline |
|
| 387 | + pipeline( |
|
| 388 | + 'post_edition', |
|
| 389 | + [ |
|
| 390 | + 'args' => [ |
|
| 391 | + 'table' => 'spip_articles', |
|
| 392 | + 'id_objet' => $id_article, |
|
| 393 | + 'action' => 'instituer', |
|
| 394 | + 'statut_ancien' => $statut_ancien, |
|
| 395 | + 'date_ancienne' => $date_ancienne, |
|
| 396 | + ], |
|
| 397 | + 'data' => $champs |
|
| 398 | + ] |
|
| 399 | + ); |
|
| 400 | + |
|
| 401 | + // Notifications |
|
| 402 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 403 | + $notifications( |
|
| 404 | + 'instituerarticle', |
|
| 405 | + $id_article, |
|
| 406 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 407 | + ); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + return ''; // pas d'erreur |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -432,37 +432,37 @@ discard block |
||
| 432 | 432 | */ |
| 433 | 433 | function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) { |
| 434 | 434 | |
| 435 | - // Si on deplace l'article |
|
| 436 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 437 | - if (isset($champs['id_rubrique'])) { |
|
| 438 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 439 | - |
|
| 440 | - $langue = $row_rub['lang']; |
|
| 441 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 442 | - if ( |
|
| 443 | - sql_fetsel( |
|
| 444 | - '1', |
|
| 445 | - 'spip_articles', |
|
| 446 | - 'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 447 | - ) |
|
| 448 | - ) { |
|
| 449 | - $champs['lang'] = $langue; |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - if (!$champs) { |
|
| 454 | - return; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article)); |
|
| 458 | - |
|
| 459 | - // Changer le statut des rubriques concernees |
|
| 460 | - |
|
| 461 | - if ($cond) { |
|
| 462 | - include_spip('inc/rubriques'); |
|
| 463 | - $postdate = ($GLOBALS['meta']['post_dates'] == 'non' and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false; |
|
| 464 | - calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 465 | - } |
|
| 435 | + // Si on deplace l'article |
|
| 436 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 437 | + if (isset($champs['id_rubrique'])) { |
|
| 438 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 439 | + |
|
| 440 | + $langue = $row_rub['lang']; |
|
| 441 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 442 | + if ( |
|
| 443 | + sql_fetsel( |
|
| 444 | + '1', |
|
| 445 | + 'spip_articles', |
|
| 446 | + 'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 447 | + ) |
|
| 448 | + ) { |
|
| 449 | + $champs['lang'] = $langue; |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + if (!$champs) { |
|
| 454 | + return; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article)); |
|
| 458 | + |
|
| 459 | + // Changer le statut des rubriques concernees |
|
| 460 | + |
|
| 461 | + if ($cond) { |
|
| 462 | + include_spip('inc/rubriques'); |
|
| 463 | + $postdate = ($GLOBALS['meta']['post_dates'] == 'non' and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false; |
|
| 464 | + calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
@@ -471,10 +471,10 @@ discard block |
||
| 471 | 471 | * @return void |
| 472 | 472 | */ |
| 473 | 473 | function trop_longs_articles() { |
| 474 | - if (is_array($plus = _request('texte_plus'))) { |
|
| 475 | - foreach ($plus as $n => $t) { |
|
| 476 | - $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t); |
|
| 477 | - } |
|
| 478 | - set_request('texte', join('', $plus) . _request('texte')); |
|
| 479 | - } |
|
| 474 | + if (is_array($plus = _request('texte_plus'))) { |
|
| 475 | + foreach ($plus as $n => $t) { |
|
| 476 | + $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t); |
|
| 477 | + } |
|
| 478 | + set_request('texte', join('', $plus) . _request('texte')); |
|
| 479 | + } |
|
| 480 | 480 | } |
@@ -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 | /** |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | 36 | function action_ajouter_lien_dist($arg = null) { |
| 37 | - if (is_null($arg)) { |
|
| 38 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | - $arg = $securiser_action(); |
|
| 40 | - } |
|
| 37 | + if (is_null($arg)) { |
|
| 38 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | + $arg = $securiser_action(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $arg = explode('-', $arg); |
|
| 43 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 42 | + $arg = explode('-', $arg); |
|
| 43 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 44 | 44 | |
| 45 | - include_spip('action/editer_liens'); |
|
| 46 | - objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 45 | + include_spip('action/editer_liens'); |
|
| 46 | + objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 47 | 47 | } |
@@ -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,17 +31,17 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_debloquer_edition_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | 36 | |
| 37 | - if ($arg) { |
|
| 38 | - include_spip('inc/drapeau_edition'); |
|
| 39 | - if ($arg == 'tous') { |
|
| 40 | - debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | - } else { |
|
| 42 | - $arg = explode('-', $arg); |
|
| 43 | - [$objet, $id_objet] = $arg; |
|
| 44 | - debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | - } |
|
| 46 | - } |
|
| 37 | + if ($arg) { |
|
| 38 | + include_spip('inc/drapeau_edition'); |
|
| 39 | + if ($arg == 'tous') { |
|
| 40 | + debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | + } else { |
|
| 42 | + $arg = explode('-', $arg); |
|
| 43 | + [$objet, $id_objet] = $arg; |
|
| 44 | + debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -33,93 +33,93 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | 35 | function action_cookie_dist($set_cookie_admin = null, $change_session = null) { |
| 36 | - $redirect_echec = $redirect = null; |
|
| 37 | - $test_echec_cookie = null; |
|
| 38 | - $url = ''; |
|
| 39 | - if (is_null($set_cookie_admin)) { |
|
| 40 | - $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | - $change_session = _request('change_session'); |
|
| 42 | - $test_echec_cookie = _request('test_echec_cookie'); |
|
| 36 | + $redirect_echec = $redirect = null; |
|
| 37 | + $test_echec_cookie = null; |
|
| 38 | + $url = ''; |
|
| 39 | + if (is_null($set_cookie_admin)) { |
|
| 40 | + $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | + $change_session = _request('change_session'); |
|
| 42 | + $test_echec_cookie = _request('test_echec_cookie'); |
|
| 43 | 43 | |
| 44 | - // La cible de notre operation de connexion |
|
| 45 | - $url = securiser_redirect_action(_request('url')); |
|
| 46 | - $redirect = $url ?: generer_url_ecrire('accueil'); |
|
| 47 | - $redirect_echec = _request('url_echec'); |
|
| 48 | - if (!isset($redirect_echec)) { |
|
| 49 | - if (strpos($redirect, (string) _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | - $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | - } else { |
|
| 52 | - $redirect_echec = $redirect; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 44 | + // La cible de notre operation de connexion |
|
| 45 | + $url = securiser_redirect_action(_request('url')); |
|
| 46 | + $redirect = $url ?: generer_url_ecrire('accueil'); |
|
| 47 | + $redirect_echec = _request('url_echec'); |
|
| 48 | + if (!isset($redirect_echec)) { |
|
| 49 | + if (strpos($redirect, (string) _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | + $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | + } else { |
|
| 52 | + $redirect_echec = $redirect; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - // rejoue le cookie pour renouveler spip_session |
|
| 59 | - if ($change_session == 'oui') { |
|
| 60 | - $session = charger_fonction('session', 'inc'); |
|
| 61 | - $session(true); |
|
| 62 | - spip_log('statut 204 pour ' . $_SERVER['REQUEST_URI']); |
|
| 63 | - http_response_code(204); // No Content |
|
| 64 | - return; |
|
| 65 | - } |
|
| 58 | + // rejoue le cookie pour renouveler spip_session |
|
| 59 | + if ($change_session == 'oui') { |
|
| 60 | + $session = charger_fonction('session', 'inc'); |
|
| 61 | + $session(true); |
|
| 62 | + spip_log('statut 204 pour ' . $_SERVER['REQUEST_URI']); |
|
| 63 | + http_response_code(204); // No Content |
|
| 64 | + return; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - // tentative de connexion en auth_http |
|
| 68 | - if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | - include_spip('inc/auth'); |
|
| 70 | - if ( |
|
| 71 | - @$_SERVER['PHP_AUTH_USER'] |
|
| 72 | - and @$_SERVER['PHP_AUTH_PW'] |
|
| 73 | - and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 74 | - ) { |
|
| 75 | - auth_loger($auteur); |
|
| 76 | - redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 77 | - } else { |
|
| 78 | - ask_php_auth( |
|
| 79 | - _T('info_connexion_refusee'), |
|
| 80 | - _T('login_login_pass_incorrect'), |
|
| 81 | - _T('login_retour_site'), |
|
| 82 | - 'url=' . rawurlencode($redirect), |
|
| 83 | - _T('login_nouvelle_tentative'), |
|
| 84 | - (strpos($url, (string) _DIR_RESTREINT_ABS) !== false) |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 89 | - // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 90 | - // le cas echeant. |
|
| 91 | - if ($test_echec_cookie == 'oui') { |
|
| 92 | - spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 93 | - if ($redirect) { |
|
| 94 | - $redirect = parametre_url( |
|
| 95 | - parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), |
|
| 96 | - 'url', |
|
| 97 | - rawurlencode($redirect), |
|
| 98 | - '&' |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - } else { |
|
| 102 | - $cook = $_COOKIE['spip_admin'] ?? ''; |
|
| 103 | - // Suppression cookie d'admin ? |
|
| 104 | - if ($set_cookie_admin == 'non') { |
|
| 105 | - if ($cook) { |
|
| 106 | - spip_setcookie('spip_admin', $cook, [ |
|
| 107 | - 'expires' => time() - 3600 * 24 |
|
| 108 | - ]); |
|
| 109 | - } |
|
| 110 | - } // Ajout de cookie d'admin |
|
| 111 | - else { |
|
| 112 | - if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 113 | - spip_setcookie('spip_admin', $set_cookie_admin, [ |
|
| 114 | - 'expires' => time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA) |
|
| 115 | - ]); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 67 | + // tentative de connexion en auth_http |
|
| 68 | + if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | + include_spip('inc/auth'); |
|
| 70 | + if ( |
|
| 71 | + @$_SERVER['PHP_AUTH_USER'] |
|
| 72 | + and @$_SERVER['PHP_AUTH_PW'] |
|
| 73 | + and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 74 | + ) { |
|
| 75 | + auth_loger($auteur); |
|
| 76 | + redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 77 | + } else { |
|
| 78 | + ask_php_auth( |
|
| 79 | + _T('info_connexion_refusee'), |
|
| 80 | + _T('login_login_pass_incorrect'), |
|
| 81 | + _T('login_retour_site'), |
|
| 82 | + 'url=' . rawurlencode($redirect), |
|
| 83 | + _T('login_nouvelle_tentative'), |
|
| 84 | + (strpos($url, (string) _DIR_RESTREINT_ABS) !== false) |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 89 | + // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 90 | + // le cas echeant. |
|
| 91 | + if ($test_echec_cookie == 'oui') { |
|
| 92 | + spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 93 | + if ($redirect) { |
|
| 94 | + $redirect = parametre_url( |
|
| 95 | + parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), |
|
| 96 | + 'url', |
|
| 97 | + rawurlencode($redirect), |
|
| 98 | + '&' |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + } else { |
|
| 102 | + $cook = $_COOKIE['spip_admin'] ?? ''; |
|
| 103 | + // Suppression cookie d'admin ? |
|
| 104 | + if ($set_cookie_admin == 'non') { |
|
| 105 | + if ($cook) { |
|
| 106 | + spip_setcookie('spip_admin', $cook, [ |
|
| 107 | + 'expires' => time() - 3600 * 24 |
|
| 108 | + ]); |
|
| 109 | + } |
|
| 110 | + } // Ajout de cookie d'admin |
|
| 111 | + else { |
|
| 112 | + if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 113 | + spip_setcookie('spip_admin', $set_cookie_admin, [ |
|
| 114 | + 'expires' => time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA) |
|
| 115 | + ]); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - // Redirection finale |
|
| 122 | - if ($redirect) { |
|
| 123 | - redirige_par_entete($redirect, true); |
|
| 124 | - } |
|
| 121 | + // Redirection finale |
|
| 122 | + if ($redirect) { |
|
| 123 | + redirige_par_entete($redirect, true); |
|
| 124 | + } |
|
| 125 | 125 | } |
@@ -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 | /** |
@@ -30,155 +30,155 @@ discard block |
||
| 30 | 30 | * redirige sur l'image ainsi créée (sinon sur une image d'echec). |
| 31 | 31 | **/ |
| 32 | 32 | function action_tester_dist() { |
| 33 | - $arg = _request('arg'); |
|
| 34 | - |
|
| 35 | - $gd_formats = []; |
|
| 36 | - $gd_formats_read_gif = ''; |
|
| 37 | - // verifier les formats acceptes par GD |
|
| 38 | - if ($arg == 'gd1') { |
|
| 39 | - // Si GD est installe et php >= 4.0.2 |
|
| 40 | - if (function_exists('imagetypes')) { |
|
| 41 | - if (imagetypes() & IMG_GIF) { |
|
| 42 | - $gd_formats[] = 'gif'; |
|
| 43 | - } else { |
|
| 44 | - # Attention GD sait lire le gif mais pas forcement l'ecrire |
|
| 45 | - if (function_exists('ImageCreateFromGIF')) { |
|
| 46 | - $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 47 | - if ($srcImage) { |
|
| 48 | - $gd_formats_read_gif = ',gif'; |
|
| 49 | - ImageDestroy($srcImage); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (imagetypes() & IMG_JPG) { |
|
| 55 | - $gd_formats[] = 'jpg'; |
|
| 56 | - } |
|
| 57 | - if (imagetypes() & IMG_PNG) { |
|
| 58 | - $gd_formats[] = 'png'; |
|
| 59 | - } |
|
| 60 | - if (imagetypes() & IMG_WEBP) { |
|
| 61 | - $gd_formats[] = 'webp'; |
|
| 62 | - } |
|
| 63 | - } else { |
|
| 64 | - # ancienne methode de detection des formats, qui en plus |
|
| 65 | - # est bugguee car elle teste les formats en lecture |
|
| 66 | - # alors que la valeur deduite sert a identifier |
|
| 67 | - # les formats disponibles en ecriture... (cf. inc_logos) |
|
| 68 | - |
|
| 69 | - if (function_exists('ImageCreateFromJPEG')) { |
|
| 70 | - $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK . 'test.jpg'); |
|
| 71 | - if ($srcImage) { |
|
| 72 | - $gd_formats[] = 'jpg'; |
|
| 73 | - ImageDestroy($srcImage); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - if (function_exists('ImageCreateFromGIF')) { |
|
| 77 | - $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 78 | - if ($srcImage) { |
|
| 79 | - $gd_formats[] = 'gif'; |
|
| 80 | - ImageDestroy($srcImage); |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - if (function_exists('ImageCreateFromPNG')) { |
|
| 84 | - $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK . 'test.png'); |
|
| 85 | - if ($srcImage) { |
|
| 86 | - $gd_formats[] = 'png'; |
|
| 87 | - ImageDestroy($srcImage); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - if (function_exists('ImageCreateFromWEBP')) { |
|
| 91 | - $srcImage = @ImageCreateFromWEBP(_ROOT_IMG_PACK . 'test.webp'); |
|
| 92 | - if ($srcImage) { |
|
| 93 | - $gd_formats[] = 'webp'; |
|
| 94 | - ImageDestroy($srcImage); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if (! empty($gd_formats)) { |
|
| 100 | - $gd_formats = join(',', $gd_formats); |
|
| 101 | - } |
|
| 102 | - ecrire_meta('gd_formats_read', $gd_formats . $gd_formats_read_gif); |
|
| 103 | - ecrire_meta('gd_formats', $gd_formats); |
|
| 104 | - } // verifier les formats netpbm |
|
| 105 | - else { |
|
| 106 | - if ($arg == 'netpbm') { |
|
| 107 | - if (!defined('_PNMSCALE_COMMAND')) { |
|
| 108 | - define('_PNMSCALE_COMMAND', 'pnmscale'); |
|
| 109 | - } // Securite : mes_options.php peut preciser le chemin absolu |
|
| 110 | - if (_PNMSCALE_COMMAND == '') { |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - $netpbm_formats = []; |
|
| 114 | - |
|
| 115 | - $jpegtopnm_command = str_replace( |
|
| 116 | - 'pnmscale', |
|
| 117 | - 'jpegtopnm', |
|
| 118 | - _PNMSCALE_COMMAND |
|
| 119 | - ); |
|
| 120 | - $pnmtojpeg_command = str_replace( |
|
| 121 | - 'pnmscale', |
|
| 122 | - 'pnmtojpeg', |
|
| 123 | - _PNMSCALE_COMMAND |
|
| 124 | - ); |
|
| 125 | - |
|
| 126 | - $vignette = _ROOT_IMG_PACK . 'test.jpg'; |
|
| 127 | - $dest = _DIR_VAR . 'test-jpg.jpg'; |
|
| 128 | - $commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 129 | - spip_log($commande); |
|
| 130 | - exec($commande); |
|
| 131 | - if ($taille = @getimagesize($dest)) { |
|
| 132 | - if ($taille[1] == 10) { |
|
| 133 | - $netpbm_formats[] = 'jpg'; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND); |
|
| 137 | - $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND); |
|
| 138 | - $vignette = _ROOT_IMG_PACK . 'test.gif'; |
|
| 139 | - $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 140 | - $commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 141 | - spip_log($commande); |
|
| 142 | - exec($commande); |
|
| 143 | - if ($taille = @getimagesize($dest)) { |
|
| 144 | - if ($taille[1] == 10) { |
|
| 145 | - $netpbm_formats[] = 'gif'; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND); |
|
| 150 | - $vignette = _ROOT_IMG_PACK . 'test.png'; |
|
| 151 | - $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 152 | - $commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 153 | - spip_log($commande); |
|
| 154 | - exec($commande); |
|
| 155 | - if ($taille = @getimagesize($dest)) { |
|
| 156 | - if ($taille[1] == 10) { |
|
| 157 | - $netpbm_formats[] = 'png'; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - ecrire_meta('netpbm_formats', join(',', $netpbm_formats ?: [])); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // et maintenant envoyer la vignette de tests |
|
| 166 | - if (in_array($arg, ['gd1', 'gd2', 'imagick', 'convert', 'netpbm'])) { |
|
| 167 | - include_spip('inc/filtres'); |
|
| 168 | - include_spip('inc/filtres_images_mini'); |
|
| 169 | - $taille_preview = 150; |
|
| 170 | - $image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg'); |
|
| 171 | - |
|
| 172 | - $image['fichier_dest'] = _DIR_VAR . "test_$arg"; |
|
| 173 | - |
|
| 174 | - if ( |
|
| 175 | - $preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
|
| 176 | - and ($preview['width'] * $preview['height'] > 0) |
|
| 177 | - ) { |
|
| 178 | - redirige_par_entete($preview['fichier']); |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - # image echec |
|
| 183 | - redirige_par_entete(chemin_image('echec-reducteur-xx.svg')); |
|
| 33 | + $arg = _request('arg'); |
|
| 34 | + |
|
| 35 | + $gd_formats = []; |
|
| 36 | + $gd_formats_read_gif = ''; |
|
| 37 | + // verifier les formats acceptes par GD |
|
| 38 | + if ($arg == 'gd1') { |
|
| 39 | + // Si GD est installe et php >= 4.0.2 |
|
| 40 | + if (function_exists('imagetypes')) { |
|
| 41 | + if (imagetypes() & IMG_GIF) { |
|
| 42 | + $gd_formats[] = 'gif'; |
|
| 43 | + } else { |
|
| 44 | + # Attention GD sait lire le gif mais pas forcement l'ecrire |
|
| 45 | + if (function_exists('ImageCreateFromGIF')) { |
|
| 46 | + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 47 | + if ($srcImage) { |
|
| 48 | + $gd_formats_read_gif = ',gif'; |
|
| 49 | + ImageDestroy($srcImage); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (imagetypes() & IMG_JPG) { |
|
| 55 | + $gd_formats[] = 'jpg'; |
|
| 56 | + } |
|
| 57 | + if (imagetypes() & IMG_PNG) { |
|
| 58 | + $gd_formats[] = 'png'; |
|
| 59 | + } |
|
| 60 | + if (imagetypes() & IMG_WEBP) { |
|
| 61 | + $gd_formats[] = 'webp'; |
|
| 62 | + } |
|
| 63 | + } else { |
|
| 64 | + # ancienne methode de detection des formats, qui en plus |
|
| 65 | + # est bugguee car elle teste les formats en lecture |
|
| 66 | + # alors que la valeur deduite sert a identifier |
|
| 67 | + # les formats disponibles en ecriture... (cf. inc_logos) |
|
| 68 | + |
|
| 69 | + if (function_exists('ImageCreateFromJPEG')) { |
|
| 70 | + $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK . 'test.jpg'); |
|
| 71 | + if ($srcImage) { |
|
| 72 | + $gd_formats[] = 'jpg'; |
|
| 73 | + ImageDestroy($srcImage); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + if (function_exists('ImageCreateFromGIF')) { |
|
| 77 | + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 78 | + if ($srcImage) { |
|
| 79 | + $gd_formats[] = 'gif'; |
|
| 80 | + ImageDestroy($srcImage); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + if (function_exists('ImageCreateFromPNG')) { |
|
| 84 | + $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK . 'test.png'); |
|
| 85 | + if ($srcImage) { |
|
| 86 | + $gd_formats[] = 'png'; |
|
| 87 | + ImageDestroy($srcImage); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + if (function_exists('ImageCreateFromWEBP')) { |
|
| 91 | + $srcImage = @ImageCreateFromWEBP(_ROOT_IMG_PACK . 'test.webp'); |
|
| 92 | + if ($srcImage) { |
|
| 93 | + $gd_formats[] = 'webp'; |
|
| 94 | + ImageDestroy($srcImage); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if (! empty($gd_formats)) { |
|
| 100 | + $gd_formats = join(',', $gd_formats); |
|
| 101 | + } |
|
| 102 | + ecrire_meta('gd_formats_read', $gd_formats . $gd_formats_read_gif); |
|
| 103 | + ecrire_meta('gd_formats', $gd_formats); |
|
| 104 | + } // verifier les formats netpbm |
|
| 105 | + else { |
|
| 106 | + if ($arg == 'netpbm') { |
|
| 107 | + if (!defined('_PNMSCALE_COMMAND')) { |
|
| 108 | + define('_PNMSCALE_COMMAND', 'pnmscale'); |
|
| 109 | + } // Securite : mes_options.php peut preciser le chemin absolu |
|
| 110 | + if (_PNMSCALE_COMMAND == '') { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + $netpbm_formats = []; |
|
| 114 | + |
|
| 115 | + $jpegtopnm_command = str_replace( |
|
| 116 | + 'pnmscale', |
|
| 117 | + 'jpegtopnm', |
|
| 118 | + _PNMSCALE_COMMAND |
|
| 119 | + ); |
|
| 120 | + $pnmtojpeg_command = str_replace( |
|
| 121 | + 'pnmscale', |
|
| 122 | + 'pnmtojpeg', |
|
| 123 | + _PNMSCALE_COMMAND |
|
| 124 | + ); |
|
| 125 | + |
|
| 126 | + $vignette = _ROOT_IMG_PACK . 'test.jpg'; |
|
| 127 | + $dest = _DIR_VAR . 'test-jpg.jpg'; |
|
| 128 | + $commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 129 | + spip_log($commande); |
|
| 130 | + exec($commande); |
|
| 131 | + if ($taille = @getimagesize($dest)) { |
|
| 132 | + if ($taille[1] == 10) { |
|
| 133 | + $netpbm_formats[] = 'jpg'; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND); |
|
| 137 | + $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND); |
|
| 138 | + $vignette = _ROOT_IMG_PACK . 'test.gif'; |
|
| 139 | + $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 140 | + $commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 141 | + spip_log($commande); |
|
| 142 | + exec($commande); |
|
| 143 | + if ($taille = @getimagesize($dest)) { |
|
| 144 | + if ($taille[1] == 10) { |
|
| 145 | + $netpbm_formats[] = 'gif'; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND); |
|
| 150 | + $vignette = _ROOT_IMG_PACK . 'test.png'; |
|
| 151 | + $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 152 | + $commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 153 | + spip_log($commande); |
|
| 154 | + exec($commande); |
|
| 155 | + if ($taille = @getimagesize($dest)) { |
|
| 156 | + if ($taille[1] == 10) { |
|
| 157 | + $netpbm_formats[] = 'png'; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + ecrire_meta('netpbm_formats', join(',', $netpbm_formats ?: [])); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // et maintenant envoyer la vignette de tests |
|
| 166 | + if (in_array($arg, ['gd1', 'gd2', 'imagick', 'convert', 'netpbm'])) { |
|
| 167 | + include_spip('inc/filtres'); |
|
| 168 | + include_spip('inc/filtres_images_mini'); |
|
| 169 | + $taille_preview = 150; |
|
| 170 | + $image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg'); |
|
| 171 | + |
|
| 172 | + $image['fichier_dest'] = _DIR_VAR . "test_$arg"; |
|
| 173 | + |
|
| 174 | + if ( |
|
| 175 | + $preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
|
| 176 | + and ($preview['width'] * $preview['height'] > 0) |
|
| 177 | + ) { |
|
| 178 | + redirige_par_entete($preview['fichier']); |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + # image echec |
|
| 183 | + redirige_par_entete(chemin_image('echec-reducteur-xx.svg')); |
|
| 184 | 184 | } |
@@ -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 | /** |
@@ -32,28 +32,28 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function action_desinstaller_plugin_dist() { |
| 34 | 34 | |
| 35 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 36 | - $arg = $securiser_action(); |
|
| 37 | - [$dir_plugins, $plugin] = explode('::', $arg); |
|
| 38 | - $dir_type = '_DIR_PLUGINS'; |
|
| 39 | - if (defined('_DIR_PLUGINS_SUPPL') and $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 40 | - $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 41 | - } |
|
| 42 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 43 | - $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 44 | - if ($infos and !$infos['install_test'][0]) { |
|
| 45 | - include_spip('inc/plugin'); |
|
| 46 | - ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 47 | - $erreur = ''; |
|
| 48 | - } else { |
|
| 49 | - $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 50 | - } |
|
| 51 | - if ($redirect = _request('redirect')) { |
|
| 52 | - include_spip('inc/headers'); |
|
| 53 | - if ($erreur) { |
|
| 54 | - $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 55 | - } |
|
| 56 | - $redirect = str_replace('&', '&', $redirect); |
|
| 57 | - redirige_par_entete($redirect); |
|
| 58 | - } |
|
| 35 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 36 | + $arg = $securiser_action(); |
|
| 37 | + [$dir_plugins, $plugin] = explode('::', $arg); |
|
| 38 | + $dir_type = '_DIR_PLUGINS'; |
|
| 39 | + if (defined('_DIR_PLUGINS_SUPPL') and $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 40 | + $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 41 | + } |
|
| 42 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 43 | + $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 44 | + if ($infos and !$infos['install_test'][0]) { |
|
| 45 | + include_spip('inc/plugin'); |
|
| 46 | + ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 47 | + $erreur = ''; |
|
| 48 | + } else { |
|
| 49 | + $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 50 | + } |
|
| 51 | + if ($redirect = _request('redirect')) { |
|
| 52 | + include_spip('inc/headers'); |
|
| 53 | + if ($erreur) { |
|
| 54 | + $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 55 | + } |
|
| 56 | + $redirect = str_replace('&', '&', $redirect); |
|
| 57 | + redirige_par_entete($redirect); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -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 | |
@@ -54,84 +54,84 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function balise_LOGO__dist($p) { |
| 56 | 56 | |
| 57 | - preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 58 | - $type = strtolower($regs[1]); |
|
| 59 | - $suite_logo = $regs[2]; |
|
| 60 | - |
|
| 61 | - // cas de #LOGO_SITE_SPIP |
|
| 62 | - if ($type == 'site_spip') { |
|
| 63 | - $type = 'site'; |
|
| 64 | - $_id_objet = "\"'0'\""; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - $id_objet = id_table_objet($type); |
|
| 68 | - if (!isset($_id_objet)) { |
|
| 69 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 73 | - $coord = []; |
|
| 74 | - $align = $lien = ''; |
|
| 75 | - $mode_logo = ''; |
|
| 76 | - |
|
| 77 | - if ($p->param and !$p->param[0][0]) { |
|
| 78 | - $params = $p->param[0]; |
|
| 79 | - array_shift($params); |
|
| 80 | - foreach ($params as $a) { |
|
| 81 | - if ($a[0]->type === 'texte') { |
|
| 82 | - $n = $a[0]->texte; |
|
| 83 | - if (is_numeric($n)) { |
|
| 84 | - $coord[] = $n; |
|
| 85 | - } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 86 | - $align = $n; |
|
| 87 | - } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 88 | - $mode_logo = $n; |
|
| 89 | - } |
|
| 90 | - } else { |
|
| 91 | - $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $coord_x = !$coord ? 0 : intval(array_shift($coord)); |
|
| 97 | - $coord_y = !$coord ? 0 : intval(array_shift($coord)); |
|
| 98 | - |
|
| 99 | - if ($p->etoile === '*') { |
|
| 100 | - include_spip('balise/url_'); |
|
| 101 | - $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 105 | - if ($type == 'document') { |
|
| 106 | - $qconnect = _q($connect); |
|
| 107 | - $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 108 | - if ($fichier) { |
|
| 109 | - $code = "quete_logo_file($doc, $qconnect)"; |
|
| 110 | - } else { |
|
| 111 | - $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 112 | - } |
|
| 113 | - // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 114 | - if ($p->descr['documents']) { |
|
| 115 | - $code = '(($doublons["documents"] .= ",". ' |
|
| 116 | - . $_id_objet |
|
| 117 | - . ") ? $code : '')"; |
|
| 118 | - } |
|
| 119 | - } elseif ($connect) { |
|
| 120 | - $code = "''"; |
|
| 121 | - spip_log('Les logos distants ne sont pas prevus'); |
|
| 122 | - } else { |
|
| 123 | - $code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 127 | - if ($coord_x or $coord_y) { |
|
| 128 | - $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $p->code = $code; |
|
| 132 | - $p->interdire_scripts = false; |
|
| 133 | - |
|
| 134 | - return $p; |
|
| 57 | + preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 58 | + $type = strtolower($regs[1]); |
|
| 59 | + $suite_logo = $regs[2]; |
|
| 60 | + |
|
| 61 | + // cas de #LOGO_SITE_SPIP |
|
| 62 | + if ($type == 'site_spip') { |
|
| 63 | + $type = 'site'; |
|
| 64 | + $_id_objet = "\"'0'\""; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + $id_objet = id_table_objet($type); |
|
| 68 | + if (!isset($_id_objet)) { |
|
| 69 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 73 | + $coord = []; |
|
| 74 | + $align = $lien = ''; |
|
| 75 | + $mode_logo = ''; |
|
| 76 | + |
|
| 77 | + if ($p->param and !$p->param[0][0]) { |
|
| 78 | + $params = $p->param[0]; |
|
| 79 | + array_shift($params); |
|
| 80 | + foreach ($params as $a) { |
|
| 81 | + if ($a[0]->type === 'texte') { |
|
| 82 | + $n = $a[0]->texte; |
|
| 83 | + if (is_numeric($n)) { |
|
| 84 | + $coord[] = $n; |
|
| 85 | + } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 86 | + $align = $n; |
|
| 87 | + } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 88 | + $mode_logo = $n; |
|
| 89 | + } |
|
| 90 | + } else { |
|
| 91 | + $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $coord_x = !$coord ? 0 : intval(array_shift($coord)); |
|
| 97 | + $coord_y = !$coord ? 0 : intval(array_shift($coord)); |
|
| 98 | + |
|
| 99 | + if ($p->etoile === '*') { |
|
| 100 | + include_spip('balise/url_'); |
|
| 101 | + $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 105 | + if ($type == 'document') { |
|
| 106 | + $qconnect = _q($connect); |
|
| 107 | + $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 108 | + if ($fichier) { |
|
| 109 | + $code = "quete_logo_file($doc, $qconnect)"; |
|
| 110 | + } else { |
|
| 111 | + $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 112 | + } |
|
| 113 | + // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 114 | + if ($p->descr['documents']) { |
|
| 115 | + $code = '(($doublons["documents"] .= ",". ' |
|
| 116 | + . $_id_objet |
|
| 117 | + . ") ? $code : '')"; |
|
| 118 | + } |
|
| 119 | + } elseif ($connect) { |
|
| 120 | + $code = "''"; |
|
| 121 | + spip_log('Les logos distants ne sont pas prevus'); |
|
| 122 | + } else { |
|
| 123 | + $code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 127 | + if ($coord_x or $coord_y) { |
|
| 128 | + $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $p->code = $code; |
|
| 132 | + $p->interdire_scripts = false; |
|
| 133 | + |
|
| 134 | + return $p; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -158,20 +158,20 @@ discard block |
||
| 158 | 158 | * Code compilé retournant le chemin du logo ou le code HTML du logo. |
| 159 | 159 | **/ |
| 160 | 160 | function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $_lien, $p, $suite) { |
| 161 | - $code = "quete_logo('$id_objet', '" . |
|
| 162 | - (($suite == '_SURVOL') ? 'off' : |
|
| 163 | - (($suite == '_NORMAL') ? 'on' : 'ON')) . |
|
| 164 | - "', $_id_objet," . |
|
| 165 | - (($suite == '_RUBRIQUE') ? |
|
| 166 | - champ_sql('id_rubrique', $p) : |
|
| 167 | - (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) . |
|
| 168 | - ', ' . intval($fichier) . ')'; |
|
| 169 | - |
|
| 170 | - if ($fichier) { |
|
| 171 | - return $code; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $align = preg_replace(',\W,', '', $align); |
|
| 175 | - |
|
| 176 | - return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 161 | + $code = "quete_logo('$id_objet', '" . |
|
| 162 | + (($suite == '_SURVOL') ? 'off' : |
|
| 163 | + (($suite == '_NORMAL') ? 'on' : 'ON')) . |
|
| 164 | + "', $_id_objet," . |
|
| 165 | + (($suite == '_RUBRIQUE') ? |
|
| 166 | + champ_sql('id_rubrique', $p) : |
|
| 167 | + (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) . |
|
| 168 | + ', ' . intval($fichier) . ')'; |
|
| 169 | + |
|
| 170 | + if ($fichier) { |
|
| 171 | + return $code; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $align = preg_replace(',\W,', '', $align); |
|
| 175 | + |
|
| 176 | + return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 177 | 177 | } |
@@ -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 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Pile complétée du code compilé |
| 37 | 37 | **/ |
| 38 | 38 | function balise_URL_LOGOUT($p) { |
| 39 | - return calculer_balise_dynamique($p, 'URL_LOGOUT', []); |
|
| 39 | + return calculer_balise_dynamique($p, 'URL_LOGOUT', []); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * Liste (url) des arguments collectés. |
| 53 | 53 | */ |
| 54 | 54 | function balise_URL_LOGOUT_stat($args, $context_compil) { |
| 55 | - $url = $args[0] ?? ''; |
|
| 55 | + $url = $args[0] ?? ''; |
|
| 56 | 56 | |
| 57 | - return [$url]; |
|
| 57 | + return [$url]; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | **/ |
| 70 | 70 | function balise_URL_LOGOUT_dyn($cible) { |
| 71 | 71 | |
| 72 | - if (empty($GLOBALS['visiteur_session']['login']) and empty($GLOBALS['visiteur_session']['statut'])) { |
|
| 73 | - return ''; |
|
| 74 | - } |
|
| 72 | + if (empty($GLOBALS['visiteur_session']['login']) and empty($GLOBALS['visiteur_session']['statut'])) { |
|
| 73 | + return ''; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return generer_url_action('logout', 'logout=public&url=' . rawurlencode($cible ?: self('&'))); |
|
| 76 | + return generer_url_action('logout', 'logout=public&url=' . rawurlencode($cible ?: self('&'))); |
|
| 77 | 77 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Pile complétée du code compilé |
| 44 | 44 | **/ |
| 45 | 45 | function balise_FORMULAIRE_INSCRIPTION($p) { |
| 46 | - return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []); |
|
| 46 | + return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * - chaîne vide sinon. |
| 73 | 73 | */ |
| 74 | 74 | function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) { |
| 75 | - [$mode, $id, $retour] = array_pad($args, 3, null); |
|
| 76 | - include_spip('action/inscrire_auteur'); |
|
| 77 | - $mode = tester_statut_inscription($mode, $id ?? 0); |
|
| 75 | + [$mode, $id, $retour] = array_pad($args, 3, null); |
|
| 76 | + include_spip('action/inscrire_auteur'); |
|
| 77 | + $mode = tester_statut_inscription($mode, $id ?? 0); |
|
| 78 | 78 | |
| 79 | - return $mode ? [$mode, $id, $retour] : ''; |
|
| 79 | + return $mode ? [$mode, $id, $retour] : ''; |
|
| 80 | 80 | } |