<?php

class Welcome extends Controller {

	function __construct()
	{
		parent::Controller();
	}
	
	function index(){
    header("Location: /partners/");
    exit();


		$this->index2014();
		return;
		
		/*if( strstr($_SERVER['SCRIPT_URI'],'http://') ){
			header("Location: https://".$_SERVER['HTTP_HOST']);
			exit;
		}*/
		
		$data['javascript'] = array(
					'welcome',
					'jsor-jcarousel/lib/jquery.jcarousel.min',
					
					'jquery.mousewheel.min',
					'jscrollpane/jquery.jscrollpane.min'/*,
					
					'gallery2012'*/,
					
					'fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack',
					'choco-slider/jquery.chocoslider'
				);
				
		$data['style'] = array(
					'lapozo_min',
					/*'jquery.jscrollpane_min',*/
					'../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2_min',
					'choco-slider/chocoslider'
				);
		
		
		$order   = array("\r\n", "\n", "\r");
		$replace = '<br />';
		$nyelv   = $this->muser->user['lang'];
		
		$dobozok = $this->cache->get('welcome-dobozok-'.$nyelv);
		$foinfo = $this->cache->get('foinfo-dobozok-'.$nyelv);

		if( !$dobozok || !$foinfo ){
			$dobozok = $this->db->query("SELECT * FROM welcome_box WHERE sorszam>0 AND nyelv='{$nyelv}' ORDER BY sorszam")->result();
			
			foreach($dobozok as $doboz){
				$doboz->infok = $this->db->query("SELECT * FROM welcome_info WHERE doboz=".$doboz->id." AND sorszam>0 AND nyelv='{$nyelv}' ORDER BY sorszam")->result();
				
				// új sorok cseréje html-es új sorra ..
				foreach($doboz->infok as $info){
					$info->info = str_replace($order, $replace, $info->info);
				}
			}
			
			$foinfo = $this->db->query("SELECT * FROM welcome_info WHERE doboz=0 AND sorszam=100 AND nyelv='{$nyelv}' ORDER BY sorszam")->row();
			$foinfo->info = str_replace($order, $replace, $foinfo->info);
				
			$this->cache->write($dobozok, 'welcome-dobozok-'.$nyelv, 6000000);
			$this->cache->write($foinfo, 'foinfo-dobozok-'.$nyelv, 6000000);
		}
		
		$data['dobozok'] = $dobozok;
		$data['fo_info'] = $foinfo;
		
		$data['title'] = hun() ? "ARCHLine.XP építészeti, belsőépítészeti és lakberendezési tervezőprogram" : "ARCHLine.XP CAD software, Architect and Interior design";
		
		$data['utvonal'] = 'public/img/banner405/';
		/*$kepek = array();
		$kepek[0] = new stdClass();
		$kepek[0]->img = 'banner_KBB_2013.jpg';
		$kepek[0]->link = '/news/show/kbb-2013';
		$kepek[1] = new stdClass();
		$kepek[1]->img = 'bathroom_design_banner_2013.jpg';
		$kepek[1]->link = '/newsletter/show/bathroom-design';
		$kepek[2] = new stdClass();
		$kepek[2]->img = 'furniture_design_banner_2013.jpg';
		$kepek[2]->link = '/newsletter/show/modelling-furniture-design';
		$kepek[3] = new stdClass();
		$kepek[3]->img = 'kitchen_design_banner_2013.jpg';
		$kepek[3]->link = '/newsletter/show/kitchen-design';
		$kepek[4] = new stdClass();
		$kepek[4]->img = 'virtual_staging_banner_2013.jpg';
		$kepek[4]->link = '/newsletter/show/virtual_staging';*/
		
		$most = time();
		$kepek = $this->db->query("SELECT title, filename img, link FROM welcome_banner2 WHERE lang='{$nyelv}' AND position>0 AND start_date<{$most} AND stop_date>{$most} ORDER BY position")->result();
		
		$data['kepek'] = $kepek;
		
		$data['home']=true;
		
		//if(!hun() /*$this->uri->segment(3)=="newgallery"*/)
			$data['tartalom'] = "welcome_2013_jsgallery";
		/*else
			$data['tartalom'] = "welcome_2013_youtube";*/
		
		$this->load->view('site_wel2012',$data);
		
	}
	
	
	function gallery(){
		$data['kepek']      = scandir('public/img/gallery2012/');
		
		$data['tartalom']   = 'other/gallery';
		
		$data['javascript'] = array('choco-slider/jquery.chocoslider.min');
		$data['style']      = array('../js/choco-slider/chocoslider');
		
	//	$data['javascript'] = array('slides/slides.min.jquery');
	//	$data['style']      = array('sliders');
		
	//	$data['javascript'] = array('smart-gallery/smart-gallery.min');
	//	$data['style']      = array('../js/smart-gallery/smart-gallery');
		
		$this->load->view('site_new',$data);
	}
	
