@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $type = reset($objets); |
| 160 | 160 | $type = objet_type($type); |
| 161 | 161 | $id = (int) $ref; |
| 162 | - $ref = $type . $ref; |
|
| 162 | + $ref = $type.$ref; |
|
| 163 | 163 | } |
| 164 | 164 | else { |
| 165 | 165 | // Si la référence ne correspond à rien, c'est fini |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | return json_export(false); |
| 168 | 168 | } |
| 169 | 169 | // Sinon on récupère les infos utiles |
| 170 | - [$type, , $id, , , , ] = array_pad($match, 7, null); |
|
| 170 | + [$type,, $id,,,,] = array_pad($match, 7, null); |
|
| 171 | 171 | |
| 172 | 172 | // On regarde si le type trouvé fait partie des objets sélectionnables |
| 173 | 173 | if (!in_array(table_objet($type), $objets)) { |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | $types = (is_array($types) ? array_filter($types) : []); |
| 214 | 214 | |
| 215 | 215 | // recuperer tous les freres et soeurs de la rubrique visee |
| 216 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 217 | - $fratrie = sql_allfetsel('id_rubrique', 'spip_rubriques', 'id_parent=' . (int) $id_parent); |
|
| 216 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique); |
|
| 217 | + $fratrie = sql_allfetsel('id_rubrique', 'spip_rubriques', 'id_parent='.(int) $id_parent); |
|
| 218 | 218 | $fratrie = array_column($fratrie, 'id_rubrique'); |
| 219 | 219 | $has = sql_allfetsel('DISTINCT id_parent', 'spip_rubriques', sql_in('id_parent', $fratrie)); |
| 220 | 220 | $has = array_column($has, 'id_parent'); |
@@ -160,8 +160,7 @@ |
||
| 160 | 160 | $type = objet_type($type); |
| 161 | 161 | $id = (int) $ref; |
| 162 | 162 | $ref = $type . $ref; |
| 163 | - } |
|
| 164 | - else { |
|
| 163 | + } else { |
|
| 165 | 164 | // Si la référence ne correspond à rien, c'est fini |
| 166 | 165 | if (!($match = typer_raccourci($ref))) { |
| 167 | 166 | return json_export(false); |
@@ -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 | /** |
@@ -28,49 +28,49 @@ discard block |
||
| 28 | 28 | * - afficher : tableau des objets à afficher (mais pas forcément sélectionnables) |
| 29 | 29 | */ |
| 30 | 30 | function selecteur_lister_objets($includelist = [], $excludelist = []) { |
| 31 | - static $liste_selecteurs, $liste_parents; |
|
| 32 | - |
|
| 33 | - if (!$liste_selecteurs) { |
|
| 34 | - $liste_selecteurs = find_all_in_path('formulaires/selecteur/', 'hierarchie-[\w]+[.]html$'); |
|
| 35 | - } |
|
| 36 | - $objets_selectionner = []; |
|
| 37 | - foreach ($liste_selecteurs as $fichier => $chemin) { |
|
| 38 | - $objets_selectionner[] = preg_replace('/^hierarchie-([\w]+)[.]html$/', '$1', (string) $fichier); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - // S'il y a une whitelist on ne garde que ce qui est dedans |
|
| 42 | - if (!empty($includelist)) { |
|
| 43 | - $includelist = array_map('table_objet', $includelist); |
|
| 44 | - $objets_selectionner = array_intersect($objets_selectionner, $includelist); |
|
| 45 | - } |
|
| 46 | - // On supprime ce qui est dans la liste d’exclusion |
|
| 47 | - $excludelist = array_map('table_objet', $excludelist); |
|
| 48 | - // On enlève toujours la racine |
|
| 49 | - $excludelist[] = 'racine'; |
|
| 50 | - $objets_selectionner = array_diff($objets_selectionner, $excludelist); |
|
| 51 | - |
|
| 52 | - // Ensuite on cherche ce qu'on doit afficher : au moins ceux qu'on peut sélectionner |
|
| 53 | - $objets_afficher = $objets_selectionner; |
|
| 54 | - |
|
| 55 | - // Il faut alors chercher d'éventuels parents obligatoires en plus : |
|
| 56 | - // lister-trucs-bidules.html => on doit afficher des "trucs" pour trouver des "bidules" |
|
| 57 | - if (!$liste_parents) { |
|
| 58 | - $liste_parents = find_all_in_path('formulaires/selecteur/', 'lister-[\w]+-[\w]+[.]html$'); |
|
| 59 | - } |
|
| 60 | - foreach ($liste_parents as $fichier => $chemin) { |
|
| 61 | - preg_match('/^lister-([\w]+)-([\w]+)[.]html$/', (string) $fichier, $captures); |
|
| 62 | - $parent = $captures[1]; |
|
| 63 | - $type = $captures[2]; |
|
| 64 | - // Si le type fait partie de ce qu'on doit afficher alors on ajoute aussi le parent à l'affichage |
|
| 65 | - if (in_array($type, $objets_afficher)) { |
|
| 66 | - $objets_afficher[] = $parent; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return [ |
|
| 71 | - 'selectionner' => array_unique($objets_selectionner), |
|
| 72 | - 'afficher' => array_unique($objets_afficher), |
|
| 73 | - ]; |
|
| 31 | + static $liste_selecteurs, $liste_parents; |
|
| 32 | + |
|
| 33 | + if (!$liste_selecteurs) { |
|
| 34 | + $liste_selecteurs = find_all_in_path('formulaires/selecteur/', 'hierarchie-[\w]+[.]html$'); |
|
| 35 | + } |
|
| 36 | + $objets_selectionner = []; |
|
| 37 | + foreach ($liste_selecteurs as $fichier => $chemin) { |
|
| 38 | + $objets_selectionner[] = preg_replace('/^hierarchie-([\w]+)[.]html$/', '$1', (string) $fichier); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + // S'il y a une whitelist on ne garde que ce qui est dedans |
|
| 42 | + if (!empty($includelist)) { |
|
| 43 | + $includelist = array_map('table_objet', $includelist); |
|
| 44 | + $objets_selectionner = array_intersect($objets_selectionner, $includelist); |
|
| 45 | + } |
|
| 46 | + // On supprime ce qui est dans la liste d’exclusion |
|
| 47 | + $excludelist = array_map('table_objet', $excludelist); |
|
| 48 | + // On enlève toujours la racine |
|
| 49 | + $excludelist[] = 'racine'; |
|
| 50 | + $objets_selectionner = array_diff($objets_selectionner, $excludelist); |
|
| 51 | + |
|
| 52 | + // Ensuite on cherche ce qu'on doit afficher : au moins ceux qu'on peut sélectionner |
|
| 53 | + $objets_afficher = $objets_selectionner; |
|
| 54 | + |
|
| 55 | + // Il faut alors chercher d'éventuels parents obligatoires en plus : |
|
| 56 | + // lister-trucs-bidules.html => on doit afficher des "trucs" pour trouver des "bidules" |
|
| 57 | + if (!$liste_parents) { |
|
| 58 | + $liste_parents = find_all_in_path('formulaires/selecteur/', 'lister-[\w]+-[\w]+[.]html$'); |
|
| 59 | + } |
|
| 60 | + foreach ($liste_parents as $fichier => $chemin) { |
|
| 61 | + preg_match('/^lister-([\w]+)-([\w]+)[.]html$/', (string) $fichier, $captures); |
|
| 62 | + $parent = $captures[1]; |
|
| 63 | + $type = $captures[2]; |
|
| 64 | + // Si le type fait partie de ce qu'on doit afficher alors on ajoute aussi le parent à l'affichage |
|
| 65 | + if (in_array($type, $objets_afficher)) { |
|
| 66 | + $objets_afficher[] = $parent; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return [ |
|
| 71 | + 'selectionner' => array_unique($objets_selectionner), |
|
| 72 | + 'afficher' => array_unique($objets_afficher), |
|
| 73 | + ]; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -97,31 +97,31 @@ discard block |
||
| 97 | 97 | * liste des couples (objets => id_objet) ou liste des identifiants d'un type d'objet. |
| 98 | 98 | **/ |
| 99 | 99 | function picker_selected($selected, $type = '') { |
| 100 | - $select = []; |
|
| 101 | - $type = preg_replace(',\W,', '', $type); |
|
| 102 | - |
|
| 103 | - if ($selected && !is_array($selected)) { |
|
| 104 | - $selected = explode(',', $selected); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if (is_array($selected)) { |
|
| 108 | - foreach ($selected as $value) { |
|
| 109 | - // Si c'est le bon format déjà |
|
| 110 | - if (preg_match('/^([\w]+)[|](\d+)$/', (string) $value, $captures)) { |
|
| 111 | - $objet = $captures[1]; |
|
| 112 | - $id_objet = (int) $captures[2]; |
|
| 113 | - |
|
| 114 | - // Si on cherche un type et que c'est le bon, on renvoit un tableau que d'identifiants |
|
| 115 | - if (is_string($type) && $type == $objet && ($id_objet || in_array($objet, ['racine', 'rubrique']))) { |
|
| 116 | - $select[] = $id_objet; |
|
| 117 | - } elseif (!$type && ($id_objet || in_array($objet, ['racine', 'rubrique']))) { |
|
| 118 | - $select[] = ['objet' => $objet, 'id_objet' => $id_objet]; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $select; |
|
| 100 | + $select = []; |
|
| 101 | + $type = preg_replace(',\W,', '', $type); |
|
| 102 | + |
|
| 103 | + if ($selected && !is_array($selected)) { |
|
| 104 | + $selected = explode(',', $selected); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if (is_array($selected)) { |
|
| 108 | + foreach ($selected as $value) { |
|
| 109 | + // Si c'est le bon format déjà |
|
| 110 | + if (preg_match('/^([\w]+)[|](\d+)$/', (string) $value, $captures)) { |
|
| 111 | + $objet = $captures[1]; |
|
| 112 | + $id_objet = (int) $captures[2]; |
|
| 113 | + |
|
| 114 | + // Si on cherche un type et que c'est le bon, on renvoit un tableau que d'identifiants |
|
| 115 | + if (is_string($type) && $type == $objet && ($id_objet || in_array($objet, ['racine', 'rubrique']))) { |
|
| 116 | + $select[] = $id_objet; |
|
| 117 | + } elseif (!$type && ($id_objet || in_array($objet, ['racine', 'rubrique']))) { |
|
| 118 | + $select[] = ['objet' => $objet, 'id_objet' => $id_objet]; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $select; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -138,53 +138,53 @@ discard block |
||
| 138 | 138 | * Booléen indiquant si les articles sont sélectionnables |
| 139 | 139 | */ |
| 140 | 140 | function picker_identifie_id_rapide($ref, $rubriques_ou_objets = false, $articles = false) { |
| 141 | - include_spip('inc/json'); |
|
| 142 | - include_spip('inc/lien'); |
|
| 143 | - |
|
| 144 | - // On construit un tableau des objets sélectionnables suivant les paramètres |
|
| 145 | - $objets = []; |
|
| 146 | - if ($rubriques_ou_objets && is_array($rubriques_ou_objets)) { |
|
| 147 | - $objets = $rubriques_ou_objets; |
|
| 148 | - } else { |
|
| 149 | - if ($rubriques_ou_objets) { |
|
| 150 | - $objets[] = 'rubriques'; |
|
| 151 | - } |
|
| 152 | - if ($articles) { |
|
| 153 | - $objets[] = 'articles'; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - // si id numerique et un seul objet possible, pas d'ambiguite |
|
| 158 | - if (is_numeric($ref) && count($objets) === 1) { |
|
| 159 | - $type = reset($objets); |
|
| 160 | - $type = objet_type($type); |
|
| 161 | - $id = (int) $ref; |
|
| 162 | - $ref = $type . $ref; |
|
| 163 | - } |
|
| 164 | - else { |
|
| 165 | - // Si la référence ne correspond à rien, c'est fini |
|
| 166 | - if (!($match = typer_raccourci($ref))) { |
|
| 167 | - return json_export(false); |
|
| 168 | - } |
|
| 169 | - // Sinon on récupère les infos utiles |
|
| 170 | - [$type, , $id, , , , ] = array_pad($match, 7, null); |
|
| 171 | - |
|
| 172 | - // On regarde si le type trouvé fait partie des objets sélectionnables |
|
| 173 | - if (!in_array(table_objet($type), $objets)) { |
|
| 174 | - return json_export(false); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // Maintenant que tout est bon, on cherche les informations sur cet objet |
|
| 179 | - include_spip('inc/filtres'); |
|
| 180 | - if (!$titre = generer_objet_info($id, $type, 'titre')) { |
|
| 181 | - return json_export(false); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // On simplifie le texte |
|
| 185 | - $titre = attribut_html($titre); |
|
| 186 | - |
|
| 187 | - return json_export(['type' => $type, 'id' => "$type|$id", 'titre' => $titre]); |
|
| 141 | + include_spip('inc/json'); |
|
| 142 | + include_spip('inc/lien'); |
|
| 143 | + |
|
| 144 | + // On construit un tableau des objets sélectionnables suivant les paramètres |
|
| 145 | + $objets = []; |
|
| 146 | + if ($rubriques_ou_objets && is_array($rubriques_ou_objets)) { |
|
| 147 | + $objets = $rubriques_ou_objets; |
|
| 148 | + } else { |
|
| 149 | + if ($rubriques_ou_objets) { |
|
| 150 | + $objets[] = 'rubriques'; |
|
| 151 | + } |
|
| 152 | + if ($articles) { |
|
| 153 | + $objets[] = 'articles'; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + // si id numerique et un seul objet possible, pas d'ambiguite |
|
| 158 | + if (is_numeric($ref) && count($objets) === 1) { |
|
| 159 | + $type = reset($objets); |
|
| 160 | + $type = objet_type($type); |
|
| 161 | + $id = (int) $ref; |
|
| 162 | + $ref = $type . $ref; |
|
| 163 | + } |
|
| 164 | + else { |
|
| 165 | + // Si la référence ne correspond à rien, c'est fini |
|
| 166 | + if (!($match = typer_raccourci($ref))) { |
|
| 167 | + return json_export(false); |
|
| 168 | + } |
|
| 169 | + // Sinon on récupère les infos utiles |
|
| 170 | + [$type, , $id, , , , ] = array_pad($match, 7, null); |
|
| 171 | + |
|
| 172 | + // On regarde si le type trouvé fait partie des objets sélectionnables |
|
| 173 | + if (!in_array(table_objet($type), $objets)) { |
|
| 174 | + return json_export(false); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // Maintenant que tout est bon, on cherche les informations sur cet objet |
|
| 179 | + include_spip('inc/filtres'); |
|
| 180 | + if (!$titre = generer_objet_info($id, $type, 'titre')) { |
|
| 181 | + return json_export(false); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // On simplifie le texte |
|
| 185 | + $titre = attribut_html($titre); |
|
| 186 | + |
|
| 187 | + return json_export(['type' => $type, 'id' => "$type|$id", 'titre' => $titre]); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -207,34 +207,34 @@ discard block |
||
| 207 | 207 | * Comme le filtre `oui` : espace (` `) si rubrique à afficher, chaîne vide sinon. |
| 208 | 208 | */ |
| 209 | 209 | function test_enfants_rubrique($id_rubrique, $types = []) { |
| 210 | - static $has_child = []; |
|
| 211 | - |
|
| 212 | - if (!isset($has_child[$id_rubrique])) { |
|
| 213 | - $types = (is_array($types) ? array_filter($types) : []); |
|
| 214 | - |
|
| 215 | - // recuperer tous les freres et soeurs de la rubrique visee |
|
| 216 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 217 | - $fratrie = sql_allfetsel('id_rubrique', 'spip_rubriques', 'id_parent=' . (int) $id_parent); |
|
| 218 | - $fratrie = array_column($fratrie, 'id_rubrique'); |
|
| 219 | - $has = sql_allfetsel('DISTINCT id_parent', 'spip_rubriques', sql_in('id_parent', $fratrie)); |
|
| 220 | - $has = array_column($has, 'id_parent'); |
|
| 221 | - $fratrie = array_diff($fratrie, $has); |
|
| 222 | - |
|
| 223 | - while (count($fratrie) && is_array($types) && count($types)) { |
|
| 224 | - $type = array_shift($types); |
|
| 225 | - $h = sql_allfetsel('DISTINCT id_rubrique', table_objet_sql($type), sql_in('id_rubrique', $fratrie)); |
|
| 226 | - $h = array_column($h, 'id_rubrique'); |
|
| 227 | - $has = [...$has, ...$h]; |
|
| 228 | - $fratrie = array_diff($fratrie, $h); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - if ($has !== []) { |
|
| 232 | - $has_child += array_combine($has, array_pad([], count($has), true)); |
|
| 233 | - } |
|
| 234 | - if ($fratrie !== []) { |
|
| 235 | - $has_child += array_combine($fratrie, array_pad([], count($fratrie), false)); |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - return $has_child[$id_rubrique] ? ' ' : ''; |
|
| 210 | + static $has_child = []; |
|
| 211 | + |
|
| 212 | + if (!isset($has_child[$id_rubrique])) { |
|
| 213 | + $types = (is_array($types) ? array_filter($types) : []); |
|
| 214 | + |
|
| 215 | + // recuperer tous les freres et soeurs de la rubrique visee |
|
| 216 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 217 | + $fratrie = sql_allfetsel('id_rubrique', 'spip_rubriques', 'id_parent=' . (int) $id_parent); |
|
| 218 | + $fratrie = array_column($fratrie, 'id_rubrique'); |
|
| 219 | + $has = sql_allfetsel('DISTINCT id_parent', 'spip_rubriques', sql_in('id_parent', $fratrie)); |
|
| 220 | + $has = array_column($has, 'id_parent'); |
|
| 221 | + $fratrie = array_diff($fratrie, $has); |
|
| 222 | + |
|
| 223 | + while (count($fratrie) && is_array($types) && count($types)) { |
|
| 224 | + $type = array_shift($types); |
|
| 225 | + $h = sql_allfetsel('DISTINCT id_rubrique', table_objet_sql($type), sql_in('id_rubrique', $fratrie)); |
|
| 226 | + $h = array_column($h, 'id_rubrique'); |
|
| 227 | + $has = [...$has, ...$h]; |
|
| 228 | + $fratrie = array_diff($fratrie, $h); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + if ($has !== []) { |
|
| 232 | + $has_child += array_combine($has, array_pad([], count($has), true)); |
|
| 233 | + } |
|
| 234 | + if ($fratrie !== []) { |
|
| 235 | + $has_child += array_combine($fratrie, array_pad([], count($fratrie), false)); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + return $has_child[$id_rubrique] ? ' ' : ''; |
|
| 240 | 240 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -74,28 +74,28 @@ discard block |
||
| 74 | 74 | * @return |
| 75 | 75 | **/ |
| 76 | 76 | function inc_genie_dist($taches = []) { |
| 77 | - include_spip('inc/queue'); |
|
| 78 | - |
|
| 79 | - if (_request('exec') == 'job_queue') { |
|
| 80 | - return false; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $force_jobs = []; |
|
| 84 | - // l'ancienne facon de lancer une tache cron immediatement |
|
| 85 | - // etait de la passer en parametre a ing_genie_dist |
|
| 86 | - // on reroute en ajoutant simplement le job a la queue, ASAP |
|
| 87 | - foreach ($taches as $function => $period) { |
|
| 88 | - $force_jobs[] = queue_add_job( |
|
| 89 | - $function, |
|
| 90 | - _T('tache_cron_asap', ['function' => $function]), |
|
| 91 | - [time() - abs($period)], |
|
| 92 | - 'genie/' |
|
| 93 | - ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // et on passe la main a la gestion de la queue ! |
|
| 97 | - // en forcant eventuellement les jobs ajoute a l'instant |
|
| 98 | - return queue_schedule(count($force_jobs) ? $force_jobs : null); |
|
| 77 | + include_spip('inc/queue'); |
|
| 78 | + |
|
| 79 | + if (_request('exec') == 'job_queue') { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $force_jobs = []; |
|
| 84 | + // l'ancienne facon de lancer une tache cron immediatement |
|
| 85 | + // etait de la passer en parametre a ing_genie_dist |
|
| 86 | + // on reroute en ajoutant simplement le job a la queue, ASAP |
|
| 87 | + foreach ($taches as $function => $period) { |
|
| 88 | + $force_jobs[] = queue_add_job( |
|
| 89 | + $function, |
|
| 90 | + _T('tache_cron_asap', ['function' => $function]), |
|
| 91 | + [time() - abs($period)], |
|
| 92 | + 'genie/' |
|
| 93 | + ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // et on passe la main a la gestion de la queue ! |
|
| 97 | + // en forcant eventuellement les jobs ajoute a l'instant |
|
| 98 | + return queue_schedule(count($force_jobs) ? $force_jobs : null); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // |
@@ -108,34 +108,34 @@ discard block |
||
| 108 | 108 | // |
| 109 | 109 | function taches_generales($taches_generales = []) { |
| 110 | 110 | |
| 111 | - // verifier que toutes les taches cron sont planifiees |
|
| 112 | - // c'est une tache cron ! |
|
| 113 | - $taches_generales['queue_watch'] = 3600 * 24; |
|
| 111 | + // verifier que toutes les taches cron sont planifiees |
|
| 112 | + // c'est une tache cron ! |
|
| 113 | + $taches_generales['queue_watch'] = 3600 * 24; |
|
| 114 | 114 | |
| 115 | - // MAJ des rubriques publiques (cas de la publication post-datee) |
|
| 116 | - // est fait au coup par coup a present |
|
| 117 | - // $taches_generales['rubriques'] = 3600; |
|
| 115 | + // MAJ des rubriques publiques (cas de la publication post-datee) |
|
| 116 | + // est fait au coup par coup a present |
|
| 117 | + // $taches_generales['rubriques'] = 3600; |
|
| 118 | 118 | |
| 119 | - // Optimisation de la base |
|
| 120 | - $taches_generales['optimiser'] = 3600 * 48; |
|
| 119 | + // Optimisation de la base |
|
| 120 | + $taches_generales['optimiser'] = 3600 * 48; |
|
| 121 | 121 | |
| 122 | - // nouveautes |
|
| 123 | - if ( |
|
| 124 | - isset($GLOBALS['meta']['adresse_neuf']) |
|
| 125 | - && $GLOBALS['meta']['adresse_neuf'] |
|
| 126 | - && $GLOBALS['meta']['jours_neuf'] |
|
| 127 | - && $GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 128 | - ) { |
|
| 129 | - $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf']; |
|
| 130 | - } |
|
| 122 | + // nouveautes |
|
| 123 | + if ( |
|
| 124 | + isset($GLOBALS['meta']['adresse_neuf']) |
|
| 125 | + && $GLOBALS['meta']['adresse_neuf'] |
|
| 126 | + && $GLOBALS['meta']['jours_neuf'] |
|
| 127 | + && $GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 128 | + ) { |
|
| 129 | + $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf']; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - // maintenance (ajax, verifications diverses) |
|
| 133 | - $taches_generales['maintenance'] = 3600 * 2; |
|
| 132 | + // maintenance (ajax, verifications diverses) |
|
| 133 | + $taches_generales['maintenance'] = 3600 * 2; |
|
| 134 | 134 | |
| 135 | - // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement) |
|
| 136 | - $taches_generales['mise_a_jour'] = 3 * 24 * 3600; |
|
| 135 | + // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement) |
|
| 136 | + $taches_generales['mise_a_jour'] = 3 * 24 * 3600; |
|
| 137 | 137 | |
| 138 | - return pipeline('taches_generales_cron', $taches_generales); |
|
| 138 | + return pipeline('taches_generales_cron', $taches_generales); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | * @return int |
| 152 | 152 | */ |
| 153 | 153 | function genie_queue_watch_dist() { |
| 154 | - static $deja_la = false; |
|
| 155 | - if ($deja_la) { |
|
| 156 | - return; |
|
| 157 | - } // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple) |
|
| 158 | - $deja_la = true; |
|
| 159 | - $taches = taches_generales(); |
|
| 160 | - $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches))); |
|
| 161 | - $programmees = array_column($programmees, 'fonction'); |
|
| 162 | - foreach ($taches as $tache => $periode) { |
|
| 163 | - if (!in_array($tache, $programmees)) { |
|
| 164 | - queue_genie_replan_job($tache, $periode, time() - round(random_int(1, $periode)), 0); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - $deja_la = false; |
|
| 168 | - |
|
| 169 | - return 1; |
|
| 154 | + static $deja_la = false; |
|
| 155 | + if ($deja_la) { |
|
| 156 | + return; |
|
| 157 | + } // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple) |
|
| 158 | + $deja_la = true; |
|
| 159 | + $taches = taches_generales(); |
|
| 160 | + $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches))); |
|
| 161 | + $programmees = array_column($programmees, 'fonction'); |
|
| 162 | + foreach ($taches as $tache => $periode) { |
|
| 163 | + if (!in_array($tache, $programmees)) { |
|
| 164 | + queue_genie_replan_job($tache, $periode, time() - round(random_int(1, $periode)), 0); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + $deja_la = false; |
|
| 168 | + |
|
| 169 | + return 1; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -187,32 +187,32 @@ discard block |
||
| 187 | 187 | * @return void |
| 188 | 188 | */ |
| 189 | 189 | function queue_genie_replan_job($function, $period, $last = 0, $time = null, $priority = 0) { |
| 190 | - static $done = []; |
|
| 191 | - if (isset($done[$function])) { |
|
| 192 | - return; |
|
| 193 | - } |
|
| 194 | - $done[$function] = true; |
|
| 195 | - if (is_null($time)) { |
|
| 196 | - $time = time(); |
|
| 197 | - if ($last) { |
|
| 198 | - $time = max($last + $period, $time); |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - if (!$last) { |
|
| 202 | - $last = $time - $period; |
|
| 203 | - } |
|
| 204 | - spip_log("replan_job $function $period $last $time $priority", 'queue'); |
|
| 205 | - include_spip('inc/queue'); |
|
| 206 | - // on replanifie un job cron |
|
| 207 | - // uniquement si il n'y en a pas deja un avec le meme nom |
|
| 208 | - // independament de l'argument |
|
| 209 | - queue_add_job( |
|
| 210 | - $function, |
|
| 211 | - _T('tache_cron_secondes', ['function' => $function, 'nb' => $period]), |
|
| 212 | - [$last], |
|
| 213 | - 'genie/', |
|
| 214 | - 'function_only', |
|
| 215 | - $time, |
|
| 216 | - $priority |
|
| 217 | - ); |
|
| 190 | + static $done = []; |
|
| 191 | + if (isset($done[$function])) { |
|
| 192 | + return; |
|
| 193 | + } |
|
| 194 | + $done[$function] = true; |
|
| 195 | + if (is_null($time)) { |
|
| 196 | + $time = time(); |
|
| 197 | + if ($last) { |
|
| 198 | + $time = max($last + $period, $time); |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + if (!$last) { |
|
| 202 | + $last = $time - $period; |
|
| 203 | + } |
|
| 204 | + spip_log("replan_job $function $period $last $time $priority", 'queue'); |
|
| 205 | + include_spip('inc/queue'); |
|
| 206 | + // on replanifie un job cron |
|
| 207 | + // uniquement si il n'y en a pas deja un avec le meme nom |
|
| 208 | + // independament de l'argument |
|
| 209 | + queue_add_job( |
|
| 210 | + $function, |
|
| 211 | + _T('tache_cron_secondes', ['function' => $function, 'nb' => $period]), |
|
| 212 | + [$last], |
|
| 213 | + 'genie/', |
|
| 214 | + 'function_only', |
|
| 215 | + $time, |
|
| 216 | + $priority |
|
| 217 | + ); |
|
| 218 | 218 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | // confirmation du deplacement |
| 117 | 117 | if ( |
| 118 | 118 | sql_table_exists('spip_breves') |
| 119 | - && ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . (int) $id_objet)) |
|
| 119 | + && ($contient_breves = sql_countsel('spip_breves', 'id_rubrique='.(int) $id_objet)) |
|
| 120 | 120 | && $contient_breves > 0 |
| 121 | 121 | ) { |
| 122 | 122 | // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | ); |
| 131 | 131 | $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
| 132 | 132 | . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
| 133 | - . $scb . |
|
| 133 | + . $scb. |
|
| 134 | 134 | "</label></div></div>\n"; |
| 135 | 135 | } else { |
| 136 | 136 | $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $form .= $confirm; |
| 140 | 140 | if ($actionable) { |
| 141 | 141 | if (str_contains($form, '<select')) { |
| 142 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 143 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 142 | + $form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 143 | + . '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 144 | 144 | . '</div>'; |
| 145 | 145 | } |
| 146 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 146 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form; |
|
| 147 | 147 | if ($action = charger_fonction("editer_$objet", 'action', true)) { |
| 148 | 148 | $form = generer_action_auteur( |
| 149 | 149 | "editer_$objet", |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | include_spip('inc/presentation'); |
| 171 | 171 | |
| 172 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 172 | + return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur(); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | if ($statut == 'nouveau') { |
| 246 | 246 | if ($attente) { |
| 247 | 247 | $statut = $attente; |
| 248 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 248 | + $plus = ' ('._T('info_statut_auteur_a_confirmer').')'; |
|
| 249 | 249 | } else { |
| 250 | 250 | return _T('info_statut_auteur_a_confirmer'); |
| 251 | 251 | } |
@@ -258,16 +258,16 @@ discard block |
||
| 258 | 258 | '5poubelle' => _T('texte_statut_poubelle'), // bouh |
| 259 | 259 | ]; |
| 260 | 260 | if (isset($recom[$statut])) { |
| 261 | - return $recom[$statut] . $plus; |
|
| 261 | + return $recom[$statut].$plus; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // retrouver directement par le statut sinon |
| 265 | 265 | if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
| 266 | 266 | if (isset($recom[$t])) { |
| 267 | - return $recom[$t] . $plus; |
|
| 267 | + return $recom[$t].$plus; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - return _T($t) . $plus; |
|
| 270 | + return _T($t).$plus; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // si on a pas reussi a le traduire, retournons la chaine telle quelle |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | if (!$id_rubrique && defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') && _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
| 389 | 389 | $in = (is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
| 390 | - ? ' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']) |
|
| 390 | + ? ' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']) |
|
| 391 | 391 | : ''; |
| 392 | 392 | |
| 393 | 393 | // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
@@ -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 | |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | ); |
| 522 | 522 | |
| 523 | 523 | if ($alertes = array_filter($alertes)) { |
| 524 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 524 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 525 | 525 | implode(' | ', $alertes) |
| 526 | 526 | . '</div></div>'; |
| 527 | 527 | } |
@@ -557,13 +557,13 @@ discard block |
||
| 557 | 557 | */ |
| 558 | 558 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 559 | 559 | $titre = attribut_html($titre); |
| 560 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 560 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>". |
|
| 561 | + http_img_pack('information-16.png', $titre).'</a>'; |
|
| 562 | 562 | |
| 563 | 563 | if (!$titre_lien) { |
| 564 | 564 | return $icone; |
| 565 | 565 | } else { |
| 566 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 566 | + return $icone."\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Filtres |
| 16 | 16 | */ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/filtres_boites'); |
@@ -40,25 +40,25 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function parametres_css_prive() { |
| 42 | 42 | |
| 43 | - $args = []; |
|
| 44 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 45 | - $args['p'] = substr(md5((string) $GLOBALS['meta']['plugin']), 0, 4); |
|
| 46 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 47 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 48 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 49 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 43 | + $args = []; |
|
| 44 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 45 | + $args['p'] = substr(md5((string) $GLOBALS['meta']['plugin']), 0, 4); |
|
| 46 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 47 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 48 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 49 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 50 | 50 | |
| 51 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 51 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | 52 | |
| 53 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 54 | - parse_str((string) $couleurs($c), $c); |
|
| 55 | - $args = array_merge($args, $c); |
|
| 53 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 54 | + parse_str((string) $couleurs($c), $c); |
|
| 55 | + $args = array_merge($args, $c); |
|
| 56 | 56 | |
| 57 | - if (_request('var_mode') == 'recalcul' || defined('_VAR_MODE') && _VAR_MODE == 'recalcul') { |
|
| 58 | - $args['var_mode'] = 'recalcul'; |
|
| 59 | - } |
|
| 57 | + if (_request('var_mode') == 'recalcul' || defined('_VAR_MODE') && _VAR_MODE == 'recalcul') { |
|
| 58 | + $args['var_mode'] = 'recalcul'; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - return http_build_query($args); |
|
| 61 | + return http_build_query($args); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -81,95 +81,95 @@ discard block |
||
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | 83 | function chercher_rubrique( |
| 84 | - $titre, |
|
| 85 | - $id_objet, |
|
| 86 | - $id_parent, |
|
| 87 | - $objet, |
|
| 88 | - $id_secteur, |
|
| 89 | - $restreint, |
|
| 90 | - $actionable = false, |
|
| 91 | - $retour_sans_cadre = false |
|
| 84 | + $titre, |
|
| 85 | + $id_objet, |
|
| 86 | + $id_parent, |
|
| 87 | + $objet, |
|
| 88 | + $id_secteur, |
|
| 89 | + $restreint, |
|
| 90 | + $actionable = false, |
|
| 91 | + $retour_sans_cadre = false |
|
| 92 | 92 | ) { |
| 93 | 93 | |
| 94 | - include_spip('inc/autoriser'); |
|
| 95 | - if ((int) $id_objet && !autoriser('modifier', $objet, $id_objet)) { |
|
| 96 | - return ''; |
|
| 97 | - } |
|
| 98 | - if (!sql_countsel('spip_rubriques')) { |
|
| 99 | - return ''; |
|
| 100 | - } |
|
| 101 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 102 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 103 | - |
|
| 104 | - if ($id_parent == 0) { |
|
| 105 | - $logo = 'racine-24.png'; |
|
| 106 | - } elseif ($id_secteur == $id_parent) { |
|
| 107 | - $logo = 'secteur-24.png'; |
|
| 108 | - } else { |
|
| 109 | - $logo = 'rubrique-24.png'; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $confirm = ''; |
|
| 113 | - if ($objet == 'rubrique') { |
|
| 114 | - // FIXME: Migration plus adapté vers le plugin Brèves ? |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - if ( |
|
| 118 | - sql_table_exists('spip_breves') |
|
| 119 | - && ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . (int) $id_objet)) |
|
| 120 | - && $contient_breves > 0 |
|
| 121 | - ) { |
|
| 122 | - // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
|
| 123 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 124 | - $scb = _T( |
|
| 125 | - 'avis_deplacement_rubrique', |
|
| 126 | - [ |
|
| 127 | - 'contient_breves' => $contient_breves, |
|
| 128 | - 'scb' => $scb |
|
| 129 | - ] |
|
| 130 | - ); |
|
| 131 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 132 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 133 | - . $scb . |
|
| 134 | - "</label></div></div>\n"; |
|
| 135 | - } else { |
|
| 136 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - $form .= $confirm; |
|
| 140 | - if ($actionable) { |
|
| 141 | - if (str_contains($form, '<select')) { |
|
| 142 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 143 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 144 | - . '</div>'; |
|
| 145 | - } |
|
| 146 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 147 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 148 | - $form = generer_action_auteur( |
|
| 149 | - "editer_$objet", |
|
| 150 | - $id_objet, |
|
| 151 | - self(), |
|
| 152 | - $form, |
|
| 153 | - " method='post' class='submit_plongeur'" |
|
| 154 | - ); |
|
| 155 | - } else { |
|
| 156 | - $form = generer_action_auteur( |
|
| 157 | - 'editer_objet', |
|
| 158 | - "$objet/$id_objet", |
|
| 159 | - self(), |
|
| 160 | - $form, |
|
| 161 | - " method='post' class='submit_plongeur'" |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if ($retour_sans_cadre) { |
|
| 167 | - return $form; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - include_spip('inc/presentation'); |
|
| 171 | - |
|
| 172 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 94 | + include_spip('inc/autoriser'); |
|
| 95 | + if ((int) $id_objet && !autoriser('modifier', $objet, $id_objet)) { |
|
| 96 | + return ''; |
|
| 97 | + } |
|
| 98 | + if (!sql_countsel('spip_rubriques')) { |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 102 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 103 | + |
|
| 104 | + if ($id_parent == 0) { |
|
| 105 | + $logo = 'racine-24.png'; |
|
| 106 | + } elseif ($id_secteur == $id_parent) { |
|
| 107 | + $logo = 'secteur-24.png'; |
|
| 108 | + } else { |
|
| 109 | + $logo = 'rubrique-24.png'; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $confirm = ''; |
|
| 113 | + if ($objet == 'rubrique') { |
|
| 114 | + // FIXME: Migration plus adapté vers le plugin Brèves ? |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + if ( |
|
| 118 | + sql_table_exists('spip_breves') |
|
| 119 | + && ($contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . (int) $id_objet)) |
|
| 120 | + && $contient_breves > 0 |
|
| 121 | + ) { |
|
| 122 | + // FIXME: utiliser singulier_ou_pluriel, migrer dans plugin Brèves |
|
| 123 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 124 | + $scb = _T( |
|
| 125 | + 'avis_deplacement_rubrique', |
|
| 126 | + [ |
|
| 127 | + 'contient_breves' => $contient_breves, |
|
| 128 | + 'scb' => $scb |
|
| 129 | + ] |
|
| 130 | + ); |
|
| 131 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 132 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 133 | + . $scb . |
|
| 134 | + "</label></div></div>\n"; |
|
| 135 | + } else { |
|
| 136 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + $form .= $confirm; |
|
| 140 | + if ($actionable) { |
|
| 141 | + if (str_contains($form, '<select')) { |
|
| 142 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 143 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 144 | + . '</div>'; |
|
| 145 | + } |
|
| 146 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 147 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 148 | + $form = generer_action_auteur( |
|
| 149 | + "editer_$objet", |
|
| 150 | + $id_objet, |
|
| 151 | + self(), |
|
| 152 | + $form, |
|
| 153 | + " method='post' class='submit_plongeur'" |
|
| 154 | + ); |
|
| 155 | + } else { |
|
| 156 | + $form = generer_action_auteur( |
|
| 157 | + 'editer_objet', |
|
| 158 | + "$objet/$id_objet", |
|
| 159 | + self(), |
|
| 160 | + $form, |
|
| 161 | + " method='post' class='submit_plongeur'" |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if ($retour_sans_cadre) { |
|
| 167 | + return $form; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + include_spip('inc/presentation'); |
|
| 171 | + |
|
| 172 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | |
@@ -183,24 +183,24 @@ discard block |
||
| 183 | 183 | * @return bool |
| 184 | 184 | */ |
| 185 | 185 | function avoir_visiteurs($past = false, $accepter = true) { |
| 186 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if ($accepter && $GLOBALS['meta']['accepter_visiteurs'] != 'non') { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - if (!$past) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - return sql_countsel( |
|
| 200 | - 'spip_auteurs', |
|
| 201 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 186 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if ($accepter && $GLOBALS['meta']['accepter_visiteurs'] != 'non') { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + if (!$past) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + return sql_countsel( |
|
| 200 | + 'spip_auteurs', |
|
| 201 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 202 | 202 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 203 | - ); |
|
| 203 | + ); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -216,18 +216,18 @@ discard block |
||
| 216 | 216 | * @return array |
| 217 | 217 | */ |
| 218 | 218 | function statuts_articles_visibles($statut_auteur) { |
| 219 | - static $auth = []; |
|
| 220 | - if (!isset($auth[$statut_auteur])) { |
|
| 221 | - $auth[$statut_auteur] = []; |
|
| 222 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 223 | - foreach ($statuts as $s) { |
|
| 224 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 225 | - $auth[$statut_auteur][] = $s; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - return $auth[$statut_auteur]; |
|
| 219 | + static $auth = []; |
|
| 220 | + if (!isset($auth[$statut_auteur])) { |
|
| 221 | + $auth[$statut_auteur] = []; |
|
| 222 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 223 | + foreach ($statuts as $s) { |
|
| 224 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 225 | + $auth[$statut_auteur][] = $s; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + return $auth[$statut_auteur]; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -241,38 +241,38 @@ discard block |
||
| 241 | 241 | * @return string |
| 242 | 242 | */ |
| 243 | 243 | function traduire_statut_auteur($statut, $attente = '') { |
| 244 | - $plus = ''; |
|
| 245 | - if ($statut == 'nouveau') { |
|
| 246 | - if ($attente) { |
|
| 247 | - $statut = $attente; |
|
| 248 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 249 | - } else { |
|
| 250 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $recom = [ |
|
| 255 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 256 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 257 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 258 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 259 | - ]; |
|
| 260 | - if (isset($recom[$statut])) { |
|
| 261 | - return $recom[$statut] . $plus; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - // retrouver directement par le statut sinon |
|
| 265 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 266 | - if (isset($recom[$t])) { |
|
| 267 | - return $recom[$t] . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - return _T($t) . $plus; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 274 | - // c'est toujours plus informatif que rien du tout |
|
| 275 | - return $statut; |
|
| 244 | + $plus = ''; |
|
| 245 | + if ($statut == 'nouveau') { |
|
| 246 | + if ($attente) { |
|
| 247 | + $statut = $attente; |
|
| 248 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 249 | + } else { |
|
| 250 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $recom = [ |
|
| 255 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 256 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 257 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 258 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 259 | + ]; |
|
| 260 | + if (isset($recom[$statut])) { |
|
| 261 | + return $recom[$statut] . $plus; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + // retrouver directement par le statut sinon |
|
| 265 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 266 | + if (isset($recom[$t])) { |
|
| 267 | + return $recom[$t] . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + return _T($t) . $plus; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 274 | + // c'est toujours plus informatif que rien du tout |
|
| 275 | + return $statut; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -283,29 +283,29 @@ discard block |
||
| 283 | 283 | * @return string |
| 284 | 284 | */ |
| 285 | 285 | function afficher_qui_edite($id_objet, $objet): string { |
| 286 | - static $qui = []; |
|
| 287 | - if (isset($qui[$objet][$id_objet])) { |
|
| 288 | - return $qui[$objet][$id_objet]; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - include_spip('inc/config'); |
|
| 292 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 293 | - return $qui[$objet][$id_objet] = ''; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - include_spip('inc/drapeau_edition'); |
|
| 297 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 298 | - if (!$modif) { |
|
| 299 | - return $qui[$objet][$id_objet] = ''; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - include_spip('base/objets'); |
|
| 303 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 304 | - if (isset($infos['texte_signale_edition'])) { |
|
| 305 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 286 | + static $qui = []; |
|
| 287 | + if (isset($qui[$objet][$id_objet])) { |
|
| 288 | + return $qui[$objet][$id_objet]; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + include_spip('inc/config'); |
|
| 292 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 293 | + return $qui[$objet][$id_objet] = ''; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + include_spip('inc/drapeau_edition'); |
|
| 297 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 298 | + if (!$modif) { |
|
| 299 | + return $qui[$objet][$id_objet] = ''; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + include_spip('base/objets'); |
|
| 303 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 304 | + if (isset($infos['texte_signale_edition'])) { |
|
| 305 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -323,53 +323,53 @@ discard block |
||
| 323 | 323 | * @return array |
| 324 | 324 | */ |
| 325 | 325 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 326 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 327 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - switch ($quoi) { |
|
| 331 | - case 'redacteurs': |
|
| 332 | - $statut = AUTEURS_MIN_REDAC; |
|
| 333 | - $statut = explode(',', (string) $statut); |
|
| 334 | - if ($en_base) { |
|
| 335 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 336 | - $retire = array_diff($statut, $check); |
|
| 337 | - $statut = array_diff($statut, $retire); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - return array_unique($statut); |
|
| 341 | - |
|
| 342 | - case 'visiteurs': |
|
| 343 | - $statut = []; |
|
| 344 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 345 | - $exclus = explode(',', (string) $exclus); |
|
| 346 | - if (!$en_base) { |
|
| 347 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 348 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 349 | - } |
|
| 350 | - $s_complement = array_column( |
|
| 351 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 352 | - 'statut' |
|
| 353 | - ); |
|
| 354 | - |
|
| 355 | - return array_unique([...$statut, ...$s_complement]); |
|
| 356 | - |
|
| 357 | - default: |
|
| 358 | - case 'tous': |
|
| 359 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 360 | - $s_complement = array_column( |
|
| 361 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 362 | - 'statut' |
|
| 363 | - ); |
|
| 364 | - $statut = [...$statut, ...$s_complement]; |
|
| 365 | - if ($en_base) { |
|
| 366 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 367 | - $retire = array_diff($statut, $check); |
|
| 368 | - $statut = array_diff($statut, $retire); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - return array_unique($statut); |
|
| 372 | - } |
|
| 326 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 327 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + switch ($quoi) { |
|
| 331 | + case 'redacteurs': |
|
| 332 | + $statut = AUTEURS_MIN_REDAC; |
|
| 333 | + $statut = explode(',', (string) $statut); |
|
| 334 | + if ($en_base) { |
|
| 335 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 336 | + $retire = array_diff($statut, $check); |
|
| 337 | + $statut = array_diff($statut, $retire); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + return array_unique($statut); |
|
| 341 | + |
|
| 342 | + case 'visiteurs': |
|
| 343 | + $statut = []; |
|
| 344 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 345 | + $exclus = explode(',', (string) $exclus); |
|
| 346 | + if (!$en_base) { |
|
| 347 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 348 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 349 | + } |
|
| 350 | + $s_complement = array_column( |
|
| 351 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 352 | + 'statut' |
|
| 353 | + ); |
|
| 354 | + |
|
| 355 | + return array_unique([...$statut, ...$s_complement]); |
|
| 356 | + |
|
| 357 | + default: |
|
| 358 | + case 'tous': |
|
| 359 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 360 | + $s_complement = array_column( |
|
| 361 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 362 | + 'statut' |
|
| 363 | + ); |
|
| 364 | + $statut = [...$statut, ...$s_complement]; |
|
| 365 | + if ($en_base) { |
|
| 366 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 367 | + $retire = array_diff($statut, $check); |
|
| 368 | + $statut = array_diff($statut, $retire); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + return array_unique($statut); |
|
| 372 | + } |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
@@ -385,28 +385,28 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 387 | 387 | |
| 388 | - if (!$id_rubrique && defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') && _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 389 | - $in = (is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 390 | - ? ' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']) |
|
| 391 | - : ''; |
|
| 392 | - |
|
| 393 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 394 | - if ($objet == 'rubrique') { |
|
| 395 | - $id_rubrique = 0; |
|
| 396 | - } else { |
|
| 397 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 401 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 402 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 403 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 404 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - return $id_rubrique; |
|
| 388 | + if (!$id_rubrique && defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') && _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 389 | + $in = (is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 390 | + ? ' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']) |
|
| 391 | + : ''; |
|
| 392 | + |
|
| 393 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 394 | + if ($objet == 'rubrique') { |
|
| 395 | + $id_rubrique = 0; |
|
| 396 | + } else { |
|
| 397 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 401 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 402 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 403 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 404 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + return $id_rubrique; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -417,12 +417,12 @@ discard block |
||
| 417 | 417 | * @return string |
| 418 | 418 | */ |
| 419 | 419 | function lien_article_virtuel($virtuel) { |
| 420 | - include_spip('inc/lien'); |
|
| 421 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 422 | - return ''; |
|
| 423 | - } |
|
| 420 | + include_spip('inc/lien'); |
|
| 421 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 422 | + return ''; |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - return propre('[->' . $virtuel . ']'); |
|
| 425 | + return propre('[->' . $virtuel . ']'); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | * @filtre |
| 446 | 446 | */ |
| 447 | 447 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 448 | - include_spip('inc/acces'); |
|
| 449 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 448 | + include_spip('inc/acces'); |
|
| 449 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 450 | 450 | |
| 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>"; |
|
| 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>"; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | |
@@ -461,72 +461,72 @@ discard block |
||
| 461 | 461 | */ |
| 462 | 462 | function alertes_auteur($id_auteur): string { |
| 463 | 463 | |
| 464 | - $alertes = []; |
|
| 465 | - |
|
| 466 | - if ( |
|
| 467 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 468 | - && autoriser('detruire', null, null, $id_auteur) |
|
| 469 | - ) { |
|
| 470 | - include_spip('genie/maintenance'); |
|
| 471 | - if ($msg = message_crash_tables()) { |
|
| 472 | - $alertes[] = $msg; |
|
| 473 | - } |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - if ( |
|
| 477 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 478 | - && $GLOBALS['meta']['message_crash_plugins'] |
|
| 479 | - && autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 480 | - && is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 481 | - ) { |
|
| 482 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 483 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 487 | - if ($a && is_array($a = unserialize($a)) && count($a)) { |
|
| 488 | - $update = false; |
|
| 489 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 490 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 491 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - $update = true; |
|
| 493 | - } |
|
| 494 | - if (isset($a[''])) { |
|
| 495 | - $alertes = array_merge($alertes, $a['']); |
|
| 496 | - unset($a['']); |
|
| 497 | - $update = true; |
|
| 498 | - } |
|
| 499 | - if ($update) { |
|
| 500 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - if ( |
|
| 505 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 506 | - && autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 507 | - ) { |
|
| 508 | - include_spip('inc/plugin'); |
|
| 509 | - $alertes[] = plugin_donne_erreurs(); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - $alertes = pipeline( |
|
| 513 | - 'alertes_auteur', |
|
| 514 | - [ |
|
| 515 | - 'args' => [ |
|
| 516 | - 'id_auteur' => $id_auteur, |
|
| 517 | - 'exec' => _request('exec'), |
|
| 518 | - ], |
|
| 519 | - 'data' => $alertes |
|
| 520 | - ] |
|
| 521 | - ); |
|
| 522 | - |
|
| 523 | - if ($alertes = array_filter($alertes)) { |
|
| 524 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 525 | - implode(' | ', $alertes) |
|
| 526 | - . '</div></div>'; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return ''; |
|
| 464 | + $alertes = []; |
|
| 465 | + |
|
| 466 | + if ( |
|
| 467 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 468 | + && autoriser('detruire', null, null, $id_auteur) |
|
| 469 | + ) { |
|
| 470 | + include_spip('genie/maintenance'); |
|
| 471 | + if ($msg = message_crash_tables()) { |
|
| 472 | + $alertes[] = $msg; |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + if ( |
|
| 477 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 478 | + && $GLOBALS['meta']['message_crash_plugins'] |
|
| 479 | + && autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 480 | + && is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 481 | + ) { |
|
| 482 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 483 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 487 | + if ($a && is_array($a = unserialize($a)) && count($a)) { |
|
| 488 | + $update = false; |
|
| 489 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 490 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 491 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + $update = true; |
|
| 493 | + } |
|
| 494 | + if (isset($a[''])) { |
|
| 495 | + $alertes = array_merge($alertes, $a['']); |
|
| 496 | + unset($a['']); |
|
| 497 | + $update = true; |
|
| 498 | + } |
|
| 499 | + if ($update) { |
|
| 500 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + if ( |
|
| 505 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 506 | + && autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 507 | + ) { |
|
| 508 | + include_spip('inc/plugin'); |
|
| 509 | + $alertes[] = plugin_donne_erreurs(); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + $alertes = pipeline( |
|
| 513 | + 'alertes_auteur', |
|
| 514 | + [ |
|
| 515 | + 'args' => [ |
|
| 516 | + 'id_auteur' => $id_auteur, |
|
| 517 | + 'exec' => _request('exec'), |
|
| 518 | + ], |
|
| 519 | + 'data' => $alertes |
|
| 520 | + ] |
|
| 521 | + ); |
|
| 522 | + |
|
| 523 | + if ($alertes = array_filter($alertes)) { |
|
| 524 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 525 | + implode(' | ', $alertes) |
|
| 526 | + . '</div></div>'; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return ''; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -536,9 +536,9 @@ discard block |
||
| 536 | 536 | * @return string |
| 537 | 537 | */ |
| 538 | 538 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 539 | - include_spip('inc/presenter_enfants'); |
|
| 539 | + include_spip('inc/presenter_enfants'); |
|
| 540 | 540 | |
| 541 | - return afficher_enfant_rub((int) $id_rubrique); |
|
| 541 | + return afficher_enfant_rub((int) $id_rubrique); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -556,15 +556,15 @@ discard block |
||
| 556 | 556 | * @return string |
| 557 | 557 | */ |
| 558 | 558 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 559 | - $titre = attribut_html($titre); |
|
| 560 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | - |
|
| 563 | - if (!$titre_lien) { |
|
| 564 | - return $icone; |
|
| 565 | - } else { |
|
| 566 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | - } |
|
| 559 | + $titre = attribut_html($titre); |
|
| 560 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 561 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 562 | + |
|
| 563 | + if (!$titre_lien) { |
|
| 564 | + return $icone; |
|
| 565 | + } else { |
|
| 566 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 567 | + } |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | |
@@ -583,20 +583,20 @@ discard block |
||
| 583 | 583 | * @return array |
| 584 | 584 | */ |
| 585 | 585 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 586 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 587 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 588 | - return []; |
|
| 589 | - } |
|
| 590 | - $r = reset($res); |
|
| 591 | - $colonne_id = ($objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet'); |
|
| 592 | - if (isset($r['rang_lien'])) { |
|
| 593 | - $l = array_column($res, 'rang_lien', $colonne_id); |
|
| 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($res, $colonne_id); |
|
| 600 | - } |
|
| 601 | - return $l; |
|
| 586 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 587 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 588 | + return []; |
|
| 589 | + } |
|
| 590 | + $r = reset($res); |
|
| 591 | + $colonne_id = ($objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet'); |
|
| 592 | + if (isset($r['rang_lien'])) { |
|
| 593 | + $l = array_column($res, 'rang_lien', $colonne_id); |
|
| 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($res, $colonne_id); |
|
| 600 | + } |
|
| 601 | + return $l; |
|
| 602 | 602 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | 29 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 30 | - return; |
|
| 30 | + return; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -47,55 +47,55 @@ discard block |
||
| 47 | 47 | * array : description des roles applicables dans 3 index : colonne, titres, roles |
| 48 | 48 | **/ |
| 49 | 49 | function roles_presents($objet, $objet_destination = '') { |
| 50 | - $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 51 | - |
|
| 52 | - // pas de liste de roles, on sort |
|
| 53 | - if (!isset($desc['roles_titres']) || !($titres = $desc['roles_titres'])) { |
|
| 54 | - return false; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // on vérifie que la table de liaison existe |
|
| 58 | - include_spip('action/editer_liens'); |
|
| 59 | - if (!$lien = objet_associable($objet)) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 64 | - $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 65 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 66 | - [, $table_lien] = $lien; |
|
| 67 | - $desc_lien = $trouver_table($table_lien); |
|
| 68 | - if (!isset($desc_lien['field'][$colonne])) { |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // sur quoi peuvent s'appliquer nos rôles |
|
| 73 | - if (!$application = $desc['roles_objets']) { |
|
| 74 | - return false; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // destination presente, on restreint si possible |
|
| 78 | - if ($objet_destination) { |
|
| 79 | - $objet_destination = table_objet($objet_destination); |
|
| 80 | - |
|
| 81 | - // pour l'objet |
|
| 82 | - if (isset($application[$objet_destination])) { |
|
| 83 | - $application = $application[$objet_destination]; |
|
| 84 | - // sinon pour tous les objets |
|
| 85 | - } elseif (isset($application['*'])) { |
|
| 86 | - $application = $application['*']; |
|
| 87 | - } // sinon tant pis |
|
| 88 | - else { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // tout est ok |
|
| 94 | - return [ |
|
| 95 | - 'titres' => $titres, |
|
| 96 | - 'roles' => $application, |
|
| 97 | - 'colonne' => $colonne |
|
| 98 | - ]; |
|
| 50 | + $desc = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 51 | + |
|
| 52 | + // pas de liste de roles, on sort |
|
| 53 | + if (!isset($desc['roles_titres']) || !($titres = $desc['roles_titres'])) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // on vérifie que la table de liaison existe |
|
| 58 | + include_spip('action/editer_liens'); |
|
| 59 | + if (!$lien = objet_associable($objet)) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role') |
|
| 64 | + $colonne = $desc['roles_colonne'] ?? 'role'; |
|
| 65 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 66 | + [, $table_lien] = $lien; |
|
| 67 | + $desc_lien = $trouver_table($table_lien); |
|
| 68 | + if (!isset($desc_lien['field'][$colonne])) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // sur quoi peuvent s'appliquer nos rôles |
|
| 73 | + if (!$application = $desc['roles_objets']) { |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // destination presente, on restreint si possible |
|
| 78 | + if ($objet_destination) { |
|
| 79 | + $objet_destination = table_objet($objet_destination); |
|
| 80 | + |
|
| 81 | + // pour l'objet |
|
| 82 | + if (isset($application[$objet_destination])) { |
|
| 83 | + $application = $application[$objet_destination]; |
|
| 84 | + // sinon pour tous les objets |
|
| 85 | + } elseif (isset($application['*'])) { |
|
| 86 | + $application = $application['*']; |
|
| 87 | + } // sinon tant pis |
|
| 88 | + else { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // tout est ok |
|
| 94 | + return [ |
|
| 95 | + 'titres' => $titres, |
|
| 96 | + 'roles' => $application, |
|
| 97 | + 'colonne' => $colonne |
|
| 98 | + ]; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | * Nom de la colonne, sinon vide |
| 110 | 110 | **/ |
| 111 | 111 | function roles_colonne($objet, $objet_destination) { |
| 112 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 113 | - return $roles['colonne']; |
|
| 114 | - } |
|
| 112 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 113 | + return $roles['colonne']; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - return ''; |
|
| 116 | + return ''; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | * Liste ('', '', array()) sinon. |
| 136 | 136 | **/ |
| 137 | 137 | function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) { |
| 138 | - // si des rôles sont possibles, on les utilise |
|
| 139 | - $role = $colonne_role = ''; # role défini |
|
| 140 | - // condition du where par defaut |
|
| 141 | - $cond = []; |
|
| 142 | - if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 143 | - $colonne_role = $roles['colonne']; |
|
| 144 | - // qu'il n'est pas défini |
|
| 145 | - if (!isset($qualif[$colonne_role]) || !($role = $qualif[$colonne_role])) { |
|
| 146 | - $role = $roles['roles']['defaut']; |
|
| 147 | - } |
|
| 148 | - // where |
|
| 149 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return [$role, $colonne_role, $cond]; |
|
| 138 | + // si des rôles sont possibles, on les utilise |
|
| 139 | + $role = $colonne_role = ''; # role défini |
|
| 140 | + // condition du where par defaut |
|
| 141 | + $cond = []; |
|
| 142 | + if ($roles = roles_presents($objet, $objet_destination)) { |
|
| 143 | + $colonne_role = $roles['colonne']; |
|
| 144 | + // qu'il n'est pas défini |
|
| 145 | + if (!isset($qualif[$colonne_role]) || !($role = $qualif[$colonne_role])) { |
|
| 146 | + $role = $roles['roles']['defaut']; |
|
| 147 | + } |
|
| 148 | + // where |
|
| 149 | + $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return [$role, $colonne_role, $cond]; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -171,18 +171,18 @@ discard block |
||
| 171 | 171 | * Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé) |
| 172 | 172 | **/ |
| 173 | 173 | function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) { |
| 174 | - // role par défaut, colonne |
|
| 175 | - [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 176 | - |
|
| 177 | - // chercher d'eventuels rôles transmis |
|
| 178 | - $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 179 | - unset($cond['role']); // cette condition est particuliere... |
|
| 180 | - // on ajoute la condition du role aux autres conditions. |
|
| 181 | - if ($colonne_role && $role != '*') { |
|
| 182 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - return [$cond, $colonne_role, $role]; |
|
| 174 | + // role par défaut, colonne |
|
| 175 | + [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet); |
|
| 176 | + |
|
| 177 | + // chercher d'eventuels rôles transmis |
|
| 178 | + $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut)); |
|
| 179 | + unset($cond['role']); // cette condition est particuliere... |
|
| 180 | + // on ajoute la condition du role aux autres conditions. |
|
| 181 | + if ($colonne_role && $role != '*') { |
|
| 182 | + $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + return [$cond, $colonne_role, $role]; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -204,28 +204,28 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | function roles_complets($objet_source, $objet, $id_objet, $objet_lien) { |
| 206 | 206 | |
| 207 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 208 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 209 | - if ($presents === false) { |
|
| 210 | - return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - // types de roles possibles |
|
| 214 | - $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 215 | - // couples id / roles |
|
| 216 | - $ids = $presents['ids']; |
|
| 217 | - |
|
| 218 | - // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 219 | - // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 220 | - // n'est pas complet |
|
| 221 | - $complets = []; |
|
| 222 | - foreach ($ids as $id => $roles_presents) { |
|
| 223 | - if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 224 | - $complets[] = $id; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return $complets; |
|
| 207 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 208 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 209 | + if ($presents === false) { |
|
| 210 | + return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + // types de roles possibles |
|
| 214 | + $roles_possibles = $presents['roles']['roles']['choix']; |
|
| 215 | + // couples id / roles |
|
| 216 | + $ids = $presents['ids']; |
|
| 217 | + |
|
| 218 | + // pour chaque groupe, on fait le diff entre tous les roles possibles |
|
| 219 | + // et les roles attribués à l'élément : s'il en reste, c'est que l'élément |
|
| 220 | + // n'est pas complet |
|
| 221 | + $complets = []; |
|
| 222 | + foreach ($ids as $id => $roles_presents) { |
|
| 223 | + if (!array_diff($roles_possibles, $roles_presents)) { |
|
| 224 | + $complets[] = $id; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return $complets; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) { |
| 244 | 244 | |
| 245 | - $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 246 | - // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 247 | - if ($presents === false) { |
|
| 248 | - return []; |
|
| 249 | - } |
|
| 245 | + $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien); |
|
| 246 | + // pas de roles sur ces objets => la liste par defaut, comme sans role |
|
| 247 | + if ($presents === false) { |
|
| 248 | + return []; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - if (!isset($presents['ids'][$id_objet_source])) { |
|
| 252 | - return []; |
|
| 253 | - } |
|
| 251 | + if (!isset($presents['ids'][$id_objet_source])) { |
|
| 252 | + return []; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - return $presents['ids'][$id_objet_source]; |
|
| 255 | + return $presents['ids'][$id_objet_source]; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
@@ -280,47 +280,47 @@ discard block |
||
| 280 | 280 | * - False si pas de role déclarés |
| 281 | 281 | */ |
| 282 | 282 | function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) { |
| 283 | - static $done = []; |
|
| 284 | - |
|
| 285 | - // stocker le résultat |
|
| 286 | - $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 287 | - if (isset($done[$hash])) { |
|
| 288 | - return $done[$hash]; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // pas de roles sur ces objets, on sort |
|
| 292 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 293 | - if (!$roles) { |
|
| 294 | - return $done[$hash] = false; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // inspiré de lister_objets_lies() |
|
| 298 | - if ($objet_lien == $objet) { |
|
| 299 | - $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 300 | - } else { |
|
| 301 | - $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // types de roles possibles |
|
| 305 | - $roles_possibles = $roles['roles']['choix']; |
|
| 306 | - // colonne du role |
|
| 307 | - $colonne = $roles['colonne']; |
|
| 308 | - |
|
| 309 | - // on recupere par id, et role existant |
|
| 310 | - $ids = []; |
|
| 311 | - while ($row = array_shift($res)) { |
|
| 312 | - $id = $row[$objet_source]; |
|
| 313 | - if (!isset($ids[$id])) { |
|
| 314 | - $ids[$id] = []; |
|
| 315 | - } |
|
| 316 | - // tableau des roles présents |
|
| 317 | - $ids[$id][] = $row[$colonne]; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - return $done[$hash] = [ |
|
| 321 | - 'roles' => $roles, |
|
| 322 | - 'ids' => $ids |
|
| 323 | - ]; |
|
| 283 | + static $done = []; |
|
| 284 | + |
|
| 285 | + // stocker le résultat |
|
| 286 | + $hash = "$objet_source-$objet-$id_objet-$objet_lien"; |
|
| 287 | + if (isset($done[$hash])) { |
|
| 288 | + return $done[$hash]; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // pas de roles sur ces objets, on sort |
|
| 292 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 293 | + if (!$roles) { |
|
| 294 | + return $done[$hash] = false; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // inspiré de lister_objets_lies() |
|
| 298 | + if ($objet_lien == $objet) { |
|
| 299 | + $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']); |
|
| 300 | + } else { |
|
| 301 | + $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // types de roles possibles |
|
| 305 | + $roles_possibles = $roles['roles']['choix']; |
|
| 306 | + // colonne du role |
|
| 307 | + $colonne = $roles['colonne']; |
|
| 308 | + |
|
| 309 | + // on recupere par id, et role existant |
|
| 310 | + $ids = []; |
|
| 311 | + while ($row = array_shift($res)) { |
|
| 312 | + $id = $row[$objet_source]; |
|
| 313 | + if (!isset($ids[$id])) { |
|
| 314 | + $ids[$id] = []; |
|
| 315 | + } |
|
| 316 | + // tableau des roles présents |
|
| 317 | + $ids[$id][] = $row[$colonne]; |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + return $done[$hash] = [ |
|
| 321 | + 'roles' => $roles, |
|
| 322 | + 'ids' => $ids |
|
| 323 | + ]; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -338,33 +338,33 @@ discard block |
||
| 338 | 338 | * - false si pas de role déclarés |
| 339 | 339 | */ |
| 340 | 340 | function roles_connus_en_base($objet_source, $objet, $objet_lien) { |
| 341 | - static $done = []; |
|
| 342 | - |
|
| 343 | - // stocker le résultat |
|
| 344 | - $hash = "$objet_source-$objet-$objet_lien"; |
|
| 345 | - if (isset($done[$hash])) { |
|
| 346 | - return $done[$hash]; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - if (!$lien = objet_associable($objet_lien)) { |
|
| 350 | - return $done[$hash] = false; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - // pas de roles sur ces objets, on sort |
|
| 354 | - $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 355 | - if (!$roles) { |
|
| 356 | - return $done[$hash] = false; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - [$primary, $l] = $lien; |
|
| 360 | - $colone_role = $roles['colonne']; |
|
| 361 | - |
|
| 362 | - $all = sql_allfetsel( |
|
| 363 | - "DISTINCT $colone_role", |
|
| 364 | - $l, |
|
| 365 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 366 | - ); |
|
| 367 | - $done[$hash] = array_map('reset', $all); |
|
| 368 | - |
|
| 369 | - return $done[$hash]; |
|
| 341 | + static $done = []; |
|
| 342 | + |
|
| 343 | + // stocker le résultat |
|
| 344 | + $hash = "$objet_source-$objet-$objet_lien"; |
|
| 345 | + if (isset($done[$hash])) { |
|
| 346 | + return $done[$hash]; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + if (!$lien = objet_associable($objet_lien)) { |
|
| 350 | + return $done[$hash] = false; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // pas de roles sur ces objets, on sort |
|
| 354 | + $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet); |
|
| 355 | + if (!$roles) { |
|
| 356 | + return $done[$hash] = false; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + [$primary, $l] = $lien; |
|
| 360 | + $colone_role = $roles['colonne']; |
|
| 361 | + |
|
| 362 | + $all = sql_allfetsel( |
|
| 363 | + "DISTINCT $colone_role", |
|
| 364 | + $l, |
|
| 365 | + 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 366 | + ); |
|
| 367 | + $done[$hash] = array_map('reset', $all); |
|
| 368 | + |
|
| 369 | + return $done[$hash]; |
|
| 370 | 370 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $role = $roles['roles']['defaut']; |
| 147 | 147 | } |
| 148 | 148 | // where |
| 149 | - $cond = ["$colonne_role=" . sql_quote($role)]; |
|
| 149 | + $cond = ["$colonne_role=".sql_quote($role)]; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return [$role, $colonne_role, $cond]; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | unset($cond['role']); // cette condition est particuliere... |
| 180 | 180 | // on ajoute la condition du role aux autres conditions. |
| 181 | 181 | if ($colonne_role && $role != '*') { |
| 182 | - $cond[] = "$colonne_role=" . sql_quote($role); |
|
| 182 | + $cond[] = "$colonne_role=".sql_quote($role); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return [$cond, $colonne_role, $role]; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | $all = sql_allfetsel( |
| 363 | 363 | "DISTINCT $colone_role", |
| 364 | 364 | $l, |
| 365 | - 'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 365 | + 'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source) |
|
| 366 | 366 | ); |
| 367 | 367 | $done[$hash] = array_map('reset', $all); |
| 368 | 368 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | static $t1 = ['&', '<', '>']; |
| 120 | 120 | static $t2 = ['&', '<', '>']; |
| 121 | 121 | |
| 122 | - return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 122 | + return '<pre>'.str_replace($t1, $t2, (string) $t).'</pre>'; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | foreach ($lignes as &$l) { |
| 140 | 140 | $l = implode('|', $l); |
| 141 | 141 | } |
| 142 | - $corps = implode("\n", $lignes) . "\n"; |
|
| 143 | - $corps = $caption . |
|
| 144 | - "\n|{{" . |
|
| 145 | - implode('}}|{{', $entete) . |
|
| 146 | - '}}|' . |
|
| 147 | - "\n|" . |
|
| 142 | + $corps = implode("\n", $lignes)."\n"; |
|
| 143 | + $corps = $caption. |
|
| 144 | + "\n|{{". |
|
| 145 | + implode('}}|{{', $entete). |
|
| 146 | + '}}|'. |
|
| 147 | + "\n|". |
|
| 148 | 148 | str_replace("\n", "|\n|", $corps); |
| 149 | 149 | include_spip('inc/texte'); |
| 150 | 150 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
| 189 | 189 | $t = safehtml(preg_replace(',<script.*?</script>,is', '', $t)); |
| 190 | 190 | |
| 191 | - return ($style ? "\n<style>" . $style . '</style>' : '') . $t; |
|
| 191 | + return ($style ? "\n<style>".$style.'</style>' : '').$t; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | **/ |
| 22 | 22 | |
| 23 | 23 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 24 | - return; |
|
| 24 | + return; |
|
| 25 | 25 | } |
| 26 | 26 | include_spip('inc/filtres'); |
| 27 | 27 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @return string Rien. |
| 39 | 39 | **/ |
| 40 | 40 | function filtre_image_dist($t) { |
| 41 | - return ''; |
|
| 41 | + return ''; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @return string Rien. |
| 52 | 52 | **/ |
| 53 | 53 | function filtre_audio_dist($t) { |
| 54 | - return ''; |
|
| 54 | + return ''; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @return string Rien. |
| 65 | 65 | **/ |
| 66 | 66 | function filtre_video_dist($t) { |
| 67 | - return ''; |
|
| 67 | + return ''; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @return string Rien. |
| 78 | 78 | **/ |
| 79 | 79 | function filtre_application_dist($t) { |
| 80 | - return ''; |
|
| 80 | + return ''; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return string Rien. |
| 91 | 91 | **/ |
| 92 | 92 | function filtre_message_dist($t) { |
| 93 | - return ''; |
|
| 93 | + return ''; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @return string Rien. |
| 104 | 104 | **/ |
| 105 | 105 | function filtre_multipart_dist($t) { |
| 106 | - return ''; |
|
| 106 | + return ''; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | * @return string Contenu échappé. |
| 117 | 117 | **/ |
| 118 | 118 | function filtre_text_dist($t) { |
| 119 | - static $t1 = ['&', '<', '>']; |
|
| 120 | - static $t2 = ['&', '<', '>']; |
|
| 119 | + static $t1 = ['&', '<', '>']; |
|
| 120 | + static $t2 = ['&', '<', '>']; |
|
| 121 | 121 | |
| 122 | - return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 122 | + return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>'; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -134,21 +134,21 @@ discard block |
||
| 134 | 134 | * Tableau (formaté en SPIP) |
| 135 | 135 | **/ |
| 136 | 136 | function filtre_text_csv_dist($t) { |
| 137 | - include_spip('inc/csv'); |
|
| 138 | - [$entete, $lignes, $caption] = analyse_csv($t); |
|
| 139 | - foreach ($lignes as &$l) { |
|
| 140 | - $l = implode('|', $l); |
|
| 141 | - } |
|
| 142 | - $corps = implode("\n", $lignes) . "\n"; |
|
| 143 | - $corps = $caption . |
|
| 144 | - "\n|{{" . |
|
| 145 | - implode('}}|{{', $entete) . |
|
| 146 | - '}}|' . |
|
| 147 | - "\n|" . |
|
| 148 | - str_replace("\n", "|\n|", $corps); |
|
| 149 | - include_spip('inc/texte'); |
|
| 150 | - |
|
| 151 | - return propre($corps); |
|
| 137 | + include_spip('inc/csv'); |
|
| 138 | + [$entete, $lignes, $caption] = analyse_csv($t); |
|
| 139 | + foreach ($lignes as &$l) { |
|
| 140 | + $l = implode('|', $l); |
|
| 141 | + } |
|
| 142 | + $corps = implode("\n", $lignes) . "\n"; |
|
| 143 | + $corps = $caption . |
|
| 144 | + "\n|{{" . |
|
| 145 | + implode('}}|{{', $entete) . |
|
| 146 | + '}}|' . |
|
| 147 | + "\n|" . |
|
| 148 | + str_replace("\n", "|\n|", $corps); |
|
| 149 | + include_spip('inc/texte'); |
|
| 150 | + |
|
| 151 | + return propre($corps); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -162,33 +162,33 @@ discard block |
||
| 162 | 162 | * @return string Code html sécurisé ou texte échappé |
| 163 | 163 | **/ |
| 164 | 164 | function filtre_text_html_dist($t) { |
| 165 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 166 | - return appliquer_filtre($t, 'text/plain'); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - [, $h, $t] = $r; |
|
| 170 | - |
|
| 171 | - $style = ''; |
|
| 172 | - // recuperer les styles internes |
|
| 173 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 174 | - $style = implode("\n", $r[1]); |
|
| 175 | - } |
|
| 176 | - // ... et externes |
|
| 177 | - |
|
| 178 | - include_spip('inc/distant'); |
|
| 179 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 180 | - foreach ($r[0] as $l) { |
|
| 181 | - preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 182 | - $page = recuperer_url($m[1]); |
|
| 183 | - $page = $page['page'] ?? ''; |
|
| 184 | - $style .= "\n/* $l */\n" |
|
| 185 | - . str_replace('<', '', (string) $page); |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 189 | - $t = safehtml(preg_replace(',<script.*?</script>,is', '', $t)); |
|
| 190 | - |
|
| 191 | - return ($style ? "\n<style>" . $style . '</style>' : '') . $t; |
|
| 165 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 166 | + return appliquer_filtre($t, 'text/plain'); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + [, $h, $t] = $r; |
|
| 170 | + |
|
| 171 | + $style = ''; |
|
| 172 | + // recuperer les styles internes |
|
| 173 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 174 | + $style = implode("\n", $r[1]); |
|
| 175 | + } |
|
| 176 | + // ... et externes |
|
| 177 | + |
|
| 178 | + include_spip('inc/distant'); |
|
| 179 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 180 | + foreach ($r[0] as $l) { |
|
| 181 | + preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 182 | + $page = recuperer_url($m[1]); |
|
| 183 | + $page = $page['page'] ?? ''; |
|
| 184 | + $style .= "\n/* $l */\n" |
|
| 185 | + . str_replace('<', '', (string) $page); |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 189 | + $t = safehtml(preg_replace(',<script.*?</script>,is', '', $t)); |
|
| 190 | + |
|
| 191 | + return ($style ? "\n<style>" . $style . '</style>' : '') . $t; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return string Code HTML des balises `<param>` |
| 202 | 202 | **/ |
| 203 | 203 | function filtre_audio_x_pn_realaudio($id) { |
| 204 | - return " |
|
| 204 | + return " |
|
| 205 | 205 | <param name='controls' value='PositionSlider' /> |
| 206 | 206 | <param name='controls' value='ImageWindow' /> |
| 207 | 207 | <param name='controls' value='PlayButton' /> |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | include_spip('inc/filtres'); |
| 22 | 22 | include_spip('inc/lang'); |
@@ -38,21 +38,21 @@ discard block |
||
| 38 | 38 | **/ |
| 39 | 39 | function definir_puce() { |
| 40 | 40 | |
| 41 | - // Attention au sens, qui n'est pas defini de la meme facon dans |
|
| 42 | - // l'espace prive (spip_lang est la langue de l'interface, lang_dir |
|
| 43 | - // celle du texte) et public (spip_lang est la langue du texte) |
|
| 44 | - $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
|
| 41 | + // Attention au sens, qui n'est pas defini de la meme facon dans |
|
| 42 | + // l'espace prive (spip_lang est la langue de l'interface, lang_dir |
|
| 43 | + // celle du texte) et public (spip_lang est la langue du texte) |
|
| 44 | + $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
|
| 45 | 45 | |
| 46 | - $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 47 | - if ($dir == 'rtl') { |
|
| 48 | - $p .= '_rtl'; |
|
| 49 | - } |
|
| 46 | + $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 47 | + if ($dir == 'rtl') { |
|
| 48 | + $p .= '_rtl'; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if (!isset($GLOBALS[$p])) { |
|
| 52 | - $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 53 | - } |
|
| 51 | + if (!isset($GLOBALS[$p])) { |
|
| 52 | + $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $GLOBALS[$p]; |
|
| 55 | + return $GLOBALS[$p]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -66,31 +66,31 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | function spip_balisage_code(string $corps, bool $bloc = false, string $attributs = '', string $langage = '') { |
| 68 | 68 | |
| 69 | - $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
|
| 70 | - $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 71 | - if ($attributs) { |
|
| 72 | - $attributs = ' ' . trim($attributs); |
|
| 73 | - } |
|
| 74 | - if ($langage) { |
|
| 75 | - $class .= " language-$langage"; |
|
| 76 | - $attributs .= ' data-language="' . $langage . '"'; |
|
| 77 | - } |
|
| 78 | - if ($bloc) { |
|
| 79 | - $html = '<div class="precode">' |
|
| 80 | - . "<pre class=\"$class\" dir=\"ltr\" style=\"text-align: left;\"$attributs>" |
|
| 81 | - . '<code>' |
|
| 82 | - . $echap |
|
| 83 | - . '</code>' |
|
| 84 | - . '</pre>' |
|
| 85 | - . '</div>'; |
|
| 86 | - } |
|
| 87 | - else { |
|
| 88 | - $echap = str_replace("\t", ' ', $echap); |
|
| 89 | - $echap = str_replace(' ', ' ', $echap); |
|
| 90 | - $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return $html; |
|
| 69 | + $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
|
| 70 | + $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 71 | + if ($attributs) { |
|
| 72 | + $attributs = ' ' . trim($attributs); |
|
| 73 | + } |
|
| 74 | + if ($langage) { |
|
| 75 | + $class .= " language-$langage"; |
|
| 76 | + $attributs .= ' data-language="' . $langage . '"'; |
|
| 77 | + } |
|
| 78 | + if ($bloc) { |
|
| 79 | + $html = '<div class="precode">' |
|
| 80 | + . "<pre class=\"$class\" dir=\"ltr\" style=\"text-align: left;\"$attributs>" |
|
| 81 | + . '<code>' |
|
| 82 | + . $echap |
|
| 83 | + . '</code>' |
|
| 84 | + . '</pre>' |
|
| 85 | + . '</div>'; |
|
| 86 | + } |
|
| 87 | + else { |
|
| 88 | + $echap = str_replace("\t", ' ', $echap); |
|
| 89 | + $echap = str_replace(' ', ' ', $echap); |
|
| 90 | + $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + return $html; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | // dont on souhaite qu'ils provoquent un saut de paragraphe |
| 99 | 99 | |
| 100 | 100 | if (!defined('_BALISES_BLOCS')) { |
| 101 | - define( |
|
| 102 | - '_BALISES_BLOCS', |
|
| 103 | - 'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style' |
|
| 104 | - ); |
|
| 101 | + define( |
|
| 102 | + '_BALISES_BLOCS', |
|
| 103 | + 'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style' |
|
| 104 | + ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (!defined('_BALISES_BLOCS_REGEXP')) { |
| 108 | - define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS'); |
|
| 108 | + define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // |
@@ -116,100 +116,100 @@ discard block |
||
| 116 | 116 | // une $source differente ; le script detecte automagiquement si ce qu'on |
| 117 | 117 | // echappe est un div ou un span |
| 118 | 118 | function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) { |
| 119 | - if (!strlen($rempl)) { |
|
| 120 | - return ''; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Tester si on echappe en span ou en div |
|
| 124 | - if (is_null($mode) or !in_array($mode, ['div', 'span'])) { |
|
| 125 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span'; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // Decouper en morceaux, base64 a des probleme selon la taille de la pile |
|
| 129 | - $taille = 30000; |
|
| 130 | - $return = ''; |
|
| 131 | - for ($i = 0; $i < strlen($rempl); $i += $taille) { |
|
| 132 | - // Convertir en base64 et cacher dans un attribut |
|
| 133 | - // utiliser les " pour eviter le re-encodage de ' et ’ |
|
| 134 | - $base64 = base64_encode(substr($rempl, $i, $taille)); |
|
| 135 | - $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>"; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - return $return; |
|
| 119 | + if (!strlen($rempl)) { |
|
| 120 | + return ''; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Tester si on echappe en span ou en div |
|
| 124 | + if (is_null($mode) or !in_array($mode, ['div', 'span'])) { |
|
| 125 | + $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span'; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // Decouper en morceaux, base64 a des probleme selon la taille de la pile |
|
| 129 | + $taille = 30000; |
|
| 130 | + $return = ''; |
|
| 131 | + for ($i = 0; $i < strlen($rempl); $i += $taille) { |
|
| 132 | + // Convertir en base64 et cacher dans un attribut |
|
| 133 | + // utiliser les " pour eviter le re-encodage de ' et ’ |
|
| 134 | + $base64 = base64_encode(substr($rempl, $i, $taille)); |
|
| 135 | + $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>"; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $return; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | // Echapper les <html>...</ html> |
| 143 | 143 | function traiter_echap_html_dist($regs, $options = []) { |
| 144 | - return $regs[3]; |
|
| 144 | + return $regs[3]; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Echapper les <pre>...</ pre> |
| 148 | 148 | function traiter_echap_pre_dist($regs, $options = []) { |
| 149 | - // echapper les <code> dans <pre> |
|
| 150 | - $pre = $regs[3]; |
|
| 151 | - |
|
| 152 | - // echapper les < dans <code> |
|
| 153 | - // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code> |
|
| 154 | - if ( |
|
| 155 | - strpos($pre, '<') !== false |
|
| 156 | - and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER) |
|
| 157 | - ) { |
|
| 158 | - foreach ($matches as $m) { |
|
| 159 | - if ($m[1] === 'code') { |
|
| 160 | - $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>'; |
|
| 161 | - $pre = str_replace($m[0], $code, $pre); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - return "<pre>$pre</pre>"; |
|
| 149 | + // echapper les <code> dans <pre> |
|
| 150 | + $pre = $regs[3]; |
|
| 151 | + |
|
| 152 | + // echapper les < dans <code> |
|
| 153 | + // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code> |
|
| 154 | + if ( |
|
| 155 | + strpos($pre, '<') !== false |
|
| 156 | + and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER) |
|
| 157 | + ) { |
|
| 158 | + foreach ($matches as $m) { |
|
| 159 | + if ($m[1] === 'code') { |
|
| 160 | + $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>'; |
|
| 161 | + $pre = str_replace($m[0], $code, $pre); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + return "<pre>$pre</pre>"; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Echapper les <code>...</ code> |
| 169 | 169 | function traiter_echap_code_dist($regs, $options = []) { |
| 170 | - [, , $att, $corps] = $regs; |
|
| 170 | + [, , $att, $corps] = $regs; |
|
| 171 | 171 | |
| 172 | - // ne pas mettre le <div...> s'il n'y a qu'une ligne |
|
| 173 | - if (strpos($corps, "\n") !== false) { |
|
| 174 | - // supprimer les sauts de ligne debut/fin |
|
| 175 | - // (mais pas les espaces => ascii art). |
|
| 176 | - $corps = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $corps); |
|
| 172 | + // ne pas mettre le <div...> s'il n'y a qu'une ligne |
|
| 173 | + if (strpos($corps, "\n") !== false) { |
|
| 174 | + // supprimer les sauts de ligne debut/fin |
|
| 175 | + // (mais pas les espaces => ascii art). |
|
| 176 | + $corps = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $corps); |
|
| 177 | 177 | |
| 178 | - $echap = spip_balisage_code($corps, true, $att); |
|
| 179 | - } else { |
|
| 180 | - $echap = spip_balisage_code($corps, false, $att); |
|
| 181 | - } |
|
| 178 | + $echap = spip_balisage_code($corps, true, $att); |
|
| 179 | + } else { |
|
| 180 | + $echap = spip_balisage_code($corps, false, $att); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - return $echap; |
|
| 183 | + return $echap; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | // Echapper les <cadre>...</ cadre> aka <frame>...</ frame> |
| 187 | 187 | function traiter_echap_cadre_dist($regs, $options = []) { |
| 188 | - $echap = trim(entites_html($regs[3])); |
|
| 189 | - // compter les lignes un peu plus finement qu'avec les \n |
|
| 190 | - $lignes = explode("\n", trim($echap)); |
|
| 191 | - $n = 0; |
|
| 192 | - foreach ($lignes as $l) { |
|
| 193 | - $n += floor(strlen($l) / 60) + 1; |
|
| 194 | - } |
|
| 195 | - $n = max($n, 2); |
|
| 196 | - $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre spip_cadre_block' dir='ltr'>$echap</textarea>"; |
|
| 197 | - |
|
| 198 | - return $echap; |
|
| 188 | + $echap = trim(entites_html($regs[3])); |
|
| 189 | + // compter les lignes un peu plus finement qu'avec les \n |
|
| 190 | + $lignes = explode("\n", trim($echap)); |
|
| 191 | + $n = 0; |
|
| 192 | + foreach ($lignes as $l) { |
|
| 193 | + $n += floor(strlen($l) / 60) + 1; |
|
| 194 | + } |
|
| 195 | + $n = max($n, 2); |
|
| 196 | + $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre spip_cadre_block' dir='ltr'>$echap</textarea>"; |
|
| 197 | + |
|
| 198 | + return $echap; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | function traiter_echap_frame_dist($regs, $options = []) { |
| 202 | - return traiter_echap_cadre_dist($regs); |
|
| 202 | + return traiter_echap_cadre_dist($regs); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | function traiter_echap_script_dist($regs, $options = []) { |
| 206 | - // rendre joli (et inactif) si c'est un script language=php |
|
| 207 | - if (preg_match(',<script\b[^>]+php,ims', $regs[0])) { |
|
| 208 | - return highlight_string($regs[0], true); |
|
| 209 | - } |
|
| 206 | + // rendre joli (et inactif) si c'est un script language=php |
|
| 207 | + if (preg_match(',<script\b[^>]+php,ims', $regs[0])) { |
|
| 208 | + return highlight_string($regs[0], true); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - // Cas normal : le script passe tel quel |
|
| 212 | - return $regs[0]; |
|
| 211 | + // Cas normal : le script passe tel quel |
|
| 212 | + return $regs[0]; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\b[^>]*)?>(.*)</\1>,UimsS'); |
@@ -228,74 +228,74 @@ discard block |
||
| 228 | 228 | * @return string|string[] |
| 229 | 229 | */ |
| 230 | 230 | function echappe_html( |
| 231 | - $letexte, |
|
| 232 | - $source = '', |
|
| 233 | - $no_transform = false, |
|
| 234 | - $preg = '', |
|
| 235 | - $callback_prefix = '', |
|
| 236 | - $callback_options = [] |
|
| 231 | + $letexte, |
|
| 232 | + $source = '', |
|
| 233 | + $no_transform = false, |
|
| 234 | + $preg = '', |
|
| 235 | + $callback_prefix = '', |
|
| 236 | + $callback_options = [] |
|
| 237 | 237 | ) { |
| 238 | - if (!is_string($letexte) or !strlen($letexte)) { |
|
| 239 | - return $letexte; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - if ( |
|
| 243 | - ($preg or str_contains($letexte, '<')) |
|
| 244 | - and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER) |
|
| 245 | - ) { |
|
| 246 | - foreach ($matches as $regs) { |
|
| 247 | - $echap = ''; |
|
| 248 | - // echappements tels quels ? |
|
| 249 | - if ($no_transform) { |
|
| 250 | - $echap = $regs[0]; |
|
| 251 | - } else { |
|
| 252 | - // sinon les traiter selon le cas |
|
| 253 | - $callback_secure_prefix = ($callback_options['secure_prefix'] ?? ''); |
|
| 254 | - if ( |
|
| 255 | - function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 256 | - or function_exists($f = $f . '_dist') |
|
| 257 | - or ($callback_secure_prefix and ( |
|
| 258 | - function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 259 | - or function_exists($f = $f . '_dist') |
|
| 260 | - )) |
|
| 261 | - ) { |
|
| 262 | - $echap = $f($regs, $callback_options); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - $p = strpos($letexte, (string) $regs[0]); |
|
| 267 | - $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0])); |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ($no_transform) { |
|
| 272 | - return $letexte; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - // Echapper le php pour faire joli (ici, c'est pas pour la securite) |
|
| 276 | - // seulement si on a echappe les <script> |
|
| 277 | - // (derogatoire car on ne peut pas faire passer < ? ... ? > |
|
| 278 | - // dans une callback autonommee |
|
| 279 | - if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) { |
|
| 280 | - if ( |
|
| 281 | - strpos($letexte, '<' . '?') !== false and preg_match_all( |
|
| 282 | - ',<[?].*($|[?]>),UisS', |
|
| 283 | - $letexte, |
|
| 284 | - $matches, |
|
| 285 | - PREG_SET_ORDER |
|
| 286 | - ) |
|
| 287 | - ) { |
|
| 288 | - foreach ($matches as $regs) { |
|
| 289 | - $letexte = str_replace( |
|
| 290 | - $regs[0], |
|
| 291 | - code_echappement(highlight_string($regs[0], true), $source), |
|
| 292 | - $letexte |
|
| 293 | - ); |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - return $letexte; |
|
| 238 | + if (!is_string($letexte) or !strlen($letexte)) { |
|
| 239 | + return $letexte; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + if ( |
|
| 243 | + ($preg or str_contains($letexte, '<')) |
|
| 244 | + and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER) |
|
| 245 | + ) { |
|
| 246 | + foreach ($matches as $regs) { |
|
| 247 | + $echap = ''; |
|
| 248 | + // echappements tels quels ? |
|
| 249 | + if ($no_transform) { |
|
| 250 | + $echap = $regs[0]; |
|
| 251 | + } else { |
|
| 252 | + // sinon les traiter selon le cas |
|
| 253 | + $callback_secure_prefix = ($callback_options['secure_prefix'] ?? ''); |
|
| 254 | + if ( |
|
| 255 | + function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 256 | + or function_exists($f = $f . '_dist') |
|
| 257 | + or ($callback_secure_prefix and ( |
|
| 258 | + function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 259 | + or function_exists($f = $f . '_dist') |
|
| 260 | + )) |
|
| 261 | + ) { |
|
| 262 | + $echap = $f($regs, $callback_options); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + $p = strpos($letexte, (string) $regs[0]); |
|
| 267 | + $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0])); |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ($no_transform) { |
|
| 272 | + return $letexte; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + // Echapper le php pour faire joli (ici, c'est pas pour la securite) |
|
| 276 | + // seulement si on a echappe les <script> |
|
| 277 | + // (derogatoire car on ne peut pas faire passer < ? ... ? > |
|
| 278 | + // dans une callback autonommee |
|
| 279 | + if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) { |
|
| 280 | + if ( |
|
| 281 | + strpos($letexte, '<' . '?') !== false and preg_match_all( |
|
| 282 | + ',<[?].*($|[?]>),UisS', |
|
| 283 | + $letexte, |
|
| 284 | + $matches, |
|
| 285 | + PREG_SET_ORDER |
|
| 286 | + ) |
|
| 287 | + ) { |
|
| 288 | + foreach ($matches as $regs) { |
|
| 289 | + $letexte = str_replace( |
|
| 290 | + $regs[0], |
|
| 291 | + code_echappement(highlight_string($regs[0], true), $source), |
|
| 292 | + $letexte |
|
| 293 | + ); |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + return $letexte; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // |
@@ -303,57 +303,57 @@ discard block |
||
| 303 | 303 | // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes |
| 304 | 304 | // par propre() : exemple dans multi et dans typo() |
| 305 | 305 | function echappe_retour($letexte, $source = '', $filtre = '') { |
| 306 | - if (strpos($letexte, (string) "base64$source")) { |
|
| 307 | - # spip_log(spip_htmlspecialchars($letexte)); ## pour les curieux |
|
| 308 | - $max_prof = 5; |
|
| 309 | - while ( |
|
| 310 | - strpos($letexte, '<') !== false |
|
| 311 | - and |
|
| 312 | - preg_match_all( |
|
| 313 | - ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS', |
|
| 314 | - $letexte, |
|
| 315 | - $regs, |
|
| 316 | - PREG_SET_ORDER |
|
| 317 | - ) |
|
| 318 | - and $max_prof-- |
|
| 319 | - ) { |
|
| 320 | - foreach ($regs as $reg) { |
|
| 321 | - $rempl = base64_decode(extraire_attribut($reg[0], 'title')); |
|
| 322 | - // recherche d'attributs supplementaires |
|
| 323 | - $at = []; |
|
| 324 | - foreach (['lang', 'dir'] as $attr) { |
|
| 325 | - if ($a = extraire_attribut($reg[0], $attr)) { |
|
| 326 | - $at[$attr] = $a; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - if ($at) { |
|
| 330 | - $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>'; |
|
| 331 | - foreach ($at as $attr => $a) { |
|
| 332 | - $rempl = inserer_attribut($rempl, $attr, $a); |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - if ($filtre) { |
|
| 336 | - $rempl = $filtre($rempl); |
|
| 337 | - } |
|
| 338 | - $letexte = str_replace($reg[0], $rempl, $letexte); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return $letexte; |
|
| 306 | + if (strpos($letexte, (string) "base64$source")) { |
|
| 307 | + # spip_log(spip_htmlspecialchars($letexte)); ## pour les curieux |
|
| 308 | + $max_prof = 5; |
|
| 309 | + while ( |
|
| 310 | + strpos($letexte, '<') !== false |
|
| 311 | + and |
|
| 312 | + preg_match_all( |
|
| 313 | + ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS', |
|
| 314 | + $letexte, |
|
| 315 | + $regs, |
|
| 316 | + PREG_SET_ORDER |
|
| 317 | + ) |
|
| 318 | + and $max_prof-- |
|
| 319 | + ) { |
|
| 320 | + foreach ($regs as $reg) { |
|
| 321 | + $rempl = base64_decode(extraire_attribut($reg[0], 'title')); |
|
| 322 | + // recherche d'attributs supplementaires |
|
| 323 | + $at = []; |
|
| 324 | + foreach (['lang', 'dir'] as $attr) { |
|
| 325 | + if ($a = extraire_attribut($reg[0], $attr)) { |
|
| 326 | + $at[$attr] = $a; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + if ($at) { |
|
| 330 | + $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>'; |
|
| 331 | + foreach ($at as $attr => $a) { |
|
| 332 | + $rempl = inserer_attribut($rempl, $attr, $a); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + if ($filtre) { |
|
| 336 | + $rempl = $filtre($rempl); |
|
| 337 | + } |
|
| 338 | + $letexte = str_replace($reg[0], $rempl, $letexte); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return $letexte; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | // Reinserer le javascript de confiance (venant des modeles) |
| 347 | 347 | |
| 348 | 348 | function echappe_retour_modeles($letexte, $interdire_scripts = false) { |
| 349 | - $letexte = echappe_retour($letexte); |
|
| 349 | + $letexte = echappe_retour($letexte); |
|
| 350 | 350 | |
| 351 | - // Dans les appels directs hors squelette, securiser aussi ici |
|
| 352 | - if ($interdire_scripts) { |
|
| 353 | - $letexte = interdire_scripts($letexte); |
|
| 354 | - } |
|
| 351 | + // Dans les appels directs hors squelette, securiser aussi ici |
|
| 352 | + if ($interdire_scripts) { |
|
| 353 | + $letexte = interdire_scripts($letexte); |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - return trim($letexte); |
|
| 356 | + return trim($letexte); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | |
@@ -381,128 +381,128 @@ discard block |
||
| 381 | 381 | * texte coupé |
| 382 | 382 | **/ |
| 383 | 383 | function couper($texte, $taille = 50, $suite = null) { |
| 384 | - if (!($length = strlen($texte)) or $taille <= 0) { |
|
| 385 | - return ''; |
|
| 386 | - } |
|
| 387 | - $offset = 400 + 2 * $taille; |
|
| 388 | - while ( |
|
| 389 | - $offset < $length |
|
| 390 | - and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille |
|
| 391 | - ) { |
|
| 392 | - $offset = 2 * $offset; |
|
| 393 | - } |
|
| 394 | - if ( |
|
| 395 | - $offset < $length |
|
| 396 | - && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null |
|
| 397 | - ) { |
|
| 398 | - $p_tag_fermant = strpos($texte, '>', $offset); |
|
| 399 | - if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) { |
|
| 400 | - $offset = $p_tag_fermant + 1; |
|
| 401 | - } // prolonger la coupe jusqu'au tag fermant suivant eventuel |
|
| 402 | - } |
|
| 403 | - $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */ |
|
| 404 | - |
|
| 405 | - if (!function_exists('nettoyer_raccourcis_typo')) { |
|
| 406 | - include_spip('inc/lien'); |
|
| 407 | - } |
|
| 408 | - $texte = nettoyer_raccourcis_typo($texte); |
|
| 409 | - |
|
| 410 | - // balises de sauts de ligne et paragraphe |
|
| 411 | - $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte); |
|
| 412 | - $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 413 | - |
|
| 414 | - // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
|
| 415 | - $texte = str_replace("\n\n", "\r\r", $texte); |
|
| 416 | - |
|
| 417 | - // supprimer les tags |
|
| 418 | - $texte = supprimer_tags($texte); |
|
| 419 | - $texte = trim(str_replace("\n", ' ', $texte)); |
|
| 420 | - |
|
| 421 | - // tester s'il est nécessaire de couper le texte |
|
| 422 | - if (spip_strlen($texte) <= $taille) { |
|
| 423 | - $points = ''; |
|
| 424 | - } else { |
|
| 425 | - // points de suite |
|
| 426 | - if (is_null($suite)) { |
|
| 427 | - $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : ' (...)'); |
|
| 428 | - } |
|
| 429 | - $taille_suite = spip_strlen(filtrer_entites($suite)); |
|
| 430 | - |
|
| 431 | - // couper au mot precedent (ou au début de la chaîne si c'est le premier mot) |
|
| 432 | - // on coupe avec un caractère de plus que la taille demandée afin de pouvoir |
|
| 433 | - // détecter si le dernier mot du texte coupé est complet ou non. ce caractère |
|
| 434 | - // excédentaire est ensuite supprimé par l'appel à preg_replace() |
|
| 435 | - $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1)); |
|
| 436 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 437 | - $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 438 | - $points = $suite; |
|
| 439 | - |
|
| 440 | - // trop court ? ne pas faire de (...) |
|
| 441 | - if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
|
| 442 | - $points = ''; |
|
| 443 | - $long = spip_substr($texte, 0, $taille + 1); |
|
| 444 | - preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m); |
|
| 445 | - $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 446 | - // encore trop court ? couper au caractere |
|
| 447 | - if (spip_strlen($texte) < 0.75 * $taille) { |
|
| 448 | - $texte = spip_substr($long, 0, $taille); |
|
| 449 | - } |
|
| 450 | - } else { |
|
| 451 | - $texte = $court; |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - // remettre les paragraphes |
|
| 456 | - $texte = preg_replace("/\r\r+/", "\n\n", $texte); |
|
| 457 | - |
|
| 458 | - // supprimer l'eventuelle entite finale mal coupee |
|
| 459 | - $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
|
| 460 | - |
|
| 461 | - return quote_amp(trim($texte)) . $points; |
|
| 384 | + if (!($length = strlen($texte)) or $taille <= 0) { |
|
| 385 | + return ''; |
|
| 386 | + } |
|
| 387 | + $offset = 400 + 2 * $taille; |
|
| 388 | + while ( |
|
| 389 | + $offset < $length |
|
| 390 | + and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille |
|
| 391 | + ) { |
|
| 392 | + $offset = 2 * $offset; |
|
| 393 | + } |
|
| 394 | + if ( |
|
| 395 | + $offset < $length |
|
| 396 | + && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null |
|
| 397 | + ) { |
|
| 398 | + $p_tag_fermant = strpos($texte, '>', $offset); |
|
| 399 | + if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) { |
|
| 400 | + $offset = $p_tag_fermant + 1; |
|
| 401 | + } // prolonger la coupe jusqu'au tag fermant suivant eventuel |
|
| 402 | + } |
|
| 403 | + $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */ |
|
| 404 | + |
|
| 405 | + if (!function_exists('nettoyer_raccourcis_typo')) { |
|
| 406 | + include_spip('inc/lien'); |
|
| 407 | + } |
|
| 408 | + $texte = nettoyer_raccourcis_typo($texte); |
|
| 409 | + |
|
| 410 | + // balises de sauts de ligne et paragraphe |
|
| 411 | + $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte); |
|
| 412 | + $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 413 | + |
|
| 414 | + // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
|
| 415 | + $texte = str_replace("\n\n", "\r\r", $texte); |
|
| 416 | + |
|
| 417 | + // supprimer les tags |
|
| 418 | + $texte = supprimer_tags($texte); |
|
| 419 | + $texte = trim(str_replace("\n", ' ', $texte)); |
|
| 420 | + |
|
| 421 | + // tester s'il est nécessaire de couper le texte |
|
| 422 | + if (spip_strlen($texte) <= $taille) { |
|
| 423 | + $points = ''; |
|
| 424 | + } else { |
|
| 425 | + // points de suite |
|
| 426 | + if (is_null($suite)) { |
|
| 427 | + $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : ' (...)'); |
|
| 428 | + } |
|
| 429 | + $taille_suite = spip_strlen(filtrer_entites($suite)); |
|
| 430 | + |
|
| 431 | + // couper au mot precedent (ou au début de la chaîne si c'est le premier mot) |
|
| 432 | + // on coupe avec un caractère de plus que la taille demandée afin de pouvoir |
|
| 433 | + // détecter si le dernier mot du texte coupé est complet ou non. ce caractère |
|
| 434 | + // excédentaire est ensuite supprimé par l'appel à preg_replace() |
|
| 435 | + $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1)); |
|
| 436 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 437 | + $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 438 | + $points = $suite; |
|
| 439 | + |
|
| 440 | + // trop court ? ne pas faire de (...) |
|
| 441 | + if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
|
| 442 | + $points = ''; |
|
| 443 | + $long = spip_substr($texte, 0, $taille + 1); |
|
| 444 | + preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m); |
|
| 445 | + $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 446 | + // encore trop court ? couper au caractere |
|
| 447 | + if (spip_strlen($texte) < 0.75 * $taille) { |
|
| 448 | + $texte = spip_substr($long, 0, $taille); |
|
| 449 | + } |
|
| 450 | + } else { |
|
| 451 | + $texte = $court; |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + // remettre les paragraphes |
|
| 456 | + $texte = preg_replace("/\r\r+/", "\n\n", $texte); |
|
| 457 | + |
|
| 458 | + // supprimer l'eventuelle entite finale mal coupee |
|
| 459 | + $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
|
| 460 | + |
|
| 461 | + return quote_amp(trim($texte)) . $points; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | |
| 465 | 465 | function protege_js_modeles($t) { |
| 466 | - if (isset($GLOBALS['visiteur_session'])) { |
|
| 467 | - if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 468 | - if (!defined('_PROTEGE_JS_MODELES')) { |
|
| 469 | - include_spip('inc/acces'); |
|
| 470 | - define('_PROTEGE_JS_MODELES', creer_uniqid()); |
|
| 471 | - } |
|
| 472 | - foreach ($r as $regs) { |
|
| 473 | - $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t); |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 477 | - if (!defined('_PROTEGE_PHP_MODELES')) { |
|
| 478 | - include_spip('inc/acces'); |
|
| 479 | - define('_PROTEGE_PHP_MODELES', creer_uniqid()); |
|
| 480 | - } |
|
| 481 | - foreach ($r as $regs) { |
|
| 482 | - $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t); |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - return $t; |
|
| 466 | + if (isset($GLOBALS['visiteur_session'])) { |
|
| 467 | + if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 468 | + if (!defined('_PROTEGE_JS_MODELES')) { |
|
| 469 | + include_spip('inc/acces'); |
|
| 470 | + define('_PROTEGE_JS_MODELES', creer_uniqid()); |
|
| 471 | + } |
|
| 472 | + foreach ($r as $regs) { |
|
| 473 | + $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t); |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 477 | + if (!defined('_PROTEGE_PHP_MODELES')) { |
|
| 478 | + include_spip('inc/acces'); |
|
| 479 | + define('_PROTEGE_PHP_MODELES', creer_uniqid()); |
|
| 480 | + } |
|
| 481 | + foreach ($r as $regs) { |
|
| 482 | + $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t); |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + return $t; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
| 491 | 491 | function echapper_faux_tags($letexte) { |
| 492 | - if (strpos($letexte, '<') === false) { |
|
| 493 | - return $letexte; |
|
| 494 | - } |
|
| 495 | - $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 496 | - |
|
| 497 | - $letexte = ''; |
|
| 498 | - while (is_countable($textMatches) ? count($textMatches) : 0) { |
|
| 499 | - // un texte a echapper |
|
| 500 | - $letexte .= str_replace('<', '<', array_shift($textMatches)); |
|
| 501 | - // un tag html qui a servit a faite le split |
|
| 502 | - $letexte .= array_shift($textMatches); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - return $letexte; |
|
| 492 | + if (strpos($letexte, '<') === false) { |
|
| 493 | + return $letexte; |
|
| 494 | + } |
|
| 495 | + $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 496 | + |
|
| 497 | + $letexte = ''; |
|
| 498 | + while (is_countable($textMatches) ? count($textMatches) : 0) { |
|
| 499 | + // un texte a echapper |
|
| 500 | + $letexte .= str_replace('<', '<', array_shift($textMatches)); |
|
| 501 | + // un tag html qui a servit a faite le split |
|
| 502 | + $letexte .= array_shift($textMatches); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + return $letexte; |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /** |
@@ -522,114 +522,114 @@ discard block |
||
| 522 | 522 | * @return string |
| 523 | 523 | */ |
| 524 | 524 | function echapper_html_suspect($texte, $options = [], $connect = null, $env = []) { |
| 525 | - static $echapper_html_suspect; |
|
| 526 | - if (!$texte or !is_string($texte)) { |
|
| 527 | - return $texte; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - if (!isset($echapper_html_suspect)) { |
|
| 531 | - $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true); |
|
| 532 | - } |
|
| 533 | - // si fonction personalisee, on delegue |
|
| 534 | - if ($echapper_html_suspect) { |
|
| 535 | - // on collecte le tableau d'arg minimal pour ne pas casser un appel a une fonction inc_echapper_html_suspect() selon l'ancienne signature |
|
| 536 | - $args = [$texte, $options]; |
|
| 537 | - if ($connect or !empty($env)) { |
|
| 538 | - $args[] = $connect; |
|
| 539 | - } |
|
| 540 | - if (!empty($env)) { |
|
| 541 | - $args[] = $env; |
|
| 542 | - } |
|
| 543 | - return $echapper_html_suspect(...$args); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - if (is_bool($options)) { |
|
| 547 | - $options = ['strict' => $options]; |
|
| 548 | - } |
|
| 549 | - $strict = $options['strict'] ?? true; |
|
| 550 | - |
|
| 551 | - // pas de balise html ou pas d'attribut sur les balises ? c'est OK |
|
| 552 | - if ( |
|
| 553 | - strpos($texte, '<') === false |
|
| 554 | - or !str_contains($texte, '=') |
|
| 555 | - ) { |
|
| 556 | - return $texte; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - // dans le prive, on veut afficher tout echappé pour la moderation |
|
| 560 | - if (!isset($env['espace_prive'])) { |
|
| 561 | - // conserver le comportement historique en cas d'appel court sans env |
|
| 562 | - $env['espace_prive'] = test_espace_prive(); |
|
| 563 | - } |
|
| 564 | - if (!empty($env['espace_prive']) or !empty($env['wysiwyg'])) { |
|
| 565 | - // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx= |
|
| 566 | - // car sinon on declenche sur les modeles ou ressources |
|
| 567 | - if ( |
|
| 568 | - !$strict and |
|
| 569 | - (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte)) |
|
| 570 | - ) { |
|
| 571 | - return $texte; |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 575 | - include_spip('src/Texte/Collecteur/Modeles'); |
|
| 576 | - $collecteurModeles = new Spip\Texte\Collecteur\Modeles(); |
|
| 577 | - $texte = $collecteurModeles->echapper($texte); |
|
| 578 | - $texte = echappe_js($texte); |
|
| 579 | - |
|
| 580 | - $texte_to_check = $texte; |
|
| 581 | - // si les raccourcis liens vont etre interprétés, il faut les expanser avant de vérifier que le html est safe |
|
| 582 | - // car un raccourci peut etre utilisé pour faire un lien malin |
|
| 583 | - // et un raccourci est potentiellement modifié par safehtml, ce qui fait un faux positif dans is_html_safe |
|
| 584 | - if (!empty($options['expanser_liens'])) { |
|
| 585 | - $texte_to_check = expanser_liens($texte_to_check, $env['connect'] ?? '', $env['env'] ?? []); |
|
| 586 | - } |
|
| 587 | - if (!is_html_safe($texte_to_check)) { |
|
| 588 | - $texte = $options['texte_source_affiche'] ?? $texte; |
|
| 589 | - $texte = preg_replace(",<(/?\w+\b[^>]*>),", "<tt><\\1</tt>", $texte); |
|
| 590 | - $texte = str_replace('<', '<', $texte); |
|
| 591 | - $texte = str_replace('<tt>', '<tt>', $texte); |
|
| 592 | - $texte = str_replace('</tt>', '</tt>', $texte); |
|
| 593 | - if (!function_exists('attribut_html')) { |
|
| 594 | - include_spip('inc/filtres'); |
|
| 595 | - } |
|
| 596 | - if (!empty($options['wrap_suspect'])) { |
|
| 597 | - $texte = wrap($texte, $options['wrap_suspect']); |
|
| 598 | - } |
|
| 599 | - $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - $texte = $collecteurModeles->retablir($texte); |
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - // si on est là dans le public c'est le mode parano |
|
| 606 | - // on veut donc un rendu propre et secure, et virer silencieusement ce qui est dangereux |
|
| 607 | - else { |
|
| 608 | - $collecteurLiens = $collecteurModeles = null; |
|
| 609 | - if (!empty($options['expanser_liens'])) { |
|
| 610 | - $texte = expanser_liens($texte, $env['connect'] ?? '', $env['env'] ?? []); |
|
| 611 | - } |
|
| 612 | - else { |
|
| 613 | - include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 614 | - include_spip('src/Texte/Collecteur/Liens'); |
|
| 615 | - include_spip('src/Texte/Collecteur/Modeles'); |
|
| 616 | - |
|
| 617 | - $collecteurLiens = new Spip\Texte\Collecteur\Liens(); |
|
| 618 | - $texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']); |
|
| 619 | - |
|
| 620 | - $collecteurModeles = new Spip\Texte\Collecteur\Modeles(); |
|
| 621 | - $texte = $collecteurModeles->echapper($texte); |
|
| 622 | - } |
|
| 623 | - $texte = safehtml($texte); |
|
| 624 | - if ($collecteurModeles) { |
|
| 625 | - $texte = $collecteurModeles->retablir($texte); |
|
| 626 | - } |
|
| 627 | - if ($collecteurLiens) { |
|
| 628 | - $texte = $collecteurLiens->retablir($texte); |
|
| 629 | - } |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - return $texte; |
|
| 525 | + static $echapper_html_suspect; |
|
| 526 | + if (!$texte or !is_string($texte)) { |
|
| 527 | + return $texte; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + if (!isset($echapper_html_suspect)) { |
|
| 531 | + $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true); |
|
| 532 | + } |
|
| 533 | + // si fonction personalisee, on delegue |
|
| 534 | + if ($echapper_html_suspect) { |
|
| 535 | + // on collecte le tableau d'arg minimal pour ne pas casser un appel a une fonction inc_echapper_html_suspect() selon l'ancienne signature |
|
| 536 | + $args = [$texte, $options]; |
|
| 537 | + if ($connect or !empty($env)) { |
|
| 538 | + $args[] = $connect; |
|
| 539 | + } |
|
| 540 | + if (!empty($env)) { |
|
| 541 | + $args[] = $env; |
|
| 542 | + } |
|
| 543 | + return $echapper_html_suspect(...$args); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + if (is_bool($options)) { |
|
| 547 | + $options = ['strict' => $options]; |
|
| 548 | + } |
|
| 549 | + $strict = $options['strict'] ?? true; |
|
| 550 | + |
|
| 551 | + // pas de balise html ou pas d'attribut sur les balises ? c'est OK |
|
| 552 | + if ( |
|
| 553 | + strpos($texte, '<') === false |
|
| 554 | + or !str_contains($texte, '=') |
|
| 555 | + ) { |
|
| 556 | + return $texte; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + // dans le prive, on veut afficher tout echappé pour la moderation |
|
| 560 | + if (!isset($env['espace_prive'])) { |
|
| 561 | + // conserver le comportement historique en cas d'appel court sans env |
|
| 562 | + $env['espace_prive'] = test_espace_prive(); |
|
| 563 | + } |
|
| 564 | + if (!empty($env['espace_prive']) or !empty($env['wysiwyg'])) { |
|
| 565 | + // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx= |
|
| 566 | + // car sinon on declenche sur les modeles ou ressources |
|
| 567 | + if ( |
|
| 568 | + !$strict and |
|
| 569 | + (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte)) |
|
| 570 | + ) { |
|
| 571 | + return $texte; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 575 | + include_spip('src/Texte/Collecteur/Modeles'); |
|
| 576 | + $collecteurModeles = new Spip\Texte\Collecteur\Modeles(); |
|
| 577 | + $texte = $collecteurModeles->echapper($texte); |
|
| 578 | + $texte = echappe_js($texte); |
|
| 579 | + |
|
| 580 | + $texte_to_check = $texte; |
|
| 581 | + // si les raccourcis liens vont etre interprétés, il faut les expanser avant de vérifier que le html est safe |
|
| 582 | + // car un raccourci peut etre utilisé pour faire un lien malin |
|
| 583 | + // et un raccourci est potentiellement modifié par safehtml, ce qui fait un faux positif dans is_html_safe |
|
| 584 | + if (!empty($options['expanser_liens'])) { |
|
| 585 | + $texte_to_check = expanser_liens($texte_to_check, $env['connect'] ?? '', $env['env'] ?? []); |
|
| 586 | + } |
|
| 587 | + if (!is_html_safe($texte_to_check)) { |
|
| 588 | + $texte = $options['texte_source_affiche'] ?? $texte; |
|
| 589 | + $texte = preg_replace(",<(/?\w+\b[^>]*>),", "<tt><\\1</tt>", $texte); |
|
| 590 | + $texte = str_replace('<', '<', $texte); |
|
| 591 | + $texte = str_replace('<tt>', '<tt>', $texte); |
|
| 592 | + $texte = str_replace('</tt>', '</tt>', $texte); |
|
| 593 | + if (!function_exists('attribut_html')) { |
|
| 594 | + include_spip('inc/filtres'); |
|
| 595 | + } |
|
| 596 | + if (!empty($options['wrap_suspect'])) { |
|
| 597 | + $texte = wrap($texte, $options['wrap_suspect']); |
|
| 598 | + } |
|
| 599 | + $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + $texte = $collecteurModeles->retablir($texte); |
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + // si on est là dans le public c'est le mode parano |
|
| 606 | + // on veut donc un rendu propre et secure, et virer silencieusement ce qui est dangereux |
|
| 607 | + else { |
|
| 608 | + $collecteurLiens = $collecteurModeles = null; |
|
| 609 | + if (!empty($options['expanser_liens'])) { |
|
| 610 | + $texte = expanser_liens($texte, $env['connect'] ?? '', $env['env'] ?? []); |
|
| 611 | + } |
|
| 612 | + else { |
|
| 613 | + include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 614 | + include_spip('src/Texte/Collecteur/Liens'); |
|
| 615 | + include_spip('src/Texte/Collecteur/Modeles'); |
|
| 616 | + |
|
| 617 | + $collecteurLiens = new Spip\Texte\Collecteur\Liens(); |
|
| 618 | + $texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']); |
|
| 619 | + |
|
| 620 | + $collecteurModeles = new Spip\Texte\Collecteur\Modeles(); |
|
| 621 | + $texte = $collecteurModeles->echapper($texte); |
|
| 622 | + } |
|
| 623 | + $texte = safehtml($texte); |
|
| 624 | + if ($collecteurModeles) { |
|
| 625 | + $texte = $collecteurModeles->retablir($texte); |
|
| 626 | + } |
|
| 627 | + if ($collecteurLiens) { |
|
| 628 | + $texte = $collecteurLiens->retablir($texte); |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + return $texte; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | |
@@ -650,52 +650,52 @@ discard block |
||
| 650 | 650 | * texte sécurisé |
| 651 | 651 | **/ |
| 652 | 652 | function safehtml($t) { |
| 653 | - static $safehtml; |
|
| 654 | - |
|
| 655 | - if (!$t or !is_string($t)) { |
|
| 656 | - return $t; |
|
| 657 | - } |
|
| 658 | - # attention safehtml nettoie deux ou trois caracteres de plus. A voir |
|
| 659 | - if (strpos($t, '<') === false) { |
|
| 660 | - return str_replace("\x00", '', $t); |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - $collecteurIdiomes = null; |
|
| 664 | - if (stripos($t, '<:') !== false) { |
|
| 665 | - include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 666 | - include_spip('src/Texte/Collecteur/Idiomes'); |
|
| 667 | - $collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes(); |
|
| 668 | - $t = $collecteurIdiomes->echapper($t); |
|
| 669 | - } |
|
| 670 | - $collecteurMultis = null; |
|
| 671 | - if (stripos($t, '<multi') !== false) { |
|
| 672 | - include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 673 | - include_spip('src/Texte/Collecteur/Multis'); |
|
| 674 | - $collecteurMultis = new Spip\Texte\Collecteur\Multis(); |
|
| 675 | - $t = $collecteurMultis->echapper($t, ['sanitize_callback' => 'safehtml']); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - if (!function_exists('interdire_scripts')) { |
|
| 679 | - include_spip('inc/texte'); |
|
| 680 | - } |
|
| 681 | - $t = interdire_scripts($t); // jolifier le php |
|
| 682 | - $t = echappe_js($t); |
|
| 683 | - |
|
| 684 | - if (!isset($safehtml)) { |
|
| 685 | - $safehtml = charger_fonction('safehtml', 'inc', true); |
|
| 686 | - } |
|
| 687 | - if ($safehtml) { |
|
| 688 | - $t = $safehtml($t); |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - if ($collecteurMultis) { |
|
| 692 | - $t = $collecteurMultis->retablir($t); |
|
| 693 | - } |
|
| 694 | - if ($collecteurIdiomes) { |
|
| 695 | - $t = $collecteurIdiomes->retablir($t); |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - return interdire_scripts($t); // interdire le php (2 precautions) |
|
| 653 | + static $safehtml; |
|
| 654 | + |
|
| 655 | + if (!$t or !is_string($t)) { |
|
| 656 | + return $t; |
|
| 657 | + } |
|
| 658 | + # attention safehtml nettoie deux ou trois caracteres de plus. A voir |
|
| 659 | + if (strpos($t, '<') === false) { |
|
| 660 | + return str_replace("\x00", '', $t); |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + $collecteurIdiomes = null; |
|
| 664 | + if (stripos($t, '<:') !== false) { |
|
| 665 | + include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 666 | + include_spip('src/Texte/Collecteur/Idiomes'); |
|
| 667 | + $collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes(); |
|
| 668 | + $t = $collecteurIdiomes->echapper($t); |
|
| 669 | + } |
|
| 670 | + $collecteurMultis = null; |
|
| 671 | + if (stripos($t, '<multi') !== false) { |
|
| 672 | + include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
|
| 673 | + include_spip('src/Texte/Collecteur/Multis'); |
|
| 674 | + $collecteurMultis = new Spip\Texte\Collecteur\Multis(); |
|
| 675 | + $t = $collecteurMultis->echapper($t, ['sanitize_callback' => 'safehtml']); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + if (!function_exists('interdire_scripts')) { |
|
| 679 | + include_spip('inc/texte'); |
|
| 680 | + } |
|
| 681 | + $t = interdire_scripts($t); // jolifier le php |
|
| 682 | + $t = echappe_js($t); |
|
| 683 | + |
|
| 684 | + if (!isset($safehtml)) { |
|
| 685 | + $safehtml = charger_fonction('safehtml', 'inc', true); |
|
| 686 | + } |
|
| 687 | + if ($safehtml) { |
|
| 688 | + $t = $safehtml($t); |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + if ($collecteurMultis) { |
|
| 692 | + $t = $collecteurMultis->retablir($t); |
|
| 693 | + } |
|
| 694 | + if ($collecteurIdiomes) { |
|
| 695 | + $t = $collecteurIdiomes->retablir($t); |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + return interdire_scripts($t); // interdire le php (2 precautions) |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -703,25 +703,25 @@ discard block |
||
| 703 | 703 | * Detecter si un texte est "safe" ie non modifie significativement par safehtml() |
| 704 | 704 | */ |
| 705 | 705 | function is_html_safe(string $texte): bool { |
| 706 | - if ($is_html_safe = charger_fonction('is_html_safe', 'inc', true)) { |
|
| 707 | - return $is_html_safe($texte); |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - // simplifier les retour ligne pour etre certain de ce que l'on compare |
|
| 711 | - $texte = str_replace("\r\n", "\n", $texte); |
|
| 712 | - // safehtml reduit aussi potentiellement les |
|
| 713 | - $texte = str_replace(' ', ' ', $texte); |
|
| 714 | - // safehtml remplace les entités numériques |
|
| 715 | - if (strpos($texte, '&#') !== false) { |
|
| 716 | - $texte = unicode2charset($texte); |
|
| 717 | - } |
|
| 718 | - |
|
| 719 | - $texte_safe = safehtml($texte); |
|
| 720 | - |
|
| 721 | - // on teste sur strlen car safehtml supprime le contenu dangereux |
|
| 722 | - // mais il peut aussi changer des ' en " sur les attributs html, |
|
| 723 | - // donc un test d'egalite est trop strict |
|
| 724 | - return strlen($texte_safe) === strlen($texte); |
|
| 706 | + if ($is_html_safe = charger_fonction('is_html_safe', 'inc', true)) { |
|
| 707 | + return $is_html_safe($texte); |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + // simplifier les retour ligne pour etre certain de ce que l'on compare |
|
| 711 | + $texte = str_replace("\r\n", "\n", $texte); |
|
| 712 | + // safehtml reduit aussi potentiellement les |
|
| 713 | + $texte = str_replace(' ', ' ', $texte); |
|
| 714 | + // safehtml remplace les entités numériques |
|
| 715 | + if (strpos($texte, '&#') !== false) { |
|
| 716 | + $texte = unicode2charset($texte); |
|
| 717 | + } |
|
| 718 | + |
|
| 719 | + $texte_safe = safehtml($texte); |
|
| 720 | + |
|
| 721 | + // on teste sur strlen car safehtml supprime le contenu dangereux |
|
| 722 | + // mais il peut aussi changer des ' en " sur les attributs html, |
|
| 723 | + // donc un test d'egalite est trop strict |
|
| 724 | + return strlen($texte_safe) === strlen($texte); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
@@ -742,13 +742,13 @@ discard block |
||
| 742 | 742 | * texte sans les modèles d'image |
| 743 | 743 | **/ |
| 744 | 744 | function supprime_img($letexte, $message = null) { |
| 745 | - if ($message === null) { |
|
| 746 | - $message = '(' . _T('img_indisponible') . ')'; |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - return preg_replace( |
|
| 750 | - ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 751 | - $message, |
|
| 752 | - $letexte |
|
| 753 | - ); |
|
| 745 | + if ($message === null) { |
|
| 746 | + $message = '(' . _T('img_indisponible') . ')'; |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + return preg_replace( |
|
| 750 | + ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 751 | + $message, |
|
| 752 | + $letexte |
|
| 753 | + ); |
|
| 754 | 754 | } |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | // celle du texte) et public (spip_lang est la langue du texte) |
| 44 | 44 | $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
| 45 | 45 | |
| 46 | - $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 46 | + $p = 'puce'.(test_espace_prive() ? '_prive' : ''); |
|
| 47 | 47 | if ($dir == 'rtl') { |
| 48 | 48 | $p .= '_rtl'; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (!isset($GLOBALS[$p])) { |
| 52 | - $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 52 | + $GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>'; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $GLOBALS[$p]; |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | function spip_balisage_code(string $corps, bool $bloc = false, string $attributs = '', string $langage = '') { |
| 68 | 68 | |
| 69 | 69 | $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
| 70 | - $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 70 | + $class = 'spip_code '.($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 71 | 71 | if ($attributs) { |
| 72 | - $attributs = ' ' . trim($attributs); |
|
| 72 | + $attributs = ' '.trim($attributs); |
|
| 73 | 73 | } |
| 74 | 74 | if ($langage) { |
| 75 | 75 | $class .= " language-$langage"; |
| 76 | - $attributs .= ' data-language="' . $langage . '"'; |
|
| 76 | + $attributs .= ' data-language="'.$langage.'"'; |
|
| 77 | 77 | } |
| 78 | 78 | if ($bloc) { |
| 79 | 79 | $html = '<div class="precode">' |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | else { |
| 88 | 88 | $echap = str_replace("\t", ' ', $echap); |
| 89 | 89 | $echap = str_replace(' ', ' ', $echap); |
| 90 | - $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
|
| 90 | + $html = "<code class=\"$class\" dir=\"ltr\"$attributs>".$echap.'</code>'; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return $html; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (!defined('_BALISES_BLOCS_REGEXP')) { |
| 108 | - define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS'); |
|
| 108 | + define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS'); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | // Tester si on echappe en span ou en div |
| 124 | 124 | if (is_null($mode) or !in_array($mode, ['div', 'span'])) { |
| 125 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span'; |
|
| 125 | + $mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span'; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Decouper en morceaux, base64 a des probleme selon la taille de la pile |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | ) { |
| 158 | 158 | foreach ($matches as $m) { |
| 159 | 159 | if ($m[1] === 'code') { |
| 160 | - $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>'; |
|
| 160 | + $code = '<code'.$m[2].'>'.spip_htmlspecialchars($m[3]).'</code>'; |
|
| 161 | 161 | $pre = str_replace($m[0], $code, $pre); |
| 162 | 162 | } |
| 163 | 163 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | // Echapper les <code>...</ code> |
| 169 | 169 | function traiter_echap_code_dist($regs, $options = []) { |
| 170 | - [, , $att, $corps] = $regs; |
|
| 170 | + [,, $att, $corps] = $regs; |
|
| 171 | 171 | |
| 172 | 172 | // ne pas mettre le <div...> s'il n'y a qu'une ligne |
| 173 | 173 | if (strpos($corps, "\n") !== false) { |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | // sinon les traiter selon le cas |
| 253 | 253 | $callback_secure_prefix = ($callback_options['secure_prefix'] ?? ''); |
| 254 | 254 | if ( |
| 255 | - function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 256 | - or function_exists($f = $f . '_dist') |
|
| 255 | + function_exists($f = $callback_prefix.$callback_secure_prefix.'traiter_echap_'.strtolower($regs[1])) |
|
| 256 | + or function_exists($f = $f.'_dist') |
|
| 257 | 257 | or ($callback_secure_prefix and ( |
| 258 | - function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1])) |
|
| 259 | - or function_exists($f = $f . '_dist') |
|
| 258 | + function_exists($f = $callback_prefix.'traiter_echap_'.strtolower($regs[1])) |
|
| 259 | + or function_exists($f = $f.'_dist') |
|
| 260 | 260 | )) |
| 261 | 261 | ) { |
| 262 | 262 | $echap = $f($regs, $callback_options); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | // dans une callback autonommee |
| 279 | 279 | if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) { |
| 280 | 280 | if ( |
| 281 | - strpos($letexte, '<' . '?') !== false and preg_match_all( |
|
| 281 | + strpos($letexte, '<'.'?') !== false and preg_match_all( |
|
| 282 | 282 | ',<[?].*($|[?]>),UisS', |
| 283 | 283 | $letexte, |
| 284 | 284 | $matches, |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | strpos($letexte, '<') !== false |
| 311 | 311 | and |
| 312 | 312 | preg_match_all( |
| 313 | - ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS', |
|
| 313 | + ',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS', |
|
| 314 | 314 | $letexte, |
| 315 | 315 | $regs, |
| 316 | 316 | PREG_SET_ORDER |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | if ($at) { |
| 330 | - $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>'; |
|
| 330 | + $rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>'; |
|
| 331 | 331 | foreach ($at as $attr => $a) { |
| 332 | 332 | $rempl = inserer_attribut($rempl, $attr, $a); |
| 333 | 333 | } |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | $texte = nettoyer_raccourcis_typo($texte); |
| 409 | 409 | |
| 410 | 410 | // balises de sauts de ligne et paragraphe |
| 411 | - $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte); |
|
| 412 | - $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 411 | + $texte = preg_replace('/<p( [^>]*)?'.'>/', "\r\r", $texte); |
|
| 412 | + $texte = preg_replace('/<br( [^>]*)?'.'>/', "\n", $texte); |
|
| 413 | 413 | |
| 414 | 414 | // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
| 415 | 415 | $texte = str_replace("\n\n", "\r\r", $texte); |
@@ -434,15 +434,15 @@ discard block |
||
| 434 | 434 | // excédentaire est ensuite supprimé par l'appel à preg_replace() |
| 435 | 435 | $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1)); |
| 436 | 436 | $u = $GLOBALS['meta']['pcre_u']; |
| 437 | - $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 437 | + $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, "\\2", $long); |
|
| 438 | 438 | $points = $suite; |
| 439 | 439 | |
| 440 | 440 | // trop court ? ne pas faire de (...) |
| 441 | 441 | if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
| 442 | 442 | $points = ''; |
| 443 | 443 | $long = spip_substr($texte, 0, $taille + 1); |
| 444 | - preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m); |
|
| 445 | - $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 444 | + preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, $long, $m); |
|
| 445 | + $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, "\\2", $long); |
|
| 446 | 446 | // encore trop court ? couper au caractere |
| 447 | 447 | if (spip_strlen($texte) < 0.75 * $taille) { |
| 448 | 448 | $texte = spip_substr($long, 0, $taille); |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | // supprimer l'eventuelle entite finale mal coupee |
| 459 | 459 | $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
| 460 | 460 | |
| 461 | - return quote_amp(trim($texte)) . $points; |
|
| 461 | + return quote_amp(trim($texte)).$points; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | |
@@ -470,16 +470,16 @@ discard block |
||
| 470 | 470 | define('_PROTEGE_JS_MODELES', creer_uniqid()); |
| 471 | 471 | } |
| 472 | 472 | foreach ($r as $regs) { |
| 473 | - $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t); |
|
| 473 | + $t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t); |
|
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | - if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 476 | + if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) { |
|
| 477 | 477 | if (!defined('_PROTEGE_PHP_MODELES')) { |
| 478 | 478 | include_spip('inc/acces'); |
| 479 | 479 | define('_PROTEGE_PHP_MODELES', creer_uniqid()); |
| 480 | 480 | } |
| 481 | 481 | foreach ($r as $regs) { |
| 482 | - $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t); |
|
| 482 | + $t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | if (!empty($options['wrap_suspect'])) { |
| 597 | 597 | $texte = wrap($texte, $options['wrap_suspect']); |
| 598 | 598 | } |
| 599 | - $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 599 | + $texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | $texte = $collecteurModeles->retablir($texte); |
@@ -743,11 +743,11 @@ discard block |
||
| 743 | 743 | **/ |
| 744 | 744 | function supprime_img($letexte, $message = null) { |
| 745 | 745 | if ($message === null) { |
| 746 | - $message = '(' . _T('img_indisponible') . ')'; |
|
| 746 | + $message = '('._T('img_indisponible').')'; |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | return preg_replace( |
| 750 | - ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 750 | + ',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i', |
|
| 751 | 751 | $message, |
| 752 | 752 | $letexte |
| 753 | 753 | ); |
@@ -83,8 +83,7 @@ discard block |
||
| 83 | 83 | . '</code>' |
| 84 | 84 | . '</pre>' |
| 85 | 85 | . '</div>'; |
| 86 | - } |
|
| 87 | - else { |
|
| 86 | + } else { |
|
| 88 | 87 | $echap = str_replace("\t", ' ', $echap); |
| 89 | 88 | $echap = str_replace(' ', ' ', $echap); |
| 90 | 89 | $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
@@ -608,8 +607,7 @@ discard block |
||
| 608 | 607 | $collecteurLiens = $collecteurModeles = null; |
| 609 | 608 | if (!empty($options['expanser_liens'])) { |
| 610 | 609 | $texte = expanser_liens($texte, $env['connect'] ?? '', $env['env'] ?? []); |
| 611 | - } |
|
| 612 | - else { |
|
| 610 | + } else { |
|
| 613 | 611 | include_spip('src/Texte/Collecteur/AbstractCollecteur'); |
| 614 | 612 | include_spip('src/Texte/Collecteur/Liens'); |
| 615 | 613 | include_spip('src/Texte/Collecteur/Modeles'); |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/charsets'); |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | 43 | function importer_csv_importcharset($texte, $definir_charset_source = false) { |
| 44 | - // le plus frequent, en particulier avec les trucs de ms@@@ |
|
| 45 | - static $charset_source = 'iso-8859-1'; |
|
| 46 | - if ($definir_charset_source) { |
|
| 47 | - $charset_source = $definir_charset_source === true ? 'iso-8859-1' : $definir_charset_source; |
|
| 48 | - } |
|
| 49 | - // mais open-office sait faire mieux, donc mefiance ! |
|
| 50 | - $charset = is_utf8($texte) ? 'utf-8' : $charset_source; |
|
| 51 | - return importer_charset($texte, $charset); |
|
| 44 | + // le plus frequent, en particulier avec les trucs de ms@@@ |
|
| 45 | + static $charset_source = 'iso-8859-1'; |
|
| 46 | + if ($definir_charset_source) { |
|
| 47 | + $charset_source = $definir_charset_source === true ? 'iso-8859-1' : $definir_charset_source; |
|
| 48 | + } |
|
| 49 | + // mais open-office sait faire mieux, donc mefiance ! |
|
| 50 | + $charset = is_utf8($texte) ? 'utf-8' : $charset_source; |
|
| 51 | + return importer_charset($texte, $charset); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | 61 | function importer_csv_nettoie_key($key) { |
| 62 | - return translitteration($key); |
|
| 62 | + return translitteration($key); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -78,70 +78,70 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | function inc_importer_csv_dist($file, $options = []) { |
| 80 | 80 | |
| 81 | - // support ancienne syntaxe |
|
| 82 | - // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '') |
|
| 83 | - if (!is_array($options)) { |
|
| 84 | - $args = func_get_args(); |
|
| 85 | - $options = []; |
|
| 86 | - foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) { |
|
| 87 | - if (!empty($args[$k])) { |
|
| 88 | - $options[$option] = $args[$k]; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 81 | + // support ancienne syntaxe |
|
| 82 | + // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '') |
|
| 83 | + if (!is_array($options)) { |
|
| 84 | + $args = func_get_args(); |
|
| 85 | + $options = []; |
|
| 86 | + foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) { |
|
| 87 | + if (!empty($args[$k])) { |
|
| 88 | + $options[$option] = $args[$k]; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $default_options = [ |
|
| 94 | - 'head' => false, |
|
| 95 | - 'delim' => ',', |
|
| 96 | - 'enclos' => '"', |
|
| 97 | - 'len' => 10000, |
|
| 98 | - 'charset_source' => '', |
|
| 99 | - ]; |
|
| 100 | - $options = array_merge($default_options, $options); |
|
| 93 | + $default_options = [ |
|
| 94 | + 'head' => false, |
|
| 95 | + 'delim' => ',', |
|
| 96 | + 'enclos' => '"', |
|
| 97 | + 'len' => 10000, |
|
| 98 | + 'charset_source' => '', |
|
| 99 | + ]; |
|
| 100 | + $options = array_merge($default_options, $options); |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | - $return = []; |
|
| 104 | - if (@file_exists($file) && ($handle = fopen($file, 'r'))) { |
|
| 105 | - if ($options['charset_source']) { |
|
| 106 | - importer_csv_importcharset('', $options['charset_source']); |
|
| 107 | - } |
|
| 108 | - if ($options['head']) { |
|
| 109 | - $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']); |
|
| 110 | - if ($header) { |
|
| 111 | - $header = array_map('importer_csv_importcharset', $header); |
|
| 112 | - $header = array_map('importer_csv_nettoie_key', $header); |
|
| 113 | - $header_type = []; |
|
| 114 | - foreach ($header as $heading) { |
|
| 115 | - $header_type[$heading] = isset($header_type[$heading]) ? 'array' : 'scalar'; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 103 | + $return = []; |
|
| 104 | + if (@file_exists($file) && ($handle = fopen($file, 'r'))) { |
|
| 105 | + if ($options['charset_source']) { |
|
| 106 | + importer_csv_importcharset('', $options['charset_source']); |
|
| 107 | + } |
|
| 108 | + if ($options['head']) { |
|
| 109 | + $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']); |
|
| 110 | + if ($header) { |
|
| 111 | + $header = array_map('importer_csv_importcharset', $header); |
|
| 112 | + $header = array_map('importer_csv_nettoie_key', $header); |
|
| 113 | + $header_type = []; |
|
| 114 | + foreach ($header as $heading) { |
|
| 115 | + $header_type[$heading] = isset($header_type[$heading]) ? 'array' : 'scalar'; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) { |
|
| 121 | - $data = array_map('importer_csv_importcharset', $data); |
|
| 122 | - if ($options['head'] && isset($header)) { |
|
| 123 | - $row = []; |
|
| 124 | - foreach ($header as $key => $heading) { |
|
| 125 | - if ($header_type[$heading] == 'array') { |
|
| 126 | - if (!isset($row[$heading])) { |
|
| 127 | - $row[$heading] = []; |
|
| 128 | - } |
|
| 129 | - if (isset($data[$key]) && strlen($data[$key])) { |
|
| 130 | - $row[$heading][] = $data[$key]; |
|
| 131 | - } |
|
| 132 | - } else { |
|
| 133 | - $row[$heading] = $data[$key] ?? ''; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $return[] = $row; |
|
| 137 | - } else { |
|
| 138 | - $return[] = $data; |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - if ($options['charset_source']) { |
|
| 142 | - importer_csv_importcharset('', true); |
|
| 143 | - } |
|
| 144 | - } |
|
| 120 | + while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) { |
|
| 121 | + $data = array_map('importer_csv_importcharset', $data); |
|
| 122 | + if ($options['head'] && isset($header)) { |
|
| 123 | + $row = []; |
|
| 124 | + foreach ($header as $key => $heading) { |
|
| 125 | + if ($header_type[$heading] == 'array') { |
|
| 126 | + if (!isset($row[$heading])) { |
|
| 127 | + $row[$heading] = []; |
|
| 128 | + } |
|
| 129 | + if (isset($data[$key]) && strlen($data[$key])) { |
|
| 130 | + $row[$heading][] = $data[$key]; |
|
| 131 | + } |
|
| 132 | + } else { |
|
| 133 | + $row[$heading] = $data[$key] ?? ''; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $return[] = $row; |
|
| 137 | + } else { |
|
| 138 | + $return[] = $data; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + if ($options['charset_source']) { |
|
| 142 | + importer_csv_importcharset('', true); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - return $return ?: false; |
|
| 146 | + return $return ?: false; |
|
| 147 | 147 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Minipres |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) { |
| 37 | 37 | |
| 38 | - if ($onLoad) { |
|
| 39 | - include_spip('inc/filtres'); |
|
| 40 | - $onLoad = extraire_attribut("<body $onLoad>", 'onload'); |
|
| 41 | - } |
|
| 38 | + if ($onLoad) { |
|
| 39 | + include_spip('inc/filtres'); |
|
| 40 | + $onLoad = extraire_attribut("<body $onLoad>", 'onload'); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $options = [ |
|
| 44 | - 'all_inline' => $all_inline, |
|
| 45 | - 'onload' => $onLoad, |
|
| 46 | - 'titre' => $titre, |
|
| 47 | - ]; |
|
| 43 | + $options = [ |
|
| 44 | + 'all_inline' => $all_inline, |
|
| 45 | + 'onload' => $onLoad, |
|
| 46 | + 'titre' => $titre, |
|
| 47 | + ]; |
|
| 48 | 48 | |
| 49 | - $minipage = new Spip\Afficher\Minipage\Admin(); |
|
| 50 | - return $minipage->installDebutPage($options); |
|
| 49 | + $minipage = new Spip\Afficher\Minipage\Admin(); |
|
| 50 | + return $minipage->installDebutPage($options); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | * @return string Code HTML |
| 60 | 60 | */ |
| 61 | 61 | function install_fin_html() { |
| 62 | - $minipage = new Spip\Afficher\Minipage\Admin(); |
|
| 63 | - return $minipage->installFinPage(); |
|
| 62 | + $minipage = new Spip\Afficher\Minipage\Admin(); |
|
| 63 | + return $minipage->installFinPage(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
@@ -99,23 +99,23 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | function minipres($titre = '', $corps = '', $options = []) { |
| 101 | 101 | |
| 102 | - // compat signature old |
|
| 103 | - // minipres($titre='', $corps="", $onload='', $all_inline = false) |
|
| 104 | - $args = func_get_args(); |
|
| 105 | - if (isset($args[2]) && is_string($args[2])) { |
|
| 106 | - $options = ['onload' => $args[2]]; |
|
| 107 | - } |
|
| 108 | - if (isset($args[3])) { |
|
| 109 | - $options['all_inline'] = $args[3]; |
|
| 110 | - } |
|
| 102 | + // compat signature old |
|
| 103 | + // minipres($titre='', $corps="", $onload='', $all_inline = false) |
|
| 104 | + $args = func_get_args(); |
|
| 105 | + if (isset($args[2]) && is_string($args[2])) { |
|
| 106 | + $options = ['onload' => $args[2]]; |
|
| 107 | + } |
|
| 108 | + if (isset($args[3])) { |
|
| 109 | + $options['all_inline'] = $args[3]; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - $options = array_merge([ |
|
| 113 | - 'onload' => '', |
|
| 114 | - 'all_inline' => false, |
|
| 115 | - ], $options); |
|
| 112 | + $options = array_merge([ |
|
| 113 | + 'onload' => '', |
|
| 114 | + 'all_inline' => false, |
|
| 115 | + ], $options); |
|
| 116 | 116 | |
| 117 | - $options['titre'] = $titre; |
|
| 117 | + $options['titre'] = $titre; |
|
| 118 | 118 | |
| 119 | - $minipage = new Spip\Afficher\Minipage\Admin(); |
|
| 120 | - return $minipage->page($corps, $options); |
|
| 119 | + $minipage = new Spip\Afficher\Minipage\Admin(); |
|
| 120 | + return $minipage->page($corps, $options); |
|
| 121 | 121 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $_id_table = reset($_id_table); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $requete['SELECT'][] = 't.' . $_id_table; |
|
| 69 | + $requete['SELECT'][] = 't.'.$_id_table; |
|
| 70 | 70 | $a = []; |
| 71 | 71 | // Recherche fulltext |
| 72 | 72 | foreach ($champs as $champ => $poids) { |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | $champ = "t.$champ"; |
| 78 | 78 | } |
| 79 | 79 | $requete['SELECT'][] = $champ; |
| 80 | - $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 80 | + $a[] = $champ.' '.$methode.' '.$q; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | if ($a) { |
| 84 | 84 | $requete['WHERE'][] = implode(' OR ', $a); |
| 85 | 85 | } |
| 86 | - $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 86 | + $requete['FROM'][] = table_objet_sql($table).' AS t'; |
|
| 87 | 87 | |
| 88 | 88 | $results = []; |
| 89 | 89 | |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | ); |
| 245 | 245 | } // cas table de liaison generique spip_xxx_yyy |
| 246 | 246 | elseif ( |
| 247 | - ($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)) |
|
| 248 | - || ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)) |
|
| 247 | + ($t = $trouver_table($table_arrivee.'_'.$table_depart, $serveur)) |
|
| 248 | + || ($t = $trouver_table($table_depart.'_'.$table_arrivee, $serveur)) |
|
| 249 | 249 | ) { |
| 250 | 250 | $s = sql_select( |
| 251 | 251 | "$cle_depart,$cle_arrivee", |
@@ -284,12 +284,12 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | if (isset($joint['champs']) && $joint['champs']) { |
| 286 | 286 | foreach ($joint['champs'] as $c => $val) { |
| 287 | - $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 287 | + $results[$id]['champs'][$table_liee.'.'.$c] = $val; |
|
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | if (isset($joint['matches']) && $joint['matches']) { |
| 291 | 291 | foreach ($joint['matches'] as $c => $val) { |
| 292 | - $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 292 | + $results[$id]['matches'][$table_liee.'.'.$c] = $val; |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | } |
@@ -10,291 +10,291 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | // methodes sql |
| 18 | 18 | function inc_recherche_to_array_dist($recherche, $options = []) { |
| 19 | 19 | |
| 20 | - // options par defaut |
|
| 21 | - $options = array_merge( |
|
| 22 | - [ |
|
| 23 | - 'score' => true, |
|
| 24 | - 'champs' => false, |
|
| 25 | - 'toutvoir' => false, |
|
| 26 | - 'matches' => false, |
|
| 27 | - 'jointures' => false |
|
| 28 | - ], |
|
| 29 | - $options |
|
| 30 | - ); |
|
| 20 | + // options par defaut |
|
| 21 | + $options = array_merge( |
|
| 22 | + [ |
|
| 23 | + 'score' => true, |
|
| 24 | + 'champs' => false, |
|
| 25 | + 'toutvoir' => false, |
|
| 26 | + 'matches' => false, |
|
| 27 | + 'jointures' => false |
|
| 28 | + ], |
|
| 29 | + $options |
|
| 30 | + ); |
|
| 31 | 31 | |
| 32 | - include_spip('inc/rechercher'); |
|
| 33 | - include_spip('inc/autoriser'); |
|
| 32 | + include_spip('inc/rechercher'); |
|
| 33 | + include_spip('inc/autoriser'); |
|
| 34 | 34 | |
| 35 | - $requete = [ |
|
| 36 | - 'SELECT' => [], |
|
| 37 | - 'FROM' => [], |
|
| 38 | - 'WHERE' => [], |
|
| 39 | - 'GROUPBY' => [], |
|
| 40 | - 'ORDERBY' => [], |
|
| 41 | - 'LIMIT' => '', |
|
| 42 | - 'HAVING' => [] |
|
| 43 | - ]; |
|
| 35 | + $requete = [ |
|
| 36 | + 'SELECT' => [], |
|
| 37 | + 'FROM' => [], |
|
| 38 | + 'WHERE' => [], |
|
| 39 | + 'GROUPBY' => [], |
|
| 40 | + 'ORDERBY' => [], |
|
| 41 | + 'LIMIT' => '', |
|
| 42 | + 'HAVING' => [] |
|
| 43 | + ]; |
|
| 44 | 44 | |
| 45 | - $table = sinon($options['table'], 'article'); |
|
| 46 | - if ($options['champs']) { |
|
| 47 | - $champs = $options['champs']; |
|
| 48 | - } else { |
|
| 49 | - $l = liste_des_champs(); |
|
| 50 | - $champs = $l['article']; |
|
| 51 | - } |
|
| 52 | - $serveur = $options['serveur']; |
|
| 45 | + $table = sinon($options['table'], 'article'); |
|
| 46 | + if ($options['champs']) { |
|
| 47 | + $champs = $options['champs']; |
|
| 48 | + } else { |
|
| 49 | + $l = liste_des_champs(); |
|
| 50 | + $champs = $l['article']; |
|
| 51 | + } |
|
| 52 | + $serveur = $options['serveur']; |
|
| 53 | 53 | |
| 54 | - [$methode, $q, $preg] = expression_recherche($recherche, $options); |
|
| 54 | + [$methode, $q, $preg] = expression_recherche($recherche, $options); |
|
| 55 | 55 | |
| 56 | - $jointures = $options['jointures'] |
|
| 57 | - ? liste_des_jointures() |
|
| 58 | - : []; |
|
| 56 | + $jointures = $options['jointures'] |
|
| 57 | + ? liste_des_jointures() |
|
| 58 | + : []; |
|
| 59 | 59 | |
| 60 | - $_id_table = id_table_objet($table); |
|
| 60 | + $_id_table = id_table_objet($table); |
|
| 61 | 61 | |
| 62 | - // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 63 | - // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 64 | - if (str_contains((string) $_id_table, ',')) { |
|
| 65 | - $_id_table = explode(',', (string) $_id_table); |
|
| 66 | - $_id_table = reset($_id_table); |
|
| 67 | - } |
|
| 62 | + // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ',' |
|
| 63 | + // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs) |
|
| 64 | + if (str_contains((string) $_id_table, ',')) { |
|
| 65 | + $_id_table = explode(',', (string) $_id_table); |
|
| 66 | + $_id_table = reset($_id_table); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $requete['SELECT'][] = 't.' . $_id_table; |
|
| 70 | - $a = []; |
|
| 71 | - // Recherche fulltext |
|
| 72 | - foreach ($champs as $champ => $poids) { |
|
| 73 | - if (is_array($champ)) { |
|
| 74 | - spip_log('requetes imbriquees interdites'); |
|
| 75 | - } else { |
|
| 76 | - if (!str_contains((string) $champ, '.')) { |
|
| 77 | - $champ = "t.$champ"; |
|
| 78 | - } |
|
| 79 | - $requete['SELECT'][] = $champ; |
|
| 80 | - $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - if ($a) { |
|
| 84 | - $requete['WHERE'][] = implode(' OR ', $a); |
|
| 85 | - } |
|
| 86 | - $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 69 | + $requete['SELECT'][] = 't.' . $_id_table; |
|
| 70 | + $a = []; |
|
| 71 | + // Recherche fulltext |
|
| 72 | + foreach ($champs as $champ => $poids) { |
|
| 73 | + if (is_array($champ)) { |
|
| 74 | + spip_log('requetes imbriquees interdites'); |
|
| 75 | + } else { |
|
| 76 | + if (!str_contains((string) $champ, '.')) { |
|
| 77 | + $champ = "t.$champ"; |
|
| 78 | + } |
|
| 79 | + $requete['SELECT'][] = $champ; |
|
| 80 | + $a[] = $champ . ' ' . $methode . ' ' . $q; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + if ($a) { |
|
| 84 | + $requete['WHERE'][] = implode(' OR ', $a); |
|
| 85 | + } |
|
| 86 | + $requete['FROM'][] = table_objet_sql($table) . ' AS t'; |
|
| 87 | 87 | |
| 88 | - $results = []; |
|
| 88 | + $results = []; |
|
| 89 | 89 | |
| 90 | - $s = sql_select( |
|
| 91 | - $requete['SELECT'], |
|
| 92 | - $requete['FROM'], |
|
| 93 | - $requete['WHERE'], |
|
| 94 | - implode(' ', $requete['GROUPBY']), |
|
| 95 | - $requete['ORDERBY'], |
|
| 96 | - $requete['LIMIT'], |
|
| 97 | - $requete['HAVING'], |
|
| 98 | - $serveur |
|
| 99 | - ); |
|
| 90 | + $s = sql_select( |
|
| 91 | + $requete['SELECT'], |
|
| 92 | + $requete['FROM'], |
|
| 93 | + $requete['WHERE'], |
|
| 94 | + implode(' ', $requete['GROUPBY']), |
|
| 95 | + $requete['ORDERBY'], |
|
| 96 | + $requete['LIMIT'], |
|
| 97 | + $requete['HAVING'], |
|
| 98 | + $serveur |
|
| 99 | + ); |
|
| 100 | 100 | |
| 101 | - while ( |
|
| 102 | - ($t = sql_fetch($s, $serveur)) |
|
| 103 | - && (!isset($t['score']) || $t['score'] > 0) |
|
| 104 | - ) { |
|
| 105 | - $id = (int) $t[$_id_table]; |
|
| 101 | + while ( |
|
| 102 | + ($t = sql_fetch($s, $serveur)) |
|
| 103 | + && (!isset($t['score']) || $t['score'] > 0) |
|
| 104 | + ) { |
|
| 105 | + $id = (int) $t[$_id_table]; |
|
| 106 | 106 | |
| 107 | - if ($options['toutvoir'] || autoriser('voir', $table, $id)) { |
|
| 108 | - // indiquer les champs concernes |
|
| 109 | - $champs_vus = []; |
|
| 110 | - $score = 0; |
|
| 111 | - $matches = []; |
|
| 107 | + if ($options['toutvoir'] || autoriser('voir', $table, $id)) { |
|
| 108 | + // indiquer les champs concernes |
|
| 109 | + $champs_vus = []; |
|
| 110 | + $score = 0; |
|
| 111 | + $matches = []; |
|
| 112 | 112 | |
| 113 | - $vu = false; |
|
| 114 | - foreach ($champs as $champ => $poids) { |
|
| 115 | - $champ = explode('.', (string) $champ); |
|
| 116 | - $champ = end($champ); |
|
| 117 | - // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 118 | - $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 119 | - if ( |
|
| 120 | - $n = |
|
| 121 | - ($options['score'] || $options['matches']) |
|
| 122 | - ? preg_match_all($preg, (string) $value, $regs, PREG_SET_ORDER) |
|
| 123 | - : preg_match($preg, (string) $value) |
|
| 124 | - ) { |
|
| 125 | - $vu = true; |
|
| 113 | + $vu = false; |
|
| 114 | + foreach ($champs as $champ => $poids) { |
|
| 115 | + $champ = explode('.', (string) $champ); |
|
| 116 | + $champ = end($champ); |
|
| 117 | + // translitteration_rapide uniquement si on est deja en utf-8 |
|
| 118 | + $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ])); |
|
| 119 | + if ( |
|
| 120 | + $n = |
|
| 121 | + ($options['score'] || $options['matches']) |
|
| 122 | + ? preg_match_all($preg, (string) $value, $regs, PREG_SET_ORDER) |
|
| 123 | + : preg_match($preg, (string) $value) |
|
| 124 | + ) { |
|
| 125 | + $vu = true; |
|
| 126 | 126 | |
| 127 | - if ($options['champs']) { |
|
| 128 | - $champs_vus[$champ] = $t[$champ]; |
|
| 129 | - } |
|
| 130 | - if ($options['score']) { |
|
| 131 | - // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars |
|
| 132 | - $score += $poids * strlen(implode('', array_column($regs, 0))); |
|
| 133 | - } |
|
| 127 | + if ($options['champs']) { |
|
| 128 | + $champs_vus[$champ] = $t[$champ]; |
|
| 129 | + } |
|
| 130 | + if ($options['score']) { |
|
| 131 | + // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars |
|
| 132 | + $score += $poids * strlen(implode('', array_column($regs, 0))); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if ($options['matches']) { |
|
| 136 | - $matches[$champ] = $regs; |
|
| 137 | - } |
|
| 135 | + if ($options['matches']) { |
|
| 136 | + $matches[$champ] = $regs; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - if (!$options['champs'] && !$options['score'] && !$options['matches']) { |
|
| 140 | - break; |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 139 | + if (!$options['champs'] && !$options['score'] && !$options['matches']) { |
|
| 140 | + break; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ($vu) { |
|
| 146 | - if (!isset($results)) { |
|
| 147 | - $results = []; |
|
| 148 | - } |
|
| 149 | - $results[$id] = []; |
|
| 150 | - if ($champs_vus) { |
|
| 151 | - $results[$id]['champs'] = $champs_vus; |
|
| 152 | - } |
|
| 153 | - if ($score) { |
|
| 154 | - $results[$id]['score'] = $score; |
|
| 155 | - } |
|
| 156 | - if ($matches) { |
|
| 157 | - $results[$id]['matches'] = $matches; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 145 | + if ($vu) { |
|
| 146 | + if (!isset($results)) { |
|
| 147 | + $results = []; |
|
| 148 | + } |
|
| 149 | + $results[$id] = []; |
|
| 150 | + if ($champs_vus) { |
|
| 151 | + $results[$id]['champs'] = $champs_vus; |
|
| 152 | + } |
|
| 153 | + if ($score) { |
|
| 154 | + $results[$id]['score'] = $score; |
|
| 155 | + } |
|
| 156 | + if ($matches) { |
|
| 157 | + $results[$id]['matches'] = $matches; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | |
| 164 | - // Gerer les donnees associees |
|
| 165 | - // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 166 | - // on ne sait passer que par table de laison en 1 coup |
|
| 167 | - if ( |
|
| 168 | - isset($jointures[$table]) |
|
| 169 | - && ($joints = recherche_en_base( |
|
| 170 | - $recherche, |
|
| 171 | - $jointures[$table], |
|
| 172 | - array_merge($options, ['jointures' => false]) |
|
| 173 | - )) |
|
| 174 | - ) { |
|
| 175 | - include_spip('action/editer_liens'); |
|
| 176 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 177 | - $cle_depart = id_table_objet($table); |
|
| 178 | - $table_depart = table_objet($table, $serveur); |
|
| 179 | - $desc_depart = $trouver_table($table_depart, $serveur); |
|
| 180 | - $depart_associable = objet_associable($table); |
|
| 181 | - foreach ($joints as $table_liee => $ids_trouves) { |
|
| 182 | - // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 183 | - if ( |
|
| 184 | - !( |
|
| 185 | - ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true)) |
|
| 186 | - || ($rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true)) |
|
| 187 | - || ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true)) |
|
| 188 | - ) |
|
| 189 | - ) { |
|
| 190 | - $cle_arrivee = id_table_objet($table_liee); |
|
| 191 | - $table_arrivee = table_objet($table_liee, $serveur); |
|
| 192 | - $desc_arrivee = $trouver_table($table_arrivee, $serveur); |
|
| 193 | - // cas simple : $cle_depart dans la table_liee |
|
| 194 | - if (isset($desc_arrivee['field'][$cle_depart])) { |
|
| 195 | - $s = sql_select( |
|
| 196 | - "$cle_depart, $cle_arrivee", |
|
| 197 | - $desc_arrivee['table_sql'], |
|
| 198 | - sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 199 | - '', |
|
| 200 | - '', |
|
| 201 | - '', |
|
| 202 | - '', |
|
| 203 | - $serveur |
|
| 204 | - ); |
|
| 205 | - } // cas simple : $cle_arrivee dans la table |
|
| 206 | - elseif (isset($desc_depart['field'][$cle_arrivee])) { |
|
| 207 | - $s = sql_select( |
|
| 208 | - "$cle_depart, $cle_arrivee", |
|
| 209 | - $desc_depart['table_sql'], |
|
| 210 | - sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 211 | - '', |
|
| 212 | - '', |
|
| 213 | - '', |
|
| 214 | - '', |
|
| 215 | - $serveur |
|
| 216 | - ); |
|
| 217 | - } |
|
| 218 | - // sinon cherchons une table de liaison |
|
| 219 | - // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 220 | - elseif ($l = objet_associable($table_liee)) { |
|
| 221 | - [$primary, $table_liens] = $l; |
|
| 222 | - $s = sql_select( |
|
| 223 | - "id_objet as $cle_depart, $primary as $cle_arrivee", |
|
| 224 | - $table_liens, |
|
| 225 | - ["objet='$table'", sql_in($primary, array_keys($ids_trouves))], |
|
| 226 | - '', |
|
| 227 | - '', |
|
| 228 | - '', |
|
| 229 | - '', |
|
| 230 | - $serveur |
|
| 231 | - ); |
|
| 232 | - } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 233 | - elseif ($l = $depart_associable) { |
|
| 234 | - [$primary, $table_liens] = $l; |
|
| 235 | - $s = sql_select( |
|
| 236 | - "$primary as $cle_depart, id_objet as $cle_arrivee", |
|
| 237 | - $table_liens, |
|
| 238 | - ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))], |
|
| 239 | - '', |
|
| 240 | - '', |
|
| 241 | - '', |
|
| 242 | - '', |
|
| 243 | - $serveur |
|
| 244 | - ); |
|
| 245 | - } // cas table de liaison generique spip_xxx_yyy |
|
| 246 | - elseif ( |
|
| 247 | - ($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)) |
|
| 248 | - || ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)) |
|
| 249 | - ) { |
|
| 250 | - $s = sql_select( |
|
| 251 | - "$cle_depart,$cle_arrivee", |
|
| 252 | - $t['table_sql'], |
|
| 253 | - sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 254 | - '', |
|
| 255 | - '', |
|
| 256 | - '', |
|
| 257 | - '', |
|
| 258 | - $serveur |
|
| 259 | - ); |
|
| 260 | - } |
|
| 261 | - } else { |
|
| 262 | - [$cle_depart, $cle_arrivee, $s] = $rechercher_joints( |
|
| 263 | - $table, |
|
| 264 | - $table_liee, |
|
| 265 | - array_keys($ids_trouves), |
|
| 266 | - $serveur |
|
| 267 | - ); |
|
| 268 | - } |
|
| 164 | + // Gerer les donnees associees |
|
| 165 | + // ici on est un peu naze : pas capables de reconstruire une jointure complexe |
|
| 166 | + // on ne sait passer que par table de laison en 1 coup |
|
| 167 | + if ( |
|
| 168 | + isset($jointures[$table]) |
|
| 169 | + && ($joints = recherche_en_base( |
|
| 170 | + $recherche, |
|
| 171 | + $jointures[$table], |
|
| 172 | + array_merge($options, ['jointures' => false]) |
|
| 173 | + )) |
|
| 174 | + ) { |
|
| 175 | + include_spip('action/editer_liens'); |
|
| 176 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 177 | + $cle_depart = id_table_objet($table); |
|
| 178 | + $table_depart = table_objet($table, $serveur); |
|
| 179 | + $desc_depart = $trouver_table($table_depart, $serveur); |
|
| 180 | + $depart_associable = objet_associable($table); |
|
| 181 | + foreach ($joints as $table_liee => $ids_trouves) { |
|
| 182 | + // on peut definir une fonction de recherche jointe pour regler les cas particuliers |
|
| 183 | + if ( |
|
| 184 | + !( |
|
| 185 | + ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true)) |
|
| 186 | + || ($rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true)) |
|
| 187 | + || ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true)) |
|
| 188 | + ) |
|
| 189 | + ) { |
|
| 190 | + $cle_arrivee = id_table_objet($table_liee); |
|
| 191 | + $table_arrivee = table_objet($table_liee, $serveur); |
|
| 192 | + $desc_arrivee = $trouver_table($table_arrivee, $serveur); |
|
| 193 | + // cas simple : $cle_depart dans la table_liee |
|
| 194 | + if (isset($desc_arrivee['field'][$cle_depart])) { |
|
| 195 | + $s = sql_select( |
|
| 196 | + "$cle_depart, $cle_arrivee", |
|
| 197 | + $desc_arrivee['table_sql'], |
|
| 198 | + sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 199 | + '', |
|
| 200 | + '', |
|
| 201 | + '', |
|
| 202 | + '', |
|
| 203 | + $serveur |
|
| 204 | + ); |
|
| 205 | + } // cas simple : $cle_arrivee dans la table |
|
| 206 | + elseif (isset($desc_depart['field'][$cle_arrivee])) { |
|
| 207 | + $s = sql_select( |
|
| 208 | + "$cle_depart, $cle_arrivee", |
|
| 209 | + $desc_depart['table_sql'], |
|
| 210 | + sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 211 | + '', |
|
| 212 | + '', |
|
| 213 | + '', |
|
| 214 | + '', |
|
| 215 | + $serveur |
|
| 216 | + ); |
|
| 217 | + } |
|
| 218 | + // sinon cherchons une table de liaison |
|
| 219 | + // cas recherche principale article, objet lie document : passer par spip_documents_liens |
|
| 220 | + elseif ($l = objet_associable($table_liee)) { |
|
| 221 | + [$primary, $table_liens] = $l; |
|
| 222 | + $s = sql_select( |
|
| 223 | + "id_objet as $cle_depart, $primary as $cle_arrivee", |
|
| 224 | + $table_liens, |
|
| 225 | + ["objet='$table'", sql_in($primary, array_keys($ids_trouves))], |
|
| 226 | + '', |
|
| 227 | + '', |
|
| 228 | + '', |
|
| 229 | + '', |
|
| 230 | + $serveur |
|
| 231 | + ); |
|
| 232 | + } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens |
|
| 233 | + elseif ($l = $depart_associable) { |
|
| 234 | + [$primary, $table_liens] = $l; |
|
| 235 | + $s = sql_select( |
|
| 236 | + "$primary as $cle_depart, id_objet as $cle_arrivee", |
|
| 237 | + $table_liens, |
|
| 238 | + ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))], |
|
| 239 | + '', |
|
| 240 | + '', |
|
| 241 | + '', |
|
| 242 | + '', |
|
| 243 | + $serveur |
|
| 244 | + ); |
|
| 245 | + } // cas table de liaison generique spip_xxx_yyy |
|
| 246 | + elseif ( |
|
| 247 | + ($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)) |
|
| 248 | + || ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)) |
|
| 249 | + ) { |
|
| 250 | + $s = sql_select( |
|
| 251 | + "$cle_depart,$cle_arrivee", |
|
| 252 | + $t['table_sql'], |
|
| 253 | + sql_in($cle_arrivee, array_keys($ids_trouves)), |
|
| 254 | + '', |
|
| 255 | + '', |
|
| 256 | + '', |
|
| 257 | + '', |
|
| 258 | + $serveur |
|
| 259 | + ); |
|
| 260 | + } |
|
| 261 | + } else { |
|
| 262 | + [$cle_depart, $cle_arrivee, $s] = $rechercher_joints( |
|
| 263 | + $table, |
|
| 264 | + $table_liee, |
|
| 265 | + array_keys($ids_trouves), |
|
| 266 | + $serveur |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) { |
|
| 271 | - $id = $t[$cle_depart]; |
|
| 272 | - $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 273 | - if (!isset($results)) { |
|
| 274 | - $results = []; |
|
| 275 | - } |
|
| 276 | - if (!isset($results[$id])) { |
|
| 277 | - $results[$id] = []; |
|
| 278 | - } |
|
| 279 | - if (isset($joint['score']) && $joint['score']) { |
|
| 280 | - if (!isset($results[$id]['score'])) { |
|
| 281 | - $results[$id]['score'] = 0; |
|
| 282 | - } |
|
| 283 | - $results[$id]['score'] += $joint['score']; |
|
| 284 | - } |
|
| 285 | - if (isset($joint['champs']) && $joint['champs']) { |
|
| 286 | - foreach ($joint['champs'] as $c => $val) { |
|
| 287 | - $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - if (isset($joint['matches']) && $joint['matches']) { |
|
| 291 | - foreach ($joint['matches'] as $c => $val) { |
|
| 292 | - $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - } |
|
| 270 | + while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) { |
|
| 271 | + $id = $t[$cle_depart]; |
|
| 272 | + $joint = $ids_trouves[$t[$cle_arrivee]]; |
|
| 273 | + if (!isset($results)) { |
|
| 274 | + $results = []; |
|
| 275 | + } |
|
| 276 | + if (!isset($results[$id])) { |
|
| 277 | + $results[$id] = []; |
|
| 278 | + } |
|
| 279 | + if (isset($joint['score']) && $joint['score']) { |
|
| 280 | + if (!isset($results[$id]['score'])) { |
|
| 281 | + $results[$id]['score'] = 0; |
|
| 282 | + } |
|
| 283 | + $results[$id]['score'] += $joint['score']; |
|
| 284 | + } |
|
| 285 | + if (isset($joint['champs']) && $joint['champs']) { |
|
| 286 | + foreach ($joint['champs'] as $c => $val) { |
|
| 287 | + $results[$id]['champs'][$table_liee . '.' . $c] = $val; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + if (isset($joint['matches']) && $joint['matches']) { |
|
| 291 | + foreach ($joint['matches'] as $c => $val) { |
|
| 292 | + $results[$id]['matches'][$table_liee . '.' . $c] = $val; |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - return $results; |
|
| 299 | + return $results; |
|
| 300 | 300 | } |