@@ -16,107 +16,107 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | function decompiler_boucle($struct, $fmt='', $prof=0) |
| 18 | 18 | { |
| 19 | - $nom = $struct->id_boucle; |
|
| 20 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 21 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 22 | - $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 23 | - $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 24 | - |
|
| 25 | - $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 26 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 27 | - $struct->table_optionnelle); |
|
| 28 | - |
|
| 29 | - if ($struct->jointures_explicites) |
|
| 30 | - $type .= " " . $struct->jointures_explicites; |
|
| 31 | - if ($struct->table_optionnelle) |
|
| 32 | - $type .= "?"; |
|
| 33 | - // Revoir le cas de la boucle recursive |
|
| 34 | - |
|
| 35 | - $crit = $struct->param; |
|
| 36 | - if ($crit AND !is_array($crit[0])) { |
|
| 37 | - $type = strtolower($type) . array_shift($crit); |
|
| 38 | - } |
|
| 39 | - $crit = decompiler_criteres($struct, $fmt, $prof) ; |
|
| 40 | - |
|
| 41 | - $f = 'format_boucle_' . $fmt; |
|
| 42 | - return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
|
| 19 | + $nom = $struct->id_boucle; |
|
| 20 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 21 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 22 | + $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 23 | + $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 24 | + |
|
| 25 | + $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 26 | + $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 27 | + $struct->table_optionnelle); |
|
| 28 | + |
|
| 29 | + if ($struct->jointures_explicites) |
|
| 30 | + $type .= " " . $struct->jointures_explicites; |
|
| 31 | + if ($struct->table_optionnelle) |
|
| 32 | + $type .= "?"; |
|
| 33 | + // Revoir le cas de la boucle recursive |
|
| 34 | + |
|
| 35 | + $crit = $struct->param; |
|
| 36 | + if ($crit AND !is_array($crit[0])) { |
|
| 37 | + $type = strtolower($type) . array_shift($crit); |
|
| 38 | + } |
|
| 39 | + $crit = decompiler_criteres($struct, $fmt, $prof) ; |
|
| 40 | + |
|
| 41 | + $f = 'format_boucle_' . $fmt; |
|
| 42 | + return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function decompiler_include($struct, $fmt='', $prof=0) |
| 46 | 46 | { |
| 47 | - $res = array(); |
|
| 48 | - foreach($struct->param ? $struct->param : array() as $couple) { |
|
| 49 | - array_shift($couple); |
|
| 50 | - foreach($couple as $v) { |
|
| 51 | - $res[]= decompiler_($v, $fmt, $prof); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 55 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 56 | - $f = 'format_inclure_' . $fmt; |
|
| 57 | - return $f($file, $res, $prof); |
|
| 47 | + $res = array(); |
|
| 48 | + foreach($struct->param ? $struct->param : array() as $couple) { |
|
| 49 | + array_shift($couple); |
|
| 50 | + foreach($couple as $v) { |
|
| 51 | + $res[]= decompiler_($v, $fmt, $prof); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + $file = is_string($struct->texte) ? $struct->texte : |
|
| 55 | + decompiler_($struct->texte, $fmt, $prof); |
|
| 56 | + $f = 'format_inclure_' . $fmt; |
|
| 57 | + return $f($file, $res, $prof); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function decompiler_texte($struct, $fmt='', $prof=0) |
| 61 | 61 | { |
| 62 | - $f = 'format_texte_' . $fmt; |
|
| 63 | - return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 62 | + $f = 'format_texte_' . $fmt; |
|
| 63 | + return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function decompiler_polyglotte($struct, $fmt='', $prof=0) |
| 67 | 67 | { |
| 68 | - $f = 'format_polyglotte_' . $fmt; |
|
| 69 | - return $f($struct->traductions, $prof); |
|
| 68 | + $f = 'format_polyglotte_' . $fmt; |
|
| 69 | + return $f($struct->traductions, $prof); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | function decompiler_idiome($struct, $fmt='', $prof=0) |
| 73 | 73 | { |
| 74 | - $args = array(); |
|
| 75 | - foreach ($struct->arg as $k => $v) { |
|
| 76 | - $args[$k]= public_decompiler($v, $fmt, $prof); |
|
| 77 | - } |
|
| 74 | + $args = array(); |
|
| 75 | + foreach ($struct->arg as $k => $v) { |
|
| 76 | + $args[$k]= public_decompiler($v, $fmt, $prof); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 79 | + $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 80 | 80 | |
| 81 | - $f = 'format_idiome_' . $fmt; |
|
| 82 | - return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 81 | + $f = 'format_idiome_' . $fmt; |
|
| 82 | + return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function decompiler_champ($struct, $fmt='', $prof=0) |
| 86 | 86 | { |
| 87 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 88 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 89 | - $args = $filtres = ''; |
|
| 90 | - if ($p = $struct->param) { |
|
| 91 | - if ($p[0][0]==='') |
|
| 92 | - $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 93 | - $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 94 | - } |
|
| 95 | - $f = 'format_champ_' . $fmt; |
|
| 96 | - return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 87 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 88 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 89 | + $args = $filtres = ''; |
|
| 90 | + if ($p = $struct->param) { |
|
| 91 | + if ($p[0][0]==='') |
|
| 92 | + $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 93 | + $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 94 | + } |
|
| 95 | + $f = 'format_champ_' . $fmt; |
|
| 96 | + return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | function decompiler_liste($sources, $fmt='', $prof=0) { |
| 100 | - if (!is_array($sources)) return ''; |
|
| 101 | - $f = 'format_liste_' . $fmt; |
|
| 102 | - $res = ''; |
|
| 103 | - foreach($sources as $arg) { |
|
| 104 | - if (!is_array($arg)) { |
|
| 105 | - continue; // ne devrait pas arriver. |
|
| 106 | - } else {$r = array_shift($arg);} |
|
| 107 | - $args = array(); |
|
| 108 | - foreach($arg as $v) { |
|
| 109 | - // cas des arguments entoures de ' ou " |
|
| 110 | - if ((count($v) == 1) |
|
| 111 | - AND $v[0]->type=='texte' |
|
| 112 | - AND (strlen($v[0]->apres) == 1) |
|
| 113 | - AND $v[0]->apres == $v[0]->avant) |
|
| 114 | - $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 115 | - else $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 116 | - } |
|
| 117 | - if (($r!=='') OR $args) $res .= $f($r, $args, $prof); |
|
| 118 | - } |
|
| 119 | - return $res; |
|
| 100 | + if (!is_array($sources)) return ''; |
|
| 101 | + $f = 'format_liste_' . $fmt; |
|
| 102 | + $res = ''; |
|
| 103 | + foreach($sources as $arg) { |
|
| 104 | + if (!is_array($arg)) { |
|
| 105 | + continue; // ne devrait pas arriver. |
|
| 106 | + } else {$r = array_shift($arg);} |
|
| 107 | + $args = array(); |
|
| 108 | + foreach($arg as $v) { |
|
| 109 | + // cas des arguments entoures de ' ou " |
|
| 110 | + if ((count($v) == 1) |
|
| 111 | + AND $v[0]->type=='texte' |
|
| 112 | + AND (strlen($v[0]->apres) == 1) |
|
| 113 | + AND $v[0]->apres == $v[0]->avant) |
|
| 114 | + $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 115 | + else $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 116 | + } |
|
| 117 | + if (($r!=='') OR $args) $res .= $f($r, $args, $prof); |
|
| 118 | + } |
|
| 119 | + return $res; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | // Decompilation des criteres: on triche et on deroge: |
@@ -124,76 +124,76 @@ discard block |
||
| 124 | 124 | // - le champ apres signale le critere {"separateur"} ou {'separateur'} |
| 125 | 125 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 126 | 126 | function decompiler_criteres($boucle, $fmt='', $prof=0) { |
| 127 | - $sources = $boucle->param; |
|
| 128 | - if (!is_array($sources)) return ''; |
|
| 129 | - $res = ''; |
|
| 130 | - $f = 'format_critere_' . $fmt; |
|
| 131 | - foreach($sources as $crit) { |
|
| 132 | - if (!is_array($crit)) continue; // boucle recursive |
|
| 133 | - array_shift($crit); |
|
| 134 | - $args = array(); |
|
| 135 | - foreach($crit as $i => $v) { |
|
| 136 | - if ((count($v) == 1) |
|
| 137 | - AND $v[0]->type=='texte' |
|
| 138 | - AND $v[0]->apres) |
|
| 139 | - $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 140 | - else { |
|
| 141 | - $res2 = array(); |
|
| 142 | - foreach($v as $k => $p) { |
|
| 143 | - if (isset($p->type) |
|
| 144 | - AND function_exists($d = 'decompiler_' . $p->type)) { |
|
| 145 | - $r = $d($p, $fmt, (0-$prof), @$v[$k+1]); |
|
| 146 | - $res2[]= array($p->type, $r); |
|
| 147 | - } else spip_log("critere $i / $k mal forme"); |
|
| 148 | - } |
|
| 149 | - $args[]= $res2; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - $res .= $f($args); |
|
| 153 | - } |
|
| 154 | - return $res; |
|
| 127 | + $sources = $boucle->param; |
|
| 128 | + if (!is_array($sources)) return ''; |
|
| 129 | + $res = ''; |
|
| 130 | + $f = 'format_critere_' . $fmt; |
|
| 131 | + foreach($sources as $crit) { |
|
| 132 | + if (!is_array($crit)) continue; // boucle recursive |
|
| 133 | + array_shift($crit); |
|
| 134 | + $args = array(); |
|
| 135 | + foreach($crit as $i => $v) { |
|
| 136 | + if ((count($v) == 1) |
|
| 137 | + AND $v[0]->type=='texte' |
|
| 138 | + AND $v[0]->apres) |
|
| 139 | + $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 140 | + else { |
|
| 141 | + $res2 = array(); |
|
| 142 | + foreach($v as $k => $p) { |
|
| 143 | + if (isset($p->type) |
|
| 144 | + AND function_exists($d = 'decompiler_' . $p->type)) { |
|
| 145 | + $r = $d($p, $fmt, (0-$prof), @$v[$k+1]); |
|
| 146 | + $res2[]= array($p->type, $r); |
|
| 147 | + } else spip_log("critere $i / $k mal forme"); |
|
| 148 | + } |
|
| 149 | + $args[]= $res2; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + $res .= $f($args); |
|
| 153 | + } |
|
| 154 | + return $res; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | function decompiler_($liste, $fmt='', $prof=0) |
| 159 | 159 | { |
| 160 | - if (!is_array($liste)) return ''; |
|
| 161 | - $prof2 = ($prof < 0) ? ($prof-1) : ($prof+1); |
|
| 162 | - $contenu = array(); |
|
| 163 | - foreach($liste as $k => $p) { |
|
| 164 | - if (!isset($p->type)) continue; #?????? |
|
| 165 | - $d = 'decompiler_' . $p->type; |
|
| 166 | - $next = isset($liste[$k+1]) ? $liste[$k+1] : false; |
|
| 167 | - // Forcer le champ etendu si son source (pas les reecritures) |
|
| 168 | - // contenait des args et s'il est suivi d'espaces, |
|
| 169 | - // le champ simple les eliminant est un bug helas perenne. |
|
| 170 | - |
|
| 171 | - if ($next |
|
| 172 | - AND ($next->type == 'texte') |
|
| 173 | - AND $p->type == 'champ' |
|
| 174 | - AND !$p->apres |
|
| 175 | - AND !$p->avant |
|
| 176 | - AND $p->fonctions) { |
|
| 177 | - $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 178 | - if ($n) { |
|
| 179 | - $champ = new Texte; |
|
| 180 | - $champ->texte = substr($next->texte, 0, $n); |
|
| 181 | - $champ->ligne = $p->ligne; |
|
| 182 | - $p->apres = array($champ); |
|
| 183 | - $next->texte = substr($next->texte, $n); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
|
| 187 | - |
|
| 188 | - } |
|
| 189 | - $f = 'format_suite_' . $fmt; |
|
| 190 | - return $f($contenu); |
|
| 160 | + if (!is_array($liste)) return ''; |
|
| 161 | + $prof2 = ($prof < 0) ? ($prof-1) : ($prof+1); |
|
| 162 | + $contenu = array(); |
|
| 163 | + foreach($liste as $k => $p) { |
|
| 164 | + if (!isset($p->type)) continue; #?????? |
|
| 165 | + $d = 'decompiler_' . $p->type; |
|
| 166 | + $next = isset($liste[$k+1]) ? $liste[$k+1] : false; |
|
| 167 | + // Forcer le champ etendu si son source (pas les reecritures) |
|
| 168 | + // contenait des args et s'il est suivi d'espaces, |
|
| 169 | + // le champ simple les eliminant est un bug helas perenne. |
|
| 170 | + |
|
| 171 | + if ($next |
|
| 172 | + AND ($next->type == 'texte') |
|
| 173 | + AND $p->type == 'champ' |
|
| 174 | + AND !$p->apres |
|
| 175 | + AND !$p->avant |
|
| 176 | + AND $p->fonctions) { |
|
| 177 | + $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 178 | + if ($n) { |
|
| 179 | + $champ = new Texte; |
|
| 180 | + $champ->texte = substr($next->texte, 0, $n); |
|
| 181 | + $champ->ligne = $p->ligne; |
|
| 182 | + $p->apres = array($champ); |
|
| 183 | + $next->texte = substr($next->texte, $n); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
|
| 187 | + |
|
| 188 | + } |
|
| 189 | + $f = 'format_suite_' . $fmt; |
|
| 190 | + return $f($contenu); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | function public_decompiler($liste, $fmt='', $prof=0, $quoi='') |
| 194 | 194 | { |
| 195 | - if (!include_spip('public/format_' . $fmt)) return "'$fmt'?"; |
|
| 196 | - $f = 'decompiler_' . $quoi; |
|
| 197 | - return $f($liste, $fmt, $prof); |
|
| 195 | + if (!include_spip('public/format_' . $fmt)) return "'$fmt'?"; |
|
| 196 | + $f = 'decompiler_' . $quoi; |
|
| 197 | + return $f($liste, $fmt, $prof); |
|
| 198 | 198 | } |
| 199 | 199 | ?> |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 16 | 16 | |
| 17 | -function decompiler_boucle($struct, $fmt='', $prof=0) |
|
| 17 | +function decompiler_boucle($struct, $fmt = '', $prof = 0) |
|
| 18 | 18 | { |
| 19 | 19 | $nom = $struct->id_boucle; |
| 20 | 20 | $avant = decompiler_($struct->avant, $fmt, $prof); |
@@ -23,98 +23,96 @@ discard block |
||
| 23 | 23 | $milieu = decompiler_($struct->milieu, $fmt, $prof); |
| 24 | 24 | |
| 25 | 25 | $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
| 26 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 27 | - $struct->table_optionnelle); |
|
| 26 | + $type .= ($struct->type_requete ? $struct->type_requete : $struct->table_optionnelle); |
|
| 28 | 27 | |
| 29 | 28 | if ($struct->jointures_explicites) |
| 30 | - $type .= " " . $struct->jointures_explicites; |
|
| 29 | + $type .= " ".$struct->jointures_explicites; |
|
| 31 | 30 | if ($struct->table_optionnelle) |
| 32 | 31 | $type .= "?"; |
| 33 | 32 | // Revoir le cas de la boucle recursive |
| 34 | 33 | |
| 35 | 34 | $crit = $struct->param; |
| 36 | 35 | if ($crit AND !is_array($crit[0])) { |
| 37 | - $type = strtolower($type) . array_shift($crit); |
|
| 36 | + $type = strtolower($type).array_shift($crit); |
|
| 38 | 37 | } |
| 39 | - $crit = decompiler_criteres($struct, $fmt, $prof) ; |
|
| 38 | + $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 40 | 39 | |
| 41 | - $f = 'format_boucle_' . $fmt; |
|
| 40 | + $f = 'format_boucle_'.$fmt; |
|
| 42 | 41 | return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | -function decompiler_include($struct, $fmt='', $prof=0) |
|
| 44 | +function decompiler_include($struct, $fmt = '', $prof = 0) |
|
| 46 | 45 | { |
| 47 | 46 | $res = array(); |
| 48 | - foreach($struct->param ? $struct->param : array() as $couple) { |
|
| 47 | + foreach ($struct->param ? $struct->param : array() as $couple) { |
|
| 49 | 48 | array_shift($couple); |
| 50 | - foreach($couple as $v) { |
|
| 51 | - $res[]= decompiler_($v, $fmt, $prof); |
|
| 49 | + foreach ($couple as $v) { |
|
| 50 | + $res[] = decompiler_($v, $fmt, $prof); |
|
| 52 | 51 | } |
| 53 | 52 | } |
| 54 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 55 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 56 | - $f = 'format_inclure_' . $fmt; |
|
| 53 | + $file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof); |
|
| 54 | + $f = 'format_inclure_'.$fmt; |
|
| 57 | 55 | return $f($file, $res, $prof); |
| 58 | 56 | } |
| 59 | 57 | |
| 60 | -function decompiler_texte($struct, $fmt='', $prof=0) |
|
| 58 | +function decompiler_texte($struct, $fmt = '', $prof = 0) |
|
| 61 | 59 | { |
| 62 | - $f = 'format_texte_' . $fmt; |
|
| 60 | + $f = 'format_texte_'.$fmt; |
|
| 63 | 61 | return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | -function decompiler_polyglotte($struct, $fmt='', $prof=0) |
|
| 64 | +function decompiler_polyglotte($struct, $fmt = '', $prof = 0) |
|
| 67 | 65 | { |
| 68 | - $f = 'format_polyglotte_' . $fmt; |
|
| 66 | + $f = 'format_polyglotte_'.$fmt; |
|
| 69 | 67 | return $f($struct->traductions, $prof); |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | -function decompiler_idiome($struct, $fmt='', $prof=0) |
|
| 70 | +function decompiler_idiome($struct, $fmt = '', $prof = 0) |
|
| 73 | 71 | { |
| 74 | 72 | $args = array(); |
| 75 | 73 | foreach ($struct->arg as $k => $v) { |
| 76 | - $args[$k]= public_decompiler($v, $fmt, $prof); |
|
| 74 | + $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 77 | 75 | } |
| 78 | 76 | |
| 79 | - $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 77 | + $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 80 | 78 | |
| 81 | - $f = 'format_idiome_' . $fmt; |
|
| 79 | + $f = 'format_idiome_'.$fmt; |
|
| 82 | 80 | return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
| 83 | 81 | } |
| 84 | 82 | |
| 85 | -function decompiler_champ($struct, $fmt='', $prof=0) |
|
| 83 | +function decompiler_champ($struct, $fmt = '', $prof = 0) |
|
| 86 | 84 | { |
| 87 | 85 | $avant = decompiler_($struct->avant, $fmt, $prof); |
| 88 | 86 | $apres = decompiler_($struct->apres, $fmt, $prof); |
| 89 | 87 | $args = $filtres = ''; |
| 90 | 88 | if ($p = $struct->param) { |
| 91 | - if ($p[0][0]==='') |
|
| 89 | + if ($p[0][0] === '') |
|
| 92 | 90 | $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
| 93 | 91 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 94 | 92 | } |
| 95 | - $f = 'format_champ_' . $fmt; |
|
| 93 | + $f = 'format_champ_'.$fmt; |
|
| 96 | 94 | return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
| 97 | 95 | } |
| 98 | 96 | |
| 99 | -function decompiler_liste($sources, $fmt='', $prof=0) { |
|
| 97 | +function decompiler_liste($sources, $fmt = '', $prof = 0) { |
|
| 100 | 98 | if (!is_array($sources)) return ''; |
| 101 | - $f = 'format_liste_' . $fmt; |
|
| 99 | + $f = 'format_liste_'.$fmt; |
|
| 102 | 100 | $res = ''; |
| 103 | - foreach($sources as $arg) { |
|
| 104 | - if (!is_array($arg)) { |
|
| 101 | + foreach ($sources as $arg) { |
|
| 102 | + if (!is_array($arg)) { |
|
| 105 | 103 | continue; // ne devrait pas arriver. |
| 106 | - } else {$r = array_shift($arg);} |
|
| 104 | + } else {$r = array_shift($arg); } |
|
| 107 | 105 | $args = array(); |
| 108 | - foreach($arg as $v) { |
|
| 106 | + foreach ($arg as $v) { |
|
| 109 | 107 | // cas des arguments entoures de ' ou " |
| 110 | 108 | if ((count($v) == 1) |
| 111 | - AND $v[0]->type=='texte' |
|
| 109 | + AND $v[0]->type == 'texte' |
|
| 112 | 110 | AND (strlen($v[0]->apres) == 1) |
| 113 | 111 | AND $v[0]->apres == $v[0]->avant) |
| 114 | - $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 115 | - else $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 112 | + $args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres; |
|
| 113 | + else $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 116 | 114 | } |
| 117 | - if (($r!=='') OR $args) $res .= $f($r, $args, $prof); |
|
| 115 | + if (($r !== '') OR $args) $res .= $f($r, $args, $prof); |
|
| 118 | 116 | } |
| 119 | 117 | return $res; |
| 120 | 118 | } |
@@ -123,30 +121,30 @@ discard block |
||
| 123 | 121 | // - le phraseur fournit un bout du source en plus de la compil |
| 124 | 122 | // - le champ apres signale le critere {"separateur"} ou {'separateur'} |
| 125 | 123 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 126 | -function decompiler_criteres($boucle, $fmt='', $prof=0) { |
|
| 124 | +function decompiler_criteres($boucle, $fmt = '', $prof = 0) { |
|
| 127 | 125 | $sources = $boucle->param; |
| 128 | 126 | if (!is_array($sources)) return ''; |
| 129 | 127 | $res = ''; |
| 130 | - $f = 'format_critere_' . $fmt; |
|
| 131 | - foreach($sources as $crit) { |
|
| 128 | + $f = 'format_critere_'.$fmt; |
|
| 129 | + foreach ($sources as $crit) { |
|
| 132 | 130 | if (!is_array($crit)) continue; // boucle recursive |
| 133 | 131 | array_shift($crit); |
| 134 | 132 | $args = array(); |
| 135 | - foreach($crit as $i => $v) { |
|
| 133 | + foreach ($crit as $i => $v) { |
|
| 136 | 134 | if ((count($v) == 1) |
| 137 | - AND $v[0]->type=='texte' |
|
| 135 | + AND $v[0]->type == 'texte' |
|
| 138 | 136 | AND $v[0]->apres) |
| 139 | - $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 137 | + $args[] = array(array('texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres))); |
|
| 140 | 138 | else { |
| 141 | 139 | $res2 = array(); |
| 142 | - foreach($v as $k => $p) { |
|
| 140 | + foreach ($v as $k => $p) { |
|
| 143 | 141 | if (isset($p->type) |
| 144 | - AND function_exists($d = 'decompiler_' . $p->type)) { |
|
| 145 | - $r = $d($p, $fmt, (0-$prof), @$v[$k+1]); |
|
| 146 | - $res2[]= array($p->type, $r); |
|
| 142 | + AND function_exists($d = 'decompiler_'.$p->type)) { |
|
| 143 | + $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
|
| 144 | + $res2[] = array($p->type, $r); |
|
| 147 | 145 | } else spip_log("critere $i / $k mal forme"); |
| 148 | 146 | } |
| 149 | - $args[]= $res2; |
|
| 147 | + $args[] = $res2; |
|
| 150 | 148 | } |
| 151 | 149 | } |
| 152 | 150 | $res .= $f($args); |
@@ -155,15 +153,15 @@ discard block |
||
| 155 | 153 | } |
| 156 | 154 | |
| 157 | 155 | |
| 158 | -function decompiler_($liste, $fmt='', $prof=0) |
|
| 156 | +function decompiler_($liste, $fmt = '', $prof = 0) |
|
| 159 | 157 | { |
| 160 | 158 | if (!is_array($liste)) return ''; |
| 161 | - $prof2 = ($prof < 0) ? ($prof-1) : ($prof+1); |
|
| 159 | + $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 162 | 160 | $contenu = array(); |
| 163 | - foreach($liste as $k => $p) { |
|
| 161 | + foreach ($liste as $k => $p) { |
|
| 164 | 162 | if (!isset($p->type)) continue; #?????? |
| 165 | - $d = 'decompiler_' . $p->type; |
|
| 166 | - $next = isset($liste[$k+1]) ? $liste[$k+1] : false; |
|
| 163 | + $d = 'decompiler_'.$p->type; |
|
| 164 | + $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
|
| 167 | 165 | // Forcer le champ etendu si son source (pas les reecritures) |
| 168 | 166 | // contenait des args et s'il est suivi d'espaces, |
| 169 | 167 | // le champ simple les eliminant est un bug helas perenne. |
@@ -175,7 +173,7 @@ discard block |
||
| 175 | 173 | AND !$p->avant |
| 176 | 174 | AND $p->fonctions) { |
| 177 | 175 | $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
| 178 | - if ($n) { |
|
| 176 | + if ($n) { |
|
| 179 | 177 | $champ = new Texte; |
| 180 | 178 | $champ->texte = substr($next->texte, 0, $n); |
| 181 | 179 | $champ->ligne = $p->ligne; |
@@ -186,14 +184,14 @@ discard block |
||
| 186 | 184 | $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
| 187 | 185 | |
| 188 | 186 | } |
| 189 | - $f = 'format_suite_' . $fmt; |
|
| 187 | + $f = 'format_suite_'.$fmt; |
|
| 190 | 188 | return $f($contenu); |
| 191 | 189 | } |
| 192 | 190 | |
| 193 | -function public_decompiler($liste, $fmt='', $prof=0, $quoi='') |
|
| 191 | +function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') |
|
| 194 | 192 | { |
| 195 | - if (!include_spip('public/format_' . $fmt)) return "'$fmt'?"; |
|
| 196 | - $f = 'decompiler_' . $quoi; |
|
| 193 | + if (!include_spip('public/format_'.$fmt)) return "'$fmt'?"; |
|
| 194 | + $f = 'decompiler_'.$quoi; |
|
| 197 | 195 | return $f($liste, $fmt, $prof); |
| 198 | 196 | } |
| 199 | 197 | ?> |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 16 | 18 | |
@@ -26,10 +28,12 @@ discard block |
||
| 26 | 28 | $type .= ($struct->type_requete ? $struct->type_requete : |
| 27 | 29 | $struct->table_optionnelle); |
| 28 | 30 | |
| 29 | - if ($struct->jointures_explicites) |
|
| 30 | - $type .= " " . $struct->jointures_explicites; |
|
| 31 | - if ($struct->table_optionnelle) |
|
| 32 | - $type .= "?"; |
|
| 31 | + if ($struct->jointures_explicites) { |
|
| 32 | + $type .= " " . $struct->jointures_explicites; |
|
| 33 | + } |
|
| 34 | + if ($struct->table_optionnelle) { |
|
| 35 | + $type .= "?"; |
|
| 36 | + } |
|
| 33 | 37 | // Revoir le cas de la boucle recursive |
| 34 | 38 | |
| 35 | 39 | $crit = $struct->param; |
@@ -88,8 +92,9 @@ discard block |
||
| 88 | 92 | $apres = decompiler_($struct->apres, $fmt, $prof); |
| 89 | 93 | $args = $filtres = ''; |
| 90 | 94 | if ($p = $struct->param) { |
| 91 | - if ($p[0][0]==='') |
|
| 92 | - $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 95 | + if ($p[0][0]==='') { |
|
| 96 | + $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 97 | + } |
|
| 93 | 98 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 94 | 99 | } |
| 95 | 100 | $f = 'format_champ_' . $fmt; |
@@ -97,7 +102,9 @@ discard block |
||
| 97 | 102 | } |
| 98 | 103 | |
| 99 | 104 | function decompiler_liste($sources, $fmt='', $prof=0) { |
| 100 | - if (!is_array($sources)) return ''; |
|
| 105 | + if (!is_array($sources)) { |
|
| 106 | + return ''; |
|
| 107 | + } |
|
| 101 | 108 | $f = 'format_liste_' . $fmt; |
| 102 | 109 | $res = ''; |
| 103 | 110 | foreach($sources as $arg) { |
@@ -110,11 +117,15 @@ discard block |
||
| 110 | 117 | if ((count($v) == 1) |
| 111 | 118 | AND $v[0]->type=='texte' |
| 112 | 119 | AND (strlen($v[0]->apres) == 1) |
| 113 | - AND $v[0]->apres == $v[0]->avant) |
|
| 114 | - $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 115 | - else $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 120 | + AND $v[0]->apres == $v[0]->avant) { |
|
| 121 | + $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 122 | + } else { |
|
| 123 | + $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + if (($r!=='') OR $args) { |
|
| 127 | + $res .= $f($r, $args, $prof); |
|
| 116 | 128 | } |
| 117 | - if (($r!=='') OR $args) $res .= $f($r, $args, $prof); |
|
| 118 | 129 | } |
| 119 | 130 | return $res; |
| 120 | 131 | } |
@@ -125,26 +136,33 @@ discard block |
||
| 125 | 136 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 126 | 137 | function decompiler_criteres($boucle, $fmt='', $prof=0) { |
| 127 | 138 | $sources = $boucle->param; |
| 128 | - if (!is_array($sources)) return ''; |
|
| 139 | + if (!is_array($sources)) { |
|
| 140 | + return ''; |
|
| 141 | + } |
|
| 129 | 142 | $res = ''; |
| 130 | 143 | $f = 'format_critere_' . $fmt; |
| 131 | 144 | foreach($sources as $crit) { |
| 132 | - if (!is_array($crit)) continue; // boucle recursive |
|
| 145 | + if (!is_array($crit)) { |
|
| 146 | + continue; |
|
| 147 | + } |
|
| 148 | + // boucle recursive |
|
| 133 | 149 | array_shift($crit); |
| 134 | 150 | $args = array(); |
| 135 | 151 | foreach($crit as $i => $v) { |
| 136 | 152 | if ((count($v) == 1) |
| 137 | 153 | AND $v[0]->type=='texte' |
| 138 | - AND $v[0]->apres) |
|
| 139 | - $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 140 | - else { |
|
| 154 | + AND $v[0]->apres) { |
|
| 155 | + $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 156 | + } else { |
|
| 141 | 157 | $res2 = array(); |
| 142 | 158 | foreach($v as $k => $p) { |
| 143 | 159 | if (isset($p->type) |
| 144 | 160 | AND function_exists($d = 'decompiler_' . $p->type)) { |
| 145 | 161 | $r = $d($p, $fmt, (0-$prof), @$v[$k+1]); |
| 146 | 162 | $res2[]= array($p->type, $r); |
| 147 | - } else spip_log("critere $i / $k mal forme"); |
|
| 163 | + } else { |
|
| 164 | + spip_log("critere $i / $k mal forme"); |
|
| 165 | + } |
|
| 148 | 166 | } |
| 149 | 167 | $args[]= $res2; |
| 150 | 168 | } |
@@ -157,11 +175,16 @@ discard block |
||
| 157 | 175 | |
| 158 | 176 | function decompiler_($liste, $fmt='', $prof=0) |
| 159 | 177 | { |
| 160 | - if (!is_array($liste)) return ''; |
|
| 178 | + if (!is_array($liste)) { |
|
| 179 | + return ''; |
|
| 180 | + } |
|
| 161 | 181 | $prof2 = ($prof < 0) ? ($prof-1) : ($prof+1); |
| 162 | 182 | $contenu = array(); |
| 163 | 183 | foreach($liste as $k => $p) { |
| 164 | - if (!isset($p->type)) continue; #?????? |
|
| 184 | + if (!isset($p->type)) { |
|
| 185 | + continue; |
|
| 186 | + } |
|
| 187 | + #?????? |
|
| 165 | 188 | $d = 'decompiler_' . $p->type; |
| 166 | 189 | $next = isset($liste[$k+1]) ? $liste[$k+1] : false; |
| 167 | 190 | // Forcer le champ etendu si son source (pas les reecritures) |
@@ -192,7 +215,9 @@ discard block |
||
| 192 | 215 | |
| 193 | 216 | function public_decompiler($liste, $fmt='', $prof=0, $quoi='') |
| 194 | 217 | { |
| 195 | - if (!include_spip('public/format_' . $fmt)) return "'$fmt'?"; |
|
| 218 | + if (!include_spip('public/format_' . $fmt)) { |
|
| 219 | + return "'$fmt'?"; |
|
| 220 | + } |
|
| 196 | 221 | $f = 'decompiler_' . $quoi; |
| 197 | 222 | return $f($liste, $fmt, $prof); |
| 198 | 223 | } |
@@ -31,70 +31,70 @@ |
||
| 31 | 31 | // Cas d'une page contenant du PHP : |
| 32 | 32 | if ($page['process_ins'] != 'html') { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Teste si on a déjà évalué du PHP |
|
| 36 | - * |
|
| 37 | - * Inclure inc/lang la première fois pour définir spip_lang |
|
| 38 | - * si ça n'a pas encore été fait. |
|
| 39 | - */ |
|
| 40 | - if (!defined('_EVALUER_PAGE_PHP')) { |
|
| 41 | - define('_EVALUER_PAGE_PHP', true); |
|
| 42 | - include_spip('inc/lang'); |
|
| 43 | - } |
|
| 34 | + /** |
|
| 35 | + * Teste si on a déjà évalué du PHP |
|
| 36 | + * |
|
| 37 | + * Inclure inc/lang la première fois pour définir spip_lang |
|
| 38 | + * si ça n'a pas encore été fait. |
|
| 39 | + */ |
|
| 40 | + if (!defined('_EVALUER_PAGE_PHP')) { |
|
| 41 | + define('_EVALUER_PAGE_PHP', true); |
|
| 42 | + include_spip('inc/lang'); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // restaurer l'etat des notes avant calcul |
|
| 46 | - if (isset($page['notes']) |
|
| 47 | - AND $page['notes'] |
|
| 48 | - AND $notes = charger_fonction("notes","inc",true)){ |
|
| 49 | - $notes($page['notes'],'restaurer_etat'); |
|
| 50 | - } |
|
| 51 | - ob_start(); |
|
| 52 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 53 | - $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
|
| 45 | + // restaurer l'etat des notes avant calcul |
|
| 46 | + if (isset($page['notes']) |
|
| 47 | + AND $page['notes'] |
|
| 48 | + AND $notes = charger_fonction("notes","inc",true)){ |
|
| 49 | + $notes($page['notes'],'restaurer_etat'); |
|
| 50 | + } |
|
| 51 | + ob_start(); |
|
| 52 | + if (strpos($page['texte'],'?xml')!==false) |
|
| 53 | + $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
|
| 54 | 54 | |
| 55 | - try { |
|
| 56 | - $res = eval('?' . '>' . $page['texte']); |
|
| 57 | - // error catching 5.2<=PHP<7 |
|
| 58 | - if ($res === false |
|
| 59 | - and function_exists('error_get_last') |
|
| 60 | - and ($erreur = error_get_last()) ) { |
|
| 61 | - $code = $page['texte']; |
|
| 62 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 63 | - if (!function_exists('numerote_ligne_php')){ |
|
| 64 | - function numerote_ligne_php($match){ |
|
| 65 | - $GLOBALS['numero_ligne_php']++; |
|
| 66 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 70 | - $code = trim(highlight_string($code,true)); |
|
| 71 | - erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 72 | - $page['texte'] = "<!-- Erreur -->"; |
|
| 73 | - } |
|
| 74 | - else { |
|
| 75 | - $page['texte'] = ob_get_contents(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - catch (Exception $e){ |
|
| 79 | - $code = $page['texte']; |
|
| 80 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 81 | - if (!function_exists('numerote_ligne_php')){ |
|
| 82 | - function numerote_ligne_php($match){ |
|
| 83 | - $GLOBALS['numero_ligne_php']++; |
|
| 84 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 88 | - $code = trim(highlight_string($code,true)); |
|
| 89 | - erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 90 | - $page['texte'] = "<!-- Erreur -->"; |
|
| 91 | - } |
|
| 92 | - ob_end_clean(); |
|
| 55 | + try { |
|
| 56 | + $res = eval('?' . '>' . $page['texte']); |
|
| 57 | + // error catching 5.2<=PHP<7 |
|
| 58 | + if ($res === false |
|
| 59 | + and function_exists('error_get_last') |
|
| 60 | + and ($erreur = error_get_last()) ) { |
|
| 61 | + $code = $page['texte']; |
|
| 62 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 63 | + if (!function_exists('numerote_ligne_php')){ |
|
| 64 | + function numerote_ligne_php($match){ |
|
| 65 | + $GLOBALS['numero_ligne_php']++; |
|
| 66 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 70 | + $code = trim(highlight_string($code,true)); |
|
| 71 | + erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 72 | + $page['texte'] = "<!-- Erreur -->"; |
|
| 73 | + } |
|
| 74 | + else { |
|
| 75 | + $page['texte'] = ob_get_contents(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + catch (Exception $e){ |
|
| 79 | + $code = $page['texte']; |
|
| 80 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 81 | + if (!function_exists('numerote_ligne_php')){ |
|
| 82 | + function numerote_ligne_php($match){ |
|
| 83 | + $GLOBALS['numero_ligne_php']++; |
|
| 84 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 88 | + $code = trim(highlight_string($code,true)); |
|
| 89 | + erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 90 | + $page['texte'] = "<!-- Erreur -->"; |
|
| 91 | + } |
|
| 92 | + ob_end_clean(); |
|
| 93 | 93 | |
| 94 | - $page['process_ins'] = 'html'; |
|
| 94 | + $page['process_ins'] = 'html'; |
|
| 95 | 95 | |
| 96 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 97 | - $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
|
| 96 | + if (strpos($page['texte'],'?xml')!==false) |
|
| 97 | + $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | page_base_href($page['texte']); |
@@ -45,55 +45,55 @@ |
||
| 45 | 45 | // restaurer l'etat des notes avant calcul |
| 46 | 46 | if (isset($page['notes']) |
| 47 | 47 | AND $page['notes'] |
| 48 | - AND $notes = charger_fonction("notes","inc",true)){ |
|
| 49 | - $notes($page['notes'],'restaurer_etat'); |
|
| 48 | + AND $notes = charger_fonction("notes", "inc", true)) { |
|
| 49 | + $notes($page['notes'], 'restaurer_etat'); |
|
| 50 | 50 | } |
| 51 | 51 | ob_start(); |
| 52 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 52 | + if (strpos($page['texte'], '?xml') !== false) |
|
| 53 | 53 | $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
| 54 | 54 | |
| 55 | 55 | try { |
| 56 | - $res = eval('?' . '>' . $page['texte']); |
|
| 56 | + $res = eval('?'.'>'.$page['texte']); |
|
| 57 | 57 | // error catching 5.2<=PHP<7 |
| 58 | 58 | if ($res === false |
| 59 | 59 | and function_exists('error_get_last') |
| 60 | - and ($erreur = error_get_last()) ) { |
|
| 60 | + and ($erreur = error_get_last())) { |
|
| 61 | 61 | $code = $page['texte']; |
| 62 | 62 | $GLOBALS['numero_ligne_php'] = 1; |
| 63 | - if (!function_exists('numerote_ligne_php')){ |
|
| 64 | - function numerote_ligne_php($match){ |
|
| 63 | + if (!function_exists('numerote_ligne_php')) { |
|
| 64 | + function numerote_ligne_php($match) { |
|
| 65 | 65 | $GLOBALS['numero_ligne_php']++; |
| 66 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 66 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 70 | - $code = trim(highlight_string($code,true)); |
|
| 71 | - erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 69 | + $code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code); |
|
| 70 | + $code = trim(highlight_string($code, true)); |
|
| 71 | + erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code, array($page['source'], '', $erreur['file'], '', $GLOBALS['spip_lang'])); |
|
| 72 | 72 | $page['texte'] = "<!-- Erreur -->"; |
| 73 | 73 | } |
| 74 | 74 | else { |
| 75 | 75 | $page['texte'] = ob_get_contents(); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - catch (Exception $e){ |
|
| 78 | + catch (Exception $e) { |
|
| 79 | 79 | $code = $page['texte']; |
| 80 | 80 | $GLOBALS['numero_ligne_php'] = 1; |
| 81 | - if (!function_exists('numerote_ligne_php')){ |
|
| 82 | - function numerote_ligne_php($match){ |
|
| 81 | + if (!function_exists('numerote_ligne_php')) { |
|
| 82 | + function numerote_ligne_php($match) { |
|
| 83 | 83 | $GLOBALS['numero_ligne_php']++; |
| 84 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 84 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/"; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 88 | - $code = trim(highlight_string($code,true)); |
|
| 89 | - erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 87 | + $code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code); |
|
| 88 | + $code = trim(highlight_string($code, true)); |
|
| 89 | + erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code, array($page['source'], '', $e->getFile(), '', $GLOBALS['spip_lang'])); |
|
| 90 | 90 | $page['texte'] = "<!-- Erreur -->"; |
| 91 | 91 | } |
| 92 | 92 | ob_end_clean(); |
| 93 | 93 | |
| 94 | 94 | $page['process_ins'] = 'html'; |
| 95 | 95 | |
| 96 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 96 | + if (strpos($page['texte'], '?xml') !== false) |
|
| 97 | 97 | $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Evaluer la page produite par un squelette |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $notes($page['notes'],'restaurer_etat'); |
| 50 | 52 | } |
| 51 | 53 | ob_start(); |
| 52 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 53 | - $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
|
| 54 | + if (strpos($page['texte'],'?xml')!==false) { |
|
| 55 | + $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | try { |
| 56 | 59 | $res = eval('?' . '>' . $page['texte']); |
@@ -70,12 +73,10 @@ discard block |
||
| 70 | 73 | $code = trim(highlight_string($code,true)); |
| 71 | 74 | erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
| 72 | 75 | $page['texte'] = "<!-- Erreur -->"; |
| 73 | - } |
|
| 74 | - else { |
|
| 76 | + } else { |
|
| 75 | 77 | $page['texte'] = ob_get_contents(); |
| 76 | 78 | } |
| 77 | - } |
|
| 78 | - catch (Exception $e){ |
|
| 79 | + } catch (Exception $e){ |
|
| 79 | 80 | $code = $page['texte']; |
| 80 | 81 | $GLOBALS['numero_ligne_php'] = 1; |
| 81 | 82 | if (!function_exists('numerote_ligne_php')){ |
@@ -93,8 +94,9 @@ discard block |
||
| 93 | 94 | |
| 94 | 95 | $page['process_ins'] = 'html'; |
| 95 | 96 | |
| 96 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 97 | - $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
|
| 98 | -} |
|
| 97 | + if (strpos($page['texte'],'?xml')!==false) { |
|
| 98 | + $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
|
| 99 | + } |
|
| 100 | + } |
|
| 99 | 101 | |
| 100 | 102 | page_base_href($page['texte']); |
@@ -14,109 +14,109 @@ |
||
| 14 | 14 | |
| 15 | 15 | function format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
| 16 | 16 | { |
| 17 | - $avant = $avant ? "<B$nom>$avant" : ""; |
|
| 18 | - $apres = $apres ? "$apres</B$nom>" : ""; |
|
| 19 | - $altern = $altern ? "$altern<//B$nom>" : ""; |
|
| 20 | - if (!$corps) $corps = " />"; else $corps = ">$corps</BOUCLE$nom>"; |
|
| 21 | - return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern"; |
|
| 17 | + $avant = $avant ? "<B$nom>$avant" : ""; |
|
| 18 | + $apres = $apres ? "$apres</B$nom>" : ""; |
|
| 19 | + $altern = $altern ? "$altern<//B$nom>" : ""; |
|
| 20 | + if (!$corps) $corps = " />"; else $corps = ">$corps</BOUCLE$nom>"; |
|
| 21 | + return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern"; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function format_inclure_html ($file, $args, $prof) |
| 25 | 25 | { |
| 26 | - if (strpos($file, '#')===false) |
|
| 27 | - $t = $file ? ("(" . $file . ")") : "" ; |
|
| 28 | - else { |
|
| 29 | - $t = "{fond=" . $file . '}'; |
|
| 30 | - } |
|
| 31 | - $args = !$args ? '' : ("{" . join(", ",$args) . "}"); |
|
| 32 | - return ("<INCLURE" . $t . $args . ">"); |
|
| 26 | + if (strpos($file, '#')===false) |
|
| 27 | + $t = $file ? ("(" . $file . ")") : "" ; |
|
| 28 | + else { |
|
| 29 | + $t = "{fond=" . $file . '}'; |
|
| 30 | + } |
|
| 31 | + $args = !$args ? '' : ("{" . join(", ",$args) . "}"); |
|
| 32 | + return ("<INCLURE" . $t . $args . ">"); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function format_polyglotte_html ($args, $prof) |
| 36 | 36 | { |
| 37 | - $contenu = array(); |
|
| 38 | - foreach($args as $l=>$t) |
|
| 39 | - $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 40 | - return ("<multi>" . join(" ", $contenu) . "</multi>"); |
|
| 37 | + $contenu = array(); |
|
| 38 | + foreach($args as $l=>$t) |
|
| 39 | + $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 40 | + return ("<multi>" . join(" ", $contenu) . "</multi>"); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function format_idiome_html ($nom, $module, $args, $filtres, $prof) |
| 44 | 44 | { |
| 45 | - foreach ($args as $k => $v) $args[$k] = "$k=$v"; |
|
| 46 | - $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 47 | - return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); |
|
| 45 | + foreach ($args as $k => $v) $args[$k] = "$k=$v"; |
|
| 46 | + $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 47 | + return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function format_champ_html ($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) |
| 51 | 51 | { |
| 52 | - $nom = "#" |
|
| 53 | - . ($boucle ? ($boucle . ":") : "") |
|
| 54 | - . $nom |
|
| 55 | - . $etoile |
|
| 56 | - . $args |
|
| 57 | - . $filtres; |
|
| 52 | + $nom = "#" |
|
| 53 | + . ($boucle ? ($boucle . ":") : "") |
|
| 54 | + . $nom |
|
| 55 | + . $etoile |
|
| 56 | + . $args |
|
| 57 | + . $filtres; |
|
| 58 | 58 | |
| 59 | - // Determiner si c'est un champ etendu, |
|
| 59 | + // Determiner si c'est un champ etendu, |
|
| 60 | 60 | |
| 61 | - $s = ($avant OR $apres OR $filtres |
|
| 62 | - OR (strpos($args, '(#') !==false)); |
|
| 61 | + $s = ($avant OR $apres OR $filtres |
|
| 62 | + OR (strpos($args, '(#') !==false)); |
|
| 63 | 63 | |
| 64 | - return ($s ? "[$avant($nom)$apres]" : $nom); |
|
| 64 | + return ($s ? "[$avant($nom)$apres]" : $nom); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | function format_critere_html ($critere) |
| 68 | 68 | { |
| 69 | - foreach ($critere as $k => $crit) { |
|
| 70 | - $crit_s = ''; |
|
| 71 | - foreach ($crit as $operande) { |
|
| 72 | - list($type, $valeur) = $operande; |
|
| 73 | - if ($type == 'champ' AND $valeur[0]=='[') { |
|
| 74 | - $valeur = substr($valeur,1,-1); |
|
| 75 | - if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) |
|
| 76 | - $valeur = substr($valeur,1,-1); |
|
| 77 | - } |
|
| 78 | - $crit_s .= $valeur; |
|
| 79 | - } |
|
| 80 | - $critere[$k] = $crit_s; |
|
| 81 | - } |
|
| 82 | - return (!$critere ? "" : ("{" . join(",", $critere) . "}")); |
|
| 69 | + foreach ($critere as $k => $crit) { |
|
| 70 | + $crit_s = ''; |
|
| 71 | + foreach ($crit as $operande) { |
|
| 72 | + list($type, $valeur) = $operande; |
|
| 73 | + if ($type == 'champ' AND $valeur[0]=='[') { |
|
| 74 | + $valeur = substr($valeur,1,-1); |
|
| 75 | + if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) |
|
| 76 | + $valeur = substr($valeur,1,-1); |
|
| 77 | + } |
|
| 78 | + $crit_s .= $valeur; |
|
| 79 | + } |
|
| 80 | + $critere[$k] = $crit_s; |
|
| 81 | + } |
|
| 82 | + return (!$critere ? "" : ("{" . join(",", $critere) . "}")); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | function format_liste_html ($fonc, $args, $prof) |
| 86 | 86 | { |
| 87 | - return ((($fonc!=='') ? "|$fonc" : $fonc) |
|
| 88 | - . (!$args ? "" : ("{" . join(",", $args) . "}"))); |
|
| 87 | + return ((($fonc!=='') ? "|$fonc" : $fonc) |
|
| 88 | + . (!$args ? "" : ("{" . join(",", $args) . "}"))); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes |
| 92 | 92 | function format_suite_html ($args) |
| 93 | 93 | { |
| 94 | - for($i=0; $i < count($args)-1; $i++) { |
|
| 95 | - list($texte, $type) = $args[$i]; |
|
| 96 | - list($texte2, $type2) = $args[$i+1]; |
|
| 97 | - if (!$texte OR !$texte2) continue; |
|
| 98 | - $c1 = substr($texte,-1); |
|
| 99 | - if ($type2 !== 'texte') { |
|
| 100 | - // si un texte se termine par ( et est suivi d'un champ |
|
| 101 | - // ou assimiles, forcer la notation pleine |
|
| 102 | - if ($c1 == '(' AND substr($texte2,0,1) == '#') |
|
| 103 | - $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 104 | - } else { |
|
| 105 | - if ($type == 'texte') continue; |
|
| 106 | - // si un champ ou assimiles est suivi d'un texte |
|
| 107 | - // et si celui-ci commence par un caractere de champ |
|
| 108 | - // forcer la notation pleine |
|
| 109 | - if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') |
|
| 110 | - OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) |
|
| 111 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - return join("", array_map('array_shift', $args)); |
|
| 94 | + for($i=0; $i < count($args)-1; $i++) { |
|
| 95 | + list($texte, $type) = $args[$i]; |
|
| 96 | + list($texte2, $type2) = $args[$i+1]; |
|
| 97 | + if (!$texte OR !$texte2) continue; |
|
| 98 | + $c1 = substr($texte,-1); |
|
| 99 | + if ($type2 !== 'texte') { |
|
| 100 | + // si un texte se termine par ( et est suivi d'un champ |
|
| 101 | + // ou assimiles, forcer la notation pleine |
|
| 102 | + if ($c1 == '(' AND substr($texte2,0,1) == '#') |
|
| 103 | + $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 104 | + } else { |
|
| 105 | + if ($type == 'texte') continue; |
|
| 106 | + // si un champ ou assimiles est suivi d'un texte |
|
| 107 | + // et si celui-ci commence par un caractere de champ |
|
| 108 | + // forcer la notation pleine |
|
| 109 | + if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') |
|
| 110 | + OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) |
|
| 111 | + $args[$i][0] = '[(' . $texte . ')]'; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + return join("", array_map('array_shift', $args)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function format_texte_html ($texte) |
| 118 | 118 | { |
| 119 | - return $texte; |
|
| 119 | + return $texte; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | ?> |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | -function format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
|
| 15 | +function format_boucle_html($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
|
| 16 | 16 | { |
| 17 | 17 | $avant = $avant ? "<B$nom>$avant" : ""; |
| 18 | 18 | $apres = $apres ? "$apres</B$nom>" : ""; |
@@ -21,36 +21,36 @@ discard block |
||
| 21 | 21 | return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern"; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -function format_inclure_html ($file, $args, $prof) |
|
| 24 | +function format_inclure_html($file, $args, $prof) |
|
| 25 | 25 | { |
| 26 | - if (strpos($file, '#')===false) |
|
| 27 | - $t = $file ? ("(" . $file . ")") : "" ; |
|
| 26 | + if (strpos($file, '#') === false) |
|
| 27 | + $t = $file ? ("(".$file.")") : ""; |
|
| 28 | 28 | else { |
| 29 | - $t = "{fond=" . $file . '}'; |
|
| 29 | + $t = "{fond=".$file.'}'; |
|
| 30 | 30 | } |
| 31 | - $args = !$args ? '' : ("{" . join(", ",$args) . "}"); |
|
| 32 | - return ("<INCLURE" . $t . $args . ">"); |
|
| 31 | + $args = !$args ? '' : ("{".join(", ", $args)."}"); |
|
| 32 | + return ("<INCLURE".$t.$args.">"); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -function format_polyglotte_html ($args, $prof) |
|
| 35 | +function format_polyglotte_html($args, $prof) |
|
| 36 | 36 | { |
| 37 | 37 | $contenu = array(); |
| 38 | - foreach($args as $l=>$t) |
|
| 39 | - $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 40 | - return ("<multi>" . join(" ", $contenu) . "</multi>"); |
|
| 38 | + foreach ($args as $l=>$t) |
|
| 39 | + $contenu[] = ($l ? "[$l]" : '').$t; |
|
| 40 | + return ("<multi>".join(" ", $contenu)."</multi>"); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function format_idiome_html ($nom, $module, $args, $filtres, $prof) |
|
| 43 | +function format_idiome_html($nom, $module, $args, $filtres, $prof) |
|
| 44 | 44 | { |
| 45 | 45 | foreach ($args as $k => $v) $args[$k] = "$k=$v"; |
| 46 | - $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 47 | - return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); |
|
| 46 | + $args = (!$args ? '' : ('{'.join(',', $args).'}')); |
|
| 47 | + return ("<:".($module ? "$module:" : "").$nom.$args.$filtres.":>"); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -function format_champ_html ($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) |
|
| 50 | +function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) |
|
| 51 | 51 | { |
| 52 | 52 | $nom = "#" |
| 53 | - . ($boucle ? ($boucle . ":") : "") |
|
| 53 | + . ($boucle ? ($boucle.":") : "") |
|
| 54 | 54 | . $nom |
| 55 | 55 | . $etoile |
| 56 | 56 | . $args |
@@ -59,62 +59,62 @@ discard block |
||
| 59 | 59 | // Determiner si c'est un champ etendu, |
| 60 | 60 | |
| 61 | 61 | $s = ($avant OR $apres OR $filtres |
| 62 | - OR (strpos($args, '(#') !==false)); |
|
| 62 | + OR (strpos($args, '(#') !== false)); |
|
| 63 | 63 | |
| 64 | 64 | return ($s ? "[$avant($nom)$apres]" : $nom); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -function format_critere_html ($critere) |
|
| 67 | +function format_critere_html($critere) |
|
| 68 | 68 | { |
| 69 | 69 | foreach ($critere as $k => $crit) { |
| 70 | 70 | $crit_s = ''; |
| 71 | 71 | foreach ($crit as $operande) { |
| 72 | 72 | list($type, $valeur) = $operande; |
| 73 | - if ($type == 'champ' AND $valeur[0]=='[') { |
|
| 74 | - $valeur = substr($valeur,1,-1); |
|
| 73 | + if ($type == 'champ' AND $valeur[0] == '[') { |
|
| 74 | + $valeur = substr($valeur, 1, -1); |
|
| 75 | 75 | if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) |
| 76 | - $valeur = substr($valeur,1,-1); |
|
| 76 | + $valeur = substr($valeur, 1, -1); |
|
| 77 | 77 | } |
| 78 | 78 | $crit_s .= $valeur; |
| 79 | 79 | } |
| 80 | 80 | $critere[$k] = $crit_s; |
| 81 | 81 | } |
| 82 | - return (!$critere ? "" : ("{" . join(",", $critere) . "}")); |
|
| 82 | + return (!$critere ? "" : ("{".join(",", $critere)."}")); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function format_liste_html ($fonc, $args, $prof) |
|
| 85 | +function format_liste_html($fonc, $args, $prof) |
|
| 86 | 86 | { |
| 87 | - return ((($fonc!=='') ? "|$fonc" : $fonc) |
|
| 88 | - . (!$args ? "" : ("{" . join(",", $args) . "}"))); |
|
| 87 | + return ((($fonc !== '') ? "|$fonc" : $fonc) |
|
| 88 | + . (!$args ? "" : ("{".join(",", $args)."}"))); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes |
| 92 | -function format_suite_html ($args) |
|
| 92 | +function format_suite_html($args) |
|
| 93 | 93 | { |
| 94 | - for($i=0; $i < count($args)-1; $i++) { |
|
| 94 | + for ($i = 0; $i < count($args) - 1; $i++) { |
|
| 95 | 95 | list($texte, $type) = $args[$i]; |
| 96 | - list($texte2, $type2) = $args[$i+1]; |
|
| 96 | + list($texte2, $type2) = $args[$i + 1]; |
|
| 97 | 97 | if (!$texte OR !$texte2) continue; |
| 98 | - $c1 = substr($texte,-1); |
|
| 98 | + $c1 = substr($texte, -1); |
|
| 99 | 99 | if ($type2 !== 'texte') { |
| 100 | 100 | // si un texte se termine par ( et est suivi d'un champ |
| 101 | 101 | // ou assimiles, forcer la notation pleine |
| 102 | - if ($c1 == '(' AND substr($texte2,0,1) == '#') |
|
| 103 | - $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 102 | + if ($c1 == '(' AND substr($texte2, 0, 1) == '#') |
|
| 103 | + $args[$i + 1][0] = '[('.$texte2.')]'; |
|
| 104 | 104 | } else { |
| 105 | 105 | if ($type == 'texte') continue; |
| 106 | 106 | // si un champ ou assimiles est suivi d'un texte |
| 107 | 107 | // et si celui-ci commence par un caractere de champ |
| 108 | 108 | // forcer la notation pleine |
| 109 | - if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') |
|
| 109 | + if (($c1 == '}' AND substr(ltrim($texte2), 0, 1) == '|') |
|
| 110 | 110 | OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) |
| 111 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 111 | + $args[$i][0] = '[('.$texte.')]'; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | return join("", array_map('array_shift', $args)); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | -function format_texte_html ($texte) |
|
| 117 | +function format_texte_html($texte) |
|
| 118 | 118 | { |
| 119 | 119 | return $texte; |
| 120 | 120 | } |
@@ -10,22 +10,28 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | function format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
| 16 | 18 | { |
| 17 | 19 | $avant = $avant ? "<B$nom>$avant" : ""; |
| 18 | 20 | $apres = $apres ? "$apres</B$nom>" : ""; |
| 19 | 21 | $altern = $altern ? "$altern<//B$nom>" : ""; |
| 20 | - if (!$corps) $corps = " />"; else $corps = ">$corps</BOUCLE$nom>"; |
|
| 22 | + if (!$corps) { |
|
| 23 | + $corps = " />"; |
|
| 24 | + } else { |
|
| 25 | + $corps = ">$corps</BOUCLE$nom>"; |
|
| 26 | + } |
|
| 21 | 27 | return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern"; |
| 22 | 28 | } |
| 23 | 29 | |
| 24 | 30 | function format_inclure_html ($file, $args, $prof) |
| 25 | 31 | { |
| 26 | - if (strpos($file, '#')===false) |
|
| 27 | - $t = $file ? ("(" . $file . ")") : "" ; |
|
| 28 | - else { |
|
| 32 | + if (strpos($file, '#')===false) { |
|
| 33 | + $t = $file ? ("(" . $file . ")") : "" ; |
|
| 34 | + } else { |
|
| 29 | 35 | $t = "{fond=" . $file . '}'; |
| 30 | 36 | } |
| 31 | 37 | $args = !$args ? '' : ("{" . join(", ",$args) . "}"); |
@@ -35,14 +41,17 @@ discard block |
||
| 35 | 41 | function format_polyglotte_html ($args, $prof) |
| 36 | 42 | { |
| 37 | 43 | $contenu = array(); |
| 38 | - foreach($args as $l=>$t) |
|
| 39 | - $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 44 | + foreach($args as $l=>$t) { |
|
| 45 | + $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 46 | + } |
|
| 40 | 47 | return ("<multi>" . join(" ", $contenu) . "</multi>"); |
| 41 | 48 | } |
| 42 | 49 | |
| 43 | 50 | function format_idiome_html ($nom, $module, $args, $filtres, $prof) |
| 44 | 51 | { |
| 45 | - foreach ($args as $k => $v) $args[$k] = "$k=$v"; |
|
| 52 | + foreach ($args as $k => $v) { |
|
| 53 | + $args[$k] = "$k=$v"; |
|
| 54 | + } |
|
| 46 | 55 | $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
| 47 | 56 | return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); |
| 48 | 57 | } |
@@ -72,8 +81,9 @@ discard block |
||
| 72 | 81 | list($type, $valeur) = $operande; |
| 73 | 82 | if ($type == 'champ' AND $valeur[0]=='[') { |
| 74 | 83 | $valeur = substr($valeur,1,-1); |
| 75 | - if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) |
|
| 76 | - $valeur = substr($valeur,1,-1); |
|
| 84 | + if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) { |
|
| 85 | + $valeur = substr($valeur,1,-1); |
|
| 86 | + } |
|
| 77 | 87 | } |
| 78 | 88 | $crit_s .= $valeur; |
| 79 | 89 | } |
@@ -94,21 +104,27 @@ discard block |
||
| 94 | 104 | for($i=0; $i < count($args)-1; $i++) { |
| 95 | 105 | list($texte, $type) = $args[$i]; |
| 96 | 106 | list($texte2, $type2) = $args[$i+1]; |
| 97 | - if (!$texte OR !$texte2) continue; |
|
| 107 | + if (!$texte OR !$texte2) { |
|
| 108 | + continue; |
|
| 109 | + } |
|
| 98 | 110 | $c1 = substr($texte,-1); |
| 99 | 111 | if ($type2 !== 'texte') { |
| 100 | 112 | // si un texte se termine par ( et est suivi d'un champ |
| 101 | 113 | // ou assimiles, forcer la notation pleine |
| 102 | - if ($c1 == '(' AND substr($texte2,0,1) == '#') |
|
| 103 | - $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 114 | + if ($c1 == '(' AND substr($texte2,0,1) == '#') { |
|
| 115 | + $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 116 | + } |
|
| 104 | 117 | } else { |
| 105 | - if ($type == 'texte') continue; |
|
| 118 | + if ($type == 'texte') { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 106 | 121 | // si un champ ou assimiles est suivi d'un texte |
| 107 | 122 | // et si celui-ci commence par un caractere de champ |
| 108 | 123 | // forcer la notation pleine |
| 109 | 124 | if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') |
| 110 | - OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) |
|
| 111 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 125 | + OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) { |
|
| 126 | + $args[$i][0] = '[(' . $texte . ')]'; |
|
| 127 | + } |
|
| 112 | 128 | } |
| 113 | 129 | } |
| 114 | 130 | return join("", array_map('array_shift', $args)); |
@@ -13,127 +13,127 @@ discard block |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | function securiser_redirect_action($redirect) { |
| 16 | - if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect))) |
|
| 17 | - and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) { |
|
| 18 | - // si l'url est une url du site, on la laisse passer sans rien faire |
|
| 19 | - // c'est encore le plus simple |
|
| 20 | - $base = $GLOBALS['meta']['adresse_site']."/"; |
|
| 21 | - if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 22 | - return $redirect; |
|
| 23 | - $base = url_de_base(); |
|
| 24 | - if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 25 | - return $redirect; |
|
| 26 | - return ""; |
|
| 27 | - } |
|
| 28 | - return $redirect; |
|
| 16 | + if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect))) |
|
| 17 | + and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) { |
|
| 18 | + // si l'url est une url du site, on la laisse passer sans rien faire |
|
| 19 | + // c'est encore le plus simple |
|
| 20 | + $base = $GLOBALS['meta']['adresse_site']."/"; |
|
| 21 | + if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 22 | + return $redirect; |
|
| 23 | + $base = url_de_base(); |
|
| 24 | + if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 25 | + return $redirect; |
|
| 26 | + return ""; |
|
| 27 | + } |
|
| 28 | + return $redirect; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // http://doc.spip.org/@traiter_appels_actions |
| 32 | 32 | function traiter_appels_actions(){ |
| 33 | - // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
|
| 34 | - if ($action = _request('action')) { |
|
| 35 | - include_spip('base/abstract_sql'); // chargement systematique pour les actions |
|
| 36 | - include_spip('inc/autoriser'); |
|
| 37 | - include_spip('inc/headers'); |
|
| 38 | - include_spip('inc/actions'); |
|
| 39 | - // des actions peuvent appeler _T |
|
| 40 | - if (!isset($GLOBALS['spip_lang'])) { |
|
| 41 | - include_spip('inc/lang'); |
|
| 42 | - utiliser_langue_visiteur(); |
|
| 43 | - } |
|
| 44 | - // si l'action est provoque par un hit {ajax} |
|
| 45 | - // il faut transmettre l'env ajax au redirect |
|
| 46 | - // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
|
| 47 | - if (($v=_request('var_ajax')) |
|
| 48 | - AND ($v!=='form') |
|
| 49 | - AND ($args = _request('var_ajax_env')) |
|
| 50 | - AND ($url = _request('redirect'))){ |
|
| 51 | - $url = parametre_url($url,'var_ajax',$v,'&'); |
|
| 52 | - $url = parametre_url($url,'var_ajax_env',$args,'&'); |
|
| 53 | - set_request('redirect',$url); |
|
| 54 | - } |
|
| 55 | - else if(_request('redirect')){ |
|
| 56 | - set_request('redirect',securiser_redirect_action(_request('redirect'))); |
|
| 57 | - } |
|
| 58 | - $var_f = charger_fonction($action, 'action'); |
|
| 59 | - $var_f(); |
|
| 60 | - if (!isset($GLOBALS['redirect'])) { |
|
| 61 | - $GLOBALS['redirect'] = _request('redirect'); |
|
| 62 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 63 | - $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 64 | - $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
|
| 65 | - } |
|
| 66 | - if ($url = $GLOBALS['redirect']) { |
|
| 67 | - // si l'action est provoque par un hit {ajax} |
|
| 68 | - // il faut transmettre l'env ajax au redirect |
|
| 69 | - // qui a pu etre defini par l'action |
|
| 70 | - if (($v=_request('var_ajax')) |
|
| 71 | - AND ($v!=='form') |
|
| 72 | - AND ($args = _request('var_ajax_env'))) { |
|
| 73 | - $url = parametre_url($url,'var_ajax',$v,'&'); |
|
| 74 | - $url = parametre_url($url,'var_ajax_env',$args,'&'); |
|
| 75 | - // passer l'ancre en variable pour pouvoir la gerer cote serveur |
|
| 76 | - $url = preg_replace(',#([^#&?]+)$,',"&var_ajax_ancre=\\1",$url); |
|
| 77 | - } |
|
| 78 | - $url = str_replace('&','&',$url); // les redirections se font en &, pas en en & |
|
| 79 | - redirige_par_entete($url); |
|
| 80 | - } |
|
| 81 | - if (!headers_sent() |
|
| 82 | - AND !ob_get_length()) |
|
| 83 | - http_status(204); // No Content |
|
| 84 | - return true; |
|
| 85 | - } |
|
| 86 | - return false; |
|
| 33 | + // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
|
| 34 | + if ($action = _request('action')) { |
|
| 35 | + include_spip('base/abstract_sql'); // chargement systematique pour les actions |
|
| 36 | + include_spip('inc/autoriser'); |
|
| 37 | + include_spip('inc/headers'); |
|
| 38 | + include_spip('inc/actions'); |
|
| 39 | + // des actions peuvent appeler _T |
|
| 40 | + if (!isset($GLOBALS['spip_lang'])) { |
|
| 41 | + include_spip('inc/lang'); |
|
| 42 | + utiliser_langue_visiteur(); |
|
| 43 | + } |
|
| 44 | + // si l'action est provoque par un hit {ajax} |
|
| 45 | + // il faut transmettre l'env ajax au redirect |
|
| 46 | + // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
|
| 47 | + if (($v=_request('var_ajax')) |
|
| 48 | + AND ($v!=='form') |
|
| 49 | + AND ($args = _request('var_ajax_env')) |
|
| 50 | + AND ($url = _request('redirect'))){ |
|
| 51 | + $url = parametre_url($url,'var_ajax',$v,'&'); |
|
| 52 | + $url = parametre_url($url,'var_ajax_env',$args,'&'); |
|
| 53 | + set_request('redirect',$url); |
|
| 54 | + } |
|
| 55 | + else if(_request('redirect')){ |
|
| 56 | + set_request('redirect',securiser_redirect_action(_request('redirect'))); |
|
| 57 | + } |
|
| 58 | + $var_f = charger_fonction($action, 'action'); |
|
| 59 | + $var_f(); |
|
| 60 | + if (!isset($GLOBALS['redirect'])) { |
|
| 61 | + $GLOBALS['redirect'] = _request('redirect'); |
|
| 62 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 63 | + $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 64 | + $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
|
| 65 | + } |
|
| 66 | + if ($url = $GLOBALS['redirect']) { |
|
| 67 | + // si l'action est provoque par un hit {ajax} |
|
| 68 | + // il faut transmettre l'env ajax au redirect |
|
| 69 | + // qui a pu etre defini par l'action |
|
| 70 | + if (($v=_request('var_ajax')) |
|
| 71 | + AND ($v!=='form') |
|
| 72 | + AND ($args = _request('var_ajax_env'))) { |
|
| 73 | + $url = parametre_url($url,'var_ajax',$v,'&'); |
|
| 74 | + $url = parametre_url($url,'var_ajax_env',$args,'&'); |
|
| 75 | + // passer l'ancre en variable pour pouvoir la gerer cote serveur |
|
| 76 | + $url = preg_replace(',#([^#&?]+)$,',"&var_ajax_ancre=\\1",$url); |
|
| 77 | + } |
|
| 78 | + $url = str_replace('&','&',$url); // les redirections se font en &, pas en en & |
|
| 79 | + redirige_par_entete($url); |
|
| 80 | + } |
|
| 81 | + if (!headers_sent() |
|
| 82 | + AND !ob_get_length()) |
|
| 83 | + http_status(204); // No Content |
|
| 84 | + return true; |
|
| 85 | + } |
|
| 86 | + return false; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | // http://doc.spip.org/@refuser_traiter_formulaire_ajax |
| 91 | 91 | function refuser_traiter_formulaire_ajax(){ |
| 92 | - if ($v=_request('var_ajax') |
|
| 93 | - AND $v=='form' |
|
| 94 | - AND $form = _request('formulaire_action') |
|
| 95 | - AND $args = _request('formulaire_action_args') |
|
| 96 | - AND decoder_contexte_ajax($args,$form)!==false) { |
|
| 97 | - // on est bien dans le contexte de traitement d'un formulaire en ajax |
|
| 98 | - // mais traiter ne veut pas |
|
| 99 | - // on le dit a la page qui va resumbit |
|
| 100 | - // sans ajax |
|
| 101 | - include_spip('inc/actions'); |
|
| 102 | - ajax_retour('noajax',false); |
|
| 103 | - exit; |
|
| 104 | - } |
|
| 92 | + if ($v=_request('var_ajax') |
|
| 93 | + AND $v=='form' |
|
| 94 | + AND $form = _request('formulaire_action') |
|
| 95 | + AND $args = _request('formulaire_action_args') |
|
| 96 | + AND decoder_contexte_ajax($args,$form)!==false) { |
|
| 97 | + // on est bien dans le contexte de traitement d'un formulaire en ajax |
|
| 98 | + // mais traiter ne veut pas |
|
| 99 | + // on le dit a la page qui va resumbit |
|
| 100 | + // sans ajax |
|
| 101 | + include_spip('inc/actions'); |
|
| 102 | + ajax_retour('noajax',false); |
|
| 103 | + exit; |
|
| 104 | + } |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // http://doc.spip.org/@traiter_appels_inclusions_ajax |
| 108 | 108 | function traiter_appels_inclusions_ajax(){ |
| 109 | - // traiter les appels de bloc ajax (ex: pagination) |
|
| 110 | - if ($v = _request('var_ajax') |
|
| 111 | - AND $v !== 'form' |
|
| 112 | - AND $args = _request('var_ajax_env')) { |
|
| 113 | - include_spip('inc/filtres'); |
|
| 114 | - include_spip('inc/actions'); |
|
| 115 | - if ($args = decoder_contexte_ajax($args) |
|
| 116 | - AND $fond = $args['fond']) { |
|
| 117 | - include_spip('public/assembler'); |
|
| 118 | - $contexte = calculer_contexte(); |
|
| 119 | - $contexte = array_merge($args, $contexte); |
|
| 120 | - $page = recuperer_fond($fond,$contexte,array('trim'=>false)); |
|
| 121 | - $texte = $page; |
|
| 122 | - if ($ancre = _request('var_ajax_ancre')){ |
|
| 123 | - // pas n'importe quoi quand meme dans la variable ! |
|
| 124 | - $ancre = str_replace(array('<','"',"'"),array('<','"',''),$ancre); |
|
| 125 | - $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - else { |
|
| 129 | - include_spip('inc/headers'); |
|
| 130 | - http_status(403); |
|
| 131 | - $texte = _L('signature ajax bloc incorrecte'); |
|
| 132 | - } |
|
| 133 | - ajax_retour($texte, false); |
|
| 134 | - return true; // on a fini le hit |
|
| 135 | - } |
|
| 136 | - return false; |
|
| 109 | + // traiter les appels de bloc ajax (ex: pagination) |
|
| 110 | + if ($v = _request('var_ajax') |
|
| 111 | + AND $v !== 'form' |
|
| 112 | + AND $args = _request('var_ajax_env')) { |
|
| 113 | + include_spip('inc/filtres'); |
|
| 114 | + include_spip('inc/actions'); |
|
| 115 | + if ($args = decoder_contexte_ajax($args) |
|
| 116 | + AND $fond = $args['fond']) { |
|
| 117 | + include_spip('public/assembler'); |
|
| 118 | + $contexte = calculer_contexte(); |
|
| 119 | + $contexte = array_merge($args, $contexte); |
|
| 120 | + $page = recuperer_fond($fond,$contexte,array('trim'=>false)); |
|
| 121 | + $texte = $page; |
|
| 122 | + if ($ancre = _request('var_ajax_ancre')){ |
|
| 123 | + // pas n'importe quoi quand meme dans la variable ! |
|
| 124 | + $ancre = str_replace(array('<','"',"'"),array('<','"',''),$ancre); |
|
| 125 | + $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + else { |
|
| 129 | + include_spip('inc/headers'); |
|
| 130 | + http_status(403); |
|
| 131 | + $texte = _L('signature ajax bloc incorrecte'); |
|
| 132 | + } |
|
| 133 | + ajax_retour($texte, false); |
|
| 134 | + return true; // on a fini le hit |
|
| 135 | + } |
|
| 136 | + return false; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // au 1er appel, traite les formulaires dynamiques charger/verifier/traiter |
@@ -142,119 +142,119 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | // http://doc.spip.org/@traiter_formulaires_dynamiques |
| 144 | 144 | function traiter_formulaires_dynamiques($get=false){ |
| 145 | - static $post = array(); |
|
| 146 | - static $done = false; |
|
| 145 | + static $post = array(); |
|
| 146 | + static $done = false; |
|
| 147 | 147 | |
| 148 | - if ($get) return $post; |
|
| 149 | - if ($done) return false; |
|
| 150 | - $done = true; |
|
| 148 | + if ($get) return $post; |
|
| 149 | + if ($done) return false; |
|
| 150 | + $done = true; |
|
| 151 | 151 | |
| 152 | - if (!($form = _request('formulaire_action') |
|
| 153 | - AND $args = _request('formulaire_action_args'))) |
|
| 154 | - return false; // le hit peut continuer normalement |
|
| 152 | + if (!($form = _request('formulaire_action') |
|
| 153 | + AND $args = _request('formulaire_action_args'))) |
|
| 154 | + return false; // le hit peut continuer normalement |
|
| 155 | 155 | |
| 156 | - include_spip('inc/filtres'); |
|
| 157 | - if (($args = decoder_contexte_ajax($args,$form))===false) { |
|
| 158 | - spip_log("signature ajax form incorrecte : $form"); |
|
| 159 | - return false; // continuons le hit comme si de rien etait |
|
| 160 | - } else { |
|
| 161 | - include_spip('inc/lang'); |
|
| 162 | - // sauvegarder la lang en cours |
|
| 163 | - $old_lang = $GLOBALS['spip_lang']; |
|
| 164 | - // changer la langue avec celle qui a cours dans le formulaire |
|
| 165 | - // on la depile de $args car c'est un argument implicite masque |
|
| 166 | - changer_langue(array_shift($args)); |
|
| 156 | + include_spip('inc/filtres'); |
|
| 157 | + if (($args = decoder_contexte_ajax($args,$form))===false) { |
|
| 158 | + spip_log("signature ajax form incorrecte : $form"); |
|
| 159 | + return false; // continuons le hit comme si de rien etait |
|
| 160 | + } else { |
|
| 161 | + include_spip('inc/lang'); |
|
| 162 | + // sauvegarder la lang en cours |
|
| 163 | + $old_lang = $GLOBALS['spip_lang']; |
|
| 164 | + // changer la langue avec celle qui a cours dans le formulaire |
|
| 165 | + // on la depile de $args car c'est un argument implicite masque |
|
| 166 | + changer_langue(array_shift($args)); |
|
| 167 | 167 | |
| 168 | 168 | |
| 169 | - // inclure mes_fonctions et autres filtres avant verifier/traiter |
|
| 170 | - include_spip('public/parametrer'); |
|
| 171 | - $verifier = charger_fonction("verifier","formulaires/$form/",true); |
|
| 172 | - $post["erreurs_$form"] = pipeline( |
|
| 173 | - 'formulaire_verifier', |
|
| 174 | - array( |
|
| 175 | - 'args'=>array('form'=>$form,'args'=>$args), |
|
| 176 | - 'data'=>$verifier?call_user_func_array($verifier,$args):array()) |
|
| 177 | - ); |
|
| 178 | - // si on ne demandait qu'une verif json |
|
| 179 | - if (_request('formulaire_action_verifier_json')){ |
|
| 180 | - include_spip('inc/json'); |
|
| 181 | - include_spip('inc/actions'); |
|
| 182 | - ajax_retour(json_encode($post["erreurs_$form"]),'text/plain'); |
|
| 183 | - return true; // on a fini le hit |
|
| 184 | - } |
|
| 185 | - $retour = ""; |
|
| 186 | - if ((count($post["erreurs_$form"])==0)){ |
|
| 187 | - $rev = ""; |
|
| 188 | - if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) |
|
| 189 | - $rev = call_user_func_array($traiter,$args); |
|
| 169 | + // inclure mes_fonctions et autres filtres avant verifier/traiter |
|
| 170 | + include_spip('public/parametrer'); |
|
| 171 | + $verifier = charger_fonction("verifier","formulaires/$form/",true); |
|
| 172 | + $post["erreurs_$form"] = pipeline( |
|
| 173 | + 'formulaire_verifier', |
|
| 174 | + array( |
|
| 175 | + 'args'=>array('form'=>$form,'args'=>$args), |
|
| 176 | + 'data'=>$verifier?call_user_func_array($verifier,$args):array()) |
|
| 177 | + ); |
|
| 178 | + // si on ne demandait qu'une verif json |
|
| 179 | + if (_request('formulaire_action_verifier_json')){ |
|
| 180 | + include_spip('inc/json'); |
|
| 181 | + include_spip('inc/actions'); |
|
| 182 | + ajax_retour(json_encode($post["erreurs_$form"]),'text/plain'); |
|
| 183 | + return true; // on a fini le hit |
|
| 184 | + } |
|
| 185 | + $retour = ""; |
|
| 186 | + if ((count($post["erreurs_$form"])==0)){ |
|
| 187 | + $rev = ""; |
|
| 188 | + if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) |
|
| 189 | + $rev = call_user_func_array($traiter,$args); |
|
| 190 | 190 | |
| 191 | - $rev = pipeline( |
|
| 192 | - 'formulaire_traiter', |
|
| 193 | - array( |
|
| 194 | - 'args'=>array('form'=>$form,'args'=>$args), |
|
| 195 | - 'data'=>$rev) |
|
| 196 | - ); |
|
| 197 | - // le retour de traiter peut avoir 3 formats |
|
| 198 | - // - simple message texte |
|
| 199 | - // - tableau a deux entrees ($editable,$message) |
|
| 200 | - // - tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) |
|
| 201 | - // le dernier format est celui conseille car il permet le pipelinage, en particulier |
|
| 202 | - // en y passant l'id de l'objet cree/modifie |
|
| 203 | - // si message_erreur est present, on considere que le traitement a echoue |
|
| 204 | - // cas du message texte simple |
|
| 205 | - if (!is_array($rev)){ |
|
| 206 | - $post["message_ok_$form"] = $rev; |
|
| 207 | - } |
|
| 208 | - // cas du tableau deux valeurs simple (ancien format, deconseille) |
|
| 209 | - elseif (count($rev)==2 |
|
| 210 | - AND !array_key_exists('message_ok',$rev) |
|
| 211 | - AND !array_key_exists('message_erreur',$rev) |
|
| 212 | - AND !array_key_exists('redirect',$rev)) { |
|
| 213 | - $post["editable_$form"] = reset($rev); |
|
| 214 | - $post["message_ok_$form"] = end($rev); |
|
| 215 | - } |
|
| 216 | - // cas du tableau explicite (conseille) |
|
| 217 | - else { |
|
| 218 | - // verifier si traiter n'a pas echoue avec une erreur : |
|
| 219 | - if (isset($rev['message_erreur'])) { |
|
| 220 | - $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur']; |
|
| 191 | + $rev = pipeline( |
|
| 192 | + 'formulaire_traiter', |
|
| 193 | + array( |
|
| 194 | + 'args'=>array('form'=>$form,'args'=>$args), |
|
| 195 | + 'data'=>$rev) |
|
| 196 | + ); |
|
| 197 | + // le retour de traiter peut avoir 3 formats |
|
| 198 | + // - simple message texte |
|
| 199 | + // - tableau a deux entrees ($editable,$message) |
|
| 200 | + // - tableau explicite ('editable'=>$editable,'message_ok'=>$message,'redirect'=>$redirect,'id_xx'=>$id_xx) |
|
| 201 | + // le dernier format est celui conseille car il permet le pipelinage, en particulier |
|
| 202 | + // en y passant l'id de l'objet cree/modifie |
|
| 203 | + // si message_erreur est present, on considere que le traitement a echoue |
|
| 204 | + // cas du message texte simple |
|
| 205 | + if (!is_array($rev)){ |
|
| 206 | + $post["message_ok_$form"] = $rev; |
|
| 207 | + } |
|
| 208 | + // cas du tableau deux valeurs simple (ancien format, deconseille) |
|
| 209 | + elseif (count($rev)==2 |
|
| 210 | + AND !array_key_exists('message_ok',$rev) |
|
| 211 | + AND !array_key_exists('message_erreur',$rev) |
|
| 212 | + AND !array_key_exists('redirect',$rev)) { |
|
| 213 | + $post["editable_$form"] = reset($rev); |
|
| 214 | + $post["message_ok_$form"] = end($rev); |
|
| 215 | + } |
|
| 216 | + // cas du tableau explicite (conseille) |
|
| 217 | + else { |
|
| 218 | + // verifier si traiter n'a pas echoue avec une erreur : |
|
| 219 | + if (isset($rev['message_erreur'])) { |
|
| 220 | + $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur']; |
|
| 221 | 221 | |
| 222 | - } |
|
| 223 | - else { |
|
| 224 | - // sinon faire ce qu'il faut : |
|
| 225 | - if (isset($rev['message_ok'])) |
|
| 226 | - $post["message_ok_$form"] = $rev['message_ok']; |
|
| 227 | - if (isset($rev['editable'])) |
|
| 228 | - $post["editable_$form"] = $rev['editable']; |
|
| 229 | - // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
|
| 230 | - // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
|
| 231 | - if (isset($rev['redirect']) AND $rev['redirect']){ |
|
| 232 | - include_spip('inc/headers'); |
|
| 233 | - list($masque,$message) = redirige_formulaire($rev['redirect'], '','ajaxform'); |
|
| 234 | - $post["message_ok_$form"] .= $message; |
|
| 235 | - $retour .= $masque; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
|
| 241 | - if (_request('var_ajax')){ |
|
| 242 | - if (find_in_path('formulaire_.php','balise/',true)) { |
|
| 243 | - include_spip('inc/actions'); |
|
| 244 | - include_spip('public/assembler'); |
|
| 245 | - array_unshift($args,$form); |
|
| 246 | - $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn',$args),false); |
|
| 247 | - // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
|
| 248 | - // sans cela le formulaire n'est pas actif apres le hit ajax |
|
| 249 | - $retour = "<br class='bugajaxie' style='display:none;'/>".$retour; |
|
| 250 | - ajax_retour($retour,false); |
|
| 251 | - return true; // on a fini le hit |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - // restaurer la lang en cours |
|
| 255 | - changer_langue($old_lang); |
|
| 256 | - } |
|
| 257 | - return false; // le hit peut continuer normalement |
|
| 222 | + } |
|
| 223 | + else { |
|
| 224 | + // sinon faire ce qu'il faut : |
|
| 225 | + if (isset($rev['message_ok'])) |
|
| 226 | + $post["message_ok_$form"] = $rev['message_ok']; |
|
| 227 | + if (isset($rev['editable'])) |
|
| 228 | + $post["editable_$form"] = $rev['editable']; |
|
| 229 | + // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
|
| 230 | + // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
|
| 231 | + if (isset($rev['redirect']) AND $rev['redirect']){ |
|
| 232 | + include_spip('inc/headers'); |
|
| 233 | + list($masque,$message) = redirige_formulaire($rev['redirect'], '','ajaxform'); |
|
| 234 | + $post["message_ok_$form"] .= $message; |
|
| 235 | + $retour .= $masque; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
|
| 241 | + if (_request('var_ajax')){ |
|
| 242 | + if (find_in_path('formulaire_.php','balise/',true)) { |
|
| 243 | + include_spip('inc/actions'); |
|
| 244 | + include_spip('public/assembler'); |
|
| 245 | + array_unshift($args,$form); |
|
| 246 | + $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn',$args),false); |
|
| 247 | + // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
|
| 248 | + // sans cela le formulaire n'est pas actif apres le hit ajax |
|
| 249 | + $retour = "<br class='bugajaxie' style='display:none;'/>".$retour; |
|
| 250 | + ajax_retour($retour,false); |
|
| 251 | + return true; // on a fini le hit |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + // restaurer la lang en cours |
|
| 255 | + changer_langue($old_lang); |
|
| 256 | + } |
|
| 257 | + return false; // le hit peut continuer normalement |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | ?> |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | 15 | function securiser_redirect_action($redirect) { |
| 16 | - if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect))) |
|
| 16 | + if ((tester_url_absolue($redirect) or preg_match(',^\w+:,', trim($redirect))) |
|
| 17 | 17 | and !defined('_AUTORISER_ACTION_ABS_REDIRECT')) { |
| 18 | 18 | // si l'url est une url du site, on la laisse passer sans rien faire |
| 19 | 19 | // c'est encore le plus simple |
| 20 | 20 | $base = $GLOBALS['meta']['adresse_site']."/"; |
| 21 | - if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 21 | + if (strlen($base) AND strncmp($redirect, $base, strlen($base)) == 0) |
|
| 22 | 22 | return $redirect; |
| 23 | 23 | $base = url_de_base(); |
| 24 | - if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 24 | + if (strlen($base) AND strncmp($redirect, $base, strlen($base)) == 0) |
|
| 25 | 25 | return $redirect; |
| 26 | 26 | return ""; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // http://doc.spip.org/@traiter_appels_actions |
| 32 | -function traiter_appels_actions(){ |
|
| 32 | +function traiter_appels_actions() { |
|
| 33 | 33 | // cas de l'appel qui renvoie une redirection (302) ou rien (204) |
| 34 | 34 | if ($action = _request('action')) { |
| 35 | 35 | include_spip('base/abstract_sql'); // chargement systematique pour les actions |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | // si l'action est provoque par un hit {ajax} |
| 45 | 45 | // il faut transmettre l'env ajax au redirect |
| 46 | 46 | // on le met avant dans la query string au cas ou l'action fait elle meme sa redirection |
| 47 | - if (($v=_request('var_ajax')) |
|
| 48 | - AND ($v!=='form') |
|
| 47 | + if (($v = _request('var_ajax')) |
|
| 48 | + AND ($v !== 'form') |
|
| 49 | 49 | AND ($args = _request('var_ajax_env')) |
| 50 | - AND ($url = _request('redirect'))){ |
|
| 51 | - $url = parametre_url($url,'var_ajax',$v,'&'); |
|
| 52 | - $url = parametre_url($url,'var_ajax_env',$args,'&'); |
|
| 53 | - set_request('redirect',$url); |
|
| 50 | + AND ($url = _request('redirect'))) { |
|
| 51 | + $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 52 | + $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 53 | + set_request('redirect', $url); |
|
| 54 | 54 | } |
| 55 | - else if(_request('redirect')){ |
|
| 56 | - set_request('redirect',securiser_redirect_action(_request('redirect'))); |
|
| 55 | + else if (_request('redirect')) { |
|
| 56 | + set_request('redirect', securiser_redirect_action(_request('redirect'))); |
|
| 57 | 57 | } |
| 58 | 58 | $var_f = charger_fonction($action, 'action'); |
| 59 | 59 | $var_f(); |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | // si l'action est provoque par un hit {ajax} |
| 68 | 68 | // il faut transmettre l'env ajax au redirect |
| 69 | 69 | // qui a pu etre defini par l'action |
| 70 | - if (($v=_request('var_ajax')) |
|
| 71 | - AND ($v!=='form') |
|
| 70 | + if (($v = _request('var_ajax')) |
|
| 71 | + AND ($v !== 'form') |
|
| 72 | 72 | AND ($args = _request('var_ajax_env'))) { |
| 73 | - $url = parametre_url($url,'var_ajax',$v,'&'); |
|
| 74 | - $url = parametre_url($url,'var_ajax_env',$args,'&'); |
|
| 73 | + $url = parametre_url($url, 'var_ajax', $v, '&'); |
|
| 74 | + $url = parametre_url($url, 'var_ajax_env', $args, '&'); |
|
| 75 | 75 | // passer l'ancre en variable pour pouvoir la gerer cote serveur |
| 76 | - $url = preg_replace(',#([^#&?]+)$,',"&var_ajax_ancre=\\1",$url); |
|
| 76 | + $url = preg_replace(',#([^#&?]+)$,', "&var_ajax_ancre=\\1", $url); |
|
| 77 | 77 | } |
| 78 | - $url = str_replace('&','&',$url); // les redirections se font en &, pas en en & |
|
| 78 | + $url = str_replace('&', '&', $url); // les redirections se font en &, pas en en & |
|
| 79 | 79 | redirige_par_entete($url); |
| 80 | 80 | } |
| 81 | 81 | if (!headers_sent() |
@@ -88,24 +88,24 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | // http://doc.spip.org/@refuser_traiter_formulaire_ajax |
| 91 | -function refuser_traiter_formulaire_ajax(){ |
|
| 92 | - if ($v=_request('var_ajax') |
|
| 93 | - AND $v=='form' |
|
| 91 | +function refuser_traiter_formulaire_ajax() { |
|
| 92 | + if ($v = _request('var_ajax') |
|
| 93 | + AND $v == 'form' |
|
| 94 | 94 | AND $form = _request('formulaire_action') |
| 95 | 95 | AND $args = _request('formulaire_action_args') |
| 96 | - AND decoder_contexte_ajax($args,$form)!==false) { |
|
| 96 | + AND decoder_contexte_ajax($args, $form) !== false) { |
|
| 97 | 97 | // on est bien dans le contexte de traitement d'un formulaire en ajax |
| 98 | 98 | // mais traiter ne veut pas |
| 99 | 99 | // on le dit a la page qui va resumbit |
| 100 | 100 | // sans ajax |
| 101 | 101 | include_spip('inc/actions'); |
| 102 | - ajax_retour('noajax',false); |
|
| 102 | + ajax_retour('noajax', false); |
|
| 103 | 103 | exit; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // http://doc.spip.org/@traiter_appels_inclusions_ajax |
| 108 | -function traiter_appels_inclusions_ajax(){ |
|
| 108 | +function traiter_appels_inclusions_ajax() { |
|
| 109 | 109 | // traiter les appels de bloc ajax (ex: pagination) |
| 110 | 110 | if ($v = _request('var_ajax') |
| 111 | 111 | AND $v !== 'form' |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | include_spip('public/assembler'); |
| 118 | 118 | $contexte = calculer_contexte(); |
| 119 | 119 | $contexte = array_merge($args, $contexte); |
| 120 | - $page = recuperer_fond($fond,$contexte,array('trim'=>false)); |
|
| 120 | + $page = recuperer_fond($fond, $contexte, array('trim'=>false)); |
|
| 121 | 121 | $texte = $page; |
| 122 | - if ($ancre = _request('var_ajax_ancre')){ |
|
| 122 | + if ($ancre = _request('var_ajax_ancre')) { |
|
| 123 | 123 | // pas n'importe quoi quand meme dans la variable ! |
| 124 | - $ancre = str_replace(array('<','"',"'"),array('<','"',''),$ancre); |
|
| 124 | + $ancre = str_replace(array('<', '"', "'"), array('<', '"', ''), $ancre); |
|
| 125 | 125 | $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | // Le 1er renvoie True si il faut faire exit a la sortie |
| 142 | 142 | |
| 143 | 143 | // http://doc.spip.org/@traiter_formulaires_dynamiques |
| 144 | -function traiter_formulaires_dynamiques($get=false){ |
|
| 144 | +function traiter_formulaires_dynamiques($get = false) { |
|
| 145 | 145 | static $post = array(); |
| 146 | 146 | static $done = false; |
| 147 | 147 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | return false; // le hit peut continuer normalement |
| 155 | 155 | |
| 156 | 156 | include_spip('inc/filtres'); |
| 157 | - if (($args = decoder_contexte_ajax($args,$form))===false) { |
|
| 157 | + if (($args = decoder_contexte_ajax($args, $form)) === false) { |
|
| 158 | 158 | spip_log("signature ajax form incorrecte : $form"); |
| 159 | 159 | return false; // continuons le hit comme si de rien etait |
| 160 | 160 | } else { |
@@ -168,30 +168,30 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // inclure mes_fonctions et autres filtres avant verifier/traiter |
| 170 | 170 | include_spip('public/parametrer'); |
| 171 | - $verifier = charger_fonction("verifier","formulaires/$form/",true); |
|
| 171 | + $verifier = charger_fonction("verifier", "formulaires/$form/", true); |
|
| 172 | 172 | $post["erreurs_$form"] = pipeline( |
| 173 | 173 | 'formulaire_verifier', |
| 174 | 174 | array( |
| 175 | - 'args'=>array('form'=>$form,'args'=>$args), |
|
| 176 | - 'data'=>$verifier?call_user_func_array($verifier,$args):array()) |
|
| 175 | + 'args'=>array('form'=>$form, 'args'=>$args), |
|
| 176 | + 'data'=>$verifier ? call_user_func_array($verifier, $args) : array()) |
|
| 177 | 177 | ); |
| 178 | 178 | // si on ne demandait qu'une verif json |
| 179 | - if (_request('formulaire_action_verifier_json')){ |
|
| 179 | + if (_request('formulaire_action_verifier_json')) { |
|
| 180 | 180 | include_spip('inc/json'); |
| 181 | 181 | include_spip('inc/actions'); |
| 182 | - ajax_retour(json_encode($post["erreurs_$form"]),'text/plain'); |
|
| 182 | + ajax_retour(json_encode($post["erreurs_$form"]), 'text/plain'); |
|
| 183 | 183 | return true; // on a fini le hit |
| 184 | 184 | } |
| 185 | 185 | $retour = ""; |
| 186 | - if ((count($post["erreurs_$form"])==0)){ |
|
| 186 | + if ((count($post["erreurs_$form"]) == 0)) { |
|
| 187 | 187 | $rev = ""; |
| 188 | - if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) |
|
| 189 | - $rev = call_user_func_array($traiter,$args); |
|
| 188 | + if ($traiter = charger_fonction("traiter", "formulaires/$form/", true)) |
|
| 189 | + $rev = call_user_func_array($traiter, $args); |
|
| 190 | 190 | |
| 191 | 191 | $rev = pipeline( |
| 192 | 192 | 'formulaire_traiter', |
| 193 | 193 | array( |
| 194 | - 'args'=>array('form'=>$form,'args'=>$args), |
|
| 194 | + 'args'=>array('form'=>$form, 'args'=>$args), |
|
| 195 | 195 | 'data'=>$rev) |
| 196 | 196 | ); |
| 197 | 197 | // le retour de traiter peut avoir 3 formats |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | // en y passant l'id de l'objet cree/modifie |
| 203 | 203 | // si message_erreur est present, on considere que le traitement a echoue |
| 204 | 204 | // cas du message texte simple |
| 205 | - if (!is_array($rev)){ |
|
| 205 | + if (!is_array($rev)) { |
|
| 206 | 206 | $post["message_ok_$form"] = $rev; |
| 207 | 207 | } |
| 208 | 208 | // cas du tableau deux valeurs simple (ancien format, deconseille) |
| 209 | - elseif (count($rev)==2 |
|
| 210 | - AND !array_key_exists('message_ok',$rev) |
|
| 211 | - AND !array_key_exists('message_erreur',$rev) |
|
| 212 | - AND !array_key_exists('redirect',$rev)) { |
|
| 209 | + elseif (count($rev) == 2 |
|
| 210 | + AND !array_key_exists('message_ok', $rev) |
|
| 211 | + AND !array_key_exists('message_erreur', $rev) |
|
| 212 | + AND !array_key_exists('redirect', $rev)) { |
|
| 213 | 213 | $post["editable_$form"] = reset($rev); |
| 214 | 214 | $post["message_ok_$form"] = end($rev); |
| 215 | 215 | } |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | $post["editable_$form"] = $rev['editable']; |
| 229 | 229 | // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
| 230 | 230 | // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
| 231 | - if (isset($rev['redirect']) AND $rev['redirect']){ |
|
| 231 | + if (isset($rev['redirect']) AND $rev['redirect']) { |
|
| 232 | 232 | include_spip('inc/headers'); |
| 233 | - list($masque,$message) = redirige_formulaire($rev['redirect'], '','ajaxform'); |
|
| 233 | + list($masque, $message) = redirige_formulaire($rev['redirect'], '', 'ajaxform'); |
|
| 234 | 234 | $post["message_ok_$form"] .= $message; |
| 235 | 235 | $retour .= $masque; |
| 236 | 236 | } |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | // si le formulaire a ete soumis en ajax, on le renvoie direct ! |
| 241 | - if (_request('var_ajax')){ |
|
| 242 | - if (find_in_path('formulaire_.php','balise/',true)) { |
|
| 241 | + if (_request('var_ajax')) { |
|
| 242 | + if (find_in_path('formulaire_.php', 'balise/', true)) { |
|
| 243 | 243 | include_spip('inc/actions'); |
| 244 | 244 | include_spip('public/assembler'); |
| 245 | - array_unshift($args,$form); |
|
| 246 | - $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn',$args),false); |
|
| 245 | + array_unshift($args, $form); |
|
| 246 | + $retour .= inclure_balise_dynamique(call_user_func_array('balise_formulaire__dyn', $args), false); |
|
| 247 | 247 | // on ajoute un br en display none en tete du retour ajax pour regler un bug dans IE6/7 |
| 248 | 248 | // sans cela le formulaire n'est pas actif apres le hit ajax |
| 249 | 249 | $retour = "<br class='bugajaxie' style='display:none;'/>".$retour; |
| 250 | - ajax_retour($retour,false); |
|
| 250 | + ajax_retour($retour, false); |
|
| 251 | 251 | return true; // on a fini le hit |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | function securiser_redirect_action($redirect) { |
| 16 | 18 | if ((tester_url_absolue($redirect) or preg_match(',^\w+:,',trim($redirect))) |
@@ -18,11 +20,13 @@ discard block |
||
| 18 | 20 | // si l'url est une url du site, on la laisse passer sans rien faire |
| 19 | 21 | // c'est encore le plus simple |
| 20 | 22 | $base = $GLOBALS['meta']['adresse_site']."/"; |
| 21 | - if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 22 | - return $redirect; |
|
| 23 | + if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) { |
|
| 24 | + return $redirect; |
|
| 25 | + } |
|
| 23 | 26 | $base = url_de_base(); |
| 24 | - if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) |
|
| 25 | - return $redirect; |
|
| 27 | + if (strlen($base) AND strncmp($redirect,$base,strlen($base))==0) { |
|
| 28 | + return $redirect; |
|
| 29 | + } |
|
| 26 | 30 | return ""; |
| 27 | 31 | } |
| 28 | 32 | return $redirect; |
@@ -51,16 +55,16 @@ discard block |
||
| 51 | 55 | $url = parametre_url($url,'var_ajax',$v,'&'); |
| 52 | 56 | $url = parametre_url($url,'var_ajax_env',$args,'&'); |
| 53 | 57 | set_request('redirect',$url); |
| 54 | - } |
|
| 55 | - else if(_request('redirect')){ |
|
| 58 | + } else if(_request('redirect')){ |
|
| 56 | 59 | set_request('redirect',securiser_redirect_action(_request('redirect'))); |
| 57 | 60 | } |
| 58 | 61 | $var_f = charger_fonction($action, 'action'); |
| 59 | 62 | $var_f(); |
| 60 | 63 | if (!isset($GLOBALS['redirect'])) { |
| 61 | 64 | $GLOBALS['redirect'] = _request('redirect'); |
| 62 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 63 | - $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 65 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 66 | + $GLOBALS['redirect'] = urldecode($GLOBALS['redirect']); |
|
| 67 | + } |
|
| 64 | 68 | $GLOBALS['redirect'] = securiser_redirect_action($GLOBALS['redirect']); |
| 65 | 69 | } |
| 66 | 70 | if ($url = $GLOBALS['redirect']) { |
@@ -79,8 +83,10 @@ discard block |
||
| 79 | 83 | redirige_par_entete($url); |
| 80 | 84 | } |
| 81 | 85 | if (!headers_sent() |
| 82 | - AND !ob_get_length()) |
|
| 83 | - http_status(204); // No Content |
|
| 86 | + AND !ob_get_length()) { |
|
| 87 | + http_status(204); |
|
| 88 | + } |
|
| 89 | + // No Content |
|
| 84 | 90 | return true; |
| 85 | 91 | } |
| 86 | 92 | return false; |
@@ -124,8 +130,7 @@ discard block |
||
| 124 | 130 | $ancre = str_replace(array('<','"',"'"),array('<','"',''),$ancre); |
| 125 | 131 | $texte = "<a href='#$ancre' name='ajax_ancre' style='display:none;'>anchor</a>".$texte; |
| 126 | 132 | } |
| 127 | - } |
|
| 128 | - else { |
|
| 133 | + } else { |
|
| 129 | 134 | include_spip('inc/headers'); |
| 130 | 135 | http_status(403); |
| 131 | 136 | $texte = _L('signature ajax bloc incorrecte'); |
@@ -145,13 +150,19 @@ discard block |
||
| 145 | 150 | static $post = array(); |
| 146 | 151 | static $done = false; |
| 147 | 152 | |
| 148 | - if ($get) return $post; |
|
| 149 | - if ($done) return false; |
|
| 153 | + if ($get) { |
|
| 154 | + return $post; |
|
| 155 | + } |
|
| 156 | + if ($done) { |
|
| 157 | + return false; |
|
| 158 | + } |
|
| 150 | 159 | $done = true; |
| 151 | 160 | |
| 152 | 161 | if (!($form = _request('formulaire_action') |
| 153 | - AND $args = _request('formulaire_action_args'))) |
|
| 154 | - return false; // le hit peut continuer normalement |
|
| 162 | + AND $args = _request('formulaire_action_args'))) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 165 | + // le hit peut continuer normalement |
|
| 155 | 166 | |
| 156 | 167 | include_spip('inc/filtres'); |
| 157 | 168 | if (($args = decoder_contexte_ajax($args,$form))===false) { |
@@ -185,8 +196,9 @@ discard block |
||
| 185 | 196 | $retour = ""; |
| 186 | 197 | if ((count($post["erreurs_$form"])==0)){ |
| 187 | 198 | $rev = ""; |
| 188 | - if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) |
|
| 189 | - $rev = call_user_func_array($traiter,$args); |
|
| 199 | + if ($traiter = charger_fonction("traiter","formulaires/$form/",true)) { |
|
| 200 | + $rev = call_user_func_array($traiter,$args); |
|
| 201 | + } |
|
| 190 | 202 | |
| 191 | 203 | $rev = pipeline( |
| 192 | 204 | 'formulaire_traiter', |
@@ -219,13 +231,14 @@ discard block |
||
| 219 | 231 | if (isset($rev['message_erreur'])) { |
| 220 | 232 | $post["erreurs_$form"]["message_erreur"] = $rev['message_erreur']; |
| 221 | 233 | |
| 222 | - } |
|
| 223 | - else { |
|
| 234 | + } else { |
|
| 224 | 235 | // sinon faire ce qu'il faut : |
| 225 | - if (isset($rev['message_ok'])) |
|
| 226 | - $post["message_ok_$form"] = $rev['message_ok']; |
|
| 227 | - if (isset($rev['editable'])) |
|
| 228 | - $post["editable_$form"] = $rev['editable']; |
|
| 236 | + if (isset($rev['message_ok'])) { |
|
| 237 | + $post["message_ok_$form"] = $rev['message_ok']; |
|
| 238 | + } |
|
| 239 | + if (isset($rev['editable'])) { |
|
| 240 | + $post["editable_$form"] = $rev['editable']; |
|
| 241 | + } |
|
| 229 | 242 | // si une redirection est demandee, appeler redirigae_formulaire qui choisira |
| 230 | 243 | // le bon mode de redirection (302 et on ne revient pas ici, ou javascript et on continue) |
| 231 | 244 | if (isset($rev['redirect']) AND $rev['redirect']){ |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | // |
| 23 | 23 | // http://doc.spip.org/@boucle_DEFAUT_dist |
| 24 | 24 | function boucle_DEFAUT_dist($id_boucle, &$boucles) { |
| 25 | - return calculer_boucle($id_boucle, $boucles); |
|
| 25 | + return calculer_boucle($id_boucle, $boucles); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | // http://doc.spip.org/@boucle_BOUCLE_dist |
| 33 | 33 | function boucle_BOUCLE_dist($id_boucle, &$boucles) { |
| 34 | 34 | |
| 35 | - return calculer_boucle($id_boucle, $boucles); |
|
| 35 | + return calculer_boucle($id_boucle, $boucles); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -41,30 +41,30 @@ discard block |
||
| 41 | 41 | // |
| 42 | 42 | // http://doc.spip.org/@boucle_HIERARCHIE_dist |
| 43 | 43 | function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { |
| 44 | - $boucle = &$boucles[$id_boucle]; |
|
| 45 | - $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 46 | - |
|
| 47 | - // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 48 | - // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 49 | - // ou {id_article} qui positionne aussi le {tout} |
|
| 50 | - |
|
| 51 | - $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 52 | - . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 53 | - . ")))\n\t\treturn '';\n\t" |
|
| 54 | - . "include_spip('inc/rubriques');\n\t" |
|
| 55 | - . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 56 | - . (isset($boucle->modificateur['tout']) ? 'true':'false') |
|
| 57 | - . ");\n\t" |
|
| 58 | - . 'if (!$hierarchie) return "";'."\n\t"; |
|
| 59 | - |
|
| 60 | - $boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 61 | - |
|
| 62 | - $order = "FIELD($id_table, \$hierarchie)"; |
|
| 63 | - if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC") |
|
| 64 | - $boucle->default_order[] = "\"$order\""; |
|
| 65 | - else |
|
| 66 | - $boucle->default_order[0] = "\"$order DESC\""; |
|
| 67 | - return calculer_boucle($id_boucle, $boucles); |
|
| 44 | + $boucle = &$boucles[$id_boucle]; |
|
| 45 | + $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 46 | + |
|
| 47 | + // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 48 | + // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 49 | + // ou {id_article} qui positionne aussi le {tout} |
|
| 50 | + |
|
| 51 | + $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 52 | + . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 53 | + . ")))\n\t\treturn '';\n\t" |
|
| 54 | + . "include_spip('inc/rubriques');\n\t" |
|
| 55 | + . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 56 | + . (isset($boucle->modificateur['tout']) ? 'true':'false') |
|
| 57 | + . ");\n\t" |
|
| 58 | + . 'if (!$hierarchie) return "";'."\n\t"; |
|
| 59 | + |
|
| 60 | + $boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 61 | + |
|
| 62 | + $order = "FIELD($id_table, \$hierarchie)"; |
|
| 63 | + if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC") |
|
| 64 | + $boucle->default_order[] = "\"$order\""; |
|
| 65 | + else |
|
| 66 | + $boucle->default_order[0] = "\"$order DESC\""; |
|
| 67 | + return calculer_boucle($id_boucle, $boucles); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | // http://doc.spip.org/@boucle_HIERARCHIE_dist |
| 43 | 43 | function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { |
| 44 | 44 | $boucle = &$boucles[$id_boucle]; |
| 45 | - $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 45 | + $id_table = $boucle->id_table.".id_rubrique"; |
|
| 46 | 46 | |
| 47 | 47 | // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
| 48 | 48 | // sauf en presence du critere {tout} (vu par phraser_html) |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | . ")))\n\t\treturn '';\n\t" |
| 54 | 54 | . "include_spip('inc/rubriques');\n\t" |
| 55 | 55 | . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
| 56 | - . (isset($boucle->modificateur['tout']) ? 'true':'false') |
|
| 56 | + . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 57 | 57 | . ");\n\t" |
| 58 | 58 | . 'if (!$hierarchie) return "";'."\n\t"; |
| 59 | 59 | |
| 60 | - $boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 60 | + $boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 61 | 61 | |
| 62 | 62 | $order = "FIELD($id_table, \$hierarchie)"; |
| 63 | 63 | if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC") |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | // Ce fichier definit les boucles standard de SPIP |
| 16 | 16 | // |
| 17 | 17 | |
| 18 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 18 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 19 | + return; |
|
| 20 | +} |
|
| 19 | 21 | |
| 20 | 22 | // |
| 21 | 23 | // Boucle standard, sans condition rajoutee |
@@ -60,10 +62,11 @@ discard block |
||
| 60 | 62 | $boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"'); |
| 61 | 63 | |
| 62 | 64 | $order = "FIELD($id_table, \$hierarchie)"; |
| 63 | - if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC") |
|
| 64 | - $boucle->default_order[] = "\"$order\""; |
|
| 65 | - else |
|
| 66 | - $boucle->default_order[0] = "\"$order DESC\""; |
|
| 65 | + if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC") { |
|
| 66 | + $boucle->default_order[] = "\"$order\""; |
|
| 67 | + } else { |
|
| 68 | + $boucle->default_order[0] = "\"$order DESC\""; |
|
| 69 | + } |
|
| 67 | 70 | return calculer_boucle($id_boucle, $boucles); |
| 68 | 71 | } |
| 69 | 72 | |
@@ -22,132 +22,132 @@ discard block |
||
| 22 | 22 | // http://doc.spip.org/@assembler |
| 23 | 23 | function assembler($fond, $connect='') { |
| 24 | 24 | |
| 25 | - // flag_preserver est modifie ici, et utilise en globale |
|
| 26 | - // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 27 | - // contexte est utilise en globale dans le formulaire d'admin |
|
| 28 | - global $flag_preserver, $use_cache, $contexte; |
|
| 29 | - |
|
| 30 | - $contexte = calculer_contexte(); |
|
| 31 | - $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 32 | - $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 33 | - // Cette fonction est utilisee deux fois |
|
| 34 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 35 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 36 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 37 | - if ($cacher) |
|
| 38 | - $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | - else |
|
| 40 | - $use_cache = -1; |
|
| 41 | - // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 42 | - if ($res) {return array('texte' => $res);} |
|
| 43 | - |
|
| 44 | - if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 45 | - |
|
| 46 | - $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 47 | - $calculer_page = true; |
|
| 48 | - |
|
| 49 | - // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 50 | - // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 51 | - // pages sont dynamiques) |
|
| 52 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 53 | - AND (!defined('_VAR_MODE') OR !_VAR_MODE) |
|
| 54 | - AND $chemin_cache |
|
| 55 | - AND isset($page['entetes']) |
|
| 56 | - AND isset($page['entetes']['Cache-Control']) |
|
| 57 | - AND strstr($page['entetes']['Cache-Control'],'max-age=') |
|
| 58 | - AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') |
|
| 59 | - ) { |
|
| 60 | - $since = preg_replace('/;.*/', '', |
|
| 61 | - $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
| 62 | - $since = str_replace('GMT', '', $since); |
|
| 63 | - if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { |
|
| 64 | - $page['status'] = 304; |
|
| 65 | - $headers_only = true; |
|
| 66 | - $calculer_page = false; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 71 | - // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 72 | - if (!$calculer_page) { |
|
| 73 | - $page['texte'] = ""; |
|
| 74 | - } else { |
|
| 75 | - // si la page est prise dans le cache |
|
| 76 | - if (!$use_cache) { |
|
| 77 | - // Informer les boutons d'admin du contexte |
|
| 78 | - // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 79 | - $contexte = $page['contexte']; |
|
| 80 | - |
|
| 81 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 82 | - // d'inversion url => objet |
|
| 83 | - // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 84 | - #unset($_SERVER['REDIRECT_url_propre']); |
|
| 85 | - #unset($_ENV['url_propre']); |
|
| 86 | - } |
|
| 87 | - else { |
|
| 88 | - // Compat ascendante : |
|
| 89 | - // 1. $contexte est global |
|
| 90 | - // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 91 | - // et calculer la page |
|
| 92 | - if (!test_espace_prive()) { |
|
| 93 | - include_spip('inc/urls'); |
|
| 94 | - list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
|
| 95 | - } |
|
| 96 | - // squelette par defaut |
|
| 97 | - if (!strlen($fond)) |
|
| 98 | - $fond = 'sommaire'; |
|
| 99 | - |
|
| 100 | - // produire la page : peut mettre a jour $lastmodified |
|
| 101 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 102 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect); |
|
| 103 | - if ($page === '') { |
|
| 104 | - $erreur = _T('info_erreur_squelette2', |
|
| 105 | - array('fichier'=>spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES)); |
|
| 106 | - erreur_squelette($erreur); |
|
| 107 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 108 | - $page = array('texte' => '', 'erreur' => $erreur); |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 113 | - |
|
| 114 | - auto_content_type($page); |
|
| 115 | - |
|
| 116 | - $flag_preserver |= headers_sent(); |
|
| 117 | - |
|
| 118 | - // Definir les entetes si ce n'est fait |
|
| 119 | - if (!$flag_preserver) { |
|
| 120 | - if ($GLOBALS['flag_ob']) { |
|
| 121 | - // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 122 | - if (trim($page['texte']) === '' |
|
| 123 | - AND _VAR_MODE != 'debug' |
|
| 124 | - AND !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 125 | - ) { |
|
| 126 | - $contexte['fond_erreur'] = $fond; |
|
| 127 | - $page = message_page_indisponible($page, $contexte); |
|
| 128 | - } |
|
| 129 | - // pas de cache client en mode 'observation' |
|
| 130 | - if (defined('_VAR_MODE') AND _VAR_MODE) { |
|
| 131 | - $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; |
|
| 132 | - $page['entetes']["Pragma"] = "no-cache"; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // Entete Last-Modified: |
|
| 139 | - // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 140 | - // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 141 | - if ($lastmodified |
|
| 142 | - AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 143 | - AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 145 | - |
|
| 146 | - // fermer la connexion apres les headers si requete HEAD |
|
| 147 | - if ($headers_only) |
|
| 148 | - $page['entetes']["Connection"] = "close"; |
|
| 149 | - |
|
| 150 | - return $page; |
|
| 25 | + // flag_preserver est modifie ici, et utilise en globale |
|
| 26 | + // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
|
| 27 | + // contexte est utilise en globale dans le formulaire d'admin |
|
| 28 | + global $flag_preserver, $use_cache, $contexte; |
|
| 29 | + |
|
| 30 | + $contexte = calculer_contexte(); |
|
| 31 | + $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 32 | + $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 33 | + // Cette fonction est utilisee deux fois |
|
| 34 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 35 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 36 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 37 | + if ($cacher) |
|
| 38 | + $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | + else |
|
| 40 | + $use_cache = -1; |
|
| 41 | + // Si un resultat est retourne, c'est un message d'impossibilite |
|
| 42 | + if ($res) {return array('texte' => $res);} |
|
| 43 | + |
|
| 44 | + if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 45 | + |
|
| 46 | + $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
|
| 47 | + $calculer_page = true; |
|
| 48 | + |
|
| 49 | + // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) |
|
| 50 | + // une perennite valide a meme reponse qu'une requete HEAD (par defaut les |
|
| 51 | + // pages sont dynamiques) |
|
| 52 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 53 | + AND (!defined('_VAR_MODE') OR !_VAR_MODE) |
|
| 54 | + AND $chemin_cache |
|
| 55 | + AND isset($page['entetes']) |
|
| 56 | + AND isset($page['entetes']['Cache-Control']) |
|
| 57 | + AND strstr($page['entetes']['Cache-Control'],'max-age=') |
|
| 58 | + AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') |
|
| 59 | + ) { |
|
| 60 | + $since = preg_replace('/;.*/', '', |
|
| 61 | + $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
|
| 62 | + $since = str_replace('GMT', '', $since); |
|
| 63 | + if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { |
|
| 64 | + $page['status'] = 304; |
|
| 65 | + $headers_only = true; |
|
| 66 | + $calculer_page = false; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + // Si requete HEAD ou Last-modified compatible, ignorer le texte |
|
| 71 | + // et pas de content-type (pour contrer le bouton admin de inc-public) |
|
| 72 | + if (!$calculer_page) { |
|
| 73 | + $page['texte'] = ""; |
|
| 74 | + } else { |
|
| 75 | + // si la page est prise dans le cache |
|
| 76 | + if (!$use_cache) { |
|
| 77 | + // Informer les boutons d'admin du contexte |
|
| 78 | + // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
|
| 79 | + $contexte = $page['contexte']; |
|
| 80 | + |
|
| 81 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 82 | + // d'inversion url => objet |
|
| 83 | + // plus necessaire si on utilise bien la fonction urls_decoder_url |
|
| 84 | + #unset($_SERVER['REDIRECT_url_propre']); |
|
| 85 | + #unset($_ENV['url_propre']); |
|
| 86 | + } |
|
| 87 | + else { |
|
| 88 | + // Compat ascendante : |
|
| 89 | + // 1. $contexte est global |
|
| 90 | + // (a evacuer car urls_decoder_url gere ce probleme ?) |
|
| 91 | + // et calculer la page |
|
| 92 | + if (!test_espace_prive()) { |
|
| 93 | + include_spip('inc/urls'); |
|
| 94 | + list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
|
| 95 | + } |
|
| 96 | + // squelette par defaut |
|
| 97 | + if (!strlen($fond)) |
|
| 98 | + $fond = 'sommaire'; |
|
| 99 | + |
|
| 100 | + // produire la page : peut mettre a jour $lastmodified |
|
| 101 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 102 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect); |
|
| 103 | + if ($page === '') { |
|
| 104 | + $erreur = _T('info_erreur_squelette2', |
|
| 105 | + array('fichier'=>spip_htmlspecialchars($fond).'.'._EXTENSION_SQUELETTES)); |
|
| 106 | + erreur_squelette($erreur); |
|
| 107 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4 |
|
| 108 | + $page = array('texte' => '', 'erreur' => $erreur); |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 113 | + |
|
| 114 | + auto_content_type($page); |
|
| 115 | + |
|
| 116 | + $flag_preserver |= headers_sent(); |
|
| 117 | + |
|
| 118 | + // Definir les entetes si ce n'est fait |
|
| 119 | + if (!$flag_preserver) { |
|
| 120 | + if ($GLOBALS['flag_ob']) { |
|
| 121 | + // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions |
|
| 122 | + if (trim($page['texte']) === '' |
|
| 123 | + AND _VAR_MODE != 'debug' |
|
| 124 | + AND !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur |
|
| 125 | + ) { |
|
| 126 | + $contexte['fond_erreur'] = $fond; |
|
| 127 | + $page = message_page_indisponible($page, $contexte); |
|
| 128 | + } |
|
| 129 | + // pas de cache client en mode 'observation' |
|
| 130 | + if (defined('_VAR_MODE') AND _VAR_MODE) { |
|
| 131 | + $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; |
|
| 132 | + $page['entetes']["Pragma"] = "no-cache"; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // Entete Last-Modified: |
|
| 139 | + // eviter d'etre incoherent en envoyant un lastmodified identique |
|
| 140 | + // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
|
| 141 | + if ($lastmodified |
|
| 142 | + AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 143 | + AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | + $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 145 | + |
|
| 146 | + // fermer la connexion apres les headers si requete HEAD |
|
| 147 | + if ($headers_only) |
|
| 148 | + $page['entetes']["Connection"] = "close"; |
|
| 149 | + |
|
| 150 | + return $page; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // |
@@ -160,17 +160,17 @@ discard block |
||
| 160 | 160 | // http://doc.spip.org/@calculer_contexte |
| 161 | 161 | function calculer_contexte() { |
| 162 | 162 | |
| 163 | - $contexte = array(); |
|
| 164 | - foreach($_GET as $var => $val) { |
|
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | - $contexte[$var] = $val; |
|
| 167 | - } |
|
| 168 | - foreach($_POST as $var => $val) { |
|
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | - $contexte[$var] = $val; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return $contexte; |
|
| 163 | + $contexte = array(); |
|
| 164 | + foreach($_GET as $var => $val) { |
|
| 165 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | + $contexte[$var] = $val; |
|
| 167 | + } |
|
| 168 | + foreach($_POST as $var => $val) { |
|
| 169 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | + $contexte[$var] = $val; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return $contexte; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | * @return array |
| 182 | 182 | */ |
| 183 | 183 | function calculer_contexte_implicite(){ |
| 184 | - static $notes = null; |
|
| 185 | - if (is_null($notes)) |
|
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 187 | - $contexte_implicite = array( |
|
| 188 | - 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 189 | - 'host' => $_SERVER['HTTP_HOST'], |
|
| 190 | - 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
|
| 191 | - 'espace' => test_espace_prive(), |
|
| 192 | - 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | - 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | - 'notes' => $notes?$notes('','contexter_cache'):'', |
|
| 195 | - 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 196 | - ); |
|
| 197 | - return $contexte_implicite; |
|
| 184 | + static $notes = null; |
|
| 185 | + if (is_null($notes)) |
|
| 186 | + $notes = charger_fonction('notes','inc',true); |
|
| 187 | + $contexte_implicite = array( |
|
| 188 | + 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
|
| 189 | + 'host' => $_SERVER['HTTP_HOST'], |
|
| 190 | + 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
|
| 191 | + 'espace' => test_espace_prive(), |
|
| 192 | + 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | + 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | + 'notes' => $notes?$notes('','contexter_cache'):'', |
|
| 195 | + 'spip_version_code' => $GLOBALS['spip_version_code'], |
|
| 196 | + ); |
|
| 197 | + return $contexte_implicite; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // |
@@ -204,47 +204,47 @@ discard block |
||
| 204 | 204 | // http://doc.spip.org/@auto_content_type |
| 205 | 205 | function auto_content_type($page) |
| 206 | 206 | { |
| 207 | - global $flag_preserver; |
|
| 208 | - if (!isset($flag_preserver)) |
|
| 209 | - { |
|
| 210 | - $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 211 | - } |
|
| 207 | + global $flag_preserver; |
|
| 208 | + if (!isset($flag_preserver)) |
|
| 209 | + { |
|
| 210 | + $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 211 | + } |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // http://doc.spip.org/@inclure_page |
| 215 | 215 | function inclure_page($fond, $contexte, $connect='') { |
| 216 | - static $cacher, $produire_page; |
|
| 217 | - global $lastmodified; |
|
| 218 | - |
|
| 219 | - // enlever le fond de contexte inclus car sinon il prend la main |
|
| 220 | - // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 221 | - // (cette precaution n'est probablement plus utile) |
|
| 222 | - unset($contexte['fond']); |
|
| 223 | - $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 224 | - $page['contexte_implicite']['cache'] = $fond; |
|
| 225 | - if (is_null($cacher)) |
|
| 226 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 227 | - // Les quatre derniers parametres sont modifies par la fonction: |
|
| 228 | - // emplacement, validite, et, s'il est valide, contenu & age |
|
| 229 | - if ($cacher) |
|
| 230 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | - else |
|
| 232 | - $use_cache = -1; |
|
| 233 | - // $res = message d'erreur : on sort de la |
|
| 234 | - if ($res) {return array('texte' => $res);} |
|
| 235 | - |
|
| 236 | - // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 237 | - // produire la page : peut mettre a jour $lastinclude |
|
| 238 | - // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 239 | - if ($use_cache) { |
|
| 240 | - if (is_null($produire_page)) |
|
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 242 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 243 | - } |
|
| 244 | - // dans tous les cas, mettre a jour $lastmodified |
|
| 245 | - $lastmodified = max($lastmodified, $lastinclude); |
|
| 246 | - |
|
| 247 | - return $page; |
|
| 216 | + static $cacher, $produire_page; |
|
| 217 | + global $lastmodified; |
|
| 218 | + |
|
| 219 | + // enlever le fond de contexte inclus car sinon il prend la main |
|
| 220 | + // dans les sous inclusions -> boucle infinie d'inclusion identique |
|
| 221 | + // (cette precaution n'est probablement plus utile) |
|
| 222 | + unset($contexte['fond']); |
|
| 223 | + $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
|
| 224 | + $page['contexte_implicite']['cache'] = $fond; |
|
| 225 | + if (is_null($cacher)) |
|
| 226 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 227 | + // Les quatre derniers parametres sont modifies par la fonction: |
|
| 228 | + // emplacement, validite, et, s'il est valide, contenu & age |
|
| 229 | + if ($cacher) |
|
| 230 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | + else |
|
| 232 | + $use_cache = -1; |
|
| 233 | + // $res = message d'erreur : on sort de la |
|
| 234 | + if ($res) {return array('texte' => $res);} |
|
| 235 | + |
|
| 236 | + // Si use_cache ne vaut pas 0, la page doit etre calculee |
|
| 237 | + // produire la page : peut mettre a jour $lastinclude |
|
| 238 | + // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
|
| 239 | + if ($use_cache) { |
|
| 240 | + if (is_null($produire_page)) |
|
| 241 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 242 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
|
| 243 | + } |
|
| 244 | + // dans tous les cas, mettre a jour $lastmodified |
|
| 245 | + $lastmodified = max($lastmodified, $lastinclude); |
|
| 246 | + |
|
| 247 | + return $page; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -262,25 +262,25 @@ discard block |
||
| 262 | 262 | * @return array |
| 263 | 263 | */ |
| 264 | 264 | function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
| 265 | - static $parametrer,$cacher; |
|
| 266 | - if (!$parametrer) |
|
| 267 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 268 | - $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 269 | - // et on l'enregistre sur le disque |
|
| 270 | - if ($chemin_cache |
|
| 271 | - AND $use_cache>-1 |
|
| 272 | - AND is_array($page) |
|
| 273 | - AND count($page) |
|
| 274 | - AND $page['entetes']['X-Spip-Cache'] > 0){ |
|
| 275 | - if (is_null($cacher)) |
|
| 276 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 277 | - $lastinclude = time(); |
|
| 278 | - if ($cacher) |
|
| 279 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | - else |
|
| 281 | - $use_cache = -1; |
|
| 282 | - } |
|
| 283 | - return $page; |
|
| 265 | + static $parametrer,$cacher; |
|
| 266 | + if (!$parametrer) |
|
| 267 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 268 | + $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
|
| 269 | + // et on l'enregistre sur le disque |
|
| 270 | + if ($chemin_cache |
|
| 271 | + AND $use_cache>-1 |
|
| 272 | + AND is_array($page) |
|
| 273 | + AND count($page) |
|
| 274 | + AND $page['entetes']['X-Spip-Cache'] > 0){ |
|
| 275 | + if (is_null($cacher)) |
|
| 276 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 277 | + $lastinclude = time(); |
|
| 278 | + if ($cacher) |
|
| 279 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | + else |
|
| 281 | + $use_cache = -1; |
|
| 282 | + } |
|
| 283 | + return $page; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -296,11 +296,11 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) |
| 298 | 298 | { |
| 299 | - if (!is_array($contexte_exec)) |
|
| 300 | - echo $contexte_exec; // message d'erreur etc |
|
| 301 | - else { |
|
| 302 | - inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 303 | - } |
|
| 299 | + if (!is_array($contexte_exec)) |
|
| 300 | + echo $contexte_exec; // message d'erreur etc |
|
| 301 | + else { |
|
| 302 | + inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
|
| 303 | + } |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // Attention, un appel explicite a cette fonction suppose certains include |
@@ -309,204 +309,204 @@ discard block |
||
| 309 | 309 | // http://doc.spip.org/@inclure_balise_dynamique |
| 310 | 310 | function inclure_balise_dynamique($texte, $echo=true, $contexte_compil=array()) |
| 311 | 311 | { |
| 312 | - if (is_array($texte)) { |
|
| 313 | - |
|
| 314 | - list($fond, $delainc, $contexte_inclus) = $texte; |
|
| 315 | - |
|
| 316 | - // delais a l'ancienne, c'est pratiquement mort |
|
| 317 | - $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; |
|
| 318 | - $GLOBALS['delais'] = $delainc; |
|
| 319 | - |
|
| 320 | - $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 321 | - |
|
| 322 | - $texte = $page['texte']; |
|
| 323 | - |
|
| 324 | - $GLOBALS['delais'] = $d; |
|
| 325 | - // Faire remonter les entetes |
|
| 326 | - if (is_array($page['entetes'])) { |
|
| 327 | - // mais pas toutes |
|
| 328 | - unset($page['entetes']['X-Spip-Cache']); |
|
| 329 | - unset($page['entetes']['Content-Type']); |
|
| 330 | - if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
|
| 331 | - if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | - $GLOBALS['page']['entetes'] = array(); |
|
| 333 | - $GLOBALS['page']['entetes'] = |
|
| 334 | - array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 338 | - if (isset($page['contexte']['_pipelines']) |
|
| 339 | - AND is_array($page['contexte']['_pipelines']) |
|
| 340 | - AND count($page['contexte']['_pipelines'])) { |
|
| 341 | - foreach($page['contexte']['_pipelines'] as $pipe=>$args){ |
|
| 342 | - $args['contexte'] = $page['contexte']; |
|
| 343 | - unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 344 | - $texte = pipeline( |
|
| 345 | - $pipe, |
|
| 346 | - array( |
|
| 347 | - 'data'=>$texte, |
|
| 348 | - 'args'=>$args |
|
| 349 | - ), |
|
| 350 | - false |
|
| 351 | - ); |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
|
| 357 | - // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 358 | - $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 359 | - $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 360 | - } |
|
| 361 | - if ($echo) |
|
| 362 | - echo $texte; |
|
| 363 | - else |
|
| 364 | - return $texte; |
|
| 312 | + if (is_array($texte)) { |
|
| 313 | + |
|
| 314 | + list($fond, $delainc, $contexte_inclus) = $texte; |
|
| 315 | + |
|
| 316 | + // delais a l'ancienne, c'est pratiquement mort |
|
| 317 | + $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; |
|
| 318 | + $GLOBALS['delais'] = $delainc; |
|
| 319 | + |
|
| 320 | + $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 321 | + |
|
| 322 | + $texte = $page['texte']; |
|
| 323 | + |
|
| 324 | + $GLOBALS['delais'] = $d; |
|
| 325 | + // Faire remonter les entetes |
|
| 326 | + if (is_array($page['entetes'])) { |
|
| 327 | + // mais pas toutes |
|
| 328 | + unset($page['entetes']['X-Spip-Cache']); |
|
| 329 | + unset($page['entetes']['Content-Type']); |
|
| 330 | + if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
|
| 331 | + if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | + $GLOBALS['page']['entetes'] = array(); |
|
| 333 | + $GLOBALS['page']['entetes'] = |
|
| 334 | + array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
|
| 338 | + if (isset($page['contexte']['_pipelines']) |
|
| 339 | + AND is_array($page['contexte']['_pipelines']) |
|
| 340 | + AND count($page['contexte']['_pipelines'])) { |
|
| 341 | + foreach($page['contexte']['_pipelines'] as $pipe=>$args){ |
|
| 342 | + $args['contexte'] = $page['contexte']; |
|
| 343 | + unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
|
| 344 | + $texte = pipeline( |
|
| 345 | + $pipe, |
|
| 346 | + array( |
|
| 347 | + 'data'=>$texte, |
|
| 348 | + 'args'=>$args |
|
| 349 | + ), |
|
| 350 | + false |
|
| 351 | + ); |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
|
| 357 | + // compatibilite : avant on donnait le numero de ligne ou rien. |
|
| 358 | + $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 359 | + $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
|
| 360 | + } |
|
| 361 | + if ($echo) |
|
| 362 | + echo $texte; |
|
| 363 | + else |
|
| 364 | + return $texte; |
|
| 365 | 365 | |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // http://doc.spip.org/@message_page_indisponible |
| 369 | 369 | function message_page_indisponible ($page, $contexte) { |
| 370 | - static $deja = false; |
|
| 371 | - if ($deja) return "erreur"; |
|
| 372 | - $codes = array( |
|
| 373 | - '404' => '404 Not Found', |
|
| 374 | - '503' => '503 Service Unavailable', |
|
| 375 | - ); |
|
| 376 | - |
|
| 377 | - $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 378 | - $contexte['code'] = $codes[$contexte['status']]; |
|
| 379 | - $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 380 | - if (!isset($contexte['lang'])) |
|
| 381 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 382 | - |
|
| 383 | - $deja = true; |
|
| 384 | - // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 385 | - // ex restriction d'acces => 401 |
|
| 386 | - $contexte = pipeline('page_indisponible',$contexte); |
|
| 387 | - |
|
| 388 | - // produire la page d'erreur |
|
| 389 | - $page = inclure_page($contexte['fond'], $contexte); |
|
| 390 | - if (!$page) |
|
| 391 | - $page = inclure_page('404', $contexte); |
|
| 392 | - $page['status'] = $contexte['status']; |
|
| 393 | - |
|
| 394 | - return $page; |
|
| 370 | + static $deja = false; |
|
| 371 | + if ($deja) return "erreur"; |
|
| 372 | + $codes = array( |
|
| 373 | + '404' => '404 Not Found', |
|
| 374 | + '503' => '503 Service Unavailable', |
|
| 375 | + ); |
|
| 376 | + |
|
| 377 | + $contexte['status'] = ($page !== false) ? '404' : '503'; |
|
| 378 | + $contexte['code'] = $codes[$contexte['status']]; |
|
| 379 | + $contexte['fond'] = '404'; // gere les 2 erreurs |
|
| 380 | + if (!isset($contexte['lang'])) |
|
| 381 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 382 | + |
|
| 383 | + $deja = true; |
|
| 384 | + // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
|
| 385 | + // ex restriction d'acces => 401 |
|
| 386 | + $contexte = pipeline('page_indisponible',$contexte); |
|
| 387 | + |
|
| 388 | + // produire la page d'erreur |
|
| 389 | + $page = inclure_page($contexte['fond'], $contexte); |
|
| 390 | + if (!$page) |
|
| 391 | + $page = inclure_page('404', $contexte); |
|
| 392 | + $page['status'] = $contexte['status']; |
|
| 393 | + |
|
| 394 | + return $page; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // temporairement ici : a mettre dans le futur inc/modeles |
| 398 | 398 | // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array() |
| 399 | 399 | // http://doc.spip.org/@creer_contexte_de_modele |
| 400 | 400 | function creer_contexte_de_modele($args) { |
| 401 | - $contexte = array(); |
|
| 402 | - foreach ($args as $var=>$val) { |
|
| 403 | - if (is_int($var)){ // argument pas formate |
|
| 404 | - if (in_array($val, array('left', 'right', 'center'))) { |
|
| 405 | - $var = 'align'; |
|
| 406 | - $contexte[$var] = $val; |
|
| 407 | - } else { |
|
| 408 | - $args = explode('=', $val); |
|
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | - $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
|
| 411 | - else // notation abregee |
|
| 412 | - $contexte[trim($val)] = trim($val); |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - else |
|
| 416 | - $contexte[$var] = $val; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - return $contexte; |
|
| 401 | + $contexte = array(); |
|
| 402 | + foreach ($args as $var=>$val) { |
|
| 403 | + if (is_int($var)){ // argument pas formate |
|
| 404 | + if (in_array($val, array('left', 'right', 'center'))) { |
|
| 405 | + $var = 'align'; |
|
| 406 | + $contexte[$var] = $val; |
|
| 407 | + } else { |
|
| 408 | + $args = explode('=', $val); |
|
| 409 | + if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | + $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
|
| 411 | + else // notation abregee |
|
| 412 | + $contexte[trim($val)] = trim($val); |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + else |
|
| 416 | + $contexte[$var] = $val; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + return $contexte; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // Calcule le modele et retourne la mini-page ainsi calculee |
| 423 | 423 | // http://doc.spip.org/@inclure_modele |
| 424 | 424 | function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
| 425 | 425 | |
| 426 | - static $compteur; |
|
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 428 | - |
|
| 429 | - $type = strtolower($type); |
|
| 430 | - |
|
| 431 | - $fond = $class = ''; |
|
| 432 | - |
|
| 433 | - $params = array_filter(explode('|', $params)); |
|
| 434 | - if ($params) { |
|
| 435 | - list(,$soustype) = each($params); |
|
| 436 | - $soustype = strtolower(trim($soustype)); |
|
| 437 | - if (in_array($soustype, |
|
| 438 | - array('left', 'right', 'center', 'ajax'))) { |
|
| 439 | - list(,$soustype) = each($params); |
|
| 440 | - $soustype = strtolower($soustype); |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 444 | - if (!trouve_modele($fond = ($type.'_'.$soustype))) { |
|
| 445 | - $fond = ''; |
|
| 446 | - $class = $soustype; |
|
| 447 | - } |
|
| 448 | - // enlever le sous type des params |
|
| 449 | - $params = array_diff($params,array($soustype)); |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 454 | - if (!$fond AND !trouve_modele($fond = $type)){ |
|
| 455 | - spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE); |
|
| 456 | - return false; |
|
| 457 | - } |
|
| 458 | - $fond = 'modeles/'.$fond; |
|
| 459 | - // Creer le contexte |
|
| 460 | - $contexte = $env; |
|
| 461 | - $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 462 | - |
|
| 463 | - // Le numero du modele est mis dans l'environnement |
|
| 464 | - // d'une part sous l'identifiant "id" |
|
| 465 | - // et d'autre part sous l'identifiant de la cle primaire |
|
| 466 | - // par la fonction id_table_objet, |
|
| 467 | - // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 468 | - $_id = id_table_objet($type); |
|
| 469 | - $contexte['id'] = $contexte[$_id] = $id; |
|
| 470 | - |
|
| 471 | - if (isset($class)) |
|
| 472 | - $contexte['class'] = $class; |
|
| 473 | - |
|
| 474 | - // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
|
| 475 | - if ($lien) { |
|
| 476 | - # un eventuel guillemet (") sera reechappe par #ENV |
|
| 477 | - $contexte['lien'] = str_replace(""",'"', $lien['href']); |
|
| 478 | - $contexte['lien_class'] = $lien['class']; |
|
| 479 | - $contexte['lien_mime'] = $lien['mime']; |
|
| 480 | - $contexte['lien_title'] = $lien['title']; |
|
| 481 | - $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - // Traiter les parametres |
|
| 485 | - // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 486 | - $arg_list = creer_contexte_de_modele($params); |
|
| 487 | - $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 488 | - $contexte = array_merge($contexte,$arg_list); |
|
| 489 | - |
|
| 490 | - |
|
| 491 | - // Appliquer le modele avec le contexte |
|
| 492 | - $retour = recuperer_fond($fond, $contexte, array(), $connect); |
|
| 493 | - |
|
| 494 | - |
|
| 495 | - // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 496 | - // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 497 | - // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 498 | - if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', |
|
| 499 | - 'spip_lien_ok')) { |
|
| 500 | - $retour = inserer_attribut($retour, 'class', |
|
| 501 | - trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
|
| 502 | - } else if ($lien) |
|
| 503 | - $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 504 | - |
|
| 505 | - $compteur--; |
|
| 506 | - |
|
| 507 | - return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') |
|
| 508 | - ? encoder_contexte_ajax($contexte,'',$retour) |
|
| 509 | - : $retour; |
|
| 426 | + static $compteur; |
|
| 427 | + if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 428 | + |
|
| 429 | + $type = strtolower($type); |
|
| 430 | + |
|
| 431 | + $fond = $class = ''; |
|
| 432 | + |
|
| 433 | + $params = array_filter(explode('|', $params)); |
|
| 434 | + if ($params) { |
|
| 435 | + list(,$soustype) = each($params); |
|
| 436 | + $soustype = strtolower(trim($soustype)); |
|
| 437 | + if (in_array($soustype, |
|
| 438 | + array('left', 'right', 'center', 'ajax'))) { |
|
| 439 | + list(,$soustype) = each($params); |
|
| 440 | + $soustype = strtolower($soustype); |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + if (preg_match(',^[a-z0-9_]+$,', $soustype)) { |
|
| 444 | + if (!trouve_modele($fond = ($type.'_'.$soustype))) { |
|
| 445 | + $fond = ''; |
|
| 446 | + $class = $soustype; |
|
| 447 | + } |
|
| 448 | + // enlever le sous type des params |
|
| 449 | + $params = array_diff($params,array($soustype)); |
|
| 450 | + } |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + // Si ca marche pas en precisant le sous-type, prendre le type |
|
| 454 | + if (!$fond AND !trouve_modele($fond = $type)){ |
|
| 455 | + spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE); |
|
| 456 | + return false; |
|
| 457 | + } |
|
| 458 | + $fond = 'modeles/'.$fond; |
|
| 459 | + // Creer le contexte |
|
| 460 | + $contexte = $env; |
|
| 461 | + $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte |
|
| 462 | + |
|
| 463 | + // Le numero du modele est mis dans l'environnement |
|
| 464 | + // d'une part sous l'identifiant "id" |
|
| 465 | + // et d'autre part sous l'identifiant de la cle primaire |
|
| 466 | + // par la fonction id_table_objet, |
|
| 467 | + // (<article1> =>> article =>> id_article =>> id_article=1) |
|
| 468 | + $_id = id_table_objet($type); |
|
| 469 | + $contexte['id'] = $contexte[$_id] = $id; |
|
| 470 | + |
|
| 471 | + if (isset($class)) |
|
| 472 | + $contexte['class'] = $class; |
|
| 473 | + |
|
| 474 | + // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
|
| 475 | + if ($lien) { |
|
| 476 | + # un eventuel guillemet (") sera reechappe par #ENV |
|
| 477 | + $contexte['lien'] = str_replace(""",'"', $lien['href']); |
|
| 478 | + $contexte['lien_class'] = $lien['class']; |
|
| 479 | + $contexte['lien_mime'] = $lien['mime']; |
|
| 480 | + $contexte['lien_title'] = $lien['title']; |
|
| 481 | + $contexte['lien_hreflang'] = $lien['hreflang']; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + // Traiter les parametres |
|
| 485 | + // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
|
| 486 | + $arg_list = creer_contexte_de_modele($params); |
|
| 487 | + $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
|
| 488 | + $contexte = array_merge($contexte,$arg_list); |
|
| 489 | + |
|
| 490 | + |
|
| 491 | + // Appliquer le modele avec le contexte |
|
| 492 | + $retour = recuperer_fond($fond, $contexte, array(), $connect); |
|
| 493 | + |
|
| 494 | + |
|
| 495 | + // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
|
| 496 | + // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
|
| 497 | + // sinon, s'il y a un lien, on l'ajoute classiquement |
|
| 498 | + if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', |
|
| 499 | + 'spip_lien_ok')) { |
|
| 500 | + $retour = inserer_attribut($retour, 'class', |
|
| 501 | + trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
|
| 502 | + } else if ($lien) |
|
| 503 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 504 | + |
|
| 505 | + $compteur--; |
|
| 506 | + |
|
| 507 | + return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') |
|
| 508 | + ? encoder_contexte_ajax($contexte,'',$retour) |
|
| 509 | + : $retour; |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | // Un inclure_page qui marche aussi pour l'espace prive |
@@ -516,77 +516,77 @@ discard block |
||
| 516 | 516 | // http://doc.spip.org/@evaluer_fond |
| 517 | 517 | function evaluer_fond ($fond, $contexte=array(), $connect=null) { |
| 518 | 518 | |
| 519 | - $page = inclure_page($fond, $contexte, $connect); |
|
| 519 | + $page = inclure_page($fond, $contexte, $connect); |
|
| 520 | 520 | |
| 521 | - if (!$page) return $page; |
|
| 522 | - // eval $page et affecte $res |
|
| 523 | - include _ROOT_RESTREINT."public/evaluer_page.php"; |
|
| 521 | + if (!$page) return $page; |
|
| 522 | + // eval $page et affecte $res |
|
| 523 | + include _ROOT_RESTREINT."public/evaluer_page.php"; |
|
| 524 | 524 | |
| 525 | - // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 526 | - // a destination de public/parametrer |
|
| 527 | - // pour remonter vers les inclusions appelantes |
|
| 528 | - // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 529 | - // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 530 | - if (isset($page['invalideurs']) |
|
| 531 | - AND isset($page['invalideurs']['session'])) |
|
| 532 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 533 | - |
|
| 534 | - return $page; |
|
| 525 | + // Lever un drapeau (global) si le fond utilise #SESSION |
|
| 526 | + // a destination de public/parametrer |
|
| 527 | + // pour remonter vers les inclusions appelantes |
|
| 528 | + // il faut bien lever ce drapeau apres avoir evalue le fond |
|
| 529 | + // pour ne pas faire descendre le flag vers les inclusions appelees |
|
| 530 | + if (isset($page['invalideurs']) |
|
| 531 | + AND isset($page['invalideurs']['session'])) |
|
| 532 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 533 | + |
|
| 534 | + return $page; |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | // http://doc.spip.org/@page_base_href |
| 539 | 539 | function page_base_href(&$texte){ |
| 540 | - static $set_html_base = null; |
|
| 541 | - if (is_null($set_html_base)){ |
|
| 542 | - if (!defined('_SET_HTML_BASE')) |
|
| 543 | - // si la profondeur est superieure a 1 |
|
| 544 | - // est que ce n'est pas une url page ni une url action |
|
| 545 | - // activer par defaut |
|
| 546 | - $set_html_base = (( |
|
| 547 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
|
| 548 | - AND _request(_SPIP_PAGE) !== 'login' |
|
| 549 | - AND !_request('action'))?true:false); |
|
| 550 | - else |
|
| 551 | - $set_html_base = _SET_HTML_BASE; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - if ($set_html_base |
|
| 555 | - AND isset($GLOBALS['html']) AND $GLOBALS['html'] |
|
| 556 | - AND $GLOBALS['profondeur_url']>0 |
|
| 557 | - AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
|
| 558 | - $head = substr($texte,0,$poshead); |
|
| 559 | - $insert = false; |
|
| 560 | - if (strpos($head, '<base')===false) |
|
| 561 | - $insert = true; |
|
| 562 | - else { |
|
| 563 | - // si aucun <base ...> n'a de href c'est bon quand meme ! |
|
| 564 | - $insert = true; |
|
| 565 | - include_spip('inc/filtres'); |
|
| 566 | - $bases = extraire_balises($head,'base'); |
|
| 567 | - foreach ($bases as $base) |
|
| 568 | - if (extraire_attribut($base,'href')) |
|
| 569 | - $insert = false; |
|
| 570 | - } |
|
| 571 | - if ($insert) { |
|
| 572 | - include_spip('inc/filtres_mini'); |
|
| 573 | - // ajouter un base qui reglera tous les liens relatifs |
|
| 574 | - $base = url_absolue('./'); |
|
| 575 | - $bbase = "\n<base href=\"$base\" />"; |
|
| 576 | - if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | - $head = str_replace($r[0], $r[0].$bbase, $head); |
|
| 580 | - } |
|
| 581 | - $texte = $head . substr($texte,$poshead); |
|
| 582 | - // gerer les ancres |
|
| 583 | - $base = $_SERVER['REQUEST_URI']; |
|
| 584 | - if (strpos($texte,"href='#")!==false) |
|
| 585 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 586 | - if (strpos($texte, "href=\"#")!==false) |
|
| 587 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 588 | - } |
|
| 589 | - } |
|
| 540 | + static $set_html_base = null; |
|
| 541 | + if (is_null($set_html_base)){ |
|
| 542 | + if (!defined('_SET_HTML_BASE')) |
|
| 543 | + // si la profondeur est superieure a 1 |
|
| 544 | + // est que ce n'est pas une url page ni une url action |
|
| 545 | + // activer par defaut |
|
| 546 | + $set_html_base = (( |
|
| 547 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
|
| 548 | + AND _request(_SPIP_PAGE) !== 'login' |
|
| 549 | + AND !_request('action'))?true:false); |
|
| 550 | + else |
|
| 551 | + $set_html_base = _SET_HTML_BASE; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + if ($set_html_base |
|
| 555 | + AND isset($GLOBALS['html']) AND $GLOBALS['html'] |
|
| 556 | + AND $GLOBALS['profondeur_url']>0 |
|
| 557 | + AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
|
| 558 | + $head = substr($texte,0,$poshead); |
|
| 559 | + $insert = false; |
|
| 560 | + if (strpos($head, '<base')===false) |
|
| 561 | + $insert = true; |
|
| 562 | + else { |
|
| 563 | + // si aucun <base ...> n'a de href c'est bon quand meme ! |
|
| 564 | + $insert = true; |
|
| 565 | + include_spip('inc/filtres'); |
|
| 566 | + $bases = extraire_balises($head,'base'); |
|
| 567 | + foreach ($bases as $base) |
|
| 568 | + if (extraire_attribut($base,'href')) |
|
| 569 | + $insert = false; |
|
| 570 | + } |
|
| 571 | + if ($insert) { |
|
| 572 | + include_spip('inc/filtres_mini'); |
|
| 573 | + // ajouter un base qui reglera tous les liens relatifs |
|
| 574 | + $base = url_absolue('./'); |
|
| 575 | + $bbase = "\n<base href=\"$base\" />"; |
|
| 576 | + if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | + $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | + elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | + $head = str_replace($r[0], $r[0].$bbase, $head); |
|
| 580 | + } |
|
| 581 | + $texte = $head . substr($texte,$poshead); |
|
| 582 | + // gerer les ancres |
|
| 583 | + $base = $_SERVER['REQUEST_URI']; |
|
| 584 | + if (strpos($texte,"href='#")!==false) |
|
| 585 | + $texte = str_replace("href='#","href='$base#",$texte); |
|
| 586 | + if (strpos($texte, "href=\"#")!==false) |
|
| 587 | + $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
@@ -594,9 +594,9 @@ discard block |
||
| 594 | 594 | // et demarrent par X-Spip-... |
| 595 | 595 | // http://doc.spip.org/@envoyer_entetes |
| 596 | 596 | function envoyer_entetes($entetes) { |
| 597 | - foreach ($entetes as $k => $v) |
|
| 598 | - # if (strncmp($k, 'X-Spip-', 7)) |
|
| 599 | - @header(strlen($v)?"$k: $v":$k); |
|
| 597 | + foreach ($entetes as $k => $v) |
|
| 598 | + # if (strncmp($k, 'X-Spip-', 7)) |
|
| 599 | + @header(strlen($v)?"$k: $v":$k); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | ?> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | // |
| 21 | 21 | |
| 22 | 22 | // http://doc.spip.org/@assembler |
| 23 | -function assembler($fond, $connect='') { |
|
| 23 | +function assembler($fond, $connect = '') { |
|
| 24 | 24 | |
| 25 | 25 | // flag_preserver est modifie ici, et utilise en globale |
| 26 | 26 | // use_cache sert a informer le bouton d'admin pr savoir s'il met un * |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $contexte = calculer_contexte(); |
| 31 | 31 | $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
| 32 | - $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 32 | + $page['contexte_implicite']['cache'] = $fond.preg_replace(',\.[a-zA-Z0-9]*$,', '', preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); |
|
| 33 | 33 | // Cette fonction est utilisee deux fois |
| 34 | 34 | $cacher = charger_fonction('cacher', 'public', true); |
| 35 | 35 | // Les quatre derniers parametres sont modifies par la fonction: |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | else |
| 40 | 40 | $use_cache = -1; |
| 41 | 41 | // Si un resultat est retourne, c'est un message d'impossibilite |
| 42 | - if ($res) {return array('texte' => $res);} |
|
| 42 | + if ($res) {return array('texte' => $res); } |
|
| 43 | 43 | |
| 44 | 44 | if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
| 45 | 45 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | AND $chemin_cache |
| 55 | 55 | AND isset($page['entetes']) |
| 56 | 56 | AND isset($page['entetes']['Cache-Control']) |
| 57 | - AND strstr($page['entetes']['Cache-Control'],'max-age=') |
|
| 58 | - AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/') |
|
| 57 | + AND strstr($page['entetes']['Cache-Control'], 'max-age=') |
|
| 58 | + AND !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 59 | 59 | ) { |
| 60 | 60 | $since = preg_replace('/;.*/', '', |
| 61 | 61 | $_SERVER['HTTP_IF_MODIFIED_SINCE']); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $page['texte'] = ""; |
| 74 | 74 | } else { |
| 75 | 75 | // si la page est prise dans le cache |
| 76 | - if (!$use_cache) { |
|
| 76 | + if (!$use_cache) { |
|
| 77 | 77 | // Informer les boutons d'admin du contexte |
| 78 | 78 | // (fourni par urls_decoder_url ci-dessous lors de la mise en cache) |
| 79 | 79 | $contexte = $page['contexte']; |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | // et calculer la page |
| 92 | 92 | if (!test_espace_prive()) { |
| 93 | 93 | include_spip('inc/urls'); |
| 94 | - list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
|
| 94 | + list($fond, $contexte, $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $contexte, true); |
|
| 95 | 95 | } |
| 96 | 96 | // squelette par defaut |
| 97 | 97 | if (!strlen($fond)) |
| 98 | 98 | $fond = 'sommaire'; |
| 99 | 99 | |
| 100 | 100 | // produire la page : peut mettre a jour $lastmodified |
| 101 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 101 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 102 | 102 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, NULL, $page, $lastmodified, $connect); |
| 103 | 103 | if ($page === '') { |
| 104 | 104 | $erreur = _T('info_erreur_squelette2', |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | auto_content_type($page); |
| 115 | 115 | |
| 116 | - $flag_preserver |= headers_sent(); |
|
| 116 | + $flag_preserver |= headers_sent(); |
|
| 117 | 117 | |
| 118 | 118 | // Definir les entetes si ce n'est fait |
| 119 | 119 | if (!$flag_preserver) { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | // pas de cache client en mode 'observation' |
| 130 | 130 | if (defined('_VAR_MODE') AND _VAR_MODE) { |
| 131 | - $page['entetes']["Cache-Control"]= "no-cache,must-revalidate"; |
|
| 131 | + $page['entetes']["Cache-Control"] = "no-cache,must-revalidate"; |
|
| 132 | 132 | $page['entetes']["Pragma"] = "no-cache"; |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | if ($lastmodified |
| 142 | 142 | AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 143 | 143 | AND !isset($page['entetes']["Last-Modified"])) |
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 144 | + $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 145 | 145 | |
| 146 | 146 | // fermer la connexion apres les headers si requete HEAD |
| 147 | 147 | if ($headers_only) |
@@ -161,12 +161,12 @@ discard block |
||
| 161 | 161 | function calculer_contexte() { |
| 162 | 162 | |
| 163 | 163 | $contexte = array(); |
| 164 | - foreach($_GET as $var => $val) { |
|
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 164 | + foreach ($_GET as $var => $val) { |
|
| 165 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) |
|
| 166 | 166 | $contexte[$var] = $val; |
| 167 | 167 | } |
| 168 | - foreach($_POST as $var => $val) { |
|
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 168 | + foreach ($_POST as $var => $val) { |
|
| 169 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) |
|
| 170 | 170 | $contexte[$var] = $val; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -180,18 +180,18 @@ discard block |
||
| 180 | 180 | * @staticvar string $notes |
| 181 | 181 | * @return array |
| 182 | 182 | */ |
| 183 | -function calculer_contexte_implicite(){ |
|
| 183 | +function calculer_contexte_implicite() { |
|
| 184 | 184 | static $notes = null; |
| 185 | 185 | if (is_null($notes)) |
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 186 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 187 | 187 | $contexte_implicite = array( |
| 188 | 188 | 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
| 189 | 189 | 'host' => $_SERVER['HTTP_HOST'], |
| 190 | 190 | 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''), |
| 191 | 191 | 'espace' => test_espace_prive(), |
| 192 | - 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | - 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | - 'notes' => $notes?$notes('','contexter_cache'):'', |
|
| 192 | + 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''), |
|
| 193 | + 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''), |
|
| 194 | + 'notes' => $notes ? $notes('', 'contexter_cache') : '', |
|
| 195 | 195 | 'spip_version_code' => $GLOBALS['spip_version_code'], |
| 196 | 196 | ); |
| 197 | 197 | return $contexte_implicite; |
@@ -207,12 +207,12 @@ discard block |
||
| 207 | 207 | global $flag_preserver; |
| 208 | 208 | if (!isset($flag_preserver)) |
| 209 | 209 | { |
| 210 | - $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx",$page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 210 | + $flag_preserver = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", $page['texte']) || (isset($page['entetes']['Content-Type']))); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // http://doc.spip.org/@inclure_page |
| 215 | -function inclure_page($fond, $contexte, $connect='') { |
|
| 215 | +function inclure_page($fond, $contexte, $connect = '') { |
|
| 216 | 216 | static $cacher, $produire_page; |
| 217 | 217 | global $lastmodified; |
| 218 | 218 | |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | else |
| 232 | 232 | $use_cache = -1; |
| 233 | 233 | // $res = message d'erreur : on sort de la |
| 234 | - if ($res) {return array('texte' => $res);} |
|
| 234 | + if ($res) {return array('texte' => $res); } |
|
| 235 | 235 | |
| 236 | 236 | // Si use_cache ne vaut pas 0, la page doit etre calculee |
| 237 | 237 | // produire la page : peut mettre a jour $lastinclude |
| 238 | 238 | // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
| 239 | 239 | if ($use_cache) { |
| 240 | 240 | if (is_null($produire_page)) |
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 241 | + $produire_page = charger_fonction('produire_page', 'public'); |
|
| 242 | 242 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
| 243 | 243 | } |
| 244 | 244 | // dans tous les cas, mettre a jour $lastmodified |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | * @param string $connect |
| 262 | 262 | * @return array |
| 263 | 263 | */ |
| 264 | -function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
|
| 265 | - static $parametrer,$cacher; |
|
| 264 | +function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect = '') { |
|
| 265 | + static $parametrer, $cacher; |
|
| 266 | 266 | if (!$parametrer) |
| 267 | 267 | $parametrer = charger_fonction('parametrer', 'public'); |
| 268 | 268 | $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
| 269 | 269 | // et on l'enregistre sur le disque |
| 270 | 270 | if ($chemin_cache |
| 271 | - AND $use_cache>-1 |
|
| 271 | + AND $use_cache > -1 |
|
| 272 | 272 | AND is_array($page) |
| 273 | 273 | AND count($page) |
| 274 | - AND $page['entetes']['X-Spip-Cache'] > 0){ |
|
| 274 | + AND $page['entetes']['X-Spip-Cache'] > 0) { |
|
| 275 | 275 | if (is_null($cacher)) |
| 276 | 276 | $cacher = charger_fonction('cacher', 'public', true); |
| 277 | 277 | $lastinclude = time(); |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // $echo = faut-il faire echo ou return |
| 308 | 308 | |
| 309 | 309 | // http://doc.spip.org/@inclure_balise_dynamique |
| 310 | -function inclure_balise_dynamique($texte, $echo=true, $contexte_compil=array()) |
|
| 310 | +function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array()) |
|
| 311 | 311 | { |
| 312 | 312 | if (is_array($texte)) { |
| 313 | 313 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : NULL; |
| 318 | 318 | $GLOBALS['delais'] = $delainc; |
| 319 | 319 | |
| 320 | - $page = recuperer_fond($fond,$contexte_inclus,array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 320 | + $page = recuperer_fond($fond, $contexte_inclus, array('trim'=>false, 'raw' => true, 'compil' => $contexte_compil)); |
|
| 321 | 321 | |
| 322 | 322 | $texte = $page['texte']; |
| 323 | 323 | |
@@ -331,14 +331,14 @@ discard block |
||
| 331 | 331 | if (!is_array($GLOBALS['page']['entetes'])) |
| 332 | 332 | $GLOBALS['page']['entetes'] = array(); |
| 333 | 333 | $GLOBALS['page']['entetes'] = |
| 334 | - array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
|
| 334 | + array_merge($GLOBALS['page']['entetes'], $page['entetes']); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines |
| 338 | 338 | if (isset($page['contexte']['_pipelines']) |
| 339 | 339 | AND is_array($page['contexte']['_pipelines']) |
| 340 | 340 | AND count($page['contexte']['_pipelines'])) { |
| 341 | - foreach($page['contexte']['_pipelines'] as $pipe=>$args){ |
|
| 341 | + foreach ($page['contexte']['_pipelines'] as $pipe=>$args) { |
|
| 342 | 342 | $args['contexte'] = $page['contexte']; |
| 343 | 343 | unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul |
| 344 | 344 | $texte = pipeline( |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
| 357 | 357 | // compatibilite : avant on donnait le numero de ligne ou rien. |
| 358 | - $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 358 | + $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
|
| 359 | 359 | $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
| 360 | 360 | } |
| 361 | 361 | if ($echo) |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // http://doc.spip.org/@message_page_indisponible |
| 369 | -function message_page_indisponible ($page, $contexte) { |
|
| 369 | +function message_page_indisponible($page, $contexte) { |
|
| 370 | 370 | static $deja = false; |
| 371 | 371 | if ($deja) return "erreur"; |
| 372 | 372 | $codes = array( |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | $deja = true; |
| 384 | 384 | // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
| 385 | 385 | // ex restriction d'acces => 401 |
| 386 | - $contexte = pipeline('page_indisponible',$contexte); |
|
| 386 | + $contexte = pipeline('page_indisponible', $contexte); |
|
| 387 | 387 | |
| 388 | 388 | // produire la page d'erreur |
| 389 | 389 | $page = inclure_page($contexte['fond'], $contexte); |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | function creer_contexte_de_modele($args) { |
| 401 | 401 | $contexte = array(); |
| 402 | 402 | foreach ($args as $var=>$val) { |
| 403 | - if (is_int($var)){ // argument pas formate |
|
| 403 | + if (is_int($var)) { // argument pas formate |
|
| 404 | 404 | if (in_array($val, array('left', 'right', 'center'))) { |
| 405 | 405 | $var = 'align'; |
| 406 | 406 | $contexte[$var] = $val; |
| 407 | 407 | } else { |
| 408 | 408 | $args = explode('=', $val); |
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | - $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
|
| 409 | + if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | + $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1); |
|
| 411 | 411 | else // notation abregee |
| 412 | 412 | $contexte[trim($val)] = trim($val); |
| 413 | 413 | } |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | // Calcule le modele et retourne la mini-page ainsi calculee |
| 423 | 423 | // http://doc.spip.org/@inclure_modele |
| 424 | -function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
|
| 424 | +function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) { |
|
| 425 | 425 | |
| 426 | 426 | static $compteur; |
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 427 | + if (++$compteur > 10) return ''; # ne pas boucler indefiniment |
|
| 428 | 428 | |
| 429 | 429 | $type = strtolower($type); |
| 430 | 430 | |
@@ -446,13 +446,13 @@ discard block |
||
| 446 | 446 | $class = $soustype; |
| 447 | 447 | } |
| 448 | 448 | // enlever le sous type des params |
| 449 | - $params = array_diff($params,array($soustype)); |
|
| 449 | + $params = array_diff($params, array($soustype)); |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | // Si ca marche pas en precisant le sous-type, prendre le type |
| 454 | - if (!$fond AND !trouve_modele($fond = $type)){ |
|
| 455 | - spip_log("Modele $type introuvable",_LOG_INFO_IMPORTANTE); |
|
| 454 | + if (!$fond AND !trouve_modele($fond = $type)) { |
|
| 455 | + spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); |
|
| 456 | 456 | return false; |
| 457 | 457 | } |
| 458 | 458 | $fond = 'modeles/'.$fond; |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
| 475 | 475 | if ($lien) { |
| 476 | 476 | # un eventuel guillemet (") sera reechappe par #ENV |
| 477 | - $contexte['lien'] = str_replace(""",'"', $lien['href']); |
|
| 477 | + $contexte['lien'] = str_replace(""", '"', $lien['href']); |
|
| 478 | 478 | $contexte['lien_class'] = $lien['class']; |
| 479 | 479 | $contexte['lien_mime'] = $lien['mime']; |
| 480 | 480 | $contexte['lien_title'] = $lien['title']; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en> |
| 486 | 486 | $arg_list = creer_contexte_de_modele($params); |
| 487 | 487 | $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args |
| 488 | - $contexte = array_merge($contexte,$arg_list); |
|
| 488 | + $contexte = array_merge($contexte, $arg_list); |
|
| 489 | 489 | |
| 490 | 490 | |
| 491 | 491 | // Appliquer le modele avec le contexte |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | // Regarder si le modele tient compte des liens (il *doit* alors indiquer |
| 496 | 496 | // spip_lien_ok dans les classes de son conteneur de premier niveau ; |
| 497 | 497 | // sinon, s'il y a un lien, on l'ajoute classiquement |
| 498 | - if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')).' ', |
|
| 498 | + if (strstr(' '.($classes = extraire_attribut($retour, 'class')).' ', |
|
| 499 | 499 | 'spip_lien_ok')) { |
| 500 | 500 | $retour = inserer_attribut($retour, 'class', |
| 501 | 501 | trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | $compteur--; |
| 506 | 506 | |
| 507 | - return (isset($arg_list['ajax'])AND $arg_list['ajax']=='ajax') |
|
| 508 | - ? encoder_contexte_ajax($contexte,'',$retour) |
|
| 507 | + return (isset($arg_list['ajax']) AND $arg_list['ajax'] == 'ajax') |
|
| 508 | + ? encoder_contexte_ajax($contexte, '', $retour) |
|
| 509 | 509 | : $retour; |
| 510 | 510 | } |
| 511 | 511 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | // pour recuperer $page complet, utiliser: |
| 515 | 515 | // recuperer_fond($fond,$contexte,array('raw'=>true)) |
| 516 | 516 | // http://doc.spip.org/@evaluer_fond |
| 517 | -function evaluer_fond ($fond, $contexte=array(), $connect=null) { |
|
| 517 | +function evaluer_fond($fond, $contexte = array(), $connect = null) { |
|
| 518 | 518 | |
| 519 | 519 | $page = inclure_page($fond, $contexte, $connect); |
| 520 | 520 | |
@@ -536,36 +536,36 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | |
| 538 | 538 | // http://doc.spip.org/@page_base_href |
| 539 | -function page_base_href(&$texte){ |
|
| 539 | +function page_base_href(&$texte) { |
|
| 540 | 540 | static $set_html_base = null; |
| 541 | - if (is_null($set_html_base)){ |
|
| 541 | + if (is_null($set_html_base)) { |
|
| 542 | 542 | if (!defined('_SET_HTML_BASE')) |
| 543 | 543 | // si la profondeur est superieure a 1 |
| 544 | 544 | // est que ce n'est pas une url page ni une url action |
| 545 | 545 | // activer par defaut |
| 546 | 546 | $set_html_base = (( |
| 547 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
|
| 547 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2) |
|
| 548 | 548 | AND _request(_SPIP_PAGE) !== 'login' |
| 549 | - AND !_request('action'))?true:false); |
|
| 549 | + AND !_request('action')) ? true : false); |
|
| 550 | 550 | else |
| 551 | 551 | $set_html_base = _SET_HTML_BASE; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | if ($set_html_base |
| 555 | 555 | AND isset($GLOBALS['html']) AND $GLOBALS['html'] |
| 556 | - AND $GLOBALS['profondeur_url']>0 |
|
| 557 | - AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
|
| 558 | - $head = substr($texte,0,$poshead); |
|
| 556 | + AND $GLOBALS['profondeur_url'] > 0 |
|
| 557 | + AND ($poshead = strpos($texte, '</head>')) !== FALSE) { |
|
| 558 | + $head = substr($texte, 0, $poshead); |
|
| 559 | 559 | $insert = false; |
| 560 | - if (strpos($head, '<base')===false) |
|
| 560 | + if (strpos($head, '<base') === false) |
|
| 561 | 561 | $insert = true; |
| 562 | 562 | else { |
| 563 | 563 | // si aucun <base ...> n'a de href c'est bon quand meme ! |
| 564 | 564 | $insert = true; |
| 565 | 565 | include_spip('inc/filtres'); |
| 566 | - $bases = extraire_balises($head,'base'); |
|
| 566 | + $bases = extraire_balises($head, 'base'); |
|
| 567 | 567 | foreach ($bases as $base) |
| 568 | - if (extraire_attribut($base,'href')) |
|
| 568 | + if (extraire_attribut($base, 'href')) |
|
| 569 | 569 | $insert = false; |
| 570 | 570 | } |
| 571 | 571 | if ($insert) { |
@@ -574,17 +574,17 @@ discard block |
||
| 574 | 574 | $base = url_absolue('./'); |
| 575 | 575 | $bbase = "\n<base href=\"$base\" />"; |
| 576 | 576 | if (($pos = strpos($head, '<head>')) !== false) |
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 577 | + $head = substr_replace($head, $bbase, $pos + 6, 0); |
|
| 578 | + elseif (preg_match(",<head[^>]*>,i", $head, $r)) { |
|
| 579 | 579 | $head = str_replace($r[0], $r[0].$bbase, $head); |
| 580 | 580 | } |
| 581 | - $texte = $head . substr($texte,$poshead); |
|
| 581 | + $texte = $head.substr($texte, $poshead); |
|
| 582 | 582 | // gerer les ancres |
| 583 | 583 | $base = $_SERVER['REQUEST_URI']; |
| 584 | - if (strpos($texte,"href='#")!==false) |
|
| 585 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 586 | - if (strpos($texte, "href=\"#")!==false) |
|
| 587 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 584 | + if (strpos($texte, "href='#") !== false) |
|
| 585 | + $texte = str_replace("href='#", "href='$base#", $texte); |
|
| 586 | + if (strpos($texte, "href=\"#") !== false) |
|
| 587 | + $texte = str_replace("href=\"#", "href=\"$base#", $texte); |
|
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | function envoyer_entetes($entetes) { |
| 597 | 597 | foreach ($entetes as $k => $v) |
| 598 | 598 | # if (strncmp($k, 'X-Spip-', 7)) |
| 599 | - @header(strlen($v)?"$k: $v":$k); |
|
| 599 | + @header(strlen($v) ? "$k: $v" : $k); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | ?> |
@@ -10,9 +10,13 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | -if (!defined('_CONTEXTE_IGNORE_VARIABLES')) define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$)/"); |
|
| 17 | +if (!defined('_CONTEXTE_IGNORE_VARIABLES')) { |
|
| 18 | + define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$)/"); |
|
| 19 | +} |
|
| 16 | 20 | // |
| 17 | 21 | // calcule la page et les entetes |
| 18 | 22 | // determine le contexte donne par l'URL (en tenant compte des reecritures) |
@@ -34,14 +38,17 @@ discard block |
||
| 34 | 38 | $cacher = charger_fonction('cacher', 'public', true); |
| 35 | 39 | // Les quatre derniers parametres sont modifies par la fonction: |
| 36 | 40 | // emplacement, validite, et, s'il est valide, contenu & age |
| 37 | - if ($cacher) |
|
| 38 | - $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 39 | - else |
|
| 40 | - $use_cache = -1; |
|
| 41 | + if ($cacher) { |
|
| 42 | + $res = $cacher($GLOBALS['contexte'], $use_cache, $chemin_cache, $page, $lastmodified); |
|
| 43 | + } else { |
|
| 44 | + $use_cache = -1; |
|
| 45 | + } |
|
| 41 | 46 | // Si un resultat est retourne, c'est un message d'impossibilite |
| 42 | 47 | if ($res) {return array('texte' => $res);} |
| 43 | 48 | |
| 44 | - if (!$chemin_cache || !$lastmodified) $lastmodified = time(); |
|
| 49 | + if (!$chemin_cache || !$lastmodified) { |
|
| 50 | + $lastmodified = time(); |
|
| 51 | + } |
|
| 45 | 52 | |
| 46 | 53 | $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD'); |
| 47 | 54 | $calculer_page = true; |
@@ -83,8 +90,7 @@ discard block |
||
| 83 | 90 | // plus necessaire si on utilise bien la fonction urls_decoder_url |
| 84 | 91 | #unset($_SERVER['REDIRECT_url_propre']); |
| 85 | 92 | #unset($_ENV['url_propre']); |
| 86 | - } |
|
| 87 | - else { |
|
| 93 | + } else { |
|
| 88 | 94 | // Compat ascendante : |
| 89 | 95 | // 1. $contexte est global |
| 90 | 96 | // (a evacuer car urls_decoder_url gere ce probleme ?) |
@@ -94,8 +100,9 @@ discard block |
||
| 94 | 100 | list($fond,$contexte,$url_redirect) = urls_decoder_url(nettoyer_uri(),$fond,$contexte,true); |
| 95 | 101 | } |
| 96 | 102 | // squelette par defaut |
| 97 | - if (!strlen($fond)) |
|
| 98 | - $fond = 'sommaire'; |
|
| 103 | + if (!strlen($fond)) { |
|
| 104 | + $fond = 'sommaire'; |
|
| 105 | + } |
|
| 99 | 106 | |
| 100 | 107 | // produire la page : peut mettre a jour $lastmodified |
| 101 | 108 | $produire_page = charger_fonction('produire_page','public'); |
@@ -109,7 +116,9 @@ discard block |
||
| 109 | 116 | } |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | - if ($page AND $chemin_cache) $page['cache'] = $chemin_cache; |
|
| 119 | + if ($page AND $chemin_cache) { |
|
| 120 | + $page['cache'] = $chemin_cache; |
|
| 121 | + } |
|
| 113 | 122 | |
| 114 | 123 | auto_content_type($page); |
| 115 | 124 | |
@@ -140,12 +149,14 @@ discard block |
||
| 140 | 149 | // a celui qu'on a refuse d'honorer plus haut (cf. #655) |
| 141 | 150 | if ($lastmodified |
| 142 | 151 | AND !isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
| 143 | - AND !isset($page['entetes']["Last-Modified"])) |
|
| 144 | - $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 152 | + AND !isset($page['entetes']["Last-Modified"])) { |
|
| 153 | + $page['entetes']["Last-Modified"]=gmdate("D, d M Y H:i:s", $lastmodified)." GMT"; |
|
| 154 | + } |
|
| 145 | 155 | |
| 146 | 156 | // fermer la connexion apres les headers si requete HEAD |
| 147 | - if ($headers_only) |
|
| 148 | - $page['entetes']["Connection"] = "close"; |
|
| 157 | + if ($headers_only) { |
|
| 158 | + $page['entetes']["Connection"] = "close"; |
|
| 159 | + } |
|
| 149 | 160 | |
| 150 | 161 | return $page; |
| 151 | 162 | } |
@@ -162,12 +173,14 @@ discard block |
||
| 162 | 173 | |
| 163 | 174 | $contexte = array(); |
| 164 | 175 | foreach($_GET as $var => $val) { |
| 165 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 166 | - $contexte[$var] = $val; |
|
| 176 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) { |
|
| 177 | + $contexte[$var] = $val; |
|
| 178 | + } |
|
| 167 | 179 | } |
| 168 | 180 | foreach($_POST as $var => $val) { |
| 169 | - if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) |
|
| 170 | - $contexte[$var] = $val; |
|
| 181 | + if (!preg_match(_CONTEXTE_IGNORE_VARIABLES,$var)) { |
|
| 182 | + $contexte[$var] = $val; |
|
| 183 | + } |
|
| 171 | 184 | } |
| 172 | 185 | |
| 173 | 186 | return $contexte; |
@@ -182,8 +195,9 @@ discard block |
||
| 182 | 195 | */ |
| 183 | 196 | function calculer_contexte_implicite(){ |
| 184 | 197 | static $notes = null; |
| 185 | - if (is_null($notes)) |
|
| 186 | - $notes = charger_fonction('notes','inc',true); |
|
| 198 | + if (is_null($notes)) { |
|
| 199 | + $notes = charger_fonction('notes','inc',true); |
|
| 200 | + } |
|
| 187 | 201 | $contexte_implicite = array( |
| 188 | 202 | 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ? |
| 189 | 203 | 'host' => $_SERVER['HTTP_HOST'], |
@@ -222,14 +236,16 @@ discard block |
||
| 222 | 236 | unset($contexte['fond']); |
| 223 | 237 | $page = array('contexte_implicite'=>calculer_contexte_implicite()); |
| 224 | 238 | $page['contexte_implicite']['cache'] = $fond; |
| 225 | - if (is_null($cacher)) |
|
| 226 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 239 | + if (is_null($cacher)) { |
|
| 240 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 241 | + } |
|
| 227 | 242 | // Les quatre derniers parametres sont modifies par la fonction: |
| 228 | 243 | // emplacement, validite, et, s'il est valide, contenu & age |
| 229 | - if ($cacher) |
|
| 230 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 231 | - else |
|
| 232 | - $use_cache = -1; |
|
| 244 | + if ($cacher) { |
|
| 245 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 246 | + } else { |
|
| 247 | + $use_cache = -1; |
|
| 248 | + } |
|
| 233 | 249 | // $res = message d'erreur : on sort de la |
| 234 | 250 | if ($res) {return array('texte' => $res);} |
| 235 | 251 | |
@@ -237,8 +253,9 @@ discard block |
||
| 237 | 253 | // produire la page : peut mettre a jour $lastinclude |
| 238 | 254 | // le contexte_cache envoye a cacher() a ete conserve et est passe a produire |
| 239 | 255 | if ($use_cache) { |
| 240 | - if (is_null($produire_page)) |
|
| 241 | - $produire_page = charger_fonction('produire_page','public'); |
|
| 256 | + if (is_null($produire_page)) { |
|
| 257 | + $produire_page = charger_fonction('produire_page','public'); |
|
| 258 | + } |
|
| 242 | 259 | $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect); |
| 243 | 260 | } |
| 244 | 261 | // dans tous les cas, mettre a jour $lastmodified |
@@ -263,8 +280,9 @@ discard block |
||
| 263 | 280 | */ |
| 264 | 281 | function public_produire_page_dist($fond, $contexte, $use_cache, $chemin_cache, $contexte_cache, &$page, &$lastinclude, $connect=''){ |
| 265 | 282 | static $parametrer,$cacher; |
| 266 | - if (!$parametrer) |
|
| 267 | - $parametrer = charger_fonction('parametrer', 'public'); |
|
| 283 | + if (!$parametrer) { |
|
| 284 | + $parametrer = charger_fonction('parametrer', 'public'); |
|
| 285 | + } |
|
| 268 | 286 | $page = $parametrer($fond, $contexte, $chemin_cache, $connect); |
| 269 | 287 | // et on l'enregistre sur le disque |
| 270 | 288 | if ($chemin_cache |
@@ -272,13 +290,15 @@ discard block |
||
| 272 | 290 | AND is_array($page) |
| 273 | 291 | AND count($page) |
| 274 | 292 | AND $page['entetes']['X-Spip-Cache'] > 0){ |
| 275 | - if (is_null($cacher)) |
|
| 276 | - $cacher = charger_fonction('cacher', 'public', true); |
|
| 293 | + if (is_null($cacher)) { |
|
| 294 | + $cacher = charger_fonction('cacher', 'public', true); |
|
| 295 | + } |
|
| 277 | 296 | $lastinclude = time(); |
| 278 | - if ($cacher) |
|
| 279 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 280 | - else |
|
| 281 | - $use_cache = -1; |
|
| 297 | + if ($cacher) { |
|
| 298 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude); |
|
| 299 | + } else { |
|
| 300 | + $use_cache = -1; |
|
| 301 | + } |
|
| 282 | 302 | } |
| 283 | 303 | return $page; |
| 284 | 304 | } |
@@ -296,8 +316,10 @@ discard block |
||
| 296 | 316 | |
| 297 | 317 | function inserer_balise_dynamique($contexte_exec, $contexte_compil) |
| 298 | 318 | { |
| 299 | - if (!is_array($contexte_exec)) |
|
| 300 | - echo $contexte_exec; // message d'erreur etc |
|
| 319 | + if (!is_array($contexte_exec)) { |
|
| 320 | + echo $contexte_exec; |
|
| 321 | + } |
|
| 322 | + // message d'erreur etc |
|
| 301 | 323 | else { |
| 302 | 324 | inclure_balise_dynamique($contexte_exec, true, $contexte_compil); |
| 303 | 325 | } |
@@ -328,8 +350,9 @@ discard block |
||
| 328 | 350 | unset($page['entetes']['X-Spip-Cache']); |
| 329 | 351 | unset($page['entetes']['Content-Type']); |
| 330 | 352 | if (isset($GLOBALS['page']) AND is_array($GLOBALS['page'])) { |
| 331 | - if (!is_array($GLOBALS['page']['entetes'])) |
|
| 332 | - $GLOBALS['page']['entetes'] = array(); |
|
| 353 | + if (!is_array($GLOBALS['page']['entetes'])) { |
|
| 354 | + $GLOBALS['page']['entetes'] = array(); |
|
| 355 | + } |
|
| 333 | 356 | $GLOBALS['page']['entetes'] = |
| 334 | 357 | array_merge($GLOBALS['page']['entetes'],$page['entetes']); |
| 335 | 358 | } |
@@ -358,17 +381,20 @@ discard block |
||
| 358 | 381 | $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil); |
| 359 | 382 | $GLOBALS['debug_objets']['resultat'][$ligne] = $texte; |
| 360 | 383 | } |
| 361 | - if ($echo) |
|
| 362 | - echo $texte; |
|
| 363 | - else |
|
| 364 | - return $texte; |
|
| 384 | + if ($echo) { |
|
| 385 | + echo $texte; |
|
| 386 | + } else { |
|
| 387 | + return $texte; |
|
| 388 | + } |
|
| 365 | 389 | |
| 366 | 390 | } |
| 367 | 391 | |
| 368 | 392 | // http://doc.spip.org/@message_page_indisponible |
| 369 | 393 | function message_page_indisponible ($page, $contexte) { |
| 370 | 394 | static $deja = false; |
| 371 | - if ($deja) return "erreur"; |
|
| 395 | + if ($deja) { |
|
| 396 | + return "erreur"; |
|
| 397 | + } |
|
| 372 | 398 | $codes = array( |
| 373 | 399 | '404' => '404 Not Found', |
| 374 | 400 | '503' => '503 Service Unavailable', |
@@ -377,8 +403,9 @@ discard block |
||
| 377 | 403 | $contexte['status'] = ($page !== false) ? '404' : '503'; |
| 378 | 404 | $contexte['code'] = $codes[$contexte['status']]; |
| 379 | 405 | $contexte['fond'] = '404'; // gere les 2 erreurs |
| 380 | - if (!isset($contexte['lang'])) |
|
| 381 | - $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 406 | + if (!isset($contexte['lang'])) { |
|
| 407 | + $contexte['lang'] = $GLOBALS['spip_lang']; |
|
| 408 | + } |
|
| 382 | 409 | |
| 383 | 410 | $deja = true; |
| 384 | 411 | // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent |
@@ -387,8 +414,9 @@ discard block |
||
| 387 | 414 | |
| 388 | 415 | // produire la page d'erreur |
| 389 | 416 | $page = inclure_page($contexte['fond'], $contexte); |
| 390 | - if (!$page) |
|
| 391 | - $page = inclure_page('404', $contexte); |
|
| 417 | + if (!$page) { |
|
| 418 | + $page = inclure_page('404', $contexte); |
|
| 419 | + } |
|
| 392 | 420 | $page['status'] = $contexte['status']; |
| 393 | 421 | |
| 394 | 422 | return $page; |
@@ -406,14 +434,17 @@ discard block |
||
| 406 | 434 | $contexte[$var] = $val; |
| 407 | 435 | } else { |
| 408 | 436 | $args = explode('=', $val); |
| 409 | - if (count($args)>=2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 437 | + if (count($args)>=2) { |
|
| 438 | + // Flashvars=arg1=machin&arg2=truc genere plus de deux args |
|
| 410 | 439 | $contexte[trim($args[0])] = substr($val,strlen($args[0])+1); |
| 411 | - else // notation abregee |
|
| 440 | + } else { |
|
| 441 | + // notation abregee |
|
| 412 | 442 | $contexte[trim($val)] = trim($val); |
| 443 | + } |
|
| 413 | 444 | } |
| 445 | + } else { |
|
| 446 | + $contexte[$var] = $val; |
|
| 414 | 447 | } |
| 415 | - else |
|
| 416 | - $contexte[$var] = $val; |
|
| 417 | 448 | } |
| 418 | 449 | |
| 419 | 450 | return $contexte; |
@@ -424,7 +455,10 @@ discard block |
||
| 424 | 455 | function inclure_modele($type, $id, $params, $lien, $connect='', $env=array()) { |
| 425 | 456 | |
| 426 | 457 | static $compteur; |
| 427 | - if (++$compteur>10) return ''; # ne pas boucler indefiniment |
|
| 458 | + if (++$compteur>10) { |
|
| 459 | + return ''; |
|
| 460 | + } |
|
| 461 | + # ne pas boucler indefiniment |
|
| 428 | 462 | |
| 429 | 463 | $type = strtolower($type); |
| 430 | 464 | |
@@ -468,8 +502,9 @@ discard block |
||
| 468 | 502 | $_id = id_table_objet($type); |
| 469 | 503 | $contexte['id'] = $contexte[$_id] = $id; |
| 470 | 504 | |
| 471 | - if (isset($class)) |
|
| 472 | - $contexte['class'] = $class; |
|
| 505 | + if (isset($class)) { |
|
| 506 | + $contexte['class'] = $class; |
|
| 507 | + } |
|
| 473 | 508 | |
| 474 | 509 | // Si un lien a ete passe en parametre, ex: [<modele1>->url] |
| 475 | 510 | if ($lien) { |
@@ -499,8 +534,9 @@ discard block |
||
| 499 | 534 | 'spip_lien_ok')) { |
| 500 | 535 | $retour = inserer_attribut($retour, 'class', |
| 501 | 536 | trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); |
| 502 | - } else if ($lien) |
|
| 503 | - $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 537 | + } else if ($lien) { |
|
| 538 | + $retour = "<a href='".$lien['href']."' class='".$lien['class']."'>".$retour."</a>"; |
|
| 539 | + } |
|
| 504 | 540 | |
| 505 | 541 | $compteur--; |
| 506 | 542 | |
@@ -518,7 +554,9 @@ discard block |
||
| 518 | 554 | |
| 519 | 555 | $page = inclure_page($fond, $contexte, $connect); |
| 520 | 556 | |
| 521 | - if (!$page) return $page; |
|
| 557 | + if (!$page) { |
|
| 558 | + return $page; |
|
| 559 | + } |
|
| 522 | 560 | // eval $page et affecte $res |
| 523 | 561 | include _ROOT_RESTREINT."public/evaluer_page.php"; |
| 524 | 562 | |
@@ -528,8 +566,9 @@ discard block |
||
| 528 | 566 | // il faut bien lever ce drapeau apres avoir evalue le fond |
| 529 | 567 | // pour ne pas faire descendre le flag vers les inclusions appelees |
| 530 | 568 | if (isset($page['invalideurs']) |
| 531 | - AND isset($page['invalideurs']['session'])) |
|
| 532 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 569 | + AND isset($page['invalideurs']['session'])) { |
|
| 570 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session']; |
|
| 571 | + } |
|
| 533 | 572 | |
| 534 | 573 | return $page; |
| 535 | 574 | } |
@@ -539,16 +578,17 @@ discard block |
||
| 539 | 578 | function page_base_href(&$texte){ |
| 540 | 579 | static $set_html_base = null; |
| 541 | 580 | if (is_null($set_html_base)){ |
| 542 | - if (!defined('_SET_HTML_BASE')) |
|
| 543 | - // si la profondeur est superieure a 1 |
|
| 581 | + if (!defined('_SET_HTML_BASE')) { |
|
| 582 | + // si la profondeur est superieure a 1 |
|
| 544 | 583 | // est que ce n'est pas une url page ni une url action |
| 545 | 584 | // activer par defaut |
| 546 | 585 | $set_html_base = (( |
| 547 | 586 | $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT?1:2) |
| 548 | 587 | AND _request(_SPIP_PAGE) !== 'login' |
| 549 | 588 | AND !_request('action'))?true:false); |
| 550 | - else |
|
| 551 | - $set_html_base = _SET_HTML_BASE; |
|
| 589 | + } else { |
|
| 590 | + $set_html_base = _SET_HTML_BASE; |
|
| 591 | + } |
|
| 552 | 592 | } |
| 553 | 593 | |
| 554 | 594 | if ($set_html_base |
@@ -557,34 +597,37 @@ discard block |
||
| 557 | 597 | AND ($poshead = strpos($texte,'</head>'))!==FALSE){ |
| 558 | 598 | $head = substr($texte,0,$poshead); |
| 559 | 599 | $insert = false; |
| 560 | - if (strpos($head, '<base')===false) |
|
| 561 | - $insert = true; |
|
| 562 | - else { |
|
| 600 | + if (strpos($head, '<base')===false) { |
|
| 601 | + $insert = true; |
|
| 602 | + } else { |
|
| 563 | 603 | // si aucun <base ...> n'a de href c'est bon quand meme ! |
| 564 | 604 | $insert = true; |
| 565 | 605 | include_spip('inc/filtres'); |
| 566 | 606 | $bases = extraire_balises($head,'base'); |
| 567 | - foreach ($bases as $base) |
|
| 568 | - if (extraire_attribut($base,'href')) |
|
| 607 | + foreach ($bases as $base) { |
|
| 608 | + if (extraire_attribut($base,'href')) |
|
| 569 | 609 | $insert = false; |
| 610 | + } |
|
| 570 | 611 | } |
| 571 | 612 | if ($insert) { |
| 572 | 613 | include_spip('inc/filtres_mini'); |
| 573 | 614 | // ajouter un base qui reglera tous les liens relatifs |
| 574 | 615 | $base = url_absolue('./'); |
| 575 | 616 | $bbase = "\n<base href=\"$base\" />"; |
| 576 | - if (($pos = strpos($head, '<head>')) !== false) |
|
| 577 | - $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 578 | - elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 617 | + if (($pos = strpos($head, '<head>')) !== false) { |
|
| 618 | + $head = substr_replace($head, $bbase, $pos+6, 0); |
|
| 619 | + } elseif(preg_match(",<head[^>]*>,i",$head,$r)){ |
|
| 579 | 620 | $head = str_replace($r[0], $r[0].$bbase, $head); |
| 580 | 621 | } |
| 581 | 622 | $texte = $head . substr($texte,$poshead); |
| 582 | 623 | // gerer les ancres |
| 583 | 624 | $base = $_SERVER['REQUEST_URI']; |
| 584 | - if (strpos($texte,"href='#")!==false) |
|
| 585 | - $texte = str_replace("href='#","href='$base#",$texte); |
|
| 586 | - if (strpos($texte, "href=\"#")!==false) |
|
| 587 | - $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 625 | + if (strpos($texte,"href='#")!==false) { |
|
| 626 | + $texte = str_replace("href='#","href='$base#",$texte); |
|
| 627 | + } |
|
| 628 | + if (strpos($texte, "href=\"#")!==false) { |
|
| 629 | + $texte = str_replace("href=\"#","href=\"$base#",$texte); |
|
| 630 | + } |
|
| 588 | 631 | } |
| 589 | 632 | } |
| 590 | 633 | } |
@@ -594,9 +637,10 @@ discard block |
||
| 594 | 637 | // et demarrent par X-Spip-... |
| 595 | 638 | // http://doc.spip.org/@envoyer_entetes |
| 596 | 639 | function envoyer_entetes($entetes) { |
| 597 | - foreach ($entetes as $k => $v) |
|
| 598 | - # if (strncmp($k, 'X-Spip-', 7)) |
|
| 599 | - @header(strlen($v)?"$k: $v":$k); |
|
| 600 | -} |
|
| 640 | + foreach ($entetes as $k => $v) { |
|
| 641 | + # if (strncmp($k, 'X-Spip-', 7)) |
|
| 642 | + @header(strlen($v)?"$k: $v":$k); |
|
| 643 | + } |
|
| 644 | + } |
|
| 601 | 645 | |
| 602 | 646 | ?> |
@@ -32,43 +32,43 @@ discard block |
||
| 32 | 32 | * @package SPIP\Compilateur\AST |
| 33 | 33 | */ |
| 34 | 34 | class Contexte { |
| 35 | - /** |
|
| 36 | - * Description du squelette |
|
| 37 | - * |
|
| 38 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 39 | - * |
|
| 40 | - * Peut contenir les index : |
|
| 41 | - * - nom : Nom du fichier de cache |
|
| 42 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 43 | - * - sourcefile : Chemin du squelette |
|
| 44 | - * - squelette : Code du squelette |
|
| 45 | - * - id_mere : Identifiant de la boucle parente |
|
| 46 | - * - documents : Pour embed et img dans les textes |
|
| 47 | - * - session : Pour un cache sessionné par auteur |
|
| 48 | - * - niv : Niveau de tabulation |
|
| 49 | - * |
|
| 50 | - * @var array */ |
|
| 51 | - public $descr = array(); |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Identifiant de la boucle |
|
| 55 | - * @var string */ |
|
| 56 | - public $id_boucle = ''; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Numéro de ligne dans le code source du squelette |
|
| 60 | - * @var int */ |
|
| 61 | - public $ligne = 0; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Langue d'exécution |
|
| 65 | - * @var string */ |
|
| 66 | - public $lang = ''; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Résultat de la compilation: toujours une expression PHP |
|
| 70 | - * @var string */ |
|
| 71 | - public $code = ''; |
|
| 35 | + /** |
|
| 36 | + * Description du squelette |
|
| 37 | + * |
|
| 38 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 39 | + * |
|
| 40 | + * Peut contenir les index : |
|
| 41 | + * - nom : Nom du fichier de cache |
|
| 42 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 43 | + * - sourcefile : Chemin du squelette |
|
| 44 | + * - squelette : Code du squelette |
|
| 45 | + * - id_mere : Identifiant de la boucle parente |
|
| 46 | + * - documents : Pour embed et img dans les textes |
|
| 47 | + * - session : Pour un cache sessionné par auteur |
|
| 48 | + * - niv : Niveau de tabulation |
|
| 49 | + * |
|
| 50 | + * @var array */ |
|
| 51 | + public $descr = array(); |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Identifiant de la boucle |
|
| 55 | + * @var string */ |
|
| 56 | + public $id_boucle = ''; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Numéro de ligne dans le code source du squelette |
|
| 60 | + * @var int */ |
|
| 61 | + public $ligne = 0; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Langue d'exécution |
|
| 65 | + * @var string */ |
|
| 66 | + public $lang = ''; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Résultat de la compilation: toujours une expression PHP |
|
| 70 | + * @var string */ |
|
| 71 | + public $code = ''; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -78,34 +78,34 @@ discard block |
||
| 78 | 78 | * @package SPIP\Compilateur\AST |
| 79 | 79 | **/ |
| 80 | 80 | class Texte { |
| 81 | - /** |
|
| 82 | - * Type de noeud |
|
| 83 | - * @var string */ |
|
| 84 | - public $type = 'texte'; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Le texte |
|
| 88 | - * @var string */ |
|
| 89 | - public $texte; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Contenu avant le texte. |
|
| 93 | - * |
|
| 94 | - * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 95 | - * @var string|array */ |
|
| 96 | - public $avant = ""; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Contenu après le texte. |
|
| 100 | - * |
|
| 101 | - * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 102 | - * @var string|array */ |
|
| 103 | - public $apres = ""; |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Numéro de ligne dans le code source du squelette |
|
| 107 | - * @var int */ |
|
| 108 | - public $ligne = 0; |
|
| 81 | + /** |
|
| 82 | + * Type de noeud |
|
| 83 | + * @var string */ |
|
| 84 | + public $type = 'texte'; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Le texte |
|
| 88 | + * @var string */ |
|
| 89 | + public $texte; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Contenu avant le texte. |
|
| 93 | + * |
|
| 94 | + * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 95 | + * @var string|array */ |
|
| 96 | + public $avant = ""; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Contenu après le texte. |
|
| 100 | + * |
|
| 101 | + * Vide ou apostrophe simple ou double si le texte en était entouré |
|
| 102 | + * @var string|array */ |
|
| 103 | + public $apres = ""; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Numéro de ligne dans le code source du squelette |
|
| 107 | + * @var int */ |
|
| 108 | + public $ligne = 0; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -114,38 +114,38 @@ discard block |
||
| 114 | 114 | * @package SPIP\Compilateur\AST |
| 115 | 115 | **/ |
| 116 | 116 | class Inclure { |
| 117 | - /** |
|
| 118 | - * Type de noeud |
|
| 119 | - * @var string */ |
|
| 120 | - public $type = 'include'; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Nom d'un fichier inclu |
|
| 124 | - * |
|
| 125 | - * - Objet Texte si inclusion d'un autre squelette |
|
| 126 | - * - chaîne si inclusion d'un fichier PHP directement |
|
| 127 | - * @var string|Texte */ |
|
| 128 | - public $texte; |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Inutilisé, propriété générique de l'AST |
|
| 132 | - * @var string|array */ |
|
| 133 | - public $avant = ''; |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Inutilisé, propriété générique de l'AST |
|
| 137 | - * @var string|array */ |
|
| 138 | - public $apres = ''; |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Numéro de ligne dans le code source du squelette |
|
| 142 | - * @var int */ |
|
| 143 | - public $ligne = 0; |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Valeurs des paramètres |
|
| 147 | - * @var array */ |
|
| 148 | - public $param = array(); |
|
| 117 | + /** |
|
| 118 | + * Type de noeud |
|
| 119 | + * @var string */ |
|
| 120 | + public $type = 'include'; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Nom d'un fichier inclu |
|
| 124 | + * |
|
| 125 | + * - Objet Texte si inclusion d'un autre squelette |
|
| 126 | + * - chaîne si inclusion d'un fichier PHP directement |
|
| 127 | + * @var string|Texte */ |
|
| 128 | + public $texte; |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Inutilisé, propriété générique de l'AST |
|
| 132 | + * @var string|array */ |
|
| 133 | + public $avant = ''; |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Inutilisé, propriété générique de l'AST |
|
| 137 | + * @var string|array */ |
|
| 138 | + public $apres = ''; |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Numéro de ligne dans le code source du squelette |
|
| 142 | + * @var int */ |
|
| 143 | + public $ligne = 0; |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Valeurs des paramètres |
|
| 147 | + * @var array */ |
|
| 148 | + public $param = array(); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -155,164 +155,164 @@ discard block |
||
| 155 | 155 | * @package SPIP\Compilateur\AST |
| 156 | 156 | **/ |
| 157 | 157 | class Boucle { |
| 158 | - /** |
|
| 159 | - * Type de noeud |
|
| 160 | - * @var string */ |
|
| 161 | - public $type = 'boucle'; |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Identifiant de la boucle |
|
| 165 | - * @var string */ |
|
| 166 | - public $id_boucle; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Identifiant de la boucle parente |
|
| 170 | - * @var string */ |
|
| 171 | - public $id_parent =''; |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Partie optionnelle avant |
|
| 175 | - * @var string|array */ |
|
| 176 | - public $avant = ''; |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Pour chaque élément |
|
| 180 | - * @var string|array */ |
|
| 181 | - public $milieu = ''; |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Partie optionnelle après |
|
| 185 | - * @var string|array */ |
|
| 186 | - public $apres = ''; |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Partie alternative, si pas de résultat dans la boucle |
|
| 190 | - * @var string|array */ |
|
| 191 | - public $altern = ''; |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * La boucle doit-elle sélectionner la langue ? |
|
| 195 | - * @var string|null */ |
|
| 196 | - public $lang_select; |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 200 | - * @var string|null */ |
|
| 201 | - public $type_requete; |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * La table est elle optionnelle ? |
|
| 205 | - * |
|
| 206 | - * Si oui, aucune erreur ne sera générée si la table demandée n'est pas présente |
|
| 207 | - * @var bool */ |
|
| 208 | - public $table_optionnelle = false; |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Nom du fichier de connexion |
|
| 212 | - * @var string */ |
|
| 213 | - public $sql_serveur = ''; |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Paramètres de la boucle |
|
| 217 | - * |
|
| 218 | - * Description des paramètres passés à la boucle, qui servent ensuite |
|
| 219 | - * au calcul des critères |
|
| 220 | - * |
|
| 221 | - * @var array */ |
|
| 222 | - public $param = array(); |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Critères de la boucle |
|
| 226 | - * @var Critere[] */ |
|
| 227 | - public $criteres = array(); |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Textes insérés entre 2 éléments de boucle (critère inter) |
|
| 231 | - * @var string[] */ |
|
| 232 | - public $separateur = array(); |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Liste des jointures possibles avec cette table |
|
| 236 | - * |
|
| 237 | - * Les jointures par défaut de la table sont complétées en priorité |
|
| 238 | - * des jointures déclarées explicitement sur la boucle |
|
| 239 | - * @see base_trouver_table_dist() |
|
| 240 | - * @var array */ |
|
| 241 | - public $jointures = array(); |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Jointures explicites avec cette table |
|
| 245 | - * |
|
| 246 | - * Ces jointures sont utilisées en priorité par rapport aux jointures |
|
| 247 | - * normales possibles pour retrouver les colonnes demandées extérieures |
|
| 248 | - * à la boucle. |
|
| 249 | - * @var string|bool */ |
|
| 250 | - public $jointures_explicites = false; |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Nom de la variable PHP stockant le noms de doublons utilisés "$doublons_index" |
|
| 254 | - * @var string|null */ |
|
| 255 | - public $doublons; |
|
| 256 | - |
|
| 257 | - var $partie, $total_parties,$mode_partie=''; |
|
| 258 | - var $externe = ''; # appel a partir d'une autre boucle (recursion) |
|
| 259 | - // champs pour la construction de la requete SQL |
|
| 260 | - var $select = array(); |
|
| 261 | - var $from = array(); |
|
| 262 | - var $from_type = array(); |
|
| 263 | - var $where = array(); |
|
| 264 | - var $join = array(); |
|
| 265 | - var $having = array(); |
|
| 266 | - var $limit; |
|
| 267 | - var $group = array(); |
|
| 268 | - var $order = array(); |
|
| 269 | - var $default_order = array(); |
|
| 270 | - var $date = 'date' ; |
|
| 271 | - var $hash = "" ; |
|
| 272 | - var $in = "" ; |
|
| 273 | - var $sous_requete = false; |
|
| 274 | - var $hierarchie = ''; |
|
| 275 | - var $statut = false; # definition/surcharge du statut des elements retournes |
|
| 276 | - // champs pour la construction du corps PHP |
|
| 277 | - var $show = array(); |
|
| 278 | - var $id_table; |
|
| 279 | - var $primary; |
|
| 280 | - var $return; |
|
| 281 | - var $numrows = false; |
|
| 282 | - var $cptrows = false; |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Description du squelette |
|
| 286 | - * |
|
| 287 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 288 | - * |
|
| 289 | - * Peut contenir les index : |
|
| 290 | - * - nom : Nom du fichier de cache |
|
| 291 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 292 | - * - sourcefile : Chemin du squelette |
|
| 293 | - * - squelette : Code du squelette |
|
| 294 | - * - id_mere : Identifiant de la boucle parente |
|
| 295 | - * - documents : Pour embed et img dans les textes |
|
| 296 | - * - session : Pour un cache sessionné par auteur |
|
| 297 | - * - niv : Niveau de tabulation |
|
| 298 | - * |
|
| 299 | - * @var array */ |
|
| 300 | - public $descr = array(); |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * Numéro de ligne dans le code source du squelette |
|
| 304 | - * @var int */ |
|
| 305 | - public $ligne = 0; |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - var $modificateur = array(); // table pour stocker les modificateurs de boucle tels que tout, plat ..., utilisable par les plugins egalement |
|
| 309 | - |
|
| 310 | - var $iterateur = ''; // type d'iterateur |
|
| 311 | - |
|
| 312 | - // obsoletes, conserves provisoirement pour compatibilite |
|
| 313 | - var $tout = false; |
|
| 314 | - var $plat = false; |
|
| 315 | - var $lien = false; |
|
| 158 | + /** |
|
| 159 | + * Type de noeud |
|
| 160 | + * @var string */ |
|
| 161 | + public $type = 'boucle'; |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Identifiant de la boucle |
|
| 165 | + * @var string */ |
|
| 166 | + public $id_boucle; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Identifiant de la boucle parente |
|
| 170 | + * @var string */ |
|
| 171 | + public $id_parent =''; |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Partie optionnelle avant |
|
| 175 | + * @var string|array */ |
|
| 176 | + public $avant = ''; |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Pour chaque élément |
|
| 180 | + * @var string|array */ |
|
| 181 | + public $milieu = ''; |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Partie optionnelle après |
|
| 185 | + * @var string|array */ |
|
| 186 | + public $apres = ''; |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Partie alternative, si pas de résultat dans la boucle |
|
| 190 | + * @var string|array */ |
|
| 191 | + public $altern = ''; |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * La boucle doit-elle sélectionner la langue ? |
|
| 195 | + * @var string|null */ |
|
| 196 | + public $lang_select; |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 200 | + * @var string|null */ |
|
| 201 | + public $type_requete; |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * La table est elle optionnelle ? |
|
| 205 | + * |
|
| 206 | + * Si oui, aucune erreur ne sera générée si la table demandée n'est pas présente |
|
| 207 | + * @var bool */ |
|
| 208 | + public $table_optionnelle = false; |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Nom du fichier de connexion |
|
| 212 | + * @var string */ |
|
| 213 | + public $sql_serveur = ''; |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Paramètres de la boucle |
|
| 217 | + * |
|
| 218 | + * Description des paramètres passés à la boucle, qui servent ensuite |
|
| 219 | + * au calcul des critères |
|
| 220 | + * |
|
| 221 | + * @var array */ |
|
| 222 | + public $param = array(); |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Critères de la boucle |
|
| 226 | + * @var Critere[] */ |
|
| 227 | + public $criteres = array(); |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * Textes insérés entre 2 éléments de boucle (critère inter) |
|
| 231 | + * @var string[] */ |
|
| 232 | + public $separateur = array(); |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Liste des jointures possibles avec cette table |
|
| 236 | + * |
|
| 237 | + * Les jointures par défaut de la table sont complétées en priorité |
|
| 238 | + * des jointures déclarées explicitement sur la boucle |
|
| 239 | + * @see base_trouver_table_dist() |
|
| 240 | + * @var array */ |
|
| 241 | + public $jointures = array(); |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Jointures explicites avec cette table |
|
| 245 | + * |
|
| 246 | + * Ces jointures sont utilisées en priorité par rapport aux jointures |
|
| 247 | + * normales possibles pour retrouver les colonnes demandées extérieures |
|
| 248 | + * à la boucle. |
|
| 249 | + * @var string|bool */ |
|
| 250 | + public $jointures_explicites = false; |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Nom de la variable PHP stockant le noms de doublons utilisés "$doublons_index" |
|
| 254 | + * @var string|null */ |
|
| 255 | + public $doublons; |
|
| 256 | + |
|
| 257 | + var $partie, $total_parties,$mode_partie=''; |
|
| 258 | + var $externe = ''; # appel a partir d'une autre boucle (recursion) |
|
| 259 | + // champs pour la construction de la requete SQL |
|
| 260 | + var $select = array(); |
|
| 261 | + var $from = array(); |
|
| 262 | + var $from_type = array(); |
|
| 263 | + var $where = array(); |
|
| 264 | + var $join = array(); |
|
| 265 | + var $having = array(); |
|
| 266 | + var $limit; |
|
| 267 | + var $group = array(); |
|
| 268 | + var $order = array(); |
|
| 269 | + var $default_order = array(); |
|
| 270 | + var $date = 'date' ; |
|
| 271 | + var $hash = "" ; |
|
| 272 | + var $in = "" ; |
|
| 273 | + var $sous_requete = false; |
|
| 274 | + var $hierarchie = ''; |
|
| 275 | + var $statut = false; # definition/surcharge du statut des elements retournes |
|
| 276 | + // champs pour la construction du corps PHP |
|
| 277 | + var $show = array(); |
|
| 278 | + var $id_table; |
|
| 279 | + var $primary; |
|
| 280 | + var $return; |
|
| 281 | + var $numrows = false; |
|
| 282 | + var $cptrows = false; |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Description du squelette |
|
| 286 | + * |
|
| 287 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 288 | + * |
|
| 289 | + * Peut contenir les index : |
|
| 290 | + * - nom : Nom du fichier de cache |
|
| 291 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 292 | + * - sourcefile : Chemin du squelette |
|
| 293 | + * - squelette : Code du squelette |
|
| 294 | + * - id_mere : Identifiant de la boucle parente |
|
| 295 | + * - documents : Pour embed et img dans les textes |
|
| 296 | + * - session : Pour un cache sessionné par auteur |
|
| 297 | + * - niv : Niveau de tabulation |
|
| 298 | + * |
|
| 299 | + * @var array */ |
|
| 300 | + public $descr = array(); |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * Numéro de ligne dans le code source du squelette |
|
| 304 | + * @var int */ |
|
| 305 | + public $ligne = 0; |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + var $modificateur = array(); // table pour stocker les modificateurs de boucle tels que tout, plat ..., utilisable par les plugins egalement |
|
| 309 | + |
|
| 310 | + var $iterateur = ''; // type d'iterateur |
|
| 311 | + |
|
| 312 | + // obsoletes, conserves provisoirement pour compatibilite |
|
| 313 | + var $tout = false; |
|
| 314 | + var $plat = false; |
|
| 315 | + var $lien = false; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -323,37 +323,37 @@ discard block |
||
| 323 | 323 | * @package SPIP\Compilateur\AST |
| 324 | 324 | **/ |
| 325 | 325 | class Critere { |
| 326 | - /** |
|
| 327 | - * Type de noeud |
|
| 328 | - * @var string */ |
|
| 329 | - public $type = 'critere'; |
|
| 330 | - |
|
| 331 | - /** |
|
| 332 | - * Opérateur (>, <, >=, IN, ...) |
|
| 333 | - * @var null|string */ |
|
| 334 | - public $op; |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * Présence d'une négation (truc !op valeur) |
|
| 338 | - * @var null|string */ |
|
| 339 | - public $not; |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Présence d'une exclusion (!truc op valeur) |
|
| 343 | - * @var null|string */ |
|
| 344 | - public $exclus; |
|
| 345 | - |
|
| 346 | - /** |
|
| 347 | - * Paramètres du critère |
|
| 348 | - * - $param[0] : élément avant l'opérateur |
|
| 349 | - * - $param[1..n] : éléments après l'opérateur |
|
| 350 | - * @var array */ |
|
| 351 | - var $param = array(); |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Numéro de ligne dans le code source du squelette |
|
| 355 | - * @var int */ |
|
| 356 | - public $ligne = 0; |
|
| 326 | + /** |
|
| 327 | + * Type de noeud |
|
| 328 | + * @var string */ |
|
| 329 | + public $type = 'critere'; |
|
| 330 | + |
|
| 331 | + /** |
|
| 332 | + * Opérateur (>, <, >=, IN, ...) |
|
| 333 | + * @var null|string */ |
|
| 334 | + public $op; |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * Présence d'une négation (truc !op valeur) |
|
| 338 | + * @var null|string */ |
|
| 339 | + public $not; |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Présence d'une exclusion (!truc op valeur) |
|
| 343 | + * @var null|string */ |
|
| 344 | + public $exclus; |
|
| 345 | + |
|
| 346 | + /** |
|
| 347 | + * Paramètres du critère |
|
| 348 | + * - $param[0] : élément avant l'opérateur |
|
| 349 | + * - $param[1..n] : éléments après l'opérateur |
|
| 350 | + * @var array */ |
|
| 351 | + var $param = array(); |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Numéro de ligne dans le code source du squelette |
|
| 355 | + * @var int */ |
|
| 356 | + public $ligne = 0; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -362,106 +362,106 @@ discard block |
||
| 362 | 362 | * @package SPIP\Compilateur\AST |
| 363 | 363 | **/ |
| 364 | 364 | class Champ { |
| 365 | - /** |
|
| 366 | - * Type de noeud |
|
| 367 | - * @var string */ |
|
| 368 | - public $type = 'champ'; |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Nom du champ demandé. Exemple 'ID_ARTICLE' |
|
| 372 | - * @var string|null */ |
|
| 373 | - public $nom_champ; |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * Identifiant de la boucle parente si explicité |
|
| 377 | - * @var string|null */ |
|
| 378 | - public $nom_boucle= ''; |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Partie optionnelle avant |
|
| 382 | - * @var null|string|array */ |
|
| 383 | - public $avant; |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * Partie optionnelle après |
|
| 387 | - * @var null|string|array */ |
|
| 388 | - public $apres; |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Étoiles : annuler des automatismes |
|
| 392 | - * |
|
| 393 | - * - '*' annule les filtres automatiques |
|
| 394 | - * - '**' annule en plus les protections de scripts |
|
| 395 | - * @var null|string */ |
|
| 396 | - public $etoile; |
|
| 397 | - |
|
| 398 | - /** |
|
| 399 | - * Arguments et filtres explicites sur la balise |
|
| 400 | - * - $param[0] contient les arguments de la balise |
|
| 401 | - * - $param[1..n] contient les filtres à appliquer à la balise |
|
| 402 | - * @var array */ |
|
| 403 | - public $param = array(); |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Source des filtres (compatibilité) (?) |
|
| 407 | - * @var array|null */ |
|
| 408 | - public $fonctions = array(); |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Identifiant de la boucle |
|
| 412 | - * @var string */ |
|
| 413 | - public $id_boucle = ''; |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * AST du squelette, liste de toutes les boucles |
|
| 417 | - * @var Boucles[] */ |
|
| 418 | - public $boucles; |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 422 | - * @var string|null */ |
|
| 423 | - public $type_requete; |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Résultat de la compilation: toujours une expression PHP |
|
| 427 | - * @var string */ |
|
| 428 | - public $code = ''; |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * Interdire les scripts |
|
| 432 | - * |
|
| 433 | - * false si on est sûr de cette balise |
|
| 434 | - * @see interdire_scripts() |
|
| 435 | - * @var bool */ |
|
| 436 | - public $interdire_scripts = true; |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * Description du squelette |
|
| 440 | - * |
|
| 441 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 442 | - * |
|
| 443 | - * Peut contenir les index : |
|
| 444 | - * - nom : Nom du fichier de cache |
|
| 445 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 446 | - * - sourcefile : Chemin du squelette |
|
| 447 | - * - squelette : Code du squelette |
|
| 448 | - * - id_mere : Identifiant de la boucle parente |
|
| 449 | - * - documents : Pour embed et img dans les textes |
|
| 450 | - * - session : Pour un cache sessionné par auteur |
|
| 451 | - * - niv : Niveau de tabulation |
|
| 452 | - * |
|
| 453 | - * @var array */ |
|
| 454 | - public $descr = array(); |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * Numéro de ligne dans le code source du squelette |
|
| 458 | - * @var int */ |
|
| 459 | - public $ligne = 0; |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * Drapeau pour reperer les balises calculées par une fonction explicite |
|
| 463 | - * @var bool */ |
|
| 464 | - public $balise_calculee = false; |
|
| 365 | + /** |
|
| 366 | + * Type de noeud |
|
| 367 | + * @var string */ |
|
| 368 | + public $type = 'champ'; |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Nom du champ demandé. Exemple 'ID_ARTICLE' |
|
| 372 | + * @var string|null */ |
|
| 373 | + public $nom_champ; |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * Identifiant de la boucle parente si explicité |
|
| 377 | + * @var string|null */ |
|
| 378 | + public $nom_boucle= ''; |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Partie optionnelle avant |
|
| 382 | + * @var null|string|array */ |
|
| 383 | + public $avant; |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * Partie optionnelle après |
|
| 387 | + * @var null|string|array */ |
|
| 388 | + public $apres; |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Étoiles : annuler des automatismes |
|
| 392 | + * |
|
| 393 | + * - '*' annule les filtres automatiques |
|
| 394 | + * - '**' annule en plus les protections de scripts |
|
| 395 | + * @var null|string */ |
|
| 396 | + public $etoile; |
|
| 397 | + |
|
| 398 | + /** |
|
| 399 | + * Arguments et filtres explicites sur la balise |
|
| 400 | + * - $param[0] contient les arguments de la balise |
|
| 401 | + * - $param[1..n] contient les filtres à appliquer à la balise |
|
| 402 | + * @var array */ |
|
| 403 | + public $param = array(); |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Source des filtres (compatibilité) (?) |
|
| 407 | + * @var array|null */ |
|
| 408 | + public $fonctions = array(); |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Identifiant de la boucle |
|
| 412 | + * @var string */ |
|
| 413 | + public $id_boucle = ''; |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * AST du squelette, liste de toutes les boucles |
|
| 417 | + * @var Boucles[] */ |
|
| 418 | + public $boucles; |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 422 | + * @var string|null */ |
|
| 423 | + public $type_requete; |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Résultat de la compilation: toujours une expression PHP |
|
| 427 | + * @var string */ |
|
| 428 | + public $code = ''; |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * Interdire les scripts |
|
| 432 | + * |
|
| 433 | + * false si on est sûr de cette balise |
|
| 434 | + * @see interdire_scripts() |
|
| 435 | + * @var bool */ |
|
| 436 | + public $interdire_scripts = true; |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * Description du squelette |
|
| 440 | + * |
|
| 441 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 442 | + * |
|
| 443 | + * Peut contenir les index : |
|
| 444 | + * - nom : Nom du fichier de cache |
|
| 445 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 446 | + * - sourcefile : Chemin du squelette |
|
| 447 | + * - squelette : Code du squelette |
|
| 448 | + * - id_mere : Identifiant de la boucle parente |
|
| 449 | + * - documents : Pour embed et img dans les textes |
|
| 450 | + * - session : Pour un cache sessionné par auteur |
|
| 451 | + * - niv : Niveau de tabulation |
|
| 452 | + * |
|
| 453 | + * @var array */ |
|
| 454 | + public $descr = array(); |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * Numéro de ligne dans le code source du squelette |
|
| 458 | + * @var int */ |
|
| 459 | + public $ligne = 0; |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * Drapeau pour reperer les balises calculées par une fonction explicite |
|
| 463 | + * @var bool */ |
|
| 464 | + public $balise_calculee = false; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | |
@@ -469,94 +469,94 @@ discard block |
||
| 469 | 469 | * Description d'une chaîne de langue |
| 470 | 470 | **/ |
| 471 | 471 | class Idiome { |
| 472 | - /** |
|
| 473 | - * Type de noeud |
|
| 474 | - * @var string */ |
|
| 475 | - public $type = 'idiome'; |
|
| 476 | - |
|
| 477 | - /** |
|
| 478 | - * Clé de traduction demandée. Exemple 'item_oui' |
|
| 479 | - * @var string */ |
|
| 480 | - public $nom_champ = ""; |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * Module de langue où chercher la clé de traduction. Exemple 'medias' |
|
| 484 | - * @var string */ |
|
| 485 | - public $module = ""; |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * Arguments à passer à la chaîne |
|
| 489 | - * @var array */ |
|
| 490 | - public $arg = array(); |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * Filtres à appliquer au résultat |
|
| 494 | - * @var array */ |
|
| 495 | - public $param = array(); |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * Source des filtres (compatibilité) (?) |
|
| 499 | - * @var array|null */ |
|
| 500 | - public $fonctions = array(); |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * Inutilisé, propriété générique de l'AST |
|
| 504 | - * @var string|array */ |
|
| 505 | - public $avant = ''; |
|
| 506 | - |
|
| 507 | - /** |
|
| 508 | - * Inutilisé, propriété générique de l'AST |
|
| 509 | - * @var string|array */ |
|
| 510 | - public $apres = ''; |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * Identifiant de la boucle |
|
| 514 | - * @var string */ |
|
| 515 | - public $id_boucle = ''; |
|
| 516 | - |
|
| 517 | - /** |
|
| 518 | - * AST du squelette, liste de toutes les boucles |
|
| 519 | - * @var Boucles[] */ |
|
| 520 | - public $boucles; |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 524 | - * @var string|null */ |
|
| 525 | - public $type_requete; |
|
| 526 | - |
|
| 527 | - /** |
|
| 528 | - * Résultat de la compilation: toujours une expression PHP |
|
| 529 | - * @var string */ |
|
| 530 | - public $code = ''; |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * Interdire les scripts |
|
| 534 | - * @see interdire_scripts() |
|
| 535 | - * @var bool */ |
|
| 536 | - public $interdire_scripts = false; |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Description du squelette |
|
| 540 | - * |
|
| 541 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 542 | - * |
|
| 543 | - * Peut contenir les index : |
|
| 544 | - * - nom : Nom du fichier de cache |
|
| 545 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 546 | - * - sourcefile : Chemin du squelette |
|
| 547 | - * - squelette : Code du squelette |
|
| 548 | - * - id_mere : Identifiant de la boucle parente |
|
| 549 | - * - documents : Pour embed et img dans les textes |
|
| 550 | - * - session : Pour un cache sessionné par auteur |
|
| 551 | - * - niv : Niveau de tabulation |
|
| 552 | - * |
|
| 553 | - * @var array */ |
|
| 554 | - public $descr = array(); |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * Numéro de ligne dans le code source du squelette |
|
| 558 | - * @var int */ |
|
| 559 | - public $ligne = 0; |
|
| 472 | + /** |
|
| 473 | + * Type de noeud |
|
| 474 | + * @var string */ |
|
| 475 | + public $type = 'idiome'; |
|
| 476 | + |
|
| 477 | + /** |
|
| 478 | + * Clé de traduction demandée. Exemple 'item_oui' |
|
| 479 | + * @var string */ |
|
| 480 | + public $nom_champ = ""; |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * Module de langue où chercher la clé de traduction. Exemple 'medias' |
|
| 484 | + * @var string */ |
|
| 485 | + public $module = ""; |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * Arguments à passer à la chaîne |
|
| 489 | + * @var array */ |
|
| 490 | + public $arg = array(); |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * Filtres à appliquer au résultat |
|
| 494 | + * @var array */ |
|
| 495 | + public $param = array(); |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * Source des filtres (compatibilité) (?) |
|
| 499 | + * @var array|null */ |
|
| 500 | + public $fonctions = array(); |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * Inutilisé, propriété générique de l'AST |
|
| 504 | + * @var string|array */ |
|
| 505 | + public $avant = ''; |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * Inutilisé, propriété générique de l'AST |
|
| 509 | + * @var string|array */ |
|
| 510 | + public $apres = ''; |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * Identifiant de la boucle |
|
| 514 | + * @var string */ |
|
| 515 | + public $id_boucle = ''; |
|
| 516 | + |
|
| 517 | + /** |
|
| 518 | + * AST du squelette, liste de toutes les boucles |
|
| 519 | + * @var Boucles[] */ |
|
| 520 | + public $boucles; |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 524 | + * @var string|null */ |
|
| 525 | + public $type_requete; |
|
| 526 | + |
|
| 527 | + /** |
|
| 528 | + * Résultat de la compilation: toujours une expression PHP |
|
| 529 | + * @var string */ |
|
| 530 | + public $code = ''; |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * Interdire les scripts |
|
| 534 | + * @see interdire_scripts() |
|
| 535 | + * @var bool */ |
|
| 536 | + public $interdire_scripts = false; |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Description du squelette |
|
| 540 | + * |
|
| 541 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 542 | + * |
|
| 543 | + * Peut contenir les index : |
|
| 544 | + * - nom : Nom du fichier de cache |
|
| 545 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 546 | + * - sourcefile : Chemin du squelette |
|
| 547 | + * - squelette : Code du squelette |
|
| 548 | + * - id_mere : Identifiant de la boucle parente |
|
| 549 | + * - documents : Pour embed et img dans les textes |
|
| 550 | + * - session : Pour un cache sessionné par auteur |
|
| 551 | + * - niv : Niveau de tabulation |
|
| 552 | + * |
|
| 553 | + * @var array */ |
|
| 554 | + public $descr = array(); |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * Numéro de ligne dans le code source du squelette |
|
| 558 | + * @var int */ |
|
| 559 | + public $ligne = 0; |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** |
@@ -565,22 +565,22 @@ discard block |
||
| 565 | 565 | * @package SPIP\Compilateur\AST |
| 566 | 566 | **/ |
| 567 | 567 | class Polyglotte { |
| 568 | - /** |
|
| 569 | - * Type de noeud |
|
| 570 | - * @var string */ |
|
| 571 | - public $type = 'polyglotte'; |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * Tableau des traductions possibles classées par langue |
|
| 575 | - * |
|
| 576 | - * Tableau code de langue => texte |
|
| 577 | - * @var array */ |
|
| 578 | - var $traductions = array(); |
|
| 579 | - |
|
| 580 | - /** |
|
| 581 | - * Numéro de ligne dans le code source du squelette |
|
| 582 | - * @var int */ |
|
| 583 | - public $ligne = 0; |
|
| 568 | + /** |
|
| 569 | + * Type de noeud |
|
| 570 | + * @var string */ |
|
| 571 | + public $type = 'polyglotte'; |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Tableau des traductions possibles classées par langue |
|
| 575 | + * |
|
| 576 | + * Tableau code de langue => texte |
|
| 577 | + * @var array */ |
|
| 578 | + var $traductions = array(); |
|
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * Numéro de ligne dans le code source du squelette |
|
| 582 | + * @var int */ |
|
| 583 | + public $ligne = 0; |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | |
@@ -606,87 +606,87 @@ discard block |
||
| 606 | 606 | * @return void |
| 607 | 607 | */ |
| 608 | 608 | function declarer_interfaces(){ |
| 609 | - global $exceptions_des_tables, $table_des_tables, $table_date, $table_titre, $table_statut; |
|
| 610 | - |
|
| 611 | - $table_des_tables['articles']='articles'; |
|
| 612 | - $table_des_tables['auteurs']='auteurs'; |
|
| 613 | - $table_des_tables['rubriques']='rubriques'; |
|
| 614 | - $table_des_tables['hierarchie']='rubriques'; |
|
| 615 | - |
|
| 616 | - // definition des statuts de publication |
|
| 617 | - global $tables_statut; |
|
| 618 | - $table_statut = array(); |
|
| 619 | - |
|
| 620 | - // |
|
| 621 | - // tableau des tables de jointures |
|
| 622 | - // Ex: gestion du critere {id_mot} dans la boucle(ARTICLES) |
|
| 623 | - global $tables_jointures; |
|
| 624 | - $tables_jointures = array(); |
|
| 625 | - $tables_jointures['spip_jobs'][] = 'jobs_liens'; |
|
| 626 | - |
|
| 627 | - global $exceptions_des_jointures; |
|
| 628 | - #$exceptions_des_jointures['titre_mot'] = array('spip_mots', 'titre'); // pour exemple |
|
| 629 | - $exceptions_des_jointures['profondeur'] = array('spip_rubriques', 'profondeur'); |
|
| 630 | - |
|
| 631 | - global $table_des_traitements; |
|
| 632 | - |
|
| 633 | - define('_TRAITEMENT_TYPO', 'typo(%s, "TYPO", $connect, $Pile[0])'); |
|
| 634 | - define('_TRAITEMENT_RACCOURCIS', 'propre(%s, $connect, $Pile[0])'); |
|
| 635 | - define('_TRAITEMENT_TYPO_SANS_NUMERO', 'typo(supprimer_numero(%s), "TYPO", $connect, $Pile[0])'); |
|
| 636 | - |
|
| 637 | - $table_des_traitements['BIO'][]= _TRAITEMENT_RACCOURCIS; |
|
| 638 | - $table_des_traitements['CHAPO'][]= _TRAITEMENT_RACCOURCIS; |
|
| 639 | - $table_des_traitements['DATE'][]= 'normaliser_date(%s)'; |
|
| 640 | - $table_des_traitements['DATE_REDAC'][]= 'normaliser_date(%s)'; |
|
| 641 | - $table_des_traitements['DATE_MODIF'][]= 'normaliser_date(%s)'; |
|
| 642 | - $table_des_traitements['DATE_NOUVEAUTES'][]= 'normaliser_date(%s)'; |
|
| 643 | - $table_des_traitements['DESCRIPTIF'][]= _TRAITEMENT_RACCOURCIS; |
|
| 644 | - $table_des_traitements['INTRODUCTION'][]= 'PtoBR('. _TRAITEMENT_RACCOURCIS .')'; |
|
| 645 | - $table_des_traitements['NOM_SITE_SPIP'][]= _TRAITEMENT_TYPO; |
|
| 646 | - $table_des_traitements['NOM'][]= _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 647 | - $table_des_traitements['AUTEUR'][]= _TRAITEMENT_TYPO; |
|
| 648 | - $table_des_traitements['PS'][]= _TRAITEMENT_RACCOURCIS; |
|
| 649 | - $table_des_traitements['SOURCE'][]= _TRAITEMENT_TYPO; |
|
| 650 | - $table_des_traitements['SOUSTITRE'][]= _TRAITEMENT_TYPO; |
|
| 651 | - $table_des_traitements['SURTITRE'][]= _TRAITEMENT_TYPO; |
|
| 652 | - $table_des_traitements['TAGS'][]= '%s'; |
|
| 653 | - $table_des_traitements['TEXTE'][]= _TRAITEMENT_RACCOURCIS; |
|
| 654 | - $table_des_traitements['TITRE'][]= _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 655 | - $table_des_traitements['TYPE'][]= _TRAITEMENT_TYPO; |
|
| 656 | - $table_des_traitements['DESCRIPTIF_SITE_SPIP'][]= _TRAITEMENT_RACCOURCIS; |
|
| 657 | - $table_des_traitements['SLOGAN_SITE_SPIP'][]= _TRAITEMENT_TYPO; |
|
| 658 | - $table_des_traitements['ENV'][]= 'entites_html(%s,true)'; |
|
| 659 | - |
|
| 660 | - // valeur par defaut pour les balises non listees ci-dessus |
|
| 661 | - $table_des_traitements['*'][]= false; // pas de traitement, mais permet au compilo de trouver la declaration suivante |
|
| 662 | - // toujours securiser les DATA |
|
| 663 | - $table_des_traitements['*']['DATA']= 'safehtml(%s)'; |
|
| 664 | - // expliciter pour VALEUR qui est un champ calcule et ne sera pas protege par le catch-all * |
|
| 665 | - $table_des_traitements['VALEUR']['DATA']= 'safehtml(%s)'; |
|
| 666 | - |
|
| 667 | - |
|
| 668 | - // gerer l'affectation en 2 temps car si le pipe n'est pas encore declare, on ecrase les globales |
|
| 669 | - $interfaces = pipeline('declarer_tables_interfaces', |
|
| 670 | - array( |
|
| 671 | - 'table_des_tables'=>$table_des_tables, |
|
| 672 | - 'exceptions_des_tables'=>$exceptions_des_tables, |
|
| 673 | - 'table_date'=>$table_date, |
|
| 674 | - 'table_titre'=>$table_titre, |
|
| 675 | - 'tables_jointures'=>$tables_jointures, |
|
| 676 | - 'exceptions_des_jointures'=>$exceptions_des_jointures, |
|
| 677 | - 'table_des_traitements'=>$table_des_traitements, |
|
| 678 | - 'table_statut'=>$table_statut, |
|
| 679 | - )); |
|
| 680 | - if ($interfaces){ |
|
| 681 | - $table_des_tables = $interfaces['table_des_tables']; |
|
| 682 | - $exceptions_des_tables = $interfaces['exceptions_des_tables']; |
|
| 683 | - $table_date = $interfaces['table_date']; |
|
| 684 | - $table_titre = $interfaces['table_titre']; |
|
| 685 | - $tables_jointures = $interfaces['tables_jointures']; |
|
| 686 | - $exceptions_des_jointures = $interfaces['exceptions_des_jointures']; |
|
| 687 | - $table_des_traitements = $interfaces['table_des_traitements']; |
|
| 688 | - $table_statut = $interfaces['table_statut']; |
|
| 689 | - } |
|
| 609 | + global $exceptions_des_tables, $table_des_tables, $table_date, $table_titre, $table_statut; |
|
| 610 | + |
|
| 611 | + $table_des_tables['articles']='articles'; |
|
| 612 | + $table_des_tables['auteurs']='auteurs'; |
|
| 613 | + $table_des_tables['rubriques']='rubriques'; |
|
| 614 | + $table_des_tables['hierarchie']='rubriques'; |
|
| 615 | + |
|
| 616 | + // definition des statuts de publication |
|
| 617 | + global $tables_statut; |
|
| 618 | + $table_statut = array(); |
|
| 619 | + |
|
| 620 | + // |
|
| 621 | + // tableau des tables de jointures |
|
| 622 | + // Ex: gestion du critere {id_mot} dans la boucle(ARTICLES) |
|
| 623 | + global $tables_jointures; |
|
| 624 | + $tables_jointures = array(); |
|
| 625 | + $tables_jointures['spip_jobs'][] = 'jobs_liens'; |
|
| 626 | + |
|
| 627 | + global $exceptions_des_jointures; |
|
| 628 | + #$exceptions_des_jointures['titre_mot'] = array('spip_mots', 'titre'); // pour exemple |
|
| 629 | + $exceptions_des_jointures['profondeur'] = array('spip_rubriques', 'profondeur'); |
|
| 630 | + |
|
| 631 | + global $table_des_traitements; |
|
| 632 | + |
|
| 633 | + define('_TRAITEMENT_TYPO', 'typo(%s, "TYPO", $connect, $Pile[0])'); |
|
| 634 | + define('_TRAITEMENT_RACCOURCIS', 'propre(%s, $connect, $Pile[0])'); |
|
| 635 | + define('_TRAITEMENT_TYPO_SANS_NUMERO', 'typo(supprimer_numero(%s), "TYPO", $connect, $Pile[0])'); |
|
| 636 | + |
|
| 637 | + $table_des_traitements['BIO'][]= _TRAITEMENT_RACCOURCIS; |
|
| 638 | + $table_des_traitements['CHAPO'][]= _TRAITEMENT_RACCOURCIS; |
|
| 639 | + $table_des_traitements['DATE'][]= 'normaliser_date(%s)'; |
|
| 640 | + $table_des_traitements['DATE_REDAC'][]= 'normaliser_date(%s)'; |
|
| 641 | + $table_des_traitements['DATE_MODIF'][]= 'normaliser_date(%s)'; |
|
| 642 | + $table_des_traitements['DATE_NOUVEAUTES'][]= 'normaliser_date(%s)'; |
|
| 643 | + $table_des_traitements['DESCRIPTIF'][]= _TRAITEMENT_RACCOURCIS; |
|
| 644 | + $table_des_traitements['INTRODUCTION'][]= 'PtoBR('. _TRAITEMENT_RACCOURCIS .')'; |
|
| 645 | + $table_des_traitements['NOM_SITE_SPIP'][]= _TRAITEMENT_TYPO; |
|
| 646 | + $table_des_traitements['NOM'][]= _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 647 | + $table_des_traitements['AUTEUR'][]= _TRAITEMENT_TYPO; |
|
| 648 | + $table_des_traitements['PS'][]= _TRAITEMENT_RACCOURCIS; |
|
| 649 | + $table_des_traitements['SOURCE'][]= _TRAITEMENT_TYPO; |
|
| 650 | + $table_des_traitements['SOUSTITRE'][]= _TRAITEMENT_TYPO; |
|
| 651 | + $table_des_traitements['SURTITRE'][]= _TRAITEMENT_TYPO; |
|
| 652 | + $table_des_traitements['TAGS'][]= '%s'; |
|
| 653 | + $table_des_traitements['TEXTE'][]= _TRAITEMENT_RACCOURCIS; |
|
| 654 | + $table_des_traitements['TITRE'][]= _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 655 | + $table_des_traitements['TYPE'][]= _TRAITEMENT_TYPO; |
|
| 656 | + $table_des_traitements['DESCRIPTIF_SITE_SPIP'][]= _TRAITEMENT_RACCOURCIS; |
|
| 657 | + $table_des_traitements['SLOGAN_SITE_SPIP'][]= _TRAITEMENT_TYPO; |
|
| 658 | + $table_des_traitements['ENV'][]= 'entites_html(%s,true)'; |
|
| 659 | + |
|
| 660 | + // valeur par defaut pour les balises non listees ci-dessus |
|
| 661 | + $table_des_traitements['*'][]= false; // pas de traitement, mais permet au compilo de trouver la declaration suivante |
|
| 662 | + // toujours securiser les DATA |
|
| 663 | + $table_des_traitements['*']['DATA']= 'safehtml(%s)'; |
|
| 664 | + // expliciter pour VALEUR qui est un champ calcule et ne sera pas protege par le catch-all * |
|
| 665 | + $table_des_traitements['VALEUR']['DATA']= 'safehtml(%s)'; |
|
| 666 | + |
|
| 667 | + |
|
| 668 | + // gerer l'affectation en 2 temps car si le pipe n'est pas encore declare, on ecrase les globales |
|
| 669 | + $interfaces = pipeline('declarer_tables_interfaces', |
|
| 670 | + array( |
|
| 671 | + 'table_des_tables'=>$table_des_tables, |
|
| 672 | + 'exceptions_des_tables'=>$exceptions_des_tables, |
|
| 673 | + 'table_date'=>$table_date, |
|
| 674 | + 'table_titre'=>$table_titre, |
|
| 675 | + 'tables_jointures'=>$tables_jointures, |
|
| 676 | + 'exceptions_des_jointures'=>$exceptions_des_jointures, |
|
| 677 | + 'table_des_traitements'=>$table_des_traitements, |
|
| 678 | + 'table_statut'=>$table_statut, |
|
| 679 | + )); |
|
| 680 | + if ($interfaces){ |
|
| 681 | + $table_des_tables = $interfaces['table_des_tables']; |
|
| 682 | + $exceptions_des_tables = $interfaces['exceptions_des_tables']; |
|
| 683 | + $table_date = $interfaces['table_date']; |
|
| 684 | + $table_titre = $interfaces['table_titre']; |
|
| 685 | + $tables_jointures = $interfaces['tables_jointures']; |
|
| 686 | + $exceptions_des_jointures = $interfaces['exceptions_des_jointures']; |
|
| 687 | + $table_des_traitements = $interfaces['table_des_traitements']; |
|
| 688 | + $table_statut = $interfaces['table_statut']; |
|
| 689 | + } |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | declarer_interfaces(); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | /** |
| 169 | 169 | * Identifiant de la boucle parente |
| 170 | 170 | * @var string */ |
| 171 | - public $id_parent =''; |
|
| 171 | + public $id_parent = ''; |
|
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * Partie optionnelle avant |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @var string|null */ |
| 255 | 255 | public $doublons; |
| 256 | 256 | |
| 257 | - var $partie, $total_parties,$mode_partie=''; |
|
| 257 | + var $partie, $total_parties, $mode_partie = ''; |
|
| 258 | 258 | var $externe = ''; # appel a partir d'une autre boucle (recursion) |
| 259 | 259 | // champs pour la construction de la requete SQL |
| 260 | 260 | var $select = array(); |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | var $group = array(); |
| 268 | 268 | var $order = array(); |
| 269 | 269 | var $default_order = array(); |
| 270 | - var $date = 'date' ; |
|
| 271 | - var $hash = "" ; |
|
| 272 | - var $in = "" ; |
|
| 270 | + var $date = 'date'; |
|
| 271 | + var $hash = ""; |
|
| 272 | + var $in = ""; |
|
| 273 | 273 | var $sous_requete = false; |
| 274 | 274 | var $hierarchie = ''; |
| 275 | 275 | var $statut = false; # definition/surcharge du statut des elements retournes |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | /** |
| 376 | 376 | * Identifiant de la boucle parente si explicité |
| 377 | 377 | * @var string|null */ |
| 378 | - public $nom_boucle= ''; |
|
| 378 | + public $nom_boucle = ''; |
|
| 379 | 379 | |
| 380 | 380 | /** |
| 381 | 381 | * Partie optionnelle avant |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | |
| 587 | 587 | |
| 588 | 588 | global $table_criteres_infixes; |
| 589 | -$table_criteres_infixes = array('<', '>', '<=', '>=', '==', '===', '!=', '!==', '<>', '?'); |
|
| 589 | +$table_criteres_infixes = array('<', '>', '<=', '>=', '==', '===', '!=', '!==', '<>', '?'); |
|
| 590 | 590 | |
| 591 | 591 | global $exception_des_connect; |
| 592 | 592 | $exception_des_connect[] = ''; // ne pas transmettre le connect='' par les inclure |
@@ -605,13 +605,13 @@ discard block |
||
| 605 | 605 | * |
| 606 | 606 | * @return void |
| 607 | 607 | */ |
| 608 | -function declarer_interfaces(){ |
|
| 608 | +function declarer_interfaces() { |
|
| 609 | 609 | global $exceptions_des_tables, $table_des_tables, $table_date, $table_titre, $table_statut; |
| 610 | 610 | |
| 611 | - $table_des_tables['articles']='articles'; |
|
| 612 | - $table_des_tables['auteurs']='auteurs'; |
|
| 613 | - $table_des_tables['rubriques']='rubriques'; |
|
| 614 | - $table_des_tables['hierarchie']='rubriques'; |
|
| 611 | + $table_des_tables['articles'] = 'articles'; |
|
| 612 | + $table_des_tables['auteurs'] = 'auteurs'; |
|
| 613 | + $table_des_tables['rubriques'] = 'rubriques'; |
|
| 614 | + $table_des_tables['hierarchie'] = 'rubriques'; |
|
| 615 | 615 | |
| 616 | 616 | // definition des statuts de publication |
| 617 | 617 | global $tables_statut; |
@@ -634,35 +634,35 @@ discard block |
||
| 634 | 634 | define('_TRAITEMENT_RACCOURCIS', 'propre(%s, $connect, $Pile[0])'); |
| 635 | 635 | define('_TRAITEMENT_TYPO_SANS_NUMERO', 'typo(supprimer_numero(%s), "TYPO", $connect, $Pile[0])'); |
| 636 | 636 | |
| 637 | - $table_des_traitements['BIO'][]= _TRAITEMENT_RACCOURCIS; |
|
| 638 | - $table_des_traitements['CHAPO'][]= _TRAITEMENT_RACCOURCIS; |
|
| 639 | - $table_des_traitements['DATE'][]= 'normaliser_date(%s)'; |
|
| 640 | - $table_des_traitements['DATE_REDAC'][]= 'normaliser_date(%s)'; |
|
| 641 | - $table_des_traitements['DATE_MODIF'][]= 'normaliser_date(%s)'; |
|
| 642 | - $table_des_traitements['DATE_NOUVEAUTES'][]= 'normaliser_date(%s)'; |
|
| 643 | - $table_des_traitements['DESCRIPTIF'][]= _TRAITEMENT_RACCOURCIS; |
|
| 644 | - $table_des_traitements['INTRODUCTION'][]= 'PtoBR('. _TRAITEMENT_RACCOURCIS .')'; |
|
| 645 | - $table_des_traitements['NOM_SITE_SPIP'][]= _TRAITEMENT_TYPO; |
|
| 646 | - $table_des_traitements['NOM'][]= _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 647 | - $table_des_traitements['AUTEUR'][]= _TRAITEMENT_TYPO; |
|
| 648 | - $table_des_traitements['PS'][]= _TRAITEMENT_RACCOURCIS; |
|
| 649 | - $table_des_traitements['SOURCE'][]= _TRAITEMENT_TYPO; |
|
| 650 | - $table_des_traitements['SOUSTITRE'][]= _TRAITEMENT_TYPO; |
|
| 651 | - $table_des_traitements['SURTITRE'][]= _TRAITEMENT_TYPO; |
|
| 652 | - $table_des_traitements['TAGS'][]= '%s'; |
|
| 653 | - $table_des_traitements['TEXTE'][]= _TRAITEMENT_RACCOURCIS; |
|
| 654 | - $table_des_traitements['TITRE'][]= _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 655 | - $table_des_traitements['TYPE'][]= _TRAITEMENT_TYPO; |
|
| 656 | - $table_des_traitements['DESCRIPTIF_SITE_SPIP'][]= _TRAITEMENT_RACCOURCIS; |
|
| 657 | - $table_des_traitements['SLOGAN_SITE_SPIP'][]= _TRAITEMENT_TYPO; |
|
| 658 | - $table_des_traitements['ENV'][]= 'entites_html(%s,true)'; |
|
| 637 | + $table_des_traitements['BIO'][] = _TRAITEMENT_RACCOURCIS; |
|
| 638 | + $table_des_traitements['CHAPO'][] = _TRAITEMENT_RACCOURCIS; |
|
| 639 | + $table_des_traitements['DATE'][] = 'normaliser_date(%s)'; |
|
| 640 | + $table_des_traitements['DATE_REDAC'][] = 'normaliser_date(%s)'; |
|
| 641 | + $table_des_traitements['DATE_MODIF'][] = 'normaliser_date(%s)'; |
|
| 642 | + $table_des_traitements['DATE_NOUVEAUTES'][] = 'normaliser_date(%s)'; |
|
| 643 | + $table_des_traitements['DESCRIPTIF'][] = _TRAITEMENT_RACCOURCIS; |
|
| 644 | + $table_des_traitements['INTRODUCTION'][] = 'PtoBR('._TRAITEMENT_RACCOURCIS.')'; |
|
| 645 | + $table_des_traitements['NOM_SITE_SPIP'][] = _TRAITEMENT_TYPO; |
|
| 646 | + $table_des_traitements['NOM'][] = _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 647 | + $table_des_traitements['AUTEUR'][] = _TRAITEMENT_TYPO; |
|
| 648 | + $table_des_traitements['PS'][] = _TRAITEMENT_RACCOURCIS; |
|
| 649 | + $table_des_traitements['SOURCE'][] = _TRAITEMENT_TYPO; |
|
| 650 | + $table_des_traitements['SOUSTITRE'][] = _TRAITEMENT_TYPO; |
|
| 651 | + $table_des_traitements['SURTITRE'][] = _TRAITEMENT_TYPO; |
|
| 652 | + $table_des_traitements['TAGS'][] = '%s'; |
|
| 653 | + $table_des_traitements['TEXTE'][] = _TRAITEMENT_RACCOURCIS; |
|
| 654 | + $table_des_traitements['TITRE'][] = _TRAITEMENT_TYPO_SANS_NUMERO; |
|
| 655 | + $table_des_traitements['TYPE'][] = _TRAITEMENT_TYPO; |
|
| 656 | + $table_des_traitements['DESCRIPTIF_SITE_SPIP'][] = _TRAITEMENT_RACCOURCIS; |
|
| 657 | + $table_des_traitements['SLOGAN_SITE_SPIP'][] = _TRAITEMENT_TYPO; |
|
| 658 | + $table_des_traitements['ENV'][] = 'entites_html(%s,true)'; |
|
| 659 | 659 | |
| 660 | 660 | // valeur par defaut pour les balises non listees ci-dessus |
| 661 | - $table_des_traitements['*'][]= false; // pas de traitement, mais permet au compilo de trouver la declaration suivante |
|
| 661 | + $table_des_traitements['*'][] = false; // pas de traitement, mais permet au compilo de trouver la declaration suivante |
|
| 662 | 662 | // toujours securiser les DATA |
| 663 | - $table_des_traitements['*']['DATA']= 'safehtml(%s)'; |
|
| 663 | + $table_des_traitements['*']['DATA'] = 'safehtml(%s)'; |
|
| 664 | 664 | // expliciter pour VALEUR qui est un champ calcule et ne sera pas protege par le catch-all * |
| 665 | - $table_des_traitements['VALEUR']['DATA']= 'safehtml(%s)'; |
|
| 665 | + $table_des_traitements['VALEUR']['DATA'] = 'safehtml(%s)'; |
|
| 666 | 666 | |
| 667 | 667 | |
| 668 | 668 | // gerer l'affectation en 2 temps car si le pipe n'est pas encore declare, on ecrase les globales |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | 'table_des_traitements'=>$table_des_traitements, |
| 678 | 678 | 'table_statut'=>$table_statut, |
| 679 | 679 | )); |
| 680 | - if ($interfaces){ |
|
| 680 | + if ($interfaces) { |
|
| 681 | 681 | $table_des_tables = $interfaces['table_des_tables']; |
| 682 | 682 | $exceptions_des_tables = $interfaces['exceptions_des_tables']; |
| 683 | 683 | $table_date = $interfaces['table_date']; |
@@ -16,7 +16,9 @@ |
||
| 16 | 16 | * @package SPIP\Compilateur\AST |
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 19 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 20 | + return; |
|
| 21 | +} |
|
| 20 | 22 | |
| 21 | 23 | |
| 22 | 24 | /** |
@@ -21,74 +21,74 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // http://doc.spip.org/@interprete_argument_balise |
| 23 | 23 | function interprete_argument_balise($n,$p) { |
| 24 | - if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n)) |
|
| 25 | - return calculer_liste($p->param[0][$n], |
|
| 26 | - $p->descr, |
|
| 27 | - $p->boucles, |
|
| 28 | - $p->id_boucle); |
|
| 29 | - else |
|
| 30 | - return NULL; |
|
| 24 | + if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n)) |
|
| 25 | + return calculer_liste($p->param[0][$n], |
|
| 26 | + $p->descr, |
|
| 27 | + $p->boucles, |
|
| 28 | + $p->id_boucle); |
|
| 29 | + else |
|
| 30 | + return NULL; |
|
| 31 | 31 | } |
| 32 | 32 | // |
| 33 | 33 | // Definition des balises |
| 34 | 34 | // |
| 35 | 35 | // http://doc.spip.org/@balise_NOM_SITE_SPIP_dist |
| 36 | 36 | function balise_NOM_SITE_SPIP_dist($p) { |
| 37 | - $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 38 | - #$p->interdire_scripts = true; |
|
| 39 | - return $p; |
|
| 37 | + $p->code = "\$GLOBALS['meta']['nom_site']"; |
|
| 38 | + #$p->interdire_scripts = true; |
|
| 39 | + return $p; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // http://doc.spip.org/@balise_EMAIL_WEBMASTER_dist |
| 43 | 43 | function balise_EMAIL_WEBMASTER_dist($p) { |
| 44 | - $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 45 | - #$p->interdire_scripts = true; |
|
| 46 | - return $p; |
|
| 44 | + $p->code = "\$GLOBALS['meta']['email_webmaster']"; |
|
| 45 | + #$p->interdire_scripts = true; |
|
| 46 | + return $p; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // http://doc.spip.org/@balise_DESCRIPTIF_SITE_SPIP_dist |
| 50 | 50 | function balise_DESCRIPTIF_SITE_SPIP_dist($p) { |
| 51 | - $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 52 | - #$p->interdire_scripts = true; |
|
| 53 | - return $p; |
|
| 51 | + $p->code = "\$GLOBALS['meta']['descriptif_site']"; |
|
| 52 | + #$p->interdire_scripts = true; |
|
| 53 | + return $p; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // http://doc.spip.org/@balise_CHARSET_dist |
| 57 | 57 | function balise_CHARSET_dist($p) { |
| 58 | - $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 59 | - #$p->interdire_scripts = true; |
|
| 60 | - return $p; |
|
| 58 | + $p->code = "\$GLOBALS['meta']['charset']"; |
|
| 59 | + #$p->interdire_scripts = true; |
|
| 60 | + return $p; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // http://doc.spip.org/@balise_LANG_LEFT_dist |
| 64 | 64 | function balise_LANG_LEFT_dist($p) { |
| 65 | - $_lang = champ_sql('lang', $p); |
|
| 66 | - $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 67 | - $p->interdire_scripts = false; |
|
| 68 | - return $p; |
|
| 65 | + $_lang = champ_sql('lang', $p); |
|
| 66 | + $p->code = "lang_dir($_lang, 'left','right')"; |
|
| 67 | + $p->interdire_scripts = false; |
|
| 68 | + return $p; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // http://doc.spip.org/@balise_LANG_RIGHT_dist |
| 72 | 72 | function balise_LANG_RIGHT_dist($p) { |
| 73 | - $_lang = champ_sql('lang', $p); |
|
| 74 | - $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 75 | - $p->interdire_scripts = false; |
|
| 76 | - return $p; |
|
| 73 | + $_lang = champ_sql('lang', $p); |
|
| 74 | + $p->code = "lang_dir($_lang, 'right','left')"; |
|
| 75 | + $p->interdire_scripts = false; |
|
| 76 | + return $p; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // http://doc.spip.org/@balise_LANG_DIR_dist |
| 80 | 80 | function balise_LANG_DIR_dist($p) { |
| 81 | - $_lang = champ_sql('lang', $p); |
|
| 82 | - $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 83 | - $p->interdire_scripts = false; |
|
| 84 | - return $p; |
|
| 81 | + $_lang = champ_sql('lang', $p); |
|
| 82 | + $p->code = "lang_dir($_lang, 'ltr','rtl')"; |
|
| 83 | + $p->interdire_scripts = false; |
|
| 84 | + return $p; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // http://doc.spip.org/@balise_PUCE_dist |
| 88 | 88 | function balise_PUCE_dist($p) { |
| 89 | - $p->code = "definir_puce()"; |
|
| 90 | - $p->interdire_scripts = false; |
|
| 91 | - return $p; |
|
| 89 | + $p->code = "definir_puce()"; |
|
| 90 | + $p->interdire_scripts = false; |
|
| 91 | + return $p; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // #DATE |
@@ -97,67 +97,67 @@ discard block |
||
| 97 | 97 | // http://www.spip.net/fr_article1971.html |
| 98 | 98 | // http://doc.spip.org/@balise_DATE_dist |
| 99 | 99 | function balise_DATE_dist ($p) { |
| 100 | - $d = champ_sql('date', $p); |
|
| 100 | + $d = champ_sql('date', $p); |
|
| 101 | 101 | # if ($d === "@\$Pile[0]['date']") |
| 102 | 102 | # $d = "isset(\$Pile[0]['date']) ? $d : time()"; |
| 103 | - $p->code = $d; |
|
| 104 | - return $p; |
|
| 103 | + $p->code = $d; |
|
| 104 | + return $p; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // #DATE_REDAC |
| 108 | 108 | // http://www.spip.net/fr_article1971.html |
| 109 | 109 | // http://doc.spip.org/@balise_DATE_REDAC_dist |
| 110 | 110 | function balise_DATE_REDAC_dist ($p) { |
| 111 | - $d = champ_sql('date_redac', $p); |
|
| 111 | + $d = champ_sql('date_redac', $p); |
|
| 112 | 112 | # if ($d === "@\$Pile[0]['date_redac']") |
| 113 | 113 | # $d = "isset(\$Pile[0]['date_redac']) ? $d : time()"; |
| 114 | - $p->code = $d; |
|
| 115 | - $p->interdire_scripts = false; |
|
| 116 | - return $p; |
|
| 114 | + $p->code = $d; |
|
| 115 | + $p->interdire_scripts = false; |
|
| 116 | + return $p; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // #DATE_MODIF |
| 120 | 120 | // http://www.spip.net/fr_article1971.html |
| 121 | 121 | // http://doc.spip.org/@balise_DATE_MODIF_dist |
| 122 | 122 | function balise_DATE_MODIF_dist ($p) { |
| 123 | - $p->code = champ_sql('date_modif', $p); |
|
| 124 | - $p->interdire_scripts = false; |
|
| 125 | - return $p; |
|
| 123 | + $p->code = champ_sql('date_modif', $p); |
|
| 124 | + $p->interdire_scripts = false; |
|
| 125 | + return $p; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // #DATE_NOUVEAUTES |
| 129 | 129 | // http://www.spip.net/fr_article1971.html |
| 130 | 130 | // http://doc.spip.org/@balise_DATE_NOUVEAUTES_dist |
| 131 | 131 | function balise_DATE_NOUVEAUTES_dist($p) { |
| 132 | - $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 132 | + $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui' |
|
| 133 | 133 | AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ? |
| 134 | 134 | \$GLOBALS['meta']['dernier_envoi_neuf'] : |
| 135 | 135 | \"'0000-00-00'\")"; |
| 136 | - $p->interdire_scripts = false; |
|
| 137 | - return $p; |
|
| 136 | + $p->interdire_scripts = false; |
|
| 137 | + return $p; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // http://doc.spip.org/@balise_DOSSIER_SQUELETTE_dist |
| 141 | 141 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 142 | - $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 143 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 144 | - $p->interdire_scripts = false; |
|
| 145 | - return $p; |
|
| 142 | + $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
|
| 143 | + $p->code = "_DIR_RACINE . '$code'" . |
|
| 144 | + $p->interdire_scripts = false; |
|
| 145 | + return $p; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // http://doc.spip.org/@balise_SQUELETTE_dist |
| 149 | 149 | function balise_SQUELETTE_dist($p) { |
| 150 | - $code = addslashes($p->descr['sourcefile']); |
|
| 151 | - $p->code = "'$code'" . |
|
| 152 | - $p->interdire_scripts = false; |
|
| 153 | - return $p; |
|
| 150 | + $code = addslashes($p->descr['sourcefile']); |
|
| 151 | + $p->code = "'$code'" . |
|
| 152 | + $p->interdire_scripts = false; |
|
| 153 | + return $p; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // http://doc.spip.org/@balise_SPIP_VERSION_dist |
| 157 | 157 | function balise_SPIP_VERSION_dist($p) { |
| 158 | - $p->code = "spip_version()"; |
|
| 159 | - $p->interdire_scripts = false; |
|
| 160 | - return $p; |
|
| 158 | + $p->code = "spip_version()"; |
|
| 159 | + $p->interdire_scripts = false; |
|
| 160 | + return $p; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | |
@@ -182,105 +182,105 @@ discard block |
||
| 182 | 182 | * Pile complétée par le code à générer |
| 183 | 183 | **/ |
| 184 | 184 | function balise_NOM_SITE_dist($p) { |
| 185 | - if (!$p->etoile) { |
|
| 186 | - $p->code = "supprimer_numero(calculer_url(" . |
|
| 187 | - champ_sql('url_site',$p) ."," . |
|
| 188 | - champ_sql('nom_site',$p) . |
|
| 189 | - ", 'titre', \$connect, false))"; |
|
| 190 | - } else |
|
| 191 | - $p->code = champ_sql('nom_site',$p); |
|
| 185 | + if (!$p->etoile) { |
|
| 186 | + $p->code = "supprimer_numero(calculer_url(" . |
|
| 187 | + champ_sql('url_site',$p) ."," . |
|
| 188 | + champ_sql('nom_site',$p) . |
|
| 189 | + ", 'titre', \$connect, false))"; |
|
| 190 | + } else |
|
| 191 | + $p->code = champ_sql('nom_site',$p); |
|
| 192 | 192 | |
| 193 | - $p->interdire_scripts = true; |
|
| 194 | - return $p; |
|
| 193 | + $p->interdire_scripts = true; |
|
| 194 | + return $p; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // http://doc.spip.org/@balise_NOTES_dist |
| 198 | 198 | function balise_NOTES_dist($p) { |
| 199 | - // Recuperer les notes |
|
| 200 | - $p->code = 'calculer_notes()'; |
|
| 201 | - #$p->interdire_scripts = true; |
|
| 202 | - return $p; |
|
| 199 | + // Recuperer les notes |
|
| 200 | + $p->code = 'calculer_notes()'; |
|
| 201 | + #$p->interdire_scripts = true; |
|
| 202 | + return $p; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // http://doc.spip.org/@balise_RECHERCHE_dist |
| 206 | 206 | function balise_RECHERCHE_dist($p) { |
| 207 | - $p->code = 'entites_html(_request("recherche"))'; |
|
| 208 | - $p->interdire_scripts = false; |
|
| 209 | - return $p; |
|
| 207 | + $p->code = 'entites_html(_request("recherche"))'; |
|
| 208 | + $p->interdire_scripts = false; |
|
| 209 | + return $p; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // http://doc.spip.org/@balise_COMPTEUR_BOUCLE_dist |
| 213 | 213 | function balise_COMPTEUR_BOUCLE_dist($p) { |
| 214 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 215 | - if ($b === '') { |
|
| 216 | - $msg = array('zbug_champ_hors_boucle', |
|
| 217 | - array('champ' => '#COMPTEUR_BOUCLE') |
|
| 218 | - ); |
|
| 219 | - erreur_squelette($msg, $p); |
|
| 220 | - } else { |
|
| 221 | - $p->code = "\$Numrows['$b']['compteur_boucle']"; |
|
| 222 | - $p->boucles[$b]->cptrows = true; |
|
| 223 | - $p->interdire_scripts = false; |
|
| 224 | - return $p; |
|
| 225 | - } |
|
| 214 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 215 | + if ($b === '') { |
|
| 216 | + $msg = array('zbug_champ_hors_boucle', |
|
| 217 | + array('champ' => '#COMPTEUR_BOUCLE') |
|
| 218 | + ); |
|
| 219 | + erreur_squelette($msg, $p); |
|
| 220 | + } else { |
|
| 221 | + $p->code = "\$Numrows['$b']['compteur_boucle']"; |
|
| 222 | + $p->boucles[$b]->cptrows = true; |
|
| 223 | + $p->interdire_scripts = false; |
|
| 224 | + return $p; |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // http://doc.spip.org/@balise_TOTAL_BOUCLE_dist |
| 229 | 229 | function balise_TOTAL_BOUCLE_dist($p) { |
| 230 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 231 | - if ($b === '' || !isset($p->boucles[$b])) { |
|
| 232 | - $msg = array('zbug_champ_hors_boucle', |
|
| 233 | - array('champ' => "#$b" . 'TOTAL_BOUCLE') |
|
| 234 | - ); |
|
| 235 | - erreur_squelette($msg, $p); |
|
| 236 | - } else { |
|
| 237 | - $p->code = "\$Numrows['$b']['total']"; |
|
| 238 | - $p->boucles[$b]->numrows = true; |
|
| 239 | - $p->interdire_scripts = false; |
|
| 240 | - } |
|
| 241 | - return $p; |
|
| 230 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 231 | + if ($b === '' || !isset($p->boucles[$b])) { |
|
| 232 | + $msg = array('zbug_champ_hors_boucle', |
|
| 233 | + array('champ' => "#$b" . 'TOTAL_BOUCLE') |
|
| 234 | + ); |
|
| 235 | + erreur_squelette($msg, $p); |
|
| 236 | + } else { |
|
| 237 | + $p->code = "\$Numrows['$b']['total']"; |
|
| 238 | + $p->boucles[$b]->numrows = true; |
|
| 239 | + $p->interdire_scripts = false; |
|
| 240 | + } |
|
| 241 | + return $p; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Si on est hors d'une boucle {recherche}, ne pas "prendre" cette balise |
| 245 | 245 | // http://doc.spip.org/@balise_POINTS_dist |
| 246 | 246 | function balise_POINTS_dist($p) { |
| 247 | - return rindex_pile($p, 'points', 'recherche'); |
|
| 247 | + return rindex_pile($p, 'points', 'recherche'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | // http://doc.spip.org/@balise_POPULARITE_ABSOLUE_dist |
| 251 | 251 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 252 | - $p->code = 'ceil(' . |
|
| 253 | - champ_sql('popularite', $p) . |
|
| 254 | - ')'; |
|
| 255 | - $p->interdire_scripts = false; |
|
| 256 | - return $p; |
|
| 252 | + $p->code = 'ceil(' . |
|
| 253 | + champ_sql('popularite', $p) . |
|
| 254 | + ')'; |
|
| 255 | + $p->interdire_scripts = false; |
|
| 256 | + return $p; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // http://doc.spip.org/@balise_POPULARITE_SITE_dist |
| 260 | 260 | function balise_POPULARITE_SITE_dist($p) { |
| 261 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 262 | - $p->interdire_scripts = false; |
|
| 263 | - return $p; |
|
| 261 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])'; |
|
| 262 | + $p->interdire_scripts = false; |
|
| 263 | + return $p; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | // http://doc.spip.org/@balise_POPULARITE_MAX_dist |
| 267 | 267 | function balise_POPULARITE_MAX_dist($p) { |
| 268 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 269 | - $p->interdire_scripts = false; |
|
| 270 | - return $p; |
|
| 268 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])'; |
|
| 269 | + $p->interdire_scripts = false; |
|
| 270 | + return $p; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // http://doc.spip.org/@balise_EXPOSE_dist |
| 274 | 274 | function balise_EXPOSE_dist($p) { |
| 275 | - $on = "'on'"; |
|
| 276 | - $off= "''"; |
|
| 277 | - if (($v = interprete_argument_balise(1,$p))!==NULL){ |
|
| 278 | - $on = $v; |
|
| 279 | - if (($v = interprete_argument_balise(2,$p))!==NULL) |
|
| 280 | - $off = $v; |
|
| 275 | + $on = "'on'"; |
|
| 276 | + $off= "''"; |
|
| 277 | + if (($v = interprete_argument_balise(1,$p))!==NULL){ |
|
| 278 | + $on = $v; |
|
| 279 | + if (($v = interprete_argument_balise(2,$p))!==NULL) |
|
| 280 | + $off = $v; |
|
| 281 | 281 | |
| 282 | - } |
|
| 283 | - return calculer_balise_expose($p, $on, $off); |
|
| 282 | + } |
|
| 283 | + return calculer_balise_expose($p, $on, $off); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // #VALEUR renvoie le champ valeur |
@@ -288,44 +288,44 @@ discard block |
||
| 288 | 288 | // #VALEUR{a/b} renvoie #VALEUR|table_valeur{a/b} |
| 289 | 289 | // http://doc.spip.org/@balise_VALEUR_dist |
| 290 | 290 | function balise_VALEUR_dist($p) { |
| 291 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 292 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);; |
|
| 293 | - if (($v = interprete_argument_balise(1,$p))!==NULL){ |
|
| 294 | - $p->code = 'table_valeur('.$p->code.', '.$v.')'; |
|
| 295 | - } |
|
| 296 | - $p->interdire_scripts = true; |
|
| 297 | - return $p; |
|
| 291 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 292 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);; |
|
| 293 | + if (($v = interprete_argument_balise(1,$p))!==NULL){ |
|
| 294 | + $p->code = 'table_valeur('.$p->code.', '.$v.')'; |
|
| 295 | + } |
|
| 296 | + $p->interdire_scripts = true; |
|
| 297 | + return $p; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | // http://doc.spip.org/@calculer_balise_expose |
| 301 | 301 | function calculer_balise_expose($p, $on, $off) |
| 302 | 302 | { |
| 303 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 304 | - $key = $p->boucles[$b]->primary; |
|
| 305 | - $type = $p->boucles[$p->id_boucle]->primary; |
|
| 306 | - $desc = $p->boucles[$b]->show; |
|
| 307 | - $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 303 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 304 | + $key = $p->boucles[$b]->primary; |
|
| 305 | + $type = $p->boucles[$p->id_boucle]->primary; |
|
| 306 | + $desc = $p->boucles[$b]->show; |
|
| 307 | + $connect = sql_quote($p->boucles[$b]->sql_serveur); |
|
| 308 | 308 | |
| 309 | - if (!$key) { |
|
| 310 | - $msg = array('zbug_champ_hors_boucle', array('champ' => '#EXPOSER')); |
|
| 311 | - erreur_squelette($msg, $p); |
|
| 312 | - } |
|
| 309 | + if (!$key) { |
|
| 310 | + $msg = array('zbug_champ_hors_boucle', array('champ' => '#EXPOSER')); |
|
| 311 | + erreur_squelette($msg, $p); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 315 | - $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 314 | + // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite |
|
| 315 | + $c = index_pile($p->id_boucle, $type, $p->boucles); |
|
| 316 | 316 | |
| 317 | - if (isset($desc['field']['id_parent'])) { |
|
| 318 | - $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 319 | - } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 320 | - $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 321 | - } elseif (isset($desc['field']['id_groupe'])) { |
|
| 322 | - $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 323 | - } else $parent = "''"; |
|
| 317 | + if (isset($desc['field']['id_parent'])) { |
|
| 318 | + $parent = 0; // pour if (!$parent) dans calculer_expose |
|
| 319 | + } elseif (isset($desc['field']['id_rubrique'])) { |
|
| 320 | + $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
|
| 321 | + } elseif (isset($desc['field']['id_groupe'])) { |
|
| 322 | + $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
|
| 323 | + } else $parent = "''"; |
|
| 324 | 324 | |
| 325 | - $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 325 | + $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
|
| 326 | 326 | |
| 327 | - $p->interdire_scripts = false; |
|
| 328 | - return $p; |
|
| 327 | + $p->interdire_scripts = false; |
|
| 328 | + return $p; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -336,15 +336,15 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | // http://doc.spip.org/@balise_DEBUT_SURLIGNE_dist |
| 338 | 338 | function balise_DEBUT_SURLIGNE_dist($p) { |
| 339 | - include_spip('inc/surligne'); |
|
| 340 | - $p->code = "'<!-- " . MARQUEUR_SURLIGNE . " -->'"; |
|
| 341 | - return $p; |
|
| 339 | + include_spip('inc/surligne'); |
|
| 340 | + $p->code = "'<!-- " . MARQUEUR_SURLIGNE . " -->'"; |
|
| 341 | + return $p; |
|
| 342 | 342 | } |
| 343 | 343 | // http://doc.spip.org/@balise_FIN_SURLIGNE_dist |
| 344 | 344 | function balise_FIN_SURLIGNE_dist($p) { |
| 345 | - include_spip('inc/surligne'); |
|
| 346 | - $p->code = "'<!-- " . MARQUEUR_FSURLIGNE . "-->'"; |
|
| 347 | - return $p; |
|
| 345 | + include_spip('inc/surligne'); |
|
| 346 | + $p->code = "'<!-- " . MARQUEUR_FSURLIGNE . "-->'"; |
|
| 347 | + return $p; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
@@ -354,42 +354,42 @@ discard block |
||
| 354 | 354 | // http://doc.spip.org/@balise_INTRODUCTION_dist |
| 355 | 355 | function balise_INTRODUCTION_dist($p) { |
| 356 | 356 | |
| 357 | - $type = $p->type_requete; |
|
| 357 | + $type = $p->type_requete; |
|
| 358 | 358 | |
| 359 | - $_texte = champ_sql('texte', $p); |
|
| 360 | - $_descriptif = ($type == 'articles' OR $type == 'rubriques') ? champ_sql('descriptif', $p) : "''"; |
|
| 359 | + $_texte = champ_sql('texte', $p); |
|
| 360 | + $_descriptif = ($type == 'articles' OR $type == 'rubriques') ? champ_sql('descriptif', $p) : "''"; |
|
| 361 | 361 | |
| 362 | - if ($type == 'articles') { |
|
| 363 | - $_chapo = champ_sql('chapo', $p); |
|
| 364 | - $_texte = "(strlen($_descriptif)) |
|
| 362 | + if ($type == 'articles') { |
|
| 363 | + $_chapo = champ_sql('chapo', $p); |
|
| 364 | + $_texte = "(strlen($_descriptif)) |
|
| 365 | 365 | ? '' |
| 366 | 366 | : $_chapo . \"\\n\\n\" . $_texte"; |
| 367 | - } |
|
| 368 | - |
|
| 369 | - // longueur en parametre, ou valeur par defaut |
|
| 370 | - if (($v = interprete_argument_balise(1,$p))!==NULL) { |
|
| 371 | - $longueur = 'intval('.$v.')'; |
|
| 372 | - } else { |
|
| 373 | - switch ($type) { |
|
| 374 | - case 'articles': |
|
| 375 | - $longueur = '500'; |
|
| 376 | - break; |
|
| 377 | - case 'breves': |
|
| 378 | - $longueur = '300'; |
|
| 379 | - break; |
|
| 380 | - case 'rubriques': |
|
| 381 | - default: |
|
| 382 | - $longueur = '600'; |
|
| 383 | - break; |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - $f = chercher_filtre('introduction'); |
|
| 388 | - $p->code = "$f($_descriptif, $_texte, $longueur, \$connect)"; |
|
| 389 | - |
|
| 390 | - #$p->interdire_scripts = true; |
|
| 391 | - $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 392 | - return $p; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + // longueur en parametre, ou valeur par defaut |
|
| 370 | + if (($v = interprete_argument_balise(1,$p))!==NULL) { |
|
| 371 | + $longueur = 'intval('.$v.')'; |
|
| 372 | + } else { |
|
| 373 | + switch ($type) { |
|
| 374 | + case 'articles': |
|
| 375 | + $longueur = '500'; |
|
| 376 | + break; |
|
| 377 | + case 'breves': |
|
| 378 | + $longueur = '300'; |
|
| 379 | + break; |
|
| 380 | + case 'rubriques': |
|
| 381 | + default: |
|
| 382 | + $longueur = '600'; |
|
| 383 | + break; |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + $f = chercher_filtre('introduction'); |
|
| 388 | + $p->code = "$f($_descriptif, $_texte, $longueur, \$connect)"; |
|
| 389 | + |
|
| 390 | + #$p->interdire_scripts = true; |
|
| 391 | + $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro |
|
| 392 | + return $p; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -399,13 +399,13 @@ discard block |
||
| 399 | 399 | // #LANG* n'affiche rien si aucune langue n'est trouvee dans le sql/le contexte |
| 400 | 400 | // http://doc.spip.org/@balise_LANG_dist |
| 401 | 401 | function balise_LANG_dist ($p) { |
| 402 | - $_lang = champ_sql('lang', $p); |
|
| 403 | - if (!$p->etoile) |
|
| 404 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 405 | - else |
|
| 406 | - $p->code = "spip_htmlentities($_lang)"; |
|
| 407 | - $p->interdire_scripts = false; |
|
| 408 | - return $p; |
|
| 402 | + $_lang = champ_sql('lang', $p); |
|
| 403 | + if (!$p->etoile) |
|
| 404 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 405 | + else |
|
| 406 | + $p->code = "spip_htmlentities($_lang)"; |
|
| 407 | + $p->interdire_scripts = false; |
|
| 408 | + return $p; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // #LESAUTEURS |
@@ -414,44 +414,44 @@ discard block |
||
| 414 | 414 | // http://www.spip.net/fr_article911.html |
| 415 | 415 | // http://doc.spip.org/@balise_LESAUTEURS_dist |
| 416 | 416 | function balise_LESAUTEURS_dist ($p) { |
| 417 | - // Cherche le champ 'lesauteurs' dans la pile |
|
| 418 | - $_lesauteurs = champ_sql('lesauteurs', $p, false); |
|
| 419 | - |
|
| 420 | - // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 421 | - // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 422 | - // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 423 | - // (cf extension sites/) |
|
| 424 | - if ($_lesauteurs |
|
| 425 | - AND $_lesauteurs != '@$Pile[0][\'lesauteurs\']') { |
|
| 426 | - $p->code = "safehtml($_lesauteurs)"; |
|
| 427 | - // $p->interdire_scripts = true; |
|
| 428 | - } else { |
|
| 429 | - if(!$p->id_boucle){ |
|
| 430 | - $connect = ''; |
|
| 431 | - $objet = 'article'; |
|
| 432 | - $id_table_objet = 'id_article'; |
|
| 433 | - } |
|
| 434 | - else{ |
|
| 435 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 436 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 437 | - $type_boucle = $p->boucles[$b]->type_requete; |
|
| 438 | - $objet = objet_type($type_boucle); |
|
| 439 | - $id_table_objet = id_table_objet($type_boucle); |
|
| 440 | - } |
|
| 441 | - $c = memoriser_contexte_compil($p); |
|
| 442 | - |
|
| 443 | - $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'", |
|
| 444 | - "array('objet'=>'".$objet. |
|
| 445 | - "','id_objet' => ".champ_sql($id_table_objet, $p) . |
|
| 446 | - ",'$id_table_objet' => ".champ_sql($id_table_objet, $p) . |
|
| 447 | - ($objet=='article'?"":",'id_article' => ".champ_sql('id_article', $p)). |
|
| 448 | - ")", |
|
| 449 | - "'trim'=>true, 'compil'=>array($c)", |
|
| 450 | - _q($connect)); |
|
| 451 | - $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - return $p; |
|
| 417 | + // Cherche le champ 'lesauteurs' dans la pile |
|
| 418 | + $_lesauteurs = champ_sql('lesauteurs', $p, false); |
|
| 419 | + |
|
| 420 | + // Si le champ n'existe pas (cas de spip_articles), on applique |
|
| 421 | + // le modele lesauteurs.html en passant id_article dans le contexte; |
|
| 422 | + // dans le cas contraire on prend le champ 'lesauteurs' |
|
| 423 | + // (cf extension sites/) |
|
| 424 | + if ($_lesauteurs |
|
| 425 | + AND $_lesauteurs != '@$Pile[0][\'lesauteurs\']') { |
|
| 426 | + $p->code = "safehtml($_lesauteurs)"; |
|
| 427 | + // $p->interdire_scripts = true; |
|
| 428 | + } else { |
|
| 429 | + if(!$p->id_boucle){ |
|
| 430 | + $connect = ''; |
|
| 431 | + $objet = 'article'; |
|
| 432 | + $id_table_objet = 'id_article'; |
|
| 433 | + } |
|
| 434 | + else{ |
|
| 435 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
|
| 436 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 437 | + $type_boucle = $p->boucles[$b]->type_requete; |
|
| 438 | + $objet = objet_type($type_boucle); |
|
| 439 | + $id_table_objet = id_table_objet($type_boucle); |
|
| 440 | + } |
|
| 441 | + $c = memoriser_contexte_compil($p); |
|
| 442 | + |
|
| 443 | + $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'", |
|
| 444 | + "array('objet'=>'".$objet. |
|
| 445 | + "','id_objet' => ".champ_sql($id_table_objet, $p) . |
|
| 446 | + ",'$id_table_objet' => ".champ_sql($id_table_objet, $p) . |
|
| 447 | + ($objet=='article'?"":",'id_article' => ".champ_sql('id_article', $p)). |
|
| 448 | + ")", |
|
| 449 | + "'trim'=>true, 'compil'=>array($c)", |
|
| 450 | + _q($connect)); |
|
| 451 | + $p->interdire_scripts = false; // securite apposee par recuperer_fond() |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + return $p; |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | |
@@ -472,62 +472,62 @@ discard block |
||
| 472 | 472 | * @return object |
| 473 | 473 | */ |
| 474 | 474 | function balise_RANG_dist($p) { |
| 475 | - $b = index_boucle($p); |
|
| 476 | - if ($b === '') { |
|
| 477 | - $msg = array( |
|
| 478 | - 'zbug_champ_hors_boucle', |
|
| 479 | - array('champ' => '#RANG') |
|
| 480 | - ); |
|
| 481 | - erreur_squelette($msg, $p); |
|
| 482 | - } else { |
|
| 483 | - // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 484 | - // dans la boucle immediatement englobante uniquement |
|
| 485 | - // sinon on compose le champ calcule |
|
| 486 | - $_rang = champ_sql('rang', $p, '', false); |
|
| 487 | - |
|
| 488 | - // si pas trouve de champ sql rang : |
|
| 489 | - if (!$_rang) { |
|
| 490 | - $boucle = &$p->boucles[$b]; |
|
| 491 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 492 | - $desc = $trouver_table($boucle->id_table); |
|
| 493 | - $_titre = ''; # où extraire le numero ? |
|
| 475 | + $b = index_boucle($p); |
|
| 476 | + if ($b === '') { |
|
| 477 | + $msg = array( |
|
| 478 | + 'zbug_champ_hors_boucle', |
|
| 479 | + array('champ' => '#RANG') |
|
| 480 | + ); |
|
| 481 | + erreur_squelette($msg, $p); |
|
| 482 | + } else { |
|
| 483 | + // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql) |
|
| 484 | + // dans la boucle immediatement englobante uniquement |
|
| 485 | + // sinon on compose le champ calcule |
|
| 486 | + $_rang = champ_sql('rang', $p, '', false); |
|
| 487 | + |
|
| 488 | + // si pas trouve de champ sql rang : |
|
| 489 | + if (!$_rang) { |
|
| 490 | + $boucle = &$p->boucles[$b]; |
|
| 491 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 492 | + $desc = $trouver_table($boucle->id_table); |
|
| 493 | + $_titre = ''; # où extraire le numero ? |
|
| 494 | 494 | |
| 495 | - if (isset($desc['titre'])) { |
|
| 496 | - $t = $desc['titre']; |
|
| 497 | - if ( |
|
| 498 | - // Soit on trouve avec la déclaration de la lang AVANT |
|
| 499 | - preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 500 | - // Soit on prend depuis le début |
|
| 501 | - or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 502 | - ) { |
|
| 503 | - $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 504 | - $m = trim($m); |
|
| 505 | - if ($m != "''") { |
|
| 506 | - if (!preg_match(",\W,", $m)) { |
|
| 507 | - $m = $boucle->id_table . ".$m"; |
|
| 508 | - } |
|
| 495 | + if (isset($desc['titre'])) { |
|
| 496 | + $t = $desc['titre']; |
|
| 497 | + if ( |
|
| 498 | + // Soit on trouve avec la déclaration de la lang AVANT |
|
| 499 | + preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) |
|
| 500 | + // Soit on prend depuis le début |
|
| 501 | + or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) |
|
| 502 | + ) { |
|
| 503 | + $m = preg_replace(',as\s+titre$,i', '', $m[1]); |
|
| 504 | + $m = trim($m); |
|
| 505 | + if ($m != "''") { |
|
| 506 | + if (!preg_match(",\W,", $m)) { |
|
| 507 | + $m = $boucle->id_table . ".$m"; |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | - $m .= " AS titre_rang"; |
|
| 510 | + $m .= " AS titre_rang"; |
|
| 511 | 511 | |
| 512 | - $boucle->select[] = $m; |
|
| 513 | - $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 514 | - } |
|
| 515 | - } |
|
| 516 | - } |
|
| 512 | + $boucle->select[] = $m; |
|
| 513 | + $_titre = '$Pile[$SP][\'titre_rang\']'; |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 519 | - if (!$_titre) { |
|
| 520 | - $_titre = champ_sql('titre', $p); |
|
| 521 | - } |
|
| 518 | + // si on n'a rien trouvé, on utilise le champ titre classique |
|
| 519 | + if (!$_titre) { |
|
| 520 | + $_titre = champ_sql('titre', $p); |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - $_rang = "recuperer_numero($_titre)"; |
|
| 524 | - } |
|
| 523 | + $_rang = "recuperer_numero($_titre)"; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - $p->code = $_rang; |
|
| 527 | - $p->interdire_scripts = false; |
|
| 528 | - } |
|
| 526 | + $p->code = $_rang; |
|
| 527 | + $p->interdire_scripts = false; |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - return $p; |
|
| 530 | + return $p; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | |
@@ -535,11 +535,11 @@ discard block |
||
| 535 | 535 | // http://www.spip.net/fr_article1846.html |
| 536 | 536 | // http://doc.spip.org/@balise_POPULARITE_dist |
| 537 | 537 | function balise_POPULARITE_dist ($p) { |
| 538 | - $_popularite = champ_sql('popularite', $p); |
|
| 539 | - $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 538 | + $_popularite = champ_sql('popularite', $p); |
|
| 539 | + $p->code = "(ceil(min(100, 100 * $_popularite |
|
| 540 | 540 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; |
| 541 | - $p->interdire_scripts = false; |
|
| 542 | - return $p; |
|
| 541 | + $p->interdire_scripts = false; |
|
| 542 | + return $p; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | // #PAGINATION |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | // l'absence peut etre due a une faute de frappe dans le contexte inclus. |
| 549 | 549 | |
| 550 | 550 | define('CODE_PAGINATION', |
| 551 | - '%s($Numrows["%s"]["grand_total"], |
|
| 551 | + '%s($Numrows["%s"]["grand_total"], |
|
| 552 | 552 | %s, |
| 553 | 553 | isset($Pile[0][%4$s])?$Pile[0][%4$s]:intval(_request(%4$s)), |
| 554 | 554 | %5$s, %6$s, %7$s, %8$s, array(%9$s))'); |
@@ -556,59 +556,59 @@ discard block |
||
| 556 | 556 | // http://www.spip.net/fr_article3367.html |
| 557 | 557 | // http://doc.spip.org/@balise_PAGINATION_dist |
| 558 | 558 | function balise_PAGINATION_dist($p, $liste='true') { |
| 559 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 560 | - |
|
| 561 | - // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 562 | - if ($b === '') { |
|
| 563 | - $msg = array('zbug_champ_hors_boucle', |
|
| 564 | - array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION') |
|
| 565 | - ); |
|
| 566 | - erreur_squelette($msg, $p); |
|
| 567 | - return $p; |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 571 | - // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 572 | - if (!$p->boucles[$b]->mode_partie) { |
|
| 573 | - if (!$p->boucles[$b]->table_optionnelle) { |
|
| 574 | - $msg = array('zbug_pagination_sans_critere', |
|
| 575 | - array('champ' => '#PAGINATION') |
|
| 576 | - ); |
|
| 577 | - erreur_squelette($msg, $p); |
|
| 578 | - } |
|
| 579 | - return $p; |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - // a priori true |
|
| 583 | - // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 584 | - // si true, les arguments simples (sans truc=chose) vont degager |
|
| 585 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 586 | - if (count($_contexte)){ |
|
| 587 | - list($key,$val) = each($_contexte); |
|
| 588 | - if (is_numeric($key)){ |
|
| 589 | - array_shift($_contexte); |
|
| 590 | - $__modele = interprete_argument_balise(1,$p); |
|
| 591 | - } |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - if (count($_contexte)){ |
|
| 595 | - $code_contexte = implode(',',$_contexte); |
|
| 596 | - } |
|
| 597 | - else |
|
| 598 | - $code_contexte = ''; |
|
| 599 | - |
|
| 600 | - $connect = $p->boucles[$b]->sql_serveur; |
|
| 601 | - $pas = $p->boucles[$b]->total_parties; |
|
| 602 | - $f_pagination = chercher_filtre('pagination'); |
|
| 603 | - $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 604 | - $modif = ($type[0]!=="'") ? "'debut'.$type" |
|
| 605 | - : ("'debut" .substr($type,1)); |
|
| 606 | - |
|
| 607 | - $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste, ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte); |
|
| 608 | - |
|
| 609 | - $p->boucles[$b]->numrows = true; |
|
| 610 | - $p->interdire_scripts = false; |
|
| 611 | - return $p; |
|
| 559 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 560 | + |
|
| 561 | + // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
|
| 562 | + if ($b === '') { |
|
| 563 | + $msg = array('zbug_champ_hors_boucle', |
|
| 564 | + array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION') |
|
| 565 | + ); |
|
| 566 | + erreur_squelette($msg, $p); |
|
| 567 | + return $p; |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + // s'il n'y a pas de mode_partie, c'est qu'on se trouve |
|
| 571 | + // dans un boucle recursive ou qu'on a oublie le critere {pagination} |
|
| 572 | + if (!$p->boucles[$b]->mode_partie) { |
|
| 573 | + if (!$p->boucles[$b]->table_optionnelle) { |
|
| 574 | + $msg = array('zbug_pagination_sans_critere', |
|
| 575 | + array('champ' => '#PAGINATION') |
|
| 576 | + ); |
|
| 577 | + erreur_squelette($msg, $p); |
|
| 578 | + } |
|
| 579 | + return $p; |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + // a priori true |
|
| 583 | + // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
|
| 584 | + // si true, les arguments simples (sans truc=chose) vont degager |
|
| 585 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
|
| 586 | + if (count($_contexte)){ |
|
| 587 | + list($key,$val) = each($_contexte); |
|
| 588 | + if (is_numeric($key)){ |
|
| 589 | + array_shift($_contexte); |
|
| 590 | + $__modele = interprete_argument_balise(1,$p); |
|
| 591 | + } |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + if (count($_contexte)){ |
|
| 595 | + $code_contexte = implode(',',$_contexte); |
|
| 596 | + } |
|
| 597 | + else |
|
| 598 | + $code_contexte = ''; |
|
| 599 | + |
|
| 600 | + $connect = $p->boucles[$b]->sql_serveur; |
|
| 601 | + $pas = $p->boucles[$b]->total_parties; |
|
| 602 | + $f_pagination = chercher_filtre('pagination'); |
|
| 603 | + $type = $p->boucles[$b]->modificateur['debut_nom']; |
|
| 604 | + $modif = ($type[0]!=="'") ? "'debut'.$type" |
|
| 605 | + : ("'debut" .substr($type,1)); |
|
| 606 | + |
|
| 607 | + $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste, ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte); |
|
| 608 | + |
|
| 609 | + $p->boucles[$b]->numrows = true; |
|
| 610 | + $p->interdire_scripts = false; |
|
| 611 | + return $p; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | |
@@ -616,28 +616,28 @@ discard block |
||
| 616 | 616 | // qu'on mettra les liens en-dessous de la liste paginee) |
| 617 | 617 | // http://doc.spip.org/@balise_ANCRE_PAGINATION_dist |
| 618 | 618 | function balise_ANCRE_PAGINATION_dist($p) { |
| 619 | - if ($f = charger_fonction('PAGINATION', 'balise', true)) |
|
| 620 | - return $f($p, $liste='false'); |
|
| 621 | - else return NULL; // ou une erreur ? |
|
| 619 | + if ($f = charger_fonction('PAGINATION', 'balise', true)) |
|
| 620 | + return $f($p, $liste='false'); |
|
| 621 | + else return NULL; // ou une erreur ? |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | // equivalent a #TOTAL_BOUCLE sauf pour les boucles paginees, ou elle |
| 625 | 625 | // indique le nombre total d'articles repondant aux criteres hors pagination |
| 626 | 626 | // http://doc.spip.org/@balise_GRAND_TOTAL_dist |
| 627 | 627 | function balise_GRAND_TOTAL_dist($p) { |
| 628 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 629 | - if ($b === '' || !isset($p->boucles[$b])) { |
|
| 630 | - $msg = array('zbug_champ_hors_boucle', |
|
| 631 | - array('champ' => "#$b" . 'TOTAL_BOUCLE') |
|
| 632 | - ); |
|
| 633 | - erreur_squelette($msg, $p); |
|
| 634 | - } else { |
|
| 635 | - $p->code = "(isset(\$Numrows['$b']['grand_total']) |
|
| 628 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 629 | + if ($b === '' || !isset($p->boucles[$b])) { |
|
| 630 | + $msg = array('zbug_champ_hors_boucle', |
|
| 631 | + array('champ' => "#$b" . 'TOTAL_BOUCLE') |
|
| 632 | + ); |
|
| 633 | + erreur_squelette($msg, $p); |
|
| 634 | + } else { |
|
| 635 | + $p->code = "(isset(\$Numrows['$b']['grand_total']) |
|
| 636 | 636 | ? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'])"; |
| 637 | - $p->boucles[$b]->numrows = true; |
|
| 638 | - $p->interdire_scripts = false; |
|
| 639 | - } |
|
| 640 | - return $p; |
|
| 637 | + $p->boucles[$b]->numrows = true; |
|
| 638 | + $p->interdire_scripts = false; |
|
| 639 | + } |
|
| 640 | + return $p; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | // Reference a l'URL de la page courante |
@@ -647,9 +647,9 @@ discard block |
||
| 647 | 647 | // http://www.spip.net/@self |
| 648 | 648 | // http://doc.spip.org/@balise_SELF_dist |
| 649 | 649 | function balise_SELF_dist($p) { |
| 650 | - $p->code = 'self()'; |
|
| 651 | - $p->interdire_scripts = false; |
|
| 652 | - return $p; |
|
| 650 | + $p->code = 'self()'; |
|
| 651 | + $p->interdire_scripts = false; |
|
| 652 | + return $p; |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | // |
@@ -657,26 +657,26 @@ discard block |
||
| 657 | 657 | // |
| 658 | 658 | // http://doc.spip.org/@balise_CHEMIN_dist |
| 659 | 659 | function balise_CHEMIN_dist($p) { |
| 660 | - $arg = interprete_argument_balise(1,$p); |
|
| 661 | - if (!$arg) { |
|
| 662 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
|
| 663 | - erreur_squelette($msg, $p); |
|
| 664 | - } else |
|
| 665 | - $p->code = 'find_in_path(' . $arg .')'; |
|
| 660 | + $arg = interprete_argument_balise(1,$p); |
|
| 661 | + if (!$arg) { |
|
| 662 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
|
| 663 | + erreur_squelette($msg, $p); |
|
| 664 | + } else |
|
| 665 | + $p->code = 'find_in_path(' . $arg .')'; |
|
| 666 | 666 | |
| 667 | - #$p->interdire_scripts = true; |
|
| 668 | - return $p; |
|
| 667 | + #$p->interdire_scripts = true; |
|
| 668 | + return $p; |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | function balise_CHEMIN_IMAGE_dist($p) { |
| 672 | - $arg = interprete_argument_balise(1,$p); |
|
| 673 | - if (!$arg) { |
|
| 674 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); |
|
| 675 | - erreur_squelette($msg, $p); |
|
| 676 | - } else $p->code = 'chemin_image(' . $arg .')'; |
|
| 672 | + $arg = interprete_argument_balise(1,$p); |
|
| 673 | + if (!$arg) { |
|
| 674 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); |
|
| 675 | + erreur_squelette($msg, $p); |
|
| 676 | + } else $p->code = 'chemin_image(' . $arg .')'; |
|
| 677 | 677 | |
| 678 | - #$p->interdire_scripts = true; |
|
| 679 | - return $p; |
|
| 678 | + #$p->interdire_scripts = true; |
|
| 679 | + return $p; |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | |
@@ -718,35 +718,35 @@ discard block |
||
| 718 | 718 | **/ |
| 719 | 719 | function balise_ENV_dist($p, $src = NULL) { |
| 720 | 720 | |
| 721 | - // cle du tableau desiree |
|
| 722 | - $_nom = interprete_argument_balise(1,$p); |
|
| 723 | - // valeur par defaut |
|
| 724 | - $_sinon = interprete_argument_balise(2,$p); |
|
| 721 | + // cle du tableau desiree |
|
| 722 | + $_nom = interprete_argument_balise(1,$p); |
|
| 723 | + // valeur par defaut |
|
| 724 | + $_sinon = interprete_argument_balise(2,$p); |
|
| 725 | 725 | |
| 726 | - // $src est un tableau de donnees sources eventuellement transmis |
|
| 727 | - // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 726 | + // $src est un tableau de donnees sources eventuellement transmis |
|
| 727 | + // en absence, on utilise l'environnement du squelette $Pile[0] |
|
| 728 | 728 | |
| 729 | - if (!$_nom) { |
|
| 730 | - // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 731 | - // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 732 | - if ($src) { |
|
| 733 | - $p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")'; |
|
| 734 | - } else { |
|
| 735 | - $p->code = '@serialize($Pile[0])'; |
|
| 736 | - } |
|
| 737 | - } else { |
|
| 738 | - if (!$src) { |
|
| 739 | - $src = '@$Pile[0]'; |
|
| 740 | - } |
|
| 741 | - if ($_sinon) { |
|
| 742 | - $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 743 | - } else { |
|
| 744 | - $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - #$p->interdire_scripts = true; |
|
| 748 | - |
|
| 749 | - return $p; |
|
| 729 | + if (!$_nom) { |
|
| 730 | + // cas de #ENV sans argument : on retourne le serialize() du tableau |
|
| 731 | + // une belle fonction [(#ENV|affiche_env)] serait pratique |
|
| 732 | + if ($src) { |
|
| 733 | + $p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")'; |
|
| 734 | + } else { |
|
| 735 | + $p->code = '@serialize($Pile[0])'; |
|
| 736 | + } |
|
| 737 | + } else { |
|
| 738 | + if (!$src) { |
|
| 739 | + $src = '@$Pile[0]'; |
|
| 740 | + } |
|
| 741 | + if ($_sinon) { |
|
| 742 | + $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)"; |
|
| 743 | + } else { |
|
| 744 | + $p->code = "table_valeur($src, (string)$_nom, null)"; |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + #$p->interdire_scripts = true; |
|
| 748 | + |
|
| 749 | + return $p; |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
@@ -766,24 +766,24 @@ discard block |
||
| 766 | 766 | * @return Object |
| 767 | 767 | */ |
| 768 | 768 | function balise_CONFIG_dist($p) { |
| 769 | - if (!$arg = interprete_argument_balise(1,$p)) { |
|
| 770 | - $arg = "''"; |
|
| 771 | - } |
|
| 772 | - $_sinon = interprete_argument_balise(2,$p); |
|
| 773 | - $_unserialize = sinon(interprete_argument_balise(3,$p),"false"); |
|
| 769 | + if (!$arg = interprete_argument_balise(1,$p)) { |
|
| 770 | + $arg = "''"; |
|
| 771 | + } |
|
| 772 | + $_sinon = interprete_argument_balise(2,$p); |
|
| 773 | + $_unserialize = sinon(interprete_argument_balise(3,$p),"false"); |
|
| 774 | 774 | |
| 775 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 776 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 775 | + $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 776 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 777 | 777 | |
| 778 | - return $p; |
|
| 778 | + return $p; |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | |
| 782 | 782 | // http://doc.spip.org/@balise_CONNECT_dist |
| 783 | 783 | function balise_CONNECT_dist($p) { |
| 784 | - $p->code = '($connect ? $connect : NULL)'; |
|
| 785 | - $p->interdire_scripts = false; |
|
| 786 | - return $p; |
|
| 784 | + $p->code = '($connect ? $connect : NULL)'; |
|
| 785 | + $p->interdire_scripts = false; |
|
| 786 | + return $p; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | // |
@@ -794,14 +794,14 @@ discard block |
||
| 794 | 794 | // pas la meme session |
| 795 | 795 | // http://doc.spip.org/@balise_SESSION_dist |
| 796 | 796 | function balise_SESSION_dist($p) { |
| 797 | - $p->descr['session'] = true; |
|
| 797 | + $p->descr['session'] = true; |
|
| 798 | 798 | |
| 799 | - $f = function_exists('balise_ENV') |
|
| 800 | - ? 'balise_ENV' |
|
| 801 | - : 'balise_ENV_dist'; |
|
| 799 | + $f = function_exists('balise_ENV') |
|
| 800 | + ? 'balise_ENV' |
|
| 801 | + : 'balise_ENV_dist'; |
|
| 802 | 802 | |
| 803 | - $p = $f($p, '$GLOBALS["visiteur_session"]'); |
|
| 804 | - return $p; |
|
| 803 | + $p = $f($p, '$GLOBALS["visiteur_session"]'); |
|
| 804 | + return $p; |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | // |
@@ -809,16 +809,16 @@ discard block |
||
| 809 | 809 | // Ajoute x=y dans la session du visiteur |
| 810 | 810 | // http://doc.spip.org/@balise_SESSION_SET_dist |
| 811 | 811 | function balise_SESSION_SET_dist($p) { |
| 812 | - $_nom = interprete_argument_balise(1,$p); |
|
| 813 | - $_val = interprete_argument_balise(2,$p); |
|
| 814 | - if (!$_nom OR !$_val) { |
|
| 815 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); |
|
| 816 | - erreur_squelette($err_b_s_a, $p); |
|
| 817 | - } else $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; |
|
| 812 | + $_nom = interprete_argument_balise(1,$p); |
|
| 813 | + $_val = interprete_argument_balise(2,$p); |
|
| 814 | + if (!$_nom OR !$_val) { |
|
| 815 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); |
|
| 816 | + erreur_squelette($err_b_s_a, $p); |
|
| 817 | + } else $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; |
|
| 818 | 818 | |
| 819 | - $p->interdire_scripts = false; |
|
| 819 | + $p->interdire_scripts = false; |
|
| 820 | 820 | |
| 821 | - return $p; |
|
| 821 | + return $p; |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | |
@@ -836,23 +836,23 @@ discard block |
||
| 836 | 836 | // #EVAL{'str_replace("r","z", "roger")'} (attention les "'" sont interdits) |
| 837 | 837 | // http://doc.spip.org/@balise_EVAL_dist |
| 838 | 838 | function balise_EVAL_dist($p) { |
| 839 | - $php = interprete_argument_balise(1,$p); |
|
| 840 | - if ($php) { |
|
| 841 | - # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 842 | - # attention au commentaire "// x signes" qui precede |
|
| 843 | - if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 844 | - $php,$r)) |
|
| 845 | - $p->code = /* $r[1]. */'('.$r[2].')'; |
|
| 846 | - else |
|
| 847 | - $p->code = "eval('return '.$php.';')"; |
|
| 848 | - } else { |
|
| 849 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); |
|
| 850 | - erreur_squelette($msg, $p); |
|
| 851 | - } |
|
| 839 | + $php = interprete_argument_balise(1,$p); |
|
| 840 | + if ($php) { |
|
| 841 | + # optimisation sur les #EVAL{une expression sans #BALISE} |
|
| 842 | + # attention au commentaire "// x signes" qui precede |
|
| 843 | + if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
|
| 844 | + $php,$r)) |
|
| 845 | + $p->code = /* $r[1]. */'('.$r[2].')'; |
|
| 846 | + else |
|
| 847 | + $p->code = "eval('return '.$php.';')"; |
|
| 848 | + } else { |
|
| 849 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); |
|
| 850 | + erreur_squelette($msg, $p); |
|
| 851 | + } |
|
| 852 | 852 | |
| 853 | - #$p->interdire_scripts = true; |
|
| 853 | + #$p->interdire_scripts = true; |
|
| 854 | 854 | |
| 855 | - return $p; |
|
| 855 | + return $p; |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | // #CHAMP_SQL{x} renvoie la valeur du champ sql 'x' |
@@ -862,27 +862,27 @@ discard block |
||
| 862 | 862 | // http://doc.spip.org/@balise_CHAMP_SQL_dist |
| 863 | 863 | function balise_CHAMP_SQL_dist($p){ |
| 864 | 864 | |
| 865 | - if ($p->param |
|
| 866 | - AND isset($p->param[0][1][0]) |
|
| 867 | - AND $champ = ($p->param[0][1][0]->texte)) |
|
| 868 | - $p->code = champ_sql($champ, $p); |
|
| 869 | - else { |
|
| 870 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); |
|
| 871 | - erreur_squelette($err_b_s_a, $p); |
|
| 872 | - } |
|
| 873 | - #$p->interdire_scripts = true; |
|
| 874 | - return $p; |
|
| 865 | + if ($p->param |
|
| 866 | + AND isset($p->param[0][1][0]) |
|
| 867 | + AND $champ = ($p->param[0][1][0]->texte)) |
|
| 868 | + $p->code = champ_sql($champ, $p); |
|
| 869 | + else { |
|
| 870 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); |
|
| 871 | + erreur_squelette($err_b_s_a, $p); |
|
| 872 | + } |
|
| 873 | + #$p->interdire_scripts = true; |
|
| 874 | + return $p; |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | // #VAL{x} renvoie 'x' (permet d'appliquer un filtre a une chaine) |
| 878 | 878 | // Attention #VAL{1,2} renvoie '1', indiquer #VAL{'1,2'} |
| 879 | 879 | // http://doc.spip.org/@balise_VAL_dist |
| 880 | 880 | function balise_VAL_dist($p){ |
| 881 | - $p->code = interprete_argument_balise(1,$p); |
|
| 882 | - if (!strlen($p->code)) |
|
| 883 | - $p->code = "''"; |
|
| 884 | - $p->interdire_scripts = false; |
|
| 885 | - return $p; |
|
| 881 | + $p->code = interprete_argument_balise(1,$p); |
|
| 882 | + if (!strlen($p->code)) |
|
| 883 | + $p->code = "''"; |
|
| 884 | + $p->interdire_scripts = false; |
|
| 885 | + return $p; |
|
| 886 | 886 | } |
| 887 | 887 | // #NOOP est un alias pour regler #948, ne pas documenter |
| 888 | 888 | // http://doc.spip.org/@balise_NOOP_dist |
@@ -894,9 +894,9 @@ discard block |
||
| 894 | 894 | // |
| 895 | 895 | // http://doc.spip.org/@balise_REM_dist |
| 896 | 896 | function balise_REM_dist($p) { |
| 897 | - $p->code="''"; |
|
| 898 | - $p->interdire_scripts = false; |
|
| 899 | - return $p; |
|
| 897 | + $p->code="''"; |
|
| 898 | + $p->interdire_scripts = false; |
|
| 899 | + return $p; |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | |
@@ -921,18 +921,18 @@ discard block |
||
| 921 | 921 | **/ |
| 922 | 922 | function balise_HTTP_HEADER_dist($p) { |
| 923 | 923 | |
| 924 | - $header = interprete_argument_balise(1, $p); |
|
| 925 | - if (!$header) { |
|
| 926 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER')); |
|
| 927 | - erreur_squelette($err_b_s_a, $p); |
|
| 928 | - } else { |
|
| 929 | - $p->code = "'<'.'?php header(' . _q(" |
|
| 930 | - . $header |
|
| 931 | - . ") . '); ?'.'>'"; |
|
| 932 | - } |
|
| 933 | - $p->interdire_scripts = false; |
|
| 924 | + $header = interprete_argument_balise(1, $p); |
|
| 925 | + if (!$header) { |
|
| 926 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER')); |
|
| 927 | + erreur_squelette($err_b_s_a, $p); |
|
| 928 | + } else { |
|
| 929 | + $p->code = "'<'.'?php header(' . _q(" |
|
| 930 | + . $header |
|
| 931 | + . ") . '); ?'.'>'"; |
|
| 932 | + } |
|
| 933 | + $p->interdire_scripts = false; |
|
| 934 | 934 | |
| 935 | - return $p; |
|
| 935 | + return $p; |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | |
@@ -941,18 +941,18 @@ discard block |
||
| 941 | 941 | // (filtrage fait au niveau du squelette, et sans s'appliquer aux <INCLURE>) |
| 942 | 942 | // http://doc.spip.org/@balise_FILTRE_dist |
| 943 | 943 | function balise_FILTRE_dist($p) { |
| 944 | - if ($p->param) { |
|
| 945 | - $args = array(); |
|
| 946 | - foreach ($p->param as $i => $ignore) |
|
| 947 | - $args[] = interprete_argument_balise($i+1,$p); |
|
| 948 | - $p->code = "'<' . '" |
|
| 949 | - .'?php header("X-Spip-Filtre: \'.' |
|
| 950 | - .join('.\'|\'.', $args) |
|
| 951 | - . " . '\"); ?'.'>'"; |
|
| 944 | + if ($p->param) { |
|
| 945 | + $args = array(); |
|
| 946 | + foreach ($p->param as $i => $ignore) |
|
| 947 | + $args[] = interprete_argument_balise($i+1,$p); |
|
| 948 | + $p->code = "'<' . '" |
|
| 949 | + .'?php header("X-Spip-Filtre: \'.' |
|
| 950 | + .join('.\'|\'.', $args) |
|
| 951 | + . " . '\"); ?'.'>'"; |
|
| 952 | 952 | |
| 953 | - $p->interdire_scripts = false; |
|
| 954 | - return $p; |
|
| 955 | - } |
|
| 953 | + $p->interdire_scripts = false; |
|
| 954 | + return $p; |
|
| 955 | + } |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | 958 | // |
@@ -968,46 +968,46 @@ discard block |
||
| 968 | 968 | // http://doc.spip.org/@balise_CACHE_dist |
| 969 | 969 | function balise_CACHE_dist($p) { |
| 970 | 970 | |
| 971 | - if ($p->param) { |
|
| 972 | - $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 973 | - |
|
| 974 | - // noter la duree du cache dans un entete proprietaire |
|
| 975 | - |
|
| 976 | - $code = '\'<'.'?php header("X-Spip-Cache: ' |
|
| 977 | - . $duree |
|
| 978 | - . '"); ?'.'>\''; |
|
| 979 | - |
|
| 980 | - // Remplir le header Cache-Control |
|
| 981 | - // cas #CACHE{0} |
|
| 982 | - if ($duree == 0) |
|
| 983 | - $code .= '.\'<' |
|
| 984 | - .'?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 985 | - .'><' |
|
| 986 | - .'?php header("Pragma: no-cache"); ?' |
|
| 987 | - .'>\''; |
|
| 988 | - |
|
| 989 | - // recuperer les parametres suivants |
|
| 990 | - $i = 1; |
|
| 991 | - while (isset($p->param[0][++$i])) { |
|
| 992 | - $pa = ($p->param[0][$i][0]->texte); |
|
| 993 | - |
|
| 994 | - if ($pa == 'cache-client' |
|
| 995 | - AND $duree > 0) { |
|
| 996 | - $code .= '.\'<'.'?php header("Cache-Control: max-age=' |
|
| 997 | - . $duree |
|
| 998 | - . '"); ?'.'>\''; |
|
| 999 | - // il semble logique, si on cache-client, de ne pas invalider |
|
| 1000 | - $pa = 'statique'; |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - if ($pa == 'statique' |
|
| 1004 | - AND $duree > 0) |
|
| 1005 | - $code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\''; |
|
| 1006 | - } |
|
| 1007 | - } else $code = "''"; |
|
| 1008 | - $p->code = $code; |
|
| 1009 | - $p->interdire_scripts = false; |
|
| 1010 | - return $p; |
|
| 971 | + if ($p->param) { |
|
| 972 | + $duree = valeur_numerique($p->param[0][1][0]->texte); |
|
| 973 | + |
|
| 974 | + // noter la duree du cache dans un entete proprietaire |
|
| 975 | + |
|
| 976 | + $code = '\'<'.'?php header("X-Spip-Cache: ' |
|
| 977 | + . $duree |
|
| 978 | + . '"); ?'.'>\''; |
|
| 979 | + |
|
| 980 | + // Remplir le header Cache-Control |
|
| 981 | + // cas #CACHE{0} |
|
| 982 | + if ($duree == 0) |
|
| 983 | + $code .= '.\'<' |
|
| 984 | + .'?php header("Cache-Control: no-cache, must-revalidate"); ?' |
|
| 985 | + .'><' |
|
| 986 | + .'?php header("Pragma: no-cache"); ?' |
|
| 987 | + .'>\''; |
|
| 988 | + |
|
| 989 | + // recuperer les parametres suivants |
|
| 990 | + $i = 1; |
|
| 991 | + while (isset($p->param[0][++$i])) { |
|
| 992 | + $pa = ($p->param[0][$i][0]->texte); |
|
| 993 | + |
|
| 994 | + if ($pa == 'cache-client' |
|
| 995 | + AND $duree > 0) { |
|
| 996 | + $code .= '.\'<'.'?php header("Cache-Control: max-age=' |
|
| 997 | + . $duree |
|
| 998 | + . '"); ?'.'>\''; |
|
| 999 | + // il semble logique, si on cache-client, de ne pas invalider |
|
| 1000 | + $pa = 'statique'; |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + if ($pa == 'statique' |
|
| 1004 | + AND $duree > 0) |
|
| 1005 | + $code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\''; |
|
| 1006 | + } |
|
| 1007 | + } else $code = "''"; |
|
| 1008 | + $p->code = $code; |
|
| 1009 | + $p->interdire_scripts = false; |
|
| 1010 | + return $p; |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | |
@@ -1030,13 +1030,13 @@ discard block |
||
| 1030 | 1030 | * @return object |
| 1031 | 1031 | */ |
| 1032 | 1032 | function balise_INSERT_HEAD_dist($p) { |
| 1033 | - $p->code = '\'<' |
|
| 1034 | - .'?php header("X-Spip-Filtre: \'.' |
|
| 1035 | - .'\'insert_head_css_conditionnel\'' |
|
| 1036 | - . " . '\"); ?'.'>'"; |
|
| 1037 | - $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1038 | - $p->interdire_scripts = false; |
|
| 1039 | - return $p; |
|
| 1033 | + $p->code = '\'<' |
|
| 1034 | + .'?php header("X-Spip-Filtre: \'.' |
|
| 1035 | + .'\'insert_head_css_conditionnel\'' |
|
| 1036 | + . " . '\"); ?'.'>'"; |
|
| 1037 | + $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; |
|
| 1038 | + $p->interdire_scripts = false; |
|
| 1039 | + return $p; |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | /** |
@@ -1049,9 +1049,9 @@ discard block |
||
| 1049 | 1049 | * @return object |
| 1050 | 1050 | */ |
| 1051 | 1051 | function balise_INSERT_HEAD_CSS_dist($p) { |
| 1052 | - $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1053 | - $p->interdire_scripts = false; |
|
| 1054 | - return $p; |
|
| 1052 | + $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; |
|
| 1053 | + $p->interdire_scripts = false; |
|
| 1054 | + return $p; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | // |
| 1057 | 1057 | // #INCLURE statique |
@@ -1061,119 +1061,119 @@ discard block |
||
| 1061 | 1061 | // (Incompatible avec les balises dynamiques) |
| 1062 | 1062 | // http://doc.spip.org/@balise_INCLUDE_dist |
| 1063 | 1063 | function balise_INCLUDE_dist($p) { |
| 1064 | - if(function_exists('balise_INCLURE')) |
|
| 1065 | - return balise_INCLURE($p); |
|
| 1066 | - else |
|
| 1067 | - return balise_INCLURE_dist($p); |
|
| 1064 | + if(function_exists('balise_INCLURE')) |
|
| 1065 | + return balise_INCLURE($p); |
|
| 1066 | + else |
|
| 1067 | + return balise_INCLURE_dist($p); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | // http://doc.spip.org/@balise_INCLURE_dist |
| 1070 | 1070 | function balise_INCLURE_dist($p) { |
| 1071 | - $id_boucle = $p->id_boucle; |
|
| 1072 | - // la lang n'est pas passe de facon automatique par argumenter |
|
| 1073 | - // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1074 | - // en option |
|
| 1071 | + $id_boucle = $p->id_boucle; |
|
| 1072 | + // la lang n'est pas passe de facon automatique par argumenter |
|
| 1073 | + // mais le sera pas recuperer_fond, sauf si etoile=>true est passe |
|
| 1074 | + // en option |
|
| 1075 | 1075 | |
| 1076 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1076 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false); |
|
| 1077 | 1077 | |
| 1078 | - // erreur de syntaxe = fond absent |
|
| 1079 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1080 | - if (!$_contexte) $contexte = array(); |
|
| 1078 | + // erreur de syntaxe = fond absent |
|
| 1079 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1080 | + if (!$_contexte) $contexte = array(); |
|
| 1081 | 1081 | |
| 1082 | - if (isset($_contexte['fond'])) { |
|
| 1082 | + if (isset($_contexte['fond'])) { |
|
| 1083 | 1083 | |
| 1084 | - $f = $_contexte['fond']; |
|
| 1085 | - // toujours vrai : |
|
| 1086 | - if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1087 | - $f = $r[1]; |
|
| 1088 | - unset($_contexte['fond']); |
|
| 1089 | - } else spip_log("compilation de #INCLURE a revoir"); |
|
| 1084 | + $f = $_contexte['fond']; |
|
| 1085 | + // toujours vrai : |
|
| 1086 | + if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
|
| 1087 | + $f = $r[1]; |
|
| 1088 | + unset($_contexte['fond']); |
|
| 1089 | + } else spip_log("compilation de #INCLURE a revoir"); |
|
| 1090 | 1090 | |
| 1091 | - // #INCLURE{doublons} |
|
| 1092 | - if (isset($_contexte['doublons'])) { |
|
| 1093 | - $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 1094 | - } |
|
| 1091 | + // #INCLURE{doublons} |
|
| 1092 | + if (isset($_contexte['doublons'])) { |
|
| 1093 | + $_contexte['doublons'] = "'doublons' => \$doublons"; |
|
| 1094 | + } |
|
| 1095 | 1095 | |
| 1096 | - // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 1097 | - if (isset($_contexte['env']) |
|
| 1098 | - || isset($_contexte['self']) |
|
| 1099 | - ) { |
|
| 1100 | - $flag_env = true; |
|
| 1101 | - unset($_contexte['env']); |
|
| 1102 | - } else $flag_env = false; |
|
| 1096 | + // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
|
| 1097 | + if (isset($_contexte['env']) |
|
| 1098 | + || isset($_contexte['self']) |
|
| 1099 | + ) { |
|
| 1100 | + $flag_env = true; |
|
| 1101 | + unset($_contexte['env']); |
|
| 1102 | + } else $flag_env = false; |
|
| 1103 | 1103 | |
| 1104 | - $_options = array(); |
|
| 1105 | - if (isset($_contexte['ajax'])) { |
|
| 1106 | - $_options[] = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 1107 | - unset($_contexte['ajax']); |
|
| 1108 | - } |
|
| 1109 | - if ($p->etoile) $_options[] = "'etoile'=>true"; |
|
| 1110 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) .")"; |
|
| 1104 | + $_options = array(); |
|
| 1105 | + if (isset($_contexte['ajax'])) { |
|
| 1106 | + $_options[] = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 1107 | + unset($_contexte['ajax']); |
|
| 1108 | + } |
|
| 1109 | + if ($p->etoile) $_options[] = "'etoile'=>true"; |
|
| 1110 | + $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) .")"; |
|
| 1111 | 1111 | |
| 1112 | - $_l = 'array(' . join(",\n\t", $_contexte) .')'; |
|
| 1113 | - if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 1112 | + $_l = 'array(' . join(",\n\t", $_contexte) .')'; |
|
| 1113 | + if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 1114 | 1114 | |
| 1115 | - $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',',$_options),"''"); |
|
| 1115 | + $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',',$_options),"''"); |
|
| 1116 | 1116 | |
| 1117 | - } elseif (!isset($_contexte[1])) { |
|
| 1118 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); |
|
| 1119 | - erreur_squelette($msg, $p); |
|
| 1120 | - } else $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 1117 | + } elseif (!isset($_contexte[1])) { |
|
| 1118 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); |
|
| 1119 | + erreur_squelette($msg, $p); |
|
| 1120 | + } else $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 1121 | 1121 | |
| 1122 | - $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 1123 | - return $p; |
|
| 1122 | + $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
|
| 1123 | + return $p; |
|
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | 1126 | // Inclure un modele : #MODELE{modele, params} |
| 1127 | 1127 | // http://doc.spip.org/@balise_MODELE_dist |
| 1128 | 1128 | function balise_MODELE_dist($p) { |
| 1129 | 1129 | |
| 1130 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 1130 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false); |
|
| 1131 | 1131 | |
| 1132 | - // erreur de syntaxe = fond absent |
|
| 1133 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1134 | - if (!$_contexte) $contexte = array(); |
|
| 1132 | + // erreur de syntaxe = fond absent |
|
| 1133 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
|
| 1134 | + if (!$_contexte) $contexte = array(); |
|
| 1135 | 1135 | |
| 1136 | - if (!isset($_contexte[1])) { |
|
| 1137 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); |
|
| 1138 | - erreur_squelette($msg, $p); |
|
| 1139 | - } else { |
|
| 1140 | - $nom = $_contexte[1]; |
|
| 1141 | - unset($_contexte[1]); |
|
| 1136 | + if (!isset($_contexte[1])) { |
|
| 1137 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); |
|
| 1138 | + erreur_squelette($msg, $p); |
|
| 1139 | + } else { |
|
| 1140 | + $nom = $_contexte[1]; |
|
| 1141 | + unset($_contexte[1]); |
|
| 1142 | 1142 | |
| 1143 | - if (preg_match("/^\s*'[^']*'/s", $nom)) |
|
| 1144 | - $nom = "'modeles/" . substr($nom,1); |
|
| 1145 | - else $nom = "'modeles/' . $nom"; |
|
| 1143 | + if (preg_match("/^\s*'[^']*'/s", $nom)) |
|
| 1144 | + $nom = "'modeles/" . substr($nom,1); |
|
| 1145 | + else $nom = "'modeles/' . $nom"; |
|
| 1146 | 1146 | |
| 1147 | - // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 1148 | - // Reserver la cle primaire de la boucle courante si elle existe |
|
| 1149 | - if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 1150 | - $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 1151 | - if (!strpos($primary,',')) { |
|
| 1152 | - $id = champ_sql($primary, $p); |
|
| 1153 | - $_contexte[] = "'$primary'=>".$id; |
|
| 1154 | - $_contexte[] = "'id'=>".$id; |
|
| 1155 | - } |
|
| 1156 | - } |
|
| 1157 | - $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 1158 | - $connect = ''; |
|
| 1159 | - if (isset($p->boucles[$p->id_boucle])) |
|
| 1160 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 1147 | + // Incoherence dans la syntaxe du contexte. A revoir. |
|
| 1148 | + // Reserver la cle primaire de la boucle courante si elle existe |
|
| 1149 | + if (isset($p->boucles[$p->id_boucle]->primary)) { |
|
| 1150 | + $primary = $p->boucles[$p->id_boucle]->primary; |
|
| 1151 | + if (!strpos($primary,',')) { |
|
| 1152 | + $id = champ_sql($primary, $p); |
|
| 1153 | + $_contexte[] = "'$primary'=>".$id; |
|
| 1154 | + $_contexte[] = "'id'=>".$id; |
|
| 1155 | + } |
|
| 1156 | + } |
|
| 1157 | + $_contexte[] = "'recurs'=>(++\$recurs)"; |
|
| 1158 | + $connect = ''; |
|
| 1159 | + if (isset($p->boucles[$p->id_boucle])) |
|
| 1160 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 1161 | 1161 | |
| 1162 | - $_options = memoriser_contexte_compil($p); |
|
| 1163 | - $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 1164 | - if (isset($_contexte['ajax'])){ |
|
| 1165 | - $_options .= ", ".preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 1166 | - unset($_contexte['ajax']); |
|
| 1167 | - } |
|
| 1162 | + $_options = memoriser_contexte_compil($p); |
|
| 1163 | + $_options = "'compil'=>array($_options), 'trim'=>true"; |
|
| 1164 | + if (isset($_contexte['ajax'])){ |
|
| 1165 | + $_options .= ", ".preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 1166 | + unset($_contexte['ajax']); |
|
| 1167 | + } |
|
| 1168 | 1168 | |
| 1169 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, 'array(' . join(',', $_contexte) .')', $_options, _q($connect)); |
|
| 1169 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, 'array(' . join(',', $_contexte) .')', $_options, _q($connect)); |
|
| 1170 | 1170 | |
| 1171 | - $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 1171 | + $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
|
| 1172 | 1172 | |
| 1173 | - $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 1174 | - } |
|
| 1173 | + $p->interdire_scripts = false; // securite assuree par le squelette |
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | - return $p; |
|
| 1176 | + return $p; |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | // |
@@ -1183,19 +1183,19 @@ discard block |
||
| 1183 | 1183 | // la balise renvoie la valeur |
| 1184 | 1184 | // http://doc.spip.org/@balise_SET_dist |
| 1185 | 1185 | function balise_SET_dist($p){ |
| 1186 | - $_nom = interprete_argument_balise(1,$p); |
|
| 1187 | - $_val = interprete_argument_balise(2,$p); |
|
| 1186 | + $_nom = interprete_argument_balise(1,$p); |
|
| 1187 | + $_val = interprete_argument_balise(2,$p); |
|
| 1188 | 1188 | |
| 1189 | - if (!$_nom OR !$_val) { |
|
| 1190 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); |
|
| 1191 | - erreur_squelette($err_b_s_a, $p); |
|
| 1192 | - } |
|
| 1193 | - // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 1194 | - // cf https://bugs.php.net/bug.php?id=65845 |
|
| 1195 | - else $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 1189 | + if (!$_nom OR !$_val) { |
|
| 1190 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); |
|
| 1191 | + erreur_squelette($err_b_s_a, $p); |
|
| 1192 | + } |
|
| 1193 | + // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
|
| 1194 | + // cf https://bugs.php.net/bug.php?id=65845 |
|
| 1195 | + else $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 1196 | 1196 | |
| 1197 | - $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 1198 | - return $p; |
|
| 1197 | + $p->interdire_scripts = false; // la balise ne renvoie rien |
|
| 1198 | + return $p; |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | // |
@@ -1205,11 +1205,11 @@ discard block |
||
| 1205 | 1205 | // |
| 1206 | 1206 | // http://doc.spip.org/@balise_GET_dist |
| 1207 | 1207 | function balise_GET_dist($p) { |
| 1208 | - $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 1209 | - if (function_exists('balise_ENV')) |
|
| 1210 | - return balise_ENV($p, '$Pile["vars"]'); |
|
| 1211 | - else |
|
| 1212 | - return balise_ENV_dist($p, '$Pile["vars"]'); |
|
| 1208 | + $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
|
| 1209 | + if (function_exists('balise_ENV')) |
|
| 1210 | + return balise_ENV($p, '$Pile["vars"]'); |
|
| 1211 | + else |
|
| 1212 | + return balise_ENV_dist($p, '$Pile["vars"]'); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | |
@@ -1229,20 +1229,20 @@ discard block |
||
| 1229 | 1229 | * Pile complétée par le code à générer |
| 1230 | 1230 | **/ |
| 1231 | 1231 | function balise_DOUBLONS_dist($p) { |
| 1232 | - if ($type = interprete_argument_balise(1,$p)) { |
|
| 1233 | - if ($famille = interprete_argument_balise(2,$p)) |
|
| 1234 | - $type .= '.' . $famille; |
|
| 1235 | - $p->code = '$doublons['.$type.']'; |
|
| 1236 | - if (!$p->etoile) |
|
| 1237 | - $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 1238 | - . $p->code . ')))'; |
|
| 1239 | - } |
|
| 1240 | - else |
|
| 1241 | - $p->code = '$doublons'; |
|
| 1232 | + if ($type = interprete_argument_balise(1,$p)) { |
|
| 1233 | + if ($famille = interprete_argument_balise(2,$p)) |
|
| 1234 | + $type .= '.' . $famille; |
|
| 1235 | + $p->code = '$doublons['.$type.']'; |
|
| 1236 | + if (!$p->etoile) |
|
| 1237 | + $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 1238 | + . $p->code . ')))'; |
|
| 1239 | + } |
|
| 1240 | + else |
|
| 1241 | + $p->code = '$doublons'; |
|
| 1242 | 1242 | |
| 1243 | - $p->interdire_scripts = false; |
|
| 1243 | + $p->interdire_scripts = false; |
|
| 1244 | 1244 | |
| 1245 | - return $p; |
|
| 1245 | + return $p; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | |
@@ -1254,17 +1254,17 @@ discard block |
||
| 1254 | 1254 | // |
| 1255 | 1255 | // http://doc.spip.org/@balise_PIPELINE_dist |
| 1256 | 1256 | function balise_PIPELINE_dist($p) { |
| 1257 | - $_pipe = interprete_argument_balise(1,$p); |
|
| 1258 | - if (!$_pipe) { |
|
| 1259 | - $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); |
|
| 1260 | - erreur_squelette($err_b_s_a, $p); |
|
| 1261 | - } else { |
|
| 1262 | - $_flux = interprete_argument_balise(2,$p); |
|
| 1263 | - $_flux = $_flux?$_flux:"''"; |
|
| 1264 | - $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 1265 | - $p->interdire_scripts = false; |
|
| 1266 | - } |
|
| 1267 | - return $p; |
|
| 1257 | + $_pipe = interprete_argument_balise(1,$p); |
|
| 1258 | + if (!$_pipe) { |
|
| 1259 | + $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); |
|
| 1260 | + erreur_squelette($err_b_s_a, $p); |
|
| 1261 | + } else { |
|
| 1262 | + $_flux = interprete_argument_balise(2,$p); |
|
| 1263 | + $_flux = $_flux?$_flux:"''"; |
|
| 1264 | + $p->code = "pipeline( $_pipe , $_flux )"; |
|
| 1265 | + $p->interdire_scripts = false; |
|
| 1266 | + } |
|
| 1267 | + return $p; |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | // |
@@ -1273,9 +1273,9 @@ discard block |
||
| 1273 | 1273 | // |
| 1274 | 1274 | // http://doc.spip.org/@balise_EDIT_dist |
| 1275 | 1275 | function balise_EDIT_dist($p) { |
| 1276 | - $p->code = "''"; |
|
| 1277 | - $p->interdire_scripts = false; |
|
| 1278 | - return $p; |
|
| 1276 | + $p->code = "''"; |
|
| 1277 | + $p->interdire_scripts = false; |
|
| 1278 | + return $p; |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | |
@@ -1289,10 +1289,10 @@ discard block |
||
| 1289 | 1289 | // |
| 1290 | 1290 | // http://doc.spip.org/@balise_TOTAL_UNIQUE_dist |
| 1291 | 1291 | function balise_TOTAL_UNIQUE_dist($p) { |
| 1292 | - $_famille = interprete_argument_balise(1,$p); |
|
| 1293 | - $_famille = $_famille ? $_famille : "''"; |
|
| 1294 | - $p->code = "unique('', $_famille, true)"; |
|
| 1295 | - return $p; |
|
| 1292 | + $_famille = interprete_argument_balise(1,$p); |
|
| 1293 | + $_famille = $_famille ? $_famille : "''"; |
|
| 1294 | + $p->code = "unique('', $_famille, true)"; |
|
| 1295 | + return $p; |
|
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | 1298 | // |
@@ -1302,16 +1302,16 @@ discard block |
||
| 1302 | 1302 | // |
| 1303 | 1303 | // http://doc.spip.org/@balise_ARRAY_dist |
| 1304 | 1304 | function balise_ARRAY_dist($p) { |
| 1305 | - $_code = array(); |
|
| 1306 | - $n=1; |
|
| 1307 | - do { |
|
| 1308 | - $_key = interprete_argument_balise($n++,$p); |
|
| 1309 | - $_val = interprete_argument_balise($n++,$p); |
|
| 1310 | - if ($_key AND $_val) $_code[] = "$_key => $_val"; |
|
| 1311 | - } while ($_key && $_val); |
|
| 1312 | - $p->code = 'array(' . join(', ',$_code).')'; |
|
| 1313 | - $p->interdire_scripts = false; |
|
| 1314 | - return $p; |
|
| 1305 | + $_code = array(); |
|
| 1306 | + $n=1; |
|
| 1307 | + do { |
|
| 1308 | + $_key = interprete_argument_balise($n++,$p); |
|
| 1309 | + $_val = interprete_argument_balise($n++,$p); |
|
| 1310 | + if ($_key AND $_val) $_code[] = "$_key => $_val"; |
|
| 1311 | + } while ($_key && $_val); |
|
| 1312 | + $p->code = 'array(' . join(', ',$_code).')'; |
|
| 1313 | + $p->interdire_scripts = false; |
|
| 1314 | + return $p; |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
@@ -1321,13 +1321,13 @@ discard block |
||
| 1321 | 1321 | * @return <type> |
| 1322 | 1322 | */ |
| 1323 | 1323 | function balise_LISTE_dist($p) { |
| 1324 | - $_code = array(); |
|
| 1325 | - $n=1; |
|
| 1326 | - while ($_val = interprete_argument_balise($n++,$p)) |
|
| 1327 | - $_code[] = $_val; |
|
| 1328 | - $p->code = 'array(' . join(', ',$_code).')'; |
|
| 1329 | - $p->interdire_scripts = false; |
|
| 1330 | - return $p; |
|
| 1324 | + $_code = array(); |
|
| 1325 | + $n=1; |
|
| 1326 | + while ($_val = interprete_argument_balise($n++,$p)) |
|
| 1327 | + $_code[] = $_val; |
|
| 1328 | + $p->code = 'array(' . join(', ',$_code).')'; |
|
| 1329 | + $p->interdire_scripts = false; |
|
| 1330 | + return $p; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | // Appelle la fonction autoriser et renvoie ' ' si OK, '' si niet |
@@ -1335,54 +1335,54 @@ discard block |
||
| 1335 | 1335 | // Cette balise cree un cache par session |
| 1336 | 1336 | // http://doc.spip.org/@balise_AUTORISER_dist |
| 1337 | 1337 | function balise_AUTORISER_dist($p) { |
| 1338 | - $_code = array(); |
|
| 1339 | - $p->descr['session'] = true; // faire un cache par session |
|
| 1338 | + $_code = array(); |
|
| 1339 | + $p->descr['session'] = true; // faire un cache par session |
|
| 1340 | 1340 | |
| 1341 | - $n=1; |
|
| 1342 | - while ($_v = interprete_argument_balise($n++,$p)) |
|
| 1343 | - $_code[] = $_v; |
|
| 1341 | + $n=1; |
|
| 1342 | + while ($_v = interprete_argument_balise($n++,$p)) |
|
| 1343 | + $_code[] = $_v; |
|
| 1344 | 1344 | |
| 1345 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',$_code).')?" ":"")'; |
|
| 1346 | - $p->interdire_scripts = false; |
|
| 1347 | - return $p; |
|
| 1345 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',$_code).')?" ":"")'; |
|
| 1346 | + $p->interdire_scripts = false; |
|
| 1347 | + return $p; |
|
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | 1350 | // Appelle la fonction info_plugin |
| 1351 | 1351 | // Afficher des informations sur les plugins dans le site public |
| 1352 | 1352 | // http://doc.spip.org/@balise_PLUGIN_dist |
| 1353 | 1353 | function balise_PLUGIN_dist($p) { |
| 1354 | - $plugin = interprete_argument_balise(1,$p); |
|
| 1355 | - $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 1356 | - $type_info = interprete_argument_balise(2,$p); |
|
| 1357 | - $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 1354 | + $plugin = interprete_argument_balise(1,$p); |
|
| 1355 | + $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
|
| 1356 | + $type_info = interprete_argument_balise(2,$p); |
|
| 1357 | + $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
|
| 1358 | 1358 | |
| 1359 | - $f = chercher_filtre('info_plugin'); |
|
| 1360 | - $p->code = $f.'('.$plugin.', '.$type_info.')'; |
|
| 1361 | - return $p; |
|
| 1359 | + $f = chercher_filtre('info_plugin'); |
|
| 1360 | + $p->code = $f.'('.$plugin.', '.$type_info.')'; |
|
| 1361 | + return $p; |
|
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | // Appelle la fonction inc_aider_dist |
| 1365 | 1365 | // http://doc.spip.org/@balise_AIDER_dist |
| 1366 | 1366 | function balise_AIDER_dist($p) { |
| 1367 | - $_motif = interprete_argument_balise(1,$p); |
|
| 1368 | - $s = "'" . addslashes($p->descr['sourcefile']) . "'"; |
|
| 1369 | - $aider = charger_fonction('aider','inc'); |
|
| 1370 | - $p->code = "((\$aider=charger_fonction('aider','inc'))?\$aider($_motif,$s, \$Pile[0]):'')"; |
|
| 1371 | - return $p; |
|
| 1367 | + $_motif = interprete_argument_balise(1,$p); |
|
| 1368 | + $s = "'" . addslashes($p->descr['sourcefile']) . "'"; |
|
| 1369 | + $aider = charger_fonction('aider','inc'); |
|
| 1370 | + $p->code = "((\$aider=charger_fonction('aider','inc'))?\$aider($_motif,$s, \$Pile[0]):'')"; |
|
| 1371 | + return $p; |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | // Insertion du contexte des formulaires charger/verifier/traiter |
| 1375 | 1375 | // avec les hidden de l'url d'action |
| 1376 | 1376 | // http://doc.spip.org/@balise_ACTION_FORMULAIRE |
| 1377 | 1377 | function balise_ACTION_FORMULAIRE($p){ |
| 1378 | - if (!$_url = interprete_argument_balise(1,$p)) |
|
| 1379 | - $_url = "@\$Pile[0]['action']"; |
|
| 1380 | - if (!$_form = interprete_argument_balise(2,$p)) |
|
| 1381 | - $_form = "@\$Pile[0]['form']"; |
|
| 1382 | - |
|
| 1383 | - // envoyer le nom du formulaire que l'on traite |
|
| 1384 | - // transmettre les eventuels args de la balise formulaire |
|
| 1385 | - $p->code = " '<div>' . |
|
| 1378 | + if (!$_url = interprete_argument_balise(1,$p)) |
|
| 1379 | + $_url = "@\$Pile[0]['action']"; |
|
| 1380 | + if (!$_form = interprete_argument_balise(2,$p)) |
|
| 1381 | + $_form = "@\$Pile[0]['form']"; |
|
| 1382 | + |
|
| 1383 | + // envoyer le nom du formulaire que l'on traite |
|
| 1384 | + // transmettre les eventuels args de la balise formulaire |
|
| 1385 | + $p->code = " '<div>' . |
|
| 1386 | 1386 | form_hidden($_url) . |
| 1387 | 1387 | '<input name=\'formulaire_action\' type=\'hidden\' |
| 1388 | 1388 | value=\'' . $_form . '\' />' . |
@@ -1391,8 +1391,8 @@ discard block |
||
| 1391 | 1391 | (@\$Pile[0]['_hidden']?@\$Pile[0]['_hidden']:'') . |
| 1392 | 1392 | '</div>'"; |
| 1393 | 1393 | |
| 1394 | - $p->interdire_scripts = false; |
|
| 1395 | - return $p; |
|
| 1394 | + $p->interdire_scripts = false; |
|
| 1395 | + return $p; |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | |
@@ -1412,29 +1412,29 @@ discard block |
||
| 1412 | 1412 | */ |
| 1413 | 1413 | function balise_BOUTON_ACTION_dist($p){ |
| 1414 | 1414 | |
| 1415 | - $args = array(); |
|
| 1416 | - for ($k=1;$k<=6;$k++){ |
|
| 1417 | - $_a = interprete_argument_balise($k,$p); |
|
| 1418 | - if (!$_a) $_a="''"; |
|
| 1419 | - $args[] = $_a; |
|
| 1420 | - } |
|
| 1421 | - // supprimer les args vides |
|
| 1422 | - while(end($args)=="''" AND count($args)>2) |
|
| 1423 | - array_pop($args); |
|
| 1424 | - $args = implode(",",$args); |
|
| 1415 | + $args = array(); |
|
| 1416 | + for ($k=1;$k<=6;$k++){ |
|
| 1417 | + $_a = interprete_argument_balise($k,$p); |
|
| 1418 | + if (!$_a) $_a="''"; |
|
| 1419 | + $args[] = $_a; |
|
| 1420 | + } |
|
| 1421 | + // supprimer les args vides |
|
| 1422 | + while(end($args)=="''" AND count($args)>2) |
|
| 1423 | + array_pop($args); |
|
| 1424 | + $args = implode(",",$args); |
|
| 1425 | 1425 | |
| 1426 | - $bouton_action = chercher_filtre("bouton_action"); |
|
| 1427 | - $p->code = "$bouton_action($args)"; |
|
| 1428 | - $p->interdire_scripts = false; |
|
| 1429 | - return $p; |
|
| 1426 | + $bouton_action = chercher_filtre("bouton_action"); |
|
| 1427 | + $p->code = "$bouton_action($args)"; |
|
| 1428 | + $p->interdire_scripts = false; |
|
| 1429 | + return $p; |
|
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | 1432 | |
| 1433 | 1433 | |
| 1434 | 1434 | function balise_SLOGAN_SITE_SPIP_dist($p) { |
| 1435 | - $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 1436 | - #$p->interdire_scripts = true; |
|
| 1437 | - return $p; |
|
| 1435 | + $p->code = "\$GLOBALS['meta']['slogan_site']"; |
|
| 1436 | + #$p->interdire_scripts = true; |
|
| 1437 | + return $p; |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | // #HTML5 |
@@ -1442,9 +1442,9 @@ discard block |
||
| 1442 | 1442 | // le site public, et '' si le code doit etre strictement compatible HTML4 |
| 1443 | 1443 | // http://doc.spip.org/@balise_HTML5_dist |
| 1444 | 1444 | function balise_HTML5_dist($p) { |
| 1445 | - $p->code = html5_permis() ? "' '" : "''"; |
|
| 1446 | - $p->interdire_scripts = false; |
|
| 1447 | - return $p; |
|
| 1445 | + $p->code = html5_permis() ? "' '" : "''"; |
|
| 1446 | + $p->interdire_scripts = false; |
|
| 1447 | + return $p; |
|
| 1448 | 1448 | } |
| 1449 | 1449 | |
| 1450 | 1450 | |
@@ -1459,58 +1459,58 @@ discard block |
||
| 1459 | 1459 | * @return unknown |
| 1460 | 1460 | */ |
| 1461 | 1461 | function balise_TRI_dist($p, $liste='true') { |
| 1462 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 1463 | - |
|
| 1464 | - // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 1465 | - if ($b === '') { |
|
| 1466 | - erreur_squelette( |
|
| 1467 | - _T('zbug_champ_hors_boucle', |
|
| 1468 | - array('champ' => '#TRI') |
|
| 1469 | - ), $p->id_boucle); |
|
| 1470 | - $p->code = "''"; |
|
| 1471 | - return $p; |
|
| 1472 | - } |
|
| 1473 | - $boucle = $p->boucles[$b]; |
|
| 1474 | - |
|
| 1475 | - // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 1476 | - // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 1477 | - if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 1478 | - erreur_squelette( |
|
| 1479 | - _T('zbug_tri_sans_critere', |
|
| 1480 | - array('champ' => '#TRI') |
|
| 1481 | - ), $p->id_boucle); |
|
| 1482 | - $p->code = "''"; |
|
| 1483 | - return $p; |
|
| 1484 | - } |
|
| 1485 | - |
|
| 1486 | - $_champ = interprete_argument_balise(1,$p); |
|
| 1487 | - // si pas de champ, renvoyer le critere de tri utilise |
|
| 1488 | - if (!$_champ){ |
|
| 1489 | - $p->code = $boucle->modificateur['tri_champ']; |
|
| 1490 | - return $p; |
|
| 1491 | - } |
|
| 1492 | - // forcer la jointure si besoin, et si le champ est statique |
|
| 1493 | - if (preg_match(",^'([\w.]+)'$,i",$_champ,$m)){ |
|
| 1494 | - index_pile($b, $m[1], $p->boucles); |
|
| 1495 | - } |
|
| 1496 | - |
|
| 1497 | - $_libelle = interprete_argument_balise(2,$p); |
|
| 1498 | - $_libelle = $_libelle?$_libelle:$_champ; |
|
| 1499 | - |
|
| 1500 | - $_class = interprete_argument_balise(3,$p); |
|
| 1501 | - // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
|
| 1502 | - // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
|
| 1503 | - $_issens = "in_array($_champ,array('>','<'))"; |
|
| 1504 | - $_sens = "(strpos('< >',$_champ)-1)"; |
|
| 1505 | - |
|
| 1506 | - $_variable = "((\$s=$_issens)?'sens':'tri').".$boucle->modificateur['tri_nom']; |
|
| 1507 | - $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
|
| 1508 | - $_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)"; |
|
| 1509 | - |
|
| 1510 | - $p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class?",$_class":"").")"; |
|
| 1511 | - //$p->code = "''"; |
|
| 1512 | - $p->interdire_scripts = false; |
|
| 1513 | - return $p; |
|
| 1462 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
|
| 1463 | + |
|
| 1464 | + // s'il n'y a pas de nom de boucle, on ne peut pas trier |
|
| 1465 | + if ($b === '') { |
|
| 1466 | + erreur_squelette( |
|
| 1467 | + _T('zbug_champ_hors_boucle', |
|
| 1468 | + array('champ' => '#TRI') |
|
| 1469 | + ), $p->id_boucle); |
|
| 1470 | + $p->code = "''"; |
|
| 1471 | + return $p; |
|
| 1472 | + } |
|
| 1473 | + $boucle = $p->boucles[$b]; |
|
| 1474 | + |
|
| 1475 | + // s'il n'y a pas de tri_champ, c'est qu'on se trouve |
|
| 1476 | + // dans un boucle recursive ou qu'on a oublie le critere {tri} |
|
| 1477 | + if (!isset($boucle->modificateur['tri_champ'])) { |
|
| 1478 | + erreur_squelette( |
|
| 1479 | + _T('zbug_tri_sans_critere', |
|
| 1480 | + array('champ' => '#TRI') |
|
| 1481 | + ), $p->id_boucle); |
|
| 1482 | + $p->code = "''"; |
|
| 1483 | + return $p; |
|
| 1484 | + } |
|
| 1485 | + |
|
| 1486 | + $_champ = interprete_argument_balise(1,$p); |
|
| 1487 | + // si pas de champ, renvoyer le critere de tri utilise |
|
| 1488 | + if (!$_champ){ |
|
| 1489 | + $p->code = $boucle->modificateur['tri_champ']; |
|
| 1490 | + return $p; |
|
| 1491 | + } |
|
| 1492 | + // forcer la jointure si besoin, et si le champ est statique |
|
| 1493 | + if (preg_match(",^'([\w.]+)'$,i",$_champ,$m)){ |
|
| 1494 | + index_pile($b, $m[1], $p->boucles); |
|
| 1495 | + } |
|
| 1496 | + |
|
| 1497 | + $_libelle = interprete_argument_balise(2,$p); |
|
| 1498 | + $_libelle = $_libelle?$_libelle:$_champ; |
|
| 1499 | + |
|
| 1500 | + $_class = interprete_argument_balise(3,$p); |
|
| 1501 | + // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
|
| 1502 | + // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
|
| 1503 | + $_issens = "in_array($_champ,array('>','<'))"; |
|
| 1504 | + $_sens = "(strpos('< >',$_champ)-1)"; |
|
| 1505 | + |
|
| 1506 | + $_variable = "((\$s=$_issens)?'sens':'tri').".$boucle->modificateur['tri_nom']; |
|
| 1507 | + $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
|
| 1508 | + $_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)"; |
|
| 1509 | + |
|
| 1510 | + $p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class?",$_class":"").")"; |
|
| 1511 | + //$p->code = "''"; |
|
| 1512 | + $p->interdire_scripts = false; |
|
| 1513 | + return $p; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | |
@@ -1526,22 +1526,22 @@ discard block |
||
| 1526 | 1526 | * @return <type> |
| 1527 | 1527 | */ |
| 1528 | 1528 | function balise_SAUTER_dist($p){ |
| 1529 | - $id_boucle = $p->id_boucle; |
|
| 1530 | - $boucle = $p->boucles[$id_boucle]; |
|
| 1529 | + $id_boucle = $p->id_boucle; |
|
| 1530 | + $boucle = $p->boucles[$id_boucle]; |
|
| 1531 | 1531 | |
| 1532 | - if (!$boucle) { |
|
| 1533 | - $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); |
|
| 1534 | - erreur_squelette($msg, $p); |
|
| 1535 | - } |
|
| 1536 | - else { |
|
| 1537 | - $_saut = interprete_argument_balise(1,$p); |
|
| 1538 | - $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 1539 | - $_total = "\$Numrows['$id_boucle']['total']"; |
|
| 1532 | + if (!$boucle) { |
|
| 1533 | + $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); |
|
| 1534 | + erreur_squelette($msg, $p); |
|
| 1535 | + } |
|
| 1536 | + else { |
|
| 1537 | + $_saut = interprete_argument_balise(1,$p); |
|
| 1538 | + $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
|
| 1539 | + $_total = "\$Numrows['$id_boucle']['total']"; |
|
| 1540 | 1540 | |
| 1541 | - $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 1542 | - } |
|
| 1543 | - $p->interdire_scripts = false; |
|
| 1544 | - return $p; |
|
| 1541 | + $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))"; |
|
| 1542 | + } |
|
| 1543 | + $p->interdire_scripts = false; |
|
| 1544 | + return $p; |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | |
@@ -1552,18 +1552,18 @@ discard block |
||
| 1552 | 1552 | * @return <type> |
| 1553 | 1553 | */ |
| 1554 | 1554 | function balise_PUBLIE_dist($p) { |
| 1555 | - if (!$_type = interprete_argument_balise(1,$p)){ |
|
| 1556 | - $_type = _q($p->type_requete); |
|
| 1557 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary,$p); |
|
| 1558 | - } |
|
| 1559 | - else |
|
| 1560 | - $_id = interprete_argument_balise(2,$p); |
|
| 1555 | + if (!$_type = interprete_argument_balise(1,$p)){ |
|
| 1556 | + $_type = _q($p->type_requete); |
|
| 1557 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary,$p); |
|
| 1558 | + } |
|
| 1559 | + else |
|
| 1560 | + $_id = interprete_argument_balise(2,$p); |
|
| 1561 | 1561 | |
| 1562 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 1562 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 1563 | 1563 | |
| 1564 | - $p->code = "(objet_test_si_publie(".$_type.",intval(".$_id."),"._q($connect).")?' ':'')"; |
|
| 1565 | - $p->interdire_scripts = false; |
|
| 1566 | - return $p; |
|
| 1564 | + $p->code = "(objet_test_si_publie(".$_type.",intval(".$_id."),"._q($connect).")?' ':'')"; |
|
| 1565 | + $p->interdire_scripts = false; |
|
| 1566 | + return $p; |
|
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | 1569 | /** |
@@ -1582,12 +1582,12 @@ discard block |
||
| 1582 | 1582 | * @return object |
| 1583 | 1583 | */ |
| 1584 | 1584 | function balise_PRODUIRE_dist($p){ |
| 1585 | - $balise_inclure = charger_fonction('INCLURE','balise'); |
|
| 1586 | - $p = $balise_inclure($p); |
|
| 1585 | + $balise_inclure = charger_fonction('INCLURE','balise'); |
|
| 1586 | + $p = $balise_inclure($p); |
|
| 1587 | 1587 | |
| 1588 | - $p->code = str_replace('recuperer_fond(','produire_fond_statique(',$p->code); |
|
| 1588 | + $p->code = str_replace('recuperer_fond(','produire_fond_statique(',$p->code); |
|
| 1589 | 1589 | |
| 1590 | - return $p; |
|
| 1590 | + return $p; |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | /** |
@@ -1598,9 +1598,9 @@ discard block |
||
| 1598 | 1598 | * @return |
| 1599 | 1599 | */ |
| 1600 | 1600 | function balise_LARGEUR_ECRAN_dist($p){ |
| 1601 | - $_class = interprete_argument_balise(1,$p); |
|
| 1602 | - if (!$_class) $_class='null'; |
|
| 1603 | - $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 1604 | - return $p; |
|
| 1601 | + $_class = interprete_argument_balise(1,$p); |
|
| 1602 | + if (!$_class) $_class='null'; |
|
| 1603 | + $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
|
| 1604 | + return $p; |
|
| 1605 | 1605 | } |
| 1606 | 1606 | ?> |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 21 | 21 | |
| 22 | 22 | // http://doc.spip.org/@interprete_argument_balise |
| 23 | -function interprete_argument_balise($n,$p) { |
|
| 24 | - if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n)) |
|
| 23 | +function interprete_argument_balise($n, $p) { |
|
| 24 | + if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) |
|
| 25 | 25 | return calculer_liste($p->param[0][$n], |
| 26 | 26 | $p->descr, |
| 27 | 27 | $p->boucles, |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | // quand #DATE est en dehors des boucles |
| 97 | 97 | // http://www.spip.net/fr_article1971.html |
| 98 | 98 | // http://doc.spip.org/@balise_DATE_dist |
| 99 | -function balise_DATE_dist ($p) { |
|
| 99 | +function balise_DATE_dist($p) { |
|
| 100 | 100 | $d = champ_sql('date', $p); |
| 101 | 101 | # if ($d === "@\$Pile[0]['date']") |
| 102 | 102 | # $d = "isset(\$Pile[0]['date']) ? $d : time()"; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | // #DATE_REDAC |
| 108 | 108 | // http://www.spip.net/fr_article1971.html |
| 109 | 109 | // http://doc.spip.org/@balise_DATE_REDAC_dist |
| 110 | -function balise_DATE_REDAC_dist ($p) { |
|
| 110 | +function balise_DATE_REDAC_dist($p) { |
|
| 111 | 111 | $d = champ_sql('date_redac', $p); |
| 112 | 112 | # if ($d === "@\$Pile[0]['date_redac']") |
| 113 | 113 | # $d = "isset(\$Pile[0]['date_redac']) ? $d : time()"; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | // #DATE_MODIF |
| 120 | 120 | // http://www.spip.net/fr_article1971.html |
| 121 | 121 | // http://doc.spip.org/@balise_DATE_MODIF_dist |
| 122 | -function balise_DATE_MODIF_dist ($p) { |
|
| 122 | +function balise_DATE_MODIF_dist($p) { |
|
| 123 | 123 | $p->code = champ_sql('date_modif', $p); |
| 124 | 124 | $p->interdire_scripts = false; |
| 125 | 125 | return $p; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | // http://doc.spip.org/@balise_DOSSIER_SQUELETTE_dist |
| 141 | 141 | function balise_DOSSIER_SQUELETTE_dist($p) { |
| 142 | 142 | $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE)); |
| 143 | - $p->code = "_DIR_RACINE . '$code'" . |
|
| 143 | + $p->code = "_DIR_RACINE . '$code'". |
|
| 144 | 144 | $p->interdire_scripts = false; |
| 145 | 145 | return $p; |
| 146 | 146 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | // http://doc.spip.org/@balise_SQUELETTE_dist |
| 149 | 149 | function balise_SQUELETTE_dist($p) { |
| 150 | 150 | $code = addslashes($p->descr['sourcefile']); |
| 151 | - $p->code = "'$code'" . |
|
| 151 | + $p->code = "'$code'". |
|
| 152 | 152 | $p->interdire_scripts = false; |
| 153 | 153 | return $p; |
| 154 | 154 | } |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | **/ |
| 184 | 184 | function balise_NOM_SITE_dist($p) { |
| 185 | 185 | if (!$p->etoile) { |
| 186 | - $p->code = "supprimer_numero(calculer_url(" . |
|
| 187 | - champ_sql('url_site',$p) ."," . |
|
| 188 | - champ_sql('nom_site',$p) . |
|
| 186 | + $p->code = "supprimer_numero(calculer_url(". |
|
| 187 | + champ_sql('url_site', $p).",". |
|
| 188 | + champ_sql('nom_site', $p). |
|
| 189 | 189 | ", 'titre', \$connect, false))"; |
| 190 | 190 | } else |
| 191 | - $p->code = champ_sql('nom_site',$p); |
|
| 191 | + $p->code = champ_sql('nom_site', $p); |
|
| 192 | 192 | |
| 193 | 193 | $p->interdire_scripts = true; |
| 194 | 194 | return $p; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
| 231 | 231 | if ($b === '' || !isset($p->boucles[$b])) { |
| 232 | 232 | $msg = array('zbug_champ_hors_boucle', |
| 233 | - array('champ' => "#$b" . 'TOTAL_BOUCLE') |
|
| 233 | + array('champ' => "#$b".'TOTAL_BOUCLE') |
|
| 234 | 234 | ); |
| 235 | 235 | erreur_squelette($msg, $p); |
| 236 | 236 | } else { |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | // http://doc.spip.org/@balise_POPULARITE_ABSOLUE_dist |
| 251 | 251 | function balise_POPULARITE_ABSOLUE_dist($p) { |
| 252 | - $p->code = 'ceil(' . |
|
| 253 | - champ_sql('popularite', $p) . |
|
| 252 | + $p->code = 'ceil('. |
|
| 253 | + champ_sql('popularite', $p). |
|
| 254 | 254 | ')'; |
| 255 | 255 | $p->interdire_scripts = false; |
| 256 | 256 | return $p; |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | // http://doc.spip.org/@balise_EXPOSE_dist |
| 274 | 274 | function balise_EXPOSE_dist($p) { |
| 275 | 275 | $on = "'on'"; |
| 276 | - $off= "''"; |
|
| 277 | - if (($v = interprete_argument_balise(1,$p))!==NULL){ |
|
| 276 | + $off = "''"; |
|
| 277 | + if (($v = interprete_argument_balise(1, $p)) !== NULL) { |
|
| 278 | 278 | $on = $v; |
| 279 | - if (($v = interprete_argument_balise(2,$p))!==NULL) |
|
| 279 | + if (($v = interprete_argument_balise(2, $p)) !== NULL) |
|
| 280 | 280 | $off = $v; |
| 281 | 281 | |
| 282 | 282 | } |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | // http://doc.spip.org/@balise_VALEUR_dist |
| 290 | 290 | function balise_VALEUR_dist($p) { |
| 291 | 291 | $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
| 292 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);; |
|
| 293 | - if (($v = interprete_argument_balise(1,$p))!==NULL){ |
|
| 292 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); ; |
|
| 293 | + if (($v = interprete_argument_balise(1, $p)) !== NULL) { |
|
| 294 | 294 | $p->code = 'table_valeur('.$p->code.', '.$v.')'; |
| 295 | 295 | } |
| 296 | 296 | $p->interdire_scripts = true; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $parent = 0; // pour if (!$parent) dans calculer_expose |
| 319 | 319 | } elseif (isset($desc['field']['id_rubrique'])) { |
| 320 | 320 | $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
| 321 | - } elseif (isset($desc['field']['id_groupe'])) { |
|
| 321 | + } elseif (isset($desc['field']['id_groupe'])) { |
|
| 322 | 322 | $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
| 323 | 323 | } else $parent = "''"; |
| 324 | 324 | |
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | // http://doc.spip.org/@balise_DEBUT_SURLIGNE_dist |
| 338 | 338 | function balise_DEBUT_SURLIGNE_dist($p) { |
| 339 | 339 | include_spip('inc/surligne'); |
| 340 | - $p->code = "'<!-- " . MARQUEUR_SURLIGNE . " -->'"; |
|
| 340 | + $p->code = "'<!-- ".MARQUEUR_SURLIGNE." -->'"; |
|
| 341 | 341 | return $p; |
| 342 | 342 | } |
| 343 | 343 | // http://doc.spip.org/@balise_FIN_SURLIGNE_dist |
| 344 | 344 | function balise_FIN_SURLIGNE_dist($p) { |
| 345 | 345 | include_spip('inc/surligne'); |
| 346 | - $p->code = "'<!-- " . MARQUEUR_FSURLIGNE . "-->'"; |
|
| 346 | + $p->code = "'<!-- ".MARQUEUR_FSURLIGNE."-->'"; |
|
| 347 | 347 | return $p; |
| 348 | 348 | } |
| 349 | 349 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | // longueur en parametre, ou valeur par defaut |
| 370 | - if (($v = interprete_argument_balise(1,$p))!==NULL) { |
|
| 370 | + if (($v = interprete_argument_balise(1, $p)) !== NULL) { |
|
| 371 | 371 | $longueur = 'intval('.$v.')'; |
| 372 | 372 | } else { |
| 373 | 373 | switch ($type) { |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | // (celle du site ou celle qui a ete passee dans l'URL par le visiteur) |
| 399 | 399 | // #LANG* n'affiche rien si aucune langue n'est trouvee dans le sql/le contexte |
| 400 | 400 | // http://doc.spip.org/@balise_LANG_dist |
| 401 | -function balise_LANG_dist ($p) { |
|
| 401 | +function balise_LANG_dist($p) { |
|
| 402 | 402 | $_lang = champ_sql('lang', $p); |
| 403 | 403 | if (!$p->etoile) |
| 404 | 404 | $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | // http://www.spip.net/fr_article902.html |
| 414 | 414 | // http://www.spip.net/fr_article911.html |
| 415 | 415 | // http://doc.spip.org/@balise_LESAUTEURS_dist |
| 416 | -function balise_LESAUTEURS_dist ($p) { |
|
| 416 | +function balise_LESAUTEURS_dist($p) { |
|
| 417 | 417 | // Cherche le champ 'lesauteurs' dans la pile |
| 418 | 418 | $_lesauteurs = champ_sql('lesauteurs', $p, false); |
| 419 | 419 | |
@@ -426,12 +426,12 @@ discard block |
||
| 426 | 426 | $p->code = "safehtml($_lesauteurs)"; |
| 427 | 427 | // $p->interdire_scripts = true; |
| 428 | 428 | } else { |
| 429 | - if(!$p->id_boucle){ |
|
| 429 | + if (!$p->id_boucle) { |
|
| 430 | 430 | $connect = ''; |
| 431 | 431 | $objet = 'article'; |
| 432 | 432 | $id_table_objet = 'id_article'; |
| 433 | 433 | } |
| 434 | - else{ |
|
| 434 | + else { |
|
| 435 | 435 | $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
| 436 | 436 | $connect = $p->boucles[$b]->sql_serveur; |
| 437 | 437 | $type_boucle = $p->boucles[$b]->type_requete; |
@@ -442,9 +442,9 @@ discard block |
||
| 442 | 442 | |
| 443 | 443 | $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'", |
| 444 | 444 | "array('objet'=>'".$objet. |
| 445 | - "','id_objet' => ".champ_sql($id_table_objet, $p) . |
|
| 446 | - ",'$id_table_objet' => ".champ_sql($id_table_objet, $p) . |
|
| 447 | - ($objet=='article'?"":",'id_article' => ".champ_sql('id_article', $p)). |
|
| 445 | + "','id_objet' => ".champ_sql($id_table_objet, $p). |
|
| 446 | + ",'$id_table_objet' => ".champ_sql($id_table_objet, $p). |
|
| 447 | + ($objet == 'article' ? "" : ",'id_article' => ".champ_sql('id_article', $p)). |
|
| 448 | 448 | ")", |
| 449 | 449 | "'trim'=>true, 'compil'=>array($c)", |
| 450 | 450 | _q($connect)); |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | $m = trim($m); |
| 505 | 505 | if ($m != "''") { |
| 506 | 506 | if (!preg_match(",\W,", $m)) { |
| 507 | - $m = $boucle->id_table . ".$m"; |
|
| 507 | + $m = $boucle->id_table.".$m"; |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | $m .= " AS titre_rang"; |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | // #POPULARITE |
| 535 | 535 | // http://www.spip.net/fr_article1846.html |
| 536 | 536 | // http://doc.spip.org/@balise_POPULARITE_dist |
| 537 | -function balise_POPULARITE_dist ($p) { |
|
| 537 | +function balise_POPULARITE_dist($p) { |
|
| 538 | 538 | $_popularite = champ_sql('popularite', $p); |
| 539 | 539 | $p->code = "(ceil(min(100, 100 * $_popularite |
| 540 | 540 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))"; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | |
| 556 | 556 | // http://www.spip.net/fr_article3367.html |
| 557 | 557 | // http://doc.spip.org/@balise_PAGINATION_dist |
| 558 | -function balise_PAGINATION_dist($p, $liste='true') { |
|
| 558 | +function balise_PAGINATION_dist($p, $liste = 'true') { |
|
| 559 | 559 | $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
| 560 | 560 | |
| 561 | 561 | // s'il n'y a pas de nom de boucle, on ne peut pas paginer |
@@ -583,16 +583,16 @@ discard block |
||
| 583 | 583 | // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise |
| 584 | 584 | // si true, les arguments simples (sans truc=chose) vont degager |
| 585 | 585 | $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false); |
| 586 | - if (count($_contexte)){ |
|
| 587 | - list($key,$val) = each($_contexte); |
|
| 588 | - if (is_numeric($key)){ |
|
| 586 | + if (count($_contexte)) { |
|
| 587 | + list($key, $val) = each($_contexte); |
|
| 588 | + if (is_numeric($key)) { |
|
| 589 | 589 | array_shift($_contexte); |
| 590 | - $__modele = interprete_argument_balise(1,$p); |
|
| 590 | + $__modele = interprete_argument_balise(1, $p); |
|
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - if (count($_contexte)){ |
|
| 595 | - $code_contexte = implode(',',$_contexte); |
|
| 594 | + if (count($_contexte)) { |
|
| 595 | + $code_contexte = implode(',', $_contexte); |
|
| 596 | 596 | } |
| 597 | 597 | else |
| 598 | 598 | $code_contexte = ''; |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | $pas = $p->boucles[$b]->total_parties; |
| 602 | 602 | $f_pagination = chercher_filtre('pagination'); |
| 603 | 603 | $type = $p->boucles[$b]->modificateur['debut_nom']; |
| 604 | - $modif = ($type[0]!=="'") ? "'debut'.$type" |
|
| 605 | - : ("'debut" .substr($type,1)); |
|
| 604 | + $modif = ($type[0] !== "'") ? "'debut'.$type" |
|
| 605 | + : ("'debut".substr($type, 1)); |
|
| 606 | 606 | |
| 607 | 607 | $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste, ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte); |
| 608 | 608 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | // http://doc.spip.org/@balise_ANCRE_PAGINATION_dist |
| 618 | 618 | function balise_ANCRE_PAGINATION_dist($p) { |
| 619 | 619 | if ($f = charger_fonction('PAGINATION', 'balise', true)) |
| 620 | - return $f($p, $liste='false'); |
|
| 620 | + return $f($p, $liste = 'false'); |
|
| 621 | 621 | else return NULL; // ou une erreur ? |
| 622 | 622 | } |
| 623 | 623 | |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
| 629 | 629 | if ($b === '' || !isset($p->boucles[$b])) { |
| 630 | 630 | $msg = array('zbug_champ_hors_boucle', |
| 631 | - array('champ' => "#$b" . 'TOTAL_BOUCLE') |
|
| 631 | + array('champ' => "#$b".'TOTAL_BOUCLE') |
|
| 632 | 632 | ); |
| 633 | 633 | erreur_squelette($msg, $p); |
| 634 | 634 | } else { |
@@ -657,23 +657,23 @@ discard block |
||
| 657 | 657 | // |
| 658 | 658 | // http://doc.spip.org/@balise_CHEMIN_dist |
| 659 | 659 | function balise_CHEMIN_dist($p) { |
| 660 | - $arg = interprete_argument_balise(1,$p); |
|
| 660 | + $arg = interprete_argument_balise(1, $p); |
|
| 661 | 661 | if (!$arg) { |
| 662 | - $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
|
| 662 | + $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
|
| 663 | 663 | erreur_squelette($msg, $p); |
| 664 | 664 | } else |
| 665 | - $p->code = 'find_in_path(' . $arg .')'; |
|
| 665 | + $p->code = 'find_in_path('.$arg.')'; |
|
| 666 | 666 | |
| 667 | 667 | #$p->interdire_scripts = true; |
| 668 | 668 | return $p; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | function balise_CHEMIN_IMAGE_dist($p) { |
| 672 | - $arg = interprete_argument_balise(1,$p); |
|
| 672 | + $arg = interprete_argument_balise(1, $p); |
|
| 673 | 673 | if (!$arg) { |
| 674 | 674 | $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); |
| 675 | 675 | erreur_squelette($msg, $p); |
| 676 | - } else $p->code = 'chemin_image(' . $arg .')'; |
|
| 676 | + } else $p->code = 'chemin_image('.$arg.')'; |
|
| 677 | 677 | |
| 678 | 678 | #$p->interdire_scripts = true; |
| 679 | 679 | return $p; |
@@ -719,9 +719,9 @@ discard block |
||
| 719 | 719 | function balise_ENV_dist($p, $src = NULL) { |
| 720 | 720 | |
| 721 | 721 | // cle du tableau desiree |
| 722 | - $_nom = interprete_argument_balise(1,$p); |
|
| 722 | + $_nom = interprete_argument_balise(1, $p); |
|
| 723 | 723 | // valeur par defaut |
| 724 | - $_sinon = interprete_argument_balise(2,$p); |
|
| 724 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 725 | 725 | |
| 726 | 726 | // $src est un tableau de donnees sources eventuellement transmis |
| 727 | 727 | // en absence, on utilise l'environnement du squelette $Pile[0] |
@@ -766,14 +766,14 @@ discard block |
||
| 766 | 766 | * @return Object |
| 767 | 767 | */ |
| 768 | 768 | function balise_CONFIG_dist($p) { |
| 769 | - if (!$arg = interprete_argument_balise(1,$p)) { |
|
| 769 | + if (!$arg = interprete_argument_balise(1, $p)) { |
|
| 770 | 770 | $arg = "''"; |
| 771 | 771 | } |
| 772 | - $_sinon = interprete_argument_balise(2,$p); |
|
| 773 | - $_unserialize = sinon(interprete_argument_balise(3,$p),"false"); |
|
| 772 | + $_sinon = interprete_argument_balise(2, $p); |
|
| 773 | + $_unserialize = sinon(interprete_argument_balise(3, $p), "false"); |
|
| 774 | 774 | |
| 775 | - $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . |
|
| 776 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')"; |
|
| 775 | + $p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','. |
|
| 776 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')"; |
|
| 777 | 777 | |
| 778 | 778 | return $p; |
| 779 | 779 | } |
@@ -809,8 +809,8 @@ discard block |
||
| 809 | 809 | // Ajoute x=y dans la session du visiteur |
| 810 | 810 | // http://doc.spip.org/@balise_SESSION_SET_dist |
| 811 | 811 | function balise_SESSION_SET_dist($p) { |
| 812 | - $_nom = interprete_argument_balise(1,$p); |
|
| 813 | - $_val = interprete_argument_balise(2,$p); |
|
| 812 | + $_nom = interprete_argument_balise(1, $p); |
|
| 813 | + $_val = interprete_argument_balise(2, $p); |
|
| 814 | 814 | if (!$_nom OR !$_val) { |
| 815 | 815 | $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); |
| 816 | 816 | erreur_squelette($err_b_s_a, $p); |
@@ -836,12 +836,12 @@ discard block |
||
| 836 | 836 | // #EVAL{'str_replace("r","z", "roger")'} (attention les "'" sont interdits) |
| 837 | 837 | // http://doc.spip.org/@balise_EVAL_dist |
| 838 | 838 | function balise_EVAL_dist($p) { |
| 839 | - $php = interprete_argument_balise(1,$p); |
|
| 839 | + $php = interprete_argument_balise(1, $p); |
|
| 840 | 840 | if ($php) { |
| 841 | 841 | # optimisation sur les #EVAL{une expression sans #BALISE} |
| 842 | 842 | # attention au commentaire "// x signes" qui precede |
| 843 | 843 | if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
| 844 | - $php,$r)) |
|
| 844 | + $php, $r)) |
|
| 845 | 845 | $p->code = /* $r[1]. */'('.$r[2].')'; |
| 846 | 846 | else |
| 847 | 847 | $p->code = "eval('return '.$php.';')"; |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | // (impossible via #NOTES qui est une balise calculee) |
| 861 | 861 | // ne permet pas de passer une expression pour x qui ne peut etre qu'un texte statique ! |
| 862 | 862 | // http://doc.spip.org/@balise_CHAMP_SQL_dist |
| 863 | -function balise_CHAMP_SQL_dist($p){ |
|
| 863 | +function balise_CHAMP_SQL_dist($p) { |
|
| 864 | 864 | |
| 865 | 865 | if ($p->param |
| 866 | 866 | AND isset($p->param[0][1][0]) |
@@ -877,8 +877,8 @@ discard block |
||
| 877 | 877 | // #VAL{x} renvoie 'x' (permet d'appliquer un filtre a une chaine) |
| 878 | 878 | // Attention #VAL{1,2} renvoie '1', indiquer #VAL{'1,2'} |
| 879 | 879 | // http://doc.spip.org/@balise_VAL_dist |
| 880 | -function balise_VAL_dist($p){ |
|
| 881 | - $p->code = interprete_argument_balise(1,$p); |
|
| 880 | +function balise_VAL_dist($p) { |
|
| 881 | + $p->code = interprete_argument_balise(1, $p); |
|
| 882 | 882 | if (!strlen($p->code)) |
| 883 | 883 | $p->code = "''"; |
| 884 | 884 | $p->interdire_scripts = false; |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | // |
| 895 | 895 | // http://doc.spip.org/@balise_REM_dist |
| 896 | 896 | function balise_REM_dist($p) { |
| 897 | - $p->code="''"; |
|
| 897 | + $p->code = "''"; |
|
| 898 | 898 | $p->interdire_scripts = false; |
| 899 | 899 | return $p; |
| 900 | 900 | } |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | if ($p->param) { |
| 945 | 945 | $args = array(); |
| 946 | 946 | foreach ($p->param as $i => $ignore) |
| 947 | - $args[] = interprete_argument_balise($i+1,$p); |
|
| 947 | + $args[] = interprete_argument_balise($i + 1, $p); |
|
| 948 | 948 | $p->code = "'<' . '" |
| 949 | 949 | .'?php header("X-Spip-Filtre: \'.' |
| 950 | 950 | .join('.\'|\'.', $args) |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | // (Incompatible avec les balises dynamiques) |
| 1062 | 1062 | // http://doc.spip.org/@balise_INCLUDE_dist |
| 1063 | 1063 | function balise_INCLUDE_dist($p) { |
| 1064 | - if(function_exists('balise_INCLURE')) |
|
| 1064 | + if (function_exists('balise_INCLURE')) |
|
| 1065 | 1065 | return balise_INCLURE($p); |
| 1066 | 1066 | else |
| 1067 | 1067 | return balise_INCLURE_dist($p); |
@@ -1103,21 +1103,21 @@ discard block |
||
| 1103 | 1103 | |
| 1104 | 1104 | $_options = array(); |
| 1105 | 1105 | if (isset($_contexte['ajax'])) { |
| 1106 | - $_options[] = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 1106 | + $_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 1107 | 1107 | unset($_contexte['ajax']); |
| 1108 | 1108 | } |
| 1109 | 1109 | if ($p->etoile) $_options[] = "'etoile'=>true"; |
| 1110 | - $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) .")"; |
|
| 1110 | + $_options[] = "'compil'=>array(".memoriser_contexte_compil($p).")"; |
|
| 1111 | 1111 | |
| 1112 | - $_l = 'array(' . join(",\n\t", $_contexte) .')'; |
|
| 1112 | + $_l = 'array('.join(",\n\t", $_contexte).')'; |
|
| 1113 | 1113 | if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)"; |
| 1114 | 1114 | |
| 1115 | - $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',',$_options),"''"); |
|
| 1115 | + $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "''"); |
|
| 1116 | 1116 | |
| 1117 | 1117 | } elseif (!isset($_contexte[1])) { |
| 1118 | 1118 | $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); |
| 1119 | 1119 | erreur_squelette($msg, $p); |
| 1120 | - } else $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 1120 | + } else $p->code = 'charge_scripts('.$_contexte[1].',false)'; |
|
| 1121 | 1121 | |
| 1122 | 1122 | $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
| 1123 | 1123 | return $p; |
@@ -1141,14 +1141,14 @@ discard block |
||
| 1141 | 1141 | unset($_contexte[1]); |
| 1142 | 1142 | |
| 1143 | 1143 | if (preg_match("/^\s*'[^']*'/s", $nom)) |
| 1144 | - $nom = "'modeles/" . substr($nom,1); |
|
| 1144 | + $nom = "'modeles/".substr($nom, 1); |
|
| 1145 | 1145 | else $nom = "'modeles/' . $nom"; |
| 1146 | 1146 | |
| 1147 | 1147 | // Incoherence dans la syntaxe du contexte. A revoir. |
| 1148 | 1148 | // Reserver la cle primaire de la boucle courante si elle existe |
| 1149 | 1149 | if (isset($p->boucles[$p->id_boucle]->primary)) { |
| 1150 | 1150 | $primary = $p->boucles[$p->id_boucle]->primary; |
| 1151 | - if (!strpos($primary,',')) { |
|
| 1151 | + if (!strpos($primary, ',')) { |
|
| 1152 | 1152 | $id = champ_sql($primary, $p); |
| 1153 | 1153 | $_contexte[] = "'$primary'=>".$id; |
| 1154 | 1154 | $_contexte[] = "'id'=>".$id; |
@@ -1161,12 +1161,12 @@ discard block |
||
| 1161 | 1161 | |
| 1162 | 1162 | $_options = memoriser_contexte_compil($p); |
| 1163 | 1163 | $_options = "'compil'=>array($_options), 'trim'=>true"; |
| 1164 | - if (isset($_contexte['ajax'])){ |
|
| 1165 | - $_options .= ", ".preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 1164 | + if (isset($_contexte['ajax'])) { |
|
| 1165 | + $_options .= ", ".preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 1166 | 1166 | unset($_contexte['ajax']); |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, 'array(' . join(',', $_contexte) .')', $_options, _q($connect)); |
|
| 1169 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, 'array('.join(',', $_contexte).')', $_options, _q($connect)); |
|
| 1170 | 1170 | |
| 1171 | 1171 | $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n"; |
| 1172 | 1172 | |
@@ -1182,9 +1182,9 @@ discard block |
||
| 1182 | 1182 | // #SET{nom,valeur} |
| 1183 | 1183 | // la balise renvoie la valeur |
| 1184 | 1184 | // http://doc.spip.org/@balise_SET_dist |
| 1185 | -function balise_SET_dist($p){ |
|
| 1186 | - $_nom = interprete_argument_balise(1,$p); |
|
| 1187 | - $_val = interprete_argument_balise(2,$p); |
|
| 1185 | +function balise_SET_dist($p) { |
|
| 1186 | + $_nom = interprete_argument_balise(1, $p); |
|
| 1187 | + $_val = interprete_argument_balise(2, $p); |
|
| 1188 | 1188 | |
| 1189 | 1189 | if (!$_nom OR !$_val) { |
| 1190 | 1190 | $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); |
@@ -1229,13 +1229,13 @@ discard block |
||
| 1229 | 1229 | * Pile complétée par le code à générer |
| 1230 | 1230 | **/ |
| 1231 | 1231 | function balise_DOUBLONS_dist($p) { |
| 1232 | - if ($type = interprete_argument_balise(1,$p)) { |
|
| 1233 | - if ($famille = interprete_argument_balise(2,$p)) |
|
| 1234 | - $type .= '.' . $famille; |
|
| 1232 | + if ($type = interprete_argument_balise(1, $p)) { |
|
| 1233 | + if ($famille = interprete_argument_balise(2, $p)) |
|
| 1234 | + $type .= '.'.$famille; |
|
| 1235 | 1235 | $p->code = '$doublons['.$type.']'; |
| 1236 | 1236 | if (!$p->etoile) |
| 1237 | 1237 | $p->code = 'array_filter(array_map("intval",explode(",",' |
| 1238 | - . $p->code . ')))'; |
|
| 1238 | + . $p->code.')))'; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | else |
| 1241 | 1241 | $p->code = '$doublons'; |
@@ -1254,13 +1254,13 @@ discard block |
||
| 1254 | 1254 | // |
| 1255 | 1255 | // http://doc.spip.org/@balise_PIPELINE_dist |
| 1256 | 1256 | function balise_PIPELINE_dist($p) { |
| 1257 | - $_pipe = interprete_argument_balise(1,$p); |
|
| 1257 | + $_pipe = interprete_argument_balise(1, $p); |
|
| 1258 | 1258 | if (!$_pipe) { |
| 1259 | 1259 | $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); |
| 1260 | 1260 | erreur_squelette($err_b_s_a, $p); |
| 1261 | 1261 | } else { |
| 1262 | - $_flux = interprete_argument_balise(2,$p); |
|
| 1263 | - $_flux = $_flux?$_flux:"''"; |
|
| 1262 | + $_flux = interprete_argument_balise(2, $p); |
|
| 1263 | + $_flux = $_flux ? $_flux : "''"; |
|
| 1264 | 1264 | $p->code = "pipeline( $_pipe , $_flux )"; |
| 1265 | 1265 | $p->interdire_scripts = false; |
| 1266 | 1266 | } |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | // |
| 1290 | 1290 | // http://doc.spip.org/@balise_TOTAL_UNIQUE_dist |
| 1291 | 1291 | function balise_TOTAL_UNIQUE_dist($p) { |
| 1292 | - $_famille = interprete_argument_balise(1,$p); |
|
| 1292 | + $_famille = interprete_argument_balise(1, $p); |
|
| 1293 | 1293 | $_famille = $_famille ? $_famille : "''"; |
| 1294 | 1294 | $p->code = "unique('', $_famille, true)"; |
| 1295 | 1295 | return $p; |
@@ -1303,13 +1303,13 @@ discard block |
||
| 1303 | 1303 | // http://doc.spip.org/@balise_ARRAY_dist |
| 1304 | 1304 | function balise_ARRAY_dist($p) { |
| 1305 | 1305 | $_code = array(); |
| 1306 | - $n=1; |
|
| 1306 | + $n = 1; |
|
| 1307 | 1307 | do { |
| 1308 | - $_key = interprete_argument_balise($n++,$p); |
|
| 1309 | - $_val = interprete_argument_balise($n++,$p); |
|
| 1308 | + $_key = interprete_argument_balise($n++, $p); |
|
| 1309 | + $_val = interprete_argument_balise($n++, $p); |
|
| 1310 | 1310 | if ($_key AND $_val) $_code[] = "$_key => $_val"; |
| 1311 | 1311 | } while ($_key && $_val); |
| 1312 | - $p->code = 'array(' . join(', ',$_code).')'; |
|
| 1312 | + $p->code = 'array('.join(', ', $_code).')'; |
|
| 1313 | 1313 | $p->interdire_scripts = false; |
| 1314 | 1314 | return $p; |
| 1315 | 1315 | } |
@@ -1322,10 +1322,10 @@ discard block |
||
| 1322 | 1322 | */ |
| 1323 | 1323 | function balise_LISTE_dist($p) { |
| 1324 | 1324 | $_code = array(); |
| 1325 | - $n=1; |
|
| 1326 | - while ($_val = interprete_argument_balise($n++,$p)) |
|
| 1325 | + $n = 1; |
|
| 1326 | + while ($_val = interprete_argument_balise($n++, $p)) |
|
| 1327 | 1327 | $_code[] = $_val; |
| 1328 | - $p->code = 'array(' . join(', ',$_code).')'; |
|
| 1328 | + $p->code = 'array('.join(', ', $_code).')'; |
|
| 1329 | 1329 | $p->interdire_scripts = false; |
| 1330 | 1330 | return $p; |
| 1331 | 1331 | } |
@@ -1338,11 +1338,11 @@ discard block |
||
| 1338 | 1338 | $_code = array(); |
| 1339 | 1339 | $p->descr['session'] = true; // faire un cache par session |
| 1340 | 1340 | |
| 1341 | - $n=1; |
|
| 1342 | - while ($_v = interprete_argument_balise($n++,$p)) |
|
| 1341 | + $n = 1; |
|
| 1342 | + while ($_v = interprete_argument_balise($n++, $p)) |
|
| 1343 | 1343 | $_code[] = $_v; |
| 1344 | 1344 | |
| 1345 | - $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',$_code).')?" ":"")'; |
|
| 1345 | + $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join(', ', $_code).')?" ":"")'; |
|
| 1346 | 1346 | $p->interdire_scripts = false; |
| 1347 | 1347 | return $p; |
| 1348 | 1348 | } |
@@ -1351,9 +1351,9 @@ discard block |
||
| 1351 | 1351 | // Afficher des informations sur les plugins dans le site public |
| 1352 | 1352 | // http://doc.spip.org/@balise_PLUGIN_dist |
| 1353 | 1353 | function balise_PLUGIN_dist($p) { |
| 1354 | - $plugin = interprete_argument_balise(1,$p); |
|
| 1354 | + $plugin = interprete_argument_balise(1, $p); |
|
| 1355 | 1355 | $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; |
| 1356 | - $type_info = interprete_argument_balise(2,$p); |
|
| 1356 | + $type_info = interprete_argument_balise(2, $p); |
|
| 1357 | 1357 | $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; |
| 1358 | 1358 | |
| 1359 | 1359 | $f = chercher_filtre('info_plugin'); |
@@ -1364,9 +1364,9 @@ discard block |
||
| 1364 | 1364 | // Appelle la fonction inc_aider_dist |
| 1365 | 1365 | // http://doc.spip.org/@balise_AIDER_dist |
| 1366 | 1366 | function balise_AIDER_dist($p) { |
| 1367 | - $_motif = interprete_argument_balise(1,$p); |
|
| 1368 | - $s = "'" . addslashes($p->descr['sourcefile']) . "'"; |
|
| 1369 | - $aider = charger_fonction('aider','inc'); |
|
| 1367 | + $_motif = interprete_argument_balise(1, $p); |
|
| 1368 | + $s = "'".addslashes($p->descr['sourcefile'])."'"; |
|
| 1369 | + $aider = charger_fonction('aider', 'inc'); |
|
| 1370 | 1370 | $p->code = "((\$aider=charger_fonction('aider','inc'))?\$aider($_motif,$s, \$Pile[0]):'')"; |
| 1371 | 1371 | return $p; |
| 1372 | 1372 | } |
@@ -1374,10 +1374,10 @@ discard block |
||
| 1374 | 1374 | // Insertion du contexte des formulaires charger/verifier/traiter |
| 1375 | 1375 | // avec les hidden de l'url d'action |
| 1376 | 1376 | // http://doc.spip.org/@balise_ACTION_FORMULAIRE |
| 1377 | -function balise_ACTION_FORMULAIRE($p){ |
|
| 1378 | - if (!$_url = interprete_argument_balise(1,$p)) |
|
| 1377 | +function balise_ACTION_FORMULAIRE($p) { |
|
| 1378 | + if (!$_url = interprete_argument_balise(1, $p)) |
|
| 1379 | 1379 | $_url = "@\$Pile[0]['action']"; |
| 1380 | - if (!$_form = interprete_argument_balise(2,$p)) |
|
| 1380 | + if (!$_form = interprete_argument_balise(2, $p)) |
|
| 1381 | 1381 | $_form = "@\$Pile[0]['form']"; |
| 1382 | 1382 | |
| 1383 | 1383 | // envoyer le nom du formulaire que l'on traite |
@@ -1410,18 +1410,18 @@ discard block |
||
| 1410 | 1410 | * @param unknown_type $p |
| 1411 | 1411 | * @return unknown |
| 1412 | 1412 | */ |
| 1413 | -function balise_BOUTON_ACTION_dist($p){ |
|
| 1413 | +function balise_BOUTON_ACTION_dist($p) { |
|
| 1414 | 1414 | |
| 1415 | 1415 | $args = array(); |
| 1416 | - for ($k=1;$k<=6;$k++){ |
|
| 1417 | - $_a = interprete_argument_balise($k,$p); |
|
| 1418 | - if (!$_a) $_a="''"; |
|
| 1416 | + for ($k = 1; $k <= 6; $k++) { |
|
| 1417 | + $_a = interprete_argument_balise($k, $p); |
|
| 1418 | + if (!$_a) $_a = "''"; |
|
| 1419 | 1419 | $args[] = $_a; |
| 1420 | 1420 | } |
| 1421 | 1421 | // supprimer les args vides |
| 1422 | - while(end($args)=="''" AND count($args)>2) |
|
| 1422 | + while (end($args) == "''" AND count($args) > 2) |
|
| 1423 | 1423 | array_pop($args); |
| 1424 | - $args = implode(",",$args); |
|
| 1424 | + $args = implode(",", $args); |
|
| 1425 | 1425 | |
| 1426 | 1426 | $bouton_action = chercher_filtre("bouton_action"); |
| 1427 | 1427 | $p->code = "$bouton_action($args)"; |
@@ -1458,7 +1458,7 @@ discard block |
||
| 1458 | 1458 | * @param unknown_type $liste |
| 1459 | 1459 | * @return unknown |
| 1460 | 1460 | */ |
| 1461 | -function balise_TRI_dist($p, $liste='true') { |
|
| 1461 | +function balise_TRI_dist($p, $liste = 'true') { |
|
| 1462 | 1462 | $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere']; |
| 1463 | 1463 | |
| 1464 | 1464 | // s'il n'y a pas de nom de boucle, on ne peut pas trier |
@@ -1483,21 +1483,21 @@ discard block |
||
| 1483 | 1483 | return $p; |
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | - $_champ = interprete_argument_balise(1,$p); |
|
| 1486 | + $_champ = interprete_argument_balise(1, $p); |
|
| 1487 | 1487 | // si pas de champ, renvoyer le critere de tri utilise |
| 1488 | - if (!$_champ){ |
|
| 1488 | + if (!$_champ) { |
|
| 1489 | 1489 | $p->code = $boucle->modificateur['tri_champ']; |
| 1490 | 1490 | return $p; |
| 1491 | 1491 | } |
| 1492 | 1492 | // forcer la jointure si besoin, et si le champ est statique |
| 1493 | - if (preg_match(",^'([\w.]+)'$,i",$_champ,$m)){ |
|
| 1493 | + if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { |
|
| 1494 | 1494 | index_pile($b, $m[1], $p->boucles); |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | - $_libelle = interprete_argument_balise(2,$p); |
|
| 1498 | - $_libelle = $_libelle?$_libelle:$_champ; |
|
| 1497 | + $_libelle = interprete_argument_balise(2, $p); |
|
| 1498 | + $_libelle = $_libelle ? $_libelle : $_champ; |
|
| 1499 | 1499 | |
| 1500 | - $_class = interprete_argument_balise(3,$p); |
|
| 1500 | + $_class = interprete_argument_balise(3, $p); |
|
| 1501 | 1501 | // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1 |
| 1502 | 1502 | // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1 |
| 1503 | 1503 | $_issens = "in_array($_champ,array('>','<'))"; |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)"; |
| 1508 | 1508 | $_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)"; |
| 1509 | 1509 | |
| 1510 | - $p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class?",$_class":"").")"; |
|
| 1510 | + $p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class ? ",$_class" : "").")"; |
|
| 1511 | 1511 | //$p->code = "''"; |
| 1512 | 1512 | $p->interdire_scripts = false; |
| 1513 | 1513 | return $p; |
@@ -1525,7 +1525,7 @@ discard block |
||
| 1525 | 1525 | * @param <type> $p |
| 1526 | 1526 | * @return <type> |
| 1527 | 1527 | */ |
| 1528 | -function balise_SAUTER_dist($p){ |
|
| 1528 | +function balise_SAUTER_dist($p) { |
|
| 1529 | 1529 | $id_boucle = $p->id_boucle; |
| 1530 | 1530 | $boucle = $p->boucles[$id_boucle]; |
| 1531 | 1531 | |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | erreur_squelette($msg, $p); |
| 1535 | 1535 | } |
| 1536 | 1536 | else { |
| 1537 | - $_saut = interprete_argument_balise(1,$p); |
|
| 1537 | + $_saut = interprete_argument_balise(1, $p); |
|
| 1538 | 1538 | $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
| 1539 | 1539 | $_total = "\$Numrows['$id_boucle']['total']"; |
| 1540 | 1540 | |
@@ -1552,12 +1552,12 @@ discard block |
||
| 1552 | 1552 | * @return <type> |
| 1553 | 1553 | */ |
| 1554 | 1554 | function balise_PUBLIE_dist($p) { |
| 1555 | - if (!$_type = interprete_argument_balise(1,$p)){ |
|
| 1555 | + if (!$_type = interprete_argument_balise(1, $p)) { |
|
| 1556 | 1556 | $_type = _q($p->type_requete); |
| 1557 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary,$p); |
|
| 1557 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | else |
| 1560 | - $_id = interprete_argument_balise(2,$p); |
|
| 1560 | + $_id = interprete_argument_balise(2, $p); |
|
| 1561 | 1561 | |
| 1562 | 1562 | $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
| 1563 | 1563 | |
@@ -1581,11 +1581,11 @@ discard block |
||
| 1581 | 1581 | * @param object $p |
| 1582 | 1582 | * @return object |
| 1583 | 1583 | */ |
| 1584 | -function balise_PRODUIRE_dist($p){ |
|
| 1585 | - $balise_inclure = charger_fonction('INCLURE','balise'); |
|
| 1584 | +function balise_PRODUIRE_dist($p) { |
|
| 1585 | + $balise_inclure = charger_fonction('INCLURE', 'balise'); |
|
| 1586 | 1586 | $p = $balise_inclure($p); |
| 1587 | 1587 | |
| 1588 | - $p->code = str_replace('recuperer_fond(','produire_fond_statique(',$p->code); |
|
| 1588 | + $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); |
|
| 1589 | 1589 | |
| 1590 | 1590 | return $p; |
| 1591 | 1591 | } |
@@ -1597,9 +1597,9 @@ discard block |
||
| 1597 | 1597 | * @param $p |
| 1598 | 1598 | * @return |
| 1599 | 1599 | */ |
| 1600 | -function balise_LARGEUR_ECRAN_dist($p){ |
|
| 1601 | - $_class = interprete_argument_balise(1,$p); |
|
| 1602 | - if (!$_class) $_class='null'; |
|
| 1600 | +function balise_LARGEUR_ECRAN_dist($p) { |
|
| 1601 | + $_class = interprete_argument_balise(1, $p); |
|
| 1602 | + if (!$_class) $_class = 'null'; |
|
| 1603 | 1603 | $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
| 1604 | 1604 | return $p; |
| 1605 | 1605 | } |
@@ -17,18 +17,21 @@ discard block |
||
| 17 | 17 | // elle recoit en entree un objet de classe CHAMP, le modifie et le retourne. |
| 18 | 18 | // Cette classe est definie dans public/interfaces |
| 19 | 19 | |
| 20 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 20 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 21 | + return; |
|
| 22 | +} |
|
| 21 | 23 | |
| 22 | 24 | // http://doc.spip.org/@interprete_argument_balise |
| 23 | 25 | function interprete_argument_balise($n,$p) { |
| 24 | - if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n)) |
|
| 25 | - return calculer_liste($p->param[0][$n], |
|
| 26 | + if (($p->param) && (!$p->param[0][0]) && (count($p->param[0])>$n)) { |
|
| 27 | + return calculer_liste($p->param[0][$n], |
|
| 26 | 28 | $p->descr, |
| 27 | 29 | $p->boucles, |
| 28 | 30 | $p->id_boucle); |
| 29 | - else |
|
| 30 | - return NULL; |
|
| 31 | -} |
|
| 31 | + } else { |
|
| 32 | + return NULL; |
|
| 33 | + } |
|
| 34 | + } |
|
| 32 | 35 | // |
| 33 | 36 | // Definition des balises |
| 34 | 37 | // |
@@ -187,8 +190,9 @@ discard block |
||
| 187 | 190 | champ_sql('url_site',$p) ."," . |
| 188 | 191 | champ_sql('nom_site',$p) . |
| 189 | 192 | ", 'titre', \$connect, false))"; |
| 190 | - } else |
|
| 191 | - $p->code = champ_sql('nom_site',$p); |
|
| 193 | + } else { |
|
| 194 | + $p->code = champ_sql('nom_site',$p); |
|
| 195 | + } |
|
| 192 | 196 | |
| 193 | 197 | $p->interdire_scripts = true; |
| 194 | 198 | return $p; |
@@ -276,8 +280,9 @@ discard block |
||
| 276 | 280 | $off= "''"; |
| 277 | 281 | if (($v = interprete_argument_balise(1,$p))!==NULL){ |
| 278 | 282 | $on = $v; |
| 279 | - if (($v = interprete_argument_balise(2,$p))!==NULL) |
|
| 280 | - $off = $v; |
|
| 283 | + if (($v = interprete_argument_balise(2,$p))!==NULL) { |
|
| 284 | + $off = $v; |
|
| 285 | + } |
|
| 281 | 286 | |
| 282 | 287 | } |
| 283 | 288 | return calculer_balise_expose($p, $on, $off); |
@@ -320,7 +325,9 @@ discard block |
||
| 320 | 325 | $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b); |
| 321 | 326 | } elseif (isset($desc['field']['id_groupe'])) { |
| 322 | 327 | $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b); |
| 323 | - } else $parent = "''"; |
|
| 328 | + } else { |
|
| 329 | + $parent = "''"; |
|
| 330 | + } |
|
| 324 | 331 | |
| 325 | 332 | $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)"; |
| 326 | 333 | |
@@ -400,10 +407,11 @@ discard block |
||
| 400 | 407 | // http://doc.spip.org/@balise_LANG_dist |
| 401 | 408 | function balise_LANG_dist ($p) { |
| 402 | 409 | $_lang = champ_sql('lang', $p); |
| 403 | - if (!$p->etoile) |
|
| 404 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 405 | - else |
|
| 406 | - $p->code = "spip_htmlentities($_lang)"; |
|
| 410 | + if (!$p->etoile) { |
|
| 411 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])"; |
|
| 412 | + } else { |
|
| 413 | + $p->code = "spip_htmlentities($_lang)"; |
|
| 414 | + } |
|
| 407 | 415 | $p->interdire_scripts = false; |
| 408 | 416 | return $p; |
| 409 | 417 | } |
@@ -430,8 +438,7 @@ discard block |
||
| 430 | 438 | $connect = ''; |
| 431 | 439 | $objet = 'article'; |
| 432 | 440 | $id_table_objet = 'id_article'; |
| 433 | - } |
|
| 434 | - else{ |
|
| 441 | + } else{ |
|
| 435 | 442 | $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle; |
| 436 | 443 | $connect = $p->boucles[$b]->sql_serveur; |
| 437 | 444 | $type_boucle = $p->boucles[$b]->type_requete; |
@@ -593,9 +600,9 @@ discard block |
||
| 593 | 600 | |
| 594 | 601 | if (count($_contexte)){ |
| 595 | 602 | $code_contexte = implode(',',$_contexte); |
| 603 | + } else { |
|
| 604 | + $code_contexte = ''; |
|
| 596 | 605 | } |
| 597 | - else |
|
| 598 | - $code_contexte = ''; |
|
| 599 | 606 | |
| 600 | 607 | $connect = $p->boucles[$b]->sql_serveur; |
| 601 | 608 | $pas = $p->boucles[$b]->total_parties; |
@@ -616,9 +623,12 @@ discard block |
||
| 616 | 623 | // qu'on mettra les liens en-dessous de la liste paginee) |
| 617 | 624 | // http://doc.spip.org/@balise_ANCRE_PAGINATION_dist |
| 618 | 625 | function balise_ANCRE_PAGINATION_dist($p) { |
| 619 | - if ($f = charger_fonction('PAGINATION', 'balise', true)) |
|
| 620 | - return $f($p, $liste='false'); |
|
| 621 | - else return NULL; // ou une erreur ? |
|
| 626 | + if ($f = charger_fonction('PAGINATION', 'balise', true)) { |
|
| 627 | + return $f($p, $liste='false'); |
|
| 628 | + } else { |
|
| 629 | + return NULL; |
|
| 630 | + } |
|
| 631 | + // ou une erreur ? |
|
| 622 | 632 | } |
| 623 | 633 | |
| 624 | 634 | // equivalent a #TOTAL_BOUCLE sauf pour les boucles paginees, ou elle |
@@ -661,8 +671,9 @@ discard block |
||
| 661 | 671 | if (!$arg) { |
| 662 | 672 | $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); |
| 663 | 673 | erreur_squelette($msg, $p); |
| 664 | - } else |
|
| 665 | - $p->code = 'find_in_path(' . $arg .')'; |
|
| 674 | + } else { |
|
| 675 | + $p->code = 'find_in_path(' . $arg .')'; |
|
| 676 | + } |
|
| 666 | 677 | |
| 667 | 678 | #$p->interdire_scripts = true; |
| 668 | 679 | return $p; |
@@ -673,7 +684,9 @@ discard block |
||
| 673 | 684 | if (!$arg) { |
| 674 | 685 | $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); |
| 675 | 686 | erreur_squelette($msg, $p); |
| 676 | - } else $p->code = 'chemin_image(' . $arg .')'; |
|
| 687 | + } else { |
|
| 688 | + $p->code = 'chemin_image(' . $arg .')'; |
|
| 689 | + } |
|
| 677 | 690 | |
| 678 | 691 | #$p->interdire_scripts = true; |
| 679 | 692 | return $p; |
@@ -814,7 +827,9 @@ discard block |
||
| 814 | 827 | if (!$_nom OR !$_val) { |
| 815 | 828 | $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); |
| 816 | 829 | erreur_squelette($err_b_s_a, $p); |
| 817 | - } else $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; |
|
| 830 | + } else { |
|
| 831 | + $p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; |
|
| 832 | + } |
|
| 818 | 833 | |
| 819 | 834 | $p->interdire_scripts = false; |
| 820 | 835 | |
@@ -841,10 +856,11 @@ discard block |
||
| 841 | 856 | # optimisation sur les #EVAL{une expression sans #BALISE} |
| 842 | 857 | # attention au commentaire "// x signes" qui precede |
| 843 | 858 | if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", |
| 844 | - $php,$r)) |
|
| 845 | - $p->code = /* $r[1]. */'('.$r[2].')'; |
|
| 846 | - else |
|
| 847 | - $p->code = "eval('return '.$php.';')"; |
|
| 859 | + $php,$r)) { |
|
| 860 | + $p->code = /* $r[1]. */'('.$r[2].')'; |
|
| 861 | + } else { |
|
| 862 | + $p->code = "eval('return '.$php.';')"; |
|
| 863 | + } |
|
| 848 | 864 | } else { |
| 849 | 865 | $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); |
| 850 | 866 | erreur_squelette($msg, $p); |
@@ -864,9 +880,9 @@ discard block |
||
| 864 | 880 | |
| 865 | 881 | if ($p->param |
| 866 | 882 | AND isset($p->param[0][1][0]) |
| 867 | - AND $champ = ($p->param[0][1][0]->texte)) |
|
| 868 | - $p->code = champ_sql($champ, $p); |
|
| 869 | - else { |
|
| 883 | + AND $champ = ($p->param[0][1][0]->texte)) { |
|
| 884 | + $p->code = champ_sql($champ, $p); |
|
| 885 | + } else { |
|
| 870 | 886 | $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); |
| 871 | 887 | erreur_squelette($err_b_s_a, $p); |
| 872 | 888 | } |
@@ -879,8 +895,9 @@ discard block |
||
| 879 | 895 | // http://doc.spip.org/@balise_VAL_dist |
| 880 | 896 | function balise_VAL_dist($p){ |
| 881 | 897 | $p->code = interprete_argument_balise(1,$p); |
| 882 | - if (!strlen($p->code)) |
|
| 883 | - $p->code = "''"; |
|
| 898 | + if (!strlen($p->code)) { |
|
| 899 | + $p->code = "''"; |
|
| 900 | + } |
|
| 884 | 901 | $p->interdire_scripts = false; |
| 885 | 902 | return $p; |
| 886 | 903 | } |
@@ -943,8 +960,9 @@ discard block |
||
| 943 | 960 | function balise_FILTRE_dist($p) { |
| 944 | 961 | if ($p->param) { |
| 945 | 962 | $args = array(); |
| 946 | - foreach ($p->param as $i => $ignore) |
|
| 947 | - $args[] = interprete_argument_balise($i+1,$p); |
|
| 963 | + foreach ($p->param as $i => $ignore) { |
|
| 964 | + $args[] = interprete_argument_balise($i+1,$p); |
|
| 965 | + } |
|
| 948 | 966 | $p->code = "'<' . '" |
| 949 | 967 | .'?php header("X-Spip-Filtre: \'.' |
| 950 | 968 | .join('.\'|\'.', $args) |
@@ -979,12 +997,13 @@ discard block |
||
| 979 | 997 | |
| 980 | 998 | // Remplir le header Cache-Control |
| 981 | 999 | // cas #CACHE{0} |
| 982 | - if ($duree == 0) |
|
| 983 | - $code .= '.\'<' |
|
| 1000 | + if ($duree == 0) { |
|
| 1001 | + $code .= '.\'<' |
|
| 984 | 1002 | .'?php header("Cache-Control: no-cache, must-revalidate"); ?' |
| 985 | 1003 | .'><' |
| 986 | 1004 | .'?php header("Pragma: no-cache"); ?' |
| 987 | 1005 | .'>\''; |
| 1006 | + } |
|
| 988 | 1007 | |
| 989 | 1008 | // recuperer les parametres suivants |
| 990 | 1009 | $i = 1; |
@@ -1001,10 +1020,13 @@ discard block |
||
| 1001 | 1020 | } |
| 1002 | 1021 | |
| 1003 | 1022 | if ($pa == 'statique' |
| 1004 | - AND $duree > 0) |
|
| 1005 | - $code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\''; |
|
| 1023 | + AND $duree > 0) { |
|
| 1024 | + $code .= '.\'<'.'?php header("X-Spip-Statique: oui"); ?'.'>\''; |
|
| 1025 | + } |
|
| 1006 | 1026 | } |
| 1007 | - } else $code = "''"; |
|
| 1027 | + } else { |
|
| 1028 | + $code = "''"; |
|
| 1029 | + } |
|
| 1008 | 1030 | $p->code = $code; |
| 1009 | 1031 | $p->interdire_scripts = false; |
| 1010 | 1032 | return $p; |
@@ -1061,11 +1083,12 @@ discard block |
||
| 1061 | 1083 | // (Incompatible avec les balises dynamiques) |
| 1062 | 1084 | // http://doc.spip.org/@balise_INCLUDE_dist |
| 1063 | 1085 | function balise_INCLUDE_dist($p) { |
| 1064 | - if(function_exists('balise_INCLURE')) |
|
| 1065 | - return balise_INCLURE($p); |
|
| 1066 | - else |
|
| 1067 | - return balise_INCLURE_dist($p); |
|
| 1068 | -} |
|
| 1086 | + if(function_exists('balise_INCLURE')) { |
|
| 1087 | + return balise_INCLURE($p); |
|
| 1088 | + } else { |
|
| 1089 | + return balise_INCLURE_dist($p); |
|
| 1090 | + } |
|
| 1091 | + } |
|
| 1069 | 1092 | // http://doc.spip.org/@balise_INCLURE_dist |
| 1070 | 1093 | function balise_INCLURE_dist($p) { |
| 1071 | 1094 | $id_boucle = $p->id_boucle; |
@@ -1077,7 +1100,9 @@ discard block |
||
| 1077 | 1100 | |
| 1078 | 1101 | // erreur de syntaxe = fond absent |
| 1079 | 1102 | // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
| 1080 | - if (!$_contexte) $contexte = array(); |
|
| 1103 | + if (!$_contexte) { |
|
| 1104 | + $contexte = array(); |
|
| 1105 | + } |
|
| 1081 | 1106 | |
| 1082 | 1107 | if (isset($_contexte['fond'])) { |
| 1083 | 1108 | |
@@ -1086,7 +1111,9 @@ discard block |
||
| 1086 | 1111 | if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { |
| 1087 | 1112 | $f = $r[1]; |
| 1088 | 1113 | unset($_contexte['fond']); |
| 1089 | - } else spip_log("compilation de #INCLURE a revoir"); |
|
| 1114 | + } else { |
|
| 1115 | + spip_log("compilation de #INCLURE a revoir"); |
|
| 1116 | + } |
|
| 1090 | 1117 | |
| 1091 | 1118 | // #INCLURE{doublons} |
| 1092 | 1119 | if (isset($_contexte['doublons'])) { |
@@ -1099,25 +1126,33 @@ discard block |
||
| 1099 | 1126 | ) { |
| 1100 | 1127 | $flag_env = true; |
| 1101 | 1128 | unset($_contexte['env']); |
| 1102 | - } else $flag_env = false; |
|
| 1129 | + } else { |
|
| 1130 | + $flag_env = false; |
|
| 1131 | + } |
|
| 1103 | 1132 | |
| 1104 | 1133 | $_options = array(); |
| 1105 | 1134 | if (isset($_contexte['ajax'])) { |
| 1106 | 1135 | $_options[] = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
| 1107 | 1136 | unset($_contexte['ajax']); |
| 1108 | 1137 | } |
| 1109 | - if ($p->etoile) $_options[] = "'etoile'=>true"; |
|
| 1138 | + if ($p->etoile) { |
|
| 1139 | + $_options[] = "'etoile'=>true"; |
|
| 1140 | + } |
|
| 1110 | 1141 | $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) .")"; |
| 1111 | 1142 | |
| 1112 | 1143 | $_l = 'array(' . join(",\n\t", $_contexte) .')'; |
| 1113 | - if ($flag_env) $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 1144 | + if ($flag_env) { |
|
| 1145 | + $_l = "array_merge(\$Pile[0],$_l)"; |
|
| 1146 | + } |
|
| 1114 | 1147 | |
| 1115 | 1148 | $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',',$_options),"''"); |
| 1116 | 1149 | |
| 1117 | 1150 | } elseif (!isset($_contexte[1])) { |
| 1118 | 1151 | $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); |
| 1119 | 1152 | erreur_squelette($msg, $p); |
| 1120 | - } else $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 1153 | + } else { |
|
| 1154 | + $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; |
|
| 1155 | + } |
|
| 1121 | 1156 | |
| 1122 | 1157 | $p->interdire_scripts = false; // la securite est assuree par recuperer_fond |
| 1123 | 1158 | return $p; |
@@ -1131,7 +1166,9 @@ discard block |
||
| 1131 | 1166 | |
| 1132 | 1167 | // erreur de syntaxe = fond absent |
| 1133 | 1168 | // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP |
| 1134 | - if (!$_contexte) $contexte = array(); |
|
| 1169 | + if (!$_contexte) { |
|
| 1170 | + $contexte = array(); |
|
| 1171 | + } |
|
| 1135 | 1172 | |
| 1136 | 1173 | if (!isset($_contexte[1])) { |
| 1137 | 1174 | $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); |
@@ -1140,9 +1177,11 @@ discard block |
||
| 1140 | 1177 | $nom = $_contexte[1]; |
| 1141 | 1178 | unset($_contexte[1]); |
| 1142 | 1179 | |
| 1143 | - if (preg_match("/^\s*'[^']*'/s", $nom)) |
|
| 1144 | - $nom = "'modeles/" . substr($nom,1); |
|
| 1145 | - else $nom = "'modeles/' . $nom"; |
|
| 1180 | + if (preg_match("/^\s*'[^']*'/s", $nom)) { |
|
| 1181 | + $nom = "'modeles/" . substr($nom,1); |
|
| 1182 | + } else { |
|
| 1183 | + $nom = "'modeles/' . $nom"; |
|
| 1184 | + } |
|
| 1146 | 1185 | |
| 1147 | 1186 | // Incoherence dans la syntaxe du contexte. A revoir. |
| 1148 | 1187 | // Reserver la cle primaire de la boucle courante si elle existe |
@@ -1156,8 +1195,9 @@ discard block |
||
| 1156 | 1195 | } |
| 1157 | 1196 | $_contexte[] = "'recurs'=>(++\$recurs)"; |
| 1158 | 1197 | $connect = ''; |
| 1159 | - if (isset($p->boucles[$p->id_boucle])) |
|
| 1160 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 1198 | + if (isset($p->boucles[$p->id_boucle])) { |
|
| 1199 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
|
| 1200 | + } |
|
| 1161 | 1201 | |
| 1162 | 1202 | $_options = memoriser_contexte_compil($p); |
| 1163 | 1203 | $_options = "'compil'=>array($_options), 'trim'=>true"; |
@@ -1192,7 +1232,9 @@ discard block |
||
| 1192 | 1232 | } |
| 1193 | 1233 | // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4 |
| 1194 | 1234 | // cf https://bugs.php.net/bug.php?id=65845 |
| 1195 | - else $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 1235 | + else { |
|
| 1236 | + $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)"; |
|
| 1237 | + } |
|
| 1196 | 1238 | |
| 1197 | 1239 | $p->interdire_scripts = false; // la balise ne renvoie rien |
| 1198 | 1240 | return $p; |
@@ -1206,11 +1248,12 @@ discard block |
||
| 1206 | 1248 | // http://doc.spip.org/@balise_GET_dist |
| 1207 | 1249 | function balise_GET_dist($p) { |
| 1208 | 1250 | $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance |
| 1209 | - if (function_exists('balise_ENV')) |
|
| 1210 | - return balise_ENV($p, '$Pile["vars"]'); |
|
| 1211 | - else |
|
| 1212 | - return balise_ENV_dist($p, '$Pile["vars"]'); |
|
| 1213 | -} |
|
| 1251 | + if (function_exists('balise_ENV')) { |
|
| 1252 | + return balise_ENV($p, '$Pile["vars"]'); |
|
| 1253 | + } else { |
|
| 1254 | + return balise_ENV_dist($p, '$Pile["vars"]'); |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1214 | 1257 | |
| 1215 | 1258 | |
| 1216 | 1259 | /** |
@@ -1230,15 +1273,17 @@ discard block |
||
| 1230 | 1273 | **/ |
| 1231 | 1274 | function balise_DOUBLONS_dist($p) { |
| 1232 | 1275 | if ($type = interprete_argument_balise(1,$p)) { |
| 1233 | - if ($famille = interprete_argument_balise(2,$p)) |
|
| 1234 | - $type .= '.' . $famille; |
|
| 1276 | + if ($famille = interprete_argument_balise(2,$p)) { |
|
| 1277 | + $type .= '.' . $famille; |
|
| 1278 | + } |
|
| 1235 | 1279 | $p->code = '$doublons['.$type.']'; |
| 1236 | - if (!$p->etoile) |
|
| 1237 | - $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 1280 | + if (!$p->etoile) { |
|
| 1281 | + $p->code = 'array_filter(array_map("intval",explode(",",' |
|
| 1238 | 1282 | . $p->code . ')))'; |
| 1283 | + } |
|
| 1284 | + } else { |
|
| 1285 | + $p->code = '$doublons'; |
|
| 1239 | 1286 | } |
| 1240 | - else |
|
| 1241 | - $p->code = '$doublons'; |
|
| 1242 | 1287 | |
| 1243 | 1288 | $p->interdire_scripts = false; |
| 1244 | 1289 | |
@@ -1307,7 +1352,9 @@ discard block |
||
| 1307 | 1352 | do { |
| 1308 | 1353 | $_key = interprete_argument_balise($n++,$p); |
| 1309 | 1354 | $_val = interprete_argument_balise($n++,$p); |
| 1310 | - if ($_key AND $_val) $_code[] = "$_key => $_val"; |
|
| 1355 | + if ($_key AND $_val) { |
|
| 1356 | + $_code[] = "$_key => $_val"; |
|
| 1357 | + } |
|
| 1311 | 1358 | } while ($_key && $_val); |
| 1312 | 1359 | $p->code = 'array(' . join(', ',$_code).')'; |
| 1313 | 1360 | $p->interdire_scripts = false; |
@@ -1323,8 +1370,9 @@ discard block |
||
| 1323 | 1370 | function balise_LISTE_dist($p) { |
| 1324 | 1371 | $_code = array(); |
| 1325 | 1372 | $n=1; |
| 1326 | - while ($_val = interprete_argument_balise($n++,$p)) |
|
| 1327 | - $_code[] = $_val; |
|
| 1373 | + while ($_val = interprete_argument_balise($n++,$p)) { |
|
| 1374 | + $_code[] = $_val; |
|
| 1375 | + } |
|
| 1328 | 1376 | $p->code = 'array(' . join(', ',$_code).')'; |
| 1329 | 1377 | $p->interdire_scripts = false; |
| 1330 | 1378 | return $p; |
@@ -1339,8 +1387,9 @@ discard block |
||
| 1339 | 1387 | $p->descr['session'] = true; // faire un cache par session |
| 1340 | 1388 | |
| 1341 | 1389 | $n=1; |
| 1342 | - while ($_v = interprete_argument_balise($n++,$p)) |
|
| 1343 | - $_code[] = $_v; |
|
| 1390 | + while ($_v = interprete_argument_balise($n++,$p)) { |
|
| 1391 | + $_code[] = $_v; |
|
| 1392 | + } |
|
| 1344 | 1393 | |
| 1345 | 1394 | $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ',$_code).')?" ":"")'; |
| 1346 | 1395 | $p->interdire_scripts = false; |
@@ -1375,10 +1424,12 @@ discard block |
||
| 1375 | 1424 | // avec les hidden de l'url d'action |
| 1376 | 1425 | // http://doc.spip.org/@balise_ACTION_FORMULAIRE |
| 1377 | 1426 | function balise_ACTION_FORMULAIRE($p){ |
| 1378 | - if (!$_url = interprete_argument_balise(1,$p)) |
|
| 1379 | - $_url = "@\$Pile[0]['action']"; |
|
| 1380 | - if (!$_form = interprete_argument_balise(2,$p)) |
|
| 1381 | - $_form = "@\$Pile[0]['form']"; |
|
| 1427 | + if (!$_url = interprete_argument_balise(1,$p)) { |
|
| 1428 | + $_url = "@\$Pile[0]['action']"; |
|
| 1429 | + } |
|
| 1430 | + if (!$_form = interprete_argument_balise(2,$p)) { |
|
| 1431 | + $_form = "@\$Pile[0]['form']"; |
|
| 1432 | + } |
|
| 1382 | 1433 | |
| 1383 | 1434 | // envoyer le nom du formulaire que l'on traite |
| 1384 | 1435 | // transmettre les eventuels args de la balise formulaire |
@@ -1415,12 +1466,15 @@ discard block |
||
| 1415 | 1466 | $args = array(); |
| 1416 | 1467 | for ($k=1;$k<=6;$k++){ |
| 1417 | 1468 | $_a = interprete_argument_balise($k,$p); |
| 1418 | - if (!$_a) $_a="''"; |
|
| 1469 | + if (!$_a) { |
|
| 1470 | + $_a="''"; |
|
| 1471 | + } |
|
| 1419 | 1472 | $args[] = $_a; |
| 1420 | 1473 | } |
| 1421 | 1474 | // supprimer les args vides |
| 1422 | - while(end($args)=="''" AND count($args)>2) |
|
| 1423 | - array_pop($args); |
|
| 1475 | + while(end($args)=="''" AND count($args)>2) { |
|
| 1476 | + array_pop($args); |
|
| 1477 | + } |
|
| 1424 | 1478 | $args = implode(",",$args); |
| 1425 | 1479 | |
| 1426 | 1480 | $bouton_action = chercher_filtre("bouton_action"); |
@@ -1532,8 +1586,7 @@ discard block |
||
| 1532 | 1586 | if (!$boucle) { |
| 1533 | 1587 | $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); |
| 1534 | 1588 | erreur_squelette($msg, $p); |
| 1535 | - } |
|
| 1536 | - else { |
|
| 1589 | + } else { |
|
| 1537 | 1590 | $_saut = interprete_argument_balise(1,$p); |
| 1538 | 1591 | $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']"; |
| 1539 | 1592 | $_total = "\$Numrows['$id_boucle']['total']"; |
@@ -1555,9 +1608,9 @@ discard block |
||
| 1555 | 1608 | if (!$_type = interprete_argument_balise(1,$p)){ |
| 1556 | 1609 | $_type = _q($p->type_requete); |
| 1557 | 1610 | $_id = champ_sql($p->boucles[$p->id_boucle]->primary,$p); |
| 1611 | + } else { |
|
| 1612 | + $_id = interprete_argument_balise(2,$p); |
|
| 1558 | 1613 | } |
| 1559 | - else |
|
| 1560 | - $_id = interprete_argument_balise(2,$p); |
|
| 1561 | 1614 | |
| 1562 | 1615 | $connect = $p->boucles[$p->id_boucle]->sql_serveur; |
| 1563 | 1616 | |
@@ -1599,7 +1652,9 @@ discard block |
||
| 1599 | 1652 | */ |
| 1600 | 1653 | function balise_LARGEUR_ECRAN_dist($p){ |
| 1601 | 1654 | $_class = interprete_argument_balise(1,$p); |
| 1602 | - if (!$_class) $_class='null'; |
|
| 1655 | + if (!$_class) { |
|
| 1656 | + $_class='null'; |
|
| 1657 | + } |
|
| 1603 | 1658 | $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))"; |
| 1604 | 1659 | return $p; |
| 1605 | 1660 | } |
@@ -24,28 +24,28 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function action_editer_objet_dist($id=null, $objet=null, $set=null) { |
| 26 | 26 | |
| 27 | - // appel direct depuis une url interdit |
|
| 28 | - if (is_null($id) OR is_null($objet)){ |
|
| 29 | - include_spip('inc/minipres'); |
|
| 30 | - echo minipres(_T('info_acces_interdit')); |
|
| 31 | - die(); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - // si id n'est pas un nombre, c'est une creation |
|
| 35 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 36 | - if (!$id = intval($id)) { |
|
| 37 | - // on ne sait pas si un parent existe mais on essaye |
|
| 38 | - $id_parent = _request('id_parent'); |
|
| 39 | - $id = objet_inserer($objet, $id_parent); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if (!($id = intval($id))>0) |
|
| 43 | - return array($id,_L('echec enregistrement en base')); |
|
| 44 | - |
|
| 45 | - // Enregistre l'envoi dans la BD |
|
| 46 | - $err = objet_modifier($objet, $id, $set); |
|
| 47 | - |
|
| 48 | - return array($id,$err); |
|
| 27 | + // appel direct depuis une url interdit |
|
| 28 | + if (is_null($id) OR is_null($objet)){ |
|
| 29 | + include_spip('inc/minipres'); |
|
| 30 | + echo minipres(_T('info_acces_interdit')); |
|
| 31 | + die(); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + // si id n'est pas un nombre, c'est une creation |
|
| 35 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 36 | + if (!$id = intval($id)) { |
|
| 37 | + // on ne sait pas si un parent existe mais on essaye |
|
| 38 | + $id_parent = _request('id_parent'); |
|
| 39 | + $id = objet_inserer($objet, $id_parent); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if (!($id = intval($id))>0) |
|
| 43 | + return array($id,_L('echec enregistrement en base')); |
|
| 44 | + |
|
| 45 | + // Enregistre l'envoi dans la BD |
|
| 46 | + $err = objet_modifier($objet, $id, $set); |
|
| 47 | + |
|
| 48 | + return array($id,$err); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -58,71 +58,71 @@ discard block |
||
| 58 | 58 | * @return mixed|string |
| 59 | 59 | */ |
| 60 | 60 | function objet_modifier($objet, $id, $set=null) { |
| 61 | - if (include_spip('action/editer_'.$objet) |
|
| 62 | - AND function_exists($modifier = $objet."_modifier")) |
|
| 63 | - return $modifier($id,$set); |
|
| 64 | - |
|
| 65 | - $table_sql = table_objet_sql($objet); |
|
| 66 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 67 | - $desc = $trouver_table($table_sql); |
|
| 68 | - if (!$desc OR !isset($desc['field'])) { |
|
| 69 | - spip_log("Objet $objet inconnu dans objet_modifier",_LOG_ERREUR); |
|
| 70 | - return _L("Erreur objet $objet inconnu"); |
|
| 71 | - } |
|
| 72 | - include_spip('inc/modifier'); |
|
| 73 | - |
|
| 74 | - $champ_date = ''; |
|
| 75 | - if (isset($desc['date']) AND $desc['date']) |
|
| 76 | - $champ_date = $desc['date']; |
|
| 77 | - elseif (isset($desc['field']['date'])) |
|
| 78 | - $champ_date = 'date'; |
|
| 79 | - |
|
| 80 | - $white = array_keys($desc['field']); |
|
| 81 | - // on ne traite pas la cle primaire par defaut, notamment car |
|
| 82 | - // sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base |
|
| 83 | - $white = array_diff($white, array($desc['key']['PRIMARY KEY'])); |
|
| 84 | - |
|
| 85 | - if (isset($desc['champs_editables']) AND is_array($desc['champs_editables'])) { |
|
| 86 | - $white = $desc['champs_editables']; |
|
| 87 | - } |
|
| 88 | - $c = collecter_requests( |
|
| 89 | - // white list |
|
| 90 | - $white, |
|
| 91 | - // black list |
|
| 92 | - array($champ_date,'statut','id_parent','id_secteur'), |
|
| 93 | - // donnees eventuellement fournies |
|
| 94 | - $set |
|
| 95 | - ); |
|
| 96 | - |
|
| 97 | - // Si l'objet est publie, invalider les caches et demander sa reindexation |
|
| 98 | - if (objet_test_si_publie($objet,$id)){ |
|
| 99 | - $invalideur = "id='$objet/$id'"; |
|
| 100 | - $indexation = true; |
|
| 101 | - } |
|
| 102 | - else { |
|
| 103 | - $invalideur = ""; |
|
| 104 | - $indexation = false; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ($err = objet_modifier_champs($objet, $id, |
|
| 108 | - array( |
|
| 109 | - 'data' => $set, |
|
| 110 | - 'nonvide' => '', |
|
| 111 | - 'invalideur' => $invalideur, |
|
| 112 | - 'indexation' => $indexation, |
|
| 113 | - // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 114 | - 'date_modif' => (isset($desc['field']['date_modif'])?'date_modif':'') |
|
| 115 | - ), |
|
| 116 | - $c)) |
|
| 117 | - return $err; |
|
| 118 | - |
|
| 119 | - // Modification de statut, changement de rubrique ? |
|
| 120 | - // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
|
| 121 | - // le tableau $set hors black liste, mais du coup on a possiblement des champs en trop. |
|
| 122 | - $c = collecter_requests(array($champ_date, 'statut', 'id_parent'),array(),$set); |
|
| 123 | - $err = objet_instituer($objet, $id, $c); |
|
| 124 | - |
|
| 125 | - return $err; |
|
| 61 | + if (include_spip('action/editer_'.$objet) |
|
| 62 | + AND function_exists($modifier = $objet."_modifier")) |
|
| 63 | + return $modifier($id,$set); |
|
| 64 | + |
|
| 65 | + $table_sql = table_objet_sql($objet); |
|
| 66 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 67 | + $desc = $trouver_table($table_sql); |
|
| 68 | + if (!$desc OR !isset($desc['field'])) { |
|
| 69 | + spip_log("Objet $objet inconnu dans objet_modifier",_LOG_ERREUR); |
|
| 70 | + return _L("Erreur objet $objet inconnu"); |
|
| 71 | + } |
|
| 72 | + include_spip('inc/modifier'); |
|
| 73 | + |
|
| 74 | + $champ_date = ''; |
|
| 75 | + if (isset($desc['date']) AND $desc['date']) |
|
| 76 | + $champ_date = $desc['date']; |
|
| 77 | + elseif (isset($desc['field']['date'])) |
|
| 78 | + $champ_date = 'date'; |
|
| 79 | + |
|
| 80 | + $white = array_keys($desc['field']); |
|
| 81 | + // on ne traite pas la cle primaire par defaut, notamment car |
|
| 82 | + // sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base |
|
| 83 | + $white = array_diff($white, array($desc['key']['PRIMARY KEY'])); |
|
| 84 | + |
|
| 85 | + if (isset($desc['champs_editables']) AND is_array($desc['champs_editables'])) { |
|
| 86 | + $white = $desc['champs_editables']; |
|
| 87 | + } |
|
| 88 | + $c = collecter_requests( |
|
| 89 | + // white list |
|
| 90 | + $white, |
|
| 91 | + // black list |
|
| 92 | + array($champ_date,'statut','id_parent','id_secteur'), |
|
| 93 | + // donnees eventuellement fournies |
|
| 94 | + $set |
|
| 95 | + ); |
|
| 96 | + |
|
| 97 | + // Si l'objet est publie, invalider les caches et demander sa reindexation |
|
| 98 | + if (objet_test_si_publie($objet,$id)){ |
|
| 99 | + $invalideur = "id='$objet/$id'"; |
|
| 100 | + $indexation = true; |
|
| 101 | + } |
|
| 102 | + else { |
|
| 103 | + $invalideur = ""; |
|
| 104 | + $indexation = false; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ($err = objet_modifier_champs($objet, $id, |
|
| 108 | + array( |
|
| 109 | + 'data' => $set, |
|
| 110 | + 'nonvide' => '', |
|
| 111 | + 'invalideur' => $invalideur, |
|
| 112 | + 'indexation' => $indexation, |
|
| 113 | + // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 114 | + 'date_modif' => (isset($desc['field']['date_modif'])?'date_modif':'') |
|
| 115 | + ), |
|
| 116 | + $c)) |
|
| 117 | + return $err; |
|
| 118 | + |
|
| 119 | + // Modification de statut, changement de rubrique ? |
|
| 120 | + // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
|
| 121 | + // le tableau $set hors black liste, mais du coup on a possiblement des champs en trop. |
|
| 122 | + $c = collecter_requests(array($champ_date, 'statut', 'id_parent'),array(),$set); |
|
| 123 | + $err = objet_instituer($objet, $id, $c); |
|
| 124 | + |
|
| 125 | + return $err; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -133,108 +133,108 @@ discard block |
||
| 133 | 133 | * @return bool|int |
| 134 | 134 | */ |
| 135 | 135 | function objet_inserer($objet, $id_parent=null, $set=null) { |
| 136 | - if (include_spip('action/editer_'.$objet) |
|
| 137 | - AND function_exists($inserer = $objet."_inserer")) |
|
| 138 | - return $inserer($id_parent); |
|
| 139 | - |
|
| 140 | - $table_sql = table_objet_sql($objet); |
|
| 141 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 142 | - $desc = $trouver_table($table_sql); |
|
| 143 | - if (!$desc OR !isset($desc['field'])) |
|
| 144 | - return 0; |
|
| 145 | - |
|
| 146 | - $lang_rub = ""; |
|
| 147 | - $champs = array(); |
|
| 148 | - if (isset($desc['field']['id_rubrique'])){ |
|
| 149 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
|
| 150 | - // dans la premiere rubrique racine |
|
| 151 | - if (!$id_rubrique = intval($id_parent)) { |
|
| 152 | - $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
|
| 153 | - $id_rubrique = $row['id_rubrique']; |
|
| 154 | - } |
|
| 155 | - else |
|
| 156 | - $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 157 | - |
|
| 158 | - $champs['id_rubrique'] = $id_rubrique; |
|
| 159 | - if (isset($desc['field']['id_secteur'])) |
|
| 160 | - $champs['id_secteur'] = $row['id_secteur']; |
|
| 161 | - $lang_rub = $row['lang']; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 165 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 166 | - // ou a defaut celle de la rubrique |
|
| 167 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 168 | - if (isset($desc['field']['lang']) AND $GLOBALS['meta']['multi_objets'] AND in_array($table_sql, explode(',', $GLOBALS['meta']['multi_objets']))) { |
|
| 169 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 170 | - if (in_array($GLOBALS['spip_lang'], |
|
| 171 | - explode(',', $GLOBALS['meta']['langues_multilingue']))) { |
|
| 172 | - $champs['lang'] = $GLOBALS['spip_lang']; |
|
| 173 | - if (isset($desc['field']['langue_choisie'])) |
|
| 174 | - $champs['langue_choisie'] = 'oui'; |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - elseif (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) { |
|
| 178 | - $champs['lang'] = ($lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site']); |
|
| 179 | - $champs['langue_choisie'] = 'non'; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - if (isset($desc['field']['statut'])){ |
|
| 183 | - if (isset($desc['statut_textes_instituer'])){ |
|
| 184 | - $cles_statut = array_keys($desc['statut_textes_instituer']); |
|
| 185 | - $champs['statut'] = reset($cles_statut); |
|
| 186 | - } |
|
| 187 | - else |
|
| 188 | - $champs['statut'] = 'prepa'; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date'])) |
|
| 193 | - $champs[$d] = date('Y-m-d H:i:s'); |
|
| 194 | - |
|
| 195 | - if ($set) |
|
| 196 | - $champs = array_merge($champs, $set); |
|
| 197 | - |
|
| 198 | - // Envoyer aux plugins |
|
| 199 | - $champs = pipeline('pre_insertion', |
|
| 200 | - array( |
|
| 201 | - 'args' => array( |
|
| 202 | - 'table' => $table_sql, |
|
| 203 | - ), |
|
| 204 | - 'data' => $champs |
|
| 205 | - ) |
|
| 206 | - ); |
|
| 207 | - |
|
| 208 | - $id = sql_insertq($table_sql, $champs); |
|
| 209 | - |
|
| 210 | - if ($id){ |
|
| 211 | - pipeline('post_insertion', |
|
| 212 | - array( |
|
| 213 | - 'args' => array( |
|
| 214 | - 'table' => $table_sql, |
|
| 215 | - 'id_objet' => $id, |
|
| 216 | - ), |
|
| 217 | - 'data' => $champs |
|
| 218 | - ) |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 222 | - // et associer l'auteur sinon |
|
| 223 | - // si la table n'a pas deja un champ id_auteur |
|
| 224 | - // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
|
| 225 | - if ($id > 0 |
|
| 226 | - AND !isset($desc['field']['id_auteur'])){ |
|
| 227 | - $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))? |
|
| 228 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 229 | - :_request('id_auteur')); |
|
| 230 | - if ($id_auteur) { |
|
| 231 | - include_spip('action/editer_auteur'); |
|
| 232 | - auteur_associer($id_auteur, array($objet=>$id)); |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - return $id; |
|
| 136 | + if (include_spip('action/editer_'.$objet) |
|
| 137 | + AND function_exists($inserer = $objet."_inserer")) |
|
| 138 | + return $inserer($id_parent); |
|
| 139 | + |
|
| 140 | + $table_sql = table_objet_sql($objet); |
|
| 141 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 142 | + $desc = $trouver_table($table_sql); |
|
| 143 | + if (!$desc OR !isset($desc['field'])) |
|
| 144 | + return 0; |
|
| 145 | + |
|
| 146 | + $lang_rub = ""; |
|
| 147 | + $champs = array(); |
|
| 148 | + if (isset($desc['field']['id_rubrique'])){ |
|
| 149 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
|
| 150 | + // dans la premiere rubrique racine |
|
| 151 | + if (!$id_rubrique = intval($id_parent)) { |
|
| 152 | + $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
|
| 153 | + $id_rubrique = $row['id_rubrique']; |
|
| 154 | + } |
|
| 155 | + else |
|
| 156 | + $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 157 | + |
|
| 158 | + $champs['id_rubrique'] = $id_rubrique; |
|
| 159 | + if (isset($desc['field']['id_secteur'])) |
|
| 160 | + $champs['id_secteur'] = $row['id_secteur']; |
|
| 161 | + $lang_rub = $row['lang']; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 165 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 166 | + // ou a defaut celle de la rubrique |
|
| 167 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 168 | + if (isset($desc['field']['lang']) AND $GLOBALS['meta']['multi_objets'] AND in_array($table_sql, explode(',', $GLOBALS['meta']['multi_objets']))) { |
|
| 169 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 170 | + if (in_array($GLOBALS['spip_lang'], |
|
| 171 | + explode(',', $GLOBALS['meta']['langues_multilingue']))) { |
|
| 172 | + $champs['lang'] = $GLOBALS['spip_lang']; |
|
| 173 | + if (isset($desc['field']['langue_choisie'])) |
|
| 174 | + $champs['langue_choisie'] = 'oui'; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + elseif (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) { |
|
| 178 | + $champs['lang'] = ($lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site']); |
|
| 179 | + $champs['langue_choisie'] = 'non'; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + if (isset($desc['field']['statut'])){ |
|
| 183 | + if (isset($desc['statut_textes_instituer'])){ |
|
| 184 | + $cles_statut = array_keys($desc['statut_textes_instituer']); |
|
| 185 | + $champs['statut'] = reset($cles_statut); |
|
| 186 | + } |
|
| 187 | + else |
|
| 188 | + $champs['statut'] = 'prepa'; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date'])) |
|
| 193 | + $champs[$d] = date('Y-m-d H:i:s'); |
|
| 194 | + |
|
| 195 | + if ($set) |
|
| 196 | + $champs = array_merge($champs, $set); |
|
| 197 | + |
|
| 198 | + // Envoyer aux plugins |
|
| 199 | + $champs = pipeline('pre_insertion', |
|
| 200 | + array( |
|
| 201 | + 'args' => array( |
|
| 202 | + 'table' => $table_sql, |
|
| 203 | + ), |
|
| 204 | + 'data' => $champs |
|
| 205 | + ) |
|
| 206 | + ); |
|
| 207 | + |
|
| 208 | + $id = sql_insertq($table_sql, $champs); |
|
| 209 | + |
|
| 210 | + if ($id){ |
|
| 211 | + pipeline('post_insertion', |
|
| 212 | + array( |
|
| 213 | + 'args' => array( |
|
| 214 | + 'table' => $table_sql, |
|
| 215 | + 'id_objet' => $id, |
|
| 216 | + ), |
|
| 217 | + 'data' => $champs |
|
| 218 | + ) |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 222 | + // et associer l'auteur sinon |
|
| 223 | + // si la table n'a pas deja un champ id_auteur |
|
| 224 | + // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
|
| 225 | + if ($id > 0 |
|
| 226 | + AND !isset($desc['field']['id_auteur'])){ |
|
| 227 | + $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))? |
|
| 228 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 229 | + :_request('id_auteur')); |
|
| 230 | + if ($id_auteur) { |
|
| 231 | + include_spip('action/editer_auteur'); |
|
| 232 | + auteur_associer($id_auteur, array($objet=>$id)); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + return $id; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
@@ -250,114 +250,114 @@ discard block |
||
| 250 | 250 | * @return mixed|string |
| 251 | 251 | */ |
| 252 | 252 | function objet_instituer($objet, $id, $c, $calcul_rub=true) { |
| 253 | - if (include_spip('action/editer_'.$objet) |
|
| 254 | - AND function_exists($instituer = $objet."_instituer")) |
|
| 255 | - return $instituer($id,$c,$calcul_rub); |
|
| 256 | - |
|
| 257 | - $table_sql = table_objet_sql($objet); |
|
| 258 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 259 | - $desc = $trouver_table($table_sql); |
|
| 260 | - if (!$desc OR !isset($desc['field'])) |
|
| 261 | - return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 262 | - |
|
| 263 | - include_spip('inc/autoriser'); |
|
| 264 | - include_spip('inc/rubriques'); |
|
| 265 | - include_spip('inc/modifier'); |
|
| 266 | - |
|
| 267 | - $sel = array(); |
|
| 268 | - $sel[] = (isset($desc['field']['statut'])?"statut":"'' as statut"); |
|
| 269 | - |
|
| 270 | - $champ_date = ''; |
|
| 271 | - if (isset($desc['date']) AND $desc['date']) |
|
| 272 | - $champ_date = $desc['date']; |
|
| 273 | - elseif (isset($desc['field']['date'])) |
|
| 274 | - $champ_date = 'date'; |
|
| 275 | - |
|
| 276 | - $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
|
| 277 | - $sel[] = (isset($desc['field']['id_rubrique'])?'id_rubrique':"0 as id_rubrique"); |
|
| 278 | - |
|
| 279 | - $row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.intval($id)); |
|
| 280 | - |
|
| 281 | - $id_rubrique = $row['id_rubrique']; |
|
| 282 | - $statut_ancien = $statut = $row['statut']; |
|
| 283 | - $date_ancienne = $date = $row['date']; |
|
| 284 | - $champs = array(); |
|
| 285 | - |
|
| 286 | - $d = ($date AND isset($c[$champ_date]))?$c[$champ_date]:null; |
|
| 287 | - $s = (isset($desc['field']['statut']) AND isset($c['statut']))?$c['statut']:$statut; |
|
| 288 | - |
|
| 289 | - // cf autorisations dans inc/instituer_objet |
|
| 290 | - if ($s != $statut OR ($d AND $d != $date)) { |
|
| 291 | - if ($id_rubrique ? |
|
| 292 | - autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 293 | - : |
|
| 294 | - autoriser('instituer', $objet, $id, null, array('statut'=>$s)) |
|
| 295 | - ) |
|
| 296 | - $statut = $champs['statut'] = $s; |
|
| 297 | - else if ($s!='publie' AND autoriser('modifier', $objet, $id)) |
|
| 298 | - $statut = $champs['statut'] = $s; |
|
| 299 | - else |
|
| 300 | - spip_log("editer_objet $id refus " . join(' ', $c)); |
|
| 301 | - |
|
| 302 | - // En cas de publication, fixer la date a "maintenant" |
|
| 303 | - // sauf si $c commande autre chose |
|
| 304 | - // ou si l'objet est deja date dans le futur |
|
| 305 | - // En cas de proposition d'un objet (mais pas depublication), idem |
|
| 306 | - if ($champ_date) { |
|
| 307 | - if ($champs['statut'] == 'publie' |
|
| 308 | - OR ($champs['statut'] == 'prop' AND !in_array($statut_ancien, array('publie', 'prop'))) |
|
| 309 | - OR $d |
|
| 310 | - ) { |
|
| 311 | - if ($d OR strtotime($d=$date)>time()) |
|
| 312 | - $champs[$champ_date] = $date = $d; |
|
| 313 | - else |
|
| 314 | - $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - // Verifier que la rubrique demandee existe et est differente |
|
| 320 | - // de la rubrique actuelle |
|
| 321 | - if ($id_rubrique |
|
| 322 | - AND $id_parent = $c['id_parent'] |
|
| 323 | - AND $id_parent != $id_rubrique |
|
| 324 | - AND (sql_fetsel('1', "spip_rubriques", "id_rubrique=".intval($id_parent)))) { |
|
| 325 | - $champs['id_rubrique'] = $id_parent; |
|
| 326 | - |
|
| 327 | - // si l'objet etait publie |
|
| 328 | - // et que le demandeur n'est pas admin de la rubrique |
|
| 329 | - // repasser l'objet en statut 'propose'. |
|
| 330 | - if ($statut == 'publie' |
|
| 331 | - AND !autoriser('publierdans', 'rubrique', $id_rubrique)) |
|
| 332 | - $champs['statut'] = 'prop'; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - // Envoyer aux plugins |
|
| 337 | - $champs = pipeline('pre_edition', |
|
| 338 | - array( |
|
| 339 | - 'args' => array( |
|
| 340 | - 'table' => $table_sql, |
|
| 341 | - 'id_objet' => $id, |
|
| 342 | - 'action'=>'instituer', |
|
| 343 | - 'statut_ancien' => $statut_ancien, |
|
| 344 | - 'date_ancienne' => $date_ancienne, |
|
| 345 | - 'id_parent_ancien' => $id_rubrique, |
|
| 346 | - ), |
|
| 347 | - 'data' => $champs |
|
| 348 | - ) |
|
| 349 | - ); |
|
| 350 | - |
|
| 351 | - if (!count($champs)) return ''; |
|
| 352 | - |
|
| 353 | - // Envoyer les modifs. |
|
| 354 | - objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 355 | - |
|
| 356 | - // Invalider les caches |
|
| 357 | - include_spip('inc/invalideur'); |
|
| 358 | - suivre_invalideur("id='$objet/$id'"); |
|
| 359 | - |
|
| 360 | - /* |
|
| 253 | + if (include_spip('action/editer_'.$objet) |
|
| 254 | + AND function_exists($instituer = $objet."_instituer")) |
|
| 255 | + return $instituer($id,$c,$calcul_rub); |
|
| 256 | + |
|
| 257 | + $table_sql = table_objet_sql($objet); |
|
| 258 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 259 | + $desc = $trouver_table($table_sql); |
|
| 260 | + if (!$desc OR !isset($desc['field'])) |
|
| 261 | + return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 262 | + |
|
| 263 | + include_spip('inc/autoriser'); |
|
| 264 | + include_spip('inc/rubriques'); |
|
| 265 | + include_spip('inc/modifier'); |
|
| 266 | + |
|
| 267 | + $sel = array(); |
|
| 268 | + $sel[] = (isset($desc['field']['statut'])?"statut":"'' as statut"); |
|
| 269 | + |
|
| 270 | + $champ_date = ''; |
|
| 271 | + if (isset($desc['date']) AND $desc['date']) |
|
| 272 | + $champ_date = $desc['date']; |
|
| 273 | + elseif (isset($desc['field']['date'])) |
|
| 274 | + $champ_date = 'date'; |
|
| 275 | + |
|
| 276 | + $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
|
| 277 | + $sel[] = (isset($desc['field']['id_rubrique'])?'id_rubrique':"0 as id_rubrique"); |
|
| 278 | + |
|
| 279 | + $row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.intval($id)); |
|
| 280 | + |
|
| 281 | + $id_rubrique = $row['id_rubrique']; |
|
| 282 | + $statut_ancien = $statut = $row['statut']; |
|
| 283 | + $date_ancienne = $date = $row['date']; |
|
| 284 | + $champs = array(); |
|
| 285 | + |
|
| 286 | + $d = ($date AND isset($c[$champ_date]))?$c[$champ_date]:null; |
|
| 287 | + $s = (isset($desc['field']['statut']) AND isset($c['statut']))?$c['statut']:$statut; |
|
| 288 | + |
|
| 289 | + // cf autorisations dans inc/instituer_objet |
|
| 290 | + if ($s != $statut OR ($d AND $d != $date)) { |
|
| 291 | + if ($id_rubrique ? |
|
| 292 | + autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 293 | + : |
|
| 294 | + autoriser('instituer', $objet, $id, null, array('statut'=>$s)) |
|
| 295 | + ) |
|
| 296 | + $statut = $champs['statut'] = $s; |
|
| 297 | + else if ($s!='publie' AND autoriser('modifier', $objet, $id)) |
|
| 298 | + $statut = $champs['statut'] = $s; |
|
| 299 | + else |
|
| 300 | + spip_log("editer_objet $id refus " . join(' ', $c)); |
|
| 301 | + |
|
| 302 | + // En cas de publication, fixer la date a "maintenant" |
|
| 303 | + // sauf si $c commande autre chose |
|
| 304 | + // ou si l'objet est deja date dans le futur |
|
| 305 | + // En cas de proposition d'un objet (mais pas depublication), idem |
|
| 306 | + if ($champ_date) { |
|
| 307 | + if ($champs['statut'] == 'publie' |
|
| 308 | + OR ($champs['statut'] == 'prop' AND !in_array($statut_ancien, array('publie', 'prop'))) |
|
| 309 | + OR $d |
|
| 310 | + ) { |
|
| 311 | + if ($d OR strtotime($d=$date)>time()) |
|
| 312 | + $champs[$champ_date] = $date = $d; |
|
| 313 | + else |
|
| 314 | + $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + // Verifier que la rubrique demandee existe et est differente |
|
| 320 | + // de la rubrique actuelle |
|
| 321 | + if ($id_rubrique |
|
| 322 | + AND $id_parent = $c['id_parent'] |
|
| 323 | + AND $id_parent != $id_rubrique |
|
| 324 | + AND (sql_fetsel('1', "spip_rubriques", "id_rubrique=".intval($id_parent)))) { |
|
| 325 | + $champs['id_rubrique'] = $id_parent; |
|
| 326 | + |
|
| 327 | + // si l'objet etait publie |
|
| 328 | + // et que le demandeur n'est pas admin de la rubrique |
|
| 329 | + // repasser l'objet en statut 'propose'. |
|
| 330 | + if ($statut == 'publie' |
|
| 331 | + AND !autoriser('publierdans', 'rubrique', $id_rubrique)) |
|
| 332 | + $champs['statut'] = 'prop'; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + // Envoyer aux plugins |
|
| 337 | + $champs = pipeline('pre_edition', |
|
| 338 | + array( |
|
| 339 | + 'args' => array( |
|
| 340 | + 'table' => $table_sql, |
|
| 341 | + 'id_objet' => $id, |
|
| 342 | + 'action'=>'instituer', |
|
| 343 | + 'statut_ancien' => $statut_ancien, |
|
| 344 | + 'date_ancienne' => $date_ancienne, |
|
| 345 | + 'id_parent_ancien' => $id_rubrique, |
|
| 346 | + ), |
|
| 347 | + 'data' => $champs |
|
| 348 | + ) |
|
| 349 | + ); |
|
| 350 | + |
|
| 351 | + if (!count($champs)) return ''; |
|
| 352 | + |
|
| 353 | + // Envoyer les modifs. |
|
| 354 | + objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 355 | + |
|
| 356 | + // Invalider les caches |
|
| 357 | + include_spip('inc/invalideur'); |
|
| 358 | + suivre_invalideur("id='$objet/$id'"); |
|
| 359 | + |
|
| 360 | + /* |
|
| 361 | 361 | if ($date) { |
| 362 | 362 | $t = strtotime($date); |
| 363 | 363 | $p = @$GLOBALS['meta']['date_prochain_postdate']; |
@@ -366,29 +366,29 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | }*/ |
| 368 | 368 | |
| 369 | - // Pipeline |
|
| 370 | - pipeline('post_edition', |
|
| 371 | - array( |
|
| 372 | - 'args' => array( |
|
| 373 | - 'table' => $table_sql, |
|
| 374 | - 'id_objet' => $id, |
|
| 375 | - 'action'=>'instituer', |
|
| 376 | - 'statut_ancien' => $statut_ancien, |
|
| 377 | - 'date_ancienne' => $date_ancienne, |
|
| 378 | - 'id_parent_ancien' => $id_rubrique, |
|
| 379 | - ), |
|
| 380 | - 'data' => $champs |
|
| 381 | - ) |
|
| 382 | - ); |
|
| 383 | - |
|
| 384 | - // Notifications |
|
| 385 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 386 | - $notifications("instituer$objet", $id, |
|
| 387 | - array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date'=>$date, 'date_ancienne' => $date_ancienne) |
|
| 388 | - ); |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - return ''; // pas d'erreur |
|
| 369 | + // Pipeline |
|
| 370 | + pipeline('post_edition', |
|
| 371 | + array( |
|
| 372 | + 'args' => array( |
|
| 373 | + 'table' => $table_sql, |
|
| 374 | + 'id_objet' => $id, |
|
| 375 | + 'action'=>'instituer', |
|
| 376 | + 'statut_ancien' => $statut_ancien, |
|
| 377 | + 'date_ancienne' => $date_ancienne, |
|
| 378 | + 'id_parent_ancien' => $id_rubrique, |
|
| 379 | + ), |
|
| 380 | + 'data' => $champs |
|
| 381 | + ) |
|
| 382 | + ); |
|
| 383 | + |
|
| 384 | + // Notifications |
|
| 385 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 386 | + $notifications("instituer$objet", $id, |
|
| 387 | + array('statut' => $statut, 'statut_ancien' => $statut_ancien, 'date'=>$date, 'date_ancienne' => $date_ancienne) |
|
| 388 | + ); |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + return ''; // pas d'erreur |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -403,36 +403,36 @@ discard block |
||
| 403 | 403 | * @return |
| 404 | 404 | */ |
| 405 | 405 | function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond=true) { |
| 406 | - $table_sql = table_objet_sql($objet); |
|
| 407 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 408 | - $desc = $trouver_table($table_sql); |
|
| 409 | - |
|
| 410 | - // Si on deplace l'objet |
|
| 411 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 412 | - if (isset($champs['id_rubrique'])) { |
|
| 413 | - |
|
| 414 | - $row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique'])); |
|
| 415 | - $langue = $row_rub['lang']; |
|
| 416 | - |
|
| 417 | - if (isset($desc['field']['id_secteur'])) |
|
| 418 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 419 | - |
|
| 420 | - if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) |
|
| 421 | - if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 422 | - $champs['lang'] = $langue; |
|
| 423 | - } |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - if (!$champs) return; |
|
| 427 | - sql_updateq($table_sql, $champs, id_table_objet($objet).'='.intval($id)); |
|
| 428 | - |
|
| 429 | - // Changer le statut des rubriques concernees |
|
| 430 | - if ($cond) { |
|
| 431 | - include_spip('inc/rubriques'); |
|
| 432 | - //$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 433 | - $postdate = false; |
|
| 434 | - calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 435 | - } |
|
| 406 | + $table_sql = table_objet_sql($objet); |
|
| 407 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 408 | + $desc = $trouver_table($table_sql); |
|
| 409 | + |
|
| 410 | + // Si on deplace l'objet |
|
| 411 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 412 | + if (isset($champs['id_rubrique'])) { |
|
| 413 | + |
|
| 414 | + $row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique'])); |
|
| 415 | + $langue = $row_rub['lang']; |
|
| 416 | + |
|
| 417 | + if (isset($desc['field']['id_secteur'])) |
|
| 418 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 419 | + |
|
| 420 | + if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) |
|
| 421 | + if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 422 | + $champs['lang'] = $langue; |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + if (!$champs) return; |
|
| 427 | + sql_updateq($table_sql, $champs, id_table_objet($objet).'='.intval($id)); |
|
| 428 | + |
|
| 429 | + // Changer le statut des rubriques concernees |
|
| 430 | + if ($cond) { |
|
| 431 | + include_spip('inc/rubriques'); |
|
| 432 | + //$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 433 | + $postdate = false; |
|
| 434 | + calculer_rubriques_if($id_rubrique, $champs, $statut, $postdate); |
|
| 435 | + } |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | ?> |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * @param array $set |
| 23 | 23 | * @return array |
| 24 | 24 | */ |
| 25 | -function action_editer_objet_dist($id=null, $objet=null, $set=null) { |
|
| 25 | +function action_editer_objet_dist($id = null, $objet = null, $set = null) { |
|
| 26 | 26 | |
| 27 | 27 | // appel direct depuis une url interdit |
| 28 | - if (is_null($id) OR is_null($objet)){ |
|
| 28 | + if (is_null($id) OR is_null($objet)) { |
|
| 29 | 29 | include_spip('inc/minipres'); |
| 30 | 30 | echo minipres(_T('info_acces_interdit')); |
| 31 | 31 | die(); |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | $id = objet_inserer($objet, $id_parent); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if (!($id = intval($id))>0) |
|
| 43 | - return array($id,_L('echec enregistrement en base')); |
|
| 42 | + if (!($id = intval($id)) > 0) |
|
| 43 | + return array($id, _L('echec enregistrement en base')); |
|
| 44 | 44 | |
| 45 | 45 | // Enregistre l'envoi dans la BD |
| 46 | 46 | $err = objet_modifier($objet, $id, $set); |
| 47 | 47 | |
| 48 | - return array($id,$err); |
|
| 48 | + return array($id, $err); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | * @param array|null $set |
| 58 | 58 | * @return mixed|string |
| 59 | 59 | */ |
| 60 | -function objet_modifier($objet, $id, $set=null) { |
|
| 60 | +function objet_modifier($objet, $id, $set = null) { |
|
| 61 | 61 | if (include_spip('action/editer_'.$objet) |
| 62 | 62 | AND function_exists($modifier = $objet."_modifier")) |
| 63 | - return $modifier($id,$set); |
|
| 63 | + return $modifier($id, $set); |
|
| 64 | 64 | |
| 65 | 65 | $table_sql = table_objet_sql($objet); |
| 66 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 66 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 67 | 67 | $desc = $trouver_table($table_sql); |
| 68 | 68 | if (!$desc OR !isset($desc['field'])) { |
| 69 | - spip_log("Objet $objet inconnu dans objet_modifier",_LOG_ERREUR); |
|
| 69 | + spip_log("Objet $objet inconnu dans objet_modifier", _LOG_ERREUR); |
|
| 70 | 70 | return _L("Erreur objet $objet inconnu"); |
| 71 | 71 | } |
| 72 | 72 | include_spip('inc/modifier'); |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | // white list |
| 90 | 90 | $white, |
| 91 | 91 | // black list |
| 92 | - array($champ_date,'statut','id_parent','id_secteur'), |
|
| 92 | + array($champ_date, 'statut', 'id_parent', 'id_secteur'), |
|
| 93 | 93 | // donnees eventuellement fournies |
| 94 | 94 | $set |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | 97 | // Si l'objet est publie, invalider les caches et demander sa reindexation |
| 98 | - if (objet_test_si_publie($objet,$id)){ |
|
| 98 | + if (objet_test_si_publie($objet, $id)) { |
|
| 99 | 99 | $invalideur = "id='$objet/$id'"; |
| 100 | 100 | $indexation = true; |
| 101 | 101 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | 'invalideur' => $invalideur, |
| 112 | 112 | 'indexation' => $indexation, |
| 113 | 113 | // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
| 114 | - 'date_modif' => (isset($desc['field']['date_modif'])?'date_modif':'') |
|
| 114 | + 'date_modif' => (isset($desc['field']['date_modif']) ? 'date_modif' : '') |
|
| 115 | 115 | ), |
| 116 | 116 | $c)) |
| 117 | 117 | return $err; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | // Modification de statut, changement de rubrique ? |
| 120 | 120 | // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
| 121 | 121 | // le tableau $set hors black liste, mais du coup on a possiblement des champs en trop. |
| 122 | - $c = collecter_requests(array($champ_date, 'statut', 'id_parent'),array(),$set); |
|
| 122 | + $c = collecter_requests(array($champ_date, 'statut', 'id_parent'), array(), $set); |
|
| 123 | 123 | $err = objet_instituer($objet, $id, $c); |
| 124 | 124 | |
| 125 | 125 | return $err; |
@@ -132,24 +132,24 @@ discard block |
||
| 132 | 132 | * @param array|null $set |
| 133 | 133 | * @return bool|int |
| 134 | 134 | */ |
| 135 | -function objet_inserer($objet, $id_parent=null, $set=null) { |
|
| 135 | +function objet_inserer($objet, $id_parent = null, $set = null) { |
|
| 136 | 136 | if (include_spip('action/editer_'.$objet) |
| 137 | 137 | AND function_exists($inserer = $objet."_inserer")) |
| 138 | 138 | return $inserer($id_parent); |
| 139 | 139 | |
| 140 | 140 | $table_sql = table_objet_sql($objet); |
| 141 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 141 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 142 | 142 | $desc = $trouver_table($table_sql); |
| 143 | 143 | if (!$desc OR !isset($desc['field'])) |
| 144 | 144 | return 0; |
| 145 | 145 | |
| 146 | 146 | $lang_rub = ""; |
| 147 | 147 | $champs = array(); |
| 148 | - if (isset($desc['field']['id_rubrique'])){ |
|
| 148 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 149 | 149 | // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
| 150 | 150 | // dans la premiere rubrique racine |
| 151 | 151 | if (!$id_rubrique = intval($id_parent)) { |
| 152 | - $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
|
| 152 | + $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0", '', '0+titre,titre', "1"); |
|
| 153 | 153 | $id_rubrique = $row['id_rubrique']; |
| 154 | 154 | } |
| 155 | 155 | else |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | $champs['langue_choisie'] = 'non'; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if (isset($desc['field']['statut'])){ |
|
| 183 | - if (isset($desc['statut_textes_instituer'])){ |
|
| 182 | + if (isset($desc['field']['statut'])) { |
|
| 183 | + if (isset($desc['statut_textes_instituer'])) { |
|
| 184 | 184 | $cles_statut = array_keys($desc['statut_textes_instituer']); |
| 185 | 185 | $champs['statut'] = reset($cles_statut); |
| 186 | 186 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
| 192 | - if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date'])) |
|
| 192 | + if ((isset($desc['date']) AND $d = $desc['date']) OR isset($desc['field'][$d = 'date'])) |
|
| 193 | 193 | $champs[$d] = date('Y-m-d H:i:s'); |
| 194 | 194 | |
| 195 | 195 | if ($set) |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $id = sql_insertq($table_sql, $champs); |
| 209 | 209 | |
| 210 | - if ($id){ |
|
| 210 | + if ($id) { |
|
| 211 | 211 | pipeline('post_insertion', |
| 212 | 212 | array( |
| 213 | 213 | 'args' => array( |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | // si la table n'a pas deja un champ id_auteur |
| 224 | 224 | // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
| 225 | 225 | if ($id > 0 |
| 226 | - AND !isset($desc['field']['id_auteur'])){ |
|
| 227 | - $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur']))? |
|
| 226 | + AND !isset($desc['field']['id_auteur'])) { |
|
| 227 | + $id_auteur = ((is_null(_request('id_auteur')) AND isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 228 | 228 | $GLOBALS['visiteur_session']['id_auteur'] |
| 229 | 229 | :_request('id_auteur')); |
| 230 | 230 | if ($id_auteur) { |
@@ -249,13 +249,13 @@ discard block |
||
| 249 | 249 | * @param bool $calcul_rub |
| 250 | 250 | * @return mixed|string |
| 251 | 251 | */ |
| 252 | -function objet_instituer($objet, $id, $c, $calcul_rub=true) { |
|
| 252 | +function objet_instituer($objet, $id, $c, $calcul_rub = true) { |
|
| 253 | 253 | if (include_spip('action/editer_'.$objet) |
| 254 | 254 | AND function_exists($instituer = $objet."_instituer")) |
| 255 | - return $instituer($id,$c,$calcul_rub); |
|
| 255 | + return $instituer($id, $c, $calcul_rub); |
|
| 256 | 256 | |
| 257 | 257 | $table_sql = table_objet_sql($objet); |
| 258 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 258 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 259 | 259 | $desc = $trouver_table($table_sql); |
| 260 | 260 | if (!$desc OR !isset($desc['field'])) |
| 261 | 261 | return _L("Impossible d'instituer $objet : non connu en base"); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | include_spip('inc/modifier'); |
| 266 | 266 | |
| 267 | 267 | $sel = array(); |
| 268 | - $sel[] = (isset($desc['field']['statut'])?"statut":"'' as statut"); |
|
| 268 | + $sel[] = (isset($desc['field']['statut']) ? "statut" : "'' as statut"); |
|
| 269 | 269 | |
| 270 | 270 | $champ_date = ''; |
| 271 | 271 | if (isset($desc['date']) AND $desc['date']) |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $champ_date = 'date'; |
| 275 | 275 | |
| 276 | 276 | $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
| 277 | - $sel[] = (isset($desc['field']['id_rubrique'])?'id_rubrique':"0 as id_rubrique"); |
|
| 277 | + $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : "0 as id_rubrique"); |
|
| 278 | 278 | |
| 279 | 279 | $row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.intval($id)); |
| 280 | 280 | |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | $date_ancienne = $date = $row['date']; |
| 284 | 284 | $champs = array(); |
| 285 | 285 | |
| 286 | - $d = ($date AND isset($c[$champ_date]))?$c[$champ_date]:null; |
|
| 287 | - $s = (isset($desc['field']['statut']) AND isset($c['statut']))?$c['statut']:$statut; |
|
| 286 | + $d = ($date AND isset($c[$champ_date])) ? $c[$champ_date] : null; |
|
| 287 | + $s = (isset($desc['field']['statut']) AND isset($c['statut'])) ? $c['statut'] : $statut; |
|
| 288 | 288 | |
| 289 | 289 | // cf autorisations dans inc/instituer_objet |
| 290 | 290 | if ($s != $statut OR ($d AND $d != $date)) { |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | autoriser('instituer', $objet, $id, null, array('statut'=>$s)) |
| 295 | 295 | ) |
| 296 | 296 | $statut = $champs['statut'] = $s; |
| 297 | - else if ($s!='publie' AND autoriser('modifier', $objet, $id)) |
|
| 297 | + else if ($s != 'publie' AND autoriser('modifier', $objet, $id)) |
|
| 298 | 298 | $statut = $champs['statut'] = $s; |
| 299 | 299 | else |
| 300 | - spip_log("editer_objet $id refus " . join(' ', $c)); |
|
| 300 | + spip_log("editer_objet $id refus ".join(' ', $c)); |
|
| 301 | 301 | |
| 302 | 302 | // En cas de publication, fixer la date a "maintenant" |
| 303 | 303 | // sauf si $c commande autre chose |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | OR ($champs['statut'] == 'prop' AND !in_array($statut_ancien, array('publie', 'prop'))) |
| 309 | 309 | OR $d |
| 310 | 310 | ) { |
| 311 | - if ($d OR strtotime($d=$date)>time()) |
|
| 311 | + if ($d OR strtotime($d = $date) > time()) |
|
| 312 | 312 | $champs[$champ_date] = $date = $d; |
| 313 | 313 | else |
| 314 | 314 | $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | * @param bool $cond |
| 403 | 403 | * @return |
| 404 | 404 | */ |
| 405 | -function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond=true) { |
|
| 405 | +function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond = true) { |
|
| 406 | 406 | $table_sql = table_objet_sql($objet); |
| 407 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 407 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 408 | 408 | $desc = $trouver_table($table_sql); |
| 409 | 409 | |
| 410 | 410 | // Si on deplace l'objet |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $champs['id_secteur'] = $row_rub['id_secteur']; |
| 419 | 419 | |
| 420 | 420 | if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) |
| 421 | - if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 421 | + if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue))) { |
|
| 422 | 422 | $champs['lang'] = $langue; |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Point d'entree d'edition d'un objet |
@@ -39,8 +41,9 @@ discard block |
||
| 39 | 41 | $id = objet_inserer($objet, $id_parent); |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | - if (!($id = intval($id))>0) |
|
| 43 | - return array($id,_L('echec enregistrement en base')); |
|
| 44 | + if (!($id = intval($id))>0) { |
|
| 45 | + return array($id,_L('echec enregistrement en base')); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Enregistre l'envoi dans la BD |
| 46 | 49 | $err = objet_modifier($objet, $id, $set); |
@@ -59,8 +62,9 @@ discard block |
||
| 59 | 62 | */ |
| 60 | 63 | function objet_modifier($objet, $id, $set=null) { |
| 61 | 64 | if (include_spip('action/editer_'.$objet) |
| 62 | - AND function_exists($modifier = $objet."_modifier")) |
|
| 63 | - return $modifier($id,$set); |
|
| 65 | + AND function_exists($modifier = $objet."_modifier")) { |
|
| 66 | + return $modifier($id,$set); |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | $table_sql = table_objet_sql($objet); |
| 66 | 70 | $trouver_table = charger_fonction('trouver_table','base'); |
@@ -72,10 +76,11 @@ discard block |
||
| 72 | 76 | include_spip('inc/modifier'); |
| 73 | 77 | |
| 74 | 78 | $champ_date = ''; |
| 75 | - if (isset($desc['date']) AND $desc['date']) |
|
| 76 | - $champ_date = $desc['date']; |
|
| 77 | - elseif (isset($desc['field']['date'])) |
|
| 78 | - $champ_date = 'date'; |
|
| 79 | + if (isset($desc['date']) AND $desc['date']) { |
|
| 80 | + $champ_date = $desc['date']; |
|
| 81 | + } elseif (isset($desc['field']['date'])) { |
|
| 82 | + $champ_date = 'date'; |
|
| 83 | + } |
|
| 79 | 84 | |
| 80 | 85 | $white = array_keys($desc['field']); |
| 81 | 86 | // on ne traite pas la cle primaire par defaut, notamment car |
@@ -98,8 +103,7 @@ discard block |
||
| 98 | 103 | if (objet_test_si_publie($objet,$id)){ |
| 99 | 104 | $invalideur = "id='$objet/$id'"; |
| 100 | 105 | $indexation = true; |
| 101 | - } |
|
| 102 | - else { |
|
| 106 | + } else { |
|
| 103 | 107 | $invalideur = ""; |
| 104 | 108 | $indexation = false; |
| 105 | 109 | } |
@@ -113,8 +117,9 @@ discard block |
||
| 113 | 117 | // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
| 114 | 118 | 'date_modif' => (isset($desc['field']['date_modif'])?'date_modif':'') |
| 115 | 119 | ), |
| 116 | - $c)) |
|
| 117 | - return $err; |
|
| 120 | + $c)) { |
|
| 121 | + return $err; |
|
| 122 | + } |
|
| 118 | 123 | |
| 119 | 124 | // Modification de statut, changement de rubrique ? |
| 120 | 125 | // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
@@ -134,14 +139,16 @@ discard block |
||
| 134 | 139 | */ |
| 135 | 140 | function objet_inserer($objet, $id_parent=null, $set=null) { |
| 136 | 141 | if (include_spip('action/editer_'.$objet) |
| 137 | - AND function_exists($inserer = $objet."_inserer")) |
|
| 138 | - return $inserer($id_parent); |
|
| 142 | + AND function_exists($inserer = $objet."_inserer")) { |
|
| 143 | + return $inserer($id_parent); |
|
| 144 | + } |
|
| 139 | 145 | |
| 140 | 146 | $table_sql = table_objet_sql($objet); |
| 141 | 147 | $trouver_table = charger_fonction('trouver_table','base'); |
| 142 | 148 | $desc = $trouver_table($table_sql); |
| 143 | - if (!$desc OR !isset($desc['field'])) |
|
| 144 | - return 0; |
|
| 149 | + if (!$desc OR !isset($desc['field'])) { |
|
| 150 | + return 0; |
|
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $lang_rub = ""; |
| 147 | 154 | $champs = array(); |
@@ -151,13 +158,14 @@ discard block |
||
| 151 | 158 | if (!$id_rubrique = intval($id_parent)) { |
| 152 | 159 | $row = sql_fetsel("id_rubrique, id_secteur, lang", "spip_rubriques", "id_parent=0",'', '0+titre,titre', "1"); |
| 153 | 160 | $id_rubrique = $row['id_rubrique']; |
| 161 | + } else { |
|
| 162 | + $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 154 | 163 | } |
| 155 | - else |
|
| 156 | - $row = sql_fetsel("lang, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 157 | 164 | |
| 158 | 165 | $champs['id_rubrique'] = $id_rubrique; |
| 159 | - if (isset($desc['field']['id_secteur'])) |
|
| 160 | - $champs['id_secteur'] = $row['id_secteur']; |
|
| 166 | + if (isset($desc['field']['id_secteur'])) { |
|
| 167 | + $champs['id_secteur'] = $row['id_secteur']; |
|
| 168 | + } |
|
| 161 | 169 | $lang_rub = $row['lang']; |
| 162 | 170 | } |
| 163 | 171 | |
@@ -170,11 +178,11 @@ discard block |
||
| 170 | 178 | if (in_array($GLOBALS['spip_lang'], |
| 171 | 179 | explode(',', $GLOBALS['meta']['langues_multilingue']))) { |
| 172 | 180 | $champs['lang'] = $GLOBALS['spip_lang']; |
| 173 | - if (isset($desc['field']['langue_choisie'])) |
|
| 174 | - $champs['langue_choisie'] = 'oui'; |
|
| 181 | + if (isset($desc['field']['langue_choisie'])) { |
|
| 182 | + $champs['langue_choisie'] = 'oui'; |
|
| 183 | + } |
|
| 175 | 184 | } |
| 176 | - } |
|
| 177 | - elseif (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) { |
|
| 185 | + } elseif (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) { |
|
| 178 | 186 | $champs['lang'] = ($lang_rub ? $lang_rub : $GLOBALS['meta']['langue_site']); |
| 179 | 187 | $champs['langue_choisie'] = 'non'; |
| 180 | 188 | } |
@@ -183,17 +191,19 @@ discard block |
||
| 183 | 191 | if (isset($desc['statut_textes_instituer'])){ |
| 184 | 192 | $cles_statut = array_keys($desc['statut_textes_instituer']); |
| 185 | 193 | $champs['statut'] = reset($cles_statut); |
| 194 | + } else { |
|
| 195 | + $champs['statut'] = 'prepa'; |
|
| 186 | 196 | } |
| 187 | - else |
|
| 188 | - $champs['statut'] = 'prepa'; |
|
| 189 | 197 | } |
| 190 | 198 | |
| 191 | 199 | |
| 192 | - if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date'])) |
|
| 193 | - $champs[$d] = date('Y-m-d H:i:s'); |
|
| 200 | + if ((isset($desc['date']) AND $d=$desc['date']) OR isset($desc['field'][$d='date'])) { |
|
| 201 | + $champs[$d] = date('Y-m-d H:i:s'); |
|
| 202 | + } |
|
| 194 | 203 | |
| 195 | - if ($set) |
|
| 196 | - $champs = array_merge($champs, $set); |
|
| 204 | + if ($set) { |
|
| 205 | + $champs = array_merge($champs, $set); |
|
| 206 | + } |
|
| 197 | 207 | |
| 198 | 208 | // Envoyer aux plugins |
| 199 | 209 | $champs = pipeline('pre_insertion', |
@@ -251,14 +261,16 @@ discard block |
||
| 251 | 261 | */ |
| 252 | 262 | function objet_instituer($objet, $id, $c, $calcul_rub=true) { |
| 253 | 263 | if (include_spip('action/editer_'.$objet) |
| 254 | - AND function_exists($instituer = $objet."_instituer")) |
|
| 255 | - return $instituer($id,$c,$calcul_rub); |
|
| 264 | + AND function_exists($instituer = $objet."_instituer")) { |
|
| 265 | + return $instituer($id,$c,$calcul_rub); |
|
| 266 | + } |
|
| 256 | 267 | |
| 257 | 268 | $table_sql = table_objet_sql($objet); |
| 258 | 269 | $trouver_table = charger_fonction('trouver_table','base'); |
| 259 | 270 | $desc = $trouver_table($table_sql); |
| 260 | - if (!$desc OR !isset($desc['field'])) |
|
| 261 | - return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 271 | + if (!$desc OR !isset($desc['field'])) { |
|
| 272 | + return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 273 | + } |
|
| 262 | 274 | |
| 263 | 275 | include_spip('inc/autoriser'); |
| 264 | 276 | include_spip('inc/rubriques'); |
@@ -268,10 +280,11 @@ discard block |
||
| 268 | 280 | $sel[] = (isset($desc['field']['statut'])?"statut":"'' as statut"); |
| 269 | 281 | |
| 270 | 282 | $champ_date = ''; |
| 271 | - if (isset($desc['date']) AND $desc['date']) |
|
| 272 | - $champ_date = $desc['date']; |
|
| 273 | - elseif (isset($desc['field']['date'])) |
|
| 274 | - $champ_date = 'date'; |
|
| 283 | + if (isset($desc['date']) AND $desc['date']) { |
|
| 284 | + $champ_date = $desc['date']; |
|
| 285 | + } elseif (isset($desc['field']['date'])) { |
|
| 286 | + $champ_date = 'date'; |
|
| 287 | + } |
|
| 275 | 288 | |
| 276 | 289 | $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
| 277 | 290 | $sel[] = (isset($desc['field']['id_rubrique'])?'id_rubrique':"0 as id_rubrique"); |
@@ -292,12 +305,13 @@ discard block |
||
| 292 | 305 | autoriser('publierdans', 'rubrique', $id_rubrique) |
| 293 | 306 | : |
| 294 | 307 | autoriser('instituer', $objet, $id, null, array('statut'=>$s)) |
| 295 | - ) |
|
| 296 | - $statut = $champs['statut'] = $s; |
|
| 297 | - else if ($s!='publie' AND autoriser('modifier', $objet, $id)) |
|
| 298 | - $statut = $champs['statut'] = $s; |
|
| 299 | - else |
|
| 300 | - spip_log("editer_objet $id refus " . join(' ', $c)); |
|
| 308 | + ) { |
|
| 309 | + $statut = $champs['statut'] = $s; |
|
| 310 | + } else if ($s!='publie' AND autoriser('modifier', $objet, $id)) { |
|
| 311 | + $statut = $champs['statut'] = $s; |
|
| 312 | + } else { |
|
| 313 | + spip_log("editer_objet $id refus " . join(' ', $c)); |
|
| 314 | + } |
|
| 301 | 315 | |
| 302 | 316 | // En cas de publication, fixer la date a "maintenant" |
| 303 | 317 | // sauf si $c commande autre chose |
@@ -308,10 +322,11 @@ discard block |
||
| 308 | 322 | OR ($champs['statut'] == 'prop' AND !in_array($statut_ancien, array('publie', 'prop'))) |
| 309 | 323 | OR $d |
| 310 | 324 | ) { |
| 311 | - if ($d OR strtotime($d=$date)>time()) |
|
| 312 | - $champs[$champ_date] = $date = $d; |
|
| 313 | - else |
|
| 314 | - $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
|
| 325 | + if ($d OR strtotime($d=$date)>time()) { |
|
| 326 | + $champs[$champ_date] = $date = $d; |
|
| 327 | + } else { |
|
| 328 | + $champs[$champ_date] = $date = date('Y-m-d H:i:s'); |
|
| 329 | + } |
|
| 315 | 330 | } |
| 316 | 331 | } |
| 317 | 332 | } |
@@ -328,8 +343,9 @@ discard block |
||
| 328 | 343 | // et que le demandeur n'est pas admin de la rubrique |
| 329 | 344 | // repasser l'objet en statut 'propose'. |
| 330 | 345 | if ($statut == 'publie' |
| 331 | - AND !autoriser('publierdans', 'rubrique', $id_rubrique)) |
|
| 332 | - $champs['statut'] = 'prop'; |
|
| 346 | + AND !autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 347 | + $champs['statut'] = 'prop'; |
|
| 348 | + } |
|
| 333 | 349 | } |
| 334 | 350 | |
| 335 | 351 | |
@@ -348,7 +364,9 @@ discard block |
||
| 348 | 364 | ) |
| 349 | 365 | ); |
| 350 | 366 | |
| 351 | - if (!count($champs)) return ''; |
|
| 367 | + if (!count($champs)) { |
|
| 368 | + return ''; |
|
| 369 | + } |
|
| 352 | 370 | |
| 353 | 371 | // Envoyer les modifs. |
| 354 | 372 | objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
@@ -414,16 +432,20 @@ discard block |
||
| 414 | 432 | $row_rub = sql_fetsel("id_secteur, lang", "spip_rubriques", "id_rubrique=".sql_quote($champs['id_rubrique'])); |
| 415 | 433 | $langue = $row_rub['lang']; |
| 416 | 434 | |
| 417 | - if (isset($desc['field']['id_secteur'])) |
|
| 418 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 435 | + if (isset($desc['field']['id_secteur'])) { |
|
| 436 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 437 | + } |
|
| 419 | 438 | |
| 420 | - if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) |
|
| 421 | - if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 439 | + if (isset($desc['field']['lang']) AND isset($desc['field']['langue_choisie'])) { |
|
| 440 | + if (sql_fetsel('1', $table_sql, id_table_objet($objet)."=".intval($id)." AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue))) { |
|
| 422 | 441 | $champs['lang'] = $langue; |
| 442 | + } |
|
| 423 | 443 | } |
| 424 | 444 | } |
| 425 | 445 | |
| 426 | - if (!$champs) return; |
|
| 446 | + if (!$champs) { |
|
| 447 | + return; |
|
| 448 | + } |
|
| 427 | 449 | sql_updateq($table_sql, $champs, id_table_objet($objet).'='.intval($id)); |
| 428 | 450 | |
| 429 | 451 | // Changer le statut des rubriques concernees |