<?php
class Multimedia extends Controller
{
	function Multimedia()
	{
		parent::Controller();
		$this->load->model('mmedia');
		
		define("BENTIIPGALERIAHOZ",'78.92.184.211');
		define("RENDSZERGALERIAHOZ",'inuxdfsdf');
	}

	function index()
	{
		$data['lang']=$this->muser->user['lang'];
		$data['csik']=array('home','multimedia');
		$data['tartalom']='media/index';

		$data['title'] = hun() ? 'ARCHLine.XP Multimédia' : 'ARCHLine.XP Multimedia';
		
		$this->load->view('site',$data);	
	}
	
	
	function images()
	{
		$this->load->model('mgallery');
		
		$data['lang']  = $this->muser->user['lang'];
		$data['csik']  = array('home','multimedia','images');
        $data['title'] = hun() ? 'ARCHLine.XP Építészet galériája' : 'ARCHLine.XP Gallery of the Architect';
		$data['tartalom']='media/images';
		$data['mobilink']= "/mobile/galleryarchitect";
		
		$nyelv = hun() ? "hun" : "eng";
		$data['galeriak'] = $this->mgallery->get_all($nyelv,'architect');
		
		$this->load->view('site_new',$data);
	}
	
	function videos()
	{
		$data['lang']=$this->muser->user['lang'];
		$data['csik']=array('home','multimedia','videos');

		$data['title'] = hun() ? 'ARCHLine.XP Multimédia - Videók' : 'ARCHLine.XP Multimedia - Videos';
		$data['tartalom']='media/videos';
		
		$this->load->view('site',$data);
	}
	
	
	function play()
	{
		$data['file'] = $this->uri->segment(3);
		
		$x = $this->uri->segment(4);
		$y = $this->uri->segment(5);
		
		if(!$x) {$x = 800;}
		if(!$y) {$y = 600;}
		
		
		$data['x'] = $x;
		$data['y'] = $y;
		$this->load->view('media/play',$data);
		
		
	}
	
	function gallery()
	{
		$this->load->model('mgallery');
		$folder = $this->uri->segment(3);
		if($folder && $this->mgallery->checkFolder($folder))
		{
			//create thumbs if they are missing
			$this->mgallery->prepImages($folder);

            $data['tartalom'] = 'media/showimg';
			$data['javascript'] = array(
									'temp',
									'fancybox/jquery-1.3.2.min',
									'fancybox/jquery.easing.1.3',
									'fancybox/jquery.fancybox-1.2.1.pack',
									'fancybox/fancy'
									);

			$data['style'] = array('fancybox');

			//set the folder's name
			$data['folder'] = $folder;

			//load images from the folder
			$data['images'] = $this->mgallery->getImages($folder);

			$this->load->view('site',$data);
		}
		else
		{
            redirect('multimedia');
		}
	}
	
	function show_images()
	{
		$galeria = $this->uri->segment(3);
		if(!$galeria)
		{
			redirect('multimedia/images');
		}
		
		$kepek = $this->mmedia->prep_img_dir($galeria);
		if(!$kepek ||count($kepek)==0)
		{
			show_error('Nincs ilyen galéria');
		}
		else
		{
			$data['kepek']=$kepek;
			$data['galeria']=$galeria;
			$data['lang']=$this->muser->user['lang'];
			
			$data['fullpath']='/'.$this->mmedia->img_dir.$galeria.'/';
			
			$data['csik']=array('home','multimedia','images');
			
			$data['tartalom']='media/show_images';
			
			$data['javascript'] = array('lightbox');
			
			$data['title']='ARCHline.XP CAD Software - Image Gallery ' . substr($galeria, 7, 1);
			
			$this->load->view('site',$data);
		}
	}
	
	
	function imagegallery(){
		$p = $this->uri->segment(3);
	//	print "p: ".$p;
		$p = base64_decode($p);
	//	print " , p: ".$p;
		
		$utvonal = "";
		
		if( $p )
			$utvonal = $p;
		else
			$utvonal = 'public/img/services/gallery/';
		
		$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;
		
		$this->load->view('other/gallery2012',$data);
	}
	
}
?>