<?php
class Gallery extends Controller
{
	function Gallery()
	{
		parent::Controller();
	}

	function index()
	{
        $data['title'] = hun() ? 'ARCHLine.XP Látványtervek' : 'ARCHLine.XP Showcase';
        $data['tartalom']='gallery/index';
        $data['javascript'] = array('interior_menu','fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack');
        $data['style'] = array('../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2');
		
		$this->load->view('site_new',$data);
	}
	
	function show(){
		$mappa = $this->uri->segment(2);
		$utvonal = "public/gallery/{$mappa}/";
		$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['title']      = hun() ? 'Galéria' : 'Gallery';
		$data['tartalom'  ] = 'gallery/show';
		$data['style']      = array('gallery');
		
		$this->load->view('site',$data);
	}
	
	function show2(){
		$this->load->model('mclusers');
		$mappa = $this->uri->segment(3);
		
		// email atalakitasa
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		
		
		$egyezes = "gallery/".$mappa;
		if(hun())
			$info = "Galéria megtekintve: ".$level->news_title." (http://archline.hu/gallery/".$mappa.")";
		else
			$info = "Has been seen: ".$level->news_title." (http://archlinexp.com/gallery/".$mappa.")";
		$hibainfo = "Uj galeria, {$mappa}";
		
		if(hun()){
			$this->mclusers->levelesemeny($email, "gallery", "show2", 63, $egyezes, $info, "hun", $hibainfo);
		}
		else{
			$this->mclusers->levelesemeny($email, "gallery", "show2", 178, $egyezes, $info, "eng", $hibainfo);
		}
		
		
		$user = $this->phpsession->get('user');
		$user['voltmobiloldal'] = true;
		$this->phpsession->save('user',$user);
		$mobil = $user['mobil'];
		
		redirect("gallery/".$mappa);
		return;
	}
	
}

?>