@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -35,33 +35,33 @@ discard block |
||
| 35 | 35 | * - une chaîne vide si autorisation à pénétrer dans l'espace privé. |
| 36 | 36 | */ |
| 37 | 37 | function inc_auth_dist() { |
| 38 | - $row = auth_mode(); |
|
| 38 | + $row = auth_mode(); |
|
| 39 | 39 | |
| 40 | - if ($row) { |
|
| 41 | - return auth_init_droits($row); |
|
| 42 | - } |
|
| 40 | + if ($row) { |
|
| 41 | + return auth_init_droits($row); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if (!$GLOBALS['connect_login']) { |
|
| 45 | - return auth_a_loger(); |
|
| 46 | - } |
|
| 44 | + if (!$GLOBALS['connect_login']) { |
|
| 45 | + return auth_a_loger(); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui |
|
| 49 | - // C'est soit parce que la base est inutilisable, |
|
| 50 | - // soit parce que la table des auteurs a changee (restauration etc) |
|
| 51 | - // Pas la peine d'insister. |
|
| 52 | - // Renvoyer le nom fautif et une URL de remise a zero |
|
| 48 | + // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui |
|
| 49 | + // C'est soit parce que la base est inutilisable, |
|
| 50 | + // soit parce que la table des auteurs a changee (restauration etc) |
|
| 51 | + // Pas la peine d'insister. |
|
| 52 | + // Renvoyer le nom fautif et une URL de remise a zero |
|
| 53 | 53 | |
| 54 | - if (spip_connect()) { |
|
| 55 | - return [ |
|
| 56 | - 'login' => $GLOBALS['connect_login'], |
|
| 57 | - 'site' => generer_url_public('', 'action=logout&logout=prive') |
|
| 58 | - ]; |
|
| 59 | - } |
|
| 54 | + if (spip_connect()) { |
|
| 55 | + return [ |
|
| 56 | + 'login' => $GLOBALS['connect_login'], |
|
| 57 | + 'site' => generer_url_public('', 'action=logout&logout=prive') |
|
| 58 | + ]; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $n = intval(sql_errno()); |
|
| 62 | - spip_log("Erreur base de donnees $n " . sql_error()); |
|
| 61 | + $n = intval(sql_errno()); |
|
| 62 | + spip_log("Erreur base de donnees $n " . sql_error()); |
|
| 63 | 63 | |
| 64 | - return $n ? $n : 1; |
|
| 64 | + return $n ? $n : 1; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -73,39 +73,39 @@ discard block |
||
| 73 | 73 | * @return array|string |
| 74 | 74 | */ |
| 75 | 75 | function auth_echec($raison) { |
| 76 | - include_spip('inc/minipres'); |
|
| 77 | - include_spip('inc/headers'); |
|
| 78 | - // pas authentifie. Pourquoi ? |
|
| 79 | - if (is_string($raison)) { |
|
| 80 | - // redirection vers une page d'authentification |
|
| 81 | - // on ne revient pas de cette fonction |
|
| 82 | - // sauf si pb de header |
|
| 83 | - $raison = redirige_formulaire($raison); |
|
| 84 | - } elseif (is_int($raison)) { |
|
| 85 | - // erreur SQL a afficher |
|
| 86 | - $raison = minipres( |
|
| 87 | - _T('info_travaux_titre'), |
|
| 88 | - _T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>' |
|
| 89 | - ); |
|
| 90 | - } elseif (@$raison['statut']) { |
|
| 91 | - // un simple visiteur n'a pas acces a l'espace prive |
|
| 92 | - spip_log('connexion refusee a ' . @$raison['id_auteur']); |
|
| 93 | - $raison = minipres(_T('avis_erreur_connexion'), _T('avis_erreur_visiteur')); |
|
| 94 | - } else { |
|
| 95 | - // auteur en fin de droits ... |
|
| 96 | - $h = $raison['site']; |
|
| 97 | - $raison = minipres( |
|
| 98 | - _T('avis_erreur_connexion'), |
|
| 99 | - '<br /><br /><p>' |
|
| 100 | - . _T('texte_inc_auth_1', ['auth_login' => $raison['login']]) |
|
| 101 | - . " <a href='$h'>" |
|
| 102 | - . _T('texte_inc_auth_2') |
|
| 103 | - . '</a>' |
|
| 104 | - . _T('texte_inc_auth_3') |
|
| 105 | - ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - return $raison; |
|
| 76 | + include_spip('inc/minipres'); |
|
| 77 | + include_spip('inc/headers'); |
|
| 78 | + // pas authentifie. Pourquoi ? |
|
| 79 | + if (is_string($raison)) { |
|
| 80 | + // redirection vers une page d'authentification |
|
| 81 | + // on ne revient pas de cette fonction |
|
| 82 | + // sauf si pb de header |
|
| 83 | + $raison = redirige_formulaire($raison); |
|
| 84 | + } elseif (is_int($raison)) { |
|
| 85 | + // erreur SQL a afficher |
|
| 86 | + $raison = minipres( |
|
| 87 | + _T('info_travaux_titre'), |
|
| 88 | + _T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>' |
|
| 89 | + ); |
|
| 90 | + } elseif (@$raison['statut']) { |
|
| 91 | + // un simple visiteur n'a pas acces a l'espace prive |
|
| 92 | + spip_log('connexion refusee a ' . @$raison['id_auteur']); |
|
| 93 | + $raison = minipres(_T('avis_erreur_connexion'), _T('avis_erreur_visiteur')); |
|
| 94 | + } else { |
|
| 95 | + // auteur en fin de droits ... |
|
| 96 | + $h = $raison['site']; |
|
| 97 | + $raison = minipres( |
|
| 98 | + _T('avis_erreur_connexion'), |
|
| 99 | + '<br /><br /><p>' |
|
| 100 | + . _T('texte_inc_auth_1', ['auth_login' => $raison['login']]) |
|
| 101 | + . " <a href='$h'>" |
|
| 102 | + . _T('texte_inc_auth_2') |
|
| 103 | + . '</a>' |
|
| 104 | + . _T('texte_inc_auth_3') |
|
| 105 | + ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + return $raison; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -115,81 +115,81 @@ discard block |
||
| 115 | 115 | * @return array|bool|string |
| 116 | 116 | */ |
| 117 | 117 | function auth_mode() { |
| 118 | - // |
|
| 119 | - // Initialiser variables (eviter hacks par URL) |
|
| 120 | - // |
|
| 121 | - $GLOBALS['connect_login'] = ''; |
|
| 122 | - $id_auteur = null; |
|
| 123 | - $GLOBALS['auth_can_disconnect'] = false; |
|
| 124 | - |
|
| 125 | - // |
|
| 126 | - // Recuperer les donnees d'identification |
|
| 127 | - // |
|
| 128 | - include_spip('inc/session'); |
|
| 129 | - // Session valide en cours ? |
|
| 130 | - if (isset($_COOKIE['spip_session'])) { |
|
| 131 | - $session = charger_fonction('session', 'inc'); |
|
| 132 | - if ( |
|
| 133 | - $id_auteur = $session() |
|
| 134 | - or $id_auteur === 0 // reprise sur restauration |
|
| 135 | - ) { |
|
| 136 | - $GLOBALS['auth_can_disconnect'] = true; |
|
| 137 | - $GLOBALS['connect_login'] = session_get('login'); |
|
| 138 | - } else { |
|
| 139 | - unset($_COOKIE['spip_session']); |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // Essayer auth http si significatif |
|
| 144 | - // (ignorer les login d'intranet independants de spip) |
|
| 145 | - if (!$GLOBALS['ignore_auth_http']) { |
|
| 146 | - if ( |
|
| 147 | - (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW']) |
|
| 148 | - and $r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) |
|
| 149 | - or |
|
| 150 | - // Si auth http differtente de basic, PHP_AUTH_PW |
|
| 151 | - // est indisponible mais tentons quand meme pour |
|
| 152 | - // autocreation via LDAP |
|
| 153 | - (isset($_SERVER['REMOTE_USER']) |
|
| 154 | - and $r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], '')) |
|
| 155 | - ) { |
|
| 156 | - if (!$id_auteur) { |
|
| 157 | - $_SERVER['PHP_AUTH_PW'] = ''; |
|
| 158 | - $GLOBALS['auth_can_disconnect'] = true; |
|
| 159 | - $GLOBALS['visiteur_session'] = $r; |
|
| 160 | - $GLOBALS['connect_login'] = session_get('login'); |
|
| 161 | - $id_auteur = $r['id_auteur']; |
|
| 162 | - } else { |
|
| 163 | - // cas de la session en plus de PHP_AUTH |
|
| 164 | - /* if ($id_auteur != $r['id_auteur']){ |
|
| 118 | + // |
|
| 119 | + // Initialiser variables (eviter hacks par URL) |
|
| 120 | + // |
|
| 121 | + $GLOBALS['connect_login'] = ''; |
|
| 122 | + $id_auteur = null; |
|
| 123 | + $GLOBALS['auth_can_disconnect'] = false; |
|
| 124 | + |
|
| 125 | + // |
|
| 126 | + // Recuperer les donnees d'identification |
|
| 127 | + // |
|
| 128 | + include_spip('inc/session'); |
|
| 129 | + // Session valide en cours ? |
|
| 130 | + if (isset($_COOKIE['spip_session'])) { |
|
| 131 | + $session = charger_fonction('session', 'inc'); |
|
| 132 | + if ( |
|
| 133 | + $id_auteur = $session() |
|
| 134 | + or $id_auteur === 0 // reprise sur restauration |
|
| 135 | + ) { |
|
| 136 | + $GLOBALS['auth_can_disconnect'] = true; |
|
| 137 | + $GLOBALS['connect_login'] = session_get('login'); |
|
| 138 | + } else { |
|
| 139 | + unset($_COOKIE['spip_session']); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // Essayer auth http si significatif |
|
| 144 | + // (ignorer les login d'intranet independants de spip) |
|
| 145 | + if (!$GLOBALS['ignore_auth_http']) { |
|
| 146 | + if ( |
|
| 147 | + (isset($_SERVER['PHP_AUTH_USER']) and isset($_SERVER['PHP_AUTH_PW']) |
|
| 148 | + and $r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) |
|
| 149 | + or |
|
| 150 | + // Si auth http differtente de basic, PHP_AUTH_PW |
|
| 151 | + // est indisponible mais tentons quand meme pour |
|
| 152 | + // autocreation via LDAP |
|
| 153 | + (isset($_SERVER['REMOTE_USER']) |
|
| 154 | + and $r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], '')) |
|
| 155 | + ) { |
|
| 156 | + if (!$id_auteur) { |
|
| 157 | + $_SERVER['PHP_AUTH_PW'] = ''; |
|
| 158 | + $GLOBALS['auth_can_disconnect'] = true; |
|
| 159 | + $GLOBALS['visiteur_session'] = $r; |
|
| 160 | + $GLOBALS['connect_login'] = session_get('login'); |
|
| 161 | + $id_auteur = $r['id_auteur']; |
|
| 162 | + } else { |
|
| 163 | + // cas de la session en plus de PHP_AUTH |
|
| 164 | + /* if ($id_auteur != $r['id_auteur']){ |
|
| 165 | 165 | spip_log("vol de session $id_auteur" . join(', ', $r)); |
| 166 | 166 | unset($_COOKIE['spip_session']); |
| 167 | 167 | $id_auteur = ''; |
| 168 | 168 | } */ |
| 169 | - } |
|
| 170 | - } else { |
|
| 171 | - // Authentification .htaccess old style, car .htaccess semble |
|
| 172 | - // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW |
|
| 173 | - if (isset($_SERVER['REMOTE_USER'])) { |
|
| 174 | - $GLOBALS['connect_login'] = $_SERVER['REMOTE_USER']; |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - $where = (is_numeric($id_auteur) |
|
| 180 | - /*AND $id_auteur>0*/ // reprise lors des restaurations |
|
| 181 | - ) ? |
|
| 182 | - "id_auteur=$id_auteur" : |
|
| 183 | - (!strlen($GLOBALS['connect_login']) ? '' : 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text')); |
|
| 184 | - |
|
| 185 | - if (!$where) { |
|
| 186 | - return ''; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // Trouver les autres infos dans la table auteurs. |
|
| 190 | - // le champ 'quand' est utilise par l'agenda |
|
| 191 | - |
|
| 192 | - return sql_fetsel('*, en_ligne AS quand', 'spip_auteurs', "$where AND statut!='5poubelle'"); |
|
| 169 | + } |
|
| 170 | + } else { |
|
| 171 | + // Authentification .htaccess old style, car .htaccess semble |
|
| 172 | + // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW |
|
| 173 | + if (isset($_SERVER['REMOTE_USER'])) { |
|
| 174 | + $GLOBALS['connect_login'] = $_SERVER['REMOTE_USER']; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + $where = (is_numeric($id_auteur) |
|
| 180 | + /*AND $id_auteur>0*/ // reprise lors des restaurations |
|
| 181 | + ) ? |
|
| 182 | + "id_auteur=$id_auteur" : |
|
| 183 | + (!strlen($GLOBALS['connect_login']) ? '' : 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text')); |
|
| 184 | + |
|
| 185 | + if (!$where) { |
|
| 186 | + return ''; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // Trouver les autres infos dans la table auteurs. |
|
| 190 | + // le champ 'quand' est utilise par l'agenda |
|
| 191 | + |
|
| 192 | + return sql_fetsel('*, en_ligne AS quand', 'spip_auteurs', "$where AND statut!='5poubelle'"); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -207,86 +207,86 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | function auth_init_droits($row) { |
| 209 | 209 | |
| 210 | - include_spip('inc/autoriser'); |
|
| 211 | - if (!autoriser('loger', '', 0, $row)) { |
|
| 212 | - return false; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - if ($row['statut'] == 'nouveau') { |
|
| 217 | - include_spip('action/inscrire_auteur'); |
|
| 218 | - $row = confirmer_statut_inscription($row); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - $GLOBALS['connect_id_auteur'] = $row['id_auteur']; |
|
| 222 | - $GLOBALS['connect_login'] = $row['login']; |
|
| 223 | - $GLOBALS['connect_statut'] = $row['statut']; |
|
| 224 | - |
|
| 225 | - $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row); |
|
| 226 | - |
|
| 227 | - // au cas ou : ne pas memoriser les champs sensibles |
|
| 228 | - unset($GLOBALS['visiteur_session']['pass']); |
|
| 229 | - unset($GLOBALS['visiteur_session']['htpass']); |
|
| 230 | - unset($GLOBALS['visiteur_session']['alea_actuel']); |
|
| 231 | - unset($GLOBALS['visiteur_session']['alea_futur']); |
|
| 232 | - unset($GLOBALS['visiteur_session']['ldap_password']); |
|
| 233 | - |
|
| 234 | - // creer la session au besoin |
|
| 235 | - if (!isset($_COOKIE['spip_session'])) { |
|
| 236 | - $session = charger_fonction('session', 'inc'); |
|
| 237 | - $spip_session = $session($row); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - // reinjecter les preferences_auteur apres le reset de spip_session |
|
| 241 | - // car utilisees au retour par auth_loger() |
|
| 242 | - $r = @unserialize($row['prefs']); |
|
| 243 | - $GLOBALS['visiteur_session']['prefs'] = ($r ? $r : []); |
|
| 244 | - // si prefs pas definies, les definir par defaut |
|
| 245 | - if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) { |
|
| 246 | - $GLOBALS['visiteur_session']['prefs']['couleur'] = 2; |
|
| 247 | - $GLOBALS['visiteur_session']['prefs']['display'] = 2; |
|
| 248 | - $GLOBALS['visiteur_session']['prefs']['display_navigation'] = 'navigation_avec_icones'; |
|
| 249 | - $GLOBALS['visiteur_session']['prefs']['display_outils'] = 'oui'; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $GLOBALS['visiteur_session'] = pipeline( |
|
| 253 | - 'preparer_visiteur_session', |
|
| 254 | - ['args' => ['row' => $row], |
|
| 255 | - 'data' => $GLOBALS['visiteur_session']] |
|
| 256 | - ); |
|
| 257 | - |
|
| 258 | - // Etablir les droits selon le codage attendu |
|
| 259 | - // dans ecrire/index.php ecrire/prive.php |
|
| 260 | - |
|
| 261 | - // Pas autorise a acceder a ecrire ? renvoyer le tableau |
|
| 262 | - // A noter : le premier appel a autoriser() a le bon gout |
|
| 263 | - // d'initialiser $GLOBALS['visiteur_session']['restreint'], |
|
| 264 | - // qui ne figure pas dans le fichier de session |
|
| 265 | - |
|
| 266 | - if (!autoriser('ecrire')) { |
|
| 267 | - return $row; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // autoriser('ecrire') ne laisse passer que les Admin et les Redac |
|
| 271 | - |
|
| 272 | - auth_trace($row); |
|
| 273 | - |
|
| 274 | - // Administrateurs |
|
| 275 | - if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) { |
|
| 276 | - if ( |
|
| 277 | - isset($GLOBALS['visiteur_session']['restreint']) |
|
| 278 | - and is_array($GLOBALS['visiteur_session']['restreint']) |
|
| 279 | - ) { |
|
| 280 | - $GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint']; |
|
| 281 | - } |
|
| 282 | - if ($GLOBALS['connect_statut'] == '0minirezo') { |
|
| 283 | - $GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique']; |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - // Pour les redacteurs, inc_version a fait l'initialisation minimale |
|
| 288 | - |
|
| 289 | - return ''; // i.e. pas de pb. |
|
| 210 | + include_spip('inc/autoriser'); |
|
| 211 | + if (!autoriser('loger', '', 0, $row)) { |
|
| 212 | + return false; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + if ($row['statut'] == 'nouveau') { |
|
| 217 | + include_spip('action/inscrire_auteur'); |
|
| 218 | + $row = confirmer_statut_inscription($row); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + $GLOBALS['connect_id_auteur'] = $row['id_auteur']; |
|
| 222 | + $GLOBALS['connect_login'] = $row['login']; |
|
| 223 | + $GLOBALS['connect_statut'] = $row['statut']; |
|
| 224 | + |
|
| 225 | + $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row); |
|
| 226 | + |
|
| 227 | + // au cas ou : ne pas memoriser les champs sensibles |
|
| 228 | + unset($GLOBALS['visiteur_session']['pass']); |
|
| 229 | + unset($GLOBALS['visiteur_session']['htpass']); |
|
| 230 | + unset($GLOBALS['visiteur_session']['alea_actuel']); |
|
| 231 | + unset($GLOBALS['visiteur_session']['alea_futur']); |
|
| 232 | + unset($GLOBALS['visiteur_session']['ldap_password']); |
|
| 233 | + |
|
| 234 | + // creer la session au besoin |
|
| 235 | + if (!isset($_COOKIE['spip_session'])) { |
|
| 236 | + $session = charger_fonction('session', 'inc'); |
|
| 237 | + $spip_session = $session($row); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + // reinjecter les preferences_auteur apres le reset de spip_session |
|
| 241 | + // car utilisees au retour par auth_loger() |
|
| 242 | + $r = @unserialize($row['prefs']); |
|
| 243 | + $GLOBALS['visiteur_session']['prefs'] = ($r ? $r : []); |
|
| 244 | + // si prefs pas definies, les definir par defaut |
|
| 245 | + if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) { |
|
| 246 | + $GLOBALS['visiteur_session']['prefs']['couleur'] = 2; |
|
| 247 | + $GLOBALS['visiteur_session']['prefs']['display'] = 2; |
|
| 248 | + $GLOBALS['visiteur_session']['prefs']['display_navigation'] = 'navigation_avec_icones'; |
|
| 249 | + $GLOBALS['visiteur_session']['prefs']['display_outils'] = 'oui'; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $GLOBALS['visiteur_session'] = pipeline( |
|
| 253 | + 'preparer_visiteur_session', |
|
| 254 | + ['args' => ['row' => $row], |
|
| 255 | + 'data' => $GLOBALS['visiteur_session']] |
|
| 256 | + ); |
|
| 257 | + |
|
| 258 | + // Etablir les droits selon le codage attendu |
|
| 259 | + // dans ecrire/index.php ecrire/prive.php |
|
| 260 | + |
|
| 261 | + // Pas autorise a acceder a ecrire ? renvoyer le tableau |
|
| 262 | + // A noter : le premier appel a autoriser() a le bon gout |
|
| 263 | + // d'initialiser $GLOBALS['visiteur_session']['restreint'], |
|
| 264 | + // qui ne figure pas dans le fichier de session |
|
| 265 | + |
|
| 266 | + if (!autoriser('ecrire')) { |
|
| 267 | + return $row; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // autoriser('ecrire') ne laisse passer que les Admin et les Redac |
|
| 271 | + |
|
| 272 | + auth_trace($row); |
|
| 273 | + |
|
| 274 | + // Administrateurs |
|
| 275 | + if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) { |
|
| 276 | + if ( |
|
| 277 | + isset($GLOBALS['visiteur_session']['restreint']) |
|
| 278 | + and is_array($GLOBALS['visiteur_session']['restreint']) |
|
| 279 | + ) { |
|
| 280 | + $GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint']; |
|
| 281 | + } |
|
| 282 | + if ($GLOBALS['connect_statut'] == '0minirezo') { |
|
| 283 | + $GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique']; |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + // Pour les redacteurs, inc_version a fait l'initialisation minimale |
|
| 288 | + |
|
| 289 | + return ''; // i.e. pas de pb. |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -295,23 +295,23 @@ discard block |
||
| 295 | 295 | * @return string |
| 296 | 296 | */ |
| 297 | 297 | function auth_a_loger() { |
| 298 | - $redirect = generer_url_public('login', 'url=' . rawurlencode(self('&', true)), '&'); |
|
| 299 | - |
|
| 300 | - // un echec au "bonjour" (login initial) quand le statut est |
|
| 301 | - // inconnu signale sans doute un probleme de cookies |
|
| 302 | - if (isset($_GET['bonjour'])) { |
|
| 303 | - $redirect = parametre_url( |
|
| 304 | - $redirect, |
|
| 305 | - 'var_erreur', |
|
| 306 | - (!isset($GLOBALS['visiteur_session']['statut']) |
|
| 307 | - ? 'cookie' |
|
| 308 | - : 'statut' |
|
| 309 | - ), |
|
| 310 | - '&' |
|
| 311 | - ); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - return $redirect; |
|
| 298 | + $redirect = generer_url_public('login', 'url=' . rawurlencode(self('&', true)), '&'); |
|
| 299 | + |
|
| 300 | + // un echec au "bonjour" (login initial) quand le statut est |
|
| 301 | + // inconnu signale sans doute un probleme de cookies |
|
| 302 | + if (isset($_GET['bonjour'])) { |
|
| 303 | + $redirect = parametre_url( |
|
| 304 | + $redirect, |
|
| 305 | + 'var_erreur', |
|
| 306 | + (!isset($GLOBALS['visiteur_session']['statut']) |
|
| 307 | + ? 'cookie' |
|
| 308 | + : 'statut' |
|
| 309 | + ), |
|
| 310 | + '&' |
|
| 311 | + ); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + return $redirect; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -323,21 +323,21 @@ discard block |
||
| 323 | 323 | * @param null|string $date |
| 324 | 324 | */ |
| 325 | 325 | function auth_trace($row, $date = null) { |
| 326 | - // Indiquer la connexion. A la minute pres ca suffit. |
|
| 327 | - if (!is_numeric($connect_quand = isset($row['quand']) ? $row['quand'] : '')) { |
|
| 328 | - $connect_quand = strtotime($connect_quand); |
|
| 329 | - } |
|
| 326 | + // Indiquer la connexion. A la minute pres ca suffit. |
|
| 327 | + if (!is_numeric($connect_quand = isset($row['quand']) ? $row['quand'] : '')) { |
|
| 328 | + $connect_quand = strtotime($connect_quand); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - if (is_null($date)) { |
|
| 332 | - $date = date('Y-m-d H:i:s'); |
|
| 333 | - } |
|
| 331 | + if (is_null($date)) { |
|
| 332 | + $date = date('Y-m-d H:i:s'); |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - if (abs(strtotime($date) - $connect_quand) >= 60) { |
|
| 336 | - sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 337 | - $row['en_ligne'] = $date; |
|
| 338 | - } |
|
| 335 | + if (abs(strtotime($date) - $connect_quand) >= 60) { |
|
| 336 | + sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 337 | + $row['en_ligne'] = $date; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - pipeline('trig_auth_trace', ['args' => ['row' => $row, 'date' => $date]]); |
|
| 340 | + pipeline('trig_auth_trace', ['args' => ['row' => $row, 'date' => $date]]); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
@@ -363,28 +363,28 @@ discard block |
||
| 363 | 363 | * @return mixed |
| 364 | 364 | */ |
| 365 | 365 | function auth_administrer($fonction, $args, $defaut = false) { |
| 366 | - $auth_methode = array_shift($args); |
|
| 367 | - $auth_methode = $auth_methode ? $auth_methode : 'spip'; // valeur par defaut au cas ou |
|
| 368 | - if ( |
|
| 369 | - $auth = charger_fonction($auth_methode, 'auth', true) |
|
| 370 | - and function_exists($f = "auth_{$auth_methode}_$fonction") |
|
| 371 | - ) { |
|
| 372 | - $res = call_user_func_array($f, $args); |
|
| 373 | - } else { |
|
| 374 | - $res = $defaut; |
|
| 375 | - } |
|
| 376 | - $res = pipeline( |
|
| 377 | - 'auth_administrer', |
|
| 378 | - [ |
|
| 379 | - 'args' => [ |
|
| 380 | - 'fonction' => $fonction, |
|
| 381 | - 'methode' => $auth_methode, |
|
| 382 | - 'args' => $args |
|
| 383 | - ], |
|
| 384 | - 'data' => $res |
|
| 385 | - ] |
|
| 386 | - ); |
|
| 387 | - return $res; |
|
| 366 | + $auth_methode = array_shift($args); |
|
| 367 | + $auth_methode = $auth_methode ? $auth_methode : 'spip'; // valeur par defaut au cas ou |
|
| 368 | + if ( |
|
| 369 | + $auth = charger_fonction($auth_methode, 'auth', true) |
|
| 370 | + and function_exists($f = "auth_{$auth_methode}_$fonction") |
|
| 371 | + ) { |
|
| 372 | + $res = call_user_func_array($f, $args); |
|
| 373 | + } else { |
|
| 374 | + $res = $defaut; |
|
| 375 | + } |
|
| 376 | + $res = pipeline( |
|
| 377 | + 'auth_administrer', |
|
| 378 | + [ |
|
| 379 | + 'args' => [ |
|
| 380 | + 'fonction' => $fonction, |
|
| 381 | + 'methode' => $auth_methode, |
|
| 382 | + 'args' => $args |
|
| 383 | + ], |
|
| 384 | + 'data' => $res |
|
| 385 | + ] |
|
| 386 | + ); |
|
| 387 | + return $res; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | /** |
@@ -394,11 +394,11 @@ discard block |
||
| 394 | 394 | * @return array |
| 395 | 395 | */ |
| 396 | 396 | function auth_formulaire_login($flux) { |
| 397 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 398 | - $flux = auth_administrer('formulaire_login', [$methode, $flux], $flux); |
|
| 399 | - } |
|
| 397 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 398 | + $flux = auth_administrer('formulaire_login', [$methode, $flux], $flux); |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - return $flux; |
|
| 401 | + return $flux; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | |
@@ -412,19 +412,19 @@ discard block |
||
| 412 | 412 | * @return string/bool |
| 413 | 413 | */ |
| 414 | 414 | function auth_retrouver_login($login, $serveur = '') { |
| 415 | - if (!spip_connect($serveur)) { |
|
| 416 | - include_spip('inc/minipres'); |
|
| 417 | - echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique')); |
|
| 418 | - exit; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 422 | - if ($auteur = auth_administrer('retrouver_login', [$methode, $login, $serveur])) { |
|
| 423 | - return $auteur; |
|
| 424 | - } |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - return false; |
|
| 415 | + if (!spip_connect($serveur)) { |
|
| 416 | + include_spip('inc/minipres'); |
|
| 417 | + echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique')); |
|
| 418 | + exit; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 422 | + if ($auteur = auth_administrer('retrouver_login', [$methode, $login, $serveur])) { |
|
| 423 | + return $auteur; |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + return false; |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -439,52 +439,52 @@ discard block |
||
| 439 | 439 | * @return array |
| 440 | 440 | */ |
| 441 | 441 | function auth_informer_login($login, $serveur = '') { |
| 442 | - if ( |
|
| 443 | - !$login |
|
| 444 | - or !$login_base = auth_retrouver_login($login, $serveur) |
|
| 445 | - or !$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur) |
|
| 446 | - ) { |
|
| 447 | - // generer de fausses infos, mais credibles, pour eviter une attaque |
|
| 448 | - // https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691 |
|
| 449 | - include_spip('inc/securiser_action'); |
|
| 450 | - $fauxalea1 = md5('fauxalea' . secret_du_site() . $login . floor(date('U') / 86400)); |
|
| 451 | - $fauxalea2 = md5('fauxalea' . secret_du_site() . $login . ceil(date('U') / 86400)); |
|
| 452 | - |
|
| 453 | - $row = [ |
|
| 454 | - 'login' => $login, |
|
| 455 | - 'cnx' => '0', |
|
| 456 | - 'logo' => '', |
|
| 457 | - 'alea_actuel' => substr_replace($fauxalea1, '.', 24, 0), |
|
| 458 | - 'alea_futur' => substr_replace($fauxalea2, '.', 24, 0) |
|
| 459 | - ]; |
|
| 460 | - |
|
| 461 | - // permettre d'autoriser l'envoi de password non crypte lorsque |
|
| 462 | - // l'auteur n'est pas (encore) declare dans SPIP, par exemple pour les cas |
|
| 463 | - // de premiere authentification via SPIP a une autre application. |
|
| 464 | - if (defined('_AUTORISER_AUTH_FAIBLE') and _AUTORISER_AUTH_FAIBLE) { |
|
| 465 | - $row['alea_actuel'] = ''; |
|
| 466 | - $row['alea_futur'] = ''; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - return $row; |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - $prefs = @unserialize($row['prefs']); |
|
| 473 | - $infos = [ |
|
| 474 | - 'id_auteur' => $row['id_auteur'], |
|
| 475 | - 'login' => $row['login'], |
|
| 476 | - 'cnx' => (isset($prefs['cnx']) and $prefs['cnx'] === 'perma') ? '1' : '0', |
|
| 477 | - 'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row), |
|
| 478 | - ]; |
|
| 479 | - |
|
| 480 | - // desactiver le hash md5 si pas auteur spip ? |
|
| 481 | - if ($row['source'] !== 'spip') { |
|
| 482 | - $row['alea_actuel'] = ''; |
|
| 483 | - $row['alea_futur'] = ''; |
|
| 484 | - } |
|
| 485 | - verifier_visiteur(); |
|
| 486 | - |
|
| 487 | - return auth_administrer('informer_login', [$row['source'], $infos, $row, $serveur], $infos); |
|
| 442 | + if ( |
|
| 443 | + !$login |
|
| 444 | + or !$login_base = auth_retrouver_login($login, $serveur) |
|
| 445 | + or !$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur) |
|
| 446 | + ) { |
|
| 447 | + // generer de fausses infos, mais credibles, pour eviter une attaque |
|
| 448 | + // https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691 |
|
| 449 | + include_spip('inc/securiser_action'); |
|
| 450 | + $fauxalea1 = md5('fauxalea' . secret_du_site() . $login . floor(date('U') / 86400)); |
|
| 451 | + $fauxalea2 = md5('fauxalea' . secret_du_site() . $login . ceil(date('U') / 86400)); |
|
| 452 | + |
|
| 453 | + $row = [ |
|
| 454 | + 'login' => $login, |
|
| 455 | + 'cnx' => '0', |
|
| 456 | + 'logo' => '', |
|
| 457 | + 'alea_actuel' => substr_replace($fauxalea1, '.', 24, 0), |
|
| 458 | + 'alea_futur' => substr_replace($fauxalea2, '.', 24, 0) |
|
| 459 | + ]; |
|
| 460 | + |
|
| 461 | + // permettre d'autoriser l'envoi de password non crypte lorsque |
|
| 462 | + // l'auteur n'est pas (encore) declare dans SPIP, par exemple pour les cas |
|
| 463 | + // de premiere authentification via SPIP a une autre application. |
|
| 464 | + if (defined('_AUTORISER_AUTH_FAIBLE') and _AUTORISER_AUTH_FAIBLE) { |
|
| 465 | + $row['alea_actuel'] = ''; |
|
| 466 | + $row['alea_futur'] = ''; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + return $row; |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + $prefs = @unserialize($row['prefs']); |
|
| 473 | + $infos = [ |
|
| 474 | + 'id_auteur' => $row['id_auteur'], |
|
| 475 | + 'login' => $row['login'], |
|
| 476 | + 'cnx' => (isset($prefs['cnx']) and $prefs['cnx'] === 'perma') ? '1' : '0', |
|
| 477 | + 'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row), |
|
| 478 | + ]; |
|
| 479 | + |
|
| 480 | + // desactiver le hash md5 si pas auteur spip ? |
|
| 481 | + if ($row['source'] !== 'spip') { |
|
| 482 | + $row['alea_actuel'] = ''; |
|
| 483 | + $row['alea_futur'] = ''; |
|
| 484 | + } |
|
| 485 | + verifier_visiteur(); |
|
| 486 | + |
|
| 487 | + return auth_administrer('informer_login', [$row['source'], $infos, $row, $serveur], $infos); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
@@ -498,21 +498,21 @@ discard block |
||
| 498 | 498 | * @return mixed |
| 499 | 499 | */ |
| 500 | 500 | function auth_identifier_login($login, $password, $serveur = '') { |
| 501 | - $erreur = ''; |
|
| 502 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 503 | - if ($auth = charger_fonction($methode, 'auth', true)) { |
|
| 504 | - $auteur = $auth($login, $password, $serveur); |
|
| 505 | - if (is_array($auteur) and count($auteur)) { |
|
| 506 | - spip_log("connexion de $login par methode $methode"); |
|
| 507 | - $auteur['auth'] = $methode; |
|
| 508 | - return $auteur; |
|
| 509 | - } elseif (is_string($auteur)) { |
|
| 510 | - $erreur .= "$auteur "; |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - return $erreur; |
|
| 501 | + $erreur = ''; |
|
| 502 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 503 | + if ($auth = charger_fonction($methode, 'auth', true)) { |
|
| 504 | + $auteur = $auth($login, $password, $serveur); |
|
| 505 | + if (is_array($auteur) and count($auteur)) { |
|
| 506 | + spip_log("connexion de $login par methode $methode"); |
|
| 507 | + $auteur['auth'] = $methode; |
|
| 508 | + return $auteur; |
|
| 509 | + } elseif (is_string($auteur)) { |
|
| 510 | + $erreur .= "$auteur "; |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + return $erreur; |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | * @return string |
| 527 | 527 | */ |
| 528 | 528 | function auth_url_retour_login($auth_methode, $login, $redirect = '', $serveur = '') { |
| 529 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 530 | - return $securiser_action('auth', "$auth_methode/$login", $redirect, true); |
|
| 529 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 530 | + return $securiser_action('auth', "$auth_methode/$login", $redirect, true); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | * @return mixed |
| 542 | 542 | */ |
| 543 | 543 | function auth_terminer_identifier_login($auth_methode, $login, $serveur = '') { |
| 544 | - $args = func_get_args(); |
|
| 545 | - $auteur = auth_administrer('terminer_identifier_login', $args); |
|
| 546 | - return $auteur; |
|
| 544 | + $args = func_get_args(); |
|
| 545 | + $auteur = auth_administrer('terminer_identifier_login', $args); |
|
| 546 | + return $auteur; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -553,29 +553,29 @@ discard block |
||
| 553 | 553 | * @return bool |
| 554 | 554 | */ |
| 555 | 555 | function auth_loger($auteur) { |
| 556 | - if (!is_array($auteur) or !count($auteur)) { |
|
| 557 | - return false; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - // initialiser et poser le cookie de session |
|
| 561 | - unset($_COOKIE['spip_session']); |
|
| 562 | - if (auth_init_droits($auteur) === false) { |
|
| 563 | - return false; |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - // initialiser les prefs |
|
| 567 | - $p = $GLOBALS['visiteur_session']['prefs']; |
|
| 568 | - $p['cnx'] = (isset($auteur['cookie']) and $auteur['cookie'] == 'oui') ? 'perma' : ''; |
|
| 569 | - |
|
| 570 | - sql_updateq( |
|
| 571 | - 'spip_auteurs', |
|
| 572 | - ['prefs' => serialize($p)], |
|
| 573 | - 'id_auteur=' . intval($auteur['id_auteur']) |
|
| 574 | - ); |
|
| 575 | - |
|
| 576 | - // bloquer ici le visiteur qui tente d'abuser de ses droits |
|
| 577 | - verifier_visiteur(); |
|
| 578 | - return true; |
|
| 556 | + if (!is_array($auteur) or !count($auteur)) { |
|
| 557 | + return false; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + // initialiser et poser le cookie de session |
|
| 561 | + unset($_COOKIE['spip_session']); |
|
| 562 | + if (auth_init_droits($auteur) === false) { |
|
| 563 | + return false; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + // initialiser les prefs |
|
| 567 | + $p = $GLOBALS['visiteur_session']['prefs']; |
|
| 568 | + $p['cnx'] = (isset($auteur['cookie']) and $auteur['cookie'] == 'oui') ? 'perma' : ''; |
|
| 569 | + |
|
| 570 | + sql_updateq( |
|
| 571 | + 'spip_auteurs', |
|
| 572 | + ['prefs' => serialize($p)], |
|
| 573 | + 'id_auteur=' . intval($auteur['id_auteur']) |
|
| 574 | + ); |
|
| 575 | + |
|
| 576 | + // bloquer ici le visiteur qui tente d'abuser de ses droits |
|
| 577 | + verifier_visiteur(); |
|
| 578 | + return true; |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
@@ -585,8 +585,8 @@ discard block |
||
| 585 | 585 | * return void |
| 586 | 586 | **/ |
| 587 | 587 | function auth_deloger() { |
| 588 | - $logout = charger_fonction('logout', 'action'); |
|
| 589 | - $logout(); |
|
| 588 | + $logout = charger_fonction('logout', 'action'); |
|
| 589 | + $logout(); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -600,8 +600,8 @@ discard block |
||
| 600 | 600 | * @return bool |
| 601 | 601 | */ |
| 602 | 602 | function auth_autoriser_modifier_login($auth_methode, $serveur = '') { |
| 603 | - $args = func_get_args(); |
|
| 604 | - return auth_administrer('autoriser_modifier_login', $args); |
|
| 603 | + $args = func_get_args(); |
|
| 604 | + return auth_administrer('autoriser_modifier_login', $args); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | * message d'erreur ou chaine vide si pas d'erreur |
| 617 | 617 | */ |
| 618 | 618 | function auth_verifier_login($auth_methode, $new_login, $id_auteur = 0, $serveur = '') { |
| 619 | - $args = func_get_args(); |
|
| 620 | - return auth_administrer('verifier_login', $args, ''); |
|
| 619 | + $args = func_get_args(); |
|
| 620 | + return auth_administrer('verifier_login', $args, ''); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -630,8 +630,8 @@ discard block |
||
| 630 | 630 | * @return bool |
| 631 | 631 | */ |
| 632 | 632 | function auth_modifier_login($auth_methode, $new_login, $id_auteur, $serveur = '') { |
| 633 | - $args = func_get_args(); |
|
| 634 | - return auth_administrer('modifier_login', $args); |
|
| 633 | + $args = func_get_args(); |
|
| 634 | + return auth_administrer('modifier_login', $args); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /** |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | * succès ou échec |
| 647 | 647 | */ |
| 648 | 648 | function auth_autoriser_modifier_pass($auth_methode, $serveur = '') { |
| 649 | - $args = func_get_args(); |
|
| 650 | - return auth_administrer('autoriser_modifier_pass', $args); |
|
| 649 | + $args = func_get_args(); |
|
| 650 | + return auth_administrer('autoriser_modifier_pass', $args); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -663,8 +663,8 @@ discard block |
||
| 663 | 663 | * message d'erreur ou chaine vide si pas d'erreur |
| 664 | 664 | */ |
| 665 | 665 | function auth_verifier_pass($auth_methode, $login, $new_pass, $id_auteur = 0, $serveur = '') { |
| 666 | - $args = func_get_args(); |
|
| 667 | - return auth_administrer('verifier_pass', $args, ''); |
|
| 666 | + $args = func_get_args(); |
|
| 667 | + return auth_administrer('verifier_pass', $args, ''); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | /** |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | * succes ou echec |
| 681 | 681 | */ |
| 682 | 682 | function auth_modifier_pass($auth_methode, $login, $new_pass, $id_auteur, $serveur = '') { |
| 683 | - $args = func_get_args(); |
|
| 684 | - return auth_administrer('modifier_pass', $args); |
|
| 683 | + $args = func_get_args(); |
|
| 684 | + return auth_administrer('modifier_pass', $args); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -697,24 +697,24 @@ discard block |
||
| 697 | 697 | * @return void |
| 698 | 698 | */ |
| 699 | 699 | function auth_synchroniser_distant( |
| 700 | - $auth_methode = true, |
|
| 701 | - $id_auteur = 0, |
|
| 702 | - $champs = [], |
|
| 703 | - $options = [], |
|
| 704 | - $serveur = '' |
|
| 700 | + $auth_methode = true, |
|
| 701 | + $id_auteur = 0, |
|
| 702 | + $champs = [], |
|
| 703 | + $options = [], |
|
| 704 | + $serveur = '' |
|
| 705 | 705 | ) { |
| 706 | - $args = func_get_args(); |
|
| 707 | - if ($auth_methode === true or (isset($options['all']) and $options['all'] == true)) { |
|
| 708 | - $options['all'] = true; // ajouter une option all=>true pour chaque auth |
|
| 709 | - $args = [true, $id_auteur, $champs, $options, $serveur]; |
|
| 710 | - foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 711 | - array_shift($args); |
|
| 712 | - array_unshift($args, $methode); |
|
| 713 | - auth_administrer('synchroniser_distant', $args); |
|
| 714 | - } |
|
| 715 | - } else { |
|
| 716 | - auth_administrer('synchroniser_distant', $args); |
|
| 717 | - } |
|
| 706 | + $args = func_get_args(); |
|
| 707 | + if ($auth_methode === true or (isset($options['all']) and $options['all'] == true)) { |
|
| 708 | + $options['all'] = true; // ajouter une option all=>true pour chaque auth |
|
| 709 | + $args = [true, $id_auteur, $champs, $options, $serveur]; |
|
| 710 | + foreach ($GLOBALS['liste_des_authentifications'] as $methode) { |
|
| 711 | + array_shift($args); |
|
| 712 | + array_unshift($args, $methode); |
|
| 713 | + auth_administrer('synchroniser_distant', $args); |
|
| 714 | + } |
|
| 715 | + } else { |
|
| 716 | + auth_administrer('synchroniser_distant', $args); |
|
| 717 | + } |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | |
@@ -727,44 +727,44 @@ discard block |
||
| 727 | 727 | * @return array|bool |
| 728 | 728 | */ |
| 729 | 729 | function lire_php_auth($login, $pw, $serveur = '') { |
| 730 | - if ( |
|
| 731 | - !$login |
|
| 732 | - or !$login = auth_retrouver_login($login, $serveur) |
|
| 733 | - ) { |
|
| 734 | - return false; |
|
| 735 | - } |
|
| 736 | - |
|
| 737 | - $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login, $serveur, 'text'), '', '', '', '', $serveur); |
|
| 738 | - |
|
| 739 | - if (!$row) { |
|
| 740 | - if ( |
|
| 741 | - spip_connect_ldap($serveur) |
|
| 742 | - and $auth_ldap = charger_fonction('ldap', 'auth', true) |
|
| 743 | - ) { |
|
| 744 | - return $auth_ldap($login, $pw, $serveur, true); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - return false; |
|
| 748 | - } |
|
| 749 | - // su pas de source definie |
|
| 750 | - // ou auth/xxx introuvable, utiliser 'spip' |
|
| 751 | - if ( |
|
| 752 | - !$auth_methode = $row['source'] |
|
| 753 | - or !$auth = charger_fonction($auth_methode, 'auth', true) |
|
| 754 | - ) { |
|
| 755 | - $auth = charger_fonction('spip', 'auth', true); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - $auteur = ''; |
|
| 759 | - if ($auth) { |
|
| 760 | - $auteur = $auth($login, $pw, $serveur, true); |
|
| 761 | - } |
|
| 762 | - // verifier que ce n'est pas un message d'erreur |
|
| 763 | - if (is_array($auteur) and count($auteur)) { |
|
| 764 | - return $auteur; |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - return false; |
|
| 730 | + if ( |
|
| 731 | + !$login |
|
| 732 | + or !$login = auth_retrouver_login($login, $serveur) |
|
| 733 | + ) { |
|
| 734 | + return false; |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login, $serveur, 'text'), '', '', '', '', $serveur); |
|
| 738 | + |
|
| 739 | + if (!$row) { |
|
| 740 | + if ( |
|
| 741 | + spip_connect_ldap($serveur) |
|
| 742 | + and $auth_ldap = charger_fonction('ldap', 'auth', true) |
|
| 743 | + ) { |
|
| 744 | + return $auth_ldap($login, $pw, $serveur, true); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + return false; |
|
| 748 | + } |
|
| 749 | + // su pas de source definie |
|
| 750 | + // ou auth/xxx introuvable, utiliser 'spip' |
|
| 751 | + if ( |
|
| 752 | + !$auth_methode = $row['source'] |
|
| 753 | + or !$auth = charger_fonction($auth_methode, 'auth', true) |
|
| 754 | + ) { |
|
| 755 | + $auth = charger_fonction('spip', 'auth', true); |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + $auteur = ''; |
|
| 759 | + if ($auth) { |
|
| 760 | + $auteur = $auth($login, $pw, $serveur, true); |
|
| 761 | + } |
|
| 762 | + // verifier que ce n'est pas un message d'erreur |
|
| 763 | + if (is_array($auteur) and count($auteur)) { |
|
| 764 | + return $auteur; |
|
| 765 | + } |
|
| 766 | + |
|
| 767 | + return false; |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -780,21 +780,21 @@ discard block |
||
| 780 | 780 | * @param string $lien |
| 781 | 781 | */ |
| 782 | 782 | function ask_php_auth($pb, $raison, $retour = '', $url = '', $re = '', $lien = '') { |
| 783 | - @Header('WWW-Authenticate: Basic realm="espace prive"'); |
|
| 784 | - @Header('HTTP/1.0 401 Unauthorized'); |
|
| 785 | - $corps = ''; |
|
| 786 | - $public = generer_url_public(); |
|
| 787 | - $ecrire = generer_url_ecrire(); |
|
| 788 | - $retour = $retour ? $retour : _T('icone_retour'); |
|
| 789 | - $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] "; |
|
| 790 | - if ($url) { |
|
| 791 | - $corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]"; |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - if ($lien) { |
|
| 795 | - $corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]'; |
|
| 796 | - } |
|
| 797 | - include_spip('inc/minipres'); |
|
| 798 | - echo minipres($pb, $corps); |
|
| 799 | - exit; |
|
| 783 | + @Header('WWW-Authenticate: Basic realm="espace prive"'); |
|
| 784 | + @Header('HTTP/1.0 401 Unauthorized'); |
|
| 785 | + $corps = ''; |
|
| 786 | + $public = generer_url_public(); |
|
| 787 | + $ecrire = generer_url_ecrire(); |
|
| 788 | + $retour = $retour ? $retour : _T('icone_retour'); |
|
| 789 | + $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] "; |
|
| 790 | + if ($url) { |
|
| 791 | + $corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]"; |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + if ($lien) { |
|
| 795 | + $corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]'; |
|
| 796 | + } |
|
| 797 | + include_spip('inc/minipres'); |
|
| 798 | + echo minipres($pb, $corps); |
|
| 799 | + exit; |
|
| 800 | 800 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $n = intval(sql_errno()); |
| 62 | - spip_log("Erreur base de donnees $n " . sql_error()); |
|
| 62 | + spip_log("Erreur base de donnees $n ".sql_error()); |
|
| 63 | 63 | |
| 64 | 64 | return $n ? $n : 1; |
| 65 | 65 | } |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | // erreur SQL a afficher |
| 86 | 86 | $raison = minipres( |
| 87 | 87 | _T('info_travaux_titre'), |
| 88 | - _T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>' |
|
| 88 | + _T('titre_probleme_technique').'<p><tt>'.sql_errno().' '.sql_error().'</tt></p>' |
|
| 89 | 89 | ); |
| 90 | 90 | } elseif (@$raison['statut']) { |
| 91 | 91 | // un simple visiteur n'a pas acces a l'espace prive |
| 92 | - spip_log('connexion refusee a ' . @$raison['id_auteur']); |
|
| 92 | + spip_log('connexion refusee a '.@$raison['id_auteur']); |
|
| 93 | 93 | $raison = minipres(_T('avis_erreur_connexion'), _T('avis_erreur_visiteur')); |
| 94 | 94 | } else { |
| 95 | 95 | // auteur en fin de droits ... |
@@ -179,8 +179,7 @@ discard block |
||
| 179 | 179 | $where = (is_numeric($id_auteur) |
| 180 | 180 | /*AND $id_auteur>0*/ // reprise lors des restaurations |
| 181 | 181 | ) ? |
| 182 | - "id_auteur=$id_auteur" : |
|
| 183 | - (!strlen($GLOBALS['connect_login']) ? '' : 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text')); |
|
| 182 | + "id_auteur=$id_auteur" : (!strlen($GLOBALS['connect_login']) ? '' : 'login='.sql_quote($GLOBALS['connect_login'], '', 'text')); |
|
| 184 | 183 | |
| 185 | 184 | if (!$where) { |
| 186 | 185 | return ''; |
@@ -222,7 +221,7 @@ discard block |
||
| 222 | 221 | $GLOBALS['connect_login'] = $row['login']; |
| 223 | 222 | $GLOBALS['connect_statut'] = $row['statut']; |
| 224 | 223 | |
| 225 | - $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row); |
|
| 224 | + $GLOBALS['visiteur_session'] = array_merge((array) $GLOBALS['visiteur_session'], $row); |
|
| 226 | 225 | |
| 227 | 226 | // au cas ou : ne pas memoriser les champs sensibles |
| 228 | 227 | unset($GLOBALS['visiteur_session']['pass']); |
@@ -295,7 +294,7 @@ discard block |
||
| 295 | 294 | * @return string |
| 296 | 295 | */ |
| 297 | 296 | function auth_a_loger() { |
| 298 | - $redirect = generer_url_public('login', 'url=' . rawurlencode(self('&', true)), '&'); |
|
| 297 | + $redirect = generer_url_public('login', 'url='.rawurlencode(self('&', true)), '&'); |
|
| 299 | 298 | |
| 300 | 299 | // un echec au "bonjour" (login initial) quand le statut est |
| 301 | 300 | // inconnu signale sans doute un probleme de cookies |
@@ -333,7 +332,7 @@ discard block |
||
| 333 | 332 | } |
| 334 | 333 | |
| 335 | 334 | if (abs(strtotime($date) - $connect_quand) >= 60) { |
| 336 | - sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . intval($row['id_auteur'])); |
|
| 335 | + sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur='.intval($row['id_auteur'])); |
|
| 337 | 336 | $row['en_ligne'] = $date; |
| 338 | 337 | } |
| 339 | 338 | |
@@ -442,13 +441,13 @@ discard block |
||
| 442 | 441 | if ( |
| 443 | 442 | !$login |
| 444 | 443 | or !$login_base = auth_retrouver_login($login, $serveur) |
| 445 | - or !$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur) |
|
| 444 | + or !$row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur) |
|
| 446 | 445 | ) { |
| 447 | 446 | // generer de fausses infos, mais credibles, pour eviter une attaque |
| 448 | 447 | // https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691 |
| 449 | 448 | include_spip('inc/securiser_action'); |
| 450 | - $fauxalea1 = md5('fauxalea' . secret_du_site() . $login . floor(date('U') / 86400)); |
|
| 451 | - $fauxalea2 = md5('fauxalea' . secret_du_site() . $login . ceil(date('U') / 86400)); |
|
| 449 | + $fauxalea1 = md5('fauxalea'.secret_du_site().$login.floor(date('U') / 86400)); |
|
| 450 | + $fauxalea2 = md5('fauxalea'.secret_du_site().$login.ceil(date('U') / 86400)); |
|
| 452 | 451 | |
| 453 | 452 | $row = [ |
| 454 | 453 | 'login' => $login, |
@@ -570,7 +569,7 @@ discard block |
||
| 570 | 569 | sql_updateq( |
| 571 | 570 | 'spip_auteurs', |
| 572 | 571 | ['prefs' => serialize($p)], |
| 573 | - 'id_auteur=' . intval($auteur['id_auteur']) |
|
| 572 | + 'id_auteur='.intval($auteur['id_auteur']) |
|
| 574 | 573 | ); |
| 575 | 574 | |
| 576 | 575 | // bloquer ici le visiteur qui tente d'abuser de ses droits |
@@ -734,7 +733,7 @@ discard block |
||
| 734 | 733 | return false; |
| 735 | 734 | } |
| 736 | 735 | |
| 737 | - $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login, $serveur, 'text'), '', '', '', '', $serveur); |
|
| 736 | + $row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login, $serveur, 'text'), '', '', '', '', $serveur); |
|
| 738 | 737 | |
| 739 | 738 | if (!$row) { |
| 740 | 739 | if ( |
@@ -788,11 +787,11 @@ discard block |
||
| 788 | 787 | $retour = $retour ? $retour : _T('icone_retour'); |
| 789 | 788 | $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] "; |
| 790 | 789 | if ($url) { |
| 791 | - $corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]"; |
|
| 790 | + $corps .= "[<a href='".generer_url_action('cookie', "essai_auth_http=oui&$url")."'>$re</a>]"; |
|
| 792 | 791 | } |
| 793 | 792 | |
| 794 | 793 | if ($lien) { |
| 795 | - $corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]'; |
|
| 794 | + $corps .= " [<a href='$ecrire'>"._T('login_espace_prive').'</a>]'; |
|
| 796 | 795 | } |
| 797 | 796 | include_spip('inc/minipres'); |
| 798 | 797 | echo minipres($pb, $corps); |
@@ -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 | /** |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | * Liste des fichiers de langue trouvés, dans l'ordre des chemins |
| 39 | 39 | */ |
| 40 | 40 | function find_langs_in_path($file, $dirname = 'lang') { |
| 41 | - static $dirs = []; |
|
| 42 | - $liste = []; |
|
| 43 | - foreach (creer_chemin() as $dir) { |
|
| 44 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 45 | - $dirs[$a] = (is_dir($a) || !$a); |
|
| 46 | - } |
|
| 47 | - if ($dirs[$a]) { |
|
| 48 | - if (is_readable($a .= $file)) { |
|
| 49 | - $liste[] = $a; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 41 | + static $dirs = []; |
|
| 42 | + $liste = []; |
|
| 43 | + foreach (creer_chemin() as $dir) { |
|
| 44 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 45 | + $dirs[$a] = (is_dir($a) || !$a); |
|
| 46 | + } |
|
| 47 | + if ($dirs[$a]) { |
|
| 48 | + if (is_readable($a .= $file)) { |
|
| 49 | + $liste[] = $a; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return array_reverse($liste); |
|
| 54 | + return array_reverse($liste); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | * Liste des fichiers touvés pour ce module et cette langue. |
| 67 | 67 | **/ |
| 68 | 68 | function chercher_module_lang($module, $lang = '') { |
| 69 | - if ($lang) { |
|
| 70 | - $lang = '_' . $lang; |
|
| 71 | - } |
|
| 69 | + if ($lang) { |
|
| 70 | + $lang = '_' . $lang; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
|
| 74 | - if ( |
|
| 75 | - $f = ($module == 'local' |
|
| 76 | - ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | - : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 78 | - ) { |
|
| 79 | - return is_array($f) ? $f : [$f]; |
|
| 80 | - } |
|
| 73 | + // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
|
| 74 | + if ( |
|
| 75 | + $f = ($module == 'local' |
|
| 76 | + ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | + : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 78 | + ) { |
|
| 79 | + return is_array($f) ? $f : [$f]; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // 2) directement dans le chemin (old style, uniquement pour local) |
|
| 83 | - return (($module == 'local') or strpos($module, '/')) |
|
| 84 | - ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 85 | - : false; |
|
| 82 | + // 2) directement dans le chemin (old style, uniquement pour local) |
|
| 83 | + return (($module == 'local') or strpos($module, '/')) |
|
| 84 | + ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 85 | + : false; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -104,33 +104,33 @@ discard block |
||
| 104 | 104 | * @return string Langue du module chargé, sinon chaîne vide. |
| 105 | 105 | **/ |
| 106 | 106 | function charger_langue($lang, $module = 'spip') { |
| 107 | - static $langs = []; |
|
| 108 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 109 | - if (!isset($langs[$lang])) { |
|
| 110 | - $langs[$lang] = []; |
|
| 111 | - if ($lang) { |
|
| 112 | - $langs[$lang][] = $lang; |
|
| 113 | - if (strpos($lang, '_') !== false) { |
|
| 114 | - $l = explode('_', $lang); |
|
| 115 | - $langs[$lang][] = reset($l); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - $langs[$lang][] = $GLOBALS['meta']['langue_site']; |
|
| 119 | - $langs[$lang][] = _LANGUE_PAR_DEFAUT; |
|
| 120 | - } |
|
| 121 | - foreach ($langs[$lang] as $l) { |
|
| 122 | - if ($fichiers_lang = chercher_module_lang($module, $l)) { |
|
| 123 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 124 | - include(array_shift($fichiers_lang)); |
|
| 125 | - surcharger_langue($fichiers_lang); |
|
| 126 | - if ($l !== $lang) { |
|
| 127 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 128 | - } |
|
| 129 | - $GLOBALS['lang_' . $var] = $l; |
|
| 130 | - #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
|
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - } |
|
| 107 | + static $langs = []; |
|
| 108 | + $var = 'i18n_' . $module . '_' . $lang; |
|
| 109 | + if (!isset($langs[$lang])) { |
|
| 110 | + $langs[$lang] = []; |
|
| 111 | + if ($lang) { |
|
| 112 | + $langs[$lang][] = $lang; |
|
| 113 | + if (strpos($lang, '_') !== false) { |
|
| 114 | + $l = explode('_', $lang); |
|
| 115 | + $langs[$lang][] = reset($l); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + $langs[$lang][] = $GLOBALS['meta']['langue_site']; |
|
| 119 | + $langs[$lang][] = _LANGUE_PAR_DEFAUT; |
|
| 120 | + } |
|
| 121 | + foreach ($langs[$lang] as $l) { |
|
| 122 | + if ($fichiers_lang = chercher_module_lang($module, $l)) { |
|
| 123 | + $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 124 | + include(array_shift($fichiers_lang)); |
|
| 125 | + surcharger_langue($fichiers_lang); |
|
| 126 | + if ($l !== $lang) { |
|
| 127 | + $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 128 | + } |
|
| 129 | + $GLOBALS['lang_' . $var] = $l; |
|
| 130 | + #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -150,50 +150,50 @@ discard block |
||
| 150 | 150 | * Liste des chemins de fichiers de langue à surcharger. |
| 151 | 151 | **/ |
| 152 | 152 | function surcharger_langue($fichiers) { |
| 153 | - static $surcharges = []; |
|
| 154 | - if (!isset($GLOBALS['idx_lang'])) { |
|
| 155 | - return; |
|
| 156 | - } |
|
| 153 | + static $surcharges = []; |
|
| 154 | + if (!isset($GLOBALS['idx_lang'])) { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - if (!is_array($fichiers)) { |
|
| 159 | - $fichiers = [$fichiers]; |
|
| 160 | - } |
|
| 161 | - if (!count($fichiers)) { |
|
| 162 | - return; |
|
| 163 | - } |
|
| 164 | - foreach ($fichiers as $fichier) { |
|
| 165 | - if (!isset($surcharges[$fichier])) { |
|
| 166 | - $idx_lang_normal = $GLOBALS['idx_lang']; |
|
| 167 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 168 | - include($fichier); |
|
| 169 | - $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
|
| 170 | - unset($GLOBALS[$GLOBALS['idx_lang']]); |
|
| 171 | - $GLOBALS['idx_lang'] = $idx_lang_normal; |
|
| 172 | - } |
|
| 173 | - if (is_array($surcharges[$fichier])) { |
|
| 174 | - $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
|
| 175 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | - $surcharges[$fichier] |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - } |
|
| 158 | + if (!is_array($fichiers)) { |
|
| 159 | + $fichiers = [$fichiers]; |
|
| 160 | + } |
|
| 161 | + if (!count($fichiers)) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 164 | + foreach ($fichiers as $fichier) { |
|
| 165 | + if (!isset($surcharges[$fichier])) { |
|
| 166 | + $idx_lang_normal = $GLOBALS['idx_lang']; |
|
| 167 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 168 | + include($fichier); |
|
| 169 | + $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
|
| 170 | + unset($GLOBALS[$GLOBALS['idx_lang']]); |
|
| 171 | + $GLOBALS['idx_lang'] = $idx_lang_normal; |
|
| 172 | + } |
|
| 173 | + if (is_array($surcharges[$fichier])) { |
|
| 174 | + $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
|
| 175 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | + $surcharges[$fichier] |
|
| 177 | + ); |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | class SPIP_Traductions_Description { |
| 185 | - /** @var string code de langue (hors module) */ |
|
| 186 | - public $code; |
|
| 187 | - /** @var string nom du module de langue */ |
|
| 188 | - public $module; |
|
| 189 | - /** @var string langue de la traduction */ |
|
| 190 | - public $langue; |
|
| 191 | - /** @var string traduction */ |
|
| 192 | - public $texte; |
|
| 193 | - /** @var string var mode particulier appliqué ? */ |
|
| 194 | - public $mode; |
|
| 195 | - /** @var bool Corrections des textes appliqué ? */ |
|
| 196 | - public $corrections = false; |
|
| 185 | + /** @var string code de langue (hors module) */ |
|
| 186 | + public $code; |
|
| 187 | + /** @var string nom du module de langue */ |
|
| 188 | + public $module; |
|
| 189 | + /** @var string langue de la traduction */ |
|
| 190 | + public $langue; |
|
| 191 | + /** @var string traduction */ |
|
| 192 | + public $texte; |
|
| 193 | + /** @var string var mode particulier appliqué ? */ |
|
| 194 | + public $mode; |
|
| 195 | + /** @var bool Corrections des textes appliqué ? */ |
|
| 196 | + public $corrections = false; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -235,96 +235,96 @@ discard block |
||
| 235 | 235 | * - SPIP_Traductions_Description : traduction et description (texte, module, langue) |
| 236 | 236 | **/ |
| 237 | 237 | function inc_traduire_dist($ori, $lang, $raw = false) { |
| 238 | - static $deja_vu = []; |
|
| 239 | - static $local = []; |
|
| 238 | + static $deja_vu = []; |
|
| 239 | + static $local = []; |
|
| 240 | 240 | |
| 241 | - if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { |
|
| 242 | - return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte; |
|
| 243 | - } |
|
| 241 | + if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { |
|
| 242 | + return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES |
|
| 246 | - if (strpos($ori, ':')) { |
|
| 247 | - list($modules, $code) = explode(':', $ori, 2); |
|
| 248 | - $modules = explode('|', $modules); |
|
| 249 | - $ori_complet = $ori; |
|
| 250 | - } else { |
|
| 251 | - $modules = ['spip', 'ecrire']; |
|
| 252 | - $code = $ori; |
|
| 253 | - $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 254 | - } |
|
| 245 | + // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES |
|
| 246 | + if (strpos($ori, ':')) { |
|
| 247 | + list($modules, $code) = explode(':', $ori, 2); |
|
| 248 | + $modules = explode('|', $modules); |
|
| 249 | + $ori_complet = $ori; |
|
| 250 | + } else { |
|
| 251 | + $modules = ['spip', 'ecrire']; |
|
| 252 | + $code = $ori; |
|
| 253 | + $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - $desc = new SPIP_Traductions_Description(); |
|
| 256 | + $desc = new SPIP_Traductions_Description(); |
|
| 257 | 257 | |
| 258 | - // parcourir tous les modules jusqu'a ce qu'on trouve |
|
| 259 | - foreach ($modules as $module) { |
|
| 260 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 258 | + // parcourir tous les modules jusqu'a ce qu'on trouve |
|
| 259 | + foreach ($modules as $module) { |
|
| 260 | + $var = 'i18n_' . $module . '_' . $lang; |
|
| 261 | 261 | |
| 262 | - if (empty($GLOBALS[$var])) { |
|
| 263 | - charger_langue($lang, $module); |
|
| 264 | - // surcharges persos -- on cherche |
|
| 265 | - // (lang/)local_xx.php et/ou (lang/)local.php ... |
|
| 266 | - if (!isset($local['local_' . $lang])) { |
|
| 267 | - // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
|
| 268 | - $GLOBALS['idx_lang'] = $var; |
|
| 269 | - // ... (lang/)local_xx.php |
|
| 270 | - $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 271 | - } |
|
| 272 | - if ($local['local_' . $lang]) { |
|
| 273 | - surcharger_langue($local['local_' . $lang]); |
|
| 274 | - } |
|
| 275 | - // ... puis (lang/)local.php |
|
| 276 | - if (!isset($local['local'])) { |
|
| 277 | - $local['local'] = chercher_module_lang('local'); |
|
| 278 | - } |
|
| 279 | - if ($local['local']) { |
|
| 280 | - surcharger_langue($local['local']); |
|
| 281 | - } |
|
| 282 | - } |
|
| 262 | + if (empty($GLOBALS[$var])) { |
|
| 263 | + charger_langue($lang, $module); |
|
| 264 | + // surcharges persos -- on cherche |
|
| 265 | + // (lang/)local_xx.php et/ou (lang/)local.php ... |
|
| 266 | + if (!isset($local['local_' . $lang])) { |
|
| 267 | + // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
|
| 268 | + $GLOBALS['idx_lang'] = $var; |
|
| 269 | + // ... (lang/)local_xx.php |
|
| 270 | + $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 271 | + } |
|
| 272 | + if ($local['local_' . $lang]) { |
|
| 273 | + surcharger_langue($local['local_' . $lang]); |
|
| 274 | + } |
|
| 275 | + // ... puis (lang/)local.php |
|
| 276 | + if (!isset($local['local'])) { |
|
| 277 | + $local['local'] = chercher_module_lang('local'); |
|
| 278 | + } |
|
| 279 | + if ($local['local']) { |
|
| 280 | + surcharger_langue($local['local']); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - if (isset($GLOBALS[$var][$code])) { |
|
| 285 | - $desc->code = $code; |
|
| 286 | - $desc->module = $module; |
|
| 287 | - $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 288 | - $desc->texte = $GLOBALS[$var][$code]; |
|
| 289 | - break; |
|
| 290 | - } |
|
| 291 | - } |
|
| 284 | + if (isset($GLOBALS[$var][$code])) { |
|
| 285 | + $desc->code = $code; |
|
| 286 | + $desc->module = $module; |
|
| 287 | + $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 288 | + $desc->texte = $GLOBALS[$var][$code]; |
|
| 289 | + break; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - if (!$desc->corrections) { |
|
| 294 | - $desc->corrections = true; |
|
| 295 | - // Retour aux sources si la chaine est absente dans la langue cible ; |
|
| 296 | - // on essaie d'abord la langue du site, puis a defaut la langue fr |
|
| 297 | - if (!strlen($desc->texte) and $lang !== _LANGUE_PAR_DEFAUT) { |
|
| 298 | - if ($lang !== $GLOBALS['meta']['langue_site']) { |
|
| 299 | - $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true); |
|
| 300 | - } else { |
|
| 301 | - $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true); |
|
| 302 | - } |
|
| 303 | - } |
|
| 293 | + if (!$desc->corrections) { |
|
| 294 | + $desc->corrections = true; |
|
| 295 | + // Retour aux sources si la chaine est absente dans la langue cible ; |
|
| 296 | + // on essaie d'abord la langue du site, puis a defaut la langue fr |
|
| 297 | + if (!strlen($desc->texte) and $lang !== _LANGUE_PAR_DEFAUT) { |
|
| 298 | + if ($lang !== $GLOBALS['meta']['langue_site']) { |
|
| 299 | + $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true); |
|
| 300 | + } else { |
|
| 301 | + $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true); |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - // Supprimer la mention <NEW> ou <MODIF> |
|
| 306 | - if (substr($desc->texte, 0, 1) === '<') { |
|
| 307 | - $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte); |
|
| 308 | - } |
|
| 305 | + // Supprimer la mention <NEW> ou <MODIF> |
|
| 306 | + if (substr($desc->texte, 0, 1) === '<') { |
|
| 307 | + $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte); |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - // Si on n'est pas en utf-8, la chaine peut l'etre... |
|
| 311 | - // le cas echeant on la convertit en entites html &#xxx; |
|
| 312 | - if ( |
|
| 313 | - (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8') |
|
| 314 | - and preg_match(',[\x7f-\xff],S', $desc->texte) |
|
| 315 | - ) { |
|
| 316 | - include_spip('inc/charsets'); |
|
| 317 | - $desc->texte = charset2unicode($desc->texte, 'utf-8'); |
|
| 318 | - } |
|
| 319 | - } |
|
| 310 | + // Si on n'est pas en utf-8, la chaine peut l'etre... |
|
| 311 | + // le cas echeant on la convertit en entites html &#xxx; |
|
| 312 | + if ( |
|
| 313 | + (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8') |
|
| 314 | + and preg_match(',[\x7f-\xff],S', $desc->texte) |
|
| 315 | + ) { |
|
| 316 | + include_spip('inc/charsets'); |
|
| 317 | + $desc->texte = charset2unicode($desc->texte, 'utf-8'); |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - if (_request('var_mode') == 'traduction') { |
|
| 322 | - $desc = definir_details_traduction($desc, $ori_complet); |
|
| 323 | - } else { |
|
| 324 | - $deja_vu[$lang][$ori] = $desc; |
|
| 325 | - } |
|
| 321 | + if (_request('var_mode') == 'traduction') { |
|
| 322 | + $desc = definir_details_traduction($desc, $ori_complet); |
|
| 323 | + } else { |
|
| 324 | + $deja_vu[$lang][$ori] = $desc; |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - return $raw ? $desc : $desc->texte; |
|
| 327 | + return $raw ? $desc : $desc->texte; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -336,23 +336,23 @@ discard block |
||
| 336 | 336 | * @return SPIP_Traductions_Description |
| 337 | 337 | */ |
| 338 | 338 | function definir_details_traduction($desc, $modules) { |
| 339 | - if (!$desc->mode and $desc->texte) { |
|
| 340 | - // ne pas modifier 2 fois l'affichage |
|
| 341 | - $desc->mode = 'traduction'; |
|
| 342 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 343 | - $desc->texte = '<span ' |
|
| 344 | - . 'lang=' . $desc->langue |
|
| 345 | - . ' class=' . $classe |
|
| 346 | - . ' data-module=' . $desc->module |
|
| 347 | - . ' data-code=' . $desc->code |
|
| 348 | - . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 349 | - . $desc->texte |
|
| 350 | - . '</span>'; |
|
| 351 | - $desc->texte = str_replace( |
|
| 352 | - ["$desc->module:", "$desc->module|"], |
|
| 353 | - ["*$desc->module*:", "*$desc->module*|"], |
|
| 354 | - $desc->texte |
|
| 355 | - ); |
|
| 356 | - } |
|
| 357 | - return $desc; |
|
| 339 | + if (!$desc->mode and $desc->texte) { |
|
| 340 | + // ne pas modifier 2 fois l'affichage |
|
| 341 | + $desc->mode = 'traduction'; |
|
| 342 | + $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 343 | + $desc->texte = '<span ' |
|
| 344 | + . 'lang=' . $desc->langue |
|
| 345 | + . ' class=' . $classe |
|
| 346 | + . ' data-module=' . $desc->module |
|
| 347 | + . ' data-code=' . $desc->code |
|
| 348 | + . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 349 | + . $desc->texte |
|
| 350 | + . '</span>'; |
|
| 351 | + $desc->texte = str_replace( |
|
| 352 | + ["$desc->module:", "$desc->module|"], |
|
| 353 | + ["*$desc->module*:", "*$desc->module*|"], |
|
| 354 | + $desc->texte |
|
| 355 | + ); |
|
| 356 | + } |
|
| 357 | + return $desc; |
|
| 358 | 358 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | static $dirs = []; |
| 42 | 42 | $liste = []; |
| 43 | 43 | foreach (creer_chemin() as $dir) { |
| 44 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 44 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 45 | 45 | $dirs[$a] = (is_dir($a) || !$a); |
| 46 | 46 | } |
| 47 | 47 | if ($dirs[$a]) { |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | **/ |
| 68 | 68 | function chercher_module_lang($module, $lang = '') { |
| 69 | 69 | if ($lang) { |
| 70 | - $lang = '_' . $lang; |
|
| 70 | + $lang = '_'.$lang; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
| 74 | 74 | if ( |
| 75 | 75 | $f = ($module == 'local' |
| 76 | - ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | - : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 76 | + ? find_in_path($module.$lang.'.php', 'lang/') |
|
| 77 | + : find_langs_in_path($module.$lang.'.php', 'lang/')) |
|
| 78 | 78 | ) { |
| 79 | 79 | return is_array($f) ? $f : [$f]; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // 2) directement dans le chemin (old style, uniquement pour local) |
| 83 | 83 | return (($module == 'local') or strpos($module, '/')) |
| 84 | - ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 84 | + ? (($f = find_in_path($module.$lang.'.php')) ? [$f] : false) |
|
| 85 | 85 | : false; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | **/ |
| 106 | 106 | function charger_langue($lang, $module = 'spip') { |
| 107 | 107 | static $langs = []; |
| 108 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 108 | + $var = 'i18n_'.$module.'_'.$lang; |
|
| 109 | 109 | if (!isset($langs[$lang])) { |
| 110 | 110 | $langs[$lang] = []; |
| 111 | 111 | if ($lang) { |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | foreach ($langs[$lang] as $l) { |
| 122 | 122 | if ($fichiers_lang = chercher_module_lang($module, $l)) { |
| 123 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 123 | + $GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$l; |
|
| 124 | 124 | include(array_shift($fichiers_lang)); |
| 125 | 125 | surcharger_langue($fichiers_lang); |
| 126 | 126 | if ($l !== $lang) { |
| 127 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 127 | + $GLOBALS[$var] = &$GLOBALS['i18n_'.$module.'_'.$l]; |
|
| 128 | 128 | } |
| 129 | - $GLOBALS['lang_' . $var] = $l; |
|
| 129 | + $GLOBALS['lang_'.$var] = $l; |
|
| 130 | 130 | #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
| 131 | 131 | break; |
| 132 | 132 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | foreach ($fichiers as $fichier) { |
| 165 | 165 | if (!isset($surcharges[$fichier])) { |
| 166 | 166 | $idx_lang_normal = $GLOBALS['idx_lang']; |
| 167 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 167 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'].'@temporaire'; |
|
| 168 | 168 | include($fichier); |
| 169 | 169 | $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
| 170 | 170 | unset($GLOBALS[$GLOBALS['idx_lang']]); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | if (is_array($surcharges[$fichier])) { |
| 174 | 174 | $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
| 175 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 175 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array) $GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | 176 | $surcharges[$fichier] |
| 177 | 177 | ); |
| 178 | 178 | } |
@@ -250,27 +250,27 @@ discard block |
||
| 250 | 250 | } else { |
| 251 | 251 | $modules = ['spip', 'ecrire']; |
| 252 | 252 | $code = $ori; |
| 253 | - $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 253 | + $ori_complet = implode('|', $modules).':'.$ori; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $desc = new SPIP_Traductions_Description(); |
| 257 | 257 | |
| 258 | 258 | // parcourir tous les modules jusqu'a ce qu'on trouve |
| 259 | 259 | foreach ($modules as $module) { |
| 260 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 260 | + $var = 'i18n_'.$module.'_'.$lang; |
|
| 261 | 261 | |
| 262 | 262 | if (empty($GLOBALS[$var])) { |
| 263 | 263 | charger_langue($lang, $module); |
| 264 | 264 | // surcharges persos -- on cherche |
| 265 | 265 | // (lang/)local_xx.php et/ou (lang/)local.php ... |
| 266 | - if (!isset($local['local_' . $lang])) { |
|
| 266 | + if (!isset($local['local_'.$lang])) { |
|
| 267 | 267 | // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
| 268 | 268 | $GLOBALS['idx_lang'] = $var; |
| 269 | 269 | // ... (lang/)local_xx.php |
| 270 | - $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 270 | + $local['local_'.$lang] = chercher_module_lang('local', $lang); |
|
| 271 | 271 | } |
| 272 | - if ($local['local_' . $lang]) { |
|
| 273 | - surcharger_langue($local['local_' . $lang]); |
|
| 272 | + if ($local['local_'.$lang]) { |
|
| 273 | + surcharger_langue($local['local_'.$lang]); |
|
| 274 | 274 | } |
| 275 | 275 | // ... puis (lang/)local.php |
| 276 | 276 | if (!isset($local['local'])) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if (isset($GLOBALS[$var][$code])) { |
| 285 | 285 | $desc->code = $code; |
| 286 | 286 | $desc->module = $module; |
| 287 | - $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 287 | + $desc->langue = $GLOBALS['lang_'.$var]; |
|
| 288 | 288 | $desc->texte = $GLOBALS[$var][$code]; |
| 289 | 289 | break; |
| 290 | 290 | } |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | if (!$desc->mode and $desc->texte) { |
| 340 | 340 | // ne pas modifier 2 fois l'affichage |
| 341 | 341 | $desc->mode = 'traduction'; |
| 342 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 342 | + $classe = 'debug-traduction'.($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 343 | 343 | $desc->texte = '<span ' |
| 344 | - . 'lang=' . $desc->langue |
|
| 345 | - . ' class=' . $classe |
|
| 346 | - . ' data-module=' . $desc->module |
|
| 347 | - . ' data-code=' . $desc->code |
|
| 348 | - . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 344 | + . 'lang='.$desc->langue |
|
| 345 | + . ' class='.$classe |
|
| 346 | + . ' data-module='.$desc->module |
|
| 347 | + . ' data-code='.$desc->code |
|
| 348 | + . ' title='.$modules.'('.$desc->langue.')>' |
|
| 349 | 349 | . $desc->texte |
| 350 | 350 | . '</span>'; |
| 351 | 351 | $desc->texte = str_replace( |
@@ -18,206 +18,206 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $GLOBALS['codes_langues'] = [ |
| 25 | - 'aa' => 'Afar', |
|
| 26 | - 'ab' => 'Abkhazian', |
|
| 27 | - 'af' => 'Afrikaans', |
|
| 28 | - 'am' => 'Amharic', |
|
| 29 | - 'an' => 'Aragonés', |
|
| 30 | - 'ar' => 'عربي', |
|
| 31 | - 'as' => 'Assamese', |
|
| 32 | - 'ast' => 'asturianu', |
|
| 33 | - 'ay' => 'Aymara', |
|
| 34 | - 'az' => 'Azərbaycan dili', |
|
| 35 | - 'ba' => 'Bashkir', |
|
| 36 | - 'be' => 'Беларуская', |
|
| 37 | - 'ber_tam' => 'Tamazigh', |
|
| 38 | - 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | - 'bg' => 'български', |
|
| 40 | - 'bh' => 'Bihari', |
|
| 41 | - 'bi' => 'Bislama', |
|
| 42 | - 'bm' => 'Bambara', |
|
| 43 | - 'bn' => 'Bengali; Bangla', |
|
| 44 | - 'bo' => 'Tibetan', |
|
| 45 | - 'br' => 'brezhoneg', |
|
| 46 | - 'bs' => 'bosanski', |
|
| 47 | - 'ca' => 'català', |
|
| 48 | - 'co' => 'corsu', |
|
| 49 | - 'cpf' => 'Kréol réyoné', |
|
| 50 | - 'cpf_dom' => 'Kreyòl', |
|
| 51 | - 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | - 'cs' => 'čeština', |
|
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | - 'da' => 'dansk', |
|
| 55 | - 'de' => 'Deutsch', |
|
| 56 | - 'dz' => 'Bhutani', |
|
| 57 | - 'el' => 'ελληνικά', |
|
| 58 | - 'en' => 'English', |
|
| 59 | - 'en_hx' => 'H4ck3R', |
|
| 60 | - 'en_sm' => 'Smurf', |
|
| 61 | - 'eo' => 'Esperanto', |
|
| 62 | - 'es' => 'Español', |
|
| 63 | - 'es_co' => 'Colombiano', |
|
| 64 | - 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | - 'et' => 'eesti', |
|
| 66 | - 'eu' => 'euskara', |
|
| 67 | - 'fa' => 'فارسى', |
|
| 68 | - 'ff' => 'Fulah', // peul |
|
| 69 | - 'fi' => 'suomi', |
|
| 70 | - 'fj' => 'Fiji', |
|
| 71 | - 'fo' => 'føroyskt', |
|
| 72 | - 'fon' => 'fongbè', |
|
| 73 | - 'fr' => 'français', |
|
| 74 | - 'fr_fem' => 'français féminin', |
|
| 75 | - 'fr_sc' => 'schtroumpf', |
|
| 76 | - 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | - 'fr_lsf' => 'langue des signes française', |
|
| 78 | - 'fr_spl' => 'français simplifié', |
|
| 79 | - 'fr_tu' => 'français copain', |
|
| 80 | - 'fy' => 'Frisian', |
|
| 81 | - 'ga' => 'Irish', |
|
| 82 | - 'gd' => 'Scots Gaelic', |
|
| 83 | - 'gl' => 'galego', |
|
| 84 | - 'gn' => 'Guarani', |
|
| 85 | - 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | - 'gu' => 'Gujarati', |
|
| 87 | - 'ha' => 'Hausa', |
|
| 88 | - 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | - 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | - 'haz' => 'هزاره گی', |
|
| 91 | - 'he' => 'עברית', |
|
| 92 | - 'hi' => 'हिंदी', |
|
| 93 | - 'hr' => 'hrvatski', |
|
| 94 | - 'hu' => 'magyar', |
|
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 96 | - 'ia' => 'Interlingua', |
|
| 97 | - 'id' => 'Indonesia', |
|
| 98 | - 'ie' => 'Interlingue', |
|
| 99 | - 'ik' => 'Inupiak', |
|
| 100 | - 'is' => 'íslenska', |
|
| 101 | - 'it' => 'italiano', |
|
| 102 | - 'it_fem' => 'italiana', |
|
| 103 | - 'iu' => 'Inuktitut', |
|
| 104 | - 'ja' => '日本語', |
|
| 105 | - 'jv' => 'Javanese', |
|
| 106 | - 'ka' => 'ქართული', |
|
| 107 | - 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | - 'kl' => 'kalaallisut', |
|
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | - 'kn' => 'Kannada', |
|
| 111 | - 'ko' => '한국어', |
|
| 112 | - 'kok' => 'कोंकणी', |
|
| 113 | - 'ks' => 'Kashmiri', |
|
| 114 | - 'ku' => 'کوردی', |
|
| 115 | - 'ky' => 'Kirghiz', |
|
| 116 | - 'la' => 'lingua latina', |
|
| 117 | - 'lb' => 'Lëtzebuergesch', |
|
| 118 | - 'ln' => 'Lingala', |
|
| 119 | - 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | - 'lt' => 'lietuvių', |
|
| 121 | - 'lu' => 'luba-katanga', |
|
| 122 | - 'lv' => 'latviešu', |
|
| 123 | - 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | - 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | - 'mg' => 'Malagasy', |
|
| 126 | - 'mi' => 'Maori', |
|
| 127 | - 'mk' => 'македонски јазик', |
|
| 128 | - 'ml' => 'Malayalam', |
|
| 129 | - 'mn' => 'Монгол хэл', |
|
| 130 | - 'mo' => 'Moldavian', |
|
| 131 | - 'mos' => 'Moré', |
|
| 132 | - 'mr' => 'मराठी', |
|
| 133 | - 'ms' => 'Bahasa Malaysia', |
|
| 134 | - 'mt' => 'Maltese', |
|
| 135 | - 'my' => 'Burmese', |
|
| 136 | - 'na' => 'Nauru', |
|
| 137 | - 'nap' => 'napulitano', |
|
| 138 | - 'ne' => 'Nepali', |
|
| 139 | - 'nqo' => "N'ko", // www.manden.org |
|
| 140 | - 'nl' => 'Nederlands', |
|
| 141 | - 'no' => 'norsk', |
|
| 142 | - 'nb' => 'norsk bokmål', |
|
| 143 | - 'nn' => 'norsk nynorsk', |
|
| 144 | - 'oc' => 'òc', |
|
| 145 | - 'oc_lnc' => 'òc lengadocian', |
|
| 146 | - 'oc_ni' => 'òc niçard', |
|
| 147 | - 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | - 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | - 'oc_prv' => 'òc provençau', |
|
| 150 | - 'oc_gsc' => 'òc gascon', |
|
| 151 | - 'oc_lms' => 'òc lemosin', |
|
| 152 | - 'oc_auv' => 'òc auvernhat', |
|
| 153 | - 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | - 'om' => '(Afan) Oromo', |
|
| 155 | - 'or' => 'Oriya', |
|
| 156 | - 'pa' => 'Punjabi', |
|
| 157 | - 'pbb' => 'Nasa Yuwe', |
|
| 158 | - 'pl' => 'polski', |
|
| 159 | - 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | - 'ps' => 'پښتو', |
|
| 161 | - 'pt' => 'Português', |
|
| 162 | - 'pt_br' => 'Português do Brasil', |
|
| 163 | - 'qu' => 'Quechua', |
|
| 164 | - 'rm' => 'Rhaeto-Romance', |
|
| 165 | - 'rn' => 'Kirundi', |
|
| 166 | - 'ro' => 'română', |
|
| 167 | - 'roa' => "ch'ti", |
|
| 168 | - 'ru' => 'русский', |
|
| 169 | - 'rw' => 'Kinyarwanda', |
|
| 170 | - 'sa' => 'संस्कृत', |
|
| 171 | - 'sc' => 'sardu', |
|
| 172 | - 'scn' => 'sicilianu', |
|
| 173 | - 'sd' => 'Sindhi', |
|
| 174 | - 'sg' => 'Sangho', |
|
| 175 | - 'sh' => 'srpskohrvastski', |
|
| 176 | - 'sh_latn' => 'srpskohrvastski', |
|
| 177 | - 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | - 'si' => 'Sinhalese', |
|
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | - 'sm' => 'Samoan', |
|
| 182 | - 'sn' => 'Shona', |
|
| 183 | - 'so' => 'Somali', |
|
| 184 | - 'sq' => 'shqip', |
|
| 185 | - 'sr' => 'српски', |
|
| 186 | - 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | - 'sro' => 'sardu campidanésu', |
|
| 188 | - 'ss' => 'Siswati', |
|
| 189 | - 'st' => 'Sesotho', |
|
| 190 | - 'su' => 'Sundanese', |
|
| 191 | - 'sv' => 'svenska', |
|
| 192 | - 'sw' => 'Kiswahili', |
|
| 193 | - 'ta' => 'தமிழ்', // Tamil |
|
| 194 | - 'te' => 'Telugu', |
|
| 195 | - 'tg' => 'Tajik', |
|
| 196 | - 'th' => 'ไทย', |
|
| 197 | - 'ti' => 'Tigrinya', |
|
| 198 | - 'tk' => 'Turkmen', |
|
| 199 | - 'tl' => 'Tagalog', |
|
| 200 | - 'tn' => 'Setswana', |
|
| 201 | - 'to' => 'Tonga', |
|
| 202 | - 'tr' => 'Türkçe', |
|
| 203 | - 'ts' => 'Tsonga', |
|
| 204 | - 'tt' => 'Татар', |
|
| 205 | - 'tw' => 'Twi', |
|
| 206 | - 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | - 'ug' => 'Uighur', |
|
| 208 | - 'uk' => 'українська', |
|
| 209 | - 'ur' => 'ٱردو', |
|
| 210 | - 'uz' => "O'zbekcha", |
|
| 211 | - 'vi' => 'Tiếng Việt', |
|
| 212 | - 'vo' => 'Volapuk', |
|
| 213 | - 'wa' => 'walon', |
|
| 214 | - 'wo' => 'Wolof', |
|
| 215 | - 'xh' => 'Xhosa', |
|
| 216 | - 'yi' => 'Yiddish', |
|
| 217 | - 'yo' => 'Yoruba', |
|
| 218 | - 'za' => 'Zhuang', |
|
| 219 | - 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | - 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | - 'zu' => 'Zulu' |
|
| 25 | + 'aa' => 'Afar', |
|
| 26 | + 'ab' => 'Abkhazian', |
|
| 27 | + 'af' => 'Afrikaans', |
|
| 28 | + 'am' => 'Amharic', |
|
| 29 | + 'an' => 'Aragonés', |
|
| 30 | + 'ar' => 'عربي', |
|
| 31 | + 'as' => 'Assamese', |
|
| 32 | + 'ast' => 'asturianu', |
|
| 33 | + 'ay' => 'Aymara', |
|
| 34 | + 'az' => 'Azərbaycan dili', |
|
| 35 | + 'ba' => 'Bashkir', |
|
| 36 | + 'be' => 'Беларуская', |
|
| 37 | + 'ber_tam' => 'Tamazigh', |
|
| 38 | + 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | + 'bg' => 'български', |
|
| 40 | + 'bh' => 'Bihari', |
|
| 41 | + 'bi' => 'Bislama', |
|
| 42 | + 'bm' => 'Bambara', |
|
| 43 | + 'bn' => 'Bengali; Bangla', |
|
| 44 | + 'bo' => 'Tibetan', |
|
| 45 | + 'br' => 'brezhoneg', |
|
| 46 | + 'bs' => 'bosanski', |
|
| 47 | + 'ca' => 'català', |
|
| 48 | + 'co' => 'corsu', |
|
| 49 | + 'cpf' => 'Kréol réyoné', |
|
| 50 | + 'cpf_dom' => 'Kreyòl', |
|
| 51 | + 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | + 'cs' => 'čeština', |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | + 'da' => 'dansk', |
|
| 55 | + 'de' => 'Deutsch', |
|
| 56 | + 'dz' => 'Bhutani', |
|
| 57 | + 'el' => 'ελληνικά', |
|
| 58 | + 'en' => 'English', |
|
| 59 | + 'en_hx' => 'H4ck3R', |
|
| 60 | + 'en_sm' => 'Smurf', |
|
| 61 | + 'eo' => 'Esperanto', |
|
| 62 | + 'es' => 'Español', |
|
| 63 | + 'es_co' => 'Colombiano', |
|
| 64 | + 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | + 'et' => 'eesti', |
|
| 66 | + 'eu' => 'euskara', |
|
| 67 | + 'fa' => 'فارسى', |
|
| 68 | + 'ff' => 'Fulah', // peul |
|
| 69 | + 'fi' => 'suomi', |
|
| 70 | + 'fj' => 'Fiji', |
|
| 71 | + 'fo' => 'føroyskt', |
|
| 72 | + 'fon' => 'fongbè', |
|
| 73 | + 'fr' => 'français', |
|
| 74 | + 'fr_fem' => 'français féminin', |
|
| 75 | + 'fr_sc' => 'schtroumpf', |
|
| 76 | + 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | + 'fr_lsf' => 'langue des signes française', |
|
| 78 | + 'fr_spl' => 'français simplifié', |
|
| 79 | + 'fr_tu' => 'français copain', |
|
| 80 | + 'fy' => 'Frisian', |
|
| 81 | + 'ga' => 'Irish', |
|
| 82 | + 'gd' => 'Scots Gaelic', |
|
| 83 | + 'gl' => 'galego', |
|
| 84 | + 'gn' => 'Guarani', |
|
| 85 | + 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | + 'gu' => 'Gujarati', |
|
| 87 | + 'ha' => 'Hausa', |
|
| 88 | + 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | + 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | + 'haz' => 'هزاره گی', |
|
| 91 | + 'he' => 'עברית', |
|
| 92 | + 'hi' => 'हिंदी', |
|
| 93 | + 'hr' => 'hrvatski', |
|
| 94 | + 'hu' => 'magyar', |
|
| 95 | + 'hy' => 'Հայերեն',// Arménien |
|
| 96 | + 'ia' => 'Interlingua', |
|
| 97 | + 'id' => 'Indonesia', |
|
| 98 | + 'ie' => 'Interlingue', |
|
| 99 | + 'ik' => 'Inupiak', |
|
| 100 | + 'is' => 'íslenska', |
|
| 101 | + 'it' => 'italiano', |
|
| 102 | + 'it_fem' => 'italiana', |
|
| 103 | + 'iu' => 'Inuktitut', |
|
| 104 | + 'ja' => '日本語', |
|
| 105 | + 'jv' => 'Javanese', |
|
| 106 | + 'ka' => 'ქართული', |
|
| 107 | + 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | + 'kl' => 'kalaallisut', |
|
| 109 | + 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | + 'kn' => 'Kannada', |
|
| 111 | + 'ko' => '한국어', |
|
| 112 | + 'kok' => 'कोंकणी', |
|
| 113 | + 'ks' => 'Kashmiri', |
|
| 114 | + 'ku' => 'کوردی', |
|
| 115 | + 'ky' => 'Kirghiz', |
|
| 116 | + 'la' => 'lingua latina', |
|
| 117 | + 'lb' => 'Lëtzebuergesch', |
|
| 118 | + 'ln' => 'Lingala', |
|
| 119 | + 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | + 'lt' => 'lietuvių', |
|
| 121 | + 'lu' => 'luba-katanga', |
|
| 122 | + 'lv' => 'latviešu', |
|
| 123 | + 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | + 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | + 'mg' => 'Malagasy', |
|
| 126 | + 'mi' => 'Maori', |
|
| 127 | + 'mk' => 'македонски јазик', |
|
| 128 | + 'ml' => 'Malayalam', |
|
| 129 | + 'mn' => 'Монгол хэл', |
|
| 130 | + 'mo' => 'Moldavian', |
|
| 131 | + 'mos' => 'Moré', |
|
| 132 | + 'mr' => 'मराठी', |
|
| 133 | + 'ms' => 'Bahasa Malaysia', |
|
| 134 | + 'mt' => 'Maltese', |
|
| 135 | + 'my' => 'Burmese', |
|
| 136 | + 'na' => 'Nauru', |
|
| 137 | + 'nap' => 'napulitano', |
|
| 138 | + 'ne' => 'Nepali', |
|
| 139 | + 'nqo' => "N'ko", // www.manden.org |
|
| 140 | + 'nl' => 'Nederlands', |
|
| 141 | + 'no' => 'norsk', |
|
| 142 | + 'nb' => 'norsk bokmål', |
|
| 143 | + 'nn' => 'norsk nynorsk', |
|
| 144 | + 'oc' => 'òc', |
|
| 145 | + 'oc_lnc' => 'òc lengadocian', |
|
| 146 | + 'oc_ni' => 'òc niçard', |
|
| 147 | + 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | + 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | + 'oc_prv' => 'òc provençau', |
|
| 150 | + 'oc_gsc' => 'òc gascon', |
|
| 151 | + 'oc_lms' => 'òc lemosin', |
|
| 152 | + 'oc_auv' => 'òc auvernhat', |
|
| 153 | + 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | + 'om' => '(Afan) Oromo', |
|
| 155 | + 'or' => 'Oriya', |
|
| 156 | + 'pa' => 'Punjabi', |
|
| 157 | + 'pbb' => 'Nasa Yuwe', |
|
| 158 | + 'pl' => 'polski', |
|
| 159 | + 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | + 'ps' => 'پښتو', |
|
| 161 | + 'pt' => 'Português', |
|
| 162 | + 'pt_br' => 'Português do Brasil', |
|
| 163 | + 'qu' => 'Quechua', |
|
| 164 | + 'rm' => 'Rhaeto-Romance', |
|
| 165 | + 'rn' => 'Kirundi', |
|
| 166 | + 'ro' => 'română', |
|
| 167 | + 'roa' => "ch'ti", |
|
| 168 | + 'ru' => 'русский', |
|
| 169 | + 'rw' => 'Kinyarwanda', |
|
| 170 | + 'sa' => 'संस्कृत', |
|
| 171 | + 'sc' => 'sardu', |
|
| 172 | + 'scn' => 'sicilianu', |
|
| 173 | + 'sd' => 'Sindhi', |
|
| 174 | + 'sg' => 'Sangho', |
|
| 175 | + 'sh' => 'srpskohrvastski', |
|
| 176 | + 'sh_latn' => 'srpskohrvastski', |
|
| 177 | + 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | + 'si' => 'Sinhalese', |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | + 'sm' => 'Samoan', |
|
| 182 | + 'sn' => 'Shona', |
|
| 183 | + 'so' => 'Somali', |
|
| 184 | + 'sq' => 'shqip', |
|
| 185 | + 'sr' => 'српски', |
|
| 186 | + 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | + 'sro' => 'sardu campidanésu', |
|
| 188 | + 'ss' => 'Siswati', |
|
| 189 | + 'st' => 'Sesotho', |
|
| 190 | + 'su' => 'Sundanese', |
|
| 191 | + 'sv' => 'svenska', |
|
| 192 | + 'sw' => 'Kiswahili', |
|
| 193 | + 'ta' => 'தமிழ்', // Tamil |
|
| 194 | + 'te' => 'Telugu', |
|
| 195 | + 'tg' => 'Tajik', |
|
| 196 | + 'th' => 'ไทย', |
|
| 197 | + 'ti' => 'Tigrinya', |
|
| 198 | + 'tk' => 'Turkmen', |
|
| 199 | + 'tl' => 'Tagalog', |
|
| 200 | + 'tn' => 'Setswana', |
|
| 201 | + 'to' => 'Tonga', |
|
| 202 | + 'tr' => 'Türkçe', |
|
| 203 | + 'ts' => 'Tsonga', |
|
| 204 | + 'tt' => 'Татар', |
|
| 205 | + 'tw' => 'Twi', |
|
| 206 | + 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | + 'ug' => 'Uighur', |
|
| 208 | + 'uk' => 'українська', |
|
| 209 | + 'ur' => 'ٱردو', |
|
| 210 | + 'uz' => "O'zbekcha", |
|
| 211 | + 'vi' => 'Tiếng Việt', |
|
| 212 | + 'vo' => 'Volapuk', |
|
| 213 | + 'wa' => 'walon', |
|
| 214 | + 'wo' => 'Wolof', |
|
| 215 | + 'xh' => 'Xhosa', |
|
| 216 | + 'yi' => 'Yiddish', |
|
| 217 | + 'yo' => 'Yoruba', |
|
| 218 | + 'za' => 'Zhuang', |
|
| 219 | + 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | + 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | + 'zu' => 'Zulu' |
|
| 222 | 222 | |
| 223 | 223 | ]; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'cpf_dom' => 'Kreyòl', |
| 51 | 51 | 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
| 52 | 52 | 'cs' => 'čeština', |
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | 54 | 'da' => 'dansk', |
| 55 | 55 | 'de' => 'Deutsch', |
| 56 | 56 | 'dz' => 'Bhutani', |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | 'hi' => 'हिंदी', |
| 93 | 93 | 'hr' => 'hrvatski', |
| 94 | 94 | 'hu' => 'magyar', |
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 95 | + 'hy' => 'Հայերեն', // Arménien |
|
| 96 | 96 | 'ia' => 'Interlingua', |
| 97 | 97 | 'id' => 'Indonesia', |
| 98 | 98 | 'ie' => 'Interlingue', |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'ka' => 'ქართული', |
| 107 | 107 | 'kk' => 'қазақ тілі', // Kazakh |
| 108 | 108 | 'kl' => 'kalaallisut', |
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 109 | + 'km' => 'ភាសាខ្មែរ', // Khmer |
|
| 110 | 110 | 'kn' => 'Kannada', |
| 111 | 111 | 'ko' => '한국어', |
| 112 | 112 | 'kok' => 'कोंकणी', |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | 'sh_latn' => 'srpskohrvastski', |
| 177 | 177 | 'sh_cyrl' => 'Српскохрватски', |
| 178 | 178 | 'si' => 'Sinhalese', |
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | 181 | 'sm' => 'Samoan', |
| 182 | 182 | 'sn' => 'Shona', |
| 183 | 183 | 'so' => 'Somali', |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('base/abstract_sql'); |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | |
| 25 | 25 | function inc_lien_dist( |
| 26 | - $lien, |
|
| 27 | - $texte = '', |
|
| 28 | - $class = '', |
|
| 29 | - $title = '', |
|
| 30 | - $hlang = '', |
|
| 31 | - $rel = '', |
|
| 32 | - $connect = '', |
|
| 33 | - $env = [] |
|
| 26 | + $lien, |
|
| 27 | + $texte = '', |
|
| 28 | + $class = '', |
|
| 29 | + $title = '', |
|
| 30 | + $hlang = '', |
|
| 31 | + $rel = '', |
|
| 32 | + $connect = '', |
|
| 33 | + $env = [] |
|
| 34 | 34 | ) { |
| 35 | - return $lien; |
|
| 35 | + return $lien; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
@@ -44,30 +44,30 @@ discard block |
||
| 44 | 44 | // https://code.spip.net/@expanser_liens |
| 45 | 45 | function expanser_liens($t, $connect = '', $env = []) { |
| 46 | 46 | |
| 47 | - $t = pipeline('pre_liens', $t); |
|
| 47 | + $t = pipeline('pre_liens', $t); |
|
| 48 | 48 | |
| 49 | - // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | - // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | - $t = traiter_modeles($t, false, false, $connect); |
|
| 49 | + // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | + // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | + $t = traiter_modeles($t, false, false, $connect); |
|
| 52 | 52 | |
| 53 | - return $t; |
|
| 53 | + return $t; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Meme analyse mais pour eliminer les liens |
| 57 | 57 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 58 | 58 | // https://code.spip.net/@nettoyer_raccourcis_typo |
| 59 | 59 | function nettoyer_raccourcis_typo($texte, $connect = '') { |
| 60 | - return $texte; |
|
| 60 | + return $texte; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Repere dans la partie texte d'un raccourci [texte->...] |
| 64 | 64 | // la langue et la bulle eventuelles |
| 65 | 65 | // https://code.spip.net/@traiter_raccourci_lien_atts |
| 66 | 66 | function traiter_raccourci_lien_atts($texte) { |
| 67 | - $bulle = ''; |
|
| 68 | - $hlang = ''; |
|
| 67 | + $bulle = ''; |
|
| 68 | + $hlang = ''; |
|
| 69 | 69 | |
| 70 | - return [trim($texte), $bulle, $hlang]; |
|
| 70 | + return [trim($texte), $bulle, $hlang]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function virtuel_redirige($virtuel, $url = false) { |
| 86 | - return $virtuel; |
|
| 86 | + return $virtuel; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Cherche un lien du type [->raccourci 123] |
@@ -97,122 +97,122 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // https://code.spip.net/@calculer_url |
| 99 | 99 | function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 100 | - $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 100 | + $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 101 | 101 | |
| 102 | - return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 102 | + return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
| 106 | 106 | |
| 107 | 107 | // https://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 109 | - if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | - return ($pour != 'tout') ? '' : ['', '', '', '']; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $lien = entites_html(trim($ref)); |
|
| 114 | - |
|
| 115 | - // Liens explicites |
|
| 116 | - if (!$texte) { |
|
| 117 | - $texte = str_replace('"', '', $lien); |
|
| 118 | - // evite l'affichage de trops longues urls. |
|
| 119 | - $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | - $texte = $lien_court($texte); |
|
| 121 | - if ($echappe_typo) { |
|
| 122 | - $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // petites corrections d'URL |
|
| 127 | - if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | - $lien = 'http://' . $lien; |
|
| 129 | - } else { |
|
| 130 | - if (strpos($lien, '@') && email_valide($lien)) { |
|
| 131 | - if (!$texte) { |
|
| 132 | - $texte = $lien; |
|
| 133 | - } |
|
| 134 | - $lien = 'mailto:' . $lien; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($pour == 'url') { |
|
| 139 | - return $lien; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if ($pour == 'titre') { |
|
| 143 | - return $texte; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return ['url' => $lien, 'titre' => $texte]; |
|
| 109 | + if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | + return ($pour != 'tout') ? '' : ['', '', '', '']; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $lien = entites_html(trim($ref)); |
|
| 114 | + |
|
| 115 | + // Liens explicites |
|
| 116 | + if (!$texte) { |
|
| 117 | + $texte = str_replace('"', '', $lien); |
|
| 118 | + // evite l'affichage de trops longues urls. |
|
| 119 | + $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | + $texte = $lien_court($texte); |
|
| 121 | + if ($echappe_typo) { |
|
| 122 | + $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // petites corrections d'URL |
|
| 127 | + if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | + $lien = 'http://' . $lien; |
|
| 129 | + } else { |
|
| 130 | + if (strpos($lien, '@') && email_valide($lien)) { |
|
| 131 | + if (!$texte) { |
|
| 132 | + $texte = $lien; |
|
| 133 | + } |
|
| 134 | + $lien = 'mailto:' . $lien; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($pour == 'url') { |
|
| 139 | + return $lien; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if ($pour == 'titre') { |
|
| 143 | + return $texte; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return ['url' => $lien, 'titre' => $texte]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | - $url = $f($texte, $id); |
|
| 152 | - } else { |
|
| 153 | - $url = glossaire_std($texte); |
|
| 154 | - } |
|
| 150 | + if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | + $url = $f($texte, $id); |
|
| 152 | + } else { |
|
| 153 | + $url = glossaire_std($texte); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $url; |
|
| 156 | + return $url; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // https://code.spip.net/@traiter_lien_implicite |
| 160 | 160 | function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') { |
| 161 | - if (!($match = typer_raccourci($ref))) { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | - // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | - // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | - if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
|
| 168 | - $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | - } |
|
| 170 | - if (!$url) { |
|
| 171 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | - } |
|
| 173 | - if (!$url) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - if (is_array($url)) { |
|
| 177 | - @list($type, $id) = $url; |
|
| 178 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | - } |
|
| 180 | - if ($pour === 'url') { |
|
| 181 | - return $url; |
|
| 182 | - } |
|
| 183 | - $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | - if ($r) { |
|
| 185 | - $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | - } |
|
| 187 | - if ($texte = trim($texte)) { |
|
| 188 | - $r['titre'] = $texte; |
|
| 189 | - } |
|
| 190 | - if (!@$r['titre']) { |
|
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 192 | - } |
|
| 193 | - if ($pour == 'titre') { |
|
| 194 | - return $r['titre']; |
|
| 195 | - } |
|
| 196 | - $r['url'] = $url; |
|
| 197 | - |
|
| 198 | - // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | - if ( |
|
| 200 | - $type == 'document' |
|
| 201 | - and $mime = sql_getfetsel( |
|
| 202 | - 'mime_type', |
|
| 203 | - 'spip_types_documents', |
|
| 204 | - 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 205 | - '', |
|
| 206 | - '', |
|
| 207 | - '', |
|
| 208 | - '', |
|
| 209 | - $connect |
|
| 210 | - ) |
|
| 211 | - ) { |
|
| 212 | - $r['mime'] = $mime; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - return $r; |
|
| 161 | + if (!($match = typer_raccourci($ref))) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | + @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | + // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | + // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | + if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
|
| 168 | + $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | + } |
|
| 170 | + if (!$url) { |
|
| 171 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | + } |
|
| 173 | + if (!$url) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + if (is_array($url)) { |
|
| 177 | + @list($type, $id) = $url; |
|
| 178 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | + } |
|
| 180 | + if ($pour === 'url') { |
|
| 181 | + return $url; |
|
| 182 | + } |
|
| 183 | + $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | + if ($r) { |
|
| 185 | + $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | + } |
|
| 187 | + if ($texte = trim($texte)) { |
|
| 188 | + $r['titre'] = $texte; |
|
| 189 | + } |
|
| 190 | + if (!@$r['titre']) { |
|
| 191 | + $r['titre'] = _T($type) . " $id"; |
|
| 192 | + } |
|
| 193 | + if ($pour == 'titre') { |
|
| 194 | + return $r['titre']; |
|
| 195 | + } |
|
| 196 | + $r['url'] = $url; |
|
| 197 | + |
|
| 198 | + // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | + if ( |
|
| 200 | + $type == 'document' |
|
| 201 | + and $mime = sql_getfetsel( |
|
| 202 | + 'mime_type', |
|
| 203 | + 'spip_types_documents', |
|
| 204 | + 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 205 | + '', |
|
| 206 | + '', |
|
| 207 | + '', |
|
| 208 | + '', |
|
| 209 | + $connect |
|
| 210 | + ) |
|
| 211 | + ) { |
|
| 212 | + $r['mime'] = $mime; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + return $r; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes |
@@ -221,41 +221,41 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | // https://code.spip.net/@typer_raccourci |
| 223 | 223 | function typer_raccourci($lien) { |
| 224 | - if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 225 | - return []; |
|
| 226 | - } |
|
| 227 | - $f = $match[1]; |
|
| 228 | - // valeur par defaut et alias historiques |
|
| 229 | - if (!$f) { |
|
| 230 | - $f = 'article'; |
|
| 231 | - } else { |
|
| 232 | - if ($f == 'art') { |
|
| 233 | - $f = 'article'; |
|
| 234 | - } else { |
|
| 235 | - if ($f == 'br') { |
|
| 236 | - $f = 'breve'; |
|
| 237 | - } else { |
|
| 238 | - if ($f == 'rub') { |
|
| 239 | - $f = 'rubrique'; |
|
| 240 | - } else { |
|
| 241 | - if ($f == 'aut') { |
|
| 242 | - $f = 'auteur'; |
|
| 243 | - } else { |
|
| 244 | - if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 245 | - $f = 'document'; |
|
| 246 | - } else { |
|
| 247 | - if (preg_match('/^br..?ve$/S', $f)) { |
|
| 248 | - $f = 'breve'; |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } # accents :( |
|
| 256 | - $match[0] = $f; |
|
| 257 | - |
|
| 258 | - return $match; |
|
| 224 | + if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 225 | + return []; |
|
| 226 | + } |
|
| 227 | + $f = $match[1]; |
|
| 228 | + // valeur par defaut et alias historiques |
|
| 229 | + if (!$f) { |
|
| 230 | + $f = 'article'; |
|
| 231 | + } else { |
|
| 232 | + if ($f == 'art') { |
|
| 233 | + $f = 'article'; |
|
| 234 | + } else { |
|
| 235 | + if ($f == 'br') { |
|
| 236 | + $f = 'breve'; |
|
| 237 | + } else { |
|
| 238 | + if ($f == 'rub') { |
|
| 239 | + $f = 'rubrique'; |
|
| 240 | + } else { |
|
| 241 | + if ($f == 'aut') { |
|
| 242 | + $f = 'auteur'; |
|
| 243 | + } else { |
|
| 244 | + if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 245 | + $f = 'document'; |
|
| 246 | + } else { |
|
| 247 | + if (preg_match('/^br..?ve$/S', $f)) { |
|
| 248 | + $f = 'breve'; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } # accents :( |
|
| 256 | + $match[0] = $f; |
|
| 257 | + |
|
| 258 | + return $match; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -270,25 +270,25 @@ discard block |
||
| 270 | 270 | * } |
| 271 | 271 | **/ |
| 272 | 272 | function traiter_raccourci_titre($id, $type, $connect = null) { |
| 273 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 274 | - $desc = $trouver_table(table_objet($type)); |
|
| 275 | - if (!($desc and $s = $desc['titre'])) { |
|
| 276 | - return []; |
|
| 277 | - } |
|
| 278 | - $_id = $desc['key']['PRIMARY KEY']; |
|
| 279 | - $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 280 | - if (!$r) { |
|
| 281 | - return []; |
|
| 282 | - } |
|
| 283 | - $r['titre'] = supprimer_numero($r['titre']); |
|
| 284 | - if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 285 | - $r['titre'] = $r['surnom']; |
|
| 286 | - } |
|
| 287 | - if (!isset($r['lang'])) { |
|
| 288 | - $r['lang'] = ''; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return $r; |
|
| 273 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 274 | + $desc = $trouver_table(table_objet($type)); |
|
| 275 | + if (!($desc and $s = $desc['titre'])) { |
|
| 276 | + return []; |
|
| 277 | + } |
|
| 278 | + $_id = $desc['key']['PRIMARY KEY']; |
|
| 279 | + $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 280 | + if (!$r) { |
|
| 281 | + return []; |
|
| 282 | + } |
|
| 283 | + $r['titre'] = supprimer_numero($r['titre']); |
|
| 284 | + if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 285 | + $r['titre'] = $r['surnom']; |
|
| 286 | + } |
|
| 287 | + if (!isset($r['lang'])) { |
|
| 288 | + $r['lang'] = ''; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return $r; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // traite les modeles (dans la fonction typo), en remplacant |
@@ -300,124 +300,124 @@ discard block |
||
| 300 | 300 | // https://code.spip.net/@traiter_modeles |
| 301 | 301 | |
| 302 | 302 | define( |
| 303 | - '_RACCOURCI_MODELE', |
|
| 304 | - '(<([a-z_-]{3,})' # <modele |
|
| 305 | - . '\s*([0-9]*)\s*' # id |
|
| 306 | - . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 307 | - . '\s*/?' . '>)' # fin du modele > |
|
| 308 | - . '\s*(<\/a>)?' # eventuel </a> |
|
| 303 | + '_RACCOURCI_MODELE', |
|
| 304 | + '(<([a-z_-]{3,})' # <modele |
|
| 305 | + . '\s*([0-9]*)\s*' # id |
|
| 306 | + . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 307 | + . '\s*/?' . '>)' # fin du modele > |
|
| 308 | + . '\s*(<\/a>)?' # eventuel </a> |
|
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | 311 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 312 | 312 | |
| 313 | 313 | // https://code.spip.net/@traiter_modeles |
| 314 | 314 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = []) { |
| 315 | - // preserver la compatibilite : true = recherche des documents |
|
| 316 | - if ($doublons === true) { |
|
| 317 | - $doublons = ['documents' => ['doc', 'emb', 'img']]; |
|
| 318 | - } |
|
| 319 | - // detecter les modeles (rapide) |
|
| 320 | - if ( |
|
| 321 | - strpos($texte, '<') !== false and |
|
| 322 | - preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 323 | - ) { |
|
| 324 | - include_spip('public/assembler'); |
|
| 325 | - $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true); |
|
| 326 | - foreach ($matches as $match) { |
|
| 327 | - // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 328 | - |
|
| 329 | - $a = strpos($texte, $match[0]); |
|
| 330 | - preg_match( |
|
| 331 | - _RACCOURCI_MODELE_DEBUT, |
|
| 332 | - substr($texte, $a), |
|
| 333 | - $regs |
|
| 334 | - ); |
|
| 335 | - $regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 336 | - list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 337 | - if ( |
|
| 338 | - $fin and |
|
| 339 | - preg_match( |
|
| 340 | - '/<a\s[^<>]*>\s*$/i', |
|
| 341 | - substr($texte, 0, $a), |
|
| 342 | - $r |
|
| 343 | - ) |
|
| 344 | - ) { |
|
| 345 | - $lien = [ |
|
| 346 | - 'href' => extraire_attribut($r[0], 'href'), |
|
| 347 | - 'class' => extraire_attribut($r[0], 'class'), |
|
| 348 | - 'mime' => extraire_attribut($r[0], 'type'), |
|
| 349 | - 'title' => extraire_attribut($r[0], 'title'), |
|
| 350 | - 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 351 | - ]; |
|
| 352 | - $n = strlen($r[0]); |
|
| 353 | - $a -= $n; |
|
| 354 | - $cherche = $n + strlen($regs[0]); |
|
| 355 | - } else { |
|
| 356 | - $lien = false; |
|
| 357 | - $cherche = strlen($mod); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - // calculer le modele |
|
| 361 | - # hack indexation |
|
| 362 | - if ($doublons) { |
|
| 363 | - $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 364 | - } # version normale |
|
| 365 | - else { |
|
| 366 | - // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 367 | - // dans les parametres, plutot que les liens echappes |
|
| 368 | - if (!is_null($liens)) { |
|
| 369 | - $params = str_replace($liens[0], $liens[1], $params); |
|
| 370 | - } |
|
| 371 | - $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 372 | - // en cas d'echec, |
|
| 373 | - // si l'objet demande a une url, |
|
| 374 | - // creer un petit encadre vers elle |
|
| 375 | - if ($modele === false) { |
|
| 376 | - if (!$lien) { |
|
| 377 | - $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 378 | - } |
|
| 379 | - if ($lien) { |
|
| 380 | - $modele = '<a href="' |
|
| 381 | - . $lien['url'] |
|
| 382 | - . '" class="spip_modele' |
|
| 383 | - . '">' |
|
| 384 | - . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 385 | - . '</a>'; |
|
| 386 | - } else { |
|
| 387 | - $modele = ''; |
|
| 388 | - if (test_espace_prive()) { |
|
| 389 | - $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 390 | - if (!is_null($liens)) { |
|
| 391 | - $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>'; |
|
| 392 | - } |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - // le remplacer dans le texte |
|
| 397 | - if ($modele !== false) { |
|
| 398 | - $modele = protege_js_modeles($modele); |
|
| 399 | - if ($wrap_embed_html) { |
|
| 400 | - $modele = $wrap_embed_html($mod, $modele); |
|
| 401 | - } |
|
| 402 | - $rempl = code_echappement($modele, $echap); |
|
| 403 | - $texte = substr($texte, 0, $a) |
|
| 404 | - . $rempl |
|
| 405 | - . substr($texte, $a + $cherche); |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - // hack pour tout l'espace prive |
|
| 410 | - if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 411 | - foreach ($doublons ? $doublons : ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) { |
|
| 412 | - if (in_array($type, $modeles)) { |
|
| 413 | - $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 414 | - } |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - return $texte; |
|
| 315 | + // preserver la compatibilite : true = recherche des documents |
|
| 316 | + if ($doublons === true) { |
|
| 317 | + $doublons = ['documents' => ['doc', 'emb', 'img']]; |
|
| 318 | + } |
|
| 319 | + // detecter les modeles (rapide) |
|
| 320 | + if ( |
|
| 321 | + strpos($texte, '<') !== false and |
|
| 322 | + preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 323 | + ) { |
|
| 324 | + include_spip('public/assembler'); |
|
| 325 | + $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true); |
|
| 326 | + foreach ($matches as $match) { |
|
| 327 | + // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 328 | + |
|
| 329 | + $a = strpos($texte, $match[0]); |
|
| 330 | + preg_match( |
|
| 331 | + _RACCOURCI_MODELE_DEBUT, |
|
| 332 | + substr($texte, $a), |
|
| 333 | + $regs |
|
| 334 | + ); |
|
| 335 | + $regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 336 | + list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 337 | + if ( |
|
| 338 | + $fin and |
|
| 339 | + preg_match( |
|
| 340 | + '/<a\s[^<>]*>\s*$/i', |
|
| 341 | + substr($texte, 0, $a), |
|
| 342 | + $r |
|
| 343 | + ) |
|
| 344 | + ) { |
|
| 345 | + $lien = [ |
|
| 346 | + 'href' => extraire_attribut($r[0], 'href'), |
|
| 347 | + 'class' => extraire_attribut($r[0], 'class'), |
|
| 348 | + 'mime' => extraire_attribut($r[0], 'type'), |
|
| 349 | + 'title' => extraire_attribut($r[0], 'title'), |
|
| 350 | + 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 351 | + ]; |
|
| 352 | + $n = strlen($r[0]); |
|
| 353 | + $a -= $n; |
|
| 354 | + $cherche = $n + strlen($regs[0]); |
|
| 355 | + } else { |
|
| 356 | + $lien = false; |
|
| 357 | + $cherche = strlen($mod); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + // calculer le modele |
|
| 361 | + # hack indexation |
|
| 362 | + if ($doublons) { |
|
| 363 | + $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 364 | + } # version normale |
|
| 365 | + else { |
|
| 366 | + // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 367 | + // dans les parametres, plutot que les liens echappes |
|
| 368 | + if (!is_null($liens)) { |
|
| 369 | + $params = str_replace($liens[0], $liens[1], $params); |
|
| 370 | + } |
|
| 371 | + $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 372 | + // en cas d'echec, |
|
| 373 | + // si l'objet demande a une url, |
|
| 374 | + // creer un petit encadre vers elle |
|
| 375 | + if ($modele === false) { |
|
| 376 | + if (!$lien) { |
|
| 377 | + $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 378 | + } |
|
| 379 | + if ($lien) { |
|
| 380 | + $modele = '<a href="' |
|
| 381 | + . $lien['url'] |
|
| 382 | + . '" class="spip_modele' |
|
| 383 | + . '">' |
|
| 384 | + . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 385 | + . '</a>'; |
|
| 386 | + } else { |
|
| 387 | + $modele = ''; |
|
| 388 | + if (test_espace_prive()) { |
|
| 389 | + $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 390 | + if (!is_null($liens)) { |
|
| 391 | + $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>'; |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + // le remplacer dans le texte |
|
| 397 | + if ($modele !== false) { |
|
| 398 | + $modele = protege_js_modeles($modele); |
|
| 399 | + if ($wrap_embed_html) { |
|
| 400 | + $modele = $wrap_embed_html($mod, $modele); |
|
| 401 | + } |
|
| 402 | + $rempl = code_echappement($modele, $echap); |
|
| 403 | + $texte = substr($texte, 0, $a) |
|
| 404 | + . $rempl |
|
| 405 | + . substr($texte, $a + $cherche); |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + // hack pour tout l'espace prive |
|
| 410 | + if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 411 | + foreach ($doublons ? $doublons : ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) { |
|
| 412 | + if (in_array($type, $modeles)) { |
|
| 413 | + $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + return $texte; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | // |
@@ -425,15 +425,15 @@ discard block |
||
| 425 | 425 | // |
| 426 | 426 | // https://code.spip.net/@traiter_raccourci_ancre |
| 427 | 427 | function traiter_raccourci_ancre($letexte) { |
| 428 | - return $letexte; |
|
| 428 | + return $letexte; |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | // https://code.spip.net/@traiter_raccourci_glossaire |
| 432 | 432 | function traiter_raccourci_glossaire($texte) { |
| 433 | - return $texte; |
|
| 433 | + return $texte; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | // https://code.spip.net/@glossaire_std |
| 437 | 437 | function glossaire_std($terme) { |
| 438 | - return $terme; |
|
| 438 | + return $terme; |
|
| 439 | 439 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
|
| 105 | +define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS'); |
|
| 106 | 106 | |
| 107 | 107 | // https://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $lien_court = charger_fonction('lien_court', 'inc'); |
| 120 | 120 | $texte = $lien_court($texte); |
| 121 | 121 | if ($echappe_typo) { |
| 122 | - $texte = '<html>' . quote_amp($texte) . '</html>'; |
|
| 122 | + $texte = '<html>'.quote_amp($texte).'</html>'; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // petites corrections d'URL |
| 127 | 127 | if (preg_match('/^www\.[^@]+$/S', $lien)) { |
| 128 | - $lien = 'http://' . $lien; |
|
| 128 | + $lien = 'http://'.$lien; |
|
| 129 | 129 | } else { |
| 130 | 130 | if (strpos($lien, '@') && email_valide($lien)) { |
| 131 | 131 | if (!$texte) { |
| 132 | 132 | $texte = $lien; |
| 133 | 133 | } |
| 134 | - $lien = 'mailto:' . $lien; |
|
| 134 | + $lien = 'mailto:'.$lien; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 150 | + if (function_exists($f = 'glossaire_'.$ancre)) { |
|
| 151 | 151 | $url = $f($texte, $id); |
| 152 | 152 | } else { |
| 153 | 153 | $url = glossaire_std($texte); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | if (!($match = typer_raccourci($ref))) { |
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 164 | + @list($type,, $id,, $args,, $ancre) = $match; |
|
| 165 | 165 | // attention dans le cas des sites le lien doit pointer non pas sur |
| 166 | 166 | // la page locale du site, mais directement sur le site lui-meme |
| 167 | 167 | if ($f = charger_fonction("implicite_$type", 'liens', true)) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $r['titre'] = $texte; |
| 189 | 189 | } |
| 190 | 190 | if (!@$r['titre']) { |
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 191 | + $r['titre'] = _T($type)." $id"; |
|
| 192 | 192 | } |
| 193 | 193 | if ($pour == 'titre') { |
| 194 | 194 | return $r['titre']; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | and $mime = sql_getfetsel( |
| 202 | 202 | 'mime_type', |
| 203 | 203 | 'spip_types_documents', |
| 204 | - 'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')', |
|
| 204 | + 'extension IN ('.sql_get_select('extension', 'spip_documents', 'id_document='.sql_quote($id)).')', |
|
| 205 | 205 | '', |
| 206 | 206 | '', |
| 207 | 207 | '', |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | '(<([a-z_-]{3,})' # <modele |
| 305 | 305 | . '\s*([0-9]*)\s*' # id |
| 306 | 306 | . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
| 307 | - . '\s*/?' . '>)' # fin du modele > |
|
| 307 | + . '\s*/?'.'>)' # fin du modele > |
|
| 308 | 308 | . '\s*(<\/a>)?' # eventuel </a> |
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | -define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
|
| 311 | +define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS'); |
|
| 312 | 312 | |
| 313 | 313 | // https://code.spip.net/@traiter_modeles |
| 314 | 314 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = []) { |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | if (test_espace_prive()) { |
| 389 | 389 | $modele = entites_html(substr($texte, $a, $cherche)); |
| 390 | 390 | if (!is_null($liens)) { |
| 391 | - $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>'; |
|
| 391 | + $modele = '<pre>'.str_replace($liens[0], $liens[1], $modele).'</pre>'; |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function inc_config_dist() { |
| 31 | - actualise_metas(liste_metas()); |
|
| 31 | + actualise_metas(liste_metas()); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -45,34 +45,34 @@ discard block |
||
| 45 | 45 | * Liste (table, casier, sous_casier) |
| 46 | 46 | */ |
| 47 | 47 | function expliquer_config($cfg) { |
| 48 | - // par defaut, sur la table des meta |
|
| 49 | - $table = 'meta'; |
|
| 50 | - $casier = null; |
|
| 51 | - $sous_casier = []; |
|
| 52 | - $cfg = explode('/', $cfg); |
|
| 53 | - |
|
| 54 | - // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | - if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | - array_shift($cfg); |
|
| 57 | - $table = array_shift($cfg); |
|
| 58 | - if (!isset($GLOBALS[$table])) { |
|
| 59 | - lire_metas($table); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | - if (count($cfg)) { |
|
| 65 | - // pas sur un appel vide '' |
|
| 66 | - if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | - $casier = $c; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if (count($cfg)) { |
|
| 72 | - $sous_casier = $cfg; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return [$table, $casier, $sous_casier]; |
|
| 48 | + // par defaut, sur la table des meta |
|
| 49 | + $table = 'meta'; |
|
| 50 | + $casier = null; |
|
| 51 | + $sous_casier = []; |
|
| 52 | + $cfg = explode('/', $cfg); |
|
| 53 | + |
|
| 54 | + // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | + if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | + array_shift($cfg); |
|
| 57 | + $table = array_shift($cfg); |
|
| 58 | + if (!isset($GLOBALS[$table])) { |
|
| 59 | + lire_metas($table); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | + if (count($cfg)) { |
|
| 65 | + // pas sur un appel vide '' |
|
| 66 | + if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | + $casier = $c; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if (count($cfg)) { |
|
| 72 | + $sous_casier = $cfg; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return [$table, $casier, $sous_casier]; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -100,65 +100,65 @@ discard block |
||
| 100 | 100 | * Contenu de la configuration obtenue |
| 101 | 101 | */ |
| 102 | 102 | function lire_config($cfg = '', $def = null, $unserialize = true) { |
| 103 | - // lire le stockage sous la forme /table/valeur |
|
| 104 | - // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | - // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | - |
|
| 107 | - // traiter en priorite le cas simple et frequent |
|
| 108 | - // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | - if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | - $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | - ((!$unserialize |
|
| 112 | - // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | - or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | - // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | - or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | - or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | - : $def; |
|
| 118 | - |
|
| 119 | - return $r; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // Brancher sur methodes externes si besoin |
|
| 123 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | - $methode = substr($cfg, 0, $p); |
|
| 125 | - $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | - |
|
| 127 | - return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 131 | - |
|
| 132 | - if (!isset($GLOBALS[$table])) { |
|
| 133 | - return $def; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $r = $GLOBALS[$table]; |
|
| 137 | - |
|
| 138 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | - if (!$casier) { |
|
| 140 | - return $unserialize ? $r : serialize($r); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // casier principal : |
|
| 144 | - // le deserializer si demande |
|
| 145 | - // ou si on a besoin |
|
| 146 | - // d'un sous casier |
|
| 147 | - $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 148 | - if (($unserialize or count($sous_casier)) and $r and is_string($r)) { |
|
| 149 | - $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // aller chercher le sous_casier |
|
| 153 | - while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | - $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (is_null($r)) { |
|
| 158 | - return $def; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $r; |
|
| 103 | + // lire le stockage sous la forme /table/valeur |
|
| 104 | + // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | + // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | + |
|
| 107 | + // traiter en priorite le cas simple et frequent |
|
| 108 | + // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | + if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | + $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | + ((!$unserialize |
|
| 112 | + // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | + or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | + // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | + or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | + or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | + : $def; |
|
| 118 | + |
|
| 119 | + return $r; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // Brancher sur methodes externes si besoin |
|
| 123 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | + $methode = substr($cfg, 0, $p); |
|
| 125 | + $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | + |
|
| 127 | + return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 131 | + |
|
| 132 | + if (!isset($GLOBALS[$table])) { |
|
| 133 | + return $def; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $r = $GLOBALS[$table]; |
|
| 137 | + |
|
| 138 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | + if (!$casier) { |
|
| 140 | + return $unserialize ? $r : serialize($r); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // casier principal : |
|
| 144 | + // le deserializer si demande |
|
| 145 | + // ou si on a besoin |
|
| 146 | + // d'un sous casier |
|
| 147 | + $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 148 | + if (($unserialize or count($sous_casier)) and $r and is_string($r)) { |
|
| 149 | + $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // aller chercher le sous_casier |
|
| 153 | + while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | + $r = isset($r[$casier]) ? $r[$casier] : null; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (is_null($r)) { |
|
| 158 | + return $def; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $r; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @return mixed |
| 173 | 173 | */ |
| 174 | 174 | function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) { |
| 175 | - return lire_config($cfg, $def, $unserialize); |
|
| 175 | + return lire_config($cfg, $def, $unserialize); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -184,98 +184,98 @@ discard block |
||
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | 186 | function ecrire_config($cfg, $store) { |
| 187 | - // Brancher sur methodes externes si besoin |
|
| 188 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | - $methode = substr($cfg, 0, $p); |
|
| 190 | - $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | - |
|
| 192 | - return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 196 | - // il faut au moins un casier pour ecrire |
|
| 197 | - if (!$casier) { |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // trouvons ou creons le pointeur sur le casier |
|
| 202 | - $st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null; |
|
| 203 | - if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | - $st = unserialize($st); |
|
| 205 | - if ($st === false) { |
|
| 206 | - // ne rien creer si c'est une demande d'effacement |
|
| 207 | - if (is_null($store)) { |
|
| 208 | - return false; |
|
| 209 | - } |
|
| 210 | - $st = []; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - // si on a affaire a un sous caiser |
|
| 215 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 216 | - if ($c = $sous_casier) { |
|
| 217 | - $sc = &$st; |
|
| 218 | - $pointeurs = []; |
|
| 219 | - while (count($c) and $cc = array_shift($c)) { |
|
| 220 | - // creer l'entree si elle n'existe pas |
|
| 221 | - if (!isset($sc[$cc])) { |
|
| 222 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 223 | - // ne rien creer mais sortir |
|
| 224 | - if (is_null($store)) { |
|
| 225 | - return false; |
|
| 226 | - } |
|
| 227 | - $sc[$cc] = []; |
|
| 228 | - } |
|
| 229 | - $pointeurs[$cc] = &$sc; |
|
| 230 | - $sc = &$sc[$cc]; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // si c'est une demande d'effacement |
|
| 234 | - if (is_null($store)) { |
|
| 235 | - $c = $sous_casier; |
|
| 236 | - $sous = array_pop($c); |
|
| 237 | - // effacer, et remonter pour effacer les parents vides |
|
| 238 | - do { |
|
| 239 | - unset($pointeurs[$sous][$sous]); |
|
| 240 | - } while ($sous = array_pop($c) and !count($pointeurs[$sous][$sous])); |
|
| 241 | - |
|
| 242 | - // si on a vide tous les sous casiers, |
|
| 243 | - // et que le casier est vide |
|
| 244 | - // vider aussi la meta |
|
| 245 | - if (!$sous and !count($st)) { |
|
| 246 | - $st = null; |
|
| 247 | - } |
|
| 248 | - } // dans tous les autres cas, on ecrase |
|
| 249 | - else { |
|
| 250 | - $sc = $store; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - // Maintenant que $st est modifiee |
|
| 254 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 255 | - $store = $st; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if (is_null($store)) { |
|
| 259 | - if (is_null($st) and !$sous_casier) { |
|
| 260 | - return false; |
|
| 261 | - } // la config n'existait deja pas ! |
|
| 262 | - effacer_meta($casier, $table); |
|
| 263 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 264 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 265 | - else { |
|
| 266 | - if (!isset($GLOBALS[$table])) { |
|
| 267 | - installer_table_meta($table); |
|
| 268 | - } |
|
| 269 | - // si ce n'est pas une chaine |
|
| 270 | - // il faut serializer |
|
| 271 | - if (!is_string($store)) { |
|
| 272 | - $store = serialize($store); |
|
| 273 | - } |
|
| 274 | - ecrire_meta($casier, $store, null, $table); |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - // verifier que lire_config($cfg)==$store ? |
|
| 278 | - return true; |
|
| 187 | + // Brancher sur methodes externes si besoin |
|
| 188 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | + $methode = substr($cfg, 0, $p); |
|
| 190 | + $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | + |
|
| 192 | + return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + list($table, $casier, $sous_casier) = expliquer_config($cfg); |
|
| 196 | + // il faut au moins un casier pour ecrire |
|
| 197 | + if (!$casier) { |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // trouvons ou creons le pointeur sur le casier |
|
| 202 | + $st = isset($GLOBALS[$table][$casier]) ? $GLOBALS[$table][$casier] : null; |
|
| 203 | + if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | + $st = unserialize($st); |
|
| 205 | + if ($st === false) { |
|
| 206 | + // ne rien creer si c'est une demande d'effacement |
|
| 207 | + if (is_null($store)) { |
|
| 208 | + return false; |
|
| 209 | + } |
|
| 210 | + $st = []; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + // si on a affaire a un sous caiser |
|
| 215 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 216 | + if ($c = $sous_casier) { |
|
| 217 | + $sc = &$st; |
|
| 218 | + $pointeurs = []; |
|
| 219 | + while (count($c) and $cc = array_shift($c)) { |
|
| 220 | + // creer l'entree si elle n'existe pas |
|
| 221 | + if (!isset($sc[$cc])) { |
|
| 222 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 223 | + // ne rien creer mais sortir |
|
| 224 | + if (is_null($store)) { |
|
| 225 | + return false; |
|
| 226 | + } |
|
| 227 | + $sc[$cc] = []; |
|
| 228 | + } |
|
| 229 | + $pointeurs[$cc] = &$sc; |
|
| 230 | + $sc = &$sc[$cc]; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // si c'est une demande d'effacement |
|
| 234 | + if (is_null($store)) { |
|
| 235 | + $c = $sous_casier; |
|
| 236 | + $sous = array_pop($c); |
|
| 237 | + // effacer, et remonter pour effacer les parents vides |
|
| 238 | + do { |
|
| 239 | + unset($pointeurs[$sous][$sous]); |
|
| 240 | + } while ($sous = array_pop($c) and !count($pointeurs[$sous][$sous])); |
|
| 241 | + |
|
| 242 | + // si on a vide tous les sous casiers, |
|
| 243 | + // et que le casier est vide |
|
| 244 | + // vider aussi la meta |
|
| 245 | + if (!$sous and !count($st)) { |
|
| 246 | + $st = null; |
|
| 247 | + } |
|
| 248 | + } // dans tous les autres cas, on ecrase |
|
| 249 | + else { |
|
| 250 | + $sc = $store; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + // Maintenant que $st est modifiee |
|
| 254 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 255 | + $store = $st; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if (is_null($store)) { |
|
| 259 | + if (is_null($st) and !$sous_casier) { |
|
| 260 | + return false; |
|
| 261 | + } // la config n'existait deja pas ! |
|
| 262 | + effacer_meta($casier, $table); |
|
| 263 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 264 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 265 | + else { |
|
| 266 | + if (!isset($GLOBALS[$table])) { |
|
| 267 | + installer_table_meta($table); |
|
| 268 | + } |
|
| 269 | + // si ce n'est pas une chaine |
|
| 270 | + // il faut serializer |
|
| 271 | + if (!is_string($store)) { |
|
| 272 | + $store = serialize($store); |
|
| 273 | + } |
|
| 274 | + ecrire_meta($casier, $store, null, $table); |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + // verifier que lire_config($cfg)==$store ? |
|
| 278 | + return true; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
@@ -289,14 +289,14 @@ discard block |
||
| 289 | 289 | * @return bool |
| 290 | 290 | */ |
| 291 | 291 | function ecrire_config_metapack_dist($cfg, $store) { |
| 292 | - // cas particulier en metapack:: |
|
| 293 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 294 | - // intacte en sortie ... |
|
| 295 | - if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 296 | - $store = serialize($store); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - return ecrire_config($cfg, $store); |
|
| 292 | + // cas particulier en metapack:: |
|
| 293 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 294 | + // intacte en sortie ... |
|
| 295 | + if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 296 | + $store = serialize($store); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + return ecrire_config($cfg, $store); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -306,9 +306,9 @@ discard block |
||
| 306 | 306 | * @return bool |
| 307 | 307 | */ |
| 308 | 308 | function effacer_config($cfg) { |
| 309 | - ecrire_config($cfg, null); |
|
| 309 | + ecrire_config($cfg, null); |
|
| 310 | 310 | |
| 311 | - return true; |
|
| 311 | + return true; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -325,71 +325,71 @@ discard block |
||
| 325 | 325 | * @return array |
| 326 | 326 | */ |
| 327 | 327 | function lister_configurer($exclure = []) { |
| 328 | - return []; |
|
| 329 | - |
|
| 330 | - // lister les pages de config deja dans les menus |
|
| 331 | - $deja = []; |
|
| 332 | - foreach ($exclure as $id => $b) { |
|
| 333 | - $url = ($b['url'] ? $b['url'] : $id); |
|
| 334 | - if (!$b['url'] or !isset($exclure[$url])) { |
|
| 335 | - if (strncmp($url, 'configurer_', 11) == 0) { |
|
| 336 | - $deja[$url] = $b; |
|
| 337 | - } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
|
| 338 | - $deja['configurer_' . $match[1]] = $b; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - $exclure = $exclure + $deja; |
|
| 343 | - |
|
| 344 | - $icone_defaut = 'images/configuration-16.png'; |
|
| 345 | - $liste = []; |
|
| 346 | - $skels = []; |
|
| 347 | - $forms = []; |
|
| 348 | - |
|
| 349 | - // trouver toutes les pages configurer_xxx de l'espace prive |
|
| 350 | - // et construire un tableau des entrees qui ne sont pas dans $deja |
|
| 351 | - $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 352 | - |
|
| 353 | - foreach ($pages as $page) { |
|
| 354 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 355 | - if (!isset($exclure[$configurer])) { |
|
| 356 | - $liste[$configurer] = [ |
|
| 357 | - 'parent' => 'bando_configuration', |
|
| 358 | - 'url' => $configurer, |
|
| 359 | - 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 360 | - 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 361 | - ]; |
|
| 362 | - } |
|
| 363 | - $skels[$configurer] = $page; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus |
|
| 367 | - foreach ($skels as $file) { |
|
| 368 | - $forms = array_merge($forms, lister_formulaires_configurer($file)); |
|
| 369 | - } |
|
| 370 | - $forms = array_flip($forms); |
|
| 371 | - |
|
| 372 | - // trouver tous les formulaires/configurer_ |
|
| 373 | - // et construire un tableau des entrees |
|
| 374 | - $pages = find_all_in_path('formulaires/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 375 | - foreach ($pages as $page) { |
|
| 376 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 377 | - if ( |
|
| 378 | - !isset($forms[$configurer]) |
|
| 379 | - and !isset($liste[$configurer]) |
|
| 380 | - and !isset($exclure[$configurer]) |
|
| 381 | - ) { |
|
| 382 | - $liste[$configurer] = [ |
|
| 383 | - 'parent' => 'bando_configuration', |
|
| 384 | - 'url' => 'configurer', |
|
| 385 | - 'args' => 'cfg=' . substr($configurer, 11), |
|
| 386 | - 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 387 | - 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 388 | - ]; |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - return $liste; |
|
| 328 | + return []; |
|
| 329 | + |
|
| 330 | + // lister les pages de config deja dans les menus |
|
| 331 | + $deja = []; |
|
| 332 | + foreach ($exclure as $id => $b) { |
|
| 333 | + $url = ($b['url'] ? $b['url'] : $id); |
|
| 334 | + if (!$b['url'] or !isset($exclure[$url])) { |
|
| 335 | + if (strncmp($url, 'configurer_', 11) == 0) { |
|
| 336 | + $deja[$url] = $b; |
|
| 337 | + } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
|
| 338 | + $deja['configurer_' . $match[1]] = $b; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + $exclure = $exclure + $deja; |
|
| 343 | + |
|
| 344 | + $icone_defaut = 'images/configuration-16.png'; |
|
| 345 | + $liste = []; |
|
| 346 | + $skels = []; |
|
| 347 | + $forms = []; |
|
| 348 | + |
|
| 349 | + // trouver toutes les pages configurer_xxx de l'espace prive |
|
| 350 | + // et construire un tableau des entrees qui ne sont pas dans $deja |
|
| 351 | + $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 352 | + |
|
| 353 | + foreach ($pages as $page) { |
|
| 354 | + $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 355 | + if (!isset($exclure[$configurer])) { |
|
| 356 | + $liste[$configurer] = [ |
|
| 357 | + 'parent' => 'bando_configuration', |
|
| 358 | + 'url' => $configurer, |
|
| 359 | + 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 360 | + 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 361 | + ]; |
|
| 362 | + } |
|
| 363 | + $skels[$configurer] = $page; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus |
|
| 367 | + foreach ($skels as $file) { |
|
| 368 | + $forms = array_merge($forms, lister_formulaires_configurer($file)); |
|
| 369 | + } |
|
| 370 | + $forms = array_flip($forms); |
|
| 371 | + |
|
| 372 | + // trouver tous les formulaires/configurer_ |
|
| 373 | + // et construire un tableau des entrees |
|
| 374 | + $pages = find_all_in_path('formulaires/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 375 | + foreach ($pages as $page) { |
|
| 376 | + $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 377 | + if ( |
|
| 378 | + !isset($forms[$configurer]) |
|
| 379 | + and !isset($liste[$configurer]) |
|
| 380 | + and !isset($exclure[$configurer]) |
|
| 381 | + ) { |
|
| 382 | + $liste[$configurer] = [ |
|
| 383 | + 'parent' => 'bando_configuration', |
|
| 384 | + 'url' => 'configurer', |
|
| 385 | + 'args' => 'cfg=' . substr($configurer, 11), |
|
| 386 | + 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 387 | + 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 388 | + ]; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + return $liste; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -403,35 +403,35 @@ discard block |
||
| 403 | 403 | * Liste des formulaires trouvés |
| 404 | 404 | **/ |
| 405 | 405 | function lister_formulaires_configurer($file) { |
| 406 | - $forms = []; |
|
| 407 | - |
|
| 408 | - lire_fichier($file, $skel); |
|
| 409 | - if (preg_match_all(',#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),', $skel, $matches, PREG_SET_ORDER)) { |
|
| 410 | - $matches = array_map('end', $matches); |
|
| 411 | - $matches = array_map('strtolower', $matches); |
|
| 412 | - $forms = array_merge($forms, $matches); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
|
| 416 | - // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
|
| 417 | - $config = basename(substr($file, 0, -strlen('.' . _EXTENSION_SQUELETTES))); |
|
| 418 | - spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 419 | - $fond = recuperer_fond("prive/squelettes/contenu/$config", ['exec' => $config]); |
|
| 420 | - |
|
| 421 | - // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
|
| 422 | - // et donc que l'on puisse les referencer aussi ! |
|
| 423 | - $fond = pipeline('affiche_milieu', ['args' => ['exec' => $config], 'data' => $fond]); |
|
| 424 | - |
|
| 425 | - // recuperer les noms des formulaires presents. |
|
| 426 | - if (is_array($inputs = extraire_balises($fond, 'input'))) { |
|
| 427 | - foreach ($inputs as $i) { |
|
| 428 | - if (extraire_attribut($i, 'name') == 'formulaire_action') { |
|
| 429 | - $forms[] = ($c = extraire_attribut($i, 'value')); |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - return $forms; |
|
| 406 | + $forms = []; |
|
| 407 | + |
|
| 408 | + lire_fichier($file, $skel); |
|
| 409 | + if (preg_match_all(',#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),', $skel, $matches, PREG_SET_ORDER)) { |
|
| 410 | + $matches = array_map('end', $matches); |
|
| 411 | + $matches = array_map('strtolower', $matches); |
|
| 412 | + $forms = array_merge($forms, $matches); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
|
| 416 | + // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
|
| 417 | + $config = basename(substr($file, 0, -strlen('.' . _EXTENSION_SQUELETTES))); |
|
| 418 | + spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 419 | + $fond = recuperer_fond("prive/squelettes/contenu/$config", ['exec' => $config]); |
|
| 420 | + |
|
| 421 | + // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
|
| 422 | + // et donc que l'on puisse les referencer aussi ! |
|
| 423 | + $fond = pipeline('affiche_milieu', ['args' => ['exec' => $config], 'data' => $fond]); |
|
| 424 | + |
|
| 425 | + // recuperer les noms des formulaires presents. |
|
| 426 | + if (is_array($inputs = extraire_balises($fond, 'input'))) { |
|
| 427 | + foreach ($inputs as $i) { |
|
| 428 | + if (extraire_attribut($i, 'name') == 'formulaire_action') { |
|
| 429 | + $forms[] = ($c = extraire_attribut($i, 'value')); |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + return $forms; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | |
@@ -449,58 +449,58 @@ discard block |
||
| 449 | 449 | * Couples nom de la `meta` => valeur par défaut |
| 450 | 450 | */ |
| 451 | 451 | function liste_metas() { |
| 452 | - return pipeline('configurer_liste_metas', [ |
|
| 453 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 454 | - 'slogan_site' => '', |
|
| 455 | - 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 456 | - 'descriptif_site' => '', |
|
| 457 | - 'activer_logos' => 'oui', |
|
| 458 | - 'activer_logos_survol' => 'non', |
|
| 459 | - 'articles_surtitre' => 'non', |
|
| 460 | - 'articles_soustitre' => 'non', |
|
| 461 | - 'articles_descriptif' => 'non', |
|
| 462 | - 'articles_chapeau' => 'non', |
|
| 463 | - 'articles_texte' => 'oui', |
|
| 464 | - 'articles_ps' => 'non', |
|
| 465 | - 'articles_redac' => 'non', |
|
| 466 | - 'post_dates' => 'non', |
|
| 467 | - 'articles_urlref' => 'non', |
|
| 468 | - 'articles_redirection' => 'non', |
|
| 469 | - 'creer_preview' => 'non', |
|
| 470 | - 'taille_preview' => 150, |
|
| 471 | - 'articles_modif' => 'non', |
|
| 472 | - |
|
| 473 | - 'rubriques_descriptif' => 'non', |
|
| 474 | - 'rubriques_texte' => 'oui', |
|
| 475 | - |
|
| 476 | - 'accepter_inscriptions' => 'non', |
|
| 477 | - 'accepter_visiteurs' => 'non', |
|
| 478 | - 'prevenir_auteurs' => 'non', |
|
| 479 | - 'suivi_edito' => 'non', |
|
| 480 | - 'adresse_suivi' => '', |
|
| 481 | - 'adresse_suivi_inscription' => '', |
|
| 482 | - 'adresse_neuf' => '', |
|
| 483 | - 'jours_neuf' => '', |
|
| 484 | - 'quoi_de_neuf' => 'non', |
|
| 485 | - 'preview' => ',0minirezo,1comite,', |
|
| 486 | - |
|
| 487 | - 'syndication_integrale' => 'oui', |
|
| 488 | - 'charset' => _DEFAULT_CHARSET, |
|
| 489 | - 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 490 | - |
|
| 491 | - 'multi_rubriques' => 'non', |
|
| 492 | - 'multi_secteurs' => 'non', |
|
| 493 | - 'gerer_trad' => 'non', |
|
| 494 | - 'langues_multilingue' => '', |
|
| 495 | - |
|
| 496 | - 'version_html_max' => 'html4', |
|
| 497 | - |
|
| 498 | - 'type_urls' => 'page', |
|
| 499 | - |
|
| 500 | - 'email_envoi' => '', |
|
| 501 | - 'email_webmaster' => '', |
|
| 502 | - 'auto_compress_http' => 'non', |
|
| 503 | - ]); |
|
| 452 | + return pipeline('configurer_liste_metas', [ |
|
| 453 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 454 | + 'slogan_site' => '', |
|
| 455 | + 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 456 | + 'descriptif_site' => '', |
|
| 457 | + 'activer_logos' => 'oui', |
|
| 458 | + 'activer_logos_survol' => 'non', |
|
| 459 | + 'articles_surtitre' => 'non', |
|
| 460 | + 'articles_soustitre' => 'non', |
|
| 461 | + 'articles_descriptif' => 'non', |
|
| 462 | + 'articles_chapeau' => 'non', |
|
| 463 | + 'articles_texte' => 'oui', |
|
| 464 | + 'articles_ps' => 'non', |
|
| 465 | + 'articles_redac' => 'non', |
|
| 466 | + 'post_dates' => 'non', |
|
| 467 | + 'articles_urlref' => 'non', |
|
| 468 | + 'articles_redirection' => 'non', |
|
| 469 | + 'creer_preview' => 'non', |
|
| 470 | + 'taille_preview' => 150, |
|
| 471 | + 'articles_modif' => 'non', |
|
| 472 | + |
|
| 473 | + 'rubriques_descriptif' => 'non', |
|
| 474 | + 'rubriques_texte' => 'oui', |
|
| 475 | + |
|
| 476 | + 'accepter_inscriptions' => 'non', |
|
| 477 | + 'accepter_visiteurs' => 'non', |
|
| 478 | + 'prevenir_auteurs' => 'non', |
|
| 479 | + 'suivi_edito' => 'non', |
|
| 480 | + 'adresse_suivi' => '', |
|
| 481 | + 'adresse_suivi_inscription' => '', |
|
| 482 | + 'adresse_neuf' => '', |
|
| 483 | + 'jours_neuf' => '', |
|
| 484 | + 'quoi_de_neuf' => 'non', |
|
| 485 | + 'preview' => ',0minirezo,1comite,', |
|
| 486 | + |
|
| 487 | + 'syndication_integrale' => 'oui', |
|
| 488 | + 'charset' => _DEFAULT_CHARSET, |
|
| 489 | + 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 490 | + |
|
| 491 | + 'multi_rubriques' => 'non', |
|
| 492 | + 'multi_secteurs' => 'non', |
|
| 493 | + 'gerer_trad' => 'non', |
|
| 494 | + 'langues_multilingue' => '', |
|
| 495 | + |
|
| 496 | + 'version_html_max' => 'html4', |
|
| 497 | + |
|
| 498 | + 'type_urls' => 'page', |
|
| 499 | + |
|
| 500 | + 'email_envoi' => '', |
|
| 501 | + 'email_webmaster' => '', |
|
| 502 | + 'auto_compress_http' => 'non', |
|
| 503 | + ]); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -511,43 +511,43 @@ discard block |
||
| 511 | 511 | * @return void |
| 512 | 512 | */ |
| 513 | 513 | function actualise_metas($liste_meta) { |
| 514 | - $meta_serveur = |
|
| 515 | - [ |
|
| 516 | - 'version_installee', |
|
| 517 | - 'adresse_site', |
|
| 518 | - 'alea_ephemere_ancien', |
|
| 519 | - 'alea_ephemere', |
|
| 520 | - 'alea_ephemere_date', |
|
| 521 | - 'langue_site', |
|
| 522 | - 'langues_proposees', |
|
| 523 | - 'date_calcul_rubriques', |
|
| 524 | - 'derniere_modif', |
|
| 525 | - 'optimiser_table', |
|
| 526 | - 'drapeau_edition', |
|
| 527 | - 'creer_preview', |
|
| 528 | - 'taille_preview', |
|
| 529 | - 'creer_htpasswd', |
|
| 530 | - 'creer_htaccess', |
|
| 531 | - 'gd_formats_read', |
|
| 532 | - 'gd_formats', |
|
| 533 | - 'netpbm_formats', |
|
| 534 | - 'formats_graphiques', |
|
| 535 | - 'image_process', |
|
| 536 | - 'plugin_header', |
|
| 537 | - 'plugin' |
|
| 538 | - ]; |
|
| 539 | - // verifier le impt=non |
|
| 540 | - sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 541 | - |
|
| 542 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 543 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 544 | - ecrire_meta($nom, $valeur); |
|
| 545 | - } |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - include_spip('inc/rubriques'); |
|
| 549 | - $langues = calculer_langues_utilisees(); |
|
| 550 | - ecrire_meta('langues_utilisees', $langues); |
|
| 514 | + $meta_serveur = |
|
| 515 | + [ |
|
| 516 | + 'version_installee', |
|
| 517 | + 'adresse_site', |
|
| 518 | + 'alea_ephemere_ancien', |
|
| 519 | + 'alea_ephemere', |
|
| 520 | + 'alea_ephemere_date', |
|
| 521 | + 'langue_site', |
|
| 522 | + 'langues_proposees', |
|
| 523 | + 'date_calcul_rubriques', |
|
| 524 | + 'derniere_modif', |
|
| 525 | + 'optimiser_table', |
|
| 526 | + 'drapeau_edition', |
|
| 527 | + 'creer_preview', |
|
| 528 | + 'taille_preview', |
|
| 529 | + 'creer_htpasswd', |
|
| 530 | + 'creer_htaccess', |
|
| 531 | + 'gd_formats_read', |
|
| 532 | + 'gd_formats', |
|
| 533 | + 'netpbm_formats', |
|
| 534 | + 'formats_graphiques', |
|
| 535 | + 'image_process', |
|
| 536 | + 'plugin_header', |
|
| 537 | + 'plugin' |
|
| 538 | + ]; |
|
| 539 | + // verifier le impt=non |
|
| 540 | + sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 541 | + |
|
| 542 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 543 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 544 | + ecrire_meta($nom, $valeur); |
|
| 545 | + } |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + include_spip('inc/rubriques'); |
|
| 549 | + $langues = calculer_langues_utilisees(); |
|
| 550 | + ecrire_meta('langues_utilisees', $langues); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | |
@@ -569,18 +569,18 @@ discard block |
||
| 569 | 569 | */ |
| 570 | 570 | function appliquer_modifs_config($purger_skel = false) { |
| 571 | 571 | |
| 572 | - foreach (liste_metas() as $i => $v) { |
|
| 573 | - if (($x = _request($i)) !== null) { |
|
| 574 | - ecrire_meta($i, $x); |
|
| 575 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 576 | - ecrire_meta($i, $v); |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - if ($purger_skel) { |
|
| 581 | - include_spip('inc/invalideur'); |
|
| 582 | - purger_repertoire(_DIR_SKELS); |
|
| 583 | - } |
|
| 572 | + foreach (liste_metas() as $i => $v) { |
|
| 573 | + if (($x = _request($i)) !== null) { |
|
| 574 | + ecrire_meta($i, $x); |
|
| 575 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 576 | + ecrire_meta($i, $v); |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + if ($purger_skel) { |
|
| 581 | + include_spip('inc/invalideur'); |
|
| 582 | + purger_repertoire(_DIR_SKELS); |
|
| 583 | + } |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -591,21 +591,21 @@ discard block |
||
| 591 | 591 | * @return string |
| 592 | 592 | */ |
| 593 | 593 | function appliquer_adresse_site($adresse_site) { |
| 594 | - if ($adresse_site !== null) { |
|
| 595 | - if (!strlen($adresse_site)) { |
|
| 596 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 597 | - $adresse_site = url_de_base(); |
|
| 598 | - } |
|
| 599 | - $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 594 | + if ($adresse_site !== null) { |
|
| 595 | + if (!strlen($adresse_site)) { |
|
| 596 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 597 | + $adresse_site = url_de_base(); |
|
| 598 | + } |
|
| 599 | + $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 600 | 600 | |
| 601 | - if (!tester_url_absolue($adresse_site)) { |
|
| 602 | - $adresse_site = "http://$adresse_site"; |
|
| 603 | - } |
|
| 601 | + if (!tester_url_absolue($adresse_site)) { |
|
| 602 | + $adresse_site = "http://$adresse_site"; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | - $adresse_site = entites_html($adresse_site); |
|
| 605 | + $adresse_site = entites_html($adresse_site); |
|
| 606 | 606 | |
| 607 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 608 | - } |
|
| 607 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 608 | + } |
|
| 609 | 609 | |
| 610 | - return $adresse_site; |
|
| 610 | + return $adresse_site; |
|
| 611 | 611 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | if (strncmp($url, 'configurer_', 11) == 0) { |
| 336 | 336 | $deja[$url] = $b; |
| 337 | 337 | } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
| 338 | - $deja['configurer_' . $match[1]] = $b; |
|
| 338 | + $deja['configurer_'.$match[1]] = $b; |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
@@ -348,10 +348,10 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | // trouver toutes les pages configurer_xxx de l'espace prive |
| 350 | 350 | // et construire un tableau des entrees qui ne sont pas dans $deja |
| 351 | - $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 351 | + $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]'._EXTENSION_SQUELETTES.'$'); |
|
| 352 | 352 | |
| 353 | 353 | foreach ($pages as $page) { |
| 354 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 354 | + $configurer = basename($page, '.'._EXTENSION_SQUELETTES); |
|
| 355 | 355 | if (!isset($exclure[$configurer])) { |
| 356 | 356 | $liste[$configurer] = [ |
| 357 | 357 | 'parent' => 'bando_configuration', |
@@ -371,9 +371,9 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | // trouver tous les formulaires/configurer_ |
| 373 | 373 | // et construire un tableau des entrees |
| 374 | - $pages = find_all_in_path('formulaires/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 374 | + $pages = find_all_in_path('formulaires/', 'configurer_.*[.]'._EXTENSION_SQUELETTES.'$'); |
|
| 375 | 375 | foreach ($pages as $page) { |
| 376 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 376 | + $configurer = basename($page, '.'._EXTENSION_SQUELETTES); |
|
| 377 | 377 | if ( |
| 378 | 378 | !isset($forms[$configurer]) |
| 379 | 379 | and !isset($liste[$configurer]) |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $liste[$configurer] = [ |
| 383 | 383 | 'parent' => 'bando_configuration', |
| 384 | 384 | 'url' => 'configurer', |
| 385 | - 'args' => 'cfg=' . substr($configurer, 11), |
|
| 385 | + 'args' => 'cfg='.substr($configurer, 11), |
|
| 386 | 386 | 'titre' => _T("configurer:{$configurer}_titre"), |
| 387 | 387 | 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
| 388 | 388 | ]; |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
| 416 | 416 | // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
| 417 | - $config = basename(substr($file, 0, -strlen('.' . _EXTENSION_SQUELETTES))); |
|
| 418 | - spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 417 | + $config = basename(substr($file, 0, -strlen('.'._EXTENSION_SQUELETTES))); |
|
| 418 | + spip_log('Calcul de '."prive/squelettes/contenu/$config"); |
|
| 419 | 419 | $fond = recuperer_fond("prive/squelettes/contenu/$config", ['exec' => $config]); |
| 420 | 420 | |
| 421 | 421 | // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/serial'); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * en droit de l'éliminer |
| 28 | 28 | */ |
| 29 | 29 | if (!defined('_AGE_CACHE_ATIME')) { |
| 30 | - define('_AGE_CACHE_ATIME', 3600); |
|
| 30 | + define('_AGE_CACHE_ATIME', 3600); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -40,31 +40,31 @@ discard block |
||
| 40 | 40 | * @return int Taille approximative en octets |
| 41 | 41 | **/ |
| 42 | 42 | function taille_du_cache() { |
| 43 | - # check dirs until we reach > 500 files |
|
| 44 | - $t = 0; |
|
| 45 | - $n = 0; |
|
| 46 | - $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; |
|
| 47 | - for ($i = 0; $i < 256; $i++) { |
|
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | - while (($f = readdir($d)) !== false) { |
|
| 51 | - if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | - $n++; |
|
| 53 | - if ($a['mtime'] >= $time) { |
|
| 54 | - if ($a['blocks'] > 0) { |
|
| 55 | - $t += 512 * $a['blocks']; |
|
| 56 | - } else { |
|
| 57 | - $t += $a['size']; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - if ($n > 500) { |
|
| 64 | - return intval(256 * $t / (1 + $i)); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $t; |
|
| 43 | + # check dirs until we reach > 500 files |
|
| 44 | + $t = 0; |
|
| 45 | + $n = 0; |
|
| 46 | + $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; |
|
| 47 | + for ($i = 0; $i < 256; $i++) { |
|
| 48 | + $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | + while (($f = readdir($d)) !== false) { |
|
| 51 | + if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | + $n++; |
|
| 53 | + if ($a['mtime'] >= $time) { |
|
| 54 | + if ($a['blocks'] > 0) { |
|
| 55 | + $t += 512 * $a['blocks']; |
|
| 56 | + } else { |
|
| 57 | + $t += $a['size']; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + if ($n > 500) { |
|
| 64 | + return intval(256 * $t / (1 + $i)); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $t; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -91,30 +91,30 @@ discard block |
||
| 91 | 91 | * Inutilisé |
| 92 | 92 | **/ |
| 93 | 93 | function inc_suivre_invalideur_dist($cond, $modif = true) { |
| 94 | - if (!$modif) { |
|
| 95 | - return; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // determiner l'objet modifie : forum, article, etc |
|
| 99 | - if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | - $objet = objet_type($r[1]); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | - if (isset($objet)) { |
|
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | - // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | - if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | - if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | - ecrire_meta('derniere_modif', time()); |
|
| 113 | - } |
|
| 114 | - } // sinon, cas standard, toujours affecter la meta |
|
| 115 | - else { |
|
| 116 | - ecrire_meta('derniere_modif', time()); |
|
| 117 | - } |
|
| 94 | + if (!$modif) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // determiner l'objet modifie : forum, article, etc |
|
| 99 | + if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | + $objet = objet_type($r[1]); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | + if (isset($objet)) { |
|
| 105 | + ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | + // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | + if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | + if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | + ecrire_meta('derniere_modif', time()); |
|
| 113 | + } |
|
| 114 | + } // sinon, cas standard, toujours affecter la meta |
|
| 115 | + else { |
|
| 116 | + ecrire_meta('derniere_modif', time()); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -139,50 +139,50 @@ discard block |
||
| 139 | 139 | * Nombre de fichiers supprimés |
| 140 | 140 | **/ |
| 141 | 141 | function purger_repertoire($dir, $options = []) { |
| 142 | - if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | - return; |
|
| 144 | - } |
|
| 145 | - $handle = opendir($dir); |
|
| 146 | - if (!$handle) { |
|
| 147 | - return; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $total = 0; |
|
| 151 | - |
|
| 152 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 153 | - // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 154 | - if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 155 | - continue; |
|
| 156 | - } |
|
| 157 | - $chemin = "$dir/$fichier"; |
|
| 158 | - if (is_file($chemin)) { |
|
| 159 | - if ( |
|
| 160 | - (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 161 | - and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 162 | - ) { |
|
| 163 | - supprimer_fichier($chemin); |
|
| 164 | - $total++; |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if (is_dir($chemin)) { |
|
| 168 | - $opts = $options; |
|
| 169 | - if (isset($options['limit'])) { |
|
| 170 | - $opts['limit'] = $options['limit'] - $total; |
|
| 171 | - } |
|
| 172 | - $total += purger_repertoire($chemin, $opts); |
|
| 173 | - if (isset($options['subdir']) && $options['subdir']) { |
|
| 174 | - spip_unlink($chemin); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 180 | - break; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - closedir($handle); |
|
| 184 | - |
|
| 185 | - return $total; |
|
| 142 | + if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | + return; |
|
| 144 | + } |
|
| 145 | + $handle = opendir($dir); |
|
| 146 | + if (!$handle) { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $total = 0; |
|
| 151 | + |
|
| 152 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 153 | + // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 154 | + if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 155 | + continue; |
|
| 156 | + } |
|
| 157 | + $chemin = "$dir/$fichier"; |
|
| 158 | + if (is_file($chemin)) { |
|
| 159 | + if ( |
|
| 160 | + (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 161 | + and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 162 | + ) { |
|
| 163 | + supprimer_fichier($chemin); |
|
| 164 | + $total++; |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if (is_dir($chemin)) { |
|
| 168 | + $opts = $options; |
|
| 169 | + if (isset($options['limit'])) { |
|
| 170 | + $opts['limit'] = $options['limit'] - $total; |
|
| 171 | + } |
|
| 172 | + $total += purger_repertoire($chemin, $opts); |
|
| 173 | + if (isset($options['subdir']) && $options['subdir']) { |
|
| 174 | + spip_unlink($chemin); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 180 | + break; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + closedir($handle); |
|
| 184 | + |
|
| 185 | + return $total; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -194,17 +194,17 @@ discard block |
||
| 194 | 194 | // https://code.spip.net/@retire_cache |
| 195 | 195 | function retire_cache($cache) { |
| 196 | 196 | |
| 197 | - if ( |
|
| 198 | - preg_match( |
|
| 199 | - ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 200 | - $cache |
|
| 201 | - ) |
|
| 202 | - ) { |
|
| 203 | - // supprimer le fichier (de facon propre) |
|
| 204 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 205 | - } else { |
|
| 206 | - spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 207 | - } |
|
| 197 | + if ( |
|
| 198 | + preg_match( |
|
| 199 | + ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 200 | + $cache |
|
| 201 | + ) |
|
| 202 | + ) { |
|
| 203 | + // supprimer le fichier (de facon propre) |
|
| 204 | + supprimer_fichier(_DIR_CACHE . $cache); |
|
| 205 | + } else { |
|
| 206 | + spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 207 | + } |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Supprimer les caches marques "x" |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | // la meta est toujours false ; mais evitons un bug si elle est appellee |
| 213 | 213 | // https://code.spip.net/@retire_caches |
| 214 | 214 | function inc_retire_caches_dist($chemin = '') { |
| 215 | - if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 216 | - effacer_meta('invalider_caches'); |
|
| 217 | - } # concurrence |
|
| 215 | + if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 216 | + effacer_meta('invalider_caches'); |
|
| 217 | + } # concurrence |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | ####################################################################### |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | ## |
| 226 | 226 | |
| 227 | 227 | function retire_caches($chemin = '') { |
| 228 | - if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 229 | - return $retire_caches($chemin); |
|
| 230 | - } |
|
| 228 | + if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 229 | + return $retire_caches($chemin); |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | // https://code.spip.net/@calcul_invalideurs |
| 238 | 238 | function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) { |
| 239 | - if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 240 | - return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 241 | - } |
|
| 242 | - return $corps; |
|
| 239 | + if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 240 | + return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 241 | + } |
|
| 242 | + return $corps; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -249,27 +249,27 @@ discard block |
||
| 249 | 249 | // |
| 250 | 250 | // https://code.spip.net/@supprime_invalideurs |
| 251 | 251 | function supprime_invalideurs() { |
| 252 | - if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 253 | - return $supprime_invalideurs(); |
|
| 254 | - } |
|
| 252 | + if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 253 | + return $supprime_invalideurs(); |
|
| 254 | + } |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
| 258 | 258 | // Calcul des pages : noter dans la base les liens d'invalidation |
| 259 | 259 | // https://code.spip.net/@maj_invalideurs |
| 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 | // https://code.spip.net/@insere_invalideur |
| 269 | 269 | function insere_invalideur($inval, $fichier) { |
| 270 | - if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 271 | - return $insere_invalideur($inval, $fichier); |
|
| 272 | - } |
|
| 270 | + if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 271 | + return $insere_invalideur($inval, $fichier); |
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // |
@@ -277,16 +277,16 @@ discard block |
||
| 277 | 277 | // |
| 278 | 278 | // https://code.spip.net/@applique_invalideur |
| 279 | 279 | function applique_invalideur($depart) { |
| 280 | - if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | - return $applique_invalideur($depart); |
|
| 282 | - } |
|
| 280 | + if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | + return $applique_invalideur($depart); |
|
| 282 | + } |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // |
| 286 | 286 | // Invalider les caches liés à telle condition |
| 287 | 287 | // |
| 288 | 288 | function suivre_invalideur($cond, $modif = true) { |
| 289 | - if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | - return $suivre_invalideur($cond, $modif); |
|
| 291 | - } |
|
| 289 | + if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | + return $suivre_invalideur($cond, $modif); |
|
| 291 | + } |
|
| 292 | 292 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $n = 0; |
| 46 | 46 | $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; |
| 47 | 47 | for ($i = 0; $i < 256; $i++) { |
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 48 | + $dir = _DIR_CACHE.sprintf('%02s', dechex($i)); |
|
| 49 | 49 | if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
| 50 | 50 | while (($f = readdir($d)) !== false) { |
| 51 | 51 | if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | // stocker la date_modif_$objet (ne sert a rien pour le moment) |
| 104 | 104 | if (isset($objet)) { |
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 105 | + ecrire_meta('derniere_modif_'.$objet, time()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // si $derniere_modif_invalide est un array('article', 'rubrique') |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | ) |
| 202 | 202 | ) { |
| 203 | 203 | // supprimer le fichier (de facon propre) |
| 204 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 204 | + supprimer_fichier(_DIR_CACHE.$cache); |
|
| 205 | 205 | } else { |
| 206 | 206 | spip_log("Nom de fichier cache incorrect : $cache"); |
| 207 | 207 | } |
@@ -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/filtres_boites'); |
@@ -41,27 +41,27 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 53 | - ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 54 | - : 2; |
|
| 52 | + $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 53 | + ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 54 | + : 2; |
|
| 55 | 55 | |
| 56 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 57 | - parse_str($couleurs($c), $c); |
|
| 58 | - $args = array_merge($args, $c); |
|
| 56 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 57 | + parse_str($couleurs($c), $c); |
|
| 58 | + $args = array_merge($args, $c); |
|
| 59 | 59 | |
| 60 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 61 | - $args['var_mode'] = 'recalcul'; |
|
| 62 | - } |
|
| 60 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 61 | + $args['var_mode'] = 'recalcul'; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return http_build_query($args); |
|
| 64 | + return http_build_query($args); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
@@ -84,91 +84,91 @@ discard block |
||
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | 86 | function chercher_rubrique( |
| 87 | - $titre, |
|
| 88 | - $id_objet, |
|
| 89 | - $id_parent, |
|
| 90 | - $objet, |
|
| 91 | - $id_secteur, |
|
| 92 | - $restreint, |
|
| 93 | - $actionable = false, |
|
| 94 | - $retour_sans_cadre = false |
|
| 87 | + $titre, |
|
| 88 | + $id_objet, |
|
| 89 | + $id_parent, |
|
| 90 | + $objet, |
|
| 91 | + $id_secteur, |
|
| 92 | + $restreint, |
|
| 93 | + $actionable = false, |
|
| 94 | + $retour_sans_cadre = false |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | - include_spip('inc/autoriser'); |
|
| 98 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 99 | - return ''; |
|
| 100 | - } |
|
| 101 | - if (!sql_countsel('spip_rubriques')) { |
|
| 102 | - return ''; |
|
| 103 | - } |
|
| 104 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 105 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 106 | - |
|
| 107 | - if ($id_parent == 0) { |
|
| 108 | - $logo = 'racine-24.png'; |
|
| 109 | - } elseif ($id_secteur == $id_parent) { |
|
| 110 | - $logo = 'secteur-24.png'; |
|
| 111 | - } else { |
|
| 112 | - $logo = 'rubrique-24.png'; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $confirm = ''; |
|
| 116 | - if ($objet == 'rubrique') { |
|
| 117 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 118 | - // confirmation du deplacement |
|
| 119 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 120 | - |
|
| 121 | - if ($contient_breves > 0) { |
|
| 122 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 123 | - $scb = _T( |
|
| 124 | - 'avis_deplacement_rubrique', |
|
| 125 | - [ |
|
| 126 | - 'contient_breves' => $contient_breves, |
|
| 127 | - 'scb' => $scb |
|
| 128 | - ] |
|
| 129 | - ); |
|
| 130 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 131 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 132 | - . $scb . |
|
| 133 | - "</label></div></div>\n"; |
|
| 134 | - } else { |
|
| 135 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - $form .= $confirm; |
|
| 139 | - if ($actionable) { |
|
| 140 | - if (strpos($form, '<select') !== false) { |
|
| 141 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 142 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 143 | - . '</div>'; |
|
| 144 | - } |
|
| 145 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 146 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 147 | - $form = generer_action_auteur( |
|
| 148 | - "editer_$objet", |
|
| 149 | - $id_objet, |
|
| 150 | - self(), |
|
| 151 | - $form, |
|
| 152 | - " method='post' class='submit_plongeur'" |
|
| 153 | - ); |
|
| 154 | - } else { |
|
| 155 | - $form = generer_action_auteur( |
|
| 156 | - 'editer_objet', |
|
| 157 | - "$objet/$id_objet", |
|
| 158 | - self(), |
|
| 159 | - $form, |
|
| 160 | - " method='post' class='submit_plongeur'" |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - if ($retour_sans_cadre) { |
|
| 166 | - return $form; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - include_spip('inc/presentation'); |
|
| 170 | - |
|
| 171 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(true); |
|
| 97 | + include_spip('inc/autoriser'); |
|
| 98 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + if (!sql_countsel('spip_rubriques')) { |
|
| 102 | + return ''; |
|
| 103 | + } |
|
| 104 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 105 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 106 | + |
|
| 107 | + if ($id_parent == 0) { |
|
| 108 | + $logo = 'racine-24.png'; |
|
| 109 | + } elseif ($id_secteur == $id_parent) { |
|
| 110 | + $logo = 'secteur-24.png'; |
|
| 111 | + } else { |
|
| 112 | + $logo = 'rubrique-24.png'; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $confirm = ''; |
|
| 116 | + if ($objet == 'rubrique') { |
|
| 117 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 118 | + // confirmation du deplacement |
|
| 119 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 120 | + |
|
| 121 | + if ($contient_breves > 0) { |
|
| 122 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 123 | + $scb = _T( |
|
| 124 | + 'avis_deplacement_rubrique', |
|
| 125 | + [ |
|
| 126 | + 'contient_breves' => $contient_breves, |
|
| 127 | + 'scb' => $scb |
|
| 128 | + ] |
|
| 129 | + ); |
|
| 130 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 131 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 132 | + . $scb . |
|
| 133 | + "</label></div></div>\n"; |
|
| 134 | + } else { |
|
| 135 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + $form .= $confirm; |
|
| 139 | + if ($actionable) { |
|
| 140 | + if (strpos($form, '<select') !== false) { |
|
| 141 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 142 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 143 | + . '</div>'; |
|
| 144 | + } |
|
| 145 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 146 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 147 | + $form = generer_action_auteur( |
|
| 148 | + "editer_$objet", |
|
| 149 | + $id_objet, |
|
| 150 | + self(), |
|
| 151 | + $form, |
|
| 152 | + " method='post' class='submit_plongeur'" |
|
| 153 | + ); |
|
| 154 | + } else { |
|
| 155 | + $form = generer_action_auteur( |
|
| 156 | + 'editer_objet', |
|
| 157 | + "$objet/$id_objet", |
|
| 158 | + self(), |
|
| 159 | + $form, |
|
| 160 | + " method='post' class='submit_plongeur'" |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + if ($retour_sans_cadre) { |
|
| 166 | + return $form; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + include_spip('inc/presentation'); |
|
| 170 | + |
|
| 171 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(true); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -182,24 +182,24 @@ discard block |
||
| 182 | 182 | * @return bool |
| 183 | 183 | */ |
| 184 | 184 | function avoir_visiteurs($past = false, $accepter = true) { |
| 185 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 186 | - return true; |
|
| 187 | - } |
|
| 188 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 189 | - return true; |
|
| 190 | - } |
|
| 191 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 192 | - return true; |
|
| 193 | - } |
|
| 194 | - if (!$past) { |
|
| 195 | - return false; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - return sql_countsel( |
|
| 199 | - 'spip_auteurs', |
|
| 200 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 185 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 186 | + return true; |
|
| 187 | + } |
|
| 188 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 189 | + return true; |
|
| 190 | + } |
|
| 191 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 192 | + return true; |
|
| 193 | + } |
|
| 194 | + if (!$past) { |
|
| 195 | + return false; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + return sql_countsel( |
|
| 199 | + 'spip_auteurs', |
|
| 200 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 201 | 201 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 202 | - ); |
|
| 202 | + ); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -215,18 +215,18 @@ discard block |
||
| 215 | 215 | * @return array |
| 216 | 216 | */ |
| 217 | 217 | function statuts_articles_visibles($statut_auteur) { |
| 218 | - static $auth = []; |
|
| 219 | - if (!isset($auth[$statut_auteur])) { |
|
| 220 | - $auth[$statut_auteur] = []; |
|
| 221 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 222 | - foreach ($statuts as $s) { |
|
| 223 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 224 | - $auth[$statut_auteur][] = $s; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - return $auth[$statut_auteur]; |
|
| 218 | + static $auth = []; |
|
| 219 | + if (!isset($auth[$statut_auteur])) { |
|
| 220 | + $auth[$statut_auteur] = []; |
|
| 221 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 222 | + foreach ($statuts as $s) { |
|
| 223 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 224 | + $auth[$statut_auteur][] = $s; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + return $auth[$statut_auteur]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -240,38 +240,38 @@ discard block |
||
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | 242 | function traduire_statut_auteur($statut, $attente = '') { |
| 243 | - $plus = ''; |
|
| 244 | - if ($statut == 'nouveau') { |
|
| 245 | - if ($attente) { |
|
| 246 | - $statut = $attente; |
|
| 247 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 248 | - } else { |
|
| 249 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - $recom = [ |
|
| 254 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 255 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 256 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 257 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 258 | - ]; |
|
| 259 | - if (isset($recom[$statut])) { |
|
| 260 | - return $recom[$statut] . $plus; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - // retrouver directement par le statut sinon |
|
| 264 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 265 | - if (isset($recom[$t])) { |
|
| 266 | - return $recom[$t] . $plus; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - return _T($t) . $plus; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 273 | - // c'est toujours plus informatif que rien du tout |
|
| 274 | - return $statut; |
|
| 243 | + $plus = ''; |
|
| 244 | + if ($statut == 'nouveau') { |
|
| 245 | + if ($attente) { |
|
| 246 | + $statut = $attente; |
|
| 247 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 248 | + } else { |
|
| 249 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + $recom = [ |
|
| 254 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 255 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 256 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 257 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 258 | + ]; |
|
| 259 | + if (isset($recom[$statut])) { |
|
| 260 | + return $recom[$statut] . $plus; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + // retrouver directement par le statut sinon |
|
| 264 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 265 | + if (isset($recom[$t])) { |
|
| 266 | + return $recom[$t] . $plus; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + return _T($t) . $plus; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 273 | + // c'est toujours plus informatif que rien du tout |
|
| 274 | + return $statut; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -282,28 +282,28 @@ discard block |
||
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | 284 | function afficher_qui_edite($id_objet, $objet) { |
| 285 | - static $qui = []; |
|
| 286 | - if (isset($qui[$objet][$id_objet])) { |
|
| 287 | - return $qui[$objet][$id_objet]; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 291 | - return $qui[$objet][$id_objet] = ''; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - include_spip('inc/drapeau_edition'); |
|
| 295 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 296 | - if (!$modif) { |
|
| 297 | - return $qui[$objet][$id_objet] = ''; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - include_spip('base/objets'); |
|
| 301 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 302 | - if (isset($infos['texte_signale_edition'])) { |
|
| 303 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 285 | + static $qui = []; |
|
| 286 | + if (isset($qui[$objet][$id_objet])) { |
|
| 287 | + return $qui[$objet][$id_objet]; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 291 | + return $qui[$objet][$id_objet] = ''; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + include_spip('inc/drapeau_edition'); |
|
| 295 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 296 | + if (!$modif) { |
|
| 297 | + return $qui[$objet][$id_objet] = ''; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + include_spip('base/objets'); |
|
| 301 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 302 | + if (isset($infos['texte_signale_edition'])) { |
|
| 303 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -321,57 +321,57 @@ discard block |
||
| 321 | 321 | * @return array |
| 322 | 322 | */ |
| 323 | 323 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true) { |
| 324 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 325 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - switch ($quoi) { |
|
| 329 | - case 'redacteurs': |
|
| 330 | - $statut = AUTEURS_MIN_REDAC; |
|
| 331 | - $statut = explode(',', $statut); |
|
| 332 | - if ($en_base) { |
|
| 333 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 334 | - $retire = array_diff($statut, $check); |
|
| 335 | - $statut = array_diff($statut, $retire); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - return array_unique($statut); |
|
| 339 | - break; |
|
| 340 | - case 'visiteurs': |
|
| 341 | - $statut = []; |
|
| 342 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 343 | - $exclus = explode(',', $exclus); |
|
| 344 | - if (!$en_base) { |
|
| 345 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 346 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 347 | - } |
|
| 348 | - $s_complement = array_column( |
|
| 349 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 350 | - 'statut' |
|
| 351 | - ); |
|
| 352 | - |
|
| 353 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 354 | - break; |
|
| 355 | - default: |
|
| 356 | - case 'tous': |
|
| 357 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 358 | - $s_complement = array_column( |
|
| 359 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 360 | - 'statut' |
|
| 361 | - ); |
|
| 362 | - $statut = array_merge($statut, $s_complement); |
|
| 363 | - if ($en_base) { |
|
| 364 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 365 | - $retire = array_diff($statut, $check); |
|
| 366 | - $statut = array_diff($statut, $retire); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - return array_unique($statut); |
|
| 370 | - break; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - // on arrive jamais ici |
|
| 374 | - return array_values($GLOBALS['liste_des_statuts']); |
|
| 324 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 325 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + switch ($quoi) { |
|
| 329 | + case 'redacteurs': |
|
| 330 | + $statut = AUTEURS_MIN_REDAC; |
|
| 331 | + $statut = explode(',', $statut); |
|
| 332 | + if ($en_base) { |
|
| 333 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 334 | + $retire = array_diff($statut, $check); |
|
| 335 | + $statut = array_diff($statut, $retire); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + return array_unique($statut); |
|
| 339 | + break; |
|
| 340 | + case 'visiteurs': |
|
| 341 | + $statut = []; |
|
| 342 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 343 | + $exclus = explode(',', $exclus); |
|
| 344 | + if (!$en_base) { |
|
| 345 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 346 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 347 | + } |
|
| 348 | + $s_complement = array_column( |
|
| 349 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 350 | + 'statut' |
|
| 351 | + ); |
|
| 352 | + |
|
| 353 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 354 | + break; |
|
| 355 | + default: |
|
| 356 | + case 'tous': |
|
| 357 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 358 | + $s_complement = array_column( |
|
| 359 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 360 | + 'statut' |
|
| 361 | + ); |
|
| 362 | + $statut = array_merge($statut, $s_complement); |
|
| 363 | + if ($en_base) { |
|
| 364 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 365 | + $retire = array_diff($statut, $check); |
|
| 366 | + $statut = array_diff($statut, $retire); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + return array_unique($statut); |
|
| 370 | + break; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + // on arrive jamais ici |
|
| 374 | + return array_values($GLOBALS['liste_des_statuts']); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -387,28 +387,28 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 389 | 389 | |
| 390 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 391 | - $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 392 | - ? '' |
|
| 393 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 394 | - |
|
| 395 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 396 | - if ($objet == 'rubrique') { |
|
| 397 | - $id_rubrique = 0; |
|
| 398 | - } else { |
|
| 399 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 403 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 404 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 405 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 406 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - return $id_rubrique; |
|
| 390 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 391 | + $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 392 | + ? '' |
|
| 393 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 394 | + |
|
| 395 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 396 | + if ($objet == 'rubrique') { |
|
| 397 | + $id_rubrique = 0; |
|
| 398 | + } else { |
|
| 399 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 403 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 404 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 405 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 406 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return $id_rubrique; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -419,12 +419,12 @@ discard block |
||
| 419 | 419 | * @return string |
| 420 | 420 | */ |
| 421 | 421 | function lien_article_virtuel($virtuel) { |
| 422 | - include_spip('inc/lien'); |
|
| 423 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 424 | - return ''; |
|
| 425 | - } |
|
| 422 | + include_spip('inc/lien'); |
|
| 423 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 424 | + return ''; |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - return propre('[->' . $virtuel . ']'); |
|
| 427 | + return propre('[->' . $virtuel . ']'); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | * Code HTML du lien |
| 448 | 448 | */ |
| 449 | 449 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 450 | - include_spip('inc/acces'); |
|
| 451 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 452 | - $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 453 | - $url = generer_url_public('rss', $args); |
|
| 450 | + include_spip('inc/acces'); |
|
| 451 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 452 | + $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 453 | + $url = generer_url_public('rss', $args); |
|
| 454 | 454 | |
| 455 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 455 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | |
@@ -464,74 +464,74 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | function alertes_auteur($id_auteur) { |
| 466 | 466 | |
| 467 | - $alertes = []; |
|
| 468 | - |
|
| 469 | - if ( |
|
| 470 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 471 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 472 | - ) { |
|
| 473 | - include_spip('genie/maintenance'); |
|
| 474 | - if ($msg = message_crash_tables()) { |
|
| 475 | - $alertes[] = $msg; |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - if ( |
|
| 480 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 481 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 482 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 483 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 484 | - ) { |
|
| 485 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 486 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 490 | - if ( |
|
| 491 | - $a |
|
| 492 | - and is_array($a = unserialize($a)) |
|
| 493 | - and count($a) |
|
| 494 | - ) { |
|
| 495 | - $update = false; |
|
| 496 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 497 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 498 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 499 | - $update = true; |
|
| 500 | - } |
|
| 501 | - if (isset($a[''])) { |
|
| 502 | - $alertes = array_merge($alertes, $a['']); |
|
| 503 | - unset($a['']); |
|
| 504 | - $update = true; |
|
| 505 | - } |
|
| 506 | - if ($update) { |
|
| 507 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - if ( |
|
| 512 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 513 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 514 | - ) { |
|
| 515 | - include_spip('inc/plugin'); |
|
| 516 | - $alertes[] = plugin_donne_erreurs(); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - $alertes = pipeline( |
|
| 520 | - 'alertes_auteur', |
|
| 521 | - [ |
|
| 522 | - 'args' => [ |
|
| 523 | - 'id_auteur' => $id_auteur, |
|
| 524 | - 'exec' => _request('exec'), |
|
| 525 | - ], |
|
| 526 | - 'data' => $alertes |
|
| 527 | - ] |
|
| 528 | - ); |
|
| 529 | - |
|
| 530 | - if ($alertes = array_filter($alertes)) { |
|
| 531 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 532 | - join(' | ', $alertes) |
|
| 533 | - . '</div></div>'; |
|
| 534 | - } |
|
| 467 | + $alertes = []; |
|
| 468 | + |
|
| 469 | + if ( |
|
| 470 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 471 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 472 | + ) { |
|
| 473 | + include_spip('genie/maintenance'); |
|
| 474 | + if ($msg = message_crash_tables()) { |
|
| 475 | + $alertes[] = $msg; |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + if ( |
|
| 480 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 481 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 482 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 483 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 484 | + ) { |
|
| 485 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 486 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 490 | + if ( |
|
| 491 | + $a |
|
| 492 | + and is_array($a = unserialize($a)) |
|
| 493 | + and count($a) |
|
| 494 | + ) { |
|
| 495 | + $update = false; |
|
| 496 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 497 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 498 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 499 | + $update = true; |
|
| 500 | + } |
|
| 501 | + if (isset($a[''])) { |
|
| 502 | + $alertes = array_merge($alertes, $a['']); |
|
| 503 | + unset($a['']); |
|
| 504 | + $update = true; |
|
| 505 | + } |
|
| 506 | + if ($update) { |
|
| 507 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 508 | + } |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + if ( |
|
| 512 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 513 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 514 | + ) { |
|
| 515 | + include_spip('inc/plugin'); |
|
| 516 | + $alertes[] = plugin_donne_erreurs(); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + $alertes = pipeline( |
|
| 520 | + 'alertes_auteur', |
|
| 521 | + [ |
|
| 522 | + 'args' => [ |
|
| 523 | + 'id_auteur' => $id_auteur, |
|
| 524 | + 'exec' => _request('exec'), |
|
| 525 | + ], |
|
| 526 | + 'data' => $alertes |
|
| 527 | + ] |
|
| 528 | + ); |
|
| 529 | + |
|
| 530 | + if ($alertes = array_filter($alertes)) { |
|
| 531 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 532 | + join(' | ', $alertes) |
|
| 533 | + . '</div></div>'; |
|
| 534 | + } |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | 543 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 544 | - include_spip('inc/presenter_enfants'); |
|
| 544 | + include_spip('inc/presenter_enfants'); |
|
| 545 | 545 | |
| 546 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 546 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -561,15 +561,15 @@ discard block |
||
| 561 | 561 | * @return string |
| 562 | 562 | */ |
| 563 | 563 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 564 | - $titre = attribut_html($titre); |
|
| 565 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | - |
|
| 568 | - if (!$titre_lien) { |
|
| 569 | - return $icone; |
|
| 570 | - } else { |
|
| 571 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | - } |
|
| 564 | + $titre = attribut_html($titre); |
|
| 565 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | + |
|
| 568 | + if (!$titre_lien) { |
|
| 569 | + return $icone; |
|
| 570 | + } else { |
|
| 571 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | + } |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | |
@@ -588,17 +588,17 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 591 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | - if (!count($res)) { |
|
| 593 | - return []; |
|
| 594 | - } |
|
| 595 | - $r = reset($res); |
|
| 596 | - if (isset($r['rang_lien'])) { |
|
| 597 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 598 | - asort($l); |
|
| 599 | - $l = array_keys($l); |
|
| 600 | - } else { |
|
| 601 | - $l = array_column($res, $objet_source); |
|
| 602 | - } |
|
| 603 | - return $l; |
|
| 591 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | + if (!count($res)) { |
|
| 593 | + return []; |
|
| 594 | + } |
|
| 595 | + $r = reset($res); |
|
| 596 | + if (isset($r['rang_lien'])) { |
|
| 597 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 598 | + asort($l); |
|
| 599 | + $l = array_keys($l); |
|
| 600 | + } else { |
|
| 601 | + $l = array_column($res, $objet_source); |
|
| 602 | + } |
|
| 603 | + return $l; |
|
| 604 | 604 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($objet == 'rubrique') { |
| 117 | 117 | // si c'est une rubrique-secteur contenant des breves, demander la |
| 118 | 118 | // confirmation du deplacement |
| 119 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 119 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique='.intval($id_objet)); |
|
| 120 | 120 | |
| 121 | 121 | if ($contient_breves > 0) { |
| 122 | 122 | $scb = ($contient_breves > 1 ? 's' : ''); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | ); |
| 130 | 130 | $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
| 131 | 131 | . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
| 132 | - . $scb . |
|
| 132 | + . $scb. |
|
| 133 | 133 | "</label></div></div>\n"; |
| 134 | 134 | } else { |
| 135 | 135 | $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | $form .= $confirm; |
| 139 | 139 | if ($actionable) { |
| 140 | 140 | if (strpos($form, '<select') !== false) { |
| 141 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 142 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + $form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 142 | + . '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 143 | 143 | . '</div>'; |
| 144 | 144 | } |
| 145 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 145 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form; |
|
| 146 | 146 | if ($action = charger_fonction("editer_$objet", 'action', true)) { |
| 147 | 147 | $form = generer_action_auteur( |
| 148 | 148 | "editer_$objet", |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | include_spip('inc/presentation'); |
| 170 | 170 | |
| 171 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(true); |
|
| 171 | + return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur(true); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | if ($statut == 'nouveau') { |
| 245 | 245 | if ($attente) { |
| 246 | 246 | $statut = $attente; |
| 247 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 247 | + $plus = ' ('._T('info_statut_auteur_a_confirmer').')'; |
|
| 248 | 248 | } else { |
| 249 | 249 | return _T('info_statut_auteur_a_confirmer'); |
| 250 | 250 | } |
@@ -257,16 +257,16 @@ discard block |
||
| 257 | 257 | '5poubelle' => _T('texte_statut_poubelle'), // bouh |
| 258 | 258 | ]; |
| 259 | 259 | if (isset($recom[$statut])) { |
| 260 | - return $recom[$statut] . $plus; |
|
| 260 | + return $recom[$statut].$plus; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // retrouver directement par le statut sinon |
| 264 | 264 | if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
| 265 | 265 | if (isset($recom[$t])) { |
| 266 | - return $recom[$t] . $plus; |
|
| 266 | + return $recom[$t].$plus; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - return _T($t) . $plus; |
|
| 269 | + return _T($t).$plus; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // si on a pas reussi a le traduire, retournons la chaine telle quelle |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
| 391 | 391 | $in = !count($GLOBALS['connect_id_rubrique']) |
| 392 | 392 | ? '' |
| 393 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 393 | + : (' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 394 | 394 | |
| 395 | 395 | // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
| 396 | 396 | if ($objet == 'rubrique') { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | return ''; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return propre('[->' . $virtuel . ']'); |
|
| 427 | + return propre('[->'.$virtuel.']'); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $args = param_low_sec($op, $args, $lang, 'rss'); |
| 453 | 453 | $url = generer_url_public('rss', $args); |
| 454 | 454 | |
| 455 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 455 | + return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | ); |
| 529 | 529 | |
| 530 | 530 | if ($alertes = array_filter($alertes)) { |
| 531 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 531 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 532 | 532 | join(' | ', $alertes) |
| 533 | 533 | . '</div></div>'; |
| 534 | 534 | } |
@@ -562,13 +562,13 @@ discard block |
||
| 562 | 562 | */ |
| 563 | 563 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 564 | 564 | $titre = attribut_html($titre); |
| 565 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 565 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>". |
|
| 566 | + http_img_pack('information-16.png', $titre).'</a>'; |
|
| 567 | 567 | |
| 568 | 568 | if (!$titre_lien) { |
| 569 | 569 | return $icone; |
| 570 | 570 | } else { |
| 571 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 571 | + return $icone."\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/filtres'); |
@@ -46,56 +46,56 @@ discard block |
||
| 46 | 46 | **/ |
| 47 | 47 | function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') { |
| 48 | 48 | |
| 49 | - if ($recur) { |
|
| 50 | - $recur = mini_hier($sel); |
|
| 51 | - } else { |
|
| 52 | - $sel = 0; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if ($aff_racine) { |
|
| 56 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | - $idom3 = $idom . '_selection'; |
|
| 58 | - |
|
| 59 | - $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | - |
|
| 61 | - $ondbClick = strtr( |
|
| 62 | - str_replace( |
|
| 63 | - "'", |
|
| 64 | - '’', |
|
| 65 | - str_replace( |
|
| 66 | - '"', |
|
| 67 | - '"', |
|
| 68 | - textebrut(_T('info_racine_site')) |
|
| 69 | - ) |
|
| 70 | - ), |
|
| 71 | - "\n\r", |
|
| 72 | - ' ' |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 76 | - $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 77 | - |
|
| 78 | - $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 79 | - . "<a href='#'" |
|
| 80 | - . 'onclick="' |
|
| 81 | - . $onClick |
|
| 82 | - . "\"\nondbclick=\"" |
|
| 83 | - . $ondbClick |
|
| 84 | - . $onClick |
|
| 85 | - . '">' |
|
| 86 | - . _T('info_racine_site') |
|
| 87 | - . '</a></div>'; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 91 | - |
|
| 92 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 93 | - $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 94 | - |
|
| 95 | - // url completee par la fonction JS onkeypress_rechercher |
|
| 96 | - $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 97 | - |
|
| 98 | - return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 49 | + if ($recur) { |
|
| 50 | + $recur = mini_hier($sel); |
|
| 51 | + } else { |
|
| 52 | + $sel = 0; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if ($aff_racine) { |
|
| 56 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | + $idom3 = $idom . '_selection'; |
|
| 58 | + |
|
| 59 | + $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | + |
|
| 61 | + $ondbClick = strtr( |
|
| 62 | + str_replace( |
|
| 63 | + "'", |
|
| 64 | + '’', |
|
| 65 | + str_replace( |
|
| 66 | + '"', |
|
| 67 | + '"', |
|
| 68 | + textebrut(_T('info_racine_site')) |
|
| 69 | + ) |
|
| 70 | + ), |
|
| 71 | + "\n\r", |
|
| 72 | + ' ' |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + $js_func = $do . '_selection_titre'; |
|
| 76 | + $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 77 | + |
|
| 78 | + $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 79 | + . "<a href='#'" |
|
| 80 | + . 'onclick="' |
|
| 81 | + . $onClick |
|
| 82 | + . "\"\nondbclick=\"" |
|
| 83 | + . $ondbClick |
|
| 84 | + . $onClick |
|
| 85 | + . '">' |
|
| 86 | + . _T('info_racine_site') |
|
| 87 | + . '</a></div>'; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 91 | + |
|
| 92 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 93 | + $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 94 | + |
|
| 95 | + // url completee par la fonction JS onkeypress_rechercher |
|
| 96 | + $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 97 | + |
|
| 98 | + return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -113,58 +113,58 @@ discard block |
||
| 113 | 113 | **/ |
| 114 | 114 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 115 | 115 | |
| 116 | - $idom1 = $idom . '_champ_recherche'; |
|
| 117 | - $idom2 = $idom . '_principal'; |
|
| 118 | - $idom3 = $idom . '_selection'; |
|
| 119 | - $idom4 = $idom . '_col_1'; |
|
| 120 | - $idom5 = 'img_' . $idom4; |
|
| 121 | - $idom6 = $idom . '_fonc'; |
|
| 122 | - |
|
| 123 | - return "<div id='$idom'>" |
|
| 124 | - . "<a id='$idom6' style='visibility: hidden;'" |
|
| 125 | - . ($url_init ? "\nhref='$url_init'" : '') |
|
| 126 | - . '></a>' |
|
| 127 | - . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 128 | - . http_img_pack( |
|
| 129 | - 'loader.svg', |
|
| 130 | - '', |
|
| 131 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 132 | - ) |
|
| 133 | - . '' |
|
| 134 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 135 | - // eliminer Return car il provoque la soumission (balise unique) |
|
| 136 | - // et eliminer Tab pour la navigation au clavier |
|
| 137 | - // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 138 | - // resultats retournes par la recherche |
|
| 139 | - . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 140 | - // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 141 | - . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 142 | - // la destination de la recherche |
|
| 143 | - . "'$idom4'" |
|
| 116 | + $idom1 = $idom . '_champ_recherche'; |
|
| 117 | + $idom2 = $idom . '_principal'; |
|
| 118 | + $idom3 = $idom . '_selection'; |
|
| 119 | + $idom4 = $idom . '_col_1'; |
|
| 120 | + $idom5 = 'img_' . $idom4; |
|
| 121 | + $idom6 = $idom . '_fonc'; |
|
| 122 | + |
|
| 123 | + return "<div id='$idom'>" |
|
| 124 | + . "<a id='$idom6' style='visibility: hidden;'" |
|
| 125 | + . ($url_init ? "\nhref='$url_init'" : '') |
|
| 126 | + . '></a>' |
|
| 127 | + . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 128 | + . http_img_pack( |
|
| 129 | + 'loader.svg', |
|
| 130 | + '', |
|
| 131 | + "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 132 | + ) |
|
| 133 | + . '' |
|
| 134 | + . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 135 | + // eliminer Return car il provoque la soumission (balise unique) |
|
| 136 | + // et eliminer Tab pour la navigation au clavier |
|
| 137 | + // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 138 | + // resultats retournes par la recherche |
|
| 139 | + . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 140 | + // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 141 | + . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 142 | + // la destination de la recherche |
|
| 143 | + . "'$idom4'" |
|
| 144 | 144 | # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id" |
| 145 | - . ",'" |
|
| 146 | - // l'url effectuant la recherche |
|
| 147 | - . $url |
|
| 148 | - . "'," |
|
| 149 | - // le noeud contenant un gif anime |
|
| 150 | - // . "'idom5'" |
|
| 151 | - . 'this.parentNode.previousSibling.firstChild' |
|
| 152 | - . ",'" |
|
| 153 | - // la valeur de l'attribut Name a remplir |
|
| 154 | - . $name |
|
| 155 | - . "','" |
|
| 156 | - // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 157 | - . $idom6 |
|
| 158 | - . "')\"" |
|
| 159 | - . ' />' |
|
| 160 | - . "\n</div>" |
|
| 161 | - . ($racine ? "<div>$racine</div>" : '') |
|
| 162 | - . "<div id='" |
|
| 163 | - . $idom2 |
|
| 164 | - . "'><div id='$idom4'" |
|
| 165 | - . " class=''>" |
|
| 166 | - . $liste |
|
| 167 | - . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 145 | + . ",'" |
|
| 146 | + // l'url effectuant la recherche |
|
| 147 | + . $url |
|
| 148 | + . "'," |
|
| 149 | + // le noeud contenant un gif anime |
|
| 150 | + // . "'idom5'" |
|
| 151 | + . 'this.parentNode.previousSibling.firstChild' |
|
| 152 | + . ",'" |
|
| 153 | + // la valeur de l'attribut Name a remplir |
|
| 154 | + . $name |
|
| 155 | + . "','" |
|
| 156 | + // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 157 | + . $idom6 |
|
| 158 | + . "')\"" |
|
| 159 | + . ' />' |
|
| 160 | + . "\n</div>" |
|
| 161 | + . ($racine ? "<div>$racine</div>" : '') |
|
| 162 | + . "<div id='" |
|
| 163 | + . $idom2 |
|
| 164 | + . "'><div id='$idom4'" |
|
| 165 | + . " class=''>" |
|
| 166 | + . $liste |
|
| 167 | + . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | **/ |
| 177 | 177 | function mini_hier($id_rubrique) { |
| 178 | 178 | |
| 179 | - $liste = $id_rubrique; |
|
| 180 | - $id_rubrique = intval($id_rubrique); |
|
| 181 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | - $liste = $id_rubrique . ",$liste"; |
|
| 183 | - } |
|
| 179 | + $liste = $id_rubrique; |
|
| 180 | + $id_rubrique = intval($id_rubrique); |
|
| 181 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | + $liste = $id_rubrique . ",$liste"; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return explode(',', "0,$liste"); |
|
| 185 | + return explode(',', "0,$liste"); |
|
| 186 | 186 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if ($aff_racine) { |
| 56 | 56 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 57 | - $idom3 = $idom . '_selection'; |
|
| 57 | + $idom3 = $idom.'_selection'; |
|
| 58 | 58 | |
| 59 | 59 | $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
| 60 | 60 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ' ' |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 75 | + $js_func = $do.'_selection_titre'; |
|
| 76 | 76 | $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
| 77 | 77 | |
| 78 | 78 | $aff_racine = "<div class='petit-item petite-racine item'>" |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | **/ |
| 114 | 114 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 115 | 115 | |
| 116 | - $idom1 = $idom . '_champ_recherche'; |
|
| 117 | - $idom2 = $idom . '_principal'; |
|
| 118 | - $idom3 = $idom . '_selection'; |
|
| 119 | - $idom4 = $idom . '_col_1'; |
|
| 120 | - $idom5 = 'img_' . $idom4; |
|
| 121 | - $idom6 = $idom . '_fonc'; |
|
| 116 | + $idom1 = $idom.'_champ_recherche'; |
|
| 117 | + $idom2 = $idom.'_principal'; |
|
| 118 | + $idom3 = $idom.'_selection'; |
|
| 119 | + $idom4 = $idom.'_col_1'; |
|
| 120 | + $idom5 = 'img_'.$idom4; |
|
| 121 | + $idom6 = $idom.'_fonc'; |
|
| 122 | 122 | |
| 123 | 123 | return "<div id='$idom'>" |
| 124 | 124 | . "<a id='$idom6' style='visibility: hidden;'" |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | . http_img_pack( |
| 129 | 129 | 'loader.svg', |
| 130 | 130 | '', |
| 131 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 131 | + "class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'" |
|
| 132 | 132 | ) |
| 133 | 133 | . '' |
| 134 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 134 | + . "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'" |
|
| 135 | 135 | // eliminer Return car il provoque la soumission (balise unique) |
| 136 | 136 | // et eliminer Tab pour la navigation au clavier |
| 137 | 137 | // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $liste = $id_rubrique; |
| 180 | 180 | $id_rubrique = intval($id_rubrique); |
| 181 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | - $liste = $id_rubrique . ",$liste"; |
|
| 181 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) { |
|
| 182 | + $liste = $id_rubrique.",$liste"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return explode(',', "0,$liste"); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Notifications |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function inc_notifications_dist($quoi, $id = 0, $options = []) { |
| 35 | 35 | |
| 36 | - // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | - // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | - pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 36 | + // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | + // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | + pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 39 | 39 | |
| 40 | - if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | - spip_log("$notification($quoi,$id" |
|
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 43 | - . ')', 'notifications'); |
|
| 44 | - $notification($quoi, $id, $options); |
|
| 45 | - } |
|
| 40 | + if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | + spip_log("$notification($quoi,$id" |
|
| 42 | + . ($options ? ',' . serialize($options) : '') |
|
| 43 | + . ')', 'notifications'); |
|
| 44 | + $notification($quoi, $id, $options); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | * @param array $exclure |
| 57 | 57 | */ |
| 58 | 58 | function notifications_nettoyer_emails(&$emails, $exclure = []) { |
| 59 | - // filtrer et unifier |
|
| 60 | - $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | - if ($exclure and count($exclure)) { |
|
| 62 | - // nettoyer les exclusions d'abord |
|
| 63 | - notifications_nettoyer_emails($exclure); |
|
| 64 | - // faire un diff |
|
| 65 | - $emails = array_diff($emails, $exclure); |
|
| 66 | - } |
|
| 59 | + // filtrer et unifier |
|
| 60 | + $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | + if ($exclure and count($exclure)) { |
|
| 62 | + // nettoyer les exclusions d'abord |
|
| 63 | + notifications_nettoyer_emails($exclure); |
|
| 64 | + // faire un diff |
|
| 65 | + $emails = array_diff($emails, $exclure); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -78,90 +78,90 @@ discard block |
||
| 78 | 78 | * @param string $headers |
| 79 | 79 | */ |
| 80 | 80 | function notifications_envoyer_mails($emails, $texte, $sujet = '', $from = '', $headers = '') { |
| 81 | - // rien a faire si pas de texte ! |
|
| 82 | - if (!strlen($texte)) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | - if (!is_array($emails)) { |
|
| 88 | - $emails = explode(',', $emails); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - notifications_nettoyer_emails($emails); |
|
| 92 | - |
|
| 93 | - // tester si le mail est deja en html |
|
| 94 | - if ( |
|
| 95 | - strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | - and $ttrim = trim($texte) |
|
| 97 | - and substr($ttrim, 0, 1) == '<' |
|
| 98 | - and substr($ttrim, -1, 1) == '>' |
|
| 99 | - and stripos($ttrim, '</html>') !== false |
|
| 100 | - ) { |
|
| 101 | - if (!strlen($sujet)) { |
|
| 102 | - // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | - if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | - $sujet = $m[1]; |
|
| 105 | - } else { |
|
| 106 | - // fallback, on prend le body si on le trouve |
|
| 107 | - if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | - $ttrim = $m[1]; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // et on extrait la premiere ligne de vrai texte... |
|
| 112 | - // nettoyer le html et les retours chariots |
|
| 113 | - $ttrim = textebrut($ttrim); |
|
| 114 | - $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | - $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | - // decouper |
|
| 117 | - $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | - // extraire la premiere ligne de texte brut |
|
| 119 | - $sujet = array_shift($ttrim); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // si besoin on ajoute le content-type dans les headers |
|
| 124 | - if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | - $headers .= "Content-Type: text/html\n"; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | - // du mail qui est donc du texte |
|
| 131 | - if (!strlen($sujet)) { |
|
| 132 | - // nettoyer un peu les retours chariots |
|
| 133 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | - $texte = str_replace("\r", "\n", $texte); |
|
| 135 | - // decouper |
|
| 136 | - $texte = explode("\n", trim($texte)); |
|
| 137 | - // extraire la premiere ligne |
|
| 138 | - $sujet = array_shift($texte); |
|
| 139 | - $texte = trim(implode("\n", $texte)); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | - foreach ($emails as $email) { |
|
| 144 | - // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | - // (url de suivi des notifications par exemple) |
|
| 146 | - $envoi = pipeline( |
|
| 147 | - 'notifications_envoyer_mails', |
|
| 148 | - [ |
|
| 149 | - 'email' => $email, |
|
| 150 | - 'sujet' => $sujet, |
|
| 151 | - 'texte' => $texte, |
|
| 152 | - 'from' => $from, |
|
| 153 | - 'headers' => $headers, |
|
| 154 | - ] |
|
| 155 | - ); |
|
| 156 | - $email = $envoi['email']; |
|
| 157 | - |
|
| 158 | - job_queue_add( |
|
| 159 | - 'envoyer_mail', |
|
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 161 | - [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | - 'inc/' |
|
| 163 | - ); |
|
| 164 | - } |
|
| 81 | + // rien a faire si pas de texte ! |
|
| 82 | + if (!strlen($texte)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | + if (!is_array($emails)) { |
|
| 88 | + $emails = explode(',', $emails); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + notifications_nettoyer_emails($emails); |
|
| 92 | + |
|
| 93 | + // tester si le mail est deja en html |
|
| 94 | + if ( |
|
| 95 | + strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | + and $ttrim = trim($texte) |
|
| 97 | + and substr($ttrim, 0, 1) == '<' |
|
| 98 | + and substr($ttrim, -1, 1) == '>' |
|
| 99 | + and stripos($ttrim, '</html>') !== false |
|
| 100 | + ) { |
|
| 101 | + if (!strlen($sujet)) { |
|
| 102 | + // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | + if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | + $sujet = $m[1]; |
|
| 105 | + } else { |
|
| 106 | + // fallback, on prend le body si on le trouve |
|
| 107 | + if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | + $ttrim = $m[1]; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // et on extrait la premiere ligne de vrai texte... |
|
| 112 | + // nettoyer le html et les retours chariots |
|
| 113 | + $ttrim = textebrut($ttrim); |
|
| 114 | + $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | + $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | + // decouper |
|
| 117 | + $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | + // extraire la premiere ligne de texte brut |
|
| 119 | + $sujet = array_shift($ttrim); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // si besoin on ajoute le content-type dans les headers |
|
| 124 | + if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | + $headers .= "Content-Type: text/html\n"; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | + // du mail qui est donc du texte |
|
| 131 | + if (!strlen($sujet)) { |
|
| 132 | + // nettoyer un peu les retours chariots |
|
| 133 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | + $texte = str_replace("\r", "\n", $texte); |
|
| 135 | + // decouper |
|
| 136 | + $texte = explode("\n", trim($texte)); |
|
| 137 | + // extraire la premiere ligne |
|
| 138 | + $sujet = array_shift($texte); |
|
| 139 | + $texte = trim(implode("\n", $texte)); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | + foreach ($emails as $email) { |
|
| 144 | + // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | + // (url de suivi des notifications par exemple) |
|
| 146 | + $envoi = pipeline( |
|
| 147 | + 'notifications_envoyer_mails', |
|
| 148 | + [ |
|
| 149 | + 'email' => $email, |
|
| 150 | + 'sujet' => $sujet, |
|
| 151 | + 'texte' => $texte, |
|
| 152 | + 'from' => $from, |
|
| 153 | + 'headers' => $headers, |
|
| 154 | + ] |
|
| 155 | + ); |
|
| 156 | + $email = $envoi['email']; |
|
| 157 | + |
|
| 158 | + job_queue_add( |
|
| 159 | + 'envoyer_mail', |
|
| 160 | + ">$email : " . $envoi['sujet'], |
|
| 161 | + [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | + 'inc/' |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | 179 | function email_notification_objet($id_objet, $type_objet, $modele) { |
| 180 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | - $id_type = id_table_objet($type_objet); |
|
| 180 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | + $id_type = id_table_objet($type_objet); |
|
| 182 | 182 | |
| 183 | - return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 183 | + return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | 197 | function email_notification_article($id_article, $modele) { |
| 198 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 198 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 199 | 199 | |
| 200 | - return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 200 | + return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 201 | 201 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | if ($notification = charger_fonction($quoi, 'notifications', true)) { |
| 41 | 41 | spip_log("$notification($quoi,$id" |
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 42 | + . ($options ? ','.serialize($options) : '') |
|
| 43 | 43 | . ')', 'notifications'); |
| 44 | 44 | $notification($quoi, $id, $options); |
| 45 | 45 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | job_queue_add( |
| 159 | 159 | 'envoyer_mail', |
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 160 | + ">$email : ".$envoi['sujet'], |
|
| 161 | 161 | [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
| 162 | 162 | 'inc/' |
| 163 | 163 | ); |