	function interiorgallery(){
		$utvonal = 'public/img/gallery2012/';
		
		$kepek       = scandir($utvonal);
		
		unset($kepek[0],$kepek[1]);
		
		if( is_dir($utvonal."thumbs/") ){
			$kiskepek = scandir($utvonal."thumbs/");
			unset($kiskepek[0],$kiskepek[1]);
		}
		
		foreach($kepek as $kep){
			if( !is_dir( $utvonal.$kep ) ){
					$data['elsokep'] = $utvonal.$kep;
				
				break;
			}else{
				unset($kep);		// ???
			}
		}
		
		$data['utvonal'] = $utvonal;
		$data['kepek']   = $kepek;
		$data['iframeurl'] = '/multimedia/imagegallery/cHVibGljL2ltZy9nYWxsZXJ5MjAxMi8=';
		
		$data['tartalom'] = 'other/iframe';
		$this->load->view('site',$data);
	}
	
	function index2014(){
		$data['javascript'] = array(
					'welcome',
					'jsor-jcarousel/lib/jquery.jcarousel.min',
					
					'jquery.mousewheel.min',
					'jscrollpane/jquery.jscrollpane.min',
					
					'fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack',
					'choco-slider/jquery.chocoslider'
				);
				
		$data['style'] = array(
					'lapozo_min',
					'../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2_min',
					'choco-slider/chocoslider'
				);
		
		
		$order   = array("\r\n", "\n", "\r");
		$replace = '<br />';
		$nyelv   = $this->muser->user['lang'];
		
		//$dobozok = $this->cache->get('welcome-dobozok-'.$nyelv);
		//$foinfo = $this->cache->get('foinfo-dobozok-'.$nyelv);
		
    if( true || !$dobozok || !$foinfo ){
			$dobozok = $this->db->query("SELECT * FROM welcome_box WHERE sorszam_2014>0 AND nyelv='{$nyelv}' ORDER BY sorszam_2014")->result();
			
			foreach($dobozok as $doboz){
				$doboz->infok = $this->db->query("SELECT * FROM welcome_info WHERE doboz=".$doboz->id." AND sorszam>0 AND nyelv='{$nyelv}' ORDER BY sorszam")->result();
				
				// új sorok cseréje html-es új sorra ..
				foreach($doboz->infok as $info){
					$info->info = str_replace($order, $replace, $info->info);
				}
			}
			
			$foinfo = $this->db->query("SELECT * FROM welcome_info WHERE doboz=0 AND sorszam=200 AND nyelv='{$nyelv}' ORDER BY sorszam")->row();
			$foinfo->info = str_replace($order, $replace, $foinfo->info);
			$dobozszam = hun() ? 26 : 25;
			$foinfolinkek = $this->db->query("SELECT * FROM welcome_info WHERE doboz={$dobozszam} AND (sorszam>0 or sorszam=-1) order by sorszam asc ")->result();
			$h1cim = $this->db->query("SELECT cim_2014 FROM welcome_box WHERE id = {$dobozszam}")->row();
				
			//$this->cache->write($dobozok, 'welcome-dobozok-'.$nyelv, 6000);
			//$this->cache->write($foinfo, 'foinfo-dobozok-'.$nyelv, 6000);
		}
		
		
		$data['dobozok'] = $dobozok;
		$data['fo_info'] = $foinfo;
		$data['foinfolinkek'] = $foinfolinkek;
		$data['h1cim'] = $h1cim->cim_2014;
		
		$data['title'] = hun() ? "ARCHLine.XP építészeti, belsőépítészeti és lakberendezési tervezőprogram" : "ARCHLine.XP, the Interior design software";
		
		$data['utvonal'] = 'public/img/banner405/';
		
		$most = time();
		$kepek = $this->db->query("SELECT title, filename img, link FROM welcome_banner2 WHERE lang='{$nyelv}' AND position>0 AND start_date<{$most} AND stop_date>{$most} ORDER BY position")->result();
		
		$data['kepek'] = $kepek;
		$data['home']=true;
		
		$data['tartalom'] = "welcome_2014";
		
		$this->load->view('site_wel2012',$data);
	}
	
}

/* End of file welcome.php */
