<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.8 www.exoops.info 2006/03
// 
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Pascal Le Boustouller
// Author Website : http://www.perso-search.com/e-xoopsien/
// Licence Type   : GPL
// ------------------------------------------------------------------------- //
function annonces_show(){
	global $db, $bcoosConfig, $ynprice, $myts;
		$block = array();
	$block['title'] = _MB_CLA_TITLE;
	
	include(XOOPS_ROOT_PATH."/modules/MyAnnonces/cache/config.php");
	
if ($affichebloc == '1') {	
	 $result=$db->query("SELECT lid, title, type FROM ".$db->prefix("ann_annonces")." WHERE valid='Yes' ORDER BY date DESC LIMIT $newclassifieds");
	while(list($lid, $title, $type)=$db->fetchRow($result)){
	
	$type = $myts->makeTboxData4Show($type);
	$title = $myts->makeTareaData4Show($title);
	
	
		if ( strlen($title) > 14 ) {
			$title = substr($title, 0, 14)."..";
		}
	
	
	    $block['content'] .= "<div style='text-align: left;'>- $type : <A HREF=\"".XOOPS_URL."/modules/MyAnnonces/index.php?pa=viewannonces&lid=$lid\">$title</A><br /></div>";
        }
		$block['content'] .= "<DIV ALIGN=\"right\"><A HREF=\"".XOOPS_URL."/modules/MyAnnonces/\">"._MB_CLA_ALLANN."</A></DIV>";
        return $block;
}
		
	
if ($affichebloc == '2') {
	list($numrows) = $db->fetchRow($db->query("SELECT  COUNT(*)  FROM ".$db->prefix("ann_annonces")."  WHERE valid='Yes'"));
    if ($numrows>1) {
	$numrows = $numrows-1;
	mt_srand((double)microtime()*1000000);
	$calba = mt_rand(0, $numrows);
    } else {
	$calba = 0;
    }
        $result = $db->query("SELECT lid, title, type, price, typeprix, description, town, country FROM ".$db->prefix("ann_annonces")."  WHERE valid='Yes' LIMIT $calba,1");
	while(list($lid, $title, $type, $price, $typeprix, $description, $town, $country)=$db->fetchRow($result)){
	
	$title = $myts->makeTboxData4Show($title);
	$type = $myts->makeTboxData4Show($type);
	$description = $myts->makeTboxData4Show($description);
	$price = $myts->makeTboxData4Show($price);
	$typeprix = $myts->makeTboxData4Show($typeprix);
	$town = $myts->makeTboxData4Show($town);
	$country = $myts->makeTboxData4Show($country);
        $block['content'] .= "<div style='text-align: left;'>+ $type : <A HREF=\"".XOOPS_URL."/modules/MyAnnonces/index.php?pa=viewannonces&lid=$lid\">$title</A><br />$description";
		if ($ynprice == 1) {
		if ($price > 0) { $block['content'] .= "<br />$price $monnaie $typeprix"; }
		}
        $block['content'] .= "<br />$town $country</div>";
		}
		$block['content'] .= "<DIV ALIGN=\"right\"><A HREF=\"".XOOPS_URL."/modules/MyAnnonces/\">"._MB_CLA_ALLANN."</A></DIV>";
        return $block;
}
		
}
?>