@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | * @param array $opt |
| 24 | 24 | */ |
| 25 | 25 | function inc_journal_dist($phrase, $opt = []) { |
| 26 | - if (!strlen((string) $phrase)) { |
|
| 27 | - return; |
|
| 28 | - } |
|
| 29 | - if ($opt) { |
|
| 30 | - $phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt)); |
|
| 31 | - } |
|
| 32 | - spip_log($phrase, 'journal'); |
|
| 26 | + if (!strlen((string) $phrase)) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | + if ($opt) { |
|
| 30 | + $phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt)); |
|
| 31 | + } |
|
| 32 | + spip_log($phrase, 'journal'); |
|
| 33 | 33 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Mail |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/charsets'); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | 33 | function nettoyer_titre_email($titre) { |
| 34 | - return str_replace("\n", ' ', nettoyer_caracteres_mail(textebrut(corriger_typo($titre)))); |
|
| 34 | + return str_replace("\n", ' ', nettoyer_caracteres_mail(textebrut(corriger_typo($titre)))); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -47,21 +47,21 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function nettoyer_caracteres_mail($t) { |
| 49 | 49 | |
| 50 | - $t = filtrer_entites($t); |
|
| 51 | - |
|
| 52 | - if ($GLOBALS['meta']['charset'] != 'utf-8') { |
|
| 53 | - $t = str_replace( |
|
| 54 | - ['’', '“', '”'], |
|
| 55 | - ["'", '"', '"'], |
|
| 56 | - $t |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - return str_replace( |
|
| 61 | - ['—', '&endash;'], |
|
| 62 | - ['--', '-'], |
|
| 63 | - $t |
|
| 64 | - ); |
|
| 50 | + $t = filtrer_entites($t); |
|
| 51 | + |
|
| 52 | + if ($GLOBALS['meta']['charset'] != 'utf-8') { |
|
| 53 | + $t = str_replace( |
|
| 54 | + ['’', '“', '”'], |
|
| 55 | + ["'", '"', '"'], |
|
| 56 | + $t |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + return str_replace( |
|
| 61 | + ['—', '&endash;'], |
|
| 62 | + ['--', '-'], |
|
| 63 | + $t |
|
| 64 | + ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -94,87 +94,87 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | function inc_envoyer_mail_dist($destinataire, $sujet, $corps, $from = '', $headers = '') { |
| 96 | 96 | |
| 97 | - if (!email_valide($destinataire)) { |
|
| 98 | - return false; |
|
| 99 | - } |
|
| 100 | - if ($destinataire == _T('info_mail_fournisseur')) { |
|
| 101 | - return false; |
|
| 102 | - } // tres fort |
|
| 103 | - |
|
| 104 | - // Fournir si possible un Message-Id: conforme au RFC1036, |
|
| 105 | - // sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER |
|
| 106 | - |
|
| 107 | - $email_envoi = $GLOBALS['meta']['email_envoi']; |
|
| 108 | - if (!email_valide($email_envoi)) { |
|
| 109 | - spip_log('Meta email_envoi invalide. Le mail sera probablement vu comme spam.'); |
|
| 110 | - $email_envoi = $destinataire; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $parts = ''; |
|
| 114 | - if (is_array($corps)) { |
|
| 115 | - $texte = $corps['texte']; |
|
| 116 | - $from = ($corps['from'] ?? $from); |
|
| 117 | - $headers = ($corps['headers'] ?? $headers); |
|
| 118 | - if (is_array($headers)) { |
|
| 119 | - $headers = implode("\n", $headers); |
|
| 120 | - } |
|
| 121 | - if (isset($corps['pieces_jointes']) && function_exists('mail_embarquer_pieces_jointes')) { |
|
| 122 | - $parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']); |
|
| 123 | - } |
|
| 124 | - } else { |
|
| 125 | - $texte = $corps; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if (!$from) { |
|
| 129 | - $from = $email_envoi; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin |
|
| 133 | - if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', (string) $from)) { |
|
| 134 | - $from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', (string) $from))) . ')'; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // nettoyer les é ’, &emdash; etc... |
|
| 138 | - // les 'cliquer ici' etc sont a eviter; voir: |
|
| 139 | - // http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf |
|
| 140 | - $texte = nettoyer_caracteres_mail($texte); |
|
| 141 | - $sujet = nettoyer_caracteres_mail($sujet); |
|
| 142 | - |
|
| 143 | - // encoder le sujet si possible selon la RFC |
|
| 144 | - if (init_mb_string()) { |
|
| 145 | - # un bug de mb_string casse mb_encode_mimeheader si l'encoding interne |
|
| 146 | - # est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian) |
|
| 147 | - $charset = $GLOBALS['meta']['charset']; |
|
| 148 | - mb_internal_encoding($charset); |
|
| 149 | - $sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n"); |
|
| 150 | - mb_internal_encoding('utf-8'); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - $headers ??= ''; |
|
| 154 | - if (function_exists('wordwrap') && (preg_match(',multipart/mixed,', (string) $headers) == 0)) { |
|
| 155 | - $texte = wordwrap($texte); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - [$headers, $texte] = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts); |
|
| 159 | - |
|
| 160 | - if (_OS_SERVEUR == 'windows') { |
|
| 161 | - $texte = preg_replace("@\r*\n@", "\r\n", (string) $texte); |
|
| 162 | - $headers = preg_replace("@\r*\n@", "\r\n", (string) $headers); |
|
| 163 | - $sujet = preg_replace("@\r*\n@", "\r\n", $sujet); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - spip_log("mail $destinataire\n$sujet\n$headers", 'mails'); |
|
| 167 | - // mode TEST : forcer l'email |
|
| 168 | - if (defined('_TEST_EMAIL_DEST')) { |
|
| 169 | - if (!_TEST_EMAIL_DEST) { |
|
| 170 | - return false; |
|
| 171 | - } else { |
|
| 172 | - $texte = "Dest : $destinataire\r\n" . $texte; |
|
| 173 | - $destinataire = _TEST_EMAIL_DEST; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return @mail((string) $destinataire, $sujet, (string) $texte, $headers); |
|
| 97 | + if (!email_valide($destinataire)) { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 100 | + if ($destinataire == _T('info_mail_fournisseur')) { |
|
| 101 | + return false; |
|
| 102 | + } // tres fort |
|
| 103 | + |
|
| 104 | + // Fournir si possible un Message-Id: conforme au RFC1036, |
|
| 105 | + // sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER |
|
| 106 | + |
|
| 107 | + $email_envoi = $GLOBALS['meta']['email_envoi']; |
|
| 108 | + if (!email_valide($email_envoi)) { |
|
| 109 | + spip_log('Meta email_envoi invalide. Le mail sera probablement vu comme spam.'); |
|
| 110 | + $email_envoi = $destinataire; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $parts = ''; |
|
| 114 | + if (is_array($corps)) { |
|
| 115 | + $texte = $corps['texte']; |
|
| 116 | + $from = ($corps['from'] ?? $from); |
|
| 117 | + $headers = ($corps['headers'] ?? $headers); |
|
| 118 | + if (is_array($headers)) { |
|
| 119 | + $headers = implode("\n", $headers); |
|
| 120 | + } |
|
| 121 | + if (isset($corps['pieces_jointes']) && function_exists('mail_embarquer_pieces_jointes')) { |
|
| 122 | + $parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']); |
|
| 123 | + } |
|
| 124 | + } else { |
|
| 125 | + $texte = $corps; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if (!$from) { |
|
| 129 | + $from = $email_envoi; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin |
|
| 133 | + if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', (string) $from)) { |
|
| 134 | + $from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', (string) $from))) . ')'; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // nettoyer les é ’, &emdash; etc... |
|
| 138 | + // les 'cliquer ici' etc sont a eviter; voir: |
|
| 139 | + // http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf |
|
| 140 | + $texte = nettoyer_caracteres_mail($texte); |
|
| 141 | + $sujet = nettoyer_caracteres_mail($sujet); |
|
| 142 | + |
|
| 143 | + // encoder le sujet si possible selon la RFC |
|
| 144 | + if (init_mb_string()) { |
|
| 145 | + # un bug de mb_string casse mb_encode_mimeheader si l'encoding interne |
|
| 146 | + # est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian) |
|
| 147 | + $charset = $GLOBALS['meta']['charset']; |
|
| 148 | + mb_internal_encoding($charset); |
|
| 149 | + $sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n"); |
|
| 150 | + mb_internal_encoding('utf-8'); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + $headers ??= ''; |
|
| 154 | + if (function_exists('wordwrap') && (preg_match(',multipart/mixed,', (string) $headers) == 0)) { |
|
| 155 | + $texte = wordwrap($texte); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + [$headers, $texte] = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts); |
|
| 159 | + |
|
| 160 | + if (_OS_SERVEUR == 'windows') { |
|
| 161 | + $texte = preg_replace("@\r*\n@", "\r\n", (string) $texte); |
|
| 162 | + $headers = preg_replace("@\r*\n@", "\r\n", (string) $headers); |
|
| 163 | + $sujet = preg_replace("@\r*\n@", "\r\n", $sujet); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + spip_log("mail $destinataire\n$sujet\n$headers", 'mails'); |
|
| 167 | + // mode TEST : forcer l'email |
|
| 168 | + if (defined('_TEST_EMAIL_DEST')) { |
|
| 169 | + if (!_TEST_EMAIL_DEST) { |
|
| 170 | + return false; |
|
| 171 | + } else { |
|
| 172 | + $texte = "Dest : $destinataire\r\n" . $texte; |
|
| 173 | + $destinataire = _TEST_EMAIL_DEST; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return @mail((string) $destinataire, $sujet, (string) $texte, $headers); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -188,53 +188,53 @@ discard block |
||
| 188 | 188 | * @return array |
| 189 | 189 | */ |
| 190 | 190 | function mail_normaliser_headers($headers, $from, $to, $texte, $parts = '') { |
| 191 | - $charset = $GLOBALS['meta']['charset']; |
|
| 192 | - |
|
| 193 | - // Ajouter le Content-Type et consort s'il n'y est pas deja |
|
| 194 | - if (!str_contains($headers, 'Content-Type: ')) { |
|
| 195 | - $type = |
|
| 196 | - "Content-Type: text/plain;charset=\"$charset\";\n" . |
|
| 197 | - "Content-Transfer-Encoding: 8bit\n"; |
|
| 198 | - } else { |
|
| 199 | - $type = ''; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - // calculer un identifiant unique |
|
| 203 | - // Marie Toto <[email protected]> => @toto.com |
|
| 204 | - $domain = preg_match('/@[^\s>]+/', $from, $domain) ? $domain[0] : '@unknown-' . md5($from) . '.org'; |
|
| 205 | - $uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain; |
|
| 206 | - |
|
| 207 | - // Si multi-part, s'en servir comme borne ... |
|
| 208 | - if ($parts) { |
|
| 209 | - $texte = "--$uniq\n$type\n" . $texte . "\n"; |
|
| 210 | - foreach ($parts as $part) { |
|
| 211 | - $n = strlen((string) $part[1]) . ($part[0] ? "\n" : ''); |
|
| 212 | - $e = implode("\n", $part[0]); |
|
| 213 | - $texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1]; |
|
| 214 | - } |
|
| 215 | - $texte .= "\n\n--$uniq--\n"; |
|
| 216 | - // Si boundary n'est pas entre guillemets, |
|
| 217 | - // elle est comprise mais le charset est ignoree ! |
|
| 218 | - $type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n"; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - // .. et s'en servir pour plaire a SpamAssassin |
|
| 222 | - |
|
| 223 | - $mid = 'Message-Id: <' . $uniq . '>'; |
|
| 224 | - |
|
| 225 | - // indispensable pour les sites qui collent d'office From: serveur-http |
|
| 226 | - // sauf si deja mis par l'envoyeur |
|
| 227 | - $rep = (str_contains($headers, 'Reply-To:')) ? '' : "Reply-To: $from\n"; |
|
| 228 | - |
|
| 229 | - // Nettoyer les en-tetes envoyees |
|
| 230 | - // Ajouter le \n final |
|
| 231 | - if (strlen($headers = trim($headers))) { |
|
| 232 | - $headers .= "\n"; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // Et mentionner l'indeboulonable nomenclature ratee |
|
| 236 | - |
|
| 237 | - $headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n"; |
|
| 238 | - |
|
| 239 | - return [$headers, $texte]; |
|
| 191 | + $charset = $GLOBALS['meta']['charset']; |
|
| 192 | + |
|
| 193 | + // Ajouter le Content-Type et consort s'il n'y est pas deja |
|
| 194 | + if (!str_contains($headers, 'Content-Type: ')) { |
|
| 195 | + $type = |
|
| 196 | + "Content-Type: text/plain;charset=\"$charset\";\n" . |
|
| 197 | + "Content-Transfer-Encoding: 8bit\n"; |
|
| 198 | + } else { |
|
| 199 | + $type = ''; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + // calculer un identifiant unique |
|
| 203 | + // Marie Toto <[email protected]> => @toto.com |
|
| 204 | + $domain = preg_match('/@[^\s>]+/', $from, $domain) ? $domain[0] : '@unknown-' . md5($from) . '.org'; |
|
| 205 | + $uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain; |
|
| 206 | + |
|
| 207 | + // Si multi-part, s'en servir comme borne ... |
|
| 208 | + if ($parts) { |
|
| 209 | + $texte = "--$uniq\n$type\n" . $texte . "\n"; |
|
| 210 | + foreach ($parts as $part) { |
|
| 211 | + $n = strlen((string) $part[1]) . ($part[0] ? "\n" : ''); |
|
| 212 | + $e = implode("\n", $part[0]); |
|
| 213 | + $texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1]; |
|
| 214 | + } |
|
| 215 | + $texte .= "\n\n--$uniq--\n"; |
|
| 216 | + // Si boundary n'est pas entre guillemets, |
|
| 217 | + // elle est comprise mais le charset est ignoree ! |
|
| 218 | + $type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n"; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + // .. et s'en servir pour plaire a SpamAssassin |
|
| 222 | + |
|
| 223 | + $mid = 'Message-Id: <' . $uniq . '>'; |
|
| 224 | + |
|
| 225 | + // indispensable pour les sites qui collent d'office From: serveur-http |
|
| 226 | + // sauf si deja mis par l'envoyeur |
|
| 227 | + $rep = (str_contains($headers, 'Reply-To:')) ? '' : "Reply-To: $from\n"; |
|
| 228 | + |
|
| 229 | + // Nettoyer les en-tetes envoyees |
|
| 230 | + // Ajouter le \n final |
|
| 231 | + if (strlen($headers = trim($headers))) { |
|
| 232 | + $headers .= "\n"; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // Et mentionner l'indeboulonable nomenclature ratee |
|
| 236 | + |
|
| 237 | + $headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n"; |
|
| 238 | + |
|
| 239 | + return [$headers, $texte]; |
|
| 240 | 240 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /* |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | * http://zoumzamzouilam/truc/chose/machin..." |
| 22 | 22 | */ |
| 23 | 23 | function inc_lien_court($url) { |
| 24 | - $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40; |
|
| 25 | - $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35; |
|
| 24 | + $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40; |
|
| 25 | + $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35; |
|
| 26 | 26 | |
| 27 | - if (strlen((string) $url) > $long_url) { |
|
| 28 | - $url = substr((string) $url, 0, $coupe_url) . '...'; |
|
| 29 | - } |
|
| 27 | + if (strlen((string) $url) > $long_url) { |
|
| 28 | + $url = substr((string) $url, 0, $coupe_url) . '...'; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - return $url; |
|
| 31 | + return $url; |
|
| 32 | 32 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres'); |
@@ -45,56 +45,56 @@ discard block |
||
| 45 | 45 | **/ |
| 46 | 46 | function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') { |
| 47 | 47 | |
| 48 | - if ($recur) { |
|
| 49 | - $recur = mini_hier($sel); |
|
| 50 | - } else { |
|
| 51 | - $sel = 0; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($aff_racine) { |
|
| 55 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 56 | - $idom3 = $idom . '_selection'; |
|
| 57 | - |
|
| 58 | - $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 59 | - |
|
| 60 | - $ondbClick = strtr( |
|
| 61 | - str_replace( |
|
| 62 | - "'", |
|
| 63 | - '’', |
|
| 64 | - str_replace( |
|
| 65 | - '"', |
|
| 66 | - '"', |
|
| 67 | - (string) textebrut(_T('info_racine_site')) |
|
| 68 | - ) |
|
| 69 | - ), |
|
| 70 | - "\n\r", |
|
| 71 | - ' ' |
|
| 72 | - ); |
|
| 73 | - |
|
| 74 | - $js_func = $do . '_selection_titre'; |
|
| 75 | - $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 76 | - |
|
| 77 | - $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 78 | - . "<a href='#'" |
|
| 79 | - . 'onclick="' |
|
| 80 | - . $onClick |
|
| 81 | - . "\"\nondbclick=\"" |
|
| 82 | - . $ondbClick |
|
| 83 | - . $onClick |
|
| 84 | - . '">' |
|
| 85 | - . _T('info_racine_site') |
|
| 86 | - . '</a></div>'; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 90 | - |
|
| 91 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 92 | - $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 93 | - |
|
| 94 | - // url completee par la fonction JS onkeypress_rechercher |
|
| 95 | - $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 96 | - |
|
| 97 | - return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 48 | + if ($recur) { |
|
| 49 | + $recur = mini_hier($sel); |
|
| 50 | + } else { |
|
| 51 | + $sel = 0; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($aff_racine) { |
|
| 55 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 56 | + $idom3 = $idom . '_selection'; |
|
| 57 | + |
|
| 58 | + $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 59 | + |
|
| 60 | + $ondbClick = strtr( |
|
| 61 | + str_replace( |
|
| 62 | + "'", |
|
| 63 | + '’', |
|
| 64 | + str_replace( |
|
| 65 | + '"', |
|
| 66 | + '"', |
|
| 67 | + (string) textebrut(_T('info_racine_site')) |
|
| 68 | + ) |
|
| 69 | + ), |
|
| 70 | + "\n\r", |
|
| 71 | + ' ' |
|
| 72 | + ); |
|
| 73 | + |
|
| 74 | + $js_func = $do . '_selection_titre'; |
|
| 75 | + $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 76 | + |
|
| 77 | + $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 78 | + . "<a href='#'" |
|
| 79 | + . 'onclick="' |
|
| 80 | + . $onClick |
|
| 81 | + . "\"\nondbclick=\"" |
|
| 82 | + . $ondbClick |
|
| 83 | + . $onClick |
|
| 84 | + . '">' |
|
| 85 | + . _T('info_racine_site') |
|
| 86 | + . '</a></div>'; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 90 | + |
|
| 91 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 92 | + $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 93 | + |
|
| 94 | + // url completee par la fonction JS onkeypress_rechercher |
|
| 95 | + $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 96 | + |
|
| 97 | + return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -112,58 +112,58 @@ discard block |
||
| 112 | 112 | **/ |
| 113 | 113 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 114 | 114 | |
| 115 | - $idom1 = $idom . '_champ_recherche'; |
|
| 116 | - $idom2 = $idom . '_principal'; |
|
| 117 | - $idom3 = $idom . '_selection'; |
|
| 118 | - $idom4 = $idom . '_col_1'; |
|
| 119 | - $idom5 = 'img_' . $idom4; |
|
| 120 | - $idom6 = $idom . '_fonc'; |
|
| 121 | - |
|
| 122 | - return "<div id='$idom'>" |
|
| 123 | - . "<a id='$idom6' style='visibility: hidden;'" |
|
| 124 | - . ($url_init ? "\nhref='$url_init'" : '') |
|
| 125 | - . '></a>' |
|
| 126 | - . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 127 | - . http_img_pack( |
|
| 128 | - 'loader.svg', |
|
| 129 | - '', |
|
| 130 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 131 | - ) |
|
| 132 | - . '' |
|
| 133 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 134 | - // eliminer Return car il provoque la soumission (balise unique) |
|
| 135 | - // et eliminer Tab pour la navigation au clavier |
|
| 136 | - // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 137 | - // resultats retournes par la recherche |
|
| 138 | - . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 139 | - // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 140 | - . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 141 | - // la destination de la recherche |
|
| 142 | - . "'$idom4'" |
|
| 115 | + $idom1 = $idom . '_champ_recherche'; |
|
| 116 | + $idom2 = $idom . '_principal'; |
|
| 117 | + $idom3 = $idom . '_selection'; |
|
| 118 | + $idom4 = $idom . '_col_1'; |
|
| 119 | + $idom5 = 'img_' . $idom4; |
|
| 120 | + $idom6 = $idom . '_fonc'; |
|
| 121 | + |
|
| 122 | + return "<div id='$idom'>" |
|
| 123 | + . "<a id='$idom6' style='visibility: hidden;'" |
|
| 124 | + . ($url_init ? "\nhref='$url_init'" : '') |
|
| 125 | + . '></a>' |
|
| 126 | + . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 127 | + . http_img_pack( |
|
| 128 | + 'loader.svg', |
|
| 129 | + '', |
|
| 130 | + "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 131 | + ) |
|
| 132 | + . '' |
|
| 133 | + . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 134 | + // eliminer Return car il provoque la soumission (balise unique) |
|
| 135 | + // et eliminer Tab pour la navigation au clavier |
|
| 136 | + // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 137 | + // resultats retournes par la recherche |
|
| 138 | + . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 139 | + // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 140 | + . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 141 | + // la destination de la recherche |
|
| 142 | + . "'$idom4'" |
|
| 143 | 143 | # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id" |
| 144 | - . ",'" |
|
| 145 | - // l'url effectuant la recherche |
|
| 146 | - . $url |
|
| 147 | - . "'," |
|
| 148 | - // le noeud contenant un gif anime |
|
| 149 | - // . "'idom5'" |
|
| 150 | - . 'this.parentNode.previousSibling.firstChild' |
|
| 151 | - . ",'" |
|
| 152 | - // la valeur de l'attribut Name a remplir |
|
| 153 | - . $name |
|
| 154 | - . "','" |
|
| 155 | - // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 156 | - . $idom6 |
|
| 157 | - . "')\"" |
|
| 158 | - . ' />' |
|
| 159 | - . "\n</div>" |
|
| 160 | - . ($racine ? "<div>$racine</div>" : '') |
|
| 161 | - . "<div id='" |
|
| 162 | - . $idom2 |
|
| 163 | - . "'><div id='$idom4'" |
|
| 164 | - . " class=''>" |
|
| 165 | - . $liste |
|
| 166 | - . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 144 | + . ",'" |
|
| 145 | + // l'url effectuant la recherche |
|
| 146 | + . $url |
|
| 147 | + . "'," |
|
| 148 | + // le noeud contenant un gif anime |
|
| 149 | + // . "'idom5'" |
|
| 150 | + . 'this.parentNode.previousSibling.firstChild' |
|
| 151 | + . ",'" |
|
| 152 | + // la valeur de l'attribut Name a remplir |
|
| 153 | + . $name |
|
| 154 | + . "','" |
|
| 155 | + // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 156 | + . $idom6 |
|
| 157 | + . "')\"" |
|
| 158 | + . ' />' |
|
| 159 | + . "\n</div>" |
|
| 160 | + . ($racine ? "<div>$racine</div>" : '') |
|
| 161 | + . "<div id='" |
|
| 162 | + . $idom2 |
|
| 163 | + . "'><div id='$idom4'" |
|
| 164 | + . " class=''>" |
|
| 165 | + . $liste |
|
| 166 | + . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | **/ |
| 176 | 176 | function mini_hier($id_rubrique) { |
| 177 | 177 | |
| 178 | - $liste = $id_rubrique; |
|
| 179 | - $id_rubrique = (int) $id_rubrique; |
|
| 180 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 181 | - $liste = $id_rubrique . ",$liste"; |
|
| 182 | - } |
|
| 178 | + $liste = $id_rubrique; |
|
| 179 | + $id_rubrique = (int) $id_rubrique; |
|
| 180 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 181 | + $liste = $id_rubrique . ",$liste"; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - return explode(',', "0,$liste"); |
|
| 184 | + return explode(',', "0,$liste"); |
|
| 185 | 185 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('base/abstract_sql'); |
@@ -36,42 +36,42 @@ discard block |
||
| 36 | 36 | * @return string |
| 37 | 37 | */ |
| 38 | 38 | function inc_lien_dist( |
| 39 | - $lien, |
|
| 40 | - $texte = '', |
|
| 41 | - $class = '', |
|
| 42 | - $title = '', |
|
| 43 | - $hlang = '', |
|
| 44 | - $rel = '', |
|
| 45 | - string $connect = '', |
|
| 46 | - $env = [] |
|
| 39 | + $lien, |
|
| 40 | + $texte = '', |
|
| 41 | + $class = '', |
|
| 42 | + $title = '', |
|
| 43 | + $hlang = '', |
|
| 44 | + $rel = '', |
|
| 45 | + string $connect = '', |
|
| 46 | + $env = [] |
|
| 47 | 47 | ) { |
| 48 | - return $lien; |
|
| 48 | + return $lien; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | function expanser_liens($t, string $connect = '', $env = []) { |
| 52 | 52 | |
| 53 | - $t = pipeline('pre_liens', $t); |
|
| 53 | + $t = pipeline('pre_liens', $t); |
|
| 54 | 54 | |
| 55 | - // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 56 | - // de remettre le texte d'origine dans les parametres du modele |
|
| 57 | - $t = traiter_modeles($t, false, false, $connect); |
|
| 55 | + // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 56 | + // de remettre le texte d'origine dans les parametres du modele |
|
| 57 | + $t = traiter_modeles($t, false, false, $connect); |
|
| 58 | 58 | |
| 59 | - return $t; |
|
| 59 | + return $t; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Meme analyse mais pour eliminer les liens |
| 63 | 63 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 64 | 64 | function nettoyer_raccourcis_typo($texte, string $connect = '') { |
| 65 | - return $texte; |
|
| 65 | + return $texte; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Repere dans la partie texte d'un raccourci [texte->...] |
| 69 | 69 | // la langue et la bulle eventuelles |
| 70 | 70 | function traiter_raccourci_lien_atts($texte) { |
| 71 | - $bulle = ''; |
|
| 72 | - $hlang = ''; |
|
| 71 | + $bulle = ''; |
|
| 72 | + $hlang = ''; |
|
| 73 | 73 | |
| 74 | - return [trim((string) $texte), $bulle, $hlang]; |
|
| 74 | + return [trim((string) $texte), $bulle, $hlang]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @return string |
| 88 | 88 | */ |
| 89 | 89 | function virtuel_redirige($virtuel, $url = false) { |
| 90 | - return $virtuel; |
|
| 90 | + return $virtuel; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Cherche un lien du type [->raccourci 123] |
@@ -100,56 +100,56 @@ discard block |
||
| 100 | 100 | // 'url': seulement U (i.e. generer_url_RACCOURCI) |
| 101 | 101 | |
| 102 | 102 | function calculer_url($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) { |
| 103 | - $r = traiter_lien_implicite($ref, $texte, $pour, $connect); |
|
| 103 | + $r = traiter_lien_implicite($ref, $texte, $pour, $connect); |
|
| 104 | 104 | |
| 105 | - return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 105 | + return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
| 109 | 109 | |
| 110 | 110 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) { |
| 111 | - if (preg_match(_EXTRAIRE_LIEN, (string) $ref)) { |
|
| 112 | - return ($pour != 'tout') ? '' : ['', '', '', '']; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $lien = entites_html(trim((string) $ref)); |
|
| 116 | - |
|
| 117 | - // Liens explicites |
|
| 118 | - if (!$texte) { |
|
| 119 | - $texte = str_replace('"', '', (string) $lien); |
|
| 120 | - // evite l'affichage de trops longues urls. |
|
| 121 | - $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 122 | - $texte = $lien_court($texte); |
|
| 123 | - if ($echappe_typo) { |
|
| 124 | - $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // petites corrections d'URL |
|
| 129 | - if (preg_match('/^www\.[^@]+$/S', (string) $lien)) { |
|
| 130 | - $lien = 'http://' . $lien; |
|
| 131 | - } else { |
|
| 132 | - if (strpos((string) $lien, '@') && email_valide($lien)) { |
|
| 133 | - if (!$texte) { |
|
| 134 | - $texte = $lien; |
|
| 135 | - } |
|
| 136 | - $lien = 'mailto:' . $lien; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - if ($pour == 'url') { |
|
| 141 | - return $lien; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - if ($pour == 'titre') { |
|
| 145 | - return $texte; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return ['url' => $lien, 'titre' => $texte]; |
|
| 111 | + if (preg_match(_EXTRAIRE_LIEN, (string) $ref)) { |
|
| 112 | + return ($pour != 'tout') ? '' : ['', '', '', '']; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $lien = entites_html(trim((string) $ref)); |
|
| 116 | + |
|
| 117 | + // Liens explicites |
|
| 118 | + if (!$texte) { |
|
| 119 | + $texte = str_replace('"', '', (string) $lien); |
|
| 120 | + // evite l'affichage de trops longues urls. |
|
| 121 | + $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 122 | + $texte = $lien_court($texte); |
|
| 123 | + if ($echappe_typo) { |
|
| 124 | + $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // petites corrections d'URL |
|
| 129 | + if (preg_match('/^www\.[^@]+$/S', (string) $lien)) { |
|
| 130 | + $lien = 'http://' . $lien; |
|
| 131 | + } else { |
|
| 132 | + if (strpos((string) $lien, '@') && email_valide($lien)) { |
|
| 133 | + if (!$texte) { |
|
| 134 | + $texte = $lien; |
|
| 135 | + } |
|
| 136 | + $lien = 'mailto:' . $lien; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + if ($pour == 'url') { |
|
| 141 | + return $lien; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + if ($pour == 'titre') { |
|
| 145 | + return $texte; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return ['url' => $lien, 'titre' => $texte]; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, string $connect = '') { |
| 152 | - return function_exists($f = 'glossaire_' . $ancre) ? $f($texte, $id) : glossaire_std($texte); |
|
| 152 | + return function_exists($f = 'glossaire_' . $ancre) ? $f($texte, $id) : glossaire_std($texte); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -171,73 +171,73 @@ discard block |
||
| 171 | 171 | * @return array|bool|string |
| 172 | 172 | */ |
| 173 | 173 | function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') { |
| 174 | - $cible = $GLOBALS['lien_implicite_cible_public'] ?? null; |
|
| 175 | - if (!($match = typer_raccourci($ref))) { |
|
| 176 | - return false; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - [$type, , $id, , $args, , $ancre] = array_pad($match, 7, null); |
|
| 180 | - |
|
| 181 | - # attention dans le cas des sites le lien doit pointer non pas sur |
|
| 182 | - # la page locale du site, mais directement sur le site lui-meme |
|
| 183 | - $url = ''; |
|
| 184 | - if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
|
| 185 | - $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - if (!$url) { |
|
| 189 | - $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', $cible, '', $connect ?? ''); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - if (!$url) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - if (is_array($url)) { |
|
| 197 | - [$type, $id] = array_pad($url, 2, null); |
|
| 198 | - $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', $cible, '', $connect ?? ''); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - if ($pour === 'url') { |
|
| 202 | - return $url; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 206 | - if ($r) { |
|
| 207 | - $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - if ($texte = trim($texte)) { |
|
| 211 | - $r['titre'] = $texte; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - if (!@$r['titre']) { |
|
| 215 | - $r['titre'] = _T($type) . " $id"; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if ($pour == 'titre') { |
|
| 219 | - return $r['titre']; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - $r['url'] = $url; |
|
| 223 | - |
|
| 224 | - // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 225 | - if ( |
|
| 226 | - $type == 'document' && ($mime = sql_getfetsel( |
|
| 227 | - 'mime_type', |
|
| 228 | - 'spip_types_documents', |
|
| 229 | - 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 230 | - '', |
|
| 231 | - '', |
|
| 232 | - '', |
|
| 233 | - '', |
|
| 234 | - $connect |
|
| 235 | - )) |
|
| 236 | - ) { |
|
| 237 | - $r['mime'] = $mime; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - return $r; |
|
| 174 | + $cible = $GLOBALS['lien_implicite_cible_public'] ?? null; |
|
| 175 | + if (!($match = typer_raccourci($ref))) { |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + [$type, , $id, , $args, , $ancre] = array_pad($match, 7, null); |
|
| 180 | + |
|
| 181 | + # attention dans le cas des sites le lien doit pointer non pas sur |
|
| 182 | + # la page locale du site, mais directement sur le site lui-meme |
|
| 183 | + $url = ''; |
|
| 184 | + if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
|
| 185 | + $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + if (!$url) { |
|
| 189 | + $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', $cible, '', $connect ?? ''); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + if (!$url) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + if (is_array($url)) { |
|
| 197 | + [$type, $id] = array_pad($url, 2, null); |
|
| 198 | + $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', $cible, '', $connect ?? ''); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + if ($pour === 'url') { |
|
| 202 | + return $url; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 206 | + if ($r) { |
|
| 207 | + $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + if ($texte = trim($texte)) { |
|
| 211 | + $r['titre'] = $texte; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + if (!@$r['titre']) { |
|
| 215 | + $r['titre'] = _T($type) . " $id"; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if ($pour == 'titre') { |
|
| 219 | + return $r['titre']; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + $r['url'] = $url; |
|
| 223 | + |
|
| 224 | + // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 225 | + if ( |
|
| 226 | + $type == 'document' && ($mime = sql_getfetsel( |
|
| 227 | + 'mime_type', |
|
| 228 | + 'spip_types_documents', |
|
| 229 | + 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 230 | + '', |
|
| 231 | + '', |
|
| 232 | + '', |
|
| 233 | + '', |
|
| 234 | + $connect |
|
| 235 | + )) |
|
| 236 | + ) { |
|
| 237 | + $r['mime'] = $mime; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + return $r; |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes |
@@ -245,43 +245,43 @@ discard block |
||
| 245 | 245 | define('_RACCOURCI_URL', '/^\s*(\w*?)\s*(\d+)(\?(.*?))?(#([^\s]*))?\s*$/S'); |
| 246 | 246 | |
| 247 | 247 | function typer_raccourci($lien) { |
| 248 | - if (!preg_match(_RACCOURCI_URL, (string) $lien, $match)) { |
|
| 249 | - return []; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $f = $match[1]; |
|
| 253 | - // valeur par defaut et alias historiques |
|
| 254 | - if (!$f) { |
|
| 255 | - $f = 'article'; |
|
| 256 | - } else { |
|
| 257 | - if ($f == 'art') { |
|
| 258 | - $f = 'article'; |
|
| 259 | - } else { |
|
| 260 | - if ($f == 'br') { |
|
| 261 | - $f = 'breve'; |
|
| 262 | - } else { |
|
| 263 | - if ($f == 'rub') { |
|
| 264 | - $f = 'rubrique'; |
|
| 265 | - } else { |
|
| 266 | - if ($f == 'aut') { |
|
| 267 | - $f = 'auteur'; |
|
| 268 | - } else { |
|
| 269 | - if ($f == 'doc' || $f == 'im' || $f == 'img' || $f == 'image' || $f == 'emb') { |
|
| 270 | - $f = 'document'; |
|
| 271 | - } else { |
|
| 272 | - if (preg_match('/^br..?ve$/S', $f)) { |
|
| 273 | - $f = 'breve'; # accents :( |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - $match[0] = $f; |
|
| 283 | - |
|
| 284 | - return $match; |
|
| 248 | + if (!preg_match(_RACCOURCI_URL, (string) $lien, $match)) { |
|
| 249 | + return []; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $f = $match[1]; |
|
| 253 | + // valeur par defaut et alias historiques |
|
| 254 | + if (!$f) { |
|
| 255 | + $f = 'article'; |
|
| 256 | + } else { |
|
| 257 | + if ($f == 'art') { |
|
| 258 | + $f = 'article'; |
|
| 259 | + } else { |
|
| 260 | + if ($f == 'br') { |
|
| 261 | + $f = 'breve'; |
|
| 262 | + } else { |
|
| 263 | + if ($f == 'rub') { |
|
| 264 | + $f = 'rubrique'; |
|
| 265 | + } else { |
|
| 266 | + if ($f == 'aut') { |
|
| 267 | + $f = 'auteur'; |
|
| 268 | + } else { |
|
| 269 | + if ($f == 'doc' || $f == 'im' || $f == 'img' || $f == 'image' || $f == 'emb') { |
|
| 270 | + $f = 'document'; |
|
| 271 | + } else { |
|
| 272 | + if (preg_match('/^br..?ve$/S', $f)) { |
|
| 273 | + $f = 'breve'; # accents :( |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + $match[0] = $f; |
|
| 283 | + |
|
| 284 | + return $match; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -296,44 +296,44 @@ discard block |
||
| 296 | 296 | * } |
| 297 | 297 | **/ |
| 298 | 298 | function traiter_raccourci_titre($id, $type, $connect = null) { |
| 299 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 300 | - $desc = $trouver_table(table_objet($type)); |
|
| 299 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 300 | + $desc = $trouver_table(table_objet($type)); |
|
| 301 | 301 | |
| 302 | - if (!($desc && ($s = $desc['titre']))) { |
|
| 303 | - return []; |
|
| 304 | - } |
|
| 302 | + if (!($desc && ($s = $desc['titre']))) { |
|
| 303 | + return []; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - $_id = $desc['key']['PRIMARY KEY']; |
|
| 307 | - $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 306 | + $_id = $desc['key']['PRIMARY KEY']; |
|
| 307 | + $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 308 | 308 | |
| 309 | - if (!$r) { |
|
| 310 | - return []; |
|
| 311 | - } |
|
| 309 | + if (!$r) { |
|
| 310 | + return []; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - $r['titre'] = supprimer_numero($r['titre']); |
|
| 313 | + $r['titre'] = supprimer_numero($r['titre']); |
|
| 314 | 314 | |
| 315 | - if (!$r['titre'] && !empty($r['surnom'])) { |
|
| 316 | - $r['titre'] = $r['surnom']; |
|
| 317 | - } |
|
| 315 | + if (!$r['titre'] && !empty($r['surnom'])) { |
|
| 316 | + $r['titre'] = $r['surnom']; |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | - if (!isset($r['lang'])) { |
|
| 320 | - $r['lang'] = ''; |
|
| 321 | - } |
|
| 319 | + if (!isset($r['lang'])) { |
|
| 320 | + $r['lang'] = ''; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - return $r; |
|
| 323 | + return $r; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // |
| 327 | 327 | // Raccourcis ancre [#ancre<-] |
| 328 | 328 | // |
| 329 | 329 | function traiter_raccourci_ancre($letexte) { |
| 330 | - return $letexte; |
|
| 330 | + return $letexte; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | function traiter_raccourci_glossaire($texte) { |
| 334 | - return $texte; |
|
| 334 | + return $texte; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | function glossaire_std($terme) { |
| 338 | - return $terme; |
|
| 338 | + return $terme; |
|
| 339 | 339 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -34,35 +34,35 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function definir_barre_onglets($script) { |
| 36 | 36 | |
| 37 | - $onglets = []; |
|
| 38 | - $liste_onglets = []; |
|
| 37 | + $onglets = []; |
|
| 38 | + $liste_onglets = []; |
|
| 39 | 39 | |
| 40 | - // ajouter les onglets issus des plugin via paquet.xml |
|
| 41 | - if (function_exists('onglets_plugins')) { |
|
| 42 | - $liste_onglets = onglets_plugins(); |
|
| 43 | - } |
|
| 40 | + // ajouter les onglets issus des plugin via paquet.xml |
|
| 41 | + if (function_exists('onglets_plugins')) { |
|
| 42 | + $liste_onglets = onglets_plugins(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - foreach ($liste_onglets as $id => $infos) { |
|
| 47 | - if ( |
|
| 48 | - ($parent = $infos['parent']) |
|
| 49 | - && $parent == $script |
|
| 50 | - && autoriser('onglet', "_$id") |
|
| 51 | - ) { |
|
| 52 | - $onglets[$id] = new Bouton( |
|
| 53 | - isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 54 | - $infos['titre'], // titre |
|
| 55 | - (isset($infos['action']) && $infos['action']) |
|
| 56 | - ? generer_url_ecrire( |
|
| 57 | - $infos['action'], |
|
| 58 | - (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : '' |
|
| 59 | - ) |
|
| 60 | - : null |
|
| 61 | - ); |
|
| 62 | - } |
|
| 63 | - } |
|
| 46 | + foreach ($liste_onglets as $id => $infos) { |
|
| 47 | + if ( |
|
| 48 | + ($parent = $infos['parent']) |
|
| 49 | + && $parent == $script |
|
| 50 | + && autoriser('onglet', "_$id") |
|
| 51 | + ) { |
|
| 52 | + $onglets[$id] = new Bouton( |
|
| 53 | + isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 54 | + $infos['titre'], // titre |
|
| 55 | + (isset($infos['action']) && $infos['action']) |
|
| 56 | + ? generer_url_ecrire( |
|
| 57 | + $infos['action'], |
|
| 58 | + (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : '' |
|
| 59 | + ) |
|
| 60 | + : null |
|
| 61 | + ); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]); |
|
| 65 | + return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | 82 | function barre_onglets($rubrique, $ongletCourant, $class = 'barre_onglet') { |
| 83 | - include_spip('inc/presentation'); |
|
| 83 | + include_spip('inc/presentation'); |
|
| 84 | 84 | |
| 85 | - $res = ''; |
|
| 85 | + $res = ''; |
|
| 86 | 86 | |
| 87 | - foreach (definir_barre_onglets($rubrique) as $exec => $onglet) { |
|
| 88 | - $url = $onglet->url ?: generer_url_ecrire($exec); |
|
| 89 | - $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone); |
|
| 90 | - } |
|
| 87 | + foreach (definir_barre_onglets($rubrique) as $exec => $onglet) { |
|
| 88 | + $url = $onglet->url ?: generer_url_ecrire($exec); |
|
| 89 | + $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return $res ? debut_onglet($class) . $res . fin_onglet() : (''); |
|
| 92 | + return $res ? debut_onglet($class) . $res . fin_onglet() : (''); |
|
| 93 | 93 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/serial'); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * en droit de l'éliminer |
| 27 | 27 | */ |
| 28 | 28 | if (!defined('_AGE_CACHE_ATIME')) { |
| 29 | - define('_AGE_CACHE_ATIME', 3600); |
|
| 29 | + define('_AGE_CACHE_ATIME', 3600); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
@@ -39,31 +39,31 @@ discard block |
||
| 39 | 39 | * @return int Taille approximative en octets |
| 40 | 40 | **/ |
| 41 | 41 | function taille_du_cache() { |
| 42 | - # check dirs until we reach > 500 files |
|
| 43 | - $t = 0; |
|
| 44 | - $n = 0; |
|
| 45 | - $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
|
| 46 | - for ($i = 0; $i < 256; $i++) { |
|
| 47 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 48 | - if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 49 | - while (($f = readdir($d)) !== false) { |
|
| 50 | - if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) && ($a = stat("$dir/$f"))) { |
|
| 51 | - $n++; |
|
| 52 | - if ($a['mtime'] >= $time) { |
|
| 53 | - if ($a['blocks'] > 0) { |
|
| 54 | - $t += 512 * $a['blocks']; |
|
| 55 | - } else { |
|
| 56 | - $t += $a['size']; |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - if ($n > 500) { |
|
| 63 | - return (int) (256 * $t / (1 + $i)); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $t; |
|
| 42 | + # check dirs until we reach > 500 files |
|
| 43 | + $t = 0; |
|
| 44 | + $n = 0; |
|
| 45 | + $time = $GLOBALS['meta']['cache_mark'] ?? 0; |
|
| 46 | + for ($i = 0; $i < 256; $i++) { |
|
| 47 | + $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 48 | + if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 49 | + while (($f = readdir($d)) !== false) { |
|
| 50 | + if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) && ($a = stat("$dir/$f"))) { |
|
| 51 | + $n++; |
|
| 52 | + if ($a['mtime'] >= $time) { |
|
| 53 | + if ($a['blocks'] > 0) { |
|
| 54 | + $t += 512 * $a['blocks']; |
|
| 55 | + } else { |
|
| 56 | + $t += $a['size']; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + if ($n > 500) { |
|
| 63 | + return (int) (256 * $t / (1 + $i)); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $t; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
@@ -90,30 +90,30 @@ discard block |
||
| 90 | 90 | * Inutilisé |
| 91 | 91 | **/ |
| 92 | 92 | function inc_suivre_invalideur_dist($cond, $modif = true) { |
| 93 | - if (!$modif) { |
|
| 94 | - return; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // determiner l'objet modifie : forum, article, etc |
|
| 98 | - if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 99 | - $objet = objet_type($r[1]); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 103 | - if (isset($objet)) { |
|
| 104 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 108 | - // n'affecter la meta que si un de ces objets est modifie |
|
| 109 | - if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 110 | - if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | - ecrire_meta('derniere_modif', time()); |
|
| 112 | - } |
|
| 113 | - } // sinon, cas standard, toujours affecter la meta |
|
| 114 | - else { |
|
| 115 | - ecrire_meta('derniere_modif', time()); |
|
| 116 | - } |
|
| 93 | + if (!$modif) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // determiner l'objet modifie : forum, article, etc |
|
| 98 | + if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 99 | + $objet = objet_type($r[1]); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 103 | + if (isset($objet)) { |
|
| 104 | + ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 108 | + // n'affecter la meta que si un de ces objets est modifie |
|
| 109 | + if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 110 | + if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | + ecrire_meta('derniere_modif', time()); |
|
| 112 | + } |
|
| 113 | + } // sinon, cas standard, toujours affecter la meta |
|
| 114 | + else { |
|
| 115 | + ecrire_meta('derniere_modif', time()); |
|
| 116 | + } |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -138,56 +138,56 @@ discard block |
||
| 138 | 138 | * Nombre de fichiers supprimés |
| 139 | 139 | **/ |
| 140 | 140 | function purger_repertoire($dir, $options = []) { |
| 141 | - if (!is_dir($dir) || !is_readable($dir)) { |
|
| 142 | - return 0; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
|
| 146 | - // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
|
| 147 | - if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 148 | - return 0; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - $handle = opendir($dir); |
|
| 152 | - if (!$handle) { |
|
| 153 | - return 0; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - $total = 0; |
|
| 157 | - |
|
| 158 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 159 | - // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 160 | - if ($fichier[0] == '.' || $fichier == 'CACHEDIR.TAG') { |
|
| 161 | - continue; |
|
| 162 | - } |
|
| 163 | - $chemin = "$dir/$fichier"; |
|
| 164 | - if (is_file($chemin)) { |
|
| 165 | - if ( |
|
| 166 | - (!isset($options['atime']) || @fileatime($chemin) < $options['atime']) && (!isset($options['mtime']) || @filemtime($chemin) < $options['mtime']) |
|
| 167 | - ) { |
|
| 168 | - supprimer_fichier($chemin); |
|
| 169 | - $total++; |
|
| 170 | - } |
|
| 171 | - } else { |
|
| 172 | - if (is_dir($chemin)) { |
|
| 173 | - $opts = $options; |
|
| 174 | - if (isset($options['limit'])) { |
|
| 175 | - $opts['limit'] = $options['limit'] - $total; |
|
| 176 | - } |
|
| 177 | - $total += purger_repertoire($chemin, $opts); |
|
| 178 | - if (isset($options['subdir']) && $options['subdir']) { |
|
| 179 | - spip_unlink($chemin); |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if (isset($options['limit']) && $total >= $options['limit']) { |
|
| 185 | - break; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - closedir($handle); |
|
| 189 | - |
|
| 190 | - return $total; |
|
| 141 | + if (!is_dir($dir) || !is_readable($dir)) { |
|
| 142 | + return 0; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + // sur certains sites on veut absolument garder certains caches référencés dans un CDN |
|
| 146 | + // on peut donc inhiber la purge de ces répertoires pour eviter tout probleme |
|
| 147 | + if (file_exists(rtrim($dir, '/') . '/inhib_purger_repertoire.txt')) { |
|
| 148 | + return 0; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + $handle = opendir($dir); |
|
| 152 | + if (!$handle) { |
|
| 153 | + return 0; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + $total = 0; |
|
| 157 | + |
|
| 158 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 159 | + // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 160 | + if ($fichier[0] == '.' || $fichier == 'CACHEDIR.TAG') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 163 | + $chemin = "$dir/$fichier"; |
|
| 164 | + if (is_file($chemin)) { |
|
| 165 | + if ( |
|
| 166 | + (!isset($options['atime']) || @fileatime($chemin) < $options['atime']) && (!isset($options['mtime']) || @filemtime($chemin) < $options['mtime']) |
|
| 167 | + ) { |
|
| 168 | + supprimer_fichier($chemin); |
|
| 169 | + $total++; |
|
| 170 | + } |
|
| 171 | + } else { |
|
| 172 | + if (is_dir($chemin)) { |
|
| 173 | + $opts = $options; |
|
| 174 | + if (isset($options['limit'])) { |
|
| 175 | + $opts['limit'] = $options['limit'] - $total; |
|
| 176 | + } |
|
| 177 | + $total += purger_repertoire($chemin, $opts); |
|
| 178 | + if (isset($options['subdir']) && $options['subdir']) { |
|
| 179 | + spip_unlink($chemin); |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if (isset($options['limit']) && $total >= $options['limit']) { |
|
| 185 | + break; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + closedir($handle); |
|
| 189 | + |
|
| 190 | + return $total; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -198,26 +198,26 @@ discard block |
||
| 198 | 198 | // Securite : est sur que c'est un cache |
| 199 | 199 | function retire_cache($cache) { |
| 200 | 200 | |
| 201 | - if ( |
|
| 202 | - preg_match( |
|
| 203 | - ',^([0-9a-f]/)?(\d+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 204 | - (string) $cache |
|
| 205 | - ) |
|
| 206 | - ) { |
|
| 207 | - // supprimer le fichier (de facon propre) |
|
| 208 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 209 | - } else { |
|
| 210 | - spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 211 | - } |
|
| 201 | + if ( |
|
| 202 | + preg_match( |
|
| 203 | + ',^([0-9a-f]/)?(\d+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 204 | + (string) $cache |
|
| 205 | + ) |
|
| 206 | + ) { |
|
| 207 | + // supprimer le fichier (de facon propre) |
|
| 208 | + supprimer_fichier(_DIR_CACHE . $cache); |
|
| 209 | + } else { |
|
| 210 | + spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 211 | + } |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // Supprimer les caches marques "x" |
| 215 | 215 | // A priori dans cette version la fonction ne sera pas appelee, car |
| 216 | 216 | // la meta est toujours false ; mais evitons un bug si elle est appellee |
| 217 | 217 | function inc_retire_caches_dist($chemin = '') { |
| 218 | - if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 219 | - effacer_meta('invalider_caches'); |
|
| 220 | - } # concurrence |
|
| 218 | + if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 219 | + effacer_meta('invalider_caches'); |
|
| 220 | + } # concurrence |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | ####################################################################### |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | ## |
| 229 | 229 | |
| 230 | 230 | function retire_caches($chemin = '') { |
| 231 | - if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 232 | - return $retire_caches($chemin); |
|
| 233 | - } |
|
| 231 | + if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 232 | + return $retire_caches($chemin); |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | // (note: si absente, n'est pas appellee) |
| 239 | 239 | |
| 240 | 240 | function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) { |
| 241 | - if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 242 | - return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 243 | - } |
|
| 244 | - return $corps; |
|
| 241 | + if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 242 | + return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 243 | + } |
|
| 244 | + return $corps; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -250,41 +250,41 @@ discard block |
||
| 250 | 250 | // invoquee quand on vide tout le cache en bloc (action/purger) |
| 251 | 251 | // |
| 252 | 252 | function supprime_invalideurs() { |
| 253 | - if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 254 | - return $supprime_invalideurs(); |
|
| 255 | - } |
|
| 253 | + if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 254 | + return $supprime_invalideurs(); |
|
| 255 | + } |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | // Calcul des pages : noter dans la base les liens d'invalidation |
| 260 | 260 | function maj_invalideurs($fichier, &$page) { |
| 261 | - if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 262 | - return $maj_invalideurs($fichier, $page); |
|
| 263 | - } |
|
| 261 | + if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 262 | + return $maj_invalideurs($fichier, $page); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
| 267 | 267 | // les invalideurs sont de la forme "objet/id_objet" |
| 268 | 268 | function insere_invalideur($inval, $fichier) { |
| 269 | - if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 270 | - return $insere_invalideur($inval, $fichier); |
|
| 271 | - } |
|
| 269 | + if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 270 | + return $insere_invalideur($inval, $fichier); |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // |
| 275 | 275 | // Marquer les fichiers caches invalides comme etant a supprimer |
| 276 | 276 | // |
| 277 | 277 | function applique_invalideur($depart) { |
| 278 | - if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 279 | - return $applique_invalideur($depart); |
|
| 280 | - } |
|
| 278 | + if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 279 | + return $applique_invalideur($depart); |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // |
| 284 | 284 | // Invalider les caches liés à telle condition |
| 285 | 285 | // |
| 286 | 286 | function suivre_invalideur($cond, $modif = true) { |
| 287 | - if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 288 | - return $suivre_invalideur($cond, $modif); |
|
| 289 | - } |
|
| 287 | + if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 288 | + return $suivre_invalideur($cond, $modif); |
|
| 289 | + } |
|
| 290 | 290 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | * Pile complétée par le code à générer |
| 44 | 44 | */ |
| 45 | 45 | function balise_BOITE_OUVRIR_dist($p) { |
| 46 | - $_titre = interprete_argument_balise(1, $p); |
|
| 47 | - $_class = interprete_argument_balise(2, $p); |
|
| 48 | - $_head_class = interprete_argument_balise(3, $p); |
|
| 49 | - $_titre = ($_titre ?: "''"); |
|
| 50 | - $_class = ($_class ? ", $_class" : ", 'simple'"); |
|
| 51 | - $_head_class = ($_head_class ? ", $_head_class" : ''); |
|
| 52 | - |
|
| 53 | - $f = chercher_filtre('boite_ouvrir'); |
|
| 54 | - $p->code = "$f($_titre$_class$_head_class)"; |
|
| 55 | - $p->interdire_scripts = false; |
|
| 56 | - |
|
| 57 | - return $p; |
|
| 46 | + $_titre = interprete_argument_balise(1, $p); |
|
| 47 | + $_class = interprete_argument_balise(2, $p); |
|
| 48 | + $_head_class = interprete_argument_balise(3, $p); |
|
| 49 | + $_titre = ($_titre ?: "''"); |
|
| 50 | + $_class = ($_class ? ", $_class" : ", 'simple'"); |
|
| 51 | + $_head_class = ($_head_class ? ", $_head_class" : ''); |
|
| 52 | + |
|
| 53 | + $f = chercher_filtre('boite_ouvrir'); |
|
| 54 | + $p->code = "$f($_titre$_class$_head_class)"; |
|
| 55 | + $p->interdire_scripts = false; |
|
| 56 | + |
|
| 57 | + return $p; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | * Pile complétée par le code à générer |
| 75 | 75 | */ |
| 76 | 76 | function balise_BOITE_PIED_dist($p) { |
| 77 | - $_class = interprete_argument_balise(1, $p); |
|
| 78 | - $_class = ($_class ? "$_class" : ''); |
|
| 77 | + $_class = interprete_argument_balise(1, $p); |
|
| 78 | + $_class = ($_class ? "$_class" : ''); |
|
| 79 | 79 | |
| 80 | - $f = chercher_filtre('boite_pied'); |
|
| 81 | - $p->code = "$f($_class)"; |
|
| 82 | - $p->interdire_scripts = false; |
|
| 80 | + $f = chercher_filtre('boite_pied'); |
|
| 81 | + $p->code = "$f($_class)"; |
|
| 82 | + $p->interdire_scripts = false; |
|
| 83 | 83 | |
| 84 | - return $p; |
|
| 84 | + return $p; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | |
@@ -101,11 +101,11 @@ discard block |
||
| 101 | 101 | * Pile complétée par le code à générer |
| 102 | 102 | */ |
| 103 | 103 | function balise_BOITE_FERMER_dist($p) { |
| 104 | - $f = chercher_filtre('boite_fermer'); |
|
| 105 | - $p->code = "$f()"; |
|
| 106 | - $p->interdire_scripts = false; |
|
| 104 | + $f = chercher_filtre('boite_fermer'); |
|
| 105 | + $p->code = "$f()"; |
|
| 106 | + $p->interdire_scripts = false; |
|
| 107 | 107 | |
| 108 | - return $p; |
|
| 108 | + return $p; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -127,16 +127,16 @@ discard block |
||
| 127 | 127 | * HTML du début de la boîte |
| 128 | 128 | */ |
| 129 | 129 | function boite_ouvrir($titre, $class = '', $head_class = '', $id = '') { |
| 130 | - $class = "box $class"; |
|
| 131 | - $head_class = "box__header $head_class clearfix"; |
|
| 132 | - // dans l'espace prive, titrer en h3 si pas de balise <hn> |
|
| 133 | - if (test_espace_prive() && strlen($titre) && !str_contains($titre, '<h')) { |
|
| 134 | - $titre = "<h3>$titre</h3>"; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return '<div class="' . $class . ($id ? "\" id=\"$id" : '') . '">' |
|
| 138 | - . ($titre ? "<div class=\"$head_class\">$titre<!--/hd--></div>" : '') |
|
| 139 | - . '<div class="box__body clearfix">'; |
|
| 130 | + $class = "box $class"; |
|
| 131 | + $head_class = "box__header $head_class clearfix"; |
|
| 132 | + // dans l'espace prive, titrer en h3 si pas de balise <hn> |
|
| 133 | + if (test_espace_prive() && strlen($titre) && !str_contains($titre, '<h')) { |
|
| 134 | + $titre = "<h3>$titre</h3>"; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + return '<div class="' . $class . ($id ? "\" id=\"$id" : '') . '">' |
|
| 138 | + . ($titre ? "<div class=\"$head_class\">$titre<!--/hd--></div>" : '') |
|
| 139 | + . '<div class="box__body clearfix">'; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | * HTML de transition vers le pied de la boîte |
| 154 | 154 | */ |
| 155 | 155 | function boite_pied($class = 'act') { |
| 156 | - $class = "box__footer $class"; |
|
| 156 | + $class = "box__footer $class"; |
|
| 157 | 157 | |
| 158 | - return '</div>' |
|
| 159 | - . "<div class=\"$class clearfix\">"; |
|
| 158 | + return '</div>' |
|
| 159 | + . "<div class=\"$class clearfix\">"; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
@@ -171,5 +171,5 @@ discard block |
||
| 171 | 171 | * HTML de fin de la boîte |
| 172 | 172 | */ |
| 173 | 173 | function boite_fermer() { |
| 174 | - return '</div></div>'; |
|
| 174 | + return '</div></div>'; |
|
| 175 | 175 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -42,22 +42,22 @@ discard block |
||
| 42 | 42 | * Pile complétée par le code à générer |
| 43 | 43 | */ |
| 44 | 44 | function balise_ALERTE_MESSAGE_dist($p) { |
| 45 | - $_texte = interprete_argument_balise(1, $p); |
|
| 46 | - $_titre = interprete_argument_balise(2, $p); |
|
| 47 | - $_class = interprete_argument_balise(3, $p); |
|
| 48 | - $_role = interprete_argument_balise(4, $p); |
|
| 49 | - $_id = interprete_argument_balise(5, $p); |
|
| 50 | - $_texte = ($_texte ?: "''"); |
|
| 51 | - $_titre = ($_titre ? ", $_titre" : ', null'); |
|
| 52 | - $_class = ($_class ? ", $_class" : ', null'); |
|
| 53 | - $_role = ($_role ? ", $_role" : ', null'); |
|
| 54 | - $_id = ($_id ? ", $_id" : ', null'); |
|
| 45 | + $_texte = interprete_argument_balise(1, $p); |
|
| 46 | + $_titre = interprete_argument_balise(2, $p); |
|
| 47 | + $_class = interprete_argument_balise(3, $p); |
|
| 48 | + $_role = interprete_argument_balise(4, $p); |
|
| 49 | + $_id = interprete_argument_balise(5, $p); |
|
| 50 | + $_texte = ($_texte ?: "''"); |
|
| 51 | + $_titre = ($_titre ? ", $_titre" : ', null'); |
|
| 52 | + $_class = ($_class ? ", $_class" : ', null'); |
|
| 53 | + $_role = ($_role ? ", $_role" : ', null'); |
|
| 54 | + $_id = ($_id ? ", $_id" : ', null'); |
|
| 55 | 55 | |
| 56 | - $f = chercher_filtre('message_alerte'); |
|
| 57 | - $p->code = "$f($_texte$_titre$_class$_role$_id)"; |
|
| 58 | - $p->interdire_scripts = false; |
|
| 56 | + $f = chercher_filtre('message_alerte'); |
|
| 57 | + $p->code = "$f($_texte$_titre$_class$_role$_id)"; |
|
| 58 | + $p->interdire_scripts = false; |
|
| 59 | 59 | |
| 60 | - return $p; |
|
| 60 | + return $p; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -85,20 +85,20 @@ discard block |
||
| 85 | 85 | * Pile complétée par le code à générer |
| 86 | 86 | */ |
| 87 | 87 | function balise_ALERTE_OUVRIR_dist($p) { |
| 88 | - $_titre = interprete_argument_balise(1, $p); |
|
| 89 | - $_class = interprete_argument_balise(2, $p); |
|
| 90 | - $_role = interprete_argument_balise(3, $p); |
|
| 91 | - $_id = interprete_argument_balise(4, $p); |
|
| 92 | - $_titre = ($_titre ? "$_titre" : 'null'); |
|
| 93 | - $_class = ($_class ? ", $_class" : ', null'); |
|
| 94 | - $_role = ($_role ? ", $_role" : ', null'); |
|
| 95 | - $_id = ($_id ? ", $_id" : ', null'); |
|
| 88 | + $_titre = interprete_argument_balise(1, $p); |
|
| 89 | + $_class = interprete_argument_balise(2, $p); |
|
| 90 | + $_role = interprete_argument_balise(3, $p); |
|
| 91 | + $_id = interprete_argument_balise(4, $p); |
|
| 92 | + $_titre = ($_titre ? "$_titre" : 'null'); |
|
| 93 | + $_class = ($_class ? ", $_class" : ', null'); |
|
| 94 | + $_role = ($_role ? ", $_role" : ', null'); |
|
| 95 | + $_id = ($_id ? ", $_id" : ', null'); |
|
| 96 | 96 | |
| 97 | - $f = chercher_filtre('message_alerte_ouvrir'); |
|
| 98 | - $p->code = "$f($_titre$_class$_role$_id)"; |
|
| 99 | - $p->interdire_scripts = false; |
|
| 97 | + $f = chercher_filtre('message_alerte_ouvrir'); |
|
| 98 | + $p->code = "$f($_titre$_class$_role$_id)"; |
|
| 99 | + $p->interdire_scripts = false; |
|
| 100 | 100 | |
| 101 | - return $p; |
|
| 101 | + return $p; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * Pile complétée par le code à générer |
| 121 | 121 | */ |
| 122 | 122 | function balise_ALERTE_FERMER_dist($p) { |
| 123 | - $f = chercher_filtre('message_alerte_fermer'); |
|
| 124 | - $p->code = "$f()"; |
|
| 125 | - $p->interdire_scripts = false; |
|
| 123 | + $f = chercher_filtre('message_alerte_fermer'); |
|
| 124 | + $p->code = "$f()"; |
|
| 125 | + $p->interdire_scripts = false; |
|
| 126 | 126 | |
| 127 | - return $p; |
|
| 127 | + return $p; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | function message_alerte(string $texte, ?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string { |
| 161 | 161 | |
| 162 | - $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir'); |
|
| 163 | - $message_alerte_fermer = chercher_filtre('message_alerte_fermer'); |
|
| 162 | + $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir'); |
|
| 163 | + $message_alerte_fermer = chercher_filtre('message_alerte_fermer'); |
|
| 164 | 164 | |
| 165 | - return $message_alerte_ouvrir($titre, $class, $role, $id) . |
|
| 166 | - $texte . |
|
| 167 | - $message_alerte_fermer(); |
|
| 165 | + return $message_alerte_ouvrir($titre, $class, $role, $id) . |
|
| 166 | + $texte . |
|
| 167 | + $message_alerte_fermer(); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -195,53 +195,53 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | function message_alerte_ouvrir(?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string { |
| 197 | 197 | |
| 198 | - $prive = test_espace_prive(); |
|
| 198 | + $prive = test_espace_prive(); |
|
| 199 | 199 | |
| 200 | - // Valeurs par défaut |
|
| 201 | - $titre = trim($titre ?? ''); |
|
| 202 | - $role ??= 'alert'; // fallback uniquement si null |
|
| 203 | - $class ??= 'notice'; // fallback uniquement si null |
|
| 200 | + // Valeurs par défaut |
|
| 201 | + $titre = trim($titre ?? ''); |
|
| 202 | + $role ??= 'alert'; // fallback uniquement si null |
|
| 203 | + $class ??= 'notice'; // fallback uniquement si null |
|
| 204 | 204 | |
| 205 | - // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter |
|
| 206 | - $types = [ |
|
| 207 | - 'notice', |
|
| 208 | - 'error', |
|
| 209 | - 'success', |
|
| 210 | - 'info', |
|
| 211 | - ]; |
|
| 212 | - $type = array_intersect(explode(' ', $class), $types); |
|
| 213 | - $type = reset($type); |
|
| 214 | - $class = trim(str_replace($types, '', $class) . " $type"); |
|
| 205 | + // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter |
|
| 206 | + $types = [ |
|
| 207 | + 'notice', |
|
| 208 | + 'error', |
|
| 209 | + 'success', |
|
| 210 | + 'info', |
|
| 211 | + ]; |
|
| 212 | + $type = array_intersect(explode(' ', $class), $types); |
|
| 213 | + $type = reset($type); |
|
| 214 | + $class = trim(str_replace($types, '', $class) . " $type"); |
|
| 215 | 215 | |
| 216 | - // Classes |
|
| 217 | - $class_racine = 'msg-alert'; |
|
| 218 | - $clearfix = ($prive ? 'clearfix' : ''); |
|
| 219 | - $class_alerte = "$class_racine $class"; |
|
| 220 | - $class_texte = "{$class_racine}__text $clearfix"; |
|
| 221 | - $class_titre = "{$class_racine}__heading"; |
|
| 216 | + // Classes |
|
| 217 | + $class_racine = 'msg-alert'; |
|
| 218 | + $clearfix = ($prive ? 'clearfix' : ''); |
|
| 219 | + $class_alerte = "$class_racine $class"; |
|
| 220 | + $class_texte = "{$class_racine}__text $clearfix"; |
|
| 221 | + $class_titre = "{$class_racine}__heading"; |
|
| 222 | 222 | |
| 223 | - // Titre : markup |
|
| 224 | - $titre = trim($titre); |
|
| 225 | - if (strlen($titre)) { |
|
| 226 | - include_spip('inc/filtres'); |
|
| 227 | - // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon. |
|
| 228 | - $cherche_tag = ($prive ? '<h' : '<'); |
|
| 229 | - $wrap_tag = ($prive ? '<h3>' : '<div>'); |
|
| 230 | - if (!str_starts_with($titre, $cherche_tag)) { |
|
| 231 | - $titre = wrap($titre, $wrap_tag); |
|
| 232 | - } |
|
| 233 | - // puis on ajoute la classe |
|
| 234 | - $titre = ajouter_class($titre, $class_titre); |
|
| 235 | - } |
|
| 223 | + // Titre : markup |
|
| 224 | + $titre = trim($titre); |
|
| 225 | + if (strlen($titre)) { |
|
| 226 | + include_spip('inc/filtres'); |
|
| 227 | + // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon. |
|
| 228 | + $cherche_tag = ($prive ? '<h' : '<'); |
|
| 229 | + $wrap_tag = ($prive ? '<h3>' : '<div>'); |
|
| 230 | + if (!str_starts_with($titre, $cherche_tag)) { |
|
| 231 | + $titre = wrap($titre, $wrap_tag); |
|
| 232 | + } |
|
| 233 | + // puis on ajoute la classe |
|
| 234 | + $titre = ajouter_class($titre, $class_titre); |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - // Attributs |
|
| 238 | - $attr_role = ($role ? "role=\"$role\"" : ''); |
|
| 239 | - $attr_id = ($id ? "id=\"$id\"" : ''); |
|
| 240 | - $attr_data = ($type ? "data-alert=\"$type\"" : ''); |
|
| 237 | + // Attributs |
|
| 238 | + $attr_role = ($role ? "role=\"$role\"" : ''); |
|
| 239 | + $attr_id = ($id ? "id=\"$id\"" : ''); |
|
| 240 | + $attr_data = ($type ? "data-alert=\"$type\"" : ''); |
|
| 241 | 241 | |
| 242 | - return "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>" |
|
| 243 | - . $titre |
|
| 244 | - . "<div class=\"$class_texte\">"; |
|
| 242 | + return "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>" |
|
| 243 | + . $titre |
|
| 244 | + . "<div class=\"$class_texte\">"; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -255,5 +255,5 @@ discard block |
||
| 255 | 255 | * HTML de fin de l'alerte |
| 256 | 256 | */ |
| 257 | 257 | function message_alerte_fermer(): string { |
| 258 | - return '</div></div>'; |
|
| 258 | + return '</div></div>'; |
|
| 259 | 259 | } |