diff --git a/ecrire/exec/memoriser.php b/ecrire/exec/memoriser.php index 0a81f58692570632331e0fb487eb51c024fdcdc9..0e75618dfc05ca8569cbf348ea1d0a23e8068192 100644 --- a/ecrire/exec/memoriser.php +++ b/ecrire/exec/memoriser.php @@ -18,11 +18,16 @@ if (!defined("_ECRIRE_INC_VERSION")) return; function exec_memoriser_dist() { $hash = _request('hash'); + $order = _request('order'); + $by = _request('by'); lire_fichier(_DIR_SESSIONS.'ajax_fonctions.txt', $ajax_fonctions); $ajax_fonctions = @unserialize($ajax_fonctions); if ($res = $ajax_fonctions[$hash]) { list(,$t,$r,$p,$f) = $res; + if (preg_match('/^[a-z0-9+.,]+$/', $by) + AND preg_match('/^\w*$/', $order)) + $r['ORDER BY'] = str_replace(',', " $order, ", $by) . " $order"; $cpt = sql_countsel($r['FROM'], $r['WHERE'], $r['GROUP BY']); include_spip('inc/presentation'); include_spip('inc/afficher_objets'); diff --git a/ecrire/inc/afficher_objets.php b/ecrire/inc/afficher_objets.php index 31815caff8ac0aac504c5369d9640d29bb83e1f8..073b365d645764e45c8884aa23a96ca6b36da265 100644 --- a/ecrire/inc/afficher_objets.php +++ b/ecrire/inc/afficher_objets.php @@ -98,13 +98,14 @@ function afficher_titre_objet($type,$row){ } // http://doc.spip.org/@afficher_titre_site function afficher_titre_site($row){ - $syndication = $row['syndication']; - $s = ""; - $s .= $row['nom_site']?(strlen($row['nom_site'])>1?typo($row['nom_site']):""._T('info_sans_titre_2').""):"("._T('info_sans_titre_2').")"; + $nom = $row['nom_site']; + + $nom = $nom?(strlen($nom)>1?typo($nom):_T('info_sans_titre_2')):("("._T('info_sans_titre_2').")"); + $s2 = " <span class='spip_xx-small'>[<a href='" .$row['url_site']."'>"._T('lien_visite_site')."</a>]</span>"; - return array($s,$s2); + return array($nom,$s2); } // http://doc.spip.org/@afficher_titre_auteur function afficher_titre_auteur($row){ @@ -280,7 +281,7 @@ function afficher_objet_boucle($row, $own) $vals[] = $puce_statut($id_objet, $statut, $id_rubrique, $type); list($titre,$suite) = afficher_titre_objet($type,$row); - $s = "\n<div>"; + $flogo = ''; if ($chercher_logo) { if ($chercher_logo !== true OR $chercher_logo = charger_fonction_logo_if()) @@ -288,13 +289,12 @@ function afficher_objet_boucle($row, $own) list($fid, $dir, $nom, $format) = $logo; include_spip('inc/filtres_images'); $logo = image_reduire("<img src='$fid' alt='' />", 26, 20); - if ($logo) - $s .= "\n<span style='float: $spip_lang_right; margin-top: -2px; margin-bottom: -2px;'>$logo</span>"; + $flogo = "\n<span style='float: $spip_lang_right; margin-top: -2px; margin-bottom: -2px;'>$logo</span>"; } } - if (strlen($titre)){ - $s .= "<a href='" + if ($titre) { + $titre = "<a href='" . lien_voir_objet($type,$primary,$id_objet) . "' " . "title='" . _T('info_numero_abbreviation'). $id_objet @@ -302,9 +302,7 @@ function afficher_objet_boucle($row, $own) . $titre . "</a>"; } - $s .= $suite; - $s .= "</div>"; - $vals[] = $s; + $vals[] = "\n<div>$flogo$titre$suite</div>"; $s = ""; if ($afficher_langue){ @@ -324,8 +322,7 @@ function afficher_objet_boucle($row, $own) } $vals[] = $s; - $s = afficher_complement_objet($type,$row); - $vals[] = $s; + $vals[] = afficher_complement_objet($type,$row); $s = ""; if ($affrub && $id_rubrique) { @@ -412,9 +409,8 @@ function afficher_articles_trad($titre_table, $requete, $formater, $tmp_var, $ha $icone = "langues-off-12.gif"; $alt = _T('masquer_trad'); } else { - if (!$formater) { + if (!$formater) $formater = charger_fonction('formater_article', 'inc'); - } $icone = 'langues-12.gif'; $alt = _T('afficher_trad'); } @@ -424,21 +420,42 @@ function afficher_articles_trad($titre_table, $requete, $formater, $tmp_var, $ha if (($GLOBALS['meta']['gerer_trad'] == "oui")) { $url = generer_url_ecrire('memoriser',"hash=$hash&trad=" . (1-$trad)); $texte .= - "\n<span style='float: $spip_lang_right;'><a href=\"#\"\nonclick=\"return charger_id_url('$url','$tmp_var');\">" - . "<img\nsrc='". chemin_image($icone) ."' alt='$alt' /></a></span>"; - + "\n<span style='float: $spip_lang_right;'><a href=\"#\"" + . generer_onclic_ajax($url, $tmp_var, 0) + . "><img\nsrc='". chemin_image($icone) ."' alt='$alt' /></a></span>"; } + $url_t = generer_url_ecrire('memoriser',"hash=$hash&by=0%2Btitre,titre"); + $url_t = afficher_boutons_tri($url_t, $tmp_var); + + $url_d = generer_url_ecrire('memoriser',"hash=$hash&by=date"); + $url_d = afficher_boutons_tri($url_d, $tmp_var); $presenter_liste = charger_fonction('presenter_liste', 'inc'); - $styles = array(array('', 11), array('arial2',''), array('arial1', 80), array('arial1', 100), array('arial1', 50)); + $styles = array(array('', 11), array('arial2','', $url_t), array('arial1', 80), array('arial1', 100, $url_d), array('arial1', 50)); $tableau = array(); $url = generer_url_ecrire('memoriser', "hash=$hash&trad=$trad"); - $res = $presenter_liste($requete, $formater, $tableau, array(), false, $styles, $tmp_var, $texte, "article-24.gif", $url, $cpt); + $res = $presenter_liste($requete, $formater, $tableau, array(), false, $styles, $tmp_var, $texte, "article-24.gif", $url, $cpt); return ajax_action_greffe($tmp_var, '', $res); } +function afficher_boutons_tri($url, $tmp_var) +{ + static $monter = ''; + static $descendre = ''; + + if (!$monter) { + $monter = http_img_pack('monter-16.png', '<'); + $descendre = http_img_pack('descendre-16.png', '>'); + } + + $url_d = generer_onclic_ajax($url ."&order=desc", $tmp_var, 0); + $url_a = generer_onclic_ajax($url ."&order=asc", $tmp_var, 0); + + return "<a href='$url'$url_d>$monter</a><a href='$url'$url_a>$descendre</a>"; +} + // http://doc.spip.org/@afficher_articles_trad_boucle function afficher_articles_trad_boucle($row, $own='') { diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index 7261bc5802b924bebc25e24d847cf880ef569a61..8c723bce2a72c02a879b7d0e79b57ffc7ee3f5dd 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -371,13 +371,7 @@ function navigation_pagination($num_rows, $nb_aff=10, $href=null, $on='', $tmp_v } else { $script = parametre_url($self, $tmp_var, $deb-1); - if ($on) { - $on = "\nonclick=\"return charger_id_url('" - . parametre_url($href, $tmp_var, $deb-1) - . "','" - . $tmp_var - . '\');"'; - } + if ($on) $on = generer_onclic_ajax($href, $tmp_var, $deb-1); $texte .= "<a href=\"$script\"$on>$deb</a>"; } } @@ -386,6 +380,15 @@ function navigation_pagination($num_rows, $nb_aff=10, $href=null, $on='', $tmp_v return $texte; } +function generer_onclic_ajax($url, $idom, $val) +{ + return "\nonclick=\"return charger_id_url('" + . parametre_url($url, $idom, $val) + . "','" + . $idom + . '\');"'; +} + // http://doc.spip.org/@avoir_visiteurs function avoir_visiteurs($past=false) { if ($GLOBALS['meta']["forums_publics"] == 'abo') return true; diff --git a/ecrire/inc/presenter_liste.php b/ecrire/inc/presenter_liste.php index c3a180edfb194147b9d9bdab9d37ab48a5d84c36..b2d37f6ed59b42d9d88527cf1d976de96fae82bf 100644 --- a/ecrire/inc/presenter_liste.php +++ b/ecrire/inc/presenter_liste.php @@ -40,24 +40,29 @@ function inc_presenter_liste_dist($requete, $fonc, &$prims, $own, $force, $style onmouseover=\"changeclass(this,'tr_liste_over');\" onmouseout=\"changeclass(this,'tr_liste');\"" ; - $table = ''; + $table = $head = ''; + $th = 0; while ($r = sql_fetch($result)) { if ($prim) $prims[]= $r[$prim]; if ($vals = $fonc($r, $own)) { reset($styles); $res = ''; foreach ($vals as $t) { - list(,list($style, $largeur)) = each($styles); + list(,list($style, $largeur, $nom)) = each($styles); if ($largeur) $largeur = " style='width: $largeur" ."px;'"; if ($style) $style = " class=\"$style\""; $t = !trim($t) ? " " : lignes_longues($t); $res .= "\n<td$class$style>$t</td>"; + if (!$table) { + $th |= $nom ? 1 : 0; + $head .= "\n<th style='text-align:center'>$nom</th>"; + } } $table .= "\n<tr class='tr_liste'$evt>$res</tr>"; } } - - $tranches .= "<table width='100%' cellpadding='2' cellspacing='0' border='0'>$table</table>"; + if (!$th) $head= ''; + $tranches .= "<table width='100%' cellpadding='2' cellspacing='0' border='0'>$head$table</table>"; } else { while ($r = sql_fetch($req)) { if ($prim) $prims[]= $r[$prim]; @@ -94,27 +99,18 @@ function afficher_tranches_requete($num_rows, $idom, $url='', $nb_aff = 10, $old $self = self(); $ie_style = ($browser_name == "MSIE") ? "height:1%" : ''; $style = "style='visibility: hidden; float: $spip_lang_right'"; - $texte = http_img_pack("searching.gif", "*", "$style id='img_$idom'") - - . "\n<div style='$ie_style;' class='arial1 tranches' id='a$ancre'>" - . navigation_pagination($num_rows, $nb_aff, $url, $onclick=true, $idom); - - $on =''; + $nav= navigation_pagination($num_rows, $nb_aff, $url, $onclick=true, $idom); $script = parametre_url($self, $idom, -1); - if ($url) { - $on = "\nonclick=\"return charger_id_url('" - . $url - . "&" - . $idom - . "=-1','" - . $idom - . '\');"'; - } $l = htmlentities(_T('lien_tout_afficher')); - $texte .= "<a href=\"$script#a$ancre\"$on class='plus'><img\nsrc='". chemin_image("plus.gif") . "' title=\"$l\" alt=\"$l\" /></a>"; - $texte .= "</div>\n"; - return $texte; + return http_img_pack("searching.gif", "*", "$style id='img_$idom'") + . "\n<div style='$ie_style;' class='arial1 tranches' id='a$ancre'>" + . $nav + . "<a href='$script#a$ancre' class='plus'" + . (!$url ? '' : generer_onclic_ajax($url, $idom,-1)) + . "><img title=\"$l\" alt=\"$l\"\nsrc=\"" + . chemin_image("plus.gif") + . "\" /></a></div>\n"; } // http://doc.spip.org/@affiche_tranche_bandeau