<?php
// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting,
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds.
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------
// Recently Viewed by user listings
function block_Recently_Viewed(&$tpl, $args = ''){ // amount, hide_if_empty
global $db,$TITLE_FIELD,$HW_LANG;
$amt = isset($args['amount']) ? abs(intval($args['amount'])) : 10;
$a_v = hwSessionGetVar('b_RVA');
if(!is_array($a_v)) $a_v = array();
if(!array_key_exists($HW_LANG, $a_v)) $a_v[$HW_LANG] = array();
if($_GET['page']=='out') {
$id = (int)$_GET['id'];
if($id && !in_array($id, $a_v[$HW_LANG])){
array_unshift($a_v[$HW_LANG], $id);
while(count($a_v[$HW_LANG])>$amt) array_pop($a_v[$HW_LANG]);
hwSessionSetVar('b_RVA',$a_v);
}
}
if($args['hide_if_empty'] && empty($a_v[$HW_LANG])) return;
$tpl->AddCell('b_Recently_Viewed','','start');
$a_v = $a_v[$HW_LANG];
if($a_v) {
$ql = 'SELECT '.hwSQLFieldsGet().' FROM '.TBL_AD.' WHERE link_id IN ('.implode(',',$a_v).')'.hwFilterGetSQL().' LIMIT '.$amt;
$a_db = $db->getAssoc($ql, true, null, 'FETCH_ASSOC');
$num = 0;
foreach($a_v as $id){
if(!$a_db[$id]) continue;
$v = $a_db[$id];
$v['link_id'] = $id;
$v['num'] = ++$num;
$tpl->AddCell('b_Recently_Viewed',hwSQLRowGet($v),'row');
}
}
$tpl->AddCell('b_Recently_Viewed','','end');
}
?>