<?php
$module_dir = "wb_categories";
$module_css_path = ($line_domain['theme'] != "" && $line_domain['theme'] != "default") ? ($path . ('assets/themes/' . $line_domain['theme'] . '/')) : $path;

$bound_district_code = null;
$bound_district_name = null;
$districts = [];
$q = "SELECT * FROM cyprus_districts WHERE active='1' ORDER BY pos ASC;";
$r = @mysql_query($q);
if($r && mysql_num_rows($r) > 0) {
	while($row = mysql_fetch_assoc($r)) {
		$districts[$row['dcode']] = stripslashes($row['district']);
	}
}

if(isset($catdom_id) && intval($catdom_id)>0){
	$catdom_id_adv = $catdom_id;
}
else {
	$catdom_id_adv = $domain_id;
	$catdom_id = $domain_id;
}

if($catdom_id_adv != $domain_id) {
	// Try to find if maybe the catdom_id_adv reprezents a district
	$catdom_title = stripslashes($line_catdom_id['title_en']);
	//echo '<pre>', var_export($line_catdom_id, true), '</pre>';
	if(count($districts) > 0) {
		$_catdom_title = strtolower($catdom_title);
		foreach($districts as $d_code=>$d_name) {
			$_dname = strtolower($d_name);
			if(strpos($_catdom_title, $_dname) !== false) {
				$bound_district_code = $d_code;
				$bound_district_name = $d_name;
				break;
			}
		}
	}

}

$locations_map = array(
	"Famagusta"		=> "Famagusta",
	"Larnaca"		=> "Larnaca",
	"Limassol"		=> "Limassol",
	"Nicosia"		=> "Nicosia",
	"Paphos"		=> "Paphos"
);



if(file_exists($modules_path . "$module_dir/wb_categories_init.php")) {
	include($modules_path . "$module_dir/wb_categories_init.php");
	
	if(file_exists($modules_path . "$module_dir/wb_categories_default.php")) {

		/*$no_minify_domains = [

		];
		if(!in_array($_SERVER['HTTP_HOST'], $no_minify_domains)) {
			include($modules_path . "$module_dir/wb_categories_lazy_default.php");
		}
		else {
			include($modules_path . "$module_dir/wb_categories_default.php");
		}*/


		if(in_array($ultra_domainname, $use_json_schema)) {
			require_once(dirname(__FILE__) . "/wb_categories_lazy_schema.php");
		}
		else {
			require_once(dirname(__FILE__) . "/wb_categories_lazy_default.php");
		}


	}
	else {
		echo $modules_path . "$module_dir/wb_categories_default.php does not exist";
	}
}


	
if(isset($module_params)) {
	unset($module_params);
}
?>