From d7525ebd8f8d89099bd8880b8596e8af53669f21 Mon Sep 17 00:00:00 2001 From: Cerdic <cedric@yterium.com> Date: Mon, 29 Mar 2010 21:31:57 +0000 Subject: [PATCH] Report de [15514] [15515] [15516] [15517] [15518] [15519] [15528] [15529] [15530] [15531] [15532] [15533] [15535] [15536] --- ecrire/action/editer_groupe_mot.php | 2 +- ecrire/balise/formulaire_.php | 7 +- ecrire/exec/fond.php | 22 ++- ecrire/inc/auth.php | 2 +- ecrire/inc/commencer_page.php | 11 ++ ecrire/inc/cookie.php | 4 +- ecrire/inc/filtres.php | 6 +- ecrire/inc/filtres_images_lib_mini.php | 2 +- ecrire/inc/iconifier.php | 11 +- ecrire/inc/utils.php | 24 +++- ecrire/inc_version.php | 1 + ecrire/public/composer.php | 22 +-- ecrire/public/phraser_html.php | 168 +++++++++++------------ ecrire/public/references.php | 5 + prive/formulaires/editer_groupe_mot.html | 1 + prive/javascript/ajaxCallback.js | 16 ++- 16 files changed, 184 insertions(+), 120 deletions(-) diff --git a/ecrire/action/editer_groupe_mot.php b/ecrire/action/editer_groupe_mot.php index c8dac91b1e..3ae31a1715 100644 --- a/ecrire/action/editer_groupe_mot.php +++ b/ecrire/action/editer_groupe_mot.php @@ -43,7 +43,7 @@ function action_editer_groupe_mot_dist() $c[$champ] = _request("acces_$champ")=='oui'?'oui':'non'; if (is_array($c['tables_liees'])) - $c['tables_liees'] = implode(',',$c['tables_liees']); + $c['tables_liees'] = implode(',',array_diff($c['tables_liees'],array(''))); revision_groupe_mot($id_groupe, $c); if ($redirect = _request('redirect')) { diff --git a/ecrire/balise/formulaire_.php b/ecrire/balise/formulaire_.php index 3e2d96dca2..4938aba373 100644 --- a/ecrire/balise/formulaire_.php +++ b/ecrire/balise/formulaire_.php @@ -33,9 +33,9 @@ function existe_formulaire($form) else $form = strtolower($form); - if (!$form) return ''; + if (!$form) return ''; // on ne sait pas, le nom du formulaire n'est pas fourni ici - return find_in_path($form.'.' . _EXTENSION_SQUELETTES, 'formulaires/') ? $form : ''; + return find_in_path($form.'.' . _EXTENSION_SQUELETTES, 'formulaires/') ? $form : false; } @@ -44,7 +44,8 @@ function existe_formulaire($form) function balise_FORMULAIRE__dist($p) { // Cas d'un #FORMULAIRE_TOTO inexistant : renvoyer la chaine vide. - if (!existe_formulaire($p->nom_champ)) { + // mais si #FORMULAIRE_{toto} on ne peut pas savoir a la compilation, continuer + if (existe_formulaire($p->nom_champ)===FALSE) { $p->code = "''"; $p->interdire_scripts = false; return $p; diff --git a/ecrire/exec/fond.php b/ecrire/exec/fond.php index 5a371c77cb..e0181ea30e 100644 --- a/ecrire/exec/fond.php +++ b/ecrire/exec/fond.php @@ -37,6 +37,12 @@ function exec_fond_dist(){ $titre = $match[1]; } + // recuperer la hierarchie (au-dessus du contenu) + if (preg_match(",<!--#hierarchie-->.+<!--/#hierarchie-->,Uims",$fond,$match)){ + $hierarchie = $match[0]; + $fond = str_replace($hierarchie,"",$fond); + } + // recuperer la navigation (colonne de gauche) if (preg_match(",<!--#navigation-->.+<!--/#navigation-->,Uims",$fond,$match)){ $navigation = $match[0]; @@ -52,7 +58,21 @@ function exec_fond_dist(){ include_spip('inc/presentation_mini'); // alleger les inclusions avec un inc/presentation_mini $commencer_page = charger_fonction('commencer_page','inc'); echo $commencer_page($titre); - + + if ($hierarchie){ + echo debut_grand_cadre(true); + echo pipeline( + 'affiche_hierarchie', + array( + 'args' => array( + 'exec' => $exec + ), + 'data' => $hierarchie + ) + ); + echo fin_grand_cadre(true); + } + echo debut_gauche("exec_$exec",true); echo $navigation; echo pipeline('affiche_gauche',array('args'=>array('exec'=>$exec),'data'=>'')); diff --git a/ecrire/inc/auth.php b/ecrire/inc/auth.php index 4bd67e053b..1827ed0b5f 100644 --- a/ecrire/inc/auth.php +++ b/ecrire/inc/auth.php @@ -293,7 +293,7 @@ function auth_trace($row, $date=null) if (is_null($date)) $date = date('Y-m-d H:i:s'); - if ((time() - $connect_quand) >= 60) { + if (abs(strtotime($date) - $connect_quand) >= 60) { sql_updateq("spip_auteurs", array("en_ligne" => $date), "id_auteur=" .$row['id_auteur']); } } diff --git a/ecrire/inc/commencer_page.php b/ecrire/inc/commencer_page.php index f8d0bb1602..c10fc95a0a 100644 --- a/ecrire/inc/commencer_page.php +++ b/ecrire/inc/commencer_page.php @@ -131,6 +131,17 @@ function alertes_auteur($id_auteur) { $alertes[] = avertissement_messagerie($id_auteur); + $alertes = pipeline( + 'alertes_auteur', + array( + 'args' => array( + 'id_auteur' => $id_auteur, + 'exec' => _request('exec'), + ), + 'data' => $alertes + ) + ); + if ($alertes = array_filter($alertes)) return "<div class='wrap-messages'><div class='messages'>". join('<hr />', $alertes) diff --git a/ecrire/inc/cookie.php b/ecrire/inc/cookie.php index fbd0dde90c..44da5c03b2 100644 --- a/ecrire/inc/cookie.php +++ b/ecrire/inc/cookie.php @@ -19,7 +19,9 @@ if (!defined("_ECRIRE_INC_VERSION")) return; function spip_setcookie ($name='', $value='', $expire=0, $path='AUTO', $domain='', $secure='') { $name = preg_replace ('/^spip_/', $GLOBALS['cookie_prefix'].'_', $name); if ($path == 'AUTO') - $path = preg_replace(',^\w+://[^/]*,', '', url_de_base()); + $path = defined('_COOKIE_PATH')?_COOKIE_PATH:preg_replace(',^\w+://[^/]*,', '', url_de_base()); + if (!$domain AND defined('_COOKIE_DOMAIN')) + $domain = _COOKIE_DOMAIN; #spip_log("cookie('$name', '$value', '$expire', '$path', '$domain', '$secure'"); diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index 72f10cb541..3b02ee6f8f 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -464,15 +464,17 @@ function lignes_longues($texte, $l = 70) { // Passer en utf-8 pour ne pas avoir de coupes trop courtes avec les &#xxxx; // qui prennent 7 caracteres #include_spip('inc/charsets'); + $texte = html2unicode($texte, true); $texte = unicode_to_utf_8(charset2unicode( $texte, $GLOBALS['meta']['charset'], true)); // echapper les tags (on ne veut pas casser les a href=...) $tags = array(); - if (preg_match_all('/<.+>|&[^;\s]+;/UumsS', $texte, $t, PREG_SET_ORDER)) { + if (preg_match_all('/<.+>|&(amp;)?#[0-9]+;|&(amp;)?[a-zA-Z1-4]{2,6};/UumsS', $texte, $t, PREG_SET_ORDER)) { foreach ($t as $n => $tag) { + $space = substr($tag[0],0,1)=='&'?'':' '; $tags[$n] = $tag[0]; - $texte = str_replace($tag[0], " <---$n---> ", $texte); + $texte = str_replace($tag[0], "$space<---$n--->$space", $texte); } } // casser les mots longs qui restent diff --git a/ecrire/inc/filtres_images_lib_mini.php b/ecrire/inc/filtres_images_lib_mini.php index 4b4bbb41fc..0c40404849 100644 --- a/ecrire/inc/filtres_images_lib_mini.php +++ b/ecrire/inc/filtres_images_lib_mini.php @@ -418,7 +418,7 @@ function _image_tag_changer_taille($tag,$width,$height,$style=false){ // function d'ecriture du de la balise img en sortie des filtre image // reprend le tag initial et surcharge les tags modifies -function _image_ecrire_tag($valeurs,$surcharge){ +function _image_ecrire_tag($valeurs,$surcharge=array()){ $tag = str_replace(">","/>",str_replace("/>",">",$valeurs['tag'])); // fermer les tags img pas bien fermes; // le style diff --git a/ecrire/inc/iconifier.php b/ecrire/inc/iconifier.php index a9478b2a42..760f92d099 100644 --- a/ecrire/inc/iconifier.php +++ b/ecrire/inc/iconifier.php @@ -123,15 +123,18 @@ function indiquer_logo($titre, $id_objet, $mode, $id, $script, $iframe_script) { // http://doc.spip.org/@decrire_logo function decrire_logo($id_objet, $mode, $id, $width, $height, $img, $titre="", $script="", $flag_modif=true) { - list($fid, $dir, $nom, $format) = $img; + list($fid, $dir, $nom, $format, $timestamp) = $img; include_spip('inc/filtres_images_mini'); + $res = image_reduire("<img src='$fid' alt='' class='miniature_logo' />", $width, $height); - if ($res) + if ($res){ + $src = extraire_attribut($res,'src'); + $res = inserer_attribut($res, 'src', "$src?$timestamp"); $res = "<div><a href='" . $fid . "'>$res</a></div>"; + } else - $res = "<img src='$fid' width='$width' height='$height' alt=\"" - . htmlentities($titre) . '" />'; + $res = "<img src='$fid?$timestamp' width='$width' height='$height' alt=\"" . htmlentities($titre) . '" />'; if ($taille = @getimagesize($fid)) $taille = _T('info_largeur_vignette', array('largeur_vignette' => $taille[0], diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 0450dc234c..a835d79387 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -968,15 +968,29 @@ function url_de_base() { $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING']; } } - $myself = $http.'://'.$_SERVER['HTTP_HOST'].$GLOBALS['REQUEST_URI']; + $url[$GLOBALS['profondeur_url']] = url_de_($http,$_SERVER['HTTP_HOST'],$GLOBALS['REQUEST_URI'],$GLOBALS['profondeur_url']); + + return $url[$GLOBALS['profondeur_url']]; +} +/** + * fonction testable de construction d'une url appelee par url_de_base() + * @param string $http + * @param string $host + * @param string $request + * @param int $prof + * @return string + */ +function url_de_($http,$host,$request,$prof=0){ + $prof = max($prof,0); + + $myself = ltrim($request,'/'); # supprimer la chaine de GET list($myself) = explode('?', $myself); + $url = join('/', array_slice(explode('/', $myself), 0, -1-$prof)).'/'; - # supprimer n sous-repertoires - $url[$GLOBALS['profondeur_url']] = join('/', array_slice(explode('/', $myself), 0, -1-$GLOBALS['profondeur_url'])).'/'; - - return $url[$GLOBALS['profondeur_url']]; + $url = $http.'://'.rtrim($host,'/').'/'.ltrim($url,'/'); + return $url; } diff --git a/ecrire/inc_version.php b/ecrire/inc_version.php index 5c52487bf8..0db8501c68 100644 --- a/ecrire/inc_version.php +++ b/ecrire/inc_version.php @@ -270,6 +270,7 @@ $spip_pipeline = array( 'affiche_enfants' => '', 'affiche_hierarchie' => '', 'affiche_formulaire_login' => '|auth_formulaire_login', + 'alertes_auteur' => '', 'base_admin_repair' => '', 'boite_infos' => 'f_boite_infos', 'ajouter_boutons' => '', diff --git a/ecrire/public/composer.php b/ecrire/public/composer.php index 7bca9619a5..7420bc95ec 100644 --- a/ecrire/public/composer.php +++ b/ecrire/public/composer.php @@ -191,18 +191,18 @@ function analyse_resultat_skel($nom, $cache, $corps, $source='') { // "a la main" dans les squelettes, mais evidemment sans exhaustivite if (preg_match_all( '/(<[?]php\s+)@?header\s*\(\s*.([^:]*):\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims', - $corps, $regs, PREG_SET_ORDER)) - foreach ($regs as $r) { - $corps = str_replace($r[0], '', $corps); - # $j = Content-Type, et pas content-TYPE. - $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); - - if ($j=='X-Spip-Filtre' AND isset($headers[$j])) - $headers[$j].="|".$r[3]; - else - $headers[$j] = $r[3]; + $corps, $regs, PREG_SET_ORDER)){ + foreach ($regs as $r) { + $corps = str_replace($r[0], '', $corps); + # $j = Content-Type, et pas content-TYPE. + $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); + + if ($j=='X-Spip-Filtre' AND isset($headers[$j])) + $headers[$j].="|".$r[3]; + else + $headers[$j] = $r[3]; + } } - // S'agit-il d'un resultat constant ou contenant du code php $process_ins = ( strpos($corps,'<'.'?') === false diff --git a/ecrire/public/phraser_html.php b/ecrire/public/phraser_html.php index a20abfe5bc..9302c7b380 100644 --- a/ecrire/public/phraser_html.php +++ b/ecrire/public/phraser_html.php @@ -217,29 +217,29 @@ function phraser_args($texte, $fin, $sep, $result, &$pointeur_champ) { // http://doc.spip.org/@phraser_arg function phraser_arg(&$texte, $sep, $result, &$pointeur_champ) { - preg_match(",^(\|?[^}{)|]*)(.*)$,ms", $texte, $match); - $suite = ltrim($match[2]); - $fonc = trim($match[1]); - if ($fonc && $fonc[0] == "|") $fonc = ltrim(substr($fonc,1)); - $res = array($fonc); - $err_f = ''; - // cas du filtre sans argument ou du critere / - if (($suite && ($suite[0] != '{')) || ($fonc && $fonc[0] == '/')) { - // si pas d'argument, alors il faut une fonction ou un double | - if (!$match[1]) { - $err_f = array('zbug_erreur_filtre', array('filtre' => $texte)); - erreur_squelette($err_f, $pointeur_champ); - $texte = ''; - } else $texte = $suite; - if ($err_f) $pointeur_champ->param = false; - elseif ($fonc!=='') $pointeur_champ->param[] = $res; - // pour les balises avec faux filtres qui boudent ce dur larbeur - $pointeur_champ->fonctions[] = array($fonc, ''); - return $result; - } - $args = ltrim(substr($suite,1)); // virer le '(' initial - $collecte = array(); - while ($args && $args[0] != '}') { + preg_match(",^(\|?[^}{)|]*)(.*)$,ms", $texte, $match); + $suite = ltrim($match[2]); + $fonc = trim($match[1]); + if ($fonc && $fonc[0] == "|") $fonc = ltrim(substr($fonc,1)); + $res = array($fonc); + $err_f = ''; + // cas du filtre sans argument ou du critere / + if (($suite && ($suite[0] != '{')) || ($fonc && $fonc[0] == '/')) { + // si pas d'argument, alors il faut une fonction ou un double | + if (!$match[1]) { + $err_f = array('zbug_erreur_filtre', array('filtre' => $texte)); + erreur_squelette($err_f, $pointeur_champ); + $texte = ''; + } else $texte = $suite; + if ($err_f) $pointeur_champ->param = false; + elseif ($fonc!=='') $pointeur_champ->param[] = $res; + // pour les balises avec faux filtres qui boudent ce dur larbeur + $pointeur_champ->fonctions[] = array($fonc, ''); + return $result; + } + $args = ltrim(substr($suite,1)); // virer le '(' initial + $collecte = array(); + while ($args && $args[0] != '}') { if ($args[0] == '"') preg_match ('/^(")([^"]*)(")(.*)$/ms', $args, $regs); else if ($args[0] == "'") @@ -263,71 +263,71 @@ function phraser_arg(&$texte, $sep, $result, &$pointeur_champ) { $collecte[] = $champ; $args = ltrim($regs[count($regs)-1]); } else { - if (!preg_match("/".NOM_DE_CHAMP ."([{|])/", $arg, $r)) { - // 0 est un aveu d'impuissance. A completer - $arg = phraser_champs_exterieurs($arg, 0, $sep, $result); + if (!preg_match("/".NOM_DE_CHAMP ."([{|])/", $arg, $r)) { + // 0 est un aveu d'impuissance. A completer + $arg = phraser_champs_exterieurs($arg, 0, $sep, $result); - $args = ltrim($regs[count($regs)-1]); - $collecte = array_merge($collecte, $arg); - $result = array_merge($result, $arg); - } - else { - $n = strpos($args,$r[0]); - $pred = substr($args, 0, $n); - $par = ',}'; - if (preg_match('/^(.*)\($/', $pred, $m)) - {$pred = $m[1]; $par =')';} - if ($pred) { - $champ = new Texte; - $champ->texte = $pred; - $champ->apres = $champ->avant = ""; - $result[] = $champ; - $collecte[] = $champ; - } - $rec = substr($args, $n + strlen($r[0]) -1); - $champ = new Champ; - $champ->nom_boucle = $r[2]; - $champ->nom_champ = $r[3]; - $champ->etoile = $r[5]; - $next = $r[6]; - while ($next=='{') { - phraser_arg($rec, $sep, array(), $champ); - $args = ltrim($rec) ; - $next = $args[0]; - } - while ($next=='|') { - phraser_args($rec, $par, $sep, array(), $champ); - $args = $champ->apres ; - $champ->apres = ''; - $next = $args[0]; - } - // Si erreur de syntaxe dans un sous-argument, propager. - if ($champ->param === false) - $err_f = true; - else phraser_vieux($champ); - if ($par==')') $args = substr($args,1); - $collecte[] = $champ; - $result[] = $champ; - } + $args = ltrim($regs[count($regs)-1]); + $collecte = array_merge($collecte, $arg); + $result = array_merge($result, $arg); + } + else { + $n = strpos($args,$r[0]); + $pred = substr($args, 0, $n); + $par = ',}'; + if (preg_match('/^(.*)\($/', $pred, $m)) + {$pred = $m[1]; $par =')';} + if ($pred) { + $champ = new Texte; + $champ->texte = $pred; + $champ->apres = $champ->avant = ""; + $result[] = $champ; + $collecte[] = $champ; + } + $rec = substr($args, $n + strlen($r[0]) -1); + $champ = new Champ; + $champ->nom_boucle = $r[2]; + $champ->nom_champ = $r[3]; + $champ->etoile = $r[5]; + $next = $r[6]; + while ($next=='{') { + phraser_arg($rec, $sep, array(), $champ); + $args = ltrim($rec) ; + $next = $args[0]; + } + while ($next=='|') { + phraser_args($rec, $par, $sep, array(), $champ); + $args = $champ->apres ; + $champ->apres = ''; + $next = $args[0]; + } + // Si erreur de syntaxe dans un sous-argument, propager. + if ($champ->param === false) + $err_f = true; + else phraser_vieux($champ); + if ($par==')') $args = substr($args,1); + $collecte[] = $champ; + $result[] = $champ; + } } if ($args[0] == ',') { - $args = ltrim(substr($args,1)); - if ($collecte) {$res[] = $collecte; $collecte = array();} + $args = ltrim(substr($args,1)); + if ($collecte) {$res[] = $collecte; $collecte = array();} } - } - if ($collecte) {$res[] = $collecte; $collecte = array();} - $texte = substr($args,1); - $source = substr($texte, 0, strlen($texte) - strlen($args)); - // propager les erreurs, et ignorer les param vides - if ($pointeur_champ->param !== false) { - if ($err_f) - $pointeur_champ->param = false; - elseif ($fonc!=='' || count($res) > 1) - $pointeur_champ->param[] = $res; - } - // pour les balises avec faux filtres qui boudent ce dur larbeur - $pointeur_champ->fonctions[] = array($fonc, $source); - return $result; + } + if ($collecte) {$res[] = $collecte; $collecte = array();} + $texte = substr($args,1); + $source = substr($texte, 0, strlen($texte) - strlen($args)); + // propager les erreurs, et ignorer les param vides + if ($pointeur_champ->param !== false) { + if ($err_f) + $pointeur_champ->param = false; + elseif ($fonc!=='' || count($res) > 1) + $pointeur_champ->param[] = $res; + } + // pour les balises avec faux filtres qui boudent ce dur larbeur + $pointeur_champ->fonctions[] = array($fonc, $source); + return $result; } diff --git a/ecrire/public/references.php b/ecrire/public/references.php index facc132e24..4a827a8e84 100644 --- a/ecrire/public/references.php +++ b/ecrire/public/references.php @@ -245,6 +245,11 @@ function calculer_balise_dynamique($p, $nom, $l, $supp=array()) { $p->code = "''"; return $p; } + // compatibilite: depuis qu'on accepte #BALISE{ses_args} sans [(...)] autour + // il faut recracher {...} quand ce n'est finalement pas des args + if ($p->fonctions AND (!$p->fonctions[0][0]) AND $p->fonctions[0][1]) { + $p->fonctions = null; + } if ($p->param AND ($c = $p->param[0])) { // liste d'arguments commence toujours par la chaine vide diff --git a/prive/formulaires/editer_groupe_mot.html b/prive/formulaires/editer_groupe_mot.html index ab2517a28b..2119b4c188 100644 --- a/prive/formulaires/editer_groupe_mot.html +++ b/prive/formulaires/editer_groupe_mot.html @@ -29,6 +29,7 @@ <li class="fieldset"> <fieldset><h3 class="legend"><:info_mots_cles_association:></h3> <ul><li class="editer_groupe_mots_associer"> + <input type='hidden' name='tables_liees[]' value='' /> <div class='choix'><input type='checkbox' class='checkbox' name='tables_liees[]' value='articles'[(#VAL{articles}|in_any{#ENV{tables_liees}})checked='checked'] id='articles' /><label for='articles'><:item_mots_cles_association_articles:></label></div> [(#ENV{config}|table_valeur{activer_breves}|=={oui}|oui) <div class='choix'><input type='checkbox' class='checkbox' name='tables_liees[]' value='breves'[(#VAL{breves}|in_any{#ENV{tables_liees}})checked='checked'] id='breves' /><label for='breves'><:item_mots_cles_association_breves:></label></div> diff --git a/prive/javascript/ajaxCallback.js b/prive/javascript/ajaxCallback.js index 14b1b2369b..7dfbe6b969 100644 --- a/prive/javascript/ajaxCallback.js +++ b/prive/javascript/ajaxCallback.js @@ -161,13 +161,16 @@ jQuery.fn.formulaire_dyn_ajax = function(target) { .removeClass('loading') .html(c); var a = jQuery('a:first',recu).eq(0); - if (a.length && a.is('a[name=ajax_ancre]')){ + if (a.length + && a.is('a[name=ajax_ancre]') + && jQuery(a.attr('href'),cible).length){ a = a.attr('href'); - setTimeout(function(){ + if (jQuery(a,cible).length) + setTimeout(function(){ jQuery(a,cible).positionner(true); //a = a.split('#'); //window.location.hash = a[1]; - },10); + },10); } else{ jQuery(cible).positionner(false); @@ -224,9 +227,10 @@ jQuery.fn.ajaxbloc = function() { .html(c) .removeClass('loading'); var a = jQuery('a:first',jQuery(blocfrag)).eq(0); - if (a.length && a.is('a[name=ajax_ancre]') - ){ - a = a.attr('href'); + if (a.length + && a.is('a[name=ajax_ancre]') + && jQuery(a.attr('href'),blocfrag).length){ + a = a.attr('href') setTimeout(function(){ jQuery(a,blocfrag).positionner(true); //a = a.split('#'); -- GitLab