@@ -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 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Mail |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * - la normalisation de la dernière adresse donnée sinon |
| 32 | 32 | **/ |
| 33 | 33 | function inc_email_valide_dist($adresses) { |
| 34 | - // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | - if (!is_string($adresses)) { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | - if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | - spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | - |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - foreach (explode(',', $adresses) as $v) { |
|
| 47 | - // nettoyer certains formats |
|
| 48 | - // "Marie Toto <[email protected]>" |
|
| 49 | - $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | - // RFC 822 |
|
| 51 | - if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $adresse; |
|
| 34 | + // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | + if (!is_string($adresses)) { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | + if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | + spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | + |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + foreach (explode(',', $adresses) as $v) { |
|
| 47 | + // nettoyer certains formats |
|
| 48 | + // "Marie Toto <[email protected]>" |
|
| 49 | + $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | + // RFC 822 |
|
| 51 | + if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $adresse; |
|
| 57 | 57 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Logos |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | **/ |
| 38 | 38 | function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on', $compat_old_logos = true) { |
| 39 | 39 | |
| 40 | - $mode = preg_replace(',\W,', '', $mode); |
|
| 41 | - if ($mode) { |
|
| 42 | - // chercher dans la base |
|
| 43 | - $mode_document = 'logo' . $mode; |
|
| 44 | - $objet = objet_type($_id_objet); |
|
| 45 | - $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 46 | - if ($doc) { |
|
| 47 | - include_spip('inc/documents'); |
|
| 48 | - $d = get_spip_doc($doc['fichier']); |
|
| 49 | - return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 50 | - } |
|
| 40 | + $mode = preg_replace(',\W,', '', $mode); |
|
| 41 | + if ($mode) { |
|
| 42 | + // chercher dans la base |
|
| 43 | + $mode_document = 'logo' . $mode; |
|
| 44 | + $objet = objet_type($_id_objet); |
|
| 45 | + $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 46 | + if ($doc) { |
|
| 47 | + include_spip('inc/documents'); |
|
| 48 | + $d = get_spip_doc($doc['fichier']); |
|
| 49 | + return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - # deprecated TODO remove |
|
| 53 | - if ($compat_old_logos) { |
|
| 54 | - # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
|
| 55 | - $type = type_du_logo($_id_objet); |
|
| 56 | - $nom = $type . $mode . intval($id); |
|
| 52 | + # deprecated TODO remove |
|
| 53 | + if ($compat_old_logos) { |
|
| 54 | + # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
|
| 55 | + $type = type_du_logo($_id_objet); |
|
| 56 | + $nom = $type . $mode . intval($id); |
|
| 57 | 57 | |
| 58 | - foreach ($GLOBALS['formats_logos'] as $format) { |
|
| 59 | - if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 60 | - return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 58 | + foreach ($GLOBALS['formats_logos'] as $format) { |
|
| 59 | + if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 60 | + return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - # coherence de type pour servir comme filtre (formulaire_login) |
|
| 67 | - return []; |
|
| 66 | + # coherence de type pour servir comme filtre (formulaire_login) |
|
| 67 | + return []; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | * @deprecated 4.0 MAIS NE PAS SUPPRIMER CAR SERT POUR L'UPGRADE des logos et leur mise en base |
| 84 | 84 | **/ |
| 85 | 85 | function type_du_logo($_id_objet) { |
| 86 | - return isset($GLOBALS['table_logos'][$_id_objet]) |
|
| 87 | - ? $GLOBALS['table_logos'][$_id_objet] |
|
| 88 | - : objet_type(preg_replace(',^id_,', '', $_id_objet)); |
|
| 86 | + return isset($GLOBALS['table_logos'][$_id_objet]) |
|
| 87 | + ? $GLOBALS['table_logos'][$_id_objet] |
|
| 88 | + : objet_type(preg_replace(',^id_,', '', $_id_objet)); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Exceptions standards (historique) |
| 92 | 92 | $GLOBALS['table_logos'] = [ |
| 93 | - 'id_article' => 'art', |
|
| 94 | - 'id_auteur' => 'aut', |
|
| 95 | - 'id_rubrique' => 'rub', |
|
| 96 | - 'id_groupe' => 'groupe', |
|
| 93 | + 'id_article' => 'art', |
|
| 94 | + 'id_auteur' => 'aut', |
|
| 95 | + 'id_rubrique' => 'rub', |
|
| 96 | + 'id_groupe' => 'groupe', |
|
| 97 | 97 | ]; |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $mode = preg_replace(',\W,', '', $mode); |
| 41 | 41 | if ($mode) { |
| 42 | 42 | // chercher dans la base |
| 43 | - $mode_document = 'logo' . $mode; |
|
| 43 | + $mode_document = 'logo'.$mode; |
|
| 44 | 44 | $objet = objet_type($_id_objet); |
| 45 | - $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 45 | + $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode='.sql_quote($mode_document).' AND L.objet='.sql_quote($objet).' AND id_objet='.intval($id)); |
|
| 46 | 46 | if ($doc) { |
| 47 | 47 | include_spip('inc/documents'); |
| 48 | 48 | $d = get_spip_doc($doc['fichier']); |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | if ($compat_old_logos) { |
| 54 | 54 | # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
| 55 | 55 | $type = type_du_logo($_id_objet); |
| 56 | - $nom = $type . $mode . intval($id); |
|
| 56 | + $nom = $type.$mode.intval($id); |
|
| 57 | 57 | |
| 58 | 58 | foreach ($GLOBALS['formats_logos'] as $format) { |
| 59 | - if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 59 | + if (@file_exists($d = (_DIR_LOGOS.$nom.'.'.$format))) { |
|
| 60 | 60 | return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -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 | /** |
@@ -29,51 +29,51 @@ discard block |
||
| 29 | 29 | * @return string Erreur éventuelle |
| 30 | 30 | */ |
| 31 | 31 | function inc_completer_traduction_dist($objet, $id_objet, $id_trad) { |
| 32 | - // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 33 | - // cf API editer_liens |
|
| 34 | - include_spip('action/editer_liens'); |
|
| 35 | - objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 36 | - $_id_table = id_table_objet($objet); |
|
| 32 | + // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 33 | + // cf API editer_liens |
|
| 34 | + include_spip('action/editer_liens'); |
|
| 35 | + objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 36 | + $_id_table = id_table_objet($objet); |
|
| 37 | 37 | |
| 38 | - // recuperer le logo |
|
| 39 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | - include_spip('action/editer_logo'); |
|
| 41 | - foreach (['on', 'off'] as $etat) { |
|
| 42 | - $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 43 | - if ($logo and $file = reset($logo)) { |
|
| 44 | - logo_modifier($objet, $id_objet, $etat, $file); |
|
| 45 | - } |
|
| 46 | - } |
|
| 38 | + // recuperer le logo |
|
| 39 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | + include_spip('action/editer_logo'); |
|
| 41 | + foreach (['on', 'off'] as $etat) { |
|
| 42 | + $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 43 | + if ($logo and $file = reset($logo)) { |
|
| 44 | + logo_modifier($objet, $id_objet, $etat, $file); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // dupliquer certains champs |
|
| 49 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 50 | - $desc = $trouver_table(table_objet_sql($objet)); |
|
| 51 | - $champs = $set = []; |
|
| 48 | + // dupliquer certains champs |
|
| 49 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 50 | + $desc = $trouver_table(table_objet_sql($objet)); |
|
| 51 | + $champs = $set = []; |
|
| 52 | 52 | |
| 53 | - // un éventuel champ 'virtuel' (redirections) |
|
| 54 | - if (!empty($desc['field']['virtuel'])) { |
|
| 55 | - $champs[] = 'virtuel'; |
|
| 56 | - } |
|
| 53 | + // un éventuel champ 'virtuel' (redirections) |
|
| 54 | + if (!empty($desc['field']['virtuel'])) { |
|
| 55 | + $champs[] = 'virtuel'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 58 | + $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 59 | 59 | |
| 60 | - foreach ($champs as $c) { |
|
| 61 | - $set[$c] = $data[$c]; |
|
| 62 | - } |
|
| 60 | + foreach ($champs as $c) { |
|
| 61 | + $set[$c] = $data[$c]; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /* |
|
| 64 | + /* |
|
| 65 | 65 | * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'. |
| 66 | 66 | * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction. |
| 67 | 67 | */ |
| 68 | - $err = objet_modifier_champs( |
|
| 69 | - $objet, |
|
| 70 | - $id_objet, |
|
| 71 | - [ |
|
| 72 | - 'data' => $data, |
|
| 73 | - 'action' => 'completer_traduction', |
|
| 74 | - ], |
|
| 75 | - $set |
|
| 76 | - ); |
|
| 68 | + $err = objet_modifier_champs( |
|
| 69 | + $objet, |
|
| 70 | + $id_objet, |
|
| 71 | + [ |
|
| 72 | + 'data' => $data, |
|
| 73 | + 'action' => 'completer_traduction', |
|
| 74 | + ], |
|
| 75 | + $set |
|
| 76 | + ); |
|
| 77 | 77 | |
| 78 | - return $err; |
|
| 78 | + return $err; |
|
| 79 | 79 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | $champs[] = 'virtuel'; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 58 | + $data = sql_fetsel('*', $desc['table'], $_id_table.'='.intval($id_trad)); |
|
| 59 | 59 | |
| 60 | 60 | foreach ($champs as $c) { |
| 61 | 61 | $set[$c] = $data[$c]; |
@@ -11,107 +11,107 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) { |
| 18 | - static $test_repertoire = []; |
|
| 19 | - static $compteur = []; |
|
| 20 | - static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | - |
|
| 22 | - if (is_null($logname) or !is_string($logname)) { |
|
| 23 | - $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | - } |
|
| 25 | - if (!isset($compteur[$logname])) { |
|
| 26 | - $compteur[$logname] = 0; |
|
| 27 | - } |
|
| 28 | - if ( |
|
| 29 | - $logname != 'maj' |
|
| 30 | - and defined('_MAX_LOG') |
|
| 31 | - and ( |
|
| 32 | - $compteur[$logname]++ > _MAX_LOG |
|
| 33 | - or !$GLOBALS['nombre_de_logs'] |
|
| 34 | - or !$GLOBALS['taille_des_logs'] |
|
| 35 | - ) |
|
| 36 | - ) { |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $logfile = ($logdir === null ? _DIR_LOG : $logdir) |
|
| 41 | - . ($logname) |
|
| 42 | - . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 43 | - |
|
| 44 | - if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 45 | - $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 46 | - $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 47 | - $d, |
|
| 48 | - '', |
|
| 49 | - false, |
|
| 50 | - true |
|
| 51 | - ) : false)); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 55 | - if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
|
| 56 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $rotate = 0; |
|
| 60 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 61 | - |
|
| 62 | - // accepter spip_log( Array ) |
|
| 63 | - if (!is_string($message)) { |
|
| 64 | - $message = var_export($message, true); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 68 | - $debug = debug_backtrace(); |
|
| 69 | - $l = $debug[1]['line']; |
|
| 70 | - $fi = $debug[1]['file']; |
|
| 71 | - if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 72 | - $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 73 | - } |
|
| 74 | - $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 75 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 79 | - //distinguer les logs prives et publics dans les grep |
|
| 80 | - . $debugverb |
|
| 81 | - . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 82 | - . preg_replace("/\n*$/", "\n", $message); |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - if ( |
|
| 86 | - @is_readable($logfile) |
|
| 87 | - and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 88 | - ) { |
|
| 89 | - $rotate = $GLOBALS['nombre_de_logs']; |
|
| 90 | - $m .= "[-- rotate --]\n"; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $f = @fopen($logfile, 'ab'); |
|
| 94 | - if ($f) { |
|
| 95 | - fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 96 | - fclose($f); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if ( |
|
| 100 | - $rotate-- > 0 |
|
| 101 | - and function_exists('spip_unlink') |
|
| 102 | - ) { |
|
| 103 | - spip_unlink($logfile . '.' . $rotate); |
|
| 104 | - while ($rotate--) { |
|
| 105 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // Dupliquer les erreurs specifiques dans le log general |
|
| 110 | - if ( |
|
| 111 | - $logname !== _FILE_LOG |
|
| 112 | - and defined('_FILE_LOG') |
|
| 113 | - ) { |
|
| 114 | - inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 115 | - } |
|
| 116 | - $debugverb = ''; |
|
| 18 | + static $test_repertoire = []; |
|
| 19 | + static $compteur = []; |
|
| 20 | + static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | + |
|
| 22 | + if (is_null($logname) or !is_string($logname)) { |
|
| 23 | + $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | + } |
|
| 25 | + if (!isset($compteur[$logname])) { |
|
| 26 | + $compteur[$logname] = 0; |
|
| 27 | + } |
|
| 28 | + if ( |
|
| 29 | + $logname != 'maj' |
|
| 30 | + and defined('_MAX_LOG') |
|
| 31 | + and ( |
|
| 32 | + $compteur[$logname]++ > _MAX_LOG |
|
| 33 | + or !$GLOBALS['nombre_de_logs'] |
|
| 34 | + or !$GLOBALS['taille_des_logs'] |
|
| 35 | + ) |
|
| 36 | + ) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $logfile = ($logdir === null ? _DIR_LOG : $logdir) |
|
| 41 | + . ($logname) |
|
| 42 | + . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 43 | + |
|
| 44 | + if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 45 | + $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 46 | + $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 47 | + $d, |
|
| 48 | + '', |
|
| 49 | + false, |
|
| 50 | + true |
|
| 51 | + ) : false)); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 55 | + if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
|
| 56 | + $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $rotate = 0; |
|
| 60 | + $pid = '(pid ' . @getmypid() . ')'; |
|
| 61 | + |
|
| 62 | + // accepter spip_log( Array ) |
|
| 63 | + if (!is_string($message)) { |
|
| 64 | + $message = var_export($message, true); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 68 | + $debug = debug_backtrace(); |
|
| 69 | + $l = $debug[1]['line']; |
|
| 70 | + $fi = $debug[1]['file']; |
|
| 71 | + if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 72 | + $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 73 | + } |
|
| 74 | + $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 75 | + $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 79 | + //distinguer les logs prives et publics dans les grep |
|
| 80 | + . $debugverb |
|
| 81 | + . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 82 | + . preg_replace("/\n*$/", "\n", $message); |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + if ( |
|
| 86 | + @is_readable($logfile) |
|
| 87 | + and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 88 | + ) { |
|
| 89 | + $rotate = $GLOBALS['nombre_de_logs']; |
|
| 90 | + $m .= "[-- rotate --]\n"; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $f = @fopen($logfile, 'ab'); |
|
| 94 | + if ($f) { |
|
| 95 | + fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 96 | + fclose($f); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if ( |
|
| 100 | + $rotate-- > 0 |
|
| 101 | + and function_exists('spip_unlink') |
|
| 102 | + ) { |
|
| 103 | + spip_unlink($logfile . '.' . $rotate); |
|
| 104 | + while ($rotate--) { |
|
| 105 | + @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // Dupliquer les erreurs specifiques dans le log general |
|
| 110 | + if ( |
|
| 111 | + $logname !== _FILE_LOG |
|
| 112 | + and defined('_FILE_LOG') |
|
| 113 | + ) { |
|
| 114 | + inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 115 | + } |
|
| 116 | + $debugverb = ''; |
|
| 117 | 117 | } |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
| 55 | 55 | if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
| 56 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 56 | + $logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log'; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $rotate = 0; |
| 60 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 60 | + $pid = '(pid '.@getmypid().')'; |
|
| 61 | 61 | |
| 62 | 62 | // accepter spip_log( Array ) |
| 63 | 63 | if (!is_string($message)) { |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | $fi = substr($fi, strlen(_ROOT_RACINE)); |
| 73 | 73 | } |
| 74 | 74 | $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
| 75 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 75 | + $debugverb = "$fi:L$l:$fu".'():'; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 78 | + $m = date('Y-m-d H:i:s').' '.(isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '').' '.$pid.' ' |
|
| 79 | 79 | //distinguer les logs prives et publics dans les grep |
| 80 | 80 | . $debugverb |
| 81 | 81 | . (test_espace_prive() ? ':Pri:' : ':Pub:') |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | $rotate-- > 0 |
| 101 | 101 | and function_exists('spip_unlink') |
| 102 | 102 | ) { |
| 103 | - spip_unlink($logfile . '.' . $rotate); |
|
| 103 | + spip_unlink($logfile.'.'.$rotate); |
|
| 104 | 104 | while ($rotate--) { |
| 105 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 105 | + @rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1)); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |