<?php  return 'function elements_modsnippet_47($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
$trosk = $modx->getService(\'trosk\',\'Trosk\',$modx->getOption(\'doodles.core_path\',null,$modx->getOption(\'core_path\').\'components/trosk/\').\'model/trosk/\',$scriptProperties);
if (!($trosk instanceof Trosk)) return \'\';

$tekst[\'text\']=\'<p>Mjesto za vašu reklamu!</p>\';
$tpl=\'fem.banners.rightBanner\';
$criteria=$modx->newQuery(\'modResource\');
$criteria->where(array(
	\'published\' => 1,
	\'parent\' => $parent,
));
$criteria->sortBy(\'RAND()\');
$banners=$modx->getCollection(\'modResource\',$criteria);
if(empty($banners)) {
	$tpl=\'fem.banners.rightBannerEmpty\';
	for ($i = 0; $i < 8; $i++) {
		$output.=$modx->getChunk($tpl,$tekst);
	}
	return $output;
}
$ctxs = !empty($ctxs) ? $ctxs : $modx->context->get(\'key\');
if (!is_array($ctxs)) $ctxs = explode(\',\',$ctxs);
if (!$modx->user->hasSessionContext($ctxs)) {
	$i=0;
	foreach ($banners as $banner) {
		$zups=$banner->getTVValue(\'zupanije\');
		if(empty($zups)){
			$i++;
			$output.=$trosk->bannerCount($banner,$tpl);		
		}
		if ($i==8) break;
	}
	if($i<8){
		$tpl=\'fem.banners.rightBannerEmpty\';
		for ($k = $i; $k < 8; $k++) {
			$output.=$modx->getChunk($tpl,$tekst);
		}
	}
	return $output;
}
$profile=$modx->user->getOne(\'Profile\');
$userZups=unserialize($profile->get(\'photo\'));
$i=0;
foreach ($banners as $banner) {
	$zups=$banner->getTVValue(\'zupanije\');
	$zupsArray=explode(\'||\',$zups);
	$match=array_intersect($userZups,$zupsArray);
	if(empty($match) AND !empty($zups)) continue;
	$i++;
	$output.=$trosk->bannerCount($banner,$tpl);
	if ($i==8) break;
}
	if($i<8){
		$tpl=\'fem.banners.rightBannerEmpty\';
		for ($k = $i; $k < 8; $k++) {
			$output.=$modx->getChunk($tpl,$tekst);
		}
	}
	return $output;
}
';