<?php
/*===================================================+
|| # HoloCMS - Website and Content Management System
|+===================================================+
|| # Copyright © 2008 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|+===================================================+
|| # HoloCMS is provided "as is" and comes without
|| # warrenty of any kind. HoloCMS is free software!
|+===================================================*/

if($bypass1 == true){
$page = "1";
}else{
require_once('../global.php');
$page = Filter($_POST['pageNumber']);
$widgetid = Filter($_POST['widgetId']);
}

$sql = mysql_query("SELECT userid FROM cms_homes_stickers WHERE id = '".$widgetid."' LIMIT 1");
$rrow1 = mysql_fetch_assoc($sql);
$user = $rrow1['userid'];
$offset = $page - 1;
$offset = $offset * 16;
$sql = mysql_query("SELECT * FROM user_badges WHERE user_id = '".$user."' ORDER BY badge_id DESC LIMIT 16 OFFSET ".$offset);
?>
    <ul class="clearfix">
	<?php while($rrow = mysql_fetch_assoc($sql)){ ?>
            <li style="background-image: url(<?php echo $cimagesurl.$badgesurl.$rrow['badge_id'].".gif"; ?>)"></li>
    <?php } ?>
    </ul>

<div id="badge-list-paging">
<?php
$sql = mysql_query("SELECT * FROM user_badges WHERE user_id = '".$user."' ORDER BY badge_id DESC");
$count = mysql_num_rows($sql);
$offset = $offset * 2;
$at = $page - 1;
$at = $at * 16;
$at = $at + 1;
$to = $offset + 16;

if($to > $count){ $to = $count; }
$totalpages = ceil($count / 16);
?>
    <?php echo $at; ?> - <?php echo $to; ?> / <?php echo $count; ?>
    <br/>
	<?php if($page != 1){ ?>
    <a href="#" id="badge-list-search-first" >Premier</a> |
    <a href="#" id="badge-list-search-previous" >&lt;&lt;</a> |
	<?php }else{ ?>
	Premier |
    &lt;&lt; |
	<?php } ?>
	<?php if($page != $totalpages){ ?>
    <a href="#" id="badge-list-search-next" >&gt;&gt;</a> |
    <a href="#" id="badge-list-search-last" >Dernier</a>
	<?php }else{ ?>
	&gt;&gt; |
    Dernier
	<?php } ?>
<input type="hidden" id="badgeListPageNumber" value="<?php echo $page; ?>"/>
<input type="hidden" id="badgeListTotalPages" value="<?php echo $totalpages; ?>"/>
</div>