function controle_petition_args($id_article, $type, $date, $debut, $titre, $where, $pas, $id_signature=0) { if (!preg_match('/^\w+$/',$type)) $type = 'public'; if ($id_article) $where .= "id_article=$id_article AND "; $extrait = "(statut='publie' OR statut='poubelle')"; if ($type == 'interne') $extrait = "NOT($extrait)"; $where .= $extrait; $order = "date_time DESC"; if (!$pas) $pas = 10; if ($date) { include_spip('inc/forum'); $query = array('SELECT' => 'UNIX_TIMESTAMP(date_time) AS d', 'FROM' => 'spip_signatures', 'WHERE' => $where, 'ORDER BY' => $order); $debut = navigation_trouve_date($date, 'd', $pas, $query); } $signatures = charger_fonction('signatures', 'inc'); $res = $signatures('controle_petition', $id_article, $debut, $pas, $where, $order, $type); if (_AJAX) { ajax_retour($res); } else { $count = ($type != 'interne') ? 0 : sql_countsel("spip_signatures", $where); controle_petition_page($id_article, $titre, $id_signature ? '' : $type, $res, $count); } }
function affiche_navigation_forum(&$query, $script, $args, $debut, $pas=NULL, $enplus=NULL, $date=NULL) { if (!$pas) $pas = 10; if (!$enplus) $enplus = 100; $total = sql_countsel($query['FROM'], $query['WHERE'], $query['GROUP BY']); // pas de navigation si tout tient if ($total > $pas) { if ($date) { preg_match('/^\w+/', $query['ORDER BY'], $m); $debut = navigation_trouve_date($date, $m[0], $pas, $query); } if ($total <= $debut) $debut = $total-$pas; $max = min($total, $debut+$enplus); $tranche = $debut; while (($tranche + $enplus) >= $max) $tranche -= $pas; if ($tranche <0) $tranche = 0; $h = generer_url_ecrire($script, $args); $nav = (!$tranche ? '' : "<a href='$h'>0</a>| ... |\n"); $e = (_SPIP_AJAX === 1 ); for (;$tranche<$max;$tranche+=$pas){ if ($tranche == $debut) $nav .= "<span class='spip_medium'><b>$tranche</b></span> |\n"; else { $h = "$args&debut=$tranche"; $h = generer_url_ecrire($script, $h); if ($e) $e = "\nonclick=" . ajax_action_declencheur($h,$script); $nav .= "<a href='$h'$e>$tranche</a> |\n"; } } if ($tranche < $total) { $h = generer_url_ecrire($script, $args . "&debut=" . $total); if ($e) { $e = "\nonclick=" . ajax_action_declencheur($h,$script); } $nav .= "... | <a href='$h'$e>$total</a>"; } } $query['LIMIT'] = "$debut, $pas"; return $nav; }