git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-240
.implode(',',array_filter(array($fields->get_order_statement(), 'promo DESC, NomSortKey, prenom'))).'
LIMIT '.$offset->value.','.$globals->search->per_page;
- $page->mysql_assign($sql, 'resultats', 'nb_resultats','nb_resultats_total');
- $nb_tot = $page->get_template_vars('nb_resultats_total');
+ $page->assign('resultats', $globals->xdb->iterator($sql));
+ $res = $globals->xdb->query("SELECT FOUND_ROWS()");
+ $nb_tot = $res->fetchOneCell();
$nbpages = ($nb_tot - 1)/$globals->search->per_page;
$url_ext = Array(
$page->assign('url_short', $url_short);
$page->assign('url_args', $url_args);
$page->assign('perpage', $globals->search->per_page);
+ $page->assign('nb_tot', $nb_tot);
if (empty($nb_tot)) {
form_prepare();
.implode(',',array_filter(array($fields->get_order_statement(), 'u.promo DESC, NomSortKey, prenom'))).'
LIMIT '.$offset->value.','.$globals->search->per_page;
- $page->mysql_assign($sql, 'resultats', 'nb_resultats','nb_resultats_total');
- $nb_total = $page->get_template_vars('nb_resultats_total');
- $nbpages = ($nb_total-1)/$globals->search->per_page;
+ $page->assign('resultats', $globals->xdb->iterator($sql));
+ $res = $globals->xdb->query("SELECT FOUND_ROWS()");
+ $nb_tot = $res->fetchOneCell();
+ $nbpages = ($nb_tot-1)/$globals->search->per_page;
$url_ext = Array(
'mod_date_sort' => Env::has('mod_date_sort')
$page->assign('offsets', range(0, $nbpages));
$page->assign('url_args', $fields->get_url($url_ext));
$page->assign('perpage', $globals->search->per_page);
+ $page->assign('nb_tot', $nb_tot);
- if (!logged() && $nb_total > $globals->search->public_max) {
+ if (!logged() && $nb_tot > $globals->search->public_max) {
new ThrowError('Votre recherche a généré trop de résultats pour un affichage public.');
- } elseif ($nb_total > $globals->search->private_max) {
+ } elseif ($nb_tot > $globals->search->private_max) {
new ThrowError('Recherche trop générale');
- } elseif (empty($nb_total)) {
+ } elseif (empty($nb_tot)) {
new ThrowError('il n\'existe personne correspondant à ces critères dans la base !');
}
function XOrgDBResult($query)
{
global $globals;
- $this->_res =& $globals->db->query($query);
+ if (strpos("SQL_CALC_FOUND_ROWS", $query) === false) {
+ $this->_res = $globals->db->query($query);
+ } else {
+ $this->_res = mysql_query($query);
+ }
}
// }}}
function doAuth() { }
// }}}
- // {{{ function mysql_assign()
-
- function mysql_assign($sql_query,$var_name,$var_nb_name='',$var_found_rows='') {
- global $globals;
- //lorsqu'on désire obtenir found_rows il faut désactiver la trace du résultat
- $switch_trace = false;
- if (!empty($var_found_rows) && $globals->db->_trace==1) {
- $switch_trace = true;
- $globals->db->trace_off();
- }
-
- $sql = $globals->db->query($sql_query);
- if (mysql_errno()) {
- return(mysql_error($sql));
- }
-
- $array = Array();
- while ($array[] = mysql_fetch_assoc($sql));
- array_pop($array);
- mysql_free_result($sql);
- $this->assign_by_ref($var_name,$array);
- if (!empty($var_nb_name)) {
- $this->assign($var_nb_name, count($array));
- }
-
- if (!empty($var_found_rows)) {
- $res = $globals->xdb->query('SELECT FOUND_ROWS()');
- $this->assign($var_found_rows, $res->fetchOneCell());
- //si la trace était activée on affiche la trace sur la requête initiale
- if ($switch_trace) {
- $globals->db->trace_on();
- $sql = $globals->db->query($sql_query);
- mysql_free_result($sql);
- }
- }
- return 0;
- }
-
- // }}}
// {{{ function loadModule()
function loadModule($modname)
{/if}
<h1 class='right'>
- {if $nb_resultats_total==0}Aucune{else}{$nb_resultats_total}{/if} réponse{if $nb_resultats_total>1}s{/if}.
+ {if $nb_tot==0}Aucune{else}{$nb_tot}{/if} réponse{if $nb_tot>1}s{/if}.
</h1>
<div class="contact-list" style="clear:both">
{capture name=list}
- {section name=resultat loop=$resultats}
- {if $resultats[resultat].contact || $resultats[resultat].watch}
- {assign var="show_action" value="retirer"}
+ {iterate item=res from=$resultats}
+ {if $res.contact || $res.watch}
+ {include file=include/minifiche.tpl c=$res show_action="retirer"}
{else}
- {assign var="show_action" value="ajouter"}
+ {include file=include/minifiche.tpl c=$res show_action="ajouter"}
{/if}
- {include file=include/minifiche.tpl c=$resultats[resultat] show_action=$show_action}
- {/section}
+ {/iterate}
{/capture}
{$smarty.capture.list|smarty:nodefaults}
</div>
- {if $perpage < $nb_resultats_total}
+ {if $perpage < $nb_tot}
<p>
{if $offset!=0}
<a href="{$smarty.server.PHP_SELF}?{$url_args}&offset={$offset-$perpage}">Précédent</a>
{/if}
{/section}
- {if $offset < $nb_resultats_total-$perpage}
+ {if $offset < $nb_tot-$perpage}
<a href="{$smarty.server.PHP_SELF}?{$url_args}&offset={$offset+$perpage}">Suivant</a>
{/if}