@@ -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 | ?> |
@@ -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']){ |
@@ -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 | } |
@@ -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 | |
@@ -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 |
@@ -30,62 +30,62 @@ discard block |
||
| 30 | 30 | * @return array|string |
| 31 | 31 | */ |
| 32 | 32 | function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = array()){ |
| 33 | - if (!is_array($options)) |
|
| 34 | - $options = array('id'=>$options); |
|
| 35 | - |
|
| 36 | - if (function_exists('test_inscription')) |
|
| 37 | - $f = 'test_inscription'; |
|
| 38 | - else $f = 'test_inscription_dist'; |
|
| 39 | - $desc = $f($statut, $mail_complet, $nom, $options); |
|
| 40 | - |
|
| 41 | - // erreur ? |
|
| 42 | - if (!is_array($desc)) |
|
| 43 | - return _T($desc); |
|
| 44 | - |
|
| 45 | - include_spip('base/abstract_sql'); |
|
| 46 | - $res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email'])); |
|
| 47 | - // erreur ? |
|
| 48 | - if (!$res) |
|
| 49 | - return _T('titre_probleme_technique'); |
|
| 50 | - |
|
| 51 | - $row = sql_fetch($res); |
|
| 52 | - sql_free($res); |
|
| 53 | - if ($row){ |
|
| 54 | - if (isset($options['force_nouveau']) AND $options['force_nouveau']==true){ |
|
| 55 | - $desc['id_auteur'] = $row['id_auteur']; |
|
| 56 | - $desc = inscription_nouveau($desc); |
|
| 57 | - } |
|
| 58 | - else |
|
| 59 | - $desc = $row; |
|
| 60 | - } |
|
| 61 | - else |
|
| 62 | - // s'il n'existe pas deja, creer les identifiants |
|
| 63 | - $desc = inscription_nouveau($desc); |
|
| 64 | - |
|
| 65 | - // erreur ? |
|
| 66 | - if (!is_array($desc)) |
|
| 67 | - return $desc; |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - // generer le mot de passe (ou le refaire si compte inutilise) |
|
| 71 | - $desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']); |
|
| 72 | - |
|
| 73 | - // attribuer un jeton pour confirmation par clic sur un lien |
|
| 74 | - $desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']); |
|
| 75 | - |
|
| 76 | - // charger de suite cette fonction, pour ses utilitaires |
|
| 77 | - $envoyer_inscription = charger_fonction("envoyer_inscription",""); |
|
| 78 | - list($sujet,$msg,$from,$head) = $envoyer_inscription($desc, $nom, $statut, $options); |
|
| 79 | - |
|
| 80 | - $notifications = charger_fonction('notifications', 'inc'); |
|
| 81 | - notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head); |
|
| 82 | - |
|
| 83 | - // Notifications |
|
| 84 | - $notifications('inscription', $desc['id_auteur'], |
|
| 85 | - array('nom' => $desc['nom'], 'email' => $desc['email']) |
|
| 86 | - ); |
|
| 87 | - |
|
| 88 | - return $desc; |
|
| 33 | + if (!is_array($options)) |
|
| 34 | + $options = array('id'=>$options); |
|
| 35 | + |
|
| 36 | + if (function_exists('test_inscription')) |
|
| 37 | + $f = 'test_inscription'; |
|
| 38 | + else $f = 'test_inscription_dist'; |
|
| 39 | + $desc = $f($statut, $mail_complet, $nom, $options); |
|
| 40 | + |
|
| 41 | + // erreur ? |
|
| 42 | + if (!is_array($desc)) |
|
| 43 | + return _T($desc); |
|
| 44 | + |
|
| 45 | + include_spip('base/abstract_sql'); |
|
| 46 | + $res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email'])); |
|
| 47 | + // erreur ? |
|
| 48 | + if (!$res) |
|
| 49 | + return _T('titre_probleme_technique'); |
|
| 50 | + |
|
| 51 | + $row = sql_fetch($res); |
|
| 52 | + sql_free($res); |
|
| 53 | + if ($row){ |
|
| 54 | + if (isset($options['force_nouveau']) AND $options['force_nouveau']==true){ |
|
| 55 | + $desc['id_auteur'] = $row['id_auteur']; |
|
| 56 | + $desc = inscription_nouveau($desc); |
|
| 57 | + } |
|
| 58 | + else |
|
| 59 | + $desc = $row; |
|
| 60 | + } |
|
| 61 | + else |
|
| 62 | + // s'il n'existe pas deja, creer les identifiants |
|
| 63 | + $desc = inscription_nouveau($desc); |
|
| 64 | + |
|
| 65 | + // erreur ? |
|
| 66 | + if (!is_array($desc)) |
|
| 67 | + return $desc; |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + // generer le mot de passe (ou le refaire si compte inutilise) |
|
| 71 | + $desc['pass'] = creer_pass_pour_auteur($desc['id_auteur']); |
|
| 72 | + |
|
| 73 | + // attribuer un jeton pour confirmation par clic sur un lien |
|
| 74 | + $desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']); |
|
| 75 | + |
|
| 76 | + // charger de suite cette fonction, pour ses utilitaires |
|
| 77 | + $envoyer_inscription = charger_fonction("envoyer_inscription",""); |
|
| 78 | + list($sujet,$msg,$from,$head) = $envoyer_inscription($desc, $nom, $statut, $options); |
|
| 79 | + |
|
| 80 | + $notifications = charger_fonction('notifications', 'inc'); |
|
| 81 | + notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head); |
|
| 82 | + |
|
| 83 | + // Notifications |
|
| 84 | + $notifications('inscription', $desc['id_auteur'], |
|
| 85 | + array('nom' => $desc['nom'], 'email' => $desc['email']) |
|
| 86 | + ); |
|
| 87 | + |
|
| 88 | + return $desc; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
@@ -107,18 +107,18 @@ discard block |
||
| 107 | 107 | * @return array|string |
| 108 | 108 | */ |
| 109 | 109 | function test_inscription_dist($statut, $mail, $nom, $options) { |
| 110 | - include_spip('inc/filtres'); |
|
| 111 | - if (!$r = email_valide($mail)) return 'info_email_invalide'; |
|
| 112 | - $nom = trim(corriger_caracteres($nom)); |
|
| 113 | - $res = array('email' => $r, 'nom' => $nom, 'prefs' => $statut); |
|
| 114 | - if (isset($options['login'])) { |
|
| 115 | - $login = trim(corriger_caracteres($options['login'])); |
|
| 116 | - if((strlen ($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64)) |
|
| 117 | - $res['login'] = $login; |
|
| 118 | - } |
|
| 119 | - if(!isset($res['login']) AND ((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64))) |
|
| 120 | - return 'ecrire:info_login_trop_court'; |
|
| 121 | - return $res; |
|
| 110 | + include_spip('inc/filtres'); |
|
| 111 | + if (!$r = email_valide($mail)) return 'info_email_invalide'; |
|
| 112 | + $nom = trim(corriger_caracteres($nom)); |
|
| 113 | + $res = array('email' => $r, 'nom' => $nom, 'prefs' => $statut); |
|
| 114 | + if (isset($options['login'])) { |
|
| 115 | + $login = trim(corriger_caracteres($options['login'])); |
|
| 116 | + if((strlen ($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64)) |
|
| 117 | + $res['login'] = $login; |
|
| 118 | + } |
|
| 119 | + if(!isset($res['login']) AND ((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64))) |
|
| 120 | + return 'ecrire:info_login_trop_court'; |
|
| 121 | + return $res; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
@@ -134,27 +134,27 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | function inscription_nouveau($desc) |
| 136 | 136 | { |
| 137 | - if (!isset($desc['login']) OR !strlen($desc['login'])) |
|
| 138 | - $desc['login'] = test_login($desc['nom'], $desc['email']); |
|
| 137 | + if (!isset($desc['login']) OR !strlen($desc['login'])) |
|
| 138 | + $desc['login'] = test_login($desc['nom'], $desc['email']); |
|
| 139 | 139 | |
| 140 | - $desc['statut'] = 'nouveau'; |
|
| 141 | - include_spip('action/editer_auteur'); |
|
| 142 | - if (isset($desc['id_auteur'])) |
|
| 143 | - $id_auteur = $desc['id_auteur']; |
|
| 144 | - else |
|
| 145 | - $id_auteur = auteur_inserer(); |
|
| 140 | + $desc['statut'] = 'nouveau'; |
|
| 141 | + include_spip('action/editer_auteur'); |
|
| 142 | + if (isset($desc['id_auteur'])) |
|
| 143 | + $id_auteur = $desc['id_auteur']; |
|
| 144 | + else |
|
| 145 | + $id_auteur = auteur_inserer(); |
|
| 146 | 146 | |
| 147 | - if (!$id_auteur) return _T('titre_probleme_technique'); |
|
| 147 | + if (!$id_auteur) return _T('titre_probleme_technique'); |
|
| 148 | 148 | |
| 149 | - include_spip('inc/autoriser'); |
|
| 150 | - // lever l'autorisation pour pouvoir modifier le statut |
|
| 151 | - autoriser_exception('modifier','auteur',$id_auteur); |
|
| 152 | - auteur_modifier($id_auteur, $desc); |
|
| 153 | - autoriser_exception('modifier','auteur',$id_auteur,false); |
|
| 149 | + include_spip('inc/autoriser'); |
|
| 150 | + // lever l'autorisation pour pouvoir modifier le statut |
|
| 151 | + autoriser_exception('modifier','auteur',$id_auteur); |
|
| 152 | + auteur_modifier($id_auteur, $desc); |
|
| 153 | + autoriser_exception('modifier','auteur',$id_auteur,false); |
|
| 154 | 154 | |
| 155 | - $desc['id_auteur'] = $id_auteur; |
|
| 155 | + $desc['id_auteur'] = $id_auteur; |
|
| 156 | 156 | |
| 157 | - return $desc; |
|
| 157 | + return $desc; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -166,26 +166,26 @@ discard block |
||
| 166 | 166 | * @return string |
| 167 | 167 | */ |
| 168 | 168 | function test_login($nom, $mail) { |
| 169 | - include_spip('inc/charsets'); |
|
| 170 | - $nom = strtolower(translitteration($nom)); |
|
| 171 | - $login_base = preg_replace("/[^\w\d_]/", "_", $nom); |
|
| 172 | - |
|
| 173 | - // il faut eviter que le login soit vraiment trop court |
|
| 174 | - if (strlen($login_base) < 3) { |
|
| 175 | - $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); |
|
| 176 | - $login_base = preg_replace("/[^\w\d]/", "_", $mail); |
|
| 177 | - } |
|
| 178 | - if (strlen($login_base) < 3) |
|
| 179 | - $login_base = 'user'; |
|
| 180 | - |
|
| 181 | - $login = $login_base; |
|
| 182 | - |
|
| 183 | - for ($i = 1; ; $i++) { |
|
| 184 | - if (!sql_countsel('spip_auteurs', "login='$login'")) |
|
| 185 | - return $login; |
|
| 186 | - $login = $login_base.$i; |
|
| 187 | - } |
|
| 188 | - return $login; |
|
| 169 | + include_spip('inc/charsets'); |
|
| 170 | + $nom = strtolower(translitteration($nom)); |
|
| 171 | + $login_base = preg_replace("/[^\w\d_]/", "_", $nom); |
|
| 172 | + |
|
| 173 | + // il faut eviter que le login soit vraiment trop court |
|
| 174 | + if (strlen($login_base) < 3) { |
|
| 175 | + $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); |
|
| 176 | + $login_base = preg_replace("/[^\w\d]/", "_", $mail); |
|
| 177 | + } |
|
| 178 | + if (strlen($login_base) < 3) |
|
| 179 | + $login_base = 'user'; |
|
| 180 | + |
|
| 181 | + $login = $login_base; |
|
| 182 | + |
|
| 183 | + for ($i = 1; ; $i++) { |
|
| 184 | + if (!sql_countsel('spip_auteurs', "login='$login'")) |
|
| 185 | + return $login; |
|
| 186 | + $login = $login_base.$i; |
|
| 187 | + } |
|
| 188 | + return $login; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -204,21 +204,21 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | function envoyer_inscription_dist($desc, $nom, $mode, $options=array()) { |
| 206 | 206 | |
| 207 | - $contexte = array_merge($desc,$options); |
|
| 208 | - $contexte['nom'] = $nom; |
|
| 209 | - $contexte['mode'] = $mode; |
|
| 210 | - $contexte['url_confirm'] = generer_url_action('confirmer_inscription','',true,true); |
|
| 211 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'email',$desc['email']); |
|
| 212 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'jeton',$desc['jeton']); |
|
| 213 | - |
|
| 214 | - $modele_mail = 'modeles/mail_inscription'; |
|
| 215 | - if (isset($options['modele_mail']) and $options['modele_mail']){ |
|
| 216 | - $modele_mail = $options['modele_mail']; |
|
| 217 | - } |
|
| 218 | - $message = recuperer_fond($modele_mail, $contexte); |
|
| 219 | - $from = (isset($options['from']) ? $options['from'] : null); |
|
| 220 | - $head = null; |
|
| 221 | - return array("", $message,$from,$head); |
|
| 207 | + $contexte = array_merge($desc,$options); |
|
| 208 | + $contexte['nom'] = $nom; |
|
| 209 | + $contexte['mode'] = $mode; |
|
| 210 | + $contexte['url_confirm'] = generer_url_action('confirmer_inscription','',true,true); |
|
| 211 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'email',$desc['email']); |
|
| 212 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'jeton',$desc['jeton']); |
|
| 213 | + |
|
| 214 | + $modele_mail = 'modeles/mail_inscription'; |
|
| 215 | + if (isset($options['modele_mail']) and $options['modele_mail']){ |
|
| 216 | + $modele_mail = $options['modele_mail']; |
|
| 217 | + } |
|
| 218 | + $message = recuperer_fond($modele_mail, $contexte); |
|
| 219 | + $from = (isset($options['from']) ? $options['from'] : null); |
|
| 220 | + $head = null; |
|
| 221 | + return array("", $message,$from,$head); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | 233 | function creer_pass_pour_auteur($id_auteur) { |
| 234 | - include_spip('inc/acces'); |
|
| 235 | - $pass = creer_pass_aleatoire(8, $id_auteur); |
|
| 236 | - include_spip('action/editer_auteur'); |
|
| 237 | - auteur_instituer($id_auteur, array('pass'=>$pass)); |
|
| 238 | - return $pass; |
|
| 234 | + include_spip('inc/acces'); |
|
| 235 | + $pass = creer_pass_aleatoire(8, $id_auteur); |
|
| 236 | + include_spip('action/editer_auteur'); |
|
| 237 | + auteur_instituer($id_auteur, array('pass'=>$pass)); |
|
| 238 | + return $pass; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -248,15 +248,15 @@ discard block |
||
| 248 | 248 | * @return string |
| 249 | 249 | */ |
| 250 | 250 | function tester_statut_inscription($statut_tmp, $id){ |
| 251 | - include_spip('inc/autoriser'); |
|
| 252 | - if ($statut_tmp) |
|
| 253 | - return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
|
| 254 | - elseif ( |
|
| 255 | - autoriser('inscrireauteur', $statut_tmp = "1comite", $id) |
|
| 256 | - OR autoriser('inscrireauteur', $statut_tmp = "6forum", $id)) |
|
| 257 | - return $statut_tmp; |
|
| 258 | - |
|
| 259 | - return ''; |
|
| 251 | + include_spip('inc/autoriser'); |
|
| 252 | + if ($statut_tmp) |
|
| 253 | + return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
|
| 254 | + elseif ( |
|
| 255 | + autoriser('inscrireauteur', $statut_tmp = "1comite", $id) |
|
| 256 | + OR autoriser('inscrireauteur', $statut_tmp = "6forum", $id)) |
|
| 257 | + return $statut_tmp; |
|
| 258 | + |
|
| 259 | + return ''; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | |
@@ -272,27 +272,27 @@ discard block |
||
| 272 | 272 | * @return array |
| 273 | 273 | */ |
| 274 | 274 | function confirmer_statut_inscription($auteur){ |
| 275 | - // securite |
|
| 276 | - if ($auteur['statut'] != 'nouveau') return $auteur; |
|
| 277 | - |
|
| 278 | - include_spip('inc/autoriser'); |
|
| 279 | - if (!autoriser('inscrireauteur', $auteur['prefs'])) |
|
| 280 | - return $auteur; |
|
| 281 | - $s = $auteur['prefs']; |
|
| 282 | - |
|
| 283 | - include_spip('inc/autoriser'); |
|
| 284 | - // accorder l'autorisation de modif du statut auteur |
|
| 285 | - autoriser_exception('modifier','auteur',$auteur['id_auteur']); |
|
| 286 | - include_spip('action/editer_auteur'); |
|
| 287 | - // changer le statut |
|
| 288 | - auteur_modifier($auteur['id_auteur'],array('statut'=> $s)); |
|
| 289 | - unset($_COOKIE['spip_session']); // forcer la maj de la session |
|
| 290 | - // lever l'autorisation de modif du statut auteur |
|
| 291 | - autoriser_exception('modifier','auteur',$auteur['id_auteur'],false); |
|
| 292 | - |
|
| 293 | - // mettre a jour le statut |
|
| 294 | - $auteur['statut'] = $s; |
|
| 295 | - return $auteur; |
|
| 275 | + // securite |
|
| 276 | + if ($auteur['statut'] != 'nouveau') return $auteur; |
|
| 277 | + |
|
| 278 | + include_spip('inc/autoriser'); |
|
| 279 | + if (!autoriser('inscrireauteur', $auteur['prefs'])) |
|
| 280 | + return $auteur; |
|
| 281 | + $s = $auteur['prefs']; |
|
| 282 | + |
|
| 283 | + include_spip('inc/autoriser'); |
|
| 284 | + // accorder l'autorisation de modif du statut auteur |
|
| 285 | + autoriser_exception('modifier','auteur',$auteur['id_auteur']); |
|
| 286 | + include_spip('action/editer_auteur'); |
|
| 287 | + // changer le statut |
|
| 288 | + auteur_modifier($auteur['id_auteur'],array('statut'=> $s)); |
|
| 289 | + unset($_COOKIE['spip_session']); // forcer la maj de la session |
|
| 290 | + // lever l'autorisation de modif du statut auteur |
|
| 291 | + autoriser_exception('modifier','auteur',$auteur['id_auteur'],false); |
|
| 292 | + |
|
| 293 | + // mettre a jour le statut |
|
| 294 | + $auteur['statut'] = $s; |
|
| 295 | + return $auteur; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -303,14 +303,14 @@ discard block |
||
| 303 | 303 | * @return string |
| 304 | 304 | */ |
| 305 | 305 | function auteur_attribuer_jeton($id_auteur){ |
| 306 | - include_spip('inc/acces'); |
|
| 307 | - // s'assurer de l'unicite du jeton pour le couple (email,cookie) |
|
| 308 | - do { |
|
| 309 | - $jeton = creer_uniqid(); |
|
| 310 | - sql_updateq("spip_auteurs", array("cookie_oubli" => $jeton), "id_auteur=" . intval($id_auteur)); |
|
| 311 | - } |
|
| 312 | - while (sql_countsel("spip_auteurs","cookie_oubli=".sql_quote($jeton))>1); |
|
| 313 | - return $jeton; |
|
| 306 | + include_spip('inc/acces'); |
|
| 307 | + // s'assurer de l'unicite du jeton pour le couple (email,cookie) |
|
| 308 | + do { |
|
| 309 | + $jeton = creer_uniqid(); |
|
| 310 | + sql_updateq("spip_auteurs", array("cookie_oubli" => $jeton), "id_auteur=" . intval($id_auteur)); |
|
| 311 | + } |
|
| 312 | + while (sql_countsel("spip_auteurs","cookie_oubli=".sql_quote($jeton))>1); |
|
| 313 | + return $jeton; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -319,12 +319,12 @@ discard block |
||
| 319 | 319 | * @return array|bool |
| 320 | 320 | */ |
| 321 | 321 | function auteur_verifier_jeton($jeton){ |
| 322 | - // refuser un jeton corrompu |
|
| 323 | - if (preg_match(',[^0-9a-f.],i',$jeton)) |
|
| 324 | - return false; |
|
| 322 | + // refuser un jeton corrompu |
|
| 323 | + if (preg_match(',[^0-9a-f.],i',$jeton)) |
|
| 324 | + return false; |
|
| 325 | 325 | |
| 326 | - $desc = sql_fetsel('*','spip_auteurs',"cookie_oubli=".sql_quote($jeton, $serveur, 'string')); |
|
| 327 | - return $desc; |
|
| 326 | + $desc = sql_fetsel('*','spip_auteurs',"cookie_oubli=".sql_quote($jeton, $serveur, 'string')); |
|
| 327 | + return $desc; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -334,5 +334,5 @@ discard block |
||
| 334 | 334 | * @return bool |
| 335 | 335 | */ |
| 336 | 336 | function auteur_effacer_jeton($id_auteur){ |
| 337 | - return sql_updateq("spip_auteurs", array("cookie_oubli" => ''), "id_auteur=" . intval($id_auteur)); |
|
| 337 | + return sql_updateq("spip_auteurs", array("cookie_oubli" => ''), "id_auteur=" . intval($id_auteur)); |
|
| 338 | 338 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * modele_mail : squelette de mail a utiliser |
| 30 | 30 | * @return array|string |
| 31 | 31 | */ |
| 32 | -function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = array()){ |
|
| 32 | +function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = array()) { |
|
| 33 | 33 | if (!is_array($options)) |
| 34 | 34 | $options = array('id'=>$options); |
| 35 | 35 | |
@@ -43,15 +43,15 @@ discard block |
||
| 43 | 43 | return _T($desc); |
| 44 | 44 | |
| 45 | 45 | include_spip('base/abstract_sql'); |
| 46 | - $res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email'])); |
|
| 46 | + $res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=".sql_quote($desc['email'])); |
|
| 47 | 47 | // erreur ? |
| 48 | 48 | if (!$res) |
| 49 | 49 | return _T('titre_probleme_technique'); |
| 50 | 50 | |
| 51 | 51 | $row = sql_fetch($res); |
| 52 | 52 | sql_free($res); |
| 53 | - if ($row){ |
|
| 54 | - if (isset($options['force_nouveau']) AND $options['force_nouveau']==true){ |
|
| 53 | + if ($row) { |
|
| 54 | + if (isset($options['force_nouveau']) AND $options['force_nouveau'] == true) { |
|
| 55 | 55 | $desc['id_auteur'] = $row['id_auteur']; |
| 56 | 56 | $desc = inscription_nouveau($desc); |
| 57 | 57 | } |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | $desc['jeton'] = auteur_attribuer_jeton($desc['id_auteur']); |
| 75 | 75 | |
| 76 | 76 | // charger de suite cette fonction, pour ses utilitaires |
| 77 | - $envoyer_inscription = charger_fonction("envoyer_inscription",""); |
|
| 78 | - list($sujet,$msg,$from,$head) = $envoyer_inscription($desc, $nom, $statut, $options); |
|
| 77 | + $envoyer_inscription = charger_fonction("envoyer_inscription", ""); |
|
| 78 | + list($sujet, $msg, $from, $head) = $envoyer_inscription($desc, $nom, $statut, $options); |
|
| 79 | 79 | |
| 80 | 80 | $notifications = charger_fonction('notifications', 'inc'); |
| 81 | 81 | notifications_envoyer_mails($mail_complet, $msg, $sujet, $from, $head); |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | $res = array('email' => $r, 'nom' => $nom, 'prefs' => $statut); |
| 114 | 114 | if (isset($options['login'])) { |
| 115 | 115 | $login = trim(corriger_caracteres($options['login'])); |
| 116 | - if((strlen ($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64)) |
|
| 116 | + if ((strlen($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64)) |
|
| 117 | 117 | $res['login'] = $login; |
| 118 | 118 | } |
| 119 | - if(!isset($res['login']) AND ((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64))) |
|
| 119 | + if (!isset($res['login']) AND ((strlen($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64))) |
|
| 120 | 120 | return 'ecrire:info_login_trop_court'; |
| 121 | 121 | return $res; |
| 122 | 122 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | include_spip('inc/autoriser'); |
| 150 | 150 | // lever l'autorisation pour pouvoir modifier le statut |
| 151 | - autoriser_exception('modifier','auteur',$id_auteur); |
|
| 151 | + autoriser_exception('modifier', 'auteur', $id_auteur); |
|
| 152 | 152 | auteur_modifier($id_auteur, $desc); |
| 153 | - autoriser_exception('modifier','auteur',$id_auteur,false); |
|
| 153 | + autoriser_exception('modifier', 'auteur', $id_auteur, false); |
|
| 154 | 154 | |
| 155 | 155 | $desc['id_auteur'] = $id_auteur; |
| 156 | 156 | |
@@ -202,23 +202,23 @@ discard block |
||
| 202 | 202 | * @param array $options |
| 203 | 203 | * @return array |
| 204 | 204 | */ |
| 205 | -function envoyer_inscription_dist($desc, $nom, $mode, $options=array()) { |
|
| 205 | +function envoyer_inscription_dist($desc, $nom, $mode, $options = array()) { |
|
| 206 | 206 | |
| 207 | - $contexte = array_merge($desc,$options); |
|
| 207 | + $contexte = array_merge($desc, $options); |
|
| 208 | 208 | $contexte['nom'] = $nom; |
| 209 | 209 | $contexte['mode'] = $mode; |
| 210 | - $contexte['url_confirm'] = generer_url_action('confirmer_inscription','',true,true); |
|
| 211 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'email',$desc['email']); |
|
| 212 | - $contexte['url_confirm'] = parametre_url($contexte['url_confirm'],'jeton',$desc['jeton']); |
|
| 210 | + $contexte['url_confirm'] = generer_url_action('confirmer_inscription', '', true, true); |
|
| 211 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'email', $desc['email']); |
|
| 212 | + $contexte['url_confirm'] = parametre_url($contexte['url_confirm'], 'jeton', $desc['jeton']); |
|
| 213 | 213 | |
| 214 | 214 | $modele_mail = 'modeles/mail_inscription'; |
| 215 | - if (isset($options['modele_mail']) and $options['modele_mail']){ |
|
| 215 | + if (isset($options['modele_mail']) and $options['modele_mail']) { |
|
| 216 | 216 | $modele_mail = $options['modele_mail']; |
| 217 | 217 | } |
| 218 | 218 | $message = recuperer_fond($modele_mail, $contexte); |
| 219 | 219 | $from = (isset($options['from']) ? $options['from'] : null); |
| 220 | 220 | $head = null; |
| 221 | - return array("", $message,$from,$head); |
|
| 221 | + return array("", $message, $from, $head); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @param int $id |
| 248 | 248 | * @return string |
| 249 | 249 | */ |
| 250 | -function tester_statut_inscription($statut_tmp, $id){ |
|
| 250 | +function tester_statut_inscription($statut_tmp, $id) { |
|
| 251 | 251 | include_spip('inc/autoriser'); |
| 252 | 252 | if ($statut_tmp) |
| 253 | 253 | return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param array $auteur |
| 272 | 272 | * @return array |
| 273 | 273 | */ |
| 274 | -function confirmer_statut_inscription($auteur){ |
|
| 274 | +function confirmer_statut_inscription($auteur) { |
|
| 275 | 275 | // securite |
| 276 | 276 | if ($auteur['statut'] != 'nouveau') return $auteur; |
| 277 | 277 | |
@@ -282,13 +282,13 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | include_spip('inc/autoriser'); |
| 284 | 284 | // accorder l'autorisation de modif du statut auteur |
| 285 | - autoriser_exception('modifier','auteur',$auteur['id_auteur']); |
|
| 285 | + autoriser_exception('modifier', 'auteur', $auteur['id_auteur']); |
|
| 286 | 286 | include_spip('action/editer_auteur'); |
| 287 | 287 | // changer le statut |
| 288 | - auteur_modifier($auteur['id_auteur'],array('statut'=> $s)); |
|
| 288 | + auteur_modifier($auteur['id_auteur'], array('statut'=> $s)); |
|
| 289 | 289 | unset($_COOKIE['spip_session']); // forcer la maj de la session |
| 290 | 290 | // lever l'autorisation de modif du statut auteur |
| 291 | - autoriser_exception('modifier','auteur',$auteur['id_auteur'],false); |
|
| 291 | + autoriser_exception('modifier', 'auteur', $auteur['id_auteur'], false); |
|
| 292 | 292 | |
| 293 | 293 | // mettre a jour le statut |
| 294 | 294 | $auteur['statut'] = $s; |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | * @param int $id_auteur |
| 303 | 303 | * @return string |
| 304 | 304 | */ |
| 305 | -function auteur_attribuer_jeton($id_auteur){ |
|
| 305 | +function auteur_attribuer_jeton($id_auteur) { |
|
| 306 | 306 | include_spip('inc/acces'); |
| 307 | 307 | // s'assurer de l'unicite du jeton pour le couple (email,cookie) |
| 308 | 308 | do { |
| 309 | 309 | $jeton = creer_uniqid(); |
| 310 | - sql_updateq("spip_auteurs", array("cookie_oubli" => $jeton), "id_auteur=" . intval($id_auteur)); |
|
| 310 | + sql_updateq("spip_auteurs", array("cookie_oubli" => $jeton), "id_auteur=".intval($id_auteur)); |
|
| 311 | 311 | } |
| 312 | - while (sql_countsel("spip_auteurs","cookie_oubli=".sql_quote($jeton))>1); |
|
| 312 | + while (sql_countsel("spip_auteurs", "cookie_oubli=".sql_quote($jeton)) > 1); |
|
| 313 | 313 | return $jeton; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | * @param string $jeton |
| 319 | 319 | * @return array|bool |
| 320 | 320 | */ |
| 321 | -function auteur_verifier_jeton($jeton){ |
|
| 321 | +function auteur_verifier_jeton($jeton) { |
|
| 322 | 322 | // refuser un jeton corrompu |
| 323 | - if (preg_match(',[^0-9a-f.],i',$jeton)) |
|
| 323 | + if (preg_match(',[^0-9a-f.],i', $jeton)) |
|
| 324 | 324 | return false; |
| 325 | 325 | |
| 326 | - $desc = sql_fetsel('*','spip_auteurs',"cookie_oubli=".sql_quote($jeton, $serveur, 'string')); |
|
| 326 | + $desc = sql_fetsel('*', 'spip_auteurs', "cookie_oubli=".sql_quote($jeton, $serveur, 'string')); |
|
| 327 | 327 | return $desc; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -333,6 +333,6 @@ discard block |
||
| 333 | 333 | * @param int $id_auteur |
| 334 | 334 | * @return bool |
| 335 | 335 | */ |
| 336 | -function auteur_effacer_jeton($id_auteur){ |
|
| 337 | - return sql_updateq("spip_auteurs", array("cookie_oubli" => ''), "id_auteur=" . intval($id_auteur)); |
|
| 336 | +function auteur_effacer_jeton($id_auteur) { |
|
| 337 | + return sql_updateq("spip_auteurs", array("cookie_oubli" => ''), "id_auteur=".intval($id_auteur)); |
|
| 338 | 338 | } |
@@ -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 | /** |
@@ -30,23 +32,28 @@ discard block |
||
| 30 | 32 | * @return array|string |
| 31 | 33 | */ |
| 32 | 34 | function action_inscrire_auteur_dist($statut, $mail_complet, $nom, $options = array()){ |
| 33 | - if (!is_array($options)) |
|
| 34 | - $options = array('id'=>$options); |
|
| 35 | + if (!is_array($options)) { |
|
| 36 | + $options = array('id'=>$options); |
|
| 37 | + } |
|
| 35 | 38 | |
| 36 | - if (function_exists('test_inscription')) |
|
| 37 | - $f = 'test_inscription'; |
|
| 38 | - else $f = 'test_inscription_dist'; |
|
| 39 | + if (function_exists('test_inscription')) { |
|
| 40 | + $f = 'test_inscription'; |
|
| 41 | + } else { |
|
| 42 | + $f = 'test_inscription_dist'; |
|
| 43 | + } |
|
| 39 | 44 | $desc = $f($statut, $mail_complet, $nom, $options); |
| 40 | 45 | |
| 41 | 46 | // erreur ? |
| 42 | - if (!is_array($desc)) |
|
| 43 | - return _T($desc); |
|
| 47 | + if (!is_array($desc)) { |
|
| 48 | + return _T($desc); |
|
| 49 | + } |
|
| 44 | 50 | |
| 45 | 51 | include_spip('base/abstract_sql'); |
| 46 | 52 | $res = sql_select("statut, id_auteur, login, email", "spip_auteurs", "email=" . sql_quote($desc['email'])); |
| 47 | 53 | // erreur ? |
| 48 | - if (!$res) |
|
| 49 | - return _T('titre_probleme_technique'); |
|
| 54 | + if (!$res) { |
|
| 55 | + return _T('titre_probleme_technique'); |
|
| 56 | + } |
|
| 50 | 57 | |
| 51 | 58 | $row = sql_fetch($res); |
| 52 | 59 | sql_free($res); |
@@ -54,17 +61,18 @@ discard block |
||
| 54 | 61 | if (isset($options['force_nouveau']) AND $options['force_nouveau']==true){ |
| 55 | 62 | $desc['id_auteur'] = $row['id_auteur']; |
| 56 | 63 | $desc = inscription_nouveau($desc); |
| 64 | + } else { |
|
| 65 | + $desc = $row; |
|
| 57 | 66 | } |
| 58 | - else |
|
| 59 | - $desc = $row; |
|
| 60 | - } |
|
| 61 | - else |
|
| 62 | - // s'il n'existe pas deja, creer les identifiants |
|
| 67 | + } else { |
|
| 68 | + // s'il n'existe pas deja, creer les identifiants |
|
| 63 | 69 | $desc = inscription_nouveau($desc); |
| 70 | + } |
|
| 64 | 71 | |
| 65 | 72 | // erreur ? |
| 66 | - if (!is_array($desc)) |
|
| 67 | - return $desc; |
|
| 73 | + if (!is_array($desc)) { |
|
| 74 | + return $desc; |
|
| 75 | + } |
|
| 68 | 76 | |
| 69 | 77 | |
| 70 | 78 | // generer le mot de passe (ou le refaire si compte inutilise) |
@@ -108,16 +116,20 @@ discard block |
||
| 108 | 116 | */ |
| 109 | 117 | function test_inscription_dist($statut, $mail, $nom, $options) { |
| 110 | 118 | include_spip('inc/filtres'); |
| 111 | - if (!$r = email_valide($mail)) return 'info_email_invalide'; |
|
| 119 | + if (!$r = email_valide($mail)) { |
|
| 120 | + return 'info_email_invalide'; |
|
| 121 | + } |
|
| 112 | 122 | $nom = trim(corriger_caracteres($nom)); |
| 113 | 123 | $res = array('email' => $r, 'nom' => $nom, 'prefs' => $statut); |
| 114 | 124 | if (isset($options['login'])) { |
| 115 | 125 | $login = trim(corriger_caracteres($options['login'])); |
| 116 | - if((strlen ($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64)) |
|
| 117 | - $res['login'] = $login; |
|
| 126 | + if((strlen ($login) >= _LOGIN_TROP_COURT) AND (strlen($nom) <= 64)) { |
|
| 127 | + $res['login'] = $login; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + if(!isset($res['login']) AND ((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64))) { |
|
| 131 | + return 'ecrire:info_login_trop_court'; |
|
| 118 | 132 | } |
| 119 | - if(!isset($res['login']) AND ((strlen ($nom) < _LOGIN_TROP_COURT) OR (strlen($nom) > 64))) |
|
| 120 | - return 'ecrire:info_login_trop_court'; |
|
| 121 | 133 | return $res; |
| 122 | 134 | } |
| 123 | 135 | |
@@ -134,17 +146,21 @@ discard block |
||
| 134 | 146 | */ |
| 135 | 147 | function inscription_nouveau($desc) |
| 136 | 148 | { |
| 137 | - if (!isset($desc['login']) OR !strlen($desc['login'])) |
|
| 138 | - $desc['login'] = test_login($desc['nom'], $desc['email']); |
|
| 149 | + if (!isset($desc['login']) OR !strlen($desc['login'])) { |
|
| 150 | + $desc['login'] = test_login($desc['nom'], $desc['email']); |
|
| 151 | + } |
|
| 139 | 152 | |
| 140 | 153 | $desc['statut'] = 'nouveau'; |
| 141 | 154 | include_spip('action/editer_auteur'); |
| 142 | - if (isset($desc['id_auteur'])) |
|
| 143 | - $id_auteur = $desc['id_auteur']; |
|
| 144 | - else |
|
| 145 | - $id_auteur = auteur_inserer(); |
|
| 155 | + if (isset($desc['id_auteur'])) { |
|
| 156 | + $id_auteur = $desc['id_auteur']; |
|
| 157 | + } else { |
|
| 158 | + $id_auteur = auteur_inserer(); |
|
| 159 | + } |
|
| 146 | 160 | |
| 147 | - if (!$id_auteur) return _T('titre_probleme_technique'); |
|
| 161 | + if (!$id_auteur) { |
|
| 162 | + return _T('titre_probleme_technique'); |
|
| 163 | + } |
|
| 148 | 164 | |
| 149 | 165 | include_spip('inc/autoriser'); |
| 150 | 166 | // lever l'autorisation pour pouvoir modifier le statut |
@@ -175,14 +191,16 @@ discard block |
||
| 175 | 191 | $mail = strtolower(translitteration(preg_replace('/@.*/', '', $mail))); |
| 176 | 192 | $login_base = preg_replace("/[^\w\d]/", "_", $mail); |
| 177 | 193 | } |
| 178 | - if (strlen($login_base) < 3) |
|
| 179 | - $login_base = 'user'; |
|
| 194 | + if (strlen($login_base) < 3) { |
|
| 195 | + $login_base = 'user'; |
|
| 196 | + } |
|
| 180 | 197 | |
| 181 | 198 | $login = $login_base; |
| 182 | 199 | |
| 183 | 200 | for ($i = 1; ; $i++) { |
| 184 | - if (!sql_countsel('spip_auteurs', "login='$login'")) |
|
| 185 | - return $login; |
|
| 201 | + if (!sql_countsel('spip_auteurs', "login='$login'")) { |
|
| 202 | + return $login; |
|
| 203 | + } |
|
| 186 | 204 | $login = $login_base.$i; |
| 187 | 205 | } |
| 188 | 206 | return $login; |
@@ -249,12 +267,13 @@ discard block |
||
| 249 | 267 | */ |
| 250 | 268 | function tester_statut_inscription($statut_tmp, $id){ |
| 251 | 269 | include_spip('inc/autoriser'); |
| 252 | - if ($statut_tmp) |
|
| 253 | - return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
|
| 254 | - elseif ( |
|
| 270 | + if ($statut_tmp) { |
|
| 271 | + return autoriser('inscrireauteur', $statut_tmp, $id) ? $statut_tmp : ''; |
|
| 272 | + } elseif ( |
|
| 255 | 273 | autoriser('inscrireauteur', $statut_tmp = "1comite", $id) |
| 256 | - OR autoriser('inscrireauteur', $statut_tmp = "6forum", $id)) |
|
| 257 | - return $statut_tmp; |
|
| 274 | + OR autoriser('inscrireauteur', $statut_tmp = "6forum", $id)) { |
|
| 275 | + return $statut_tmp; |
|
| 276 | + } |
|
| 258 | 277 | |
| 259 | 278 | return ''; |
| 260 | 279 | } |
@@ -273,11 +292,14 @@ discard block |
||
| 273 | 292 | */ |
| 274 | 293 | function confirmer_statut_inscription($auteur){ |
| 275 | 294 | // securite |
| 276 | - if ($auteur['statut'] != 'nouveau') return $auteur; |
|
| 295 | + if ($auteur['statut'] != 'nouveau') { |
|
| 296 | + return $auteur; |
|
| 297 | + } |
|
| 277 | 298 | |
| 278 | 299 | include_spip('inc/autoriser'); |
| 279 | - if (!autoriser('inscrireauteur', $auteur['prefs'])) |
|
| 280 | - return $auteur; |
|
| 300 | + if (!autoriser('inscrireauteur', $auteur['prefs'])) { |
|
| 301 | + return $auteur; |
|
| 302 | + } |
|
| 281 | 303 | $s = $auteur['prefs']; |
| 282 | 304 | |
| 283 | 305 | include_spip('inc/autoriser'); |
@@ -320,8 +342,9 @@ discard block |
||
| 320 | 342 | */ |
| 321 | 343 | function auteur_verifier_jeton($jeton){ |
| 322 | 344 | // refuser un jeton corrompu |
| 323 | - if (preg_match(',[^0-9a-f.],i',$jeton)) |
|
| 324 | - return false; |
|
| 345 | + if (preg_match(',[^0-9a-f.],i',$jeton)) { |
|
| 346 | + return false; |
|
| 347 | + } |
|
| 325 | 348 | |
| 326 | 349 | $desc = sql_fetsel('*','spip_auteurs',"cookie_oubli=".sql_quote($jeton, $serveur, 'string')); |
| 327 | 350 | return $desc; |
@@ -16,22 +16,22 @@ |
||
| 16 | 16 | |
| 17 | 17 | function action_redirect_dist() |
| 18 | 18 | { |
| 19 | - $type = _request('type'); |
|
| 20 | - if (!preg_match('/^\w+$/', $type)) return; |
|
| 21 | - if ($m = _request('var_mode')) { |
|
| 22 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 23 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 24 | - $m = 'var_mode='.urlencode($m); |
|
| 25 | - } |
|
| 26 | - $h = generer_url_entite_absolue(intval(_request('id')), $type, $m, '', true); |
|
| 27 | - $status = '302'; |
|
| 28 | - if (_request('status') AND _request('status')=='301') |
|
| 29 | - $status = '301'; |
|
| 19 | + $type = _request('type'); |
|
| 20 | + if (!preg_match('/^\w+$/', $type)) return; |
|
| 21 | + if ($m = _request('var_mode')) { |
|
| 22 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 23 | + if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 24 | + $m = 'var_mode='.urlencode($m); |
|
| 25 | + } |
|
| 26 | + $h = generer_url_entite_absolue(intval(_request('id')), $type, $m, '', true); |
|
| 27 | + $status = '302'; |
|
| 28 | + if (_request('status') AND _request('status')=='301') |
|
| 29 | + $status = '301'; |
|
| 30 | 30 | |
| 31 | - if ($h) |
|
| 32 | - redirige_par_entete(str_replace('&', '&', $h),'',$status); |
|
| 33 | - else |
|
| 34 | - redirige_par_entete('/','',$status); |
|
| 31 | + if ($h) |
|
| 32 | + redirige_par_entete(str_replace('&', '&', $h),'',$status); |
|
| 33 | + else |
|
| 34 | + redirige_par_entete('/','',$status); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ?> |
@@ -20,18 +20,18 @@ |
||
| 20 | 20 | if (!preg_match('/^\w+$/', $type)) return; |
| 21 | 21 | if ($m = _request('var_mode')) { |
| 22 | 22 | // forcer la mise a jour de l'url de cet objet ! |
| 23 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 23 | + if (!defined('_VAR_URLS')) define('_VAR_URLS', true); |
|
| 24 | 24 | $m = 'var_mode='.urlencode($m); |
| 25 | 25 | } |
| 26 | 26 | $h = generer_url_entite_absolue(intval(_request('id')), $type, $m, '', true); |
| 27 | 27 | $status = '302'; |
| 28 | - if (_request('status') AND _request('status')=='301') |
|
| 28 | + if (_request('status') AND _request('status') == '301') |
|
| 29 | 29 | $status = '301'; |
| 30 | 30 | |
| 31 | 31 | if ($h) |
| 32 | - redirige_par_entete(str_replace('&', '&', $h),'',$status); |
|
| 32 | + redirige_par_entete(str_replace('&', '&', $h), '', $status); |
|
| 33 | 33 | else |
| 34 | - redirige_par_entete('/','',$status); |
|
| 34 | + redirige_par_entete('/', '', $status); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ?> |
@@ -10,28 +10,36 @@ |
||
| 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 | // Un script utile pour recalculer une URL symbolique des son changement |
| 16 | 18 | |
| 17 | 19 | function action_redirect_dist() |
| 18 | 20 | { |
| 19 | 21 | $type = _request('type'); |
| 20 | - if (!preg_match('/^\w+$/', $type)) return; |
|
| 22 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 21 | 25 | if ($m = _request('var_mode')) { |
| 22 | 26 | // forcer la mise a jour de l'url de cet objet ! |
| 23 | - if (!defined('_VAR_URLS')) define('_VAR_URLS',true); |
|
| 27 | + if (!defined('_VAR_URLS')) { |
|
| 28 | + define('_VAR_URLS',true); |
|
| 29 | + } |
|
| 24 | 30 | $m = 'var_mode='.urlencode($m); |
| 25 | 31 | } |
| 26 | 32 | $h = generer_url_entite_absolue(intval(_request('id')), $type, $m, '', true); |
| 27 | 33 | $status = '302'; |
| 28 | - if (_request('status') AND _request('status')=='301') |
|
| 29 | - $status = '301'; |
|
| 34 | + if (_request('status') AND _request('status')=='301') { |
|
| 35 | + $status = '301'; |
|
| 36 | + } |
|
| 30 | 37 | |
| 31 | - if ($h) |
|
| 32 | - redirige_par_entete(str_replace('&', '&', $h),'',$status); |
|
| 33 | - else |
|
| 34 | - redirige_par_entete('/','',$status); |
|
| 35 | -} |
|
| 38 | + if ($h) { |
|
| 39 | + redirige_par_entete(str_replace('&', '&', $h),'',$status); |
|
| 40 | + } else { |
|
| 41 | + redirige_par_entete('/','',$status); |
|
| 42 | + } |
|
| 43 | + } |
|
| 36 | 44 | |
| 37 | 45 | ?> |