@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Presentation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/presentation_mini'); |
@@ -31,141 +31,141 @@ discard block |
||
| 31 | 31 | include_spip('inc/filtres_alertes'); |
| 32 | 32 | |
| 33 | 33 | function debut_cadre($style, $icone = '', $fonction = '', $titre = '', $id = '', $class = '', $padding = true) { |
| 34 | - $fond = null; |
|
| 35 | - $style_mapping = [ |
|
| 36 | - 'r' => 'simple', |
|
| 37 | - 'e' => 'raccourcis', |
|
| 38 | - 'couleur' => 'basic highlight', |
|
| 39 | - 'couleur-foncee' => 'basic highlight', |
|
| 40 | - 'trait-couleur' => 'important', |
|
| 41 | - 'alerte' => 'notice', |
|
| 42 | - 'info' => 'info', |
|
| 43 | - 'sous_rub' => 'simple sous-rub' |
|
| 44 | - ]; |
|
| 45 | - $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section']; |
|
| 46 | - $c = $style_mapping[$style] ?? 'simple'; |
|
| 47 | - $class = $c . ($class ? " $class" : ''); |
|
| 48 | - if (!$padding) { |
|
| 49 | - $class .= ($class ? ' ' : '') . 'no-padding'; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - //($id?"id='$id' ":"") |
|
| 53 | - if (strlen($icone) > 1) { |
|
| 54 | - if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 55 | - [$fond, $fonction] = $icone_renommer($icone, $fonction); |
|
| 56 | - } |
|
| 57 | - $size = 24; |
|
| 58 | - if (preg_match('/-([0-9]{1,3})[.](gif|png)$/i', $fond, $match)) { |
|
| 59 | - $size = $match[1]; |
|
| 60 | - } |
|
| 61 | - if ($fonction) { |
|
| 62 | - // 2 images pour composer l'icone : le fond (article) en background, |
|
| 63 | - // la fonction (new) en image |
|
| 64 | - $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" . |
|
| 65 | - http_style_background($fond, 'no-repeat center center', $size)); |
|
| 66 | - } else { |
|
| 67 | - $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'"); |
|
| 68 | - } |
|
| 69 | - $titre = $icone . $titre; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id); |
|
| 34 | + $fond = null; |
|
| 35 | + $style_mapping = [ |
|
| 36 | + 'r' => 'simple', |
|
| 37 | + 'e' => 'raccourcis', |
|
| 38 | + 'couleur' => 'basic highlight', |
|
| 39 | + 'couleur-foncee' => 'basic highlight', |
|
| 40 | + 'trait-couleur' => 'important', |
|
| 41 | + 'alerte' => 'notice', |
|
| 42 | + 'info' => 'info', |
|
| 43 | + 'sous_rub' => 'simple sous-rub' |
|
| 44 | + ]; |
|
| 45 | + $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section']; |
|
| 46 | + $c = $style_mapping[$style] ?? 'simple'; |
|
| 47 | + $class = $c . ($class ? " $class" : ''); |
|
| 48 | + if (!$padding) { |
|
| 49 | + $class .= ($class ? ' ' : '') . 'no-padding'; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + //($id?"id='$id' ":"") |
|
| 53 | + if (strlen($icone) > 1) { |
|
| 54 | + if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 55 | + [$fond, $fonction] = $icone_renommer($icone, $fonction); |
|
| 56 | + } |
|
| 57 | + $size = 24; |
|
| 58 | + if (preg_match('/-([0-9]{1,3})[.](gif|png)$/i', $fond, $match)) { |
|
| 59 | + $size = $match[1]; |
|
| 60 | + } |
|
| 61 | + if ($fonction) { |
|
| 62 | + // 2 images pour composer l'icone : le fond (article) en background, |
|
| 63 | + // la fonction (new) en image |
|
| 64 | + $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" . |
|
| 65 | + http_style_background($fond, 'no-repeat center center', $size)); |
|
| 66 | + } else { |
|
| 67 | + $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'"); |
|
| 68 | + } |
|
| 69 | + $titre = $icone . $titre; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function fin_cadre() { |
| 76 | - return boite_fermer(); |
|
| 76 | + return boite_fermer(); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | function debut_cadre_relief( |
| 81 | - $icone = '', |
|
| 82 | - $dummy = '', |
|
| 83 | - $fonction = '', |
|
| 84 | - $titre = '', |
|
| 85 | - $id = '', |
|
| 86 | - $class = '' |
|
| 81 | + $icone = '', |
|
| 82 | + $dummy = '', |
|
| 83 | + $fonction = '', |
|
| 84 | + $titre = '', |
|
| 85 | + $id = '', |
|
| 86 | + $class = '' |
|
| 87 | 87 | ) { |
| 88 | - return debut_cadre('r', $icone, $fonction, $titre, $id, $class); |
|
| 88 | + return debut_cadre('r', $icone, $fonction, $titre, $id, $class); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function fin_cadre_relief() { |
| 92 | - return fin_cadre(); |
|
| 92 | + return fin_cadre(); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | function debut_cadre_enfonce( |
| 96 | - $icone = '', |
|
| 97 | - $dummy = '', |
|
| 98 | - $fonction = '', |
|
| 99 | - $titre = '', |
|
| 100 | - $id = '', |
|
| 101 | - $class = '' |
|
| 96 | + $icone = '', |
|
| 97 | + $dummy = '', |
|
| 98 | + $fonction = '', |
|
| 99 | + $titre = '', |
|
| 100 | + $id = '', |
|
| 101 | + $class = '' |
|
| 102 | 102 | ) { |
| 103 | - return debut_cadre('e', $icone, $fonction, $titre, $id, $class); |
|
| 103 | + return debut_cadre('e', $icone, $fonction, $titre, $id, $class); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | function fin_cadre_enfonce() { |
| 107 | - return fin_cadre(); |
|
| 107 | + return fin_cadre(); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | function debut_cadre_sous_rub( |
| 111 | - $icone = '', |
|
| 112 | - $dummy = '', |
|
| 113 | - $fonction = '', |
|
| 114 | - $titre = '', |
|
| 115 | - $id = '', |
|
| 116 | - $class = '' |
|
| 111 | + $icone = '', |
|
| 112 | + $dummy = '', |
|
| 113 | + $fonction = '', |
|
| 114 | + $titre = '', |
|
| 115 | + $id = '', |
|
| 116 | + $class = '' |
|
| 117 | 117 | ) { |
| 118 | - return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class); |
|
| 118 | + return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function fin_cadre_sous_rub() { |
| 122 | - return fin_cadre(); |
|
| 122 | + return fin_cadre(); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | function debut_cadre_couleur( |
| 126 | - $icone = '', |
|
| 127 | - $dummy = '', |
|
| 128 | - $fonction = '', |
|
| 129 | - $titre = '', |
|
| 130 | - $id = '', |
|
| 131 | - $class = '' |
|
| 126 | + $icone = '', |
|
| 127 | + $dummy = '', |
|
| 128 | + $fonction = '', |
|
| 129 | + $titre = '', |
|
| 130 | + $id = '', |
|
| 131 | + $class = '' |
|
| 132 | 132 | ) { |
| 133 | - return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class); |
|
| 133 | + return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | function fin_cadre_couleur() { |
| 137 | - return fin_cadre(); |
|
| 137 | + return fin_cadre(); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | function debut_cadre_trait_couleur( |
| 141 | - $icone = '', |
|
| 142 | - $dummy = '', |
|
| 143 | - $fonction = '', |
|
| 144 | - $titre = '', |
|
| 145 | - $id = '', |
|
| 146 | - $class = '' |
|
| 141 | + $icone = '', |
|
| 142 | + $dummy = '', |
|
| 143 | + $fonction = '', |
|
| 144 | + $titre = '', |
|
| 145 | + $id = '', |
|
| 146 | + $class = '' |
|
| 147 | 147 | ) { |
| 148 | - return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class); |
|
| 148 | + return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function fin_cadre_trait_couleur() { |
| 152 | - return fin_cadre(); |
|
| 152 | + return fin_cadre(); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | function debut_boite_alerte() { |
| 156 | - return debut_cadre('alerte', '', '', '', '', ''); |
|
| 156 | + return debut_cadre('alerte', '', '', '', '', ''); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | function fin_boite_alerte() { |
| 160 | - return fin_cadre(); |
|
| 160 | + return fin_cadre(); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | function debut_boite_info() { |
| 164 | - return debut_cadre('info', '', '', '', '', ''); |
|
| 164 | + return debut_cadre('info', '', '', '', '', ''); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function fin_boite_info() { |
| 168 | - return fin_cadre(); |
|
| 168 | + return fin_cadre(); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | * @return string Code PHP. |
| 177 | 177 | **/ |
| 178 | 178 | function gros_titre( |
| 179 | - $titre, |
|
| 180 | - $ze_logo = '' |
|
| 179 | + $titre, |
|
| 180 | + $ze_logo = '' |
|
| 181 | 181 | ) { |
| 182 | - return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n"; |
|
| 182 | + return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // La boite des raccourcis |
| 186 | 186 | // Se place a droite si l'ecran est en mode panoramique. |
| 187 | 187 | function bloc_des_raccourcis($bloc) { |
| 188 | - return creer_colonne_droite() |
|
| 189 | - . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer(); |
|
| 188 | + return creer_colonne_droite() |
|
| 189 | + . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer(); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // |
@@ -196,18 +196,18 @@ discard block |
||
| 196 | 196 | // Fonctions onglets |
| 197 | 197 | // @param string $sous_classe prend la valeur second pour definir les onglet de deuxieme niveau |
| 198 | 198 | function debut_onglet($classe = 'barre_onglet') { |
| 199 | - return "<div class = '$classe clearfix'><ul>\n"; |
|
| 199 | + return "<div class = '$classe clearfix'><ul>\n"; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | function fin_onglet() { |
| 203 | - return "</ul></div>\n"; |
|
| 203 | + return "</ul></div>\n"; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | function onglet($texte, $lien, $onglet_ref, $onglet, $icone = '') { |
| 207 | - return '<li>' |
|
| 208 | - . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '') |
|
| 209 | - . lien_ou_expose($lien, $texte, $onglet == $onglet_ref) |
|
| 210 | - . '</li>'; |
|
| 207 | + return '<li>' |
|
| 208 | + . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '') |
|
| 209 | + . lien_ou_expose($lien, $texte, $onglet == $onglet_ref) |
|
| 210 | + . '</li>'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | * Code HTML du lien |
| 240 | 240 | **/ |
| 241 | 241 | function icone_verticale($texte, $lien, $fond, $fonction = '', $align = '', $javascript = '') { |
| 242 | - // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 243 | - // (il faudrait fusionner avec le cas $javascript) |
|
| 244 | - if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 245 | - [$x, $lien, $atts, $texte] = $r; |
|
| 246 | - $javascript .= $atts; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript); |
|
| 242 | + // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 243 | + // (il faudrait fusionner avec le cas $javascript) |
|
| 244 | + if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 245 | + [$x, $lien, $atts, $texte] = $r; |
|
| 246 | + $javascript .= $atts; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -271,15 +271,15 @@ discard block |
||
| 271 | 271 | * Code HTML du lien |
| 272 | 272 | **/ |
| 273 | 273 | function icone_horizontale($texte, $lien, $fond, $fonction = '', $dummy = '', $javascript = '') { |
| 274 | - $retour = ''; |
|
| 275 | - // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 276 | - // (il faudrait fusionner avec le cas $javascript) |
|
| 277 | - if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 278 | - [$x, $lien, $atts, $texte] = $r; |
|
| 279 | - $javascript .= $atts; |
|
| 280 | - } |
|
| 274 | + $retour = ''; |
|
| 275 | + // cas d'ajax_action_auteur: faut defaire le boulot |
|
| 276 | + // (il faudrait fusionner avec le cas $javascript) |
|
| 277 | + if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) { |
|
| 278 | + [$x, $lien, $atts, $texte] = $r; |
|
| 279 | + $javascript .= $atts; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - $retour = icone_base($lien, $texte, $fond, $fonction, 'horizontale', $javascript); |
|
| 282 | + $retour = icone_base($lien, $texte, $fond, $fonction, 'horizontale', $javascript); |
|
| 283 | 283 | |
| 284 | - return $retour; |
|
| 284 | + return $retour; |
|
| 285 | 285 | } |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | ]; |
| 45 | 45 | $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section']; |
| 46 | 46 | $c = $style_mapping[$style] ?? 'simple'; |
| 47 | - $class = $c . ($class ? " $class" : ''); |
|
| 47 | + $class = $c.($class ? " $class" : ''); |
|
| 48 | 48 | if (!$padding) { |
| 49 | - $class .= ($class ? ' ' : '') . 'no-padding'; |
|
| 49 | + $class .= ($class ? ' ' : '').'no-padding'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | //($id?"id='$id' ":"") |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | if ($fonction) { |
| 62 | 62 | // 2 images pour composer l'icone : le fond (article) en background, |
| 63 | 63 | // la fonction (new) en image |
| 64 | - $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" . |
|
| 64 | + $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n". |
|
| 65 | 65 | http_style_background($fond, 'no-repeat center center', $size)); |
| 66 | 66 | } else { |
| 67 | 67 | $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'"); |
| 68 | 68 | } |
| 69 | - $titre = $icone . $titre; |
|
| 69 | + $titre = $icone.$titre; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id); |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | $titre, |
| 180 | 180 | $ze_logo = '' |
| 181 | 181 | ) { |
| 182 | - return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n"; |
|
| 182 | + return "<h1 class = 'grostitre'>".$ze_logo.' '.typo($titre)."</h1>\n"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // La boite des raccourcis |
| 186 | 186 | // Se place a droite si l'ecran est en mode panoramique. |
| 187 | 187 | function bloc_des_raccourcis($bloc) { |
| 188 | 188 | return creer_colonne_droite() |
| 189 | - . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer(); |
|
| 189 | + . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis').$bloc.boite_fermer(); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/charsets'); |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @return string Fonction PHP correspondante du filtre |
| 43 | 43 | */ |
| 44 | 44 | function charger_filtre($fonc, $default = 'filtre_identite_dist') { |
| 45 | - include_fichiers_fonctions(); // inclure les fichiers fonctions |
|
| 46 | - return chercher_filtre($fonc, $default); |
|
| 45 | + include_fichiers_fonctions(); // inclure les fichiers fonctions |
|
| 46 | + return chercher_filtre($fonc, $default); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return string Texte |
| 54 | 54 | **/ |
| 55 | 55 | function filtre_identite_dist($texte) { |
| 56 | - return $texte; |
|
| 56 | + return $texte; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -77,33 +77,33 @@ discard block |
||
| 77 | 77 | * Fonction PHP correspondante du filtre demandé |
| 78 | 78 | */ |
| 79 | 79 | function chercher_filtre($fonc, $default = null) { |
| 80 | - if (!$fonc) { |
|
| 81 | - return $default; |
|
| 82 | - } |
|
| 83 | - // Cas des types mime, sans confondre avec les appels de fonction de classe |
|
| 84 | - // Foo::Bar |
|
| 85 | - // qui peuvent etre avec un namespace : space\Foo::Bar |
|
| 86 | - if (preg_match(',^[\w]+/,', $fonc)) { |
|
| 87 | - $nom = preg_replace(',\W,', '_', $fonc); |
|
| 88 | - $f = chercher_filtre($nom); |
|
| 89 | - // cas du sous-type MIME sans filtre associe, passer au type: |
|
| 90 | - // si filtre_text_plain pas defini, passe a filtre_text |
|
| 91 | - if (!$f and $nom !== $fonc) { |
|
| 92 | - $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc)); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - return $f; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - include_fichiers_fonctions(); |
|
| 99 | - foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) { |
|
| 100 | - trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 101 | - if (is_callable($f)) { |
|
| 102 | - return $f; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - return $default; |
|
| 80 | + if (!$fonc) { |
|
| 81 | + return $default; |
|
| 82 | + } |
|
| 83 | + // Cas des types mime, sans confondre avec les appels de fonction de classe |
|
| 84 | + // Foo::Bar |
|
| 85 | + // qui peuvent etre avec un namespace : space\Foo::Bar |
|
| 86 | + if (preg_match(',^[\w]+/,', $fonc)) { |
|
| 87 | + $nom = preg_replace(',\W,', '_', $fonc); |
|
| 88 | + $f = chercher_filtre($nom); |
|
| 89 | + // cas du sous-type MIME sans filtre associe, passer au type: |
|
| 90 | + // si filtre_text_plain pas defini, passe a filtre_text |
|
| 91 | + if (!$f and $nom !== $fonc) { |
|
| 92 | + $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc)); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + return $f; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + include_fichiers_fonctions(); |
|
| 99 | + foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) { |
|
| 100 | + trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
|
| 101 | + if (is_callable($f)) { |
|
| 102 | + return $f; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + return $default; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | * Chaîne vide sinon. |
| 148 | 148 | **/ |
| 149 | 149 | function appliquer_filtre($arg, $filtre) { |
| 150 | - $args = func_get_args(); |
|
| 151 | - return appliquer_filtre_sinon($arg, $filtre, $args, ''); |
|
| 150 | + $args = func_get_args(); |
|
| 151 | + return appliquer_filtre_sinon($arg, $filtre, $args, ''); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * Texte d'origine sinon |
| 174 | 174 | **/ |
| 175 | 175 | function appliquer_si_filtre($arg, $filtre) { |
| 176 | - $args = func_get_args(); |
|
| 177 | - return appliquer_filtre_sinon($arg, $filtre, $args, $arg); |
|
| 176 | + $args = func_get_args(); |
|
| 177 | + return appliquer_filtre_sinon($arg, $filtre, $args, $arg); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -190,12 +190,12 @@ discard block |
||
| 190 | 190 | * Version de SPIP |
| 191 | 191 | **/ |
| 192 | 192 | function spip_version() { |
| 193 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 194 | - if ($vcs_version = version_vcs_courante(_DIR_RACINE)) { |
|
| 195 | - $version .= " $vcs_version"; |
|
| 196 | - } |
|
| 193 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 194 | + if ($vcs_version = version_vcs_courante(_DIR_RACINE)) { |
|
| 195 | + $version .= " $vcs_version"; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - return $version; |
|
| 198 | + return $version; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | * @return string |
| 208 | 208 | */ |
| 209 | 209 | function header_silencieux($version): string { |
| 210 | - if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) { |
|
| 211 | - $version = ''; |
|
| 212 | - } |
|
| 210 | + if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) { |
|
| 211 | + $version = ''; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - return (string) $version; |
|
| 214 | + return (string) $version; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -224,19 +224,19 @@ discard block |
||
| 224 | 224 | * - string|null si $raw = false |
| 225 | 225 | */ |
| 226 | 226 | function version_vcs_courante($dir, $raw = false) { |
| 227 | - $desc = decrire_version_git($dir); |
|
| 228 | - if ($desc === null) { |
|
| 229 | - $desc = decrire_version_svn($dir); |
|
| 230 | - } |
|
| 231 | - if ($desc === null or $raw) { |
|
| 232 | - return $desc; |
|
| 233 | - } |
|
| 234 | - // affichage "GIT [master: abcdef]" |
|
| 235 | - $commit = $desc['commit_short'] ?? $desc['commit']; |
|
| 236 | - if ($desc['branch']) { |
|
| 237 | - $commit = $desc['branch'] . ': ' . $commit; |
|
| 238 | - } |
|
| 239 | - return "{$desc['vcs']} [$commit]"; |
|
| 227 | + $desc = decrire_version_git($dir); |
|
| 228 | + if ($desc === null) { |
|
| 229 | + $desc = decrire_version_svn($dir); |
|
| 230 | + } |
|
| 231 | + if ($desc === null or $raw) { |
|
| 232 | + return $desc; |
|
| 233 | + } |
|
| 234 | + // affichage "GIT [master: abcdef]" |
|
| 235 | + $commit = $desc['commit_short'] ?? $desc['commit']; |
|
| 236 | + if ($desc['branch']) { |
|
| 237 | + $commit = $desc['branch'] . ': ' . $commit; |
|
| 238 | + } |
|
| 239 | + return "{$desc['vcs']} [$commit]"; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -248,24 +248,24 @@ discard block |
||
| 248 | 248 | * array ['branch' => xx, 'commit' => yy] sinon. |
| 249 | 249 | **/ |
| 250 | 250 | function decrire_version_git($dir) { |
| 251 | - if (!$dir) { |
|
| 252 | - $dir = '.'; |
|
| 253 | - } |
|
| 251 | + if (!$dir) { |
|
| 252 | + $dir = '.'; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - // version installee par GIT |
|
| 256 | - if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 257 | - $currentHead = trim(substr($c, 4)); |
|
| 258 | - if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 259 | - return [ |
|
| 260 | - 'vcs' => 'GIT', |
|
| 261 | - 'branch' => basename($currentHead), |
|
| 262 | - 'commit' => trim($hash), |
|
| 263 | - 'commit_short' => substr(trim($hash), 0, 8), |
|
| 264 | - ]; |
|
| 265 | - } |
|
| 266 | - } |
|
| 255 | + // version installee par GIT |
|
| 256 | + if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 257 | + $currentHead = trim(substr($c, 4)); |
|
| 258 | + if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 259 | + return [ |
|
| 260 | + 'vcs' => 'GIT', |
|
| 261 | + 'branch' => basename($currentHead), |
|
| 262 | + 'commit' => trim($hash), |
|
| 263 | + 'commit_short' => substr(trim($hash), 0, 8), |
|
| 264 | + ]; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - return null; |
|
| 268 | + return null; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | |
@@ -278,25 +278,25 @@ discard block |
||
| 278 | 278 | * array ['commit' => yy, 'date' => xx, 'author' => xx] sinon. |
| 279 | 279 | **/ |
| 280 | 280 | function decrire_version_svn($dir) { |
| 281 | - if (!$dir) { |
|
| 282 | - $dir = '.'; |
|
| 283 | - } |
|
| 284 | - // version installee par SVN |
|
| 285 | - if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 286 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 287 | - $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 288 | - if ($result) { |
|
| 289 | - $row = $result->fetchArray(); |
|
| 290 | - if ($row['changed_revision'] != '') { |
|
| 291 | - return [ |
|
| 292 | - 'vcs' => 'SVN', |
|
| 293 | - 'branch' => '', |
|
| 294 | - 'commit' => $row['changed_revision'], |
|
| 295 | - ]; |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - return null; |
|
| 281 | + if (!$dir) { |
|
| 282 | + $dir = '.'; |
|
| 283 | + } |
|
| 284 | + // version installee par SVN |
|
| 285 | + if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 286 | + $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 287 | + $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
|
| 288 | + if ($result) { |
|
| 289 | + $row = $result->fetchArray(); |
|
| 290 | + if ($row['changed_revision'] != '') { |
|
| 291 | + return [ |
|
| 292 | + 'vcs' => 'SVN', |
|
| 293 | + 'branch' => '', |
|
| 294 | + 'commit' => $row['changed_revision'], |
|
| 295 | + ]; |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + return null; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
@@ -343,18 +343,18 @@ discard block |
||
| 343 | 343 | * Code HTML retourné par le filtre |
| 344 | 344 | **/ |
| 345 | 345 | function filtrer($filtre) { |
| 346 | - $tous = func_get_args(); |
|
| 347 | - if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 348 | - return image_filtrer($tous); |
|
| 349 | - } elseif ($f = chercher_filtre($filtre)) { |
|
| 350 | - array_shift($tous); |
|
| 351 | - return $f(...$tous); |
|
| 352 | - } else { |
|
| 353 | - // le filtre n'existe pas, on provoque une erreur |
|
| 354 | - $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]]; |
|
| 355 | - erreur_squelette($msg); |
|
| 356 | - return ''; |
|
| 357 | - } |
|
| 346 | + $tous = func_get_args(); |
|
| 347 | + if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') { |
|
| 348 | + return image_filtrer($tous); |
|
| 349 | + } elseif ($f = chercher_filtre($filtre)) { |
|
| 350 | + array_shift($tous); |
|
| 351 | + return $f(...$tous); |
|
| 352 | + } else { |
|
| 353 | + // le filtre n'existe pas, on provoque une erreur |
|
| 354 | + $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]]; |
|
| 355 | + erreur_squelette($msg); |
|
| 356 | + return ''; |
|
| 357 | + } |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -371,11 +371,11 @@ discard block |
||
| 371 | 371 | * @return bool true si on trouve le filtre dans la matrice, false sinon. |
| 372 | 372 | */ |
| 373 | 373 | function trouver_filtre_matrice($filtre) { |
| 374 | - if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 375 | - find_in_path($f, '', true); |
|
| 376 | - $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 377 | - } |
|
| 378 | - return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 374 | + if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) { |
|
| 375 | + find_in_path($f, '', true); |
|
| 376 | + $GLOBALS['spip_matrice'][$filtre] = true; |
|
| 377 | + } |
|
| 378 | + return !empty($GLOBALS['spip_matrice'][$filtre]); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | * @return mixed |
| 404 | 404 | */ |
| 405 | 405 | function filtre_set(&$Pile, $val, $key, $continue = null) { |
| 406 | - $Pile['vars'][$key] = $val; |
|
| 407 | - return $continue ? $val : ''; |
|
| 406 | + $Pile['vars'][$key] = $val; |
|
| 407 | + return $continue ? $val : ''; |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''. |
| 431 | 431 | */ |
| 432 | 432 | function filtre_setenv(&$Pile, $val, $key, $continue = null) { |
| 433 | - $Pile[0][$key] = $val; |
|
| 434 | - return $continue ? $val : ''; |
|
| 433 | + $Pile[0][$key] = $val; |
|
| 434 | + return $continue ? $val : ''; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -440,8 +440,8 @@ discard block |
||
| 440 | 440 | * @return string |
| 441 | 441 | */ |
| 442 | 442 | function filtre_sanitize_env(&$Pile, $keys) { |
| 443 | - $Pile[0] = spip_sanitize_from_request($Pile[0], $keys); |
|
| 444 | - return ''; |
|
| 443 | + $Pile[0] = spip_sanitize_from_request($Pile[0], $keys); |
|
| 444 | + return ''; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | |
@@ -464,18 +464,18 @@ discard block |
||
| 464 | 464 | * @return mixed Retourne la valeur (sans la modifier). |
| 465 | 465 | */ |
| 466 | 466 | function filtre_debug($val, $key = null) { |
| 467 | - $debug = ( |
|
| 468 | - is_null($key) ? '' : (var_export($key, true) . ' = ') |
|
| 469 | - ) . var_export($val, true); |
|
| 467 | + $debug = ( |
|
| 468 | + is_null($key) ? '' : (var_export($key, true) . ' = ') |
|
| 469 | + ) . var_export($val, true); |
|
| 470 | 470 | |
| 471 | - include_spip('inc/autoriser'); |
|
| 472 | - if (autoriser('webmestre')) { |
|
| 473 | - echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 474 | - } |
|
| 471 | + include_spip('inc/autoriser'); |
|
| 472 | + if (autoriser('webmestre')) { |
|
| 473 | + echo "<div class='spip_debug'>\n", $debug, "</div>\n"; |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - spip_log($debug, 'debug'); |
|
| 476 | + spip_log($debug, 'debug'); |
|
| 477 | 477 | |
| 478 | - return $val; |
|
| 478 | + return $val; |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | |
@@ -505,84 +505,84 @@ discard block |
||
| 505 | 505 | * Texte qui a reçu les filtres |
| 506 | 506 | **/ |
| 507 | 507 | function image_filtrer($args) { |
| 508 | - $filtre = array_shift($args); # enlever $filtre |
|
| 509 | - $texte = array_shift($args); |
|
| 510 | - if ($texte === null || !strlen($texte)) { |
|
| 511 | - return ''; |
|
| 512 | - } |
|
| 513 | - find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 514 | - statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 515 | - // Cas du nom de fichier local |
|
| 516 | - $is_file = trim($texte); |
|
| 517 | - if ( |
|
| 518 | - strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false |
|
| 519 | - or strpbrk($is_file, "<>\n\r\t") !== false |
|
| 520 | - or strpos($is_file, '/') === 0 |
|
| 521 | - ) { |
|
| 522 | - $is_file = false; |
|
| 523 | - } |
|
| 524 | - if ($is_file) { |
|
| 525 | - $is_local_file = function ($path) { |
|
| 526 | - if (strpos($path, '?') !== false) { |
|
| 527 | - $path = supprimer_timestamp($path); |
|
| 528 | - // remove ?24px added by find_in_theme on .svg files |
|
| 529 | - $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path); |
|
| 530 | - } |
|
| 531 | - return file_exists($path); |
|
| 532 | - }; |
|
| 533 | - if ($is_local_file($is_file) or tester_url_absolue($is_file)) { |
|
| 534 | - $res = $filtre("<img src='$is_file' />", ...$args); |
|
| 535 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 536 | - return $res; |
|
| 537 | - } |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 541 | - if ( |
|
| 542 | - preg_match_all( |
|
| 543 | - ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 544 | - $texte, |
|
| 545 | - $tags, |
|
| 546 | - PREG_SET_ORDER |
|
| 547 | - ) |
|
| 548 | - ) { |
|
| 549 | - foreach ($tags as $tag) { |
|
| 550 | - $class = extraire_attribut($tag[3], 'class'); |
|
| 551 | - if ( |
|
| 552 | - !$class or |
|
| 553 | - (strpos($class, 'filtre_inactif') === false |
|
| 554 | - // compat historique a virer en 3.2 |
|
| 555 | - and strpos($class, 'no_image_filtrer') === false) |
|
| 556 | - ) { |
|
| 557 | - if ($reduit = $filtre($tag[3], ...$args)) { |
|
| 558 | - // En cas de span spip_documents, modifier le style=...width: |
|
| 559 | - if ($tag[1]) { |
|
| 560 | - $w = extraire_attribut($reduit, 'width'); |
|
| 561 | - if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) { |
|
| 562 | - $w = $regs[1]; |
|
| 563 | - } |
|
| 564 | - if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 565 | - $style = preg_replace(',width:\s*\d+px,S', "width:${w}px", $style); |
|
| 566 | - $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 567 | - $texte = str_replace($tag[1], $replace, $texte); |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - // traiter aussi un eventuel mouseover |
|
| 571 | - if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 572 | - if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 573 | - $srcover = $match[1]; |
|
| 574 | - $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args); |
|
| 575 | - $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 576 | - $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - $texte = str_replace($tag[3], $reduit, $texte); |
|
| 580 | - } |
|
| 581 | - } |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 585 | - return $texte; |
|
| 508 | + $filtre = array_shift($args); # enlever $filtre |
|
| 509 | + $texte = array_shift($args); |
|
| 510 | + if ($texte === null || !strlen($texte)) { |
|
| 511 | + return ''; |
|
| 512 | + } |
|
| 513 | + find_in_path('filtres_images_mini.php', 'inc/', true); |
|
| 514 | + statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver |
|
| 515 | + // Cas du nom de fichier local |
|
| 516 | + $is_file = trim($texte); |
|
| 517 | + if ( |
|
| 518 | + strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false |
|
| 519 | + or strpbrk($is_file, "<>\n\r\t") !== false |
|
| 520 | + or strpos($is_file, '/') === 0 |
|
| 521 | + ) { |
|
| 522 | + $is_file = false; |
|
| 523 | + } |
|
| 524 | + if ($is_file) { |
|
| 525 | + $is_local_file = function ($path) { |
|
| 526 | + if (strpos($path, '?') !== false) { |
|
| 527 | + $path = supprimer_timestamp($path); |
|
| 528 | + // remove ?24px added by find_in_theme on .svg files |
|
| 529 | + $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path); |
|
| 530 | + } |
|
| 531 | + return file_exists($path); |
|
| 532 | + }; |
|
| 533 | + if ($is_local_file($is_file) or tester_url_absolue($is_file)) { |
|
| 534 | + $res = $filtre("<img src='$is_file' />", ...$args); |
|
| 535 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 536 | + return $res; |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + // Cas general : trier toutes les images, avec eventuellement leur <span> |
|
| 541 | + if ( |
|
| 542 | + preg_match_all( |
|
| 543 | + ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS', |
|
| 544 | + $texte, |
|
| 545 | + $tags, |
|
| 546 | + PREG_SET_ORDER |
|
| 547 | + ) |
|
| 548 | + ) { |
|
| 549 | + foreach ($tags as $tag) { |
|
| 550 | + $class = extraire_attribut($tag[3], 'class'); |
|
| 551 | + if ( |
|
| 552 | + !$class or |
|
| 553 | + (strpos($class, 'filtre_inactif') === false |
|
| 554 | + // compat historique a virer en 3.2 |
|
| 555 | + and strpos($class, 'no_image_filtrer') === false) |
|
| 556 | + ) { |
|
| 557 | + if ($reduit = $filtre($tag[3], ...$args)) { |
|
| 558 | + // En cas de span spip_documents, modifier le style=...width: |
|
| 559 | + if ($tag[1]) { |
|
| 560 | + $w = extraire_attribut($reduit, 'width'); |
|
| 561 | + if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) { |
|
| 562 | + $w = $regs[1]; |
|
| 563 | + } |
|
| 564 | + if ($w and ($style = extraire_attribut($tag[1], 'style'))) { |
|
| 565 | + $style = preg_replace(',width:\s*\d+px,S', "width:${w}px", $style); |
|
| 566 | + $replace = inserer_attribut($tag[1], 'style', $style); |
|
| 567 | + $texte = str_replace($tag[1], $replace, $texte); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + // traiter aussi un eventuel mouseover |
|
| 571 | + if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
|
| 572 | + if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
|
| 573 | + $srcover = $match[1]; |
|
| 574 | + $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args); |
|
| 575 | + $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
|
| 576 | + $reduit = str_replace($srcover, $srcover_filter, $reduit); |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + $texte = str_replace($tag[3], $reduit, $texte); |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo |
|
| 585 | + return $texte; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -599,91 +599,91 @@ discard block |
||
| 599 | 599 | **/ |
| 600 | 600 | function infos_image($img, $force_refresh = false) { |
| 601 | 601 | |
| 602 | - static $largeur_img = [], $hauteur_img = [], $poids_img = []; |
|
| 603 | - $srcWidth = 0; |
|
| 604 | - $srcHeight = 0; |
|
| 605 | - $srcSize = null; |
|
| 606 | - |
|
| 607 | - $src = extraire_attribut($img, 'src'); |
|
| 608 | - |
|
| 609 | - if (!$src) { |
|
| 610 | - $src = $img; |
|
| 611 | - } else { |
|
| 612 | - $srcWidth = extraire_attribut($img, 'width'); |
|
| 613 | - $srcHeight = extraire_attribut($img, 'height'); |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 617 | - // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 618 | - if (tester_url_absolue($src)) { |
|
| 619 | - include_spip('inc/distant'); |
|
| 620 | - $fichier = copie_locale($src); |
|
| 621 | - $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 622 | - } |
|
| 623 | - if (($p = strpos($src, '?')) !== false) { |
|
| 624 | - $src = substr($src, 0, $p); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - $imagesize = false; |
|
| 628 | - if (isset($largeur_img[$src]) and !$force_refresh) { |
|
| 629 | - $srcWidth = $largeur_img[$src]; |
|
| 630 | - } |
|
| 631 | - if (isset($hauteur_img[$src]) and !$force_refresh) { |
|
| 632 | - $srcHeight = $hauteur_img[$src]; |
|
| 633 | - } |
|
| 634 | - if (isset($poids_img[$src]) and !$force_refresh) { |
|
| 635 | - $srcSize = $poids_img[$src]; |
|
| 636 | - } |
|
| 637 | - if (!$srcWidth or !$srcHeight or is_null($srcSize)) { |
|
| 638 | - if ( |
|
| 639 | - file_exists($src) |
|
| 640 | - and $imagesize = spip_getimagesize($src) |
|
| 641 | - ) { |
|
| 642 | - if (!$srcWidth) { |
|
| 643 | - $largeur_img[$src] = $srcWidth = $imagesize[0]; |
|
| 644 | - } |
|
| 645 | - if (!$srcHeight) { |
|
| 646 | - $hauteur_img[$src] = $srcHeight = $imagesize[1]; |
|
| 647 | - } |
|
| 648 | - if (!$srcSize) { |
|
| 649 | - $poids_img[$src] = filesize($src); |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - elseif (strpos($src, '<svg') !== false) { |
|
| 653 | - include_spip('inc/svg'); |
|
| 654 | - if ($attrs = svg_lire_attributs($src)) { |
|
| 655 | - [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 656 | - if (!$srcWidth) { |
|
| 657 | - $largeur_img[$src] = $srcWidth = $width; |
|
| 658 | - } |
|
| 659 | - if (!$srcHeight) { |
|
| 660 | - $hauteur_img[$src] = $srcHeight = $height; |
|
| 661 | - } |
|
| 662 | - if (!$srcSize) { |
|
| 663 | - $poids_img[$src] = $srcSize = strlen($src); |
|
| 664 | - } |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 668 | - // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 669 | - elseif ( |
|
| 670 | - @file_exists($f = "$src.src") |
|
| 671 | - and lire_fichier($f, $valeurs) |
|
| 672 | - and $valeurs = unserialize($valeurs) |
|
| 673 | - ) { |
|
| 674 | - if (!$srcWidth) { |
|
| 675 | - $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest']; |
|
| 676 | - } |
|
| 677 | - if (!$srcHeight) { |
|
| 678 | - $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest']; |
|
| 679 | - } |
|
| 680 | - if (!$srcSize) { |
|
| 681 | - $poids_img[$src] = $srcSize = 0; |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize]; |
|
| 602 | + static $largeur_img = [], $hauteur_img = [], $poids_img = []; |
|
| 603 | + $srcWidth = 0; |
|
| 604 | + $srcHeight = 0; |
|
| 605 | + $srcSize = null; |
|
| 606 | + |
|
| 607 | + $src = extraire_attribut($img, 'src'); |
|
| 608 | + |
|
| 609 | + if (!$src) { |
|
| 610 | + $src = $img; |
|
| 611 | + } else { |
|
| 612 | + $srcWidth = extraire_attribut($img, 'width'); |
|
| 613 | + $srcHeight = extraire_attribut($img, 'height'); |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 617 | + // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 618 | + if (tester_url_absolue($src)) { |
|
| 619 | + include_spip('inc/distant'); |
|
| 620 | + $fichier = copie_locale($src); |
|
| 621 | + $src = $fichier ? _DIR_RACINE . $fichier : $src; |
|
| 622 | + } |
|
| 623 | + if (($p = strpos($src, '?')) !== false) { |
|
| 624 | + $src = substr($src, 0, $p); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + $imagesize = false; |
|
| 628 | + if (isset($largeur_img[$src]) and !$force_refresh) { |
|
| 629 | + $srcWidth = $largeur_img[$src]; |
|
| 630 | + } |
|
| 631 | + if (isset($hauteur_img[$src]) and !$force_refresh) { |
|
| 632 | + $srcHeight = $hauteur_img[$src]; |
|
| 633 | + } |
|
| 634 | + if (isset($poids_img[$src]) and !$force_refresh) { |
|
| 635 | + $srcSize = $poids_img[$src]; |
|
| 636 | + } |
|
| 637 | + if (!$srcWidth or !$srcHeight or is_null($srcSize)) { |
|
| 638 | + if ( |
|
| 639 | + file_exists($src) |
|
| 640 | + and $imagesize = spip_getimagesize($src) |
|
| 641 | + ) { |
|
| 642 | + if (!$srcWidth) { |
|
| 643 | + $largeur_img[$src] = $srcWidth = $imagesize[0]; |
|
| 644 | + } |
|
| 645 | + if (!$srcHeight) { |
|
| 646 | + $hauteur_img[$src] = $srcHeight = $imagesize[1]; |
|
| 647 | + } |
|
| 648 | + if (!$srcSize) { |
|
| 649 | + $poids_img[$src] = filesize($src); |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + elseif (strpos($src, '<svg') !== false) { |
|
| 653 | + include_spip('inc/svg'); |
|
| 654 | + if ($attrs = svg_lire_attributs($src)) { |
|
| 655 | + [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs); |
|
| 656 | + if (!$srcWidth) { |
|
| 657 | + $largeur_img[$src] = $srcWidth = $width; |
|
| 658 | + } |
|
| 659 | + if (!$srcHeight) { |
|
| 660 | + $hauteur_img[$src] = $srcHeight = $height; |
|
| 661 | + } |
|
| 662 | + if (!$srcSize) { |
|
| 663 | + $poids_img[$src] = $srcSize = strlen($src); |
|
| 664 | + } |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + // $src peut etre une reference a une image temporaire dont a n'a que le log .src |
|
| 668 | + // on s'y refere, l'image sera reconstruite en temps utile si necessaire |
|
| 669 | + elseif ( |
|
| 670 | + @file_exists($f = "$src.src") |
|
| 671 | + and lire_fichier($f, $valeurs) |
|
| 672 | + and $valeurs = unserialize($valeurs) |
|
| 673 | + ) { |
|
| 674 | + if (!$srcWidth) { |
|
| 675 | + $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest']; |
|
| 676 | + } |
|
| 677 | + if (!$srcHeight) { |
|
| 678 | + $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest']; |
|
| 679 | + } |
|
| 680 | + if (!$srcSize) { |
|
| 681 | + $poids_img[$src] = $srcSize = 0; |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize]; |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -699,13 +699,13 @@ discard block |
||
| 699 | 699 | * poids |
| 700 | 700 | **/ |
| 701 | 701 | function poids_image($img, $force_refresh = false) { |
| 702 | - $infos = infos_image($img, $force_refresh); |
|
| 703 | - return $infos['poids']; |
|
| 702 | + $infos = infos_image($img, $force_refresh); |
|
| 703 | + return $infos['poids']; |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | function taille_image($img, $force_refresh = false) { |
| 707 | - $infos = infos_image($img, $force_refresh); |
|
| 708 | - return [$infos['hauteur'], $infos['largeur']]; |
|
| 707 | + $infos = infos_image($img, $force_refresh); |
|
| 708 | + return [$infos['hauteur'], $infos['largeur']]; |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | /** |
@@ -722,12 +722,12 @@ discard block |
||
| 722 | 722 | * Largeur en pixels, NULL ou 0 si aucune image. |
| 723 | 723 | **/ |
| 724 | 724 | function largeur($img) { |
| 725 | - if (!$img) { |
|
| 726 | - return; |
|
| 727 | - } |
|
| 728 | - [$h, $l] = taille_image($img); |
|
| 725 | + if (!$img) { |
|
| 726 | + return; |
|
| 727 | + } |
|
| 728 | + [$h, $l] = taille_image($img); |
|
| 729 | 729 | |
| 730 | - return $l; |
|
| 730 | + return $l; |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | /** |
@@ -744,12 +744,12 @@ discard block |
||
| 744 | 744 | * Hauteur en pixels, NULL ou 0 si aucune image. |
| 745 | 745 | **/ |
| 746 | 746 | function hauteur($img) { |
| 747 | - if (!$img) { |
|
| 748 | - return; |
|
| 749 | - } |
|
| 750 | - [$h, $l] = taille_image($img); |
|
| 747 | + if (!$img) { |
|
| 748 | + return; |
|
| 749 | + } |
|
| 750 | + [$h, $l] = taille_image($img); |
|
| 751 | 751 | |
| 752 | - return $h; |
|
| 752 | + return $h; |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | |
@@ -769,11 +769,11 @@ discard block |
||
| 769 | 769 | * @return string |
| 770 | 770 | **/ |
| 771 | 771 | function corriger_entites_html($texte) { |
| 772 | - if (strpos($texte, '&') === false) { |
|
| 773 | - return $texte; |
|
| 774 | - } |
|
| 772 | + if (strpos($texte, '&') === false) { |
|
| 773 | + return $texte; |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | - return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 776 | + return preg_replace(',&(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte); |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | /** |
@@ -788,11 +788,11 @@ discard block |
||
| 788 | 788 | * @return string |
| 789 | 789 | **/ |
| 790 | 790 | function corriger_toutes_entites_html($texte) { |
| 791 | - if (strpos($texte, '&') === false) { |
|
| 792 | - return $texte; |
|
| 793 | - } |
|
| 791 | + if (strpos($texte, '&') === false) { |
|
| 792 | + return $texte; |
|
| 793 | + } |
|
| 794 | 794 | |
| 795 | - return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 795 | + return preg_replace(',&(#?[a-z0-9]+;),iS', '&\1', $texte); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | * @return string |
| 803 | 803 | **/ |
| 804 | 804 | function proteger_amp($texte) { |
| 805 | - return str_replace('&', '&', $texte); |
|
| 805 | + return str_replace('&', '&', $texte); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | |
@@ -833,21 +833,21 @@ discard block |
||
| 833 | 833 | * @return mixed|string |
| 834 | 834 | */ |
| 835 | 835 | function entites_html($texte, $tout = false, $quote = true) { |
| 836 | - if ( |
|
| 837 | - !is_string($texte) or !$texte |
|
| 838 | - or strpbrk($texte, "&\"'<>") == false |
|
| 839 | - ) { |
|
| 840 | - return $texte; |
|
| 841 | - } |
|
| 842 | - include_spip('inc/texte'); |
|
| 843 | - $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 844 | - $flags |= ENT_HTML401; |
|
| 845 | - $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 846 | - if ($tout) { |
|
| 847 | - return corriger_toutes_entites_html($texte); |
|
| 848 | - } else { |
|
| 849 | - return corriger_entites_html($texte); |
|
| 850 | - } |
|
| 836 | + if ( |
|
| 837 | + !is_string($texte) or !$texte |
|
| 838 | + or strpbrk($texte, "&\"'<>") == false |
|
| 839 | + ) { |
|
| 840 | + return $texte; |
|
| 841 | + } |
|
| 842 | + include_spip('inc/texte'); |
|
| 843 | + $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES); |
|
| 844 | + $flags |= ENT_HTML401; |
|
| 845 | + $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags); |
|
| 846 | + if ($tout) { |
|
| 847 | + return corriger_toutes_entites_html($texte); |
|
| 848 | + } else { |
|
| 849 | + return corriger_entites_html($texte); |
|
| 850 | + } |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | /** |
@@ -866,37 +866,37 @@ discard block |
||
| 866 | 866 | * Texte converti |
| 867 | 867 | **/ |
| 868 | 868 | function filtrer_entites($texte) { |
| 869 | - if (strpos($texte, '&') === false) { |
|
| 870 | - return $texte; |
|
| 871 | - } |
|
| 872 | - // filtrer |
|
| 873 | - $texte = html2unicode($texte); |
|
| 874 | - // remettre le tout dans le charset cible |
|
| 875 | - $texte = unicode2charset($texte); |
|
| 876 | - // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 877 | - // (on le faisait deja avec un ") |
|
| 878 | - if (strpos($texte, '&#') !== false) { |
|
| 879 | - $texte = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $texte); |
|
| 880 | - } |
|
| 869 | + if (strpos($texte, '&') === false) { |
|
| 870 | + return $texte; |
|
| 871 | + } |
|
| 872 | + // filtrer |
|
| 873 | + $texte = html2unicode($texte); |
|
| 874 | + // remettre le tout dans le charset cible |
|
| 875 | + $texte = unicode2charset($texte); |
|
| 876 | + // cas particulier des " et ' qu'il faut filtrer aussi |
|
| 877 | + // (on le faisait deja avec un ") |
|
| 878 | + if (strpos($texte, '&#') !== false) { |
|
| 879 | + $texte = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $texte); |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | - return $texte; |
|
| 882 | + return $texte; |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | |
| 886 | 886 | if (!function_exists('filtre_filtrer_entites_dist')) { |
| 887 | - /** |
|
| 888 | - * Version sécurisée de filtrer_entites |
|
| 889 | - * |
|
| 890 | - * @uses interdire_scripts() |
|
| 891 | - * @uses filtrer_entites() |
|
| 892 | - * |
|
| 893 | - * @param string $t |
|
| 894 | - * @return string |
|
| 895 | - */ |
|
| 896 | - function filtre_filtrer_entites_dist($t) { |
|
| 897 | - include_spip('inc/texte'); |
|
| 898 | - return interdire_scripts(filtrer_entites($t)); |
|
| 899 | - } |
|
| 887 | + /** |
|
| 888 | + * Version sécurisée de filtrer_entites |
|
| 889 | + * |
|
| 890 | + * @uses interdire_scripts() |
|
| 891 | + * @uses filtrer_entites() |
|
| 892 | + * |
|
| 893 | + * @param string $t |
|
| 894 | + * @return string |
|
| 895 | + */ |
|
| 896 | + function filtre_filtrer_entites_dist($t) { |
|
| 897 | + include_spip('inc/texte'); |
|
| 898 | + return interdire_scripts(filtrer_entites($t)); |
|
| 899 | + } |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | |
@@ -911,18 +911,18 @@ discard block |
||
| 911 | 911 | * @return string|array |
| 912 | 912 | **/ |
| 913 | 913 | function supprimer_caracteres_illegaux($texte) { |
| 914 | - static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; |
|
| 915 | - static $to = null; |
|
| 914 | + static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; |
|
| 915 | + static $to = null; |
|
| 916 | 916 | |
| 917 | - if (is_array($texte)) { |
|
| 918 | - return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 919 | - } |
|
| 917 | + if (is_array($texte)) { |
|
| 918 | + return array_map('supprimer_caracteres_illegaux', $texte); |
|
| 919 | + } |
|
| 920 | 920 | |
| 921 | - if (!$to) { |
|
| 922 | - $to = str_repeat('-', strlen($from)); |
|
| 923 | - } |
|
| 921 | + if (!$to) { |
|
| 922 | + $to = str_repeat('-', strlen($from)); |
|
| 923 | + } |
|
| 924 | 924 | |
| 925 | - return strtr($texte, $from, $to); |
|
| 925 | + return strtr($texte, $from, $to); |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | /** |
@@ -934,10 +934,10 @@ discard block |
||
| 934 | 934 | * @return string|array |
| 935 | 935 | **/ |
| 936 | 936 | function corriger_caracteres($texte) { |
| 937 | - $texte = corriger_caracteres_windows($texte); |
|
| 938 | - $texte = supprimer_caracteres_illegaux($texte); |
|
| 937 | + $texte = corriger_caracteres_windows($texte); |
|
| 938 | + $texte = supprimer_caracteres_illegaux($texte); |
|
| 939 | 939 | |
| 940 | - return $texte; |
|
| 940 | + return $texte; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | /** |
@@ -954,44 +954,44 @@ discard block |
||
| 954 | 954 | * Texte encodé pour XML |
| 955 | 955 | */ |
| 956 | 956 | function texte_backend(string $texte): string { |
| 957 | - if ($texte === '') { |
|
| 958 | - return ''; |
|
| 959 | - } |
|
| 957 | + if ($texte === '') { |
|
| 958 | + return ''; |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | - static $apostrophe = ['’', "'"]; # n'allouer qu'une fois |
|
| 961 | + static $apostrophe = ['’', "'"]; # n'allouer qu'une fois |
|
| 962 | 962 | |
| 963 | - // si on a des liens ou des images, les passer en absolu |
|
| 964 | - $texte = liens_absolus($texte); |
|
| 963 | + // si on a des liens ou des images, les passer en absolu |
|
| 964 | + $texte = liens_absolus($texte); |
|
| 965 | 965 | |
| 966 | - // echapper les tags > < |
|
| 967 | - $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 966 | + // echapper les tags > < |
|
| 967 | + $texte = preg_replace(',&(gt|lt);,S', '&\1;', $texte); |
|
| 968 | 968 | |
| 969 | - // importer les é |
|
| 970 | - $texte = filtrer_entites($texte); |
|
| 969 | + // importer les é |
|
| 970 | + $texte = filtrer_entites($texte); |
|
| 971 | 971 | |
| 972 | - // " -> " et tout ce genre de choses |
|
| 973 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 974 | - $texte = str_replace(' ', ' ', $texte); |
|
| 975 | - $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte); |
|
| 976 | - // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 977 | - $texte = entites_html($texte, false, false); |
|
| 978 | - // mais bien echapper les double quotes ! |
|
| 979 | - $texte = str_replace('"', '"', $texte); |
|
| 972 | + // " -> " et tout ce genre de choses |
|
| 973 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 974 | + $texte = str_replace(' ', ' ', $texte); |
|
| 975 | + $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte); |
|
| 976 | + // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
|
| 977 | + $texte = entites_html($texte, false, false); |
|
| 978 | + // mais bien echapper les double quotes ! |
|
| 979 | + $texte = str_replace('"', '"', $texte); |
|
| 980 | 980 | |
| 981 | - // verifier le charset |
|
| 982 | - $texte = charset2unicode($texte); |
|
| 981 | + // verifier le charset |
|
| 982 | + $texte = charset2unicode($texte); |
|
| 983 | 983 | |
| 984 | - // Caracteres problematiques en iso-latin 1 |
|
| 985 | - if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 986 | - $texte = str_replace(chr(156), 'œ', $texte); |
|
| 987 | - $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 988 | - $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 989 | - } |
|
| 984 | + // Caracteres problematiques en iso-latin 1 |
|
| 985 | + if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') { |
|
| 986 | + $texte = str_replace(chr(156), 'œ', $texte); |
|
| 987 | + $texte = str_replace(chr(140), 'Œ', $texte); |
|
| 988 | + $texte = str_replace(chr(159), 'Ÿ', $texte); |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | - // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 992 | - // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 993 | - // ==> on les remplace par l'entite HTML |
|
| 994 | - return str_replace($apostrophe, "'", $texte); |
|
| 991 | + // l'apostrophe curly pose probleme a certains lecteure de RSS |
|
| 992 | + // et le caractere apostrophe alourdit les squelettes avec PHP |
|
| 993 | + // ==> on les remplace par l'entite HTML |
|
| 994 | + return str_replace($apostrophe, "'", $texte); |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | /** |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | * Texte encodé et quote pour XML |
| 1009 | 1009 | */ |
| 1010 | 1010 | function texte_backendq(string $texte): string { |
| 1011 | - return addslashes(texte_backend($texte)); |
|
| 1011 | + return addslashes(texte_backend($texte)); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | |
@@ -1031,11 +1031,11 @@ discard block |
||
| 1031 | 1031 | * Numéro de titre, sinon chaîne vide |
| 1032 | 1032 | **/ |
| 1033 | 1033 | function supprimer_numero($texte) { |
| 1034 | - return preg_replace( |
|
| 1035 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1036 | - '', |
|
| 1037 | - $texte |
|
| 1038 | - ); |
|
| 1034 | + return preg_replace( |
|
| 1035 | + ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1036 | + '', |
|
| 1037 | + $texte |
|
| 1038 | + ); |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | /** |
@@ -1058,17 +1058,17 @@ discard block |
||
| 1058 | 1058 | * Numéro de titre, sinon chaîne vide |
| 1059 | 1059 | **/ |
| 1060 | 1060 | function recuperer_numero($texte) { |
| 1061 | - if ( |
|
| 1062 | - preg_match( |
|
| 1063 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1064 | - $texte, |
|
| 1065 | - $regs |
|
| 1066 | - ) |
|
| 1067 | - ) { |
|
| 1068 | - return strval($regs[1]); |
|
| 1069 | - } else { |
|
| 1070 | - return ''; |
|
| 1071 | - } |
|
| 1061 | + if ( |
|
| 1062 | + preg_match( |
|
| 1063 | + ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1064 | + $texte, |
|
| 1065 | + $regs |
|
| 1066 | + ) |
|
| 1067 | + ) { |
|
| 1068 | + return strval($regs[1]); |
|
| 1069 | + } else { |
|
| 1070 | + return ''; |
|
| 1071 | + } |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | /** |
@@ -1095,16 +1095,16 @@ discard block |
||
| 1095 | 1095 | * Texte ou tableau de textes converti |
| 1096 | 1096 | **/ |
| 1097 | 1097 | function supprimer_tags($texte, $rempl = '') { |
| 1098 | - if ($texte === null) { |
|
| 1099 | - return ''; |
|
| 1100 | - } |
|
| 1101 | - $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte); |
|
| 1102 | - // ne pas oublier un < final non ferme car coupe |
|
| 1103 | - $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte); |
|
| 1104 | - // mais qui peut aussi etre un simple signe plus petit que |
|
| 1105 | - $texte = str_replace('<', '<', $texte); |
|
| 1098 | + if ($texte === null) { |
|
| 1099 | + return ''; |
|
| 1100 | + } |
|
| 1101 | + $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte); |
|
| 1102 | + // ne pas oublier un < final non ferme car coupe |
|
| 1103 | + $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte); |
|
| 1104 | + // mais qui peut aussi etre un simple signe plus petit que |
|
| 1105 | + $texte = str_replace('<', '<', $texte); |
|
| 1106 | 1106 | |
| 1107 | - return $texte; |
|
| 1107 | + return $texte; |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | 1110 | /** |
@@ -1127,9 +1127,9 @@ discard block |
||
| 1127 | 1127 | * Texte converti |
| 1128 | 1128 | **/ |
| 1129 | 1129 | function echapper_tags($texte, $rempl = '') { |
| 1130 | - $texte = preg_replace('/<([^>]*)>/', "<\\1>", $texte); |
|
| 1130 | + $texte = preg_replace('/<([^>]*)>/', "<\\1>", $texte); |
|
| 1131 | 1131 | |
| 1132 | - return $texte; |
|
| 1132 | + return $texte; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | /** |
@@ -1150,18 +1150,18 @@ discard block |
||
| 1150 | 1150 | * Texte converti |
| 1151 | 1151 | **/ |
| 1152 | 1152 | function textebrut($texte) { |
| 1153 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1154 | - $texte = preg_replace('/\s+/S' . $u, ' ', $texte); |
|
| 1155 | - $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte); |
|
| 1156 | - $texte = preg_replace("/^\n+/", '', $texte); |
|
| 1157 | - $texte = preg_replace("/\n+$/", '', $texte); |
|
| 1158 | - $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 1159 | - $texte = supprimer_tags($texte); |
|
| 1160 | - $texte = preg_replace('/( | )+/S', ' ', $texte); |
|
| 1161 | - // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 1162 | - $texte = str_replace('’', "'", $texte); |
|
| 1153 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1154 | + $texte = preg_replace('/\s+/S' . $u, ' ', $texte); |
|
| 1155 | + $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte); |
|
| 1156 | + $texte = preg_replace("/^\n+/", '', $texte); |
|
| 1157 | + $texte = preg_replace("/\n+$/", '', $texte); |
|
| 1158 | + $texte = preg_replace("/\n +/", "\n", $texte); |
|
| 1159 | + $texte = supprimer_tags($texte); |
|
| 1160 | + $texte = preg_replace('/( | )+/S', ' ', $texte); |
|
| 1161 | + // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail... |
|
| 1162 | + $texte = str_replace('’', "'", $texte); |
|
| 1163 | 1163 | |
| 1164 | - return $texte; |
|
| 1164 | + return $texte; |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | |
@@ -1177,23 +1177,23 @@ discard block |
||
| 1177 | 1177 | * Texte avec liens ouvrants |
| 1178 | 1178 | **/ |
| 1179 | 1179 | function liens_ouvrants($texte) { |
| 1180 | - if ( |
|
| 1181 | - preg_match_all( |
|
| 1182 | - ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1183 | - $texte, |
|
| 1184 | - $liens, |
|
| 1185 | - PREG_PATTERN_ORDER |
|
| 1186 | - ) |
|
| 1187 | - ) { |
|
| 1188 | - foreach ($liens[0] as $a) { |
|
| 1189 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1190 | - $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1191 | - $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1192 | - $texte = str_replace($a, $ablank, $texte); |
|
| 1193 | - } |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - return $texte; |
|
| 1180 | + if ( |
|
| 1181 | + preg_match_all( |
|
| 1182 | + ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS", |
|
| 1183 | + $texte, |
|
| 1184 | + $liens, |
|
| 1185 | + PREG_PATTERN_ORDER |
|
| 1186 | + ) |
|
| 1187 | + ) { |
|
| 1188 | + foreach ($liens[0] as $a) { |
|
| 1189 | + $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1190 | + $ablank = inserer_attribut($a, 'rel', $rel); |
|
| 1191 | + $ablank = inserer_attribut($ablank, 'target', '_blank'); |
|
| 1192 | + $texte = str_replace($a, $ablank, $texte); |
|
| 1193 | + } |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + return $texte; |
|
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | /** |
@@ -1203,22 +1203,22 @@ discard block |
||
| 1203 | 1203 | * @return string |
| 1204 | 1204 | */ |
| 1205 | 1205 | function liens_nofollow($texte) { |
| 1206 | - if (stripos($texte, '<a') === false) { |
|
| 1207 | - return $texte; |
|
| 1208 | - } |
|
| 1206 | + if (stripos($texte, '<a') === false) { |
|
| 1207 | + return $texte; |
|
| 1208 | + } |
|
| 1209 | 1209 | |
| 1210 | - if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1211 | - foreach ($regs[0] as $a) { |
|
| 1212 | - $rel = extraire_attribut($a, 'rel') ?? ''; |
|
| 1213 | - if (strpos($rel, 'nofollow') === false) { |
|
| 1214 | - $rel = 'nofollow' . ($rel ? " $rel" : ''); |
|
| 1215 | - $anofollow = inserer_attribut($a, 'rel', $rel); |
|
| 1216 | - $texte = str_replace($a, $anofollow, $texte); |
|
| 1217 | - } |
|
| 1218 | - } |
|
| 1219 | - } |
|
| 1210 | + if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) { |
|
| 1211 | + foreach ($regs[0] as $a) { |
|
| 1212 | + $rel = extraire_attribut($a, 'rel') ?? ''; |
|
| 1213 | + if (strpos($rel, 'nofollow') === false) { |
|
| 1214 | + $rel = 'nofollow' . ($rel ? " $rel" : ''); |
|
| 1215 | + $anofollow = inserer_attribut($a, 'rel', $rel); |
|
| 1216 | + $texte = str_replace($a, $anofollow, $texte); |
|
| 1217 | + } |
|
| 1218 | + } |
|
| 1219 | + } |
|
| 1220 | 1220 | |
| 1221 | - return $texte; |
|
| 1221 | + return $texte; |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | /** |
@@ -1237,12 +1237,12 @@ discard block |
||
| 1237 | 1237 | * Texte sans paraghaphes |
| 1238 | 1238 | **/ |
| 1239 | 1239 | function PtoBR($texte) { |
| 1240 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1241 | - $texte = preg_replace('@</p>@iS', "\n", $texte); |
|
| 1242 | - $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte); |
|
| 1243 | - $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte); |
|
| 1240 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1241 | + $texte = preg_replace('@</p>@iS', "\n", $texte); |
|
| 1242 | + $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte); |
|
| 1243 | + $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte); |
|
| 1244 | 1244 | |
| 1245 | - return $texte; |
|
| 1245 | + return $texte; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | |
@@ -1267,14 +1267,14 @@ discard block |
||
| 1267 | 1267 | * @return string Texte encadré du style CSS |
| 1268 | 1268 | */ |
| 1269 | 1269 | function lignes_longues($texte) { |
| 1270 | - if (!strlen(trim($texte))) { |
|
| 1271 | - return $texte; |
|
| 1272 | - } |
|
| 1273 | - include_spip('inc/texte'); |
|
| 1274 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1275 | - 'div' : 'span'; |
|
| 1270 | + if (!strlen(trim($texte))) { |
|
| 1271 | + return $texte; |
|
| 1272 | + } |
|
| 1273 | + include_spip('inc/texte'); |
|
| 1274 | + $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1275 | + 'div' : 'span'; |
|
| 1276 | 1276 | |
| 1277 | - return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1277 | + return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | /** |
@@ -1293,30 +1293,30 @@ discard block |
||
| 1293 | 1293 | * @return string Texte en majuscule |
| 1294 | 1294 | */ |
| 1295 | 1295 | function majuscules($texte) { |
| 1296 | - if (!strlen($texte)) { |
|
| 1297 | - return ''; |
|
| 1298 | - } |
|
| 1296 | + if (!strlen($texte)) { |
|
| 1297 | + return ''; |
|
| 1298 | + } |
|
| 1299 | 1299 | |
| 1300 | - // Cas du turc |
|
| 1301 | - if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1302 | - # remplacer hors des tags et des entites |
|
| 1303 | - if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1304 | - foreach ($regs as $n => $match) { |
|
| 1305 | - $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1306 | - } |
|
| 1307 | - } |
|
| 1300 | + // Cas du turc |
|
| 1301 | + if ($GLOBALS['spip_lang'] == 'tr') { |
|
| 1302 | + # remplacer hors des tags et des entites |
|
| 1303 | + if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) { |
|
| 1304 | + foreach ($regs as $n => $match) { |
|
| 1305 | + $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte); |
|
| 1306 | + } |
|
| 1307 | + } |
|
| 1308 | 1308 | |
| 1309 | - $texte = str_replace('i', 'İ', $texte); |
|
| 1309 | + $texte = str_replace('i', 'İ', $texte); |
|
| 1310 | 1310 | |
| 1311 | - if ($regs) { |
|
| 1312 | - foreach ($regs as $n => $match) { |
|
| 1313 | - $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1314 | - } |
|
| 1315 | - } |
|
| 1316 | - } |
|
| 1311 | + if ($regs) { |
|
| 1312 | + foreach ($regs as $n => $match) { |
|
| 1313 | + $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte); |
|
| 1314 | + } |
|
| 1315 | + } |
|
| 1316 | + } |
|
| 1317 | 1317 | |
| 1318 | - // Cas general |
|
| 1319 | - return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1318 | + // Cas general |
|
| 1319 | + return "<span style='text-transform: uppercase;'>$texte</span>"; |
|
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | /** |
@@ -1334,29 +1334,29 @@ discard block |
||
| 1334 | 1334 | * @return string |
| 1335 | 1335 | **/ |
| 1336 | 1336 | function taille_en_octets($taille) { |
| 1337 | - if (!defined('_KILOBYTE')) { |
|
| 1338 | - /** |
|
| 1339 | - * Définit le nombre d'octets dans un Kilobyte |
|
| 1340 | - * |
|
| 1341 | - * @var int |
|
| 1342 | - **/ |
|
| 1343 | - define('_KILOBYTE', 1024); |
|
| 1344 | - } |
|
| 1337 | + if (!defined('_KILOBYTE')) { |
|
| 1338 | + /** |
|
| 1339 | + * Définit le nombre d'octets dans un Kilobyte |
|
| 1340 | + * |
|
| 1341 | + * @var int |
|
| 1342 | + **/ |
|
| 1343 | + define('_KILOBYTE', 1024); |
|
| 1344 | + } |
|
| 1345 | 1345 | |
| 1346 | - if ($taille < 1) { |
|
| 1347 | - return ''; |
|
| 1348 | - } |
|
| 1349 | - if ($taille < _KILOBYTE) { |
|
| 1350 | - $taille = _T('taille_octets', ['taille' => $taille]); |
|
| 1351 | - } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1352 | - $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]); |
|
| 1353 | - } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1354 | - $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]); |
|
| 1355 | - } else { |
|
| 1356 | - $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]); |
|
| 1357 | - } |
|
| 1346 | + if ($taille < 1) { |
|
| 1347 | + return ''; |
|
| 1348 | + } |
|
| 1349 | + if ($taille < _KILOBYTE) { |
|
| 1350 | + $taille = _T('taille_octets', ['taille' => $taille]); |
|
| 1351 | + } elseif ($taille < _KILOBYTE * _KILOBYTE) { |
|
| 1352 | + $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]); |
|
| 1353 | + } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) { |
|
| 1354 | + $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]); |
|
| 1355 | + } else { |
|
| 1356 | + $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]); |
|
| 1357 | + } |
|
| 1358 | 1358 | |
| 1359 | - return $taille; |
|
| 1359 | + return $taille; |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | |
@@ -1378,21 +1378,21 @@ discard block |
||
| 1378 | 1378 | * Texte prêt pour être utilisé en attribut HTML |
| 1379 | 1379 | **/ |
| 1380 | 1380 | function attribut_html(?string $texte, $textebrut = true): string { |
| 1381 | - if ($texte === null) { |
|
| 1382 | - return ''; |
|
| 1383 | - } |
|
| 1384 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 1385 | - if ($textebrut) { |
|
| 1386 | - $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); |
|
| 1387 | - } |
|
| 1388 | - $texte = texte_backend($texte); |
|
| 1389 | - $texte = str_replace(["'", '"'], [''', '"'], $texte); |
|
| 1381 | + if ($texte === null) { |
|
| 1382 | + return ''; |
|
| 1383 | + } |
|
| 1384 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 1385 | + if ($textebrut) { |
|
| 1386 | + $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); |
|
| 1387 | + } |
|
| 1388 | + $texte = texte_backend($texte); |
|
| 1389 | + $texte = str_replace(["'", '"'], [''', '"'], $texte); |
|
| 1390 | 1390 | |
| 1391 | - return preg_replace( |
|
| 1392 | - ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'], |
|
| 1393 | - ['&', '&'], |
|
| 1394 | - $texte |
|
| 1395 | - ); |
|
| 1391 | + return preg_replace( |
|
| 1392 | + ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'], |
|
| 1393 | + ['&', '&'], |
|
| 1394 | + $texte |
|
| 1395 | + ); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | |
@@ -1412,15 +1412,15 @@ discard block |
||
| 1412 | 1412 | * URL ou chaîne vide |
| 1413 | 1413 | **/ |
| 1414 | 1414 | function vider_url(?string $url, $entites = true): string { |
| 1415 | - if ($url === null) { |
|
| 1416 | - return ''; |
|
| 1417 | - } |
|
| 1418 | - # un message pour abs_url |
|
| 1419 | - $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1420 | - $url = trim($url); |
|
| 1421 | - $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1415 | + if ($url === null) { |
|
| 1416 | + return ''; |
|
| 1417 | + } |
|
| 1418 | + # un message pour abs_url |
|
| 1419 | + $GLOBALS['mode_abs_url'] = 'url'; |
|
| 1420 | + $url = trim($url); |
|
| 1421 | + $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1422 | 1422 | |
| 1423 | - return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1423 | + return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
|
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | |
@@ -1435,10 +1435,10 @@ discard block |
||
| 1435 | 1435 | * @return string Adresse email maquillée |
| 1436 | 1436 | **/ |
| 1437 | 1437 | function antispam($texte) { |
| 1438 | - include_spip('inc/acces'); |
|
| 1439 | - $masque = creer_pass_aleatoire(3); |
|
| 1438 | + include_spip('inc/acces'); |
|
| 1439 | + $masque = creer_pass_aleatoire(3); |
|
| 1440 | 1440 | |
| 1441 | - return preg_replace('/@/', " $masque ", $texte); |
|
| 1441 | + return preg_replace('/@/', " $masque ", $texte); |
|
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | /** |
@@ -1470,8 +1470,8 @@ discard block |
||
| 1470 | 1470 | * True si on a le droit d'accès, false sinon. |
| 1471 | 1471 | **/ |
| 1472 | 1472 | function filtre_securiser_acces_dist($id_auteur, $cle, $dir, $op = '', $args = '') { |
| 1473 | - include_spip('inc/acces'); |
|
| 1474 | - return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir); |
|
| 1473 | + include_spip('inc/acces'); |
|
| 1474 | + return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir); |
|
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | 1477 | /** |
@@ -1496,13 +1496,13 @@ discard block |
||
| 1496 | 1496 | * Retourne $texte, sinon $sinon. |
| 1497 | 1497 | **/ |
| 1498 | 1498 | function sinon($texte, $sinon = '') { |
| 1499 | - if ($texte) { |
|
| 1500 | - return $texte; |
|
| 1501 | - } elseif (is_scalar($texte) and strlen($texte)) { |
|
| 1502 | - return $texte; |
|
| 1503 | - } else { |
|
| 1504 | - return $sinon; |
|
| 1505 | - } |
|
| 1499 | + if ($texte) { |
|
| 1500 | + return $texte; |
|
| 1501 | + } elseif (is_scalar($texte) and strlen($texte)) { |
|
| 1502 | + return $texte; |
|
| 1503 | + } else { |
|
| 1504 | + return $sinon; |
|
| 1505 | + } |
|
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | /** |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | * @return mixed |
| 1527 | 1527 | **/ |
| 1528 | 1528 | function choixsivide($a, $vide, $pasvide) { |
| 1529 | - return $a ? $pasvide : $vide; |
|
| 1529 | + return $a ? $pasvide : $vide; |
|
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | /** |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | * @return mixed |
| 1551 | 1551 | **/ |
| 1552 | 1552 | function choixsiegal($a1, $a2, $v, $f) { |
| 1553 | - return ($a1 == $a2) ? $v : $f; |
|
| 1553 | + return ($a1 == $a2) ? $v : $f; |
|
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | 1556 | // |
@@ -1569,13 +1569,13 @@ discard block |
||
| 1569 | 1569 | * @return string |
| 1570 | 1570 | **/ |
| 1571 | 1571 | function filtrer_ical($texte) { |
| 1572 | - #include_spip('inc/charsets'); |
|
| 1573 | - $texte = html2unicode($texte); |
|
| 1574 | - $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8'); |
|
| 1575 | - $texte = preg_replace("/\n/", ' ', $texte); |
|
| 1576 | - $texte = preg_replace('/,/', '\,', $texte); |
|
| 1572 | + #include_spip('inc/charsets'); |
|
| 1573 | + $texte = html2unicode($texte); |
|
| 1574 | + $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8'); |
|
| 1575 | + $texte = preg_replace("/\n/", ' ', $texte); |
|
| 1576 | + $texte = preg_replace('/,/', '\,', $texte); |
|
| 1577 | 1577 | |
| 1578 | - return $texte; |
|
| 1578 | + return $texte; |
|
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | |
@@ -1600,54 +1600,54 @@ discard block |
||
| 1600 | 1600 | * @return string |
| 1601 | 1601 | **/ |
| 1602 | 1602 | function post_autobr($texte, $delim = "\n_ ") { |
| 1603 | - if (!function_exists('echappe_html')) { |
|
| 1604 | - include_spip('inc/texte_mini'); |
|
| 1605 | - } |
|
| 1606 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 1607 | - $texte = str_replace("\r", "\n", $texte); |
|
| 1608 | - |
|
| 1609 | - if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1610 | - $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1611 | - } else { |
|
| 1612 | - $fin = ''; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - $texte = echappe_html($texte, '', true); |
|
| 1616 | - |
|
| 1617 | - // echapper les modeles |
|
| 1618 | - if (strpos($texte, '<') !== false) { |
|
| 1619 | - include_spip('inc/lien'); |
|
| 1620 | - if (defined('_PREG_MODELE')) { |
|
| 1621 | - $preg_modeles = '@' . _PREG_MODELE . '@imsS'; |
|
| 1622 | - $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1623 | - } |
|
| 1624 | - } |
|
| 1625 | - |
|
| 1626 | - $debut = ''; |
|
| 1627 | - $suite = $texte; |
|
| 1628 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1629 | - $debut .= substr($suite, 0, $t - 1); |
|
| 1630 | - $suite = substr($suite, $t); |
|
| 1631 | - $car = substr($suite, 0, 1); |
|
| 1632 | - if ( |
|
| 1633 | - ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}') |
|
| 1634 | - and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1635 | - and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1636 | - ) { |
|
| 1637 | - $debut .= $delim; |
|
| 1638 | - } else { |
|
| 1639 | - $debut .= "\n"; |
|
| 1640 | - } |
|
| 1641 | - if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1642 | - $debut .= $regs[0]; |
|
| 1643 | - $suite = substr($suite, strlen($regs[0])); |
|
| 1644 | - } |
|
| 1645 | - } |
|
| 1646 | - $texte = $debut . $suite; |
|
| 1647 | - |
|
| 1648 | - $texte = echappe_retour($texte); |
|
| 1649 | - |
|
| 1650 | - return $texte . $fin; |
|
| 1603 | + if (!function_exists('echappe_html')) { |
|
| 1604 | + include_spip('inc/texte_mini'); |
|
| 1605 | + } |
|
| 1606 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 1607 | + $texte = str_replace("\r", "\n", $texte); |
|
| 1608 | + |
|
| 1609 | + if (preg_match(",\n+$,", $texte, $fin)) { |
|
| 1610 | + $texte = substr($texte, 0, -strlen($fin = $fin[0])); |
|
| 1611 | + } else { |
|
| 1612 | + $fin = ''; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + $texte = echappe_html($texte, '', true); |
|
| 1616 | + |
|
| 1617 | + // echapper les modeles |
|
| 1618 | + if (strpos($texte, '<') !== false) { |
|
| 1619 | + include_spip('inc/lien'); |
|
| 1620 | + if (defined('_PREG_MODELE')) { |
|
| 1621 | + $preg_modeles = '@' . _PREG_MODELE . '@imsS'; |
|
| 1622 | + $texte = echappe_html($texte, '', true, $preg_modeles); |
|
| 1623 | + } |
|
| 1624 | + } |
|
| 1625 | + |
|
| 1626 | + $debut = ''; |
|
| 1627 | + $suite = $texte; |
|
| 1628 | + while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1629 | + $debut .= substr($suite, 0, $t - 1); |
|
| 1630 | + $suite = substr($suite, $t); |
|
| 1631 | + $car = substr($suite, 0, 1); |
|
| 1632 | + if ( |
|
| 1633 | + ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}') |
|
| 1634 | + and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite)) |
|
| 1635 | + and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut) |
|
| 1636 | + ) { |
|
| 1637 | + $debut .= $delim; |
|
| 1638 | + } else { |
|
| 1639 | + $debut .= "\n"; |
|
| 1640 | + } |
|
| 1641 | + if (preg_match(",^\n+,", $suite, $regs)) { |
|
| 1642 | + $debut .= $regs[0]; |
|
| 1643 | + $suite = substr($suite, strlen($regs[0])); |
|
| 1644 | + } |
|
| 1645 | + } |
|
| 1646 | + $texte = $debut . $suite; |
|
| 1647 | + |
|
| 1648 | + $texte = echappe_retour($texte); |
|
| 1649 | + |
|
| 1650 | + return $texte . $fin; |
|
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | |
@@ -1688,47 +1688,47 @@ discard block |
||
| 1688 | 1688 | * @return string |
| 1689 | 1689 | **/ |
| 1690 | 1690 | function extraire_idiome($letexte, $lang = null, $options = []) { |
| 1691 | - static $traduire = false; |
|
| 1692 | - if ( |
|
| 1693 | - $letexte |
|
| 1694 | - and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1695 | - ) { |
|
| 1696 | - if (!$traduire) { |
|
| 1697 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 1698 | - include_spip('inc/lang'); |
|
| 1699 | - } |
|
| 1700 | - if (!$lang) { |
|
| 1701 | - $lang = $GLOBALS['spip_lang']; |
|
| 1702 | - } |
|
| 1703 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1704 | - if (is_bool($options)) { |
|
| 1705 | - $options = ['echappe_span' => $options]; |
|
| 1706 | - } |
|
| 1707 | - if (!isset($options['echappe_span'])) { |
|
| 1708 | - $options = array_merge($options, ['echappe_span' => false]); |
|
| 1709 | - } |
|
| 1710 | - |
|
| 1711 | - foreach ($regs as $reg) { |
|
| 1712 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1713 | - $desc = $traduire($cle, $lang, true); |
|
| 1714 | - $l = $desc->langue; |
|
| 1715 | - // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1716 | - if (strlen($desc->texte ?? '')) { |
|
| 1717 | - $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1718 | - if ($l !== $lang) { |
|
| 1719 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1720 | - } |
|
| 1721 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1722 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1723 | - } |
|
| 1724 | - if (!$options['echappe_span']) { |
|
| 1725 | - $trad = echappe_retour($trad, 'idiome'); |
|
| 1726 | - } |
|
| 1727 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1728 | - } |
|
| 1729 | - } |
|
| 1730 | - } |
|
| 1731 | - return $letexte; |
|
| 1691 | + static $traduire = false; |
|
| 1692 | + if ( |
|
| 1693 | + $letexte |
|
| 1694 | + and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER) |
|
| 1695 | + ) { |
|
| 1696 | + if (!$traduire) { |
|
| 1697 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 1698 | + include_spip('inc/lang'); |
|
| 1699 | + } |
|
| 1700 | + if (!$lang) { |
|
| 1701 | + $lang = $GLOBALS['spip_lang']; |
|
| 1702 | + } |
|
| 1703 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1704 | + if (is_bool($options)) { |
|
| 1705 | + $options = ['echappe_span' => $options]; |
|
| 1706 | + } |
|
| 1707 | + if (!isset($options['echappe_span'])) { |
|
| 1708 | + $options = array_merge($options, ['echappe_span' => false]); |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + foreach ($regs as $reg) { |
|
| 1712 | + $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1713 | + $desc = $traduire($cle, $lang, true); |
|
| 1714 | + $l = $desc->langue; |
|
| 1715 | + // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
|
| 1716 | + if (strlen($desc->texte ?? '')) { |
|
| 1717 | + $trad = code_echappement($desc->texte, 'idiome', false); |
|
| 1718 | + if ($l !== $lang) { |
|
| 1719 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1720 | + } |
|
| 1721 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1722 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1723 | + } |
|
| 1724 | + if (!$options['echappe_span']) { |
|
| 1725 | + $trad = echappe_retour($trad, 'idiome'); |
|
| 1726 | + } |
|
| 1727 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1728 | + } |
|
| 1729 | + } |
|
| 1730 | + } |
|
| 1731 | + return $letexte; |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | 1734 | /** |
@@ -1780,68 +1780,68 @@ discard block |
||
| 1780 | 1780 | **/ |
| 1781 | 1781 | function extraire_multi($letexte, $lang = null, $options = []) { |
| 1782 | 1782 | |
| 1783 | - if ( |
|
| 1784 | - $letexte |
|
| 1785 | - and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1786 | - ) { |
|
| 1787 | - if (!$lang) { |
|
| 1788 | - $lang = $GLOBALS['spip_lang']; |
|
| 1789 | - } |
|
| 1790 | - |
|
| 1791 | - // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1792 | - if (is_bool($options)) { |
|
| 1793 | - $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT]; |
|
| 1794 | - } |
|
| 1795 | - if (!isset($options['echappe_span'])) { |
|
| 1796 | - $options = array_merge($options, ['echappe_span' => false]); |
|
| 1797 | - } |
|
| 1798 | - if (!isset($options['lang_defaut'])) { |
|
| 1799 | - $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]); |
|
| 1800 | - } |
|
| 1801 | - |
|
| 1802 | - include_spip('inc/lang'); |
|
| 1803 | - foreach ($regs as $reg) { |
|
| 1804 | - // chercher la version de la langue courante |
|
| 1805 | - $trads = extraire_trads($reg[1]); |
|
| 1806 | - if ($l = approcher_langue($trads, $lang)) { |
|
| 1807 | - $trad = $trads[$l]; |
|
| 1808 | - } else { |
|
| 1809 | - if ($options['lang_defaut'] == 'aucune') { |
|
| 1810 | - $trad = ''; |
|
| 1811 | - } else { |
|
| 1812 | - // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1813 | - // ou la premiere dispo |
|
| 1814 | - // mais typographier le texte selon les regles de celle-ci |
|
| 1815 | - // Attention aux blocs multi sur plusieurs lignes |
|
| 1816 | - if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1817 | - $l = key($trads); |
|
| 1818 | - } |
|
| 1819 | - $trad = $trads[$l]; |
|
| 1820 | - $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1821 | - $trad = $typographie($trad); |
|
| 1822 | - // Tester si on echappe en span ou en div |
|
| 1823 | - // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1824 | - include_spip('inc/texte'); |
|
| 1825 | - $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad)); |
|
| 1826 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1827 | - if ($mode === 'div') { |
|
| 1828 | - $trad = rtrim($trad) . "\n\n"; |
|
| 1829 | - } |
|
| 1830 | - $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1831 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1832 | - if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1833 | - $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1834 | - } |
|
| 1835 | - if (!$options['echappe_span']) { |
|
| 1836 | - $trad = echappe_retour($trad, 'multi'); |
|
| 1837 | - } |
|
| 1838 | - } |
|
| 1839 | - } |
|
| 1840 | - $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1841 | - } |
|
| 1842 | - } |
|
| 1843 | - |
|
| 1844 | - return $letexte; |
|
| 1783 | + if ( |
|
| 1784 | + $letexte |
|
| 1785 | + and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER) |
|
| 1786 | + ) { |
|
| 1787 | + if (!$lang) { |
|
| 1788 | + $lang = $GLOBALS['spip_lang']; |
|
| 1789 | + } |
|
| 1790 | + |
|
| 1791 | + // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean |
|
| 1792 | + if (is_bool($options)) { |
|
| 1793 | + $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT]; |
|
| 1794 | + } |
|
| 1795 | + if (!isset($options['echappe_span'])) { |
|
| 1796 | + $options = array_merge($options, ['echappe_span' => false]); |
|
| 1797 | + } |
|
| 1798 | + if (!isset($options['lang_defaut'])) { |
|
| 1799 | + $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]); |
|
| 1800 | + } |
|
| 1801 | + |
|
| 1802 | + include_spip('inc/lang'); |
|
| 1803 | + foreach ($regs as $reg) { |
|
| 1804 | + // chercher la version de la langue courante |
|
| 1805 | + $trads = extraire_trads($reg[1]); |
|
| 1806 | + if ($l = approcher_langue($trads, $lang)) { |
|
| 1807 | + $trad = $trads[$l]; |
|
| 1808 | + } else { |
|
| 1809 | + if ($options['lang_defaut'] == 'aucune') { |
|
| 1810 | + $trad = ''; |
|
| 1811 | + } else { |
|
| 1812 | + // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php) |
|
| 1813 | + // ou la premiere dispo |
|
| 1814 | + // mais typographier le texte selon les regles de celle-ci |
|
| 1815 | + // Attention aux blocs multi sur plusieurs lignes |
|
| 1816 | + if (!$l = approcher_langue($trads, $options['lang_defaut'])) { |
|
| 1817 | + $l = key($trads); |
|
| 1818 | + } |
|
| 1819 | + $trad = $trads[$l]; |
|
| 1820 | + $typographie = charger_fonction(lang_typo($l), 'typographie'); |
|
| 1821 | + $trad = $typographie($trad); |
|
| 1822 | + // Tester si on echappe en span ou en div |
|
| 1823 | + // il ne faut pas echapper en div si propre produit un seul paragraphe |
|
| 1824 | + include_spip('inc/texte'); |
|
| 1825 | + $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad)); |
|
| 1826 | + $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1827 | + if ($mode === 'div') { |
|
| 1828 | + $trad = rtrim($trad) . "\n\n"; |
|
| 1829 | + } |
|
| 1830 | + $trad = code_echappement($trad, 'multi', false, $mode); |
|
| 1831 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
|
| 1832 | + if (lang_dir($l) !== lang_dir($lang)) { |
|
| 1833 | + $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l))); |
|
| 1834 | + } |
|
| 1835 | + if (!$options['echappe_span']) { |
|
| 1836 | + $trad = echappe_retour($trad, 'multi'); |
|
| 1837 | + } |
|
| 1838 | + } |
|
| 1839 | + } |
|
| 1840 | + $letexte = str_replace($reg[0], $trad, $letexte); |
|
| 1841 | + } |
|
| 1842 | + } |
|
| 1843 | + |
|
| 1844 | + return $letexte; |
|
| 1845 | 1845 | } |
| 1846 | 1846 | |
| 1847 | 1847 | /** |
@@ -1857,21 +1857,21 @@ discard block |
||
| 1857 | 1857 | * Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué. |
| 1858 | 1858 | **/ |
| 1859 | 1859 | function extraire_trads($bloc) { |
| 1860 | - $trads = []; |
|
| 1861 | - $lang = ''; |
|
| 1860 | + $trads = []; |
|
| 1861 | + $lang = ''; |
|
| 1862 | 1862 | // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ |
| 1863 | 1863 | // while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) { |
| 1864 | - while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) { |
|
| 1865 | - $texte = trim($regs[1]); |
|
| 1866 | - if ($texte or $lang) { |
|
| 1867 | - $trads[$lang] = $texte; |
|
| 1868 | - } |
|
| 1869 | - $bloc = substr($bloc, strlen($regs[0])); |
|
| 1870 | - $lang = $regs[2]; |
|
| 1871 | - } |
|
| 1872 | - $trads[$lang] = $bloc; |
|
| 1864 | + while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) { |
|
| 1865 | + $texte = trim($regs[1]); |
|
| 1866 | + if ($texte or $lang) { |
|
| 1867 | + $trads[$lang] = $texte; |
|
| 1868 | + } |
|
| 1869 | + $bloc = substr($bloc, strlen($regs[0])); |
|
| 1870 | + $lang = $regs[2]; |
|
| 1871 | + } |
|
| 1872 | + $trads[$lang] = $bloc; |
|
| 1873 | 1873 | |
| 1874 | - return $trads; |
|
| 1874 | + return $trads; |
|
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | * @return string L'initiale en majuscule |
| 1883 | 1883 | */ |
| 1884 | 1884 | function filtre_initiale($nom) { |
| 1885 | - return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1885 | + return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1); |
|
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | |
@@ -1927,33 +1927,33 @@ discard block |
||
| 1927 | 1927 | * - null (interne) : si on empile |
| 1928 | 1928 | **/ |
| 1929 | 1929 | function unique($donnee, $famille = '', $cpt = false) { |
| 1930 | - static $mem = []; |
|
| 1931 | - // permettre de vider la pile et de la restaurer |
|
| 1932 | - // pour le calcul de introduction... |
|
| 1933 | - if ($famille == '_spip_raz_') { |
|
| 1934 | - $tmp = $mem; |
|
| 1935 | - $mem = []; |
|
| 1936 | - |
|
| 1937 | - return $tmp; |
|
| 1938 | - } elseif ($famille == '_spip_set_') { |
|
| 1939 | - $mem = $donnee; |
|
| 1940 | - |
|
| 1941 | - return; |
|
| 1942 | - } |
|
| 1943 | - // eviter une notice |
|
| 1944 | - if (!isset($mem[$famille])) { |
|
| 1945 | - $mem[$famille] = []; |
|
| 1946 | - } |
|
| 1947 | - if ($cpt) { |
|
| 1948 | - return is_countable($mem[$famille]) ? count($mem[$famille]) : 0; |
|
| 1949 | - } |
|
| 1950 | - // eviter une notice |
|
| 1951 | - if (!isset($mem[$famille][$donnee])) { |
|
| 1952 | - $mem[$famille][$donnee] = 0; |
|
| 1953 | - } |
|
| 1954 | - if (!($mem[$famille][$donnee]++)) { |
|
| 1955 | - return $donnee; |
|
| 1956 | - } |
|
| 1930 | + static $mem = []; |
|
| 1931 | + // permettre de vider la pile et de la restaurer |
|
| 1932 | + // pour le calcul de introduction... |
|
| 1933 | + if ($famille == '_spip_raz_') { |
|
| 1934 | + $tmp = $mem; |
|
| 1935 | + $mem = []; |
|
| 1936 | + |
|
| 1937 | + return $tmp; |
|
| 1938 | + } elseif ($famille == '_spip_set_') { |
|
| 1939 | + $mem = $donnee; |
|
| 1940 | + |
|
| 1941 | + return; |
|
| 1942 | + } |
|
| 1943 | + // eviter une notice |
|
| 1944 | + if (!isset($mem[$famille])) { |
|
| 1945 | + $mem[$famille] = []; |
|
| 1946 | + } |
|
| 1947 | + if ($cpt) { |
|
| 1948 | + return is_countable($mem[$famille]) ? count($mem[$famille]) : 0; |
|
| 1949 | + } |
|
| 1950 | + // eviter une notice |
|
| 1951 | + if (!isset($mem[$famille][$donnee])) { |
|
| 1952 | + $mem[$famille][$donnee] = 0; |
|
| 1953 | + } |
|
| 1954 | + if (!($mem[$famille][$donnee]++)) { |
|
| 1955 | + return $donnee; |
|
| 1956 | + } |
|
| 1957 | 1957 | } |
| 1958 | 1958 | |
| 1959 | 1959 | |
@@ -1983,20 +1983,20 @@ discard block |
||
| 1983 | 1983 | * Une des valeurs en fonction du compteur. |
| 1984 | 1984 | **/ |
| 1985 | 1985 | function alterner($i, ...$args) { |
| 1986 | - // recuperer les arguments (attention fonctions un peu space) |
|
| 1987 | - $num = count($args); |
|
| 1986 | + // recuperer les arguments (attention fonctions un peu space) |
|
| 1987 | + $num = count($args); |
|
| 1988 | 1988 | |
| 1989 | - if ($num === 1 && is_array($args[0])) { |
|
| 1990 | - // un tableau de valeur dont les cles sont numerotees de 0 a num |
|
| 1991 | - $args = array_values($args[0]); |
|
| 1992 | - $num = count($args); |
|
| 1993 | - } |
|
| 1989 | + if ($num === 1 && is_array($args[0])) { |
|
| 1990 | + // un tableau de valeur dont les cles sont numerotees de 0 a num |
|
| 1991 | + $args = array_values($args[0]); |
|
| 1992 | + $num = count($args); |
|
| 1993 | + } |
|
| 1994 | 1994 | |
| 1995 | - // un index compris entre 0 et num exclus |
|
| 1996 | - $i = ((intval($i) - 1) % $num); // dans ]-$num;$num[ |
|
| 1997 | - $i = ($i + $num) % $num; // dans [0;$num[ |
|
| 1998 | - // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1999 | - return $args[$i]; |
|
| 1995 | + // un index compris entre 0 et num exclus |
|
| 1996 | + $i = ((intval($i) - 1) % $num); // dans ]-$num;$num[ |
|
| 1997 | + $i = ($i + $num) % $num; // dans [0;$num[ |
|
| 1998 | + // renvoyer le i-ieme argument, modulo le nombre d'arguments |
|
| 1999 | + return $args[$i]; |
|
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | 2002 | |
@@ -2022,51 +2022,51 @@ discard block |
||
| 2022 | 2022 | * - null lorsque l’attribut n’existe pas. |
| 2023 | 2023 | **/ |
| 2024 | 2024 | function extraire_attribut($balise, $attribut, $complet = false) { |
| 2025 | - if (is_array($balise)) { |
|
| 2026 | - array_walk( |
|
| 2027 | - $balise, |
|
| 2028 | - function (&$a, $key, $t) { |
|
| 2029 | - $a = extraire_attribut($a, $t); |
|
| 2030 | - }, |
|
| 2031 | - $attribut |
|
| 2032 | - ); |
|
| 2033 | - |
|
| 2034 | - return $balise; |
|
| 2035 | - } |
|
| 2036 | - if ( |
|
| 2037 | - $balise |
|
| 2038 | - && preg_match( |
|
| 2039 | - ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 2040 | - . $attribut |
|
| 2041 | - . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 2042 | - $balise, |
|
| 2043 | - $r |
|
| 2044 | - ) |
|
| 2045 | - ) { |
|
| 2046 | - if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 2047 | - $r[4] = substr($r[3], 1, -1); |
|
| 2048 | - $r[3] = $r[3][0]; |
|
| 2049 | - } elseif ($r[3] !== '') { |
|
| 2050 | - $r[4] = $r[3]; |
|
| 2051 | - $r[3] = ''; |
|
| 2052 | - } else { |
|
| 2053 | - $r[4] = trim($r[2]); |
|
| 2054 | - } |
|
| 2055 | - $att = $r[4]; |
|
| 2056 | - if (strpos($att, '&#') !== false) { |
|
| 2057 | - $att = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $att); |
|
| 2058 | - } |
|
| 2059 | - $att = filtrer_entites($att); |
|
| 2060 | - } else { |
|
| 2061 | - $att = null; |
|
| 2062 | - $r = []; |
|
| 2063 | - } |
|
| 2064 | - |
|
| 2065 | - if ($complet) { |
|
| 2066 | - return [$att, $r]; |
|
| 2067 | - } else { |
|
| 2068 | - return $att; |
|
| 2069 | - } |
|
| 2025 | + if (is_array($balise)) { |
|
| 2026 | + array_walk( |
|
| 2027 | + $balise, |
|
| 2028 | + function (&$a, $key, $t) { |
|
| 2029 | + $a = extraire_attribut($a, $t); |
|
| 2030 | + }, |
|
| 2031 | + $attribut |
|
| 2032 | + ); |
|
| 2033 | + |
|
| 2034 | + return $balise; |
|
| 2035 | + } |
|
| 2036 | + if ( |
|
| 2037 | + $balise |
|
| 2038 | + && preg_match( |
|
| 2039 | + ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+' |
|
| 2040 | + . $attribut |
|
| 2041 | + . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS', |
|
| 2042 | + $balise, |
|
| 2043 | + $r |
|
| 2044 | + ) |
|
| 2045 | + ) { |
|
| 2046 | + if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) { |
|
| 2047 | + $r[4] = substr($r[3], 1, -1); |
|
| 2048 | + $r[3] = $r[3][0]; |
|
| 2049 | + } elseif ($r[3] !== '') { |
|
| 2050 | + $r[4] = $r[3]; |
|
| 2051 | + $r[3] = ''; |
|
| 2052 | + } else { |
|
| 2053 | + $r[4] = trim($r[2]); |
|
| 2054 | + } |
|
| 2055 | + $att = $r[4]; |
|
| 2056 | + if (strpos($att, '&#') !== false) { |
|
| 2057 | + $att = str_replace([''', ''', '"', '"'], ["'", "'", '"', '"'], $att); |
|
| 2058 | + } |
|
| 2059 | + $att = filtrer_entites($att); |
|
| 2060 | + } else { |
|
| 2061 | + $att = null; |
|
| 2062 | + $r = []; |
|
| 2063 | + } |
|
| 2064 | + |
|
| 2065 | + if ($complet) { |
|
| 2066 | + return [$att, $r]; |
|
| 2067 | + } else { |
|
| 2068 | + return $att; |
|
| 2069 | + } |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | /** |
@@ -2099,41 +2099,41 @@ discard block |
||
| 2099 | 2099 | **/ |
| 2100 | 2100 | function inserer_attribut(?string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false): string { |
| 2101 | 2101 | |
| 2102 | - if ($balise === null or $balise === '') { |
|
| 2103 | - return ''; |
|
| 2104 | - } |
|
| 2102 | + if ($balise === null or $balise === '') { |
|
| 2103 | + return ''; |
|
| 2104 | + } |
|
| 2105 | 2105 | |
| 2106 | - // preparer l'attribut |
|
| 2107 | - // supprimer les etc mais pas les balises html |
|
| 2108 | - // qui ont un sens dans un attribut value d'un input |
|
| 2109 | - if ($proteger) { |
|
| 2110 | - $val = attribut_html($val, false); |
|
| 2111 | - } |
|
| 2106 | + // preparer l'attribut |
|
| 2107 | + // supprimer les etc mais pas les balises html |
|
| 2108 | + // qui ont un sens dans un attribut value d'un input |
|
| 2109 | + if ($proteger) { |
|
| 2110 | + $val = attribut_html($val, false); |
|
| 2111 | + } |
|
| 2112 | 2112 | |
| 2113 | - // echapper les ' pour eviter tout bug |
|
| 2114 | - $val = str_replace("'", ''', $val); |
|
| 2115 | - if ($vider and strlen($val) === 0) { |
|
| 2116 | - $insert = ''; |
|
| 2117 | - } else { |
|
| 2118 | - $insert = " $attribut='$val'"; |
|
| 2119 | - } |
|
| 2113 | + // echapper les ' pour eviter tout bug |
|
| 2114 | + $val = str_replace("'", ''', $val); |
|
| 2115 | + if ($vider and strlen($val) === 0) { |
|
| 2116 | + $insert = ''; |
|
| 2117 | + } else { |
|
| 2118 | + $insert = " $attribut='$val'"; |
|
| 2119 | + } |
|
| 2120 | 2120 | |
| 2121 | - [$old, $r] = extraire_attribut($balise, $attribut, true); |
|
| 2121 | + [$old, $r] = extraire_attribut($balise, $attribut, true); |
|
| 2122 | 2122 | |
| 2123 | - if ($old !== null) { |
|
| 2124 | - // Remplacer l'ancien attribut du meme nom |
|
| 2125 | - $balise = $r[1] . $insert . $r[5]; |
|
| 2126 | - } else { |
|
| 2127 | - // preferer une balise " />" (comme <img />) |
|
| 2128 | - if (preg_match(',/>,', $balise)) { |
|
| 2129 | - $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1); |
|
| 2130 | - } // sinon une balise <a ...> ... </a> |
|
| 2131 | - else { |
|
| 2132 | - $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1); |
|
| 2133 | - } |
|
| 2134 | - } |
|
| 2123 | + if ($old !== null) { |
|
| 2124 | + // Remplacer l'ancien attribut du meme nom |
|
| 2125 | + $balise = $r[1] . $insert . $r[5]; |
|
| 2126 | + } else { |
|
| 2127 | + // preferer une balise " />" (comme <img />) |
|
| 2128 | + if (preg_match(',/>,', $balise)) { |
|
| 2129 | + $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1); |
|
| 2130 | + } // sinon une balise <a ...> ... </a> |
|
| 2131 | + else { |
|
| 2132 | + $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1); |
|
| 2133 | + } |
|
| 2134 | + } |
|
| 2135 | 2135 | |
| 2136 | - return $balise; |
|
| 2136 | + return $balise; |
|
| 2137 | 2137 | } |
| 2138 | 2138 | |
| 2139 | 2139 | /** |
@@ -2151,7 +2151,7 @@ discard block |
||
| 2151 | 2151 | * @return string Code HTML sans l'attribut |
| 2152 | 2152 | **/ |
| 2153 | 2153 | function vider_attribut(?string $balise, string $attribut): string { |
| 2154 | - return inserer_attribut($balise, $attribut, '', false, true); |
|
| 2154 | + return inserer_attribut($balise, $attribut, '', false, true); |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | /** |
@@ -2163,53 +2163,53 @@ discard block |
||
| 2163 | 2163 | * @return string |
| 2164 | 2164 | */ |
| 2165 | 2165 | function modifier_class($balise, $class, $operation = 'ajouter') { |
| 2166 | - if (is_string($class)) { |
|
| 2167 | - $class = explode(' ', trim($class)); |
|
| 2168 | - } |
|
| 2169 | - $class = array_filter($class); |
|
| 2170 | - $class = array_unique($class); |
|
| 2171 | - if (!$class) { |
|
| 2172 | - return $balise; |
|
| 2173 | - } |
|
| 2174 | - |
|
| 2175 | - // si la ou les classes ont des caracteres invalides on ne fait rien |
|
| 2176 | - if (preg_match(',[^\w-],', implode('', $class))) { |
|
| 2177 | - return $balise; |
|
| 2178 | - } |
|
| 2179 | - |
|
| 2180 | - $class_courante = extraire_attribut($balise, 'class'); |
|
| 2181 | - $class_new = $class_courante; |
|
| 2182 | - foreach ($class as $c) { |
|
| 2183 | - $is_class_presente = false; |
|
| 2184 | - if ( |
|
| 2185 | - $class_courante |
|
| 2186 | - and strpos($class_courante, (string) $c) !== false |
|
| 2187 | - and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante) |
|
| 2188 | - ) { |
|
| 2189 | - $is_class_presente = true; |
|
| 2190 | - } |
|
| 2191 | - if ( |
|
| 2192 | - in_array($operation, ['ajouter', 'commuter']) |
|
| 2193 | - and !$is_class_presente |
|
| 2194 | - ) { |
|
| 2195 | - $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c); |
|
| 2196 | - } elseif ( |
|
| 2197 | - in_array($operation, ['supprimer', 'commuter']) |
|
| 2198 | - and $is_class_presente |
|
| 2199 | - ) { |
|
| 2200 | - $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new)); |
|
| 2201 | - } |
|
| 2202 | - } |
|
| 2203 | - |
|
| 2204 | - if ($class_new !== $class_courante) { |
|
| 2205 | - if (strlen($class_new)) { |
|
| 2206 | - $balise = inserer_attribut($balise, 'class', $class_new); |
|
| 2207 | - } elseif ($class_courante) { |
|
| 2208 | - $balise = vider_attribut($balise, 'class'); |
|
| 2209 | - } |
|
| 2210 | - } |
|
| 2211 | - |
|
| 2212 | - return $balise; |
|
| 2166 | + if (is_string($class)) { |
|
| 2167 | + $class = explode(' ', trim($class)); |
|
| 2168 | + } |
|
| 2169 | + $class = array_filter($class); |
|
| 2170 | + $class = array_unique($class); |
|
| 2171 | + if (!$class) { |
|
| 2172 | + return $balise; |
|
| 2173 | + } |
|
| 2174 | + |
|
| 2175 | + // si la ou les classes ont des caracteres invalides on ne fait rien |
|
| 2176 | + if (preg_match(',[^\w-],', implode('', $class))) { |
|
| 2177 | + return $balise; |
|
| 2178 | + } |
|
| 2179 | + |
|
| 2180 | + $class_courante = extraire_attribut($balise, 'class'); |
|
| 2181 | + $class_new = $class_courante; |
|
| 2182 | + foreach ($class as $c) { |
|
| 2183 | + $is_class_presente = false; |
|
| 2184 | + if ( |
|
| 2185 | + $class_courante |
|
| 2186 | + and strpos($class_courante, (string) $c) !== false |
|
| 2187 | + and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante) |
|
| 2188 | + ) { |
|
| 2189 | + $is_class_presente = true; |
|
| 2190 | + } |
|
| 2191 | + if ( |
|
| 2192 | + in_array($operation, ['ajouter', 'commuter']) |
|
| 2193 | + and !$is_class_presente |
|
| 2194 | + ) { |
|
| 2195 | + $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c); |
|
| 2196 | + } elseif ( |
|
| 2197 | + in_array($operation, ['supprimer', 'commuter']) |
|
| 2198 | + and $is_class_presente |
|
| 2199 | + ) { |
|
| 2200 | + $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new)); |
|
| 2201 | + } |
|
| 2202 | + } |
|
| 2203 | + |
|
| 2204 | + if ($class_new !== $class_courante) { |
|
| 2205 | + if (strlen($class_new)) { |
|
| 2206 | + $balise = inserer_attribut($balise, 'class', $class_new); |
|
| 2207 | + } elseif ($class_courante) { |
|
| 2208 | + $balise = vider_attribut($balise, 'class'); |
|
| 2209 | + } |
|
| 2210 | + } |
|
| 2211 | + |
|
| 2212 | + return $balise; |
|
| 2213 | 2213 | } |
| 2214 | 2214 | |
| 2215 | 2215 | /** |
@@ -2219,7 +2219,7 @@ discard block |
||
| 2219 | 2219 | * @return string |
| 2220 | 2220 | */ |
| 2221 | 2221 | function ajouter_class($balise, $class) { |
| 2222 | - return modifier_class($balise, $class, 'ajouter'); |
|
| 2222 | + return modifier_class($balise, $class, 'ajouter'); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | |
| 2225 | 2225 | /** |
@@ -2229,7 +2229,7 @@ discard block |
||
| 2229 | 2229 | * @return string |
| 2230 | 2230 | */ |
| 2231 | 2231 | function supprimer_class($balise, $class) { |
| 2232 | - return modifier_class($balise, $class, 'supprimer'); |
|
| 2232 | + return modifier_class($balise, $class, 'supprimer'); |
|
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | 2235 | /** |
@@ -2240,7 +2240,7 @@ discard block |
||
| 2240 | 2240 | * @return string |
| 2241 | 2241 | */ |
| 2242 | 2242 | function commuter_class($balise, $class) { |
| 2243 | - return modifier_class($balise, $class, 'commuter'); |
|
| 2243 | + return modifier_class($balise, $class, 'commuter'); |
|
| 2244 | 2244 | } |
| 2245 | 2245 | |
| 2246 | 2246 | /** |
@@ -2251,19 +2251,19 @@ discard block |
||
| 2251 | 2251 | * @return string |
| 2252 | 2252 | */ |
| 2253 | 2253 | function tester_config($id, $mode = '') { |
| 2254 | - include_spip('action/inscrire_auteur'); |
|
| 2254 | + include_spip('action/inscrire_auteur'); |
|
| 2255 | 2255 | |
| 2256 | - return tester_statut_inscription($mode, $id); |
|
| 2256 | + return tester_statut_inscription($mode, $id); |
|
| 2257 | 2257 | } |
| 2258 | 2258 | |
| 2259 | 2259 | // |
| 2260 | 2260 | // Quelques fonctions de calcul arithmetique |
| 2261 | 2261 | // |
| 2262 | 2262 | function floatstr($a) { |
| 2263 | - return str_replace(',', '.', (string)floatval($a)); |
|
| 2263 | + return str_replace(',', '.', (string)floatval($a)); |
|
| 2264 | 2264 | } |
| 2265 | 2265 | function strize($f, $a, $b) { |
| 2266 | - return floatstr($f(floatstr($a), floatstr($b))); |
|
| 2266 | + return floatstr($f(floatstr($a), floatstr($b))); |
|
| 2267 | 2267 | } |
| 2268 | 2268 | |
| 2269 | 2269 | /** |
@@ -2282,7 +2282,7 @@ discard block |
||
| 2282 | 2282 | * @return int $a+$b |
| 2283 | 2283 | **/ |
| 2284 | 2284 | function plus($a, $b) { |
| 2285 | - return $a + $b; |
|
| 2285 | + return $a + $b; |
|
| 2286 | 2286 | } |
| 2287 | 2287 | function strplus($a, $b) { |
| 2288 | 2288 | return strize('plus', $a, $b); |
@@ -2303,7 +2303,7 @@ discard block |
||
| 2303 | 2303 | * @return int $a-$b |
| 2304 | 2304 | **/ |
| 2305 | 2305 | function moins($a, $b) { |
| 2306 | - return $a - $b; |
|
| 2306 | + return $a - $b; |
|
| 2307 | 2307 | } |
| 2308 | 2308 | function strmoins($a, $b) { |
| 2309 | 2309 | return strize('moins', $a, $b); |
@@ -2326,7 +2326,7 @@ discard block |
||
| 2326 | 2326 | * @return int $a*$b |
| 2327 | 2327 | **/ |
| 2328 | 2328 | function mult($a, $b) { |
| 2329 | - return $a * $b; |
|
| 2329 | + return $a * $b; |
|
| 2330 | 2330 | } |
| 2331 | 2331 | function strmult($a, $b) { |
| 2332 | 2332 | return strize('mult', $a, $b); |
@@ -2349,7 +2349,7 @@ discard block |
||
| 2349 | 2349 | * @return int $a/$b (ou 0 si $b est nul) |
| 2350 | 2350 | **/ |
| 2351 | 2351 | function div($a, $b) { |
| 2352 | - return $b ? $a / $b : 0; |
|
| 2352 | + return $b ? $a / $b : 0; |
|
| 2353 | 2353 | } |
| 2354 | 2354 | function strdiv($a, $b) { |
| 2355 | 2355 | return strize('div', $a, $b); |
@@ -2373,7 +2373,7 @@ discard block |
||
| 2373 | 2373 | * @return int ($nb % $mod) + $add |
| 2374 | 2374 | **/ |
| 2375 | 2375 | function modulo($nb, $mod, $add = 0) { |
| 2376 | - return ($mod ? $nb % $mod : 0) + $add; |
|
| 2376 | + return ($mod ? $nb % $mod : 0) + $add; |
|
| 2377 | 2377 | } |
| 2378 | 2378 | |
| 2379 | 2379 | |
@@ -2388,26 +2388,26 @@ discard block |
||
| 2388 | 2388 | * - true sinon |
| 2389 | 2389 | **/ |
| 2390 | 2390 | function nom_acceptable($nom) { |
| 2391 | - $remp2 = []; |
|
| 2392 | - $remp1 = []; |
|
| 2393 | - if (!is_string($nom)) { |
|
| 2394 | - return false; |
|
| 2395 | - } |
|
| 2396 | - if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2397 | - define('_TAGS_NOM_AUTEUR', ''); |
|
| 2398 | - } |
|
| 2399 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2400 | - foreach ($tags_acceptes as $tag) { |
|
| 2401 | - if (strlen($tag)) { |
|
| 2402 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2403 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2404 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2405 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2406 | - } |
|
| 2407 | - } |
|
| 2408 | - $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2409 | - |
|
| 2410 | - return str_replace('<', '<', $v_nom) == $nom; |
|
| 2391 | + $remp2 = []; |
|
| 2392 | + $remp1 = []; |
|
| 2393 | + if (!is_string($nom)) { |
|
| 2394 | + return false; |
|
| 2395 | + } |
|
| 2396 | + if (!defined('_TAGS_NOM_AUTEUR')) { |
|
| 2397 | + define('_TAGS_NOM_AUTEUR', ''); |
|
| 2398 | + } |
|
| 2399 | + $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2400 | + foreach ($tags_acceptes as $tag) { |
|
| 2401 | + if (strlen($tag)) { |
|
| 2402 | + $remp1[] = '<' . trim($tag) . '>'; |
|
| 2403 | + $remp1[] = '</' . trim($tag) . '>'; |
|
| 2404 | + $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2405 | + $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2406 | + } |
|
| 2407 | + } |
|
| 2408 | + $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
|
| 2409 | + |
|
| 2410 | + return str_replace('<', '<', $v_nom) == $nom; |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | 2413 | |
@@ -2423,14 +2423,14 @@ discard block |
||
| 2423 | 2423 | * - renvoie un tableau si l'entree est un tableau |
| 2424 | 2424 | **/ |
| 2425 | 2425 | function email_valide($adresses) { |
| 2426 | - if (is_array($adresses)) { |
|
| 2427 | - $adresses = array_map('email_valide', $adresses); |
|
| 2428 | - $adresses = array_filter($adresses); |
|
| 2429 | - return $adresses; |
|
| 2430 | - } |
|
| 2426 | + if (is_array($adresses)) { |
|
| 2427 | + $adresses = array_map('email_valide', $adresses); |
|
| 2428 | + $adresses = array_filter($adresses); |
|
| 2429 | + return $adresses; |
|
| 2430 | + } |
|
| 2431 | 2431 | |
| 2432 | - $email_valide = charger_fonction('email_valide', 'inc'); |
|
| 2433 | - return $email_valide($adresses); |
|
| 2432 | + $email_valide = charger_fonction('email_valide', 'inc'); |
|
| 2433 | + return $email_valide($adresses); |
|
| 2434 | 2434 | } |
| 2435 | 2435 | |
| 2436 | 2436 | /** |
@@ -2444,27 +2444,27 @@ discard block |
||
| 2444 | 2444 | * @return string Texte |
| 2445 | 2445 | **/ |
| 2446 | 2446 | function afficher_enclosures($tags) { |
| 2447 | - $s = []; |
|
| 2448 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2449 | - if ( |
|
| 2450 | - extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2451 | - and $t = extraire_attribut($tag, 'href') |
|
| 2452 | - ) { |
|
| 2453 | - $s[] = preg_replace( |
|
| 2454 | - ',>[^<]+</a>,S', |
|
| 2455 | - '>' |
|
| 2456 | - . http_img_pack( |
|
| 2457 | - 'attachment-16.png', |
|
| 2458 | - $t, |
|
| 2459 | - 'title="' . attribut_html($t) . '"' |
|
| 2460 | - ) |
|
| 2461 | - . '</a>', |
|
| 2462 | - $tag |
|
| 2463 | - ); |
|
| 2464 | - } |
|
| 2465 | - } |
|
| 2466 | - |
|
| 2467 | - return join(' ', $s); |
|
| 2447 | + $s = []; |
|
| 2448 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2449 | + if ( |
|
| 2450 | + extraire_attribut($tag, 'rel') == 'enclosure' |
|
| 2451 | + and $t = extraire_attribut($tag, 'href') |
|
| 2452 | + ) { |
|
| 2453 | + $s[] = preg_replace( |
|
| 2454 | + ',>[^<]+</a>,S', |
|
| 2455 | + '>' |
|
| 2456 | + . http_img_pack( |
|
| 2457 | + 'attachment-16.png', |
|
| 2458 | + $t, |
|
| 2459 | + 'title="' . attribut_html($t) . '"' |
|
| 2460 | + ) |
|
| 2461 | + . '</a>', |
|
| 2462 | + $tag |
|
| 2463 | + ); |
|
| 2464 | + } |
|
| 2465 | + } |
|
| 2466 | + |
|
| 2467 | + return join(' ', $s); |
|
| 2468 | 2468 | } |
| 2469 | 2469 | |
| 2470 | 2470 | /** |
@@ -2479,15 +2479,15 @@ discard block |
||
| 2479 | 2479 | * @return string Liens trouvés |
| 2480 | 2480 | **/ |
| 2481 | 2481 | function afficher_tags($tags, $rels = 'tag,directory') { |
| 2482 | - $s = []; |
|
| 2483 | - foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2484 | - $rel = extraire_attribut($tag, 'rel'); |
|
| 2485 | - if (strstr(",$rels,", (string) ",$rel,")) { |
|
| 2486 | - $s[] = $tag; |
|
| 2487 | - } |
|
| 2488 | - } |
|
| 2482 | + $s = []; |
|
| 2483 | + foreach (extraire_balises($tags, 'a') as $tag) { |
|
| 2484 | + $rel = extraire_attribut($tag, 'rel'); |
|
| 2485 | + if (strstr(",$rels,", (string) ",$rel,")) { |
|
| 2486 | + $s[] = $tag; |
|
| 2487 | + } |
|
| 2488 | + } |
|
| 2489 | 2489 | |
| 2490 | - return join(', ', $s); |
|
| 2490 | + return join(', ', $s); |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | |
@@ -2509,21 +2509,21 @@ discard block |
||
| 2509 | 2509 | * @return string Tag HTML `<a>` avec microformat. |
| 2510 | 2510 | **/ |
| 2511 | 2511 | function enclosure2microformat($e) { |
| 2512 | - if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2513 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2514 | - } |
|
| 2515 | - $type = extraire_attribut($e, 'type'); |
|
| 2516 | - if (!$length = extraire_attribut($e, 'length')) { |
|
| 2517 | - # <media:content : longeur dans fileSize. On tente. |
|
| 2518 | - $length = extraire_attribut($e, 'fileSize'); |
|
| 2519 | - } |
|
| 2520 | - $fichier = basename($url); |
|
| 2512 | + if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) { |
|
| 2513 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2514 | + } |
|
| 2515 | + $type = extraire_attribut($e, 'type'); |
|
| 2516 | + if (!$length = extraire_attribut($e, 'length')) { |
|
| 2517 | + # <media:content : longeur dans fileSize. On tente. |
|
| 2518 | + $length = extraire_attribut($e, 'fileSize'); |
|
| 2519 | + } |
|
| 2520 | + $fichier = basename($url); |
|
| 2521 | 2521 | |
| 2522 | - return '<a rel="enclosure"' |
|
| 2523 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2524 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2525 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2526 | - . '>' . $fichier . '</a>'; |
|
| 2522 | + return '<a rel="enclosure"' |
|
| 2523 | + . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2524 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2525 | + . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2526 | + . '>' . $fichier . '</a>'; |
|
| 2527 | 2527 | } |
| 2528 | 2528 | |
| 2529 | 2529 | /** |
@@ -2541,24 +2541,24 @@ discard block |
||
| 2541 | 2541 | * @return string Tags RSS `<enclosure>`. |
| 2542 | 2542 | **/ |
| 2543 | 2543 | function microformat2enclosure($tags) { |
| 2544 | - $enclosures = []; |
|
| 2545 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2546 | - if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2547 | - $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2548 | - $type = extraire_attribut($e, 'type'); |
|
| 2549 | - if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2550 | - $length = intval(extraire_attribut($e, 'length')); |
|
| 2551 | - } # vieux data |
|
| 2552 | - $fichier = basename($url); |
|
| 2553 | - $enclosures[] = '<enclosure' |
|
| 2554 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2555 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2556 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2557 | - . ' />'; |
|
| 2558 | - } |
|
| 2559 | - } |
|
| 2544 | + $enclosures = []; |
|
| 2545 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2546 | + if (extraire_attribut($e, 'rel') == 'enclosure') { |
|
| 2547 | + $url = filtrer_entites(extraire_attribut($e, 'href')); |
|
| 2548 | + $type = extraire_attribut($e, 'type'); |
|
| 2549 | + if (!$length = intval(extraire_attribut($e, 'title'))) { |
|
| 2550 | + $length = intval(extraire_attribut($e, 'length')); |
|
| 2551 | + } # vieux data |
|
| 2552 | + $fichier = basename($url); |
|
| 2553 | + $enclosures[] = '<enclosure' |
|
| 2554 | + . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2555 | + . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2556 | + . ($length ? ' length="' . $length . '"' : '') |
|
| 2557 | + . ' />'; |
|
| 2558 | + } |
|
| 2559 | + } |
|
| 2560 | 2560 | |
| 2561 | - return join("\n", $enclosures); |
|
| 2561 | + return join("\n", $enclosures); |
|
| 2562 | 2562 | } |
| 2563 | 2563 | |
| 2564 | 2564 | |
@@ -2574,16 +2574,16 @@ discard block |
||
| 2574 | 2574 | * @return string Tags RSS Atom `<dc:subject>`. |
| 2575 | 2575 | **/ |
| 2576 | 2576 | function tags2dcsubject($tags) { |
| 2577 | - $subjects = ''; |
|
| 2578 | - foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2579 | - if (extraire_attribut($e, 'rel') == 'tag') { |
|
| 2580 | - $subjects .= '<dc:subject>' |
|
| 2581 | - . texte_backend(textebrut($e)) |
|
| 2582 | - . '</dc:subject>' . "\n"; |
|
| 2583 | - } |
|
| 2584 | - } |
|
| 2577 | + $subjects = ''; |
|
| 2578 | + foreach (extraire_balises($tags, 'a') as $e) { |
|
| 2579 | + if (extraire_attribut($e, 'rel') == 'tag') { |
|
| 2580 | + $subjects .= '<dc:subject>' |
|
| 2581 | + . texte_backend(textebrut($e)) |
|
| 2582 | + . '</dc:subject>' . "\n"; |
|
| 2583 | + } |
|
| 2584 | + } |
|
| 2585 | 2585 | |
| 2586 | - return $subjects; |
|
| 2586 | + return $subjects; |
|
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | 2589 | /** |
@@ -2612,27 +2612,27 @@ discard block |
||
| 2612 | 2612 | * - Tableau de résultats, si tableau en entrée. |
| 2613 | 2613 | **/ |
| 2614 | 2614 | function extraire_balise($texte, $tag = 'a') { |
| 2615 | - if (is_array($texte)) { |
|
| 2616 | - array_walk( |
|
| 2617 | - $texte, |
|
| 2618 | - function (&$a, $key, $t) { |
|
| 2619 | - $a = extraire_balise($a, $t); |
|
| 2620 | - }, |
|
| 2621 | - $tag |
|
| 2622 | - ); |
|
| 2623 | - |
|
| 2624 | - return $texte; |
|
| 2625 | - } |
|
| 2626 | - |
|
| 2627 | - if ( |
|
| 2628 | - preg_match( |
|
| 2629 | - ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2630 | - $texte, |
|
| 2631 | - $regs |
|
| 2632 | - ) |
|
| 2633 | - ) { |
|
| 2634 | - return $regs[0]; |
|
| 2635 | - } |
|
| 2615 | + if (is_array($texte)) { |
|
| 2616 | + array_walk( |
|
| 2617 | + $texte, |
|
| 2618 | + function (&$a, $key, $t) { |
|
| 2619 | + $a = extraire_balise($a, $t); |
|
| 2620 | + }, |
|
| 2621 | + $tag |
|
| 2622 | + ); |
|
| 2623 | + |
|
| 2624 | + return $texte; |
|
| 2625 | + } |
|
| 2626 | + |
|
| 2627 | + if ( |
|
| 2628 | + preg_match( |
|
| 2629 | + ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS", |
|
| 2630 | + $texte, |
|
| 2631 | + $regs |
|
| 2632 | + ) |
|
| 2633 | + ) { |
|
| 2634 | + return $regs[0]; |
|
| 2635 | + } |
|
| 2636 | 2636 | } |
| 2637 | 2637 | |
| 2638 | 2638 | /** |
@@ -2660,30 +2660,30 @@ discard block |
||
| 2660 | 2660 | * - Tableau de résultats, si tableau en entrée. |
| 2661 | 2661 | **/ |
| 2662 | 2662 | function extraire_balises($texte, $tag = 'a') { |
| 2663 | - if (is_array($texte)) { |
|
| 2664 | - array_walk( |
|
| 2665 | - $texte, |
|
| 2666 | - function (&$a, $key, $t) { |
|
| 2667 | - $a = extraire_balises($a, $t); |
|
| 2668 | - }, |
|
| 2669 | - $tag |
|
| 2670 | - ); |
|
| 2671 | - |
|
| 2672 | - return $texte; |
|
| 2673 | - } |
|
| 2674 | - |
|
| 2675 | - if ( |
|
| 2676 | - preg_match_all( |
|
| 2677 | - ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2678 | - $texte, |
|
| 2679 | - $regs, |
|
| 2680 | - PREG_PATTERN_ORDER |
|
| 2681 | - ) |
|
| 2682 | - ) { |
|
| 2683 | - return $regs[0]; |
|
| 2684 | - } else { |
|
| 2685 | - return []; |
|
| 2686 | - } |
|
| 2663 | + if (is_array($texte)) { |
|
| 2664 | + array_walk( |
|
| 2665 | + $texte, |
|
| 2666 | + function (&$a, $key, $t) { |
|
| 2667 | + $a = extraire_balises($a, $t); |
|
| 2668 | + }, |
|
| 2669 | + $tag |
|
| 2670 | + ); |
|
| 2671 | + |
|
| 2672 | + return $texte; |
|
| 2673 | + } |
|
| 2674 | + |
|
| 2675 | + if ( |
|
| 2676 | + preg_match_all( |
|
| 2677 | + ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS", |
|
| 2678 | + $texte, |
|
| 2679 | + $regs, |
|
| 2680 | + PREG_PATTERN_ORDER |
|
| 2681 | + ) |
|
| 2682 | + ) { |
|
| 2683 | + return $regs[0]; |
|
| 2684 | + } else { |
|
| 2685 | + return []; |
|
| 2686 | + } |
|
| 2687 | 2687 | } |
| 2688 | 2688 | |
| 2689 | 2689 | /** |
@@ -2712,11 +2712,11 @@ discard block |
||
| 2712 | 2712 | * - `$def` si on n'a pas transmis de tableau |
| 2713 | 2713 | **/ |
| 2714 | 2714 | function in_any($val, $vals, $def = '') { |
| 2715 | - if (!is_array($vals) and $vals and $v = unserialize($vals)) { |
|
| 2716 | - $vals = $v; |
|
| 2717 | - } |
|
| 2715 | + if (!is_array($vals) and $vals and $v = unserialize($vals)) { |
|
| 2716 | + $vals = $v; |
|
| 2717 | + } |
|
| 2718 | 2718 | |
| 2719 | - return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2719 | + return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : '')); |
|
| 2720 | 2720 | } |
| 2721 | 2721 | |
| 2722 | 2722 | |
@@ -2737,12 +2737,12 @@ discard block |
||
| 2737 | 2737 | * Résultat du calcul |
| 2738 | 2738 | **/ |
| 2739 | 2739 | function valeur_numerique($expr) { |
| 2740 | - $a = 0; |
|
| 2741 | - if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2742 | - eval("\$a = $expr;"); |
|
| 2743 | - } |
|
| 2740 | + $a = 0; |
|
| 2741 | + if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) { |
|
| 2742 | + eval("\$a = $expr;"); |
|
| 2743 | + } |
|
| 2744 | 2744 | |
| 2745 | - return intval($a); |
|
| 2745 | + return intval($a); |
|
| 2746 | 2746 | } |
| 2747 | 2747 | |
| 2748 | 2748 | /** |
@@ -2761,7 +2761,7 @@ discard block |
||
| 2761 | 2761 | * Retourne `$a*$b/$c` |
| 2762 | 2762 | **/ |
| 2763 | 2763 | function regledetrois($a, $b, $c) { |
| 2764 | - return round($a * $b / $c); |
|
| 2764 | + return round($a * $b / $c); |
|
| 2765 | 2765 | } |
| 2766 | 2766 | |
| 2767 | 2767 | |
@@ -2784,79 +2784,79 @@ discard block |
||
| 2784 | 2784 | * @return string Suite de champs input hidden |
| 2785 | 2785 | **/ |
| 2786 | 2786 | function form_hidden(?string $action = ''): string { |
| 2787 | - $action ??= ''; |
|
| 2788 | - |
|
| 2789 | - $contexte = []; |
|
| 2790 | - include_spip('inc/urls'); |
|
| 2791 | - if ( |
|
| 2792 | - $p = urls_decoder_url($action, '') |
|
| 2793 | - and reset($p) |
|
| 2794 | - ) { |
|
| 2795 | - $fond = array_shift($p); |
|
| 2796 | - if ($fond != '404') { |
|
| 2797 | - $contexte = array_shift($p); |
|
| 2798 | - $contexte['page'] = $fond; |
|
| 2799 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2800 | - } |
|
| 2801 | - } |
|
| 2802 | - // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2803 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2804 | - unset($contexte['type']); |
|
| 2805 | - } |
|
| 2806 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2807 | - unset($contexte['type-page']); |
|
| 2808 | - } |
|
| 2809 | - |
|
| 2810 | - // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2811 | - // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2812 | - $values = []; |
|
| 2813 | - |
|
| 2814 | - // d'abord avec celles de l'url |
|
| 2815 | - if (false !== ($p = strpos($action, '?'))) { |
|
| 2816 | - foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2817 | - $c = explode('=', $c, 2); |
|
| 2818 | - $var = array_shift($c); |
|
| 2819 | - $val = array_shift($c) ?? ''; |
|
| 2820 | - if ($var) { |
|
| 2821 | - $val = rawurldecode($val); |
|
| 2822 | - $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2823 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2824 | - $values[] = [$var, $val]; |
|
| 2825 | - } else { |
|
| 2826 | - if (!isset($values[$var])) { |
|
| 2827 | - $values[$var] = [$var, $val]; |
|
| 2828 | - } |
|
| 2829 | - } |
|
| 2830 | - } |
|
| 2831 | - } |
|
| 2832 | - } |
|
| 2833 | - |
|
| 2834 | - // ensuite avec celles du contexte, sans doublonner ! |
|
| 2835 | - foreach ($contexte as $var => $val) { |
|
| 2836 | - if (preg_match(',\[\]$,S', $var)) { |
|
| 2837 | - $values[] = [$var, $val]; |
|
| 2838 | - } else { |
|
| 2839 | - if (!isset($values[$var])) { |
|
| 2840 | - $values[$var] = [$var, $val]; |
|
| 2841 | - } |
|
| 2842 | - } |
|
| 2843 | - } |
|
| 2844 | - |
|
| 2845 | - // puis on rassemble le tout |
|
| 2846 | - $hidden = []; |
|
| 2847 | - foreach ($values as $value) { |
|
| 2848 | - [$var, $val] = $value; |
|
| 2849 | - $hidden[] = '<input name="' |
|
| 2850 | - . entites_html($var) |
|
| 2851 | - . '"' |
|
| 2852 | - . (is_null($val) |
|
| 2853 | - ? '' |
|
| 2854 | - : ' value="' . entites_html($val) . '"' |
|
| 2855 | - ) |
|
| 2856 | - . ' type="hidden"' . "\n/>"; |
|
| 2857 | - } |
|
| 2858 | - |
|
| 2859 | - return join('', $hidden); |
|
| 2787 | + $action ??= ''; |
|
| 2788 | + |
|
| 2789 | + $contexte = []; |
|
| 2790 | + include_spip('inc/urls'); |
|
| 2791 | + if ( |
|
| 2792 | + $p = urls_decoder_url($action, '') |
|
| 2793 | + and reset($p) |
|
| 2794 | + ) { |
|
| 2795 | + $fond = array_shift($p); |
|
| 2796 | + if ($fond != '404') { |
|
| 2797 | + $contexte = array_shift($p); |
|
| 2798 | + $contexte['page'] = $fond; |
|
| 2799 | + $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2800 | + } |
|
| 2801 | + } |
|
| 2802 | + // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
|
| 2803 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 2804 | + unset($contexte['type']); |
|
| 2805 | + } |
|
| 2806 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 2807 | + unset($contexte['type-page']); |
|
| 2808 | + } |
|
| 2809 | + |
|
| 2810 | + // on va remplir un tableau de valeurs en prenant bien soin de ne pas |
|
| 2811 | + // ecraser les elements de la forme mots[]=1&mots[]=2 |
|
| 2812 | + $values = []; |
|
| 2813 | + |
|
| 2814 | + // d'abord avec celles de l'url |
|
| 2815 | + if (false !== ($p = strpos($action, '?'))) { |
|
| 2816 | + foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) { |
|
| 2817 | + $c = explode('=', $c, 2); |
|
| 2818 | + $var = array_shift($c); |
|
| 2819 | + $val = array_shift($c) ?? ''; |
|
| 2820 | + if ($var) { |
|
| 2821 | + $val = rawurldecode($val); |
|
| 2822 | + $var = rawurldecode($var); // decoder les [] eventuels |
|
| 2823 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2824 | + $values[] = [$var, $val]; |
|
| 2825 | + } else { |
|
| 2826 | + if (!isset($values[$var])) { |
|
| 2827 | + $values[$var] = [$var, $val]; |
|
| 2828 | + } |
|
| 2829 | + } |
|
| 2830 | + } |
|
| 2831 | + } |
|
| 2832 | + } |
|
| 2833 | + |
|
| 2834 | + // ensuite avec celles du contexte, sans doublonner ! |
|
| 2835 | + foreach ($contexte as $var => $val) { |
|
| 2836 | + if (preg_match(',\[\]$,S', $var)) { |
|
| 2837 | + $values[] = [$var, $val]; |
|
| 2838 | + } else { |
|
| 2839 | + if (!isset($values[$var])) { |
|
| 2840 | + $values[$var] = [$var, $val]; |
|
| 2841 | + } |
|
| 2842 | + } |
|
| 2843 | + } |
|
| 2844 | + |
|
| 2845 | + // puis on rassemble le tout |
|
| 2846 | + $hidden = []; |
|
| 2847 | + foreach ($values as $value) { |
|
| 2848 | + [$var, $val] = $value; |
|
| 2849 | + $hidden[] = '<input name="' |
|
| 2850 | + . entites_html($var) |
|
| 2851 | + . '"' |
|
| 2852 | + . (is_null($val) |
|
| 2853 | + ? '' |
|
| 2854 | + : ' value="' . entites_html($val) . '"' |
|
| 2855 | + ) |
|
| 2856 | + . ' type="hidden"' . "\n/>"; |
|
| 2857 | + } |
|
| 2858 | + |
|
| 2859 | + return join('', $hidden); |
|
| 2860 | 2860 | } |
| 2861 | 2861 | |
| 2862 | 2862 | |
@@ -2878,7 +2878,7 @@ discard block |
||
| 2878 | 2878 | * - la première valeur du tableau sinon. |
| 2879 | 2879 | **/ |
| 2880 | 2880 | function filtre_reset($array) { |
| 2881 | - return !is_array($array) ? null : reset($array); |
|
| 2881 | + return !is_array($array) ? null : reset($array); |
|
| 2882 | 2882 | } |
| 2883 | 2883 | |
| 2884 | 2884 | /** |
@@ -2899,7 +2899,7 @@ discard block |
||
| 2899 | 2899 | * - la dernière valeur du tableau sinon. |
| 2900 | 2900 | **/ |
| 2901 | 2901 | function filtre_end($array) { |
| 2902 | - return !is_array($array) ? null : end($array); |
|
| 2902 | + return !is_array($array) ? null : end($array); |
|
| 2903 | 2903 | } |
| 2904 | 2904 | |
| 2905 | 2905 | /** |
@@ -2919,11 +2919,11 @@ discard block |
||
| 2919 | 2919 | * |
| 2920 | 2920 | **/ |
| 2921 | 2921 | function filtre_push($array, $val) { |
| 2922 | - if (!is_array($array) or !array_push($array, $val)) { |
|
| 2923 | - return ''; |
|
| 2924 | - } |
|
| 2922 | + if (!is_array($array) or !array_push($array, $val)) { |
|
| 2923 | + return ''; |
|
| 2924 | + } |
|
| 2925 | 2925 | |
| 2926 | - return $array; |
|
| 2926 | + return $array; |
|
| 2927 | 2927 | } |
| 2928 | 2928 | |
| 2929 | 2929 | /** |
@@ -2942,7 +2942,7 @@ discard block |
||
| 2942 | 2942 | * - `true` si la valeur existe dans le tableau, `false` sinon. |
| 2943 | 2943 | **/ |
| 2944 | 2944 | function filtre_find($array, $val) { |
| 2945 | - return (is_array($array) and in_array($val, $array)); |
|
| 2945 | + return (is_array($array) and in_array($val, $array)); |
|
| 2946 | 2946 | } |
| 2947 | 2947 | |
| 2948 | 2948 | |
@@ -2959,13 +2959,13 @@ discard block |
||
| 2959 | 2959 | * Contenu avec urls en absolus |
| 2960 | 2960 | **/ |
| 2961 | 2961 | function urls_absolues_css($contenu, $source) { |
| 2962 | - $path = suivre_lien(url_absolue($source), './'); |
|
| 2962 | + $path = suivre_lien(url_absolue($source), './'); |
|
| 2963 | 2963 | |
| 2964 | - return preg_replace_callback( |
|
| 2965 | - ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2966 | - fn($x) => "url('" . suivre_lien($path, $x[1]) . "')", |
|
| 2967 | - $contenu |
|
| 2968 | - ); |
|
| 2964 | + return preg_replace_callback( |
|
| 2965 | + ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
|
| 2966 | + fn($x) => "url('" . suivre_lien($path, $x[1]) . "')", |
|
| 2967 | + $contenu |
|
| 2968 | + ); |
|
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | |
@@ -2994,119 +2994,119 @@ discard block |
||
| 2994 | 2994 | * Chemin du fichier CSS inversé |
| 2995 | 2995 | **/ |
| 2996 | 2996 | function direction_css($css, $voulue = '') { |
| 2997 | - if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2998 | - return $css; |
|
| 2999 | - } |
|
| 3000 | - include_spip('inc/lang'); |
|
| 3001 | - // si on a precise le sens voulu en argument, le prendre en compte |
|
| 3002 | - if ($voulue = strtolower($voulue)) { |
|
| 3003 | - if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 3004 | - $voulue = lang_dir($voulue); |
|
| 3005 | - } |
|
| 3006 | - } else { |
|
| 3007 | - $voulue = lang_dir(); |
|
| 3008 | - } |
|
| 3009 | - |
|
| 3010 | - $r = count($r) > 1; |
|
| 3011 | - $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 3012 | - $dir = $r ? 'rtl' : 'ltr'; |
|
| 3013 | - $ndir = $r ? 'ltr' : 'rtl'; |
|
| 3014 | - |
|
| 3015 | - if ($voulue == $dir) { |
|
| 3016 | - return $css; |
|
| 3017 | - } |
|
| 3018 | - |
|
| 3019 | - if ( |
|
| 3020 | - // url absolue |
|
| 3021 | - preg_match(',^https?:,i', $css) |
|
| 3022 | - // ou qui contient un ? |
|
| 3023 | - or (($p = strpos($css, '?')) !== false) |
|
| 3024 | - ) { |
|
| 3025 | - $distant = true; |
|
| 3026 | - $cssf = parse_url($css); |
|
| 3027 | - $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : ''); |
|
| 3028 | - $cssf = preg_replace(',[?:&=],', '_', $cssf); |
|
| 3029 | - } else { |
|
| 3030 | - $distant = false; |
|
| 3031 | - $cssf = $css; |
|
| 3032 | - // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 3033 | - //propose (rien a faire dans ce cas) |
|
| 3034 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 3035 | - if (@file_exists($f)) { |
|
| 3036 | - return $f; |
|
| 3037 | - } |
|
| 3038 | - } |
|
| 3039 | - |
|
| 3040 | - // 2. |
|
| 3041 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 3042 | - $f = $dir_var |
|
| 3043 | - . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 3044 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 3045 | - |
|
| 3046 | - // la css peut etre distante (url absolue !) |
|
| 3047 | - if ($distant) { |
|
| 3048 | - include_spip('inc/distant'); |
|
| 3049 | - $res = recuperer_url($css); |
|
| 3050 | - if (!$res or !$contenu = $res['page']) { |
|
| 3051 | - return $css; |
|
| 3052 | - } |
|
| 3053 | - } else { |
|
| 3054 | - if ( |
|
| 3055 | - (@filemtime($f) > @filemtime($css)) |
|
| 3056 | - and (_VAR_MODE != 'recalcul') |
|
| 3057 | - ) { |
|
| 3058 | - return $f; |
|
| 3059 | - } |
|
| 3060 | - if (!lire_fichier($css, $contenu)) { |
|
| 3061 | - return $css; |
|
| 3062 | - } |
|
| 3063 | - } |
|
| 3064 | - |
|
| 3065 | - |
|
| 3066 | - // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 3067 | - include_spip('lib/csstidy/class.csstidy'); |
|
| 3068 | - $parser = new csstidy(); |
|
| 3069 | - $parser->set_cfg('optimise_shorthands', 0); |
|
| 3070 | - $parser->set_cfg('reverse_left_and_right', true); |
|
| 3071 | - $parser->parse($contenu); |
|
| 3072 | - |
|
| 3073 | - $contenu = $parser->print->plain(); |
|
| 3074 | - |
|
| 3075 | - |
|
| 3076 | - // reperer les @import auxquels il faut propager le direction_css |
|
| 3077 | - preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 3078 | - $src = []; |
|
| 3079 | - $src_direction_css = []; |
|
| 3080 | - $src_faux_abs = []; |
|
| 3081 | - $d = dirname($css); |
|
| 3082 | - foreach ($regs[1] as $k => $import_css) { |
|
| 3083 | - $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 3084 | - // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 3085 | - if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 3086 | - $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 3087 | - } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 3088 | - elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 3089 | - $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 3090 | - $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction; |
|
| 3091 | - $css_direction = '/@@@@@@/' . $css_direction; |
|
| 3092 | - } |
|
| 3093 | - $src[] = $regs[0][$k]; |
|
| 3094 | - $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 3095 | - } |
|
| 3096 | - $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 3097 | - |
|
| 3098 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 3099 | - |
|
| 3100 | - // virer les fausses url absolues que l'on a mis dans les import |
|
| 3101 | - if (count($src_faux_abs)) { |
|
| 3102 | - $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 3103 | - } |
|
| 3104 | - |
|
| 3105 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 3106 | - return $css; |
|
| 3107 | - } |
|
| 3108 | - |
|
| 3109 | - return $f; |
|
| 2997 | + if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) { |
|
| 2998 | + return $css; |
|
| 2999 | + } |
|
| 3000 | + include_spip('inc/lang'); |
|
| 3001 | + // si on a precise le sens voulu en argument, le prendre en compte |
|
| 3002 | + if ($voulue = strtolower($voulue)) { |
|
| 3003 | + if ($voulue != 'rtl' and $voulue != 'ltr') { |
|
| 3004 | + $voulue = lang_dir($voulue); |
|
| 3005 | + } |
|
| 3006 | + } else { |
|
| 3007 | + $voulue = lang_dir(); |
|
| 3008 | + } |
|
| 3009 | + |
|
| 3010 | + $r = count($r) > 1; |
|
| 3011 | + $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree |
|
| 3012 | + $dir = $r ? 'rtl' : 'ltr'; |
|
| 3013 | + $ndir = $r ? 'ltr' : 'rtl'; |
|
| 3014 | + |
|
| 3015 | + if ($voulue == $dir) { |
|
| 3016 | + return $css; |
|
| 3017 | + } |
|
| 3018 | + |
|
| 3019 | + if ( |
|
| 3020 | + // url absolue |
|
| 3021 | + preg_match(',^https?:,i', $css) |
|
| 3022 | + // ou qui contient un ? |
|
| 3023 | + or (($p = strpos($css, '?')) !== false) |
|
| 3024 | + ) { |
|
| 3025 | + $distant = true; |
|
| 3026 | + $cssf = parse_url($css); |
|
| 3027 | + $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : ''); |
|
| 3028 | + $cssf = preg_replace(',[?:&=],', '_', $cssf); |
|
| 3029 | + } else { |
|
| 3030 | + $distant = false; |
|
| 3031 | + $cssf = $css; |
|
| 3032 | + // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
|
| 3033 | + //propose (rien a faire dans ce cas) |
|
| 3034 | + $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 3035 | + if (@file_exists($f)) { |
|
| 3036 | + return $f; |
|
| 3037 | + } |
|
| 3038 | + } |
|
| 3039 | + |
|
| 3040 | + // 2. |
|
| 3041 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
|
| 3042 | + $f = $dir_var |
|
| 3043 | + . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
|
| 3044 | + . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 3045 | + |
|
| 3046 | + // la css peut etre distante (url absolue !) |
|
| 3047 | + if ($distant) { |
|
| 3048 | + include_spip('inc/distant'); |
|
| 3049 | + $res = recuperer_url($css); |
|
| 3050 | + if (!$res or !$contenu = $res['page']) { |
|
| 3051 | + return $css; |
|
| 3052 | + } |
|
| 3053 | + } else { |
|
| 3054 | + if ( |
|
| 3055 | + (@filemtime($f) > @filemtime($css)) |
|
| 3056 | + and (_VAR_MODE != 'recalcul') |
|
| 3057 | + ) { |
|
| 3058 | + return $f; |
|
| 3059 | + } |
|
| 3060 | + if (!lire_fichier($css, $contenu)) { |
|
| 3061 | + return $css; |
|
| 3062 | + } |
|
| 3063 | + } |
|
| 3064 | + |
|
| 3065 | + |
|
| 3066 | + // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands |
|
| 3067 | + include_spip('lib/csstidy/class.csstidy'); |
|
| 3068 | + $parser = new csstidy(); |
|
| 3069 | + $parser->set_cfg('optimise_shorthands', 0); |
|
| 3070 | + $parser->set_cfg('reverse_left_and_right', true); |
|
| 3071 | + $parser->parse($contenu); |
|
| 3072 | + |
|
| 3073 | + $contenu = $parser->print->plain(); |
|
| 3074 | + |
|
| 3075 | + |
|
| 3076 | + // reperer les @import auxquels il faut propager le direction_css |
|
| 3077 | + preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs); |
|
| 3078 | + $src = []; |
|
| 3079 | + $src_direction_css = []; |
|
| 3080 | + $src_faux_abs = []; |
|
| 3081 | + $d = dirname($css); |
|
| 3082 | + foreach ($regs[1] as $k => $import_css) { |
|
| 3083 | + $css_direction = direction_css("$d/$import_css", $voulue); |
|
| 3084 | + // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue |
|
| 3085 | + if (substr($css_direction, 0, strlen($d) + 1) == "$d/") { |
|
| 3086 | + $css_direction = substr($css_direction, strlen($d) + 1); |
|
| 3087 | + } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
|
| 3088 | + elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
|
| 3089 | + $css_direction = substr($css_direction, strlen($dir_var)); |
|
| 3090 | + $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction; |
|
| 3091 | + $css_direction = '/@@@@@@/' . $css_direction; |
|
| 3092 | + } |
|
| 3093 | + $src[] = $regs[0][$k]; |
|
| 3094 | + $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
|
| 3095 | + } |
|
| 3096 | + $contenu = str_replace($src, $src_direction_css, $contenu); |
|
| 3097 | + |
|
| 3098 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 3099 | + |
|
| 3100 | + // virer les fausses url absolues que l'on a mis dans les import |
|
| 3101 | + if (count($src_faux_abs)) { |
|
| 3102 | + $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu); |
|
| 3103 | + } |
|
| 3104 | + |
|
| 3105 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 3106 | + return $css; |
|
| 3107 | + } |
|
| 3108 | + |
|
| 3109 | + return $f; |
|
| 3110 | 3110 | } |
| 3111 | 3111 | |
| 3112 | 3112 | |
@@ -3129,46 +3129,46 @@ discard block |
||
| 3129 | 3129 | * - Chemin ou URL du fichier CSS source sinon. |
| 3130 | 3130 | **/ |
| 3131 | 3131 | function url_absolue_css($css) { |
| 3132 | - if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 3133 | - return $css; |
|
| 3134 | - } |
|
| 3132 | + if (!preg_match(',\.css$,i', $css, $r)) { |
|
| 3133 | + return $css; |
|
| 3134 | + } |
|
| 3135 | 3135 | |
| 3136 | - $url_absolue_css = url_absolue($css); |
|
| 3136 | + $url_absolue_css = url_absolue($css); |
|
| 3137 | 3137 | |
| 3138 | - $f = basename($css, '.css'); |
|
| 3139 | - $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 3140 | - . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3141 | - . '.css'; |
|
| 3138 | + $f = basename($css, '.css'); |
|
| 3139 | + $f = sous_repertoire(_DIR_VAR, 'cache-css') |
|
| 3140 | + . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3141 | + . '.css'; |
|
| 3142 | 3142 | |
| 3143 | - if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 3144 | - return $f; |
|
| 3145 | - } |
|
| 3143 | + if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
|
| 3144 | + return $f; |
|
| 3145 | + } |
|
| 3146 | 3146 | |
| 3147 | - if ($url_absolue_css == $css) { |
|
| 3148 | - if ( |
|
| 3149 | - strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 3150 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3151 | - ) { |
|
| 3152 | - include_spip('inc/distant'); |
|
| 3153 | - $contenu = recuperer_url($css); |
|
| 3154 | - $contenu = $contenu['page'] ?? ''; |
|
| 3155 | - if (!$contenu) { |
|
| 3156 | - return $css; |
|
| 3157 | - } |
|
| 3158 | - } |
|
| 3159 | - } elseif (!lire_fichier($css, $contenu)) { |
|
| 3160 | - return $css; |
|
| 3161 | - } |
|
| 3147 | + if ($url_absolue_css == $css) { |
|
| 3148 | + if ( |
|
| 3149 | + strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
|
| 3150 | + or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3151 | + ) { |
|
| 3152 | + include_spip('inc/distant'); |
|
| 3153 | + $contenu = recuperer_url($css); |
|
| 3154 | + $contenu = $contenu['page'] ?? ''; |
|
| 3155 | + if (!$contenu) { |
|
| 3156 | + return $css; |
|
| 3157 | + } |
|
| 3158 | + } |
|
| 3159 | + } elseif (!lire_fichier($css, $contenu)) { |
|
| 3160 | + return $css; |
|
| 3161 | + } |
|
| 3162 | 3162 | |
| 3163 | - // passer les url relatives a la css d'origine en url absolues |
|
| 3164 | - $contenu = urls_absolues_css($contenu, $css); |
|
| 3163 | + // passer les url relatives a la css d'origine en url absolues |
|
| 3164 | + $contenu = urls_absolues_css($contenu, $css); |
|
| 3165 | 3165 | |
| 3166 | - // ecrire la css |
|
| 3167 | - if (!ecrire_fichier($f, $contenu)) { |
|
| 3168 | - return $css; |
|
| 3169 | - } |
|
| 3166 | + // ecrire la css |
|
| 3167 | + if (!ecrire_fichier($f, $contenu)) { |
|
| 3168 | + return $css; |
|
| 3169 | + } |
|
| 3170 | 3170 | |
| 3171 | - return $f; |
|
| 3171 | + return $f; |
|
| 3172 | 3172 | } |
| 3173 | 3173 | |
| 3174 | 3174 | |
@@ -3202,24 +3202,24 @@ discard block |
||
| 3202 | 3202 | * Valeur trouvée ou valeur par défaut. |
| 3203 | 3203 | **/ |
| 3204 | 3204 | function table_valeur($table, $cle, $defaut = '', $conserver_null = false) { |
| 3205 | - foreach (explode('/', $cle) as $k) { |
|
| 3206 | - $table = (is_string($table) ? @unserialize($table) : $table); |
|
| 3205 | + foreach (explode('/', $cle) as $k) { |
|
| 3206 | + $table = (is_string($table) ? @unserialize($table) : $table); |
|
| 3207 | 3207 | |
| 3208 | - if (is_object($table)) { |
|
| 3209 | - $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3210 | - } elseif (is_array($table)) { |
|
| 3211 | - if ($conserver_null) { |
|
| 3212 | - $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3213 | - } else { |
|
| 3214 | - $table = ($table[$k] ?? $defaut); |
|
| 3215 | - } |
|
| 3216 | - } else { |
|
| 3217 | - $table = $defaut; |
|
| 3218 | - break; |
|
| 3219 | - } |
|
| 3220 | - } |
|
| 3208 | + if (is_object($table)) { |
|
| 3209 | + $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut; |
|
| 3210 | + } elseif (is_array($table)) { |
|
| 3211 | + if ($conserver_null) { |
|
| 3212 | + $table = array_key_exists($k, $table) ? $table[$k] : $defaut; |
|
| 3213 | + } else { |
|
| 3214 | + $table = ($table[$k] ?? $defaut); |
|
| 3215 | + } |
|
| 3216 | + } else { |
|
| 3217 | + $table = $defaut; |
|
| 3218 | + break; |
|
| 3219 | + } |
|
| 3220 | + } |
|
| 3221 | 3221 | |
| 3222 | - return $table; |
|
| 3222 | + return $table; |
|
| 3223 | 3223 | } |
| 3224 | 3224 | |
| 3225 | 3225 | /** |
@@ -3252,22 +3252,22 @@ discard block |
||
| 3252 | 3252 | * - string : expression trouvée. |
| 3253 | 3253 | **/ |
| 3254 | 3254 | function filtre_match_dist(?string $texte, $expression, $modif = 'UimsS', $capte = 0) { |
| 3255 | - if (intval($modif) and $capte == 0) { |
|
| 3256 | - $capte = $modif; |
|
| 3257 | - $modif = 'UimsS'; |
|
| 3258 | - } |
|
| 3259 | - $expression = str_replace('\/', '/', $expression); |
|
| 3260 | - $expression = str_replace('/', '\/', $expression); |
|
| 3255 | + if (intval($modif) and $capte == 0) { |
|
| 3256 | + $capte = $modif; |
|
| 3257 | + $modif = 'UimsS'; |
|
| 3258 | + } |
|
| 3259 | + $expression = str_replace('\/', '/', $expression); |
|
| 3260 | + $expression = str_replace('/', '\/', $expression); |
|
| 3261 | 3261 | |
| 3262 | - if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) { |
|
| 3263 | - if (isset($r[$capte])) { |
|
| 3264 | - return $r[$capte]; |
|
| 3265 | - } else { |
|
| 3266 | - return true; |
|
| 3267 | - } |
|
| 3268 | - } |
|
| 3262 | + if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) { |
|
| 3263 | + if (isset($r[$capte])) { |
|
| 3264 | + return $r[$capte]; |
|
| 3265 | + } else { |
|
| 3266 | + return true; |
|
| 3267 | + } |
|
| 3268 | + } |
|
| 3269 | 3269 | |
| 3270 | - return false; |
|
| 3270 | + return false; |
|
| 3271 | 3271 | } |
| 3272 | 3272 | |
| 3273 | 3273 | |
@@ -3294,10 +3294,10 @@ discard block |
||
| 3294 | 3294 | * Texte |
| 3295 | 3295 | **/ |
| 3296 | 3296 | function replace($texte, $expression, $replace = '', $modif = 'UimsS') { |
| 3297 | - $expression = str_replace('\/', '/', $expression); |
|
| 3298 | - $expression = str_replace('/', '\/', $expression); |
|
| 3297 | + $expression = str_replace('\/', '/', $expression); |
|
| 3298 | + $expression = str_replace('/', '\/', $expression); |
|
| 3299 | 3299 | |
| 3300 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3300 | + return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3301 | 3301 | } |
| 3302 | 3302 | |
| 3303 | 3303 | |
@@ -3315,25 +3315,25 @@ discard block |
||
| 3315 | 3315 | **/ |
| 3316 | 3316 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3317 | 3317 | |
| 3318 | - // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3319 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3318 | + // Verifier dans le texte & les notes (pas beau, helas) |
|
| 3319 | + $t = $letexte . $GLOBALS['les_notes']; |
|
| 3320 | 3320 | |
| 3321 | - if ( |
|
| 3322 | - strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3323 | - and preg_match_all( |
|
| 3324 | - ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3325 | - $t, |
|
| 3326 | - $matches, |
|
| 3327 | - PREG_PATTERN_ORDER |
|
| 3328 | - ) |
|
| 3329 | - ) { |
|
| 3330 | - if (!isset($doublons['documents'])) { |
|
| 3331 | - $doublons['documents'] = ''; |
|
| 3332 | - } |
|
| 3333 | - $doublons['documents'] .= ',' . join(',', $matches[1]); |
|
| 3334 | - } |
|
| 3321 | + if ( |
|
| 3322 | + strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
|
| 3323 | + and preg_match_all( |
|
| 3324 | + ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS', |
|
| 3325 | + $t, |
|
| 3326 | + $matches, |
|
| 3327 | + PREG_PATTERN_ORDER |
|
| 3328 | + ) |
|
| 3329 | + ) { |
|
| 3330 | + if (!isset($doublons['documents'])) { |
|
| 3331 | + $doublons['documents'] = ''; |
|
| 3332 | + } |
|
| 3333 | + $doublons['documents'] .= ',' . join(',', $matches[1]); |
|
| 3334 | + } |
|
| 3335 | 3335 | |
| 3336 | - return $letexte; |
|
| 3336 | + return $letexte; |
|
| 3337 | 3337 | } |
| 3338 | 3338 | |
| 3339 | 3339 | /** |
@@ -3347,7 +3347,7 @@ discard block |
||
| 3347 | 3347 | * @return string Chaîne vide |
| 3348 | 3348 | **/ |
| 3349 | 3349 | function vide($texte) { |
| 3350 | - return ''; |
|
| 3350 | + return ''; |
|
| 3351 | 3351 | } |
| 3352 | 3352 | |
| 3353 | 3353 | // |
@@ -3376,23 +3376,23 @@ discard block |
||
| 3376 | 3376 | * Code HTML résultant |
| 3377 | 3377 | **/ |
| 3378 | 3378 | function env_to_params($env, $ignore_params = []) { |
| 3379 | - $ignore_params = array_merge( |
|
| 3380 | - ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3381 | - $ignore_params |
|
| 3382 | - ); |
|
| 3383 | - if (!is_array($env)) { |
|
| 3384 | - $env = unserialize($env); |
|
| 3385 | - } |
|
| 3386 | - $texte = ''; |
|
| 3387 | - if ($env) { |
|
| 3388 | - foreach ($env as $i => $j) { |
|
| 3389 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3390 | - $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3391 | - } |
|
| 3392 | - } |
|
| 3393 | - } |
|
| 3394 | - |
|
| 3395 | - return $texte; |
|
| 3379 | + $ignore_params = array_merge( |
|
| 3380 | + ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3381 | + $ignore_params |
|
| 3382 | + ); |
|
| 3383 | + if (!is_array($env)) { |
|
| 3384 | + $env = unserialize($env); |
|
| 3385 | + } |
|
| 3386 | + $texte = ''; |
|
| 3387 | + if ($env) { |
|
| 3388 | + foreach ($env as $i => $j) { |
|
| 3389 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3390 | + $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3391 | + } |
|
| 3392 | + } |
|
| 3393 | + } |
|
| 3394 | + |
|
| 3395 | + return $texte; |
|
| 3396 | 3396 | } |
| 3397 | 3397 | |
| 3398 | 3398 | /** |
@@ -3415,23 +3415,23 @@ discard block |
||
| 3415 | 3415 | * Code HTML résultant |
| 3416 | 3416 | **/ |
| 3417 | 3417 | function env_to_attributs($env, $ignore_params = []) { |
| 3418 | - $ignore_params = array_merge( |
|
| 3419 | - ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3420 | - $ignore_params |
|
| 3421 | - ); |
|
| 3422 | - if (!is_array($env)) { |
|
| 3423 | - $env = unserialize($env); |
|
| 3424 | - } |
|
| 3425 | - $texte = ''; |
|
| 3426 | - if ($env) { |
|
| 3427 | - foreach ($env as $i => $j) { |
|
| 3428 | - if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3429 | - $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3430 | - } |
|
| 3431 | - } |
|
| 3432 | - } |
|
| 3418 | + $ignore_params = array_merge( |
|
| 3419 | + ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'], |
|
| 3420 | + $ignore_params |
|
| 3421 | + ); |
|
| 3422 | + if (!is_array($env)) { |
|
| 3423 | + $env = unserialize($env); |
|
| 3424 | + } |
|
| 3425 | + $texte = ''; |
|
| 3426 | + if ($env) { |
|
| 3427 | + foreach ($env as $i => $j) { |
|
| 3428 | + if (is_string($j) and !in_array($i, $ignore_params)) { |
|
| 3429 | + $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3430 | + } |
|
| 3431 | + } |
|
| 3432 | + } |
|
| 3433 | 3433 | |
| 3434 | - return $texte; |
|
| 3434 | + return $texte; |
|
| 3435 | 3435 | } |
| 3436 | 3436 | |
| 3437 | 3437 | |
@@ -3449,7 +3449,7 @@ discard block |
||
| 3449 | 3449 | * @return string Chaînes concaténés |
| 3450 | 3450 | **/ |
| 3451 | 3451 | function concat(...$args): string { |
| 3452 | - return join('', $args); |
|
| 3452 | + return join('', $args); |
|
| 3453 | 3453 | } |
| 3454 | 3454 | |
| 3455 | 3455 | |
@@ -3469,23 +3469,23 @@ discard block |
||
| 3469 | 3469 | * Contenu du ou des fichiers, concaténé |
| 3470 | 3470 | **/ |
| 3471 | 3471 | function charge_scripts($files, $script = true) { |
| 3472 | - $flux = ''; |
|
| 3473 | - foreach (is_array($files) ? $files : explode('|', $files) as $file) { |
|
| 3474 | - if (!is_string($file)) { |
|
| 3475 | - continue; |
|
| 3476 | - } |
|
| 3477 | - if ($script) { |
|
| 3478 | - $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : ''; |
|
| 3479 | - } |
|
| 3480 | - if ($file) { |
|
| 3481 | - $path = find_in_path($file); |
|
| 3482 | - if ($path) { |
|
| 3483 | - $flux .= spip_file_get_contents($path); |
|
| 3484 | - } |
|
| 3485 | - } |
|
| 3486 | - } |
|
| 3487 | - |
|
| 3488 | - return $flux; |
|
| 3472 | + $flux = ''; |
|
| 3473 | + foreach (is_array($files) ? $files : explode('|', $files) as $file) { |
|
| 3474 | + if (!is_string($file)) { |
|
| 3475 | + continue; |
|
| 3476 | + } |
|
| 3477 | + if ($script) { |
|
| 3478 | + $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : ''; |
|
| 3479 | + } |
|
| 3480 | + if ($file) { |
|
| 3481 | + $path = find_in_path($file); |
|
| 3482 | + if ($path) { |
|
| 3483 | + $flux .= spip_file_get_contents($path); |
|
| 3484 | + } |
|
| 3485 | + } |
|
| 3486 | + } |
|
| 3487 | + |
|
| 3488 | + return $flux; |
|
| 3489 | 3489 | } |
| 3490 | 3490 | |
| 3491 | 3491 | /** |
@@ -3496,22 +3496,22 @@ discard block |
||
| 3496 | 3496 | * @return string |
| 3497 | 3497 | */ |
| 3498 | 3498 | function http_img_variante_svg_si_possible($img_file) { |
| 3499 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3500 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3501 | - if ( |
|
| 3502 | - preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3503 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 3504 | - and file_exists($variante_svg_generique) |
|
| 3505 | - ) { |
|
| 3506 | - if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) { |
|
| 3507 | - $img_file = $variante_svg_size; |
|
| 3508 | - } |
|
| 3509 | - else { |
|
| 3510 | - $img_file = $variante_svg_generique; |
|
| 3511 | - } |
|
| 3512 | - } |
|
| 3499 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 3500 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 3501 | + if ( |
|
| 3502 | + preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
|
| 3503 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 3504 | + and file_exists($variante_svg_generique) |
|
| 3505 | + ) { |
|
| 3506 | + if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) { |
|
| 3507 | + $img_file = $variante_svg_size; |
|
| 3508 | + } |
|
| 3509 | + else { |
|
| 3510 | + $img_file = $variante_svg_generique; |
|
| 3511 | + } |
|
| 3512 | + } |
|
| 3513 | 3513 | |
| 3514 | - return $img_file; |
|
| 3514 | + return $img_file; |
|
| 3515 | 3515 | } |
| 3516 | 3516 | |
| 3517 | 3517 | /** |
@@ -3532,54 +3532,54 @@ discard block |
||
| 3532 | 3532 | */ |
| 3533 | 3533 | function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) { |
| 3534 | 3534 | |
| 3535 | - $img_file = $img; |
|
| 3536 | - if ($p = strpos($img_file, '?')) { |
|
| 3537 | - $img_file = substr($img_file, 0, $p); |
|
| 3538 | - } |
|
| 3539 | - if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3540 | - $img_file = chemin_image($img); |
|
| 3541 | - } |
|
| 3542 | - else { |
|
| 3543 | - if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) { |
|
| 3544 | - $img_file = http_img_variante_svg_si_possible($img_file); |
|
| 3545 | - } |
|
| 3546 | - } |
|
| 3547 | - if (stripos($atts, 'width') === false) { |
|
| 3548 | - // utiliser directement l'info de taille presente dans le nom |
|
| 3549 | - if ( |
|
| 3550 | - (!isset($options['utiliser_suffixe_size']) |
|
| 3551 | - or $options['utiliser_suffixe_size'] == true |
|
| 3552 | - or strpos($img_file, '-xx.svg') !== false) |
|
| 3553 | - and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3554 | - or preg_match(',\?([0-9]+)px$,', $img, $regs)) |
|
| 3555 | - ) { |
|
| 3556 | - $largeur = $hauteur = intval($regs[1]); |
|
| 3557 | - } else { |
|
| 3558 | - $taille = taille_image($img_file); |
|
| 3559 | - [$hauteur, $largeur] = $taille; |
|
| 3560 | - if (!$hauteur or !$largeur) { |
|
| 3561 | - return ''; |
|
| 3562 | - } |
|
| 3563 | - } |
|
| 3564 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3565 | - } |
|
| 3566 | - |
|
| 3567 | - if (file_exists($img_file)) { |
|
| 3568 | - $img_file = timestamp($img_file); |
|
| 3569 | - } |
|
| 3570 | - if ($alt === false) { |
|
| 3571 | - $alt = ''; |
|
| 3572 | - } |
|
| 3573 | - elseif ($alt or $alt === '') { |
|
| 3574 | - $alt = " alt='" . attribut_html($alt) . "'"; |
|
| 3575 | - } |
|
| 3576 | - else { |
|
| 3577 | - $alt = " alt='" . attribut_html($title) . "'"; |
|
| 3578 | - } |
|
| 3579 | - return "<img src='$img_file'$alt" |
|
| 3580 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3581 | - . ' ' . ltrim($atts) |
|
| 3582 | - . ' />'; |
|
| 3535 | + $img_file = $img; |
|
| 3536 | + if ($p = strpos($img_file, '?')) { |
|
| 3537 | + $img_file = substr($img_file, 0, $p); |
|
| 3538 | + } |
|
| 3539 | + if (!isset($options['chemin_image']) or $options['chemin_image'] == true) { |
|
| 3540 | + $img_file = chemin_image($img); |
|
| 3541 | + } |
|
| 3542 | + else { |
|
| 3543 | + if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) { |
|
| 3544 | + $img_file = http_img_variante_svg_si_possible($img_file); |
|
| 3545 | + } |
|
| 3546 | + } |
|
| 3547 | + if (stripos($atts, 'width') === false) { |
|
| 3548 | + // utiliser directement l'info de taille presente dans le nom |
|
| 3549 | + if ( |
|
| 3550 | + (!isset($options['utiliser_suffixe_size']) |
|
| 3551 | + or $options['utiliser_suffixe_size'] == true |
|
| 3552 | + or strpos($img_file, '-xx.svg') !== false) |
|
| 3553 | + and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs) |
|
| 3554 | + or preg_match(',\?([0-9]+)px$,', $img, $regs)) |
|
| 3555 | + ) { |
|
| 3556 | + $largeur = $hauteur = intval($regs[1]); |
|
| 3557 | + } else { |
|
| 3558 | + $taille = taille_image($img_file); |
|
| 3559 | + [$hauteur, $largeur] = $taille; |
|
| 3560 | + if (!$hauteur or !$largeur) { |
|
| 3561 | + return ''; |
|
| 3562 | + } |
|
| 3563 | + } |
|
| 3564 | + $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3565 | + } |
|
| 3566 | + |
|
| 3567 | + if (file_exists($img_file)) { |
|
| 3568 | + $img_file = timestamp($img_file); |
|
| 3569 | + } |
|
| 3570 | + if ($alt === false) { |
|
| 3571 | + $alt = ''; |
|
| 3572 | + } |
|
| 3573 | + elseif ($alt or $alt === '') { |
|
| 3574 | + $alt = " alt='" . attribut_html($alt) . "'"; |
|
| 3575 | + } |
|
| 3576 | + else { |
|
| 3577 | + $alt = " alt='" . attribut_html($title) . "'"; |
|
| 3578 | + } |
|
| 3579 | + return "<img src='$img_file'$alt" |
|
| 3580 | + . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3581 | + . ' ' . ltrim($atts) |
|
| 3582 | + . ' />'; |
|
| 3583 | 3583 | } |
| 3584 | 3584 | |
| 3585 | 3585 | /** |
@@ -3591,70 +3591,70 @@ discard block |
||
| 3591 | 3591 | * @return string |
| 3592 | 3592 | */ |
| 3593 | 3593 | function http_style_background($img, $att = '', $size = null) { |
| 3594 | - if ($size and is_numeric($size)) { |
|
| 3595 | - $size = trim($size) . 'px'; |
|
| 3596 | - } |
|
| 3597 | - return " style='background" . |
|
| 3598 | - ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';' |
|
| 3599 | - . ($size ? "background-size:{$size};" : '') |
|
| 3600 | - . "'"; |
|
| 3594 | + if ($size and is_numeric($size)) { |
|
| 3595 | + $size = trim($size) . 'px'; |
|
| 3596 | + } |
|
| 3597 | + return " style='background" . |
|
| 3598 | + ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';' |
|
| 3599 | + . ($size ? "background-size:{$size};" : '') |
|
| 3600 | + . "'"; |
|
| 3601 | 3601 | } |
| 3602 | 3602 | |
| 3603 | 3603 | |
| 3604 | 3604 | function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) { |
| 3605 | - $args = [$alt_or_size, $class_or_size, $size]; |
|
| 3606 | - while (is_null(end($args)) and count($args)) { |
|
| 3607 | - array_pop($args); |
|
| 3608 | - } |
|
| 3609 | - if (!count($args)) { |
|
| 3610 | - return [null, null, null]; |
|
| 3611 | - } |
|
| 3612 | - if (count($args) < 3) { |
|
| 3613 | - $maybe_size = array_pop($args); |
|
| 3614 | - // @2x |
|
| 3615 | - // @1.5x |
|
| 3616 | - // 512 |
|
| 3617 | - // 512x* |
|
| 3618 | - // 512x300 |
|
| 3619 | - if ( |
|
| 3620 | - !strlen($maybe_size) |
|
| 3621 | - or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size)) |
|
| 3622 | - ) { |
|
| 3623 | - $args[] = $maybe_size; |
|
| 3624 | - $maybe_size = null; |
|
| 3625 | - } |
|
| 3626 | - while (count($args) < 2) { |
|
| 3627 | - $args[] = null; // default alt or class |
|
| 3628 | - } |
|
| 3629 | - $args[] = $maybe_size; |
|
| 3630 | - } |
|
| 3631 | - return $args; |
|
| 3605 | + $args = [$alt_or_size, $class_or_size, $size]; |
|
| 3606 | + while (is_null(end($args)) and count($args)) { |
|
| 3607 | + array_pop($args); |
|
| 3608 | + } |
|
| 3609 | + if (!count($args)) { |
|
| 3610 | + return [null, null, null]; |
|
| 3611 | + } |
|
| 3612 | + if (count($args) < 3) { |
|
| 3613 | + $maybe_size = array_pop($args); |
|
| 3614 | + // @2x |
|
| 3615 | + // @1.5x |
|
| 3616 | + // 512 |
|
| 3617 | + // 512x* |
|
| 3618 | + // 512x300 |
|
| 3619 | + if ( |
|
| 3620 | + !strlen($maybe_size) |
|
| 3621 | + or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size)) |
|
| 3622 | + ) { |
|
| 3623 | + $args[] = $maybe_size; |
|
| 3624 | + $maybe_size = null; |
|
| 3625 | + } |
|
| 3626 | + while (count($args) < 2) { |
|
| 3627 | + $args[] = null; // default alt or class |
|
| 3628 | + } |
|
| 3629 | + $args[] = $maybe_size; |
|
| 3630 | + } |
|
| 3631 | + return $args; |
|
| 3632 | 3632 | } |
| 3633 | 3633 | |
| 3634 | 3634 | function helper_filtre_balise_img_svg_size($img, $size) { |
| 3635 | - // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite |
|
| 3636 | - if (strpos($size, '@') === 0 and substr($size, -1) === 'x') { |
|
| 3637 | - $coef = floatval(substr($size, 1, -1)); |
|
| 3638 | - [$h, $w] = taille_image($img); |
|
| 3639 | - $height = intval(round($h / $coef)); |
|
| 3640 | - $width = intval(round($w / $coef)); |
|
| 3641 | - } |
|
| 3642 | - // sinon c'est une valeur seule si image caree ou largeurxhauteur |
|
| 3643 | - else { |
|
| 3644 | - $size = explode('x', $size, 2); |
|
| 3645 | - $size = array_map('trim', $size); |
|
| 3646 | - $height = $width = intval(array_shift($size)); |
|
| 3647 | - |
|
| 3648 | - if (count($size) and reset($size)) { |
|
| 3649 | - $height = array_shift($size); |
|
| 3650 | - if ($height === '*') { |
|
| 3651 | - [$h, $w] = taille_image($img); |
|
| 3652 | - $height = intval(round($h * $width / $w)); |
|
| 3653 | - } |
|
| 3654 | - } |
|
| 3655 | - } |
|
| 3656 | - |
|
| 3657 | - return [$width, $height]; |
|
| 3635 | + // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite |
|
| 3636 | + if (strpos($size, '@') === 0 and substr($size, -1) === 'x') { |
|
| 3637 | + $coef = floatval(substr($size, 1, -1)); |
|
| 3638 | + [$h, $w] = taille_image($img); |
|
| 3639 | + $height = intval(round($h / $coef)); |
|
| 3640 | + $width = intval(round($w / $coef)); |
|
| 3641 | + } |
|
| 3642 | + // sinon c'est une valeur seule si image caree ou largeurxhauteur |
|
| 3643 | + else { |
|
| 3644 | + $size = explode('x', $size, 2); |
|
| 3645 | + $size = array_map('trim', $size); |
|
| 3646 | + $height = $width = intval(array_shift($size)); |
|
| 3647 | + |
|
| 3648 | + if (count($size) and reset($size)) { |
|
| 3649 | + $height = array_shift($size); |
|
| 3650 | + if ($height === '*') { |
|
| 3651 | + [$h, $w] = taille_image($img); |
|
| 3652 | + $height = intval(round($h * $width / $w)); |
|
| 3653 | + } |
|
| 3654 | + } |
|
| 3655 | + } |
|
| 3656 | + |
|
| 3657 | + return [$width, $height]; |
|
| 3658 | 3658 | } |
| 3659 | 3659 | |
| 3660 | 3660 | /** |
@@ -3690,43 +3690,43 @@ discard block |
||
| 3690 | 3690 | */ |
| 3691 | 3691 | function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) { |
| 3692 | 3692 | |
| 3693 | - [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3694 | - |
|
| 3695 | - $img = trim((string) $img); |
|
| 3696 | - if (strpos($img, '<img') === 0) { |
|
| 3697 | - if (!is_null($alt)) { |
|
| 3698 | - $img = inserer_attribut($img, 'alt', $alt); |
|
| 3699 | - } |
|
| 3700 | - if (!is_null($class)) { |
|
| 3701 | - if (strlen($class)) { |
|
| 3702 | - $img = inserer_attribut($img, 'class', $class); |
|
| 3703 | - } |
|
| 3704 | - else { |
|
| 3705 | - $img = vider_attribut($img, 'class'); |
|
| 3706 | - } |
|
| 3707 | - } |
|
| 3708 | - } |
|
| 3709 | - else { |
|
| 3710 | - $img = http_img_pack( |
|
| 3711 | - $img, |
|
| 3712 | - $alt, |
|
| 3713 | - $class ? " class='" . attribut_html($class) . "'" : '', |
|
| 3714 | - '', |
|
| 3715 | - ['chemin_image' => false, 'utiliser_suffixe_size' => false] |
|
| 3716 | - ); |
|
| 3717 | - if (is_null($alt)) { |
|
| 3718 | - $img = vider_attribut($img, 'alt'); |
|
| 3719 | - } |
|
| 3720 | - } |
|
| 3721 | - |
|
| 3722 | - if ($img and !is_null($size) and strlen($size = trim($size))) { |
|
| 3723 | - [$width, $height] = helper_filtre_balise_img_svg_size($img, $size); |
|
| 3724 | - |
|
| 3725 | - $img = inserer_attribut($img, 'width', $width); |
|
| 3726 | - $img = inserer_attribut($img, 'height', $height); |
|
| 3727 | - } |
|
| 3728 | - |
|
| 3729 | - return $img; |
|
| 3693 | + [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3694 | + |
|
| 3695 | + $img = trim((string) $img); |
|
| 3696 | + if (strpos($img, '<img') === 0) { |
|
| 3697 | + if (!is_null($alt)) { |
|
| 3698 | + $img = inserer_attribut($img, 'alt', $alt); |
|
| 3699 | + } |
|
| 3700 | + if (!is_null($class)) { |
|
| 3701 | + if (strlen($class)) { |
|
| 3702 | + $img = inserer_attribut($img, 'class', $class); |
|
| 3703 | + } |
|
| 3704 | + else { |
|
| 3705 | + $img = vider_attribut($img, 'class'); |
|
| 3706 | + } |
|
| 3707 | + } |
|
| 3708 | + } |
|
| 3709 | + else { |
|
| 3710 | + $img = http_img_pack( |
|
| 3711 | + $img, |
|
| 3712 | + $alt, |
|
| 3713 | + $class ? " class='" . attribut_html($class) . "'" : '', |
|
| 3714 | + '', |
|
| 3715 | + ['chemin_image' => false, 'utiliser_suffixe_size' => false] |
|
| 3716 | + ); |
|
| 3717 | + if (is_null($alt)) { |
|
| 3718 | + $img = vider_attribut($img, 'alt'); |
|
| 3719 | + } |
|
| 3720 | + } |
|
| 3721 | + |
|
| 3722 | + if ($img and !is_null($size) and strlen($size = trim($size))) { |
|
| 3723 | + [$width, $height] = helper_filtre_balise_img_svg_size($img, $size); |
|
| 3724 | + |
|
| 3725 | + $img = inserer_attribut($img, 'width', $width); |
|
| 3726 | + $img = inserer_attribut($img, 'height', $height); |
|
| 3727 | + } |
|
| 3728 | + |
|
| 3729 | + return $img; |
|
| 3730 | 3730 | } |
| 3731 | 3731 | |
| 3732 | 3732 | |
@@ -3760,80 +3760,80 @@ discard block |
||
| 3760 | 3760 | */ |
| 3761 | 3761 | function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) { |
| 3762 | 3762 | |
| 3763 | - $svg = null; |
|
| 3764 | - $img = trim($img); |
|
| 3765 | - $img_file = $img; |
|
| 3766 | - if (strpos($img, '<svg') === false) { |
|
| 3767 | - if ($p = strpos($img_file, '?')) { |
|
| 3768 | - $img_file = substr($img_file, 0, $p); |
|
| 3769 | - } |
|
| 3770 | - |
|
| 3771 | - // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 3772 | - // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 3773 | - if (tester_url_absolue($img_file)) { |
|
| 3774 | - include_spip('inc/distant'); |
|
| 3775 | - $fichier = copie_locale($img_file); |
|
| 3776 | - $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file); |
|
| 3777 | - } |
|
| 3778 | - |
|
| 3779 | - if ( |
|
| 3780 | - !$img_file |
|
| 3781 | - or !file_exists($img_file) |
|
| 3782 | - or !$svg = file_get_contents($img_file) |
|
| 3783 | - ) { |
|
| 3784 | - return ''; |
|
| 3785 | - } |
|
| 3786 | - } |
|
| 3787 | - |
|
| 3788 | - if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3789 | - return ''; |
|
| 3790 | - } |
|
| 3791 | - |
|
| 3792 | - [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3793 | - |
|
| 3794 | - $balise_svg = $match[0]; |
|
| 3795 | - $balise_svg_source = $balise_svg; |
|
| 3796 | - |
|
| 3797 | - // entete XML à supprimer |
|
| 3798 | - $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3799 | - |
|
| 3800 | - // IE est toujours mon ami |
|
| 3801 | - $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3802 | - |
|
| 3803 | - // regler la classe |
|
| 3804 | - if (!is_null($class)) { |
|
| 3805 | - if (strlen($class)) { |
|
| 3806 | - $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3807 | - } |
|
| 3808 | - else { |
|
| 3809 | - $balise_svg = vider_attribut($balise_svg, 'class'); |
|
| 3810 | - } |
|
| 3811 | - } |
|
| 3812 | - |
|
| 3813 | - // regler le alt |
|
| 3814 | - if ($alt) { |
|
| 3815 | - $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3816 | - $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3817 | - $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3818 | - $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n"; |
|
| 3819 | - $balise_svg .= $title; |
|
| 3820 | - } |
|
| 3821 | - else { |
|
| 3822 | - $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3823 | - } |
|
| 3824 | - |
|
| 3825 | - $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3826 | - |
|
| 3827 | - if (!is_null($size) and strlen($size = trim($size))) { |
|
| 3828 | - [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size); |
|
| 3829 | - |
|
| 3830 | - if (!function_exists('svg_redimensionner')) { |
|
| 3831 | - include_spip('inc/svg'); |
|
| 3832 | - } |
|
| 3833 | - $svg = svg_redimensionner($svg, $width, $height); |
|
| 3834 | - } |
|
| 3835 | - |
|
| 3836 | - return $svg; |
|
| 3763 | + $svg = null; |
|
| 3764 | + $img = trim($img); |
|
| 3765 | + $img_file = $img; |
|
| 3766 | + if (strpos($img, '<svg') === false) { |
|
| 3767 | + if ($p = strpos($img_file, '?')) { |
|
| 3768 | + $img_file = substr($img_file, 0, $p); |
|
| 3769 | + } |
|
| 3770 | + |
|
| 3771 | + // ne jamais operer directement sur une image distante pour des raisons de perfo |
|
| 3772 | + // la copie locale a toutes les chances d'etre la ou de resservir |
|
| 3773 | + if (tester_url_absolue($img_file)) { |
|
| 3774 | + include_spip('inc/distant'); |
|
| 3775 | + $fichier = copie_locale($img_file); |
|
| 3776 | + $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file); |
|
| 3777 | + } |
|
| 3778 | + |
|
| 3779 | + if ( |
|
| 3780 | + !$img_file |
|
| 3781 | + or !file_exists($img_file) |
|
| 3782 | + or !$svg = file_get_contents($img_file) |
|
| 3783 | + ) { |
|
| 3784 | + return ''; |
|
| 3785 | + } |
|
| 3786 | + } |
|
| 3787 | + |
|
| 3788 | + if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) { |
|
| 3789 | + return ''; |
|
| 3790 | + } |
|
| 3791 | + |
|
| 3792 | + [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size); |
|
| 3793 | + |
|
| 3794 | + $balise_svg = $match[0]; |
|
| 3795 | + $balise_svg_source = $balise_svg; |
|
| 3796 | + |
|
| 3797 | + // entete XML à supprimer |
|
| 3798 | + $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3799 | + |
|
| 3800 | + // IE est toujours mon ami |
|
| 3801 | + $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
|
| 3802 | + |
|
| 3803 | + // regler la classe |
|
| 3804 | + if (!is_null($class)) { |
|
| 3805 | + if (strlen($class)) { |
|
| 3806 | + $balise_svg = inserer_attribut($balise_svg, 'class', $class); |
|
| 3807 | + } |
|
| 3808 | + else { |
|
| 3809 | + $balise_svg = vider_attribut($balise_svg, 'class'); |
|
| 3810 | + } |
|
| 3811 | + } |
|
| 3812 | + |
|
| 3813 | + // regler le alt |
|
| 3814 | + if ($alt) { |
|
| 3815 | + $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
|
| 3816 | + $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3817 | + $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
|
| 3818 | + $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n"; |
|
| 3819 | + $balise_svg .= $title; |
|
| 3820 | + } |
|
| 3821 | + else { |
|
| 3822 | + $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true'); |
|
| 3823 | + } |
|
| 3824 | + |
|
| 3825 | + $svg = str_replace($balise_svg_source, $balise_svg, $svg); |
|
| 3826 | + |
|
| 3827 | + if (!is_null($size) and strlen($size = trim($size))) { |
|
| 3828 | + [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size); |
|
| 3829 | + |
|
| 3830 | + if (!function_exists('svg_redimensionner')) { |
|
| 3831 | + include_spip('inc/svg'); |
|
| 3832 | + } |
|
| 3833 | + $svg = svg_redimensionner($svg, $width, $height); |
|
| 3834 | + } |
|
| 3835 | + |
|
| 3836 | + return $svg; |
|
| 3837 | 3837 | } |
| 3838 | 3838 | |
| 3839 | 3839 | |
@@ -3859,18 +3859,18 @@ discard block |
||
| 3859 | 3859 | * Code HTML résultant |
| 3860 | 3860 | **/ |
| 3861 | 3861 | function filtre_foreach_dist($tableau, $modele = 'foreach') { |
| 3862 | - $texte = ''; |
|
| 3863 | - if (is_array($tableau)) { |
|
| 3864 | - foreach ($tableau as $k => $v) { |
|
| 3865 | - $res = recuperer_fond( |
|
| 3866 | - 'modeles/' . $modele, |
|
| 3867 | - array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v])) |
|
| 3868 | - ); |
|
| 3869 | - $texte .= $res; |
|
| 3870 | - } |
|
| 3871 | - } |
|
| 3862 | + $texte = ''; |
|
| 3863 | + if (is_array($tableau)) { |
|
| 3864 | + foreach ($tableau as $k => $v) { |
|
| 3865 | + $res = recuperer_fond( |
|
| 3866 | + 'modeles/' . $modele, |
|
| 3867 | + array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v])) |
|
| 3868 | + ); |
|
| 3869 | + $texte .= $res; |
|
| 3870 | + } |
|
| 3871 | + } |
|
| 3872 | 3872 | |
| 3873 | - return $texte; |
|
| 3873 | + return $texte; |
|
| 3874 | 3874 | } |
| 3875 | 3875 | |
| 3876 | 3876 | |
@@ -3895,37 +3895,37 @@ discard block |
||
| 3895 | 3895 | * - tout : retourne toutes les informations du plugin actif |
| 3896 | 3896 | **/ |
| 3897 | 3897 | function filtre_info_plugin_dist($plugin, $type_info, $reload = false) { |
| 3898 | - include_spip('inc/plugin'); |
|
| 3899 | - $plugin = strtoupper($plugin); |
|
| 3900 | - $plugins_actifs = liste_plugin_actifs(); |
|
| 3901 | - |
|
| 3902 | - if (!$plugin) { |
|
| 3903 | - return serialize(array_keys($plugins_actifs)); |
|
| 3904 | - } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3905 | - return ''; |
|
| 3906 | - } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3907 | - return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3908 | - } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3909 | - return $plugins_actifs[$plugin][$type_info]; |
|
| 3910 | - } else { |
|
| 3911 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3912 | - // On prend en compte les extensions |
|
| 3913 | - if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3914 | - $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3915 | - } else { |
|
| 3916 | - $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3917 | - } |
|
| 3918 | - if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3919 | - return ''; |
|
| 3920 | - } |
|
| 3921 | - if ($type_info == 'tout') { |
|
| 3922 | - return $infos; |
|
| 3923 | - } elseif ($type_info == 'est_actif') { |
|
| 3924 | - return $infos ? 1 : 0; |
|
| 3925 | - } else { |
|
| 3926 | - return strval($infos[$type_info]); |
|
| 3927 | - } |
|
| 3928 | - } |
|
| 3898 | + include_spip('inc/plugin'); |
|
| 3899 | + $plugin = strtoupper($plugin); |
|
| 3900 | + $plugins_actifs = liste_plugin_actifs(); |
|
| 3901 | + |
|
| 3902 | + if (!$plugin) { |
|
| 3903 | + return serialize(array_keys($plugins_actifs)); |
|
| 3904 | + } elseif (empty($plugins_actifs[$plugin]) and !$reload) { |
|
| 3905 | + return ''; |
|
| 3906 | + } elseif (($type_info == 'est_actif') and !$reload) { |
|
| 3907 | + return $plugins_actifs[$plugin] ? 1 : 0; |
|
| 3908 | + } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) { |
|
| 3909 | + return $plugins_actifs[$plugin][$type_info]; |
|
| 3910 | + } else { |
|
| 3911 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 3912 | + // On prend en compte les extensions |
|
| 3913 | + if (!is_dir($plugins_actifs[$plugin]['dir_type'])) { |
|
| 3914 | + $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']); |
|
| 3915 | + } else { |
|
| 3916 | + $dir_plugins = $plugins_actifs[$plugin]['dir_type']; |
|
| 3917 | + } |
|
| 3918 | + if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) { |
|
| 3919 | + return ''; |
|
| 3920 | + } |
|
| 3921 | + if ($type_info == 'tout') { |
|
| 3922 | + return $infos; |
|
| 3923 | + } elseif ($type_info == 'est_actif') { |
|
| 3924 | + return $infos ? 1 : 0; |
|
| 3925 | + } else { |
|
| 3926 | + return strval($infos[$type_info]); |
|
| 3927 | + } |
|
| 3928 | + } |
|
| 3929 | 3929 | } |
| 3930 | 3930 | |
| 3931 | 3931 | |
@@ -3952,9 +3952,9 @@ discard block |
||
| 3952 | 3952 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3953 | 3953 | */ |
| 3954 | 3954 | function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) { |
| 3955 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3955 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3956 | 3956 | |
| 3957 | - return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3957 | + return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax); |
|
| 3958 | 3958 | } |
| 3959 | 3959 | |
| 3960 | 3960 | |
@@ -3984,19 +3984,19 @@ discard block |
||
| 3984 | 3984 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 3985 | 3985 | */ |
| 3986 | 3986 | function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) { |
| 3987 | - static $puce_statut = null; |
|
| 3988 | - if (!$puce_statut) { |
|
| 3989 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3990 | - } |
|
| 3987 | + static $puce_statut = null; |
|
| 3988 | + if (!$puce_statut) { |
|
| 3989 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 3990 | + } |
|
| 3991 | 3991 | |
| 3992 | - return $puce_statut( |
|
| 3993 | - $id_objet, |
|
| 3994 | - $statut, |
|
| 3995 | - $id_parent, |
|
| 3996 | - $objet, |
|
| 3997 | - false, |
|
| 3998 | - objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false |
|
| 3999 | - ); |
|
| 3992 | + return $puce_statut( |
|
| 3993 | + $id_objet, |
|
| 3994 | + $statut, |
|
| 3995 | + $id_parent, |
|
| 3996 | + $objet, |
|
| 3997 | + false, |
|
| 3998 | + objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false |
|
| 3999 | + ); |
|
| 4000 | 4000 | } |
| 4001 | 4001 | |
| 4002 | 4002 | |
@@ -4023,98 +4023,98 @@ discard block |
||
| 4023 | 4023 | * hash du contexte |
| 4024 | 4024 | */ |
| 4025 | 4025 | function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') { |
| 4026 | - $env = null; |
|
| 4027 | - if ( |
|
| 4028 | - is_string($c) |
|
| 4029 | - and @unserialize($c) !== false |
|
| 4030 | - ) { |
|
| 4031 | - $c = unserialize($c); |
|
| 4032 | - } |
|
| 4033 | - |
|
| 4034 | - // supprimer les parametres debut_x |
|
| 4035 | - // pour que la pagination ajax ne soit pas plantee |
|
| 4036 | - // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 4037 | - // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 4038 | - if (is_array($c)) { |
|
| 4039 | - foreach ($c as $k => $v) { |
|
| 4040 | - if (strpos($k, 'debut_') === 0) { |
|
| 4041 | - unset($c[$k]); |
|
| 4042 | - } |
|
| 4043 | - } |
|
| 4044 | - } |
|
| 4045 | - |
|
| 4046 | - if (!function_exists('calculer_cle_action')) { |
|
| 4047 | - include_spip('inc/securiser_action'); |
|
| 4048 | - } |
|
| 4049 | - |
|
| 4050 | - $c = serialize($c); |
|
| 4051 | - $cle = calculer_cle_action($form . $c); |
|
| 4052 | - $c = "$cle:$c"; |
|
| 4053 | - |
|
| 4054 | - // on ne stocke pas les contextes dans des fichiers en cache |
|
| 4055 | - // par defaut, sauf si cette configuration a été forcée |
|
| 4056 | - // OU que la longueur de l’argument géneré est plus long |
|
| 4057 | - // que ce qui est toléré. |
|
| 4058 | - $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 4059 | - if (!$cache_contextes_ajax) { |
|
| 4060 | - $env = $c; |
|
| 4061 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4062 | - $env = gzdeflate($env); |
|
| 4063 | - } |
|
| 4064 | - $env = _xor($env); |
|
| 4065 | - $env = base64_encode($env); |
|
| 4066 | - $len = strlen($env); |
|
| 4067 | - // Si l’url est trop longue pour le navigateur |
|
| 4068 | - $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR; |
|
| 4069 | - if ($len > $max_len) { |
|
| 4070 | - $cache_contextes_ajax = true; |
|
| 4071 | - spip_log( |
|
| 4072 | - 'Contextes AJAX forces en fichiers !' |
|
| 4073 | - . ' Cela arrive lorsque la valeur du contexte' |
|
| 4074 | - . " depasse la longueur maximale autorisee ($max_len). Ici : $len.", |
|
| 4075 | - _LOG_AVERTISSEMENT |
|
| 4076 | - ); |
|
| 4077 | - } |
|
| 4078 | - // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET... |
|
| 4079 | - elseif ( |
|
| 4080 | - $max_len = @ini_get('suhosin.get.max_value_length') |
|
| 4081 | - and $max_len < $len |
|
| 4082 | - ) { |
|
| 4083 | - $cache_contextes_ajax = true; |
|
| 4084 | - spip_log('Contextes AJAX forces en fichiers !' |
|
| 4085 | - . ' Cela arrive lorsque la valeur du contexte' |
|
| 4086 | - . ' depasse la longueur maximale autorisee par Suhosin' |
|
| 4087 | - . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 4088 | - . ' Vous devriez modifier les parametres de Suhosin' |
|
| 4089 | - . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT); |
|
| 4090 | - } |
|
| 4091 | - } |
|
| 4092 | - |
|
| 4093 | - if ($cache_contextes_ajax) { |
|
| 4094 | - $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 4095 | - // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 4096 | - $md5 = md5($c); |
|
| 4097 | - ecrire_fichier("$dir/c$md5", $c); |
|
| 4098 | - $env = $md5; |
|
| 4099 | - } |
|
| 4100 | - |
|
| 4101 | - if ($emboite === null) { |
|
| 4102 | - return $env; |
|
| 4103 | - } |
|
| 4104 | - if (!trim($emboite)) { |
|
| 4105 | - return ''; |
|
| 4106 | - } |
|
| 4107 | - // toujours encoder l'url source dans le bloc ajax |
|
| 4108 | - $r = self(); |
|
| 4109 | - $r = ' data-origin="' . $r . '"'; |
|
| 4110 | - $class = 'ajaxbloc'; |
|
| 4111 | - if ($ajaxid and is_string($ajaxid)) { |
|
| 4112 | - // ajaxid est normalement conforme a un nom de classe css |
|
| 4113 | - // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 4114 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 4115 | - } |
|
| 4116 | - |
|
| 4117 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4026 | + $env = null; |
|
| 4027 | + if ( |
|
| 4028 | + is_string($c) |
|
| 4029 | + and @unserialize($c) !== false |
|
| 4030 | + ) { |
|
| 4031 | + $c = unserialize($c); |
|
| 4032 | + } |
|
| 4033 | + |
|
| 4034 | + // supprimer les parametres debut_x |
|
| 4035 | + // pour que la pagination ajax ne soit pas plantee |
|
| 4036 | + // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0, |
|
| 4037 | + // le debut_x=0 n'existe pas, et on resterait sur 1 |
|
| 4038 | + if (is_array($c)) { |
|
| 4039 | + foreach ($c as $k => $v) { |
|
| 4040 | + if (strpos($k, 'debut_') === 0) { |
|
| 4041 | + unset($c[$k]); |
|
| 4042 | + } |
|
| 4043 | + } |
|
| 4044 | + } |
|
| 4045 | + |
|
| 4046 | + if (!function_exists('calculer_cle_action')) { |
|
| 4047 | + include_spip('inc/securiser_action'); |
|
| 4048 | + } |
|
| 4049 | + |
|
| 4050 | + $c = serialize($c); |
|
| 4051 | + $cle = calculer_cle_action($form . $c); |
|
| 4052 | + $c = "$cle:$c"; |
|
| 4053 | + |
|
| 4054 | + // on ne stocke pas les contextes dans des fichiers en cache |
|
| 4055 | + // par defaut, sauf si cette configuration a été forcée |
|
| 4056 | + // OU que la longueur de l’argument géneré est plus long |
|
| 4057 | + // que ce qui est toléré. |
|
| 4058 | + $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX); |
|
| 4059 | + if (!$cache_contextes_ajax) { |
|
| 4060 | + $env = $c; |
|
| 4061 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4062 | + $env = gzdeflate($env); |
|
| 4063 | + } |
|
| 4064 | + $env = _xor($env); |
|
| 4065 | + $env = base64_encode($env); |
|
| 4066 | + $len = strlen($env); |
|
| 4067 | + // Si l’url est trop longue pour le navigateur |
|
| 4068 | + $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR; |
|
| 4069 | + if ($len > $max_len) { |
|
| 4070 | + $cache_contextes_ajax = true; |
|
| 4071 | + spip_log( |
|
| 4072 | + 'Contextes AJAX forces en fichiers !' |
|
| 4073 | + . ' Cela arrive lorsque la valeur du contexte' |
|
| 4074 | + . " depasse la longueur maximale autorisee ($max_len). Ici : $len.", |
|
| 4075 | + _LOG_AVERTISSEMENT |
|
| 4076 | + ); |
|
| 4077 | + } |
|
| 4078 | + // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET... |
|
| 4079 | + elseif ( |
|
| 4080 | + $max_len = @ini_get('suhosin.get.max_value_length') |
|
| 4081 | + and $max_len < $len |
|
| 4082 | + ) { |
|
| 4083 | + $cache_contextes_ajax = true; |
|
| 4084 | + spip_log('Contextes AJAX forces en fichiers !' |
|
| 4085 | + . ' Cela arrive lorsque la valeur du contexte' |
|
| 4086 | + . ' depasse la longueur maximale autorisee par Suhosin' |
|
| 4087 | + . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len." |
|
| 4088 | + . ' Vous devriez modifier les parametres de Suhosin' |
|
| 4089 | + . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT); |
|
| 4090 | + } |
|
| 4091 | + } |
|
| 4092 | + |
|
| 4093 | + if ($cache_contextes_ajax) { |
|
| 4094 | + $dir = sous_repertoire(_DIR_CACHE, 'contextes'); |
|
| 4095 | + // stocker les contextes sur disque et ne passer qu'un hash dans l'url |
|
| 4096 | + $md5 = md5($c); |
|
| 4097 | + ecrire_fichier("$dir/c$md5", $c); |
|
| 4098 | + $env = $md5; |
|
| 4099 | + } |
|
| 4100 | + |
|
| 4101 | + if ($emboite === null) { |
|
| 4102 | + return $env; |
|
| 4103 | + } |
|
| 4104 | + if (!trim($emboite)) { |
|
| 4105 | + return ''; |
|
| 4106 | + } |
|
| 4107 | + // toujours encoder l'url source dans le bloc ajax |
|
| 4108 | + $r = self(); |
|
| 4109 | + $r = ' data-origin="' . $r . '"'; |
|
| 4110 | + $class = 'ajaxbloc'; |
|
| 4111 | + if ($ajaxid and is_string($ajaxid)) { |
|
| 4112 | + // ajaxid est normalement conforme a un nom de classe css |
|
| 4113 | + // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
|
| 4114 | + $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 4115 | + } |
|
| 4116 | + |
|
| 4117 | + return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4118 | 4118 | } |
| 4119 | 4119 | |
| 4120 | 4120 | /** |
@@ -4134,37 +4134,37 @@ discard block |
||
| 4134 | 4134 | * - false : erreur de décodage |
| 4135 | 4135 | */ |
| 4136 | 4136 | function decoder_contexte_ajax($c, $form = '') { |
| 4137 | - if (!function_exists('calculer_cle_action')) { |
|
| 4138 | - include_spip('inc/securiser_action'); |
|
| 4139 | - } |
|
| 4140 | - if ( |
|
| 4141 | - ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 4142 | - and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 4143 | - and lire_fichier("$dir/c$c", $contexte) |
|
| 4144 | - ) { |
|
| 4145 | - $c = $contexte; |
|
| 4146 | - } else { |
|
| 4147 | - $c = @base64_decode($c); |
|
| 4148 | - $c = _xor($c); |
|
| 4149 | - if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4150 | - $c = @gzinflate($c); |
|
| 4151 | - } |
|
| 4152 | - } |
|
| 4153 | - |
|
| 4154 | - // extraire la signature en debut de contexte |
|
| 4155 | - // et la verifier avant de deserializer |
|
| 4156 | - // format : signature:donneesserializees |
|
| 4157 | - if ($p = strpos($c, ':')) { |
|
| 4158 | - $cle = substr($c, 0, $p); |
|
| 4159 | - $c = substr($c, $p + 1); |
|
| 4160 | - |
|
| 4161 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 4162 | - $env = @unserialize($c); |
|
| 4163 | - return $env; |
|
| 4164 | - } |
|
| 4165 | - } |
|
| 4166 | - |
|
| 4167 | - return false; |
|
| 4137 | + if (!function_exists('calculer_cle_action')) { |
|
| 4138 | + include_spip('inc/securiser_action'); |
|
| 4139 | + } |
|
| 4140 | + if ( |
|
| 4141 | + ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32) |
|
| 4142 | + and $dir = sous_repertoire(_DIR_CACHE, 'contextes') |
|
| 4143 | + and lire_fichier("$dir/c$c", $contexte) |
|
| 4144 | + ) { |
|
| 4145 | + $c = $contexte; |
|
| 4146 | + } else { |
|
| 4147 | + $c = @base64_decode($c); |
|
| 4148 | + $c = _xor($c); |
|
| 4149 | + if (function_exists('gzdeflate') && function_exists('gzinflate')) { |
|
| 4150 | + $c = @gzinflate($c); |
|
| 4151 | + } |
|
| 4152 | + } |
|
| 4153 | + |
|
| 4154 | + // extraire la signature en debut de contexte |
|
| 4155 | + // et la verifier avant de deserializer |
|
| 4156 | + // format : signature:donneesserializees |
|
| 4157 | + if ($p = strpos($c, ':')) { |
|
| 4158 | + $cle = substr($c, 0, $p); |
|
| 4159 | + $c = substr($c, $p + 1); |
|
| 4160 | + |
|
| 4161 | + if ($cle == calculer_cle_action($form . $c)) { |
|
| 4162 | + $env = @unserialize($c); |
|
| 4163 | + return $env; |
|
| 4164 | + } |
|
| 4165 | + } |
|
| 4166 | + |
|
| 4167 | + return false; |
|
| 4168 | 4168 | } |
| 4169 | 4169 | |
| 4170 | 4170 | |
@@ -4182,20 +4182,20 @@ discard block |
||
| 4182 | 4182 | * Message décrypté ou encrypté |
| 4183 | 4183 | **/ |
| 4184 | 4184 | function _xor($message, $key = null) { |
| 4185 | - if (is_null($key)) { |
|
| 4186 | - if (!function_exists('calculer_cle_action')) { |
|
| 4187 | - include_spip('inc/securiser_action'); |
|
| 4188 | - } |
|
| 4189 | - $key = pack('H*', calculer_cle_action('_xor')); |
|
| 4190 | - } |
|
| 4185 | + if (is_null($key)) { |
|
| 4186 | + if (!function_exists('calculer_cle_action')) { |
|
| 4187 | + include_spip('inc/securiser_action'); |
|
| 4188 | + } |
|
| 4189 | + $key = pack('H*', calculer_cle_action('_xor')); |
|
| 4190 | + } |
|
| 4191 | 4191 | |
| 4192 | - $keylen = strlen($key); |
|
| 4193 | - $messagelen = strlen($message); |
|
| 4194 | - for ($i = 0; $i < $messagelen; $i++) { |
|
| 4195 | - $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 4196 | - } |
|
| 4192 | + $keylen = strlen($key); |
|
| 4193 | + $messagelen = strlen($message); |
|
| 4194 | + for ($i = 0; $i < $messagelen; $i++) { |
|
| 4195 | + $message[$i] = ~($message[$i] ^ $key[$i % $keylen]); |
|
| 4196 | + } |
|
| 4197 | 4197 | |
| 4198 | - return $message; |
|
| 4198 | + return $message; |
|
| 4199 | 4199 | } |
| 4200 | 4200 | |
| 4201 | 4201 | /** |
@@ -4209,7 +4209,7 @@ discard block |
||
| 4209 | 4209 | * @return string |
| 4210 | 4210 | */ |
| 4211 | 4211 | function url_reponse_forum($texte) { |
| 4212 | - return $texte; |
|
| 4212 | + return $texte; |
|
| 4213 | 4213 | } |
| 4214 | 4214 | |
| 4215 | 4215 | /** |
@@ -4223,7 +4223,7 @@ discard block |
||
| 4223 | 4223 | * @return string |
| 4224 | 4224 | */ |
| 4225 | 4225 | function url_rss_forum($texte) { |
| 4226 | - return $texte; |
|
| 4226 | + return $texte; |
|
| 4227 | 4227 | } |
| 4228 | 4228 | |
| 4229 | 4229 | |
@@ -4262,37 +4262,37 @@ discard block |
||
| 4262 | 4262 | * Code HTML |
| 4263 | 4263 | */ |
| 4264 | 4264 | function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') { |
| 4265 | - if ($on) { |
|
| 4266 | - $bal = 'strong'; |
|
| 4267 | - $class = ''; |
|
| 4268 | - $att = ''; |
|
| 4269 | - // si $on passe la balise et optionnelement une ou ++classe |
|
| 4270 | - // a.active span.selected.active etc.... |
|
| 4271 | - if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) { |
|
| 4272 | - $on = explode('.', $on); |
|
| 4273 | - // on verifie que c'est exactement une des 3 balises a, span ou strong |
|
| 4274 | - if (in_array(reset($on), ['a', 'span', 'strong'])) { |
|
| 4275 | - $bal = array_shift($on); |
|
| 4276 | - $class = implode(' ', $on); |
|
| 4277 | - if ($bal == 'a') { |
|
| 4278 | - $att = 'href="#" '; |
|
| 4279 | - } |
|
| 4280 | - } |
|
| 4281 | - } |
|
| 4282 | - $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4283 | - } else { |
|
| 4284 | - $bal = 'a'; |
|
| 4285 | - $att = "href='$url'" |
|
| 4286 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4287 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4288 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4289 | - . $evt; |
|
| 4290 | - } |
|
| 4291 | - if ($libelle === null) { |
|
| 4292 | - $libelle = $url; |
|
| 4293 | - } |
|
| 4294 | - |
|
| 4295 | - return "<$bal $att>$libelle</$bal>"; |
|
| 4265 | + if ($on) { |
|
| 4266 | + $bal = 'strong'; |
|
| 4267 | + $class = ''; |
|
| 4268 | + $att = ''; |
|
| 4269 | + // si $on passe la balise et optionnelement une ou ++classe |
|
| 4270 | + // a.active span.selected.active etc.... |
|
| 4271 | + if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) { |
|
| 4272 | + $on = explode('.', $on); |
|
| 4273 | + // on verifie que c'est exactement une des 3 balises a, span ou strong |
|
| 4274 | + if (in_array(reset($on), ['a', 'span', 'strong'])) { |
|
| 4275 | + $bal = array_shift($on); |
|
| 4276 | + $class = implode(' ', $on); |
|
| 4277 | + if ($bal == 'a') { |
|
| 4278 | + $att = 'href="#" '; |
|
| 4279 | + } |
|
| 4280 | + } |
|
| 4281 | + } |
|
| 4282 | + $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4283 | + } else { |
|
| 4284 | + $bal = 'a'; |
|
| 4285 | + $att = "href='$url'" |
|
| 4286 | + . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4287 | + . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4288 | + . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4289 | + . $evt; |
|
| 4290 | + } |
|
| 4291 | + if ($libelle === null) { |
|
| 4292 | + $libelle = $url; |
|
| 4293 | + } |
|
| 4294 | + |
|
| 4295 | + return "<$bal $att>$libelle</$bal>"; |
|
| 4296 | 4296 | } |
| 4297 | 4297 | |
| 4298 | 4298 | |
@@ -4309,39 +4309,39 @@ discard block |
||
| 4309 | 4309 | * @return string : la chaine de langue finale en utilisant la fonction _T() |
| 4310 | 4310 | */ |
| 4311 | 4311 | function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) { |
| 4312 | - static $local_singulier_ou_pluriel = []; |
|
| 4313 | - |
|
| 4314 | - // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon |
|
| 4315 | - if (!is_numeric($nb) or $nb == 0) { |
|
| 4316 | - return ''; |
|
| 4317 | - } |
|
| 4318 | - if (!is_array($vars)) { |
|
| 4319 | - return ''; |
|
| 4320 | - } |
|
| 4321 | - |
|
| 4322 | - $langue = $GLOBALS['spip_lang']; |
|
| 4323 | - if (!isset($local_singulier_ou_pluriel[$langue])) { |
|
| 4324 | - $local_singulier_ou_pluriel[$langue] = false; |
|
| 4325 | - if ( |
|
| 4326 | - $f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true) |
|
| 4327 | - or $f = charger_fonction('singulier_ou_pluriel', 'inc', true) |
|
| 4328 | - ) { |
|
| 4329 | - $local_singulier_ou_pluriel[$langue] = $f; |
|
| 4330 | - } |
|
| 4331 | - } |
|
| 4332 | - |
|
| 4333 | - // si on a une surcharge on l'utilise |
|
| 4334 | - if ($local_singulier_ou_pluriel[$langue]) { |
|
| 4335 | - return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars); |
|
| 4336 | - } |
|
| 4337 | - |
|
| 4338 | - // sinon traitement par defaut |
|
| 4339 | - $vars[$var] = $nb; |
|
| 4340 | - if ($nb >= 2) { |
|
| 4341 | - return _T($chaine_plusieurs, $vars); |
|
| 4342 | - } else { |
|
| 4343 | - return _T($chaine_un, $vars); |
|
| 4344 | - } |
|
| 4312 | + static $local_singulier_ou_pluriel = []; |
|
| 4313 | + |
|
| 4314 | + // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon |
|
| 4315 | + if (!is_numeric($nb) or $nb == 0) { |
|
| 4316 | + return ''; |
|
| 4317 | + } |
|
| 4318 | + if (!is_array($vars)) { |
|
| 4319 | + return ''; |
|
| 4320 | + } |
|
| 4321 | + |
|
| 4322 | + $langue = $GLOBALS['spip_lang']; |
|
| 4323 | + if (!isset($local_singulier_ou_pluriel[$langue])) { |
|
| 4324 | + $local_singulier_ou_pluriel[$langue] = false; |
|
| 4325 | + if ( |
|
| 4326 | + $f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true) |
|
| 4327 | + or $f = charger_fonction('singulier_ou_pluriel', 'inc', true) |
|
| 4328 | + ) { |
|
| 4329 | + $local_singulier_ou_pluriel[$langue] = $f; |
|
| 4330 | + } |
|
| 4331 | + } |
|
| 4332 | + |
|
| 4333 | + // si on a une surcharge on l'utilise |
|
| 4334 | + if ($local_singulier_ou_pluriel[$langue]) { |
|
| 4335 | + return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars); |
|
| 4336 | + } |
|
| 4337 | + |
|
| 4338 | + // sinon traitement par defaut |
|
| 4339 | + $vars[$var] = $nb; |
|
| 4340 | + if ($nb >= 2) { |
|
| 4341 | + return _T($chaine_plusieurs, $vars); |
|
| 4342 | + } else { |
|
| 4343 | + return _T($chaine_un, $vars); |
|
| 4344 | + } |
|
| 4345 | 4345 | } |
| 4346 | 4346 | |
| 4347 | 4347 | |
@@ -4369,73 +4369,73 @@ discard block |
||
| 4369 | 4369 | */ |
| 4370 | 4370 | function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4371 | 4371 | |
| 4372 | - $class_lien = $class_bouton = $class; |
|
| 4373 | - |
|
| 4374 | - // Normaliser la fonction et compléter la classe en fonction |
|
| 4375 | - if (in_array($fonction, ['del', 'supprimer.gif'])) { |
|
| 4376 | - $class_lien .= ' danger'; |
|
| 4377 | - $class_bouton .= ' btn_danger'; |
|
| 4378 | - } elseif ($fonction == 'rien.gif') { |
|
| 4379 | - $fonction = ''; |
|
| 4380 | - } elseif ($fonction == 'delsafe') { |
|
| 4381 | - $fonction = 'del'; |
|
| 4382 | - } |
|
| 4383 | - |
|
| 4384 | - $fond_origine = $fond; |
|
| 4385 | - // Remappage des icone : article-24.png+new => article-new-24.png |
|
| 4386 | - if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 4387 | - [$fond, $fonction] = $icone_renommer($fond, $fonction); |
|
| 4388 | - } |
|
| 4389 | - |
|
| 4390 | - // Ajouter le type d'objet dans la classe |
|
| 4391 | - $objet_type = substr(basename($fond), 0, -4); |
|
| 4392 | - $class_lien .= " $objet_type"; |
|
| 4393 | - $class_bouton .= " $objet_type"; |
|
| 4394 | - |
|
| 4395 | - // Texte |
|
| 4396 | - $alt = attribut_html($texte); |
|
| 4397 | - $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 4398 | - |
|
| 4399 | - // Liens : préparer les classes ajax |
|
| 4400 | - $ajax = ''; |
|
| 4401 | - if ($type === 'lien') { |
|
| 4402 | - if (strpos($class_lien, 'ajax') !== false) { |
|
| 4403 | - $ajax = 'ajax'; |
|
| 4404 | - if (strpos($class_lien, 'preload') !== false) { |
|
| 4405 | - $ajax .= ' preload'; |
|
| 4406 | - } |
|
| 4407 | - if (strpos($class_lien, 'nocache') !== false) { |
|
| 4408 | - $ajax .= ' nocache'; |
|
| 4409 | - } |
|
| 4410 | - $ajax = " class='$ajax'"; |
|
| 4411 | - } |
|
| 4412 | - } |
|
| 4413 | - |
|
| 4414 | - // Repérer la taille et l'ajouter dans la classe |
|
| 4415 | - $size = 24; |
|
| 4416 | - if ( |
|
| 4417 | - preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match) |
|
| 4418 | - or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match) |
|
| 4419 | - ) { |
|
| 4420 | - $size = $match[1]; |
|
| 4421 | - } |
|
| 4422 | - $class_lien .= " s$size"; |
|
| 4423 | - $class_bouton .= " s$size"; |
|
| 4424 | - |
|
| 4425 | - // Icône |
|
| 4426 | - $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 4427 | - $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>"; |
|
| 4428 | - |
|
| 4429 | - // Markup final |
|
| 4430 | - if ($type == 'lien') { |
|
| 4431 | - return "<span class='icone $class_lien'>" |
|
| 4432 | - . "<a href='$lien'$title$ajax$javascript>" |
|
| 4433 | - . $icone |
|
| 4434 | - . "<b>$texte</b>" |
|
| 4435 | - . "</a></span>\n"; |
|
| 4436 | - } else { |
|
| 4437 | - return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt); |
|
| 4438 | - } |
|
| 4372 | + $class_lien = $class_bouton = $class; |
|
| 4373 | + |
|
| 4374 | + // Normaliser la fonction et compléter la classe en fonction |
|
| 4375 | + if (in_array($fonction, ['del', 'supprimer.gif'])) { |
|
| 4376 | + $class_lien .= ' danger'; |
|
| 4377 | + $class_bouton .= ' btn_danger'; |
|
| 4378 | + } elseif ($fonction == 'rien.gif') { |
|
| 4379 | + $fonction = ''; |
|
| 4380 | + } elseif ($fonction == 'delsafe') { |
|
| 4381 | + $fonction = 'del'; |
|
| 4382 | + } |
|
| 4383 | + |
|
| 4384 | + $fond_origine = $fond; |
|
| 4385 | + // Remappage des icone : article-24.png+new => article-new-24.png |
|
| 4386 | + if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { |
|
| 4387 | + [$fond, $fonction] = $icone_renommer($fond, $fonction); |
|
| 4388 | + } |
|
| 4389 | + |
|
| 4390 | + // Ajouter le type d'objet dans la classe |
|
| 4391 | + $objet_type = substr(basename($fond), 0, -4); |
|
| 4392 | + $class_lien .= " $objet_type"; |
|
| 4393 | + $class_bouton .= " $objet_type"; |
|
| 4394 | + |
|
| 4395 | + // Texte |
|
| 4396 | + $alt = attribut_html($texte); |
|
| 4397 | + $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ? |
|
| 4398 | + |
|
| 4399 | + // Liens : préparer les classes ajax |
|
| 4400 | + $ajax = ''; |
|
| 4401 | + if ($type === 'lien') { |
|
| 4402 | + if (strpos($class_lien, 'ajax') !== false) { |
|
| 4403 | + $ajax = 'ajax'; |
|
| 4404 | + if (strpos($class_lien, 'preload') !== false) { |
|
| 4405 | + $ajax .= ' preload'; |
|
| 4406 | + } |
|
| 4407 | + if (strpos($class_lien, 'nocache') !== false) { |
|
| 4408 | + $ajax .= ' nocache'; |
|
| 4409 | + } |
|
| 4410 | + $ajax = " class='$ajax'"; |
|
| 4411 | + } |
|
| 4412 | + } |
|
| 4413 | + |
|
| 4414 | + // Repérer la taille et l'ajouter dans la classe |
|
| 4415 | + $size = 24; |
|
| 4416 | + if ( |
|
| 4417 | + preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match) |
|
| 4418 | + or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match) |
|
| 4419 | + ) { |
|
| 4420 | + $size = $match[1]; |
|
| 4421 | + } |
|
| 4422 | + $class_lien .= " s$size"; |
|
| 4423 | + $class_bouton .= " s$size"; |
|
| 4424 | + |
|
| 4425 | + // Icône |
|
| 4426 | + $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
|
| 4427 | + $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>"; |
|
| 4428 | + |
|
| 4429 | + // Markup final |
|
| 4430 | + if ($type == 'lien') { |
|
| 4431 | + return "<span class='icone $class_lien'>" |
|
| 4432 | + . "<a href='$lien'$title$ajax$javascript>" |
|
| 4433 | + . $icone |
|
| 4434 | + . "<b>$texte</b>" |
|
| 4435 | + . "</a></span>\n"; |
|
| 4436 | + } else { |
|
| 4437 | + return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt); |
|
| 4438 | + } |
|
| 4439 | 4439 | } |
| 4440 | 4440 | |
| 4441 | 4441 | /** |
@@ -4459,7 +4459,7 @@ discard block |
||
| 4459 | 4459 | * Code HTML du lien |
| 4460 | 4460 | **/ |
| 4461 | 4461 | function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4462 | - return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 4462 | + return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript); |
|
| 4463 | 4463 | } |
| 4464 | 4464 | |
| 4465 | 4465 | /** |
@@ -4494,7 +4494,7 @@ discard block |
||
| 4494 | 4494 | * Code HTML du lien |
| 4495 | 4495 | **/ |
| 4496 | 4496 | function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4497 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 4497 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript); |
|
| 4498 | 4498 | } |
| 4499 | 4499 | |
| 4500 | 4500 | /** |
@@ -4539,7 +4539,7 @@ discard block |
||
| 4539 | 4539 | * Code HTML du lien |
| 4540 | 4540 | **/ |
| 4541 | 4541 | function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') { |
| 4542 | - return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4542 | + return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript); |
|
| 4543 | 4543 | } |
| 4544 | 4544 | |
| 4545 | 4545 | /** |
@@ -4570,7 +4570,7 @@ discard block |
||
| 4570 | 4570 | * Code HTML du lien |
| 4571 | 4571 | **/ |
| 4572 | 4572 | function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') { |
| 4573 | - return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm); |
|
| 4573 | + return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm); |
|
| 4574 | 4574 | } |
| 4575 | 4575 | |
| 4576 | 4576 | /** |
@@ -4601,7 +4601,7 @@ discard block |
||
| 4601 | 4601 | * Code HTML du lien |
| 4602 | 4602 | */ |
| 4603 | 4603 | function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') { |
| 4604 | - return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4604 | + return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript); |
|
| 4605 | 4605 | } |
| 4606 | 4606 | |
| 4607 | 4607 | |
@@ -4623,7 +4623,7 @@ discard block |
||
| 4623 | 4623 | * @return array Liste des éléments |
| 4624 | 4624 | */ |
| 4625 | 4625 | function filtre_explode_dist($a, $b) { |
| 4626 | - return explode($b, (string) $a); |
|
| 4626 | + return explode($b, (string) $a); |
|
| 4627 | 4627 | } |
| 4628 | 4628 | |
| 4629 | 4629 | /** |
@@ -4644,7 +4644,7 @@ discard block |
||
| 4644 | 4644 | * @return string Texte |
| 4645 | 4645 | */ |
| 4646 | 4646 | function filtre_implode_dist($a, $b) { |
| 4647 | - return is_array($a) ? implode($b, $a) : $a; |
|
| 4647 | + return is_array($a) ? implode($b, $a) : $a; |
|
| 4648 | 4648 | } |
| 4649 | 4649 | |
| 4650 | 4650 | /** |
@@ -4653,22 +4653,22 @@ discard block |
||
| 4653 | 4653 | * @return string Code CSS |
| 4654 | 4654 | */ |
| 4655 | 4655 | function bando_images_background() { |
| 4656 | - include_spip('inc/bandeau'); |
|
| 4657 | - // recuperer tous les boutons et leurs images |
|
| 4658 | - $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4656 | + include_spip('inc/bandeau'); |
|
| 4657 | + // recuperer tous les boutons et leurs images |
|
| 4658 | + $boutons = definir_barre_boutons(definir_barre_contexte(), true, false); |
|
| 4659 | 4659 | |
| 4660 | - $res = ''; |
|
| 4661 | - foreach ($boutons as $page => $detail) { |
|
| 4662 | - $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones '); |
|
| 4663 | - foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4664 | - if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4665 | - $img = http_img_variante_svg_si_possible($sousdetail->icone); |
|
| 4666 | - $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}"; |
|
| 4667 | - } |
|
| 4668 | - } |
|
| 4669 | - } |
|
| 4660 | + $res = ''; |
|
| 4661 | + foreach ($boutons as $page => $detail) { |
|
| 4662 | + $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones '); |
|
| 4663 | + foreach ($detail->sousmenu as $souspage => $sousdetail) { |
|
| 4664 | + if ($sousdetail->icone and strlen(trim($sousdetail->icone))) { |
|
| 4665 | + $img = http_img_variante_svg_si_possible($sousdetail->icone); |
|
| 4666 | + $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}"; |
|
| 4667 | + } |
|
| 4668 | + } |
|
| 4669 | + } |
|
| 4670 | 4670 | |
| 4671 | - return $res; |
|
| 4671 | + return $res; |
|
| 4672 | 4672 | } |
| 4673 | 4673 | |
| 4674 | 4674 | /** |
@@ -4693,27 +4693,27 @@ discard block |
||
| 4693 | 4693 | */ |
| 4694 | 4694 | function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') { |
| 4695 | 4695 | |
| 4696 | - // Classes : dispatcher `ajax` sur le formulaire |
|
| 4697 | - $class_form = ''; |
|
| 4698 | - if (strpos($class, 'ajax') !== false) { |
|
| 4699 | - $class_form = 'ajax'; |
|
| 4700 | - $class = str_replace('ajax', '', $class); |
|
| 4701 | - } |
|
| 4702 | - $class_btn = 'submit ' . trim($class); |
|
| 4696 | + // Classes : dispatcher `ajax` sur le formulaire |
|
| 4697 | + $class_form = ''; |
|
| 4698 | + if (strpos($class, 'ajax') !== false) { |
|
| 4699 | + $class_form = 'ajax'; |
|
| 4700 | + $class = str_replace('ajax', '', $class); |
|
| 4701 | + } |
|
| 4702 | + $class_btn = 'submit ' . trim($class); |
|
| 4703 | 4703 | |
| 4704 | - if ($confirm) { |
|
| 4705 | - $confirm = 'confirm("' . attribut_html($confirm) . '")'; |
|
| 4706 | - if ($callback) { |
|
| 4707 | - $callback = "$confirm?($callback):false"; |
|
| 4708 | - } else { |
|
| 4709 | - $callback = $confirm; |
|
| 4710 | - } |
|
| 4711 | - } |
|
| 4712 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ''; |
|
| 4713 | - $title = $title ? " title='$title'" : ''; |
|
| 4704 | + if ($confirm) { |
|
| 4705 | + $confirm = 'confirm("' . attribut_html($confirm) . '")'; |
|
| 4706 | + if ($callback) { |
|
| 4707 | + $callback = "$confirm?($callback):false"; |
|
| 4708 | + } else { |
|
| 4709 | + $callback = $confirm; |
|
| 4710 | + } |
|
| 4711 | + } |
|
| 4712 | + $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ''; |
|
| 4713 | + $title = $title ? " title='$title'" : ''; |
|
| 4714 | 4714 | |
| 4715 | - return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4716 | - . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
|
| 4715 | + return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4716 | + . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
|
| 4717 | 4717 | } |
| 4718 | 4718 | |
| 4719 | 4719 | /** |
@@ -4736,101 +4736,101 @@ discard block |
||
| 4736 | 4736 | * @return string |
| 4737 | 4737 | */ |
| 4738 | 4738 | function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string { |
| 4739 | - static $trouver_table = null; |
|
| 4740 | - static $objets; |
|
| 4741 | - |
|
| 4742 | - // On verifie qu'on a tout ce qu'il faut |
|
| 4743 | - $id_objet = intval($id_objet); |
|
| 4744 | - if (!($id_objet and $type_objet and $info)) { |
|
| 4745 | - return ''; |
|
| 4746 | - } |
|
| 4747 | - |
|
| 4748 | - // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4749 | - if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4750 | - return ''; |
|
| 4751 | - } |
|
| 4752 | - |
|
| 4753 | - // Si on demande l'url, on retourne direct la fonction |
|
| 4754 | - if ($info == 'url') { |
|
| 4755 | - return generer_objet_url($id_objet, $type_objet, ...$params); |
|
| 4756 | - } |
|
| 4757 | - |
|
| 4758 | - // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4759 | - $demande_titre = ($info === 'titre'); |
|
| 4760 | - $demande_introduction = ($info === 'introduction'); |
|
| 4761 | - |
|
| 4762 | - // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore |
|
| 4763 | - if ( |
|
| 4764 | - !isset($objets[$type_objet][$id_objet]) |
|
| 4765 | - or |
|
| 4766 | - ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4767 | - ) { |
|
| 4768 | - if (!$trouver_table) { |
|
| 4769 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4770 | - } |
|
| 4771 | - $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4772 | - if (!$desc) { |
|
| 4773 | - return $objets[$type_objet] = false; |
|
| 4774 | - } |
|
| 4775 | - |
|
| 4776 | - // Si on demande le titre, on le gere en interne |
|
| 4777 | - $champ_titre = ''; |
|
| 4778 | - if ($demande_titre) { |
|
| 4779 | - // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4780 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4781 | - } |
|
| 4782 | - include_spip('base/abstract_sql'); |
|
| 4783 | - include_spip('base/connect_sql'); |
|
| 4784 | - $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4785 | - '*' . $champ_titre, |
|
| 4786 | - $desc['table_sql'], |
|
| 4787 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4788 | - ); |
|
| 4789 | - |
|
| 4790 | - // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci |
|
| 4791 | - $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null; |
|
| 4792 | - } |
|
| 4793 | - |
|
| 4794 | - // Pour les fonction generer_xxx, si on demande l'introduction, |
|
| 4795 | - // ajouter la longueur au début des params supplémentaires |
|
| 4796 | - if ($demande_introduction) { |
|
| 4797 | - $introduction_longueur = $objets[$type_objet]['introduction_longueur']; |
|
| 4798 | - array_unshift($params, $introduction_longueur); |
|
| 4799 | - } |
|
| 4800 | - |
|
| 4801 | - // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4802 | - if ( |
|
| 4803 | - $generer = charger_fonction("generer_${type_objet}_${info}", '', true) |
|
| 4804 | - // @deprecated 4.1 generer_TRUC_TYPE |
|
| 4805 | - or $generer = charger_fonction("generer_${info}_${type_objet}", '', true) |
|
| 4806 | - ) { |
|
| 4807 | - $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4808 | - } |
|
| 4809 | - // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4810 | - elseif ( |
|
| 4811 | - $generer = charger_fonction("generer_objet_${info}", '', true) |
|
| 4812 | - // @deprecated 4.1 generer_TRUC_entite |
|
| 4813 | - or $generer = charger_fonction("generer_${info}_entite", '', true) |
|
| 4814 | - ) { |
|
| 4815 | - $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4816 | - } // Sinon on prend directement le champ SQL tel quel |
|
| 4817 | - else { |
|
| 4818 | - $info_generee = ($objets[$type_objet][$id_objet][$info] ?? ''); |
|
| 4819 | - } |
|
| 4820 | - |
|
| 4821 | - // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4822 | - if (!$etoile) { |
|
| 4823 | - // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4824 | - // mais ce fonctionnement est a ameliorer ! |
|
| 4825 | - $info_generee = appliquer_traitement_champ( |
|
| 4826 | - $info_generee, |
|
| 4827 | - $info, |
|
| 4828 | - table_objet($type_objet), |
|
| 4829 | - ['id_objet' => $id_objet, 'objet' => $type_objet, ''] |
|
| 4830 | - ); |
|
| 4831 | - } |
|
| 4832 | - |
|
| 4833 | - return $info_generee; |
|
| 4739 | + static $trouver_table = null; |
|
| 4740 | + static $objets; |
|
| 4741 | + |
|
| 4742 | + // On verifie qu'on a tout ce qu'il faut |
|
| 4743 | + $id_objet = intval($id_objet); |
|
| 4744 | + if (!($id_objet and $type_objet and $info)) { |
|
| 4745 | + return ''; |
|
| 4746 | + } |
|
| 4747 | + |
|
| 4748 | + // si on a deja note que l'objet n'existe pas, ne pas aller plus loin |
|
| 4749 | + if (isset($objets[$type_objet]) and $objets[$type_objet] === false) { |
|
| 4750 | + return ''; |
|
| 4751 | + } |
|
| 4752 | + |
|
| 4753 | + // Si on demande l'url, on retourne direct la fonction |
|
| 4754 | + if ($info == 'url') { |
|
| 4755 | + return generer_objet_url($id_objet, $type_objet, ...$params); |
|
| 4756 | + } |
|
| 4757 | + |
|
| 4758 | + // Sinon on va tout chercher dans la table et on garde en memoire |
|
| 4759 | + $demande_titre = ($info === 'titre'); |
|
| 4760 | + $demande_introduction = ($info === 'introduction'); |
|
| 4761 | + |
|
| 4762 | + // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore |
|
| 4763 | + if ( |
|
| 4764 | + !isset($objets[$type_objet][$id_objet]) |
|
| 4765 | + or |
|
| 4766 | + ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre'])) |
|
| 4767 | + ) { |
|
| 4768 | + if (!$trouver_table) { |
|
| 4769 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 4770 | + } |
|
| 4771 | + $desc = $trouver_table(table_objet_sql($type_objet)); |
|
| 4772 | + if (!$desc) { |
|
| 4773 | + return $objets[$type_objet] = false; |
|
| 4774 | + } |
|
| 4775 | + |
|
| 4776 | + // Si on demande le titre, on le gere en interne |
|
| 4777 | + $champ_titre = ''; |
|
| 4778 | + if ($demande_titre) { |
|
| 4779 | + // si pas de titre declare mais champ titre, il sera peuple par le select * |
|
| 4780 | + $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4781 | + } |
|
| 4782 | + include_spip('base/abstract_sql'); |
|
| 4783 | + include_spip('base/connect_sql'); |
|
| 4784 | + $objets[$type_objet][$id_objet] = sql_fetsel( |
|
| 4785 | + '*' . $champ_titre, |
|
| 4786 | + $desc['table_sql'], |
|
| 4787 | + id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4788 | + ); |
|
| 4789 | + |
|
| 4790 | + // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci |
|
| 4791 | + $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null; |
|
| 4792 | + } |
|
| 4793 | + |
|
| 4794 | + // Pour les fonction generer_xxx, si on demande l'introduction, |
|
| 4795 | + // ajouter la longueur au début des params supplémentaires |
|
| 4796 | + if ($demande_introduction) { |
|
| 4797 | + $introduction_longueur = $objets[$type_objet]['introduction_longueur']; |
|
| 4798 | + array_unshift($params, $introduction_longueur); |
|
| 4799 | + } |
|
| 4800 | + |
|
| 4801 | + // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4802 | + if ( |
|
| 4803 | + $generer = charger_fonction("generer_${type_objet}_${info}", '', true) |
|
| 4804 | + // @deprecated 4.1 generer_TRUC_TYPE |
|
| 4805 | + or $generer = charger_fonction("generer_${info}_${type_objet}", '', true) |
|
| 4806 | + ) { |
|
| 4807 | + $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4808 | + } |
|
| 4809 | + // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee |
|
| 4810 | + elseif ( |
|
| 4811 | + $generer = charger_fonction("generer_objet_${info}", '', true) |
|
| 4812 | + // @deprecated 4.1 generer_TRUC_entite |
|
| 4813 | + or $generer = charger_fonction("generer_${info}_entite", '', true) |
|
| 4814 | + ) { |
|
| 4815 | + $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params); |
|
| 4816 | + } // Sinon on prend directement le champ SQL tel quel |
|
| 4817 | + else { |
|
| 4818 | + $info_generee = ($objets[$type_objet][$id_objet][$info] ?? ''); |
|
| 4819 | + } |
|
| 4820 | + |
|
| 4821 | + // On va ensuite appliquer les traitements automatiques si besoin |
|
| 4822 | + if (!$etoile) { |
|
| 4823 | + // FIXME: on fournit un ENV minimum avec id et type et connect='' |
|
| 4824 | + // mais ce fonctionnement est a ameliorer ! |
|
| 4825 | + $info_generee = appliquer_traitement_champ( |
|
| 4826 | + $info_generee, |
|
| 4827 | + $info, |
|
| 4828 | + table_objet($type_objet), |
|
| 4829 | + ['id_objet' => $id_objet, 'objet' => $type_objet, ''] |
|
| 4830 | + ); |
|
| 4831 | + } |
|
| 4832 | + |
|
| 4833 | + return $info_generee; |
|
| 4834 | 4834 | } |
| 4835 | 4835 | |
| 4836 | 4836 | /** |
@@ -4838,7 +4838,7 @@ discard block |
||
| 4838 | 4838 | * @see generer_objet_info |
| 4839 | 4839 | */ |
| 4840 | 4840 | function generer_info_entite($id_objet, $type_objet, $info, $etoile = '', $params = []) { |
| 4841 | - return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params); |
|
| 4841 | + return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params); |
|
| 4842 | 4842 | } |
| 4843 | 4843 | |
| 4844 | 4844 | /** |
@@ -4871,36 +4871,36 @@ discard block |
||
| 4871 | 4871 | */ |
| 4872 | 4872 | function generer_objet_introduction(int $id_objet, string $type_objet, array $ligne_sql, ?int $introduction_longueur = null, $longueur_ou_suite = null, ?string $suite = null, string $connect = ''): string { |
| 4873 | 4873 | |
| 4874 | - $descriptif = $ligne_sql['descriptif'] ?? ''; |
|
| 4875 | - $texte = $ligne_sql['texte'] ?? ''; |
|
| 4876 | - // En absence de descriptif, on se rabat sur chapo + texte |
|
| 4877 | - if (isset($ligne_sql['chapo'])) { |
|
| 4878 | - $chapo = $ligne_sql['chapo']; |
|
| 4879 | - $texte = strlen($descriptif) ? |
|
| 4880 | - '' : |
|
| 4881 | - "$chapo \n\n $texte"; |
|
| 4882 | - } |
|
| 4874 | + $descriptif = $ligne_sql['descriptif'] ?? ''; |
|
| 4875 | + $texte = $ligne_sql['texte'] ?? ''; |
|
| 4876 | + // En absence de descriptif, on se rabat sur chapo + texte |
|
| 4877 | + if (isset($ligne_sql['chapo'])) { |
|
| 4878 | + $chapo = $ligne_sql['chapo']; |
|
| 4879 | + $texte = strlen($descriptif) ? |
|
| 4880 | + '' : |
|
| 4881 | + "$chapo \n\n $texte"; |
|
| 4882 | + } |
|
| 4883 | 4883 | |
| 4884 | - // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur |
|
| 4885 | - if (!intval($longueur_ou_suite)) { |
|
| 4886 | - $longueur = intval($introduction_longueur ?: 600); |
|
| 4887 | - } else { |
|
| 4888 | - $longueur = intval($longueur_ou_suite); |
|
| 4889 | - } |
|
| 4884 | + // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur |
|
| 4885 | + if (!intval($longueur_ou_suite)) { |
|
| 4886 | + $longueur = intval($introduction_longueur ?: 600); |
|
| 4887 | + } else { |
|
| 4888 | + $longueur = intval($longueur_ou_suite); |
|
| 4889 | + } |
|
| 4890 | 4890 | |
| 4891 | - // On peut optionnellement passer la suite en 1er paramètre de la balise |
|
| 4892 | - // Ex : #INTRODUCTION{...} |
|
| 4893 | - if ( |
|
| 4894 | - is_null($suite) |
|
| 4895 | - and !intval($longueur_ou_suite) |
|
| 4896 | - ) { |
|
| 4897 | - $suite = $longueur_ou_suite; |
|
| 4898 | - } |
|
| 4891 | + // On peut optionnellement passer la suite en 1er paramètre de la balise |
|
| 4892 | + // Ex : #INTRODUCTION{...} |
|
| 4893 | + if ( |
|
| 4894 | + is_null($suite) |
|
| 4895 | + and !intval($longueur_ou_suite) |
|
| 4896 | + ) { |
|
| 4897 | + $suite = $longueur_ou_suite; |
|
| 4898 | + } |
|
| 4899 | 4899 | |
| 4900 | - $f = chercher_filtre('introduction'); |
|
| 4901 | - $introduction = $f($descriptif, $texte, $longueur, $connect, $suite); |
|
| 4900 | + $f = chercher_filtre('introduction'); |
|
| 4901 | + $introduction = $f($descriptif, $texte, $longueur, $connect, $suite); |
|
| 4902 | 4902 | |
| 4903 | - return $introduction; |
|
| 4903 | + return $introduction; |
|
| 4904 | 4904 | } |
| 4905 | 4905 | |
| 4906 | 4906 | /** |
@@ -4908,7 +4908,7 @@ discard block |
||
| 4908 | 4908 | * @see generer_objet_introduction |
| 4909 | 4909 | */ |
| 4910 | 4910 | function generer_introduction_entite($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') { |
| 4911 | - return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect); |
|
| 4911 | + return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect); |
|
| 4912 | 4912 | } |
| 4913 | 4913 | |
| 4914 | 4914 | /** |
@@ -4922,44 +4922,44 @@ discard block |
||
| 4922 | 4922 | * @return string |
| 4923 | 4923 | */ |
| 4924 | 4924 | function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') { |
| 4925 | - if (!$champ) { |
|
| 4926 | - return $texte; |
|
| 4927 | - } |
|
| 4925 | + if (!$champ) { |
|
| 4926 | + return $texte; |
|
| 4927 | + } |
|
| 4928 | 4928 | |
| 4929 | - // On charge les définitions des traitements (inc/texte et fichiers de fonctions) |
|
| 4930 | - // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4931 | - include_fichiers_fonctions(); |
|
| 4929 | + // On charge les définitions des traitements (inc/texte et fichiers de fonctions) |
|
| 4930 | + // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc) |
|
| 4931 | + include_fichiers_fonctions(); |
|
| 4932 | 4932 | |
| 4933 | - $champ = strtoupper($champ); |
|
| 4934 | - $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false; |
|
| 4935 | - if (!$traitements or !is_array($traitements)) { |
|
| 4936 | - return $texte; |
|
| 4937 | - } |
|
| 4933 | + $champ = strtoupper($champ); |
|
| 4934 | + $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false; |
|
| 4935 | + if (!$traitements or !is_array($traitements)) { |
|
| 4936 | + return $texte; |
|
| 4937 | + } |
|
| 4938 | 4938 | |
| 4939 | - $traitement = ''; |
|
| 4940 | - if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4941 | - // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4942 | - $table_objet = table_objet($table_objet); |
|
| 4943 | - if (isset($traitements[$table_objet])) { |
|
| 4944 | - $traitement = $traitements[$table_objet]; |
|
| 4945 | - } |
|
| 4946 | - } |
|
| 4947 | - if (!$traitement and isset($traitements[0])) { |
|
| 4948 | - $traitement = $traitements[0]; |
|
| 4949 | - } |
|
| 4950 | - // (sinon prendre le premier de la liste par defaut ?) |
|
| 4939 | + $traitement = ''; |
|
| 4940 | + if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) { |
|
| 4941 | + // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg |
|
| 4942 | + $table_objet = table_objet($table_objet); |
|
| 4943 | + if (isset($traitements[$table_objet])) { |
|
| 4944 | + $traitement = $traitements[$table_objet]; |
|
| 4945 | + } |
|
| 4946 | + } |
|
| 4947 | + if (!$traitement and isset($traitements[0])) { |
|
| 4948 | + $traitement = $traitements[0]; |
|
| 4949 | + } |
|
| 4950 | + // (sinon prendre le premier de la liste par defaut ?) |
|
| 4951 | 4951 | |
| 4952 | - if (!$traitement) { |
|
| 4953 | - return $texte; |
|
| 4954 | - } |
|
| 4952 | + if (!$traitement) { |
|
| 4953 | + return $texte; |
|
| 4954 | + } |
|
| 4955 | 4955 | |
| 4956 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4956 | + $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4957 | 4957 | |
| 4958 | - // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4959 | - $Pile = [0 => $env]; |
|
| 4960 | - eval("\$texte = $traitement;"); |
|
| 4958 | + // Fournir $connect et $Pile[0] au traitement si besoin |
|
| 4959 | + $Pile = [0 => $env]; |
|
| 4960 | + eval("\$texte = $traitement;"); |
|
| 4961 | 4961 | |
| 4962 | - return $texte; |
|
| 4962 | + return $texte; |
|
| 4963 | 4963 | } |
| 4964 | 4964 | |
| 4965 | 4965 | |
@@ -4973,21 +4973,21 @@ discard block |
||
| 4973 | 4973 | * @return string |
| 4974 | 4974 | */ |
| 4975 | 4975 | function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string { |
| 4976 | - include_spip('inc/liens'); |
|
| 4977 | - $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4978 | - // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4979 | - // le raccourcis n'est plus valide |
|
| 4980 | - $titre = typo($titre['titre']) ?? ''; |
|
| 4981 | - // on essaye avec generer_info_entite ? |
|
| 4982 | - if (!strlen($titre) and !$connect) { |
|
| 4983 | - $titre = generer_objet_info($id_objet, $objet, 'titre'); |
|
| 4984 | - } |
|
| 4985 | - if (!strlen($titre)) { |
|
| 4986 | - $titre = _T('info_sans_titre'); |
|
| 4987 | - } |
|
| 4988 | - $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect); |
|
| 4976 | + include_spip('inc/liens'); |
|
| 4977 | + $titre = traiter_raccourci_titre($id_objet, $objet, $connect); |
|
| 4978 | + // lorsque l'objet n'est plus declare (plugin desactive par exemple) |
|
| 4979 | + // le raccourcis n'est plus valide |
|
| 4980 | + $titre = typo($titre['titre']) ?? ''; |
|
| 4981 | + // on essaye avec generer_info_entite ? |
|
| 4982 | + if (!strlen($titre) and !$connect) { |
|
| 4983 | + $titre = generer_objet_info($id_objet, $objet, 'titre'); |
|
| 4984 | + } |
|
| 4985 | + if (!strlen($titre)) { |
|
| 4986 | + $titre = _T('info_sans_titre'); |
|
| 4987 | + } |
|
| 4988 | + $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect); |
|
| 4989 | 4989 | |
| 4990 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>'; |
|
| 4990 | + return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>'; |
|
| 4991 | 4991 | } |
| 4992 | 4992 | |
| 4993 | 4993 | /** |
@@ -4995,7 +4995,7 @@ discard block |
||
| 4995 | 4995 | * @see generer_objet_lien |
| 4996 | 4996 | */ |
| 4997 | 4997 | function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) { |
| 4998 | - return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? ''); |
|
| 4998 | + return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? ''); |
|
| 4999 | 4999 | } |
| 5000 | 5000 | |
| 5001 | 5001 | /** |
@@ -5011,15 +5011,15 @@ discard block |
||
| 5011 | 5011 | * @return string |
| 5012 | 5012 | */ |
| 5013 | 5013 | function wrap($texte, $wrap) { |
| 5014 | - $balises = extraire_balises($wrap); |
|
| 5015 | - if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 5016 | - $texte = $wrap . $texte; |
|
| 5017 | - $regs = array_reverse($regs[1]); |
|
| 5018 | - $wrap = '</' . implode('></', $regs) . '>'; |
|
| 5019 | - $texte = $texte . $wrap; |
|
| 5020 | - } |
|
| 5014 | + $balises = extraire_balises($wrap); |
|
| 5015 | + if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
|
| 5016 | + $texte = $wrap . $texte; |
|
| 5017 | + $regs = array_reverse($regs[1]); |
|
| 5018 | + $wrap = '</' . implode('></', $regs) . '>'; |
|
| 5019 | + $texte = $texte . $wrap; |
|
| 5020 | + } |
|
| 5021 | 5021 | |
| 5022 | - return $texte; |
|
| 5022 | + return $texte; |
|
| 5023 | 5023 | } |
| 5024 | 5024 | |
| 5025 | 5025 | |
@@ -5039,44 +5039,44 @@ discard block |
||
| 5039 | 5039 | * @return array|mixed|string |
| 5040 | 5040 | */ |
| 5041 | 5041 | function filtre_print_dist($u, $join = '<br />', $indent = 0) { |
| 5042 | - if (is_string($u)) { |
|
| 5043 | - $u = typo($u); |
|
| 5042 | + if (is_string($u)) { |
|
| 5043 | + $u = typo($u); |
|
| 5044 | 5044 | |
| 5045 | - return $u; |
|
| 5046 | - } |
|
| 5045 | + return $u; |
|
| 5046 | + } |
|
| 5047 | 5047 | |
| 5048 | - // caster $u en array si besoin |
|
| 5049 | - if (is_object($u)) { |
|
| 5050 | - $u = (array)$u; |
|
| 5051 | - } |
|
| 5048 | + // caster $u en array si besoin |
|
| 5049 | + if (is_object($u)) { |
|
| 5050 | + $u = (array)$u; |
|
| 5051 | + } |
|
| 5052 | 5052 | |
| 5053 | - if (is_array($u)) { |
|
| 5054 | - $out = ''; |
|
| 5055 | - // toutes les cles sont numeriques ? |
|
| 5056 | - // et aucun enfant n'est un tableau |
|
| 5057 | - // liste simple separee par des virgules |
|
| 5058 | - $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 5059 | - $array_values = array_map('is_array', $u); |
|
| 5060 | - $object_values = array_map('is_object', $u); |
|
| 5061 | - if ( |
|
| 5062 | - array_sum($numeric_keys) == count($numeric_keys) |
|
| 5063 | - and !array_sum($array_values) |
|
| 5064 | - and !array_sum($object_values) |
|
| 5065 | - ) { |
|
| 5066 | - return join(', ', array_map('filtre_print_dist', $u)); |
|
| 5067 | - } |
|
| 5053 | + if (is_array($u)) { |
|
| 5054 | + $out = ''; |
|
| 5055 | + // toutes les cles sont numeriques ? |
|
| 5056 | + // et aucun enfant n'est un tableau |
|
| 5057 | + // liste simple separee par des virgules |
|
| 5058 | + $numeric_keys = array_map('is_numeric', array_keys($u)); |
|
| 5059 | + $array_values = array_map('is_array', $u); |
|
| 5060 | + $object_values = array_map('is_object', $u); |
|
| 5061 | + if ( |
|
| 5062 | + array_sum($numeric_keys) == count($numeric_keys) |
|
| 5063 | + and !array_sum($array_values) |
|
| 5064 | + and !array_sum($object_values) |
|
| 5065 | + ) { |
|
| 5066 | + return join(', ', array_map('filtre_print_dist', $u)); |
|
| 5067 | + } |
|
| 5068 | 5068 | |
| 5069 | - // sinon on passe a la ligne et on indente |
|
| 5070 | - $i_str = str_pad('', $indent, ' '); |
|
| 5071 | - foreach ($u as $k => $v) { |
|
| 5072 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 5073 | - } |
|
| 5069 | + // sinon on passe a la ligne et on indente |
|
| 5070 | + $i_str = str_pad('', $indent, ' '); |
|
| 5071 | + foreach ($u as $k => $v) { |
|
| 5072 | + $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 5073 | + } |
|
| 5074 | 5074 | |
| 5075 | - return $out; |
|
| 5076 | - } |
|
| 5075 | + return $out; |
|
| 5076 | + } |
|
| 5077 | 5077 | |
| 5078 | - // on sait pas quoi faire... |
|
| 5079 | - return $u; |
|
| 5078 | + // on sait pas quoi faire... |
|
| 5079 | + return $u; |
|
| 5080 | 5080 | } |
| 5081 | 5081 | |
| 5082 | 5082 | |
@@ -5089,10 +5089,10 @@ discard block |
||
| 5089 | 5089 | * @return string|array |
| 5090 | 5090 | */ |
| 5091 | 5091 | function objet_info($objet, $info) { |
| 5092 | - $table = table_objet_sql($objet); |
|
| 5093 | - $infos = lister_tables_objets_sql($table); |
|
| 5092 | + $table = table_objet_sql($objet); |
|
| 5093 | + $infos = lister_tables_objets_sql($table); |
|
| 5094 | 5094 | |
| 5095 | - return ($infos[$info] ?? ''); |
|
| 5095 | + return ($infos[$info] ?? ''); |
|
| 5096 | 5096 | } |
| 5097 | 5097 | |
| 5098 | 5098 | /** |
@@ -5107,11 +5107,11 @@ discard block |
||
| 5107 | 5107 | * Texte traduit du comptage, tel que '3 articles' |
| 5108 | 5108 | */ |
| 5109 | 5109 | function objet_afficher_nb($nb, $objet) { |
| 5110 | - if (!$nb) { |
|
| 5111 | - return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 5112 | - } else { |
|
| 5113 | - return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]); |
|
| 5114 | - } |
|
| 5110 | + if (!$nb) { |
|
| 5111 | + return _T(objet_info($objet, 'info_aucun_objet')); |
|
| 5112 | + } else { |
|
| 5113 | + return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]); |
|
| 5114 | + } |
|
| 5115 | 5115 | } |
| 5116 | 5116 | |
| 5117 | 5117 | /** |
@@ -5123,11 +5123,11 @@ discard block |
||
| 5123 | 5123 | * @return string |
| 5124 | 5124 | */ |
| 5125 | 5125 | function objet_icone($objet, $taille = 24, $class = '') { |
| 5126 | - $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png'; |
|
| 5127 | - $icone = chemin_image($icone); |
|
| 5128 | - $balise_img = charger_filtre('balise_img'); |
|
| 5126 | + $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png'; |
|
| 5127 | + $icone = chemin_image($icone); |
|
| 5128 | + $balise_img = charger_filtre('balise_img'); |
|
| 5129 | 5129 | |
| 5130 | - return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : ''; |
|
| 5130 | + return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : ''; |
|
| 5131 | 5131 | } |
| 5132 | 5132 | |
| 5133 | 5133 | /** |
@@ -5148,12 +5148,12 @@ discard block |
||
| 5148 | 5148 | * @return string |
| 5149 | 5149 | */ |
| 5150 | 5150 | function objet_T($objet, $chaine, $args = [], $options = []) { |
| 5151 | - $chaine = explode(':', $chaine); |
|
| 5152 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5153 | - return $t; |
|
| 5154 | - } |
|
| 5155 | - $chaine = implode(':', $chaine); |
|
| 5156 | - return _T($chaine, $args, $options); |
|
| 5151 | + $chaine = explode(':', $chaine); |
|
| 5152 | + if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5153 | + return $t; |
|
| 5154 | + } |
|
| 5155 | + $chaine = implode(':', $chaine); |
|
| 5156 | + return _T($chaine, $args, $options); |
|
| 5157 | 5157 | } |
| 5158 | 5158 | |
| 5159 | 5159 | /** |
@@ -5167,18 +5167,18 @@ discard block |
||
| 5167 | 5167 | * @return string Code HTML |
| 5168 | 5168 | */ |
| 5169 | 5169 | function insert_head_css_conditionnel($flux) { |
| 5170 | - if ( |
|
| 5171 | - strpos($flux, '<!-- insert_head_css -->') === false |
|
| 5172 | - and $p = strpos($flux, '<!-- insert_head -->') |
|
| 5173 | - ) { |
|
| 5174 | - // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 5175 | - if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 5176 | - $p = $p1; |
|
| 5177 | - } |
|
| 5178 | - $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 5179 | - } |
|
| 5170 | + if ( |
|
| 5171 | + strpos($flux, '<!-- insert_head_css -->') === false |
|
| 5172 | + and $p = strpos($flux, '<!-- insert_head -->') |
|
| 5173 | + ) { |
|
| 5174 | + // plutot avant le premier js externe (jquery) pour etre non bloquant |
|
| 5175 | + if ($p1 = stripos($flux, '<script src=') and $p1 < $p) { |
|
| 5176 | + $p = $p1; |
|
| 5177 | + } |
|
| 5178 | + $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0); |
|
| 5179 | + } |
|
| 5180 | 5180 | |
| 5181 | - return $flux; |
|
| 5181 | + return $flux; |
|
| 5182 | 5182 | } |
| 5183 | 5183 | |
| 5184 | 5184 | /** |
@@ -5201,72 +5201,72 @@ discard block |
||
| 5201 | 5201 | * @return string |
| 5202 | 5202 | */ |
| 5203 | 5203 | function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') { |
| 5204 | - if (isset($contexte['format'])) { |
|
| 5205 | - $extension = $contexte['format']; |
|
| 5206 | - unset($contexte['format']); |
|
| 5207 | - } else { |
|
| 5208 | - $extension = 'html'; |
|
| 5209 | - if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) { |
|
| 5210 | - $extension = $m[1]; |
|
| 5211 | - } |
|
| 5212 | - } |
|
| 5213 | - // recuperer le contenu produit par le squelette |
|
| 5214 | - $options['raw'] = true; |
|
| 5215 | - $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 5216 | - |
|
| 5217 | - // calculer le nom de la css |
|
| 5218 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 5219 | - $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond)); |
|
| 5220 | - $contexte_implicite = calculer_contexte_implicite(); |
|
| 5221 | - |
|
| 5222 | - // par defaut on hash selon les contextes qui sont a priori moins variables |
|
| 5223 | - // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
|
| 5224 | - // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
|
| 5225 | - if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
|
| 5226 | - $hash = md5($contexte_implicite['host'] . '::' . $cache); |
|
| 5227 | - } |
|
| 5228 | - else { |
|
| 5229 | - unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
|
| 5230 | - ksort($contexte); |
|
| 5231 | - $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect); |
|
| 5232 | - } |
|
| 5233 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 5234 | - |
|
| 5235 | - // mettre a jour le fichier si il n'existe pas |
|
| 5236 | - // ou trop ancien |
|
| 5237 | - // le dernier fichier produit est toujours suffixe par .last |
|
| 5238 | - // et recopie sur le fichier cible uniquement si il change |
|
| 5239 | - if ( |
|
| 5240 | - !file_exists($filename) |
|
| 5241 | - or !file_exists($filename . '.last') |
|
| 5242 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified']) |
|
| 5243 | - or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 5244 | - ) { |
|
| 5245 | - $contenu = $cache['texte']; |
|
| 5246 | - // passer les urls en absolu si c'est une css |
|
| 5247 | - if ($extension == 'css') { |
|
| 5248 | - $contenu = urls_absolues_css( |
|
| 5249 | - $contenu, |
|
| 5250 | - test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond) |
|
| 5251 | - ); |
|
| 5252 | - } |
|
| 5253 | - |
|
| 5254 | - $comment = ''; |
|
| 5255 | - // ne pas insérer de commentaire sur certains formats |
|
| 5256 | - if (!in_array($extension, ['json', 'xml', 'svg'])) { |
|
| 5257 | - $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 5258 | - foreach ($contexte as $k => $v) { |
|
| 5259 | - $comment .= ",$k=$v"; |
|
| 5260 | - } |
|
| 5261 | - // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 5262 | - // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 5263 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 5264 | - } |
|
| 5265 | - // et ecrire le fichier si il change |
|
| 5266 | - ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 5267 | - } |
|
| 5268 | - |
|
| 5269 | - return timestamp($filename); |
|
| 5204 | + if (isset($contexte['format'])) { |
|
| 5205 | + $extension = $contexte['format']; |
|
| 5206 | + unset($contexte['format']); |
|
| 5207 | + } else { |
|
| 5208 | + $extension = 'html'; |
|
| 5209 | + if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) { |
|
| 5210 | + $extension = $m[1]; |
|
| 5211 | + } |
|
| 5212 | + } |
|
| 5213 | + // recuperer le contenu produit par le squelette |
|
| 5214 | + $options['raw'] = true; |
|
| 5215 | + $cache = recuperer_fond($fond, $contexte, $options, $connect); |
|
| 5216 | + |
|
| 5217 | + // calculer le nom de la css |
|
| 5218 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 5219 | + $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond)); |
|
| 5220 | + $contexte_implicite = calculer_contexte_implicite(); |
|
| 5221 | + |
|
| 5222 | + // par defaut on hash selon les contextes qui sont a priori moins variables |
|
| 5223 | + // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
|
| 5224 | + // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
|
| 5225 | + if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
|
| 5226 | + $hash = md5($contexte_implicite['host'] . '::' . $cache); |
|
| 5227 | + } |
|
| 5228 | + else { |
|
| 5229 | + unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
|
| 5230 | + ksort($contexte); |
|
| 5231 | + $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect); |
|
| 5232 | + } |
|
| 5233 | + $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 5234 | + |
|
| 5235 | + // mettre a jour le fichier si il n'existe pas |
|
| 5236 | + // ou trop ancien |
|
| 5237 | + // le dernier fichier produit est toujours suffixe par .last |
|
| 5238 | + // et recopie sur le fichier cible uniquement si il change |
|
| 5239 | + if ( |
|
| 5240 | + !file_exists($filename) |
|
| 5241 | + or !file_exists($filename . '.last') |
|
| 5242 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified']) |
|
| 5243 | + or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 5244 | + ) { |
|
| 5245 | + $contenu = $cache['texte']; |
|
| 5246 | + // passer les urls en absolu si c'est une css |
|
| 5247 | + if ($extension == 'css') { |
|
| 5248 | + $contenu = urls_absolues_css( |
|
| 5249 | + $contenu, |
|
| 5250 | + test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond) |
|
| 5251 | + ); |
|
| 5252 | + } |
|
| 5253 | + |
|
| 5254 | + $comment = ''; |
|
| 5255 | + // ne pas insérer de commentaire sur certains formats |
|
| 5256 | + if (!in_array($extension, ['json', 'xml', 'svg'])) { |
|
| 5257 | + $comment = "/* #PRODUIRE{fond=$fond"; |
|
| 5258 | + foreach ($contexte as $k => $v) { |
|
| 5259 | + $comment .= ",$k=$v"; |
|
| 5260 | + } |
|
| 5261 | + // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
|
| 5262 | + // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
|
| 5263 | + $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 5264 | + } |
|
| 5265 | + // et ecrire le fichier si il change |
|
| 5266 | + ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 5267 | + } |
|
| 5268 | + |
|
| 5269 | + return timestamp($filename); |
|
| 5270 | 5270 | } |
| 5271 | 5271 | |
| 5272 | 5272 | /** |
@@ -5279,15 +5279,15 @@ discard block |
||
| 5279 | 5279 | * $fichier auquel on a ajouté le timestamp |
| 5280 | 5280 | */ |
| 5281 | 5281 | function timestamp($fichier) { |
| 5282 | - if ( |
|
| 5283 | - !$fichier |
|
| 5284 | - or !file_exists($fichier) |
|
| 5285 | - or !$m = filemtime($fichier) |
|
| 5286 | - ) { |
|
| 5287 | - return $fichier; |
|
| 5288 | - } |
|
| 5282 | + if ( |
|
| 5283 | + !$fichier |
|
| 5284 | + or !file_exists($fichier) |
|
| 5285 | + or !$m = filemtime($fichier) |
|
| 5286 | + ) { |
|
| 5287 | + return $fichier; |
|
| 5288 | + } |
|
| 5289 | 5289 | |
| 5290 | - return "$fichier?$m"; |
|
| 5290 | + return "$fichier?$m"; |
|
| 5291 | 5291 | } |
| 5292 | 5292 | |
| 5293 | 5293 | /** |
@@ -5297,11 +5297,11 @@ discard block |
||
| 5297 | 5297 | * @return string |
| 5298 | 5298 | */ |
| 5299 | 5299 | function supprimer_timestamp($url) { |
| 5300 | - if (strpos($url, '?') === false) { |
|
| 5301 | - return $url; |
|
| 5302 | - } |
|
| 5300 | + if (strpos($url, '?') === false) { |
|
| 5301 | + return $url; |
|
| 5302 | + } |
|
| 5303 | 5303 | |
| 5304 | - return preg_replace(',\?[[:digit:]]+$,', '', $url); |
|
| 5304 | + return preg_replace(',\?[[:digit:]]+$,', '', $url); |
|
| 5305 | 5305 | } |
| 5306 | 5306 | |
| 5307 | 5307 | /** |
@@ -5316,9 +5316,9 @@ discard block |
||
| 5316 | 5316 | * @return string |
| 5317 | 5317 | */ |
| 5318 | 5318 | function filtre_nettoyer_titre_email_dist($titre) { |
| 5319 | - include_spip('inc/envoyer_mail'); |
|
| 5319 | + include_spip('inc/envoyer_mail'); |
|
| 5320 | 5320 | |
| 5321 | - return nettoyer_titre_email($titre); |
|
| 5321 | + return nettoyer_titre_email($titre); |
|
| 5322 | 5322 | } |
| 5323 | 5323 | |
| 5324 | 5324 | /** |
@@ -5340,27 +5340,27 @@ discard block |
||
| 5340 | 5340 | * @return string |
| 5341 | 5341 | */ |
| 5342 | 5342 | function filtre_chercher_rubrique_dist( |
| 5343 | - $titre, |
|
| 5344 | - $id_objet, |
|
| 5345 | - $id_parent, |
|
| 5346 | - $objet, |
|
| 5347 | - $id_secteur, |
|
| 5348 | - $restreint, |
|
| 5349 | - $actionable = false, |
|
| 5350 | - $retour_sans_cadre = false |
|
| 5343 | + $titre, |
|
| 5344 | + $id_objet, |
|
| 5345 | + $id_parent, |
|
| 5346 | + $objet, |
|
| 5347 | + $id_secteur, |
|
| 5348 | + $restreint, |
|
| 5349 | + $actionable = false, |
|
| 5350 | + $retour_sans_cadre = false |
|
| 5351 | 5351 | ) { |
| 5352 | - include_spip('inc/filtres_ecrire'); |
|
| 5352 | + include_spip('inc/filtres_ecrire'); |
|
| 5353 | 5353 | |
| 5354 | - return chercher_rubrique( |
|
| 5355 | - $titre, |
|
| 5356 | - $id_objet, |
|
| 5357 | - $id_parent, |
|
| 5358 | - $objet, |
|
| 5359 | - $id_secteur, |
|
| 5360 | - $restreint, |
|
| 5361 | - $actionable, |
|
| 5362 | - $retour_sans_cadre |
|
| 5363 | - ); |
|
| 5354 | + return chercher_rubrique( |
|
| 5355 | + $titre, |
|
| 5356 | + $id_objet, |
|
| 5357 | + $id_parent, |
|
| 5358 | + $objet, |
|
| 5359 | + $id_secteur, |
|
| 5360 | + $restreint, |
|
| 5361 | + $actionable, |
|
| 5362 | + $retour_sans_cadre |
|
| 5363 | + ); |
|
| 5364 | 5364 | } |
| 5365 | 5365 | |
| 5366 | 5366 | /** |
@@ -5389,56 +5389,56 @@ discard block |
||
| 5389 | 5389 | * Chaîne vide si l'accès est autorisé |
| 5390 | 5390 | */ |
| 5391 | 5391 | function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) { |
| 5392 | - if ($ok) { |
|
| 5393 | - return ''; |
|
| 5394 | - } |
|
| 5395 | - |
|
| 5396 | - // Vider tous les tampons |
|
| 5397 | - $level = @ob_get_level(); |
|
| 5398 | - while ($level--) { |
|
| 5399 | - @ob_end_clean(); |
|
| 5400 | - } |
|
| 5401 | - |
|
| 5402 | - include_spip('inc/headers'); |
|
| 5403 | - |
|
| 5404 | - // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 5405 | - if ($url) { |
|
| 5406 | - redirige_par_entete($url, '', $statut); |
|
| 5407 | - } |
|
| 5408 | - |
|
| 5409 | - // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 5410 | - if (!is_numeric($statut) and is_null($message)) { |
|
| 5411 | - $message = $statut; |
|
| 5412 | - $statut = 0; |
|
| 5413 | - } |
|
| 5414 | - if (!$message) { |
|
| 5415 | - $message = ''; |
|
| 5416 | - } |
|
| 5417 | - $statut = intval($statut); |
|
| 5418 | - |
|
| 5419 | - // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 5420 | - if (test_espace_prive()) { |
|
| 5421 | - if (!$statut or !in_array($statut, [404, 403])) { |
|
| 5422 | - $statut = 403; |
|
| 5423 | - } |
|
| 5424 | - http_response_code(403); |
|
| 5425 | - $echec = charger_fonction('403', 'exec'); |
|
| 5426 | - $echec($message); |
|
| 5427 | - } else { |
|
| 5428 | - // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 5429 | - if (!$statut) { |
|
| 5430 | - $statut = 404; |
|
| 5431 | - } |
|
| 5432 | - // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 5433 | - http_response_code($statut); |
|
| 5434 | - // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 5435 | - if ($statut >= 400) { |
|
| 5436 | - echo recuperer_fond("$statut", ['erreur' => $message]); |
|
| 5437 | - } |
|
| 5438 | - } |
|
| 5439 | - |
|
| 5440 | - |
|
| 5441 | - exit; |
|
| 5392 | + if ($ok) { |
|
| 5393 | + return ''; |
|
| 5394 | + } |
|
| 5395 | + |
|
| 5396 | + // Vider tous les tampons |
|
| 5397 | + $level = @ob_get_level(); |
|
| 5398 | + while ($level--) { |
|
| 5399 | + @ob_end_clean(); |
|
| 5400 | + } |
|
| 5401 | + |
|
| 5402 | + include_spip('inc/headers'); |
|
| 5403 | + |
|
| 5404 | + // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut) |
|
| 5405 | + if ($url) { |
|
| 5406 | + redirige_par_entete($url, '', $statut); |
|
| 5407 | + } |
|
| 5408 | + |
|
| 5409 | + // ecriture simplifiee avec message en 3eme argument (= statut 403) |
|
| 5410 | + if (!is_numeric($statut) and is_null($message)) { |
|
| 5411 | + $message = $statut; |
|
| 5412 | + $statut = 0; |
|
| 5413 | + } |
|
| 5414 | + if (!$message) { |
|
| 5415 | + $message = ''; |
|
| 5416 | + } |
|
| 5417 | + $statut = intval($statut); |
|
| 5418 | + |
|
| 5419 | + // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404 |
|
| 5420 | + if (test_espace_prive()) { |
|
| 5421 | + if (!$statut or !in_array($statut, [404, 403])) { |
|
| 5422 | + $statut = 403; |
|
| 5423 | + } |
|
| 5424 | + http_response_code(403); |
|
| 5425 | + $echec = charger_fonction('403', 'exec'); |
|
| 5426 | + $echec($message); |
|
| 5427 | + } else { |
|
| 5428 | + // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement |
|
| 5429 | + if (!$statut) { |
|
| 5430 | + $statut = 404; |
|
| 5431 | + } |
|
| 5432 | + // Dans tous les cas on modifie l'entité avec ce qui est demandé |
|
| 5433 | + http_response_code($statut); |
|
| 5434 | + // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom |
|
| 5435 | + if ($statut >= 400) { |
|
| 5436 | + echo recuperer_fond("$statut", ['erreur' => $message]); |
|
| 5437 | + } |
|
| 5438 | + } |
|
| 5439 | + |
|
| 5440 | + |
|
| 5441 | + exit; |
|
| 5442 | 5442 | } |
| 5443 | 5443 | |
| 5444 | 5444 | /** |
@@ -5449,11 +5449,11 @@ discard block |
||
| 5449 | 5449 | * @return string |
| 5450 | 5450 | */ |
| 5451 | 5451 | function filtre_compacte_dist($source, $format = null) { |
| 5452 | - if (function_exists('minifier')) { |
|
| 5453 | - return minifier($source, $format); |
|
| 5454 | - } |
|
| 5452 | + if (function_exists('minifier')) { |
|
| 5453 | + return minifier($source, $format); |
|
| 5454 | + } |
|
| 5455 | 5455 | |
| 5456 | - return $source; |
|
| 5456 | + return $source; |
|
| 5457 | 5457 | } |
| 5458 | 5458 | |
| 5459 | 5459 | |
@@ -5465,31 +5465,31 @@ discard block |
||
| 5465 | 5465 | * @return string |
| 5466 | 5466 | */ |
| 5467 | 5467 | function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) { |
| 5468 | - $l = strlen($passe); |
|
| 5469 | - |
|
| 5470 | - if ($l <= 8 or !$afficher_partiellement) { |
|
| 5471 | - if (!$l) { |
|
| 5472 | - return ''; // montrer qu'il y a pas de mot de passe si il y en a pas |
|
| 5473 | - } |
|
| 5474 | - return str_pad('', $afficher_partiellement ? $l : 16, '*'); |
|
| 5475 | - } |
|
| 5476 | - |
|
| 5477 | - if (is_null($portion_pourcent)) { |
|
| 5478 | - if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) { |
|
| 5479 | - define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20% |
|
| 5480 | - } |
|
| 5481 | - $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT; |
|
| 5482 | - } |
|
| 5483 | - if ($portion_pourcent >= 100) { |
|
| 5484 | - return $passe; |
|
| 5485 | - } |
|
| 5486 | - $e = intval(ceil($l * $portion_pourcent / 100 / 2)); |
|
| 5487 | - $e = max($e, 0); |
|
| 5488 | - $mid = str_pad('', $l - 2 * $e, '*'); |
|
| 5489 | - if ($e > 0 and strlen($mid) > 8) { |
|
| 5490 | - $mid = '***...***'; |
|
| 5491 | - } |
|
| 5492 | - return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : ''); |
|
| 5468 | + $l = strlen($passe); |
|
| 5469 | + |
|
| 5470 | + if ($l <= 8 or !$afficher_partiellement) { |
|
| 5471 | + if (!$l) { |
|
| 5472 | + return ''; // montrer qu'il y a pas de mot de passe si il y en a pas |
|
| 5473 | + } |
|
| 5474 | + return str_pad('', $afficher_partiellement ? $l : 16, '*'); |
|
| 5475 | + } |
|
| 5476 | + |
|
| 5477 | + if (is_null($portion_pourcent)) { |
|
| 5478 | + if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) { |
|
| 5479 | + define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20% |
|
| 5480 | + } |
|
| 5481 | + $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT; |
|
| 5482 | + } |
|
| 5483 | + if ($portion_pourcent >= 100) { |
|
| 5484 | + return $passe; |
|
| 5485 | + } |
|
| 5486 | + $e = intval(ceil($l * $portion_pourcent / 100 / 2)); |
|
| 5487 | + $e = max($e, 0); |
|
| 5488 | + $mid = str_pad('', $l - 2 * $e, '*'); |
|
| 5489 | + if ($e > 0 and strlen($mid) > 8) { |
|
| 5490 | + $mid = '***...***'; |
|
| 5491 | + } |
|
| 5492 | + return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : ''); |
|
| 5493 | 5493 | } |
| 5494 | 5494 | |
| 5495 | 5495 | |
@@ -5510,64 +5510,64 @@ discard block |
||
| 5510 | 5510 | */ |
| 5511 | 5511 | function identifiant_slug($texte, $type = '', $options = []) { |
| 5512 | 5512 | |
| 5513 | - $original = $texte; |
|
| 5514 | - $separateur = ($options['separateur'] ?? '_'); |
|
| 5515 | - $longueur_maxi = ($options['longueur_maxi'] ?? 60); |
|
| 5516 | - $longueur_mini = ($options['longueur_mini'] ?? 0); |
|
| 5513 | + $original = $texte; |
|
| 5514 | + $separateur = ($options['separateur'] ?? '_'); |
|
| 5515 | + $longueur_maxi = ($options['longueur_maxi'] ?? 60); |
|
| 5516 | + $longueur_mini = ($options['longueur_mini'] ?? 0); |
|
| 5517 | 5517 | |
| 5518 | - if (!function_exists('translitteration')) { |
|
| 5519 | - include_spip('inc/charsets'); |
|
| 5520 | - } |
|
| 5518 | + if (!function_exists('translitteration')) { |
|
| 5519 | + include_spip('inc/charsets'); |
|
| 5520 | + } |
|
| 5521 | 5521 | |
| 5522 | - // pas de balise html |
|
| 5523 | - if (strpos($texte, '<') !== false) { |
|
| 5524 | - $texte = strip_tags($texte); |
|
| 5525 | - } |
|
| 5526 | - if (strpos($texte, '&') !== false) { |
|
| 5527 | - $texte = unicode2charset($texte); |
|
| 5528 | - } |
|
| 5529 | - // On enlève les espaces indésirables |
|
| 5530 | - $texte = trim($texte); |
|
| 5522 | + // pas de balise html |
|
| 5523 | + if (strpos($texte, '<') !== false) { |
|
| 5524 | + $texte = strip_tags($texte); |
|
| 5525 | + } |
|
| 5526 | + if (strpos($texte, '&') !== false) { |
|
| 5527 | + $texte = unicode2charset($texte); |
|
| 5528 | + } |
|
| 5529 | + // On enlève les espaces indésirables |
|
| 5530 | + $texte = trim($texte); |
|
| 5531 | 5531 | |
| 5532 | - // On enlève les accents et cie |
|
| 5533 | - $texte = translitteration($texte); |
|
| 5532 | + // On enlève les accents et cie |
|
| 5533 | + $texte = translitteration($texte); |
|
| 5534 | 5534 | |
| 5535 | - // On remplace tout ce qui n'est pas un mot par un séparateur |
|
| 5536 | - $texte = preg_replace(',[\W_]+,ms', $separateur, $texte); |
|
| 5535 | + // On remplace tout ce qui n'est pas un mot par un séparateur |
|
| 5536 | + $texte = preg_replace(',[\W_]+,ms', $separateur, $texte); |
|
| 5537 | 5537 | |
| 5538 | - // nettoyer les doubles occurences du separateur si besoin |
|
| 5539 | - while (strpos($texte, (string) "$separateur$separateur") !== false) { |
|
| 5540 | - $texte = str_replace("$separateur$separateur", $separateur, $texte); |
|
| 5541 | - } |
|
| 5538 | + // nettoyer les doubles occurences du separateur si besoin |
|
| 5539 | + while (strpos($texte, (string) "$separateur$separateur") !== false) { |
|
| 5540 | + $texte = str_replace("$separateur$separateur", $separateur, $texte); |
|
| 5541 | + } |
|
| 5542 | 5542 | |
| 5543 | - // pas de separateur au debut ni a la fin |
|
| 5544 | - $texte = trim($texte, $separateur); |
|
| 5543 | + // pas de separateur au debut ni a la fin |
|
| 5544 | + $texte = trim($texte, $separateur); |
|
| 5545 | 5545 | |
| 5546 | - // en minuscules |
|
| 5547 | - $texte = strtolower($texte); |
|
| 5546 | + // en minuscules |
|
| 5547 | + $texte = strtolower($texte); |
|
| 5548 | 5548 | |
| 5549 | - switch ($type) { |
|
| 5550 | - case 'class': |
|
| 5551 | - case 'id': |
|
| 5552 | - case 'anchor': |
|
| 5553 | - if (preg_match(',^\d,', $texte)) { |
|
| 5554 | - $texte = substr($type, 0, 1) . $texte; |
|
| 5555 | - } |
|
| 5556 | - } |
|
| 5549 | + switch ($type) { |
|
| 5550 | + case 'class': |
|
| 5551 | + case 'id': |
|
| 5552 | + case 'anchor': |
|
| 5553 | + if (preg_match(',^\d,', $texte)) { |
|
| 5554 | + $texte = substr($type, 0, 1) . $texte; |
|
| 5555 | + } |
|
| 5556 | + } |
|
| 5557 | 5557 | |
| 5558 | - if (strlen($texte) > $longueur_maxi) { |
|
| 5559 | - $texte = substr($texte, 0, $longueur_maxi); |
|
| 5560 | - } |
|
| 5558 | + if (strlen($texte) > $longueur_maxi) { |
|
| 5559 | + $texte = substr($texte, 0, $longueur_maxi); |
|
| 5560 | + } |
|
| 5561 | 5561 | |
| 5562 | - if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
|
| 5563 | - if (preg_match(',^\d,', $texte)) { |
|
| 5564 | - $texte = ($type ? substr($type, 0, 1) : 's') . $texte; |
|
| 5565 | - } |
|
| 5566 | - $texte .= $separateur . md5($original); |
|
| 5567 | - $texte = substr($texte, 0, $longueur_mini); |
|
| 5568 | - } |
|
| 5562 | + if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
|
| 5563 | + if (preg_match(',^\d,', $texte)) { |
|
| 5564 | + $texte = ($type ? substr($type, 0, 1) : 's') . $texte; |
|
| 5565 | + } |
|
| 5566 | + $texte .= $separateur . md5($original); |
|
| 5567 | + $texte = substr($texte, 0, $longueur_mini); |
|
| 5568 | + } |
|
| 5569 | 5569 | |
| 5570 | - return $texte; |
|
| 5570 | + return $texte; |
|
| 5571 | 5571 | } |
| 5572 | 5572 | |
| 5573 | 5573 | |
@@ -5588,11 +5588,11 @@ discard block |
||
| 5588 | 5588 | * @exemple `<:info_maximum|label_nettoyer:>` |
| 5589 | 5589 | */ |
| 5590 | 5590 | function label_nettoyer(string $text, bool $ucfirst = true): string { |
| 5591 | - $label = preg_replace('#([\s:]|\ )+$#u', '', $text); |
|
| 5592 | - if ($ucfirst) { |
|
| 5593 | - $label = spip_ucfirst($label); |
|
| 5594 | - } |
|
| 5595 | - return $label; |
|
| 5591 | + $label = preg_replace('#([\s:]|\ )+$#u', '', $text); |
|
| 5592 | + if ($ucfirst) { |
|
| 5593 | + $label = spip_ucfirst($label); |
|
| 5594 | + } |
|
| 5595 | + return $label; |
|
| 5596 | 5596 | } |
| 5597 | 5597 | |
| 5598 | 5598 | /** |
@@ -5605,8 +5605,8 @@ discard block |
||
| 5605 | 5605 | * @exemple `<:info_maximum|label_ponctuer:>` |
| 5606 | 5606 | */ |
| 5607 | 5607 | function label_ponctuer(string $text, bool $ucfirst = true): string { |
| 5608 | - $label = label_nettoyer($text, $ucfirst); |
|
| 5609 | - return _T('label_ponctuer', ['label' => $label]); |
|
| 5608 | + $label = label_nettoyer($text, $ucfirst); |
|
| 5609 | + return _T('label_ponctuer', ['label' => $label]); |
|
| 5610 | 5610 | } |
| 5611 | 5611 | |
| 5612 | 5612 | |
@@ -5619,19 +5619,19 @@ discard block |
||
| 5619 | 5619 | * @return array |
| 5620 | 5620 | */ |
| 5621 | 5621 | function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) { |
| 5622 | - if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) { |
|
| 5623 | - return []; |
|
| 5624 | - } |
|
| 5622 | + if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) { |
|
| 5623 | + return []; |
|
| 5624 | + } |
|
| 5625 | 5625 | |
| 5626 | - // compatibilite signature inversee |
|
| 5627 | - if (is_numeric($objet) and !is_numeric($id_objet)) { |
|
| 5628 | - [$objet, $id_objet] = [$id_objet, $objet]; |
|
| 5629 | - } |
|
| 5626 | + // compatibilite signature inversee |
|
| 5627 | + if (is_numeric($objet) and !is_numeric($id_objet)) { |
|
| 5628 | + [$objet, $id_objet] = [$id_objet, $objet]; |
|
| 5629 | + } |
|
| 5630 | 5630 | |
| 5631 | - if (!function_exists($fonction)) { |
|
| 5632 | - include_spip('base/objets'); |
|
| 5633 | - } |
|
| 5634 | - return $fonction($objet, $id_objet); |
|
| 5631 | + if (!function_exists($fonction)) { |
|
| 5632 | + include_spip('base/objets'); |
|
| 5633 | + } |
|
| 5634 | + return $fonction($objet, $id_objet); |
|
| 5635 | 5635 | } |
| 5636 | 5636 | |
| 5637 | 5637 | |
@@ -5646,7 +5646,7 @@ discard block |
||
| 5646 | 5646 | * @return array |
| 5647 | 5647 | */ |
| 5648 | 5648 | function filtre_objet_lister_parents_dist($objet, $id_objet) { |
| 5649 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents'); |
|
| 5649 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents'); |
|
| 5650 | 5650 | } |
| 5651 | 5651 | |
| 5652 | 5652 | /** |
@@ -5660,7 +5660,7 @@ discard block |
||
| 5660 | 5660 | * @return array |
| 5661 | 5661 | */ |
| 5662 | 5662 | function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) { |
| 5663 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type'); |
|
| 5663 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type'); |
|
| 5664 | 5664 | } |
| 5665 | 5665 | |
| 5666 | 5666 | /** |
@@ -5674,7 +5674,7 @@ discard block |
||
| 5674 | 5674 | * @return array |
| 5675 | 5675 | */ |
| 5676 | 5676 | function filtre_objet_lister_enfants_dist($objet, $id_objet) { |
| 5677 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants'); |
|
| 5677 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants'); |
|
| 5678 | 5678 | } |
| 5679 | 5679 | |
| 5680 | 5680 | /** |
@@ -5688,5 +5688,5 @@ discard block |
||
| 5688 | 5688 | * @return array |
| 5689 | 5689 | */ |
| 5690 | 5690 | function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) { |
| 5691 | - return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type'); |
|
| 5691 | + return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type'); |
|
| 5692 | 5692 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | include_fichiers_fonctions(); |
| 99 | - foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) { |
|
| 99 | + foreach (['filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc] as $f) { |
|
| 100 | 100 | trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels |
| 101 | 101 | if (is_callable($f)) { |
| 102 | 102 | return $f; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // affichage "GIT [master: abcdef]" |
| 235 | 235 | $commit = $desc['commit_short'] ?? $desc['commit']; |
| 236 | 236 | if ($desc['branch']) { |
| 237 | - $commit = $desc['branch'] . ': ' . $commit; |
|
| 237 | + $commit = $desc['branch'].': '.$commit; |
|
| 238 | 238 | } |
| 239 | 239 | return "{$desc['vcs']} [$commit]"; |
| 240 | 240 | } |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | // version installee par GIT |
| 256 | - if (lire_fichier($dir . '/.git/HEAD', $c)) { |
|
| 256 | + if (lire_fichier($dir.'/.git/HEAD', $c)) { |
|
| 257 | 257 | $currentHead = trim(substr($c, 4)); |
| 258 | - if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) { |
|
| 258 | + if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) { |
|
| 259 | 259 | return [ |
| 260 | 260 | 'vcs' => 'GIT', |
| 261 | 261 | 'branch' => basename($currentHead), |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | $dir = '.'; |
| 283 | 283 | } |
| 284 | 284 | // version installee par SVN |
| 285 | - if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 286 | - $db = new SQLite3($dir . '/.svn/wc.db'); |
|
| 285 | + if (file_exists($dir.'/.svn/wc.db') && class_exists(\SQLite3::class)) { |
|
| 286 | + $db = new SQLite3($dir.'/.svn/wc.db'); |
|
| 287 | 287 | $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1'); |
| 288 | 288 | if ($result) { |
| 289 | 289 | $row = $result->fetchArray(); |
@@ -301,12 +301,12 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images |
| 303 | 303 | // et laisser passer les fonctions personnelles baptisees image_... |
| 304 | -$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php'; |
|
| 305 | -$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php'; |
|
| 306 | -$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php'; |
|
| 307 | -$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php'; |
|
| 308 | -$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php'; |
|
| 309 | -$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php'; |
|
| 304 | +$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php'; |
|
| 305 | +$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php'; |
|
| 306 | +$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php'; |
|
| 307 | +$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php'; |
|
| 308 | +$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php'; |
|
| 309 | +$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php'; |
|
| 310 | 310 | |
| 311 | 311 | $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php'; |
| 312 | 312 | $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php'; |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function filtre_debug($val, $key = null) { |
| 467 | 467 | $debug = ( |
| 468 | - is_null($key) ? '' : (var_export($key, true) . ' = ') |
|
| 469 | - ) . var_export($val, true); |
|
| 468 | + is_null($key) ? '' : (var_export($key, true).' = ') |
|
| 469 | + ).var_export($val, true); |
|
| 470 | 470 | |
| 471 | 471 | include_spip('inc/autoriser'); |
| 472 | 472 | if (autoriser('webmestre')) { |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | $is_file = false; |
| 523 | 523 | } |
| 524 | 524 | if ($is_file) { |
| 525 | - $is_local_file = function ($path) { |
|
| 525 | + $is_local_file = function($path) { |
|
| 526 | 526 | if (strpos($path, '?') !== false) { |
| 527 | 527 | $path = supprimer_timestamp($path); |
| 528 | 528 | // remove ?24px added by find_in_theme on .svg files |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | if ($mouseover = extraire_attribut($reduit, 'onmouseover')) { |
| 572 | 572 | if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) { |
| 573 | 573 | $srcover = $match[1]; |
| 574 | - $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args); |
|
| 574 | + $srcover_filter = $filtre("<img src='".$match[1]."' />", ...$args); |
|
| 575 | 575 | $srcover_filter = extraire_attribut($srcover_filter, 'src'); |
| 576 | 576 | $reduit = str_replace($srcover, $srcover_filter, $reduit); |
| 577 | 577 | } |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | // " -> " et tout ce genre de choses |
| 973 | 973 | $u = $GLOBALS['meta']['pcre_u']; |
| 974 | 974 | $texte = str_replace(' ', ' ', $texte); |
| 975 | - $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte); |
|
| 975 | + $texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte); |
|
| 976 | 976 | // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal |
| 977 | 977 | $texte = entites_html($texte, false, false); |
| 978 | 978 | // mais bien echapper les double quotes ! |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | **/ |
| 1033 | 1033 | function supprimer_numero($texte) { |
| 1034 | 1034 | return preg_replace( |
| 1035 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1035 | + ',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S', |
|
| 1036 | 1036 | '', |
| 1037 | 1037 | $texte |
| 1038 | 1038 | ); |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | function recuperer_numero($texte) { |
| 1061 | 1061 | if ( |
| 1062 | 1062 | preg_match( |
| 1063 | - ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S', |
|
| 1063 | + ',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S', |
|
| 1064 | 1064 | $texte, |
| 1065 | 1065 | $regs |
| 1066 | 1066 | ) |
@@ -1151,8 +1151,8 @@ discard block |
||
| 1151 | 1151 | **/ |
| 1152 | 1152 | function textebrut($texte) { |
| 1153 | 1153 | $u = $GLOBALS['meta']['pcre_u']; |
| 1154 | - $texte = preg_replace('/\s+/S' . $u, ' ', $texte); |
|
| 1155 | - $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte); |
|
| 1154 | + $texte = preg_replace('/\s+/S'.$u, ' ', $texte); |
|
| 1155 | + $texte = preg_replace('/<(p|br)( [^>]*)?'.'>/iS', "\n\n", $texte); |
|
| 1156 | 1156 | $texte = preg_replace("/^\n+/", '', $texte); |
| 1157 | 1157 | $texte = preg_replace("/\n+$/", '', $texte); |
| 1158 | 1158 | $texte = preg_replace("/\n +/", "\n", $texte); |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | ) |
| 1187 | 1187 | ) { |
| 1188 | 1188 | foreach ($liens[0] as $a) { |
| 1189 | - $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel'); |
|
| 1189 | + $rel = 'noopener noreferrer '.extraire_attribut($a, 'rel'); |
|
| 1190 | 1190 | $ablank = inserer_attribut($a, 'rel', $rel); |
| 1191 | 1191 | $ablank = inserer_attribut($ablank, 'target', '_blank'); |
| 1192 | 1192 | $texte = str_replace($a, $ablank, $texte); |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | foreach ($regs[0] as $a) { |
| 1212 | 1212 | $rel = extraire_attribut($a, 'rel') ?? ''; |
| 1213 | 1213 | if (strpos($rel, 'nofollow') === false) { |
| 1214 | - $rel = 'nofollow' . ($rel ? " $rel" : ''); |
|
| 1214 | + $rel = 'nofollow'.($rel ? " $rel" : ''); |
|
| 1215 | 1215 | $anofollow = inserer_attribut($a, 'rel', $rel); |
| 1216 | 1216 | $texte = str_replace($a, $anofollow, $texte); |
| 1217 | 1217 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | $u = $GLOBALS['meta']['pcre_u']; |
| 1241 | 1241 | $texte = preg_replace('@</p>@iS', "\n", $texte); |
| 1242 | 1242 | $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte); |
| 1243 | - $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte); |
|
| 1243 | + $texte = preg_replace('@^\s*<br />@S'.$u, '', $texte); |
|
| 1244 | 1244 | |
| 1245 | 1245 | return $texte; |
| 1246 | 1246 | } |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | return $texte; |
| 1272 | 1272 | } |
| 1273 | 1273 | include_spip('inc/texte'); |
| 1274 | - $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ? |
|
| 1274 | + $tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ? |
|
| 1275 | 1275 | 'div' : 'span'; |
| 1276 | 1276 | |
| 1277 | 1277 | return "<$tag style='word-wrap:break-word;'>$texte</$tag>"; |
@@ -1383,7 +1383,7 @@ discard block |
||
| 1383 | 1383 | } |
| 1384 | 1384 | $u = $GLOBALS['meta']['pcre_u']; |
| 1385 | 1385 | if ($textebrut) { |
| 1386 | - $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); |
|
| 1386 | + $texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte)); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | $texte = texte_backend($texte); |
| 1389 | 1389 | $texte = str_replace(["'", '"'], [''', '"'], $texte); |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | # un message pour abs_url |
| 1419 | 1419 | $GLOBALS['mode_abs_url'] = 'url'; |
| 1420 | 1420 | $url = trim($url); |
| 1421 | - $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS'; |
|
| 1421 | + $r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS'; |
|
| 1422 | 1422 | |
| 1423 | 1423 | return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url); |
| 1424 | 1424 | } |
@@ -1618,14 +1618,14 @@ discard block |
||
| 1618 | 1618 | if (strpos($texte, '<') !== false) { |
| 1619 | 1619 | include_spip('inc/lien'); |
| 1620 | 1620 | if (defined('_PREG_MODELE')) { |
| 1621 | - $preg_modeles = '@' . _PREG_MODELE . '@imsS'; |
|
| 1621 | + $preg_modeles = '@'._PREG_MODELE.'@imsS'; |
|
| 1622 | 1622 | $texte = echappe_html($texte, '', true, $preg_modeles); |
| 1623 | 1623 | } |
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | 1626 | $debut = ''; |
| 1627 | 1627 | $suite = $texte; |
| 1628 | - while ($t = strpos('-' . $suite, "\n", 1)) { |
|
| 1628 | + while ($t = strpos('-'.$suite, "\n", 1)) { |
|
| 1629 | 1629 | $debut .= substr($suite, 0, $t - 1); |
| 1630 | 1630 | $suite = substr($suite, $t); |
| 1631 | 1631 | $car = substr($suite, 0, 1); |
@@ -1643,11 +1643,11 @@ discard block |
||
| 1643 | 1643 | $suite = substr($suite, strlen($regs[0])); |
| 1644 | 1644 | } |
| 1645 | 1645 | } |
| 1646 | - $texte = $debut . $suite; |
|
| 1646 | + $texte = $debut.$suite; |
|
| 1647 | 1647 | |
| 1648 | 1648 | $texte = echappe_retour($texte); |
| 1649 | 1649 | |
| 1650 | - return $texte . $fin; |
|
| 1650 | + return $texte.$fin; |
|
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | 1711 | foreach ($regs as $reg) { |
| 1712 | - $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2]; |
|
| 1712 | + $cle = ($reg[1] ? $reg[1].':' : '').$reg[2]; |
|
| 1713 | 1713 | $desc = $traduire($cle, $lang, true); |
| 1714 | 1714 | $l = $desc->langue; |
| 1715 | 1715 | // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte. |
@@ -1823,9 +1823,9 @@ discard block |
||
| 1823 | 1823 | // il ne faut pas echapper en div si propre produit un seul paragraphe |
| 1824 | 1824 | include_spip('inc/texte'); |
| 1825 | 1825 | $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad)); |
| 1826 | - $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1826 | + $mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span'; |
|
| 1827 | 1827 | if ($mode === 'div') { |
| 1828 | - $trad = rtrim($trad) . "\n\n"; |
|
| 1828 | + $trad = rtrim($trad)."\n\n"; |
|
| 1829 | 1829 | } |
| 1830 | 1830 | $trad = code_echappement($trad, 'multi', false, $mode); |
| 1831 | 1831 | $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l)); |
@@ -2025,7 +2025,7 @@ discard block |
||
| 2025 | 2025 | if (is_array($balise)) { |
| 2026 | 2026 | array_walk( |
| 2027 | 2027 | $balise, |
| 2028 | - function (&$a, $key, $t) { |
|
| 2028 | + function(&$a, $key, $t) { |
|
| 2029 | 2029 | $a = extraire_attribut($a, $t); |
| 2030 | 2030 | }, |
| 2031 | 2031 | $attribut |
@@ -2122,14 +2122,14 @@ discard block |
||
| 2122 | 2122 | |
| 2123 | 2123 | if ($old !== null) { |
| 2124 | 2124 | // Remplacer l'ancien attribut du meme nom |
| 2125 | - $balise = $r[1] . $insert . $r[5]; |
|
| 2125 | + $balise = $r[1].$insert.$r[5]; |
|
| 2126 | 2126 | } else { |
| 2127 | 2127 | // preferer une balise " />" (comme <img />) |
| 2128 | 2128 | if (preg_match(',/>,', $balise)) { |
| 2129 | - $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1); |
|
| 2129 | + $balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1); |
|
| 2130 | 2130 | } // sinon une balise <a ...> ... </a> |
| 2131 | 2131 | else { |
| 2132 | - $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1); |
|
| 2132 | + $balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1); |
|
| 2133 | 2133 | } |
| 2134 | 2134 | } |
| 2135 | 2135 | |
@@ -2184,7 +2184,7 @@ discard block |
||
| 2184 | 2184 | if ( |
| 2185 | 2185 | $class_courante |
| 2186 | 2186 | and strpos($class_courante, (string) $c) !== false |
| 2187 | - and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante) |
|
| 2187 | + and preg_match('/(^|\s)'.preg_quote($c).'($|\s)/', $class_courante) |
|
| 2188 | 2188 | ) { |
| 2189 | 2189 | $is_class_presente = true; |
| 2190 | 2190 | } |
@@ -2192,12 +2192,12 @@ discard block |
||
| 2192 | 2192 | in_array($operation, ['ajouter', 'commuter']) |
| 2193 | 2193 | and !$is_class_presente |
| 2194 | 2194 | ) { |
| 2195 | - $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c); |
|
| 2195 | + $class_new = ltrim(rtrim($class_new ?? '').' '.$c); |
|
| 2196 | 2196 | } elseif ( |
| 2197 | 2197 | in_array($operation, ['supprimer', 'commuter']) |
| 2198 | 2198 | and $is_class_presente |
| 2199 | 2199 | ) { |
| 2200 | - $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new)); |
|
| 2200 | + $class_new = trim(preg_replace('/(^|\s)'.preg_quote($c).'($|\s)/', "\\1", $class_new)); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | } |
| 2203 | 2203 | |
@@ -2260,7 +2260,7 @@ discard block |
||
| 2260 | 2260 | // Quelques fonctions de calcul arithmetique |
| 2261 | 2261 | // |
| 2262 | 2262 | function floatstr($a) { |
| 2263 | - return str_replace(',', '.', (string)floatval($a)); |
|
| 2263 | + return str_replace(',', '.', (string) floatval($a)); |
|
| 2264 | 2264 | } |
| 2265 | 2265 | function strize($f, $a, $b) { |
| 2266 | 2266 | return floatstr($f(floatstr($a), floatstr($b))); |
@@ -2396,13 +2396,13 @@ discard block |
||
| 2396 | 2396 | if (!defined('_TAGS_NOM_AUTEUR')) { |
| 2397 | 2397 | define('_TAGS_NOM_AUTEUR', ''); |
| 2398 | 2398 | } |
| 2399 | - $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR)); |
|
| 2399 | + $tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR)); |
|
| 2400 | 2400 | foreach ($tags_acceptes as $tag) { |
| 2401 | 2401 | if (strlen($tag)) { |
| 2402 | - $remp1[] = '<' . trim($tag) . '>'; |
|
| 2403 | - $remp1[] = '</' . trim($tag) . '>'; |
|
| 2404 | - $remp2[] = '\x60' . trim($tag) . '\x61'; |
|
| 2405 | - $remp2[] = '\x60/' . trim($tag) . '\x61'; |
|
| 2402 | + $remp1[] = '<'.trim($tag).'>'; |
|
| 2403 | + $remp1[] = '</'.trim($tag).'>'; |
|
| 2404 | + $remp2[] = '\x60'.trim($tag).'\x61'; |
|
| 2405 | + $remp2[] = '\x60/'.trim($tag).'\x61'; |
|
| 2406 | 2406 | } |
| 2407 | 2407 | } |
| 2408 | 2408 | $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom))); |
@@ -2456,7 +2456,7 @@ discard block |
||
| 2456 | 2456 | . http_img_pack( |
| 2457 | 2457 | 'attachment-16.png', |
| 2458 | 2458 | $t, |
| 2459 | - 'title="' . attribut_html($t) . '"' |
|
| 2459 | + 'title="'.attribut_html($t).'"' |
|
| 2460 | 2460 | ) |
| 2461 | 2461 | . '</a>', |
| 2462 | 2462 | $tag |
@@ -2520,10 +2520,10 @@ discard block |
||
| 2520 | 2520 | $fichier = basename($url); |
| 2521 | 2521 | |
| 2522 | 2522 | return '<a rel="enclosure"' |
| 2523 | - . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2524 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2525 | - . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '') |
|
| 2526 | - . '>' . $fichier . '</a>'; |
|
| 2523 | + . ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '') |
|
| 2524 | + . ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '') |
|
| 2525 | + . ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '') |
|
| 2526 | + . '>'.$fichier.'</a>'; |
|
| 2527 | 2527 | } |
| 2528 | 2528 | |
| 2529 | 2529 | /** |
@@ -2551,9 +2551,9 @@ discard block |
||
| 2551 | 2551 | } # vieux data |
| 2552 | 2552 | $fichier = basename($url); |
| 2553 | 2553 | $enclosures[] = '<enclosure' |
| 2554 | - . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '') |
|
| 2555 | - . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '') |
|
| 2556 | - . ($length ? ' length="' . $length . '"' : '') |
|
| 2554 | + . ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '') |
|
| 2555 | + . ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '') |
|
| 2556 | + . ($length ? ' length="'.$length.'"' : '') |
|
| 2557 | 2557 | . ' />'; |
| 2558 | 2558 | } |
| 2559 | 2559 | } |
@@ -2579,7 +2579,7 @@ discard block |
||
| 2579 | 2579 | if (extraire_attribut($e, 'rel') == 'tag') { |
| 2580 | 2580 | $subjects .= '<dc:subject>' |
| 2581 | 2581 | . texte_backend(textebrut($e)) |
| 2582 | - . '</dc:subject>' . "\n"; |
|
| 2582 | + . '</dc:subject>'."\n"; |
|
| 2583 | 2583 | } |
| 2584 | 2584 | } |
| 2585 | 2585 | |
@@ -2615,7 +2615,7 @@ discard block |
||
| 2615 | 2615 | if (is_array($texte)) { |
| 2616 | 2616 | array_walk( |
| 2617 | 2617 | $texte, |
| 2618 | - function (&$a, $key, $t) { |
|
| 2618 | + function(&$a, $key, $t) { |
|
| 2619 | 2619 | $a = extraire_balise($a, $t); |
| 2620 | 2620 | }, |
| 2621 | 2621 | $tag |
@@ -2663,7 +2663,7 @@ discard block |
||
| 2663 | 2663 | if (is_array($texte)) { |
| 2664 | 2664 | array_walk( |
| 2665 | 2665 | $texte, |
| 2666 | - function (&$a, $key, $t) { |
|
| 2666 | + function(&$a, $key, $t) { |
|
| 2667 | 2667 | $a = extraire_balises($a, $t); |
| 2668 | 2668 | }, |
| 2669 | 2669 | $tag |
@@ -2796,7 +2796,7 @@ discard block |
||
| 2796 | 2796 | if ($fond != '404') { |
| 2797 | 2797 | $contexte = array_shift($p); |
| 2798 | 2798 | $contexte['page'] = $fond; |
| 2799 | - $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2799 | + $action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action); |
|
| 2800 | 2800 | } |
| 2801 | 2801 | } |
| 2802 | 2802 | // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url |
@@ -2851,9 +2851,9 @@ discard block |
||
| 2851 | 2851 | . '"' |
| 2852 | 2852 | . (is_null($val) |
| 2853 | 2853 | ? '' |
| 2854 | - : ' value="' . entites_html($val) . '"' |
|
| 2854 | + : ' value="'.entites_html($val).'"' |
|
| 2855 | 2855 | ) |
| 2856 | - . ' type="hidden"' . "\n/>"; |
|
| 2856 | + . ' type="hidden"'."\n/>"; |
|
| 2857 | 2857 | } |
| 2858 | 2858 | |
| 2859 | 2859 | return join('', $hidden); |
@@ -2963,7 +2963,7 @@ discard block |
||
| 2963 | 2963 | |
| 2964 | 2964 | return preg_replace_callback( |
| 2965 | 2965 | ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims", |
| 2966 | - fn($x) => "url('" . suivre_lien($path, $x[1]) . "')", |
|
| 2966 | + fn($x) => "url('".suivre_lien($path, $x[1])."')", |
|
| 2967 | 2967 | $contenu |
| 2968 | 2968 | ); |
| 2969 | 2969 | } |
@@ -3024,14 +3024,14 @@ discard block |
||
| 3024 | 3024 | ) { |
| 3025 | 3025 | $distant = true; |
| 3026 | 3026 | $cssf = parse_url($css); |
| 3027 | - $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : ''); |
|
| 3027 | + $cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : ''); |
|
| 3028 | 3028 | $cssf = preg_replace(',[?:&=],', '_', $cssf); |
| 3029 | 3029 | } else { |
| 3030 | 3030 | $distant = false; |
| 3031 | 3031 | $cssf = $css; |
| 3032 | 3032 | // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi |
| 3033 | 3033 | //propose (rien a faire dans ce cas) |
| 3034 | - $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css); |
|
| 3034 | + $f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css); |
|
| 3035 | 3035 | if (@file_exists($f)) { |
| 3036 | 3036 | return $f; |
| 3037 | 3037 | } |
@@ -3041,7 +3041,7 @@ discard block |
||
| 3041 | 3041 | $dir_var = sous_repertoire(_DIR_VAR, 'cache-css'); |
| 3042 | 3042 | $f = $dir_var |
| 3043 | 3043 | . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf) |
| 3044 | - . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css'; |
|
| 3044 | + . '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css'; |
|
| 3045 | 3045 | |
| 3046 | 3046 | // la css peut etre distante (url absolue !) |
| 3047 | 3047 | if ($distant) { |
@@ -3087,8 +3087,8 @@ discard block |
||
| 3087 | 3087 | } // si la css_direction commence par $dir_var on la fait passer pour une absolue |
| 3088 | 3088 | elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) { |
| 3089 | 3089 | $css_direction = substr($css_direction, strlen($dir_var)); |
| 3090 | - $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction; |
|
| 3091 | - $css_direction = '/@@@@@@/' . $css_direction; |
|
| 3090 | + $src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction; |
|
| 3091 | + $css_direction = '/@@@@@@/'.$css_direction; |
|
| 3092 | 3092 | } |
| 3093 | 3093 | $src[] = $regs[0][$k]; |
| 3094 | 3094 | $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]); |
@@ -3137,7 +3137,7 @@ discard block |
||
| 3137 | 3137 | |
| 3138 | 3138 | $f = basename($css, '.css'); |
| 3139 | 3139 | $f = sous_repertoire(_DIR_VAR, 'cache-css') |
| 3140 | - . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f) |
|
| 3140 | + . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f) |
|
| 3141 | 3141 | . '.css'; |
| 3142 | 3142 | |
| 3143 | 3143 | if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) { |
@@ -3147,7 +3147,7 @@ discard block |
||
| 3147 | 3147 | if ($url_absolue_css == $css) { |
| 3148 | 3148 | if ( |
| 3149 | 3149 | strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0 |
| 3150 | - or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu) |
|
| 3150 | + or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu) |
|
| 3151 | 3151 | ) { |
| 3152 | 3152 | include_spip('inc/distant'); |
| 3153 | 3153 | $contenu = recuperer_url($css); |
@@ -3259,7 +3259,7 @@ discard block |
||
| 3259 | 3259 | $expression = str_replace('\/', '/', $expression); |
| 3260 | 3260 | $expression = str_replace('/', '\/', $expression); |
| 3261 | 3261 | |
| 3262 | - if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) { |
|
| 3262 | + if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) { |
|
| 3263 | 3263 | if (isset($r[$capte])) { |
| 3264 | 3264 | return $r[$capte]; |
| 3265 | 3265 | } else { |
@@ -3297,7 +3297,7 @@ discard block |
||
| 3297 | 3297 | $expression = str_replace('\/', '/', $expression); |
| 3298 | 3298 | $expression = str_replace('/', '\/', $expression); |
| 3299 | 3299 | |
| 3300 | - return preg_replace('/' . $expression . '/' . $modif, $replace, $texte); |
|
| 3300 | + return preg_replace('/'.$expression.'/'.$modif, $replace, $texte); |
|
| 3301 | 3301 | } |
| 3302 | 3302 | |
| 3303 | 3303 | |
@@ -3316,7 +3316,7 @@ discard block |
||
| 3316 | 3316 | function traiter_doublons_documents(&$doublons, $letexte) { |
| 3317 | 3317 | |
| 3318 | 3318 | // Verifier dans le texte & les notes (pas beau, helas) |
| 3319 | - $t = $letexte . $GLOBALS['les_notes']; |
|
| 3319 | + $t = $letexte.$GLOBALS['les_notes']; |
|
| 3320 | 3320 | |
| 3321 | 3321 | if ( |
| 3322 | 3322 | strstr($t, 'spip_document_') // evite le preg_match_all si inutile |
@@ -3330,7 +3330,7 @@ discard block |
||
| 3330 | 3330 | if (!isset($doublons['documents'])) { |
| 3331 | 3331 | $doublons['documents'] = ''; |
| 3332 | 3332 | } |
| 3333 | - $doublons['documents'] .= ',' . join(',', $matches[1]); |
|
| 3333 | + $doublons['documents'] .= ','.join(',', $matches[1]); |
|
| 3334 | 3334 | } |
| 3335 | 3335 | |
| 3336 | 3336 | return $letexte; |
@@ -3387,7 +3387,7 @@ discard block |
||
| 3387 | 3387 | if ($env) { |
| 3388 | 3388 | foreach ($env as $i => $j) { |
| 3389 | 3389 | if (is_string($j) and !in_array($i, $ignore_params)) { |
| 3390 | - $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />"; |
|
| 3390 | + $texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />"; |
|
| 3391 | 3391 | } |
| 3392 | 3392 | } |
| 3393 | 3393 | } |
@@ -3426,7 +3426,7 @@ discard block |
||
| 3426 | 3426 | if ($env) { |
| 3427 | 3427 | foreach ($env as $i => $j) { |
| 3428 | 3428 | if (is_string($j) and !in_array($i, $ignore_params)) { |
| 3429 | - $texte .= attribut_html($i) . "='" . attribut_html($j) . "' "; |
|
| 3429 | + $texte .= attribut_html($i)."='".attribut_html($j)."' "; |
|
| 3430 | 3430 | } |
| 3431 | 3431 | } |
| 3432 | 3432 | } |
@@ -3500,10 +3500,10 @@ discard block |
||
| 3500 | 3500 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 3501 | 3501 | if ( |
| 3502 | 3502 | preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m) |
| 3503 | - and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg' |
|
| 3503 | + and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg' |
|
| 3504 | 3504 | and file_exists($variante_svg_generique) |
| 3505 | 3505 | ) { |
| 3506 | - if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) { |
|
| 3506 | + if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg' and file_exists($variante_svg_size)) { |
|
| 3507 | 3507 | $img_file = $variante_svg_size; |
| 3508 | 3508 | } |
| 3509 | 3509 | else { |
@@ -3561,7 +3561,7 @@ discard block |
||
| 3561 | 3561 | return ''; |
| 3562 | 3562 | } |
| 3563 | 3563 | } |
| 3564 | - $atts .= " width='" . $largeur . "' height='" . $hauteur . "'"; |
|
| 3564 | + $atts .= " width='".$largeur."' height='".$hauteur."'"; |
|
| 3565 | 3565 | } |
| 3566 | 3566 | |
| 3567 | 3567 | if (file_exists($img_file)) { |
@@ -3571,14 +3571,14 @@ discard block |
||
| 3571 | 3571 | $alt = ''; |
| 3572 | 3572 | } |
| 3573 | 3573 | elseif ($alt or $alt === '') { |
| 3574 | - $alt = " alt='" . attribut_html($alt) . "'"; |
|
| 3574 | + $alt = " alt='".attribut_html($alt)."'"; |
|
| 3575 | 3575 | } |
| 3576 | 3576 | else { |
| 3577 | - $alt = " alt='" . attribut_html($title) . "'"; |
|
| 3577 | + $alt = " alt='".attribut_html($title)."'"; |
|
| 3578 | 3578 | } |
| 3579 | 3579 | return "<img src='$img_file'$alt" |
| 3580 | - . ($title ? ' title="' . attribut_html($title) . '"' : '') |
|
| 3581 | - . ' ' . ltrim($atts) |
|
| 3580 | + . ($title ? ' title="'.attribut_html($title).'"' : '') |
|
| 3581 | + . ' '.ltrim($atts) |
|
| 3582 | 3582 | . ' />'; |
| 3583 | 3583 | } |
| 3584 | 3584 | |
@@ -3592,10 +3592,10 @@ discard block |
||
| 3592 | 3592 | */ |
| 3593 | 3593 | function http_style_background($img, $att = '', $size = null) { |
| 3594 | 3594 | if ($size and is_numeric($size)) { |
| 3595 | - $size = trim($size) . 'px'; |
|
| 3595 | + $size = trim($size).'px'; |
|
| 3596 | 3596 | } |
| 3597 | - return " style='background" . |
|
| 3598 | - ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';' |
|
| 3597 | + return " style='background". |
|
| 3598 | + ($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';' |
|
| 3599 | 3599 | . ($size ? "background-size:{$size};" : '') |
| 3600 | 3600 | . "'"; |
| 3601 | 3601 | } |
@@ -3710,7 +3710,7 @@ discard block |
||
| 3710 | 3710 | $img = http_img_pack( |
| 3711 | 3711 | $img, |
| 3712 | 3712 | $alt, |
| 3713 | - $class ? " class='" . attribut_html($class) . "'" : '', |
|
| 3713 | + $class ? " class='".attribut_html($class)."'" : '', |
|
| 3714 | 3714 | '', |
| 3715 | 3715 | ['chemin_image' => false, 'utiliser_suffixe_size' => false] |
| 3716 | 3716 | ); |
@@ -3795,7 +3795,7 @@ discard block |
||
| 3795 | 3795 | $balise_svg_source = $balise_svg; |
| 3796 | 3796 | |
| 3797 | 3797 | // entete XML à supprimer |
| 3798 | - $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg); |
|
| 3798 | + $svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg); |
|
| 3799 | 3799 | |
| 3800 | 3800 | // IE est toujours mon ami |
| 3801 | 3801 | $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false'); |
@@ -3813,9 +3813,9 @@ discard block |
||
| 3813 | 3813 | // regler le alt |
| 3814 | 3814 | if ($alt) { |
| 3815 | 3815 | $balise_svg = inserer_attribut($balise_svg, 'role', 'img'); |
| 3816 | - $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3816 | + $id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4); |
|
| 3817 | 3817 | $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id); |
| 3818 | - $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n"; |
|
| 3818 | + $title = "<title id=\"$id\">".entites_html($alt)."</title>\n"; |
|
| 3819 | 3819 | $balise_svg .= $title; |
| 3820 | 3820 | } |
| 3821 | 3821 | else { |
@@ -3863,7 +3863,7 @@ discard block |
||
| 3863 | 3863 | if (is_array($tableau)) { |
| 3864 | 3864 | foreach ($tableau as $k => $v) { |
| 3865 | 3865 | $res = recuperer_fond( |
| 3866 | - 'modeles/' . $modele, |
|
| 3866 | + 'modeles/'.$modele, |
|
| 3867 | 3867 | array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v])) |
| 3868 | 3868 | ); |
| 3869 | 3869 | $texte .= $res; |
@@ -4048,7 +4048,7 @@ discard block |
||
| 4048 | 4048 | } |
| 4049 | 4049 | |
| 4050 | 4050 | $c = serialize($c); |
| 4051 | - $cle = calculer_cle_action($form . $c); |
|
| 4051 | + $cle = calculer_cle_action($form.$c); |
|
| 4052 | 4052 | $c = "$cle:$c"; |
| 4053 | 4053 | |
| 4054 | 4054 | // on ne stocke pas les contextes dans des fichiers en cache |
@@ -4106,15 +4106,15 @@ discard block |
||
| 4106 | 4106 | } |
| 4107 | 4107 | // toujours encoder l'url source dans le bloc ajax |
| 4108 | 4108 | $r = self(); |
| 4109 | - $r = ' data-origin="' . $r . '"'; |
|
| 4109 | + $r = ' data-origin="'.$r.'"'; |
|
| 4110 | 4110 | $class = 'ajaxbloc'; |
| 4111 | 4111 | if ($ajaxid and is_string($ajaxid)) { |
| 4112 | 4112 | // ajaxid est normalement conforme a un nom de classe css |
| 4113 | 4113 | // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution |
| 4114 | - $class .= ' ajax-id-' . entites_html($ajaxid); |
|
| 4114 | + $class .= ' ajax-id-'.entites_html($ajaxid); |
|
| 4115 | 4115 | } |
| 4116 | 4116 | |
| 4117 | - return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4117 | + return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n"; |
|
| 4118 | 4118 | } |
| 4119 | 4119 | |
| 4120 | 4120 | /** |
@@ -4158,7 +4158,7 @@ discard block |
||
| 4158 | 4158 | $cle = substr($c, 0, $p); |
| 4159 | 4159 | $c = substr($c, $p + 1); |
| 4160 | 4160 | |
| 4161 | - if ($cle == calculer_cle_action($form . $c)) { |
|
| 4161 | + if ($cle == calculer_cle_action($form.$c)) { |
|
| 4162 | 4162 | $env = @unserialize($c); |
| 4163 | 4163 | return $env; |
| 4164 | 4164 | } |
@@ -4279,13 +4279,13 @@ discard block |
||
| 4279 | 4279 | } |
| 4280 | 4280 | } |
| 4281 | 4281 | } |
| 4282 | - $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"'; |
|
| 4282 | + $att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"'; |
|
| 4283 | 4283 | } else { |
| 4284 | 4284 | $bal = 'a'; |
| 4285 | 4285 | $att = "href='$url'" |
| 4286 | - . ($title ? " title='" . attribut_html($title) . "'" : '') |
|
| 4287 | - . ($class ? " class='" . attribut_html($class) . "'" : '') |
|
| 4288 | - . ($rel ? " rel='" . attribut_html($rel) . "'" : '') |
|
| 4286 | + . ($title ? " title='".attribut_html($title)."'" : '') |
|
| 4287 | + . ($class ? " class='".attribut_html($class)."'" : '') |
|
| 4288 | + . ($rel ? " rel='".attribut_html($rel)."'" : '') |
|
| 4289 | 4289 | . $evt; |
| 4290 | 4290 | } |
| 4291 | 4291 | if ($libelle === null) { |
@@ -4424,7 +4424,7 @@ discard block |
||
| 4424 | 4424 | |
| 4425 | 4425 | // Icône |
| 4426 | 4426 | $icone = http_img_pack($fond, $alt, "width='$size' height='$size'"); |
| 4427 | - $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>"; |
|
| 4427 | + $icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>"; |
|
| 4428 | 4428 | |
| 4429 | 4429 | // Markup final |
| 4430 | 4430 | if ($type == 'lien') { |
@@ -4699,20 +4699,20 @@ discard block |
||
| 4699 | 4699 | $class_form = 'ajax'; |
| 4700 | 4700 | $class = str_replace('ajax', '', $class); |
| 4701 | 4701 | } |
| 4702 | - $class_btn = 'submit ' . trim($class); |
|
| 4702 | + $class_btn = 'submit '.trim($class); |
|
| 4703 | 4703 | |
| 4704 | 4704 | if ($confirm) { |
| 4705 | - $confirm = 'confirm("' . attribut_html($confirm) . '")'; |
|
| 4705 | + $confirm = 'confirm("'.attribut_html($confirm).'")'; |
|
| 4706 | 4706 | if ($callback) { |
| 4707 | 4707 | $callback = "$confirm?($callback):false"; |
| 4708 | 4708 | } else { |
| 4709 | 4709 | $callback = $confirm; |
| 4710 | 4710 | } |
| 4711 | 4711 | } |
| 4712 | - $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : ''; |
|
| 4712 | + $onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : ''; |
|
| 4713 | 4713 | $title = $title ? " title='$title'" : ''; |
| 4714 | 4714 | |
| 4715 | - return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url) |
|
| 4715 | + return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url) |
|
| 4716 | 4716 | . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>"; |
| 4717 | 4717 | } |
| 4718 | 4718 | |
@@ -4777,14 +4777,14 @@ discard block |
||
| 4777 | 4777 | $champ_titre = ''; |
| 4778 | 4778 | if ($demande_titre) { |
| 4779 | 4779 | // si pas de titre declare mais champ titre, il sera peuple par le select * |
| 4780 | - $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : ''; |
|
| 4780 | + $champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : ''; |
|
| 4781 | 4781 | } |
| 4782 | 4782 | include_spip('base/abstract_sql'); |
| 4783 | 4783 | include_spip('base/connect_sql'); |
| 4784 | 4784 | $objets[$type_objet][$id_objet] = sql_fetsel( |
| 4785 | - '*' . $champ_titre, |
|
| 4785 | + '*'.$champ_titre, |
|
| 4786 | 4786 | $desc['table_sql'], |
| 4787 | - id_table_objet($type_objet) . ' = ' . intval($id_objet) |
|
| 4787 | + id_table_objet($type_objet).' = '.intval($id_objet) |
|
| 4788 | 4788 | ); |
| 4789 | 4789 | |
| 4790 | 4790 | // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci |
@@ -4877,8 +4877,7 @@ discard block |
||
| 4877 | 4877 | if (isset($ligne_sql['chapo'])) { |
| 4878 | 4878 | $chapo = $ligne_sql['chapo']; |
| 4879 | 4879 | $texte = strlen($descriptif) ? |
| 4880 | - '' : |
|
| 4881 | - "$chapo \n\n $texte"; |
|
| 4880 | + '' : "$chapo \n\n $texte"; |
|
| 4882 | 4881 | } |
| 4883 | 4882 | |
| 4884 | 4883 | // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur |
@@ -4953,7 +4952,7 @@ discard block |
||
| 4953 | 4952 | return $texte; |
| 4954 | 4953 | } |
| 4955 | 4954 | |
| 4956 | - $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement); |
|
| 4955 | + $traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement); |
|
| 4957 | 4956 | |
| 4958 | 4957 | // Fournir $connect et $Pile[0] au traitement si besoin |
| 4959 | 4958 | $Pile = [0 => $env]; |
@@ -4987,7 +4986,7 @@ discard block |
||
| 4987 | 4986 | } |
| 4988 | 4987 | $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect); |
| 4989 | 4988 | |
| 4990 | - return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>'; |
|
| 4989 | + return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>'; |
|
| 4991 | 4990 | } |
| 4992 | 4991 | |
| 4993 | 4992 | /** |
@@ -5013,10 +5012,10 @@ discard block |
||
| 5013 | 5012 | function wrap($texte, $wrap) { |
| 5014 | 5013 | $balises = extraire_balises($wrap); |
| 5015 | 5014 | if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) { |
| 5016 | - $texte = $wrap . $texte; |
|
| 5015 | + $texte = $wrap.$texte; |
|
| 5017 | 5016 | $regs = array_reverse($regs[1]); |
| 5018 | - $wrap = '</' . implode('></', $regs) . '>'; |
|
| 5019 | - $texte = $texte . $wrap; |
|
| 5017 | + $wrap = '</'.implode('></', $regs).'>'; |
|
| 5018 | + $texte = $texte.$wrap; |
|
| 5020 | 5019 | } |
| 5021 | 5020 | |
| 5022 | 5021 | return $texte; |
@@ -5047,7 +5046,7 @@ discard block |
||
| 5047 | 5046 | |
| 5048 | 5047 | // caster $u en array si besoin |
| 5049 | 5048 | if (is_object($u)) { |
| 5050 | - $u = (array)$u; |
|
| 5049 | + $u = (array) $u; |
|
| 5051 | 5050 | } |
| 5052 | 5051 | |
| 5053 | 5052 | if (is_array($u)) { |
@@ -5069,7 +5068,7 @@ discard block |
||
| 5069 | 5068 | // sinon on passe a la ligne et on indente |
| 5070 | 5069 | $i_str = str_pad('', $indent, ' '); |
| 5071 | 5070 | foreach ($u as $k => $v) { |
| 5072 | - $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2); |
|
| 5071 | + $out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2); |
|
| 5073 | 5072 | } |
| 5074 | 5073 | |
| 5075 | 5074 | return $out; |
@@ -5123,7 +5122,7 @@ discard block |
||
| 5123 | 5122 | * @return string |
| 5124 | 5123 | */ |
| 5125 | 5124 | function objet_icone($objet, $taille = 24, $class = '') { |
| 5126 | - $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png'; |
|
| 5125 | + $icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png'; |
|
| 5127 | 5126 | $icone = chemin_image($icone); |
| 5128 | 5127 | $balise_img = charger_filtre('balise_img'); |
| 5129 | 5128 | |
@@ -5149,7 +5148,7 @@ discard block |
||
| 5149 | 5148 | */ |
| 5150 | 5149 | function objet_T($objet, $chaine, $args = [], $options = []) { |
| 5151 | 5150 | $chaine = explode(':', $chaine); |
| 5152 | - if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5151 | + if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) { |
|
| 5153 | 5152 | return $t; |
| 5154 | 5153 | } |
| 5155 | 5154 | $chaine = implode(':', $chaine); |
@@ -5215,7 +5214,7 @@ discard block |
||
| 5215 | 5214 | $cache = recuperer_fond($fond, $contexte, $options, $connect); |
| 5216 | 5215 | |
| 5217 | 5216 | // calculer le nom de la css |
| 5218 | - $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension); |
|
| 5217 | + $dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension); |
|
| 5219 | 5218 | $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond)); |
| 5220 | 5219 | $contexte_implicite = calculer_contexte_implicite(); |
| 5221 | 5220 | |
@@ -5223,14 +5222,14 @@ discard block |
||
| 5223 | 5222 | // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu |
| 5224 | 5223 | // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine |
| 5225 | 5224 | if (isset($options['hash_on_content']) and $options['hash_on_content']) { |
| 5226 | - $hash = md5($contexte_implicite['host'] . '::' . $cache); |
|
| 5225 | + $hash = md5($contexte_implicite['host'].'::'.$cache); |
|
| 5227 | 5226 | } |
| 5228 | 5227 | else { |
| 5229 | 5228 | unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js |
| 5230 | 5229 | ksort($contexte); |
| 5231 | - $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect); |
|
| 5230 | + $hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect); |
|
| 5232 | 5231 | } |
| 5233 | - $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension"; |
|
| 5232 | + $filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension"; |
|
| 5234 | 5233 | |
| 5235 | 5234 | // mettre a jour le fichier si il n'existe pas |
| 5236 | 5235 | // ou trop ancien |
@@ -5238,8 +5237,8 @@ discard block |
||
| 5238 | 5237 | // et recopie sur le fichier cible uniquement si il change |
| 5239 | 5238 | if ( |
| 5240 | 5239 | !file_exists($filename) |
| 5241 | - or !file_exists($filename . '.last') |
|
| 5242 | - or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified']) |
|
| 5240 | + or !file_exists($filename.'.last') |
|
| 5241 | + or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.'.last') < $cache['lastmodified']) |
|
| 5243 | 5242 | or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
| 5244 | 5243 | ) { |
| 5245 | 5244 | $contenu = $cache['texte']; |
@@ -5260,10 +5259,10 @@ discard block |
||
| 5260 | 5259 | } |
| 5261 | 5260 | // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj |
| 5262 | 5261 | // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non |
| 5263 | - $comment .= "}\n md5:" . md5($contenu) . " */\n"; |
|
| 5262 | + $comment .= "}\n md5:".md5($contenu)." */\n"; |
|
| 5264 | 5263 | } |
| 5265 | 5264 | // et ecrire le fichier si il change |
| 5266 | - ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true); |
|
| 5265 | + ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true); |
|
| 5267 | 5266 | } |
| 5268 | 5267 | |
| 5269 | 5268 | return timestamp($filename); |
@@ -5489,7 +5488,7 @@ discard block |
||
| 5489 | 5488 | if ($e > 0 and strlen($mid) > 8) { |
| 5490 | 5489 | $mid = '***...***'; |
| 5491 | 5490 | } |
| 5492 | - return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : ''); |
|
| 5491 | + return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : ''); |
|
| 5493 | 5492 | } |
| 5494 | 5493 | |
| 5495 | 5494 | |
@@ -5551,7 +5550,7 @@ discard block |
||
| 5551 | 5550 | case 'id': |
| 5552 | 5551 | case 'anchor': |
| 5553 | 5552 | if (preg_match(',^\d,', $texte)) { |
| 5554 | - $texte = substr($type, 0, 1) . $texte; |
|
| 5553 | + $texte = substr($type, 0, 1).$texte; |
|
| 5555 | 5554 | } |
| 5556 | 5555 | } |
| 5557 | 5556 | |
@@ -5561,9 +5560,9 @@ discard block |
||
| 5561 | 5560 | |
| 5562 | 5561 | if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) { |
| 5563 | 5562 | if (preg_match(',^\d,', $texte)) { |
| 5564 | - $texte = ($type ? substr($type, 0, 1) : 's') . $texte; |
|
| 5563 | + $texte = ($type ? substr($type, 0, 1) : 's').$texte; |
|
| 5565 | 5564 | } |
| 5566 | - $texte .= $separateur . md5($original); |
|
| 5565 | + $texte .= $separateur.md5($original); |
|
| 5567 | 5566 | $texte = substr($texte, 0, $longueur_mini); |
| 5568 | 5567 | } |
| 5569 | 5568 | |