diff --git a/ecrire/action/editer_groupe_mot.php b/ecrire/action/editer_groupe_mot.php index c8dac91b1ebceafae3f03f6e82049aa77a4a8cd2..3ae31a1715953a2201735e65b80de237e2034b53 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 3e2d96dca27263dc0df2013fb4a70520b3aa3ade..4938aba37311b067cb865ba661a4fb42c6a30982 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 5a371c77cb05ba50ffc2a3fe0a7e1099caed3dfc..e0181ea30e108be7f8ebbbafa4d301333fe4d8de 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 4bd67e053b074ae2edaa61934b91e3a52936cafa..1827ed0b5f4c4154bde7dd3fef5a685ac04e44d0 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 f8d0bb1602141ecf7be561e9dd8eb1c68df01420..c10fc95a0a4923007ec8704c4f15bee4712652b7 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 fbd0dde90cbca20994331ab5f0e1fb99d1348f42..44da5c03b2ce74ca2189fec957dc06434cb34baf 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 72f10cb54155a444568b73d6a59b016d03cac936..3b02ee6f8fa79ae035baf6492ac1df490aa28a00 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 4b4bbb41fcd697c3d61b67ecf7342485b66582d3..0c40404849136a24280c5097e2fb7f1181852d1a 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 a9478b2a4272ccf1353297b994f4a0fb1162b315..760f92d099bbb8caa17dc30e7eda76a4bff58800 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 0450dc234c720dff2366d4a33118254f999d0c37..a835d79387c72564430ca8ae060a67cf148cdbd2 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 5c52487bf8bb9deac691acecb44240402e7fb3d4..0db8501c68f13b3924e8a93aa5d772b04cf41f56 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 7bca9619a5efaba25b198b5f98779e7ffe4a9a65..7420bc95ecd20b368d4ff5ff9b42b10066c9af7c 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 a20abfe5bc89238070f1def0b91f6cab880ff81a..9302c7b380f28e3e1cc93511c736e75e68c9289f 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 facc132e24015269a2478ec8201ea2497b5a7cab..4a827a8e8427a46abe15654c64a6d6ce43f301ae 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 ab2517a28b17577d64ebceaf009dd9988b925c9a..2119b4c188c08aaf52e8135b8eba4f5ae9c2aac0 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 14b1b2369b09ea66c6a329b1d1030c5186fc9bc1..7dfbe6b9696d10bf0b7a43388ba7927e5c3b30c2 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('#');