@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Génère les variables CSS relatif à la typo et langue pour l'espace privé |
| 29 | 29 | * |
| 30 | - * @param Pile $pile Pile |
|
| 30 | + * @param Pile $Pile Pile |
|
| 31 | 31 | */ |
| 32 | 32 | function spip_generer_variables_css_typo(array $Pile) : \Spip_Css_Vars_Collection { |
| 33 | 33 | $vars = new \Spip_Css_Vars_Collection(); |
@@ -5,23 +5,23 @@ discard block |
||
| 5 | 5 | * @internal |
| 6 | 6 | */ |
| 7 | 7 | class Spip_Css_Vars_Collection { |
| 8 | - private $vars = []; |
|
| 9 | - |
|
| 10 | - public function add(string $var, string $value) { |
|
| 11 | - $this->vars[$var] = $value; |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - public function getString() : string { |
|
| 15 | - $string = ''; |
|
| 16 | - foreach ($this->vars as $key => $value) { |
|
| 17 | - $string .= "$key: $value;\n"; |
|
| 18 | - } |
|
| 19 | - return $string; |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function __toString() : string { |
|
| 23 | - return $this->getString(); |
|
| 24 | - } |
|
| 8 | + private $vars = []; |
|
| 9 | + |
|
| 10 | + public function add(string $var, string $value) { |
|
| 11 | + $this->vars[$var] = $value; |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + public function getString() : string { |
|
| 15 | + $string = ''; |
|
| 16 | + foreach ($this->vars as $key => $value) { |
|
| 17 | + $string .= "$key: $value;\n"; |
|
| 18 | + } |
|
| 19 | + return $string; |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function __toString() : string { |
|
| 23 | + return $this->getString(); |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -30,49 +30,49 @@ discard block |
||
| 30 | 30 | * @param Pile $pile Pile |
| 31 | 31 | */ |
| 32 | 32 | function spip_generer_variables_css_typo(array $Pile) : \Spip_Css_Vars_Collection { |
| 33 | - $vars = new \Spip_Css_Vars_Collection(); |
|
| 34 | - |
|
| 35 | - // Direction |
|
| 36 | - $vars->add('--spip-dir', $Pile[0]['dir']); |
|
| 37 | - $vars->add('--spip-left', $Pile[0]['left']); |
|
| 38 | - $vars->add('--spip-right', $Pile[0]['right']); |
|
| 39 | - |
|
| 40 | - // Typographie |
|
| 41 | - $vars->add('--spip-font-size', $Pile[0]['font-size']); |
|
| 42 | - $vars->add('--spip-line-height', $Pile[0]['line-height']); |
|
| 43 | - $vars->add('--spip-text-indent', $Pile[0]['text-indent']); |
|
| 44 | - $vars->add('--spip-font-family', $Pile[0]['font-family']); |
|
| 45 | - |
|
| 46 | - // Couleurs hors thème |
|
| 47 | - $vars->add('--spip-background-color', $Pile[0]['background-color']); |
|
| 48 | - $vars->add('--spip-color', $Pile[0]['color']); |
|
| 49 | - |
|
| 50 | - // Espacements pour le rythme vertical et les gouttières |
|
| 51 | - // Basés sur la hauteur d'une ligne de texte |
|
| 52 | - $vars->add('--spip-spacing-y', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4) . 'em'); |
|
| 53 | - $vars->add('--spip-spacing-x', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4) . 'em'); |
|
| 54 | - $vars->add('--spip-margin-bottom', $Pile[0]['margin-bottom']); // À éviter |
|
| 55 | - |
|
| 56 | - // Bordures |
|
| 57 | - $vars->add('--spip-border-radius-mini', '0.2em'); |
|
| 58 | - $vars->add('--spip-border-radius', '0.33em'); |
|
| 59 | - $vars->add('--spip-border-radius-large', '0.66em'); |
|
| 60 | - |
|
| 61 | - // Ombres portées |
|
| 62 | - $vars->add |
|
| 63 | - ('--spip-box-shadow', |
|
| 64 | - '0 0.05em 0.15em hsla(0, 0%, 0%, 0.33),' . |
|
| 65 | - '0 0.1em 0.25em hsla(0, 0%, 0%, 0.05),' . |
|
| 66 | - '0 0.1em 0.5em hsla(0, 0%, 0%, 0.05)' |
|
| 67 | - ); |
|
| 68 | - $vars->add |
|
| 69 | - ('--spip-box-shadow-hover', |
|
| 70 | - '0 0.05em 0.15em hsla(0, 0%, 0%, 0.1),' . |
|
| 71 | - '0 0.2em 0.5em hsla(0, 0%, 0%, 0.1),' . |
|
| 72 | - '0 0.2em 1em hsla(0, 0%, 0%, 0.075)' |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - return $vars; |
|
| 33 | + $vars = new \Spip_Css_Vars_Collection(); |
|
| 34 | + |
|
| 35 | + // Direction |
|
| 36 | + $vars->add('--spip-dir', $Pile[0]['dir']); |
|
| 37 | + $vars->add('--spip-left', $Pile[0]['left']); |
|
| 38 | + $vars->add('--spip-right', $Pile[0]['right']); |
|
| 39 | + |
|
| 40 | + // Typographie |
|
| 41 | + $vars->add('--spip-font-size', $Pile[0]['font-size']); |
|
| 42 | + $vars->add('--spip-line-height', $Pile[0]['line-height']); |
|
| 43 | + $vars->add('--spip-text-indent', $Pile[0]['text-indent']); |
|
| 44 | + $vars->add('--spip-font-family', $Pile[0]['font-family']); |
|
| 45 | + |
|
| 46 | + // Couleurs hors thème |
|
| 47 | + $vars->add('--spip-background-color', $Pile[0]['background-color']); |
|
| 48 | + $vars->add('--spip-color', $Pile[0]['color']); |
|
| 49 | + |
|
| 50 | + // Espacements pour le rythme vertical et les gouttières |
|
| 51 | + // Basés sur la hauteur d'une ligne de texte |
|
| 52 | + $vars->add('--spip-spacing-y', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4) . 'em'); |
|
| 53 | + $vars->add('--spip-spacing-x', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4) . 'em'); |
|
| 54 | + $vars->add('--spip-margin-bottom', $Pile[0]['margin-bottom']); // À éviter |
|
| 55 | + |
|
| 56 | + // Bordures |
|
| 57 | + $vars->add('--spip-border-radius-mini', '0.2em'); |
|
| 58 | + $vars->add('--spip-border-radius', '0.33em'); |
|
| 59 | + $vars->add('--spip-border-radius-large', '0.66em'); |
|
| 60 | + |
|
| 61 | + // Ombres portées |
|
| 62 | + $vars->add |
|
| 63 | + ('--spip-box-shadow', |
|
| 64 | + '0 0.05em 0.15em hsla(0, 0%, 0%, 0.33),' . |
|
| 65 | + '0 0.1em 0.25em hsla(0, 0%, 0%, 0.05),' . |
|
| 66 | + '0 0.1em 0.5em hsla(0, 0%, 0%, 0.05)' |
|
| 67 | + ); |
|
| 68 | + $vars->add |
|
| 69 | + ('--spip-box-shadow-hover', |
|
| 70 | + '0 0.05em 0.15em hsla(0, 0%, 0%, 0.1),' . |
|
| 71 | + '0 0.2em 0.5em hsla(0, 0%, 0%, 0.1),' . |
|
| 72 | + '0 0.2em 1em hsla(0, 0%, 0%, 0.075)' |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + return $vars; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,101 +81,101 @@ discard block |
||
| 81 | 81 | * @param string $couleur Couleur hex |
| 82 | 82 | */ |
| 83 | 83 | function spip_generer_variables_css_couleurs_theme(string $couleur) : \Spip_Css_Vars_Collection { |
| 84 | - $vars = new \Spip_Css_Vars_Collection(); |
|
| 85 | - |
|
| 86 | - #$vars->add('--spip-color-theme--hsl', couleur_hex_to_hsl($couleur, 'h, s, l')); // redéfini ensuite |
|
| 87 | - $vars->add('--spip-color-theme--h', couleur_hex_to_hsl($couleur, 'h')); |
|
| 88 | - $vars->add('--spip-color-theme--s', couleur_hex_to_hsl($couleur, 's')); |
|
| 89 | - $vars->add('--spip-color-theme--l', couleur_hex_to_hsl($couleur, 'l')); |
|
| 90 | - |
|
| 91 | - // un joli dégradé coloré de presque blanc à presque noir… |
|
| 92 | - $vars->add('--spip-color-theme--100', couleur_hex_to_hsl(couleur_eclaircir($couleur, .99), 'h, s, l')); |
|
| 93 | - $vars->add('--spip-color-theme--98', couleur_hex_to_hsl(couleur_eclaircir($couleur, .95), 'h, s, l')); |
|
| 94 | - $vars->add('--spip-color-theme--95', couleur_hex_to_hsl(couleur_eclaircir($couleur, .90), 'h, s, l')); |
|
| 95 | - $vars->add('--spip-color-theme--90', couleur_hex_to_hsl(couleur_eclaircir($couleur, .75), 'h, s, l')); |
|
| 96 | - $vars->add('--spip-color-theme--80', couleur_hex_to_hsl(couleur_eclaircir($couleur, .50), 'h, s, l')); |
|
| 97 | - $vars->add('--spip-color-theme--70', couleur_hex_to_hsl(couleur_eclaircir($couleur, .25), 'h, s, l')); |
|
| 98 | - $vars->add('--spip-color-theme--60', couleur_hex_to_hsl($couleur, 'h, s, l')); |
|
| 99 | - $vars->add('--spip-color-theme--50', couleur_hex_to_hsl(couleur_foncer($couleur, .125), 'h, s, l')); |
|
| 100 | - $vars->add('--spip-color-theme--40', couleur_hex_to_hsl(couleur_foncer($couleur, .25), 'h, s, l')); |
|
| 101 | - $vars->add('--spip-color-theme--30', couleur_hex_to_hsl(couleur_foncer($couleur, .375), 'h, s, l')); |
|
| 102 | - $vars->add('--spip-color-theme--20', couleur_hex_to_hsl(couleur_foncer($couleur, .50), 'h, s, l')); |
|
| 103 | - $vars->add('--spip-color-theme--10', couleur_hex_to_hsl(couleur_foncer($couleur, .75), 'h, s, l')); |
|
| 104 | - $vars->add('--spip-color-theme--00', couleur_hex_to_hsl(couleur_foncer($couleur, .98), 'h, s, l')); |
|
| 105 | - |
|
| 106 | - return $vars; |
|
| 84 | + $vars = new \Spip_Css_Vars_Collection(); |
|
| 85 | + |
|
| 86 | + #$vars->add('--spip-color-theme--hsl', couleur_hex_to_hsl($couleur, 'h, s, l')); // redéfini ensuite |
|
| 87 | + $vars->add('--spip-color-theme--h', couleur_hex_to_hsl($couleur, 'h')); |
|
| 88 | + $vars->add('--spip-color-theme--s', couleur_hex_to_hsl($couleur, 's')); |
|
| 89 | + $vars->add('--spip-color-theme--l', couleur_hex_to_hsl($couleur, 'l')); |
|
| 90 | + |
|
| 91 | + // un joli dégradé coloré de presque blanc à presque noir… |
|
| 92 | + $vars->add('--spip-color-theme--100', couleur_hex_to_hsl(couleur_eclaircir($couleur, .99), 'h, s, l')); |
|
| 93 | + $vars->add('--spip-color-theme--98', couleur_hex_to_hsl(couleur_eclaircir($couleur, .95), 'h, s, l')); |
|
| 94 | + $vars->add('--spip-color-theme--95', couleur_hex_to_hsl(couleur_eclaircir($couleur, .90), 'h, s, l')); |
|
| 95 | + $vars->add('--spip-color-theme--90', couleur_hex_to_hsl(couleur_eclaircir($couleur, .75), 'h, s, l')); |
|
| 96 | + $vars->add('--spip-color-theme--80', couleur_hex_to_hsl(couleur_eclaircir($couleur, .50), 'h, s, l')); |
|
| 97 | + $vars->add('--spip-color-theme--70', couleur_hex_to_hsl(couleur_eclaircir($couleur, .25), 'h, s, l')); |
|
| 98 | + $vars->add('--spip-color-theme--60', couleur_hex_to_hsl($couleur, 'h, s, l')); |
|
| 99 | + $vars->add('--spip-color-theme--50', couleur_hex_to_hsl(couleur_foncer($couleur, .125), 'h, s, l')); |
|
| 100 | + $vars->add('--spip-color-theme--40', couleur_hex_to_hsl(couleur_foncer($couleur, .25), 'h, s, l')); |
|
| 101 | + $vars->add('--spip-color-theme--30', couleur_hex_to_hsl(couleur_foncer($couleur, .375), 'h, s, l')); |
|
| 102 | + $vars->add('--spip-color-theme--20', couleur_hex_to_hsl(couleur_foncer($couleur, .50), 'h, s, l')); |
|
| 103 | + $vars->add('--spip-color-theme--10', couleur_hex_to_hsl(couleur_foncer($couleur, .75), 'h, s, l')); |
|
| 104 | + $vars->add('--spip-color-theme--00', couleur_hex_to_hsl(couleur_foncer($couleur, .98), 'h, s, l')); |
|
| 105 | + |
|
| 106 | + return $vars; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Génère les variables CSS de couleurs, dont celles dépendantes des couleurs du thème actif. |
| 111 | 111 | */ |
| 112 | 112 | function spip_generer_variables_css_couleurs() : \Spip_Css_Vars_Collection { |
| 113 | - $vars = new \Spip_Css_Vars_Collection(); |
|
| 114 | - |
|
| 115 | - // nos déclinaisons de couleur (basées sur le dégradé précedent, où 60 est là couleur du thème) |
|
| 116 | - $vars->add('--spip-color-theme-white--hsl', 'var(--spip-color-theme--100)'); |
|
| 117 | - $vars->add('--spip-color-theme-lightest--hsl', 'var(--spip-color-theme--95)'); |
|
| 118 | - $vars->add('--spip-color-theme-lighter--hsl', 'var(--spip-color-theme--90)'); |
|
| 119 | - $vars->add('--spip-color-theme-light--hsl', 'var(--spip-color-theme--80)'); |
|
| 120 | - $vars->add('--spip-color-theme--hsl', 'var(--spip-color-theme--60)'); |
|
| 121 | - $vars->add('--spip-color-theme-dark--hsl', 'var(--spip-color-theme--40)'); |
|
| 122 | - $vars->add('--spip-color-theme-darker--hsl', 'var(--spip-color-theme--20)'); |
|
| 123 | - $vars->add('--spip-color-theme-darkest--hsl', 'var(--spip-color-theme--10)'); |
|
| 124 | - $vars->add('--spip-color-theme-black--hsl', 'var(--spip-color-theme--00)'); |
|
| 125 | - |
|
| 126 | - $vars->add('--spip-color-theme-white', 'hsl(var(--spip-color-theme-white--hsl))'); |
|
| 127 | - $vars->add('--spip-color-theme-lightest', 'hsl(var(--spip-color-theme-lightest--hsl))'); |
|
| 128 | - $vars->add('--spip-color-theme-lighter', 'hsl(var(--spip-color-theme-lighter--hsl))'); |
|
| 129 | - $vars->add('--spip-color-theme-light', 'hsl(var(--spip-color-theme-light--hsl))'); |
|
| 130 | - $vars->add('--spip-color-theme', 'hsl(var(--spip-color-theme--hsl))'); |
|
| 131 | - $vars->add('--spip-color-theme-dark', 'hsl(var(--spip-color-theme-dark--hsl))'); |
|
| 132 | - $vars->add('--spip-color-theme-darker', 'hsl(var(--spip-color-theme-darker--hsl))'); |
|
| 133 | - $vars->add('--spip-color-theme-darkest', 'hsl(var(--spip-color-theme-darkest--hsl))'); |
|
| 134 | - $vars->add('--spip-color-theme-black', 'hsl(var(--spip-color-theme-black--hsl))'); |
|
| 135 | - |
|
| 136 | - // déclinaisons de gris (luminosité calquée sur le dégradé de couleur) |
|
| 137 | - $vars->add('--spip-color-white--hsl', '0, 0%, 100%'); |
|
| 138 | - $vars->add('--spip-color-gray-lightest--hsl', '0, 0%, 96%'); |
|
| 139 | - $vars->add('--spip-color-gray-lighter--hsl', '0, 0%, 90%'); |
|
| 140 | - $vars->add('--spip-color-gray-light--hsl', '0, 0%, 80%'); |
|
| 141 | - $vars->add('--spip-color-gray--hsl', '0, 0%, 60%'); |
|
| 142 | - $vars->add('--spip-color-gray-dark--hsl', '0, 0%, 40%'); |
|
| 143 | - $vars->add('--spip-color-gray-darker--hsl', '0, 0%, 20%'); |
|
| 144 | - $vars->add('--spip-color-gray-darkest--hsl', '0, 0%, 10%'); |
|
| 145 | - $vars->add('--spip-color-black--hsl', '0, 0%, 0%'); |
|
| 146 | - |
|
| 147 | - $vars->add('--spip-color-white', 'hsl(var(--spip-color-white--hsl))'); |
|
| 148 | - $vars->add('--spip-color-gray-lightest', 'hsl(var(--spip-color-gray-lightest--hsl))'); |
|
| 149 | - $vars->add('--spip-color-gray-lighter', 'hsl(var(--spip-color-gray-lighter--hsl))'); |
|
| 150 | - $vars->add('--spip-color-gray-light', 'hsl(var(--spip-color-gray-light--hsl))'); |
|
| 151 | - $vars->add('--spip-color-gray', 'hsl(var(--spip-color-gray--hsl))'); |
|
| 152 | - $vars->add('--spip-color-gray-dark', 'hsl(var(--spip-color-gray-dark--hsl))'); |
|
| 153 | - $vars->add('--spip-color-gray-darker', 'hsl(var(--spip-color-gray-darker--hsl))'); |
|
| 154 | - $vars->add('--spip-color-gray-darkest', 'hsl(var(--spip-color-gray-darkest--hsl))'); |
|
| 155 | - $vars->add('--spip-color-black', 'hsl(var(--spip-color-black--hsl))'); |
|
| 156 | - |
|
| 157 | - // Différents états : erreur, etc. |
|
| 158 | - $vars->add('--spip-color-success--hsl', '72, 66%, 62%'); |
|
| 159 | - $vars->add('--spip-color-success--h', '72'); |
|
| 160 | - $vars->add('--spip-color-success--s', '66%'); |
|
| 161 | - $vars->add('--spip-color-success--l', '62%'); |
|
| 162 | - $vars->add('--spip-color-error--hsl', '356, 70%, 57%'); |
|
| 163 | - $vars->add('--spip-color-error--h', '356'); |
|
| 164 | - $vars->add('--spip-color-error--s', '70%'); |
|
| 165 | - $vars->add('--spip-color-error--l', '57%'); |
|
| 166 | - $vars->add('--spip-color-notice--hsl', '47, 100%, 62%'); |
|
| 167 | - $vars->add('--spip-color-notice--h', '47'); |
|
| 168 | - $vars->add('--spip-color-notice--s', '100%'); |
|
| 169 | - $vars->add('--spip-color-notice--l', '62%'); |
|
| 170 | - $vars->add('--spip-color-info--hsl', '197, 56%, 27%'); |
|
| 171 | - $vars->add('--spip-color-info--h', '197'); |
|
| 172 | - $vars->add('--spip-color-info--s', '56%'); |
|
| 173 | - $vars->add('--spip-color-info--l', '27%'); |
|
| 174 | - |
|
| 175 | - $vars->add('--spip-color-success', 'hsl(var(--spip-color-success--hsl))'); |
|
| 176 | - $vars->add('--spip-color-error', 'hsl(var(--spip-color-error--hsl))'); |
|
| 177 | - $vars->add('--spip-color-notice', 'hsl(var(--spip-color-notice--hsl))'); |
|
| 178 | - $vars->add('--spip-color-info', 'hsl(var(--spip-color-info--hsl))'); |
|
| 179 | - |
|
| 180 | - return $vars; |
|
| 113 | + $vars = new \Spip_Css_Vars_Collection(); |
|
| 114 | + |
|
| 115 | + // nos déclinaisons de couleur (basées sur le dégradé précedent, où 60 est là couleur du thème) |
|
| 116 | + $vars->add('--spip-color-theme-white--hsl', 'var(--spip-color-theme--100)'); |
|
| 117 | + $vars->add('--spip-color-theme-lightest--hsl', 'var(--spip-color-theme--95)'); |
|
| 118 | + $vars->add('--spip-color-theme-lighter--hsl', 'var(--spip-color-theme--90)'); |
|
| 119 | + $vars->add('--spip-color-theme-light--hsl', 'var(--spip-color-theme--80)'); |
|
| 120 | + $vars->add('--spip-color-theme--hsl', 'var(--spip-color-theme--60)'); |
|
| 121 | + $vars->add('--spip-color-theme-dark--hsl', 'var(--spip-color-theme--40)'); |
|
| 122 | + $vars->add('--spip-color-theme-darker--hsl', 'var(--spip-color-theme--20)'); |
|
| 123 | + $vars->add('--spip-color-theme-darkest--hsl', 'var(--spip-color-theme--10)'); |
|
| 124 | + $vars->add('--spip-color-theme-black--hsl', 'var(--spip-color-theme--00)'); |
|
| 125 | + |
|
| 126 | + $vars->add('--spip-color-theme-white', 'hsl(var(--spip-color-theme-white--hsl))'); |
|
| 127 | + $vars->add('--spip-color-theme-lightest', 'hsl(var(--spip-color-theme-lightest--hsl))'); |
|
| 128 | + $vars->add('--spip-color-theme-lighter', 'hsl(var(--spip-color-theme-lighter--hsl))'); |
|
| 129 | + $vars->add('--spip-color-theme-light', 'hsl(var(--spip-color-theme-light--hsl))'); |
|
| 130 | + $vars->add('--spip-color-theme', 'hsl(var(--spip-color-theme--hsl))'); |
|
| 131 | + $vars->add('--spip-color-theme-dark', 'hsl(var(--spip-color-theme-dark--hsl))'); |
|
| 132 | + $vars->add('--spip-color-theme-darker', 'hsl(var(--spip-color-theme-darker--hsl))'); |
|
| 133 | + $vars->add('--spip-color-theme-darkest', 'hsl(var(--spip-color-theme-darkest--hsl))'); |
|
| 134 | + $vars->add('--spip-color-theme-black', 'hsl(var(--spip-color-theme-black--hsl))'); |
|
| 135 | + |
|
| 136 | + // déclinaisons de gris (luminosité calquée sur le dégradé de couleur) |
|
| 137 | + $vars->add('--spip-color-white--hsl', '0, 0%, 100%'); |
|
| 138 | + $vars->add('--spip-color-gray-lightest--hsl', '0, 0%, 96%'); |
|
| 139 | + $vars->add('--spip-color-gray-lighter--hsl', '0, 0%, 90%'); |
|
| 140 | + $vars->add('--spip-color-gray-light--hsl', '0, 0%, 80%'); |
|
| 141 | + $vars->add('--spip-color-gray--hsl', '0, 0%, 60%'); |
|
| 142 | + $vars->add('--spip-color-gray-dark--hsl', '0, 0%, 40%'); |
|
| 143 | + $vars->add('--spip-color-gray-darker--hsl', '0, 0%, 20%'); |
|
| 144 | + $vars->add('--spip-color-gray-darkest--hsl', '0, 0%, 10%'); |
|
| 145 | + $vars->add('--spip-color-black--hsl', '0, 0%, 0%'); |
|
| 146 | + |
|
| 147 | + $vars->add('--spip-color-white', 'hsl(var(--spip-color-white--hsl))'); |
|
| 148 | + $vars->add('--spip-color-gray-lightest', 'hsl(var(--spip-color-gray-lightest--hsl))'); |
|
| 149 | + $vars->add('--spip-color-gray-lighter', 'hsl(var(--spip-color-gray-lighter--hsl))'); |
|
| 150 | + $vars->add('--spip-color-gray-light', 'hsl(var(--spip-color-gray-light--hsl))'); |
|
| 151 | + $vars->add('--spip-color-gray', 'hsl(var(--spip-color-gray--hsl))'); |
|
| 152 | + $vars->add('--spip-color-gray-dark', 'hsl(var(--spip-color-gray-dark--hsl))'); |
|
| 153 | + $vars->add('--spip-color-gray-darker', 'hsl(var(--spip-color-gray-darker--hsl))'); |
|
| 154 | + $vars->add('--spip-color-gray-darkest', 'hsl(var(--spip-color-gray-darkest--hsl))'); |
|
| 155 | + $vars->add('--spip-color-black', 'hsl(var(--spip-color-black--hsl))'); |
|
| 156 | + |
|
| 157 | + // Différents états : erreur, etc. |
|
| 158 | + $vars->add('--spip-color-success--hsl', '72, 66%, 62%'); |
|
| 159 | + $vars->add('--spip-color-success--h', '72'); |
|
| 160 | + $vars->add('--spip-color-success--s', '66%'); |
|
| 161 | + $vars->add('--spip-color-success--l', '62%'); |
|
| 162 | + $vars->add('--spip-color-error--hsl', '356, 70%, 57%'); |
|
| 163 | + $vars->add('--spip-color-error--h', '356'); |
|
| 164 | + $vars->add('--spip-color-error--s', '70%'); |
|
| 165 | + $vars->add('--spip-color-error--l', '57%'); |
|
| 166 | + $vars->add('--spip-color-notice--hsl', '47, 100%, 62%'); |
|
| 167 | + $vars->add('--spip-color-notice--h', '47'); |
|
| 168 | + $vars->add('--spip-color-notice--s', '100%'); |
|
| 169 | + $vars->add('--spip-color-notice--l', '62%'); |
|
| 170 | + $vars->add('--spip-color-info--hsl', '197, 56%, 27%'); |
|
| 171 | + $vars->add('--spip-color-info--h', '197'); |
|
| 172 | + $vars->add('--spip-color-info--s', '56%'); |
|
| 173 | + $vars->add('--spip-color-info--l', '27%'); |
|
| 174 | + |
|
| 175 | + $vars->add('--spip-color-success', 'hsl(var(--spip-color-success--hsl))'); |
|
| 176 | + $vars->add('--spip-color-error', 'hsl(var(--spip-color-error--hsl))'); |
|
| 177 | + $vars->add('--spip-color-notice', 'hsl(var(--spip-color-notice--hsl))'); |
|
| 178 | + $vars->add('--spip-color-info', 'hsl(var(--spip-color-info--hsl))'); |
|
| 179 | + |
|
| 180 | + return $vars; |
|
| 181 | 181 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // Typographie |
| 41 | 41 | $vars->add('--spip-font-size', $Pile[0]['font-size']); |
| 42 | - $vars->add('--spip-line-height', $Pile[0]['line-height']); |
|
| 42 | + $vars->add('--spip-line-height', $Pile[0]['line-height']); |
|
| 43 | 43 | $vars->add('--spip-text-indent', $Pile[0]['text-indent']); |
| 44 | 44 | $vars->add('--spip-font-family', $Pile[0]['font-family']); |
| 45 | 45 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Espacements pour le rythme vertical et les gouttières |
| 51 | 51 | // Basés sur la hauteur d'une ligne de texte |
| 52 | - $vars->add('--spip-spacing-y', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4) . 'em'); |
|
| 53 | - $vars->add('--spip-spacing-x', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4) . 'em'); |
|
| 52 | + $vars->add('--spip-spacing-y', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4).'em'); |
|
| 53 | + $vars->add('--spip-spacing-x', round(strmult($Pile[0]['font-size'], $Pile[0]['line-height']), 4).'em'); |
|
| 54 | 54 | $vars->add('--spip-margin-bottom', $Pile[0]['margin-bottom']); // À éviter |
| 55 | 55 | |
| 56 | 56 | // Bordures |
@@ -59,16 +59,14 @@ discard block |
||
| 59 | 59 | $vars->add('--spip-border-radius-large', '0.66em'); |
| 60 | 60 | |
| 61 | 61 | // Ombres portées |
| 62 | - $vars->add |
|
| 63 | - ('--spip-box-shadow', |
|
| 64 | - '0 0.05em 0.15em hsla(0, 0%, 0%, 0.33),' . |
|
| 65 | - '0 0.1em 0.25em hsla(0, 0%, 0%, 0.05),' . |
|
| 62 | + $vars->add('--spip-box-shadow', |
|
| 63 | + '0 0.05em 0.15em hsla(0, 0%, 0%, 0.33),'. |
|
| 64 | + '0 0.1em 0.25em hsla(0, 0%, 0%, 0.05),'. |
|
| 66 | 65 | '0 0.1em 0.5em hsla(0, 0%, 0%, 0.05)' |
| 67 | 66 | ); |
| 68 | - $vars->add |
|
| 69 | - ('--spip-box-shadow-hover', |
|
| 70 | - '0 0.05em 0.15em hsla(0, 0%, 0%, 0.1),' . |
|
| 71 | - '0 0.2em 0.5em hsla(0, 0%, 0%, 0.1),' . |
|
| 67 | + $vars->add('--spip-box-shadow-hover', |
|
| 68 | + '0 0.05em 0.15em hsla(0, 0%, 0%, 0.1),'. |
|
| 69 | + '0 0.2em 0.5em hsla(0, 0%, 0%, 0.1),'. |
|
| 72 | 70 | '0 0.2em 1em hsla(0, 0%, 0%, 0.075)' |
| 73 | 71 | ); |
| 74 | 72 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | **/ |
| 27 | 27 | |
| 28 | 28 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 29 | - return; |
|
| 29 | + return; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | * Code PHP si cet argument est présent, sinon null |
| 49 | 49 | **/ |
| 50 | 50 | function interprete_argument_balise($n, $p) { |
| 51 | - if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) { |
|
| 52 | - return calculer_liste($p->param[0][$n], |
|
| 53 | - $p->descr, |
|
| 54 | - $p->boucles, |
|
| 55 | - $p->id_boucle); |
|
| 56 | - } else { |
|
| 57 | - return null; |
|
| 58 | - } |
|
| 51 | + if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) { |
|
| 52 | + return calculer_liste($p->param[0][$n], |
|
| 53 | + $p->descr, |
|
| 54 | + $p->boucles, |
|
| 55 | + $p->id_boucle); |
|
| 56 | + } else { |
|
| 57 | + return null; |
|
| 58 | + } |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | * Pile complétée par le code à générer |
| 76 | 76 | **/ |
| 77 | 77 | function balise_NOM_SITE_SPIP_dist($p) { |
| 78 | - $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 78 | + $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 79 | 79 | |
| 80 | - #$p->interdire_scripts = true; |
|
| 81 | - return $p; |
|
| 80 | + #$p->interdire_scripts = true; |
|
| 81 | + return $p; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * Pile complétée par le code à générer |
| 95 | 95 | **/ |
| 96 | 96 | function balise_EMAIL_WEBMASTER_dist($p) { |
| 97 | - $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 97 | + $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 98 | 98 | |
| 99 | - #$p->interdire_scripts = true; |
|
| 100 | - return $p; |
|
| 99 | + #$p->interdire_scripts = true; |
|
| 100 | + return $p; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | * Pile complétée par le code à générer |
| 114 | 114 | **/ |
| 115 | 115 | function balise_DESCRIPTIF_SITE_SPIP_dist($p) { |
| 116 | - $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 116 | + $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 117 | 117 | |
| 118 | - #$p->interdire_scripts = true; |
|
| 119 | - return $p; |
|
| 118 | + #$p->interdire_scripts = true; |
|
| 119 | + return $p; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | * Pile complétée par le code à générer |
| 138 | 138 | **/ |
| 139 | 139 | function balise_CHARSET_dist($p) { |
| 140 | - $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 140 | + $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 141 | 141 | |
| 142 | - #$p->interdire_scripts = true; |
|
| 143 | - return $p; |
|
| 142 | + #$p->interdire_scripts = true; |
|
| 143 | + return $p; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | * Pile complétée par le code à générer |
| 166 | 166 | **/ |
| 167 | 167 | function balise_LANG_LEFT_dist($p) { |
| 168 | - $_lang = champ_sql('lang', $p); |
|
| 169 | - $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 170 | - $p->interdire_scripts = false; |
|
| 168 | + $_lang = champ_sql('lang', $p); |
|
| 169 | + $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 170 | + $p->interdire_scripts = false; |
|
| 171 | 171 | |
| 172 | - return $p; |
|
| 172 | + return $p; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -189,11 +189,11 @@ discard block |
||
| 189 | 189 | * Pile complétée par le code à générer |
| 190 | 190 | **/ |
| 191 | 191 | function balise_LANG_RIGHT_dist($p) { |
| 192 | - $_lang = champ_sql('lang', $p); |
|
| 193 | - $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 194 | - $p->interdire_scripts = false; |
|
| 192 | + $_lang = champ_sql('lang', $p); |
|
| 193 | + $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 194 | + $p->interdire_scripts = false; |
|
| 195 | 195 | |
| 196 | - return $p; |
|
| 196 | + return $p; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | * Pile complétée par le code à générer |
| 219 | 219 | **/ |
| 220 | 220 | function balise_LANG_DIR_dist($p) { |
| 221 | - $_lang = champ_sql('lang', $p); |
|
| 222 | - $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 223 | - $p->interdire_scripts = false; |
|
| 221 | + $_lang = champ_sql('lang', $p); |
|
| 222 | + $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 223 | + $p->interdire_scripts = false; |
|
| 224 | 224 | |
| 225 | - return $p; |
|
| 225 | + return $p; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | * Pile complétée par le code à générer |
| 240 | 240 | **/ |
| 241 | 241 | function balise_PUCE_dist($p) { |
| 242 | - $p->code = "definir_puce()"; |
|
| 243 | - $p->interdire_scripts = false; |
|
| 242 | + $p->code = "definir_puce()"; |
|
| 243 | + $p->interdire_scripts = false; |
|
| 244 | 244 | |
| 245 | - return $p; |
|
| 245 | + return $p; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | * Pile completée du code PHP d'exécution de la balise |
| 267 | 267 | */ |
| 268 | 268 | function balise_DATE_dist($p) { |
| 269 | - $d = champ_sql('date', $p); |
|
| 269 | + $d = champ_sql('date', $p); |
|
| 270 | 270 | # if ($d === "@\$Pile[0]['date']") |
| 271 | 271 | # $d = "isset(\$Pile[0]['date']) ? $d : time()"; |
| 272 | - $p->code = $d; |
|
| 272 | + $p->code = $d; |
|
| 273 | 273 | |
| 274 | - return $p; |
|
| 274 | + return $p; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | |
@@ -291,13 +291,13 @@ discard block |
||
| 291 | 291 | * Pile completée du code PHP d'exécution de la balise |
| 292 | 292 | */ |
| 293 | 293 | function balise_DATE_REDAC_dist($p) { |
| 294 | - $d = champ_sql('date_redac', $p); |
|
| 294 | + $d = champ_sql('date_redac', $p); |
|
| 295 | 295 | # if ($d === "@\$Pile[0]['date_redac']") |
| 296 | 296 | # $d = "isset(\$Pile[0]['date_redac']) ? $d : time()"; |
| 297 | - $p->code = $d; |
|
| 298 | - $p->interdire_scripts = false; |
|
| 297 | + $p->code = $d; |
|
| 298 | + $p->interdire_scripts = false; |
|
| 299 | 299 | |
| 300 | - return $p; |
|
| 300 | + return $p; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | * Pile completée du code PHP d'exécution de la balise |
| 317 | 317 | */ |
| 318 | 318 | function balise_DATE_MODIF_dist($p) { |
| 319 | - $p->code = champ_sql('date_modif', $p); |
|
| 320 | - $p->interdire_scripts = false; |
|
| 319 | + $p->code = champ_sql('date_modif', $p); |
|
| 320 | + $p->interdire_scripts = false; |
|
| 321 | 321 | |
| 322 | - return $p; |
|
| 322 | + return $p; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | * Pile completée du code PHP d'exécution de la balise |
| 338 | 338 | */ |
| 339 | 339 | function balise_DATE_NOUVEAUTES_dist($p) { |
| 340 | - $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 340 | + $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 341 | 341 | AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ? |
| 342 | 342 | \$GLOBALS['meta']['dernier_envoi_neuf'] : |
| 343 | 343 | \"'0000-00-00'\")"; |
| 344 | - $p->interdire_scripts = false; |
|
| 344 | + $p->interdire_scripts = false; |
|
| 345 | 345 | |
| 346 | - return $p; |
|
| 346 | + return $p; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | * Pile completée du code PHP d'exécution de la balise |
| 363 | 363 | */ |
| 364 | 364 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 365 | - $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 366 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 367 | - $p->interdire_scripts = false; |
|
| 365 | + $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 366 | + $p->code = "_DIR_RACINE . '$code'" . |
|
| 367 | + $p->interdire_scripts = false; |
|
| 368 | 368 | |
| 369 | - return $p; |
|
| 369 | + return $p; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -381,11 +381,11 @@ discard block |
||
| 381 | 381 | * Pile completée du code PHP d'exécution de la balise |
| 382 | 382 | */ |
| 383 | 383 | function balise_SQUELETTE_dist($p) { |
| 384 | - $code = addslashes($p->descr['sourcefile']); |
|
| 385 | - $p->code = "'$code'" . |
|
| 386 | - $p->interdire_scripts = false; |
|
| 384 | + $code = addslashes($p->descr['sourcefile']); |
|
| 385 | + $p->code = "'$code'" . |
|
| 386 | + $p->interdire_scripts = false; |
|
| 387 | 387 | |
| 388 | - return $p; |
|
| 388 | + return $p; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -404,10 +404,10 @@ discard block |
||
| 404 | 404 | * Pile completée du code PHP d'exécution de la balise |
| 405 | 405 | */ |
| 406 | 406 | function balise_SPIP_VERSION_dist($p) { |
| 407 | - $p->code = "spip_version()"; |
|
| 408 | - $p->interdire_scripts = false; |
|
| 407 | + $p->code = "spip_version()"; |
|
| 408 | + $p->interdire_scripts = false; |
|
| 409 | 409 | |
| 410 | - return $p; |
|
| 410 | + return $p; |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | |
@@ -433,18 +433,18 @@ discard block |
||
| 433 | 433 | * Pile complétée par le code à générer |
| 434 | 434 | **/ |
| 435 | 435 | function balise_NOM_SITE_dist($p) { |
| 436 | - if (!$p->etoile) { |
|
| 437 | - $p->code = "supprimer_numero(calculer_url(" . |
|
| 438 | - champ_sql('url_site', $p) . "," . |
|
| 439 | - champ_sql('nom_site', $p) . |
|
| 440 | - ", 'titre', \$connect, false))"; |
|
| 441 | - } else { |
|
| 442 | - $p->code = champ_sql('nom_site', $p); |
|
| 443 | - } |
|
| 436 | + if (!$p->etoile) { |
|
| 437 | + $p->code = "supprimer_numero(calculer_url(" . |
|
| 438 | + champ_sql('url_site', $p) . "," . |
|
| 439 | + champ_sql('nom_site', $p) . |
|
| 440 | + ", 'titre', \$connect, false))"; |
|
| 441 | + } else { |
|
| 442 | + $p->code = champ_sql('nom_site', $p); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - $p->interdire_scripts = true; |
|
| 445 | + $p->interdire_scripts = true; |
|
| 446 | 446 | |
| 447 | - return $p; |
|
| 447 | + return $p; |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
@@ -461,11 +461,11 @@ discard block |
||
| 461 | 461 | * Pile complétée par le code à générer |
| 462 | 462 | **/ |
| 463 | 463 | function balise_NOTES_dist($p) { |
| 464 | - // Recuperer les notes |
|
| 465 | - $p->code = 'calculer_notes()'; |
|
| 464 | + // Recuperer les notes |
|
| 465 | + $p->code = 'calculer_notes()'; |
|
| 466 | 466 | |
| 467 | - #$p->interdire_scripts = true; |
|
| 468 | - return $p; |
|
| 467 | + #$p->interdire_scripts = true; |
|
| 468 | + return $p; |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | |
@@ -487,10 +487,10 @@ discard block |
||
| 487 | 487 | * Pile complétée par le code à générer |
| 488 | 488 | **/ |
| 489 | 489 | function balise_RECHERCHE_dist($p) { |
| 490 | - $p->code = 'entites_html(_request("recherche"))'; |
|
| 491 | - $p->interdire_scripts = false; |
|
| 490 | + $p->code = 'entites_html(_request("recherche"))'; |
|
| 491 | + $p->interdire_scripts = false; |
|
| 492 | 492 | |
| 493 | - return $p; |
|
| 493 | + return $p; |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | |
@@ -508,17 +508,17 @@ discard block |
||
| 508 | 508 | * Pile complétée par le code à générer |
| 509 | 509 | **/ |
| 510 | 510 | function balise_COMPTEUR_BOUCLE_dist($p) { |
| 511 | - $b = index_boucle_mere($p); |
|
| 512 | - if ($b === '') { |
|
| 513 | - $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 514 | - erreur_squelette($msg, $p); |
|
| 515 | - } else { |
|
| 516 | - $p->code = "\$Numrows['$b']['compteur_boucle']"; |
|
| 517 | - $p->boucles[$b]->cptrows = true; |
|
| 518 | - $p->interdire_scripts = false; |
|
| 511 | + $b = index_boucle_mere($p); |
|
| 512 | + if ($b === '') { |
|
| 513 | + $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 514 | + erreur_squelette($msg, $p); |
|
| 515 | + } else { |
|
| 516 | + $p->code = "\$Numrows['$b']['compteur_boucle']"; |
|
| 517 | + $p->boucles[$b]->cptrows = true; |
|
| 518 | + $p->interdire_scripts = false; |
|
| 519 | 519 | |
| 520 | - return $p; |
|
| 521 | - } |
|
| 520 | + return $p; |
|
| 521 | + } |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -536,17 +536,17 @@ discard block |
||
| 536 | 536 | * Pile complétée par le code à générer |
| 537 | 537 | **/ |
| 538 | 538 | function balise_TOTAL_BOUCLE_dist($p) { |
| 539 | - $b = index_boucle_mere($p); |
|
| 540 | - if ($b === '') { |
|
| 541 | - $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 542 | - erreur_squelette($msg, $p); |
|
| 543 | - } else { |
|
| 544 | - $p->code = "\$Numrows['$b']['total']"; |
|
| 545 | - $p->boucles[$b]->numrows = true; |
|
| 546 | - $p->interdire_scripts = false; |
|
| 547 | - } |
|
| 539 | + $b = index_boucle_mere($p); |
|
| 540 | + if ($b === '') { |
|
| 541 | + $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 542 | + erreur_squelette($msg, $p); |
|
| 543 | + } else { |
|
| 544 | + $p->code = "\$Numrows['$b']['total']"; |
|
| 545 | + $p->boucles[$b]->numrows = true; |
|
| 546 | + $p->interdire_scripts = false; |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | - return $p; |
|
| 549 | + return $p; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * Pile complétée par le code à générer |
| 567 | 567 | **/ |
| 568 | 568 | function balise_POINTS_dist($p) { |
| 569 | - return rindex_pile($p, 'points', 'recherche'); |
|
| 569 | + return rindex_pile($p, 'points', 'recherche'); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | |
@@ -587,12 +587,12 @@ discard block |
||
| 587 | 587 | * Pile complétée par le code à générer |
| 588 | 588 | **/ |
| 589 | 589 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 590 | - $p->code = 'ceil(' . |
|
| 591 | - champ_sql('popularite', $p) . |
|
| 592 | - ')'; |
|
| 593 | - $p->interdire_scripts = false; |
|
| 590 | + $p->code = 'ceil(' . |
|
| 591 | + champ_sql('popularite', $p) . |
|
| 592 | + ')'; |
|
| 593 | + $p->interdire_scripts = false; |
|
| 594 | 594 | |
| 595 | - return $p; |
|
| 595 | + return $p; |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | /** |
@@ -612,10 +612,10 @@ discard block |
||
| 612 | 612 | * Pile complétée par le code à générer |
| 613 | 613 | **/ |
| 614 | 614 | function balise_POPULARITE_SITE_dist($p) { |
| 615 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 616 | - $p->interdire_scripts = false; |
|
| 615 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 616 | + $p->interdire_scripts = false; |
|
| 617 | 617 | |
| 618 | - return $p; |
|
| 618 | + return $p; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -636,10 +636,10 @@ discard block |
||
| 636 | 636 | * Pile complétée par le code à générer |
| 637 | 637 | **/ |
| 638 | 638 | function balise_POPULARITE_MAX_dist($p) { |
| 639 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 640 | - $p->interdire_scripts = false; |
|
| 639 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 640 | + $p->interdire_scripts = false; |
|
| 641 | 641 | |
| 642 | - return $p; |
|
| 642 | + return $p; |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | |
@@ -665,14 +665,14 @@ discard block |
||
| 665 | 665 | * Pile complétée par le code à générer |
| 666 | 666 | **/ |
| 667 | 667 | function balise_VALEUR_dist($p) { |
| 668 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 669 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);; |
|
| 670 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 671 | - $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 672 | - } |
|
| 673 | - $p->interdire_scripts = true; |
|
| 668 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 669 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);; |
|
| 670 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 671 | + $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; |
|
| 672 | + } |
|
| 673 | + $p->interdire_scripts = true; |
|
| 674 | 674 | |
| 675 | - return $p; |
|
| 675 | + return $p; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -701,17 +701,17 @@ discard block |
||
| 701 | 701 | * Pile complétée par le code à générer |
| 702 | 702 | **/ |
| 703 | 703 | function balise_EXPOSE_dist($p) { |
| 704 | - $on = "'on'"; |
|
| 705 | - $off = "''"; |
|
| 706 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 707 | - $on = $v; |
|
| 708 | - if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 709 | - $off = $v; |
|
| 710 | - } |
|
| 704 | + $on = "'on'"; |
|
| 705 | + $off = "''"; |
|
| 706 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 707 | + $on = $v; |
|
| 708 | + if (($v = interprete_argument_balise(2, $p)) !== null) { |
|
| 709 | + $off = $v; |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - return calculer_balise_expose($p, $on, $off); |
|
| 714 | + return calculer_balise_expose($p, $on, $off); |
|
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -729,36 +729,36 @@ discard block |
||
| 729 | 729 | * Pile complétée par le code à générer |
| 730 | 730 | **/ |
| 731 | 731 | function calculer_balise_expose($p, $on, $off) { |
| 732 | - $b = index_boucle($p); |
|
| 733 | - if (empty($p->boucles[$b]->primary)) { |
|
| 734 | - $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 735 | - erreur_squelette($msg, $p); |
|
| 736 | - } else { |
|
| 732 | + $b = index_boucle($p); |
|
| 733 | + if (empty($p->boucles[$b]->primary)) { |
|
| 734 | + $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 735 | + erreur_squelette($msg, $p); |
|
| 736 | + } else { |
|
| 737 | 737 | |
| 738 | - $key = $p->boucles[$b]->primary; |
|
| 739 | - $type = $p->boucles[$p->id_boucle]->primary; |
|
| 740 | - $desc = $p->boucles[$b]->show; |
|
| 741 | - $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 738 | + $key = $p->boucles[$b]->primary; |
|
| 739 | + $type = $p->boucles[$p->id_boucle]->primary; |
|
| 740 | + $desc = $p->boucles[$b]->show; |
|
| 741 | + $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 742 | 742 | |
| 743 | - // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 744 | - $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 743 | + // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 744 | + $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 745 | 745 | |
| 746 | - if (isset($desc['field']['id_parent'])) { |
|
| 747 | - $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 748 | - } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 749 | - $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 750 | - } elseif (isset($desc['field']['id_groupe'])) { |
|
| 751 | - $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 752 | - } else { |
|
| 753 | - $parent = "''"; |
|
| 754 | - } |
|
| 746 | + if (isset($desc['field']['id_parent'])) { |
|
| 747 | + $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 748 | + } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 749 | + $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 750 | + } elseif (isset($desc['field']['id_groupe'])) { |
|
| 751 | + $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 752 | + } else { |
|
| 753 | + $parent = "''"; |
|
| 754 | + } |
|
| 755 | 755 | |
| 756 | - $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 757 | - } |
|
| 756 | + $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 757 | + } |
|
| 758 | 758 | |
| 759 | - $p->interdire_scripts = false; |
|
| 759 | + $p->interdire_scripts = false; |
|
| 760 | 760 | |
| 761 | - return $p; |
|
| 761 | + return $p; |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | |
@@ -796,47 +796,47 @@ discard block |
||
| 796 | 796 | **/ |
| 797 | 797 | function balise_INTRODUCTION_dist($p) { |
| 798 | 798 | |
| 799 | - $type = $p->type_requete; |
|
| 800 | - |
|
| 801 | - $_texte = champ_sql('texte', $p); |
|
| 802 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 803 | - $desc = $trouver_table(table_objet_sql($type)); |
|
| 804 | - $_descriptif = "''"; |
|
| 805 | - if ($desc and isset($desc['field']['descriptif'])) { |
|
| 806 | - // notamment articles et rubriques mais aussi tout nouvel objet concerne |
|
| 807 | - $_descriptif = champ_sql('descriptif', $p); |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - // notamment les articles mais aussi tout nouvel objet concerne |
|
| 811 | - if ($desc and isset($desc['field']['chapo'])) { |
|
| 812 | - $_chapo = champ_sql('chapo', $p); |
|
| 813 | - $_texte = "(strlen($_descriptif)) |
|
| 799 | + $type = $p->type_requete; |
|
| 800 | + |
|
| 801 | + $_texte = champ_sql('texte', $p); |
|
| 802 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 803 | + $desc = $trouver_table(table_objet_sql($type)); |
|
| 804 | + $_descriptif = "''"; |
|
| 805 | + if ($desc and isset($desc['field']['descriptif'])) { |
|
| 806 | + // notamment articles et rubriques mais aussi tout nouvel objet concerne |
|
| 807 | + $_descriptif = champ_sql('descriptif', $p); |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + // notamment les articles mais aussi tout nouvel objet concerne |
|
| 811 | + if ($desc and isset($desc['field']['chapo'])) { |
|
| 812 | + $_chapo = champ_sql('chapo', $p); |
|
| 813 | + $_texte = "(strlen($_descriptif)) |
|
| 814 | 814 | ? '' |
| 815 | 815 | : $_chapo . \"\\n\\n\" . $_texte"; |
| 816 | - } |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | - // longueur en parametre, ou valeur par defaut |
|
| 819 | - $longueur_defaut = objet_info($type, 'introduction_longueur'); |
|
| 820 | - if (!$longueur_defaut) { |
|
| 821 | - $longueur_defaut = 600; |
|
| 822 | - } |
|
| 818 | + // longueur en parametre, ou valeur par defaut |
|
| 819 | + $longueur_defaut = objet_info($type, 'introduction_longueur'); |
|
| 820 | + if (!$longueur_defaut) { |
|
| 821 | + $longueur_defaut = 600; |
|
| 822 | + } |
|
| 823 | 823 | |
| 824 | - $_suite = 'null'; |
|
| 825 | - $_longueur = $longueur_defaut; |
|
| 826 | - if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 827 | - $_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut; |
|
| 828 | - $_suite = '!is_numeric(' . $v . ')?' . $v . ':null'; |
|
| 829 | - } |
|
| 830 | - if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 831 | - $_suite = $v2; |
|
| 832 | - } |
|
| 824 | + $_suite = 'null'; |
|
| 825 | + $_longueur = $longueur_defaut; |
|
| 826 | + if (($v = interprete_argument_balise(1, $p)) !== null) { |
|
| 827 | + $_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut; |
|
| 828 | + $_suite = '!is_numeric(' . $v . ')?' . $v . ':null'; |
|
| 829 | + } |
|
| 830 | + if (($v2 = interprete_argument_balise(2, $p)) !== null) { |
|
| 831 | + $_suite = $v2; |
|
| 832 | + } |
|
| 833 | 833 | |
| 834 | - $f = chercher_filtre('introduction'); |
|
| 835 | - $p->code = "$f($_descriptif, $_texte, $_longueur, \$connect, $_suite)"; |
|
| 834 | + $f = chercher_filtre('introduction'); |
|
| 835 | + $p->code = "$f($_descriptif, $_texte, $_longueur, \$connect, $_suite)"; |
|
| 836 | 836 | |
| 837 | - #$p->interdire_scripts = true; |
|
| 838 | - $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 839 | - return $p; |
|
| 837 | + #$p->interdire_scripts = true; |
|
| 838 | + $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 839 | + return $p; |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | |
@@ -856,15 +856,15 @@ discard block |
||
| 856 | 856 | * Pile complétée par le code à générer |
| 857 | 857 | **/ |
| 858 | 858 | function balise_LANG_dist($p) { |
| 859 | - $_lang = champ_sql('lang', $p); |
|
| 860 | - if (!$p->etoile) { |
|
| 861 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 862 | - } else { |
|
| 863 | - $p->code = "spip_htmlentities($_lang)"; |
|
| 864 | - } |
|
| 865 | - $p->interdire_scripts = false; |
|
| 859 | + $_lang = champ_sql('lang', $p); |
|
| 860 | + if (!$p->etoile) { |
|
| 861 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 862 | + } else { |
|
| 863 | + $p->code = "spip_htmlentities($_lang)"; |
|
| 864 | + } |
|
| 865 | + $p->interdire_scripts = false; |
|
| 866 | 866 | |
| 867 | - return $p; |
|
| 867 | + return $p; |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
@@ -886,44 +886,44 @@ discard block |
||
| 886 | 886 | * Pile complétée par le code à générer |
| 887 | 887 | */ |
| 888 | 888 | function balise_LESAUTEURS_dist($p) { |
| 889 | - // Cherche le champ 'lesauteurs' dans la pile |
|
| 890 | - $_lesauteurs = champ_sql('lesauteurs', $p, false); |
|
| 891 | - |
|
| 892 | - // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 893 | - // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 894 | - // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 895 | - // (cf extension sites/) |
|
| 896 | - if ($_lesauteurs |
|
| 897 | - and $_lesauteurs != '@$Pile[0][\'lesauteurs\']' |
|
| 898 | - ) { |
|
| 899 | - $p->code = "safehtml($_lesauteurs)"; |
|
| 900 | - // $p->interdire_scripts = true; |
|
| 901 | - } else { |
|
| 902 | - if (!$p->id_boucle) { |
|
| 903 | - $connect = ''; |
|
| 904 | - $objet = 'article'; |
|
| 905 | - $id_table_objet = 'id_article'; |
|
| 906 | - } else { |
|
| 907 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 908 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 909 | - $type_boucle = $p->boucles[$b]->type_requete; |
|
| 910 | - $objet = objet_type($type_boucle); |
|
| 911 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 912 | - } |
|
| 913 | - $c = memoriser_contexte_compil($p); |
|
| 914 | - |
|
| 915 | - $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'", |
|
| 916 | - "array('objet'=>'" . $objet . |
|
| 917 | - "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 918 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 919 | - ($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 920 | - ")", |
|
| 921 | - "'trim'=>true, 'compil'=>array($c)", |
|
| 922 | - _q($connect)); |
|
| 923 | - $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - return $p; |
|
| 889 | + // Cherche le champ 'lesauteurs' dans la pile |
|
| 890 | + $_lesauteurs = champ_sql('lesauteurs', $p, false); |
|
| 891 | + |
|
| 892 | + // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 893 | + // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 894 | + // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 895 | + // (cf extension sites/) |
|
| 896 | + if ($_lesauteurs |
|
| 897 | + and $_lesauteurs != '@$Pile[0][\'lesauteurs\']' |
|
| 898 | + ) { |
|
| 899 | + $p->code = "safehtml($_lesauteurs)"; |
|
| 900 | + // $p->interdire_scripts = true; |
|
| 901 | + } else { |
|
| 902 | + if (!$p->id_boucle) { |
|
| 903 | + $connect = ''; |
|
| 904 | + $objet = 'article'; |
|
| 905 | + $id_table_objet = 'id_article'; |
|
| 906 | + } else { |
|
| 907 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 908 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 909 | + $type_boucle = $p->boucles[$b]->type_requete; |
|
| 910 | + $objet = objet_type($type_boucle); |
|
| 911 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 912 | + } |
|
| 913 | + $c = memoriser_contexte_compil($p); |
|
| 914 | + |
|
| 915 | + $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'", |
|
| 916 | + "array('objet'=>'" . $objet . |
|
| 917 | + "','id_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 918 | + ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) . |
|
| 919 | + ($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) . |
|
| 920 | + ")", |
|
| 921 | + "'trim'=>true, 'compil'=>array($c)", |
|
| 922 | + _q($connect)); |
|
| 923 | + $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + return $p; |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | |
@@ -950,75 +950,75 @@ discard block |
||
| 950 | 950 | * Pile complétée par le code à générer |
| 951 | 951 | */ |
| 952 | 952 | function balise_RANG_dist($p) { |
| 953 | - $b = index_boucle($p); |
|
| 954 | - if ($b === '') { |
|
| 955 | - $msg = array( |
|
| 956 | - 'zbug_champ_hors_boucle', |
|
| 957 | - array('champ' => '#RANG') |
|
| 958 | - ); |
|
| 959 | - erreur_squelette($msg, $p); |
|
| 960 | - } else { |
|
| 961 | - // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 962 | - // dans la boucle immediatement englobante uniquement |
|
| 963 | - // sinon on compose le champ calcule |
|
| 964 | - $_rang = champ_sql('rang', $p, '', false); |
|
| 965 | - |
|
| 966 | - // si pas trouve de champ sql rang : |
|
| 967 | - if (!$_rang or $_rang == "''") { |
|
| 968 | - $boucle = &$p->boucles[$b]; |
|
| 969 | - |
|
| 970 | - // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 971 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 972 | - $desc = $trouver_table($boucle->id_table); |
|
| 973 | - $_titre = ''; # où extraire le numero ? |
|
| 953 | + $b = index_boucle($p); |
|
| 954 | + if ($b === '') { |
|
| 955 | + $msg = array( |
|
| 956 | + 'zbug_champ_hors_boucle', |
|
| 957 | + array('champ' => '#RANG') |
|
| 958 | + ); |
|
| 959 | + erreur_squelette($msg, $p); |
|
| 960 | + } else { |
|
| 961 | + // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 962 | + // dans la boucle immediatement englobante uniquement |
|
| 963 | + // sinon on compose le champ calcule |
|
| 964 | + $_rang = champ_sql('rang', $p, '', false); |
|
| 965 | + |
|
| 966 | + // si pas trouve de champ sql rang : |
|
| 967 | + if (!$_rang or $_rang == "''") { |
|
| 968 | + $boucle = &$p->boucles[$b]; |
|
| 969 | + |
|
| 970 | + // on gere le cas ou #RANG est une extraction du numero dans le titre |
|
| 971 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 972 | + $desc = $trouver_table($boucle->id_table); |
|
| 973 | + $_titre = ''; # où extraire le numero ? |
|
| 974 | 974 | |
| 975 | - if (isset($desc['titre'])) { |
|
| 976 | - $t = $desc['titre']; |
|
| 977 | - if ( |
|
| 978 | - // Soit on trouve avec la déclaration de la lang AVANT |
|
| 979 | - preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 980 | - // Soit on prend depuis le début |
|
| 981 | - or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 982 | - ) { |
|
| 983 | - $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 984 | - $m = trim($m); |
|
| 985 | - if ($m != "''") { |
|
| 986 | - if (!preg_match(",\W,", $m)) { |
|
| 987 | - $m = $boucle->id_table . ".$m"; |
|
| 988 | - } |
|
| 975 | + if (isset($desc['titre'])) { |
|
| 976 | + $t = $desc['titre']; |
|
| 977 | + if ( |
|
| 978 | + // Soit on trouve avec la déclaration de la lang AVANT |
|
| 979 | + preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 980 | + // Soit on prend depuis le début |
|
| 981 | + or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 982 | + ) { |
|
| 983 | + $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 984 | + $m = trim($m); |
|
| 985 | + if ($m != "''") { |
|
| 986 | + if (!preg_match(",\W,", $m)) { |
|
| 987 | + $m = $boucle->id_table . ".$m"; |
|
| 988 | + } |
|
| 989 | 989 | |
| 990 | - $m .= " AS titre_rang"; |
|
| 991 | - |
|
| 992 | - $boucle->select[] = $m; |
|
| 993 | - $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 994 | - } |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 999 | - if (!$_titre) { |
|
| 1000 | - $_titre = champ_sql('titre', $p); |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1004 | - // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1005 | - $type_boucle = $boucle->type_requete; |
|
| 1006 | - $objet = objet_type($type_boucle); |
|
| 1007 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 1008 | - $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1009 | - $_env = '$Pile[0]'; |
|
| 1010 | - |
|
| 1011 | - if (!$_titre) {$_titre = "''";} |
|
| 1012 | - if (!$_primary) {$_primary = "''";} |
|
| 1013 | - $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1014 | - |
|
| 1015 | - } |
|
| 990 | + $m .= " AS titre_rang"; |
|
| 991 | + |
|
| 992 | + $boucle->select[] = $m; |
|
| 993 | + $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 999 | + if (!$_titre) { |
|
| 1000 | + $_titre = champ_sql('titre', $p); |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + // et on recupere aussi les infos de liaison si on est en train d'editer les liens justement |
|
| 1004 | + // cas des formulaires xxx_lies utilises par #FORMULAIRE_EDITER_LIENS |
|
| 1005 | + $type_boucle = $boucle->type_requete; |
|
| 1006 | + $objet = objet_type($type_boucle); |
|
| 1007 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 1008 | + $_primary = champ_sql($id_table_objet, $p, '', false); |
|
| 1009 | + $_env = '$Pile[0]'; |
|
| 1010 | + |
|
| 1011 | + if (!$_titre) {$_titre = "''";} |
|
| 1012 | + if (!$_primary) {$_primary = "''";} |
|
| 1013 | + $_rang = "calculer_rang_smart($_titre, '$objet', $_primary, $_env)"; |
|
| 1014 | + |
|
| 1015 | + } |
|
| 1016 | 1016 | |
| 1017 | - $p->code = $_rang; |
|
| 1018 | - $p->interdire_scripts = false; |
|
| 1019 | - } |
|
| 1017 | + $p->code = $_rang; |
|
| 1018 | + $p->interdire_scripts = false; |
|
| 1019 | + } |
|
| 1020 | 1020 | |
| 1021 | - return $p; |
|
| 1021 | + return $p; |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | |
@@ -1040,12 +1040,12 @@ discard block |
||
| 1040 | 1040 | * Pile complétée par le code à générer |
| 1041 | 1041 | **/ |
| 1042 | 1042 | function balise_POPULARITE_dist($p) { |
| 1043 | - $_popularite = champ_sql('popularite', $p); |
|
| 1044 | - $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1043 | + $_popularite = champ_sql('popularite', $p); |
|
| 1044 | + $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 1045 | 1045 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; |
| 1046 | - $p->interdire_scripts = false; |
|
| 1046 | + $p->interdire_scripts = false; |
|
| 1047 | 1047 | |
| 1048 | - return $p; |
|
| 1048 | + return $p; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | /** |
@@ -1092,65 +1092,65 @@ discard block |
||
| 1092 | 1092 | * Pile complétée par le code à générer |
| 1093 | 1093 | */ |
| 1094 | 1094 | function balise_PAGINATION_dist($p, $liste = 'true') { |
| 1095 | - $b = index_boucle_mere($p); |
|
| 1096 | - |
|
| 1097 | - // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1098 | - if ($b === '') { |
|
| 1099 | - $msg = array( |
|
| 1100 | - 'zbug_champ_hors_boucle', |
|
| 1101 | - array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION') |
|
| 1102 | - ); |
|
| 1103 | - erreur_squelette($msg, $p); |
|
| 1104 | - |
|
| 1105 | - return $p; |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1109 | - // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1110 | - if (!$p->boucles[$b]->mode_partie) { |
|
| 1111 | - if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1112 | - $msg = array( |
|
| 1113 | - 'zbug_pagination_sans_critere', |
|
| 1114 | - array('champ' => '#PAGINATION') |
|
| 1115 | - ); |
|
| 1116 | - erreur_squelette($msg, $p); |
|
| 1117 | - } |
|
| 1118 | - |
|
| 1119 | - return $p; |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - // a priori true |
|
| 1123 | - // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1124 | - // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1125 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1126 | - if (count($_contexte)) { |
|
| 1127 | - $key = key($_contexte); |
|
| 1128 | - if (is_numeric($key)) { |
|
| 1129 | - array_shift($_contexte); |
|
| 1130 | - $__modele = interprete_argument_balise(1, $p); |
|
| 1131 | - } |
|
| 1132 | - } |
|
| 1133 | - |
|
| 1134 | - if (count($_contexte)) { |
|
| 1135 | - $code_contexte = implode(',', $_contexte); |
|
| 1136 | - } else { |
|
| 1137 | - $code_contexte = ''; |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 1141 | - $pas = $p->boucles[$b]->total_parties; |
|
| 1142 | - $f_pagination = chercher_filtre('pagination'); |
|
| 1143 | - $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1144 | - $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1145 | - : ("'debut" . substr($type, 1)); |
|
| 1146 | - |
|
| 1147 | - $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste, |
|
| 1148 | - ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte); |
|
| 1149 | - |
|
| 1150 | - $p->boucles[$b]->numrows = true; |
|
| 1151 | - $p->interdire_scripts = false; |
|
| 1152 | - |
|
| 1153 | - return $p; |
|
| 1095 | + $b = index_boucle_mere($p); |
|
| 1096 | + |
|
| 1097 | + // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 1098 | + if ($b === '') { |
|
| 1099 | + $msg = array( |
|
| 1100 | + 'zbug_champ_hors_boucle', |
|
| 1101 | + array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION') |
|
| 1102 | + ); |
|
| 1103 | + erreur_squelette($msg, $p); |
|
| 1104 | + |
|
| 1105 | + return $p; |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 1109 | + // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 1110 | + if (!$p->boucles[$b]->mode_partie) { |
|
| 1111 | + if (!$p->boucles[$b]->table_optionnelle) { |
|
| 1112 | + $msg = array( |
|
| 1113 | + 'zbug_pagination_sans_critere', |
|
| 1114 | + array('champ' => '#PAGINATION') |
|
| 1115 | + ); |
|
| 1116 | + erreur_squelette($msg, $p); |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + return $p; |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + // a priori true |
|
| 1123 | + // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 1124 | + // si true, les arguments simples (sans truc=chose) vont degager |
|
| 1125 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 1126 | + if (count($_contexte)) { |
|
| 1127 | + $key = key($_contexte); |
|
| 1128 | + if (is_numeric($key)) { |
|
| 1129 | + array_shift($_contexte); |
|
| 1130 | + $__modele = interprete_argument_balise(1, $p); |
|
| 1131 | + } |
|
| 1132 | + } |
|
| 1133 | + |
|
| 1134 | + if (count($_contexte)) { |
|
| 1135 | + $code_contexte = implode(',', $_contexte); |
|
| 1136 | + } else { |
|
| 1137 | + $code_contexte = ''; |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 1141 | + $pas = $p->boucles[$b]->total_parties; |
|
| 1142 | + $f_pagination = chercher_filtre('pagination'); |
|
| 1143 | + $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 1144 | + $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 1145 | + : ("'debut" . substr($type, 1)); |
|
| 1146 | + |
|
| 1147 | + $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste, |
|
| 1148 | + ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte); |
|
| 1149 | + |
|
| 1150 | + $p->boucles[$b]->numrows = true; |
|
| 1151 | + $p->interdire_scripts = false; |
|
| 1152 | + |
|
| 1153 | + return $p; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | |
@@ -1177,11 +1177,11 @@ discard block |
||
| 1177 | 1177 | * Pile complétée par le code à générer |
| 1178 | 1178 | **/ |
| 1179 | 1179 | function balise_ANCRE_PAGINATION_dist($p) { |
| 1180 | - if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1181 | - return $f($p, $liste = 'false'); |
|
| 1182 | - } else { |
|
| 1183 | - return null; |
|
| 1184 | - } // ou une erreur ? |
|
| 1180 | + if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 1181 | + return $f($p, $liste = 'false'); |
|
| 1182 | + } else { |
|
| 1183 | + return null; |
|
| 1184 | + } // ou une erreur ? |
|
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | 1187 | |
@@ -1202,18 +1202,18 @@ discard block |
||
| 1202 | 1202 | * Pile complétée par le code à générer |
| 1203 | 1203 | **/ |
| 1204 | 1204 | function balise_GRAND_TOTAL_dist($p) { |
| 1205 | - $b = index_boucle_mere($p); |
|
| 1206 | - if ($b === '') { |
|
| 1207 | - $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 1208 | - erreur_squelette($msg, $p); |
|
| 1209 | - } else { |
|
| 1210 | - $p->code = "(isset(\$Numrows['$b']['grand_total']) |
|
| 1205 | + $b = index_boucle_mere($p); |
|
| 1206 | + if ($b === '') { |
|
| 1207 | + $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 1208 | + erreur_squelette($msg, $p); |
|
| 1209 | + } else { |
|
| 1210 | + $p->code = "(isset(\$Numrows['$b']['grand_total']) |
|
| 1211 | 1211 | ? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'])"; |
| 1212 | - $p->boucles[$b]->numrows = true; |
|
| 1213 | - $p->interdire_scripts = false; |
|
| 1214 | - } |
|
| 1212 | + $p->boucles[$b]->numrows = true; |
|
| 1213 | + $p->interdire_scripts = false; |
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | - return $p; |
|
| 1216 | + return $p; |
|
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | |
@@ -1241,10 +1241,10 @@ discard block |
||
| 1241 | 1241 | * Pile complétée par le code à générer |
| 1242 | 1242 | **/ |
| 1243 | 1243 | function balise_SELF_dist($p) { |
| 1244 | - $p->code = 'self()'; |
|
| 1245 | - $p->interdire_scripts = false; |
|
| 1244 | + $p->code = 'self()'; |
|
| 1245 | + $p->interdire_scripts = false; |
|
| 1246 | 1246 | |
| 1247 | - return $p; |
|
| 1247 | + return $p; |
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | 1250 | |
@@ -1271,17 +1271,17 @@ discard block |
||
| 1271 | 1271 | * Pile complétée par le code à générer |
| 1272 | 1272 | **/ |
| 1273 | 1273 | function balise_CHEMIN_dist($p) { |
| 1274 | - $arg = interprete_argument_balise(1, $p); |
|
| 1275 | - if (!$arg) { |
|
| 1276 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
|
| 1277 | - erreur_squelette($msg, $p); |
|
| 1278 | - } else { |
|
| 1279 | - $p->code = 'find_in_path(' . $arg . ')'; |
|
| 1280 | - } |
|
| 1274 | + $arg = interprete_argument_balise(1, $p); |
|
| 1275 | + if (!$arg) { |
|
| 1276 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
|
| 1277 | + erreur_squelette($msg, $p); |
|
| 1278 | + } else { |
|
| 1279 | + $p->code = 'find_in_path(' . $arg . ')'; |
|
| 1280 | + } |
|
| 1281 | 1281 | |
| 1282 | - $p->interdire_scripts = false; |
|
| 1282 | + $p->interdire_scripts = false; |
|
| 1283 | 1283 | |
| 1284 | - return $p; |
|
| 1284 | + return $p; |
|
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | 1287 | /** |
@@ -1306,16 +1306,16 @@ discard block |
||
| 1306 | 1306 | * Pile complétée par le code à générer |
| 1307 | 1307 | **/ |
| 1308 | 1308 | function balise_CHEMIN_IMAGE_dist($p) { |
| 1309 | - $arg = interprete_argument_balise(1, $p); |
|
| 1310 | - if (!$arg) { |
|
| 1311 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); |
|
| 1312 | - erreur_squelette($msg, $p); |
|
| 1313 | - } else { |
|
| 1314 | - $p->code = 'chemin_image(' . $arg . ')'; |
|
| 1315 | - } |
|
| 1309 | + $arg = interprete_argument_balise(1, $p); |
|
| 1310 | + if (!$arg) { |
|
| 1311 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); |
|
| 1312 | + erreur_squelette($msg, $p); |
|
| 1313 | + } else { |
|
| 1314 | + $p->code = 'chemin_image(' . $arg . ')'; |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | - $p->interdire_scripts = false; |
|
| 1318 | - return $p; |
|
| 1317 | + $p->interdire_scripts = false; |
|
| 1318 | + return $p; |
|
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | |
@@ -1353,36 +1353,36 @@ discard block |
||
| 1353 | 1353 | **/ |
| 1354 | 1354 | function balise_ENV_dist($p, $src = null) { |
| 1355 | 1355 | |
| 1356 | - // cle du tableau desiree |
|
| 1357 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1358 | - // valeur par defaut |
|
| 1359 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1356 | + // cle du tableau desiree |
|
| 1357 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1358 | + // valeur par defaut |
|
| 1359 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1360 | 1360 | |
| 1361 | - // $src est un tableau de donnees sources eventuellement transmis |
|
| 1362 | - // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1361 | + // $src est un tableau de donnees sources eventuellement transmis |
|
| 1362 | + // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 1363 | 1363 | |
| 1364 | - if (!$_nom) { |
|
| 1365 | - // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1366 | - // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1367 | - if ($src) { |
|
| 1368 | - $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1369 | - } else { |
|
| 1370 | - $p->code = '@serialize($Pile[0])'; |
|
| 1371 | - } |
|
| 1372 | - } else { |
|
| 1373 | - if (!$src) { |
|
| 1374 | - $src = '@$Pile[0]'; |
|
| 1375 | - } |
|
| 1376 | - if ($_sinon) { |
|
| 1377 | - $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1378 | - } else { |
|
| 1379 | - $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1380 | - } |
|
| 1381 | - } |
|
| 1364 | + if (!$_nom) { |
|
| 1365 | + // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 1366 | + // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 1367 | + if ($src) { |
|
| 1368 | + $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; |
|
| 1369 | + } else { |
|
| 1370 | + $p->code = '@serialize($Pile[0])'; |
|
| 1371 | + } |
|
| 1372 | + } else { |
|
| 1373 | + if (!$src) { |
|
| 1374 | + $src = '@$Pile[0]'; |
|
| 1375 | + } |
|
| 1376 | + if ($_sinon) { |
|
| 1377 | + $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 1378 | + } else { |
|
| 1379 | + $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 1380 | + } |
|
| 1381 | + } |
|
| 1382 | 1382 | |
| 1383 | - #$p->interdire_scripts = true; |
|
| 1383 | + #$p->interdire_scripts = true; |
|
| 1384 | 1384 | |
| 1385 | - return $p; |
|
| 1385 | + return $p; |
|
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | /** |
@@ -1412,16 +1412,16 @@ discard block |
||
| 1412 | 1412 | * Pile completée du code PHP d'exécution de la balise |
| 1413 | 1413 | */ |
| 1414 | 1414 | function balise_CONFIG_dist($p) { |
| 1415 | - if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1416 | - $arg = "''"; |
|
| 1417 | - } |
|
| 1418 | - $_sinon = interprete_argument_balise(2, $p); |
|
| 1419 | - $_unserialize = sinon(interprete_argument_balise(3, $p), "false"); |
|
| 1415 | + if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 1416 | + $arg = "''"; |
|
| 1417 | + } |
|
| 1418 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 1419 | + $_unserialize = sinon(interprete_argument_balise(3, $p), "false"); |
|
| 1420 | 1420 | |
| 1421 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1422 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1421 | + $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 1422 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 1423 | 1423 | |
| 1424 | - return $p; |
|
| 1424 | + return $p; |
|
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | 1427 | |
@@ -1444,10 +1444,10 @@ discard block |
||
| 1444 | 1444 | * Pile completée du code PHP d'exécution de la balise |
| 1445 | 1445 | */ |
| 1446 | 1446 | function balise_CONNECT_dist($p) { |
| 1447 | - $p->code = '($connect ? $connect : NULL)'; |
|
| 1448 | - $p->interdire_scripts = false; |
|
| 1447 | + $p->code = '($connect ? $connect : NULL)'; |
|
| 1448 | + $p->interdire_scripts = false; |
|
| 1449 | 1449 | |
| 1450 | - return $p; |
|
| 1450 | + return $p; |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | |
@@ -1475,15 +1475,15 @@ discard block |
||
| 1475 | 1475 | * Pile completée du code PHP d'exécution de la balise |
| 1476 | 1476 | **/ |
| 1477 | 1477 | function balise_SESSION_dist($p) { |
| 1478 | - $p->descr['session'] = true; |
|
| 1478 | + $p->descr['session'] = true; |
|
| 1479 | 1479 | |
| 1480 | - $f = function_exists('balise_ENV') |
|
| 1481 | - ? 'balise_ENV' |
|
| 1482 | - : 'balise_ENV_dist'; |
|
| 1480 | + $f = function_exists('balise_ENV') |
|
| 1481 | + ? 'balise_ENV' |
|
| 1482 | + : 'balise_ENV_dist'; |
|
| 1483 | 1483 | |
| 1484 | - $p = $f($p, '$GLOBALS["visiteur_session"]'); |
|
| 1484 | + $p = $f($p, '$GLOBALS["visiteur_session"]'); |
|
| 1485 | 1485 | |
| 1486 | - return $p; |
|
| 1486 | + return $p; |
|
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | 1489 | |
@@ -1506,18 +1506,18 @@ discard block |
||
| 1506 | 1506 | * Pile completée du code PHP d'exécution de la balise |
| 1507 | 1507 | **/ |
| 1508 | 1508 | function balise_SESSION_SET_dist($p) { |
| 1509 | - $_nom = interprete_argument_balise(1, $p); |
|
| 1510 | - $_val = interprete_argument_balise(2, $p); |
|
| 1511 | - if (!$_nom or !$_val) { |
|
| 1512 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); |
|
| 1513 | - erreur_squelette($err_b_s_a, $p); |
|
| 1514 | - } else { |
|
| 1515 | - $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1516 | - } |
|
| 1509 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1510 | + $_val = interprete_argument_balise(2, $p); |
|
| 1511 | + if (!$_nom or !$_val) { |
|
| 1512 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); |
|
| 1513 | + erreur_squelette($err_b_s_a, $p); |
|
| 1514 | + } else { |
|
| 1515 | + $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; |
|
| 1516 | + } |
|
| 1517 | 1517 | |
| 1518 | - $p->interdire_scripts = false; |
|
| 1518 | + $p->interdire_scripts = false; |
|
| 1519 | 1519 | |
| 1520 | - return $p; |
|
| 1520 | + return $p; |
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | |
@@ -1548,25 +1548,25 @@ discard block |
||
| 1548 | 1548 | * Pile completée du code PHP d'exécution de la balise |
| 1549 | 1549 | **/ |
| 1550 | 1550 | function balise_EVAL_dist($p) { |
| 1551 | - $php = interprete_argument_balise(1, $p); |
|
| 1552 | - if ($php) { |
|
| 1553 | - # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1554 | - # attention au commentaire "// x signes" qui precede |
|
| 1555 | - if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1556 | - $php, $r)) { |
|
| 1557 | - $p->code = /* $r[1]. */ |
|
| 1558 | - '(' . $r[2] . ')'; |
|
| 1559 | - } else { |
|
| 1560 | - $p->code = "eval('return '.$php.';')"; |
|
| 1561 | - } |
|
| 1562 | - } else { |
|
| 1563 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); |
|
| 1564 | - erreur_squelette($msg, $p); |
|
| 1565 | - } |
|
| 1551 | + $php = interprete_argument_balise(1, $p); |
|
| 1552 | + if ($php) { |
|
| 1553 | + # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 1554 | + # attention au commentaire "// x signes" qui precede |
|
| 1555 | + if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 1556 | + $php, $r)) { |
|
| 1557 | + $p->code = /* $r[1]. */ |
|
| 1558 | + '(' . $r[2] . ')'; |
|
| 1559 | + } else { |
|
| 1560 | + $p->code = "eval('return '.$php.';')"; |
|
| 1561 | + } |
|
| 1562 | + } else { |
|
| 1563 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); |
|
| 1564 | + erreur_squelette($msg, $p); |
|
| 1565 | + } |
|
| 1566 | 1566 | |
| 1567 | - #$p->interdire_scripts = true; |
|
| 1567 | + #$p->interdire_scripts = true; |
|
| 1568 | 1568 | |
| 1569 | - return $p; |
|
| 1569 | + return $p; |
|
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | |
@@ -1596,18 +1596,18 @@ discard block |
||
| 1596 | 1596 | **/ |
| 1597 | 1597 | function balise_CHAMP_SQL_dist($p) { |
| 1598 | 1598 | |
| 1599 | - if ($p->param |
|
| 1600 | - and isset($p->param[0][1][0]) |
|
| 1601 | - and $champ = ($p->param[0][1][0]->texte) |
|
| 1602 | - ) { |
|
| 1603 | - $p->code = champ_sql($champ, $p); |
|
| 1604 | - } else { |
|
| 1605 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); |
|
| 1606 | - erreur_squelette($err_b_s_a, $p); |
|
| 1607 | - } |
|
| 1599 | + if ($p->param |
|
| 1600 | + and isset($p->param[0][1][0]) |
|
| 1601 | + and $champ = ($p->param[0][1][0]->texte) |
|
| 1602 | + ) { |
|
| 1603 | + $p->code = champ_sql($champ, $p); |
|
| 1604 | + } else { |
|
| 1605 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); |
|
| 1606 | + erreur_squelette($err_b_s_a, $p); |
|
| 1607 | + } |
|
| 1608 | 1608 | |
| 1609 | - #$p->interdire_scripts = true; |
|
| 1610 | - return $p; |
|
| 1609 | + #$p->interdire_scripts = true; |
|
| 1610 | + return $p; |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | /** |
@@ -1633,13 +1633,13 @@ discard block |
||
| 1633 | 1633 | * Pile complétée par le code à générer |
| 1634 | 1634 | **/ |
| 1635 | 1635 | function balise_VAL_dist($p) { |
| 1636 | - $p->code = interprete_argument_balise(1, $p); |
|
| 1637 | - if (!strlen($p->code)) { |
|
| 1638 | - $p->code = "''"; |
|
| 1639 | - } |
|
| 1640 | - $p->interdire_scripts = false; |
|
| 1636 | + $p->code = interprete_argument_balise(1, $p); |
|
| 1637 | + if (!strlen($p->code)) { |
|
| 1638 | + $p->code = "''"; |
|
| 1639 | + } |
|
| 1640 | + $p->interdire_scripts = false; |
|
| 1641 | 1641 | |
| 1642 | - return $p; |
|
| 1642 | + return $p; |
|
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | 1645 | /** |
@@ -1685,10 +1685,10 @@ discard block |
||
| 1685 | 1685 | * Pile complétée par le code à générer |
| 1686 | 1686 | **/ |
| 1687 | 1687 | function balise_REM_dist($p) { |
| 1688 | - $p->code = "''"; |
|
| 1689 | - $p->interdire_scripts = false; |
|
| 1688 | + $p->code = "''"; |
|
| 1689 | + $p->interdire_scripts = false; |
|
| 1690 | 1690 | |
| 1691 | - return $p; |
|
| 1691 | + return $p; |
|
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | 1694 | /** |
@@ -1698,10 +1698,10 @@ discard block |
||
| 1698 | 1698 | * @return mixed |
| 1699 | 1699 | */ |
| 1700 | 1700 | function balise_NULL_dist($p) { |
| 1701 | - $p->code = "null"; |
|
| 1702 | - $p->interdire_scripts = false; |
|
| 1701 | + $p->code = "null"; |
|
| 1702 | + $p->interdire_scripts = false; |
|
| 1703 | 1703 | |
| 1704 | - return $p; |
|
| 1704 | + return $p; |
|
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | |
@@ -1725,18 +1725,18 @@ discard block |
||
| 1725 | 1725 | **/ |
| 1726 | 1726 | function balise_HTTP_HEADER_dist($p) { |
| 1727 | 1727 | |
| 1728 | - $header = interprete_argument_balise(1, $p); |
|
| 1729 | - if (!$header) { |
|
| 1730 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER')); |
|
| 1731 | - erreur_squelette($err_b_s_a, $p); |
|
| 1732 | - } else { |
|
| 1733 | - $p->code = "'<'.'?php header(' . _q(" |
|
| 1734 | - . $header |
|
| 1735 | - . ") . '); ?'.'>'"; |
|
| 1736 | - } |
|
| 1737 | - $p->interdire_scripts = false; |
|
| 1728 | + $header = interprete_argument_balise(1, $p); |
|
| 1729 | + if (!$header) { |
|
| 1730 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER')); |
|
| 1731 | + erreur_squelette($err_b_s_a, $p); |
|
| 1732 | + } else { |
|
| 1733 | + $p->code = "'<'.'?php header(' . _q(" |
|
| 1734 | + . $header |
|
| 1735 | + . ") . '); ?'.'>'"; |
|
| 1736 | + } |
|
| 1737 | + $p->interdire_scripts = false; |
|
| 1738 | 1738 | |
| 1739 | - return $p; |
|
| 1739 | + return $p; |
|
| 1740 | 1740 | } |
| 1741 | 1741 | |
| 1742 | 1742 | |
@@ -1761,20 +1761,20 @@ discard block |
||
| 1761 | 1761 | * Pile complétée par le code à générer |
| 1762 | 1762 | **/ |
| 1763 | 1763 | function balise_FILTRE_dist($p) { |
| 1764 | - if ($p->param) { |
|
| 1765 | - $args = array(); |
|
| 1766 | - foreach ($p->param as $i => $ignore) { |
|
| 1767 | - $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1768 | - } |
|
| 1769 | - $p->code = "'<' . '" |
|
| 1770 | - . '?php header("X-Spip-Filtre: \'.' |
|
| 1771 | - . join('.\'|\'.', $args) |
|
| 1772 | - . " . '\"); ?'.'>'"; |
|
| 1764 | + if ($p->param) { |
|
| 1765 | + $args = array(); |
|
| 1766 | + foreach ($p->param as $i => $ignore) { |
|
| 1767 | + $args[] = interprete_argument_balise($i + 1, $p); |
|
| 1768 | + } |
|
| 1769 | + $p->code = "'<' . '" |
|
| 1770 | + . '?php header("X-Spip-Filtre: \'.' |
|
| 1771 | + . join('.\'|\'.', $args) |
|
| 1772 | + . " . '\"); ?'.'>'"; |
|
| 1773 | 1773 | |
| 1774 | - $p->interdire_scripts = false; |
|
| 1774 | + $p->interdire_scripts = false; |
|
| 1775 | 1775 | |
| 1776 | - return $p; |
|
| 1777 | - } |
|
| 1776 | + return $p; |
|
| 1777 | + } |
|
| 1778 | 1778 | } |
| 1779 | 1779 | |
| 1780 | 1780 | |
@@ -1810,53 +1810,53 @@ discard block |
||
| 1810 | 1810 | **/ |
| 1811 | 1811 | function balise_CACHE_dist($p) { |
| 1812 | 1812 | |
| 1813 | - if ($p->param) { |
|
| 1814 | - $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1815 | - |
|
| 1816 | - // noter la duree du cache dans un entete proprietaire |
|
| 1817 | - |
|
| 1818 | - $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1819 | - . $duree |
|
| 1820 | - . '"); ?' . "'.'>'"; |
|
| 1821 | - |
|
| 1822 | - // Remplir le header Cache-Control |
|
| 1823 | - // cas #CACHE{0} |
|
| 1824 | - if ($duree == 0) { |
|
| 1825 | - $code .= ".'<'.'" |
|
| 1826 | - . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1827 | - . "'.'><'.'" |
|
| 1828 | - . '?php header("Pragma: no-cache"); ?' |
|
| 1829 | - . "'.'>'"; |
|
| 1830 | - } |
|
| 1831 | - |
|
| 1832 | - // recuperer les parametres suivants |
|
| 1833 | - $i = 1; |
|
| 1834 | - while (isset($p->param[0][++$i])) { |
|
| 1835 | - $pa = ($p->param[0][$i][0]->texte); |
|
| 1836 | - |
|
| 1837 | - if ($pa == 'cache-client' |
|
| 1838 | - and $duree > 0 |
|
| 1839 | - ) { |
|
| 1840 | - $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1841 | - . $duree |
|
| 1842 | - . '"); ?' . "'.'>'"; |
|
| 1843 | - // il semble logique, si on cache-client, de ne pas invalider |
|
| 1844 | - $pa = 'statique'; |
|
| 1845 | - } |
|
| 1846 | - |
|
| 1847 | - if ($pa == 'statique' |
|
| 1848 | - and $duree > 0 |
|
| 1849 | - ) { |
|
| 1850 | - $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1851 | - } |
|
| 1852 | - } |
|
| 1853 | - } else { |
|
| 1854 | - $code = "''"; |
|
| 1855 | - } |
|
| 1856 | - $p->code = $code; |
|
| 1857 | - $p->interdire_scripts = false; |
|
| 1858 | - |
|
| 1859 | - return $p; |
|
| 1813 | + if ($p->param) { |
|
| 1814 | + $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 1815 | + |
|
| 1816 | + // noter la duree du cache dans un entete proprietaire |
|
| 1817 | + |
|
| 1818 | + $code = "'<'.'" . '?php header("X-Spip-Cache: ' |
|
| 1819 | + . $duree |
|
| 1820 | + . '"); ?' . "'.'>'"; |
|
| 1821 | + |
|
| 1822 | + // Remplir le header Cache-Control |
|
| 1823 | + // cas #CACHE{0} |
|
| 1824 | + if ($duree == 0) { |
|
| 1825 | + $code .= ".'<'.'" |
|
| 1826 | + . '?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 1827 | + . "'.'><'.'" |
|
| 1828 | + . '?php header("Pragma: no-cache"); ?' |
|
| 1829 | + . "'.'>'"; |
|
| 1830 | + } |
|
| 1831 | + |
|
| 1832 | + // recuperer les parametres suivants |
|
| 1833 | + $i = 1; |
|
| 1834 | + while (isset($p->param[0][++$i])) { |
|
| 1835 | + $pa = ($p->param[0][$i][0]->texte); |
|
| 1836 | + |
|
| 1837 | + if ($pa == 'cache-client' |
|
| 1838 | + and $duree > 0 |
|
| 1839 | + ) { |
|
| 1840 | + $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' |
|
| 1841 | + . $duree |
|
| 1842 | + . '"); ?' . "'.'>'"; |
|
| 1843 | + // il semble logique, si on cache-client, de ne pas invalider |
|
| 1844 | + $pa = 'statique'; |
|
| 1845 | + } |
|
| 1846 | + |
|
| 1847 | + if ($pa == 'statique' |
|
| 1848 | + and $duree > 0 |
|
| 1849 | + ) { |
|
| 1850 | + $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; |
|
| 1851 | + } |
|
| 1852 | + } |
|
| 1853 | + } else { |
|
| 1854 | + $code = "''"; |
|
| 1855 | + } |
|
| 1856 | + $p->code = $code; |
|
| 1857 | + $p->interdire_scripts = false; |
|
| 1858 | + |
|
| 1859 | + return $p; |
|
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | 1862 | |
@@ -1888,13 +1888,13 @@ discard block |
||
| 1888 | 1888 | * Pile complétée par le code à générer |
| 1889 | 1889 | */ |
| 1890 | 1890 | function balise_INSERT_HEAD_dist($p) { |
| 1891 | - $p->code = "'<'.'" |
|
| 1892 | - . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1893 | - . "'.'>'"; |
|
| 1894 | - $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1895 | - $p->interdire_scripts = false; |
|
| 1891 | + $p->code = "'<'.'" |
|
| 1892 | + . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' |
|
| 1893 | + . "'.'>'"; |
|
| 1894 | + $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1895 | + $p->interdire_scripts = false; |
|
| 1896 | 1896 | |
| 1897 | - return $p; |
|
| 1897 | + return $p; |
|
| 1898 | 1898 | } |
| 1899 | 1899 | |
| 1900 | 1900 | /** |
@@ -1912,10 +1912,10 @@ discard block |
||
| 1912 | 1912 | * Pile complétée par le code à générer |
| 1913 | 1913 | */ |
| 1914 | 1914 | function balise_INSERT_HEAD_CSS_dist($p) { |
| 1915 | - $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1916 | - $p->interdire_scripts = false; |
|
| 1915 | + $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1916 | + $p->interdire_scripts = false; |
|
| 1917 | 1917 | |
| 1918 | - return $p; |
|
| 1918 | + return $p; |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | /** |
@@ -1930,11 +1930,11 @@ discard block |
||
| 1930 | 1930 | * Pile complétée par le code à générer |
| 1931 | 1931 | **/ |
| 1932 | 1932 | function balise_INCLUDE_dist($p) { |
| 1933 | - if (function_exists('balise_INCLURE')) { |
|
| 1934 | - return balise_INCLURE($p); |
|
| 1935 | - } else { |
|
| 1936 | - return balise_INCLURE_dist($p); |
|
| 1937 | - } |
|
| 1933 | + if (function_exists('balise_INCLURE')) { |
|
| 1934 | + return balise_INCLURE($p); |
|
| 1935 | + } else { |
|
| 1936 | + return balise_INCLURE_dist($p); |
|
| 1937 | + } |
|
| 1938 | 1938 | } |
| 1939 | 1939 | |
| 1940 | 1940 | /** |
@@ -1968,68 +1968,68 @@ discard block |
||
| 1968 | 1968 | * Pile complétée par le code à générer |
| 1969 | 1969 | **/ |
| 1970 | 1970 | function balise_INCLURE_dist($p) { |
| 1971 | - $id_boucle = $p->id_boucle; |
|
| 1972 | - // la lang n'est pas passe de facon automatique par argumenter |
|
| 1973 | - // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1974 | - // en option |
|
| 1975 | - |
|
| 1976 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1977 | - |
|
| 1978 | - // erreur de syntaxe = fond absent |
|
| 1979 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1980 | - if (!$_contexte) { |
|
| 1981 | - $contexte = array(); |
|
| 1982 | - } |
|
| 1983 | - |
|
| 1984 | - if (isset($_contexte['fond'])) { |
|
| 1985 | - |
|
| 1986 | - $f = $_contexte['fond']; |
|
| 1987 | - // toujours vrai : |
|
| 1988 | - if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1989 | - $f = $r[1]; |
|
| 1990 | - unset($_contexte['fond']); |
|
| 1991 | - } else { |
|
| 1992 | - spip_log("compilation de #INCLURE a revoir"); |
|
| 1993 | - } |
|
| 1994 | - |
|
| 1995 | - // #INCLURE{doublons} |
|
| 1996 | - if (isset($_contexte['doublons'])) { |
|
| 1997 | - $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 1998 | - } |
|
| 1999 | - |
|
| 2000 | - // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2001 | - $flag_env = false; |
|
| 2002 | - if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2003 | - $flag_env = true; |
|
| 2004 | - unset($_contexte['env']); |
|
| 2005 | - } |
|
| 2006 | - |
|
| 2007 | - $_options = array(); |
|
| 2008 | - if (isset($_contexte['ajax'])) { |
|
| 2009 | - $_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2010 | - unset($_contexte['ajax']); |
|
| 2011 | - } |
|
| 2012 | - if ($p->etoile) { |
|
| 2013 | - $_options[] = "'etoile'=>true"; |
|
| 2014 | - } |
|
| 2015 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")"; |
|
| 2016 | - |
|
| 2017 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2018 | - if ($flag_env) { |
|
| 2019 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2020 | - } |
|
| 2021 | - |
|
| 2022 | - $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')"); |
|
| 2023 | - |
|
| 2024 | - } elseif (!isset($_contexte[1])) { |
|
| 2025 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); |
|
| 2026 | - erreur_squelette($msg, $p); |
|
| 2027 | - } else { |
|
| 2028 | - $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2029 | - } |
|
| 2030 | - |
|
| 2031 | - $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2032 | - return $p; |
|
| 1971 | + $id_boucle = $p->id_boucle; |
|
| 1972 | + // la lang n'est pas passe de facon automatique par argumenter |
|
| 1973 | + // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1974 | + // en option |
|
| 1975 | + |
|
| 1976 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1977 | + |
|
| 1978 | + // erreur de syntaxe = fond absent |
|
| 1979 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1980 | + if (!$_contexte) { |
|
| 1981 | + $contexte = array(); |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + if (isset($_contexte['fond'])) { |
|
| 1985 | + |
|
| 1986 | + $f = $_contexte['fond']; |
|
| 1987 | + // toujours vrai : |
|
| 1988 | + if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1989 | + $f = $r[1]; |
|
| 1990 | + unset($_contexte['fond']); |
|
| 1991 | + } else { |
|
| 1992 | + spip_log("compilation de #INCLURE a revoir"); |
|
| 1993 | + } |
|
| 1994 | + |
|
| 1995 | + // #INCLURE{doublons} |
|
| 1996 | + if (isset($_contexte['doublons'])) { |
|
| 1997 | + $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 1998 | + } |
|
| 1999 | + |
|
| 2000 | + // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 2001 | + $flag_env = false; |
|
| 2002 | + if (isset($_contexte['env']) or isset($_contexte['self'])) { |
|
| 2003 | + $flag_env = true; |
|
| 2004 | + unset($_contexte['env']); |
|
| 2005 | + } |
|
| 2006 | + |
|
| 2007 | + $_options = array(); |
|
| 2008 | + if (isset($_contexte['ajax'])) { |
|
| 2009 | + $_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2010 | + unset($_contexte['ajax']); |
|
| 2011 | + } |
|
| 2012 | + if ($p->etoile) { |
|
| 2013 | + $_options[] = "'etoile'=>true"; |
|
| 2014 | + } |
|
| 2015 | + $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")"; |
|
| 2016 | + |
|
| 2017 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2018 | + if ($flag_env) { |
|
| 2019 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2020 | + } |
|
| 2021 | + |
|
| 2022 | + $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')"); |
|
| 2023 | + |
|
| 2024 | + } elseif (!isset($_contexte[1])) { |
|
| 2025 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); |
|
| 2026 | + erreur_squelette($msg, $p); |
|
| 2027 | + } else { |
|
| 2028 | + $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 2029 | + } |
|
| 2030 | + |
|
| 2031 | + $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 2032 | + return $p; |
|
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | 2035 | |
@@ -2057,69 +2057,69 @@ discard block |
||
| 2057 | 2057 | **/ |
| 2058 | 2058 | function balise_MODELE_dist($p) { |
| 2059 | 2059 | |
| 2060 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2061 | - |
|
| 2062 | - // erreur de syntaxe = fond absent |
|
| 2063 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2064 | - if (!$_contexte) { |
|
| 2065 | - $_contexte = array(); |
|
| 2066 | - } |
|
| 2067 | - |
|
| 2068 | - if (!isset($_contexte[1])) { |
|
| 2069 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); |
|
| 2070 | - erreur_squelette($msg, $p); |
|
| 2071 | - } else { |
|
| 2072 | - $nom = $_contexte[1]; |
|
| 2073 | - unset($_contexte[1]); |
|
| 2074 | - |
|
| 2075 | - if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2076 | - $nom = "'modeles/" . substr($nom, 1); |
|
| 2077 | - } else { |
|
| 2078 | - $nom = "'modeles/' . $nom"; |
|
| 2079 | - } |
|
| 2080 | - |
|
| 2081 | - $flag_env = false; |
|
| 2082 | - if (isset($_contexte['env'])) { |
|
| 2083 | - $flag_env = true; |
|
| 2084 | - unset($_contexte['env']); |
|
| 2085 | - } |
|
| 2086 | - |
|
| 2087 | - // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2088 | - // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2089 | - if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2090 | - $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2091 | - if (!strpos($primary, ',')) { |
|
| 2092 | - $id = champ_sql($primary, $p); |
|
| 2093 | - $_contexte[] = "'$primary'=>" . $id; |
|
| 2094 | - $_contexte[] = "'id'=>" . $id; |
|
| 2095 | - } |
|
| 2096 | - } |
|
| 2097 | - $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2098 | - $connect = ''; |
|
| 2099 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2100 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2101 | - } |
|
| 2102 | - |
|
| 2103 | - $_options = memoriser_contexte_compil($p); |
|
| 2104 | - $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2105 | - if (isset($_contexte['ajax'])) { |
|
| 2106 | - $_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2107 | - unset($_contexte['ajax']); |
|
| 2108 | - } |
|
| 2109 | - |
|
| 2110 | - $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2111 | - if ($flag_env) { |
|
| 2112 | - $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2113 | - } |
|
| 2114 | - |
|
| 2115 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2116 | - |
|
| 2117 | - $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2118 | - |
|
| 2119 | - $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2120 | - } |
|
| 2121 | - |
|
| 2122 | - return $p; |
|
| 2060 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 2061 | + |
|
| 2062 | + // erreur de syntaxe = fond absent |
|
| 2063 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 2064 | + if (!$_contexte) { |
|
| 2065 | + $_contexte = array(); |
|
| 2066 | + } |
|
| 2067 | + |
|
| 2068 | + if (!isset($_contexte[1])) { |
|
| 2069 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); |
|
| 2070 | + erreur_squelette($msg, $p); |
|
| 2071 | + } else { |
|
| 2072 | + $nom = $_contexte[1]; |
|
| 2073 | + unset($_contexte[1]); |
|
| 2074 | + |
|
| 2075 | + if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 2076 | + $nom = "'modeles/" . substr($nom, 1); |
|
| 2077 | + } else { |
|
| 2078 | + $nom = "'modeles/' . $nom"; |
|
| 2079 | + } |
|
| 2080 | + |
|
| 2081 | + $flag_env = false; |
|
| 2082 | + if (isset($_contexte['env'])) { |
|
| 2083 | + $flag_env = true; |
|
| 2084 | + unset($_contexte['env']); |
|
| 2085 | + } |
|
| 2086 | + |
|
| 2087 | + // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 2088 | + // Reserver la cle primaire de la boucle courante si elle existe |
|
| 2089 | + if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 2090 | + $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 2091 | + if (!strpos($primary, ',')) { |
|
| 2092 | + $id = champ_sql($primary, $p); |
|
| 2093 | + $_contexte[] = "'$primary'=>" . $id; |
|
| 2094 | + $_contexte[] = "'id'=>" . $id; |
|
| 2095 | + } |
|
| 2096 | + } |
|
| 2097 | + $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 2098 | + $connect = ''; |
|
| 2099 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2100 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2101 | + } |
|
| 2102 | + |
|
| 2103 | + $_options = memoriser_contexte_compil($p); |
|
| 2104 | + $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 2105 | + if (isset($_contexte['ajax'])) { |
|
| 2106 | + $_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 2107 | + unset($_contexte['ajax']); |
|
| 2108 | + } |
|
| 2109 | + |
|
| 2110 | + $_l = 'array(' . join(",\n\t", $_contexte) . ')'; |
|
| 2111 | + if ($flag_env) { |
|
| 2112 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 2113 | + } |
|
| 2114 | + |
|
| 2115 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect)); |
|
| 2116 | + |
|
| 2117 | + $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 2118 | + |
|
| 2119 | + $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 2120 | + } |
|
| 2121 | + |
|
| 2122 | + return $p; |
|
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | 2125 | |
@@ -2143,21 +2143,21 @@ discard block |
||
| 2143 | 2143 | * Pile complétée par le code à générer |
| 2144 | 2144 | **/ |
| 2145 | 2145 | function balise_SET_dist($p) { |
| 2146 | - $_nom = interprete_argument_balise(1, $p); |
|
| 2147 | - $_val = interprete_argument_balise(2, $p); |
|
| 2146 | + $_nom = interprete_argument_balise(1, $p); |
|
| 2147 | + $_val = interprete_argument_balise(2, $p); |
|
| 2148 | 2148 | |
| 2149 | - if (!$_nom or !$_val) { |
|
| 2150 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); |
|
| 2151 | - erreur_squelette($err_b_s_a, $p); |
|
| 2152 | - } |
|
| 2153 | - // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2154 | - // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2155 | - else { |
|
| 2156 | - $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2157 | - } |
|
| 2149 | + if (!$_nom or !$_val) { |
|
| 2150 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); |
|
| 2151 | + erreur_squelette($err_b_s_a, $p); |
|
| 2152 | + } |
|
| 2153 | + // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 2154 | + // cf https://bugs.php.net/bug.php?id=65845 |
|
| 2155 | + else { |
|
| 2156 | + $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 2157 | + } |
|
| 2158 | 2158 | |
| 2159 | - $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2160 | - return $p; |
|
| 2159 | + $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 2160 | + return $p; |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | |
@@ -2187,12 +2187,12 @@ discard block |
||
| 2187 | 2187 | * Pile complétée par le code à générer |
| 2188 | 2188 | **/ |
| 2189 | 2189 | function balise_GET_dist($p) { |
| 2190 | - $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2191 | - if (function_exists('balise_ENV')) { |
|
| 2192 | - return balise_ENV($p, '$Pile["vars"]'); |
|
| 2193 | - } else { |
|
| 2194 | - return balise_ENV_dist($p, '$Pile["vars"]'); |
|
| 2195 | - } |
|
| 2190 | + $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 2191 | + if (function_exists('balise_ENV')) { |
|
| 2192 | + return balise_ENV($p, '$Pile["vars"]'); |
|
| 2193 | + } else { |
|
| 2194 | + return balise_ENV_dist($p, '$Pile["vars"]'); |
|
| 2195 | + } |
|
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | 2198 | |
@@ -2215,22 +2215,22 @@ discard block |
||
| 2215 | 2215 | * Pile complétée par le code à générer |
| 2216 | 2216 | **/ |
| 2217 | 2217 | function balise_DOUBLONS_dist($p) { |
| 2218 | - if ($type = interprete_argument_balise(1, $p)) { |
|
| 2219 | - if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2220 | - $type .= '.' . $famille; |
|
| 2221 | - } |
|
| 2222 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2223 | - if (!$p->etoile) { |
|
| 2224 | - $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2225 | - . $p->code . ')))'; |
|
| 2226 | - } |
|
| 2227 | - } else { |
|
| 2228 | - $p->code = '$doublons'; |
|
| 2229 | - } |
|
| 2218 | + if ($type = interprete_argument_balise(1, $p)) { |
|
| 2219 | + if ($famille = interprete_argument_balise(2, $p)) { |
|
| 2220 | + $type .= '.' . $famille; |
|
| 2221 | + } |
|
| 2222 | + $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")'; |
|
| 2223 | + if (!$p->etoile) { |
|
| 2224 | + $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 2225 | + . $p->code . ')))'; |
|
| 2226 | + } |
|
| 2227 | + } else { |
|
| 2228 | + $p->code = '$doublons'; |
|
| 2229 | + } |
|
| 2230 | 2230 | |
| 2231 | - $p->interdire_scripts = false; |
|
| 2231 | + $p->interdire_scripts = false; |
|
| 2232 | 2232 | |
| 2233 | - return $p; |
|
| 2233 | + return $p; |
|
| 2234 | 2234 | } |
| 2235 | 2235 | |
| 2236 | 2236 | |
@@ -2253,18 +2253,18 @@ discard block |
||
| 2253 | 2253 | * Pile complétée par le code à générer |
| 2254 | 2254 | **/ |
| 2255 | 2255 | function balise_PIPELINE_dist($p) { |
| 2256 | - $_pipe = interprete_argument_balise(1, $p); |
|
| 2257 | - if (!$_pipe) { |
|
| 2258 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); |
|
| 2259 | - erreur_squelette($err_b_s_a, $p); |
|
| 2260 | - } else { |
|
| 2261 | - $_flux = interprete_argument_balise(2, $p); |
|
| 2262 | - $_flux = $_flux ? $_flux : "''"; |
|
| 2263 | - $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2264 | - $p->interdire_scripts = false; |
|
| 2265 | - } |
|
| 2256 | + $_pipe = interprete_argument_balise(1, $p); |
|
| 2257 | + if (!$_pipe) { |
|
| 2258 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); |
|
| 2259 | + erreur_squelette($err_b_s_a, $p); |
|
| 2260 | + } else { |
|
| 2261 | + $_flux = interprete_argument_balise(2, $p); |
|
| 2262 | + $_flux = $_flux ? $_flux : "''"; |
|
| 2263 | + $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 2264 | + $p->interdire_scripts = false; |
|
| 2265 | + } |
|
| 2266 | 2266 | |
| 2267 | - return $p; |
|
| 2267 | + return $p; |
|
| 2268 | 2268 | } |
| 2269 | 2269 | |
| 2270 | 2270 | |
@@ -2289,10 +2289,10 @@ discard block |
||
| 2289 | 2289 | * Pile complétée par le code à générer |
| 2290 | 2290 | **/ |
| 2291 | 2291 | function balise_EDIT_dist($p) { |
| 2292 | - $p->code = "''"; |
|
| 2293 | - $p->interdire_scripts = false; |
|
| 2292 | + $p->code = "''"; |
|
| 2293 | + $p->interdire_scripts = false; |
|
| 2294 | 2294 | |
| 2295 | - return $p; |
|
| 2295 | + return $p; |
|
| 2296 | 2296 | } |
| 2297 | 2297 | |
| 2298 | 2298 | |
@@ -2315,11 +2315,11 @@ discard block |
||
| 2315 | 2315 | * Pile complétée par le code à générer |
| 2316 | 2316 | **/ |
| 2317 | 2317 | function balise_TOTAL_UNIQUE_dist($p) { |
| 2318 | - $_famille = interprete_argument_balise(1, $p); |
|
| 2319 | - $_famille = $_famille ? $_famille : "''"; |
|
| 2320 | - $p->code = "unique('', $_famille, true)"; |
|
| 2318 | + $_famille = interprete_argument_balise(1, $p); |
|
| 2319 | + $_famille = $_famille ? $_famille : "''"; |
|
| 2320 | + $p->code = "unique('', $_famille, true)"; |
|
| 2321 | 2321 | |
| 2322 | - return $p; |
|
| 2322 | + return $p; |
|
| 2323 | 2323 | } |
| 2324 | 2324 | |
| 2325 | 2325 | /** |
@@ -2342,19 +2342,19 @@ discard block |
||
| 2342 | 2342 | * Pile complétée par le code à générer |
| 2343 | 2343 | **/ |
| 2344 | 2344 | function balise_ARRAY_dist($p) { |
| 2345 | - $_code = array(); |
|
| 2346 | - $n = 1; |
|
| 2347 | - do { |
|
| 2348 | - $_key = interprete_argument_balise($n++, $p); |
|
| 2349 | - $_val = interprete_argument_balise($n++, $p); |
|
| 2350 | - if ($_key and $_val) { |
|
| 2351 | - $_code[] = "$_key => $_val"; |
|
| 2352 | - } |
|
| 2353 | - } while ($_key && $_val); |
|
| 2354 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2355 | - $p->interdire_scripts = false; |
|
| 2345 | + $_code = array(); |
|
| 2346 | + $n = 1; |
|
| 2347 | + do { |
|
| 2348 | + $_key = interprete_argument_balise($n++, $p); |
|
| 2349 | + $_val = interprete_argument_balise($n++, $p); |
|
| 2350 | + if ($_key and $_val) { |
|
| 2351 | + $_code[] = "$_key => $_val"; |
|
| 2352 | + } |
|
| 2353 | + } while ($_key && $_val); |
|
| 2354 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2355 | + $p->interdire_scripts = false; |
|
| 2356 | 2356 | |
| 2357 | - return $p; |
|
| 2357 | + return $p; |
|
| 2358 | 2358 | } |
| 2359 | 2359 | |
| 2360 | 2360 | /** |
@@ -2373,15 +2373,15 @@ discard block |
||
| 2373 | 2373 | * Pile complétée par le code à générer |
| 2374 | 2374 | */ |
| 2375 | 2375 | function balise_LISTE_dist($p) { |
| 2376 | - $_code = array(); |
|
| 2377 | - $n = 1; |
|
| 2378 | - while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2379 | - $_code[] = $_val; |
|
| 2380 | - } |
|
| 2381 | - $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2382 | - $p->interdire_scripts = false; |
|
| 2376 | + $_code = array(); |
|
| 2377 | + $n = 1; |
|
| 2378 | + while ($_val = interprete_argument_balise($n++, $p)) { |
|
| 2379 | + $_code[] = $_val; |
|
| 2380 | + } |
|
| 2381 | + $p->code = 'array(' . join(', ', $_code) . ')'; |
|
| 2382 | + $p->interdire_scripts = false; |
|
| 2383 | 2383 | |
| 2384 | - return $p; |
|
| 2384 | + return $p; |
|
| 2385 | 2385 | } |
| 2386 | 2386 | |
| 2387 | 2387 | |
@@ -2415,19 +2415,19 @@ discard block |
||
| 2415 | 2415 | * Pile complétée par le code à générer |
| 2416 | 2416 | **/ |
| 2417 | 2417 | function balise_AUTORISER_dist($p) { |
| 2418 | - $_code = array(); |
|
| 2419 | - $p->descr['session'] = true; // faire un cache par session |
|
| 2418 | + $_code = array(); |
|
| 2419 | + $p->descr['session'] = true; // faire un cache par session |
|
| 2420 | 2420 | |
| 2421 | - $n = 1; |
|
| 2422 | - while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2423 | - $_code[] = $_v; |
|
| 2424 | - } |
|
| 2421 | + $n = 1; |
|
| 2422 | + while ($_v = interprete_argument_balise($n++, $p)) { |
|
| 2423 | + $_code[] = $_v; |
|
| 2424 | + } |
|
| 2425 | 2425 | |
| 2426 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ', |
|
| 2427 | - $_code) . ')?" ":"")'; |
|
| 2428 | - $p->interdire_scripts = false; |
|
| 2426 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ', |
|
| 2427 | + $_code) . ')?" ":"")'; |
|
| 2428 | + $p->interdire_scripts = false; |
|
| 2429 | 2429 | |
| 2430 | - return $p; |
|
| 2430 | + return $p; |
|
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | |
@@ -2451,15 +2451,15 @@ discard block |
||
| 2451 | 2451 | * Pile complétée par le code à générer |
| 2452 | 2452 | **/ |
| 2453 | 2453 | function balise_PLUGIN_dist($p) { |
| 2454 | - $plugin = interprete_argument_balise(1, $p); |
|
| 2455 | - $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2456 | - $type_info = interprete_argument_balise(2, $p); |
|
| 2457 | - $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2454 | + $plugin = interprete_argument_balise(1, $p); |
|
| 2455 | + $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 2456 | + $type_info = interprete_argument_balise(2, $p); |
|
| 2457 | + $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 2458 | 2458 | |
| 2459 | - $f = chercher_filtre('info_plugin'); |
|
| 2460 | - $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2459 | + $f = chercher_filtre('info_plugin'); |
|
| 2460 | + $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; |
|
| 2461 | 2461 | |
| 2462 | - return $p; |
|
| 2462 | + return $p; |
|
| 2463 | 2463 | } |
| 2464 | 2464 | |
| 2465 | 2465 | /** |
@@ -2480,11 +2480,11 @@ discard block |
||
| 2480 | 2480 | * Pile complétée par le code à générer |
| 2481 | 2481 | **/ |
| 2482 | 2482 | function balise_AIDER_dist($p) { |
| 2483 | - $_motif = interprete_argument_balise(1, $p); |
|
| 2484 | - $s = "'" . addslashes($p->descr['sourcefile']) . "'"; |
|
| 2485 | - $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif,$s, \$Pile[0]):'')"; |
|
| 2483 | + $_motif = interprete_argument_balise(1, $p); |
|
| 2484 | + $s = "'" . addslashes($p->descr['sourcefile']) . "'"; |
|
| 2485 | + $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif,$s, \$Pile[0]):'')"; |
|
| 2486 | 2486 | |
| 2487 | - return $p; |
|
| 2487 | + return $p; |
|
| 2488 | 2488 | } |
| 2489 | 2489 | |
| 2490 | 2490 | /** |
@@ -2510,16 +2510,16 @@ discard block |
||
| 2510 | 2510 | * Pile complétée par le code à générer |
| 2511 | 2511 | **/ |
| 2512 | 2512 | function balise_ACTION_FORMULAIRE($p) { |
| 2513 | - if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2514 | - $_url = "@\$Pile[0]['action']"; |
|
| 2515 | - } |
|
| 2516 | - if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2517 | - $_form = "@\$Pile[0]['form']"; |
|
| 2518 | - } |
|
| 2519 | - |
|
| 2520 | - // envoyer le nom du formulaire que l'on traite |
|
| 2521 | - // transmettre les eventuels args de la balise formulaire |
|
| 2522 | - $p->code = " '<span class=\"form-hidden\">' . |
|
| 2513 | + if (!$_url = interprete_argument_balise(1, $p)) { |
|
| 2514 | + $_url = "@\$Pile[0]['action']"; |
|
| 2515 | + } |
|
| 2516 | + if (!$_form = interprete_argument_balise(2, $p)) { |
|
| 2517 | + $_form = "@\$Pile[0]['form']"; |
|
| 2518 | + } |
|
| 2519 | + |
|
| 2520 | + // envoyer le nom du formulaire que l'on traite |
|
| 2521 | + // transmettre les eventuels args de la balise formulaire |
|
| 2522 | + $p->code = " '<span class=\"form-hidden\">' . |
|
| 2523 | 2523 | form_hidden($_url) . |
| 2524 | 2524 | '<input name=\'formulaire_action\' type=\'hidden\' |
| 2525 | 2525 | value=\'' . $_form . '\' />' . |
@@ -2528,9 +2528,9 @@ discard block |
||
| 2528 | 2528 | (!empty(\$Pile[0]['_hidden']) ? @\$Pile[0]['_hidden'] : '') . |
| 2529 | 2529 | '</span>'"; |
| 2530 | 2530 | |
| 2531 | - $p->interdire_scripts = false; |
|
| 2531 | + $p->interdire_scripts = false; |
|
| 2532 | 2532 | |
| 2533 | - return $p; |
|
| 2533 | + return $p; |
|
| 2534 | 2534 | } |
| 2535 | 2535 | |
| 2536 | 2536 | |
@@ -2571,25 +2571,25 @@ discard block |
||
| 2571 | 2571 | */ |
| 2572 | 2572 | function balise_BOUTON_ACTION_dist($p) { |
| 2573 | 2573 | |
| 2574 | - $args = array(); |
|
| 2575 | - for ($k = 1; $k <= 6; $k++) { |
|
| 2576 | - $_a = interprete_argument_balise($k, $p); |
|
| 2577 | - if (!$_a) { |
|
| 2578 | - $_a = "''"; |
|
| 2579 | - } |
|
| 2580 | - $args[] = $_a; |
|
| 2581 | - } |
|
| 2582 | - // supprimer les args vides |
|
| 2583 | - while (end($args) == "''" and count($args) > 2) { |
|
| 2584 | - array_pop($args); |
|
| 2585 | - } |
|
| 2586 | - $args = implode(",", $args); |
|
| 2574 | + $args = array(); |
|
| 2575 | + for ($k = 1; $k <= 6; $k++) { |
|
| 2576 | + $_a = interprete_argument_balise($k, $p); |
|
| 2577 | + if (!$_a) { |
|
| 2578 | + $_a = "''"; |
|
| 2579 | + } |
|
| 2580 | + $args[] = $_a; |
|
| 2581 | + } |
|
| 2582 | + // supprimer les args vides |
|
| 2583 | + while (end($args) == "''" and count($args) > 2) { |
|
| 2584 | + array_pop($args); |
|
| 2585 | + } |
|
| 2586 | + $args = implode(",", $args); |
|
| 2587 | 2587 | |
| 2588 | - $bouton_action = chercher_filtre("bouton_action"); |
|
| 2589 | - $p->code = "$bouton_action($args)"; |
|
| 2590 | - $p->interdire_scripts = false; |
|
| 2588 | + $bouton_action = chercher_filtre("bouton_action"); |
|
| 2589 | + $p->code = "$bouton_action($args)"; |
|
| 2590 | + $p->interdire_scripts = false; |
|
| 2591 | 2591 | |
| 2592 | - return $p; |
|
| 2592 | + return $p; |
|
| 2593 | 2593 | } |
| 2594 | 2594 | |
| 2595 | 2595 | |
@@ -2608,10 +2608,10 @@ discard block |
||
| 2608 | 2608 | * Pile complétée par le code à générer |
| 2609 | 2609 | */ |
| 2610 | 2610 | function balise_SLOGAN_SITE_SPIP_dist($p) { |
| 2611 | - $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2611 | + $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 2612 | 2612 | |
| 2613 | - #$p->interdire_scripts = true; |
|
| 2614 | - return $p; |
|
| 2613 | + #$p->interdire_scripts = true; |
|
| 2614 | + return $p; |
|
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | |
@@ -2635,10 +2635,10 @@ discard block |
||
| 2635 | 2635 | * Pile complétée par le code à générer |
| 2636 | 2636 | */ |
| 2637 | 2637 | function balise_HTML5_dist($p) { |
| 2638 | - $p->code = html5_permis() ? "' '" : "''"; |
|
| 2639 | - $p->interdire_scripts = false; |
|
| 2638 | + $p->code = html5_permis() ? "' '" : "''"; |
|
| 2639 | + $p->interdire_scripts = false; |
|
| 2640 | 2640 | |
| 2641 | - return $p; |
|
| 2641 | + return $p; |
|
| 2642 | 2642 | } |
| 2643 | 2643 | |
| 2644 | 2644 | |
@@ -2664,61 +2664,61 @@ discard block |
||
| 2664 | 2664 | * Pile complétée par le code à générer |
| 2665 | 2665 | */ |
| 2666 | 2666 | function balise_TRI_dist($p, $liste = 'true') { |
| 2667 | - $b = index_boucle_mere($p); |
|
| 2668 | - // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2669 | - if ($b === '') { |
|
| 2670 | - $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 2671 | - erreur_squelette($msg, $p); |
|
| 2672 | - $p->code = "''"; |
|
| 2667 | + $b = index_boucle_mere($p); |
|
| 2668 | + // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 2669 | + if ($b === '') { |
|
| 2670 | + $msg = array('zbug_champ_hors_boucle', array('champ' => zbug_presenter_champ($p))); |
|
| 2671 | + erreur_squelette($msg, $p); |
|
| 2672 | + $p->code = "''"; |
|
| 2673 | 2673 | |
| 2674 | - return $p; |
|
| 2675 | - } |
|
| 2676 | - $boucle = $p->boucles[$b]; |
|
| 2674 | + return $p; |
|
| 2675 | + } |
|
| 2676 | + $boucle = $p->boucles[$b]; |
|
| 2677 | 2677 | |
| 2678 | - // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2679 | - // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2680 | - if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2681 | - $msg = array('zbug_champ_hors_critere', array( |
|
| 2682 | - 'champ' => zbug_presenter_champ($p), |
|
| 2683 | - 'critere' => 'tri' |
|
| 2684 | - )); |
|
| 2685 | - erreur_squelette($msg, $p); |
|
| 2686 | - $p->code = "''"; |
|
| 2678 | + // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 2679 | + // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 2680 | + if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 2681 | + $msg = array('zbug_champ_hors_critere', array( |
|
| 2682 | + 'champ' => zbug_presenter_champ($p), |
|
| 2683 | + 'critere' => 'tri' |
|
| 2684 | + )); |
|
| 2685 | + erreur_squelette($msg, $p); |
|
| 2686 | + $p->code = "''"; |
|
| 2687 | 2687 | |
| 2688 | - return $p; |
|
| 2689 | - } |
|
| 2688 | + return $p; |
|
| 2689 | + } |
|
| 2690 | 2690 | |
| 2691 | - $_champ = interprete_argument_balise(1, $p); |
|
| 2692 | - // si pas de champ, renvoyer le critere de tri utilise |
|
| 2693 | - if (!$_champ) { |
|
| 2694 | - $p->code = $boucle->modificateur['tri_champ']; |
|
| 2691 | + $_champ = interprete_argument_balise(1, $p); |
|
| 2692 | + // si pas de champ, renvoyer le critere de tri utilise |
|
| 2693 | + if (!$_champ) { |
|
| 2694 | + $p->code = $boucle->modificateur['tri_champ']; |
|
| 2695 | 2695 | |
| 2696 | - return $p; |
|
| 2697 | - } |
|
| 2698 | - // forcer la jointure si besoin, et si le champ est statique |
|
| 2699 | - if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { |
|
| 2700 | - index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2701 | - } |
|
| 2696 | + return $p; |
|
| 2697 | + } |
|
| 2698 | + // forcer la jointure si besoin, et si le champ est statique |
|
| 2699 | + if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { |
|
| 2700 | + index_pile($b, $m[1], $p->boucles, '', null, true, false); |
|
| 2701 | + } |
|
| 2702 | 2702 | |
| 2703 | - $_libelle = interprete_argument_balise(2, $p); |
|
| 2704 | - $_libelle = $_libelle ? $_libelle : $_champ; |
|
| 2703 | + $_libelle = interprete_argument_balise(2, $p); |
|
| 2704 | + $_libelle = $_libelle ? $_libelle : $_champ; |
|
| 2705 | 2705 | |
| 2706 | - $_class = interprete_argument_balise(3, $p); |
|
| 2707 | - // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
|
| 2708 | - // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
|
| 2709 | - $_issens = "in_array($_champ,array('>','<'))"; |
|
| 2710 | - $_sens = "(strpos('< >',$_champ)-1)"; |
|
| 2706 | + $_class = interprete_argument_balise(3, $p); |
|
| 2707 | + // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
|
| 2708 | + // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
|
| 2709 | + $_issens = "in_array($_champ,array('>','<'))"; |
|
| 2710 | + $_sens = "(strpos('< >',$_champ)-1)"; |
|
| 2711 | 2711 | |
| 2712 | - $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom']; |
|
| 2713 | - $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
|
| 2714 | - $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; |
|
| 2715 | - $_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; |
|
| 2712 | + $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom']; |
|
| 2713 | + $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
|
| 2714 | + $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; |
|
| 2715 | + $_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; |
|
| 2716 | 2716 | |
| 2717 | - $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")"; |
|
| 2718 | - //$p->code = "''"; |
|
| 2719 | - $p->interdire_scripts = false; |
|
| 2717 | + $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")"; |
|
| 2718 | + //$p->code = "''"; |
|
| 2719 | + $p->interdire_scripts = false; |
|
| 2720 | 2720 | |
| 2721 | - return $p; |
|
| 2721 | + return $p; |
|
| 2722 | 2722 | } |
| 2723 | 2723 | |
| 2724 | 2724 | |
@@ -2739,22 +2739,22 @@ discard block |
||
| 2739 | 2739 | * Pile complétée par le code à générer |
| 2740 | 2740 | */ |
| 2741 | 2741 | function balise_SAUTER_dist($p) { |
| 2742 | - $id_boucle = $p->id_boucle; |
|
| 2742 | + $id_boucle = $p->id_boucle; |
|
| 2743 | 2743 | |
| 2744 | - if (empty($p->boucles[$id_boucle])) { |
|
| 2745 | - $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); |
|
| 2746 | - erreur_squelette($msg, $p); |
|
| 2747 | - } else { |
|
| 2748 | - $boucle = $p->boucles[$id_boucle]; |
|
| 2749 | - $_saut = interprete_argument_balise(1, $p); |
|
| 2750 | - $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2751 | - $_total = "\$Numrows['$id_boucle']['total']"; |
|
| 2744 | + if (empty($p->boucles[$id_boucle])) { |
|
| 2745 | + $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); |
|
| 2746 | + erreur_squelette($msg, $p); |
|
| 2747 | + } else { |
|
| 2748 | + $boucle = $p->boucles[$id_boucle]; |
|
| 2749 | + $_saut = interprete_argument_balise(1, $p); |
|
| 2750 | + $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 2751 | + $_total = "\$Numrows['$id_boucle']['total']"; |
|
| 2752 | 2752 | |
| 2753 | - $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2754 | - } |
|
| 2755 | - $p->interdire_scripts = false; |
|
| 2753 | + $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 2754 | + } |
|
| 2755 | + $p->interdire_scripts = false; |
|
| 2756 | 2756 | |
| 2757 | - return $p; |
|
| 2757 | + return $p; |
|
| 2758 | 2758 | } |
| 2759 | 2759 | |
| 2760 | 2760 | |
@@ -2776,22 +2776,22 @@ discard block |
||
| 2776 | 2776 | * Pile complétée par le code à générer |
| 2777 | 2777 | */ |
| 2778 | 2778 | function balise_PUBLIE_dist($p) { |
| 2779 | - if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2780 | - $_type = _q($p->type_requete); |
|
| 2781 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2782 | - } else { |
|
| 2783 | - $_id = interprete_argument_balise(2, $p); |
|
| 2784 | - } |
|
| 2779 | + if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 2780 | + $_type = _q($p->type_requete); |
|
| 2781 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 2782 | + } else { |
|
| 2783 | + $_id = interprete_argument_balise(2, $p); |
|
| 2784 | + } |
|
| 2785 | 2785 | |
| 2786 | - $connect = ''; |
|
| 2787 | - if (isset($p->boucles[$p->id_boucle])) { |
|
| 2788 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2789 | - } |
|
| 2786 | + $connect = ''; |
|
| 2787 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 2788 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 2789 | + } |
|
| 2790 | 2790 | |
| 2791 | - $p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')"; |
|
| 2792 | - $p->interdire_scripts = false; |
|
| 2791 | + $p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')"; |
|
| 2792 | + $p->interdire_scripts = false; |
|
| 2793 | 2793 | |
| 2794 | - return $p; |
|
| 2794 | + return $p; |
|
| 2795 | 2795 | } |
| 2796 | 2796 | |
| 2797 | 2797 | /** |
@@ -2820,12 +2820,12 @@ discard block |
||
| 2820 | 2820 | * Pile complétée par le code à générer |
| 2821 | 2821 | */ |
| 2822 | 2822 | function balise_PRODUIRE_dist($p) { |
| 2823 | - $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2824 | - $p = $balise_inclure($p); |
|
| 2823 | + $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 2824 | + $p = $balise_inclure($p); |
|
| 2825 | 2825 | |
| 2826 | - $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2826 | + $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 2827 | 2827 | |
| 2828 | - return $p; |
|
| 2828 | + return $p; |
|
| 2829 | 2829 | } |
| 2830 | 2830 | |
| 2831 | 2831 | /** |
@@ -2844,13 +2844,13 @@ discard block |
||
| 2844 | 2844 | * Pile complétée par le code à générer |
| 2845 | 2845 | */ |
| 2846 | 2846 | function balise_LARGEUR_ECRAN_dist($p) { |
| 2847 | - $_class = interprete_argument_balise(1, $p); |
|
| 2848 | - if (!$_class) { |
|
| 2849 | - $_class = 'null'; |
|
| 2850 | - } |
|
| 2851 | - $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2847 | + $_class = interprete_argument_balise(1, $p); |
|
| 2848 | + if (!$_class) { |
|
| 2849 | + $_class = 'null'; |
|
| 2850 | + } |
|
| 2851 | + $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 2852 | 2852 | |
| 2853 | - return $p; |
|
| 2853 | + return $p; |
|
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | 2856 | |
@@ -2866,14 +2866,14 @@ discard block |
||
| 2866 | 2866 | * Pile complétée par le code à générer |
| 2867 | 2867 | **/ |
| 2868 | 2868 | function balise_CONST_dist($p) { |
| 2869 | - $_const = interprete_argument_balise(1, $p); |
|
| 2870 | - if (!strlen($_const)) { |
|
| 2871 | - $p->code = "''"; |
|
| 2872 | - } |
|
| 2873 | - else { |
|
| 2874 | - $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2875 | - } |
|
| 2876 | - $p->interdire_scripts = false; |
|
| 2877 | - |
|
| 2878 | - return $p; |
|
| 2869 | + $_const = interprete_argument_balise(1, $p); |
|
| 2870 | + if (!strlen($_const)) { |
|
| 2871 | + $p->code = "''"; |
|
| 2872 | + } |
|
| 2873 | + else { |
|
| 2874 | + $p->code = "(defined($_const)?constant($_const):'')"; |
|
| 2875 | + } |
|
| 2876 | + $p->interdire_scripts = false; |
|
| 2877 | + |
|
| 2878 | + return $p; |
|
| 2879 | 2879 | } |
@@ -11,68 +11,68 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | # Les information d'une rubrique selectionnee dans le mini navigateur |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@inc_informer_dist |
| 20 | 20 | function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') { |
| 21 | - include_spip('inc/texte'); |
|
| 22 | - $titre = $descriptif = ''; |
|
| 23 | - if ($type == "rubrique") { |
|
| 24 | - $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id)); |
|
| 25 | - if ($row) { |
|
| 26 | - $titre = typo($row["titre"]); |
|
| 27 | - $descriptif = propre($row["descriptif"]); |
|
| 28 | - } else { |
|
| 29 | - $titre = _T('info_racine_site'); |
|
| 30 | - } |
|
| 31 | - } |
|
| 21 | + include_spip('inc/texte'); |
|
| 22 | + $titre = $descriptif = ''; |
|
| 23 | + if ($type == "rubrique") { |
|
| 24 | + $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id)); |
|
| 25 | + if ($row) { |
|
| 26 | + $titre = typo($row["titre"]); |
|
| 27 | + $descriptif = propre($row["descriptif"]); |
|
| 28 | + } else { |
|
| 29 | + $titre = _T('info_racine_site'); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - $res = ''; |
|
| 34 | - if ($type == "rubrique" and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) { |
|
| 35 | - if ($GLOBALS['meta']['image_process'] != "non") { |
|
| 36 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 37 | - if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 38 | - list($fid, $dir, $nom, $format) = $res; |
|
| 39 | - include_spip('inc/filtres_images_mini'); |
|
| 40 | - $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 41 | - if ($res) { |
|
| 42 | - $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . "; margin-" . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 33 | + $res = ''; |
|
| 34 | + if ($type == "rubrique" and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) { |
|
| 35 | + if ($GLOBALS['meta']['image_process'] != "non") { |
|
| 36 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 37 | + if ($res = $chercher_logo($id, 'id_rubrique', 'on')) { |
|
| 38 | + list($fid, $dir, $nom, $format) = $res; |
|
| 39 | + include_spip('inc/filtres_images_mini'); |
|
| 40 | + $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
|
| 41 | + if ($res) { |
|
| 42 | + $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . "; margin-" . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 49 | - $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 50 | - $id = intval($id); |
|
| 48 | + $rac = spip_htmlentities($rac, ENT_QUOTES); |
|
| 49 | + $do = spip_htmlentities($do, ENT_QUOTES); |
|
| 50 | + $id = intval($id); |
|
| 51 | 51 | |
| 52 | 52 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 53 | 53 | # et l'affichage de son titre dans le bandeau |
| 54 | - $titre = strtr(str_replace("'", "’", |
|
| 55 | - str_replace('"', """, textebrut($titre))), |
|
| 56 | - "\n\r", " "); |
|
| 54 | + $titre = strtr(str_replace("'", "’", |
|
| 55 | + str_replace('"', """, textebrut($titre))), |
|
| 56 | + "\n\r", " "); |
|
| 57 | 57 | |
| 58 | - $js_func = $do . '_selection_titre'; |
|
| 58 | + $js_func = $do . '_selection_titre'; |
|
| 59 | 59 | |
| 60 | - return "<div style='display: none;'>" |
|
| 61 | - . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 62 | - . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 63 | - . entites_html($titre) |
|
| 64 | - . "\" />" |
|
| 65 | - . "</div>" |
|
| 66 | - . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 67 | - . '<div class="informer__item">' |
|
| 68 | - . (!$res ? '' : $res) |
|
| 69 | - . "<p class='informer__titre'><b>" . safehtml($titre) . "</b></p>" |
|
| 70 | - . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . "</div>") |
|
| 71 | - . '</div>' |
|
| 72 | - . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 73 | - . "<input type='submit' class='fondo btn submit' value='" |
|
| 74 | - . _T('bouton_choisir') |
|
| 75 | - . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 76 | - . "</div>" |
|
| 77 | - . "</div>"; |
|
| 60 | + return "<div style='display: none;'>" |
|
| 61 | + . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 62 | + . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 63 | + . entites_html($titre) |
|
| 64 | + . "\" />" |
|
| 65 | + . "</div>" |
|
| 66 | + . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
|
| 67 | + . '<div class="informer__item">' |
|
| 68 | + . (!$res ? '' : $res) |
|
| 69 | + . "<p class='informer__titre'><b>" . safehtml($titre) . "</b></p>" |
|
| 70 | + . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . "</div>") |
|
| 71 | + . '</div>' |
|
| 72 | + . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 73 | + . "<input type='submit' class='fondo btn submit' value='" |
|
| 74 | + . _T('bouton_choisir') |
|
| 75 | + . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
|
| 76 | + . "</div>" |
|
| 77 | + . "</div>"; |
|
| 78 | 78 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | include_spip('inc/texte'); |
| 22 | 22 | $titre = $descriptif = ''; |
| 23 | 23 | if ($type == "rubrique") { |
| 24 | - $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = " . intval($id)); |
|
| 24 | + $row = sql_fetsel("titre, descriptif", "spip_rubriques", "id_rubrique = ".intval($id)); |
|
| 25 | 25 | if ($row) { |
| 26 | 26 | $titre = typo($row["titre"]); |
| 27 | 27 | $descriptif = propre($row["descriptif"]); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | include_spip('inc/filtres_images_mini'); |
| 40 | 40 | $res = image_reduire("<img src='$fid' alt='' />", 100, 48); |
| 41 | 41 | if ($res) { |
| 42 | - $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . "; margin-" . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>"; |
|
| 42 | + $res = "<div class='informer__media' style='float: ".$GLOBALS['spip_lang_right']."; margin-".$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>"; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | str_replace('"', """, textebrut($titre))), |
| 56 | 56 | "\n\r", " "); |
| 57 | 57 | |
| 58 | - $js_func = $do . '_selection_titre'; |
|
| 58 | + $js_func = $do.'_selection_titre'; |
|
| 59 | 59 | |
| 60 | 60 | return "<div style='display: none;'>" |
| 61 | - . "<input type='text' id='" . $rac . "_sel' value='$id' />" |
|
| 62 | - . "<input type='text' id='" . $rac . "_sel2' value=\"" |
|
| 61 | + . "<input type='text' id='".$rac."_sel' value='$id' />" |
|
| 62 | + . "<input type='text' id='".$rac."_sel2' value=\"" |
|
| 63 | 63 | . entites_html($titre) |
| 64 | 64 | . "\" />" |
| 65 | 65 | . "</div>" |
| 66 | 66 | . "<div class='informer' style='padding: 5px; border-top: 0px;'>" |
| 67 | 67 | . '<div class="informer__item">' |
| 68 | 68 | . (!$res ? '' : $res) |
| 69 | - . "<p class='informer__titre'><b>" . safehtml($titre) . "</b></p>" |
|
| 70 | - . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . "</div>") |
|
| 69 | + . "<p class='informer__titre'><b>".safehtml($titre)."</b></p>" |
|
| 70 | + . (!$descriptif ? '' : "<div class='informer__descriptif'>".safehtml($descriptif)."</div>") |
|
| 71 | 71 | . '</div>' |
| 72 | - . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 72 | + . "<div class='informer__action' style='clear:both; text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 73 | 73 | . "<input type='submit' class='fondo btn submit' value='" |
| 74 | 74 | . _T('bouton_choisir') |
| 75 | 75 | . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/texte'); |
@@ -19,98 +19,98 @@ discard block |
||
| 19 | 19 | // https://code.spip.net/@inc_plonger_dist |
| 20 | 20 | function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $exclu = 0, $do = 'aff') { |
| 21 | 21 | |
| 22 | - if ($list) { |
|
| 23 | - $id_rubrique = $list[$col - 1]; |
|
| 24 | - } |
|
| 22 | + if ($list) { |
|
| 23 | + $id_rubrique = $list[$col - 1]; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $ret = ''; |
|
| 26 | + $ret = ''; |
|
| 27 | 27 | |
| 28 | - # recherche les filles et petites-filles de la rubrique donnee |
|
| 29 | - # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 30 | - # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 31 | - # racine... sauf vers elle-meme ou sa propre branche) |
|
| 32 | - $ordre = array(); |
|
| 33 | - $rub = array(); |
|
| 28 | + # recherche les filles et petites-filles de la rubrique donnee |
|
| 29 | + # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 30 | + # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 31 | + # racine... sauf vers elle-meme ou sa propre branche) |
|
| 32 | + $ordre = array(); |
|
| 33 | + $rub = array(); |
|
| 34 | 34 | |
| 35 | - $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant", |
|
| 36 | - "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)", |
|
| 37 | - "rub1.id_parent = " . sql_quote($id_rubrique) . " |
|
| 35 | + $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant", |
|
| 36 | + "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)", |
|
| 37 | + "rub1.id_parent = " . sql_quote($id_rubrique) . " |
|
| 38 | 38 | AND rub1.id_rubrique!=" . sql_quote($exclu) . " |
| 39 | 39 | AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu) . ")", "", "0+rub1.titre,rub1.titre"); |
| 40 | 40 | |
| 41 | - while ($row = sql_fetch($res)) { |
|
| 42 | - if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 43 | - $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 44 | - if ($row['id_parent'] == $id_rubrique) { |
|
| 45 | - $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 46 | - if ($row['langue_choisie'] != 'oui') { |
|
| 47 | - $t .= ' <small title="' |
|
| 48 | - . traduire_nom_langue($row['lang']) |
|
| 49 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 50 | - } |
|
| 51 | - $ordre[$row['id_rubrique']] = $t; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 56 | - if ($ordre) { |
|
| 57 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 58 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 59 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 41 | + while ($row = sql_fetch($res)) { |
|
| 42 | + if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 43 | + $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 44 | + if ($row['id_parent'] == $id_rubrique) { |
|
| 45 | + $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 46 | + if ($row['langue_choisie'] != 'oui') { |
|
| 47 | + $t .= ' <small title="' |
|
| 48 | + . traduire_nom_langue($row['lang']) |
|
| 49 | + . '">[' . $row['lang'] . ']</small>'; |
|
| 50 | + } |
|
| 51 | + $ordre[$row['id_rubrique']] = $t; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 56 | + if ($ordre) { |
|
| 57 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 58 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 59 | + $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 60 | 60 | |
| 61 | - foreach ($ordre as $id => $titrebrut) { |
|
| 62 | - $titre = supprimer_numero($titrebrut); |
|
| 61 | + foreach ($ordre as $id => $titrebrut) { |
|
| 62 | + $titre = supprimer_numero($titrebrut); |
|
| 63 | 63 | |
| 64 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : "petit-secteur"); |
|
| 65 | - if (isset($rub[$id]["enfants"])) { |
|
| 66 | - $classe2 = " class='rub-ouverte'"; |
|
| 67 | - $url = "\nhref='$rec&id=$id'"; |
|
| 68 | - } else { |
|
| 69 | - $classe2 = $url = ''; |
|
| 70 | - $url = "\nhref='javascript:void(0)'"; |
|
| 71 | - } |
|
| 64 | + $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : "petit-secteur"); |
|
| 65 | + if (isset($rub[$id]["enfants"])) { |
|
| 66 | + $classe2 = " class='rub-ouverte'"; |
|
| 67 | + $url = "\nhref='$rec&id=$id'"; |
|
| 68 | + } else { |
|
| 69 | + $classe2 = $url = ''; |
|
| 70 | + $url = "\nhref='javascript:void(0)'"; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $js_func = $do . '_selection_titre'; |
|
| 74 | - $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 75 | - . (!is_array($list) ? ' false' |
|
| 76 | - : "aff_selection_provisoire($id,$args)") |
|
| 73 | + $js_func = $do . '_selection_titre'; |
|
| 74 | + $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 75 | + . (!is_array($list) ? ' false' |
|
| 76 | + : "aff_selection_provisoire($id,$args)") |
|
| 77 | 77 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 78 | 78 | # et l'affichage de son titre dans le bandeau |
| 79 | - . "\"\nondblclick=\"" |
|
| 80 | - . "$js_func(this." |
|
| 81 | - . "firstChild.nodeValue," |
|
| 82 | - . $id |
|
| 83 | - . ",'selection_rubrique','id_parent');" |
|
| 84 | - . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 85 | - . "\""; |
|
| 79 | + . "\"\nondblclick=\"" |
|
| 80 | + . "$js_func(this." |
|
| 81 | + . "firstChild.nodeValue," |
|
| 82 | + . $id |
|
| 83 | + . ",'selection_rubrique','id_parent');" |
|
| 84 | + . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 85 | + . "\""; |
|
| 86 | 86 | |
| 87 | - $ret .= "<div class='" |
|
| 88 | - . (($id == $next) ? "item on" : "item") |
|
| 89 | - . "'><div class='" |
|
| 90 | - . $classe1 |
|
| 91 | - . "'><div$classe2><a" |
|
| 92 | - . $url |
|
| 93 | - . $click |
|
| 94 | - . ">" |
|
| 95 | - . $titre |
|
| 96 | - . "</a></div></div></div>"; |
|
| 97 | - } |
|
| 98 | - } |
|
| 87 | + $ret .= "<div class='" |
|
| 88 | + . (($id == $next) ? "item on" : "item") |
|
| 89 | + . "'><div class='" |
|
| 90 | + . $classe1 |
|
| 91 | + . "'><div$classe2><a" |
|
| 92 | + . $url |
|
| 93 | + . $click |
|
| 94 | + . ">" |
|
| 95 | + . $titre |
|
| 96 | + . "</a></div></div></div>"; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - $idom2 = $idom . "_col_" . ($col + 1); |
|
| 101 | - $left = ($col * 150); |
|
| 100 | + $idom2 = $idom . "_col_" . ($col + 1); |
|
| 101 | + $left = ($col * 150); |
|
| 102 | 102 | |
| 103 | - return http_img_pack("loader.svg", "", |
|
| 104 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": " |
|
| 105 | - . ($left - 30) |
|
| 106 | - . "px; top: 2px; z-index: 2;' id='img_$idom2'") |
|
| 107 | - . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": " |
|
| 108 | - . ($left - 150) |
|
| 109 | - . "px;'>" |
|
| 110 | - . $ret |
|
| 111 | - . "\n</div>\n<div id='$idom2'>" |
|
| 112 | - . ($next |
|
| 113 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 114 | - : "") |
|
| 115 | - . "\n</div>"; |
|
| 103 | + return http_img_pack("loader.svg", "", |
|
| 104 | + "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": " |
|
| 105 | + . ($left - 30) |
|
| 106 | + . "px; top: 2px; z-index: 2;' id='img_$idom2'") |
|
| 107 | + . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": " |
|
| 108 | + . ($left - 150) |
|
| 109 | + . "px;'>" |
|
| 110 | + . $ret |
|
| 111 | + . "\n</div>\n<div id='$idom2'>" |
|
| 112 | + . ($next |
|
| 113 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 114 | + : "") |
|
| 115 | + . "\n</div>"; |
|
| 116 | 116 | } |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $res = sql_select("rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant", |
| 36 | 36 | "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)", |
| 37 | - "rub1.id_parent = " . sql_quote($id_rubrique) . " |
|
| 38 | - AND rub1.id_rubrique!=" . sql_quote($exclu) . " |
|
| 39 | - AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu) . ")", "", "0+rub1.titre,rub1.titre"); |
|
| 37 | + "rub1.id_parent = ".sql_quote($id_rubrique)." |
|
| 38 | + AND rub1.id_rubrique!=" . sql_quote($exclu)." |
|
| 39 | + AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=" . sql_quote($exclu).")", "", "0+rub1.titre,rub1.titre"); |
|
| 40 | 40 | |
| 41 | 41 | while ($row = sql_fetch($res)) { |
| 42 | 42 | if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | if ($row['langue_choisie'] != 'oui') { |
| 47 | 47 | $t .= ' <small title="' |
| 48 | 48 | . traduire_nom_langue($row['lang']) |
| 49 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 49 | + . '">['.$row['lang'].']</small>'; |
|
| 50 | 50 | } |
| 51 | 51 | $ordre[$row['id_rubrique']] = $t; |
| 52 | 52 | } |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | $next = isset($list[$col]) ? $list[$col] : 0; |
| 56 | 56 | if ($ordre) { |
| 57 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 57 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1)); |
|
| 58 | 58 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 59 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 59 | + $args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event"; |
|
| 60 | 60 | |
| 61 | 61 | foreach ($ordre as $id => $titrebrut) { |
| 62 | 62 | $titre = supprimer_numero($titrebrut); |
| 63 | 63 | |
| 64 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : "petit-secteur"); |
|
| 64 | + $classe1 = 'petit-item '.($id_rubrique ? 'petite-rubrique' : "petit-secteur"); |
|
| 65 | 65 | if (isset($rub[$id]["enfants"])) { |
| 66 | 66 | $classe2 = " class='rub-ouverte'"; |
| 67 | 67 | $url = "\nhref='$rec&id=$id'"; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $url = "\nhref='javascript:void(0)'"; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $js_func = $do . '_selection_titre'; |
|
| 73 | + $js_func = $do.'_selection_titre'; |
|
| 74 | 74 | $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
| 75 | 75 | . (!is_array($list) ? ' false' |
| 76 | 76 | : "aff_selection_provisoire($id,$args)") |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $idom2 = $idom . "_col_" . ($col + 1); |
|
| 100 | + $idom2 = $idom."_col_".($col + 1); |
|
| 101 | 101 | $left = ($col * 150); |
| 102 | 102 | |
| 103 | 103 | return http_img_pack("loader.svg", "", |
| 104 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ": " |
|
| 104 | + "class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].": " |
|
| 105 | 105 | . ($left - 30) |
| 106 | 106 | . "px; top: 2px; z-index: 2;' id='img_$idom2'") |
| 107 | - . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ": " |
|
| 107 | + . "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].": " |
|
| 108 | 108 | . ($left - 150) |
| 109 | 109 | . "px;'>" |
| 110 | 110 | . $ret |
@@ -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'); |
@@ -40,27 +40,27 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function parametres_css_prive() { |
| 42 | 42 | |
| 43 | - $args = array(); |
|
| 44 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 45 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 46 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 47 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 48 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 49 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 43 | + $args = array(); |
|
| 44 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 45 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 46 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 47 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 48 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 49 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 50 | 50 | |
| 51 | - $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 52 | - ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 53 | - : 9; |
|
| 51 | + $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 52 | + ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 53 | + : 9; |
|
| 54 | 54 | |
| 55 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 56 | - parse_str($couleurs($c), $c); |
|
| 57 | - $args = array_merge($args, $c); |
|
| 55 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 56 | + parse_str($couleurs($c), $c); |
|
| 57 | + $args = array_merge($args, $c); |
|
| 58 | 58 | |
| 59 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 60 | - $args['var_mode'] = 'recalcul'; |
|
| 61 | - } |
|
| 59 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 60 | + $args['var_mode'] = 'recalcul'; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return http_build_query($args); |
|
| 63 | + return http_build_query($args); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
@@ -83,79 +83,79 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function chercher_rubrique( |
| 86 | - $titre, |
|
| 87 | - $id_objet, |
|
| 88 | - $id_parent, |
|
| 89 | - $objet, |
|
| 90 | - $id_secteur, |
|
| 91 | - $restreint, |
|
| 92 | - $actionable = false, |
|
| 93 | - $retour_sans_cadre = false |
|
| 86 | + $titre, |
|
| 87 | + $id_objet, |
|
| 88 | + $id_parent, |
|
| 89 | + $objet, |
|
| 90 | + $id_secteur, |
|
| 91 | + $restreint, |
|
| 92 | + $actionable = false, |
|
| 93 | + $retour_sans_cadre = false |
|
| 94 | 94 | ) { |
| 95 | 95 | |
| 96 | - include_spip('inc/autoriser'); |
|
| 97 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 98 | - return ""; |
|
| 99 | - } |
|
| 100 | - if (!sql_countsel('spip_rubriques')) { |
|
| 101 | - return ""; |
|
| 102 | - } |
|
| 103 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 104 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 105 | - |
|
| 106 | - if ($id_parent == 0) { |
|
| 107 | - $logo = "racine-24.png"; |
|
| 108 | - } elseif ($id_secteur == $id_parent) { |
|
| 109 | - $logo = "secteur-24.png"; |
|
| 110 | - } else { |
|
| 111 | - $logo = "rubrique-24.png"; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $confirm = ""; |
|
| 115 | - if ($objet == 'rubrique') { |
|
| 116 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | - // confirmation du deplacement |
|
| 118 | - $contient_breves = sql_countsel('spip_breves', "id_rubrique=" . intval($id_objet)); |
|
| 119 | - |
|
| 120 | - if ($contient_breves > 0) { |
|
| 121 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 122 | - $scb = _T('avis_deplacement_rubrique', |
|
| 123 | - array( |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - )); |
|
| 127 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 128 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 129 | - . $scb . |
|
| 130 | - "</label></div></div>\n"; |
|
| 131 | - } else { |
|
| 132 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - $form .= $confirm; |
|
| 136 | - if ($actionable) { |
|
| 137 | - if (strpos($form, '<select') !== false) { |
|
| 138 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 139 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 140 | - . "</div>"; |
|
| 141 | - } |
|
| 142 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 143 | - if ($action = charger_fonction("editer_$objet", "action", true)) { |
|
| 144 | - $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, |
|
| 145 | - " method='post' class='submit_plongeur'"); |
|
| 146 | - } else { |
|
| 147 | - $form = generer_action_auteur("editer_objet", "$objet/$id_objet", self(), $form, |
|
| 148 | - " method='post' class='submit_plongeur'"); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($retour_sans_cadre) { |
|
| 153 | - return $form; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - include_spip('inc/presentation'); |
|
| 157 | - |
|
| 158 | - return debut_cadre_couleur($logo, true, "", $titre) . $form . fin_cadre_couleur(true); |
|
| 96 | + include_spip('inc/autoriser'); |
|
| 97 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 98 | + return ""; |
|
| 99 | + } |
|
| 100 | + if (!sql_countsel('spip_rubriques')) { |
|
| 101 | + return ""; |
|
| 102 | + } |
|
| 103 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 104 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 105 | + |
|
| 106 | + if ($id_parent == 0) { |
|
| 107 | + $logo = "racine-24.png"; |
|
| 108 | + } elseif ($id_secteur == $id_parent) { |
|
| 109 | + $logo = "secteur-24.png"; |
|
| 110 | + } else { |
|
| 111 | + $logo = "rubrique-24.png"; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $confirm = ""; |
|
| 115 | + if ($objet == 'rubrique') { |
|
| 116 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | + // confirmation du deplacement |
|
| 118 | + $contient_breves = sql_countsel('spip_breves', "id_rubrique=" . intval($id_objet)); |
|
| 119 | + |
|
| 120 | + if ($contient_breves > 0) { |
|
| 121 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 122 | + $scb = _T('avis_deplacement_rubrique', |
|
| 123 | + array( |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + )); |
|
| 127 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 128 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 129 | + . $scb . |
|
| 130 | + "</label></div></div>\n"; |
|
| 131 | + } else { |
|
| 132 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + $form .= $confirm; |
|
| 136 | + if ($actionable) { |
|
| 137 | + if (strpos($form, '<select') !== false) { |
|
| 138 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 139 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 140 | + . "</div>"; |
|
| 141 | + } |
|
| 142 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 143 | + if ($action = charger_fonction("editer_$objet", "action", true)) { |
|
| 144 | + $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, |
|
| 145 | + " method='post' class='submit_plongeur'"); |
|
| 146 | + } else { |
|
| 147 | + $form = generer_action_auteur("editer_objet", "$objet/$id_objet", self(), $form, |
|
| 148 | + " method='post' class='submit_plongeur'"); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($retour_sans_cadre) { |
|
| 153 | + return $form; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + include_spip('inc/presentation'); |
|
| 157 | + |
|
| 158 | + return debut_cadre_couleur($logo, true, "", $titre) . $form . fin_cadre_couleur(true); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -170,21 +170,21 @@ discard block |
||
| 170 | 170 | * @return bool |
| 171 | 171 | */ |
| 172 | 172 | function avoir_visiteurs($past = false, $accepter = true) { |
| 173 | - if ($GLOBALS['meta']["forums_publics"] == 'abo') { |
|
| 174 | - return true; |
|
| 175 | - } |
|
| 176 | - if ($accepter and $GLOBALS['meta']["accepter_visiteurs"] <> 'non') { |
|
| 177 | - return true; |
|
| 178 | - } |
|
| 179 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 180 | - return true; |
|
| 181 | - } |
|
| 182 | - if (!$past) { |
|
| 183 | - return false; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - return sql_countsel('spip_auteurs', |
|
| 187 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 173 | + if ($GLOBALS['meta']["forums_publics"] == 'abo') { |
|
| 174 | + return true; |
|
| 175 | + } |
|
| 176 | + if ($accepter and $GLOBALS['meta']["accepter_visiteurs"] <> 'non') { |
|
| 177 | + return true; |
|
| 178 | + } |
|
| 179 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 180 | + return true; |
|
| 181 | + } |
|
| 182 | + if (!$past) { |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + return sql_countsel('spip_auteurs', |
|
| 187 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 188 | 188 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))"); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -201,18 +201,18 @@ discard block |
||
| 201 | 201 | * @return array |
| 202 | 202 | */ |
| 203 | 203 | function statuts_articles_visibles($statut_auteur) { |
| 204 | - static $auth = array(); |
|
| 205 | - if (!isset($auth[$statut_auteur])) { |
|
| 206 | - $auth[$statut_auteur] = array(); |
|
| 207 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 208 | - foreach ($statuts as $s) { |
|
| 209 | - if (autoriser('voir', 'article', 0, array('statut' => $statut_auteur), array('statut' => $s))) { |
|
| 210 | - $auth[$statut_auteur][] = $s; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - return $auth[$statut_auteur]; |
|
| 204 | + static $auth = array(); |
|
| 205 | + if (!isset($auth[$statut_auteur])) { |
|
| 206 | + $auth[$statut_auteur] = array(); |
|
| 207 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 208 | + foreach ($statuts as $s) { |
|
| 209 | + if (autoriser('voir', 'article', 0, array('statut' => $statut_auteur), array('statut' => $s))) { |
|
| 210 | + $auth[$statut_auteur][] = $s; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + return $auth[$statut_auteur]; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -226,38 +226,38 @@ discard block |
||
| 226 | 226 | * @return string |
| 227 | 227 | */ |
| 228 | 228 | function traduire_statut_auteur($statut, $attente = "") { |
| 229 | - $plus = ""; |
|
| 230 | - if ($statut == 'nouveau') { |
|
| 231 | - if ($attente) { |
|
| 232 | - $statut = $attente; |
|
| 233 | - $plus = " (" . _T('info_statut_auteur_a_confirmer') . ")"; |
|
| 234 | - } else { |
|
| 235 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $recom = array( |
|
| 240 | - "info_administrateurs" => _T('item_administrateur_2'), |
|
| 241 | - "info_redacteurs" => _T('intem_redacteur'), |
|
| 242 | - "info_visiteurs" => _T('item_visiteur'), |
|
| 243 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 244 | - ); |
|
| 245 | - if (isset($recom[$statut])) { |
|
| 246 | - return $recom[$statut] . $plus; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - // retrouver directement par le statut sinon |
|
| 250 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 251 | - if (isset($recom[$t])) { |
|
| 252 | - return $recom[$t] . $plus; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return _T($t) . $plus; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 259 | - // c'est toujours plus informatif que rien du tout |
|
| 260 | - return $statut; |
|
| 229 | + $plus = ""; |
|
| 230 | + if ($statut == 'nouveau') { |
|
| 231 | + if ($attente) { |
|
| 232 | + $statut = $attente; |
|
| 233 | + $plus = " (" . _T('info_statut_auteur_a_confirmer') . ")"; |
|
| 234 | + } else { |
|
| 235 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $recom = array( |
|
| 240 | + "info_administrateurs" => _T('item_administrateur_2'), |
|
| 241 | + "info_redacteurs" => _T('intem_redacteur'), |
|
| 242 | + "info_visiteurs" => _T('item_visiteur'), |
|
| 243 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 244 | + ); |
|
| 245 | + if (isset($recom[$statut])) { |
|
| 246 | + return $recom[$statut] . $plus; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + // retrouver directement par le statut sinon |
|
| 250 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 251 | + if (isset($recom[$t])) { |
|
| 252 | + return $recom[$t] . $plus; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return _T($t) . $plus; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 259 | + // c'est toujours plus informatif que rien du tout |
|
| 260 | + return $statut; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -268,28 +268,28 @@ discard block |
||
| 268 | 268 | * @return string |
| 269 | 269 | */ |
| 270 | 270 | function afficher_qui_edite($id_objet, $objet) { |
| 271 | - static $qui = array(); |
|
| 272 | - if (isset($qui[$objet][$id_objet])) { |
|
| 273 | - return $qui[$objet][$id_objet]; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 277 | - return $qui[$objet][$id_objet] = ''; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - include_spip('inc/drapeau_edition'); |
|
| 281 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 282 | - if (!$modif) { |
|
| 283 | - return $qui[$objet][$id_objet] = ''; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - include_spip('base/objets'); |
|
| 287 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 288 | - if (isset($infos['texte_signale_edition'])) { |
|
| 289 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 271 | + static $qui = array(); |
|
| 272 | + if (isset($qui[$objet][$id_objet])) { |
|
| 273 | + return $qui[$objet][$id_objet]; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 277 | + return $qui[$objet][$id_objet] = ''; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + include_spip('inc/drapeau_edition'); |
|
| 281 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 282 | + if (!$modif) { |
|
| 283 | + return $qui[$objet][$id_objet] = ''; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + include_spip('base/objets'); |
|
| 287 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 288 | + if (isset($infos['texte_signale_edition'])) { |
|
| 289 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -307,57 +307,57 @@ discard block |
||
| 307 | 307 | * @return array |
| 308 | 308 | */ |
| 309 | 309 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true) { |
| 310 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 311 | - define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle"); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - switch ($quoi) { |
|
| 315 | - case "redacteurs": |
|
| 316 | - $statut = AUTEURS_MIN_REDAC; |
|
| 317 | - $statut = explode(',', $statut); |
|
| 318 | - if ($en_base) { |
|
| 319 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 320 | - $retire = array_diff($statut, $check); |
|
| 321 | - $statut = array_diff($statut, $retire); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - return array_unique($statut); |
|
| 325 | - break; |
|
| 326 | - case "visiteurs": |
|
| 327 | - $statut = array(); |
|
| 328 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 329 | - $exclus = explode(',', $exclus); |
|
| 330 | - if (!$en_base) { |
|
| 331 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 332 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 333 | - } |
|
| 334 | - $s_complement = array_column( |
|
| 335 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 336 | - 'statut' |
|
| 337 | - ); |
|
| 338 | - |
|
| 339 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 340 | - break; |
|
| 341 | - default: |
|
| 342 | - case "tous": |
|
| 343 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 344 | - $s_complement = array_column( |
|
| 345 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 346 | - 'statut' |
|
| 347 | - ); |
|
| 348 | - $statut = array_merge($statut, $s_complement); |
|
| 349 | - if ($en_base) { |
|
| 350 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 351 | - $retire = array_diff($statut, $check); |
|
| 352 | - $statut = array_diff($statut, $retire); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - return array_unique($statut); |
|
| 356 | - break; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - // on arrive jamais ici |
|
| 360 | - return array_values($GLOBALS['liste_des_statuts']); |
|
| 310 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 311 | + define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle"); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + switch ($quoi) { |
|
| 315 | + case "redacteurs": |
|
| 316 | + $statut = AUTEURS_MIN_REDAC; |
|
| 317 | + $statut = explode(',', $statut); |
|
| 318 | + if ($en_base) { |
|
| 319 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 320 | + $retire = array_diff($statut, $check); |
|
| 321 | + $statut = array_diff($statut, $retire); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + return array_unique($statut); |
|
| 325 | + break; |
|
| 326 | + case "visiteurs": |
|
| 327 | + $statut = array(); |
|
| 328 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 329 | + $exclus = explode(',', $exclus); |
|
| 330 | + if (!$en_base) { |
|
| 331 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 332 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 333 | + } |
|
| 334 | + $s_complement = array_column( |
|
| 335 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 336 | + 'statut' |
|
| 337 | + ); |
|
| 338 | + |
|
| 339 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 340 | + break; |
|
| 341 | + default: |
|
| 342 | + case "tous": |
|
| 343 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 344 | + $s_complement = array_column( |
|
| 345 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 346 | + 'statut' |
|
| 347 | + ); |
|
| 348 | + $statut = array_merge($statut, $s_complement); |
|
| 349 | + if ($en_base) { |
|
| 350 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 351 | + $retire = array_diff($statut, $check); |
|
| 352 | + $statut = array_diff($statut, $retire); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + return array_unique($statut); |
|
| 356 | + break; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + // on arrive jamais ici |
|
| 360 | + return array_values($GLOBALS['liste_des_statuts']); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -373,28 +373,28 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 375 | 375 | |
| 376 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 377 | - $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 378 | - ? '' |
|
| 379 | - : (" AND " . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 380 | - |
|
| 381 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 382 | - if ($objet == 'rubrique') { |
|
| 383 | - $id_rubrique = 0; |
|
| 384 | - } else { |
|
| 385 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 389 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 390 | - $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 391 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 392 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - return $id_rubrique; |
|
| 376 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 377 | + $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 378 | + ? '' |
|
| 379 | + : (" AND " . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 380 | + |
|
| 381 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 382 | + if ($objet == 'rubrique') { |
|
| 383 | + $id_rubrique = 0; |
|
| 384 | + } else { |
|
| 385 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 389 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 390 | + $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 391 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 392 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + return $id_rubrique; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | * @return string |
| 406 | 406 | */ |
| 407 | 407 | function lien_article_virtuel($virtuel) { |
| 408 | - include_spip('inc/lien'); |
|
| 409 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 410 | - return ''; |
|
| 411 | - } |
|
| 408 | + include_spip('inc/lien'); |
|
| 409 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 410 | + return ''; |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | - return propre("[->" . $virtuel . "]"); |
|
| 413 | + return propre("[->" . $virtuel . "]"); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
@@ -433,12 +433,12 @@ discard block |
||
| 433 | 433 | * Code HTML du lien |
| 434 | 434 | */ |
| 435 | 435 | function bouton_spip_rss($op, $args = array(), $lang = '', $title = 'RSS') { |
| 436 | - include_spip('inc/acces'); |
|
| 437 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 438 | - $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 439 | - $url = generer_url_public('rss', $args); |
|
| 436 | + include_spip('inc/acces'); |
|
| 437 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 438 | + $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 439 | + $url = generer_url_public('rss', $args); |
|
| 440 | 440 | |
| 441 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 441 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
@@ -450,70 +450,70 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | function alertes_auteur($id_auteur) { |
| 452 | 452 | |
| 453 | - $alertes = array(); |
|
| 454 | - |
|
| 455 | - if (isset($GLOBALS['meta']['message_crash_tables']) |
|
| 456 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 457 | - ) { |
|
| 458 | - include_spip('genie/maintenance'); |
|
| 459 | - if ($msg = message_crash_tables()) { |
|
| 460 | - $alertes[] = $msg; |
|
| 461 | - } |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - if (isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 465 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 466 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 467 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 468 | - ) { |
|
| 469 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 470 | - $alertes[] = _T('plugins_erreur', array('plugins' => $msg)); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 474 | - if ($a |
|
| 475 | - and is_array($a = unserialize($a)) |
|
| 476 | - and count($a) |
|
| 477 | - ) { |
|
| 478 | - $update = false; |
|
| 479 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 480 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 481 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 482 | - $update = true; |
|
| 483 | - } |
|
| 484 | - if (isset($a[''])) { |
|
| 485 | - $alertes = array_merge($alertes, $a['']); |
|
| 486 | - unset($a['']); |
|
| 487 | - $update = true; |
|
| 488 | - } |
|
| 489 | - if ($update) { |
|
| 490 | - ecrire_meta("message_alertes_auteurs", serialize($a)); |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - if (isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 495 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 496 | - ) { |
|
| 497 | - include_spip('inc/plugin'); |
|
| 498 | - $alertes[] = plugin_donne_erreurs(); |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - $alertes = pipeline( |
|
| 502 | - 'alertes_auteur', |
|
| 503 | - array( |
|
| 504 | - 'args' => array( |
|
| 505 | - 'id_auteur' => $id_auteur, |
|
| 506 | - 'exec' => _request('exec'), |
|
| 507 | - ), |
|
| 508 | - 'data' => $alertes |
|
| 509 | - ) |
|
| 510 | - ); |
|
| 511 | - |
|
| 512 | - if ($alertes = array_filter($alertes)) { |
|
| 513 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 514 | - join(' | ', $alertes) |
|
| 515 | - . "</div></div>"; |
|
| 516 | - } |
|
| 453 | + $alertes = array(); |
|
| 454 | + |
|
| 455 | + if (isset($GLOBALS['meta']['message_crash_tables']) |
|
| 456 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 457 | + ) { |
|
| 458 | + include_spip('genie/maintenance'); |
|
| 459 | + if ($msg = message_crash_tables()) { |
|
| 460 | + $alertes[] = $msg; |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + if (isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 465 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 466 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 467 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 468 | + ) { |
|
| 469 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 470 | + $alertes[] = _T('plugins_erreur', array('plugins' => $msg)); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 474 | + if ($a |
|
| 475 | + and is_array($a = unserialize($a)) |
|
| 476 | + and count($a) |
|
| 477 | + ) { |
|
| 478 | + $update = false; |
|
| 479 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 480 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 481 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 482 | + $update = true; |
|
| 483 | + } |
|
| 484 | + if (isset($a[''])) { |
|
| 485 | + $alertes = array_merge($alertes, $a['']); |
|
| 486 | + unset($a['']); |
|
| 487 | + $update = true; |
|
| 488 | + } |
|
| 489 | + if ($update) { |
|
| 490 | + ecrire_meta("message_alertes_auteurs", serialize($a)); |
|
| 491 | + } |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + if (isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 495 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 496 | + ) { |
|
| 497 | + include_spip('inc/plugin'); |
|
| 498 | + $alertes[] = plugin_donne_erreurs(); |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + $alertes = pipeline( |
|
| 502 | + 'alertes_auteur', |
|
| 503 | + array( |
|
| 504 | + 'args' => array( |
|
| 505 | + 'id_auteur' => $id_auteur, |
|
| 506 | + 'exec' => _request('exec'), |
|
| 507 | + ), |
|
| 508 | + 'data' => $alertes |
|
| 509 | + ) |
|
| 510 | + ); |
|
| 511 | + |
|
| 512 | + if ($alertes = array_filter($alertes)) { |
|
| 513 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 514 | + join(' | ', $alertes) |
|
| 515 | + . "</div></div>"; |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -523,9 +523,9 @@ discard block |
||
| 523 | 523 | * @return string |
| 524 | 524 | */ |
| 525 | 525 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 526 | - include_spip('inc/presenter_enfants'); |
|
| 526 | + include_spip('inc/presenter_enfants'); |
|
| 527 | 527 | |
| 528 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 528 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -543,15 +543,15 @@ discard block |
||
| 543 | 543 | * @return string |
| 544 | 544 | */ |
| 545 | 545 | function afficher_plus_info($lien, $titre = "+", $titre_lien = "") { |
| 546 | - $titre = attribut_html($titre); |
|
| 547 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 548 | - http_img_pack("information-16.png", $titre) . "</a>"; |
|
| 549 | - |
|
| 550 | - if (!$titre_lien) { |
|
| 551 | - return $icone; |
|
| 552 | - } else { |
|
| 553 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 554 | - } |
|
| 546 | + $titre = attribut_html($titre); |
|
| 547 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 548 | + http_img_pack("information-16.png", $titre) . "</a>"; |
|
| 549 | + |
|
| 550 | + if (!$titre_lien) { |
|
| 551 | + return $icone; |
|
| 552 | + } else { |
|
| 553 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 554 | + } |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | |
@@ -570,18 +570,18 @@ discard block |
||
| 570 | 570 | * @return array |
| 571 | 571 | */ |
| 572 | 572 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 573 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 574 | - if (!count($res)) { |
|
| 575 | - return []; |
|
| 576 | - } |
|
| 577 | - $r = reset($res); |
|
| 578 | - if (isset($r['rang_lien'])) { |
|
| 579 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 580 | - asort($l); |
|
| 581 | - $l = array_keys($l); |
|
| 582 | - } else { |
|
| 583 | - $l = array_column($res, $objet_source); |
|
| 584 | - } |
|
| 585 | - return $l; |
|
| 573 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 574 | + if (!count($res)) { |
|
| 575 | + return []; |
|
| 576 | + } |
|
| 577 | + $r = reset($res); |
|
| 578 | + if (isset($r['rang_lien'])) { |
|
| 579 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 580 | + asort($l); |
|
| 581 | + $l = array_keys($l); |
|
| 582 | + } else { |
|
| 583 | + $l = array_column($res, $objet_source); |
|
| 584 | + } |
|
| 585 | + return $l; |
|
| 586 | 586 | } |
| 587 | 587 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | if ($objet == 'rubrique') { |
| 116 | 116 | // si c'est une rubrique-secteur contenant des breves, demander la |
| 117 | 117 | // confirmation du deplacement |
| 118 | - $contient_breves = sql_countsel('spip_breves', "id_rubrique=" . intval($id_objet)); |
|
| 118 | + $contient_breves = sql_countsel('spip_breves', "id_rubrique=".intval($id_objet)); |
|
| 119 | 119 | |
| 120 | 120 | if ($contient_breves > 0) { |
| 121 | 121 | $scb = ($contient_breves > 1 ? 's' : ''); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | )); |
| 127 | 127 | $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
| 128 | 128 | . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
| 129 | - . $scb . |
|
| 129 | + . $scb. |
|
| 130 | 130 | "</label></div></div>\n"; |
| 131 | 131 | } else { |
| 132 | 132 | $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | $form .= $confirm; |
| 136 | 136 | if ($actionable) { |
| 137 | 137 | if (strpos($form, '<select') !== false) { |
| 138 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 139 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 138 | + $form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 139 | + . '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 140 | 140 | . "</div>"; |
| 141 | 141 | } |
| 142 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 142 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form; |
|
| 143 | 143 | if ($action = charger_fonction("editer_$objet", "action", true)) { |
| 144 | 144 | $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, |
| 145 | 145 | " method='post' class='submit_plongeur'"); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | include_spip('inc/presentation'); |
| 157 | 157 | |
| 158 | - return debut_cadre_couleur($logo, true, "", $titre) . $form . fin_cadre_couleur(true); |
|
| 158 | + return debut_cadre_couleur($logo, true, "", $titre).$form.fin_cadre_couleur(true); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | if ($statut == 'nouveau') { |
| 231 | 231 | if ($attente) { |
| 232 | 232 | $statut = $attente; |
| 233 | - $plus = " (" . _T('info_statut_auteur_a_confirmer') . ")"; |
|
| 233 | + $plus = " ("._T('info_statut_auteur_a_confirmer').")"; |
|
| 234 | 234 | } else { |
| 235 | 235 | return _T('info_statut_auteur_a_confirmer'); |
| 236 | 236 | } |
@@ -243,16 +243,16 @@ discard block |
||
| 243 | 243 | '5poubelle' => _T('texte_statut_poubelle'), // bouh |
| 244 | 244 | ); |
| 245 | 245 | if (isset($recom[$statut])) { |
| 246 | - return $recom[$statut] . $plus; |
|
| 246 | + return $recom[$statut].$plus; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // retrouver directement par le statut sinon |
| 250 | 250 | if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
| 251 | 251 | if (isset($recom[$t])) { |
| 252 | - return $recom[$t] . $plus; |
|
| 252 | + return $recom[$t].$plus; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - return _T($t) . $plus; |
|
| 255 | + return _T($t).$plus; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // si on a pas reussi a le traduire, retournons la chaine telle quelle |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
| 377 | 377 | $in = !count($GLOBALS['connect_id_rubrique']) |
| 378 | 378 | ? '' |
| 379 | - : (" AND " . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 379 | + : (" AND ".sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 380 | 380 | |
| 381 | 381 | // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
| 382 | 382 | if ($objet == 'rubrique') { |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | return ''; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - return propre("[->" . $virtuel . "]"); |
|
| 413 | + return propre("[->".$virtuel."]"); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $args = param_low_sec($op, $args, $lang, 'rss'); |
| 439 | 439 | $url = generer_url_public('rss', $args); |
| 440 | 440 | |
| 441 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 441 | + return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | ); |
| 511 | 511 | |
| 512 | 512 | if ($alertes = array_filter($alertes)) { |
| 513 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 513 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 514 | 514 | join(' | ', $alertes) |
| 515 | 515 | . "</div></div>"; |
| 516 | 516 | } |
@@ -544,13 +544,13 @@ discard block |
||
| 544 | 544 | */ |
| 545 | 545 | function afficher_plus_info($lien, $titre = "+", $titre_lien = "") { |
| 546 | 546 | $titre = attribut_html($titre); |
| 547 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 548 | - http_img_pack("information-16.png", $titre) . "</a>"; |
|
| 547 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>". |
|
| 548 | + http_img_pack("information-16.png", $titre)."</a>"; |
|
| 549 | 549 | |
| 550 | 550 | if (!$titre_lien) { |
| 551 | 551 | return $icone; |
| 552 | 552 | } else { |
| 553 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 553 | + return $icone."\n<a href='$lien'>$titre_lien</a>"; |
|
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | |
@@ -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 | |
@@ -48,63 +48,63 @@ discard block |
||
| 48 | 48 | * Nom de la fonction, ou false. |
| 49 | 49 | */ |
| 50 | 50 | function charger_fonction($nom, $dossier = 'exec', $continue = false) { |
| 51 | - static $echecs = array(); |
|
| 52 | - |
|
| 53 | - if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | - $dossier .= '/'; |
|
| 55 | - } |
|
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | - |
|
| 58 | - if (function_exists($f)) { |
|
| 59 | - return $f; |
|
| 60 | - } |
|
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 62 | - return $g; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (isset($echecs[$f])) { |
|
| 66 | - return $echecs[$f]; |
|
| 67 | - } |
|
| 68 | - // Sinon charger le fichier de declaration si plausible |
|
| 69 | - |
|
| 70 | - if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | - if ($continue) { |
|
| 72 | - return false; |
|
| 73 | - } //appel interne, on passe |
|
| 74 | - include_spip('inc/minipres'); |
|
| 75 | - echo minipres(); |
|
| 76 | - exit; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // passer en minuscules (cf les balises de formulaires) |
|
| 80 | - // et inclure le fichier |
|
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | - // si le fichier truc/machin/nom.php n'existe pas, |
|
| 83 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 84 | - and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 85 | - ) { |
|
| 86 | - include_spip(substr($dossier, 0, -1)); |
|
| 87 | - } |
|
| 88 | - if (function_exists($f)) { |
|
| 89 | - return $f; |
|
| 90 | - } |
|
| 91 | - if (function_exists($g)) { |
|
| 92 | - return $g; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if ($continue) { |
|
| 96 | - return $echecs[$f] = false; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - // Echec : message d'erreur |
|
| 100 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | - ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 102 | - |
|
| 103 | - include_spip('inc/minipres'); |
|
| 104 | - echo minipres(_T('forum_titre_erreur'), |
|
| 105 | - _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | - array('all_inline'=>true,'status'=>404)); |
|
| 107 | - exit; |
|
| 51 | + static $echecs = array(); |
|
| 52 | + |
|
| 53 | + if (strlen($dossier) and substr($dossier, -1) != '/') { |
|
| 54 | + $dossier .= '/'; |
|
| 55 | + } |
|
| 56 | + $f = str_replace('/', '_', $dossier) . $nom; |
|
| 57 | + |
|
| 58 | + if (function_exists($f)) { |
|
| 59 | + return $f; |
|
| 60 | + } |
|
| 61 | + if (function_exists($g = $f . '_dist')) { |
|
| 62 | + return $g; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (isset($echecs[$f])) { |
|
| 66 | + return $echecs[$f]; |
|
| 67 | + } |
|
| 68 | + // Sinon charger le fichier de declaration si plausible |
|
| 69 | + |
|
| 70 | + if (!preg_match(',^\w+$,', $f)) { |
|
| 71 | + if ($continue) { |
|
| 72 | + return false; |
|
| 73 | + } //appel interne, on passe |
|
| 74 | + include_spip('inc/minipres'); |
|
| 75 | + echo minipres(); |
|
| 76 | + exit; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // passer en minuscules (cf les balises de formulaires) |
|
| 80 | + // et inclure le fichier |
|
| 81 | + if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 82 | + // si le fichier truc/machin/nom.php n'existe pas, |
|
| 83 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
|
| 84 | + and strlen(dirname($dossier)) and dirname($dossier) != '.' |
|
| 85 | + ) { |
|
| 86 | + include_spip(substr($dossier, 0, -1)); |
|
| 87 | + } |
|
| 88 | + if (function_exists($f)) { |
|
| 89 | + return $f; |
|
| 90 | + } |
|
| 91 | + if (function_exists($g)) { |
|
| 92 | + return $g; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if ($continue) { |
|
| 96 | + return $echecs[$f] = false; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + // Echec : message d'erreur |
|
| 100 | + spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 101 | + ($inc ? "" : " (fichier $d absent de $dossier)")); |
|
| 102 | + |
|
| 103 | + include_spip('inc/minipres'); |
|
| 104 | + echo minipres(_T('forum_titre_erreur'), |
|
| 105 | + _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | + array('all_inline'=>true,'status'=>404)); |
|
| 107 | + exit; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
| 116 | 116 | function include_once_check($file) { |
| 117 | - if (file_exists($file)) { |
|
| 118 | - include_once $file; |
|
| 117 | + if (file_exists($file)) { |
|
| 118 | + include_once $file; |
|
| 119 | 119 | |
| 120 | - return true; |
|
| 121 | - } |
|
| 122 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 123 | - $crash = ($crash ? $crash : array()); |
|
| 124 | - $crash[$file] = true; |
|
| 125 | - ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 120 | + return true; |
|
| 121 | + } |
|
| 122 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : ''); |
|
| 123 | + $crash = ($crash ? $crash : array()); |
|
| 124 | + $crash[$file] = true; |
|
| 125 | + ecrire_meta('message_crash_plugins', serialize($crash)); |
|
| 126 | 126 | |
| 127 | - return false; |
|
| 127 | + return false; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * - string : chemin du fichier trouvé |
| 149 | 149 | **/ |
| 150 | 150 | function include_spip($f, $include = true) { |
| 151 | - return find_in_path($f . '.php', '', $include); |
|
| 151 | + return find_in_path($f . '.php', '', $include); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * - string : chemin du fichier trouvé |
| 169 | 169 | **/ |
| 170 | 170 | function require_spip($f) { |
| 171 | - return find_in_path($f . '.php', '', 'required'); |
|
| 171 | + return find_in_path($f . '.php', '', 'required'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -177,27 +177,27 @@ discard block |
||
| 177 | 177 | * quand on a besoin dans le PHP de filtres/fonctions qui y sont definis |
| 178 | 178 | */ |
| 179 | 179 | function include_fichiers_fonctions() { |
| 180 | - static $done = false; |
|
| 181 | - if (!$done) { |
|
| 182 | - include_spip('inc/lang'); |
|
| 183 | - |
|
| 184 | - // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 185 | - // donc il faut l'inclure "en globals" |
|
| 186 | - if ($f = find_in_path('mes_fonctions.php')) { |
|
| 187 | - global $dossier_squelettes; |
|
| 188 | - include_once(_ROOT_CWD . $f); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 192 | - // chargement optimise precompile |
|
| 193 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 194 | - } |
|
| 195 | - if (test_espace_prive()) { |
|
| 196 | - include_spip('inc/filtres_ecrire'); |
|
| 197 | - } |
|
| 198 | - include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 199 | - $done = true; |
|
| 200 | - } |
|
| 180 | + static $done = false; |
|
| 181 | + if (!$done) { |
|
| 182 | + include_spip('inc/lang'); |
|
| 183 | + |
|
| 184 | + // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
|
| 185 | + // donc il faut l'inclure "en globals" |
|
| 186 | + if ($f = find_in_path('mes_fonctions.php')) { |
|
| 187 | + global $dossier_squelettes; |
|
| 188 | + include_once(_ROOT_CWD . $f); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + if (@is_readable(_CACHE_PLUGINS_FCT)) { |
|
| 192 | + // chargement optimise precompile |
|
| 193 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 194 | + } |
|
| 195 | + if (test_espace_prive()) { |
|
| 196 | + include_spip('inc/filtres_ecrire'); |
|
| 197 | + } |
|
| 198 | + include_spip('public/fonctions'); // charger les fichiers fonctions associes aux criteres, balises.. |
|
| 199 | + $done = true; |
|
| 200 | + } |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -223,22 +223,22 @@ discard block |
||
| 223 | 223 | * Les paramètres du pipeline modifiés |
| 224 | 224 | **/ |
| 225 | 225 | function minipipe($fonc, &$val) { |
| 226 | - // fonction |
|
| 227 | - if (function_exists($fonc)) { |
|
| 228 | - $val = call_user_func($fonc, $val); |
|
| 229 | - } // Class::Methode |
|
| 230 | - else { |
|
| 231 | - if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 232 | - and $methode = array($regs[1], $regs[2]) |
|
| 233 | - and is_callable($methode) |
|
| 234 | - ) { |
|
| 235 | - $val = call_user_func($methode, $val); |
|
| 236 | - } else { |
|
| 237 | - spip_log("Erreur - '$fonc' non definie !"); |
|
| 238 | - } |
|
| 239 | - } |
|
| 226 | + // fonction |
|
| 227 | + if (function_exists($fonc)) { |
|
| 228 | + $val = call_user_func($fonc, $val); |
|
| 229 | + } // Class::Methode |
|
| 230 | + else { |
|
| 231 | + if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) |
|
| 232 | + and $methode = array($regs[1], $regs[2]) |
|
| 233 | + and is_callable($methode) |
|
| 234 | + ) { |
|
| 235 | + $val = call_user_func($methode, $val); |
|
| 236 | + } else { |
|
| 237 | + spip_log("Erreur - '$fonc' non definie !"); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - return $val; |
|
| 241 | + return $val; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -269,45 +269,45 @@ discard block |
||
| 269 | 269 | * Résultat |
| 270 | 270 | */ |
| 271 | 271 | function pipeline($action, $val = null) { |
| 272 | - static $charger; |
|
| 273 | - |
|
| 274 | - // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 275 | - if (!$charger) { |
|
| 276 | - if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 277 | - include_spip('inc/plugin'); |
|
| 278 | - // generer les fichiers php precompiles |
|
| 279 | - // de chargement des plugins et des pipelines |
|
| 280 | - actualise_plugins_actifs(); |
|
| 281 | - if (!($ok = @is_readable($charger))) { |
|
| 282 | - spip_log("fichier $charger pas cree"); |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if ($ok) { |
|
| 287 | - include_once $charger; |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // appliquer notre fonction si elle existe |
|
| 292 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 293 | - if (function_exists($fonc)) { |
|
| 294 | - $val = $fonc($val); |
|
| 295 | - } // plantage ? |
|
| 296 | - else { |
|
| 297 | - spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // si le flux est une table avec 2 cle args&data |
|
| 301 | - // on ne ressort du pipe que les donnees dans 'data' |
|
| 302 | - // array_key_exists pour php 4.1.0 |
|
| 303 | - if (is_array($val) |
|
| 304 | - and count($val) == 2 |
|
| 305 | - and (array_key_exists('data', $val)) |
|
| 306 | - ) { |
|
| 307 | - $val = $val['data']; |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - return $val; |
|
| 272 | + static $charger; |
|
| 273 | + |
|
| 274 | + // chargement initial des fonctions mises en cache, ou generation du cache |
|
| 275 | + if (!$charger) { |
|
| 276 | + if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { |
|
| 277 | + include_spip('inc/plugin'); |
|
| 278 | + // generer les fichiers php precompiles |
|
| 279 | + // de chargement des plugins et des pipelines |
|
| 280 | + actualise_plugins_actifs(); |
|
| 281 | + if (!($ok = @is_readable($charger))) { |
|
| 282 | + spip_log("fichier $charger pas cree"); |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if ($ok) { |
|
| 287 | + include_once $charger; |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // appliquer notre fonction si elle existe |
|
| 292 | + $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 293 | + if (function_exists($fonc)) { |
|
| 294 | + $val = $fonc($val); |
|
| 295 | + } // plantage ? |
|
| 296 | + else { |
|
| 297 | + spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + // si le flux est une table avec 2 cle args&data |
|
| 301 | + // on ne ressort du pipe que les donnees dans 'data' |
|
| 302 | + // array_key_exists pour php 4.1.0 |
|
| 303 | + if (is_array($val) |
|
| 304 | + and count($val) == 2 |
|
| 305 | + and (array_key_exists('data', $val)) |
|
| 306 | + ) { |
|
| 307 | + $val = $val['data']; |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + return $val; |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -351,38 +351,38 @@ discard block |
||
| 351 | 351 | * paramètre est planté pour cause de compatibilité ascendante. |
| 352 | 352 | */ |
| 353 | 353 | function spip_log($message = null, $name = null) { |
| 354 | - static $pre = array(); |
|
| 355 | - static $log; |
|
| 356 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 357 | - if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 358 | - $logname = null; |
|
| 359 | - } |
|
| 360 | - if (!isset($regs[2])) { |
|
| 361 | - $niveau = _LOG_INFO; |
|
| 362 | - } |
|
| 363 | - else { |
|
| 364 | - $niveau = intval($regs[2]); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 368 | - if (!$pre) { |
|
| 369 | - $pre = array( |
|
| 370 | - _LOG_HS => 'HS:', |
|
| 371 | - _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 372 | - _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 373 | - _LOG_ERREUR => 'ERREUR:', |
|
| 374 | - _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 375 | - _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 376 | - _LOG_INFO => 'info:', |
|
| 377 | - _LOG_DEBUG => 'debug:' |
|
| 378 | - ); |
|
| 379 | - $log = charger_fonction('log', 'inc'); |
|
| 380 | - } |
|
| 381 | - if (!is_string($message)) { |
|
| 382 | - $message = print_r($message, true); |
|
| 383 | - } |
|
| 384 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 385 | - } |
|
| 354 | + static $pre = array(); |
|
| 355 | + static $log; |
|
| 356 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 357 | + if (!isset($regs[1]) or !$logname = $regs[1]) { |
|
| 358 | + $logname = null; |
|
| 359 | + } |
|
| 360 | + if (!isset($regs[2])) { |
|
| 361 | + $niveau = _LOG_INFO; |
|
| 362 | + } |
|
| 363 | + else { |
|
| 364 | + $niveau = intval($regs[2]); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { |
|
| 368 | + if (!$pre) { |
|
| 369 | + $pre = array( |
|
| 370 | + _LOG_HS => 'HS:', |
|
| 371 | + _LOG_ALERTE_ROUGE => 'ALERTE:', |
|
| 372 | + _LOG_CRITIQUE => 'CRITIQUE:', |
|
| 373 | + _LOG_ERREUR => 'ERREUR:', |
|
| 374 | + _LOG_AVERTISSEMENT => 'WARNING:', |
|
| 375 | + _LOG_INFO_IMPORTANTE => '!INFO:', |
|
| 376 | + _LOG_INFO => 'info:', |
|
| 377 | + _LOG_DEBUG => 'debug:' |
|
| 378 | + ); |
|
| 379 | + $log = charger_fonction('log', 'inc'); |
|
| 380 | + } |
|
| 381 | + if (!is_string($message)) { |
|
| 382 | + $message = print_r($message, true); |
|
| 383 | + } |
|
| 384 | + $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | * @param array $opt Tableau d'options |
| 394 | 394 | **/ |
| 395 | 395 | function journal($phrase, $opt = array()) { |
| 396 | - $journal = charger_fonction('journal', 'inc'); |
|
| 397 | - $journal($phrase, $opt); |
|
| 396 | + $journal = charger_fonction('journal', 'inc'); |
|
| 397 | + $journal($phrase, $opt); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
@@ -413,36 +413,36 @@ discard block |
||
| 413 | 413 | **/ |
| 414 | 414 | function _request($var, $c = false) { |
| 415 | 415 | |
| 416 | - if (is_array($c)) { |
|
| 417 | - return isset($c[$var]) ? $c[$var] : null; |
|
| 418 | - } |
|
| 416 | + if (is_array($c)) { |
|
| 417 | + return isset($c[$var]) ? $c[$var] : null; |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - if (isset($_GET[$var])) { |
|
| 421 | - $a = $_GET[$var]; |
|
| 422 | - } elseif (isset($_POST[$var])) { |
|
| 423 | - $a = $_POST[$var]; |
|
| 424 | - } else { |
|
| 425 | - return null; |
|
| 426 | - } |
|
| 420 | + if (isset($_GET[$var])) { |
|
| 421 | + $a = $_GET[$var]; |
|
| 422 | + } elseif (isset($_POST[$var])) { |
|
| 423 | + $a = $_POST[$var]; |
|
| 424 | + } else { |
|
| 425 | + return null; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - // Si on est en ajax et en POST tout a ete encode |
|
| 429 | - // via encodeURIComponent, il faut donc repasser |
|
| 430 | - // dans le charset local... |
|
| 431 | - if (defined('_AJAX') |
|
| 432 | - and _AJAX |
|
| 433 | - and isset($GLOBALS['meta']['charset']) |
|
| 434 | - and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 435 | - and is_string($a) |
|
| 436 | - // check rapide mais pas fiable |
|
| 437 | - and preg_match(',[\x80-\xFF],', $a) |
|
| 438 | - // check fiable |
|
| 439 | - and include_spip('inc/charsets') |
|
| 440 | - and is_utf8($a) |
|
| 441 | - ) { |
|
| 442 | - return importer_charset($a, 'utf-8'); |
|
| 443 | - } |
|
| 428 | + // Si on est en ajax et en POST tout a ete encode |
|
| 429 | + // via encodeURIComponent, il faut donc repasser |
|
| 430 | + // dans le charset local... |
|
| 431 | + if (defined('_AJAX') |
|
| 432 | + and _AJAX |
|
| 433 | + and isset($GLOBALS['meta']['charset']) |
|
| 434 | + and $GLOBALS['meta']['charset'] != 'utf-8' |
|
| 435 | + and is_string($a) |
|
| 436 | + // check rapide mais pas fiable |
|
| 437 | + and preg_match(',[\x80-\xFF],', $a) |
|
| 438 | + // check fiable |
|
| 439 | + and include_spip('inc/charsets') |
|
| 440 | + and is_utf8($a) |
|
| 441 | + ) { |
|
| 442 | + return importer_charset($a, 'utf-8'); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - return $a; |
|
| 445 | + return $a; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | |
@@ -460,22 +460,22 @@ discard block |
||
| 460 | 460 | * - false sinon |
| 461 | 461 | **/ |
| 462 | 462 | function set_request($var, $val = null, $c = false) { |
| 463 | - if (is_array($c)) { |
|
| 464 | - unset($c[$var]); |
|
| 465 | - if ($val !== null) { |
|
| 466 | - $c[$var] = $val; |
|
| 467 | - } |
|
| 463 | + if (is_array($c)) { |
|
| 464 | + unset($c[$var]); |
|
| 465 | + if ($val !== null) { |
|
| 466 | + $c[$var] = $val; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - return $c; |
|
| 470 | - } |
|
| 469 | + return $c; |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - unset($_GET[$var]); |
|
| 473 | - unset($_POST[$var]); |
|
| 474 | - if ($val !== null) { |
|
| 475 | - $_GET[$var] = $val; |
|
| 476 | - } |
|
| 472 | + unset($_GET[$var]); |
|
| 473 | + unset($_POST[$var]); |
|
| 474 | + if ($val !== null) { |
|
| 475 | + $_GET[$var] = $val; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - return false; # n'affecte pas $c |
|
| 478 | + return false; # n'affecte pas $c |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -495,25 +495,25 @@ discard block |
||
| 495 | 495 | * @return array|mixed|string |
| 496 | 496 | */ |
| 497 | 497 | function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') { |
| 498 | - if (is_array($value)) { |
|
| 499 | - if ($key=='*') { |
|
| 500 | - $key = array_keys($value); |
|
| 501 | - } |
|
| 502 | - if (!is_array($key)) { |
|
| 503 | - $key = [$key]; |
|
| 504 | - } |
|
| 505 | - foreach ($key as $k) { |
|
| 506 | - if (!empty($value[$k])) { |
|
| 507 | - $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - return $value; |
|
| 511 | - } |
|
| 512 | - // si la valeur vient des GET ou POST on la sanitize |
|
| 513 | - if (!empty($value) and $value == _request($key)) { |
|
| 514 | - $value = $sanitize_function($value); |
|
| 515 | - } |
|
| 516 | - return $value; |
|
| 498 | + if (is_array($value)) { |
|
| 499 | + if ($key=='*') { |
|
| 500 | + $key = array_keys($value); |
|
| 501 | + } |
|
| 502 | + if (!is_array($key)) { |
|
| 503 | + $key = [$key]; |
|
| 504 | + } |
|
| 505 | + foreach ($key as $k) { |
|
| 506 | + if (!empty($value[$k])) { |
|
| 507 | + $value[$k] = spip_sanitize_from_request($value[$k], $k, $sanitize_function); |
|
| 508 | + } |
|
| 509 | + } |
|
| 510 | + return $value; |
|
| 511 | + } |
|
| 512 | + // si la valeur vient des GET ou POST on la sanitize |
|
| 513 | + if (!empty($value) and $value == _request($key)) { |
|
| 514 | + $value = $sanitize_function($value); |
|
| 515 | + } |
|
| 516 | + return $value; |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -521,23 +521,22 @@ discard block |
||
| 521 | 521 | * |
| 522 | 522 | * On est sur le web, on exclut certains protocoles, |
| 523 | 523 | * notamment 'file://', 'php://' et d'autres… |
| 524 | - |
|
| 525 | 524 | * @param string $url |
| 526 | 525 | * @return bool |
| 527 | 526 | */ |
| 528 | 527 | function tester_url_absolue($url) { |
| 529 | - $url = trim($url); |
|
| 530 | - if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 531 | - if ( |
|
| 532 | - isset($m[1]) |
|
| 533 | - and $p = strtolower(rtrim($m[1], ':')) |
|
| 534 | - and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 535 | - ) { |
|
| 536 | - return false; |
|
| 537 | - } |
|
| 538 | - return true; |
|
| 539 | - } |
|
| 540 | - return false; |
|
| 528 | + $url = trim($url); |
|
| 529 | + if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { |
|
| 530 | + if ( |
|
| 531 | + isset($m[1]) |
|
| 532 | + and $p = strtolower(rtrim($m[1], ':')) |
|
| 533 | + and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) |
|
| 534 | + ) { |
|
| 535 | + return false; |
|
| 536 | + } |
|
| 537 | + return true; |
|
| 538 | + } |
|
| 539 | + return false; |
|
| 541 | 540 | } |
| 542 | 541 | |
| 543 | 542 | /** |
@@ -559,94 +558,94 @@ discard block |
||
| 559 | 558 | * @return string URL |
| 560 | 559 | */ |
| 561 | 560 | function parametre_url($url, $c, $v = null, $sep = '&') { |
| 562 | - // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 563 | - if (strpos($c, "|") !== false and is_null($v)) { |
|
| 564 | - return null; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - // lever l'#ancre |
|
| 568 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 569 | - $url = $r[1]; |
|
| 570 | - $ancre = $r[2]; |
|
| 571 | - } else { |
|
| 572 | - $ancre = ''; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - // eclater |
|
| 576 | - $url = preg_split(',[?]|&|&,', $url); |
|
| 577 | - |
|
| 578 | - // recuperer la base |
|
| 579 | - $a = array_shift($url); |
|
| 580 | - if (!$a) { |
|
| 581 | - $a = './'; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 585 | - $ajouts = array_flip(explode('|', $c)); |
|
| 586 | - $u = is_array($v) ? $v : rawurlencode($v); |
|
| 587 | - $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 588 | - $v_read = null; |
|
| 589 | - // lire les variables et agir |
|
| 590 | - foreach ($url as $n => $val) { |
|
| 591 | - if (preg_match($regexp, urldecode($val), $r)) { |
|
| 592 | - $r = array_pad($r, 3, null); |
|
| 593 | - if ($v === null) { |
|
| 594 | - // c'est un tableau, on memorise les valeurs |
|
| 595 | - if (substr($r[1], -2) == "[]") { |
|
| 596 | - if (!$v_read) { |
|
| 597 | - $v_read = array(); |
|
| 598 | - } |
|
| 599 | - $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 600 | - } // c'est un scalaire, on retourne direct |
|
| 601 | - else { |
|
| 602 | - return $r[2] ? substr($r[2], 1) : ''; |
|
| 603 | - } |
|
| 604 | - } // suppression |
|
| 605 | - elseif (!$testv) { |
|
| 606 | - unset($url[$n]); |
|
| 607 | - } |
|
| 608 | - // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 609 | - // pour un tableau ce sera fait dans la prochaine boucle |
|
| 610 | - elseif (substr($r[1], -2) != '[]') { |
|
| 611 | - $url[$n] = $r[1] . '=' . $u; |
|
| 612 | - unset($ajouts[$r[1]]); |
|
| 613 | - } |
|
| 614 | - // Pour les tableaux on laisse tomber les valeurs de |
|
| 615 | - // départ, on remplira à l'étape suivante |
|
| 616 | - else { |
|
| 617 | - unset($url[$n]); |
|
| 618 | - } |
|
| 619 | - } |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - // traiter les parametres pas encore trouves |
|
| 623 | - if ($v === null |
|
| 624 | - and $args = func_get_args() |
|
| 625 | - and count($args) == 2 |
|
| 626 | - ) { |
|
| 627 | - return $v_read; // rien trouve ou un tableau |
|
| 628 | - } elseif ($testv) { |
|
| 629 | - foreach ($ajouts as $k => $n) { |
|
| 630 | - if (!is_array($v)) { |
|
| 631 | - $url[] = $k . '=' . $u; |
|
| 632 | - } else { |
|
| 633 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 634 | - foreach ($v as $w) { |
|
| 635 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 636 | - } |
|
| 637 | - } |
|
| 638 | - } |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - // eliminer les vides |
|
| 642 | - $url = array_filter($url); |
|
| 643 | - |
|
| 644 | - // recomposer l'adresse |
|
| 645 | - if ($url) { |
|
| 646 | - $a .= '?' . join($sep, $url); |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - return $a . $ancre; |
|
| 561 | + // requete erronnee : plusieurs variable dans $c et aucun $v |
|
| 562 | + if (strpos($c, "|") !== false and is_null($v)) { |
|
| 563 | + return null; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + // lever l'#ancre |
|
| 567 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 568 | + $url = $r[1]; |
|
| 569 | + $ancre = $r[2]; |
|
| 570 | + } else { |
|
| 571 | + $ancre = ''; |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + // eclater |
|
| 575 | + $url = preg_split(',[?]|&|&,', $url); |
|
| 576 | + |
|
| 577 | + // recuperer la base |
|
| 578 | + $a = array_shift($url); |
|
| 579 | + if (!$a) { |
|
| 580 | + $a = './'; |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 584 | + $ajouts = array_flip(explode('|', $c)); |
|
| 585 | + $u = is_array($v) ? $v : rawurlencode($v); |
|
| 586 | + $testv = (is_array($v) ? count($v) : strlen($v)); |
|
| 587 | + $v_read = null; |
|
| 588 | + // lire les variables et agir |
|
| 589 | + foreach ($url as $n => $val) { |
|
| 590 | + if (preg_match($regexp, urldecode($val), $r)) { |
|
| 591 | + $r = array_pad($r, 3, null); |
|
| 592 | + if ($v === null) { |
|
| 593 | + // c'est un tableau, on memorise les valeurs |
|
| 594 | + if (substr($r[1], -2) == "[]") { |
|
| 595 | + if (!$v_read) { |
|
| 596 | + $v_read = array(); |
|
| 597 | + } |
|
| 598 | + $v_read[] = $r[2] ? substr($r[2], 1) : ''; |
|
| 599 | + } // c'est un scalaire, on retourne direct |
|
| 600 | + else { |
|
| 601 | + return $r[2] ? substr($r[2], 1) : ''; |
|
| 602 | + } |
|
| 603 | + } // suppression |
|
| 604 | + elseif (!$testv) { |
|
| 605 | + unset($url[$n]); |
|
| 606 | + } |
|
| 607 | + // Ajout. Pour une variable, remplacer au meme endroit, |
|
| 608 | + // pour un tableau ce sera fait dans la prochaine boucle |
|
| 609 | + elseif (substr($r[1], -2) != '[]') { |
|
| 610 | + $url[$n] = $r[1] . '=' . $u; |
|
| 611 | + unset($ajouts[$r[1]]); |
|
| 612 | + } |
|
| 613 | + // Pour les tableaux on laisse tomber les valeurs de |
|
| 614 | + // départ, on remplira à l'étape suivante |
|
| 615 | + else { |
|
| 616 | + unset($url[$n]); |
|
| 617 | + } |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + // traiter les parametres pas encore trouves |
|
| 622 | + if ($v === null |
|
| 623 | + and $args = func_get_args() |
|
| 624 | + and count($args) == 2 |
|
| 625 | + ) { |
|
| 626 | + return $v_read; // rien trouve ou un tableau |
|
| 627 | + } elseif ($testv) { |
|
| 628 | + foreach ($ajouts as $k => $n) { |
|
| 629 | + if (!is_array($v)) { |
|
| 630 | + $url[] = $k . '=' . $u; |
|
| 631 | + } else { |
|
| 632 | + $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 633 | + foreach ($v as $w) { |
|
| 634 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + } |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + // eliminer les vides |
|
| 641 | + $url = array_filter($url); |
|
| 642 | + |
|
| 643 | + // recomposer l'adresse |
|
| 644 | + if ($url) { |
|
| 645 | + $a .= '?' . join($sep, $url); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + return $a . $ancre; |
|
| 650 | 649 | } |
| 651 | 650 | |
| 652 | 651 | /** |
@@ -664,21 +663,21 @@ discard block |
||
| 664 | 663 | * @return string |
| 665 | 664 | */ |
| 666 | 665 | function ancre_url($url, $ancre) { |
| 667 | - // lever l'#ancre |
|
| 668 | - if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 669 | - $url = $r[1]; |
|
| 670 | - } |
|
| 671 | - if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 672 | - if (!function_exists('translitteration')) { |
|
| 673 | - include_spip('inc/charsets'); |
|
| 674 | - } |
|
| 675 | - $ancre = preg_replace( |
|
| 676 | - array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 677 | - array('', '-'), |
|
| 678 | - translitteration($ancre) |
|
| 679 | - ); |
|
| 680 | - } |
|
| 681 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 666 | + // lever l'#ancre |
|
| 667 | + if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { |
|
| 668 | + $url = $r[1]; |
|
| 669 | + } |
|
| 670 | + if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { |
|
| 671 | + if (!function_exists('translitteration')) { |
|
| 672 | + include_spip('inc/charsets'); |
|
| 673 | + } |
|
| 674 | + $ancre = preg_replace( |
|
| 675 | + array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), |
|
| 676 | + array('', '-'), |
|
| 677 | + translitteration($ancre) |
|
| 678 | + ); |
|
| 679 | + } |
|
| 680 | + return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 682 | 681 | } |
| 683 | 682 | |
| 684 | 683 | /** |
@@ -688,16 +687,16 @@ discard block |
||
| 688 | 687 | * @return string |
| 689 | 688 | */ |
| 690 | 689 | function nettoyer_uri($reset = null) { |
| 691 | - static $done = false; |
|
| 692 | - static $propre = ''; |
|
| 693 | - if (!is_null($reset)) { |
|
| 694 | - return $propre = $reset; |
|
| 695 | - } |
|
| 696 | - if ($done) { |
|
| 697 | - return $propre; |
|
| 698 | - } |
|
| 699 | - $done = true; |
|
| 700 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 690 | + static $done = false; |
|
| 691 | + static $propre = ''; |
|
| 692 | + if (!is_null($reset)) { |
|
| 693 | + return $propre = $reset; |
|
| 694 | + } |
|
| 695 | + if ($done) { |
|
| 696 | + return $propre; |
|
| 697 | + } |
|
| 698 | + $done = true; |
|
| 699 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']); |
|
| 701 | 700 | } |
| 702 | 701 | |
| 703 | 702 | /** |
@@ -709,13 +708,13 @@ discard block |
||
| 709 | 708 | * @return string |
| 710 | 709 | */ |
| 711 | 710 | function nettoyer_uri_var($request_uri) { |
| 712 | - $uri1 = $request_uri; |
|
| 713 | - do { |
|
| 714 | - $uri = $uri1; |
|
| 715 | - $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 716 | - '\1', $uri); |
|
| 717 | - } while ($uri <> $uri1); |
|
| 718 | - return preg_replace(',[?&]$,', '', $uri1); |
|
| 711 | + $uri1 = $request_uri; |
|
| 712 | + do { |
|
| 713 | + $uri = $uri1; |
|
| 714 | + $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', |
|
| 715 | + '\1', $uri); |
|
| 716 | + } while ($uri <> $uri1); |
|
| 717 | + return preg_replace(',[?&]$,', '', $uri1); |
|
| 719 | 718 | } |
| 720 | 719 | |
| 721 | 720 | |
@@ -729,47 +728,47 @@ discard block |
||
| 729 | 728 | * URL vers soi-même |
| 730 | 729 | **/ |
| 731 | 730 | function self($amp = '&', $root = false) { |
| 732 | - $url = nettoyer_uri(); |
|
| 733 | - if (!$root |
|
| 734 | - and ( |
|
| 735 | - // si pas de profondeur on peut tronquer |
|
| 736 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 737 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 738 | - or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 739 | - ) { |
|
| 740 | - $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 741 | - } |
|
| 742 | - // ajouter le cas echeant les variables _POST['id_...'] |
|
| 743 | - foreach ($_POST as $v => $c) { |
|
| 744 | - if (substr($v, 0, 3) == 'id_') { |
|
| 745 | - $url = parametre_url($url, $v, $c, '&'); |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - // supprimer les variables sans interet |
|
| 750 | - if (test_espace_prive()) { |
|
| 751 | - $url = preg_replace(',([?&])(' |
|
| 752 | - . 'lang|show_docs|' |
|
| 753 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 754 | - $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 755 | - $url = preg_replace(',[&]$,', '\1', $url); |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - // eviter les hacks |
|
| 759 | - include_spip('inc/filtres_mini'); |
|
| 760 | - $url = spip_htmlspecialchars($url); |
|
| 731 | + $url = nettoyer_uri(); |
|
| 732 | + if (!$root |
|
| 733 | + and ( |
|
| 734 | + // si pas de profondeur on peut tronquer |
|
| 735 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2) |
|
| 736 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false |
|
| 737 | + or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) |
|
| 738 | + ) { |
|
| 739 | + $url = preg_replace(',^[^?]*/,', '', $url); |
|
| 740 | + } |
|
| 741 | + // ajouter le cas echeant les variables _POST['id_...'] |
|
| 742 | + foreach ($_POST as $v => $c) { |
|
| 743 | + if (substr($v, 0, 3) == 'id_') { |
|
| 744 | + $url = parametre_url($url, $v, $c, '&'); |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + // supprimer les variables sans interet |
|
| 749 | + if (test_espace_prive()) { |
|
| 750 | + $url = preg_replace(',([?&])(' |
|
| 751 | + . 'lang|show_docs|' |
|
| 752 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url); |
|
| 753 | + $url = preg_replace(',([?&])[&]+,', '\1', $url); |
|
| 754 | + $url = preg_replace(',[&]$,', '\1', $url); |
|
| 755 | + } |
|
| 756 | + |
|
| 757 | + // eviter les hacks |
|
| 758 | + include_spip('inc/filtres_mini'); |
|
| 759 | + $url = spip_htmlspecialchars($url); |
|
| 761 | 760 | |
| 762 | - $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 761 | + $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); |
|
| 763 | 762 | |
| 764 | - // & ? |
|
| 765 | - if ($amp != '&') { |
|
| 766 | - $url = str_replace('&', $amp, $url); |
|
| 767 | - } |
|
| 763 | + // & ? |
|
| 764 | + if ($amp != '&') { |
|
| 765 | + $url = str_replace('&', $amp, $url); |
|
| 766 | + } |
|
| 768 | 767 | |
| 769 | - // Si ca demarre par ? ou vide, donner './' |
|
| 770 | - $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 768 | + // Si ca demarre par ? ou vide, donner './' |
|
| 769 | + $url = preg_replace(',^([?].*)?$,', './\1', $url); |
|
| 771 | 770 | |
| 772 | - return $url; |
|
| 771 | + return $url; |
|
| 773 | 772 | } |
| 774 | 773 | |
| 775 | 774 | |
@@ -780,7 +779,7 @@ discard block |
||
| 780 | 779 | * true si c'est le cas, false sinon. |
| 781 | 780 | */ |
| 782 | 781 | function test_espace_prive() { |
| 783 | - return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 782 | + return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; |
|
| 784 | 783 | } |
| 785 | 784 | |
| 786 | 785 | /** |
@@ -790,7 +789,7 @@ discard block |
||
| 790 | 789 | * @return bool |
| 791 | 790 | */ |
| 792 | 791 | function test_plugin_actif($plugin) { |
| 793 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 792 | + return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 794 | 793 | } |
| 795 | 794 | |
| 796 | 795 | /** |
@@ -821,51 +820,51 @@ discard block |
||
| 821 | 820 | * Texte |
| 822 | 821 | */ |
| 823 | 822 | function _T($texte, $args = array(), $options = array()) { |
| 824 | - static $traduire = false; |
|
| 825 | - $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 826 | - if ($options) { |
|
| 827 | - // support de l'ancien argument $class |
|
| 828 | - if (is_string($options)) { |
|
| 829 | - $options = array('class' => $options); |
|
| 830 | - } |
|
| 831 | - $o = array_merge($o, $options); |
|
| 832 | - } |
|
| 823 | + static $traduire = false; |
|
| 824 | + $o = array('class' => '', 'force' => true, 'sanitize' => true); |
|
| 825 | + if ($options) { |
|
| 826 | + // support de l'ancien argument $class |
|
| 827 | + if (is_string($options)) { |
|
| 828 | + $options = array('class' => $options); |
|
| 829 | + } |
|
| 830 | + $o = array_merge($o, $options); |
|
| 831 | + } |
|
| 833 | 832 | |
| 834 | - if (!$traduire) { |
|
| 835 | - $traduire = charger_fonction('traduire', 'inc'); |
|
| 836 | - include_spip('inc/lang'); |
|
| 837 | - } |
|
| 833 | + if (!$traduire) { |
|
| 834 | + $traduire = charger_fonction('traduire', 'inc'); |
|
| 835 | + include_spip('inc/lang'); |
|
| 836 | + } |
|
| 838 | 837 | |
| 839 | - // On peut passer explicitement la langue dans le tableau |
|
| 840 | - // On utilise le même nom de variable que la globale |
|
| 841 | - if (isset($args['spip_lang'])) { |
|
| 842 | - $lang = $args['spip_lang']; |
|
| 843 | - // On l'enleve pour ne pas le passer au remplacement |
|
| 844 | - unset($args['spip_lang']); |
|
| 845 | - } // Sinon on prend la langue du contexte |
|
| 846 | - else { |
|
| 847 | - $lang = $GLOBALS['spip_lang']; |
|
| 848 | - } |
|
| 849 | - $text = $traduire($texte, $lang); |
|
| 838 | + // On peut passer explicitement la langue dans le tableau |
|
| 839 | + // On utilise le même nom de variable que la globale |
|
| 840 | + if (isset($args['spip_lang'])) { |
|
| 841 | + $lang = $args['spip_lang']; |
|
| 842 | + // On l'enleve pour ne pas le passer au remplacement |
|
| 843 | + unset($args['spip_lang']); |
|
| 844 | + } // Sinon on prend la langue du contexte |
|
| 845 | + else { |
|
| 846 | + $lang = $GLOBALS['spip_lang']; |
|
| 847 | + } |
|
| 848 | + $text = $traduire($texte, $lang); |
|
| 850 | 849 | |
| 851 | - if (!strlen($text)) { |
|
| 852 | - if (!$o['force']) { |
|
| 853 | - return ''; |
|
| 854 | - } |
|
| 850 | + if (!strlen($text)) { |
|
| 851 | + if (!$o['force']) { |
|
| 852 | + return ''; |
|
| 853 | + } |
|
| 855 | 854 | |
| 856 | - $text = $texte; |
|
| 855 | + $text = $texte; |
|
| 857 | 856 | |
| 858 | - // pour les chaines non traduites, assurer un service minimum |
|
| 859 | - if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 860 | - $text = str_replace('_', ' ', |
|
| 861 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 862 | - substr($texte, $n + 1))); |
|
| 863 | - } |
|
| 864 | - $o['class'] = null; |
|
| 857 | + // pour les chaines non traduites, assurer un service minimum |
|
| 858 | + if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
|
| 859 | + $text = str_replace('_', ' ', |
|
| 860 | + (($n = strpos($text, ':')) === false ? $texte : |
|
| 861 | + substr($texte, $n + 1))); |
|
| 862 | + } |
|
| 863 | + $o['class'] = null; |
|
| 865 | 864 | |
| 866 | - } |
|
| 865 | + } |
|
| 867 | 866 | |
| 868 | - return _L($text, $args, $o); |
|
| 867 | + return _L($text, $args, $o); |
|
| 869 | 868 | |
| 870 | 869 | } |
| 871 | 870 | |
@@ -893,53 +892,53 @@ discard block |
||
| 893 | 892 | * Texte |
| 894 | 893 | */ |
| 895 | 894 | function _L($text, $args = array(), $options = array()) { |
| 896 | - $f = $text; |
|
| 897 | - $defaut_options = array( |
|
| 898 | - 'class' => null, |
|
| 899 | - 'sanitize' => true, |
|
| 900 | - ); |
|
| 901 | - // support de l'ancien argument $class |
|
| 902 | - if ($options and is_string($options)) { |
|
| 903 | - $options = array('class' => $options); |
|
| 904 | - } |
|
| 905 | - if (is_array($options)) { |
|
| 906 | - $options += $defaut_options; |
|
| 907 | - } else { |
|
| 908 | - $options = $defaut_options; |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - if (is_array($args) and count($args)) { |
|
| 912 | - if (!function_exists('interdire_scripts')) { |
|
| 913 | - include_spip('inc/texte'); |
|
| 914 | - } |
|
| 915 | - if (!function_exists('echapper_html_suspect')) { |
|
| 916 | - include_spip('inc/texte_mini'); |
|
| 917 | - } |
|
| 918 | - foreach ($args as $name => $value) { |
|
| 919 | - if (strpos($text, "@$name@") !== false) { |
|
| 920 | - if ($options['sanitize']) { |
|
| 921 | - $value = echapper_html_suspect($value); |
|
| 922 | - $value = interdire_scripts($value, -1); |
|
| 923 | - } |
|
| 924 | - if (!empty($options['class'])) { |
|
| 925 | - $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 926 | - } |
|
| 927 | - $text = str_replace("@$name@", $value, $text); |
|
| 928 | - unset($args[$name]); |
|
| 929 | - } |
|
| 930 | - } |
|
| 931 | - // Si des variables n'ont pas ete inserees, le signaler |
|
| 932 | - // (chaines de langues pas a jour) |
|
| 933 | - if ($args) { |
|
| 934 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 935 | - } |
|
| 936 | - } |
|
| 937 | - |
|
| 938 | - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 939 | - return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 940 | - } else { |
|
| 941 | - return $text; |
|
| 942 | - } |
|
| 895 | + $f = $text; |
|
| 896 | + $defaut_options = array( |
|
| 897 | + 'class' => null, |
|
| 898 | + 'sanitize' => true, |
|
| 899 | + ); |
|
| 900 | + // support de l'ancien argument $class |
|
| 901 | + if ($options and is_string($options)) { |
|
| 902 | + $options = array('class' => $options); |
|
| 903 | + } |
|
| 904 | + if (is_array($options)) { |
|
| 905 | + $options += $defaut_options; |
|
| 906 | + } else { |
|
| 907 | + $options = $defaut_options; |
|
| 908 | + } |
|
| 909 | + |
|
| 910 | + if (is_array($args) and count($args)) { |
|
| 911 | + if (!function_exists('interdire_scripts')) { |
|
| 912 | + include_spip('inc/texte'); |
|
| 913 | + } |
|
| 914 | + if (!function_exists('echapper_html_suspect')) { |
|
| 915 | + include_spip('inc/texte_mini'); |
|
| 916 | + } |
|
| 917 | + foreach ($args as $name => $value) { |
|
| 918 | + if (strpos($text, "@$name@") !== false) { |
|
| 919 | + if ($options['sanitize']) { |
|
| 920 | + $value = echapper_html_suspect($value); |
|
| 921 | + $value = interdire_scripts($value, -1); |
|
| 922 | + } |
|
| 923 | + if (!empty($options['class'])) { |
|
| 924 | + $value = "<span class='".$options['class']."'>$value</span>"; |
|
| 925 | + } |
|
| 926 | + $text = str_replace("@$name@", $value, $text); |
|
| 927 | + unset($args[$name]); |
|
| 928 | + } |
|
| 929 | + } |
|
| 930 | + // Si des variables n'ont pas ete inserees, le signaler |
|
| 931 | + // (chaines de langues pas a jour) |
|
| 932 | + if ($args) { |
|
| 933 | + spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 934 | + } |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { |
|
| 938 | + return "<span class=debug-traduction-erreur>$text</span>"; |
|
| 939 | + } else { |
|
| 940 | + return $text; |
|
| 941 | + } |
|
| 943 | 942 | } |
| 944 | 943 | |
| 945 | 944 | |
@@ -953,13 +952,13 @@ discard block |
||
| 953 | 952 | * @return string |
| 954 | 953 | */ |
| 955 | 954 | function joli_repertoire($rep) { |
| 956 | - $a = substr($rep, 0, 1); |
|
| 957 | - if ($a <> '.' and $a <> '/') { |
|
| 958 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 959 | - } |
|
| 960 | - $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 955 | + $a = substr($rep, 0, 1); |
|
| 956 | + if ($a <> '.' and $a <> '/') { |
|
| 957 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 958 | + } |
|
| 959 | + $rep = preg_replace(',(^\.\.\/),', '', $rep); |
|
| 961 | 960 | |
| 962 | - return $rep; |
|
| 961 | + return $rep; |
|
| 963 | 962 | } |
| 964 | 963 | |
| 965 | 964 | |
@@ -984,33 +983,33 @@ discard block |
||
| 984 | 983 | * @return float|int|string|void |
| 985 | 984 | */ |
| 986 | 985 | function spip_timer($t = 'rien', $raw = false) { |
| 987 | - static $time; |
|
| 988 | - $a = time(); |
|
| 989 | - $b = microtime(); |
|
| 990 | - // microtime peut contenir les microsecondes et le temps |
|
| 991 | - $b = explode(' ', $b); |
|
| 992 | - if (count($b) == 2) { |
|
| 993 | - $a = end($b); |
|
| 994 | - } // plus precis ! |
|
| 995 | - $b = reset($b); |
|
| 996 | - if (!isset($time[$t])) { |
|
| 997 | - $time[$t] = $a + $b; |
|
| 998 | - } else { |
|
| 999 | - $p = ($a + $b - $time[$t]) * 1000; |
|
| 1000 | - unset($time[$t]); |
|
| 986 | + static $time; |
|
| 987 | + $a = time(); |
|
| 988 | + $b = microtime(); |
|
| 989 | + // microtime peut contenir les microsecondes et le temps |
|
| 990 | + $b = explode(' ', $b); |
|
| 991 | + if (count($b) == 2) { |
|
| 992 | + $a = end($b); |
|
| 993 | + } // plus precis ! |
|
| 994 | + $b = reset($b); |
|
| 995 | + if (!isset($time[$t])) { |
|
| 996 | + $time[$t] = $a + $b; |
|
| 997 | + } else { |
|
| 998 | + $p = ($a + $b - $time[$t]) * 1000; |
|
| 999 | + unset($time[$t]); |
|
| 1001 | 1000 | # echo "'$p'";exit; |
| 1002 | - if ($raw) { |
|
| 1003 | - return $p; |
|
| 1004 | - } |
|
| 1005 | - if ($p < 1000) { |
|
| 1006 | - $s = ''; |
|
| 1007 | - } else { |
|
| 1008 | - $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 1009 | - $p -= ($x * 1000); |
|
| 1010 | - } |
|
| 1001 | + if ($raw) { |
|
| 1002 | + return $p; |
|
| 1003 | + } |
|
| 1004 | + if ($p < 1000) { |
|
| 1005 | + $s = ''; |
|
| 1006 | + } else { |
|
| 1007 | + $s = sprintf("%d ", $x = floor($p / 1000)); |
|
| 1008 | + $p -= ($x * 1000); |
|
| 1009 | + } |
|
| 1011 | 1010 | |
| 1012 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1013 | - } |
|
| 1011 | + return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1012 | + } |
|
| 1014 | 1013 | } |
| 1015 | 1014 | |
| 1016 | 1015 | |
@@ -1018,21 +1017,21 @@ discard block |
||
| 1018 | 1017 | // sinon renvoie True et le date sauf si ca n'est pas souhaite |
| 1019 | 1018 | // https://code.spip.net/@spip_touch |
| 1020 | 1019 | function spip_touch($fichier, $duree = 0, $touch = true) { |
| 1021 | - if ($duree) { |
|
| 1022 | - clearstatcache(); |
|
| 1023 | - if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1024 | - return false; |
|
| 1025 | - } |
|
| 1026 | - } |
|
| 1027 | - if ($touch !== false) { |
|
| 1028 | - if (!@touch($fichier)) { |
|
| 1029 | - spip_unlink($fichier); |
|
| 1030 | - @touch($fichier); |
|
| 1031 | - }; |
|
| 1032 | - @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1033 | - } |
|
| 1020 | + if ($duree) { |
|
| 1021 | + clearstatcache(); |
|
| 1022 | + if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { |
|
| 1023 | + return false; |
|
| 1024 | + } |
|
| 1025 | + } |
|
| 1026 | + if ($touch !== false) { |
|
| 1027 | + if (!@touch($fichier)) { |
|
| 1028 | + spip_unlink($fichier); |
|
| 1029 | + @touch($fichier); |
|
| 1030 | + }; |
|
| 1031 | + @chmod($fichier, _SPIP_CHMOD & ~0111); |
|
| 1032 | + } |
|
| 1034 | 1033 | |
| 1035 | - return true; |
|
| 1034 | + return true; |
|
| 1036 | 1035 | } |
| 1037 | 1036 | |
| 1038 | 1037 | |
@@ -1044,11 +1043,11 @@ discard block |
||
| 1044 | 1043 | * @uses cron() |
| 1045 | 1044 | **/ |
| 1046 | 1045 | function action_cron() { |
| 1047 | - include_spip('inc/headers'); |
|
| 1048 | - http_status(204); // No Content |
|
| 1049 | - header("Connection: close"); |
|
| 1050 | - define('_DIRECT_CRON_FORCE', true); |
|
| 1051 | - cron(); |
|
| 1046 | + include_spip('inc/headers'); |
|
| 1047 | + http_status(204); // No Content |
|
| 1048 | + header("Connection: close"); |
|
| 1049 | + define('_DIRECT_CRON_FORCE', true); |
|
| 1050 | + cron(); |
|
| 1052 | 1051 | } |
| 1053 | 1052 | |
| 1054 | 1053 | /** |
@@ -1064,26 +1063,26 @@ discard block |
||
| 1064 | 1063 | * True si la tache a pu être effectuée |
| 1065 | 1064 | */ |
| 1066 | 1065 | function cron($taches = array(), $taches_old = array()) { |
| 1067 | - // si pas en mode cron force, laisser tomber. |
|
| 1068 | - if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1069 | - return false; |
|
| 1070 | - } |
|
| 1071 | - if (!is_array($taches)) { |
|
| 1072 | - $taches = $taches_old; |
|
| 1073 | - } // compat anciens appels |
|
| 1074 | - // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1075 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1076 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1077 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1078 | - if ($taches and count($taches) and !spip_connect()) { |
|
| 1079 | - return false; |
|
| 1080 | - } |
|
| 1081 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1082 | - if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1083 | - return $genie($taches); |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - return false; |
|
| 1066 | + // si pas en mode cron force, laisser tomber. |
|
| 1067 | + if (!defined('_DIRECT_CRON_FORCE')) { |
|
| 1068 | + return false; |
|
| 1069 | + } |
|
| 1070 | + if (!is_array($taches)) { |
|
| 1071 | + $taches = $taches_old; |
|
| 1072 | + } // compat anciens appels |
|
| 1073 | + // si taches a inserer en base et base inaccessible, laisser tomber |
|
| 1074 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve |
|
| 1075 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire |
|
| 1076 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php) |
|
| 1077 | + if ($taches and count($taches) and !spip_connect()) { |
|
| 1078 | + return false; |
|
| 1079 | + } |
|
| 1080 | + spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1081 | + if ($genie = charger_fonction('genie', 'inc', true)) { |
|
| 1082 | + return $genie($taches); |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + return false; |
|
| 1087 | 1086 | } |
| 1088 | 1087 | |
| 1089 | 1088 | /** |
@@ -1115,17 +1114,17 @@ discard block |
||
| 1115 | 1114 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté. |
| 1116 | 1115 | */ |
| 1117 | 1116 | function job_queue_add( |
| 1118 | - $function, |
|
| 1119 | - $description, |
|
| 1120 | - $arguments = array(), |
|
| 1121 | - $file = '', |
|
| 1122 | - $no_duplicate = false, |
|
| 1123 | - $time = 0, |
|
| 1124 | - $priority = 0 |
|
| 1117 | + $function, |
|
| 1118 | + $description, |
|
| 1119 | + $arguments = array(), |
|
| 1120 | + $file = '', |
|
| 1121 | + $no_duplicate = false, |
|
| 1122 | + $time = 0, |
|
| 1123 | + $priority = 0 |
|
| 1125 | 1124 | ) { |
| 1126 | - include_spip('inc/queue'); |
|
| 1125 | + include_spip('inc/queue'); |
|
| 1127 | 1126 | |
| 1128 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1127 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority); |
|
| 1129 | 1128 | } |
| 1130 | 1129 | |
| 1131 | 1130 | /** |
@@ -1136,9 +1135,9 @@ discard block |
||
| 1136 | 1135 | * @return bool |
| 1137 | 1136 | */ |
| 1138 | 1137 | function job_queue_remove($id_job) { |
| 1139 | - include_spip('inc/queue'); |
|
| 1138 | + include_spip('inc/queue'); |
|
| 1140 | 1139 | |
| 1141 | - return queue_remove_job($id_job); |
|
| 1140 | + return queue_remove_job($id_job); |
|
| 1142 | 1141 | } |
| 1143 | 1142 | |
| 1144 | 1143 | /** |
@@ -1151,9 +1150,9 @@ discard block |
||
| 1151 | 1150 | * or an array of simple array to link multiples objet in one time |
| 1152 | 1151 | */ |
| 1153 | 1152 | function job_queue_link($id_job, $objets) { |
| 1154 | - include_spip('inc/queue'); |
|
| 1153 | + include_spip('inc/queue'); |
|
| 1155 | 1154 | |
| 1156 | - return queue_link_job($id_job, $objets); |
|
| 1155 | + return queue_link_job($id_job, $objets); |
|
| 1157 | 1156 | } |
| 1158 | 1157 | |
| 1159 | 1158 | |
@@ -1173,36 +1172,36 @@ discard block |
||
| 1173 | 1172 | * - `null` si la queue n'est pas encore initialisée |
| 1174 | 1173 | */ |
| 1175 | 1174 | function queue_sleep_time_to_next_job($force = null) { |
| 1176 | - static $queue_next_job_time = -1; |
|
| 1177 | - if ($force === true) { |
|
| 1178 | - $queue_next_job_time = -1; |
|
| 1179 | - } elseif ($force) { |
|
| 1180 | - $queue_next_job_time = $force; |
|
| 1181 | - } |
|
| 1182 | - |
|
| 1183 | - if ($queue_next_job_time == -1) { |
|
| 1184 | - if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1185 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1186 | - } |
|
| 1187 | - // utiliser un cache memoire si dispo |
|
| 1188 | - if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1189 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1190 | - } else { |
|
| 1191 | - $queue_next_job_time = null; |
|
| 1192 | - if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1193 | - $queue_next_job_time = intval($contenu); |
|
| 1194 | - } |
|
| 1195 | - } |
|
| 1196 | - } |
|
| 1197 | - |
|
| 1198 | - if (is_null($queue_next_job_time)) { |
|
| 1199 | - return null; |
|
| 1200 | - } |
|
| 1201 | - if (!$_SERVER['REQUEST_TIME']) { |
|
| 1202 | - $_SERVER['REQUEST_TIME'] = time(); |
|
| 1203 | - } |
|
| 1204 | - |
|
| 1205 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1175 | + static $queue_next_job_time = -1; |
|
| 1176 | + if ($force === true) { |
|
| 1177 | + $queue_next_job_time = -1; |
|
| 1178 | + } elseif ($force) { |
|
| 1179 | + $queue_next_job_time = $force; |
|
| 1180 | + } |
|
| 1181 | + |
|
| 1182 | + if ($queue_next_job_time == -1) { |
|
| 1183 | + if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
|
| 1184 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1185 | + } |
|
| 1186 | + // utiliser un cache memoire si dispo |
|
| 1187 | + if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 1188 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME); |
|
| 1189 | + } else { |
|
| 1190 | + $queue_next_job_time = null; |
|
| 1191 | + if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { |
|
| 1192 | + $queue_next_job_time = intval($contenu); |
|
| 1193 | + } |
|
| 1194 | + } |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + if (is_null($queue_next_job_time)) { |
|
| 1198 | + return null; |
|
| 1199 | + } |
|
| 1200 | + if (!$_SERVER['REQUEST_TIME']) { |
|
| 1201 | + $_SERVER['REQUEST_TIME'] = time(); |
|
| 1202 | + } |
|
| 1203 | + |
|
| 1204 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME']; |
|
| 1206 | 1205 | } |
| 1207 | 1206 | |
| 1208 | 1207 | |
@@ -1214,9 +1213,9 @@ discard block |
||
| 1214 | 1213 | * @return string |
| 1215 | 1214 | */ |
| 1216 | 1215 | function quote_amp($u) { |
| 1217 | - return preg_replace( |
|
| 1218 | - "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1219 | - "&", $u); |
|
| 1216 | + return preg_replace( |
|
| 1217 | + "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", |
|
| 1218 | + "&", $u); |
|
| 1220 | 1219 | } |
| 1221 | 1220 | |
| 1222 | 1221 | |
@@ -1239,27 +1238,27 @@ discard block |
||
| 1239 | 1238 | * Balise HTML `<script>` et son contenu |
| 1240 | 1239 | **/ |
| 1241 | 1240 | function http_script($script, $src = '', $noscript = '') { |
| 1242 | - static $done = array(); |
|
| 1241 | + static $done = array(); |
|
| 1243 | 1242 | |
| 1244 | - if ($src && !isset($done[$src])) { |
|
| 1245 | - $done[$src] = true; |
|
| 1246 | - $src = find_in_path($src, _JAVASCRIPT); |
|
| 1247 | - $src = " src='$src'"; |
|
| 1248 | - } else { |
|
| 1249 | - $src = ''; |
|
| 1250 | - } |
|
| 1251 | - if ($script) { |
|
| 1252 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1253 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1254 | - "/*]]>*/"); |
|
| 1255 | - } |
|
| 1256 | - if ($noscript) { |
|
| 1257 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1258 | - } |
|
| 1243 | + if ($src && !isset($done[$src])) { |
|
| 1244 | + $done[$src] = true; |
|
| 1245 | + $src = find_in_path($src, _JAVASCRIPT); |
|
| 1246 | + $src = " src='$src'"; |
|
| 1247 | + } else { |
|
| 1248 | + $src = ''; |
|
| 1249 | + } |
|
| 1250 | + if ($script) { |
|
| 1251 | + $script = ("/*<![CDATA[*/\n" . |
|
| 1252 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1253 | + "/*]]>*/"); |
|
| 1254 | + } |
|
| 1255 | + if ($noscript) { |
|
| 1256 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n"; |
|
| 1257 | + } |
|
| 1259 | 1258 | |
| 1260 | - return ($src or $script or $noscript) |
|
| 1261 | - ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1262 | - : ''; |
|
| 1259 | + return ($src or $script or $noscript) |
|
| 1260 | + ? "<script type='text/javascript'$src>$script</script>$noscript" |
|
| 1261 | + : ''; |
|
| 1263 | 1262 | } |
| 1264 | 1263 | |
| 1265 | 1264 | |
@@ -1294,7 +1293,7 @@ discard block |
||
| 1294 | 1293 | * Texte échappé |
| 1295 | 1294 | **/ |
| 1296 | 1295 | function texte_script($texte) { |
| 1297 | - return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1296 | + return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); |
|
| 1298 | 1297 | } |
| 1299 | 1298 | |
| 1300 | 1299 | |
@@ -1331,68 +1330,68 @@ discard block |
||
| 1331 | 1330 | * Liste des chemins, par ordre de priorité. |
| 1332 | 1331 | **/ |
| 1333 | 1332 | function _chemin($dir_path = null) { |
| 1334 | - static $path_base = null; |
|
| 1335 | - static $path_full = null; |
|
| 1336 | - if ($path_base == null) { |
|
| 1337 | - // Chemin standard depuis l'espace public |
|
| 1338 | - $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1339 | - _DIR_RACINE . ':' . |
|
| 1340 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1341 | - _DIR_RACINE . 'prive/:' . |
|
| 1342 | - _DIR_RESTREINT; |
|
| 1343 | - // Ajouter squelettes/ |
|
| 1344 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1345 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1346 | - } |
|
| 1347 | - foreach (explode(':', $path) as $dir) { |
|
| 1348 | - if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1349 | - $dir .= "/"; |
|
| 1350 | - } |
|
| 1351 | - $path_base[] = $dir; |
|
| 1352 | - } |
|
| 1353 | - $path_full = $path_base; |
|
| 1354 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1355 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1356 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1357 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1358 | - } |
|
| 1359 | - } |
|
| 1360 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1361 | - } |
|
| 1362 | - if ($dir_path === null) { |
|
| 1363 | - return $path_full; |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1367 | - $tete = ""; |
|
| 1368 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1369 | - $tete = array_shift($path_base); |
|
| 1370 | - } |
|
| 1371 | - $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1372 | - $dirs = array_reverse($dirs); |
|
| 1373 | - foreach ($dirs as $dir_path) { |
|
| 1374 | - if (substr($dir_path, -1) != '/') { |
|
| 1375 | - $dir_path .= "/"; |
|
| 1376 | - } |
|
| 1377 | - if (!in_array($dir_path, $path_base)) { |
|
| 1378 | - array_unshift($path_base, $dir_path); |
|
| 1379 | - } |
|
| 1380 | - } |
|
| 1381 | - if (strlen($tete)) { |
|
| 1382 | - array_unshift($path_base, $tete); |
|
| 1383 | - } |
|
| 1384 | - } |
|
| 1385 | - $path_full = $path_base; |
|
| 1386 | - // Et le(s) dossier(s) des squelettes nommes |
|
| 1387 | - if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1388 | - foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1389 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - |
|
| 1393 | - $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1394 | - |
|
| 1395 | - return $path_full; |
|
| 1333 | + static $path_base = null; |
|
| 1334 | + static $path_full = null; |
|
| 1335 | + if ($path_base == null) { |
|
| 1336 | + // Chemin standard depuis l'espace public |
|
| 1337 | + $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
|
| 1338 | + _DIR_RACINE . ':' . |
|
| 1339 | + _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1340 | + _DIR_RACINE . 'prive/:' . |
|
| 1341 | + _DIR_RESTREINT; |
|
| 1342 | + // Ajouter squelettes/ |
|
| 1343 | + if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1344 | + $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1345 | + } |
|
| 1346 | + foreach (explode(':', $path) as $dir) { |
|
| 1347 | + if (strlen($dir) and substr($dir, -1) != '/') { |
|
| 1348 | + $dir .= "/"; |
|
| 1349 | + } |
|
| 1350 | + $path_base[] = $dir; |
|
| 1351 | + } |
|
| 1352 | + $path_full = $path_base; |
|
| 1353 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1354 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1355 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1356 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1357 | + } |
|
| 1358 | + } |
|
| 1359 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1360 | + } |
|
| 1361 | + if ($dir_path === null) { |
|
| 1362 | + return $path_full; |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + if (is_array($dir_path) or strlen($dir_path)) { |
|
| 1366 | + $tete = ""; |
|
| 1367 | + if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1368 | + $tete = array_shift($path_base); |
|
| 1369 | + } |
|
| 1370 | + $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
|
| 1371 | + $dirs = array_reverse($dirs); |
|
| 1372 | + foreach ($dirs as $dir_path) { |
|
| 1373 | + if (substr($dir_path, -1) != '/') { |
|
| 1374 | + $dir_path .= "/"; |
|
| 1375 | + } |
|
| 1376 | + if (!in_array($dir_path, $path_base)) { |
|
| 1377 | + array_unshift($path_base, $dir_path); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | + if (strlen($tete)) { |
|
| 1381 | + array_unshift($path_base, $tete); |
|
| 1382 | + } |
|
| 1383 | + } |
|
| 1384 | + $path_full = $path_base; |
|
| 1385 | + // Et le(s) dossier(s) des squelettes nommes |
|
| 1386 | + if (strlen($GLOBALS['dossier_squelettes'])) { |
|
| 1387 | + foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
|
| 1388 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1389 | + } |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + $GLOBALS['path_sig'] = md5(serialize($path_full)); |
|
| 1393 | + |
|
| 1394 | + return $path_full; |
|
| 1396 | 1395 | } |
| 1397 | 1396 | |
| 1398 | 1397 | /** |
@@ -1405,76 +1404,76 @@ discard block |
||
| 1405 | 1404 | * @return array Liste de chemins |
| 1406 | 1405 | **/ |
| 1407 | 1406 | function creer_chemin() { |
| 1408 | - $path_a = _chemin(); |
|
| 1409 | - static $c = ''; |
|
| 1407 | + $path_a = _chemin(); |
|
| 1408 | + static $c = ''; |
|
| 1410 | 1409 | |
| 1411 | - // on calcule le chemin si le dossier skel a change |
|
| 1412 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1413 | - // assurer le non plantage lors de la montee de version : |
|
| 1414 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1415 | - $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1416 | - } |
|
| 1410 | + // on calcule le chemin si le dossier skel a change |
|
| 1411 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1412 | + // assurer le non plantage lors de la montee de version : |
|
| 1413 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1414 | + $path_a = _chemin(''); // forcer un recalcul du chemin |
|
| 1415 | + } |
|
| 1417 | 1416 | |
| 1418 | - return $path_a; |
|
| 1417 | + return $path_a; |
|
| 1419 | 1418 | } |
| 1420 | 1419 | |
| 1421 | 1420 | |
| 1422 | 1421 | function lister_themes_prives() { |
| 1423 | - static $themes = null; |
|
| 1424 | - if (is_null($themes)) { |
|
| 1425 | - // si pas encore definie |
|
| 1426 | - if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1427 | - define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1428 | - } |
|
| 1429 | - $themes = array(_SPIP_THEME_PRIVE); |
|
| 1430 | - // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1431 | - if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1432 | - $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1433 | - } else { |
|
| 1434 | - $prefs = array(); |
|
| 1435 | - } |
|
| 1436 | - if (is_string($prefs)) { |
|
| 1437 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1438 | - } |
|
| 1439 | - if ( |
|
| 1440 | - ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1441 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1442 | - and $theme != _SPIP_THEME_PRIVE |
|
| 1443 | - ) { |
|
| 1444 | - array_unshift($themes, $theme); |
|
| 1445 | - } // placer le theme choisi en tete |
|
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - return $themes; |
|
| 1422 | + static $themes = null; |
|
| 1423 | + if (is_null($themes)) { |
|
| 1424 | + // si pas encore definie |
|
| 1425 | + if (!defined('_SPIP_THEME_PRIVE')) { |
|
| 1426 | + define('_SPIP_THEME_PRIVE', 'spip'); |
|
| 1427 | + } |
|
| 1428 | + $themes = array(_SPIP_THEME_PRIVE); |
|
| 1429 | + // lors d'une installation neuve, prefs n'est pas definie. |
|
| 1430 | + if (isset($GLOBALS['visiteur_session']['prefs'])) { |
|
| 1431 | + $prefs = $GLOBALS['visiteur_session']['prefs']; |
|
| 1432 | + } else { |
|
| 1433 | + $prefs = array(); |
|
| 1434 | + } |
|
| 1435 | + if (is_string($prefs)) { |
|
| 1436 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']); |
|
| 1437 | + } |
|
| 1438 | + if ( |
|
| 1439 | + ((isset($prefs['theme']) and $theme = $prefs['theme']) |
|
| 1440 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut'])) |
|
| 1441 | + and $theme != _SPIP_THEME_PRIVE |
|
| 1442 | + ) { |
|
| 1443 | + array_unshift($themes, $theme); |
|
| 1444 | + } // placer le theme choisi en tete |
|
| 1445 | + } |
|
| 1446 | + |
|
| 1447 | + return $themes; |
|
| 1449 | 1448 | } |
| 1450 | 1449 | |
| 1451 | 1450 | function find_in_theme($file, $subdir = '', $include = false) { |
| 1452 | - static $themefiles = array(); |
|
| 1453 | - if (isset($themefiles["$subdir$file"])) { |
|
| 1454 | - return $themefiles["$subdir$file"]; |
|
| 1455 | - } |
|
| 1456 | - // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1457 | - // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1458 | - if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1459 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1460 | - and $f = find_in_theme("$file_svg_generique")) { |
|
| 1461 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1462 | - return $themefiles["$subdir$file"] = $fsize; |
|
| 1463 | - } |
|
| 1464 | - else { |
|
| 1465 | - return $themefiles["$subdir$file"] = "$f?".$m[1]."px"; |
|
| 1466 | - } |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - $themes = lister_themes_prives(); |
|
| 1470 | - foreach ($themes as $theme) { |
|
| 1471 | - if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1472 | - return $themefiles["$subdir$file"] = $f; |
|
| 1473 | - } |
|
| 1474 | - } |
|
| 1475 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1476 | - |
|
| 1477 | - return $themefiles["$subdir$file"] = ""; |
|
| 1451 | + static $themefiles = array(); |
|
| 1452 | + if (isset($themefiles["$subdir$file"])) { |
|
| 1453 | + return $themefiles["$subdir$file"]; |
|
| 1454 | + } |
|
| 1455 | + // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
|
| 1456 | + // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
|
| 1457 | + if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
|
| 1458 | + and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1459 | + and $f = find_in_theme("$file_svg_generique")) { |
|
| 1460 | + if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1461 | + return $themefiles["$subdir$file"] = $fsize; |
|
| 1462 | + } |
|
| 1463 | + else { |
|
| 1464 | + return $themefiles["$subdir$file"] = "$f?".$m[1]."px"; |
|
| 1465 | + } |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + $themes = lister_themes_prives(); |
|
| 1469 | + foreach ($themes as $theme) { |
|
| 1470 | + if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { |
|
| 1471 | + return $themefiles["$subdir$file"] = $f; |
|
| 1472 | + } |
|
| 1473 | + } |
|
| 1474 | + spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1475 | + |
|
| 1476 | + return $themefiles["$subdir$file"] = ""; |
|
| 1478 | 1477 | } |
| 1479 | 1478 | |
| 1480 | 1479 | |
@@ -1498,31 +1497,31 @@ discard block |
||
| 1498 | 1497 | * sinon chaîne vide. |
| 1499 | 1498 | **/ |
| 1500 | 1499 | function chemin_image($icone) { |
| 1501 | - static $icone_renommer; |
|
| 1502 | - if ($p = strpos($icone, '?')) { |
|
| 1503 | - $icone = substr($icone,0, $p); |
|
| 1504 | - } |
|
| 1505 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1506 | - if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1507 | - return $icone; |
|
| 1508 | - } |
|
| 1509 | - |
|
| 1510 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1511 | - if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1512 | - return $f; |
|
| 1513 | - } |
|
| 1514 | - // sinon passer par le module de renommage |
|
| 1515 | - if (is_null($icone_renommer)) { |
|
| 1516 | - $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1517 | - } |
|
| 1518 | - if ($icone_renommer) { |
|
| 1519 | - list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1520 | - if (file_exists($icone)) { |
|
| 1521 | - return $icone; |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1500 | + static $icone_renommer; |
|
| 1501 | + if ($p = strpos($icone, '?')) { |
|
| 1502 | + $icone = substr($icone,0, $p); |
|
| 1503 | + } |
|
| 1504 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
|
| 1505 | + if (strpos($icone, "/") !== false and file_exists($icone)) { |
|
| 1506 | + return $icone; |
|
| 1507 | + } |
|
| 1508 | + |
|
| 1509 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct |
|
| 1510 | + if (preg_match(',[.](png|gif|jpg|webp|svg)$,', $icone) and $f = find_in_theme("images/$icone")) { |
|
| 1511 | + return $f; |
|
| 1512 | + } |
|
| 1513 | + // sinon passer par le module de renommage |
|
| 1514 | + if (is_null($icone_renommer)) { |
|
| 1515 | + $icone_renommer = charger_fonction('icone_renommer', 'inc', true); |
|
| 1516 | + } |
|
| 1517 | + if ($icone_renommer) { |
|
| 1518 | + list($icone, $fonction) = $icone_renommer($icone, ""); |
|
| 1519 | + if (file_exists($icone)) { |
|
| 1520 | + return $icone; |
|
| 1521 | + } |
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + return find_in_path($icone, _NOM_IMG_PACK); |
|
| 1526 | 1525 | } |
| 1527 | 1526 | |
| 1528 | 1527 | // |
@@ -1560,127 +1559,127 @@ discard block |
||
| 1560 | 1559 | * - false : fichier introuvable |
| 1561 | 1560 | **/ |
| 1562 | 1561 | function find_in_path($file, $dirname = '', $include = false) { |
| 1563 | - static $dirs = array(); |
|
| 1564 | - static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1565 | - static $c = ''; |
|
| 1566 | - |
|
| 1567 | - if (!$file and !strlen($file)) { |
|
| 1568 | - return false; |
|
| 1569 | - } |
|
| 1570 | - |
|
| 1571 | - // on calcule le chemin si le dossier skel a change |
|
| 1572 | - if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1573 | - // assurer le non plantage lors de la montee de version : |
|
| 1574 | - $c = $GLOBALS['dossier_squelettes']; |
|
| 1575 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1576 | - } |
|
| 1577 | - |
|
| 1578 | - if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1579 | - if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1580 | - return false; |
|
| 1581 | - } |
|
| 1582 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1583 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1584 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1588 | - } |
|
| 1589 | - |
|
| 1590 | - $a = strrpos($file, '/'); |
|
| 1591 | - if ($a !== false) { |
|
| 1592 | - $dirname .= substr($file, 0, ++$a); |
|
| 1593 | - $file = substr($file, $a); |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - foreach (creer_chemin() as $dir) { |
|
| 1597 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1598 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1599 | - } |
|
| 1600 | - if ($dirs[$a]) { |
|
| 1601 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1602 | - if ($include and !isset($inc[$dirname][$file])) { |
|
| 1603 | - include_once _ROOT_CWD . $a; |
|
| 1604 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1605 | - } |
|
| 1606 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1607 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1608 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1609 | - return $a; |
|
| 1610 | - } |
|
| 1611 | - define('_SAUVER_CHEMIN', true); |
|
| 1612 | - } |
|
| 1613 | - |
|
| 1614 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1615 | - } |
|
| 1616 | - } |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - if ($include) { |
|
| 1620 | - spip_log("include_spip $dirname$file non trouve"); |
|
| 1621 | - if ($include === 'required') { |
|
| 1622 | - echo '<pre>', |
|
| 1623 | - "<strong>Erreur Fatale</strong><br />"; |
|
| 1624 | - if (function_exists('debug_print_backtrace')) { |
|
| 1625 | - echo debug_print_backtrace(); |
|
| 1626 | - } |
|
| 1627 | - echo '</pre>'; |
|
| 1628 | - die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1629 | - } |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - if (!defined('_SAUVER_CHEMIN')) { |
|
| 1633 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1634 | - if (is_null($GLOBALS['path_files'])) { |
|
| 1635 | - return false; |
|
| 1636 | - } |
|
| 1637 | - define('_SAUVER_CHEMIN', true); |
|
| 1638 | - } |
|
| 1639 | - |
|
| 1640 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1562 | + static $dirs = array(); |
|
| 1563 | + static $inc = array(); # cf https://git.spip.net/spip/spip/commit/42e4e028e38c839121efaee84308d08aee307eec |
|
| 1564 | + static $c = ''; |
|
| 1565 | + |
|
| 1566 | + if (!$file and !strlen($file)) { |
|
| 1567 | + return false; |
|
| 1568 | + } |
|
| 1569 | + |
|
| 1570 | + // on calcule le chemin si le dossier skel a change |
|
| 1571 | + if ($c != $GLOBALS['dossier_squelettes']) { |
|
| 1572 | + // assurer le non plantage lors de la montee de version : |
|
| 1573 | + $c = $GLOBALS['dossier_squelettes']; |
|
| 1574 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig |
|
| 1575 | + } |
|
| 1576 | + |
|
| 1577 | + if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { |
|
| 1578 | + if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { |
|
| 1579 | + return false; |
|
| 1580 | + } |
|
| 1581 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1582 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1583 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1584 | + } |
|
| 1585 | + |
|
| 1586 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1587 | + } |
|
| 1588 | + |
|
| 1589 | + $a = strrpos($file, '/'); |
|
| 1590 | + if ($a !== false) { |
|
| 1591 | + $dirname .= substr($file, 0, ++$a); |
|
| 1592 | + $file = substr($file, $a); |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + foreach (creer_chemin() as $dir) { |
|
| 1596 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1597 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1598 | + } |
|
| 1599 | + if ($dirs[$a]) { |
|
| 1600 | + if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1601 | + if ($include and !isset($inc[$dirname][$file])) { |
|
| 1602 | + include_once _ROOT_CWD . $a; |
|
| 1603 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1604 | + } |
|
| 1605 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1606 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1607 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1608 | + return $a; |
|
| 1609 | + } |
|
| 1610 | + define('_SAUVER_CHEMIN', true); |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1614 | + } |
|
| 1615 | + } |
|
| 1616 | + } |
|
| 1617 | + |
|
| 1618 | + if ($include) { |
|
| 1619 | + spip_log("include_spip $dirname$file non trouve"); |
|
| 1620 | + if ($include === 'required') { |
|
| 1621 | + echo '<pre>', |
|
| 1622 | + "<strong>Erreur Fatale</strong><br />"; |
|
| 1623 | + if (function_exists('debug_print_backtrace')) { |
|
| 1624 | + echo debug_print_backtrace(); |
|
| 1625 | + } |
|
| 1626 | + echo '</pre>'; |
|
| 1627 | + die("Erreur interne: ne peut inclure $dirname$file"); |
|
| 1628 | + } |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + if (!defined('_SAUVER_CHEMIN')) { |
|
| 1632 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
|
| 1633 | + if (is_null($GLOBALS['path_files'])) { |
|
| 1634 | + return false; |
|
| 1635 | + } |
|
| 1636 | + define('_SAUVER_CHEMIN', true); |
|
| 1637 | + } |
|
| 1638 | + |
|
| 1639 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1641 | 1640 | } |
| 1642 | 1641 | |
| 1643 | 1642 | function clear_path_cache() { |
| 1644 | - $GLOBALS['path_files'] = array(); |
|
| 1645 | - spip_unlink(_CACHE_CHEMIN); |
|
| 1643 | + $GLOBALS['path_files'] = array(); |
|
| 1644 | + spip_unlink(_CACHE_CHEMIN); |
|
| 1646 | 1645 | } |
| 1647 | 1646 | |
| 1648 | 1647 | function load_path_cache() { |
| 1649 | - // charger le path des plugins |
|
| 1650 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1651 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1652 | - } |
|
| 1653 | - $GLOBALS['path_files'] = array(); |
|
| 1654 | - // si le visiteur est admin, |
|
| 1655 | - // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1656 | - if ( |
|
| 1657 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1658 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1659 | - // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1660 | - // on blinde par un second test au moment de la lecture de la session |
|
| 1661 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1662 | - // et en ignorant ce cache en cas de recalcul explicite |
|
| 1663 | - !_request('var_mode') |
|
| 1664 | - ) { |
|
| 1665 | - // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1666 | - if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1667 | - // mais si semble corrompu on relit avec un verrou |
|
| 1668 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1669 | - lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1670 | - if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1671 | - $GLOBALS['path_files'] = array(); |
|
| 1672 | - } |
|
| 1673 | - } |
|
| 1674 | - } |
|
| 1675 | - } |
|
| 1648 | + // charger le path des plugins |
|
| 1649 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1650 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1651 | + } |
|
| 1652 | + $GLOBALS['path_files'] = array(); |
|
| 1653 | + // si le visiteur est admin, |
|
| 1654 | + // on ne recharge pas le cache pour forcer sa mise a jour |
|
| 1655 | + if ( |
|
| 1656 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier |
|
| 1657 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo') |
|
| 1658 | + // utiliser le cookie est un pis aller qui marche 'en general' |
|
| 1659 | + // on blinde par un second test au moment de la lecture de la session |
|
| 1660 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin']) |
|
| 1661 | + // et en ignorant ce cache en cas de recalcul explicite |
|
| 1662 | + !_request('var_mode') |
|
| 1663 | + ) { |
|
| 1664 | + // on essaye de lire directement sans verrou pour aller plus vite |
|
| 1665 | + if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { |
|
| 1666 | + // mais si semble corrompu on relit avec un verrou |
|
| 1667 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1668 | + lire_fichier(_CACHE_CHEMIN, $contenu); |
|
| 1669 | + if (!$GLOBALS['path_files'] = unserialize($contenu)) { |
|
| 1670 | + $GLOBALS['path_files'] = array(); |
|
| 1671 | + } |
|
| 1672 | + } |
|
| 1673 | + } |
|
| 1674 | + } |
|
| 1676 | 1675 | } |
| 1677 | 1676 | |
| 1678 | 1677 | function save_path_cache() { |
| 1679 | - if (defined('_SAUVER_CHEMIN') |
|
| 1680 | - and _SAUVER_CHEMIN |
|
| 1681 | - ) { |
|
| 1682 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1683 | - } |
|
| 1678 | + if (defined('_SAUVER_CHEMIN') |
|
| 1679 | + and _SAUVER_CHEMIN |
|
| 1680 | + ) { |
|
| 1681 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files'])); |
|
| 1682 | + } |
|
| 1684 | 1683 | } |
| 1685 | 1684 | |
| 1686 | 1685 | |
@@ -1700,33 +1699,33 @@ discard block |
||
| 1700 | 1699 | * @return array |
| 1701 | 1700 | */ |
| 1702 | 1701 | function find_all_in_path($dir, $pattern, $recurs = false) { |
| 1703 | - $liste_fichiers = array(); |
|
| 1704 | - $maxfiles = 10000; |
|
| 1705 | - |
|
| 1706 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1707 | - // on a pas encore inclus flock.php |
|
| 1708 | - if (!function_exists('preg_files')) { |
|
| 1709 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1710 | - } |
|
| 1711 | - |
|
| 1712 | - // Parcourir le chemin |
|
| 1713 | - foreach (creer_chemin() as $d) { |
|
| 1714 | - $f = $d . $dir; |
|
| 1715 | - if (@is_dir($f)) { |
|
| 1716 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1717 | - foreach ($liste as $chemin) { |
|
| 1718 | - $nom = basename($chemin); |
|
| 1719 | - // ne prendre que les fichiers pas deja trouves |
|
| 1720 | - // car find_in_path prend le premier qu'il trouve, |
|
| 1721 | - // les autres sont donc masques |
|
| 1722 | - if (!isset($liste_fichiers[$nom])) { |
|
| 1723 | - $liste_fichiers[$nom] = $chemin; |
|
| 1724 | - } |
|
| 1725 | - } |
|
| 1726 | - } |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - return $liste_fichiers; |
|
| 1702 | + $liste_fichiers = array(); |
|
| 1703 | + $maxfiles = 10000; |
|
| 1704 | + |
|
| 1705 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
|
| 1706 | + // on a pas encore inclus flock.php |
|
| 1707 | + if (!function_exists('preg_files')) { |
|
| 1708 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1709 | + } |
|
| 1710 | + |
|
| 1711 | + // Parcourir le chemin |
|
| 1712 | + foreach (creer_chemin() as $d) { |
|
| 1713 | + $f = $d . $dir; |
|
| 1714 | + if (@is_dir($f)) { |
|
| 1715 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
|
| 1716 | + foreach ($liste as $chemin) { |
|
| 1717 | + $nom = basename($chemin); |
|
| 1718 | + // ne prendre que les fichiers pas deja trouves |
|
| 1719 | + // car find_in_path prend le premier qu'il trouve, |
|
| 1720 | + // les autres sont donc masques |
|
| 1721 | + if (!isset($liste_fichiers[$nom])) { |
|
| 1722 | + $liste_fichiers[$nom] = $chemin; |
|
| 1723 | + } |
|
| 1724 | + } |
|
| 1725 | + } |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + return $liste_fichiers; |
|
| 1730 | 1729 | } |
| 1731 | 1730 | |
| 1732 | 1731 | /** |
@@ -1738,17 +1737,17 @@ discard block |
||
| 1738 | 1737 | * @return bool |
| 1739 | 1738 | */ |
| 1740 | 1739 | function autoriser_sans_cookie($nom, $strict = false) { |
| 1741 | - static $autsanscookie = array('install', 'base_repair'); |
|
| 1740 | + static $autsanscookie = array('install', 'base_repair'); |
|
| 1742 | 1741 | |
| 1743 | - if (in_array($nom, $autsanscookie)) { |
|
| 1744 | - if (test_espace_prive()){ |
|
| 1745 | - include_spip('base/connect_sql'); |
|
| 1746 | - if (!$strict or !spip_connect()){ |
|
| 1747 | - return true; |
|
| 1748 | - } |
|
| 1749 | - } |
|
| 1750 | - } |
|
| 1751 | - return false; |
|
| 1742 | + if (in_array($nom, $autsanscookie)) { |
|
| 1743 | + if (test_espace_prive()){ |
|
| 1744 | + include_spip('base/connect_sql'); |
|
| 1745 | + if (!$strict or !spip_connect()){ |
|
| 1746 | + return true; |
|
| 1747 | + } |
|
| 1748 | + } |
|
| 1749 | + } |
|
| 1750 | + return false; |
|
| 1752 | 1751 | } |
| 1753 | 1752 | |
| 1754 | 1753 | /** |
@@ -1774,99 +1773,99 @@ discard block |
||
| 1774 | 1773 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip) |
| 1775 | 1774 | */ |
| 1776 | 1775 | function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { |
| 1777 | - if ($public === null) { |
|
| 1778 | - $public = !test_espace_prive(); |
|
| 1779 | - } |
|
| 1780 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1781 | - |
|
| 1782 | - if (!$public) { |
|
| 1783 | - if (!$entite) { |
|
| 1784 | - return ''; |
|
| 1785 | - } |
|
| 1786 | - if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1787 | - include_spip('inc/urls'); |
|
| 1788 | - } |
|
| 1789 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1790 | - } else { |
|
| 1791 | - if ($type === null) { |
|
| 1792 | - $type = (isset($GLOBALS['type_urls'])) |
|
| 1793 | - ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1794 | - : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1795 | - ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1796 | - } |
|
| 1797 | - |
|
| 1798 | - $f = charger_fonction($type, 'urls', true); |
|
| 1799 | - // se rabattre sur les urls page si les urls perso non dispo |
|
| 1800 | - if (!$f) { |
|
| 1801 | - $f = charger_fonction('page', 'urls', true); |
|
| 1802 | - } |
|
| 1803 | - |
|
| 1804 | - // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1805 | - // sinon on veut effectuer le passage id ==> URL |
|
| 1806 | - if (!$entite) { |
|
| 1807 | - return $f; |
|
| 1808 | - } |
|
| 1809 | - |
|
| 1810 | - // mais d'abord il faut tester le cas des urls sur une |
|
| 1811 | - // base distante |
|
| 1812 | - if (is_string($public) |
|
| 1813 | - and $g = charger_fonction('connect', 'urls', true) |
|
| 1814 | - ) { |
|
| 1815 | - $f = $g; |
|
| 1816 | - } |
|
| 1817 | - |
|
| 1818 | - $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1819 | - |
|
| 1820 | - } |
|
| 1821 | - if ($res) { |
|
| 1822 | - return $res; |
|
| 1823 | - } |
|
| 1824 | - // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1825 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1826 | - if (!function_exists($f .= '_dist')) { |
|
| 1827 | - $f = ''; |
|
| 1828 | - } |
|
| 1829 | - } |
|
| 1830 | - if ($f) { |
|
| 1831 | - $url = $f($id, $args, $ancre); |
|
| 1832 | - if (strlen($args)) { |
|
| 1833 | - $url .= strstr($url, '?') |
|
| 1834 | - ? '&' . $args |
|
| 1835 | - : '?' . $args; |
|
| 1836 | - } |
|
| 1837 | - |
|
| 1838 | - return $url; |
|
| 1839 | - } |
|
| 1840 | - // On a ete gentil mais la .... |
|
| 1841 | - spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1842 | - |
|
| 1843 | - return ''; |
|
| 1776 | + if ($public === null) { |
|
| 1777 | + $public = !test_espace_prive(); |
|
| 1778 | + } |
|
| 1779 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet... |
|
| 1780 | + |
|
| 1781 | + if (!$public) { |
|
| 1782 | + if (!$entite) { |
|
| 1783 | + return ''; |
|
| 1784 | + } |
|
| 1785 | + if (!function_exists('generer_url_ecrire_objet')) { |
|
| 1786 | + include_spip('inc/urls'); |
|
| 1787 | + } |
|
| 1788 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false); |
|
| 1789 | + } else { |
|
| 1790 | + if ($type === null) { |
|
| 1791 | + $type = (isset($GLOBALS['type_urls'])) |
|
| 1792 | + ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options |
|
| 1793 | + : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues |
|
| 1794 | + ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + $f = charger_fonction($type, 'urls', true); |
|
| 1798 | + // se rabattre sur les urls page si les urls perso non dispo |
|
| 1799 | + if (!$f) { |
|
| 1800 | + $f = charger_fonction('page', 'urls', true); |
|
| 1801 | + } |
|
| 1802 | + |
|
| 1803 | + // si $entite='', on veut la fonction de passage URL ==> id |
|
| 1804 | + // sinon on veut effectuer le passage id ==> URL |
|
| 1805 | + if (!$entite) { |
|
| 1806 | + return $f; |
|
| 1807 | + } |
|
| 1808 | + |
|
| 1809 | + // mais d'abord il faut tester le cas des urls sur une |
|
| 1810 | + // base distante |
|
| 1811 | + if (is_string($public) |
|
| 1812 | + and $g = charger_fonction('connect', 'urls', true) |
|
| 1813 | + ) { |
|
| 1814 | + $f = $g; |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + $res = $f(intval($id), $entite, $args, $ancre, $public); |
|
| 1818 | + |
|
| 1819 | + } |
|
| 1820 | + if ($res) { |
|
| 1821 | + return $res; |
|
| 1822 | + } |
|
| 1823 | + // Sinon c'est un raccourci ou compat SPIP < 2 |
|
| 1824 | + if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1825 | + if (!function_exists($f .= '_dist')) { |
|
| 1826 | + $f = ''; |
|
| 1827 | + } |
|
| 1828 | + } |
|
| 1829 | + if ($f) { |
|
| 1830 | + $url = $f($id, $args, $ancre); |
|
| 1831 | + if (strlen($args)) { |
|
| 1832 | + $url .= strstr($url, '?') |
|
| 1833 | + ? '&' . $args |
|
| 1834 | + : '?' . $args; |
|
| 1835 | + } |
|
| 1836 | + |
|
| 1837 | + return $url; |
|
| 1838 | + } |
|
| 1839 | + // On a ete gentil mais la .... |
|
| 1840 | + spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); |
|
| 1841 | + |
|
| 1842 | + return ''; |
|
| 1844 | 1843 | } |
| 1845 | 1844 | |
| 1846 | 1845 | function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { |
| 1847 | - $exec = objet_info($entite, 'url_edit'); |
|
| 1848 | - $url = generer_url_ecrire($exec, $args); |
|
| 1849 | - if (intval($id)) { |
|
| 1850 | - $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1851 | - } else { |
|
| 1852 | - $url = parametre_url($url, 'new', 'oui'); |
|
| 1853 | - } |
|
| 1854 | - if ($ancre) { |
|
| 1855 | - $url = ancre_url($url, $ancre); |
|
| 1856 | - } |
|
| 1846 | + $exec = objet_info($entite, 'url_edit'); |
|
| 1847 | + $url = generer_url_ecrire($exec, $args); |
|
| 1848 | + if (intval($id)) { |
|
| 1849 | + $url = parametre_url($url, id_table_objet($entite), $id); |
|
| 1850 | + } else { |
|
| 1851 | + $url = parametre_url($url, 'new', 'oui'); |
|
| 1852 | + } |
|
| 1853 | + if ($ancre) { |
|
| 1854 | + $url = ancre_url($url, $ancre); |
|
| 1855 | + } |
|
| 1857 | 1856 | |
| 1858 | - return $url; |
|
| 1857 | + return $url; |
|
| 1859 | 1858 | } |
| 1860 | 1859 | |
| 1861 | 1860 | // https://code.spip.net/@urls_connect_dist |
| 1862 | 1861 | function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { |
| 1863 | - include_spip('base/connect_sql'); |
|
| 1864 | - $id_type = id_table_objet($entite, $public); |
|
| 1862 | + include_spip('base/connect_sql'); |
|
| 1863 | + $id_type = id_table_objet($entite, $public); |
|
| 1865 | 1864 | |
| 1866 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1867 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1868 | - . (!$args ? '' : "&$args") |
|
| 1869 | - . (!$ancre ? '' : "#$ancre"); |
|
| 1865 | + return _DIR_RACINE . get_spip_script('./') |
|
| 1866 | + . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1867 | + . (!$args ? '' : "&$args") |
|
| 1868 | + . (!$ancre ? '' : "#$ancre"); |
|
| 1870 | 1869 | } |
| 1871 | 1870 | |
| 1872 | 1871 | |
@@ -1877,32 +1876,32 @@ discard block |
||
| 1877 | 1876 | * @return string |
| 1878 | 1877 | */ |
| 1879 | 1878 | function urlencode_1738($url) { |
| 1880 | - if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1881 | - $uri = ''; |
|
| 1882 | - for ($i = 0; $i < strlen($url); $i++) { |
|
| 1883 | - if (ord($a = $url[$i]) > 127) { |
|
| 1884 | - $a = rawurlencode($a); |
|
| 1885 | - } |
|
| 1886 | - $uri .= $a; |
|
| 1887 | - } |
|
| 1888 | - $url = $uri; |
|
| 1889 | - } |
|
| 1879 | + if (preg_match(',[^\x00-\x7E],sS', $url)) { |
|
| 1880 | + $uri = ''; |
|
| 1881 | + for ($i = 0; $i < strlen($url); $i++) { |
|
| 1882 | + if (ord($a = $url[$i]) > 127) { |
|
| 1883 | + $a = rawurlencode($a); |
|
| 1884 | + } |
|
| 1885 | + $uri .= $a; |
|
| 1886 | + } |
|
| 1887 | + $url = $uri; |
|
| 1888 | + } |
|
| 1890 | 1889 | |
| 1891 | - return quote_amp($url); |
|
| 1890 | + return quote_amp($url); |
|
| 1892 | 1891 | } |
| 1893 | 1892 | |
| 1894 | 1893 | // https://code.spip.net/@generer_url_entite_absolue |
| 1895 | 1894 | function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { |
| 1896 | - if (!$connect) { |
|
| 1897 | - $connect = true; |
|
| 1898 | - } |
|
| 1899 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1900 | - if (!preg_match(',^\w+:,', $h)) { |
|
| 1901 | - include_spip('inc/filtres_mini'); |
|
| 1902 | - $h = url_absolue($h); |
|
| 1903 | - } |
|
| 1895 | + if (!$connect) { |
|
| 1896 | + $connect = true; |
|
| 1897 | + } |
|
| 1898 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect); |
|
| 1899 | + if (!preg_match(',^\w+:,', $h)) { |
|
| 1900 | + include_spip('inc/filtres_mini'); |
|
| 1901 | + $h = url_absolue($h); |
|
| 1902 | + } |
|
| 1904 | 1903 | |
| 1905 | - return $h; |
|
| 1904 | + return $h; |
|
| 1906 | 1905 | } |
| 1907 | 1906 | |
| 1908 | 1907 | |
@@ -1918,11 +1917,11 @@ discard block |
||
| 1918 | 1917 | * true si la valeur est considérée active ; false sinon. |
| 1919 | 1918 | **/ |
| 1920 | 1919 | function test_valeur_serveur($truc) { |
| 1921 | - if (!$truc) { |
|
| 1922 | - return false; |
|
| 1923 | - } |
|
| 1920 | + if (!$truc) { |
|
| 1921 | + return false; |
|
| 1922 | + } |
|
| 1924 | 1923 | |
| 1925 | - return (strtolower($truc) !== 'off'); |
|
| 1924 | + return (strtolower($truc) !== 'off'); |
|
| 1926 | 1925 | } |
| 1927 | 1926 | |
| 1928 | 1927 | // |
@@ -1950,80 +1949,80 @@ discard block |
||
| 1950 | 1949 | */ |
| 1951 | 1950 | function url_de_base($profondeur = null) { |
| 1952 | 1951 | |
| 1953 | - static $url = array(); |
|
| 1954 | - if (is_array($profondeur)) { |
|
| 1955 | - return $url = $profondeur; |
|
| 1956 | - } |
|
| 1957 | - if ($profondeur === false) { |
|
| 1958 | - return $url; |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - if (is_null($profondeur)) { |
|
| 1962 | - $profondeur = $GLOBALS['profondeur_url']; |
|
| 1963 | - } |
|
| 1964 | - |
|
| 1965 | - if (isset($url[$profondeur])) { |
|
| 1966 | - return $url[$profondeur]; |
|
| 1967 | - } |
|
| 1968 | - |
|
| 1969 | - $http = 'http'; |
|
| 1970 | - |
|
| 1971 | - if ( |
|
| 1972 | - isset($_SERVER["SCRIPT_URI"]) |
|
| 1973 | - and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1974 | - ) { |
|
| 1975 | - $http = 'https'; |
|
| 1976 | - } elseif ( |
|
| 1977 | - isset($_SERVER['HTTPS']) |
|
| 1978 | - and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1979 | - ) { |
|
| 1980 | - $http = 'https'; |
|
| 1981 | - } |
|
| 1982 | - |
|
| 1983 | - // note : HTTP_HOST contient le :port si necessaire |
|
| 1984 | - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1985 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1986 | - if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1987 | - $host = $GLOBALS['meta']['adresse_site']; |
|
| 1988 | - if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1989 | - $http = $scheme; |
|
| 1990 | - $host = str_replace("{$scheme}://", '', $host); |
|
| 1991 | - } |
|
| 1992 | - } |
|
| 1993 | - if (isset($_SERVER['SERVER_PORT']) |
|
| 1994 | - and $port = $_SERVER['SERVER_PORT'] |
|
| 1995 | - and strpos($host, ":") == false |
|
| 1996 | - ) { |
|
| 1997 | - if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1998 | - define('_PORT_HTTP_STANDARD', '80'); |
|
| 1999 | - } |
|
| 2000 | - if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2001 | - define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2002 | - } |
|
| 2003 | - if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2004 | - $host .= ":$port"; |
|
| 2005 | - } |
|
| 2006 | - if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2007 | - $host .= ":$port"; |
|
| 2008 | - } |
|
| 2009 | - } |
|
| 2010 | - |
|
| 2011 | - if (!$GLOBALS['REQUEST_URI']) { |
|
| 2012 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2013 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2014 | - } else { |
|
| 2015 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2016 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2017 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2018 | - ) { |
|
| 2019 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2020 | - } |
|
| 2021 | - } |
|
| 2022 | - } |
|
| 2023 | - |
|
| 2024 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2025 | - |
|
| 2026 | - return $url[$profondeur]; |
|
| 1952 | + static $url = array(); |
|
| 1953 | + if (is_array($profondeur)) { |
|
| 1954 | + return $url = $profondeur; |
|
| 1955 | + } |
|
| 1956 | + if ($profondeur === false) { |
|
| 1957 | + return $url; |
|
| 1958 | + } |
|
| 1959 | + |
|
| 1960 | + if (is_null($profondeur)) { |
|
| 1961 | + $profondeur = $GLOBALS['profondeur_url']; |
|
| 1962 | + } |
|
| 1963 | + |
|
| 1964 | + if (isset($url[$profondeur])) { |
|
| 1965 | + return $url[$profondeur]; |
|
| 1966 | + } |
|
| 1967 | + |
|
| 1968 | + $http = 'http'; |
|
| 1969 | + |
|
| 1970 | + if ( |
|
| 1971 | + isset($_SERVER["SCRIPT_URI"]) |
|
| 1972 | + and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https' |
|
| 1973 | + ) { |
|
| 1974 | + $http = 'https'; |
|
| 1975 | + } elseif ( |
|
| 1976 | + isset($_SERVER['HTTPS']) |
|
| 1977 | + and test_valeur_serveur($_SERVER['HTTPS']) |
|
| 1978 | + ) { |
|
| 1979 | + $http = 'https'; |
|
| 1980 | + } |
|
| 1981 | + |
|
| 1982 | + // note : HTTP_HOST contient le :port si necessaire |
|
| 1983 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; |
|
| 1984 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback |
|
| 1985 | + if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { |
|
| 1986 | + $host = $GLOBALS['meta']['adresse_site']; |
|
| 1987 | + if ($scheme = parse_url($host, PHP_URL_SCHEME)) { |
|
| 1988 | + $http = $scheme; |
|
| 1989 | + $host = str_replace("{$scheme}://", '', $host); |
|
| 1990 | + } |
|
| 1991 | + } |
|
| 1992 | + if (isset($_SERVER['SERVER_PORT']) |
|
| 1993 | + and $port = $_SERVER['SERVER_PORT'] |
|
| 1994 | + and strpos($host, ":") == false |
|
| 1995 | + ) { |
|
| 1996 | + if (!defined('_PORT_HTTP_STANDARD')) { |
|
| 1997 | + define('_PORT_HTTP_STANDARD', '80'); |
|
| 1998 | + } |
|
| 1999 | + if (!defined('_PORT_HTTPS_STANDARD')) { |
|
| 2000 | + define('_PORT_HTTPS_STANDARD', '443'); |
|
| 2001 | + } |
|
| 2002 | + if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { |
|
| 2003 | + $host .= ":$port"; |
|
| 2004 | + } |
|
| 2005 | + if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { |
|
| 2006 | + $host .= ":$port"; |
|
| 2007 | + } |
|
| 2008 | + } |
|
| 2009 | + |
|
| 2010 | + if (!$GLOBALS['REQUEST_URI']) { |
|
| 2011 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2012 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2013 | + } else { |
|
| 2014 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2015 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2016 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2017 | + ) { |
|
| 2018 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2019 | + } |
|
| 2020 | + } |
|
| 2021 | + } |
|
| 2022 | + |
|
| 2023 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur); |
|
| 2024 | + |
|
| 2025 | + return $url[$profondeur]; |
|
| 2027 | 2026 | } |
| 2028 | 2027 | |
| 2029 | 2028 | /** |
@@ -2036,26 +2035,26 @@ discard block |
||
| 2036 | 2035 | * @return string |
| 2037 | 2036 | */ |
| 2038 | 2037 | function url_de_($http, $host, $request, $prof = 0) { |
| 2039 | - $prof = max($prof, 0); |
|
| 2038 | + $prof = max($prof, 0); |
|
| 2040 | 2039 | |
| 2041 | - $myself = ltrim($request, '/'); |
|
| 2042 | - # supprimer la chaine de GET |
|
| 2043 | - list($myself) = explode('?', $myself); |
|
| 2044 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2045 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2046 | - if (strpos($myself,'://') !== false) { |
|
| 2047 | - $myself = explode('://',$myself); |
|
| 2048 | - array_shift($myself); |
|
| 2049 | - $myself = implode('://',$myself); |
|
| 2050 | - $myself = explode('/',$myself); |
|
| 2051 | - array_shift($myself); |
|
| 2052 | - $myself = implode('/',$myself); |
|
| 2053 | - } |
|
| 2054 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2040 | + $myself = ltrim($request, '/'); |
|
| 2041 | + # supprimer la chaine de GET |
|
| 2042 | + list($myself) = explode('?', $myself); |
|
| 2043 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
|
| 2044 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
|
| 2045 | + if (strpos($myself,'://') !== false) { |
|
| 2046 | + $myself = explode('://',$myself); |
|
| 2047 | + array_shift($myself); |
|
| 2048 | + $myself = implode('://',$myself); |
|
| 2049 | + $myself = explode('/',$myself); |
|
| 2050 | + array_shift($myself); |
|
| 2051 | + $myself = implode('/',$myself); |
|
| 2052 | + } |
|
| 2053 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2055 | 2054 | |
| 2056 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2055 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2057 | 2056 | |
| 2058 | - return $url; |
|
| 2057 | + return $url; |
|
| 2059 | 2058 | } |
| 2060 | 2059 | |
| 2061 | 2060 | |
@@ -2090,26 +2089,26 @@ discard block |
||
| 2090 | 2089 | * @return string URL |
| 2091 | 2090 | **/ |
| 2092 | 2091 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2093 | - if (!$rel) { |
|
| 2094 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2095 | - } else { |
|
| 2096 | - if (!is_string($rel)) { |
|
| 2097 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2098 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2099 | - } |
|
| 2100 | - } |
|
| 2101 | - |
|
| 2102 | - list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2103 | - if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2104 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2105 | - } elseif ($args) { |
|
| 2106 | - $args = "?$args"; |
|
| 2107 | - } |
|
| 2108 | - if ($ancre) { |
|
| 2109 | - $args .= "#$ancre"; |
|
| 2110 | - } |
|
| 2111 | - |
|
| 2112 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2092 | + if (!$rel) { |
|
| 2093 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2094 | + } else { |
|
| 2095 | + if (!is_string($rel)) { |
|
| 2096 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
|
| 2097 | + ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2098 | + } |
|
| 2099 | + } |
|
| 2100 | + |
|
| 2101 | + list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
|
| 2102 | + if ($script and ($script <> 'accueil' or $rel)) { |
|
| 2103 | + $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2104 | + } elseif ($args) { |
|
| 2105 | + $args = "?$args"; |
|
| 2106 | + } |
|
| 2107 | + if ($ancre) { |
|
| 2108 | + $args .= "#$ancre"; |
|
| 2109 | + } |
|
| 2110 | + |
|
| 2111 | + return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | // |
@@ -2131,12 +2130,12 @@ discard block |
||
| 2131 | 2130 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut |
| 2132 | 2131 | **/ |
| 2133 | 2132 | function get_spip_script($default = '') { |
| 2134 | - # cas define('_SPIP_SCRIPT', ''); |
|
| 2135 | - if (_SPIP_SCRIPT) { |
|
| 2136 | - return _SPIP_SCRIPT; |
|
| 2137 | - } else { |
|
| 2138 | - return $default; |
|
| 2139 | - } |
|
| 2133 | + # cas define('_SPIP_SCRIPT', ''); |
|
| 2134 | + if (_SPIP_SCRIPT) { |
|
| 2135 | + return _SPIP_SCRIPT; |
|
| 2136 | + } else { |
|
| 2137 | + return $default; |
|
| 2138 | + } |
|
| 2140 | 2139 | } |
| 2141 | 2140 | |
| 2142 | 2141 | /** |
@@ -2165,39 +2164,39 @@ discard block |
||
| 2165 | 2164 | * @return string URL |
| 2166 | 2165 | **/ |
| 2167 | 2166 | function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { |
| 2168 | - // si le script est une action (spip_pass, spip_inscription), |
|
| 2169 | - // standardiser vers la nouvelle API |
|
| 2170 | - |
|
| 2171 | - if (!$action) { |
|
| 2172 | - $action = get_spip_script(); |
|
| 2173 | - } |
|
| 2174 | - if ($script) { |
|
| 2175 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2176 | - } |
|
| 2177 | - |
|
| 2178 | - if ($args) { |
|
| 2179 | - if (is_array($args)) { |
|
| 2180 | - $r = ''; |
|
| 2181 | - foreach ($args as $k => $v) { |
|
| 2182 | - $r .= '&' . $k . '=' . $v; |
|
| 2183 | - } |
|
| 2184 | - $args = substr($r, 1); |
|
| 2185 | - } |
|
| 2186 | - $action .= |
|
| 2187 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2188 | - } |
|
| 2189 | - if (!$no_entities) { |
|
| 2190 | - $action = quote_amp($action); |
|
| 2191 | - } |
|
| 2192 | - |
|
| 2193 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2194 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2167 | + // si le script est une action (spip_pass, spip_inscription), |
|
| 2168 | + // standardiser vers la nouvelle API |
|
| 2169 | + |
|
| 2170 | + if (!$action) { |
|
| 2171 | + $action = get_spip_script(); |
|
| 2172 | + } |
|
| 2173 | + if ($script) { |
|
| 2174 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&'); |
|
| 2175 | + } |
|
| 2176 | + |
|
| 2177 | + if ($args) { |
|
| 2178 | + if (is_array($args)) { |
|
| 2179 | + $r = ''; |
|
| 2180 | + foreach ($args as $k => $v) { |
|
| 2181 | + $r .= '&' . $k . '=' . $v; |
|
| 2182 | + } |
|
| 2183 | + $args = substr($r, 1); |
|
| 2184 | + } |
|
| 2185 | + $action .= |
|
| 2186 | + (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2187 | + } |
|
| 2188 | + if (!$no_entities) { |
|
| 2189 | + $action = quote_amp($action); |
|
| 2190 | + } |
|
| 2191 | + |
|
| 2192 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
|
| 2193 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2195 | 2194 | } |
| 2196 | 2195 | |
| 2197 | 2196 | // https://code.spip.net/@generer_url_prive |
| 2198 | 2197 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2199 | 2198 | |
| 2200 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2199 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2201 | 2200 | } |
| 2202 | 2201 | |
| 2203 | 2202 | // Pour les formulaires en methode POST, |
@@ -2222,19 +2221,19 @@ discard block |
||
| 2222 | 2221 | **/ |
| 2223 | 2222 | function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { |
| 2224 | 2223 | |
| 2225 | - $script1 = explode('&', $script); |
|
| 2226 | - $script1 = reset($script1); |
|
| 2224 | + $script1 = explode('&', $script); |
|
| 2225 | + $script1 = reset($script1); |
|
| 2227 | 2226 | |
| 2228 | - return "<form action='" |
|
| 2229 | - . ($script ? generer_url_ecrire($script) : '') |
|
| 2230 | - . "' " |
|
| 2231 | - . ($atts ? $atts : " method='post'") |
|
| 2232 | - . "><div>\n" |
|
| 2233 | - . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2234 | - . $corps |
|
| 2235 | - . (!$submit ? '' : |
|
| 2236 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2237 | - . "</div></form>\n"; |
|
| 2227 | + return "<form action='" |
|
| 2228 | + . ($script ? generer_url_ecrire($script) : '') |
|
| 2229 | + . "' " |
|
| 2230 | + . ($atts ? $atts : " method='post'") |
|
| 2231 | + . "><div>\n" |
|
| 2232 | + . "<input type='hidden' name='exec' value='$script1' />" |
|
| 2233 | + . $corps |
|
| 2234 | + . (!$submit ? '' : |
|
| 2235 | + ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2236 | + . "</div></form>\n"; |
|
| 2238 | 2237 | } |
| 2239 | 2238 | |
| 2240 | 2239 | /** |
@@ -2251,22 +2250,22 @@ discard block |
||
| 2251 | 2250 | * @return string |
| 2252 | 2251 | */ |
| 2253 | 2252 | function generer_form_action($script, $corps, $atts = '', $public = false) { |
| 2254 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2255 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2256 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2257 | - $h = (_DIR_RACINE and !$public) |
|
| 2258 | - ? generer_url_ecrire(_request('exec')) |
|
| 2259 | - : generer_url_public(); |
|
| 2253 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2254 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2255 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2256 | + $h = (_DIR_RACINE and !$public) |
|
| 2257 | + ? generer_url_ecrire(_request('exec')) |
|
| 2258 | + : generer_url_public(); |
|
| 2260 | 2259 | |
| 2261 | - return "\n<form action='" . |
|
| 2262 | - $h . |
|
| 2263 | - "'" . |
|
| 2264 | - $atts . |
|
| 2265 | - ">\n" . |
|
| 2266 | - "<div>" . |
|
| 2267 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2268 | - $corps . |
|
| 2269 | - "</div></form>"; |
|
| 2260 | + return "\n<form action='" . |
|
| 2261 | + $h . |
|
| 2262 | + "'" . |
|
| 2263 | + $atts . |
|
| 2264 | + ">\n" . |
|
| 2265 | + "<div>" . |
|
| 2266 | + "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2267 | + $corps . |
|
| 2268 | + "</div></form>"; |
|
| 2270 | 2269 | } |
| 2271 | 2270 | |
| 2272 | 2271 | /** |
@@ -2285,22 +2284,22 @@ discard block |
||
| 2285 | 2284 | * URL |
| 2286 | 2285 | */ |
| 2287 | 2286 | function generer_url_action($script, $args = "", $no_entities = false, $public = false) { |
| 2288 | - // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2289 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2290 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2291 | - $url = (_DIR_RACINE and !$public) |
|
| 2292 | - ? generer_url_ecrire(_request('exec')) |
|
| 2293 | - : generer_url_public('', '', false, false); |
|
| 2294 | - $url = parametre_url($url, 'action', $script); |
|
| 2295 | - if ($args) { |
|
| 2296 | - $url .= quote_amp('&' . $args); |
|
| 2297 | - } |
|
| 2287 | + // si l'on est dans l'espace prive, on garde dans l'url |
|
| 2288 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire |
|
| 2289 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple) |
|
| 2290 | + $url = (_DIR_RACINE and !$public) |
|
| 2291 | + ? generer_url_ecrire(_request('exec')) |
|
| 2292 | + : generer_url_public('', '', false, false); |
|
| 2293 | + $url = parametre_url($url, 'action', $script); |
|
| 2294 | + if ($args) { |
|
| 2295 | + $url .= quote_amp('&' . $args); |
|
| 2296 | + } |
|
| 2298 | 2297 | |
| 2299 | - if ($no_entities) { |
|
| 2300 | - $url = str_replace('&', '&', $url); |
|
| 2301 | - } |
|
| 2298 | + if ($no_entities) { |
|
| 2299 | + $url = str_replace('&', '&', $url); |
|
| 2300 | + } |
|
| 2302 | 2301 | |
| 2303 | - return $url; |
|
| 2302 | + return $url; |
|
| 2304 | 2303 | } |
| 2305 | 2304 | |
| 2306 | 2305 | |
@@ -2313,8 +2312,8 @@ discard block |
||
| 2313 | 2312 | * @param string $ta Répertoire temporaire accessible |
| 2314 | 2313 | */ |
| 2315 | 2314 | function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2316 | - spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2317 | - spip_initialisation_suite(); |
|
| 2315 | + spip_initialisation_core($pi, $pa, $ti, $ta); |
|
| 2316 | + spip_initialisation_suite(); |
|
| 2318 | 2317 | } |
| 2319 | 2318 | |
| 2320 | 2319 | /** |
@@ -2334,315 +2333,315 @@ discard block |
||
| 2334 | 2333 | * @param string $ta Répertoire temporaire accessible |
| 2335 | 2334 | */ |
| 2336 | 2335 | function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { |
| 2337 | - static $too_late = 0; |
|
| 2338 | - if ($too_late++) { |
|
| 2339 | - return; |
|
| 2340 | - } |
|
| 2341 | - |
|
| 2342 | - // Declaration des repertoires |
|
| 2343 | - |
|
| 2344 | - // le nom du repertoire plugins/ activables/desactivables |
|
| 2345 | - if (!defined('_DIR_PLUGINS')) { |
|
| 2346 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2347 | - } |
|
| 2348 | - |
|
| 2349 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2350 | - if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2351 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2352 | - } |
|
| 2353 | - |
|
| 2354 | - // le nom du repertoire des librairies |
|
| 2355 | - if (!defined('_DIR_LIB')) { |
|
| 2356 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2357 | - } |
|
| 2358 | - |
|
| 2359 | - if (!defined('_DIR_IMG')) { |
|
| 2360 | - define('_DIR_IMG', $pa); |
|
| 2361 | - } |
|
| 2362 | - if (!defined('_DIR_LOGOS')) { |
|
| 2363 | - define('_DIR_LOGOS', $pa); |
|
| 2364 | - } |
|
| 2365 | - if (!defined('_DIR_IMG_ICONES')) { |
|
| 2366 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2367 | - } |
|
| 2368 | - |
|
| 2369 | - if (!defined('_DIR_DUMP')) { |
|
| 2370 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2371 | - } |
|
| 2372 | - if (!defined('_DIR_SESSIONS')) { |
|
| 2373 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2374 | - } |
|
| 2375 | - if (!defined('_DIR_TRANSFERT')) { |
|
| 2376 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2377 | - } |
|
| 2378 | - if (!defined('_DIR_CACHE')) { |
|
| 2379 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2380 | - } |
|
| 2381 | - if (!defined('_DIR_CACHE_XML')) { |
|
| 2382 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2383 | - } |
|
| 2384 | - if (!defined('_DIR_SKELS')) { |
|
| 2385 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2386 | - } |
|
| 2387 | - if (!defined('_DIR_AIDE')) { |
|
| 2388 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2389 | - } |
|
| 2390 | - if (!defined('_DIR_TMP')) { |
|
| 2391 | - define('_DIR_TMP', $ti); |
|
| 2392 | - } |
|
| 2393 | - |
|
| 2394 | - if (!defined('_DIR_VAR')) { |
|
| 2395 | - define('_DIR_VAR', $ta); |
|
| 2396 | - } |
|
| 2397 | - |
|
| 2398 | - if (!defined('_DIR_ETC')) { |
|
| 2399 | - define('_DIR_ETC', $pi); |
|
| 2400 | - } |
|
| 2401 | - if (!defined('_DIR_CONNECT')) { |
|
| 2402 | - define('_DIR_CONNECT', $pi); |
|
| 2403 | - } |
|
| 2404 | - if (!defined('_DIR_CHMOD')) { |
|
| 2405 | - define('_DIR_CHMOD', $pi); |
|
| 2406 | - } |
|
| 2407 | - |
|
| 2408 | - if (!isset($GLOBALS['test_dirs'])) |
|
| 2409 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2410 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2411 | - { |
|
| 2412 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2413 | - } |
|
| 2414 | - |
|
| 2415 | - // Declaration des fichiers |
|
| 2416 | - |
|
| 2417 | - if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2418 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2419 | - } |
|
| 2420 | - if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2421 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2422 | - } |
|
| 2423 | - if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2424 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2425 | - } |
|
| 2426 | - if (!defined('_CACHE_PIPELINES')) { |
|
| 2427 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2428 | - } |
|
| 2429 | - if (!defined('_CACHE_CHEMIN')) { |
|
| 2430 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2431 | - } |
|
| 2432 | - |
|
| 2433 | - # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2434 | - if (!defined('_FILE_META')) { |
|
| 2435 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2436 | - } |
|
| 2437 | - if (!defined('_DIR_LOG')) { |
|
| 2438 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2439 | - } |
|
| 2440 | - if (!defined('_FILE_LOG')) { |
|
| 2441 | - define('_FILE_LOG', 'spip'); |
|
| 2442 | - } |
|
| 2443 | - if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2444 | - define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2445 | - } |
|
| 2446 | - |
|
| 2447 | - // Le fichier de connexion a la base de donnees |
|
| 2448 | - // tient compte des anciennes versions (inc_connect...) |
|
| 2449 | - if (!defined('_FILE_CONNECT_INS')) { |
|
| 2450 | - define('_FILE_CONNECT_INS', 'connect'); |
|
| 2451 | - } |
|
| 2452 | - if (!defined('_FILE_CONNECT')) { |
|
| 2453 | - define('_FILE_CONNECT', |
|
| 2454 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2455 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2456 | - : false))); |
|
| 2457 | - } |
|
| 2458 | - |
|
| 2459 | - // Le fichier de reglages des droits |
|
| 2460 | - if (!defined('_FILE_CHMOD_INS')) { |
|
| 2461 | - define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2462 | - } |
|
| 2463 | - if (!defined('_FILE_CHMOD')) { |
|
| 2464 | - define('_FILE_CHMOD', |
|
| 2465 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2466 | - : false)); |
|
| 2467 | - } |
|
| 2468 | - |
|
| 2469 | - if (!defined('_FILE_LDAP')) { |
|
| 2470 | - define('_FILE_LDAP', 'ldap.php'); |
|
| 2471 | - } |
|
| 2472 | - |
|
| 2473 | - if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2474 | - define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2475 | - } |
|
| 2476 | - if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2477 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2478 | - } |
|
| 2479 | - if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2480 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2481 | - } |
|
| 2482 | - |
|
| 2483 | - // Definition des droits d'acces en ecriture |
|
| 2484 | - if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2485 | - include_once _FILE_CHMOD; |
|
| 2486 | - } |
|
| 2487 | - |
|
| 2488 | - // Se mefier des fichiers mal remplis! |
|
| 2489 | - if (!defined('_SPIP_CHMOD')) { |
|
| 2490 | - define('_SPIP_CHMOD', 0777); |
|
| 2491 | - } |
|
| 2492 | - |
|
| 2493 | - if (!defined('_DEFAULT_CHARSET')) { |
|
| 2494 | - /** Le charset par défaut lors de l'installation */ |
|
| 2495 | - define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2496 | - } |
|
| 2497 | - if (!defined('_ROOT_PLUGINS')) { |
|
| 2498 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2499 | - } |
|
| 2500 | - if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2501 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2502 | - } |
|
| 2503 | - if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2504 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2505 | - } |
|
| 2506 | - |
|
| 2507 | - // La taille des Log |
|
| 2508 | - if (!defined('_MAX_LOG')) { |
|
| 2509 | - define('_MAX_LOG', 100); |
|
| 2510 | - } |
|
| 2511 | - |
|
| 2512 | - // Sommes-nous dans l'empire du Mal ? |
|
| 2513 | - // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2514 | - if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2515 | - if (!defined('_OS_SERVEUR')) { |
|
| 2516 | - define('_OS_SERVEUR', 'windows'); |
|
| 2517 | - } |
|
| 2518 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2519 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2520 | - } // utiliser le flock php |
|
| 2521 | - } else { |
|
| 2522 | - if (!defined('_OS_SERVEUR')) { |
|
| 2523 | - define('_OS_SERVEUR', ''); |
|
| 2524 | - } |
|
| 2525 | - if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2526 | - define('_SPIP_LOCK_MODE', 1); |
|
| 2527 | - } // utiliser le flock php |
|
| 2528 | - #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2529 | - } |
|
| 2530 | - |
|
| 2531 | - // Langue par defaut |
|
| 2532 | - if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2533 | - define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2534 | - } |
|
| 2535 | - |
|
| 2536 | - // |
|
| 2537 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2538 | - // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2539 | - // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2540 | - // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2541 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2542 | - |
|
| 2543 | - // charger tout de suite le path et son cache |
|
| 2544 | - load_path_cache(); |
|
| 2545 | - |
|
| 2546 | - // *********** traiter les variables ************ |
|
| 2547 | - |
|
| 2548 | - // |
|
| 2549 | - // Securite |
|
| 2550 | - // |
|
| 2551 | - |
|
| 2552 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2553 | - if (isset($_REQUEST['GLOBALS'])) { |
|
| 2554 | - die(); |
|
| 2555 | - } |
|
| 2556 | - // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2557 | - spip_desinfecte($_GET); |
|
| 2558 | - spip_desinfecte($_POST); |
|
| 2559 | - spip_desinfecte($_COOKIE); |
|
| 2560 | - spip_desinfecte($_REQUEST); |
|
| 2561 | - |
|
| 2562 | - // appliquer le cookie_prefix |
|
| 2563 | - if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2564 | - include_spip('inc/cookie'); |
|
| 2565 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2566 | - } |
|
| 2567 | - |
|
| 2568 | - // |
|
| 2569 | - // Capacites php (en fonction de la version) |
|
| 2570 | - // |
|
| 2571 | - $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2572 | - && function_exists("ini_get") |
|
| 2573 | - && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2574 | - $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2575 | - $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2576 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2577 | - (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2578 | - |
|
| 2579 | - |
|
| 2580 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2581 | - if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2582 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2583 | - } else { |
|
| 2584 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2585 | - if (!empty($_SERVER['QUERY_STRING']) |
|
| 2586 | - and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2587 | - ) { |
|
| 2588 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2589 | - } |
|
| 2590 | - } |
|
| 2591 | - |
|
| 2592 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2593 | - if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2594 | - define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2595 | - } |
|
| 2596 | - if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2597 | - define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2598 | - } |
|
| 2599 | - |
|
| 2600 | - // charger les meta si possible et renouveller l'alea au besoin |
|
| 2601 | - // charge aussi effacer_meta et ecrire_meta |
|
| 2602 | - $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2603 | - $inc_meta(); |
|
| 2604 | - |
|
| 2605 | - // nombre de repertoires depuis la racine |
|
| 2606 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2607 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2608 | - // le calcul est faux) |
|
| 2609 | - if (!_DIR_RESTREINT) { |
|
| 2610 | - $GLOBALS['profondeur_url'] = 1; |
|
| 2611 | - } else { |
|
| 2612 | - $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2613 | - $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2614 | - if (!$uri_ref |
|
| 2615 | - // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2616 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2617 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2618 | - // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2619 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2620 | - ) { |
|
| 2621 | - |
|
| 2622 | - if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2623 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2624 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2625 | - } else { |
|
| 2626 | - $uri_ref = ""; |
|
| 2627 | - } |
|
| 2628 | - } |
|
| 2629 | - if (!$uri or !$uri_ref) { |
|
| 2630 | - $GLOBALS['profondeur_url'] = 0; |
|
| 2631 | - } else { |
|
| 2632 | - $GLOBALS['profondeur_url'] = max(0, |
|
| 2633 | - substr_count($uri[0], '/') |
|
| 2634 | - - substr_count($uri_ref, '/')); |
|
| 2635 | - } |
|
| 2636 | - } |
|
| 2637 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2638 | - if (_FILE_CONNECT) { |
|
| 2639 | - if (verifier_visiteur() == '0minirezo' |
|
| 2640 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2641 | - and !isset($_COOKIE['spip_admin']) |
|
| 2642 | - ) { |
|
| 2643 | - clear_path_cache(); |
|
| 2644 | - } |
|
| 2645 | - } |
|
| 2336 | + static $too_late = 0; |
|
| 2337 | + if ($too_late++) { |
|
| 2338 | + return; |
|
| 2339 | + } |
|
| 2340 | + |
|
| 2341 | + // Declaration des repertoires |
|
| 2342 | + |
|
| 2343 | + // le nom du repertoire plugins/ activables/desactivables |
|
| 2344 | + if (!defined('_DIR_PLUGINS')) { |
|
| 2345 | + define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2346 | + } |
|
| 2347 | + |
|
| 2348 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives |
|
| 2349 | + if (!defined('_DIR_PLUGINS_DIST')) { |
|
| 2350 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2351 | + } |
|
| 2352 | + |
|
| 2353 | + // le nom du repertoire des librairies |
|
| 2354 | + if (!defined('_DIR_LIB')) { |
|
| 2355 | + define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2356 | + } |
|
| 2357 | + |
|
| 2358 | + if (!defined('_DIR_IMG')) { |
|
| 2359 | + define('_DIR_IMG', $pa); |
|
| 2360 | + } |
|
| 2361 | + if (!defined('_DIR_LOGOS')) { |
|
| 2362 | + define('_DIR_LOGOS', $pa); |
|
| 2363 | + } |
|
| 2364 | + if (!defined('_DIR_IMG_ICONES')) { |
|
| 2365 | + define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2366 | + } |
|
| 2367 | + |
|
| 2368 | + if (!defined('_DIR_DUMP')) { |
|
| 2369 | + define('_DIR_DUMP', $ti . "dump/"); |
|
| 2370 | + } |
|
| 2371 | + if (!defined('_DIR_SESSIONS')) { |
|
| 2372 | + define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2373 | + } |
|
| 2374 | + if (!defined('_DIR_TRANSFERT')) { |
|
| 2375 | + define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2376 | + } |
|
| 2377 | + if (!defined('_DIR_CACHE')) { |
|
| 2378 | + define('_DIR_CACHE', $ti . "cache/"); |
|
| 2379 | + } |
|
| 2380 | + if (!defined('_DIR_CACHE_XML')) { |
|
| 2381 | + define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2382 | + } |
|
| 2383 | + if (!defined('_DIR_SKELS')) { |
|
| 2384 | + define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2385 | + } |
|
| 2386 | + if (!defined('_DIR_AIDE')) { |
|
| 2387 | + define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2388 | + } |
|
| 2389 | + if (!defined('_DIR_TMP')) { |
|
| 2390 | + define('_DIR_TMP', $ti); |
|
| 2391 | + } |
|
| 2392 | + |
|
| 2393 | + if (!defined('_DIR_VAR')) { |
|
| 2394 | + define('_DIR_VAR', $ta); |
|
| 2395 | + } |
|
| 2396 | + |
|
| 2397 | + if (!defined('_DIR_ETC')) { |
|
| 2398 | + define('_DIR_ETC', $pi); |
|
| 2399 | + } |
|
| 2400 | + if (!defined('_DIR_CONNECT')) { |
|
| 2401 | + define('_DIR_CONNECT', $pi); |
|
| 2402 | + } |
|
| 2403 | + if (!defined('_DIR_CHMOD')) { |
|
| 2404 | + define('_DIR_CHMOD', $pi); |
|
| 2405 | + } |
|
| 2406 | + |
|
| 2407 | + if (!isset($GLOBALS['test_dirs'])) |
|
| 2408 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall |
|
| 2409 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install |
|
| 2410 | + { |
|
| 2411 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta); |
|
| 2412 | + } |
|
| 2413 | + |
|
| 2414 | + // Declaration des fichiers |
|
| 2415 | + |
|
| 2416 | + if (!defined('_CACHE_PLUGINS_PATH')) { |
|
| 2417 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2418 | + } |
|
| 2419 | + if (!defined('_CACHE_PLUGINS_OPT')) { |
|
| 2420 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2421 | + } |
|
| 2422 | + if (!defined('_CACHE_PLUGINS_FCT')) { |
|
| 2423 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2424 | + } |
|
| 2425 | + if (!defined('_CACHE_PIPELINES')) { |
|
| 2426 | + define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2427 | + } |
|
| 2428 | + if (!defined('_CACHE_CHEMIN')) { |
|
| 2429 | + define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2430 | + } |
|
| 2431 | + |
|
| 2432 | + # attention .php obligatoire pour ecrire_fichier_securise |
|
| 2433 | + if (!defined('_FILE_META')) { |
|
| 2434 | + define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2435 | + } |
|
| 2436 | + if (!defined('_DIR_LOG')) { |
|
| 2437 | + define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2438 | + } |
|
| 2439 | + if (!defined('_FILE_LOG')) { |
|
| 2440 | + define('_FILE_LOG', 'spip'); |
|
| 2441 | + } |
|
| 2442 | + if (!defined('_FILE_LOG_SUFFIX')) { |
|
| 2443 | + define('_FILE_LOG_SUFFIX', '.log'); |
|
| 2444 | + } |
|
| 2445 | + |
|
| 2446 | + // Le fichier de connexion a la base de donnees |
|
| 2447 | + // tient compte des anciennes versions (inc_connect...) |
|
| 2448 | + if (!defined('_FILE_CONNECT_INS')) { |
|
| 2449 | + define('_FILE_CONNECT_INS', 'connect'); |
|
| 2450 | + } |
|
| 2451 | + if (!defined('_FILE_CONNECT')) { |
|
| 2452 | + define('_FILE_CONNECT', |
|
| 2453 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2454 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2455 | + : false))); |
|
| 2456 | + } |
|
| 2457 | + |
|
| 2458 | + // Le fichier de reglages des droits |
|
| 2459 | + if (!defined('_FILE_CHMOD_INS')) { |
|
| 2460 | + define('_FILE_CHMOD_INS', 'chmod'); |
|
| 2461 | + } |
|
| 2462 | + if (!defined('_FILE_CHMOD')) { |
|
| 2463 | + define('_FILE_CHMOD', |
|
| 2464 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2465 | + : false)); |
|
| 2466 | + } |
|
| 2467 | + |
|
| 2468 | + if (!defined('_FILE_LDAP')) { |
|
| 2469 | + define('_FILE_LDAP', 'ldap.php'); |
|
| 2470 | + } |
|
| 2471 | + |
|
| 2472 | + if (!defined('_FILE_TMP_SUFFIX')) { |
|
| 2473 | + define('_FILE_TMP_SUFFIX', '.tmp.php'); |
|
| 2474 | + } |
|
| 2475 | + if (!defined('_FILE_CONNECT_TMP')) { |
|
| 2476 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2477 | + } |
|
| 2478 | + if (!defined('_FILE_CHMOD_TMP')) { |
|
| 2479 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2480 | + } |
|
| 2481 | + |
|
| 2482 | + // Definition des droits d'acces en ecriture |
|
| 2483 | + if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { |
|
| 2484 | + include_once _FILE_CHMOD; |
|
| 2485 | + } |
|
| 2486 | + |
|
| 2487 | + // Se mefier des fichiers mal remplis! |
|
| 2488 | + if (!defined('_SPIP_CHMOD')) { |
|
| 2489 | + define('_SPIP_CHMOD', 0777); |
|
| 2490 | + } |
|
| 2491 | + |
|
| 2492 | + if (!defined('_DEFAULT_CHARSET')) { |
|
| 2493 | + /** Le charset par défaut lors de l'installation */ |
|
| 2494 | + define('_DEFAULT_CHARSET', 'utf-8'); |
|
| 2495 | + } |
|
| 2496 | + if (!defined('_ROOT_PLUGINS')) { |
|
| 2497 | + define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2498 | + } |
|
| 2499 | + if (!defined('_ROOT_PLUGINS_DIST')) { |
|
| 2500 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2501 | + } |
|
| 2502 | + if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 2503 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2504 | + } |
|
| 2505 | + |
|
| 2506 | + // La taille des Log |
|
| 2507 | + if (!defined('_MAX_LOG')) { |
|
| 2508 | + define('_MAX_LOG', 100); |
|
| 2509 | + } |
|
| 2510 | + |
|
| 2511 | + // Sommes-nous dans l'empire du Mal ? |
|
| 2512 | + // (ou sous le signe du Pingouin, ascendant GNU ?) |
|
| 2513 | + if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { |
|
| 2514 | + if (!defined('_OS_SERVEUR')) { |
|
| 2515 | + define('_OS_SERVEUR', 'windows'); |
|
| 2516 | + } |
|
| 2517 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2518 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2519 | + } // utiliser le flock php |
|
| 2520 | + } else { |
|
| 2521 | + if (!defined('_OS_SERVEUR')) { |
|
| 2522 | + define('_OS_SERVEUR', ''); |
|
| 2523 | + } |
|
| 2524 | + if (!defined('_SPIP_LOCK_MODE')) { |
|
| 2525 | + define('_SPIP_LOCK_MODE', 1); |
|
| 2526 | + } // utiliser le flock php |
|
| 2527 | + #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite |
|
| 2528 | + } |
|
| 2529 | + |
|
| 2530 | + // Langue par defaut |
|
| 2531 | + if (!defined('_LANGUE_PAR_DEFAUT')) { |
|
| 2532 | + define('_LANGUE_PAR_DEFAUT', 'fr'); |
|
| 2533 | + } |
|
| 2534 | + |
|
| 2535 | + // |
|
| 2536 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock() |
|
| 2537 | + // (non surchargeable en l'etat ; attention si on utilise include_spip() |
|
| 2538 | + // pour le rendre surchargeable, on va provoquer un reecriture |
|
| 2539 | + // systematique du noyau ou une baisse de perfs => a etudier) |
|
| 2540 | + include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2541 | + |
|
| 2542 | + // charger tout de suite le path et son cache |
|
| 2543 | + load_path_cache(); |
|
| 2544 | + |
|
| 2545 | + // *********** traiter les variables ************ |
|
| 2546 | + |
|
| 2547 | + // |
|
| 2548 | + // Securite |
|
| 2549 | + // |
|
| 2550 | + |
|
| 2551 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto |
|
| 2552 | + if (isset($_REQUEST['GLOBALS'])) { |
|
| 2553 | + die(); |
|
| 2554 | + } |
|
| 2555 | + // nettoyer les magic quotes \' et les caracteres nuls %00 |
|
| 2556 | + spip_desinfecte($_GET); |
|
| 2557 | + spip_desinfecte($_POST); |
|
| 2558 | + spip_desinfecte($_COOKIE); |
|
| 2559 | + spip_desinfecte($_REQUEST); |
|
| 2560 | + |
|
| 2561 | + // appliquer le cookie_prefix |
|
| 2562 | + if ($GLOBALS['cookie_prefix'] != 'spip') { |
|
| 2563 | + include_spip('inc/cookie'); |
|
| 2564 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']); |
|
| 2565 | + } |
|
| 2566 | + |
|
| 2567 | + // |
|
| 2568 | + // Capacites php (en fonction de la version) |
|
| 2569 | + // |
|
| 2570 | + $GLOBALS['flag_ob'] = (function_exists("ob_start") |
|
| 2571 | + && function_exists("ini_get") |
|
| 2572 | + && !strstr(@ini_get('disable_functions'), 'ob_')); |
|
| 2573 | + $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); |
|
| 2574 | + $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); |
|
| 2575 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] || |
|
| 2576 | + (get_cfg_var('upload_max_filesize') > 0)); |
|
| 2577 | + |
|
| 2578 | + |
|
| 2579 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI |
|
| 2580 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
| 2581 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI']; |
|
| 2582 | + } else { |
|
| 2583 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : ''; |
|
| 2584 | + if (!empty($_SERVER['QUERY_STRING']) |
|
| 2585 | + and !strpos($_SERVER['REQUEST_URI'], '?') |
|
| 2586 | + ) { |
|
| 2587 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2588 | + } |
|
| 2589 | + } |
|
| 2590 | + |
|
| 2591 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit. |
|
| 2592 | + if (!defined('_RENOUVELLE_ALEA')) { |
|
| 2593 | + define('_RENOUVELLE_ALEA', 12 * 3600); |
|
| 2594 | + } |
|
| 2595 | + if (!defined('_DUREE_COOKIE_ADMIN')) { |
|
| 2596 | + define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); |
|
| 2597 | + } |
|
| 2598 | + |
|
| 2599 | + // charger les meta si possible et renouveller l'alea au besoin |
|
| 2600 | + // charge aussi effacer_meta et ecrire_meta |
|
| 2601 | + $inc_meta = charger_fonction('meta', 'inc'); |
|
| 2602 | + $inc_meta(); |
|
| 2603 | + |
|
| 2604 | + // nombre de repertoires depuis la racine |
|
| 2605 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"] |
|
| 2606 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse |
|
| 2607 | + // le calcul est faux) |
|
| 2608 | + if (!_DIR_RESTREINT) { |
|
| 2609 | + $GLOBALS['profondeur_url'] = 1; |
|
| 2610 | + } else { |
|
| 2611 | + $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; |
|
| 2612 | + $uri_ref = $_SERVER["SCRIPT_NAME"]; |
|
| 2613 | + if (!$uri_ref |
|
| 2614 | + // si on est appele avec un autre ti, on est sans doute en mutu |
|
| 2615 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie |
|
| 2616 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer |
|
| 2617 | + // s'en remettre a l'adresse du site. alea jacta est. |
|
| 2618 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES |
|
| 2619 | + ) { |
|
| 2620 | + |
|
| 2621 | + if (isset($GLOBALS['meta']['adresse_site'])) { |
|
| 2622 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
|
| 2623 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2624 | + } else { |
|
| 2625 | + $uri_ref = ""; |
|
| 2626 | + } |
|
| 2627 | + } |
|
| 2628 | + if (!$uri or !$uri_ref) { |
|
| 2629 | + $GLOBALS['profondeur_url'] = 0; |
|
| 2630 | + } else { |
|
| 2631 | + $GLOBALS['profondeur_url'] = max(0, |
|
| 2632 | + substr_count($uri[0], '/') |
|
| 2633 | + - substr_count($uri_ref, '/')); |
|
| 2634 | + } |
|
| 2635 | + } |
|
| 2636 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session |
|
| 2637 | + if (_FILE_CONNECT) { |
|
| 2638 | + if (verifier_visiteur() == '0minirezo' |
|
| 2639 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin ! |
|
| 2640 | + and !isset($_COOKIE['spip_admin']) |
|
| 2641 | + ) { |
|
| 2642 | + clear_path_cache(); |
|
| 2643 | + } |
|
| 2644 | + } |
|
| 2646 | 2645 | |
| 2647 | 2646 | } |
| 2648 | 2647 | |
@@ -2652,181 +2651,181 @@ discard block |
||
| 2652 | 2651 | * |
| 2653 | 2652 | */ |
| 2654 | 2653 | function spip_initialisation_suite() { |
| 2655 | - static $too_late = 0; |
|
| 2656 | - if ($too_late++) { |
|
| 2657 | - return; |
|
| 2658 | - } |
|
| 2659 | - |
|
| 2660 | - // taille mini des login |
|
| 2661 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2662 | - define('_LOGIN_TROP_COURT', 4); |
|
| 2663 | - } |
|
| 2664 | - |
|
| 2665 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2666 | - #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2667 | - #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2668 | - #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2669 | - |
|
| 2670 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2671 | - #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2672 | - #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2673 | - #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2674 | - #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2675 | - |
|
| 2676 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2677 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 2678 | - } |
|
| 2679 | - |
|
| 2680 | - |
|
| 2681 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2682 | - if (!defined('_IMG_QUALITE')) { |
|
| 2683 | - define('_IMG_QUALITE', 85); |
|
| 2684 | - } # valeur par defaut |
|
| 2685 | - if (!defined('_IMG_GD_QUALITE')) { |
|
| 2686 | - define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2687 | - } # surcharge pour la lib GD |
|
| 2688 | - if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2689 | - define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2690 | - } # surcharge pour imagick en ligne de commande |
|
| 2691 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2692 | - if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2693 | - define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2694 | - } # surcharge pour imagick en PHP |
|
| 2695 | - |
|
| 2696 | - if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2697 | - define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2698 | - } // poids en octet |
|
| 2699 | - |
|
| 2700 | - // qq chaines standard |
|
| 2701 | - if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2702 | - define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2703 | - } |
|
| 2704 | - if (!defined('_AUTH_USER_FILE')) { |
|
| 2705 | - define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2706 | - } |
|
| 2707 | - if (!defined('_SPIP_DUMP')) { |
|
| 2708 | - define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2709 | - } |
|
| 2710 | - if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2711 | - /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2712 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2713 | - } |
|
| 2714 | - if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2715 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2716 | - define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2717 | - } |
|
| 2718 | - |
|
| 2719 | - if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2720 | - /** |
|
| 2721 | - * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2722 | - * @var int Nombre de caractères */ |
|
| 2723 | - define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2724 | - } |
|
| 2725 | - |
|
| 2726 | - if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2727 | - define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2728 | - } |
|
| 2729 | - |
|
| 2730 | - if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2731 | - /** Définit le doctype de l’espace privé */ |
|
| 2732 | - define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2733 | - } |
|
| 2734 | - if (!defined('_DOCTYPE_AIDE')) { |
|
| 2735 | - /** Définit le doctype de l’aide en ligne */ |
|
| 2736 | - define('_DOCTYPE_AIDE', |
|
| 2737 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2738 | - } |
|
| 2739 | - |
|
| 2740 | - if (!defined('_SPIP_SCRIPT')) { |
|
| 2741 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2742 | - * le script de l'espace public, alias index.php */ |
|
| 2743 | - define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2744 | - } |
|
| 2745 | - if (!defined('_SPIP_PAGE')) { |
|
| 2746 | - /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2747 | - define('_SPIP_PAGE', 'page'); |
|
| 2748 | - } |
|
| 2749 | - |
|
| 2750 | - // le script de l'espace prive |
|
| 2751 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2752 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2753 | - // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2754 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2755 | - if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2756 | - define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2757 | - } else { |
|
| 2758 | - define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2759 | - } |
|
| 2760 | - } |
|
| 2761 | - |
|
| 2762 | - |
|
| 2763 | - if (!defined('_SPIP_AJAX')) { |
|
| 2764 | - define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2765 | - ? 1 |
|
| 2766 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2767 | - } |
|
| 2768 | - |
|
| 2769 | - // La requete est-elle en ajax ? |
|
| 2770 | - if (!defined('_AJAX')) { |
|
| 2771 | - define('_AJAX', |
|
| 2772 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2773 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2774 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2775 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2776 | - ) |
|
| 2777 | - and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2778 | - ); |
|
| 2779 | - } |
|
| 2780 | - |
|
| 2781 | - # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2782 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2783 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2784 | - if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2785 | - define('_IMG_GD_MAX_PIXELS', |
|
| 2786 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2787 | - ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2788 | - : 0); |
|
| 2789 | - } |
|
| 2790 | - |
|
| 2791 | - if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2792 | - define('_MEMORY_LIMIT_MIN', 16); |
|
| 2793 | - } // en Mo |
|
| 2794 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2795 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2796 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2797 | - if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2798 | - if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2799 | - $unit = strtolower(substr($memory, -1)); |
|
| 2800 | - $memory = substr($memory, 0, -1); |
|
| 2801 | - switch ($unit) { |
|
| 2802 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2803 | - case 'g': |
|
| 2804 | - $memory *= 1024; |
|
| 2805 | - case 'm': |
|
| 2806 | - $memory *= 1024; |
|
| 2807 | - case 'k': |
|
| 2808 | - $memory *= 1024; |
|
| 2809 | - } |
|
| 2810 | - if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2811 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2812 | - if (trim(ini_get('memory_limit')) != $m) { |
|
| 2813 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2814 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2815 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2816 | - } |
|
| 2817 | - } |
|
| 2818 | - } else { |
|
| 2819 | - if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2820 | - define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2821 | - } |
|
| 2822 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2823 | - } |
|
| 2824 | - // Protocoles a normaliser dans les chaines de langues |
|
| 2825 | - if (!defined('_PROTOCOLES_STD')) { |
|
| 2826 | - define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2827 | - } |
|
| 2828 | - |
|
| 2829 | - init_var_mode(); |
|
| 2654 | + static $too_late = 0; |
|
| 2655 | + if ($too_late++) { |
|
| 2656 | + return; |
|
| 2657 | + } |
|
| 2658 | + |
|
| 2659 | + // taille mini des login |
|
| 2660 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 2661 | + define('_LOGIN_TROP_COURT', 4); |
|
| 2662 | + } |
|
| 2663 | + |
|
| 2664 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2665 | + #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko |
|
| 2666 | + #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels |
|
| 2667 | + #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2668 | + |
|
| 2669 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile) |
|
| 2670 | + #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko |
|
| 2671 | + #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko |
|
| 2672 | + #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels |
|
| 2673 | + #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels |
|
| 2674 | + |
|
| 2675 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 2676 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 2677 | + } |
|
| 2678 | + |
|
| 2679 | + |
|
| 2680 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite) |
|
| 2681 | + if (!defined('_IMG_QUALITE')) { |
|
| 2682 | + define('_IMG_QUALITE', 85); |
|
| 2683 | + } # valeur par defaut |
|
| 2684 | + if (!defined('_IMG_GD_QUALITE')) { |
|
| 2685 | + define('_IMG_GD_QUALITE', _IMG_QUALITE); |
|
| 2686 | + } # surcharge pour la lib GD |
|
| 2687 | + if (!defined('_IMG_CONVERT_QUALITE')) { |
|
| 2688 | + define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); |
|
| 2689 | + } # surcharge pour imagick en ligne de commande |
|
| 2690 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE |
|
| 2691 | + if (!defined('_IMG_IMAGICK_QUALITE')) { |
|
| 2692 | + define('_IMG_IMAGICK_QUALITE', 75); |
|
| 2693 | + } # surcharge pour imagick en PHP |
|
| 2694 | + |
|
| 2695 | + if (!defined('_COPIE_LOCALE_MAX_SIZE')) { |
|
| 2696 | + define('_COPIE_LOCALE_MAX_SIZE', 33554432); |
|
| 2697 | + } // poids en octet |
|
| 2698 | + |
|
| 2699 | + // qq chaines standard |
|
| 2700 | + if (!defined('_ACCESS_FILE_NAME')) { |
|
| 2701 | + define('_ACCESS_FILE_NAME', '.htaccess'); |
|
| 2702 | + } |
|
| 2703 | + if (!defined('_AUTH_USER_FILE')) { |
|
| 2704 | + define('_AUTH_USER_FILE', '.htpasswd'); |
|
| 2705 | + } |
|
| 2706 | + if (!defined('_SPIP_DUMP')) { |
|
| 2707 | + define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); |
|
| 2708 | + } |
|
| 2709 | + if (!defined('_CACHE_RUBRIQUES')) { |
|
| 2710 | + /** Fichier cache pour le navigateur de rubrique du bandeau */ |
|
| 2711 | + define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2712 | + } |
|
| 2713 | + if (!defined('_CACHE_RUBRIQUES_MAX')) { |
|
| 2714 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
|
| 2715 | + define('_CACHE_RUBRIQUES_MAX', 500); |
|
| 2716 | + } |
|
| 2717 | + |
|
| 2718 | + if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) { |
|
| 2719 | + /** |
|
| 2720 | + * Basculer les contextes ajax en fichier si la longueur d’url est trop grande |
|
| 2721 | + * @var int Nombre de caractères */ |
|
| 2722 | + define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000); |
|
| 2723 | + } |
|
| 2724 | + |
|
| 2725 | + if (!defined('_EXTENSION_SQUELETTES')) { |
|
| 2726 | + define('_EXTENSION_SQUELETTES', 'html'); |
|
| 2727 | + } |
|
| 2728 | + |
|
| 2729 | + if (!defined('_DOCTYPE_ECRIRE')) { |
|
| 2730 | + /** Définit le doctype de l’espace privé */ |
|
| 2731 | + define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); |
|
| 2732 | + } |
|
| 2733 | + if (!defined('_DOCTYPE_AIDE')) { |
|
| 2734 | + /** Définit le doctype de l’aide en ligne */ |
|
| 2735 | + define('_DOCTYPE_AIDE', |
|
| 2736 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>"); |
|
| 2737 | + } |
|
| 2738 | + |
|
| 2739 | + if (!defined('_SPIP_SCRIPT')) { |
|
| 2740 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par |
|
| 2741 | + * le script de l'espace public, alias index.php */ |
|
| 2742 | + define('_SPIP_SCRIPT', 'spip.php'); |
|
| 2743 | + } |
|
| 2744 | + if (!defined('_SPIP_PAGE')) { |
|
| 2745 | + /** Argument page, personalisable en cas de conflit avec un autre script */ |
|
| 2746 | + define('_SPIP_PAGE', 'page'); |
|
| 2747 | + } |
|
| 2748 | + |
|
| 2749 | + // le script de l'espace prive |
|
| 2750 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes: |
|
| 2751 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419) |
|
| 2752 | + // meme pb sur thttpd cf. https://forum.spip.net/fr_184153.html |
|
| 2753 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 2754 | + if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) { |
|
| 2755 | + define('_SPIP_ECRIRE_SCRIPT', 'index.php'); |
|
| 2756 | + } else { |
|
| 2757 | + define('_SPIP_ECRIRE_SCRIPT', ''); |
|
| 2758 | + } |
|
| 2759 | + } |
|
| 2760 | + |
|
| 2761 | + |
|
| 2762 | + if (!defined('_SPIP_AJAX')) { |
|
| 2763 | + define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) |
|
| 2764 | + ? 1 |
|
| 2765 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0))); |
|
| 2766 | + } |
|
| 2767 | + |
|
| 2768 | + // La requete est-elle en ajax ? |
|
| 2769 | + if (!defined('_AJAX')) { |
|
| 2770 | + define('_AJAX', |
|
| 2771 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery |
|
| 2772 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery |
|
| 2773 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins |
|
| 2774 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip |
|
| 2775 | + ) |
|
| 2776 | + and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient |
|
| 2777 | + ); |
|
| 2778 | + } |
|
| 2779 | + |
|
| 2780 | + # nombre de pixels maxi pour calcul de la vignette avec gd |
|
| 2781 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation |
|
| 2782 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel |
|
| 2783 | + if (!defined('_IMG_GD_MAX_PIXELS')) { |
|
| 2784 | + define('_IMG_GD_MAX_PIXELS', |
|
| 2785 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes']) |
|
| 2786 | + ? $GLOBALS['meta']['max_taille_vignettes'] |
|
| 2787 | + : 0); |
|
| 2788 | + } |
|
| 2789 | + |
|
| 2790 | + if (!defined('_MEMORY_LIMIT_MIN')) { |
|
| 2791 | + define('_MEMORY_LIMIT_MIN', 16); |
|
| 2792 | + } // en Mo |
|
| 2793 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard) |
|
| 2794 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche |
|
| 2795 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche |
|
| 2796 | + if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { |
|
| 2797 | + if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { |
|
| 2798 | + $unit = strtolower(substr($memory, -1)); |
|
| 2799 | + $memory = substr($memory, 0, -1); |
|
| 2800 | + switch ($unit) { |
|
| 2801 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0 |
|
| 2802 | + case 'g': |
|
| 2803 | + $memory *= 1024; |
|
| 2804 | + case 'm': |
|
| 2805 | + $memory *= 1024; |
|
| 2806 | + case 'k': |
|
| 2807 | + $memory *= 1024; |
|
| 2808 | + } |
|
| 2809 | + if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
|
| 2810 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2811 | + if (trim(ini_get('memory_limit')) != $m) { |
|
| 2812 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2813 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2814 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2815 | + } |
|
| 2816 | + } |
|
| 2817 | + } else { |
|
| 2818 | + if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
|
| 2819 | + define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
|
| 2820 | + } |
|
| 2821 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit |
|
| 2822 | + } |
|
| 2823 | + // Protocoles a normaliser dans les chaines de langues |
|
| 2824 | + if (!defined('_PROTOCOLES_STD')) { |
|
| 2825 | + define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); |
|
| 2826 | + } |
|
| 2827 | + |
|
| 2828 | + init_var_mode(); |
|
| 2830 | 2829 | } |
| 2831 | 2830 | |
| 2832 | 2831 | /** |
@@ -2860,133 +2859,133 @@ discard block |
||
| 2860 | 2859 | * ` var_mode` (calcul ou recalcul). |
| 2861 | 2860 | */ |
| 2862 | 2861 | function init_var_mode() { |
| 2863 | - static $done = false; |
|
| 2864 | - if (!$done) { |
|
| 2865 | - |
|
| 2866 | - if (isset($_GET['var_mode'])) { |
|
| 2867 | - $var_mode = explode(',', $_GET['var_mode']); |
|
| 2868 | - // tout le monde peut calcul/recalcul |
|
| 2869 | - if (!defined('_VAR_MODE')) { |
|
| 2870 | - if (in_array('recalcul', $var_mode)) { |
|
| 2871 | - define('_VAR_MODE', 'recalcul'); |
|
| 2872 | - } elseif (in_array('calcul', $var_mode)) { |
|
| 2873 | - define('_VAR_MODE', 'calcul'); |
|
| 2874 | - } |
|
| 2875 | - } |
|
| 2876 | - $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2877 | - if ($var_mode) { |
|
| 2878 | - include_spip('inc/autoriser'); |
|
| 2879 | - // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2880 | - if (autoriser( |
|
| 2881 | - ($_GET['var_mode'] == 'preview') |
|
| 2882 | - ? 'previsualiser' |
|
| 2883 | - : 'debug' |
|
| 2884 | - )) { |
|
| 2885 | - if (in_array('traduction', $var_mode)) { |
|
| 2886 | - // forcer le calcul pour passer dans traduire |
|
| 2887 | - if (!defined('_VAR_MODE')) { |
|
| 2888 | - define('_VAR_MODE', 'calcul'); |
|
| 2889 | - } |
|
| 2890 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2891 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2892 | - define('_VAR_NOCACHE', true); |
|
| 2893 | - } |
|
| 2894 | - $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2895 | - } |
|
| 2896 | - if (in_array('preview', $var_mode)) { |
|
| 2897 | - // basculer sur les criteres de preview dans les boucles |
|
| 2898 | - if (!defined('_VAR_PREVIEW')) { |
|
| 2899 | - define('_VAR_PREVIEW', true); |
|
| 2900 | - } |
|
| 2901 | - // forcer le calcul |
|
| 2902 | - if (!defined('_VAR_MODE')) { |
|
| 2903 | - define('_VAR_MODE', 'calcul'); |
|
| 2904 | - } |
|
| 2905 | - // et ne pas enregistrer de cache |
|
| 2906 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2907 | - define('_VAR_NOCACHE', true); |
|
| 2908 | - } |
|
| 2909 | - $var_mode = array_diff($var_mode, array('preview')); |
|
| 2910 | - } |
|
| 2911 | - if (in_array('inclure', $var_mode)) { |
|
| 2912 | - // forcer le compilo et ignorer les caches existants |
|
| 2913 | - if (!defined('_VAR_MODE')) { |
|
| 2914 | - define('_VAR_MODE', 'calcul'); |
|
| 2915 | - } |
|
| 2916 | - if (!defined('_VAR_INCLURE')) { |
|
| 2917 | - define('_VAR_INCLURE', true); |
|
| 2918 | - } |
|
| 2919 | - // et ne pas enregistrer de cache |
|
| 2920 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2921 | - define('_VAR_NOCACHE', true); |
|
| 2922 | - } |
|
| 2923 | - $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2924 | - } |
|
| 2925 | - if (in_array('urls', $var_mode)) { |
|
| 2926 | - // forcer le compilo et ignorer les caches existants |
|
| 2927 | - if (!defined('_VAR_MODE')) { |
|
| 2928 | - define('_VAR_MODE', 'calcul'); |
|
| 2929 | - } |
|
| 2930 | - if (!defined('_VAR_URLS')) { |
|
| 2931 | - define('_VAR_URLS', true); |
|
| 2932 | - } |
|
| 2933 | - $var_mode = array_diff($var_mode, array('urls')); |
|
| 2934 | - } |
|
| 2935 | - if (in_array('images', $var_mode)) { |
|
| 2936 | - // forcer le compilo et ignorer les caches existants |
|
| 2937 | - if (!defined('_VAR_MODE')) { |
|
| 2938 | - define('_VAR_MODE', 'calcul'); |
|
| 2939 | - } |
|
| 2940 | - // indiquer qu'on doit recalculer les images |
|
| 2941 | - if (!defined('_VAR_IMAGES')) { |
|
| 2942 | - define('_VAR_IMAGES', true); |
|
| 2943 | - } |
|
| 2944 | - $var_mode = array_diff($var_mode, array('images')); |
|
| 2945 | - } |
|
| 2946 | - if (in_array('debug', $var_mode)) { |
|
| 2947 | - if (!defined('_VAR_MODE')) { |
|
| 2948 | - define('_VAR_MODE', 'debug'); |
|
| 2949 | - } |
|
| 2950 | - // et ne pas enregistrer de cache |
|
| 2951 | - if (!defined('_VAR_NOCACHE')) { |
|
| 2952 | - define('_VAR_NOCACHE', true); |
|
| 2953 | - } |
|
| 2954 | - $var_mode = array_diff($var_mode, array('debug')); |
|
| 2955 | - } |
|
| 2956 | - if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2957 | - define('_VAR_MODE', reset($var_mode)); |
|
| 2958 | - } |
|
| 2959 | - if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2960 | - spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2961 | - . " " . _VAR_MODE); |
|
| 2962 | - } |
|
| 2963 | - } // pas autorise ? |
|
| 2964 | - else { |
|
| 2965 | - // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 2966 | - if (!$GLOBALS['visiteur_session'] |
|
| 2967 | - and !empty($_SERVER['HTTP_HOST']) |
|
| 2968 | - and !empty($_SERVER['REQUEST_METHOD']) |
|
| 2969 | - and $_SERVER['REQUEST_METHOD'] === 'GET') { |
|
| 2970 | - $self = self('&', true); |
|
| 2971 | - if (strpos($self, 'page=login') === false) { |
|
| 2972 | - include_spip('inc/headers'); |
|
| 2973 | - $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 2974 | - redirige_par_entete(generer_url_public('login','url=' . rawurlencode($redirect), true)); |
|
| 2975 | - } |
|
| 2976 | - } |
|
| 2977 | - // sinon tant pis |
|
| 2978 | - } |
|
| 2979 | - } |
|
| 2980 | - } |
|
| 2981 | - if (!defined('_VAR_MODE')) { |
|
| 2982 | - /** |
|
| 2983 | - * Indique le mode de calcul ou d'affichage de la page. |
|
| 2984 | - * @see init_var_mode() |
|
| 2985 | - */ |
|
| 2986 | - define('_VAR_MODE', false); |
|
| 2987 | - } |
|
| 2988 | - $done = true; |
|
| 2989 | - } |
|
| 2862 | + static $done = false; |
|
| 2863 | + if (!$done) { |
|
| 2864 | + |
|
| 2865 | + if (isset($_GET['var_mode'])) { |
|
| 2866 | + $var_mode = explode(',', $_GET['var_mode']); |
|
| 2867 | + // tout le monde peut calcul/recalcul |
|
| 2868 | + if (!defined('_VAR_MODE')) { |
|
| 2869 | + if (in_array('recalcul', $var_mode)) { |
|
| 2870 | + define('_VAR_MODE', 'recalcul'); |
|
| 2871 | + } elseif (in_array('calcul', $var_mode)) { |
|
| 2872 | + define('_VAR_MODE', 'calcul'); |
|
| 2873 | + } |
|
| 2874 | + } |
|
| 2875 | + $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); |
|
| 2876 | + if ($var_mode) { |
|
| 2877 | + include_spip('inc/autoriser'); |
|
| 2878 | + // autoriser preview si preview seulement, et sinon autoriser debug |
|
| 2879 | + if (autoriser( |
|
| 2880 | + ($_GET['var_mode'] == 'preview') |
|
| 2881 | + ? 'previsualiser' |
|
| 2882 | + : 'debug' |
|
| 2883 | + )) { |
|
| 2884 | + if (in_array('traduction', $var_mode)) { |
|
| 2885 | + // forcer le calcul pour passer dans traduire |
|
| 2886 | + if (!defined('_VAR_MODE')) { |
|
| 2887 | + define('_VAR_MODE', 'calcul'); |
|
| 2888 | + } |
|
| 2889 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages |
|
| 2890 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2891 | + define('_VAR_NOCACHE', true); |
|
| 2892 | + } |
|
| 2893 | + $var_mode = array_diff($var_mode, array('traduction')); |
|
| 2894 | + } |
|
| 2895 | + if (in_array('preview', $var_mode)) { |
|
| 2896 | + // basculer sur les criteres de preview dans les boucles |
|
| 2897 | + if (!defined('_VAR_PREVIEW')) { |
|
| 2898 | + define('_VAR_PREVIEW', true); |
|
| 2899 | + } |
|
| 2900 | + // forcer le calcul |
|
| 2901 | + if (!defined('_VAR_MODE')) { |
|
| 2902 | + define('_VAR_MODE', 'calcul'); |
|
| 2903 | + } |
|
| 2904 | + // et ne pas enregistrer de cache |
|
| 2905 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2906 | + define('_VAR_NOCACHE', true); |
|
| 2907 | + } |
|
| 2908 | + $var_mode = array_diff($var_mode, array('preview')); |
|
| 2909 | + } |
|
| 2910 | + if (in_array('inclure', $var_mode)) { |
|
| 2911 | + // forcer le compilo et ignorer les caches existants |
|
| 2912 | + if (!defined('_VAR_MODE')) { |
|
| 2913 | + define('_VAR_MODE', 'calcul'); |
|
| 2914 | + } |
|
| 2915 | + if (!defined('_VAR_INCLURE')) { |
|
| 2916 | + define('_VAR_INCLURE', true); |
|
| 2917 | + } |
|
| 2918 | + // et ne pas enregistrer de cache |
|
| 2919 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2920 | + define('_VAR_NOCACHE', true); |
|
| 2921 | + } |
|
| 2922 | + $var_mode = array_diff($var_mode, array('inclure')); |
|
| 2923 | + } |
|
| 2924 | + if (in_array('urls', $var_mode)) { |
|
| 2925 | + // forcer le compilo et ignorer les caches existants |
|
| 2926 | + if (!defined('_VAR_MODE')) { |
|
| 2927 | + define('_VAR_MODE', 'calcul'); |
|
| 2928 | + } |
|
| 2929 | + if (!defined('_VAR_URLS')) { |
|
| 2930 | + define('_VAR_URLS', true); |
|
| 2931 | + } |
|
| 2932 | + $var_mode = array_diff($var_mode, array('urls')); |
|
| 2933 | + } |
|
| 2934 | + if (in_array('images', $var_mode)) { |
|
| 2935 | + // forcer le compilo et ignorer les caches existants |
|
| 2936 | + if (!defined('_VAR_MODE')) { |
|
| 2937 | + define('_VAR_MODE', 'calcul'); |
|
| 2938 | + } |
|
| 2939 | + // indiquer qu'on doit recalculer les images |
|
| 2940 | + if (!defined('_VAR_IMAGES')) { |
|
| 2941 | + define('_VAR_IMAGES', true); |
|
| 2942 | + } |
|
| 2943 | + $var_mode = array_diff($var_mode, array('images')); |
|
| 2944 | + } |
|
| 2945 | + if (in_array('debug', $var_mode)) { |
|
| 2946 | + if (!defined('_VAR_MODE')) { |
|
| 2947 | + define('_VAR_MODE', 'debug'); |
|
| 2948 | + } |
|
| 2949 | + // et ne pas enregistrer de cache |
|
| 2950 | + if (!defined('_VAR_NOCACHE')) { |
|
| 2951 | + define('_VAR_NOCACHE', true); |
|
| 2952 | + } |
|
| 2953 | + $var_mode = array_diff($var_mode, array('debug')); |
|
| 2954 | + } |
|
| 2955 | + if (count($var_mode) and !defined('_VAR_MODE')) { |
|
| 2956 | + define('_VAR_MODE', reset($var_mode)); |
|
| 2957 | + } |
|
| 2958 | + if (isset($GLOBALS['visiteur_session']['nom'])) { |
|
| 2959 | + spip_log($GLOBALS['visiteur_session']['nom'] |
|
| 2960 | + . " " . _VAR_MODE); |
|
| 2961 | + } |
|
| 2962 | + } // pas autorise ? |
|
| 2963 | + else { |
|
| 2964 | + // si on n'est pas connecte on se redirige, si on est pas en cli et pas deja en train de se loger |
|
| 2965 | + if (!$GLOBALS['visiteur_session'] |
|
| 2966 | + and !empty($_SERVER['HTTP_HOST']) |
|
| 2967 | + and !empty($_SERVER['REQUEST_METHOD']) |
|
| 2968 | + and $_SERVER['REQUEST_METHOD'] === 'GET') { |
|
| 2969 | + $self = self('&', true); |
|
| 2970 | + if (strpos($self, 'page=login') === false) { |
|
| 2971 | + include_spip('inc/headers'); |
|
| 2972 | + $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
|
| 2973 | + redirige_par_entete(generer_url_public('login','url=' . rawurlencode($redirect), true)); |
|
| 2974 | + } |
|
| 2975 | + } |
|
| 2976 | + // sinon tant pis |
|
| 2977 | + } |
|
| 2978 | + } |
|
| 2979 | + } |
|
| 2980 | + if (!defined('_VAR_MODE')) { |
|
| 2981 | + /** |
|
| 2982 | + * Indique le mode de calcul ou d'affichage de la page. |
|
| 2983 | + * @see init_var_mode() |
|
| 2984 | + */ |
|
| 2985 | + define('_VAR_MODE', false); |
|
| 2986 | + } |
|
| 2987 | + $done = true; |
|
| 2988 | + } |
|
| 2990 | 2989 | } |
| 2991 | 2990 | |
| 2992 | 2991 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ; |
@@ -2994,85 +2993,85 @@ discard block |
||
| 2994 | 2993 | // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') |
| 2995 | 2994 | // https://code.spip.net/@spip_desinfecte |
| 2996 | 2995 | function spip_desinfecte(&$t, $deep = true) { |
| 2997 | - foreach ($t as $key => $val) { |
|
| 2998 | - if (is_string($t[$key])) { |
|
| 2999 | - $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 3000 | - } // traiter aussi les "texte_plus" de article_edit |
|
| 3001 | - else { |
|
| 3002 | - if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3003 | - spip_desinfecte($t[$key], $deep); |
|
| 3004 | - } |
|
| 3005 | - } |
|
| 3006 | - } |
|
| 2996 | + foreach ($t as $key => $val) { |
|
| 2997 | + if (is_string($t[$key])) { |
|
| 2998 | + $t[$key] = str_replace(chr(0), '-', $t[$key]); |
|
| 2999 | + } // traiter aussi les "texte_plus" de article_edit |
|
| 3000 | + else { |
|
| 3001 | + if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { |
|
| 3002 | + spip_desinfecte($t[$key], $deep); |
|
| 3003 | + } |
|
| 3004 | + } |
|
| 3005 | + } |
|
| 3007 | 3006 | } |
| 3008 | 3007 | |
| 3009 | 3008 | // retourne le statut du visiteur s'il s'annonce |
| 3010 | 3009 | |
| 3011 | 3010 | // https://code.spip.net/@verifier_visiteur |
| 3012 | 3011 | function verifier_visiteur() { |
| 3013 | - // Rq: pour que cette fonction marche depuis mes_options |
|
| 3014 | - // il faut forcer l'init si ce n'est fait |
|
| 3015 | - // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3016 | - // certaines constantes |
|
| 3017 | - @spip_initialisation_core( |
|
| 3018 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3019 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3020 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3021 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3022 | - ); |
|
| 3023 | - |
|
| 3024 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3025 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3026 | - // Attention on separe bien session_nom et nom, pour eviter |
|
| 3027 | - // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3028 | - $variables_session = array('session_nom', 'session_email'); |
|
| 3029 | - foreach ($variables_session as $var) { |
|
| 3030 | - if (_request($var) !== null) { |
|
| 3031 | - $init = true; |
|
| 3032 | - break; |
|
| 3033 | - } |
|
| 3034 | - } |
|
| 3035 | - if (isset($init)) { |
|
| 3036 | - #@spip_initialisation_suite(); |
|
| 3037 | - $session = charger_fonction('session', 'inc'); |
|
| 3038 | - $session(); |
|
| 3039 | - include_spip('inc/texte'); |
|
| 3040 | - foreach ($variables_session as $var) { |
|
| 3041 | - if (($a = _request($var)) !== null) { |
|
| 3042 | - $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3043 | - } |
|
| 3044 | - } |
|
| 3045 | - if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3046 | - $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3047 | - } |
|
| 3048 | - $session($GLOBALS['visiteur_session']); |
|
| 3049 | - |
|
| 3050 | - return 0; |
|
| 3051 | - } |
|
| 3052 | - |
|
| 3053 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3054 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3055 | - |
|
| 3056 | - $session = charger_fonction('session', 'inc'); |
|
| 3057 | - if ($session()) { |
|
| 3058 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3059 | - } |
|
| 3060 | - if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3061 | - include_spip('inc/auth'); |
|
| 3062 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3063 | - } |
|
| 3064 | - if ($h) { |
|
| 3065 | - $GLOBALS['visiteur_session'] = $h; |
|
| 3066 | - |
|
| 3067 | - return $GLOBALS['visiteur_session']['statut']; |
|
| 3068 | - } |
|
| 3069 | - } |
|
| 3070 | - |
|
| 3071 | - // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3072 | - include_spip('inc/lang'); |
|
| 3073 | - utiliser_langue_visiteur(); |
|
| 3074 | - |
|
| 3075 | - return false; |
|
| 3012 | + // Rq: pour que cette fonction marche depuis mes_options |
|
| 3013 | + // il faut forcer l'init si ce n'est fait |
|
| 3014 | + // mais on risque de perturber des plugins en initialisant trop tot |
|
| 3015 | + // certaines constantes |
|
| 3016 | + @spip_initialisation_core( |
|
| 3017 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3018 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3019 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3020 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3021 | + ); |
|
| 3022 | + |
|
| 3023 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
|
| 3024 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM) |
|
| 3025 | + // Attention on separe bien session_nom et nom, pour eviter |
|
| 3026 | + // les melanges entre donnees SQL et variables plus aleatoires |
|
| 3027 | + $variables_session = array('session_nom', 'session_email'); |
|
| 3028 | + foreach ($variables_session as $var) { |
|
| 3029 | + if (_request($var) !== null) { |
|
| 3030 | + $init = true; |
|
| 3031 | + break; |
|
| 3032 | + } |
|
| 3033 | + } |
|
| 3034 | + if (isset($init)) { |
|
| 3035 | + #@spip_initialisation_suite(); |
|
| 3036 | + $session = charger_fonction('session', 'inc'); |
|
| 3037 | + $session(); |
|
| 3038 | + include_spip('inc/texte'); |
|
| 3039 | + foreach ($variables_session as $var) { |
|
| 3040 | + if (($a = _request($var)) !== null) { |
|
| 3041 | + $GLOBALS['visiteur_session'][$var] = safehtml($a); |
|
| 3042 | + } |
|
| 3043 | + } |
|
| 3044 | + if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 3045 | + $GLOBALS['visiteur_session']['id_auteur'] = 0; |
|
| 3046 | + } |
|
| 3047 | + $session($GLOBALS['visiteur_session']); |
|
| 3048 | + |
|
| 3049 | + return 0; |
|
| 3050 | + } |
|
| 3051 | + |
|
| 3052 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
|
| 3053 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3054 | + |
|
| 3055 | + $session = charger_fonction('session', 'inc'); |
|
| 3056 | + if ($session()) { |
|
| 3057 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3058 | + } |
|
| 3059 | + if ($h and isset($_SERVER['PHP_AUTH_PW'])) { |
|
| 3060 | + include_spip('inc/auth'); |
|
| 3061 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
|
| 3062 | + } |
|
| 3063 | + if ($h) { |
|
| 3064 | + $GLOBALS['visiteur_session'] = $h; |
|
| 3065 | + |
|
| 3066 | + return $GLOBALS['visiteur_session']['statut']; |
|
| 3067 | + } |
|
| 3068 | + } |
|
| 3069 | + |
|
| 3070 | + // au moins son navigateur nous dit la langue preferee de cet inconnu |
|
| 3071 | + include_spip('inc/lang'); |
|
| 3072 | + utiliser_langue_visiteur(); |
|
| 3073 | + |
|
| 3074 | + return false; |
|
| 3076 | 3075 | } |
| 3077 | 3076 | |
| 3078 | 3077 | |
@@ -3095,21 +3094,21 @@ discard block |
||
| 3095 | 3094 | * - string Langue utilisée. |
| 3096 | 3095 | **/ |
| 3097 | 3096 | function lang_select($lang = null) { |
| 3098 | - static $pile_langues = array(); |
|
| 3099 | - if (!function_exists('changer_langue')) { |
|
| 3100 | - include_spip('inc/lang'); |
|
| 3101 | - } |
|
| 3102 | - if ($lang === null) { |
|
| 3103 | - $lang = array_pop($pile_langues); |
|
| 3104 | - } else { |
|
| 3105 | - array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3106 | - } |
|
| 3107 | - if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3108 | - return $lang; |
|
| 3109 | - } |
|
| 3110 | - changer_langue($lang); |
|
| 3097 | + static $pile_langues = array(); |
|
| 3098 | + if (!function_exists('changer_langue')) { |
|
| 3099 | + include_spip('inc/lang'); |
|
| 3100 | + } |
|
| 3101 | + if ($lang === null) { |
|
| 3102 | + $lang = array_pop($pile_langues); |
|
| 3103 | + } else { |
|
| 3104 | + array_push($pile_langues, $GLOBALS['spip_lang']); |
|
| 3105 | + } |
|
| 3106 | + if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { |
|
| 3107 | + return $lang; |
|
| 3108 | + } |
|
| 3109 | + changer_langue($lang); |
|
| 3111 | 3110 | |
| 3112 | - return $lang; |
|
| 3111 | + return $lang; |
|
| 3113 | 3112 | } |
| 3114 | 3113 | |
| 3115 | 3114 | /** |
@@ -3126,19 +3125,19 @@ discard block |
||
| 3126 | 3125 | * Identifiant de la session |
| 3127 | 3126 | **/ |
| 3128 | 3127 | function spip_session($force = false) { |
| 3129 | - static $session; |
|
| 3130 | - if ($force or !isset($session)) { |
|
| 3131 | - $s = pipeline('definir_session', |
|
| 3132 | - $GLOBALS['visiteur_session'] |
|
| 3133 | - ? serialize($GLOBALS['visiteur_session']) |
|
| 3134 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3135 | - : '' |
|
| 3136 | - ); |
|
| 3137 | - $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3138 | - } |
|
| 3128 | + static $session; |
|
| 3129 | + if ($force or !isset($session)) { |
|
| 3130 | + $s = pipeline('definir_session', |
|
| 3131 | + $GLOBALS['visiteur_session'] |
|
| 3132 | + ? serialize($GLOBALS['visiteur_session']) |
|
| 3133 | + . '_' . @$_COOKIE['spip_session'] |
|
| 3134 | + : '' |
|
| 3135 | + ); |
|
| 3136 | + $session = $s ? substr(md5($s), 0, 8) : ''; |
|
| 3137 | + } |
|
| 3139 | 3138 | |
| 3140 | - #spip_log('session: '.$session); |
|
| 3141 | - return $session; |
|
| 3139 | + #spip_log('session: '.$session); |
|
| 3140 | + return $session; |
|
| 3142 | 3141 | } |
| 3143 | 3142 | |
| 3144 | 3143 | |
@@ -3157,9 +3156,9 @@ discard block |
||
| 3157 | 3156 | * Lien sur une icone d'aide |
| 3158 | 3157 | **/ |
| 3159 | 3158 | function aider($aide = '', $distante = false) { |
| 3160 | - $aider = charger_fonction('aide', 'inc', true); |
|
| 3159 | + $aider = charger_fonction('aide', 'inc', true); |
|
| 3161 | 3160 | |
| 3162 | - return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3161 | + return $aider ? $aider($aide, '', array(), $distante) : ''; |
|
| 3163 | 3162 | } |
| 3164 | 3163 | |
| 3165 | 3164 | /** |
@@ -3169,24 +3168,24 @@ discard block |
||
| 3169 | 3168 | */ |
| 3170 | 3169 | function exec_info_dist() { |
| 3171 | 3170 | |
| 3172 | - include_spip('inc/autoriser'); |
|
| 3173 | - if (autoriser('phpinfos')) { |
|
| 3174 | - $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3175 | - $cookies_backup = []; |
|
| 3176 | - foreach ($cookies_masques as $k) { |
|
| 3177 | - if (!empty($_COOKIE[$k])) { |
|
| 3178 | - $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3179 | - $_COOKIE[$k] = '******************************'; |
|
| 3180 | - } |
|
| 3181 | - } |
|
| 3182 | - phpinfo(); |
|
| 3183 | - foreach ($cookies_backup as $k => $v) { |
|
| 3184 | - $_COOKIE[$k] = $v; |
|
| 3185 | - } |
|
| 3186 | - } else { |
|
| 3187 | - include_spip('inc/filtres'); |
|
| 3188 | - sinon_interdire_acces(); |
|
| 3189 | - } |
|
| 3171 | + include_spip('inc/autoriser'); |
|
| 3172 | + if (autoriser('phpinfos')) { |
|
| 3173 | + $cookies_masques = ['spip_session', 'PHPSESSID']; |
|
| 3174 | + $cookies_backup = []; |
|
| 3175 | + foreach ($cookies_masques as $k) { |
|
| 3176 | + if (!empty($_COOKIE[$k])) { |
|
| 3177 | + $cookies_backup[$k] = $_COOKIE[$k]; |
|
| 3178 | + $_COOKIE[$k] = '******************************'; |
|
| 3179 | + } |
|
| 3180 | + } |
|
| 3181 | + phpinfo(); |
|
| 3182 | + foreach ($cookies_backup as $k => $v) { |
|
| 3183 | + $_COOKIE[$k] = $v; |
|
| 3184 | + } |
|
| 3185 | + } else { |
|
| 3186 | + include_spip('inc/filtres'); |
|
| 3187 | + sinon_interdire_acces(); |
|
| 3188 | + } |
|
| 3190 | 3189 | } |
| 3191 | 3190 | |
| 3192 | 3191 | /** |
@@ -3206,13 +3205,13 @@ discard block |
||
| 3206 | 3205 | * - string si $message à false. |
| 3207 | 3206 | **/ |
| 3208 | 3207 | function erreur_squelette($message = '', $lieu = '') { |
| 3209 | - $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3210 | - if (is_array($lieu)) { |
|
| 3211 | - include_spip('public/compiler'); |
|
| 3212 | - $lieu = reconstruire_contexte_compil($lieu); |
|
| 3213 | - } |
|
| 3208 | + $debusquer = charger_fonction('debusquer', 'public'); |
|
| 3209 | + if (is_array($lieu)) { |
|
| 3210 | + include_spip('public/compiler'); |
|
| 3211 | + $lieu = reconstruire_contexte_compil($lieu); |
|
| 3212 | + } |
|
| 3214 | 3213 | |
| 3215 | - return $debusquer($message, $lieu); |
|
| 3214 | + return $debusquer($message, $lieu); |
|
| 3216 | 3215 | } |
| 3217 | 3216 | |
| 3218 | 3217 | /** |
@@ -3249,109 +3248,109 @@ discard block |
||
| 3249 | 3248 | * - ou tableau d'information sur le squelette. |
| 3250 | 3249 | */ |
| 3251 | 3250 | function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { |
| 3252 | - if (!function_exists('evaluer_fond')) { |
|
| 3253 | - include_spip('public/assembler'); |
|
| 3254 | - } |
|
| 3255 | - // assurer la compat avec l'ancienne syntaxe |
|
| 3256 | - // (trim etait le 3eme argument, par defaut a true) |
|
| 3257 | - if (!is_array($options)) { |
|
| 3258 | - $options = array('trim' => $options); |
|
| 3259 | - } |
|
| 3260 | - if (!isset($options['trim'])) { |
|
| 3261 | - $options['trim'] = true; |
|
| 3262 | - } |
|
| 3263 | - |
|
| 3264 | - if (isset($contexte['connect'])) { |
|
| 3265 | - $connect = $contexte['connect']; |
|
| 3266 | - unset($contexte['connect']); |
|
| 3267 | - } |
|
| 3268 | - |
|
| 3269 | - $texte = ""; |
|
| 3270 | - $pages = array(); |
|
| 3271 | - $lang_select = ''; |
|
| 3272 | - if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3273 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3274 | - if (!isset($contexte['lang'])) { |
|
| 3275 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3276 | - } |
|
| 3277 | - |
|
| 3278 | - if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3279 | - $lang_select = lang_select($contexte['lang']); |
|
| 3280 | - } |
|
| 3281 | - } |
|
| 3282 | - |
|
| 3283 | - if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3284 | - $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3285 | - } |
|
| 3286 | - |
|
| 3287 | - $GLOBALS['_INC_PUBLIC']++; |
|
| 3288 | - |
|
| 3289 | - // fix #4235 |
|
| 3290 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3291 | - |
|
| 3292 | - |
|
| 3293 | - foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3251 | + if (!function_exists('evaluer_fond')) { |
|
| 3252 | + include_spip('public/assembler'); |
|
| 3253 | + } |
|
| 3254 | + // assurer la compat avec l'ancienne syntaxe |
|
| 3255 | + // (trim etait le 3eme argument, par defaut a true) |
|
| 3256 | + if (!is_array($options)) { |
|
| 3257 | + $options = array('trim' => $options); |
|
| 3258 | + } |
|
| 3259 | + if (!isset($options['trim'])) { |
|
| 3260 | + $options['trim'] = true; |
|
| 3261 | + } |
|
| 3262 | + |
|
| 3263 | + if (isset($contexte['connect'])) { |
|
| 3264 | + $connect = $contexte['connect']; |
|
| 3265 | + unset($contexte['connect']); |
|
| 3266 | + } |
|
| 3267 | + |
|
| 3268 | + $texte = ""; |
|
| 3269 | + $pages = array(); |
|
| 3270 | + $lang_select = ''; |
|
| 3271 | + if (!isset($options['etoile']) or !$options['etoile']) { |
|
| 3272 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante |
|
| 3273 | + if (!isset($contexte['lang'])) { |
|
| 3274 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 3275 | + } |
|
| 3276 | + |
|
| 3277 | + if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 3278 | + $lang_select = lang_select($contexte['lang']); |
|
| 3279 | + } |
|
| 3280 | + } |
|
| 3281 | + |
|
| 3282 | + if (!isset($GLOBALS['_INC_PUBLIC'])) { |
|
| 3283 | + $GLOBALS['_INC_PUBLIC'] = 0; |
|
| 3284 | + } |
|
| 3285 | + |
|
| 3286 | + $GLOBALS['_INC_PUBLIC']++; |
|
| 3287 | + |
|
| 3288 | + // fix #4235 |
|
| 3289 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3290 | + |
|
| 3291 | + |
|
| 3292 | + foreach (is_array($fond) ? $fond : array($fond) as $f) { |
|
| 3294 | 3293 | |
| 3295 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3296 | - |
|
| 3297 | - $page = evaluer_fond($f, $contexte, $connect); |
|
| 3298 | - if ($page === '') { |
|
| 3299 | - $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3300 | - $a = array('fichier' => $f); |
|
| 3301 | - $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3302 | - erreur_squelette($erreur, $c); |
|
| 3303 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3304 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3305 | - } |
|
| 3306 | - |
|
| 3307 | - $page = pipeline('recuperer_fond', array( |
|
| 3308 | - 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3309 | - 'data' => $page |
|
| 3310 | - )); |
|
| 3311 | - if (isset($options['ajax']) and $options['ajax']) { |
|
| 3312 | - if (!function_exists('encoder_contexte_ajax')) { |
|
| 3313 | - include_spip('inc/filtres'); |
|
| 3314 | - } |
|
| 3315 | - $page['texte'] = encoder_contexte_ajax( |
|
| 3316 | - array_merge( |
|
| 3317 | - $contexte, |
|
| 3318 | - array('fond' => $f), |
|
| 3319 | - ($connect ? array('connect' => $connect) : array()) |
|
| 3320 | - ), |
|
| 3321 | - '', |
|
| 3322 | - $page['texte'], |
|
| 3323 | - $options['ajax'] |
|
| 3324 | - ); |
|
| 3325 | - } |
|
| 3326 | - |
|
| 3327 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3328 | - $pages[] = $page; |
|
| 3329 | - } else { |
|
| 3330 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3331 | - } |
|
| 3294 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3295 | + |
|
| 3296 | + $page = evaluer_fond($f, $contexte, $connect); |
|
| 3297 | + if ($page === '') { |
|
| 3298 | + $c = isset($options['compil']) ? $options['compil'] : ''; |
|
| 3299 | + $a = array('fichier' => $f); |
|
| 3300 | + $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable |
|
| 3301 | + erreur_squelette($erreur, $c); |
|
| 3302 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 3303 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 3304 | + } |
|
| 3305 | + |
|
| 3306 | + $page = pipeline('recuperer_fond', array( |
|
| 3307 | + 'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), |
|
| 3308 | + 'data' => $page |
|
| 3309 | + )); |
|
| 3310 | + if (isset($options['ajax']) and $options['ajax']) { |
|
| 3311 | + if (!function_exists('encoder_contexte_ajax')) { |
|
| 3312 | + include_spip('inc/filtres'); |
|
| 3313 | + } |
|
| 3314 | + $page['texte'] = encoder_contexte_ajax( |
|
| 3315 | + array_merge( |
|
| 3316 | + $contexte, |
|
| 3317 | + array('fond' => $f), |
|
| 3318 | + ($connect ? array('connect' => $connect) : array()) |
|
| 3319 | + ), |
|
| 3320 | + '', |
|
| 3321 | + $page['texte'], |
|
| 3322 | + $options['ajax'] |
|
| 3323 | + ); |
|
| 3324 | + } |
|
| 3325 | + |
|
| 3326 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3327 | + $pages[] = $page; |
|
| 3328 | + } else { |
|
| 3329 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte']; |
|
| 3330 | + } |
|
| 3332 | 3331 | |
| 3333 | - // contamination de la session appelante, pour les inclusions statiques |
|
| 3334 | - if (isset($page['invalideurs']['session'])){ |
|
| 3335 | - $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3336 | - } |
|
| 3337 | - } |
|
| 3332 | + // contamination de la session appelante, pour les inclusions statiques |
|
| 3333 | + if (isset($page['invalideurs']['session'])){ |
|
| 3334 | + $cache_utilise_session_appelant = $page['invalideurs']['session']; |
|
| 3335 | + } |
|
| 3336 | + } |
|
| 3338 | 3337 | |
| 3339 | - // restaurer le sessionnement du contexte appelant, |
|
| 3340 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3341 | - if (isset($cache_utilise_session_appelant)) { |
|
| 3342 | - $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3343 | - } |
|
| 3338 | + // restaurer le sessionnement du contexte appelant, |
|
| 3339 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée |
|
| 3340 | + if (isset($cache_utilise_session_appelant)) { |
|
| 3341 | + $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant; |
|
| 3342 | + } |
|
| 3344 | 3343 | |
| 3345 | - $GLOBALS['_INC_PUBLIC']--; |
|
| 3344 | + $GLOBALS['_INC_PUBLIC']--; |
|
| 3346 | 3345 | |
| 3347 | - if ($lang_select) { |
|
| 3348 | - lang_select(); |
|
| 3349 | - } |
|
| 3350 | - if (isset($options['raw']) and $options['raw']) { |
|
| 3351 | - return is_array($fond) ? $pages : reset($pages); |
|
| 3352 | - } else { |
|
| 3353 | - return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3354 | - } |
|
| 3346 | + if ($lang_select) { |
|
| 3347 | + lang_select(); |
|
| 3348 | + } |
|
| 3349 | + if (isset($options['raw']) and $options['raw']) { |
|
| 3350 | + return is_array($fond) ? $pages : reset($pages); |
|
| 3351 | + } else { |
|
| 3352 | + return $options['trim'] ? ltrim($texte) : $texte; |
|
| 3353 | + } |
|
| 3355 | 3354 | } |
| 3356 | 3355 | |
| 3357 | 3356 | /** |
@@ -3361,7 +3360,7 @@ discard block |
||
| 3361 | 3360 | * @return string |
| 3362 | 3361 | */ |
| 3363 | 3362 | function trouve_modele($nom) { |
| 3364 | - return trouver_fond($nom, 'modeles/'); |
|
| 3363 | + return trouver_fond($nom, 'modeles/'); |
|
| 3365 | 3364 | } |
| 3366 | 3365 | |
| 3367 | 3366 | /** |
@@ -3377,21 +3376,21 @@ discard block |
||
| 3377 | 3376 | * @return array|string |
| 3378 | 3377 | */ |
| 3379 | 3378 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3380 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3381 | - if (!$pathinfo) { |
|
| 3382 | - return $f; |
|
| 3383 | - } |
|
| 3384 | - // renvoyer un tableau detaille si $pathinfo==true |
|
| 3385 | - $p = pathinfo($f); |
|
| 3386 | - if (!isset($p['extension']) or !$p['extension']) { |
|
| 3387 | - $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3388 | - } |
|
| 3389 | - if (!isset($p['extension']) or !$p['filename']) { |
|
| 3390 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3391 | - } |
|
| 3392 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3379 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3380 | + if (!$pathinfo) { |
|
| 3381 | + return $f; |
|
| 3382 | + } |
|
| 3383 | + // renvoyer un tableau detaille si $pathinfo==true |
|
| 3384 | + $p = pathinfo($f); |
|
| 3385 | + if (!isset($p['extension']) or !$p['extension']) { |
|
| 3386 | + $p['extension'] = _EXTENSION_SQUELETTES; |
|
| 3387 | + } |
|
| 3388 | + if (!isset($p['extension']) or !$p['filename']) { |
|
| 3389 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : ''); |
|
| 3390 | + } |
|
| 3391 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : ''); |
|
| 3393 | 3392 | |
| 3394 | - return $p; |
|
| 3393 | + return $p; |
|
| 3395 | 3394 | } |
| 3396 | 3395 | |
| 3397 | 3396 | /** |
@@ -3412,24 +3411,24 @@ discard block |
||
| 3412 | 3411 | * Nom de l'exec, sinon chaîne vide. |
| 3413 | 3412 | **/ |
| 3414 | 3413 | function tester_url_ecrire($nom) { |
| 3415 | - static $exec = array(); |
|
| 3416 | - if (isset($exec[$nom])) { |
|
| 3417 | - return $exec[$nom]; |
|
| 3418 | - } |
|
| 3419 | - // tester si c'est une page en squelette |
|
| 3420 | - if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3421 | - return $exec[$nom] = 'fond'; |
|
| 3422 | - } // compat skels orthogonaux version precedente |
|
| 3423 | - elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3424 | - return $exec[$nom] = 'fond_monobloc'; |
|
| 3425 | - } // echafaudage d'un fond ! |
|
| 3426 | - elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3427 | - return $exec[$nom] = 'fond'; |
|
| 3428 | - } |
|
| 3429 | - // attention, il ne faut pas inclure l'exec ici |
|
| 3430 | - // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3431 | - // et des define intrusifs potentiels |
|
| 3432 | - return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3414 | + static $exec = array(); |
|
| 3415 | + if (isset($exec[$nom])) { |
|
| 3416 | + return $exec[$nom]; |
|
| 3417 | + } |
|
| 3418 | + // tester si c'est une page en squelette |
|
| 3419 | + if (trouver_fond($nom, 'prive/squelettes/contenu/')) { |
|
| 3420 | + return $exec[$nom] = 'fond'; |
|
| 3421 | + } // compat skels orthogonaux version precedente |
|
| 3422 | + elseif (trouver_fond($nom, 'prive/exec/')) { |
|
| 3423 | + return $exec[$nom] = 'fond_monobloc'; |
|
| 3424 | + } // echafaudage d'un fond ! |
|
| 3425 | + elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { |
|
| 3426 | + return $exec[$nom] = 'fond'; |
|
| 3427 | + } |
|
| 3428 | + // attention, il ne faut pas inclure l'exec ici |
|
| 3429 | + // car sinon #URL_ECRIRE provoque des inclusions |
|
| 3430 | + // et des define intrusifs potentiels |
|
| 3431 | + return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); |
|
| 3433 | 3432 | } |
| 3434 | 3433 | |
| 3435 | 3434 | |
@@ -3445,10 +3444,10 @@ discard block |
||
| 3445 | 3444 | * @return bool true si le module est chargé |
| 3446 | 3445 | **/ |
| 3447 | 3446 | function charger_php_extension($module) { |
| 3448 | - if (extension_loaded($module)) { |
|
| 3449 | - return true; |
|
| 3450 | - } |
|
| 3451 | - return false; |
|
| 3447 | + if (extension_loaded($module)) { |
|
| 3448 | + return true; |
|
| 3449 | + } |
|
| 3450 | + return false; |
|
| 3452 | 3451 | } |
| 3453 | 3452 | |
| 3454 | 3453 | |
@@ -3459,8 +3458,8 @@ discard block |
||
| 3459 | 3458 | * true si la constante _VERSION_HTML n'est pas définie ou égale à html5 |
| 3460 | 3459 | **/ |
| 3461 | 3460 | function html5_permis() { |
| 3462 | - return (!defined('_VERSION_HTML') |
|
| 3463 | - or _VERSION_HTML !== 'html4'); |
|
| 3461 | + return (!defined('_VERSION_HTML') |
|
| 3462 | + or _VERSION_HTML !== 'html4'); |
|
| 3464 | 3463 | } |
| 3465 | 3464 | |
| 3466 | 3465 | /** |
@@ -3470,30 +3469,30 @@ discard block |
||
| 3470 | 3469 | * @return array |
| 3471 | 3470 | */ |
| 3472 | 3471 | function formats_image_acceptables($gd = null, $svg_allowed = true) { |
| 3473 | - $formats = null; |
|
| 3474 | - if (!is_null($gd)) { |
|
| 3475 | - $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3476 | - if (isset($GLOBALS['meta'][$config])) { |
|
| 3477 | - $formats = $GLOBALS['meta'][$config]; |
|
| 3478 | - $formats = explode(',', $formats); |
|
| 3479 | - $formats = array_filter($formats); |
|
| 3480 | - $formats = array_map('trim', $formats); |
|
| 3481 | - } |
|
| 3482 | - } |
|
| 3483 | - if (is_null($formats)) { |
|
| 3484 | - include_spip('inc/filtres_images_lib_mini'); |
|
| 3485 | - $formats = _image_extensions_acceptees_en_entree(); |
|
| 3486 | - } |
|
| 3487 | - |
|
| 3488 | - if ($svg_allowed) { |
|
| 3489 | - if (!in_array('svg', $formats)) { |
|
| 3490 | - $formats[] = 'svg'; |
|
| 3491 | - } |
|
| 3492 | - } |
|
| 3493 | - else { |
|
| 3494 | - $formats = array_diff($formats, ['svg']); |
|
| 3495 | - } |
|
| 3496 | - return $formats; |
|
| 3472 | + $formats = null; |
|
| 3473 | + if (!is_null($gd)) { |
|
| 3474 | + $config = ($gd ? "gd_formats" : "formats_graphiques"); |
|
| 3475 | + if (isset($GLOBALS['meta'][$config])) { |
|
| 3476 | + $formats = $GLOBALS['meta'][$config]; |
|
| 3477 | + $formats = explode(',', $formats); |
|
| 3478 | + $formats = array_filter($formats); |
|
| 3479 | + $formats = array_map('trim', $formats); |
|
| 3480 | + } |
|
| 3481 | + } |
|
| 3482 | + if (is_null($formats)) { |
|
| 3483 | + include_spip('inc/filtres_images_lib_mini'); |
|
| 3484 | + $formats = _image_extensions_acceptees_en_entree(); |
|
| 3485 | + } |
|
| 3486 | + |
|
| 3487 | + if ($svg_allowed) { |
|
| 3488 | + if (!in_array('svg', $formats)) { |
|
| 3489 | + $formats[] = 'svg'; |
|
| 3490 | + } |
|
| 3491 | + } |
|
| 3492 | + else { |
|
| 3493 | + $formats = array_diff($formats, ['svg']); |
|
| 3494 | + } |
|
| 3495 | + return $formats; |
|
| 3497 | 3496 | } |
| 3498 | 3497 | |
| 3499 | 3498 | /** |
@@ -3502,21 +3501,21 @@ discard block |
||
| 3502 | 3501 | * @return array|bool |
| 3503 | 3502 | */ |
| 3504 | 3503 | function spip_getimagesize($fichier) { |
| 3505 | - if (!$imagesize = @getimagesize($fichier)) { |
|
| 3504 | + if (!$imagesize = @getimagesize($fichier)) { |
|
| 3506 | 3505 | |
| 3507 | - include_spip("inc/svg"); |
|
| 3508 | - if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3509 | - list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 3510 | - $imagesize = [ |
|
| 3511 | - $width, |
|
| 3512 | - $height, |
|
| 3513 | - IMAGETYPE_SVG, |
|
| 3514 | - "width=\"{$width}\" height=\"{$height}\"", |
|
| 3515 | - "mime" => "image/svg+xml" |
|
| 3516 | - ]; |
|
| 3517 | - } |
|
| 3518 | - } |
|
| 3519 | - return $imagesize; |
|
| 3506 | + include_spip("inc/svg"); |
|
| 3507 | + if ($attrs = svg_lire_attributs($fichier)) { |
|
| 3508 | + list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs); |
|
| 3509 | + $imagesize = [ |
|
| 3510 | + $width, |
|
| 3511 | + $height, |
|
| 3512 | + IMAGETYPE_SVG, |
|
| 3513 | + "width=\"{$width}\" height=\"{$height}\"", |
|
| 3514 | + "mime" => "image/svg+xml" |
|
| 3515 | + ]; |
|
| 3516 | + } |
|
| 3517 | + } |
|
| 3518 | + return $imagesize; |
|
| 3520 | 3519 | } |
| 3521 | 3520 | |
| 3522 | 3521 | |
@@ -3536,7 +3535,7 @@ discard block |
||
| 3536 | 3535 | * @return mixed Valeur de la meta. |
| 3537 | 3536 | **/ |
| 3538 | 3537 | function lire_meta($nom) { |
| 3539 | - return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3538 | + return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null; |
|
| 3540 | 3539 | } |
| 3541 | 3540 | |
| 3542 | 3541 | |
@@ -3558,18 +3557,18 @@ discard block |
||
| 3558 | 3557 | * @param string $statut |
| 3559 | 3558 | */ |
| 3560 | 3559 | function avertir_auteurs($nom, $message, $statut = '') { |
| 3561 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3562 | - if (!$alertes |
|
| 3563 | - or !is_array($alertes = unserialize($alertes)) |
|
| 3564 | - ) { |
|
| 3565 | - $alertes = array(); |
|
| 3566 | - } |
|
| 3560 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs']; |
|
| 3561 | + if (!$alertes |
|
| 3562 | + or !is_array($alertes = unserialize($alertes)) |
|
| 3563 | + ) { |
|
| 3564 | + $alertes = array(); |
|
| 3565 | + } |
|
| 3567 | 3566 | |
| 3568 | - if (!isset($alertes[$statut])) { |
|
| 3569 | - $alertes[$statut] = array(); |
|
| 3570 | - } |
|
| 3571 | - $alertes[$statut][$nom] = $message; |
|
| 3572 | - ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3567 | + if (!isset($alertes[$statut])) { |
|
| 3568 | + $alertes[$statut] = array(); |
|
| 3569 | + } |
|
| 3570 | + $alertes[$statut][$nom] = $message; |
|
| 3571 | + ecrire_meta("message_alertes_auteurs", serialize($alertes)); |
|
| 3573 | 3572 | } |
| 3574 | 3573 | |
| 3575 | 3574 | /** |
@@ -3583,10 +3582,10 @@ discard block |
||
| 3583 | 3582 | * @return string|string[] |
| 3584 | 3583 | */ |
| 3585 | 3584 | function spip_sanitize_classname($classes) { |
| 3586 | - if (is_array($classes)) { |
|
| 3587 | - return array_map('spip_sanitize_classname', $classes); |
|
| 3588 | - } |
|
| 3589 | - return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes); |
|
| 3585 | + if (is_array($classes)) { |
|
| 3586 | + return array_map('spip_sanitize_classname', $classes); |
|
| 3587 | + } |
|
| 3588 | + return preg_replace("/[^ 0-9a-z_\-+@]/i", "", $classes); |
|
| 3590 | 3589 | } |
| 3591 | 3590 | |
| 3592 | 3591 | |
@@ -3611,32 +3610,32 @@ discard block |
||
| 3611 | 3610 | * Avec operateur : bool. |
| 3612 | 3611 | **/ |
| 3613 | 3612 | function spip_version_compare($v1, $v2, $op = null) { |
| 3614 | - $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3615 | - $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3616 | - $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3617 | - $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3618 | - |
|
| 3619 | - $v1 = explode('.', $v1); |
|
| 3620 | - $v2 = explode('.', $v2); |
|
| 3621 | - // $v1 est toujours une version, donc sans etoile |
|
| 3622 | - while (count($v1) < count($v2)) { |
|
| 3623 | - $v1[] = '0'; |
|
| 3624 | - } |
|
| 3625 | - |
|
| 3626 | - // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3627 | - $etoile = false; |
|
| 3628 | - foreach ($v1 as $k => $v) { |
|
| 3629 | - if (!isset($v2[$k])) { |
|
| 3630 | - $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3631 | - } else { |
|
| 3632 | - if ($v2[$k] == '*') { |
|
| 3633 | - $etoile = true; |
|
| 3634 | - $v2[$k] = $v; |
|
| 3635 | - } |
|
| 3636 | - } |
|
| 3637 | - } |
|
| 3638 | - $v1 = implode('.', $v1); |
|
| 3639 | - $v2 = implode('.', $v2); |
|
| 3640 | - |
|
| 3641 | - return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3613 | + $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1)); |
|
| 3614 | + $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2)); |
|
| 3615 | + $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3616 | + $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule |
|
| 3617 | + |
|
| 3618 | + $v1 = explode('.', $v1); |
|
| 3619 | + $v2 = explode('.', $v2); |
|
| 3620 | + // $v1 est toujours une version, donc sans etoile |
|
| 3621 | + while (count($v1) < count($v2)) { |
|
| 3622 | + $v1[] = '0'; |
|
| 3623 | + } |
|
| 3624 | + |
|
| 3625 | + // $v2 peut etre une borne, donc accepte l'etoile |
|
| 3626 | + $etoile = false; |
|
| 3627 | + foreach ($v1 as $k => $v) { |
|
| 3628 | + if (!isset($v2[$k])) { |
|
| 3629 | + $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0'; |
|
| 3630 | + } else { |
|
| 3631 | + if ($v2[$k] == '*') { |
|
| 3632 | + $etoile = true; |
|
| 3633 | + $v2[$k] = $v; |
|
| 3634 | + } |
|
| 3635 | + } |
|
| 3636 | + } |
|
| 3637 | + $v1 = implode('.', $v1); |
|
| 3638 | + $v2 = implode('.', $v2); |
|
| 3639 | + |
|
| 3640 | + return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2); |
|
| 3642 | 3641 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | if (strlen($dossier) and substr($dossier, -1) != '/') { |
| 54 | 54 | $dossier .= '/'; |
| 55 | 55 | } |
| 56 | - $f = str_replace('/', '_', $dossier) . $nom; |
|
| 56 | + $f = str_replace('/', '_', $dossier).$nom; |
|
| 57 | 57 | |
| 58 | 58 | if (function_exists($f)) { |
| 59 | 59 | return $f; |
| 60 | 60 | } |
| 61 | - if (function_exists($g = $f . '_dist')) { |
|
| 61 | + if (function_exists($g = $f.'_dist')) { |
|
| 62 | 62 | return $g; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // passer en minuscules (cf les balises de formulaires) |
| 80 | 80 | // et inclure le fichier |
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom))) |
|
| 81 | + if (!$inc = include_spip($dossier.($d = strtolower($nom))) |
|
| 82 | 82 | // si le fichier truc/machin/nom.php n'existe pas, |
| 83 | 83 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions |
| 84 | 84 | and strlen(dirname($dossier)) and dirname($dossier) != '.' |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Echec : message d'erreur |
| 100 | - spip_log("fonction $nom ($f ou $g) indisponible" . |
|
| 100 | + spip_log("fonction $nom ($f ou $g) indisponible". |
|
| 101 | 101 | ($inc ? "" : " (fichier $d absent de $dossier)")); |
| 102 | 102 | |
| 103 | 103 | include_spip('inc/minipres'); |
| 104 | 104 | echo minipres(_T('forum_titre_erreur'), |
| 105 | - _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), |
|
| 106 | - array('all_inline'=>true,'status'=>404)); |
|
| 105 | + _T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')), |
|
| 106 | + array('all_inline'=>true, 'status'=>404)); |
|
| 107 | 107 | exit; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * - string : chemin du fichier trouvé |
| 149 | 149 | **/ |
| 150 | 150 | function include_spip($f, $include = true) { |
| 151 | - return find_in_path($f . '.php', '', $include); |
|
| 151 | + return find_in_path($f.'.php', '', $include); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * - string : chemin du fichier trouvé |
| 169 | 169 | **/ |
| 170 | 170 | function require_spip($f) { |
| 171 | - return find_in_path($f . '.php', '', 'required'); |
|
| 171 | + return find_in_path($f.'.php', '', 'required'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // donc il faut l'inclure "en globals" |
| 186 | 186 | if ($f = find_in_path('mes_fonctions.php')) { |
| 187 | 187 | global $dossier_squelettes; |
| 188 | - include_once(_ROOT_CWD . $f); |
|
| 188 | + include_once(_ROOT_CWD.$f); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // appliquer notre fonction si elle existe |
| 292 | - $fonc = 'execute_pipeline_' . strtolower($action); |
|
| 292 | + $fonc = 'execute_pipeline_'.strtolower($action); |
|
| 293 | 293 | if (function_exists($fonc)) { |
| 294 | 294 | $val = $fonc($val); |
| 295 | 295 | } // plantage ? |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | function spip_log($message = null, $name = null) { |
| 354 | 354 | static $pre = array(); |
| 355 | 355 | static $log; |
| 356 | - preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); |
|
| 356 | + preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); |
|
| 357 | 357 | if (!isset($regs[1]) or !$logname = $regs[1]) { |
| 358 | 358 | $logname = null; |
| 359 | 359 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | if (!is_string($message)) { |
| 382 | 382 | $message = print_r($message, true); |
| 383 | 383 | } |
| 384 | - $log($pre[$niveau] . ' ' . $message, $logname); |
|
| 384 | + $log($pre[$niveau].' '.$message, $logname); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -494,9 +494,9 @@ discard block |
||
| 494 | 494 | * @param string $sanitize_function |
| 495 | 495 | * @return array|mixed|string |
| 496 | 496 | */ |
| 497 | -function spip_sanitize_from_request($value, $key, $sanitize_function='entites_html') { |
|
| 497 | +function spip_sanitize_from_request($value, $key, $sanitize_function = 'entites_html') { |
|
| 498 | 498 | if (is_array($value)) { |
| 499 | - if ($key=='*') { |
|
| 499 | + if ($key == '*') { |
|
| 500 | 500 | $key = array_keys($value); |
| 501 | 501 | } |
| 502 | 502 | if (!is_array($key)) { |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | $a = './'; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; |
|
| 584 | + $regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; |
|
| 585 | 585 | $ajouts = array_flip(explode('|', $c)); |
| 586 | 586 | $u = is_array($v) ? $v : rawurlencode($v); |
| 587 | 587 | $testv = (is_array($v) ? count($v) : strlen($v)); |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | // Ajout. Pour une variable, remplacer au meme endroit, |
| 609 | 609 | // pour un tableau ce sera fait dans la prochaine boucle |
| 610 | 610 | elseif (substr($r[1], -2) != '[]') { |
| 611 | - $url[$n] = $r[1] . '=' . $u; |
|
| 611 | + $url[$n] = $r[1].'='.$u; |
|
| 612 | 612 | unset($ajouts[$r[1]]); |
| 613 | 613 | } |
| 614 | 614 | // Pour les tableaux on laisse tomber les valeurs de |
@@ -628,11 +628,11 @@ discard block |
||
| 628 | 628 | } elseif ($testv) { |
| 629 | 629 | foreach ($ajouts as $k => $n) { |
| 630 | 630 | if (!is_array($v)) { |
| 631 | - $url[] = $k . '=' . $u; |
|
| 631 | + $url[] = $k.'='.$u; |
|
| 632 | 632 | } else { |
| 633 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]"); |
|
| 633 | + $id = (substr($k, -2) == '[]') ? $k : ($k."[]"); |
|
| 634 | 634 | foreach ($v as $w) { |
| 635 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w); |
|
| 635 | + $url[] = $id.'='.(is_array($w) ? 'Array' : $w); |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } |
@@ -643,10 +643,10 @@ discard block |
||
| 643 | 643 | |
| 644 | 644 | // recomposer l'adresse |
| 645 | 645 | if ($url) { |
| 646 | - $a .= '?' . join($sep, $url); |
|
| 646 | + $a .= '?'.join($sep, $url); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - return $a . $ancre; |
|
| 649 | + return $a.$ancre; |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | translitteration($ancre) |
| 679 | 679 | ); |
| 680 | 680 | } |
| 681 | - return $url . (strlen($ancre) ? '#' . $ancre : ''); |
|
| 681 | + return $url.(strlen($ancre) ? '#'.$ancre : ''); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | /** |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @return bool |
| 791 | 791 | */ |
| 792 | 792 | function test_plugin_actif($plugin) { |
| 793 | - return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; |
|
| 793 | + return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
@@ -858,8 +858,7 @@ discard block |
||
| 858 | 858 | // pour les chaines non traduites, assurer un service minimum |
| 859 | 859 | if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { |
| 860 | 860 | $text = str_replace('_', ' ', |
| 861 | - (($n = strpos($text, ':')) === false ? $texte : |
|
| 862 | - substr($texte, $n + 1))); |
|
| 861 | + (($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1))); |
|
| 863 | 862 | } |
| 864 | 863 | $o['class'] = null; |
| 865 | 864 | |
@@ -931,7 +930,7 @@ discard block |
||
| 931 | 930 | // Si des variables n'ont pas ete inserees, le signaler |
| 932 | 931 | // (chaines de langues pas a jour) |
| 933 | 932 | if ($args) { |
| 934 | - spip_log("$f: variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 933 | + spip_log("$f: variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); |
|
| 935 | 934 | } |
| 936 | 935 | } |
| 937 | 936 | |
@@ -955,7 +954,7 @@ discard block |
||
| 955 | 954 | function joli_repertoire($rep) { |
| 956 | 955 | $a = substr($rep, 0, 1); |
| 957 | 956 | if ($a <> '.' and $a <> '/') { |
| 958 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep; |
|
| 957 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep; |
|
| 959 | 958 | } |
| 960 | 959 | $rep = preg_replace(',(^\.\.\/),', '', $rep); |
| 961 | 960 | |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | $p -= ($x * 1000); |
| 1010 | 1009 | } |
| 1011 | 1010 | |
| 1012 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1011 | + return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p); |
|
| 1013 | 1012 | } |
| 1014 | 1013 | } |
| 1015 | 1014 | |
@@ -1078,7 +1077,7 @@ discard block |
||
| 1078 | 1077 | if ($taches and count($taches) and !spip_connect()) { |
| 1079 | 1078 | return false; |
| 1080 | 1079 | } |
| 1081 | - spip_log("cron !", 'jq' . _LOG_DEBUG); |
|
| 1080 | + spip_log("cron !", 'jq'._LOG_DEBUG); |
|
| 1082 | 1081 | if ($genie = charger_fonction('genie', 'inc', true)) { |
| 1083 | 1082 | return $genie($taches); |
| 1084 | 1083 | } |
@@ -1182,7 +1181,7 @@ discard block |
||
| 1182 | 1181 | |
| 1183 | 1182 | if ($queue_next_job_time == -1) { |
| 1184 | 1183 | if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { |
| 1185 | - define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); |
|
| 1184 | + define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt"); |
|
| 1186 | 1185 | } |
| 1187 | 1186 | // utiliser un cache memoire si dispo |
| 1188 | 1187 | if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
@@ -1249,8 +1248,8 @@ discard block |
||
| 1249 | 1248 | $src = ''; |
| 1250 | 1249 | } |
| 1251 | 1250 | if ($script) { |
| 1252 | - $script = ("/*<![CDATA[*/\n" . |
|
| 1253 | - preg_replace(',</([^>]*)>,', '<\/\1>', $script) . |
|
| 1251 | + $script = ("/*<![CDATA[*/\n". |
|
| 1252 | + preg_replace(',</([^>]*)>,', '<\/\1>', $script). |
|
| 1254 | 1253 | "/*]]>*/"); |
| 1255 | 1254 | } |
| 1256 | 1255 | if ($noscript) { |
@@ -1336,13 +1335,13 @@ discard block |
||
| 1336 | 1335 | if ($path_base == null) { |
| 1337 | 1336 | // Chemin standard depuis l'espace public |
| 1338 | 1337 | $path = defined('_SPIP_PATH') ? _SPIP_PATH : |
| 1339 | - _DIR_RACINE . ':' . |
|
| 1340 | - _DIR_RACINE . 'squelettes-dist/:' . |
|
| 1341 | - _DIR_RACINE . 'prive/:' . |
|
| 1338 | + _DIR_RACINE.':'. |
|
| 1339 | + _DIR_RACINE.'squelettes-dist/:'. |
|
| 1340 | + _DIR_RACINE.'prive/:'. |
|
| 1342 | 1341 | _DIR_RESTREINT; |
| 1343 | 1342 | // Ajouter squelettes/ |
| 1344 | - if (@is_dir(_DIR_RACINE . 'squelettes')) { |
|
| 1345 | - $path = _DIR_RACINE . 'squelettes/:' . $path; |
|
| 1343 | + if (@is_dir(_DIR_RACINE.'squelettes')) { |
|
| 1344 | + $path = _DIR_RACINE.'squelettes/:'.$path; |
|
| 1346 | 1345 | } |
| 1347 | 1346 | foreach (explode(':', $path) as $dir) { |
| 1348 | 1347 | if (strlen($dir) and substr($dir, -1) != '/') { |
@@ -1354,7 +1353,7 @@ discard block |
||
| 1354 | 1353 | // Et le(s) dossier(s) des squelettes nommes |
| 1355 | 1354 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1356 | 1355 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1357 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1356 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/'); |
|
| 1358 | 1357 | } |
| 1359 | 1358 | } |
| 1360 | 1359 | $GLOBALS['path_sig'] = md5(serialize($path_full)); |
@@ -1365,7 +1364,7 @@ discard block |
||
| 1365 | 1364 | |
| 1366 | 1365 | if (is_array($dir_path) or strlen($dir_path)) { |
| 1367 | 1366 | $tete = ""; |
| 1368 | - if (reset($path_base) == _DIR_RACINE . 'squelettes/') { |
|
| 1367 | + if (reset($path_base) == _DIR_RACINE.'squelettes/') { |
|
| 1369 | 1368 | $tete = array_shift($path_base); |
| 1370 | 1369 | } |
| 1371 | 1370 | $dirs = (is_array($dir_path) ? $dir_path : explode(':', $dir_path)); |
@@ -1386,7 +1385,7 @@ discard block |
||
| 1386 | 1385 | // Et le(s) dossier(s) des squelettes nommes |
| 1387 | 1386 | if (strlen($GLOBALS['dossier_squelettes'])) { |
| 1388 | 1387 | foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { |
| 1389 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/'); |
|
| 1388 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/'); |
|
| 1390 | 1389 | } |
| 1391 | 1390 | } |
| 1392 | 1391 | |
@@ -1456,9 +1455,9 @@ discard block |
||
| 1456 | 1455 | // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png |
| 1457 | 1456 | // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png |
| 1458 | 1457 | if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m) |
| 1459 | - and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg" |
|
| 1458 | + and $file_svg_generique = substr($file, 0, -strlen($m[0]))."-xx.svg" |
|
| 1460 | 1459 | and $f = find_in_theme("$file_svg_generique")) { |
| 1461 | - if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) { |
|
| 1460 | + if ($fsize = substr($f, 0, -6).$m[1].".svg" and file_exists($fsize)) { |
|
| 1462 | 1461 | return $themefiles["$subdir$file"] = $fsize; |
| 1463 | 1462 | } |
| 1464 | 1463 | else { |
@@ -1472,7 +1471,7 @@ discard block |
||
| 1472 | 1471 | return $themefiles["$subdir$file"] = $f; |
| 1473 | 1472 | } |
| 1474 | 1473 | } |
| 1475 | - spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); |
|
| 1474 | + spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); |
|
| 1476 | 1475 | |
| 1477 | 1476 | return $themefiles["$subdir$file"] = ""; |
| 1478 | 1477 | } |
@@ -1500,7 +1499,7 @@ discard block |
||
| 1500 | 1499 | function chemin_image($icone) { |
| 1501 | 1500 | static $icone_renommer; |
| 1502 | 1501 | if ($p = strpos($icone, '?')) { |
| 1503 | - $icone = substr($icone,0, $p); |
|
| 1502 | + $icone = substr($icone, 0, $p); |
|
| 1504 | 1503 | } |
| 1505 | 1504 | // gerer le cas d'un double appel en evitant de refaire le travail inutilement |
| 1506 | 1505 | if (strpos($icone, "/") !== false and file_exists($icone)) { |
@@ -1580,8 +1579,8 @@ discard block |
||
| 1580 | 1579 | return false; |
| 1581 | 1580 | } |
| 1582 | 1581 | if ($include and !isset($inc[$dirname][$file])) { |
| 1583 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1584 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1582 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
|
| 1583 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1585 | 1584 | } |
| 1586 | 1585 | |
| 1587 | 1586 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]; |
@@ -1594,14 +1593,14 @@ discard block |
||
| 1594 | 1593 | } |
| 1595 | 1594 | |
| 1596 | 1595 | foreach (creer_chemin() as $dir) { |
| 1597 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 1598 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a); |
|
| 1596 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 1597 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a); |
|
| 1599 | 1598 | } |
| 1600 | 1599 | if ($dirs[$a]) { |
| 1601 | - if (file_exists(_ROOT_CWD . ($a .= $file))) { |
|
| 1600 | + if (file_exists(_ROOT_CWD.($a .= $file))) { |
|
| 1602 | 1601 | if ($include and !isset($inc[$dirname][$file])) { |
| 1603 | - include_once _ROOT_CWD . $a; |
|
| 1604 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true; |
|
| 1602 | + include_once _ROOT_CWD.$a; |
|
| 1603 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true; |
|
| 1605 | 1604 | } |
| 1606 | 1605 | if (!defined('_SAUVER_CHEMIN')) { |
| 1607 | 1606 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher |
@@ -1611,7 +1610,7 @@ discard block |
||
| 1611 | 1610 | define('_SAUVER_CHEMIN', true); |
| 1612 | 1611 | } |
| 1613 | 1612 | |
| 1614 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a; |
|
| 1613 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a; |
|
| 1615 | 1614 | } |
| 1616 | 1615 | } |
| 1617 | 1616 | } |
@@ -1637,7 +1636,7 @@ discard block |
||
| 1637 | 1636 | define('_SAUVER_CHEMIN', true); |
| 1638 | 1637 | } |
| 1639 | 1638 | |
| 1640 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false; |
|
| 1639 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false; |
|
| 1641 | 1640 | } |
| 1642 | 1641 | |
| 1643 | 1642 | function clear_path_cache() { |
@@ -1706,12 +1705,12 @@ discard block |
||
| 1706 | 1705 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue |
| 1707 | 1706 | // on a pas encore inclus flock.php |
| 1708 | 1707 | if (!function_exists('preg_files')) { |
| 1709 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 1708 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 1710 | 1709 | } |
| 1711 | 1710 | |
| 1712 | 1711 | // Parcourir le chemin |
| 1713 | 1712 | foreach (creer_chemin() as $d) { |
| 1714 | - $f = $d . $dir; |
|
| 1713 | + $f = $d.$dir; |
|
| 1715 | 1714 | if (@is_dir($f)) { |
| 1716 | 1715 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs); |
| 1717 | 1716 | foreach ($liste as $chemin) { |
@@ -1741,9 +1740,9 @@ discard block |
||
| 1741 | 1740 | static $autsanscookie = array('install', 'base_repair'); |
| 1742 | 1741 | |
| 1743 | 1742 | if (in_array($nom, $autsanscookie)) { |
| 1744 | - if (test_espace_prive()){ |
|
| 1743 | + if (test_espace_prive()) { |
|
| 1745 | 1744 | include_spip('base/connect_sql'); |
| 1746 | - if (!$strict or !spip_connect()){ |
|
| 1745 | + if (!$strict or !spip_connect()) { |
|
| 1747 | 1746 | return true; |
| 1748 | 1747 | } |
| 1749 | 1748 | } |
@@ -1822,7 +1821,7 @@ discard block |
||
| 1822 | 1821 | return $res; |
| 1823 | 1822 | } |
| 1824 | 1823 | // Sinon c'est un raccourci ou compat SPIP < 2 |
| 1825 | - if (!function_exists($f = 'generer_url_' . $entite)) { |
|
| 1824 | + if (!function_exists($f = 'generer_url_'.$entite)) { |
|
| 1826 | 1825 | if (!function_exists($f .= '_dist')) { |
| 1827 | 1826 | $f = ''; |
| 1828 | 1827 | } |
@@ -1831,8 +1830,8 @@ discard block |
||
| 1831 | 1830 | $url = $f($id, $args, $ancre); |
| 1832 | 1831 | if (strlen($args)) { |
| 1833 | 1832 | $url .= strstr($url, '?') |
| 1834 | - ? '&' . $args |
|
| 1835 | - : '?' . $args; |
|
| 1833 | + ? '&'.$args |
|
| 1834 | + : '?'.$args; |
|
| 1836 | 1835 | } |
| 1837 | 1836 | |
| 1838 | 1837 | return $url; |
@@ -1863,8 +1862,8 @@ discard block |
||
| 1863 | 1862 | include_spip('base/connect_sql'); |
| 1864 | 1863 | $id_type = id_table_objet($entite, $public); |
| 1865 | 1864 | |
| 1866 | - return _DIR_RACINE . get_spip_script('./') |
|
| 1867 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public" |
|
| 1865 | + return _DIR_RACINE.get_spip_script('./') |
|
| 1866 | + . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public" |
|
| 1868 | 1867 | . (!$args ? '' : "&$args") |
| 1869 | 1868 | . (!$ancre ? '' : "#$ancre"); |
| 1870 | 1869 | } |
@@ -2016,7 +2015,7 @@ discard block |
||
| 2016 | 2015 | if (!empty($_SERVER['QUERY_STRING']) |
| 2017 | 2016 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2018 | 2017 | ) { |
| 2019 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2018 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2020 | 2019 | } |
| 2021 | 2020 | } |
| 2022 | 2021 | } |
@@ -2043,17 +2042,17 @@ discard block |
||
| 2043 | 2042 | list($myself) = explode('?', $myself); |
| 2044 | 2043 | // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte |
| 2045 | 2044 | // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"] |
| 2046 | - if (strpos($myself,'://') !== false) { |
|
| 2047 | - $myself = explode('://',$myself); |
|
| 2045 | + if (strpos($myself, '://') !== false) { |
|
| 2046 | + $myself = explode('://', $myself); |
|
| 2048 | 2047 | array_shift($myself); |
| 2049 | - $myself = implode('://',$myself); |
|
| 2050 | - $myself = explode('/',$myself); |
|
| 2048 | + $myself = implode('://', $myself); |
|
| 2049 | + $myself = explode('/', $myself); |
|
| 2051 | 2050 | array_shift($myself); |
| 2052 | - $myself = implode('/',$myself); |
|
| 2051 | + $myself = implode('/', $myself); |
|
| 2053 | 2052 | } |
| 2054 | - $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; |
|
| 2053 | + $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; |
|
| 2055 | 2054 | |
| 2056 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/'); |
|
| 2055 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/'); |
|
| 2057 | 2056 | |
| 2058 | 2057 | return $url; |
| 2059 | 2058 | } |
@@ -2091,17 +2090,17 @@ discard block |
||
| 2091 | 2090 | **/ |
| 2092 | 2091 | function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { |
| 2093 | 2092 | if (!$rel) { |
| 2094 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT; |
|
| 2093 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT; |
|
| 2095 | 2094 | } else { |
| 2096 | 2095 | if (!is_string($rel)) { |
| 2097 | 2096 | $rel = _DIR_RESTREINT ? _DIR_RESTREINT : |
| 2098 | - ('./' . _SPIP_ECRIRE_SCRIPT); |
|
| 2097 | + ('./'._SPIP_ECRIRE_SCRIPT); |
|
| 2099 | 2098 | } |
| 2100 | 2099 | } |
| 2101 | 2100 | |
| 2102 | 2101 | list($script, $ancre) = array_pad(explode('#', $script), 2, null); |
| 2103 | 2102 | if ($script and ($script <> 'accueil' or $rel)) { |
| 2104 | - $args = "?exec=$script" . (!$args ? '' : "&$args"); |
|
| 2103 | + $args = "?exec=$script".(!$args ? '' : "&$args"); |
|
| 2105 | 2104 | } elseif ($args) { |
| 2106 | 2105 | $args = "?$args"; |
| 2107 | 2106 | } |
@@ -2109,7 +2108,7 @@ discard block |
||
| 2109 | 2108 | $args .= "#$ancre"; |
| 2110 | 2109 | } |
| 2111 | 2110 | |
| 2112 | - return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2111 | + return $rel.($no_entities ? $args : str_replace('&', '&', $args)); |
|
| 2113 | 2112 | } |
| 2114 | 2113 | |
| 2115 | 2114 | // |
@@ -2179,25 +2178,25 @@ discard block |
||
| 2179 | 2178 | if (is_array($args)) { |
| 2180 | 2179 | $r = ''; |
| 2181 | 2180 | foreach ($args as $k => $v) { |
| 2182 | - $r .= '&' . $k . '=' . $v; |
|
| 2181 | + $r .= '&'.$k.'='.$v; |
|
| 2183 | 2182 | } |
| 2184 | 2183 | $args = substr($r, 1); |
| 2185 | 2184 | } |
| 2186 | 2185 | $action .= |
| 2187 | - (strpos($action, '?') !== false ? '&' : '?') . $args; |
|
| 2186 | + (strpos($action, '?') !== false ? '&' : '?').$args; |
|
| 2188 | 2187 | } |
| 2189 | 2188 | if (!$no_entities) { |
| 2190 | 2189 | $action = quote_amp($action); |
| 2191 | 2190 | } |
| 2192 | 2191 | |
| 2193 | 2192 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide |
| 2194 | - return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2193 | + return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action")); |
|
| 2195 | 2194 | } |
| 2196 | 2195 | |
| 2197 | 2196 | // https://code.spip.net/@generer_url_prive |
| 2198 | 2197 | function generer_url_prive($script, $args = "", $no_entities = false) { |
| 2199 | 2198 | |
| 2200 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php'); |
|
| 2199 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php'); |
|
| 2201 | 2200 | } |
| 2202 | 2201 | |
| 2203 | 2202 | // Pour les formulaires en methode POST, |
@@ -2232,8 +2231,7 @@ discard block |
||
| 2232 | 2231 | . "><div>\n" |
| 2233 | 2232 | . "<input type='hidden' name='exec' value='$script1' />" |
| 2234 | 2233 | . $corps |
| 2235 | - . (!$submit ? '' : |
|
| 2236 | - ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo submit btn' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) |
|
| 2234 | + . (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo submit btn' type='submit' value=\"".entites_html($submit)."\" /></div>")) |
|
| 2237 | 2235 | . "</div></form>\n"; |
| 2238 | 2236 | } |
| 2239 | 2237 | |
@@ -2258,14 +2256,14 @@ discard block |
||
| 2258 | 2256 | ? generer_url_ecrire(_request('exec')) |
| 2259 | 2257 | : generer_url_public(); |
| 2260 | 2258 | |
| 2261 | - return "\n<form action='" . |
|
| 2262 | - $h . |
|
| 2263 | - "'" . |
|
| 2264 | - $atts . |
|
| 2265 | - ">\n" . |
|
| 2266 | - "<div>" . |
|
| 2267 | - "\n<input type='hidden' name='action' value='$script' />" . |
|
| 2268 | - $corps . |
|
| 2259 | + return "\n<form action='". |
|
| 2260 | + $h. |
|
| 2261 | + "'". |
|
| 2262 | + $atts. |
|
| 2263 | + ">\n". |
|
| 2264 | + "<div>". |
|
| 2265 | + "\n<input type='hidden' name='action' value='$script' />". |
|
| 2266 | + $corps. |
|
| 2269 | 2267 | "</div></form>"; |
| 2270 | 2268 | } |
| 2271 | 2269 | |
@@ -2293,7 +2291,7 @@ discard block |
||
| 2293 | 2291 | : generer_url_public('', '', false, false); |
| 2294 | 2292 | $url = parametre_url($url, 'action', $script); |
| 2295 | 2293 | if ($args) { |
| 2296 | - $url .= quote_amp('&' . $args); |
|
| 2294 | + $url .= quote_amp('&'.$args); |
|
| 2297 | 2295 | } |
| 2298 | 2296 | |
| 2299 | 2297 | if ($no_entities) { |
@@ -2343,17 +2341,17 @@ discard block |
||
| 2343 | 2341 | |
| 2344 | 2342 | // le nom du repertoire plugins/ activables/desactivables |
| 2345 | 2343 | if (!defined('_DIR_PLUGINS')) { |
| 2346 | - define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); |
|
| 2344 | + define('_DIR_PLUGINS', _DIR_RACINE."plugins/"); |
|
| 2347 | 2345 | } |
| 2348 | 2346 | |
| 2349 | 2347 | // le nom du repertoire des extensions/ permanentes du core, toujours actives |
| 2350 | 2348 | if (!defined('_DIR_PLUGINS_DIST')) { |
| 2351 | - define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); |
|
| 2349 | + define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/"); |
|
| 2352 | 2350 | } |
| 2353 | 2351 | |
| 2354 | 2352 | // le nom du repertoire des librairies |
| 2355 | 2353 | if (!defined('_DIR_LIB')) { |
| 2356 | - define('_DIR_LIB', _DIR_RACINE . "lib/"); |
|
| 2354 | + define('_DIR_LIB', _DIR_RACINE."lib/"); |
|
| 2357 | 2355 | } |
| 2358 | 2356 | |
| 2359 | 2357 | if (!defined('_DIR_IMG')) { |
@@ -2363,29 +2361,29 @@ discard block |
||
| 2363 | 2361 | define('_DIR_LOGOS', $pa); |
| 2364 | 2362 | } |
| 2365 | 2363 | if (!defined('_DIR_IMG_ICONES')) { |
| 2366 | - define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); |
|
| 2364 | + define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/"); |
|
| 2367 | 2365 | } |
| 2368 | 2366 | |
| 2369 | 2367 | if (!defined('_DIR_DUMP')) { |
| 2370 | - define('_DIR_DUMP', $ti . "dump/"); |
|
| 2368 | + define('_DIR_DUMP', $ti."dump/"); |
|
| 2371 | 2369 | } |
| 2372 | 2370 | if (!defined('_DIR_SESSIONS')) { |
| 2373 | - define('_DIR_SESSIONS', $ti . "sessions/"); |
|
| 2371 | + define('_DIR_SESSIONS', $ti."sessions/"); |
|
| 2374 | 2372 | } |
| 2375 | 2373 | if (!defined('_DIR_TRANSFERT')) { |
| 2376 | - define('_DIR_TRANSFERT', $ti . "upload/"); |
|
| 2374 | + define('_DIR_TRANSFERT', $ti."upload/"); |
|
| 2377 | 2375 | } |
| 2378 | 2376 | if (!defined('_DIR_CACHE')) { |
| 2379 | - define('_DIR_CACHE', $ti . "cache/"); |
|
| 2377 | + define('_DIR_CACHE', $ti."cache/"); |
|
| 2380 | 2378 | } |
| 2381 | 2379 | if (!defined('_DIR_CACHE_XML')) { |
| 2382 | - define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); |
|
| 2380 | + define('_DIR_CACHE_XML', _DIR_CACHE."xml/"); |
|
| 2383 | 2381 | } |
| 2384 | 2382 | if (!defined('_DIR_SKELS')) { |
| 2385 | - define('_DIR_SKELS', _DIR_CACHE . "skel/"); |
|
| 2383 | + define('_DIR_SKELS', _DIR_CACHE."skel/"); |
|
| 2386 | 2384 | } |
| 2387 | 2385 | if (!defined('_DIR_AIDE')) { |
| 2388 | - define('_DIR_AIDE', _DIR_CACHE . "aide/"); |
|
| 2386 | + define('_DIR_AIDE', _DIR_CACHE."aide/"); |
|
| 2389 | 2387 | } |
| 2390 | 2388 | if (!defined('_DIR_TMP')) { |
| 2391 | 2389 | define('_DIR_TMP', $ti); |
@@ -2415,27 +2413,27 @@ discard block |
||
| 2415 | 2413 | // Declaration des fichiers |
| 2416 | 2414 | |
| 2417 | 2415 | if (!defined('_CACHE_PLUGINS_PATH')) { |
| 2418 | - define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); |
|
| 2416 | + define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php"); |
|
| 2419 | 2417 | } |
| 2420 | 2418 | if (!defined('_CACHE_PLUGINS_OPT')) { |
| 2421 | - define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); |
|
| 2419 | + define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php"); |
|
| 2422 | 2420 | } |
| 2423 | 2421 | if (!defined('_CACHE_PLUGINS_FCT')) { |
| 2424 | - define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); |
|
| 2422 | + define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php"); |
|
| 2425 | 2423 | } |
| 2426 | 2424 | if (!defined('_CACHE_PIPELINES')) { |
| 2427 | - define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); |
|
| 2425 | + define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); |
|
| 2428 | 2426 | } |
| 2429 | 2427 | if (!defined('_CACHE_CHEMIN')) { |
| 2430 | - define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); |
|
| 2428 | + define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); |
|
| 2431 | 2429 | } |
| 2432 | 2430 | |
| 2433 | 2431 | # attention .php obligatoire pour ecrire_fichier_securise |
| 2434 | 2432 | if (!defined('_FILE_META')) { |
| 2435 | - define('_FILE_META', $ti . 'meta_cache.php'); |
|
| 2433 | + define('_FILE_META', $ti.'meta_cache.php'); |
|
| 2436 | 2434 | } |
| 2437 | 2435 | if (!defined('_DIR_LOG')) { |
| 2438 | - define('_DIR_LOG', _DIR_TMP . 'log/'); |
|
| 2436 | + define('_DIR_LOG', _DIR_TMP.'log/'); |
|
| 2439 | 2437 | } |
| 2440 | 2438 | if (!defined('_FILE_LOG')) { |
| 2441 | 2439 | define('_FILE_LOG', 'spip'); |
@@ -2451,8 +2449,8 @@ discard block |
||
| 2451 | 2449 | } |
| 2452 | 2450 | if (!defined('_FILE_CONNECT')) { |
| 2453 | 2451 | define('_FILE_CONNECT', |
| 2454 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f |
|
| 2455 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f |
|
| 2452 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f |
|
| 2453 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f |
|
| 2456 | 2454 | : false))); |
| 2457 | 2455 | } |
| 2458 | 2456 | |
@@ -2462,7 +2460,7 @@ discard block |
||
| 2462 | 2460 | } |
| 2463 | 2461 | if (!defined('_FILE_CHMOD')) { |
| 2464 | 2462 | define('_FILE_CHMOD', |
| 2465 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f |
|
| 2463 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f |
|
| 2466 | 2464 | : false)); |
| 2467 | 2465 | } |
| 2468 | 2466 | |
@@ -2474,10 +2472,10 @@ discard block |
||
| 2474 | 2472 | define('_FILE_TMP_SUFFIX', '.tmp.php'); |
| 2475 | 2473 | } |
| 2476 | 2474 | if (!defined('_FILE_CONNECT_TMP')) { |
| 2477 | - define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); |
|
| 2475 | + define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); |
|
| 2478 | 2476 | } |
| 2479 | 2477 | if (!defined('_FILE_CHMOD_TMP')) { |
| 2480 | - define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); |
|
| 2478 | + define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); |
|
| 2481 | 2479 | } |
| 2482 | 2480 | |
| 2483 | 2481 | // Definition des droits d'acces en ecriture |
@@ -2495,13 +2493,13 @@ discard block |
||
| 2495 | 2493 | define('_DEFAULT_CHARSET', 'utf-8'); |
| 2496 | 2494 | } |
| 2497 | 2495 | if (!defined('_ROOT_PLUGINS')) { |
| 2498 | - define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); |
|
| 2496 | + define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/"); |
|
| 2499 | 2497 | } |
| 2500 | 2498 | if (!defined('_ROOT_PLUGINS_DIST')) { |
| 2501 | - define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); |
|
| 2499 | + define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/"); |
|
| 2502 | 2500 | } |
| 2503 | 2501 | if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
| 2504 | - define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2502 | + define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); |
|
| 2505 | 2503 | } |
| 2506 | 2504 | |
| 2507 | 2505 | // La taille des Log |
@@ -2538,7 +2536,7 @@ discard block |
||
| 2538 | 2536 | // (non surchargeable en l'etat ; attention si on utilise include_spip() |
| 2539 | 2537 | // pour le rendre surchargeable, on va provoquer un reecriture |
| 2540 | 2538 | // systematique du noyau ou une baisse de perfs => a etudier) |
| 2541 | - include_once _ROOT_RESTREINT . 'inc/flock.php'; |
|
| 2539 | + include_once _ROOT_RESTREINT.'inc/flock.php'; |
|
| 2542 | 2540 | |
| 2543 | 2541 | // charger tout de suite le path et son cache |
| 2544 | 2542 | load_path_cache(); |
@@ -2585,7 +2583,7 @@ discard block |
||
| 2585 | 2583 | if (!empty($_SERVER['QUERY_STRING']) |
| 2586 | 2584 | and !strpos($_SERVER['REQUEST_URI'], '?') |
| 2587 | 2585 | ) { |
| 2588 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; |
|
| 2586 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; |
|
| 2589 | 2587 | } |
| 2590 | 2588 | } |
| 2591 | 2589 | |
@@ -2621,7 +2619,7 @@ discard block |
||
| 2621 | 2619 | |
| 2622 | 2620 | if (isset($GLOBALS['meta']['adresse_site'])) { |
| 2623 | 2621 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']); |
| 2624 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/'; |
|
| 2622 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/'; |
|
| 2625 | 2623 | } else { |
| 2626 | 2624 | $uri_ref = ""; |
| 2627 | 2625 | } |
@@ -2709,7 +2707,7 @@ discard block |
||
| 2709 | 2707 | } |
| 2710 | 2708 | if (!defined('_CACHE_RUBRIQUES')) { |
| 2711 | 2709 | /** Fichier cache pour le navigateur de rubrique du bandeau */ |
| 2712 | - define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); |
|
| 2710 | + define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); |
|
| 2713 | 2711 | } |
| 2714 | 2712 | if (!defined('_CACHE_RUBRIQUES_MAX')) { |
| 2715 | 2713 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */ |
@@ -2808,7 +2806,7 @@ discard block |
||
| 2808 | 2806 | $memory *= 1024; |
| 2809 | 2807 | } |
| 2810 | 2808 | if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { |
| 2811 | - @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); |
|
| 2809 | + @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); |
|
| 2812 | 2810 | if (trim(ini_get('memory_limit')) != $m) { |
| 2813 | 2811 | if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { |
| 2814 | 2812 | define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); |
@@ -2958,7 +2956,7 @@ discard block |
||
| 2958 | 2956 | } |
| 2959 | 2957 | if (isset($GLOBALS['visiteur_session']['nom'])) { |
| 2960 | 2958 | spip_log($GLOBALS['visiteur_session']['nom'] |
| 2961 | - . " " . _VAR_MODE); |
|
| 2959 | + . " "._VAR_MODE); |
|
| 2962 | 2960 | } |
| 2963 | 2961 | } // pas autorise ? |
| 2964 | 2962 | else { |
@@ -2971,7 +2969,7 @@ discard block |
||
| 2971 | 2969 | if (strpos($self, 'page=login') === false) { |
| 2972 | 2970 | include_spip('inc/headers'); |
| 2973 | 2971 | $redirect = parametre_url(self('&', true), 'var_mode', $_GET['var_mode'], '&'); |
| 2974 | - redirige_par_entete(generer_url_public('login','url=' . rawurlencode($redirect), true)); |
|
| 2972 | + redirige_par_entete(generer_url_public('login', 'url='.rawurlencode($redirect), true)); |
|
| 2975 | 2973 | } |
| 2976 | 2974 | } |
| 2977 | 2975 | // sinon tant pis |
@@ -3015,10 +3013,10 @@ discard block |
||
| 3015 | 3013 | // mais on risque de perturber des plugins en initialisant trop tot |
| 3016 | 3014 | // certaines constantes |
| 3017 | 3015 | @spip_initialisation_core( |
| 3018 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES), |
|
| 3019 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES), |
|
| 3020 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3021 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3016 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES), |
|
| 3017 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES), |
|
| 3018 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES), |
|
| 3019 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES) |
|
| 3022 | 3020 | ); |
| 3023 | 3021 | |
| 3024 | 3022 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom |
@@ -3051,7 +3049,7 @@ discard block |
||
| 3051 | 3049 | } |
| 3052 | 3050 | |
| 3053 | 3051 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']); |
| 3054 | - if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { |
|
| 3052 | + if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { |
|
| 3055 | 3053 | |
| 3056 | 3054 | $session = charger_fonction('session', 'inc'); |
| 3057 | 3055 | if ($session()) { |
@@ -3131,7 +3129,7 @@ discard block |
||
| 3131 | 3129 | $s = pipeline('definir_session', |
| 3132 | 3130 | $GLOBALS['visiteur_session'] |
| 3133 | 3131 | ? serialize($GLOBALS['visiteur_session']) |
| 3134 | - . '_' . @$_COOKIE['spip_session'] |
|
| 3132 | + . '_'.@$_COOKIE['spip_session'] |
|
| 3135 | 3133 | : '' |
| 3136 | 3134 | ); |
| 3137 | 3135 | $session = $s ? substr(md5($s), 0, 8) : ''; |
@@ -3287,12 +3285,12 @@ discard block |
||
| 3287 | 3285 | $GLOBALS['_INC_PUBLIC']++; |
| 3288 | 3286 | |
| 3289 | 3287 | // fix #4235 |
| 3290 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3288 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null); |
|
| 3291 | 3289 | |
| 3292 | 3290 | |
| 3293 | 3291 | foreach (is_array($fond) ? $fond : array($fond) as $f) { |
| 3294 | 3292 | |
| 3295 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3293 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 |
|
| 3296 | 3294 | |
| 3297 | 3295 | $page = evaluer_fond($f, $contexte, $connect); |
| 3298 | 3296 | if ($page === '') { |
@@ -3331,7 +3329,7 @@ discard block |
||
| 3331 | 3329 | } |
| 3332 | 3330 | |
| 3333 | 3331 | // contamination de la session appelante, pour les inclusions statiques |
| 3334 | - if (isset($page['invalideurs']['session'])){ |
|
| 3332 | + if (isset($page['invalideurs']['session'])) { |
|
| 3335 | 3333 | $cache_utilise_session_appelant = $page['invalideurs']['session']; |
| 3336 | 3334 | } |
| 3337 | 3335 | } |
@@ -3377,7 +3375,7 @@ discard block |
||
| 3377 | 3375 | * @return array|string |
| 3378 | 3376 | */ |
| 3379 | 3377 | function trouver_fond($nom, $dir = '', $pathinfo = false) { |
| 3380 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : ''); |
|
| 3378 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : ''); |
|
| 3381 | 3379 | if (!$pathinfo) { |
| 3382 | 3380 | return $f; |
| 3383 | 3381 | } |
@@ -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,47 +46,47 @@ 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 | - } |
|
| 49 | + if ($recur) { |
|
| 50 | + $recur = mini_hier($sel); |
|
| 51 | + } else { |
|
| 52 | + $sel = 0; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if ($aff_racine) { |
|
| 56 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | - $idom3 = $idom . "_selection"; |
|
| 55 | + if ($aff_racine) { |
|
| 56 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | + $idom3 = $idom . "_selection"; |
|
| 58 | 58 | |
| 59 | - $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 59 | + $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | 60 | |
| 61 | - $ondbClick = strtr(str_replace("'", "’", |
|
| 62 | - str_replace('"', """, |
|
| 63 | - textebrut(_T('info_racine_site')))), |
|
| 64 | - "\n\r", " "); |
|
| 61 | + $ondbClick = strtr(str_replace("'", "’", |
|
| 62 | + str_replace('"', """, |
|
| 63 | + textebrut(_T('info_racine_site')))), |
|
| 64 | + "\n\r", " "); |
|
| 65 | 65 | |
| 66 | - $js_func = $do . '_selection_titre'; |
|
| 67 | - $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 66 | + $js_func = $do . '_selection_titre'; |
|
| 67 | + $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 68 | 68 | |
| 69 | - $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 70 | - . "<a href='#'" |
|
| 71 | - . "onclick=\"" |
|
| 72 | - . $onClick |
|
| 73 | - . "\"\nondbclick=\"" |
|
| 74 | - . $ondbClick |
|
| 75 | - . $onClick |
|
| 76 | - . "\">" |
|
| 77 | - . _T("info_racine_site") |
|
| 78 | - . "</a></div>"; |
|
| 79 | - } |
|
| 69 | + $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 70 | + . "<a href='#'" |
|
| 71 | + . "onclick=\"" |
|
| 72 | + . $onClick |
|
| 73 | + . "\"\nondbclick=\"" |
|
| 74 | + . $ondbClick |
|
| 75 | + . $onClick |
|
| 76 | + . "\">" |
|
| 77 | + . _T("info_racine_site") |
|
| 78 | + . "</a></div>"; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 81 | + $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 82 | 82 | |
| 83 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 84 | - $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 83 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 84 | + $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 85 | 85 | |
| 86 | - // url completee par la fonction JS onkeypress_rechercher |
|
| 87 | - $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 86 | + // url completee par la fonction JS onkeypress_rechercher |
|
| 87 | + $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 88 | 88 | |
| 89 | - return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 89 | + return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -104,55 +104,55 @@ discard block |
||
| 104 | 104 | **/ |
| 105 | 105 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 106 | 106 | |
| 107 | - $idom1 = $idom . "_champ_recherche"; |
|
| 108 | - $idom2 = $idom . "_principal"; |
|
| 109 | - $idom3 = $idom . "_selection"; |
|
| 110 | - $idom4 = $idom . "_col_1"; |
|
| 111 | - $idom5 = 'img_' . $idom4; |
|
| 112 | - $idom6 = $idom . "_fonc"; |
|
| 113 | - |
|
| 114 | - return "<div id='$idom'>" |
|
| 115 | - . "<a id='$idom6' style='visibility: hidden;'" |
|
| 116 | - . ($url_init ? "\nhref='$url_init'" : '') |
|
| 117 | - . "></a>" |
|
| 118 | - . "<div class='recherche_rapide_parent'>" |
|
| 119 | - . http_img_pack("loader.svg", "", |
|
| 120 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'") |
|
| 121 | - . "" |
|
| 122 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='search' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 123 | - // eliminer Return car il provoque la soumission (balise unique) |
|
| 124 | - // et eliminer Tab pour la navigation au clavier |
|
| 125 | - // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 126 | - // resultats retournes par la recherche |
|
| 127 | - . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 128 | - // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 129 | - . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 130 | - // la destination de la recherche |
|
| 131 | - . "'$idom4'" |
|
| 107 | + $idom1 = $idom . "_champ_recherche"; |
|
| 108 | + $idom2 = $idom . "_principal"; |
|
| 109 | + $idom3 = $idom . "_selection"; |
|
| 110 | + $idom4 = $idom . "_col_1"; |
|
| 111 | + $idom5 = 'img_' . $idom4; |
|
| 112 | + $idom6 = $idom . "_fonc"; |
|
| 113 | + |
|
| 114 | + return "<div id='$idom'>" |
|
| 115 | + . "<a id='$idom6' style='visibility: hidden;'" |
|
| 116 | + . ($url_init ? "\nhref='$url_init'" : '') |
|
| 117 | + . "></a>" |
|
| 118 | + . "<div class='recherche_rapide_parent'>" |
|
| 119 | + . http_img_pack("loader.svg", "", |
|
| 120 | + "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'") |
|
| 121 | + . "" |
|
| 122 | + . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='search' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 123 | + // eliminer Return car il provoque la soumission (balise unique) |
|
| 124 | + // et eliminer Tab pour la navigation au clavier |
|
| 125 | + // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 126 | + // resultats retournes par la recherche |
|
| 127 | + . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 128 | + // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 129 | + . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 130 | + // la destination de la recherche |
|
| 131 | + . "'$idom4'" |
|
| 132 | 132 | # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id" |
| 133 | - . ",'" |
|
| 134 | - // l'url effectuant la recherche |
|
| 135 | - . $url |
|
| 136 | - . "'," |
|
| 137 | - // le noeud contenant un gif anime |
|
| 138 | - // . "'idom5'" |
|
| 139 | - . "this.parentNode.previousSibling.firstChild" |
|
| 140 | - . ",'" |
|
| 141 | - // la valeur de l'attribut Name a remplir |
|
| 142 | - . $name |
|
| 143 | - . "','" |
|
| 144 | - // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 145 | - . $idom6 |
|
| 146 | - . "')\"" |
|
| 147 | - . " />" |
|
| 148 | - . "\n</div>" |
|
| 149 | - . ($racine ? "<div>$racine</div>" : "") |
|
| 150 | - . "<div id='" |
|
| 151 | - . $idom2 |
|
| 152 | - . "'><div id='$idom4'" |
|
| 153 | - . " class=''>" |
|
| 154 | - . $liste |
|
| 155 | - . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 133 | + . ",'" |
|
| 134 | + // l'url effectuant la recherche |
|
| 135 | + . $url |
|
| 136 | + . "'," |
|
| 137 | + // le noeud contenant un gif anime |
|
| 138 | + // . "'idom5'" |
|
| 139 | + . "this.parentNode.previousSibling.firstChild" |
|
| 140 | + . ",'" |
|
| 141 | + // la valeur de l'attribut Name a remplir |
|
| 142 | + . $name |
|
| 143 | + . "','" |
|
| 144 | + // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 145 | + . $idom6 |
|
| 146 | + . "')\"" |
|
| 147 | + . " />" |
|
| 148 | + . "\n</div>" |
|
| 149 | + . ($racine ? "<div>$racine</div>" : "") |
|
| 150 | + . "<div id='" |
|
| 151 | + . $idom2 |
|
| 152 | + . "'><div id='$idom4'" |
|
| 153 | + . " class=''>" |
|
| 154 | + . $liste |
|
| 155 | + . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | **/ |
| 165 | 165 | function mini_hier($id_rubrique) { |
| 166 | 166 | |
| 167 | - $liste = $id_rubrique; |
|
| 168 | - $id_rubrique = intval($id_rubrique); |
|
| 169 | - while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) { |
|
| 170 | - $liste = $id_rubrique . ",$liste"; |
|
| 171 | - } |
|
| 167 | + $liste = $id_rubrique; |
|
| 168 | + $id_rubrique = intval($id_rubrique); |
|
| 169 | + while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) { |
|
| 170 | + $liste = $id_rubrique . ",$liste"; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - return explode(',', "0,$liste"); |
|
| 173 | + return explode(',', "0,$liste"); |
|
| 174 | 174 | } |
@@ -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 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | textebrut(_T('info_racine_site')))), |
| 64 | 64 | "\n\r", " "); |
| 65 | 65 | |
| 66 | - $js_func = $do . '_selection_titre'; |
|
| 66 | + $js_func = $do.'_selection_titre'; |
|
| 67 | 67 | $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
| 68 | 68 | |
| 69 | 69 | $aff_racine = "<div class='petit-item petite-racine item'>" |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | **/ |
| 105 | 105 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 106 | 106 | |
| 107 | - $idom1 = $idom . "_champ_recherche"; |
|
| 108 | - $idom2 = $idom . "_principal"; |
|
| 109 | - $idom3 = $idom . "_selection"; |
|
| 110 | - $idom4 = $idom . "_col_1"; |
|
| 111 | - $idom5 = 'img_' . $idom4; |
|
| 112 | - $idom6 = $idom . "_fonc"; |
|
| 107 | + $idom1 = $idom."_champ_recherche"; |
|
| 108 | + $idom2 = $idom."_principal"; |
|
| 109 | + $idom3 = $idom."_selection"; |
|
| 110 | + $idom4 = $idom."_col_1"; |
|
| 111 | + $idom5 = 'img_'.$idom4; |
|
| 112 | + $idom6 = $idom."_fonc"; |
|
| 113 | 113 | |
| 114 | 114 | return "<div id='$idom'>" |
| 115 | 115 | . "<a id='$idom6' style='visibility: hidden;'" |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | . "></a>" |
| 118 | 118 | . "<div class='recherche_rapide_parent'>" |
| 119 | 119 | . http_img_pack("loader.svg", "", |
| 120 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'") |
|
| 120 | + "class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'") |
|
| 121 | 121 | . "" |
| 122 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='search' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 122 | + . "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='search' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'" |
|
| 123 | 123 | // eliminer Return car il provoque la soumission (balise unique) |
| 124 | 124 | // et eliminer Tab pour la navigation au clavier |
| 125 | 125 | // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $liste = $id_rubrique; |
| 168 | 168 | $id_rubrique = intval($id_rubrique); |
| 169 | - while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) { |
|
| 170 | - $liste = $id_rubrique . ",$liste"; |
|
| 169 | + while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = ".$id_rubrique)) { |
|
| 170 | + $liste = $id_rubrique.",$liste"; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return explode(',', "0,$liste"); |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_SPIP_SELECT_RUBRIQUES')) { |
| 25 | - /** |
|
| 26 | - * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | - * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | - * mettre 100000 pour desactiver ajax |
|
| 29 | - */ |
|
| 30 | - define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 25 | + /** |
|
| 26 | + * @var int Nombre de rubriques maximum du sélecteur de rubriques. |
|
| 27 | + * Au delà, on bascule sur un sélecteur ajax. |
|
| 28 | + * mettre 100000 pour desactiver ajax |
|
| 29 | + */ |
|
| 30 | + define('_SPIP_SELECT_RUBRIQUES', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -55,21 +55,21 @@ discard block |
||
| 55 | 55 | * Code HTML du sélecteur |
| 56 | 56 | **/ |
| 57 | 57 | function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 58 | - if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Mode sans Ajax : |
|
| 63 | - // - soit parce que le cookie ajax n'est pas la |
|
| 64 | - // - soit parce qu'il y a peu de rubriques |
|
| 65 | - if (_SPIP_AJAX < 1 |
|
| 66 | - or $type == 'breve' |
|
| 67 | - or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 68 | - ) { |
|
| 69 | - return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 70 | - } else { |
|
| 71 | - return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 72 | - } |
|
| 58 | + if (sql_countsel('spip_rubriques') < 1) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Mode sans Ajax : |
|
| 63 | + // - soit parce que le cookie ajax n'est pas la |
|
| 64 | + // - soit parce qu'il y a peu de rubriques |
|
| 65 | + if (_SPIP_AJAX < 1 |
|
| 66 | + or $type == 'breve' |
|
| 67 | + or sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES |
|
| 68 | + ) { |
|
| 69 | + return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem); |
|
| 70 | + } else { |
|
| 71 | + return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
@@ -87,17 +87,17 @@ discard block |
||
| 87 | 87 | **/ |
| 88 | 88 | function style_menu_rubriques($i) { |
| 89 | 89 | |
| 90 | - $espace = ''; |
|
| 91 | - $style = ''; |
|
| 92 | - for ($count = 1; $count <= $i; $count++) { |
|
| 93 | - $espace .= " "; |
|
| 94 | - } |
|
| 95 | - if ($i == 1) { |
|
| 96 | - $espace = ""; |
|
| 97 | - } |
|
| 98 | - $class = "niveau_$i"; |
|
| 99 | - |
|
| 100 | - return array($class, $style, $espace); |
|
| 90 | + $espace = ''; |
|
| 91 | + $style = ''; |
|
| 92 | + for ($count = 1; $count <= $i; $count++) { |
|
| 93 | + $espace .= " "; |
|
| 94 | + } |
|
| 95 | + if ($i == 1) { |
|
| 96 | + $espace = ""; |
|
| 97 | + } |
|
| 98 | + $class = "niveau_$i"; |
|
| 99 | + |
|
| 100 | + return array($class, $style, $espace); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -121,52 +121,52 @@ discard block |
||
| 121 | 121 | * Code HTML du sélecteur |
| 122 | 122 | **/ |
| 123 | 123 | function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) { |
| 124 | - static $decalage_secteur; |
|
| 125 | - |
|
| 126 | - // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | - if ($exclus > 0 |
|
| 128 | - and $root == $exclus |
|
| 129 | - ) { |
|
| 130 | - return ''; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 134 | - |
|
| 135 | - // selected ? |
|
| 136 | - $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 137 | - |
|
| 138 | - // le style en fonction de la profondeur |
|
| 139 | - list($class, $style, $espace) = style_menu_rubriques($niv); |
|
| 140 | - |
|
| 141 | - $class .= " selec_rub"; |
|
| 142 | - |
|
| 143 | - // creer l'<option> pour la rubrique $root |
|
| 144 | - |
|
| 145 | - if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 146 | - { |
|
| 147 | - $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | - . $data[$root] |
|
| 149 | - . '</option>' . "\n"; |
|
| 150 | - } else { |
|
| 151 | - $r = ''; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // et le sous-menu pour ses enfants |
|
| 155 | - $sous = ''; |
|
| 156 | - if (isset($enfants[$root])) { |
|
| 157 | - foreach ($enfants[$root] as $sousrub) { |
|
| 158 | - $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
|
| 159 | - $niv + 1, $data, $enfants, $exclus, $restreint, $type); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 164 | - if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 165 | - return $sous; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // et voila le travail |
|
| 169 | - return $r . $sous; |
|
| 124 | + static $decalage_secteur; |
|
| 125 | + |
|
| 126 | + // Si on a demande l'exclusion ne pas descendre dans la rubrique courante |
|
| 127 | + if ($exclus > 0 |
|
| 128 | + and $root == $exclus |
|
| 129 | + ) { |
|
| 130 | + return ''; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + // en fonction du niveau faire un affichage plus ou moins kikoo |
|
| 134 | + |
|
| 135 | + // selected ? |
|
| 136 | + $selected = ($root == $id_rubrique) ? ' selected="selected"' : ''; |
|
| 137 | + |
|
| 138 | + // le style en fonction de la profondeur |
|
| 139 | + list($class, $style, $espace) = style_menu_rubriques($niv); |
|
| 140 | + |
|
| 141 | + $class .= " selec_rub"; |
|
| 142 | + |
|
| 143 | + // creer l'<option> pour la rubrique $root |
|
| 144 | + |
|
| 145 | + if (isset($data[$root])) # pas de racine sauf pour les rubriques |
|
| 146 | + { |
|
| 147 | + $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
|
| 148 | + . $data[$root] |
|
| 149 | + . '</option>' . "\n"; |
|
| 150 | + } else { |
|
| 151 | + $r = ''; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // et le sous-menu pour ses enfants |
|
| 155 | + $sous = ''; |
|
| 156 | + if (isset($enfants[$root])) { |
|
| 157 | + foreach ($enfants[$root] as $sousrub) { |
|
| 158 | + $sous .= sous_menu_rubriques($id_rubrique, $sousrub, |
|
| 159 | + $niv + 1, $data, $enfants, $exclus, $restreint, $type); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques |
|
| 164 | + if ($restreint and $root != $id_rubrique and !autoriser('publierdans', 'rubrique', $root)) { |
|
| 165 | + return $sous; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // et voila le travail |
|
| 169 | + return $r . $sous; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -187,67 +187,67 @@ discard block |
||
| 187 | 187 | * Code HTML du sélecteur |
| 188 | 188 | **/ |
| 189 | 189 | function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) { |
| 190 | - $data = array(); |
|
| 191 | - if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 192 | - $data[0] = _T('info_racine_site'); |
|
| 193 | - } |
|
| 194 | - # premier choix = neant |
|
| 195 | - # si auteur (rubriques restreintes) |
|
| 196 | - # ou si creation avec id_rubrique=0 |
|
| 197 | - elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 198 | - $data[0] = ' '; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // |
|
| 202 | - // creer une structure contenant toute l'arborescence |
|
| 203 | - // |
|
| 204 | - |
|
| 205 | - include_spip('base/abstract_sql'); |
|
| 206 | - $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", |
|
| 207 | - ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 208 | - while ($r = sql_fetch($q)) { |
|
| 209 | - if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 210 | - // titre largeur maxi a 50 |
|
| 211 | - $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50); |
|
| 212 | - if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 213 | - and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0) |
|
| 214 | - ) { |
|
| 215 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 216 | - } |
|
| 217 | - $data[$r['id_rubrique']] = $titre; |
|
| 218 | - $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 219 | - if ($id_rubrique == $r['id_rubrique']) { |
|
| 220 | - $id_parent = $r['id_parent']; |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // si une seule rubrique comme choix possible, |
|
| 226 | - // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 227 | - // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 228 | - if (count($data) == 2 |
|
| 229 | - and isset($data[0]) |
|
| 230 | - and !in_array($type, array('auteur', 'rubrique')) |
|
| 231 | - and !$id_rubrique |
|
| 232 | - ) { |
|
| 233 | - unset($data[0]); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 238 | - $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 239 | - |
|
| 240 | - if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 241 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 242 | - } else { |
|
| 243 | - $r = "<select" . $att . " size='1'>\n$opt</select>\n"; |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - # message pour neuneus (a supprimer ?) |
|
| 190 | + $data = array(); |
|
| 191 | + if ($type == 'rubrique' and autoriser('publierdans', 'rubrique', 0)) { |
|
| 192 | + $data[0] = _T('info_racine_site'); |
|
| 193 | + } |
|
| 194 | + # premier choix = neant |
|
| 195 | + # si auteur (rubriques restreintes) |
|
| 196 | + # ou si creation avec id_rubrique=0 |
|
| 197 | + elseif ($type == 'auteur' or !$id_rubrique) { |
|
| 198 | + $data[0] = ' '; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // |
|
| 202 | + // creer une structure contenant toute l'arborescence |
|
| 203 | + // |
|
| 204 | + |
|
| 205 | + include_spip('base/abstract_sql'); |
|
| 206 | + $q = sql_select("id_rubrique, id_parent, titre, statut, lang, langue_choisie", "spip_rubriques", |
|
| 207 | + ($type == 'breve' ? ' id_parent=0 ' : ''), '', "0+titre,titre"); |
|
| 208 | + while ($r = sql_fetch($q)) { |
|
| 209 | + if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
|
| 210 | + // titre largeur maxi a 50 |
|
| 211 | + $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50); |
|
| 212 | + if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 213 | + and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0) |
|
| 214 | + ) { |
|
| 215 | + $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 216 | + } |
|
| 217 | + $data[$r['id_rubrique']] = $titre; |
|
| 218 | + $enfants[$r['id_parent']][] = $r['id_rubrique']; |
|
| 219 | + if ($id_rubrique == $r['id_rubrique']) { |
|
| 220 | + $id_parent = $r['id_parent']; |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // si une seule rubrique comme choix possible, |
|
| 226 | + // inutile de mettre le selecteur sur un choix vide par defaut |
|
| 227 | + // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas |
|
| 228 | + if (count($data) == 2 |
|
| 229 | + and isset($data[0]) |
|
| 230 | + and !in_array($type, array('auteur', 'rubrique')) |
|
| 231 | + and !$id_rubrique |
|
| 232 | + ) { |
|
| 233 | + unset($data[0]); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type); |
|
| 238 | + $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
|
| 239 | + |
|
| 240 | + if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
|
| 241 | + $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 242 | + } else { |
|
| 243 | + $r = "<select" . $att . " size='1'>\n$opt</select>\n"; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + # message pour neuneus (a supprimer ?) |
|
| 247 | 247 | # if ($type != 'auteur' AND $type != 'breve') |
| 248 | 248 | # $r .= "\n<br />"._T('texte_rappel_selection_champs'); |
| 249 | 249 | |
| 250 | - return $r; |
|
| 250 | + return $r; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -281,26 +281,26 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 283 | 283 | |
| 284 | - if ($id_rubrique) { |
|
| 285 | - $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
| 286 | - } else { |
|
| 287 | - if ($type == 'auteur') { |
|
| 288 | - $titre = ' '; |
|
| 289 | - } else { |
|
| 290 | - $titre = _T('info_racine_site'); |
|
| 291 | - } |
|
| 292 | - } |
|
| 284 | + if ($id_rubrique) { |
|
| 285 | + $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
| 286 | + } else { |
|
| 287 | + if ($type == 'auteur') { |
|
| 288 | + $titre = ' '; |
|
| 289 | + } else { |
|
| 290 | + $titre = _T('info_racine_site'); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 295 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 294 | + $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
|
| 295 | + $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 296 | 296 | |
| 297 | - $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 298 | - . (!$idem ? '' : "&exclus=$idem") |
|
| 299 | - . ($restreint ? "" : "&racine=oui") |
|
| 300 | - . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 297 | + $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
|
| 298 | + . (!$idem ? '' : "&exclus=$idem") |
|
| 299 | + . ($restreint ? "" : "&racine=oui") |
|
| 300 | + . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : '')); |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 303 | + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -330,30 +330,30 @@ discard block |
||
| 330 | 330 | * Code HTML du sélecteur de rubrique AJAX |
| 331 | 331 | **/ |
| 332 | 332 | function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) { |
| 333 | - $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 334 | - // si icone de recherche on embed le svg |
|
| 335 | - $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 336 | - $img_icone = $balise(chemin_image($icone, _T('titre_image_selecteur'))); |
|
| 337 | - |
|
| 338 | - return |
|
| 339 | - "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 340 | - . $js |
|
| 341 | - . " jQuery(this).toggleClass('toggled'); " |
|
| 342 | - . "return charger_node_url_si_vide('" |
|
| 343 | - . $url |
|
| 344 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 345 | - . $img_icone |
|
| 346 | - . "</a><img src='" |
|
| 347 | - . chemin_image('loader.svg') |
|
| 348 | - . "' class='loader' id='img_" |
|
| 349 | - . $idom |
|
| 350 | - . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 351 | - . "<input id='titreparent' name='titreparent' class='text'" |
|
| 352 | - . $init |
|
| 353 | - . " />" |
|
| 354 | - . "<input type='hidden' id='$name' name='$name' value='" |
|
| 355 | - . $id |
|
| 356 | - . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 357 | - . $idom |
|
| 358 | - . "'\nstyle='display: none;'></div>"; |
|
| 333 | + $icone = (strpos($idom, 'auteur') !== false) ? 'auteur-24.png' : 'rechercher-20.png'; |
|
| 334 | + // si icone de recherche on embed le svg |
|
| 335 | + $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img')); |
|
| 336 | + $img_icone = $balise(chemin_image($icone, _T('titre_image_selecteur'))); |
|
| 337 | + |
|
| 338 | + return |
|
| 339 | + "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\"" |
|
| 340 | + . $js |
|
| 341 | + . " jQuery(this).toggleClass('toggled'); " |
|
| 342 | + . "return charger_node_url_si_vide('" |
|
| 343 | + . $url |
|
| 344 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 345 | + . $img_icone |
|
| 346 | + . "</a><img src='" |
|
| 347 | + . chemin_image('loader.svg') |
|
| 348 | + . "' class='loader' id='img_" |
|
| 349 | + . $idom |
|
| 350 | + . "'\nstyle='visibility: hidden;' alt='*' />" |
|
| 351 | + . "<input id='titreparent' name='titreparent' class='text'" |
|
| 352 | + . $init |
|
| 353 | + . " />" |
|
| 354 | + . "<input type='hidden' id='$name' name='$name' value='" |
|
| 355 | + . $id |
|
| 356 | + . "' /><div class='nettoyeur'></div></div><div id='" |
|
| 357 | + . $idom |
|
| 358 | + . "'\nstyle='display: none;'></div>"; |
|
| 359 | 359 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $r = "<option$selected value='$root' class='$class' style='$style'>$espace" |
| 148 | 148 | . $data[$root] |
| 149 | - . '</option>' . "\n"; |
|
| 149 | + . '</option>'."\n"; |
|
| 150 | 150 | } else { |
| 151 | 151 | $r = ''; |
| 152 | 152 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // et voila le travail |
| 169 | - return $r . $sous; |
|
| 169 | + return $r.$sous; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -208,11 +208,11 @@ discard block |
||
| 208 | 208 | while ($r = sql_fetch($q)) { |
| 209 | 209 | if (autoriser('voir', 'rubrique', $r['id_rubrique'])) { |
| 210 | 210 | // titre largeur maxi a 50 |
| 211 | - $titre = couper(supprimer_tags(typo($r['titre'])) . " ", 50); |
|
| 211 | + $titre = couper(supprimer_tags(typo($r['titre']))." ", 50); |
|
| 212 | 212 | if ($GLOBALS['meta']['multi_rubriques'] == 'oui' |
| 213 | 213 | and ($r['langue_choisie'] == "oui" or $r['id_parent'] == 0) |
| 214 | 214 | ) { |
| 215 | - $titre .= ' [' . traduire_nom_langue($r['lang']) . ']'; |
|
| 215 | + $titre .= ' ['.traduire_nom_langue($r['lang']).']'; |
|
| 216 | 216 | } |
| 217 | 217 | $data[$r['id_rubrique']] = $titre; |
| 218 | 218 | $enfants[$r['id_parent']][] = $r['id_rubrique']; |
@@ -238,9 +238,9 @@ discard block |
||
| 238 | 238 | $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'"; |
| 239 | 239 | |
| 240 | 240 | if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) { |
| 241 | - $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2]; |
|
| 241 | + $r = "<input$att type='hidden' value='".$r[1]."' />".$r[2]; |
|
| 242 | 242 | } else { |
| 243 | - $r = "<select" . $att . " size='1'>\n$opt</select>\n"; |
|
| 243 | + $r = "<select".$att." size='1'>\n$opt</select>\n"; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | # message pour neuneus (a supprimer ?) |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') { |
| 283 | 283 | |
| 284 | 284 | if ($id_rubrique) { |
| 285 | - $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=" . intval($id_rubrique)); |
|
| 285 | + $titre = sql_getfetsel("titre", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 286 | 286 | } else { |
| 287 | 287 | if ($type == 'auteur') { |
| 288 | 288 | $titre = ' '; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); |
| 295 | - $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'"; |
|
| 295 | + $init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'"; |
|
| 296 | 296 | |
| 297 | 297 | $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do" |
| 298 | 298 | . (!$idem ? '' : "&exclus=$idem") |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | . " jQuery(this).toggleClass('toggled'); " |
| 342 | 342 | . "return charger_node_url_si_vide('" |
| 343 | 343 | . $url |
| 344 | - . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>" |
|
| 344 | + . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>" |
|
| 345 | 345 | . $img_icone |
| 346 | 346 | . "</a><img src='" |
| 347 | 347 | . chemin_image('loader.svg') |