@@ -10,76 +10,76 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | # Les information d'une rubrique selectionnee dans le mini navigateur |
| 17 | 17 | |
| 18 | 18 | function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') { |
| 19 | - include_spip('inc/texte'); |
|
| 20 | - $titre = $descriptif = ''; |
|
| 21 | - if ($type === 'rubrique') { |
|
| 22 | - $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . (int) $id); |
|
| 23 | - if ($row) { |
|
| 24 | - $titre = typo($row['titre']); |
|
| 25 | - $descriptif = propre($row['descriptif']); |
|
| 26 | - } else { |
|
| 27 | - $titre = _T('info_racine_site'); |
|
| 28 | - } |
|
| 29 | - } |
|
| 19 | + include_spip('inc/texte'); |
|
| 20 | + $titre = $descriptif = ''; |
|
| 21 | + if ($type === 'rubrique') { |
|
| 22 | + $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . (int) $id); |
|
| 23 | + if ($row) { |
|
| 24 | + $titre = typo($row['titre']); |
|
| 25 | + $descriptif = propre($row['descriptif']); |
|
| 26 | + } else { |
|
| 27 | + $titre = _T('info_racine_site'); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $res = ''; |
|
| 32 | - if ( |
|
| 33 | - $type === 'rubrique' |
|
| 34 | - && (int) ($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1 |
|
| 35 | - && isset($GLOBALS['meta']['image_process']) |
|
| 36 | - && $GLOBALS['meta']['image_process'] !== 'non' |
|
| 37 | - ) { |
|
| 38 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 39 | - if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 40 | - [$fid, $dir, $nom, $format] = $res; |
|
| 41 | - include_spip('inc/filtres_images_mini'); |
|
| 42 | - $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 43 | - if ($res) { |
|
| 44 | - $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 31 | + $res = ''; |
|
| 32 | + if ( |
|
| 33 | + $type === 'rubrique' |
|
| 34 | + && (int) ($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1 |
|
| 35 | + && isset($GLOBALS['meta']['image_process']) |
|
| 36 | + && $GLOBALS['meta']['image_process'] !== 'non' |
|
| 37 | + ) { |
|
| 38 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 39 | + if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 40 | + [$fid, $dir, $nom, $format] = $res; |
|
| 41 | + include_spip('inc/filtres_images_mini'); |
|
| 42 | + $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 43 | + if ($res) { |
|
| 44 | + $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 50 | - $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 51 | - $id = (int) $id; |
|
| 49 | + $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 50 | + $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 51 | + $id = (int) $id; |
|
| 52 | 52 | |
| 53 | 53 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 54 | 54 | # et l'affichage de son titre dans le bandeau |
| 55 | - $titre = strtr( |
|
| 56 | - str_replace( |
|
| 57 | - "'", |
|
| 58 | - '’', |
|
| 59 | - str_replace('"', '"', (string) textebrut($titre)) |
|
| 60 | - ), |
|
| 61 | - "\n\r", |
|
| 62 | - ' ' |
|
| 63 | - ); |
|
| 55 | + $titre = strtr( |
|
| 56 | + str_replace( |
|
| 57 | + "'", |
|
| 58 | + '’', |
|
| 59 | + str_replace('"', '"', (string) textebrut($titre)) |
|
| 60 | + ), |
|
| 61 | + "\n\r", |
|
| 62 | + ' ' |
|
| 63 | + ); |
|
| 64 | 64 | |
| 65 | - $js_func = $do . '_selection_titre'; |
|
| 65 | + $js_func = $do . '_selection_titre'; |
|
| 66 | 66 | |
| 67 | - return "<div style='display: none;'>" |
|
| 68 | - . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 69 | - . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 70 | - . entites_html($titre) |
|
| 71 | - . '" />' |
|
| 72 | - . '</div>' |
|
| 73 | - . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 74 | - . '<div class="informer__item">' |
|
| 75 | - . ($res ?: '') |
|
| 76 | - . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 77 | - . ($descriptif ? "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>' : '') |
|
| 78 | - . '</div>' |
|
| 79 | - . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 80 | - . "<input type='submit' class='fondo btn submit' value='" |
|
| 81 | - . _T('bouton_choisir') |
|
| 82 | - . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 83 | - . '</div>' |
|
| 84 | - . '</div>'; |
|
| 67 | + return "<div style='display: none;'>" |
|
| 68 | + . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 69 | + . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 70 | + . entites_html($titre) |
|
| 71 | + . '" />' |
|
| 72 | + . '</div>' |
|
| 73 | + . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 74 | + . '<div class="informer__item">' |
|
| 75 | + . ($res ?: '') |
|
| 76 | + . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>' |
|
| 77 | + . ($descriptif ? "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>' : '') |
|
| 78 | + . '</div>' |
|
| 79 | + . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 80 | + . "<input type='submit' class='fondo btn submit' value='" |
|
| 81 | + . _T('bouton_choisir') |
|
| 82 | + . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 83 | + . '</div>' |
|
| 84 | + . '</div>'; |
|
| 85 | 85 | } |
@@ -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 | } |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_SPIP_SELECT_RUBRIQUES')) { |
| 24 | - /** |
|
| 25 | - * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 26 | - * Au delà, on bascule sur un sélecteur ajax. |
|
| 27 | - * mettre 100000 pour desactiver ajax |
|
| 28 | - */ |
|
| 29 | - define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 24 | + /** |
|
| 25 | + * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 26 | + * Au delà, on bascule sur un sélecteur ajax. |
|
| 27 | + * mettre 100000 pour desactiver ajax |
|
| 28 | + */ |
|
| 29 | + define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -54,22 +54,22 @@ discard block |
||
| 54 | 54 | * Code HTML du sélecteur |
| 55 | 55 | **/ |
| 56 | 56 | function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 57 | - if (sql_countsel('spip_rubriques') < 1) { |
|
| 58 | - return ''; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - // Mode sans Ajax : |
|
| 62 | - // - soit parce que le cookie ajax n'est pas la |
|
| 63 | - // - soit parce qu'il y a peu de rubriques |
|
| 64 | - if ( |
|
| 65 | - _SPIP_AJAX < 1 |
|
| 66 | - || $type == 'breve' |
|
| 67 | - || sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 68 | - ) { |
|
| 69 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 70 | - } else { |
|
| 71 | - return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 72 | - } |
|
| 57 | + if (sql_countsel('spip_rubriques') < 1) { |
|
| 58 | + return ''; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + // Mode sans Ajax : |
|
| 62 | + // - soit parce que le cookie ajax n'est pas la |
|
| 63 | + // - soit parce qu'il y a peu de rubriques |
|
| 64 | + if ( |
|
| 65 | + _SPIP_AJAX < 1 |
|
| 66 | + || $type == 'breve' |
|
| 67 | + || sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 68 | + ) { |
|
| 69 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 70 | + } else { |
|
| 71 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // compatibilite pour extensions qui utilisaient l'ancien nom |
@@ -86,17 +86,17 @@ discard block |
||
| 86 | 86 | **/ |
| 87 | 87 | function style_menu_rubriques($i) { |
| 88 | 88 | |
| 89 | - $espace = ''; |
|
| 90 | - $style = ''; |
|
| 91 | - for ($count = 1; $count <= $i; $count++) { |
|
| 92 | - $espace .= ' '; |
|
| 93 | - } |
|
| 94 | - if ($i == 1) { |
|
| 95 | - $espace = ''; |
|
| 96 | - } |
|
| 97 | - $class = "niveau_$i"; |
|
| 98 | - |
|
| 99 | - return [$class, $style, $espace]; |
|
| 89 | + $espace = ''; |
|
| 90 | + $style = ''; |
|
| 91 | + for ($count = 1; $count <= $i; $count++) { |
|
| 92 | + $espace .= ' '; |
|
| 93 | + } |
|
| 94 | + if ($i == 1) { |
|
| 95 | + $espace = ''; |
|
| 96 | + } |
|
| 97 | + $class = "niveau_$i"; |
|
| 98 | + |
|
| 99 | + return [$class, $style, $espace]; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -120,57 +120,57 @@ discard block |
||
| 120 | 120 | * Code HTML du sélecteur |
| 121 | 121 | **/ |
| 122 | 122 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 123 | - static $decalage_secteur; |
|
| 124 | - |
|
| 125 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 126 | - if ($exclus > 0 && $root == $exclus) { |
|
| 127 | - return ''; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 131 | - |
|
| 132 | - // selected ? |
|
| 133 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 134 | - |
|
| 135 | - // le style en fonction de la profondeur |
|
| 136 | - [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 137 | - |
|
| 138 | - $class .= ' selec_rub'; |
|
| 139 | - |
|
| 140 | - // creer l'<option> pour la rubrique $root |
|
| 141 | - |
|
| 142 | - if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 143 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 144 | - . $data[$root] |
|
| 145 | - . '</option>' . "\n"; |
|
| 146 | - } else { |
|
| 147 | - $r = ''; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - // et le sous-menu pour ses enfants |
|
| 151 | - $sous = ''; |
|
| 152 | - if (isset($enfants[$root])) { |
|
| 153 | - foreach ($enfants[$root] as $sousrub) { |
|
| 154 | - $sous .= sous_menu_rubriques( |
|
| 155 | - $id_rubrique, |
|
| 156 | - $sousrub, |
|
| 157 | - $niv + 1, |
|
| 158 | - $data, |
|
| 159 | - $enfants, |
|
| 160 | - $exclus, |
|
| 161 | - $restreint, |
|
| 162 | - $type |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 168 | - if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) { |
|
| 169 | - return $sous; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - // et voila le travail |
|
| 173 | - return $r . $sous; |
|
| 123 | + static $decalage_secteur; |
|
| 124 | + |
|
| 125 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 126 | + if ($exclus > 0 && $root == $exclus) { |
|
| 127 | + return ''; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 131 | + |
|
| 132 | + // selected ? |
|
| 133 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 134 | + |
|
| 135 | + // le style en fonction de la profondeur |
|
| 136 | + [$class, $style, $espace] = style_menu_rubriques($niv); |
|
| 137 | + |
|
| 138 | + $class .= ' selec_rub'; |
|
| 139 | + |
|
| 140 | + // creer l'<option> pour la rubrique $root |
|
| 141 | + |
|
| 142 | + if (isset($data[$root])) { # pas de racine sauf pour les rubriques |
|
| 143 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 144 | + . $data[$root] |
|
| 145 | + . '</option>' . "\n"; |
|
| 146 | + } else { |
|
| 147 | + $r = ''; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + // et le sous-menu pour ses enfants |
|
| 151 | + $sous = ''; |
|
| 152 | + if (isset($enfants[$root])) { |
|
| 153 | + foreach ($enfants[$root] as $sousrub) { |
|
| 154 | + $sous .= sous_menu_rubriques( |
|
| 155 | + $id_rubrique, |
|
| 156 | + $sousrub, |
|
| 157 | + $niv + 1, |
|
| 158 | + $data, |
|
| 159 | + $enfants, |
|
| 160 | + $exclus, |
|
| 161 | + $restreint, |
|
| 162 | + $type |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 168 | + if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) { |
|
| 169 | + return $sous; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + // et voila le travail |
|
| 173 | + return $r . $sous; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -191,75 +191,75 @@ discard block |
||
| 191 | 191 | * Code HTML du sélecteur |
| 192 | 192 | **/ |
| 193 | 193 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
| 194 | - $enfants = []; |
|
| 195 | - $data = []; |
|
| 196 | - if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) { |
|
| 197 | - $data[0] = _T('info_racine_site'); |
|
| 198 | - } |
|
| 199 | - # premier choix = neant |
|
| 200 | - # si auteur (rubriques restreintes) |
|
| 201 | - # ou si creation avec id_rubrique=0 |
|
| 202 | - elseif ($type == 'auteur' || !$id_rubrique) { |
|
| 203 | - $data[0] = ' '; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - // |
|
| 207 | - // creer une structure contenant toute l'arborescence |
|
| 208 | - // |
|
| 209 | - |
|
| 210 | - include_spip('base/abstract_sql'); |
|
| 211 | - $q = sql_select( |
|
| 212 | - 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 213 | - 'spip_rubriques', |
|
| 214 | - ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 215 | - '', |
|
| 216 | - '0+titre,titre' |
|
| 217 | - ); |
|
| 218 | - while ($r = sql_fetch($q)) { |
|
| 219 | - if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 220 | - // titre largeur maxi a 50 |
|
| 221 | - $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 222 | - if ( |
|
| 223 | - $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 224 | - && ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0) |
|
| 225 | - ) { |
|
| 226 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 227 | - } |
|
| 228 | - $data[$r['id_rubrique']] = $titre; |
|
| 229 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 230 | - if ($id_rubrique == $r['id_rubrique']) { |
|
| 231 | - $id_parent = $r['id_parent']; |
|
| 232 | - } |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - // si une seule rubrique comme choix possible, |
|
| 237 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 238 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 239 | - if ( |
|
| 240 | - count($data) == 2 |
|
| 241 | - && isset($data[0]) |
|
| 242 | - && !in_array($type, ['auteur', 'rubrique']) |
|
| 243 | - && !$id_rubrique |
|
| 244 | - ) { |
|
| 245 | - unset($data[0]); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 250 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 251 | - |
|
| 252 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 253 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 254 | - } else { |
|
| 255 | - $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - # message pour neuneus (a supprimer ?) |
|
| 194 | + $enfants = []; |
|
| 195 | + $data = []; |
|
| 196 | + if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) { |
|
| 197 | + $data[0] = _T('info_racine_site'); |
|
| 198 | + } |
|
| 199 | + # premier choix = neant |
|
| 200 | + # si auteur (rubriques restreintes) |
|
| 201 | + # ou si creation avec id_rubrique=0 |
|
| 202 | + elseif ($type == 'auteur' || !$id_rubrique) { |
|
| 203 | + $data[0] = ' '; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + // |
|
| 207 | + // creer une structure contenant toute l'arborescence |
|
| 208 | + // |
|
| 209 | + |
|
| 210 | + include_spip('base/abstract_sql'); |
|
| 211 | + $q = sql_select( |
|
| 212 | + 'id_rubrique, id_parent, titre, statut, lang, langue_choisie', |
|
| 213 | + 'spip_rubriques', |
|
| 214 | + ($type == 'breve' ? ' id_parent=0 ' : ''), |
|
| 215 | + '', |
|
| 216 | + '0+titre,titre' |
|
| 217 | + ); |
|
| 218 | + while ($r = sql_fetch($q)) { |
|
| 219 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 220 | + // titre largeur maxi a 50 |
|
| 221 | + $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50); |
|
| 222 | + if ( |
|
| 223 | + $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 224 | + && ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0) |
|
| 225 | + ) { |
|
| 226 | + $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 227 | + } |
|
| 228 | + $data[$r['id_rubrique']] = $titre; |
|
| 229 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 230 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 231 | + $id_parent = $r['id_parent']; |
|
| 232 | + } |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + // si une seule rubrique comme choix possible, |
|
| 237 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 238 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 239 | + if ( |
|
| 240 | + count($data) == 2 |
|
| 241 | + && isset($data[0]) |
|
| 242 | + && !in_array($type, ['auteur', 'rubrique']) |
|
| 243 | + && !$id_rubrique |
|
| 244 | + ) { |
|
| 245 | + unset($data[0]); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 250 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 251 | + |
|
| 252 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 253 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 254 | + } else { |
|
| 255 | + $r = '<select' . $att . " size='1'>\n$opt</select>\n"; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + # message pour neuneus (a supprimer ?) |
|
| 259 | 259 | # if ($type != 'auteur' AND $type != 'breve') |
| 260 | 260 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 261 | 261 | |
| 262 | - return $r; |
|
| 262 | + return $r; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -293,22 +293,22 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 295 | 295 | |
| 296 | - if ($id_rubrique) { |
|
| 297 | - $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 298 | - } else { |
|
| 299 | - $titre = $type == 'auteur' ? ' ' : _T('info_racine_site'); |
|
| 300 | - } |
|
| 296 | + if ($id_rubrique) { |
|
| 297 | + $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 298 | + } else { |
|
| 299 | + $titre = $type == 'auteur' ? ' ' : _T('info_racine_site'); |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - $titre = str_replace('&', '&', (string) entites_html(textebrut(typo($titre)))); |
|
| 303 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 302 | + $titre = str_replace('&', '&', (string) entites_html(textebrut(typo($titre)))); |
|
| 303 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 304 | 304 | |
| 305 | - $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 306 | - . ($idem ? "&exclus=$idem" : '') |
|
| 307 | - . ($restreint ? '' : '&racine=oui') |
|
| 308 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 305 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 306 | + . ($idem ? "&exclus=$idem" : '') |
|
| 307 | + . ($restreint ? '' : '&racine=oui') |
|
| 308 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 309 | 309 | |
| 310 | 310 | |
| 311 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 311 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -338,30 +338,30 @@ discard block |
||
| 338 | 338 | * Code HTML du sélecteur de rubrique AJAX |
| 339 | 339 | **/ |
| 340 | 340 | function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
| 341 | - $icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 342 | - // si icone de recherche on embed le svg |
|
| 343 | - $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 344 | - $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 345 | - |
|
| 346 | - return |
|
| 347 | - "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 348 | - . $js |
|
| 349 | - . " jQuery(this).toggleClass('toggled'); " |
|
| 350 | - . "return charger_node_url_si_vide('" |
|
| 351 | - . $url |
|
| 352 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 353 | - . $img_icone |
|
| 354 | - . "</a><img src='" |
|
| 355 | - . chemin_image('loader.svg') |
|
| 356 | - . "' class='loader' id='img_" |
|
| 357 | - . $idom |
|
| 358 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 359 | - . "<input id='titreparent' name='titreparent' class='text'" |
|
| 360 | - . $init |
|
| 361 | - . ' />' |
|
| 362 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 363 | - . $id |
|
| 364 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 365 | - . $idom |
|
| 366 | - . "'\nstyle='display: none;'></div>"; |
|
| 341 | + $icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 342 | + // si icone de recherche on embed le svg |
|
| 343 | + $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 344 | + $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur')); |
|
| 345 | + |
|
| 346 | + return |
|
| 347 | + "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 348 | + . $js |
|
| 349 | + . " jQuery(this).toggleClass('toggled'); " |
|
| 350 | + . "return charger_node_url_si_vide('" |
|
| 351 | + . $url |
|
| 352 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 353 | + . $img_icone |
|
| 354 | + . "</a><img src='" |
|
| 355 | + . chemin_image('loader.svg') |
|
| 356 | + . "' class='loader' id='img_" |
|
| 357 | + . $idom |
|
| 358 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 359 | + . "<input id='titreparent' name='titreparent' class='text'" |
|
| 360 | + . $init |
|
| 361 | + . ' />' |
|
| 362 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 363 | + . $id |
|
| 364 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 365 | + . $idom |
|
| 366 | + . "'\nstyle='display: none;'></div>"; |
|
| 367 | 367 | } |
@@ -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 | |
| 22 | 22 | /** |
@@ -37,70 +37,70 @@ discard block |
||
| 37 | 37 | * @return array|string |
| 38 | 38 | */ |
| 39 | 39 | function inc_couleurs_dist($choix = null, $ajouter = false) { |
| 40 | - static $couleurs_spip = [ |
|
| 41 | - // Violet soutenu |
|
| 42 | - 9 => ['couleur_theme' => '#9a6ef2'], |
|
| 43 | - // Violet rosé |
|
| 44 | - 4 => ['couleur_theme' => '#c464cb'], |
|
| 45 | - // Rose interface SPIP |
|
| 46 | - 2 => ['couleur_theme' => '#F02364'], |
|
| 47 | - // Rouge |
|
| 48 | - 8 => ['couleur_theme' => '#ff4524'], |
|
| 49 | - // Orange |
|
| 50 | - 3 => ['couleur_theme' => '#c97500'], |
|
| 51 | - // Vert SPIP |
|
| 52 | - 1 => ['couleur_theme' => '#9dba00'], |
|
| 53 | - // Vert Troglo |
|
| 54 | - 7 => ['couleur_theme' => '#419a2c'], |
|
| 55 | - // Bleu-vert |
|
| 56 | - 12 => ['couleur_theme' => '#269681'], |
|
| 57 | - // Bleu pastel |
|
| 58 | - 5 => ['couleur_theme' => '#3190ae'], |
|
| 59 | - // Bleu Kermesse |
|
| 60 | - 11 => ['couleur_theme' => '#288bdd'], |
|
| 61 | - // Gris bleuté |
|
| 62 | - 6 => ['couleur_theme' => '#7d90a2'], |
|
| 63 | - // Gris |
|
| 64 | - 10 => ['couleur_theme' => '#909090'], |
|
| 65 | - ]; |
|
| 40 | + static $couleurs_spip = [ |
|
| 41 | + // Violet soutenu |
|
| 42 | + 9 => ['couleur_theme' => '#9a6ef2'], |
|
| 43 | + // Violet rosé |
|
| 44 | + 4 => ['couleur_theme' => '#c464cb'], |
|
| 45 | + // Rose interface SPIP |
|
| 46 | + 2 => ['couleur_theme' => '#F02364'], |
|
| 47 | + // Rouge |
|
| 48 | + 8 => ['couleur_theme' => '#ff4524'], |
|
| 49 | + // Orange |
|
| 50 | + 3 => ['couleur_theme' => '#c97500'], |
|
| 51 | + // Vert SPIP |
|
| 52 | + 1 => ['couleur_theme' => '#9dba00'], |
|
| 53 | + // Vert Troglo |
|
| 54 | + 7 => ['couleur_theme' => '#419a2c'], |
|
| 55 | + // Bleu-vert |
|
| 56 | + 12 => ['couleur_theme' => '#269681'], |
|
| 57 | + // Bleu pastel |
|
| 58 | + 5 => ['couleur_theme' => '#3190ae'], |
|
| 59 | + // Bleu Kermesse |
|
| 60 | + 11 => ['couleur_theme' => '#288bdd'], |
|
| 61 | + // Gris bleuté |
|
| 62 | + 6 => ['couleur_theme' => '#7d90a2'], |
|
| 63 | + // Gris |
|
| 64 | + 10 => ['couleur_theme' => '#909090'], |
|
| 65 | + ]; |
|
| 66 | 66 | |
| 67 | - if (is_numeric($choix)) { |
|
| 68 | - $c = $couleurs_spip[$choix]; |
|
| 69 | - // compat < SPIP 3.3 |
|
| 70 | - include_spip('inc/filtres_images_mini'); |
|
| 71 | - $c['couleur_foncee'] = $c['couleur_theme']; |
|
| 72 | - $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5); |
|
| 67 | + if (is_numeric($choix)) { |
|
| 68 | + $c = $couleurs_spip[$choix]; |
|
| 69 | + // compat < SPIP 3.3 |
|
| 70 | + include_spip('inc/filtres_images_mini'); |
|
| 71 | + $c['couleur_foncee'] = $c['couleur_theme']; |
|
| 72 | + $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5); |
|
| 73 | 73 | |
| 74 | - return |
|
| 75 | - 'couleur_theme=' . substr((string) $c['couleur_theme'], 1) |
|
| 76 | - // compat < SPIP 3.3 |
|
| 77 | - . '&couleur_claire=' . substr($c['couleur_claire'], 1) |
|
| 78 | - . '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1); |
|
| 79 | - } else { |
|
| 80 | - if (is_array($choix)) { |
|
| 81 | - // compat < SPIP 3.3 |
|
| 82 | - $compat_spip_33 = function ($c) { |
|
| 83 | - if (!isset($c['couleur_theme'])) { |
|
| 84 | - $c['couleur_theme'] = $c['couleur_foncee']; |
|
| 85 | - unset($c['couleur_foncee']); |
|
| 86 | - unset($c['couleur_claire']); |
|
| 87 | - unset($c['couleur_lien']); |
|
| 88 | - unset($c['couleur_lien_off']); |
|
| 89 | - } |
|
| 90 | - return $c; |
|
| 91 | - }; |
|
| 92 | - if ($ajouter) { |
|
| 93 | - foreach ($choix as $c) { |
|
| 94 | - $couleurs_spip[] = $compat_spip_33($c); |
|
| 95 | - } |
|
| 74 | + return |
|
| 75 | + 'couleur_theme=' . substr((string) $c['couleur_theme'], 1) |
|
| 76 | + // compat < SPIP 3.3 |
|
| 77 | + . '&couleur_claire=' . substr($c['couleur_claire'], 1) |
|
| 78 | + . '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1); |
|
| 79 | + } else { |
|
| 80 | + if (is_array($choix)) { |
|
| 81 | + // compat < SPIP 3.3 |
|
| 82 | + $compat_spip_33 = function ($c) { |
|
| 83 | + if (!isset($c['couleur_theme'])) { |
|
| 84 | + $c['couleur_theme'] = $c['couleur_foncee']; |
|
| 85 | + unset($c['couleur_foncee']); |
|
| 86 | + unset($c['couleur_claire']); |
|
| 87 | + unset($c['couleur_lien']); |
|
| 88 | + unset($c['couleur_lien_off']); |
|
| 89 | + } |
|
| 90 | + return $c; |
|
| 91 | + }; |
|
| 92 | + if ($ajouter) { |
|
| 93 | + foreach ($choix as $c) { |
|
| 94 | + $couleurs_spip[] = $compat_spip_33($c); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $couleurs_spip; |
|
| 98 | - } else { |
|
| 99 | - $choix = array_map($compat_spip_33, $choix); |
|
| 100 | - return $couleurs_spip = $choix; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - } |
|
| 97 | + return $couleurs_spip; |
|
| 98 | + } else { |
|
| 99 | + $choix = array_map($compat_spip_33, $choix); |
|
| 100 | + return $couleurs_spip = $choix; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return $couleurs_spip; |
|
| 105 | + return $couleurs_spip; |
|
| 106 | 106 | } |
@@ -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 | |
| 22 | 22 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | function inc_config_dist() { |
| 30 | - actualise_metas(liste_metas()); |
|
| 30 | + actualise_metas(liste_metas()); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -44,32 +44,32 @@ discard block |
||
| 44 | 44 | * Liste (table, casier, sous_casier) |
| 45 | 45 | */ |
| 46 | 46 | function expliquer_config($cfg) { |
| 47 | - // par defaut, sur la table des meta |
|
| 48 | - $table = 'meta'; |
|
| 49 | - $casier = null; |
|
| 50 | - $sous_casier = []; |
|
| 51 | - $cfg = explode('/', $cfg); |
|
| 52 | - |
|
| 53 | - // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 54 | - if (!reset($cfg) && count($cfg) > 1) { |
|
| 55 | - array_shift($cfg); |
|
| 56 | - $table = array_shift($cfg); |
|
| 57 | - if (!isset($GLOBALS[$table])) { |
|
| 58 | - lire_metas($table); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 63 | - // pas sur un appel vide '' |
|
| 64 | - if (count($cfg) && '' !== ($c = array_shift($cfg))) { |
|
| 65 | - $casier = $c; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if ($cfg !== []) { |
|
| 69 | - $sous_casier = $cfg; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return [$table, $casier, $sous_casier]; |
|
| 47 | + // par defaut, sur la table des meta |
|
| 48 | + $table = 'meta'; |
|
| 49 | + $casier = null; |
|
| 50 | + $sous_casier = []; |
|
| 51 | + $cfg = explode('/', $cfg); |
|
| 52 | + |
|
| 53 | + // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 54 | + if (!reset($cfg) && count($cfg) > 1) { |
|
| 55 | + array_shift($cfg); |
|
| 56 | + $table = array_shift($cfg); |
|
| 57 | + if (!isset($GLOBALS[$table])) { |
|
| 58 | + lire_metas($table); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 63 | + // pas sur un appel vide '' |
|
| 64 | + if (count($cfg) && '' !== ($c = array_shift($cfg))) { |
|
| 65 | + $casier = $c; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if ($cfg !== []) { |
|
| 69 | + $sous_casier = $cfg; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return [$table, $casier, $sous_casier]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -97,63 +97,63 @@ discard block |
||
| 97 | 97 | * Contenu de la configuration obtenue |
| 98 | 98 | */ |
| 99 | 99 | function lire_config($cfg = '', mixed $def = null, $unserialize = true) { |
| 100 | - // lire le stockage sous la forme /table/valeur |
|
| 101 | - // ou valeur qui est en fait implicitement /meta/valeur |
|
| 102 | - // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 103 | - |
|
| 104 | - // traiter en priorite le cas simple et frequent |
|
| 105 | - // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 106 | - if ($cfg && strpbrk($cfg, '/:') === false) { |
|
| 107 | - return isset($GLOBALS['meta'][$cfg]) |
|
| 108 | - ? (!$unserialize |
|
| 109 | - // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 110 | - || !is_string($GLOBALS['meta'][$cfg]) |
|
| 111 | - // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 112 | - || !str_contains($GLOBALS['meta'][$cfg], ':') |
|
| 113 | - || ($t = @unserialize($GLOBALS['meta'][$cfg])) === false ? $GLOBALS['meta'][$cfg] : $t) |
|
| 114 | - : $def; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // Brancher sur methodes externes si besoin |
|
| 118 | - if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 119 | - $methode = substr($cfg, 0, $p); |
|
| 120 | - $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 121 | - |
|
| 122 | - return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 126 | - |
|
| 127 | - if (!isset($GLOBALS[$table])) { |
|
| 128 | - return $def; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $r = $GLOBALS[$table]; |
|
| 132 | - |
|
| 133 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 134 | - if (!$casier) { |
|
| 135 | - return $unserialize ? $r : serialize($r); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // casier principal : |
|
| 139 | - // le deserializer si demande |
|
| 140 | - // ou si on a besoin |
|
| 141 | - // d'un sous casier |
|
| 142 | - $r = $r[$casier] ?? null; |
|
| 143 | - if (($unserialize || (is_countable($sous_casier) ? count($sous_casier) : 0)) && $r && is_string($r)) { |
|
| 144 | - $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // aller chercher le sous_casier |
|
| 148 | - while (!is_null($r) && ($casier = array_shift($sous_casier))) { |
|
| 149 | - $r = $r[$casier] ?? null; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if (is_null($r)) { |
|
| 153 | - return $def; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return $r; |
|
| 100 | + // lire le stockage sous la forme /table/valeur |
|
| 101 | + // ou valeur qui est en fait implicitement /meta/valeur |
|
| 102 | + // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 103 | + |
|
| 104 | + // traiter en priorite le cas simple et frequent |
|
| 105 | + // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 106 | + if ($cfg && strpbrk($cfg, '/:') === false) { |
|
| 107 | + return isset($GLOBALS['meta'][$cfg]) |
|
| 108 | + ? (!$unserialize |
|
| 109 | + // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 110 | + || !is_string($GLOBALS['meta'][$cfg]) |
|
| 111 | + // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 112 | + || !str_contains($GLOBALS['meta'][$cfg], ':') |
|
| 113 | + || ($t = @unserialize($GLOBALS['meta'][$cfg])) === false ? $GLOBALS['meta'][$cfg] : $t) |
|
| 114 | + : $def; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // Brancher sur methodes externes si besoin |
|
| 118 | + if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 119 | + $methode = substr($cfg, 0, $p); |
|
| 120 | + $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 121 | + |
|
| 122 | + return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 126 | + |
|
| 127 | + if (!isset($GLOBALS[$table])) { |
|
| 128 | + return $def; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $r = $GLOBALS[$table]; |
|
| 132 | + |
|
| 133 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 134 | + if (!$casier) { |
|
| 135 | + return $unserialize ? $r : serialize($r); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // casier principal : |
|
| 139 | + // le deserializer si demande |
|
| 140 | + // ou si on a besoin |
|
| 141 | + // d'un sous casier |
|
| 142 | + $r = $r[$casier] ?? null; |
|
| 143 | + if (($unserialize || (is_countable($sous_casier) ? count($sous_casier) : 0)) && $r && is_string($r)) { |
|
| 144 | + $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // aller chercher le sous_casier |
|
| 148 | + while (!is_null($r) && ($casier = array_shift($sous_casier))) { |
|
| 149 | + $r = $r[$casier] ?? null; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if (is_null($r)) { |
|
| 153 | + return $def; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return $r; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @return mixed |
| 167 | 167 | */ |
| 168 | 168 | function lire_config_metapack_dist($cfg = '', mixed $def = null, $unserialize = true) { |
| 169 | - return lire_config($cfg, $def, $unserialize); |
|
| 169 | + return lire_config($cfg, $def, $unserialize); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -177,144 +177,144 @@ discard block |
||
| 177 | 177 | * @return bool |
| 178 | 178 | */ |
| 179 | 179 | function ecrire_config($cfg, mixed $store) { |
| 180 | - // Brancher sur methodes externes si besoin |
|
| 181 | - if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 182 | - $methode = substr($cfg, 0, $p); |
|
| 183 | - $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 184 | - |
|
| 185 | - return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 189 | - // il faut au moins un casier pour ecrire |
|
| 190 | - if (!$casier) { |
|
| 191 | - return false; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // trouvons ou creons le pointeur sur le casier |
|
| 195 | - $st = $GLOBALS[$table][$casier] ?? null; |
|
| 196 | - if (!is_array($st) && ($sous_casier || is_array($store))) { |
|
| 197 | - if ($st === null) { |
|
| 198 | - // ne rien creer si c'est une demande d'effacement |
|
| 199 | - if ($store === null) { |
|
| 200 | - return false; |
|
| 201 | - } |
|
| 202 | - $st = []; |
|
| 203 | - } else { |
|
| 204 | - $st = unserialize($st); |
|
| 205 | - if ($st === false) { |
|
| 206 | - // ne rien creer si c'est une demande d'effacement |
|
| 207 | - if ($store === null) { |
|
| 208 | - return false; |
|
| 209 | - } |
|
| 210 | - $st = []; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $has_planes = false; |
|
| 216 | - // si on a affaire a un sous caiser |
|
| 217 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 218 | - if ($c = $sous_casier) { |
|
| 219 | - $sc = &$st; |
|
| 220 | - $pointeurs = []; |
|
| 221 | - while ((is_countable($c) ? count($c) : 0) && ($cc = array_shift($c))) { |
|
| 222 | - // creer l'entree si elle n'existe pas |
|
| 223 | - if (!isset($sc[$cc])) { |
|
| 224 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 225 | - // ne rien creer mais sortir |
|
| 226 | - if (is_null($store)) { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - $sc[$cc] = []; |
|
| 230 | - } |
|
| 231 | - $pointeurs[$cc] = &$sc; |
|
| 232 | - $sc = &$sc[$cc]; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // si c'est une demande d'effacement |
|
| 236 | - if (is_null($store)) { |
|
| 237 | - $c = $sous_casier; |
|
| 238 | - $sous = array_pop($c); |
|
| 239 | - // effacer, et remonter pour effacer les parents vides |
|
| 240 | - do { |
|
| 241 | - unset($pointeurs[$sous][$sous]); |
|
| 242 | - } while (($sous = array_pop($c)) && !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 243 | - |
|
| 244 | - // si on a vide tous les sous casiers, |
|
| 245 | - // et que le casier est vide |
|
| 246 | - // vider aussi la meta |
|
| 247 | - if (!$sous && !(is_countable($st) ? count($st) : 0)) { |
|
| 248 | - $st = null; |
|
| 249 | - } |
|
| 250 | - } // dans tous les autres cas, on ecrase |
|
| 251 | - else { |
|
| 252 | - if ( |
|
| 253 | - defined('_MYSQL_NOPLANES') |
|
| 254 | - && _MYSQL_NOPLANES |
|
| 255 | - && !empty($GLOBALS['meta']['charset_sql_connexion']) |
|
| 256 | - && $GLOBALS['meta']['charset_sql_connexion'] == 'utf8' |
|
| 257 | - ) { |
|
| 258 | - // detecter si la valeur qu'on veut ecrire a des planes |
|
| 259 | - // @see utf8_noplanes |
|
| 260 | - $serialized_store = (is_string($store) ? $store : serialize($store)); |
|
| 261 | - // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes |
|
| 262 | - if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) { |
|
| 263 | - if (!function_exists('utf8_noplanes')) { |
|
| 264 | - include_spip('inc/charsets'); |
|
| 265 | - } |
|
| 266 | - if ($serialized_store !== utf8_noplanes($serialized_store)) { |
|
| 267 | - $has_planes = true; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - $sc = $store; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - // Maintenant que $st est modifiee |
|
| 276 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 277 | - $store = $st; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - if (is_null($store)) { |
|
| 281 | - if (is_null($st) && !$sous_casier) { |
|
| 282 | - return false; |
|
| 283 | - } // la config n'existait deja pas ! |
|
| 284 | - effacer_meta($casier, $table); |
|
| 285 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 286 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 287 | - else { |
|
| 288 | - if (!isset($GLOBALS[$table])) { |
|
| 289 | - installer_table_meta($table); |
|
| 290 | - } |
|
| 291 | - // si ce n'est pas une chaine |
|
| 292 | - // il faut serializer |
|
| 293 | - if (!is_string($store)) { |
|
| 294 | - $serialized_store = serialize($store); |
|
| 295 | - ecrire_meta($casier, $serialized_store, null, $table); |
|
| 296 | - // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
|
| 297 | - // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
|
| 298 | - if ($has_planes) { |
|
| 299 | - $check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier)); |
|
| 300 | - if ($check_store !== $serialized_store) { |
|
| 301 | - array_walk_recursive($store, function (&$value, $key) { |
|
| 302 | - if (is_string($value)) { |
|
| 303 | - $value = utf8_noplanes($value); |
|
| 304 | - } |
|
| 305 | - }); |
|
| 306 | - $serialized_store = serialize($store); |
|
| 307 | - ecrire_meta($casier, $serialized_store, null, $table); |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - else { |
|
| 312 | - ecrire_meta($casier, $store, null, $table); |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - // verifier que lire_config($cfg)==$store ? |
|
| 317 | - return true; |
|
| 180 | + // Brancher sur methodes externes si besoin |
|
| 181 | + if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 182 | + $methode = substr($cfg, 0, $p); |
|
| 183 | + $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 184 | + |
|
| 185 | + return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 189 | + // il faut au moins un casier pour ecrire |
|
| 190 | + if (!$casier) { |
|
| 191 | + return false; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // trouvons ou creons le pointeur sur le casier |
|
| 195 | + $st = $GLOBALS[$table][$casier] ?? null; |
|
| 196 | + if (!is_array($st) && ($sous_casier || is_array($store))) { |
|
| 197 | + if ($st === null) { |
|
| 198 | + // ne rien creer si c'est une demande d'effacement |
|
| 199 | + if ($store === null) { |
|
| 200 | + return false; |
|
| 201 | + } |
|
| 202 | + $st = []; |
|
| 203 | + } else { |
|
| 204 | + $st = unserialize($st); |
|
| 205 | + if ($st === false) { |
|
| 206 | + // ne rien creer si c'est une demande d'effacement |
|
| 207 | + if ($store === null) { |
|
| 208 | + return false; |
|
| 209 | + } |
|
| 210 | + $st = []; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $has_planes = false; |
|
| 216 | + // si on a affaire a un sous caiser |
|
| 217 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 218 | + if ($c = $sous_casier) { |
|
| 219 | + $sc = &$st; |
|
| 220 | + $pointeurs = []; |
|
| 221 | + while ((is_countable($c) ? count($c) : 0) && ($cc = array_shift($c))) { |
|
| 222 | + // creer l'entree si elle n'existe pas |
|
| 223 | + if (!isset($sc[$cc])) { |
|
| 224 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 225 | + // ne rien creer mais sortir |
|
| 226 | + if (is_null($store)) { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + $sc[$cc] = []; |
|
| 230 | + } |
|
| 231 | + $pointeurs[$cc] = &$sc; |
|
| 232 | + $sc = &$sc[$cc]; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // si c'est une demande d'effacement |
|
| 236 | + if (is_null($store)) { |
|
| 237 | + $c = $sous_casier; |
|
| 238 | + $sous = array_pop($c); |
|
| 239 | + // effacer, et remonter pour effacer les parents vides |
|
| 240 | + do { |
|
| 241 | + unset($pointeurs[$sous][$sous]); |
|
| 242 | + } while (($sous = array_pop($c)) && !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 243 | + |
|
| 244 | + // si on a vide tous les sous casiers, |
|
| 245 | + // et que le casier est vide |
|
| 246 | + // vider aussi la meta |
|
| 247 | + if (!$sous && !(is_countable($st) ? count($st) : 0)) { |
|
| 248 | + $st = null; |
|
| 249 | + } |
|
| 250 | + } // dans tous les autres cas, on ecrase |
|
| 251 | + else { |
|
| 252 | + if ( |
|
| 253 | + defined('_MYSQL_NOPLANES') |
|
| 254 | + && _MYSQL_NOPLANES |
|
| 255 | + && !empty($GLOBALS['meta']['charset_sql_connexion']) |
|
| 256 | + && $GLOBALS['meta']['charset_sql_connexion'] == 'utf8' |
|
| 257 | + ) { |
|
| 258 | + // detecter si la valeur qu'on veut ecrire a des planes |
|
| 259 | + // @see utf8_noplanes |
|
| 260 | + $serialized_store = (is_string($store) ? $store : serialize($store)); |
|
| 261 | + // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes |
|
| 262 | + if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) { |
|
| 263 | + if (!function_exists('utf8_noplanes')) { |
|
| 264 | + include_spip('inc/charsets'); |
|
| 265 | + } |
|
| 266 | + if ($serialized_store !== utf8_noplanes($serialized_store)) { |
|
| 267 | + $has_planes = true; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + $sc = $store; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + // Maintenant que $st est modifiee |
|
| 276 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 277 | + $store = $st; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + if (is_null($store)) { |
|
| 281 | + if (is_null($st) && !$sous_casier) { |
|
| 282 | + return false; |
|
| 283 | + } // la config n'existait deja pas ! |
|
| 284 | + effacer_meta($casier, $table); |
|
| 285 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 286 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 287 | + else { |
|
| 288 | + if (!isset($GLOBALS[$table])) { |
|
| 289 | + installer_table_meta($table); |
|
| 290 | + } |
|
| 291 | + // si ce n'est pas une chaine |
|
| 292 | + // il faut serializer |
|
| 293 | + if (!is_string($store)) { |
|
| 294 | + $serialized_store = serialize($store); |
|
| 295 | + ecrire_meta($casier, $serialized_store, null, $table); |
|
| 296 | + // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
|
| 297 | + // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
|
| 298 | + if ($has_planes) { |
|
| 299 | + $check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier)); |
|
| 300 | + if ($check_store !== $serialized_store) { |
|
| 301 | + array_walk_recursive($store, function (&$value, $key) { |
|
| 302 | + if (is_string($value)) { |
|
| 303 | + $value = utf8_noplanes($value); |
|
| 304 | + } |
|
| 305 | + }); |
|
| 306 | + $serialized_store = serialize($store); |
|
| 307 | + ecrire_meta($casier, $serialized_store, null, $table); |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + else { |
|
| 312 | + ecrire_meta($casier, $store, null, $table); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + // verifier que lire_config($cfg)==$store ? |
|
| 317 | + return true; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
@@ -327,14 +327,14 @@ discard block |
||
| 327 | 327 | * @return bool |
| 328 | 328 | */ |
| 329 | 329 | function ecrire_config_metapack_dist($cfg, mixed $store) { |
| 330 | - // cas particulier en metapack:: |
|
| 331 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 332 | - // intacte en sortie ... |
|
| 333 | - if (is_string($store) && strpos($store, ':') && unserialize($store)) { |
|
| 334 | - $store = serialize($store); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return ecrire_config($cfg, $store); |
|
| 330 | + // cas particulier en metapack:: |
|
| 331 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 332 | + // intacte en sortie ... |
|
| 333 | + if (is_string($store) && strpos($store, ':') && unserialize($store)) { |
|
| 334 | + $store = serialize($store); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return ecrire_config($cfg, $store); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | * @return bool |
| 345 | 345 | */ |
| 346 | 346 | function effacer_config($cfg) { |
| 347 | - ecrire_config($cfg, null); |
|
| 347 | + ecrire_config($cfg, null); |
|
| 348 | 348 | |
| 349 | - return true; |
|
| 349 | + return true; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -363,58 +363,58 @@ discard block |
||
| 363 | 363 | * Couples nom de la `meta` => valeur par défaut |
| 364 | 364 | */ |
| 365 | 365 | function liste_metas() { |
| 366 | - return pipeline('configurer_liste_metas', [ |
|
| 367 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 368 | - 'slogan_site' => '', |
|
| 369 | - 'adresse_site' => preg_replace(',/$,', '', (string) url_de_base()), |
|
| 370 | - 'descriptif_site' => '', |
|
| 371 | - 'activer_logos' => 'oui', |
|
| 372 | - 'activer_logos_survol' => 'non', |
|
| 373 | - 'articles_surtitre' => 'non', |
|
| 374 | - 'articles_soustitre' => 'non', |
|
| 375 | - 'articles_descriptif' => 'non', |
|
| 376 | - 'articles_chapeau' => 'non', |
|
| 377 | - 'articles_texte' => 'oui', |
|
| 378 | - 'articles_ps' => 'non', |
|
| 379 | - 'articles_redac' => 'non', |
|
| 380 | - 'post_dates' => 'non', |
|
| 381 | - 'articles_urlref' => 'non', |
|
| 382 | - 'articles_redirection' => 'non', |
|
| 383 | - 'creer_preview' => 'non', |
|
| 384 | - 'taille_preview' => 150, |
|
| 385 | - 'articles_modif' => 'non', |
|
| 386 | - |
|
| 387 | - 'rubriques_descriptif' => 'non', |
|
| 388 | - 'rubriques_texte' => 'oui', |
|
| 389 | - |
|
| 390 | - 'accepter_inscriptions' => 'non', |
|
| 391 | - 'accepter_visiteurs' => 'non', |
|
| 392 | - 'prevenir_auteurs' => 'non', |
|
| 393 | - 'suivi_edito' => 'non', |
|
| 394 | - 'adresse_suivi' => '', |
|
| 395 | - 'adresse_suivi_inscription' => '', |
|
| 396 | - 'adresse_neuf' => '', |
|
| 397 | - 'jours_neuf' => '', |
|
| 398 | - 'quoi_de_neuf' => 'non', |
|
| 399 | - 'preview' => ',0minirezo,1comite,', |
|
| 400 | - |
|
| 401 | - 'syndication_integrale' => 'oui', |
|
| 402 | - 'charset' => _DEFAULT_CHARSET, |
|
| 403 | - 'dir_img' => substr((string) _DIR_IMG, strlen(_DIR_RACINE)), |
|
| 404 | - |
|
| 405 | - 'multi_rubriques' => 'non', |
|
| 406 | - 'multi_secteurs' => 'non', |
|
| 407 | - 'gerer_trad' => 'non', |
|
| 408 | - 'langues_multilingue' => '', |
|
| 409 | - |
|
| 410 | - 'version_html_max' => 'html4', |
|
| 411 | - |
|
| 412 | - 'type_urls' => 'page', |
|
| 413 | - |
|
| 414 | - 'email_envoi' => '', |
|
| 415 | - 'email_webmaster' => '', |
|
| 416 | - 'auto_compress_http' => 'non', |
|
| 417 | - ]); |
|
| 366 | + return pipeline('configurer_liste_metas', [ |
|
| 367 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 368 | + 'slogan_site' => '', |
|
| 369 | + 'adresse_site' => preg_replace(',/$,', '', (string) url_de_base()), |
|
| 370 | + 'descriptif_site' => '', |
|
| 371 | + 'activer_logos' => 'oui', |
|
| 372 | + 'activer_logos_survol' => 'non', |
|
| 373 | + 'articles_surtitre' => 'non', |
|
| 374 | + 'articles_soustitre' => 'non', |
|
| 375 | + 'articles_descriptif' => 'non', |
|
| 376 | + 'articles_chapeau' => 'non', |
|
| 377 | + 'articles_texte' => 'oui', |
|
| 378 | + 'articles_ps' => 'non', |
|
| 379 | + 'articles_redac' => 'non', |
|
| 380 | + 'post_dates' => 'non', |
|
| 381 | + 'articles_urlref' => 'non', |
|
| 382 | + 'articles_redirection' => 'non', |
|
| 383 | + 'creer_preview' => 'non', |
|
| 384 | + 'taille_preview' => 150, |
|
| 385 | + 'articles_modif' => 'non', |
|
| 386 | + |
|
| 387 | + 'rubriques_descriptif' => 'non', |
|
| 388 | + 'rubriques_texte' => 'oui', |
|
| 389 | + |
|
| 390 | + 'accepter_inscriptions' => 'non', |
|
| 391 | + 'accepter_visiteurs' => 'non', |
|
| 392 | + 'prevenir_auteurs' => 'non', |
|
| 393 | + 'suivi_edito' => 'non', |
|
| 394 | + 'adresse_suivi' => '', |
|
| 395 | + 'adresse_suivi_inscription' => '', |
|
| 396 | + 'adresse_neuf' => '', |
|
| 397 | + 'jours_neuf' => '', |
|
| 398 | + 'quoi_de_neuf' => 'non', |
|
| 399 | + 'preview' => ',0minirezo,1comite,', |
|
| 400 | + |
|
| 401 | + 'syndication_integrale' => 'oui', |
|
| 402 | + 'charset' => _DEFAULT_CHARSET, |
|
| 403 | + 'dir_img' => substr((string) _DIR_IMG, strlen(_DIR_RACINE)), |
|
| 404 | + |
|
| 405 | + 'multi_rubriques' => 'non', |
|
| 406 | + 'multi_secteurs' => 'non', |
|
| 407 | + 'gerer_trad' => 'non', |
|
| 408 | + 'langues_multilingue' => '', |
|
| 409 | + |
|
| 410 | + 'version_html_max' => 'html4', |
|
| 411 | + |
|
| 412 | + 'type_urls' => 'page', |
|
| 413 | + |
|
| 414 | + 'email_envoi' => '', |
|
| 415 | + 'email_webmaster' => '', |
|
| 416 | + 'auto_compress_http' => 'non', |
|
| 417 | + ]); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -425,43 +425,43 @@ discard block |
||
| 425 | 425 | * @return void |
| 426 | 426 | */ |
| 427 | 427 | function actualise_metas($liste_meta) { |
| 428 | - $meta_serveur = |
|
| 429 | - [ |
|
| 430 | - 'version_installee', |
|
| 431 | - 'adresse_site', |
|
| 432 | - 'alea_ephemere_ancien', |
|
| 433 | - 'alea_ephemere', |
|
| 434 | - 'alea_ephemere_date', |
|
| 435 | - 'langue_site', |
|
| 436 | - 'langues_proposees', |
|
| 437 | - 'date_calcul_rubriques', |
|
| 438 | - 'derniere_modif', |
|
| 439 | - 'optimiser_table', |
|
| 440 | - 'drapeau_edition', |
|
| 441 | - 'creer_preview', |
|
| 442 | - 'taille_preview', |
|
| 443 | - 'creer_htpasswd', |
|
| 444 | - 'creer_htaccess', |
|
| 445 | - 'gd_formats_read', |
|
| 446 | - 'gd_formats', |
|
| 447 | - 'netpbm_formats', |
|
| 448 | - 'formats_graphiques', |
|
| 449 | - 'image_process', |
|
| 450 | - 'plugin_header', |
|
| 451 | - 'plugin' |
|
| 452 | - ]; |
|
| 453 | - // verifier le impt=non |
|
| 454 | - sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 455 | - |
|
| 456 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 457 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 458 | - ecrire_meta($nom, $valeur); |
|
| 459 | - } |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - include_spip('inc/rubriques'); |
|
| 463 | - $langues = calculer_langues_utilisees(); |
|
| 464 | - ecrire_meta('langues_utilisees', $langues); |
|
| 428 | + $meta_serveur = |
|
| 429 | + [ |
|
| 430 | + 'version_installee', |
|
| 431 | + 'adresse_site', |
|
| 432 | + 'alea_ephemere_ancien', |
|
| 433 | + 'alea_ephemere', |
|
| 434 | + 'alea_ephemere_date', |
|
| 435 | + 'langue_site', |
|
| 436 | + 'langues_proposees', |
|
| 437 | + 'date_calcul_rubriques', |
|
| 438 | + 'derniere_modif', |
|
| 439 | + 'optimiser_table', |
|
| 440 | + 'drapeau_edition', |
|
| 441 | + 'creer_preview', |
|
| 442 | + 'taille_preview', |
|
| 443 | + 'creer_htpasswd', |
|
| 444 | + 'creer_htaccess', |
|
| 445 | + 'gd_formats_read', |
|
| 446 | + 'gd_formats', |
|
| 447 | + 'netpbm_formats', |
|
| 448 | + 'formats_graphiques', |
|
| 449 | + 'image_process', |
|
| 450 | + 'plugin_header', |
|
| 451 | + 'plugin' |
|
| 452 | + ]; |
|
| 453 | + // verifier le impt=non |
|
| 454 | + sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 455 | + |
|
| 456 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 457 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 458 | + ecrire_meta($nom, $valeur); |
|
| 459 | + } |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + include_spip('inc/rubriques'); |
|
| 463 | + $langues = calculer_langues_utilisees(); |
|
| 464 | + ecrire_meta('langues_utilisees', $langues); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | |
@@ -483,18 +483,18 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | function appliquer_modifs_config($purger_skel = false) { |
| 485 | 485 | |
| 486 | - foreach (liste_metas() as $i => $v) { |
|
| 487 | - if (($x = _request($i)) !== null) { |
|
| 488 | - ecrire_meta($i, $x); |
|
| 489 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 490 | - ecrire_meta($i, $v); |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - if ($purger_skel) { |
|
| 495 | - include_spip('inc/invalideur'); |
|
| 496 | - purger_repertoire(_DIR_SKELS); |
|
| 497 | - } |
|
| 486 | + foreach (liste_metas() as $i => $v) { |
|
| 487 | + if (($x = _request($i)) !== null) { |
|
| 488 | + ecrire_meta($i, $x); |
|
| 489 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 490 | + ecrire_meta($i, $v); |
|
| 491 | + } |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + if ($purger_skel) { |
|
| 495 | + include_spip('inc/invalideur'); |
|
| 496 | + purger_repertoire(_DIR_SKELS); |
|
| 497 | + } |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -505,21 +505,21 @@ discard block |
||
| 505 | 505 | * @return string |
| 506 | 506 | */ |
| 507 | 507 | function appliquer_adresse_site($adresse_site) { |
| 508 | - if ($adresse_site !== null) { |
|
| 509 | - if (!strlen($adresse_site)) { |
|
| 510 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 511 | - $adresse_site = url_de_base(); |
|
| 512 | - } |
|
| 513 | - $adresse_site = preg_replace(',/?\s*$,', '', (string) $adresse_site); |
|
| 508 | + if ($adresse_site !== null) { |
|
| 509 | + if (!strlen($adresse_site)) { |
|
| 510 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 511 | + $adresse_site = url_de_base(); |
|
| 512 | + } |
|
| 513 | + $adresse_site = preg_replace(',/?\s*$,', '', (string) $adresse_site); |
|
| 514 | 514 | |
| 515 | - if (!tester_url_absolue($adresse_site)) { |
|
| 516 | - $adresse_site = "http://$adresse_site"; |
|
| 517 | - } |
|
| 515 | + if (!tester_url_absolue($adresse_site)) { |
|
| 516 | + $adresse_site = "http://$adresse_site"; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | - $adresse_site = entites_html($adresse_site); |
|
| 519 | + $adresse_site = entites_html($adresse_site); |
|
| 520 | 520 | |
| 521 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 522 | - } |
|
| 521 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - return $adresse_site; |
|
| 524 | + return $adresse_site; |
|
| 525 | 525 | } |
@@ -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 | |
| 22 | 22 | /** |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | * URL, code HTML du formulaire ou tableau (action, arg, hash) |
| 43 | 43 | */ |
| 44 | 44 | function generer_action_auteur($action, $arg = '', $redirect = '', $mode = false, $att = '', $public = false) { |
| 45 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 45 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 46 | 46 | |
| 47 | - return $securiser_action($action, $arg, $redirect, $mode, $att, $public); |
|
| 47 | + return $securiser_action($action, $arg, $redirect, $mode, $att, $public); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | * Code HTML du formulaire |
| 78 | 78 | */ |
| 79 | 79 | function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) { |
| 80 | - $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true); |
|
| 80 | + $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true); |
|
| 81 | 81 | |
| 82 | - return generer_action_auteur($action, $arg, $r, $mode, $atts, $public); |
|
| 82 | + return generer_action_auteur($action, $arg, $r, $mode, $atts, $public); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * URL, code HTML du formulaire ou tableau (action, arg, hash) |
| 105 | 105 | */ |
| 106 | 106 | function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') { |
| 107 | - $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true); |
|
| 107 | + $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true); |
|
| 108 | 108 | |
| 109 | - return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'"); |
|
| 109 | + return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'"); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
@@ -123,26 +123,26 @@ discard block |
||
| 123 | 123 | * passer "text/html" comme $content_type |
| 124 | 124 | */ |
| 125 | 125 | function ajax_retour($corps, $content_type = null): void { |
| 126 | - $xml = false; |
|
| 127 | - if (is_null($content_type) || $content_type === true) { |
|
| 128 | - $xml = true; |
|
| 129 | - $content_type = 'text/html'; |
|
| 130 | - } elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) { |
|
| 131 | - $content_type = 'text/html'; |
|
| 132 | - } |
|
| 126 | + $xml = false; |
|
| 127 | + if (is_null($content_type) || $content_type === true) { |
|
| 128 | + $xml = true; |
|
| 129 | + $content_type = 'text/html'; |
|
| 130 | + } elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) { |
|
| 131 | + $content_type = 'text/html'; |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - $e = ''; |
|
| 135 | - if ( |
|
| 136 | - isset($_COOKIE['spip_admin']) |
|
| 137 | - && (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps'])) |
|
| 138 | - ) { |
|
| 139 | - $e = erreur_squelette(); |
|
| 140 | - } |
|
| 134 | + $e = ''; |
|
| 135 | + if ( |
|
| 136 | + isset($_COOKIE['spip_admin']) |
|
| 137 | + && (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps'])) |
|
| 138 | + ) { |
|
| 139 | + $e = erreur_squelette(); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - $c = $GLOBALS['meta']['charset']; |
|
| 143 | - header('Content-Type: ' . $content_type . '; charset=' . $c); |
|
| 144 | - $debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : ''); |
|
| 145 | - $fin = ''; |
|
| 142 | + $c = $GLOBALS['meta']['charset']; |
|
| 143 | + header('Content-Type: ' . $content_type . '; charset=' . $c); |
|
| 144 | + $debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : ''); |
|
| 145 | + $fin = ''; |
|
| 146 | 146 | |
| 147 | - echo $debut, $corps, $fin, $e; |
|
| 147 | + echo $debut, $corps, $fin, $e; |
|
| 148 | 148 | } |
@@ -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 | |
| 22 | 22 | /** |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | 28 | function autosave_clean_value($val) { |
| 29 | - return stripslashes(urldecode((string) $val)); |
|
| 29 | + return stripslashes(urldecode((string) $val)); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,58 +37,58 @@ discard block |
||
| 37 | 37 | * @return array |
| 38 | 38 | */ |
| 39 | 39 | function cvtautosave_formulaire_charger($flux) { |
| 40 | - if ( |
|
| 41 | - is_array($flux['data']) |
|
| 42 | - && isset($flux['data']['_autosave_id']) |
|
| 43 | - && ($cle_autosave = $flux['data']['_autosave_id']) |
|
| 44 | - ) { |
|
| 45 | - $form = $flux['args']['form']; |
|
| 46 | - $je_suis_poste = $flux['args']['je_suis_poste']; |
|
| 40 | + if ( |
|
| 41 | + is_array($flux['data']) |
|
| 42 | + && isset($flux['data']['_autosave_id']) |
|
| 43 | + && ($cle_autosave = $flux['data']['_autosave_id']) |
|
| 44 | + ) { |
|
| 45 | + $form = $flux['args']['form']; |
|
| 46 | + $je_suis_poste = $flux['args']['je_suis_poste']; |
|
| 47 | 47 | |
| 48 | - $cle_autosave = serialize($cle_autosave); |
|
| 49 | - $cle_autosave = $form . '_' . md5($cle_autosave); |
|
| 48 | + $cle_autosave = serialize($cle_autosave); |
|
| 49 | + $cle_autosave = $form . '_' . md5($cle_autosave); |
|
| 50 | 50 | |
| 51 | - // si on a un backup en session et qu'on est au premier chargement, non poste |
|
| 52 | - // on restitue les donnees |
|
| 53 | - if ( |
|
| 54 | - isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave]) |
|
| 55 | - && !$je_suis_poste |
|
| 56 | - ) { |
|
| 57 | - parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars); |
|
| 58 | - foreach ($vars as $key => $val) { |
|
| 59 | - if (isset($flux['data'][$key])) { |
|
| 60 | - $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map( |
|
| 61 | - 'autosave_clean_value', |
|
| 62 | - $val |
|
| 63 | - )); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 51 | + // si on a un backup en session et qu'on est au premier chargement, non poste |
|
| 52 | + // on restitue les donnees |
|
| 53 | + if ( |
|
| 54 | + isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave]) |
|
| 55 | + && !$je_suis_poste |
|
| 56 | + ) { |
|
| 57 | + parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars); |
|
| 58 | + foreach ($vars as $key => $val) { |
|
| 59 | + if (isset($flux['data'][$key])) { |
|
| 60 | + $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map( |
|
| 61 | + 'autosave_clean_value', |
|
| 62 | + $val |
|
| 63 | + )); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide |
|
| 69 | - // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave |
|
| 70 | - if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) { |
|
| 71 | - terminer_actualiser_sessions(); |
|
| 72 | - // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide |
|
| 73 | - if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) { |
|
| 74 | - session_set('session_autosave_' . $cle_autosave, null); |
|
| 75 | - // en court sleep pour etre certain que la concurrence est finie |
|
| 76 | - sleep(1); |
|
| 77 | - terminer_actualiser_sessions(); |
|
| 78 | - } |
|
| 79 | - } |
|
| 68 | + // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide |
|
| 69 | + // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave |
|
| 70 | + if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) { |
|
| 71 | + terminer_actualiser_sessions(); |
|
| 72 | + // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide |
|
| 73 | + if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) { |
|
| 74 | + session_set('session_autosave_' . $cle_autosave, null); |
|
| 75 | + // en court sleep pour etre certain que la concurrence est finie |
|
| 76 | + sleep(1); |
|
| 77 | + terminer_actualiser_sessions(); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Envoyer le input hidden et le bout de js qui l'utilisera |
|
| 84 | - */ |
|
| 85 | - $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />" |
|
| 86 | - . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){ |
|
| 82 | + /** |
|
| 83 | + * Envoyer le input hidden et le bout de js qui l'utilisera |
|
| 84 | + */ |
|
| 85 | + $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />" |
|
| 86 | + . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){ |
|
| 87 | 87 | $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon"); |
| 88 | 88 | });/*]]>*/</script>'; |
| 89 | - } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return $flux; |
|
| 91 | + return $flux; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -102,33 +102,33 @@ discard block |
||
| 102 | 102 | * @return array |
| 103 | 103 | */ |
| 104 | 104 | function cvtautosave_formulaire_traiter($flux) { |
| 105 | - // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder : |
|
| 106 | - // on elimine les donnees de la session |
|
| 107 | - if ($cle_autosave = _request('autosave')) { |
|
| 108 | - include_spip('inc/session'); |
|
| 109 | - session_set('session_autosave_' . $cle_autosave, null); |
|
| 110 | - } |
|
| 105 | + // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder : |
|
| 106 | + // on elimine les donnees de la session |
|
| 107 | + if ($cle_autosave = _request('autosave')) { |
|
| 108 | + include_spip('inc/session'); |
|
| 109 | + session_set('session_autosave_' . $cle_autosave, null); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) { |
|
| 113 | - // delai par defaut avant purge d'un backup de form : 72H |
|
| 114 | - if (!defined('_AUTOSAVE_GB_DELAY')) { |
|
| 115 | - define('_AUTOSAVE_GB_DELAY', 72 * 3600); |
|
| 116 | - } |
|
| 117 | - $time_too_old = time() - _AUTOSAVE_GB_DELAY; |
|
| 118 | - // purger aussi toutes les vieilles autosave |
|
| 119 | - $session = $GLOBALS['visiteur_session']; |
|
| 120 | - foreach ($session as $k => $v) { |
|
| 121 | - if (str_starts_with((string) $k, 'session_autosave_')) { |
|
| 122 | - $timestamp = 0; |
|
| 123 | - if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) { |
|
| 124 | - $timestamp = (int) $m[1]; |
|
| 125 | - } |
|
| 126 | - if ($timestamp < $time_too_old) { |
|
| 127 | - session_set($k, null); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 112 | + if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) { |
|
| 113 | + // delai par defaut avant purge d'un backup de form : 72H |
|
| 114 | + if (!defined('_AUTOSAVE_GB_DELAY')) { |
|
| 115 | + define('_AUTOSAVE_GB_DELAY', 72 * 3600); |
|
| 116 | + } |
|
| 117 | + $time_too_old = time() - _AUTOSAVE_GB_DELAY; |
|
| 118 | + // purger aussi toutes les vieilles autosave |
|
| 119 | + $session = $GLOBALS['visiteur_session']; |
|
| 120 | + foreach ($session as $k => $v) { |
|
| 121 | + if (str_starts_with((string) $k, 'session_autosave_')) { |
|
| 122 | + $timestamp = 0; |
|
| 123 | + if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) { |
|
| 124 | + $timestamp = (int) $m[1]; |
|
| 125 | + } |
|
| 126 | + if ($timestamp < $time_too_old) { |
|
| 127 | + session_set($k, null); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return $flux; |
|
| 133 | + return $flux; |
|
| 134 | 134 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('inc/boutons'); |
@@ -38,33 +38,33 @@ discard block |
||
| 38 | 38 | * contexte |
| 39 | 39 | **/ |
| 40 | 40 | function definir_barre_contexte($contexte = null) { |
| 41 | - if (is_null($contexte)) { |
|
| 42 | - $contexte = $_GET; |
|
| 43 | - } elseif (is_string($contexte)) { |
|
| 44 | - $contexte = unserialize($contexte); |
|
| 45 | - } |
|
| 46 | - if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) { |
|
| 47 | - if (!function_exists('trouver_objet_exec')) { |
|
| 48 | - include_spip('inc/pipelines_ecrire'); |
|
| 49 | - } |
|
| 50 | - if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 51 | - $_id = $e['id_table_objet']; |
|
| 52 | - if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) { |
|
| 53 | - $table = $e['table_objet_sql']; |
|
| 54 | - $row = sql_fetsel('*', $table, "$_id=" . (int) $id); |
|
| 55 | - if (isset($row['id_rubrique'])) { |
|
| 56 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 57 | - if (isset($row['id_secteur'])) { |
|
| 58 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 59 | - } |
|
| 60 | - } elseif (isset($row['id_groupe'])) { |
|
| 61 | - // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 62 | - $contexte['id_groupe'] = $row['id_groupe']; |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $contexte; |
|
| 41 | + if (is_null($contexte)) { |
|
| 42 | + $contexte = $_GET; |
|
| 43 | + } elseif (is_string($contexte)) { |
|
| 44 | + $contexte = unserialize($contexte); |
|
| 45 | + } |
|
| 46 | + if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) { |
|
| 47 | + if (!function_exists('trouver_objet_exec')) { |
|
| 48 | + include_spip('inc/pipelines_ecrire'); |
|
| 49 | + } |
|
| 50 | + if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 51 | + $_id = $e['id_table_objet']; |
|
| 52 | + if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) { |
|
| 53 | + $table = $e['table_objet_sql']; |
|
| 54 | + $row = sql_fetsel('*', $table, "$_id=" . (int) $id); |
|
| 55 | + if (isset($row['id_rubrique'])) { |
|
| 56 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 57 | + if (isset($row['id_secteur'])) { |
|
| 58 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 59 | + } |
|
| 60 | + } elseif (isset($row['id_groupe'])) { |
|
| 61 | + // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 62 | + $contexte['id_groupe'] = $row['id_groupe']; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $contexte; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -80,89 +80,89 @@ discard block |
||
| 80 | 80 | * @return array |
| 81 | 81 | */ |
| 82 | 82 | function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) { |
| 83 | - include_spip('inc/autoriser'); |
|
| 84 | - $boutons_admin = []; |
|
| 83 | + include_spip('inc/autoriser'); |
|
| 84 | + $boutons_admin = []; |
|
| 85 | 85 | |
| 86 | - // les boutons du core, issus de ecrire/paquet.xml |
|
| 87 | - $liste_boutons = []; |
|
| 86 | + // les boutons du core, issus de ecrire/paquet.xml |
|
| 87 | + $liste_boutons = []; |
|
| 88 | 88 | |
| 89 | - // ajouter les boutons issus des plugin via paquet.xml |
|
| 90 | - if ( |
|
| 91 | - function_exists('boutons_plugins') |
|
| 92 | - && is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 93 | - ) { |
|
| 94 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 95 | - } |
|
| 89 | + // ajouter les boutons issus des plugin via paquet.xml |
|
| 90 | + if ( |
|
| 91 | + function_exists('boutons_plugins') |
|
| 92 | + && is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 93 | + ) { |
|
| 94 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - foreach ($liste_boutons as $id => $infos) { |
|
| 98 | - $parent = ''; |
|
| 99 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 100 | - if ( |
|
| 101 | - !isset($infos['parent']) |
|
| 102 | - || !($parent = $infos['parent']) |
|
| 103 | - || !$autorise |
|
| 104 | - || autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 105 | - ) { |
|
| 106 | - if ( |
|
| 107 | - $parent |
|
| 108 | - && ($parent = preg_replace(',^bando_,', 'menu_', (string) $parent)) |
|
| 109 | - && isset($boutons_admin[$parent]) |
|
| 110 | - ) { |
|
| 111 | - $position = (isset($infos['position']) && strlen((string) $infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu); |
|
| 112 | - if ($position < 0) { |
|
| 113 | - $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 114 | - } |
|
| 115 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 116 | - + [ |
|
| 117 | - $id => new Bouton( |
|
| 118 | - ($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 119 | - $infos['titre'], // titre |
|
| 120 | - (isset($infos['action']) && $infos['action']) ? $infos['action'] : null, |
|
| 121 | - (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null |
|
| 122 | - ) |
|
| 123 | - ] |
|
| 124 | - + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 125 | - } |
|
| 126 | - if ( |
|
| 127 | - !$parent |
|
| 128 | - // provisoire, eviter les vieux boutons |
|
| 129 | - && !in_array($id, ['forum', 'statistiques_visites']) |
|
| 130 | - && (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 131 | - ) { |
|
| 132 | - $position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 133 | - $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 134 | - + [ |
|
| 135 | - $id => new Bouton( |
|
| 136 | - ($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 137 | - $infos['titre'], // titre |
|
| 138 | - (isset($infos['action']) && $infos['action']) ? $infos['action'] : null, |
|
| 139 | - (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null |
|
| 140 | - ) |
|
| 141 | - ] |
|
| 142 | - + array_slice($boutons_admin, $position, 100); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 97 | + foreach ($liste_boutons as $id => $infos) { |
|
| 98 | + $parent = ''; |
|
| 99 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 100 | + if ( |
|
| 101 | + !isset($infos['parent']) |
|
| 102 | + || !($parent = $infos['parent']) |
|
| 103 | + || !$autorise |
|
| 104 | + || autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 105 | + ) { |
|
| 106 | + if ( |
|
| 107 | + $parent |
|
| 108 | + && ($parent = preg_replace(',^bando_,', 'menu_', (string) $parent)) |
|
| 109 | + && isset($boutons_admin[$parent]) |
|
| 110 | + ) { |
|
| 111 | + $position = (isset($infos['position']) && strlen((string) $infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu); |
|
| 112 | + if ($position < 0) { |
|
| 113 | + $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 114 | + } |
|
| 115 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 116 | + + [ |
|
| 117 | + $id => new Bouton( |
|
| 118 | + ($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 119 | + $infos['titre'], // titre |
|
| 120 | + (isset($infos['action']) && $infos['action']) ? $infos['action'] : null, |
|
| 121 | + (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null |
|
| 122 | + ) |
|
| 123 | + ] |
|
| 124 | + + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 125 | + } |
|
| 126 | + if ( |
|
| 127 | + !$parent |
|
| 128 | + // provisoire, eviter les vieux boutons |
|
| 129 | + && !in_array($id, ['forum', 'statistiques_visites']) |
|
| 130 | + && (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 131 | + ) { |
|
| 132 | + $position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 133 | + $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 134 | + + [ |
|
| 135 | + $id => new Bouton( |
|
| 136 | + ($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 137 | + $infos['titre'], // titre |
|
| 138 | + (isset($infos['action']) && $infos['action']) ? $infos['action'] : null, |
|
| 139 | + (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null |
|
| 140 | + ) |
|
| 141 | + ] |
|
| 142 | + + array_slice($boutons_admin, $position, 100); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 147 | 147 | |
| 148 | - // définir les favoris et positions d’origine |
|
| 149 | - if ($boutons_admin) { |
|
| 150 | - $menus_favoris = obtenir_menus_favoris(); |
|
| 151 | - $i = 1; |
|
| 152 | - foreach ($boutons_admin as $key => $menu) { |
|
| 153 | - $menu->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 154 | - $menu->position = $i++; |
|
| 155 | - if ($menu->sousmenu) { |
|
| 156 | - $j = 1; |
|
| 157 | - foreach ($menu->sousmenu as $key => $bouton) { |
|
| 158 | - $bouton->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 159 | - $bouton->position = $j++; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - } |
|
| 148 | + // définir les favoris et positions d’origine |
|
| 149 | + if ($boutons_admin) { |
|
| 150 | + $menus_favoris = obtenir_menus_favoris(); |
|
| 151 | + $i = 1; |
|
| 152 | + foreach ($boutons_admin as $key => $menu) { |
|
| 153 | + $menu->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 154 | + $menu->position = $i++; |
|
| 155 | + if ($menu->sousmenu) { |
|
| 156 | + $j = 1; |
|
| 157 | + foreach ($menu->sousmenu as $key => $bouton) { |
|
| 158 | + $bouton->favori = (int) table_valeur($menus_favoris, $key, false); |
|
| 159 | + $bouton->position = $j++; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - return $boutons_admin; |
|
| 165 | + return $boutons_admin; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -174,22 +174,22 @@ discard block |
||
| 174 | 174 | * @return Bouton[] |
| 175 | 175 | */ |
| 176 | 176 | function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) { |
| 177 | - foreach ($menus as $menu) { |
|
| 178 | - if ($menu->sousmenu) { |
|
| 179 | - $libelles = $isfavoris = $favoris = []; |
|
| 180 | - foreach ($menu->sousmenu as $key => $item) { |
|
| 181 | - $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 182 | - $isfavoris[$key] = (bool) $item->favori; |
|
| 183 | - $favoris[$key] = $item->favori; |
|
| 184 | - } |
|
| 185 | - if ($avec_favoris) { |
|
| 186 | - array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 187 | - } else { |
|
| 188 | - array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - return $menus; |
|
| 177 | + foreach ($menus as $menu) { |
|
| 178 | + if ($menu->sousmenu) { |
|
| 179 | + $libelles = $isfavoris = $favoris = []; |
|
| 180 | + foreach ($menu->sousmenu as $key => $item) { |
|
| 181 | + $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 182 | + $isfavoris[$key] = (bool) $item->favori; |
|
| 183 | + $favoris[$key] = $item->favori; |
|
| 184 | + } |
|
| 185 | + if ($avec_favoris) { |
|
| 186 | + array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 187 | + } else { |
|
| 188 | + array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + return $menus; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @return Bouton[] |
| 201 | 201 | */ |
| 202 | 202 | function trier_boutons_enfants_par_favoris_alpha($menus) { |
| 203 | - return trier_boutons_enfants_par_alpha($menus, true); |
|
| 203 | + return trier_boutons_enfants_par_alpha($menus, true); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | |
@@ -213,23 +213,23 @@ discard block |
||
| 213 | 213 | * @return string |
| 214 | 214 | */ |
| 215 | 215 | function bandeau_creer_url($url, $args = '', $contexte = null) { |
| 216 | - if (!preg_match(',[\/\?],', $url)) { |
|
| 217 | - $url = generer_url_ecrire($url, $args, true); |
|
| 218 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 219 | - // &truc=@machin@ |
|
| 220 | - // @machin@ etant remplace par _request('machin') |
|
| 221 | - $url = str_replace('&', '&', $url); |
|
| 222 | - while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 223 | - if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) { |
|
| 224 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']); |
|
| 225 | - } |
|
| 226 | - $val = _request($matches[2], $contexte); |
|
| 227 | - $url = parametre_url($url, $matches[1], $val ?: '', '&'); |
|
| 228 | - } |
|
| 229 | - $url = str_replace('&', '&', $url); |
|
| 230 | - } |
|
| 216 | + if (!preg_match(',[\/\?],', $url)) { |
|
| 217 | + $url = generer_url_ecrire($url, $args, true); |
|
| 218 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 219 | + // &truc=@machin@ |
|
| 220 | + // @machin@ etant remplace par _request('machin') |
|
| 221 | + $url = str_replace('&', '&', $url); |
|
| 222 | + while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 223 | + if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) { |
|
| 224 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']); |
|
| 225 | + } |
|
| 226 | + $val = _request($matches[2], $contexte); |
|
| 227 | + $url = parametre_url($url, $matches[1], $val ?: '', '&'); |
|
| 228 | + } |
|
| 229 | + $url = str_replace('&', '&', $url); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return $url; |
|
| 232 | + return $url; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * Code HTML du bandeau |
| 240 | 240 | */ |
| 241 | 241 | function inc_bandeau_dist() { |
| 242 | - return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 242 | + return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | 250 | function obtenir_menus_favoris() { |
| 251 | - if ( |
|
| 252 | - isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 253 | - && is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 254 | - && $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 255 | - ) { |
|
| 256 | - return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 257 | - } |
|
| 258 | - $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 259 | - return $definir_menus_favoris(); |
|
| 251 | + if ( |
|
| 252 | + isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 253 | + && is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 254 | + && $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 255 | + ) { |
|
| 256 | + return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 257 | + } |
|
| 258 | + $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 259 | + return $definir_menus_favoris(); |
|
| 260 | 260 | } |
@@ -10,111 +10,111 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/texte'); |
| 17 | 17 | |
| 18 | 18 | function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') { |
| 19 | 19 | |
| 20 | - if ($list) { |
|
| 21 | - $id_rubrique = $list[$col - 1]; |
|
| 22 | - } |
|
| 20 | + if ($list) { |
|
| 21 | + $id_rubrique = $list[$col - 1]; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - $ret = ''; |
|
| 24 | + $ret = ''; |
|
| 25 | 25 | |
| 26 | - # recherche les filles et petites-filles de la rubrique donnee |
|
| 27 | - # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 28 | - # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 29 | - # racine... sauf vers elle-meme ou sa propre branche) |
|
| 30 | - $ordre = []; |
|
| 31 | - $rub = []; |
|
| 26 | + # recherche les filles et petites-filles de la rubrique donnee |
|
| 27 | + # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 28 | + # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 29 | + # racine... sauf vers elle-meme ou sa propre branche) |
|
| 30 | + $ordre = []; |
|
| 31 | + $rub = []; |
|
| 32 | 32 | |
| 33 | - $res = sql_select( |
|
| 34 | - 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 35 | - 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 36 | - 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 33 | + $res = sql_select( |
|
| 34 | + 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 35 | + 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 36 | + 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 37 | 37 | AND rub1.id_rubrique!=' . sql_quote($exclu) . ' |
| 38 | 38 | AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')', |
| 39 | - '', |
|
| 40 | - '0+rub1.titre,rub1.titre' |
|
| 41 | - ); |
|
| 39 | + '', |
|
| 40 | + '0+rub1.titre,rub1.titre' |
|
| 41 | + ); |
|
| 42 | 42 | |
| 43 | - while ($row = sql_fetch($res)) { |
|
| 44 | - if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 45 | - $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 46 | - if ($row['id_parent'] == $id_rubrique) { |
|
| 47 | - $t = trim((string) typo(supprimer_numero($row['titre']))); |
|
| 48 | - if ($row['langue_choisie'] != 'oui') { |
|
| 49 | - $t .= ' <small title="' |
|
| 50 | - . traduire_nom_langue($row['lang']) |
|
| 51 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 52 | - } |
|
| 53 | - $ordre[$row['id_rubrique']] = $t; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - $next = $list[$col] ?? 0; |
|
| 58 | - if ($ordre) { |
|
| 59 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 60 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 61 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 43 | + while ($row = sql_fetch($res)) { |
|
| 44 | + if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 45 | + $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 46 | + if ($row['id_parent'] == $id_rubrique) { |
|
| 47 | + $t = trim((string) typo(supprimer_numero($row['titre']))); |
|
| 48 | + if ($row['langue_choisie'] != 'oui') { |
|
| 49 | + $t .= ' <small title="' |
|
| 50 | + . traduire_nom_langue($row['lang']) |
|
| 51 | + . '">[' . $row['lang'] . ']</small>'; |
|
| 52 | + } |
|
| 53 | + $ordre[$row['id_rubrique']] = $t; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + $next = $list[$col] ?? 0; |
|
| 58 | + if ($ordre) { |
|
| 59 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 60 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 61 | + $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 62 | 62 | |
| 63 | - foreach ($ordre as $id => $titrebrut) { |
|
| 64 | - $titre = supprimer_numero($titrebrut); |
|
| 63 | + foreach ($ordre as $id => $titrebrut) { |
|
| 64 | + $titre = supprimer_numero($titrebrut); |
|
| 65 | 65 | |
| 66 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 67 | - if (isset($rub[$id]['enfants'])) { |
|
| 68 | - $classe2 = " class='rub-ouverte'"; |
|
| 69 | - $url = "\nhref='$rec&id=$id'"; |
|
| 70 | - } else { |
|
| 71 | - $classe2 = $url = ''; |
|
| 72 | - $url = "\nhref='javascript:void(0)'"; |
|
| 73 | - } |
|
| 66 | + $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 67 | + if (isset($rub[$id]['enfants'])) { |
|
| 68 | + $classe2 = " class='rub-ouverte'"; |
|
| 69 | + $url = "\nhref='$rec&id=$id'"; |
|
| 70 | + } else { |
|
| 71 | + $classe2 = $url = ''; |
|
| 72 | + $url = "\nhref='javascript:void(0)'"; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 76 | - $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 77 | - . (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false') |
|
| 75 | + $js_func = $do . '_selection_titre'; |
|
| 76 | + $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 77 | + . (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false') |
|
| 78 | 78 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 79 | 79 | # et l'affichage de son titre dans le bandeau |
| 80 | - . "\"\nondblclick=\"" |
|
| 81 | - . "$js_func(this." |
|
| 82 | - . 'firstChild.nodeValue,' |
|
| 83 | - . $id |
|
| 84 | - . ",'selection_rubrique','id_parent');" |
|
| 85 | - . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 86 | - . '"'; |
|
| 80 | + . "\"\nondblclick=\"" |
|
| 81 | + . "$js_func(this." |
|
| 82 | + . 'firstChild.nodeValue,' |
|
| 83 | + . $id |
|
| 84 | + . ",'selection_rubrique','id_parent');" |
|
| 85 | + . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 86 | + . '"'; |
|
| 87 | 87 | |
| 88 | - $ret .= "<div class='" |
|
| 89 | - . (($id == $next) ? 'item on' : 'item') |
|
| 90 | - . "'><div class='" |
|
| 91 | - . $classe1 |
|
| 92 | - . "'><div$classe2><a" |
|
| 93 | - . $url |
|
| 94 | - . $click |
|
| 95 | - . '>' |
|
| 96 | - . $titre |
|
| 97 | - . '</a></div></div></div>'; |
|
| 98 | - } |
|
| 99 | - } |
|
| 88 | + $ret .= "<div class='" |
|
| 89 | + . (($id == $next) ? 'item on' : 'item') |
|
| 90 | + . "'><div class='" |
|
| 91 | + . $classe1 |
|
| 92 | + . "'><div$classe2><a" |
|
| 93 | + . $url |
|
| 94 | + . $click |
|
| 95 | + . '>' |
|
| 96 | + . $titre |
|
| 97 | + . '</a></div></div></div>'; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - $idom2 = $idom . '_col_' . ($col + 1); |
|
| 102 | - $left = ($col * 250); |
|
| 101 | + $idom2 = $idom . '_col_' . ($col + 1); |
|
| 102 | + $left = ($col * 250); |
|
| 103 | 103 | |
| 104 | - return http_img_pack( |
|
| 105 | - 'loader.svg', |
|
| 106 | - '', |
|
| 107 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 108 | - . ($left - 30) |
|
| 109 | - . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 110 | - ) |
|
| 111 | - . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 112 | - . ($left - 250) |
|
| 113 | - . "px;'>" |
|
| 114 | - . $ret |
|
| 115 | - . "\n</div>\n<div id='$idom2'>" |
|
| 116 | - . ($next |
|
| 117 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 118 | - : '') |
|
| 119 | - . "\n</div>"; |
|
| 104 | + return http_img_pack( |
|
| 105 | + 'loader.svg', |
|
| 106 | + '', |
|
| 107 | + "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 108 | + . ($left - 30) |
|
| 109 | + . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 110 | + ) |
|
| 111 | + . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 112 | + . ($left - 250) |
|
| 113 | + . "px;'>" |
|
| 114 | + . $ret |
|
| 115 | + . "\n</div>\n<div id='$idom2'>" |
|
| 116 | + . ($next |
|
| 117 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 118 | + : '') |
|
| 119 | + . "\n</div>"; |
|
| 120 | 120 | } |