@@ -75,6 +75,9 @@ |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
| 78 | +/** |
|
| 79 | + * @param string $nom |
|
| 80 | + */ |
|
| 78 | 81 | function phraser_logo_faux_filtres($nom) { |
| 79 | 82 | switch ($nom) { |
| 80 | 83 | case 'top': |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $p->etoile = '*'; |
| 54 | 54 | spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
| 55 | 55 | |
| 56 | - } elseif (preg_match("/^" . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) { |
|
| 56 | + } elseif (preg_match("/^".NOM_DE_CHAMP.'(.*)$/sS', $nom, $m)) { |
|
| 57 | 57 | $champ = new Champ(); |
| 58 | 58 | $champ->nom_boucle = $m[2]; |
| 59 | 59 | $champ->nom_champ = $m[3]; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $p->param[0][1] = array($c); |
| 132 | 132 | $p->param[0][0] = ''; |
| 133 | 133 | $p->fonctions = array(); |
| 134 | - spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs'); |
|
| 134 | + spip_log('FORMULAIRE_RECHERCHE avec filtre '.$c->texte, 'vieilles_defs'); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -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 | // Les fonctions de ce fichier sont appelees en certains points |
@@ -25,135 +25,135 @@ discard block |
||
| 25 | 25 | // -> https://www.spip.net/fr_article901.html |
| 26 | 26 | |
| 27 | 27 | function phraser_vieux_logos(&$p) { |
| 28 | - if ($p->param[0][0]) { |
|
| 29 | - $args = array(''); |
|
| 30 | - } else { |
|
| 31 | - $args = array_shift($p->param); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - foreach ($p->param as $couple) { |
|
| 35 | - $nom = trim($couple[0]); |
|
| 36 | - if ($nom == '') { |
|
| 37 | - array_shift($p->param); |
|
| 38 | - break; |
|
| 39 | - } |
|
| 40 | - $r = phraser_logo_faux_filtres($nom); |
|
| 41 | - if ($r === 0) { |
|
| 42 | - $c = new Texte; |
|
| 43 | - $c->texte = $nom; |
|
| 44 | - $args[] = array($c); |
|
| 45 | - array_shift($p->param); |
|
| 46 | - spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 47 | - } elseif ($r === 2) { |
|
| 48 | - $p->etoile = '**'; |
|
| 49 | - array_shift($p->param); |
|
| 50 | - spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 51 | - } elseif ($r === 1) { |
|
| 52 | - array_shift($p->param); |
|
| 53 | - $p->etoile = '*'; |
|
| 54 | - spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 55 | - |
|
| 56 | - } elseif (preg_match("/^" . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) { |
|
| 57 | - $champ = new Champ(); |
|
| 58 | - $champ->nom_boucle = $m[2]; |
|
| 59 | - $champ->nom_champ = $m[3]; |
|
| 60 | - $champ->etoile = $m[5]; |
|
| 61 | - $champ = array($champ); |
|
| 62 | - if ($m[6]) { |
|
| 63 | - $r = new Texte; |
|
| 64 | - $r->texte = $m[6]; |
|
| 65 | - $champ[] = $r; |
|
| 66 | - } |
|
| 67 | - $args[] = $champ; |
|
| 68 | - array_shift($p->param); |
|
| 69 | - spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 70 | - |
|
| 71 | - } // le cas else est la seule incompatibilite |
|
| 72 | - |
|
| 73 | - } |
|
| 74 | - array_unshift($p->param, $args); |
|
| 28 | + if ($p->param[0][0]) { |
|
| 29 | + $args = array(''); |
|
| 30 | + } else { |
|
| 31 | + $args = array_shift($p->param); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + foreach ($p->param as $couple) { |
|
| 35 | + $nom = trim($couple[0]); |
|
| 36 | + if ($nom == '') { |
|
| 37 | + array_shift($p->param); |
|
| 38 | + break; |
|
| 39 | + } |
|
| 40 | + $r = phraser_logo_faux_filtres($nom); |
|
| 41 | + if ($r === 0) { |
|
| 42 | + $c = new Texte; |
|
| 43 | + $c->texte = $nom; |
|
| 44 | + $args[] = array($c); |
|
| 45 | + array_shift($p->param); |
|
| 46 | + spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 47 | + } elseif ($r === 2) { |
|
| 48 | + $p->etoile = '**'; |
|
| 49 | + array_shift($p->param); |
|
| 50 | + spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 51 | + } elseif ($r === 1) { |
|
| 52 | + array_shift($p->param); |
|
| 53 | + $p->etoile = '*'; |
|
| 54 | + spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 55 | + |
|
| 56 | + } elseif (preg_match("/^" . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) { |
|
| 57 | + $champ = new Champ(); |
|
| 58 | + $champ->nom_boucle = $m[2]; |
|
| 59 | + $champ->nom_champ = $m[3]; |
|
| 60 | + $champ->etoile = $m[5]; |
|
| 61 | + $champ = array($champ); |
|
| 62 | + if ($m[6]) { |
|
| 63 | + $r = new Texte; |
|
| 64 | + $r->texte = $m[6]; |
|
| 65 | + $champ[] = $r; |
|
| 66 | + } |
|
| 67 | + $args[] = $champ; |
|
| 68 | + array_shift($p->param); |
|
| 69 | + spip_log("filtre de logo obsolete $nom", 'vieilles_defs'); |
|
| 70 | + |
|
| 71 | + } // le cas else est la seule incompatibilite |
|
| 72 | + |
|
| 73 | + } |
|
| 74 | + array_unshift($p->param, $args); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | function phraser_logo_faux_filtres($nom) { |
| 79 | - switch ($nom) { |
|
| 80 | - case 'top': |
|
| 81 | - case 'left': |
|
| 82 | - case 'right': |
|
| 83 | - case 'center': |
|
| 84 | - case 'bottom': |
|
| 85 | - return 0; |
|
| 86 | - case 'lien': |
|
| 87 | - return 1; |
|
| 88 | - case 'fichier': |
|
| 89 | - return 2; |
|
| 90 | - default: |
|
| 91 | - return $nom; |
|
| 92 | - } |
|
| 79 | + switch ($nom) { |
|
| 80 | + case 'top': |
|
| 81 | + case 'left': |
|
| 82 | + case 'right': |
|
| 83 | + case 'center': |
|
| 84 | + case 'bottom': |
|
| 85 | + return 0; |
|
| 86 | + case 'lien': |
|
| 87 | + return 1; |
|
| 88 | + case 'fichier': |
|
| 89 | + return 2; |
|
| 90 | + default: |
|
| 91 | + return $nom; |
|
| 92 | + } |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | // La balise embed_document est a present le modele emb |
| 97 | 97 | |
| 98 | 98 | function phraser_vieux_emb(&$p) { |
| 99 | - if (!is_array($p->param)) { |
|
| 100 | - $p->param = array(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // Produire le premier argument {emb} |
|
| 104 | - $texte = new Texte; |
|
| 105 | - $texte->texte = 'emb'; |
|
| 106 | - $param = array('', array($texte)); |
|
| 107 | - |
|
| 108 | - // Transformer les filtres en arguments |
|
| 109 | - for ($i = 0; $i < count($p->param); $i++) { |
|
| 110 | - if ($p->param[$i][0]) { |
|
| 111 | - if (!strstr($p->param[$i][0], '=')) { |
|
| 112 | - break; |
|
| 113 | - }# on a rencontre un vrai filtre, c'est fini |
|
| 114 | - $texte = new Texte; |
|
| 115 | - $texte->texte = $p->param[$i][0]; |
|
| 116 | - $param[] = array($texte); |
|
| 117 | - } |
|
| 118 | - array_shift($p->param); |
|
| 119 | - } |
|
| 120 | - array_unshift($p->param, $param); |
|
| 121 | - spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs'); |
|
| 122 | - $p->nom_champ = 'MODELE'; |
|
| 99 | + if (!is_array($p->param)) { |
|
| 100 | + $p->param = array(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // Produire le premier argument {emb} |
|
| 104 | + $texte = new Texte; |
|
| 105 | + $texte->texte = 'emb'; |
|
| 106 | + $param = array('', array($texte)); |
|
| 107 | + |
|
| 108 | + // Transformer les filtres en arguments |
|
| 109 | + for ($i = 0; $i < count($p->param); $i++) { |
|
| 110 | + if ($p->param[$i][0]) { |
|
| 111 | + if (!strstr($p->param[$i][0], '=')) { |
|
| 112 | + break; |
|
| 113 | + }# on a rencontre un vrai filtre, c'est fini |
|
| 114 | + $texte = new Texte; |
|
| 115 | + $texte->texte = $p->param[$i][0]; |
|
| 116 | + $param[] = array($texte); |
|
| 117 | + } |
|
| 118 | + array_shift($p->param); |
|
| 119 | + } |
|
| 120 | + array_unshift($p->param, $param); |
|
| 121 | + spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs'); |
|
| 122 | + $p->nom_champ = 'MODELE'; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // Vieux formulaire de recherch |
| 126 | 126 | |
| 127 | 127 | function phraser_vieux_recherche($p) { |
| 128 | - if ($p->param[0][0]) { |
|
| 129 | - $c = new Texte; |
|
| 130 | - $c->texte = $p->param[0][0]; |
|
| 131 | - $p->param[0][1] = array($c); |
|
| 132 | - $p->param[0][0] = ''; |
|
| 133 | - $p->fonctions = array(); |
|
| 134 | - spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs'); |
|
| 135 | - } |
|
| 128 | + if ($p->param[0][0]) { |
|
| 129 | + $c = new Texte; |
|
| 130 | + $c->texte = $p->param[0][0]; |
|
| 131 | + $p->param[0][1] = array($c); |
|
| 132 | + $p->param[0][0] = ''; |
|
| 133 | + $p->fonctions = array(); |
|
| 134 | + spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs'); |
|
| 135 | + } |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Gerer la notation [(#EXPOSER|on,off)] |
| 139 | 139 | function phraser_vieux_exposer($p) { |
| 140 | - if ($a = $p->fonctions) { |
|
| 141 | - preg_match("#([^,]*)(,(.*))?#", $a[0][0], $regs); |
|
| 142 | - $args = array(); |
|
| 143 | - if ($regs[1]) { |
|
| 144 | - $a = new Texte; |
|
| 145 | - $a->texte = $regs[1]; |
|
| 146 | - $args = array('', array($a)); |
|
| 147 | - if ($regs[3]) { |
|
| 148 | - $a = new Texte; |
|
| 149 | - $a->texte = $regs[3]; |
|
| 150 | - $args[] = array($a); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - $p->param[0] = $args; |
|
| 154 | - $p->fonctions = array(); |
|
| 155 | - $p->nom_champ = 'EXPOSE'; |
|
| 156 | - } |
|
| 140 | + if ($a = $p->fonctions) { |
|
| 141 | + preg_match("#([^,]*)(,(.*))?#", $a[0][0], $regs); |
|
| 142 | + $args = array(); |
|
| 143 | + if ($regs[1]) { |
|
| 144 | + $a = new Texte; |
|
| 145 | + $a->texte = $regs[1]; |
|
| 146 | + $args = array('', array($a)); |
|
| 147 | + if ($regs[3]) { |
|
| 148 | + $a = new Texte; |
|
| 149 | + $a->texte = $regs[3]; |
|
| 150 | + $args[] = array($a); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + $p->param[0] = $args; |
|
| 154 | + $p->fonctions = array(); |
|
| 155 | + $p->nom_champ = 'EXPOSE'; |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | function phraser_vieux_modele($p) { normaliser_args_inclumodel($p); } |
@@ -161,55 +161,55 @@ discard block |
||
| 161 | 161 | function phraser_vieux_inclu($p) { normaliser_args_inclumodel($p); } |
| 162 | 162 | |
| 163 | 163 | function normaliser_args_inclumodel($p) { |
| 164 | - $params = $p->param; |
|
| 165 | - if (!$params) { |
|
| 166 | - return; |
|
| 167 | - } |
|
| 168 | - $args = $params[0]; |
|
| 169 | - if ($args[0]) { |
|
| 170 | - return; |
|
| 171 | - } // filtre immediat |
|
| 172 | - array_shift($p->param); |
|
| 173 | - foreach ($p->param as $l) { |
|
| 174 | - if (!array_shift($l)) { |
|
| 175 | - $args = array_merge($args, $l); |
|
| 176 | - array_shift($p->param); |
|
| 177 | - } else { |
|
| 178 | - break; |
|
| 179 | - } // filtre |
|
| 180 | - } |
|
| 181 | - array_unshift($p->param, $args); |
|
| 164 | + $params = $p->param; |
|
| 165 | + if (!$params) { |
|
| 166 | + return; |
|
| 167 | + } |
|
| 168 | + $args = $params[0]; |
|
| 169 | + if ($args[0]) { |
|
| 170 | + return; |
|
| 171 | + } // filtre immediat |
|
| 172 | + array_shift($p->param); |
|
| 173 | + foreach ($p->param as $l) { |
|
| 174 | + if (!array_shift($l)) { |
|
| 175 | + $args = array_merge($args, $l); |
|
| 176 | + array_shift($p->param); |
|
| 177 | + } else { |
|
| 178 | + break; |
|
| 179 | + } // filtre |
|
| 180 | + } |
|
| 181 | + array_unshift($p->param, $args); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | function normaliser_inclure($champ) { |
| 185 | - normaliser_args_inclumodel($champ); |
|
| 186 | - $l = $champ->param[0]; |
|
| 187 | - if (is_array($l) and !$l[0]) { |
|
| 188 | - foreach ($l as $k => $p) { |
|
| 189 | - if ($p and $p[0]->type == 'texte' and !strpos($p[0]->texte, '=')) { |
|
| 190 | - $p[0]->texte = trim($p[0]->texte); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - foreach ($l as $k => $p) { |
|
| 194 | - if (!$p or $p[0]->type != 'texte' or |
|
| 195 | - !preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r) |
|
| 196 | - ) { |
|
| 197 | - continue; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if ($r[1]) { |
|
| 201 | - $p[0]->texte = $r[1]; |
|
| 202 | - } else { |
|
| 203 | - unset($p[0]); |
|
| 204 | - } |
|
| 205 | - $champ->texte = $p; |
|
| 206 | - unset($champ->param[0][$k]); |
|
| 207 | - if (count($champ->param[0]) == 1) { |
|
| 208 | - array_shift($champ->param); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - return; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - spip_log("inclure sans fond ni fichier"); |
|
| 185 | + normaliser_args_inclumodel($champ); |
|
| 186 | + $l = $champ->param[0]; |
|
| 187 | + if (is_array($l) and !$l[0]) { |
|
| 188 | + foreach ($l as $k => $p) { |
|
| 189 | + if ($p and $p[0]->type == 'texte' and !strpos($p[0]->texte, '=')) { |
|
| 190 | + $p[0]->texte = trim($p[0]->texte); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + foreach ($l as $k => $p) { |
|
| 194 | + if (!$p or $p[0]->type != 'texte' or |
|
| 195 | + !preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r) |
|
| 196 | + ) { |
|
| 197 | + continue; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if ($r[1]) { |
|
| 201 | + $p[0]->texte = $r[1]; |
|
| 202 | + } else { |
|
| 203 | + unset($p[0]); |
|
| 204 | + } |
|
| 205 | + $champ->texte = $p; |
|
| 206 | + unset($champ->param[0][$k]); |
|
| 207 | + if (count($champ->param[0]) == 1) { |
|
| 208 | + array_shift($champ->param); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + return; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + spip_log("inclure sans fond ni fichier"); |
|
| 215 | 215 | } |
@@ -231,7 +231,7 @@ |
||
| 231 | 231 | * |
| 232 | 232 | * @uses public_tester_redirection_dist() |
| 233 | 233 | * @param string $fond |
| 234 | - * @param array $contexte |
|
| 234 | + * @param string $contexte |
|
| 235 | 235 | * @param string $connect |
| 236 | 236 | * @return array|bool |
| 237 | 237 | */ |
@@ -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_fichiers_fonctions(); |
@@ -31,177 +31,177 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | // https://code.spip.net/@public_parametrer_dist |
| 33 | 33 | function public_parametrer_dist($fond, $contexte = '', $cache = '', $connect = '') { |
| 34 | - static $composer, $styliser, $notes = null; |
|
| 35 | - $page = tester_redirection($fond, $contexte, $connect); |
|
| 36 | - if ($page) { |
|
| 37 | - return $page; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if (isset($contexte['lang'])) { |
|
| 41 | - $lang = $contexte['lang']; |
|
| 42 | - } elseif (!isset($lang)) { |
|
| 43 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 47 | - if ($select) { |
|
| 48 | - $select = lang_select($lang); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 52 | - |
|
| 53 | - if (!$styliser) { |
|
| 54 | - $styliser = charger_fonction('styliser', 'public'); |
|
| 55 | - } |
|
| 56 | - list($skel, $mime_type, $gram, $sourcefile) = |
|
| 57 | - $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 58 | - |
|
| 59 | - if ($skel) { |
|
| 60 | - |
|
| 61 | - // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 62 | - // (recursion possible a cause des modeles) |
|
| 63 | - if ($debug) { |
|
| 64 | - $courant = @$GLOBALS['debug_objets']['courant']; |
|
| 65 | - $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // charger le squelette en specifiant les langages cibles et source |
|
| 69 | - // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 70 | - |
|
| 71 | - if (!$composer) { |
|
| 72 | - $composer = charger_fonction('composer', 'public'); |
|
| 73 | - } |
|
| 74 | - $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 75 | - } else { |
|
| 76 | - $fonc = ''; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 80 | - $page = $fonc; |
|
| 81 | - } else { |
|
| 82 | - // Preparer l'appel de la fonction principale du squelette |
|
| 83 | - |
|
| 84 | - spip_timer($a = 'calcul page ' . rand(0, 1000)); |
|
| 85 | - |
|
| 86 | - // On cree un marqueur de notes unique lie a cette composition |
|
| 87 | - // et on enregistre l'etat courant des globales de notes... |
|
| 88 | - if (is_null($notes)) { |
|
| 89 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 90 | - } |
|
| 91 | - if ($notes) { |
|
| 92 | - $notes('', 'empiler'); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - // Rajouter d'office ces deux parametres |
|
| 96 | - // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 97 | - // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 98 | - if (!isset($contexte['date'])) { |
|
| 99 | - $contexte['date'] = date("Y-m-d H:i:s"); |
|
| 100 | - $contexte['date_default'] = true; |
|
| 101 | - } else { |
|
| 102 | - $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if (!isset($contexte['date_redac'])) { |
|
| 106 | - $contexte['date_redac'] = date("Y-m-d H:i:s"); |
|
| 107 | - $contexte['date_redac_default'] = true; |
|
| 108 | - } else { |
|
| 109 | - $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // Passer le nom du cache pour produire sa destruction automatique |
|
| 113 | - try { |
|
| 114 | - $page = $fonc(array('cache' => $cache), array($contexte)); |
|
| 115 | - } catch (Throwable $e) { |
|
| 116 | - $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 117 | - $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 118 | - $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
|
| 119 | - $corps = "<pre>$msg</pre>"; |
|
| 120 | - $page = analyse_resultat_skel($fond, array('cache' => $cache), $corps, $sourcefile); |
|
| 121 | - erreur_squelette($full_msg); |
|
| 122 | - unset($msg, $full_msg, $corps); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 126 | - // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 127 | - // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 128 | - // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 129 | - // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 130 | - if ($notes) { |
|
| 131 | - $notes('', 'depiler'); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // reinjecter en dynamique la pile des notes |
|
| 135 | - // si il y a des inclure dynamiques |
|
| 136 | - // si la pile n'est pas vide |
|
| 137 | - // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 138 | - // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 139 | - if ($notes) { |
|
| 140 | - $page['notes'] = $notes('', 'sauver_etat'); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // spip_log: un joli contexte |
|
| 144 | - $infos = presenter_contexte(array_filter($contexte)); |
|
| 145 | - |
|
| 146 | - $profile = spip_timer($a); |
|
| 147 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 148 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 149 | - |
|
| 150 | - if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 151 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 152 | - .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - if ($debug) { |
|
| 156 | - // si c'est ce que demande le debusqueur, lui passer la main |
|
| 157 | - $t = strlen($page['texte']) ? $page['texte'] : " "; |
|
| 158 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 159 | - $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 160 | - $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 161 | - if ($GLOBALS['debug_objets']['sourcefile'] |
|
| 162 | - and (_request('var_mode_objet') == $fonc) |
|
| 163 | - and (_request('var_mode_affiche') == 'resultat') |
|
| 164 | - ) { |
|
| 165 | - erreur_squelette(); |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 169 | - if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 170 | - // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 171 | - // si aucun #CACHE{} spécifié |
|
| 172 | - // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 173 | - // entre public et prive |
|
| 174 | - if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 175 | - $page['entetes']['X-Spip-Cache'] = 0; |
|
| 176 | - } else { |
|
| 177 | - $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000; |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $page['contexte'] = $contexte; |
|
| 182 | - |
|
| 183 | - // faire remonter le fichier source |
|
| 184 | - static $js_inclus = false; |
|
| 185 | - if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 186 | - $page['sourcefile'] = $sourcefile; |
|
| 187 | - $page['texte'] = |
|
| 188 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" |
|
| 189 | - . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
|
| 190 | - $js_inclus = true; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 194 | - if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 195 | - $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 196 | - unset($GLOBALS['cache_utilise_session']); |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if ($select) { |
|
| 201 | - lang_select(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - return $page; |
|
| 34 | + static $composer, $styliser, $notes = null; |
|
| 35 | + $page = tester_redirection($fond, $contexte, $connect); |
|
| 36 | + if ($page) { |
|
| 37 | + return $page; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if (isset($contexte['lang'])) { |
|
| 41 | + $lang = $contexte['lang']; |
|
| 42 | + } elseif (!isset($lang)) { |
|
| 43 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 47 | + if ($select) { |
|
| 48 | + $select = lang_select($lang); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 52 | + |
|
| 53 | + if (!$styliser) { |
|
| 54 | + $styliser = charger_fonction('styliser', 'public'); |
|
| 55 | + } |
|
| 56 | + list($skel, $mime_type, $gram, $sourcefile) = |
|
| 57 | + $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 58 | + |
|
| 59 | + if ($skel) { |
|
| 60 | + |
|
| 61 | + // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 62 | + // (recursion possible a cause des modeles) |
|
| 63 | + if ($debug) { |
|
| 64 | + $courant = @$GLOBALS['debug_objets']['courant']; |
|
| 65 | + $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // charger le squelette en specifiant les langages cibles et source |
|
| 69 | + // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 70 | + |
|
| 71 | + if (!$composer) { |
|
| 72 | + $composer = charger_fonction('composer', 'public'); |
|
| 73 | + } |
|
| 74 | + $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 75 | + } else { |
|
| 76 | + $fonc = ''; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 80 | + $page = $fonc; |
|
| 81 | + } else { |
|
| 82 | + // Preparer l'appel de la fonction principale du squelette |
|
| 83 | + |
|
| 84 | + spip_timer($a = 'calcul page ' . rand(0, 1000)); |
|
| 85 | + |
|
| 86 | + // On cree un marqueur de notes unique lie a cette composition |
|
| 87 | + // et on enregistre l'etat courant des globales de notes... |
|
| 88 | + if (is_null($notes)) { |
|
| 89 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 90 | + } |
|
| 91 | + if ($notes) { |
|
| 92 | + $notes('', 'empiler'); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + // Rajouter d'office ces deux parametres |
|
| 96 | + // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 97 | + // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 98 | + if (!isset($contexte['date'])) { |
|
| 99 | + $contexte['date'] = date("Y-m-d H:i:s"); |
|
| 100 | + $contexte['date_default'] = true; |
|
| 101 | + } else { |
|
| 102 | + $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if (!isset($contexte['date_redac'])) { |
|
| 106 | + $contexte['date_redac'] = date("Y-m-d H:i:s"); |
|
| 107 | + $contexte['date_redac_default'] = true; |
|
| 108 | + } else { |
|
| 109 | + $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // Passer le nom du cache pour produire sa destruction automatique |
|
| 113 | + try { |
|
| 114 | + $page = $fonc(array('cache' => $cache), array($contexte)); |
|
| 115 | + } catch (Throwable $e) { |
|
| 116 | + $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 117 | + $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 118 | + $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
|
| 119 | + $corps = "<pre>$msg</pre>"; |
|
| 120 | + $page = analyse_resultat_skel($fond, array('cache' => $cache), $corps, $sourcefile); |
|
| 121 | + erreur_squelette($full_msg); |
|
| 122 | + unset($msg, $full_msg, $corps); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 126 | + // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 127 | + // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 128 | + // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 129 | + // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 130 | + if ($notes) { |
|
| 131 | + $notes('', 'depiler'); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // reinjecter en dynamique la pile des notes |
|
| 135 | + // si il y a des inclure dynamiques |
|
| 136 | + // si la pile n'est pas vide |
|
| 137 | + // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 138 | + // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 139 | + if ($notes) { |
|
| 140 | + $page['notes'] = $notes('', 'sauver_etat'); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // spip_log: un joli contexte |
|
| 144 | + $infos = presenter_contexte(array_filter($contexte)); |
|
| 145 | + |
|
| 146 | + $profile = spip_timer($a); |
|
| 147 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 148 | + . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 149 | + |
|
| 150 | + if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 151 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 152 | + .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + if ($debug) { |
|
| 156 | + // si c'est ce que demande le debusqueur, lui passer la main |
|
| 157 | + $t = strlen($page['texte']) ? $page['texte'] : " "; |
|
| 158 | + $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 159 | + $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 160 | + $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 161 | + if ($GLOBALS['debug_objets']['sourcefile'] |
|
| 162 | + and (_request('var_mode_objet') == $fonc) |
|
| 163 | + and (_request('var_mode_affiche') == 'resultat') |
|
| 164 | + ) { |
|
| 165 | + erreur_squelette(); |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 169 | + if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 170 | + // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 171 | + // si aucun #CACHE{} spécifié |
|
| 172 | + // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 173 | + // entre public et prive |
|
| 174 | + if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 175 | + $page['entetes']['X-Spip-Cache'] = 0; |
|
| 176 | + } else { |
|
| 177 | + $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000; |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $page['contexte'] = $contexte; |
|
| 182 | + |
|
| 183 | + // faire remonter le fichier source |
|
| 184 | + static $js_inclus = false; |
|
| 185 | + if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 186 | + $page['sourcefile'] = $sourcefile; |
|
| 187 | + $page['texte'] = |
|
| 188 | + "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" |
|
| 189 | + . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
|
| 190 | + $js_inclus = true; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 194 | + if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 195 | + $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 196 | + unset($GLOBALS['cache_utilise_session']); |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if ($select) { |
|
| 201 | + lang_select(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + return $page; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -210,33 +210,33 @@ discard block |
||
| 210 | 210 | * @return string |
| 211 | 211 | */ |
| 212 | 212 | function presenter_contexte($contexte, $profondeur_max = 1, $max_lines = 0) { |
| 213 | - $infos = array(); |
|
| 214 | - $line = 0; |
|
| 215 | - foreach ($contexte as $var => $val) { |
|
| 216 | - $line++; |
|
| 217 | - if ($max_lines and $max_lines < $line) { |
|
| 218 | - $infos[] = '…'; |
|
| 219 | - break; |
|
| 220 | - } |
|
| 221 | - if (is_array($val)) { |
|
| 222 | - if ($profondeur_max > 0) { |
|
| 223 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 224 | - } else { |
|
| 225 | - $val = 'array:' . count($val); |
|
| 226 | - } |
|
| 227 | - } elseif (is_object($val)) { |
|
| 228 | - $val = get_class($val); |
|
| 229 | - } elseif (strlen("$val") > 30) { |
|
| 230 | - $val = substr("$val", 0, 29) . '…'; |
|
| 231 | - if (strstr($val, ' ')) { |
|
| 232 | - $val = "'$val'"; |
|
| 233 | - } |
|
| 234 | - } elseif (strstr($val, ' ')) { |
|
| 235 | - $val = "'$val'"; |
|
| 236 | - } |
|
| 237 | - $infos[] = $var . '=' . $val; |
|
| 238 | - } |
|
| 239 | - return join(', ', $infos); |
|
| 213 | + $infos = array(); |
|
| 214 | + $line = 0; |
|
| 215 | + foreach ($contexte as $var => $val) { |
|
| 216 | + $line++; |
|
| 217 | + if ($max_lines and $max_lines < $line) { |
|
| 218 | + $infos[] = '…'; |
|
| 219 | + break; |
|
| 220 | + } |
|
| 221 | + if (is_array($val)) { |
|
| 222 | + if ($profondeur_max > 0) { |
|
| 223 | + $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 224 | + } else { |
|
| 225 | + $val = 'array:' . count($val); |
|
| 226 | + } |
|
| 227 | + } elseif (is_object($val)) { |
|
| 228 | + $val = get_class($val); |
|
| 229 | + } elseif (strlen("$val") > 30) { |
|
| 230 | + $val = substr("$val", 0, 29) . '…'; |
|
| 231 | + if (strstr($val, ' ')) { |
|
| 232 | + $val = "'$val'"; |
|
| 233 | + } |
|
| 234 | + } elseif (strstr($val, ' ')) { |
|
| 235 | + $val = "'$val'"; |
|
| 236 | + } |
|
| 237 | + $infos[] = $var . '=' . $val; |
|
| 238 | + } |
|
| 239 | + return join(', ', $infos); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -253,11 +253,11 @@ discard block |
||
| 253 | 253 | * @return array|bool |
| 254 | 254 | */ |
| 255 | 255 | function tester_redirection($fond, $contexte, $connect) { |
| 256 | - static $tester_redirection = null; |
|
| 257 | - if (is_null($tester_redirection)) { |
|
| 258 | - $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 259 | - } |
|
| 260 | - return $tester_redirection($fond, $contexte, $connect); |
|
| 256 | + static $tester_redirection = null; |
|
| 257 | + if (is_null($tester_redirection)) { |
|
| 258 | + $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 259 | + } |
|
| 260 | + return $tester_redirection($fond, $contexte, $connect); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
@@ -273,41 +273,41 @@ discard block |
||
| 273 | 273 | * @return array|bool |
| 274 | 274 | */ |
| 275 | 275 | function public_tester_redirection_dist($fond, $contexte, $connect) { |
| 276 | - if ($fond == 'article' |
|
| 277 | - and !empty($contexte['id_article']) |
|
| 278 | - and $id_article = intval($contexte['id_article']) |
|
| 279 | - ) { |
|
| 280 | - include_spip('public/quete'); // pour quete_virtuel et ses dependances |
|
| 281 | - $m = quete_virtuel($id_article, $connect); |
|
| 282 | - if (strlen($m)) { |
|
| 283 | - include_spip('inc/texte'); |
|
| 284 | - // les navigateurs pataugent si l'URL est vide |
|
| 285 | - if ($url = virtuel_redirige($m, true)) { |
|
| 286 | - // passer en url absolue car cette redirection pourra |
|
| 287 | - // etre utilisee dans un contexte d'url qui change |
|
| 288 | - // y compris url arbo |
|
| 289 | - $status = 302; |
|
| 290 | - if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 291 | - $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 292 | - } |
|
| 293 | - if (!preg_match(',^\w+:,', $url)) { |
|
| 294 | - include_spip('inc/filtres_mini'); |
|
| 295 | - $url = url_absolue($url); |
|
| 296 | - } |
|
| 297 | - $url = str_replace('&', '&', $url); |
|
| 298 | - |
|
| 299 | - return array( |
|
| 300 | - 'texte' => "<" |
|
| 301 | - . "?php include_spip('inc/headers');redirige_par_entete('" |
|
| 302 | - . texte_script($url) |
|
| 303 | - . "','',$status);" |
|
| 304 | - . "?" . ">", |
|
| 305 | - 'process_ins' => 'php', |
|
| 306 | - 'status' => $status |
|
| 307 | - ); |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - return false; |
|
| 276 | + if ($fond == 'article' |
|
| 277 | + and !empty($contexte['id_article']) |
|
| 278 | + and $id_article = intval($contexte['id_article']) |
|
| 279 | + ) { |
|
| 280 | + include_spip('public/quete'); // pour quete_virtuel et ses dependances |
|
| 281 | + $m = quete_virtuel($id_article, $connect); |
|
| 282 | + if (strlen($m)) { |
|
| 283 | + include_spip('inc/texte'); |
|
| 284 | + // les navigateurs pataugent si l'URL est vide |
|
| 285 | + if ($url = virtuel_redirige($m, true)) { |
|
| 286 | + // passer en url absolue car cette redirection pourra |
|
| 287 | + // etre utilisee dans un contexte d'url qui change |
|
| 288 | + // y compris url arbo |
|
| 289 | + $status = 302; |
|
| 290 | + if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 291 | + $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 292 | + } |
|
| 293 | + if (!preg_match(',^\w+:,', $url)) { |
|
| 294 | + include_spip('inc/filtres_mini'); |
|
| 295 | + $url = url_absolue($url); |
|
| 296 | + } |
|
| 297 | + $url = str_replace('&', '&', $url); |
|
| 298 | + |
|
| 299 | + return array( |
|
| 300 | + 'texte' => "<" |
|
| 301 | + . "?php include_spip('inc/headers');redirige_par_entete('" |
|
| 302 | + . texte_script($url) |
|
| 303 | + . "','',$status);" |
|
| 304 | + . "?" . ">", |
|
| 305 | + 'process_ins' => 'php', |
|
| 306 | + 'status' => $status |
|
| 307 | + ); |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + return false; |
|
| 313 | 313 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } else { |
| 82 | 82 | // Preparer l'appel de la fonction principale du squelette |
| 83 | 83 | |
| 84 | - spip_timer($a = 'calcul page ' . rand(0, 1000)); |
|
| 84 | + spip_timer($a = 'calcul page '.rand(0, 1000)); |
|
| 85 | 85 | |
| 86 | 86 | // On cree un marqueur de notes unique lie a cette composition |
| 87 | 87 | // et on enregistre l'etat courant des globales de notes... |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | try { |
| 114 | 114 | $page = $fonc(array('cache' => $cache), array($contexte)); |
| 115 | 115 | } catch (Throwable $e) { |
| 116 | - $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 117 | - $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 116 | + $msg = _T('zbug_erreur_execution_page')." $sourcefile"; |
|
| 117 | + $full_msg = $msg.' | File '.$e->getFile().' Line '.$e->getLine().' : '.$e->getMessage(); |
|
| 118 | 118 | $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
| 119 | 119 | $corps = "<pre>$msg</pre>"; |
| 120 | 120 | $page = analyse_resultat_skel($fond, array('cache' => $cache), $corps, $sourcefile); |
@@ -145,17 +145,17 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $profile = spip_timer($a); |
| 147 | 147 | spip_log("calcul ($profile) [$skel] $infos" |
| 148 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 148 | + . ' ('.strlen($page['texte']).' octets)'); |
|
| 149 | 149 | |
| 150 | - if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 150 | + if (defined('_CALCUL_PROFILER') AND intval($profile) > _CALCUL_PROFILER) { |
|
| 151 | 151 | spip_log("calcul ($profile) [$skel] $infos" |
| 152 | - .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 152 | + .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'], "profiler"._LOG_AVERTISSEMENT); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if ($debug) { |
| 156 | 156 | // si c'est ce que demande le debusqueur, lui passer la main |
| 157 | 157 | $t = strlen($page['texte']) ? $page['texte'] : " "; |
| 158 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 158 | + $GLOBALS['debug_objets']['resultat'][$fonc.'tout'] = $t; |
|
| 159 | 159 | $GLOBALS['debug_objets']['courant'] = $courant; |
| 160 | 160 | $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
| 161 | 161 | if ($GLOBALS['debug_objets']['sourcefile'] |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
| 186 | 186 | $page['sourcefile'] = $sourcefile; |
| 187 | 187 | $page['texte'] = |
| 188 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" |
|
| 188 | + "<div class='inclure_blocs'><h6>".$page['sourcefile']."</h6>".$page['texte']."</div>" |
|
| 189 | 189 | . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
| 190 | 190 | $js_inclus = true; |
| 191 | 191 | } |
@@ -220,21 +220,21 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | if (is_array($val)) { |
| 222 | 222 | if ($profondeur_max > 0) { |
| 223 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 223 | + $val = 'array:'.count($val).'('.presenter_contexte($val, $profondeur_max - 1, 3).')'; |
|
| 224 | 224 | } else { |
| 225 | - $val = 'array:' . count($val); |
|
| 225 | + $val = 'array:'.count($val); |
|
| 226 | 226 | } |
| 227 | 227 | } elseif (is_object($val)) { |
| 228 | 228 | $val = get_class($val); |
| 229 | 229 | } elseif (strlen("$val") > 30) { |
| 230 | - $val = substr("$val", 0, 29) . '…'; |
|
| 230 | + $val = substr("$val", 0, 29).'…'; |
|
| 231 | 231 | if (strstr($val, ' ')) { |
| 232 | 232 | $val = "'$val'"; |
| 233 | 233 | } |
| 234 | 234 | } elseif (strstr($val, ' ')) { |
| 235 | 235 | $val = "'$val'"; |
| 236 | 236 | } |
| 237 | - $infos[] = $var . '=' . $val; |
|
| 237 | + $infos[] = $var.'='.$val; |
|
| 238 | 238 | } |
| 239 | 239 | return join(', ', $infos); |
| 240 | 240 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | . "?php include_spip('inc/headers');redirige_par_entete('" |
| 302 | 302 | . texte_script($url) |
| 303 | 303 | . "','',$status);" |
| 304 | - . "?" . ">", |
|
| 304 | + . "?".">", |
|
| 305 | 305 | 'process_ins' => 'php', |
| 306 | 306 | 'status' => $status |
| 307 | 307 | ); |
@@ -158,7 +158,7 @@ |
||
| 158 | 158 | * @param string $corps |
| 159 | 159 | * @param array $filtres |
| 160 | 160 | * Tableau de filtres à appliquer. |
| 161 | - * @return mixed|string |
|
| 161 | + * @return string |
|
| 162 | 162 | */ |
| 163 | 163 | function sandbox_filtrer_squelette($skel, $corps, $filtres) { |
| 164 | 164 | $series_filtres = func_get_args(); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | **/ |
| 24 | 24 | |
| 25 | 25 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 26 | - return; |
|
| 26 | + return; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | * Texte |
| 42 | 42 | */ |
| 43 | 43 | function sandbox_composer_texte($texte, &$p) { |
| 44 | - $code = "'" . str_replace(array("\\", "'"), array("\\\\", "\\'"), $texte) . "'"; |
|
| 44 | + $code = "'" . str_replace(array("\\", "'"), array("\\\\", "\\'"), $texte) . "'"; |
|
| 45 | 45 | |
| 46 | - return $code; |
|
| 46 | + return $code; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -59,43 +59,43 @@ discard block |
||
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | 61 | function sandbox_composer_filtre($fonc, $code, $arglist, &$p, $nb_arg_droite=1000) : string { |
| 62 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 63 | - $code = "filtrer('$fonc',$code$arglist)"; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // le filtre est defini sous forme de fonction ou de methode |
|
| 67 | - // par ex. dans inc_texte, inc_filtres ou mes_fonctions |
|
| 68 | - elseif ($f = chercher_filtre($fonc)) { |
|
| 69 | - |
|
| 70 | - // cas particulier : le filtre |set doit acceder a la $Pile |
|
| 71 | - // proto: filtre_set(&$Pile, $val, $args...) |
|
| 72 | - if (strpbrk($f, ':')) { // Class::method |
|
| 73 | - $refl = new ReflectionMethod($f); |
|
| 74 | - } else { |
|
| 75 | - $refl = new ReflectionFunction($f); |
|
| 76 | - } |
|
| 77 | - $refs = $refl->getParameters(); |
|
| 78 | - if (isset($refs[0]) and $refs[0]->name == 'Pile') { |
|
| 79 | - $code = "$f(\$Pile,$code$arglist)"; |
|
| 80 | - $nb_arg_gauche = 2; // la balise à laquelle s'applique le filtre + $Pile |
|
| 81 | - } else { |
|
| 82 | - $code = "$f($code$arglist)"; |
|
| 83 | - $nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre |
|
| 84 | - } |
|
| 85 | - $nb_args_f = $nb_arg_gauche+$nb_arg_droite; |
|
| 86 | - $min_f = $refl->getNumberOfRequiredParameters(); |
|
| 87 | - if (($nb_args_f < $min_f)) { |
|
| 88 | - $msg_args = ['filtre' => texte_script ($fonc), 'nb'=> $min_f - $nb_args_f]; |
|
| 89 | - erreur_squelette ([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - // le filtre n'existe pas, |
|
| 93 | - // on le notifie |
|
| 94 | - else { |
|
| 95 | - erreur_squelette(array('zbug_erreur_filtre', array('filtre' => texte_script($fonc))), $p); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - return $code; |
|
| 62 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 63 | + $code = "filtrer('$fonc',$code$arglist)"; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + // le filtre est defini sous forme de fonction ou de methode |
|
| 67 | + // par ex. dans inc_texte, inc_filtres ou mes_fonctions |
|
| 68 | + elseif ($f = chercher_filtre($fonc)) { |
|
| 69 | + |
|
| 70 | + // cas particulier : le filtre |set doit acceder a la $Pile |
|
| 71 | + // proto: filtre_set(&$Pile, $val, $args...) |
|
| 72 | + if (strpbrk($f, ':')) { // Class::method |
|
| 73 | + $refl = new ReflectionMethod($f); |
|
| 74 | + } else { |
|
| 75 | + $refl = new ReflectionFunction($f); |
|
| 76 | + } |
|
| 77 | + $refs = $refl->getParameters(); |
|
| 78 | + if (isset($refs[0]) and $refs[0]->name == 'Pile') { |
|
| 79 | + $code = "$f(\$Pile,$code$arglist)"; |
|
| 80 | + $nb_arg_gauche = 2; // la balise à laquelle s'applique le filtre + $Pile |
|
| 81 | + } else { |
|
| 82 | + $code = "$f($code$arglist)"; |
|
| 83 | + $nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre |
|
| 84 | + } |
|
| 85 | + $nb_args_f = $nb_arg_gauche+$nb_arg_droite; |
|
| 86 | + $min_f = $refl->getNumberOfRequiredParameters(); |
|
| 87 | + if (($nb_args_f < $min_f)) { |
|
| 88 | + $msg_args = ['filtre' => texte_script ($fonc), 'nb'=> $min_f - $nb_args_f]; |
|
| 89 | + erreur_squelette ([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + // le filtre n'existe pas, |
|
| 93 | + // on le notifie |
|
| 94 | + else { |
|
| 95 | + erreur_squelette(array('zbug_erreur_filtre', array('filtre' => texte_script($fonc))), $p); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + return $code; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Calculer un <INCLURE(xx.php)> |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | * @return string |
| 120 | 120 | */ |
| 121 | 121 | function sandbox_composer_inclure_php($fichier, &$p, $_contexte) { |
| 122 | - $compil = texte_script(memoriser_contexte_compil($p)); |
|
| 123 | - // si inexistant, on essaiera a l'execution |
|
| 124 | - if ($path = find_in_path($fichier)) { |
|
| 125 | - $path = "\"$path\""; |
|
| 126 | - } else { |
|
| 127 | - $path = "find_in_path(\"$fichier\")"; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte); |
|
| 122 | + $compil = texte_script(memoriser_contexte_compil($p)); |
|
| 123 | + // si inexistant, on essaiera a l'execution |
|
| 124 | + if ($path = find_in_path($fichier)) { |
|
| 125 | + $path = "\"$path\""; |
|
| 126 | + } else { |
|
| 127 | + $path = "find_in_path(\"$fichier\")"; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -139,19 +139,19 @@ discard block |
||
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | 141 | function sandbox_composer_interdire_scripts($code, &$p) { |
| 142 | - // Securite |
|
| 143 | - if ($p->interdire_scripts |
|
| 144 | - and $p->etoile != '**' |
|
| 145 | - ) { |
|
| 146 | - if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) { |
|
| 147 | - $code = "interdire_scripts($code)"; |
|
| 148 | - } else { |
|
| 149 | - $code = interdire_scripts($r[2]); |
|
| 150 | - $code = "sinon(interdire_scripts($r[1]),'$code')"; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $code; |
|
| 142 | + // Securite |
|
| 143 | + if ($p->interdire_scripts |
|
| 144 | + and $p->etoile != '**' |
|
| 145 | + ) { |
|
| 146 | + if (!preg_match("/^sinon[(](.*),'([^']*)'[)]$/", $code, $r)) { |
|
| 147 | + $code = "interdire_scripts($code)"; |
|
| 148 | + } else { |
|
| 149 | + $code = interdire_scripts($r[2]); |
|
| 150 | + $code = "sinon(interdire_scripts($r[1]),'$code')"; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $code; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
@@ -170,30 +170,30 @@ discard block |
||
| 170 | 170 | * @return mixed|string |
| 171 | 171 | */ |
| 172 | 172 | function sandbox_filtrer_squelette($skel, $corps, $filtres) { |
| 173 | - $series_filtres = func_get_args(); |
|
| 174 | - array_shift($series_filtres);// skel |
|
| 175 | - array_shift($series_filtres);// corps |
|
| 176 | - |
|
| 177 | - // proteger les <INCLUDE> et tous les morceaux de php licites |
|
| 178 | - if ($skel['process_ins'] == 'php') { |
|
| 179 | - $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // recuperer les couples de remplacement |
|
| 183 | - $replace = echapper_php_callback(); |
|
| 184 | - |
|
| 185 | - foreach ($series_filtres as $filtres) { |
|
| 186 | - if (count($filtres)) { |
|
| 187 | - foreach ($filtres as $filtre) { |
|
| 188 | - if ($filtre and $f = chercher_filtre($filtre)) { |
|
| 189 | - $corps = $f($corps); |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - // restaurer les echappements |
|
| 196 | - return str_replace($replace[0], $replace[1], $corps); |
|
| 173 | + $series_filtres = func_get_args(); |
|
| 174 | + array_shift($series_filtres);// skel |
|
| 175 | + array_shift($series_filtres);// corps |
|
| 176 | + |
|
| 177 | + // proteger les <INCLUDE> et tous les morceaux de php licites |
|
| 178 | + if ($skel['process_ins'] == 'php') { |
|
| 179 | + $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // recuperer les couples de remplacement |
|
| 183 | + $replace = echapper_php_callback(); |
|
| 184 | + |
|
| 185 | + foreach ($series_filtres as $filtres) { |
|
| 186 | + if (count($filtres)) { |
|
| 187 | + foreach ($filtres as $filtre) { |
|
| 188 | + if ($filtre and $f = chercher_filtre($filtre)) { |
|
| 189 | + $corps = $f($corps); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + // restaurer les echappements |
|
| 196 | + return str_replace($replace[0], $replace[1], $corps); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -212,21 +212,21 @@ discard block |
||
| 212 | 212 | * - array : Liste( liste des codes PHP, liste des substitutions ) |
| 213 | 213 | **/ |
| 214 | 214 | function echapper_php_callback($r = null) { |
| 215 | - static $src = array(); |
|
| 216 | - static $dst = array(); |
|
| 215 | + static $src = array(); |
|
| 216 | + static $dst = array(); |
|
| 217 | 217 | |
| 218 | - // si on recoit un tableau, on est en mode echappement |
|
| 219 | - // on enregistre le code a echapper dans dst, et le code echappe dans src |
|
| 220 | - if (is_array($r)) { |
|
| 221 | - $dst[] = $r[0]; |
|
| 218 | + // si on recoit un tableau, on est en mode echappement |
|
| 219 | + // on enregistre le code a echapper dans dst, et le code echappe dans src |
|
| 220 | + if (is_array($r)) { |
|
| 221 | + $dst[] = $r[0]; |
|
| 222 | 222 | |
| 223 | - return $src[] = '___' . md5($r[0]) . '___'; |
|
| 224 | - } |
|
| 223 | + return $src[] = '___' . md5($r[0]) . '___'; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - // si on recoit pas un tableau, on renvoit les couples de substitution |
|
| 227 | - // et on RAZ les remplacements |
|
| 228 | - $r = array($src, $dst); |
|
| 229 | - $src = $dst = array(); |
|
| 226 | + // si on recoit pas un tableau, on renvoit les couples de substitution |
|
| 227 | + // et on RAZ les remplacements |
|
| 228 | + $r = array($src, $dst); |
|
| 229 | + $src = $dst = array(); |
|
| 230 | 230 | |
| 231 | - return $r; |
|
| 231 | + return $r; |
|
| 232 | 232 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Texte |
| 42 | 42 | */ |
| 43 | 43 | function sandbox_composer_texte($texte, &$p) { |
| 44 | - $code = "'" . str_replace(array("\\", "'"), array("\\\\", "\\'"), $texte) . "'"; |
|
| 44 | + $code = "'".str_replace(array("\\", "'"), array("\\\\", "\\'"), $texte)."'"; |
|
| 45 | 45 | |
| 46 | 46 | return $code; |
| 47 | 47 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * Balise qui appelle ce filtre |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | -function sandbox_composer_filtre($fonc, $code, $arglist, &$p, $nb_arg_droite=1000) : string { |
|
| 61 | +function sandbox_composer_filtre($fonc, $code, $arglist, &$p, $nb_arg_droite = 1000) : string { |
|
| 62 | 62 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 63 | 63 | $code = "filtrer('$fonc',$code$arglist)"; |
| 64 | 64 | } |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | $code = "$f($code$arglist)"; |
| 83 | 83 | $nb_arg_gauche = 1; // la balise à laquelle s'applique le filtre |
| 84 | 84 | } |
| 85 | - $nb_args_f = $nb_arg_gauche+$nb_arg_droite; |
|
| 85 | + $nb_args_f = $nb_arg_gauche + $nb_arg_droite; |
|
| 86 | 86 | $min_f = $refl->getNumberOfRequiredParameters(); |
| 87 | 87 | if (($nb_args_f < $min_f)) { |
| 88 | - $msg_args = ['filtre' => texte_script ($fonc), 'nb'=> $min_f - $nb_args_f]; |
|
| 89 | - erreur_squelette ([ 'zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 88 | + $msg_args = ['filtre' => texte_script($fonc), 'nb'=> $min_f - $nb_args_f]; |
|
| 89 | + erreur_squelette(['zbug_erreur_filtre_nbarg_min', $msg_args], $p); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | // le filtre n'existe pas, |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | function sandbox_filtrer_squelette($skel, $corps, $filtres) { |
| 173 | 173 | $series_filtres = func_get_args(); |
| 174 | - array_shift($series_filtres);// skel |
|
| 175 | - array_shift($series_filtres);// corps |
|
| 174 | + array_shift($series_filtres); // skel |
|
| 175 | + array_shift($series_filtres); // corps |
|
| 176 | 176 | |
| 177 | 177 | // proteger les <INCLUDE> et tous les morceaux de php licites |
| 178 | 178 | if ($skel['process_ins'] == 'php') { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | if (is_array($r)) { |
| 221 | 221 | $dst[] = $r[0]; |
| 222 | 222 | |
| 223 | - return $src[] = '___' . md5($r[0]) . '___'; |
|
| 223 | + return $src[] = '___'.md5($r[0]).'___'; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // si on recoit pas un tableau, on renvoit les couples de substitution |
@@ -236,7 +236,7 @@ |
||
| 236 | 236 | * @param string $type |
| 237 | 237 | * @param string $ext |
| 238 | 238 | * @param bool $echafauder |
| 239 | - * @return mixed |
|
| 239 | + * @return string|boolean |
|
| 240 | 240 | */ |
| 241 | 241 | function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) { |
| 242 | 242 | if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\Public\Styliser |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined("_ECRIRE_INC_VERSION")) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,181 +29,181 @@ discard block |
||
| 29 | 29 | * @return array Données modifiées du pipeline |
| 30 | 30 | */ |
| 31 | 31 | function public_styliser_par_z_dist($flux) { |
| 32 | - static $prefix_path = null; |
|
| 33 | - static $prefix_length; |
|
| 34 | - static $z_blocs; |
|
| 35 | - static $apl_constant; |
|
| 36 | - static $page; |
|
| 37 | - static $disponible = array(); |
|
| 38 | - static $echafauder; |
|
| 39 | - static $prepend = ""; |
|
| 40 | - |
|
| 41 | - if (!isset($prefix_path)) { |
|
| 42 | - $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | - if (test_espace_prive()) { |
|
| 44 | - $prefix_path = "prive/squelettes/"; |
|
| 45 | - $prefix_length = strlen($prefix_path); |
|
| 46 | - $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | - $page = 'exec'; |
|
| 48 | - $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | - define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | - } else { |
|
| 51 | - $prefix_path = ""; |
|
| 52 | - $prefix_length = 0; |
|
| 53 | - $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | - $page = _SPIP_PAGE; |
|
| 55 | - $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | - define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | - '/') : '')); |
|
| 58 | - } |
|
| 59 | - $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
|
| 60 | - } |
|
| 61 | - $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 62 | - |
|
| 63 | - $fond = $flux['args']['fond']; |
|
| 64 | - |
|
| 65 | - if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 66 | - $fond = substr($fond, $prefix_length); |
|
| 67 | - $squelette = $flux['data']; |
|
| 68 | - $ext = $flux['args']['ext']; |
|
| 69 | - // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 70 | - if (defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 71 | - and $dir = explode('/', $fond) |
|
| 72 | - and count($dir) == 2 // pas un sous repertoire |
|
| 73 | - and $dir = reset($dir) |
|
| 74 | - and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 75 | - and defined($apl_constant) |
|
| 76 | - and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 77 | - and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | - ) { |
|
| 79 | - $flux['data'] = $pipe; |
|
| 80 | - |
|
| 81 | - return $flux; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 85 | - if ($squelette and !z_fond_valide($squelette)) { |
|
| 86 | - $squelette = ""; |
|
| 87 | - $echafauder = ""; |
|
| 88 | - } |
|
| 89 | - if ($prepend) { |
|
| 90 | - $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | - if ($squelette) { |
|
| 92 | - $flux['data'] = $squelette; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // gerer les squelettes non trouves |
|
| 97 | - // -> router vers les /dist.html |
|
| 98 | - // ou scaffolding ou page automatique les contenus |
|
| 99 | - if (!$squelette) { |
|
| 100 | - |
|
| 101 | - // si on est sur un ?page=XX non trouve |
|
| 102 | - if ((isset($flux['args']['contexte'][$page]) |
|
| 103 | - and $flux['args']['contexte'][$page] == $fond) |
|
| 104 | - or (isset($flux['args']['contexte']['type-page']) |
|
| 105 | - and $flux['args']['contexte']['type-page'] == $fond) |
|
| 106 | - or ($fond == 'sommaire' |
|
| 107 | - and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 108 | - ) { |
|
| 109 | - |
|
| 110 | - // si on est sur un ?page=XX non trouve |
|
| 111 | - // se brancher sur contenu/xx si il existe |
|
| 112 | - // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 113 | - if (!isset($disponible[$fond])) { |
|
| 114 | - $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if ($disponible[$fond]) { |
|
| 118 | - $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // echafaudage : |
|
| 123 | - // si c'est un fond de contenu d'un objet en base |
|
| 124 | - // generer un fond automatique a la volee pour les webmestres |
|
| 125 | - elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 126 | - $type = substr($fond, strlen($z_contenu) + 1); |
|
| 127 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 128 | - $type = $flux['args']['contexte'][$page]; |
|
| 129 | - } |
|
| 130 | - if (!isset($disponible[$type])) { |
|
| 131 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | - } |
|
| 133 | - if (is_string($disponible[$type])) { |
|
| 134 | - $flux['data'] = $disponible[$type]; |
|
| 135 | - } elseif ($echafauder |
|
| 136 | - and include_spip('inc/autoriser') |
|
| 137 | - and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 138 | - and autoriser('echafauder', $type) |
|
| 139 | - and $is = $disponible[$type] |
|
| 140 | - and is_array($is) |
|
| 141 | - ) { |
|
| 142 | - $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 143 | - } else { |
|
| 144 | - $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 145 | - $echafauder)); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 150 | - // et si il y a bien un contenu correspondant ou echafaudable |
|
| 151 | - // se rabbatre sur le dist.html du bloc concerne |
|
| 152 | - else { |
|
| 153 | - if ($dir = explode('/', $fond) |
|
| 154 | - and $dir = reset($dir) |
|
| 155 | - and $dir !== $z_contenu |
|
| 156 | - and in_array($dir, $z_blocs) |
|
| 157 | - ) { |
|
| 158 | - $type = substr($fond, strlen("$dir/")); |
|
| 159 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 160 | - $type = $flux['args']['contexte'][$page]; |
|
| 161 | - } |
|
| 162 | - if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 163 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | - } |
|
| 165 | - if ($type == 'page' or $disponible[$type]) { |
|
| 166 | - $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - $squelette = $flux['data']; |
|
| 171 | - } |
|
| 172 | - // layout specifiques par type et compositions : |
|
| 173 | - // body-article.html |
|
| 174 | - // body-sommaire.html |
|
| 175 | - // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 176 | - // meme dossier que body.html |
|
| 177 | - if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 178 | - if (isset($flux['args']['contexte']['type-page']) |
|
| 179 | - and ( |
|
| 180 | - (isset($flux['args']['contexte']['composition']) |
|
| 181 | - and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 182 | - or |
|
| 183 | - file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 184 | - ) |
|
| 185 | - ) { |
|
| 186 | - $flux['data'] = $f; |
|
| 187 | - } |
|
| 188 | - } elseif ($fond == 'structure' |
|
| 189 | - and z_sanitize_var_zajax() |
|
| 190 | - and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 191 | - ) { |
|
| 192 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 193 | - } // chercher le fond correspondant a la composition |
|
| 194 | - elseif (isset($flux['args']['contexte']['composition']) |
|
| 195 | - and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 196 | - and $dir = substr($fond, $prefix_length) |
|
| 197 | - and $dir = explode('/', $dir) |
|
| 198 | - and $dir = reset($dir) |
|
| 199 | - and in_array($dir, $z_blocs) |
|
| 200 | - and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 201 | - ) { |
|
| 202 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - return $flux; |
|
| 32 | + static $prefix_path = null; |
|
| 33 | + static $prefix_length; |
|
| 34 | + static $z_blocs; |
|
| 35 | + static $apl_constant; |
|
| 36 | + static $page; |
|
| 37 | + static $disponible = array(); |
|
| 38 | + static $echafauder; |
|
| 39 | + static $prepend = ""; |
|
| 40 | + |
|
| 41 | + if (!isset($prefix_path)) { |
|
| 42 | + $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | + if (test_espace_prive()) { |
|
| 44 | + $prefix_path = "prive/squelettes/"; |
|
| 45 | + $prefix_length = strlen($prefix_path); |
|
| 46 | + $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | + $page = 'exec'; |
|
| 48 | + $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | + define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | + } else { |
|
| 51 | + $prefix_path = ""; |
|
| 52 | + $prefix_length = 0; |
|
| 53 | + $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | + $page = _SPIP_PAGE; |
|
| 55 | + $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | + define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | + '/') : '')); |
|
| 58 | + } |
|
| 59 | + $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
|
| 60 | + } |
|
| 61 | + $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 62 | + |
|
| 63 | + $fond = $flux['args']['fond']; |
|
| 64 | + |
|
| 65 | + if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 66 | + $fond = substr($fond, $prefix_length); |
|
| 67 | + $squelette = $flux['data']; |
|
| 68 | + $ext = $flux['args']['ext']; |
|
| 69 | + // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 70 | + if (defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 71 | + and $dir = explode('/', $fond) |
|
| 72 | + and count($dir) == 2 // pas un sous repertoire |
|
| 73 | + and $dir = reset($dir) |
|
| 74 | + and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 75 | + and defined($apl_constant) |
|
| 76 | + and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 77 | + and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | + ) { |
|
| 79 | + $flux['data'] = $pipe; |
|
| 80 | + |
|
| 81 | + return $flux; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 85 | + if ($squelette and !z_fond_valide($squelette)) { |
|
| 86 | + $squelette = ""; |
|
| 87 | + $echafauder = ""; |
|
| 88 | + } |
|
| 89 | + if ($prepend) { |
|
| 90 | + $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | + if ($squelette) { |
|
| 92 | + $flux['data'] = $squelette; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // gerer les squelettes non trouves |
|
| 97 | + // -> router vers les /dist.html |
|
| 98 | + // ou scaffolding ou page automatique les contenus |
|
| 99 | + if (!$squelette) { |
|
| 100 | + |
|
| 101 | + // si on est sur un ?page=XX non trouve |
|
| 102 | + if ((isset($flux['args']['contexte'][$page]) |
|
| 103 | + and $flux['args']['contexte'][$page] == $fond) |
|
| 104 | + or (isset($flux['args']['contexte']['type-page']) |
|
| 105 | + and $flux['args']['contexte']['type-page'] == $fond) |
|
| 106 | + or ($fond == 'sommaire' |
|
| 107 | + and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 108 | + ) { |
|
| 109 | + |
|
| 110 | + // si on est sur un ?page=XX non trouve |
|
| 111 | + // se brancher sur contenu/xx si il existe |
|
| 112 | + // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 113 | + if (!isset($disponible[$fond])) { |
|
| 114 | + $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if ($disponible[$fond]) { |
|
| 118 | + $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // echafaudage : |
|
| 123 | + // si c'est un fond de contenu d'un objet en base |
|
| 124 | + // generer un fond automatique a la volee pour les webmestres |
|
| 125 | + elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 126 | + $type = substr($fond, strlen($z_contenu) + 1); |
|
| 127 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 128 | + $type = $flux['args']['contexte'][$page]; |
|
| 129 | + } |
|
| 130 | + if (!isset($disponible[$type])) { |
|
| 131 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | + } |
|
| 133 | + if (is_string($disponible[$type])) { |
|
| 134 | + $flux['data'] = $disponible[$type]; |
|
| 135 | + } elseif ($echafauder |
|
| 136 | + and include_spip('inc/autoriser') |
|
| 137 | + and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 138 | + and autoriser('echafauder', $type) |
|
| 139 | + and $is = $disponible[$type] |
|
| 140 | + and is_array($is) |
|
| 141 | + ) { |
|
| 142 | + $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 143 | + } else { |
|
| 144 | + $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 145 | + $echafauder)); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 150 | + // et si il y a bien un contenu correspondant ou echafaudable |
|
| 151 | + // se rabbatre sur le dist.html du bloc concerne |
|
| 152 | + else { |
|
| 153 | + if ($dir = explode('/', $fond) |
|
| 154 | + and $dir = reset($dir) |
|
| 155 | + and $dir !== $z_contenu |
|
| 156 | + and in_array($dir, $z_blocs) |
|
| 157 | + ) { |
|
| 158 | + $type = substr($fond, strlen("$dir/")); |
|
| 159 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 160 | + $type = $flux['args']['contexte'][$page]; |
|
| 161 | + } |
|
| 162 | + if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 163 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | + } |
|
| 165 | + if ($type == 'page' or $disponible[$type]) { |
|
| 166 | + $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + $squelette = $flux['data']; |
|
| 171 | + } |
|
| 172 | + // layout specifiques par type et compositions : |
|
| 173 | + // body-article.html |
|
| 174 | + // body-sommaire.html |
|
| 175 | + // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 176 | + // meme dossier que body.html |
|
| 177 | + if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 178 | + if (isset($flux['args']['contexte']['type-page']) |
|
| 179 | + and ( |
|
| 180 | + (isset($flux['args']['contexte']['composition']) |
|
| 181 | + and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 182 | + or |
|
| 183 | + file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 184 | + ) |
|
| 185 | + ) { |
|
| 186 | + $flux['data'] = $f; |
|
| 187 | + } |
|
| 188 | + } elseif ($fond == 'structure' |
|
| 189 | + and z_sanitize_var_zajax() |
|
| 190 | + and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 191 | + ) { |
|
| 192 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 193 | + } // chercher le fond correspondant a la composition |
|
| 194 | + elseif (isset($flux['args']['contexte']['composition']) |
|
| 195 | + and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 196 | + and $dir = substr($fond, $prefix_length) |
|
| 197 | + and $dir = explode('/', $dir) |
|
| 198 | + and $dir = reset($dir) |
|
| 199 | + and in_array($dir, $z_blocs) |
|
| 200 | + and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 201 | + ) { |
|
| 202 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + return $flux; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function z_blocs($espace_prive = false) { |
| 216 | - if ($espace_prive) { |
|
| 217 | - return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array( |
|
| 218 | - 'contenu', |
|
| 219 | - 'navigation', |
|
| 220 | - 'extra', |
|
| 221 | - 'head', |
|
| 222 | - 'hierarchie', |
|
| 223 | - 'top' |
|
| 224 | - )); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu')); |
|
| 216 | + if ($espace_prive) { |
|
| 217 | + return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array( |
|
| 218 | + 'contenu', |
|
| 219 | + 'navigation', |
|
| 220 | + 'extra', |
|
| 221 | + 'head', |
|
| 222 | + 'hierarchie', |
|
| 223 | + 'top' |
|
| 224 | + )); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu')); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | * @return mixed |
| 240 | 240 | */ |
| 241 | 241 | function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) { |
| 242 | - if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 243 | - return $d; |
|
| 244 | - } |
|
| 242 | + if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 243 | + return $d; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return $echafauder ? z_echafaudable($type) : false; |
|
| 246 | + return $echafauder ? z_echafaudable($type) : false; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -257,13 +257,13 @@ discard block |
||
| 257 | 257 | * `true` si on peut l'utiliser, `false` sinon. |
| 258 | 258 | **/ |
| 259 | 259 | function z_fond_valide($squelette) { |
| 260 | - if (!_ZCORE_EXCLURE_PATH |
|
| 261 | - or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 262 | - ) { |
|
| 263 | - return true; |
|
| 264 | - } |
|
| 260 | + if (!_ZCORE_EXCLURE_PATH |
|
| 261 | + or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 262 | + ) { |
|
| 263 | + return true; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - return false; |
|
| 266 | + return false; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -281,14 +281,14 @@ discard block |
||
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | 283 | function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) { |
| 284 | - if ( |
|
| 285 | - (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 286 | - or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 287 | - ) { |
|
| 288 | - return substr($f, 0, -strlen(".$ext")); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return ""; |
|
| 284 | + if ( |
|
| 285 | + (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 286 | + or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 287 | + ) { |
|
| 288 | + return substr($f, 0, -strlen(".$ext")); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return ""; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -300,51 +300,51 @@ discard block |
||
| 300 | 300 | * @return bool |
| 301 | 301 | */ |
| 302 | 302 | function z_echafaudable($type) { |
| 303 | - static $pages = null; |
|
| 304 | - static $echafaudable = array(); |
|
| 305 | - if (isset($echafaudable[$type])) { |
|
| 306 | - return $echafaudable[$type]; |
|
| 307 | - } |
|
| 308 | - if (preg_match(',[^\w],', $type)) { |
|
| 309 | - return $echafaudable[$type] = false; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - if (test_espace_prive()) { |
|
| 313 | - if (!function_exists('trouver_objet_exec')) { |
|
| 314 | - include_spip('inc/pipelines_ecrire'); |
|
| 315 | - } |
|
| 316 | - if ($e = trouver_objet_exec($type)) { |
|
| 317 | - return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e); |
|
| 318 | - } else { |
|
| 319 | - // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 320 | - if (($t = objet_type($type, false)) !== $type |
|
| 321 | - and $e = trouver_objet_exec($t) |
|
| 322 | - ) { |
|
| 323 | - return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t); |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } else { |
|
| 327 | - if (is_null($pages)) { |
|
| 328 | - $pages = array(); |
|
| 329 | - $liste = lister_tables_objets_sql(); |
|
| 330 | - foreach ($liste as $t => $d) { |
|
| 331 | - if ($d['page']) { |
|
| 332 | - $pages[$d['page']] = array($d['table_objet'], $t); |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - if (!isset($pages[$type])) { |
|
| 337 | - return $echafaudable[$type] = false; |
|
| 338 | - } |
|
| 339 | - if (count($pages[$type]) == 2) { |
|
| 340 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | - $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - return $echafaudable[$type] = $pages[$type]; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - return $echafaudable[$type] = false; |
|
| 303 | + static $pages = null; |
|
| 304 | + static $echafaudable = array(); |
|
| 305 | + if (isset($echafaudable[$type])) { |
|
| 306 | + return $echafaudable[$type]; |
|
| 307 | + } |
|
| 308 | + if (preg_match(',[^\w],', $type)) { |
|
| 309 | + return $echafaudable[$type] = false; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + if (test_espace_prive()) { |
|
| 313 | + if (!function_exists('trouver_objet_exec')) { |
|
| 314 | + include_spip('inc/pipelines_ecrire'); |
|
| 315 | + } |
|
| 316 | + if ($e = trouver_objet_exec($type)) { |
|
| 317 | + return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e); |
|
| 318 | + } else { |
|
| 319 | + // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 320 | + if (($t = objet_type($type, false)) !== $type |
|
| 321 | + and $e = trouver_objet_exec($t) |
|
| 322 | + ) { |
|
| 323 | + return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } else { |
|
| 327 | + if (is_null($pages)) { |
|
| 328 | + $pages = array(); |
|
| 329 | + $liste = lister_tables_objets_sql(); |
|
| 330 | + foreach ($liste as $t => $d) { |
|
| 331 | + if ($d['page']) { |
|
| 332 | + $pages[$d['page']] = array($d['table_objet'], $t); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + if (!isset($pages[$type])) { |
|
| 337 | + return $echafaudable[$type] = false; |
|
| 338 | + } |
|
| 339 | + if (count($pages[$type]) == 2) { |
|
| 340 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | + $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + return $echafaudable[$type] = $pages[$type]; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + return $echafaudable[$type] = false; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
@@ -361,46 +361,46 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) { |
| 364 | - $scaffold = ""; |
|
| 365 | - |
|
| 366 | - // page objet ou objet_edit |
|
| 367 | - if (is_array($desc_exec)) { |
|
| 368 | - $type = $desc_exec['type']; |
|
| 369 | - $primary = $desc_exec['id_table_objet']; |
|
| 370 | - |
|
| 371 | - if ($desc_exec['edition'] === false) { |
|
| 372 | - $fond = "objet"; |
|
| 373 | - } else { |
|
| 374 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 375 | - $desc = $trouver_table($table_sql); |
|
| 376 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 377 | - $fond = 'objet_edit'; |
|
| 378 | - } else { |
|
| 379 | - $fond = 'objet_edit.sans_rubrique'; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - $dir = z_blocs(test_espace_prive()); |
|
| 383 | - $dir = reset($dir); |
|
| 384 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 385 | - } // page objets |
|
| 386 | - elseif ($type = $desc_exec and strpos($type, "/") === false) { |
|
| 387 | - $dir = z_blocs(test_espace_prive()); |
|
| 388 | - $dir = reset($dir); |
|
| 389 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 390 | - } |
|
| 391 | - // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 392 | - // et objet et tire de $table |
|
| 393 | - elseif ($fond = $desc_exec) { |
|
| 394 | - $dir = md5(dirname($fond)); |
|
| 395 | - $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
|
| 399 | - $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 400 | - $f = $base_dir . "$exec"; |
|
| 401 | - ecrire_fichier("$f.$ext", $scaffold); |
|
| 402 | - |
|
| 403 | - return $f; |
|
| 364 | + $scaffold = ""; |
|
| 365 | + |
|
| 366 | + // page objet ou objet_edit |
|
| 367 | + if (is_array($desc_exec)) { |
|
| 368 | + $type = $desc_exec['type']; |
|
| 369 | + $primary = $desc_exec['id_table_objet']; |
|
| 370 | + |
|
| 371 | + if ($desc_exec['edition'] === false) { |
|
| 372 | + $fond = "objet"; |
|
| 373 | + } else { |
|
| 374 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 375 | + $desc = $trouver_table($table_sql); |
|
| 376 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 377 | + $fond = 'objet_edit'; |
|
| 378 | + } else { |
|
| 379 | + $fond = 'objet_edit.sans_rubrique'; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + $dir = z_blocs(test_espace_prive()); |
|
| 383 | + $dir = reset($dir); |
|
| 384 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 385 | + } // page objets |
|
| 386 | + elseif ($type = $desc_exec and strpos($type, "/") === false) { |
|
| 387 | + $dir = z_blocs(test_espace_prive()); |
|
| 388 | + $dir = reset($dir); |
|
| 389 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 390 | + } |
|
| 391 | + // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 392 | + // et objet et tire de $table |
|
| 393 | + elseif ($fond = $desc_exec) { |
|
| 394 | + $dir = md5(dirname($fond)); |
|
| 395 | + $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
|
| 399 | + $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 400 | + $f = $base_dir . "$exec"; |
|
| 401 | + ecrire_fichier("$f.$ext", $scaffold); |
|
| 402 | + |
|
| 403 | + return $f; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -409,16 +409,16 @@ discard block |
||
| 409 | 409 | * @return bool|string |
| 410 | 410 | */ |
| 411 | 411 | function z_sanitize_var_zajax() { |
| 412 | - $z_ajax = _request('var_zajax'); |
|
| 413 | - if (!$z_ajax) { |
|
| 414 | - return false; |
|
| 415 | - } |
|
| 416 | - if (!$z_blocs = z_blocs(test_espace_prive()) |
|
| 417 | - or !in_array($z_ajax, $z_blocs) |
|
| 418 | - ) { |
|
| 419 | - set_request('var_zajax'); // enlever cette demande incongrue |
|
| 420 | - $z_ajax = false; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - return $z_ajax; |
|
| 412 | + $z_ajax = _request('var_zajax'); |
|
| 413 | + if (!$z_ajax) { |
|
| 414 | + return false; |
|
| 415 | + } |
|
| 416 | + if (!$z_blocs = z_blocs(test_espace_prive()) |
|
| 417 | + or !in_array($z_ajax, $z_blocs) |
|
| 418 | + ) { |
|
| 419 | + set_request('var_zajax'); // enlever cette demande incongrue |
|
| 420 | + $z_ajax = false; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + return $z_ajax; |
|
| 424 | 424 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
| 54 | 54 | $page = _SPIP_PAGE; |
| 55 | 55 | $echafauder = charger_fonction('echafauder', 'public', true); |
| 56 | - define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 56 | + define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist'.(defined('_DIR_PLUGIN_DIST') ? '|\b'.rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | 57 | '/') : '')); |
| 58 | 58 | } |
| 59 | 59 | $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
| 75 | 75 | and defined($apl_constant) |
| 76 | 76 | and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
| 77 | - and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 77 | + and $pipe = z_trouver_bloc($prefix_path.$prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | 78 | ) { |
| 79 | 79 | $flux['data'] = $pipe; |
| 80 | 80 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $echafauder = ""; |
| 88 | 88 | } |
| 89 | 89 | if ($prepend) { |
| 90 | - $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 90 | + $squelette = substr(find_in_path($prefix_path.$prepend."$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | 91 | if ($squelette) { |
| 92 | 92 | $flux['data'] = $squelette; |
| 93 | 93 | } |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | // se brancher sur contenu/xx si il existe |
| 112 | 112 | // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
| 113 | 113 | if (!isset($disponible[$fond])) { |
| 114 | - $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 114 | + $disponible[$fond] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if ($disponible[$fond]) { |
| 118 | - $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 118 | + $flux['data'] = substr(find_in_path($prefix_path."page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $type = $flux['args']['contexte'][$page]; |
| 129 | 129 | } |
| 130 | 130 | if (!isset($disponible[$type])) { |
| 131 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 131 | + $disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | 132 | } |
| 133 | 133 | if (is_string($disponible[$type])) { |
| 134 | 134 | $flux['data'] = $disponible[$type]; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | ) { |
| 142 | 142 | $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
| 143 | 143 | } else { |
| 144 | - $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 144 | + $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, '404', $ext, |
|
| 145 | 145 | $echafauder)); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | $type = $flux['args']['contexte'][$page]; |
| 161 | 161 | } |
| 162 | 162 | if ($type !== 'page' and !isset($disponible[$type])) { |
| 163 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 163 | + $disponible[$type] = z_contenu_disponible($prefix_path.$prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | 164 | } |
| 165 | 165 | if ($type == 'page' or $disponible[$type]) { |
| 166 | - $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 166 | + $flux['data'] = z_trouver_bloc($prefix_path.$prepend, $dir, 'dist', $ext); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | } |
@@ -178,16 +178,16 @@ discard block |
||
| 178 | 178 | if (isset($flux['args']['contexte']['type-page']) |
| 179 | 179 | and ( |
| 180 | 180 | (isset($flux['args']['contexte']['composition']) |
| 181 | - and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 181 | + and file_exists(($f = $squelette."-".$flux['args']['contexte']['type-page']."-".$flux['args']['contexte']['composition']).".$ext")) |
|
| 182 | 182 | or |
| 183 | - file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 183 | + file_exists(($f = $squelette."-".$flux['args']['contexte']['type-page']).".$ext") |
|
| 184 | 184 | ) |
| 185 | 185 | ) { |
| 186 | 186 | $flux['data'] = $f; |
| 187 | 187 | } |
| 188 | 188 | } elseif ($fond == 'structure' |
| 189 | 189 | and z_sanitize_var_zajax() |
| 190 | - and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 190 | + and $f = find_in_path($prefix_path.$prepend.'ajax'.".$ext") |
|
| 191 | 191 | ) { |
| 192 | 192 | $flux['data'] = substr($f, 0, -strlen(".$ext")); |
| 193 | 193 | } // chercher le fond correspondant a la composition |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | and $dir = explode('/', $dir) |
| 198 | 198 | and $dir = reset($dir) |
| 199 | 199 | and in_array($dir, $z_blocs) |
| 200 | - and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 200 | + and $f = find_in_path($prefix_path.$prepend.$fond."-".$flux['args']['contexte']['composition'].".$ext") |
|
| 201 | 201 | ) { |
| 202 | 202 | $flux['data'] = substr($f, 0, -strlen(".$ext")); |
| 203 | 203 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | **/ |
| 259 | 259 | function z_fond_valide($squelette) { |
| 260 | 260 | if (!_ZCORE_EXCLURE_PATH |
| 261 | - or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 261 | + or !preg_match(',('._ZCORE_EXCLURE_PATH.')/,', $squelette) |
|
| 262 | 262 | ) { |
| 263 | 263 | return true; |
| 264 | 264 | } |
@@ -381,23 +381,23 @@ discard block |
||
| 381 | 381 | } |
| 382 | 382 | $dir = z_blocs(test_espace_prive()); |
| 383 | 383 | $dir = reset($dir); |
| 384 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 384 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/".$fond.",objet=".$type.",id_objet=#".strtoupper($primary).",env}>"; |
|
| 385 | 385 | } // page objets |
| 386 | 386 | elseif ($type = $desc_exec and strpos($type, "/") === false) { |
| 387 | 387 | $dir = z_blocs(test_espace_prive()); |
| 388 | 388 | $dir = reset($dir); |
| 389 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 389 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=".$type.",env} />"; |
|
| 390 | 390 | } |
| 391 | 391 | // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
| 392 | 392 | // et objet et tire de $table |
| 393 | 393 | elseif ($fond = $desc_exec) { |
| 394 | 394 | $dir = md5(dirname($fond)); |
| 395 | - $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 395 | + $scaffold = "<INCLURE{fond=$fond,objet=".objet_type($table).",env} />"; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
| 399 | 399 | $base_dir = sous_repertoire($base_dir, $dir, false); |
| 400 | - $f = $base_dir . "$exec"; |
|
| 400 | + $f = $base_dir."$exec"; |
|
| 401 | 401 | ecrire_fichier("$f.$ext", $scaffold); |
| 402 | 402 | |
| 403 | 403 | return $f; |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Retourne l'URL de redirection d'un article virtuel, seulement si il est publié |
| 30 | 30 | * |
| 31 | - * @param $id_article |
|
| 32 | - * @param $connect |
|
| 33 | - * @return array|bool|null |
|
| 31 | + * @param integer $id_article |
|
| 32 | + * @param string $connect |
|
| 33 | + * @return string |
|
| 34 | 34 | */ |
| 35 | 35 | function quete_virtuel($id_article, $connect) { |
| 36 | 36 | return sql_getfetsel( |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @uses quete_parent_lang() |
| 123 | 123 | * |
| 124 | 124 | * @param int $id_article |
| 125 | - * @param $serveur |
|
| 125 | + * @param string $serveur |
|
| 126 | 126 | * @return int |
| 127 | 127 | */ |
| 128 | 128 | function quete_rubrique($id_article, $serveur) { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param int $id_document |
| 295 | 295 | * @param string $serveur |
| 296 | - * @return array|bool|null |
|
| 296 | + * @return string |
|
| 297 | 297 | */ |
| 298 | 298 | function quete_fichier($id_document, $serveur = '') { |
| 299 | 299 | return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return sql_getfetsel( |
| 37 | 37 | 'virtuel', |
| 38 | 38 | 'spip_articles', |
| 39 | - array('id_article=' . intval($id_article), "statut='publie'"), |
|
| 39 | + array('id_article='.intval($id_article), "statut='publie'"), |
|
| 40 | 40 | '', |
| 41 | 41 | '', |
| 42 | 42 | '', |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $cache_quete[$connect][$table][$id] = sql_fetsel( |
| 79 | 79 | $cache_quete[$connect][$table]['_select'], |
| 80 | 80 | $table, |
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 81 | + $cache_quete[$connect][$table]['_id'].'='.intval($id), |
|
| 82 | 82 | '', |
| 83 | 83 | '', |
| 84 | 84 | '', |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | return |
| 172 | 172 | (isset($GLOBALS['meta']['date_prochain_postdate']) |
| 173 | 173 | and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
| 174 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 174 | + ? "$champ_date<".sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 175 | 175 | : '1=1'; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | and $id_table = reset($objet) |
| 230 | 230 | and $objet = objet_type($id_table) |
| 231 | 231 | ) { |
| 232 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | + $w = "$mstatut<>".sql_quote($v); |
|
| 233 | 233 | |
| 234 | 234 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 235 | 235 | // sinon l’auteur en session |
@@ -243,22 +243,22 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 246 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | + if (!autoriser('previsualiser'.$v, $objet, '', $id_auteur)) { |
|
| 247 | 247 | // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
| 248 | 248 | if (!$id_auteur) { |
| 249 | 249 | $where[] = $w; |
| 250 | 250 | } else { |
| 251 | 251 | $primary = id_table_objet($objet); |
| 252 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | + $where[] = "($w OR $id_table.$primary IN (".sql_get_select( |
|
| 253 | 253 | 'ssss.id_objet', |
| 254 | 254 | 'spip_auteurs_liens AS ssss', |
| 255 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 255 | + 'ssss.objet='.sql_quote($objet).' AND ssss.id_auteur='.intval($id_auteur), |
|
| 256 | 256 | '', |
| 257 | 257 | '', |
| 258 | 258 | '', |
| 259 | 259 | '', |
| 260 | 260 | $serveur |
| 261 | - ) . '))'; |
|
| 261 | + ).'))'; |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | } // ignorer ce statut si on ne sait pas comment le filtrer |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @return array|bool|null |
| 297 | 297 | */ |
| 298 | 298 | function quete_fichier($id_document, $serveur = '') { |
| 299 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 299 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document='.intval($id_document)), '', array(), '', '', $serveur); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * @return array|bool |
| 308 | 308 | */ |
| 309 | 309 | function quete_document($id_document, $serveur = '') { |
| 310 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 310 | + return sql_fetsel('*', 'spip_documents', ('id_document='.intval($id_document)), '', array(), '', '', $serveur); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @return array|bool|null |
| 319 | 319 | */ |
| 320 | 320 | function quete_meta($nom, $serveur) { |
| 321 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | + return sql_getfetsel('valeur', 'spip_meta', 'nom='.sql_quote($nom), '', '', '', '', $serveur); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | // qui permet de distinguer le changement de logo |
| 373 | 373 | // et placer un expire sur le dossier IMG/ |
| 374 | 374 | $res = array( |
| 375 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 376 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 377 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 375 | + $on['chemin'].($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 376 | + ($off ? $off['chemin'].($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 377 | + (!$taille ? '' : (' '.$taille[3])) |
|
| 378 | 378 | ); |
| 379 | 379 | $res['src'] = $res[0]; |
| 380 | 380 | $res['logo_on'] = $res[0]; |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | // si c'est une vignette type doc, la renvoyer direct |
| 471 | 471 | if (strcmp($logo, _DIR_PLUGINS) == 0 |
| 472 | 472 | or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
| 473 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 473 | + or strcmp($logo, _DIR_RACINE.'prive/') == 0 |
|
| 474 | 474 | ) { |
| 475 | 475 | return $logo; |
| 476 | 476 | } |
@@ -589,8 +589,7 @@ discard block |
||
| 589 | 589 | // qu'une fois (par squelette) et on conserve le resultat |
| 590 | 590 | // en static. |
| 591 | 591 | if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
| 592 | - $principal = isset($reference[$type]) ? $reference[$type] : |
|
| 593 | - // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 592 | + $principal = isset($reference[$type]) ? $reference[$type] : // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 594 | 593 | // et donne la reference dynamique @type=xx dans le contexte |
| 595 | 594 | (isset($reference["@$type"]) ? $reference["@$type"] : ''); |
| 596 | 595 | // le parent fournit en argument est le parent de $id, pas celui de $principal |
@@ -618,7 +617,7 @@ discard block |
||
| 618 | 617 | $exposer[$m][$type][$principal] = true; |
| 619 | 618 | if ($type == 'id_mot') { |
| 620 | 619 | if (!$parent) { |
| 621 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 620 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot='.intval($principal), '', '', '', '', $connect); |
|
| 622 | 621 | } |
| 623 | 622 | if ($parent) { |
| 624 | 623 | $exposer[$m]['id_groupe'][$parent] = true; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | * @return array|bool|null |
| 34 | 34 | */ |
| 35 | 35 | function quete_virtuel($id_article, $connect) { |
| 36 | - return sql_getfetsel( |
|
| 37 | - 'virtuel', |
|
| 38 | - 'spip_articles', |
|
| 39 | - array('id_article=' . intval($id_article), "statut='publie'"), |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - '', |
|
| 44 | - $connect |
|
| 45 | - ); |
|
| 36 | + return sql_getfetsel( |
|
| 37 | + 'virtuel', |
|
| 38 | + 'spip_articles', |
|
| 39 | + array('id_article=' . intval($id_article), "statut='publie'"), |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + '', |
|
| 44 | + $connect |
|
| 45 | + ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,38 +57,38 @@ discard block |
||
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | 59 | function quete_parent_lang($table, $id, $connect = '') { |
| 60 | - static $cache_quete = array(); |
|
| 61 | - |
|
| 62 | - if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | - if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | - if (!$desc = $trouver_table($table, |
|
| 66 | - $connect) or !isset($desc['field']['id_rubrique']) |
|
| 67 | - ) { |
|
| 68 | - // pas de parent rubrique, on passe |
|
| 69 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | - } else { |
|
| 71 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | - $cache_quete[$connect][$table]['_select'], |
|
| 80 | - $table, |
|
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 82 | - '', |
|
| 83 | - '', |
|
| 84 | - '', |
|
| 85 | - '', |
|
| 86 | - $connect |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null; |
|
| 60 | + static $cache_quete = array(); |
|
| 61 | + |
|
| 62 | + if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | + if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | + if (!$desc = $trouver_table($table, |
|
| 66 | + $connect) or !isset($desc['field']['id_rubrique']) |
|
| 67 | + ) { |
|
| 68 | + // pas de parent rubrique, on passe |
|
| 69 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | + } else { |
|
| 71 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | + $cache_quete[$connect][$table]['_select'], |
|
| 80 | + $table, |
|
| 81 | + $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 82 | + '', |
|
| 83 | + '', |
|
| 84 | + '', |
|
| 85 | + '', |
|
| 86 | + $connect |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | * @return int |
| 106 | 106 | */ |
| 107 | 107 | function quete_parent($id_rubrique, $connect = '') { |
| 108 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 109 | - return 0; |
|
| 110 | - } |
|
| 111 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | - return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 108 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 109 | + return 0; |
|
| 110 | + } |
|
| 111 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | + return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @return int |
| 126 | 126 | */ |
| 127 | 127 | function quete_rubrique($id_article, $serveur) { |
| 128 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 128 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 129 | 129 | |
| 130 | - return $id_parent['id_rubrique']; |
|
| 130 | + return $id_parent['id_rubrique']; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | * @return int |
| 142 | 142 | */ |
| 143 | 143 | function quete_profondeur($id, $connect = '') { |
| 144 | - $n = 0; |
|
| 145 | - while ($id) { |
|
| 146 | - $n++; |
|
| 147 | - $id = quete_parent($id, $connect); |
|
| 148 | - } |
|
| 144 | + $n = 0; |
|
| 145 | + while ($id) { |
|
| 146 | + $n++; |
|
| 147 | + $id = quete_parent($id, $connect); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - return $n; |
|
| 150 | + return $n; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -163,15 +163,15 @@ discard block |
||
| 163 | 163 | * Morceau de la requête SQL testant la date |
| 164 | 164 | */ |
| 165 | 165 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 166 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 167 | - return '1=1'; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - return |
|
| 171 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 172 | - and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 173 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 174 | - : '1=1'; |
|
| 166 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 167 | + return '1=1'; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + return |
|
| 171 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 172 | + and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 173 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 174 | + : '1=1'; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -191,100 +191,100 @@ discard block |
||
| 191 | 191 | * @return array|string |
| 192 | 192 | */ |
| 193 | 193 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 194 | - static $cond = array(); |
|
| 195 | - $key = func_get_args(); |
|
| 196 | - $key = implode('-', $key); |
|
| 197 | - if (isset($cond[$key])) { |
|
| 198 | - return $cond[$key]; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - $liste_statuts = $publie; |
|
| 202 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 203 | - $liste_statuts = $previsu; |
|
| 204 | - } |
|
| 205 | - $not = false; |
|
| 206 | - if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 207 | - $not = true; |
|
| 208 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 209 | - } |
|
| 210 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 211 | - if (!strlen($liste_statuts)) { |
|
| 212 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 216 | - $where = array(); |
|
| 217 | - foreach ($liste_statuts as $k => $v) { |
|
| 218 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 219 | - // a ceux de l'auteur identifie |
|
| 220 | - if (strpos($v, '/') !== false) { |
|
| 221 | - $v = explode('/', $v); |
|
| 222 | - $filtre = end($v); |
|
| 223 | - $v = reset($v); |
|
| 224 | - $v = preg_replace(',\W,', '', $v); |
|
| 225 | - if ($filtre == 'auteur' |
|
| 226 | - and (strpos($mstatut, '.') !== false) |
|
| 227 | - and $objet = explode('.', $mstatut) |
|
| 228 | - and $id_table = reset($objet) |
|
| 229 | - and $objet = objet_type($id_table) |
|
| 230 | - ) { |
|
| 231 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | - |
|
| 233 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 234 | - // sinon l’auteur en session |
|
| 235 | - include_spip('inc/securiser_action'); |
|
| 236 | - if ($desc = decrire_token_previsu()) { |
|
| 237 | - $id_auteur = $desc['id_auteur']; |
|
| 238 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 239 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 240 | - } else { |
|
| 241 | - $id_auteur = null; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 245 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 247 | - if (!$id_auteur) { |
|
| 248 | - $where[] = $w; |
|
| 249 | - } else { |
|
| 250 | - $primary = id_table_objet($objet); |
|
| 251 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | - 'ssss.id_objet', |
|
| 253 | - 'spip_auteurs_liens AS ssss', |
|
| 254 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 255 | - '', |
|
| 256 | - '', |
|
| 257 | - '', |
|
| 258 | - '', |
|
| 259 | - $serveur |
|
| 260 | - ) . '))'; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 264 | - else { |
|
| 265 | - $v = ''; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - // securite |
|
| 269 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 270 | - } |
|
| 271 | - $liste_statuts = array_filter($liste_statuts); |
|
| 272 | - if (count($liste_statuts) == 1) { |
|
| 273 | - $where[] = array('=', $mstatut, sql_quote(reset($liste_statuts), $serveur)); |
|
| 274 | - } else { |
|
| 275 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - while (count($where) > 1) { |
|
| 279 | - $and = array('AND', array_pop($where), array_pop($where)); |
|
| 280 | - $where[] = $and; |
|
| 281 | - } |
|
| 282 | - $cond[$key] = reset($where); |
|
| 283 | - if ($not) { |
|
| 284 | - $cond[$key] = array('NOT', $cond[$key]); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - return $cond[$key]; |
|
| 194 | + static $cond = array(); |
|
| 195 | + $key = func_get_args(); |
|
| 196 | + $key = implode('-', $key); |
|
| 197 | + if (isset($cond[$key])) { |
|
| 198 | + return $cond[$key]; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + $liste_statuts = $publie; |
|
| 202 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 203 | + $liste_statuts = $previsu; |
|
| 204 | + } |
|
| 205 | + $not = false; |
|
| 206 | + if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 207 | + $not = true; |
|
| 208 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 209 | + } |
|
| 210 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 211 | + if (!strlen($liste_statuts)) { |
|
| 212 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 216 | + $where = array(); |
|
| 217 | + foreach ($liste_statuts as $k => $v) { |
|
| 218 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 219 | + // a ceux de l'auteur identifie |
|
| 220 | + if (strpos($v, '/') !== false) { |
|
| 221 | + $v = explode('/', $v); |
|
| 222 | + $filtre = end($v); |
|
| 223 | + $v = reset($v); |
|
| 224 | + $v = preg_replace(',\W,', '', $v); |
|
| 225 | + if ($filtre == 'auteur' |
|
| 226 | + and (strpos($mstatut, '.') !== false) |
|
| 227 | + and $objet = explode('.', $mstatut) |
|
| 228 | + and $id_table = reset($objet) |
|
| 229 | + and $objet = objet_type($id_table) |
|
| 230 | + ) { |
|
| 231 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | + |
|
| 233 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 234 | + // sinon l’auteur en session |
|
| 235 | + include_spip('inc/securiser_action'); |
|
| 236 | + if ($desc = decrire_token_previsu()) { |
|
| 237 | + $id_auteur = $desc['id_auteur']; |
|
| 238 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 239 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 240 | + } else { |
|
| 241 | + $id_auteur = null; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 245 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 247 | + if (!$id_auteur) { |
|
| 248 | + $where[] = $w; |
|
| 249 | + } else { |
|
| 250 | + $primary = id_table_objet($objet); |
|
| 251 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | + 'ssss.id_objet', |
|
| 253 | + 'spip_auteurs_liens AS ssss', |
|
| 254 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 255 | + '', |
|
| 256 | + '', |
|
| 257 | + '', |
|
| 258 | + '', |
|
| 259 | + $serveur |
|
| 260 | + ) . '))'; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 264 | + else { |
|
| 265 | + $v = ''; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + // securite |
|
| 269 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 270 | + } |
|
| 271 | + $liste_statuts = array_filter($liste_statuts); |
|
| 272 | + if (count($liste_statuts) == 1) { |
|
| 273 | + $where[] = array('=', $mstatut, sql_quote(reset($liste_statuts), $serveur)); |
|
| 274 | + } else { |
|
| 275 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + while (count($where) > 1) { |
|
| 279 | + $and = array('AND', array_pop($where), array_pop($where)); |
|
| 280 | + $where[] = $and; |
|
| 281 | + } |
|
| 282 | + $cond[$key] = reset($where); |
|
| 283 | + if ($not) { |
|
| 284 | + $cond[$key] = array('NOT', $cond[$key]); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + return $cond[$key]; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @return array|bool|null |
| 296 | 296 | */ |
| 297 | 297 | function quete_fichier($id_document, $serveur = '') { |
| 298 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 298 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return array|bool |
| 307 | 307 | */ |
| 308 | 308 | function quete_document($id_document, $serveur = '') { |
| 309 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 309 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return array|bool|null |
| 318 | 318 | */ |
| 319 | 319 | function quete_meta($nom, $serveur) { |
| 320 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 320 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -343,66 +343,66 @@ discard block |
||
| 343 | 343 | * Retourne soit un tableau, soit le chemin du fichier. |
| 344 | 344 | */ |
| 345 | 345 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag) { |
| 346 | - include_spip('base/objets'); |
|
| 347 | - $nom = strtolower($onoff); |
|
| 348 | - |
|
| 349 | - $cle_objet = id_table_objet($cle_objet); |
|
| 350 | - |
|
| 351 | - while (1) { |
|
| 352 | - $objet = objet_type($cle_objet); |
|
| 353 | - |
|
| 354 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 355 | - |
|
| 356 | - if ($on) { |
|
| 357 | - if ($flag) { |
|
| 358 | - return basename($on['chemin']); |
|
| 359 | - } else { |
|
| 360 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 361 | - |
|
| 362 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 363 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 364 | - // alors on ne cherche pas du tout le survol ici |
|
| 365 | - if ($onoff != 'ON') { |
|
| 366 | - $off = ''; |
|
| 367 | - } else { |
|
| 368 | - // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 369 | - $off = quete_logo_objet($id, $objet, 'off'); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 373 | - // qui permet de distinguer le changement de logo |
|
| 374 | - // et placer un expire sur le dossier IMG/ |
|
| 375 | - $res = array( |
|
| 376 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 377 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 378 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 379 | - ); |
|
| 380 | - $res['src'] = $res[0]; |
|
| 381 | - $res['logo_on'] = $res[0]; |
|
| 382 | - $res['logo_off'] = $res[1]; |
|
| 383 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 384 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 385 | - |
|
| 386 | - return $res; |
|
| 387 | - } |
|
| 388 | - } else { |
|
| 389 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 390 | - return ''; |
|
| 391 | - } else { |
|
| 392 | - if ($id_rubrique) { |
|
| 393 | - $cle_objet = 'id_rubrique'; |
|
| 394 | - $id = $id_rubrique; |
|
| 395 | - $id_rubrique = 0; |
|
| 396 | - } else { |
|
| 397 | - if ($id and $cle_objet == 'id_rubrique') { |
|
| 398 | - $id = quete_parent($id); |
|
| 399 | - } else { |
|
| 400 | - return ''; |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - } |
|
| 346 | + include_spip('base/objets'); |
|
| 347 | + $nom = strtolower($onoff); |
|
| 348 | + |
|
| 349 | + $cle_objet = id_table_objet($cle_objet); |
|
| 350 | + |
|
| 351 | + while (1) { |
|
| 352 | + $objet = objet_type($cle_objet); |
|
| 353 | + |
|
| 354 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 355 | + |
|
| 356 | + if ($on) { |
|
| 357 | + if ($flag) { |
|
| 358 | + return basename($on['chemin']); |
|
| 359 | + } else { |
|
| 360 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 361 | + |
|
| 362 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 363 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 364 | + // alors on ne cherche pas du tout le survol ici |
|
| 365 | + if ($onoff != 'ON') { |
|
| 366 | + $off = ''; |
|
| 367 | + } else { |
|
| 368 | + // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 369 | + $off = quete_logo_objet($id, $objet, 'off'); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 373 | + // qui permet de distinguer le changement de logo |
|
| 374 | + // et placer un expire sur le dossier IMG/ |
|
| 375 | + $res = array( |
|
| 376 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 377 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 378 | + (!$taille ? '' : (' ' . $taille[3])) |
|
| 379 | + ); |
|
| 380 | + $res['src'] = $res[0]; |
|
| 381 | + $res['logo_on'] = $res[0]; |
|
| 382 | + $res['logo_off'] = $res[1]; |
|
| 383 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 384 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 385 | + |
|
| 386 | + return $res; |
|
| 387 | + } |
|
| 388 | + } else { |
|
| 389 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 390 | + return ''; |
|
| 391 | + } else { |
|
| 392 | + if ($id_rubrique) { |
|
| 393 | + $cle_objet = 'id_rubrique'; |
|
| 394 | + $id = $id_rubrique; |
|
| 395 | + $id_rubrique = 0; |
|
| 396 | + } else { |
|
| 397 | + if ($id and $cle_objet == 'id_rubrique') { |
|
| 398 | + $id = quete_parent($id); |
|
| 399 | + } else { |
|
| 400 | + return ''; |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | /** |
@@ -416,37 +416,37 @@ discard block |
||
| 416 | 416 | * "on" ou "off" suivant le logo normal ou survol |
| 417 | 417 | **/ |
| 418 | 418 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 419 | - static $chercher_logo; |
|
| 420 | - if (is_null($chercher_logo)) { |
|
| 421 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 422 | - } |
|
| 423 | - $cle_objet = id_table_objet($objet); |
|
| 424 | - |
|
| 425 | - // On cherche pas la méthode classique |
|
| 426 | - $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 427 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 428 | - if (!empty($infos_logo)) { |
|
| 429 | - $infos_logo = array( |
|
| 430 | - 'chemin' => $infos_logo[0], |
|
| 431 | - 'timestamp' => $infos_logo[4], |
|
| 432 | - ); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - // On passe cette recherche de logo dans un pipeline |
|
| 436 | - $infos_logo = pipeline( |
|
| 437 | - 'quete_logo_objet', |
|
| 438 | - array( |
|
| 439 | - 'args' => array( |
|
| 440 | - 'id_objet' => $id_objet, |
|
| 441 | - 'objet' => $objet, |
|
| 442 | - 'cle_objet' => $cle_objet, |
|
| 443 | - 'mode' => $mode, |
|
| 444 | - ), |
|
| 445 | - 'data' => $infos_logo, |
|
| 446 | - ) |
|
| 447 | - ); |
|
| 448 | - |
|
| 449 | - return $infos_logo; |
|
| 419 | + static $chercher_logo; |
|
| 420 | + if (is_null($chercher_logo)) { |
|
| 421 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 422 | + } |
|
| 423 | + $cle_objet = id_table_objet($objet); |
|
| 424 | + |
|
| 425 | + // On cherche pas la méthode classique |
|
| 426 | + $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 427 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 428 | + if (!empty($infos_logo)) { |
|
| 429 | + $infos_logo = array( |
|
| 430 | + 'chemin' => $infos_logo[0], |
|
| 431 | + 'timestamp' => $infos_logo[4], |
|
| 432 | + ); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + // On passe cette recherche de logo dans un pipeline |
|
| 436 | + $infos_logo = pipeline( |
|
| 437 | + 'quete_logo_objet', |
|
| 438 | + array( |
|
| 439 | + 'args' => array( |
|
| 440 | + 'id_objet' => $id_objet, |
|
| 441 | + 'objet' => $objet, |
|
| 442 | + 'cle_objet' => $cle_objet, |
|
| 443 | + 'mode' => $mode, |
|
| 444 | + ), |
|
| 445 | + 'data' => $infos_logo, |
|
| 446 | + ) |
|
| 447 | + ); |
|
| 448 | + |
|
| 449 | + return $infos_logo; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -459,24 +459,24 @@ discard block |
||
| 459 | 459 | * @return bool|string |
| 460 | 460 | */ |
| 461 | 461 | function quete_logo_file($row, $connect = null) { |
| 462 | - include_spip('inc/documents'); |
|
| 463 | - $logo = vignette_logo_document($row, $connect); |
|
| 464 | - if (!$logo) { |
|
| 465 | - $logo = image_du_document($row, $connect); |
|
| 466 | - } |
|
| 467 | - if (!$logo) { |
|
| 468 | - $f = charger_fonction('vignette', 'inc'); |
|
| 469 | - $logo = $f($row['extension'], false); |
|
| 470 | - } |
|
| 471 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 472 | - if (strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 473 | - or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 474 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 475 | - ) { |
|
| 476 | - return $logo; |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - return get_spip_doc($logo); |
|
| 462 | + include_spip('inc/documents'); |
|
| 463 | + $logo = vignette_logo_document($row, $connect); |
|
| 464 | + if (!$logo) { |
|
| 465 | + $logo = image_du_document($row, $connect); |
|
| 466 | + } |
|
| 467 | + if (!$logo) { |
|
| 468 | + $f = charger_fonction('vignette', 'inc'); |
|
| 469 | + $logo = $f($row['extension'], false); |
|
| 470 | + } |
|
| 471 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 472 | + if (strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 473 | + or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 474 | + or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 475 | + ) { |
|
| 476 | + return $logo; |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + return get_spip_doc($logo); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
@@ -504,20 +504,20 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, $connect = null) { |
| 506 | 506 | |
| 507 | - include_spip('inc/documents'); |
|
| 508 | - $logo = ''; |
|
| 509 | - if (!in_array($mode_logo, array('icone', 'apercu'))) { |
|
| 510 | - $logo = vignette_logo_document($row, $connect); |
|
| 511 | - } |
|
| 512 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 513 | - if ($mode_logo == 'vignette' and !$logo) { |
|
| 514 | - return ''; |
|
| 515 | - } |
|
| 516 | - if ($mode_logo == 'icone') { |
|
| 517 | - $row['fichier'] = ''; |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 507 | + include_spip('inc/documents'); |
|
| 508 | + $logo = ''; |
|
| 509 | + if (!in_array($mode_logo, array('icone', 'apercu'))) { |
|
| 510 | + $logo = vignette_logo_document($row, $connect); |
|
| 511 | + } |
|
| 512 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 513 | + if ($mode_logo == 'vignette' and !$logo) { |
|
| 514 | + return ''; |
|
| 515 | + } |
|
| 516 | + if ($mode_logo == 'icone') { |
|
| 517 | + $row['fichier'] = ''; |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | /** |
@@ -529,19 +529,19 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | function quete_html_logo($logo, $align, $lien) { |
| 531 | 531 | |
| 532 | - if (!is_array($logo)) { |
|
| 533 | - return ''; |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - $contexte = []; |
|
| 537 | - foreach ($logo as $k=>$v) { |
|
| 538 | - if (!is_numeric($k)) { |
|
| 539 | - $contexte[$k] = $v; |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - $contexte['align'] = $align; |
|
| 543 | - $contexte['lien'] = $lien; |
|
| 544 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 532 | + if (!is_array($logo)) { |
|
| 533 | + return ''; |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + $contexte = []; |
|
| 537 | + foreach ($logo as $k=>$v) { |
|
| 538 | + if (!is_numeric($k)) { |
|
| 539 | + $contexte[$k] = $v; |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + $contexte['align'] = $align; |
|
| 543 | + $contexte['lien'] = $lien; |
|
| 544 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -555,14 +555,14 @@ discard block |
||
| 555 | 555 | * @return string|false |
| 556 | 556 | */ |
| 557 | 557 | function document_spip_externe($fichier, $connect) { |
| 558 | - if ($connect) { |
|
| 559 | - $site = quete_meta('adresse_site', $connect); |
|
| 560 | - if ($site) { |
|
| 561 | - $dir = quete_meta('dir_img', $connect); |
|
| 562 | - return "$site/$dir$fichier"; |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - return false; |
|
| 558 | + if ($connect) { |
|
| 559 | + $site = quete_meta('adresse_site', $connect); |
|
| 560 | + if ($site) { |
|
| 561 | + $dir = quete_meta('dir_img', $connect); |
|
| 562 | + return "$site/$dir$fichier"; |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + return false; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -575,23 +575,23 @@ discard block |
||
| 575 | 575 | * @return string |
| 576 | 576 | */ |
| 577 | 577 | function vignette_logo_document($row, $connect = '') { |
| 578 | - if (!$row['id_vignette']) { |
|
| 579 | - return ''; |
|
| 580 | - } |
|
| 581 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 582 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 583 | - return $url; |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - $f = get_spip_doc($fichier); |
|
| 587 | - if ($f and @file_exists($f)) { |
|
| 588 | - return $f; |
|
| 589 | - } |
|
| 590 | - if ($row['mode'] !== 'vignette') { |
|
| 591 | - return ''; |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - return generer_url_entite($row['id_document'], 'document', '', '', $connect); |
|
| 578 | + if (!$row['id_vignette']) { |
|
| 579 | + return ''; |
|
| 580 | + } |
|
| 581 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 582 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 583 | + return $url; |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + $f = get_spip_doc($fichier); |
|
| 587 | + if ($f and @file_exists($f)) { |
|
| 588 | + return $f; |
|
| 589 | + } |
|
| 590 | + if ($row['mode'] !== 'vignette') { |
|
| 591 | + return ''; |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + return generer_url_entite($row['id_document'], 'document', '', '', $connect); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -607,68 +607,68 @@ discard block |
||
| 607 | 607 | * @return bool|string |
| 608 | 608 | */ |
| 609 | 609 | function calcul_exposer($id, $prim, $reference, $parent, $type, $connect = '') { |
| 610 | - static $exposer = array(); |
|
| 611 | - |
|
| 612 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 613 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 614 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 615 | - // en static. |
|
| 616 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 617 | - $principal = isset($reference[$type]) ? $reference[$type] : |
|
| 618 | - // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 619 | - // et donne la reference dynamique @type=xx dans le contexte |
|
| 620 | - (isset($reference["@$type"]) ? $reference["@$type"] : ''); |
|
| 621 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 622 | - // il n'est donc pas utile |
|
| 623 | - $parent = 0; |
|
| 624 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 625 | - $enfants = array('id_rubrique' => array('id_article'), 'id_groupe' => array('id_mot')); |
|
| 626 | - if (isset($enfants[$type])) { |
|
| 627 | - foreach ($enfants[$type] as $t) { |
|
| 628 | - if (isset($reference[$t]) |
|
| 629 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 630 | - or isset($reference["@$t"]) |
|
| 631 | - ) { |
|
| 632 | - $type = $t; |
|
| 633 | - $principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"]; |
|
| 634 | - continue; |
|
| 635 | - } |
|
| 636 | - } |
|
| 637 | - } |
|
| 638 | - } |
|
| 639 | - $exposer[$m][$type] = array(); |
|
| 640 | - if ($principal) { |
|
| 641 | - $principaux = is_array($principal) ? $principal : array($principal); |
|
| 642 | - foreach ($principaux as $principal) { |
|
| 643 | - $exposer[$m][$type][$principal] = true; |
|
| 644 | - if ($type == 'id_mot') { |
|
| 645 | - if (!$parent) { |
|
| 646 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 647 | - } |
|
| 648 | - if ($parent) { |
|
| 649 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 650 | - } |
|
| 651 | - } else { |
|
| 652 | - if ($type != 'id_groupe') { |
|
| 653 | - if (!$parent) { |
|
| 654 | - if ($type == 'id_rubrique') { |
|
| 655 | - $parent = $principal; |
|
| 656 | - } |
|
| 657 | - if ($type == 'id_article') { |
|
| 658 | - $parent = quete_rubrique($principal, $connect); |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - do { |
|
| 662 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 663 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 664 | - } |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - // And the winner is... |
|
| 671 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 610 | + static $exposer = array(); |
|
| 611 | + |
|
| 612 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 613 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 614 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 615 | + // en static. |
|
| 616 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 617 | + $principal = isset($reference[$type]) ? $reference[$type] : |
|
| 618 | + // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 619 | + // et donne la reference dynamique @type=xx dans le contexte |
|
| 620 | + (isset($reference["@$type"]) ? $reference["@$type"] : ''); |
|
| 621 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 622 | + // il n'est donc pas utile |
|
| 623 | + $parent = 0; |
|
| 624 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 625 | + $enfants = array('id_rubrique' => array('id_article'), 'id_groupe' => array('id_mot')); |
|
| 626 | + if (isset($enfants[$type])) { |
|
| 627 | + foreach ($enfants[$type] as $t) { |
|
| 628 | + if (isset($reference[$t]) |
|
| 629 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 630 | + or isset($reference["@$t"]) |
|
| 631 | + ) { |
|
| 632 | + $type = $t; |
|
| 633 | + $principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"]; |
|
| 634 | + continue; |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + } |
|
| 638 | + } |
|
| 639 | + $exposer[$m][$type] = array(); |
|
| 640 | + if ($principal) { |
|
| 641 | + $principaux = is_array($principal) ? $principal : array($principal); |
|
| 642 | + foreach ($principaux as $principal) { |
|
| 643 | + $exposer[$m][$type][$principal] = true; |
|
| 644 | + if ($type == 'id_mot') { |
|
| 645 | + if (!$parent) { |
|
| 646 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 647 | + } |
|
| 648 | + if ($parent) { |
|
| 649 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 650 | + } |
|
| 651 | + } else { |
|
| 652 | + if ($type != 'id_groupe') { |
|
| 653 | + if (!$parent) { |
|
| 654 | + if ($type == 'id_rubrique') { |
|
| 655 | + $parent = $principal; |
|
| 656 | + } |
|
| 657 | + if ($type == 'id_article') { |
|
| 658 | + $parent = quete_rubrique($principal, $connect); |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + do { |
|
| 662 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 663 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 664 | + } |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + // And the winner is... |
|
| 671 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -683,21 +683,21 @@ discard block |
||
| 683 | 683 | * @return int |
| 684 | 684 | */ |
| 685 | 685 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 686 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 687 | - // ou composee, mais verifions |
|
| 688 | - if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 689 | - return 0; |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - $pos = 0; |
|
| 693 | - while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 694 | - $pos++; |
|
| 695 | - } |
|
| 696 | - // si on a pas trouve |
|
| 697 | - if (!$row or $row[$primary] != $valeur) { |
|
| 698 | - return 0; |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - // sinon, calculer le bon numero de page |
|
| 702 | - return floor($pos / $pas) * $pas; |
|
| 686 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 687 | + // ou composee, mais verifions |
|
| 688 | + if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 689 | + return 0; |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + $pos = 0; |
|
| 693 | + while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 694 | + $pos++; |
|
| 695 | + } |
|
| 696 | + // si on a pas trouve |
|
| 697 | + if (!$row or $row[$primary] != $valeur) { |
|
| 698 | + return 0; |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + // sinon, calculer le bon numero de page |
|
| 702 | + return floor($pos / $pas) * $pas; |
|
| 703 | 703 | } |
@@ -1,3 +1,3 @@ |
||
| 1 | 1 | <?php |
| 2 | - # appel SPIP |
|
| 3 | - include('spip.php'); |
|
| 2 | + # appel SPIP |
|
| 3 | + include('spip.php'); |
|
@@ -11,24 +11,24 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function lister_traductions($id_trad, $objet) { |
| 18 | - $table_objet_sql = table_objet_sql($objet); |
|
| 19 | - $primary = id_table_objet($objet); |
|
| 18 | + $table_objet_sql = table_objet_sql($objet); |
|
| 19 | + $primary = id_table_objet($objet); |
|
| 20 | 20 | |
| 21 | - $select = "$primary as id,lang"; |
|
| 22 | - $where = 'id_trad=' . intval($id_trad); |
|
| 23 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 24 | - $desc = $trouver_table($table_objet_sql); |
|
| 25 | - if (isset($desc['field']['statut'])) { |
|
| 26 | - $select .= ',statut'; |
|
| 27 | - $where .= ' AND statut!='.sql_quote('poubelle'); |
|
| 28 | - } |
|
| 21 | + $select = "$primary as id,lang"; |
|
| 22 | + $where = 'id_trad=' . intval($id_trad); |
|
| 23 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 24 | + $desc = $trouver_table($table_objet_sql); |
|
| 25 | + if (isset($desc['field']['statut'])) { |
|
| 26 | + $select .= ',statut'; |
|
| 27 | + $where .= ' AND statut!='.sql_quote('poubelle'); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $rows = sql_allfetsel($select, $table_objet_sql, $where); |
|
| 31 | - lang_select(); |
|
| 30 | + $rows = sql_allfetsel($select, $table_objet_sql, $where); |
|
| 31 | + lang_select(); |
|
| 32 | 32 | |
| 33 | - return $rows; |
|
| 33 | + return $rows; |
|
| 34 | 34 | } |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | $primary = id_table_objet($objet); |
| 20 | 20 | |
| 21 | 21 | $select = "$primary as id,lang"; |
| 22 | - $where = 'id_trad=' . intval($id_trad); |
|
| 23 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 22 | + $where = 'id_trad='.intval($id_trad); |
|
| 23 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 24 | 24 | $desc = $trouver_table($table_objet_sql); |
| 25 | 25 | if (isset($desc['field']['statut'])) { |
| 26 | 26 | $select .= ',statut'; |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('prive/objets/liste/auteurs_fonctions'); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/drapeau_edition'); |