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

	function index(){
		redirect("videok/tapasztalt");
		
		/*$nyelv = hun() ? "hun" : "eng";
		$videokvegyes = $this->db->query("SELECT * FROM videos WHERE sorszam > 0 AND nyelv='{$nyelv}' ORDER BY sorszam")->result();
		
		$videok = array();
		foreach($videokvegyes as $video){
			$csoport = $video->csoport;
			if( !is_array($videok[$csoport]) )
				$videok[$csoport] = array();
			
			$videok[$csoport][] = $video;
		}
		
		$lap = $this->mpages->get_row(715);
		foreach($videok as $k=>$v){
			$csere = '#'.$k.'#';
			$lap->page_body = str_replace($csere,$this->strcsere($k,$videok[$k]),$lap->page_body);
		}
		
		$data['videok']      = $videok;
		$data['lap']         = $lap;
		$data['style']       = array( 'jquery.jscrollpane' );
		$data['javascript']  = array(
					'jquery.mousewheel.min',
					'jscrollpane/jquery.jscrollpane.min'
				);
		
		$data['title']    = hun() ? 'ARCHLine.XP Oktatóvideók' : 'ARCHLine.XP videos';
        $data['tartalom'] = 'oktatovideok/index';
		
		$this->load->view('site',$data);*/
	}
	
	function email(){
		$this->load->model('mclusers');
		$fv = $this->uri->segment(3);
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		
		$user = $this->phpsession->get('user');
		$user['voltmobiloldal'] = true;
		$this->phpsession->save('user',$user);
		$link = $this->uri->segment(1)."/".$fv;
		
		$egyezes = "Videók megtekintve: ".$_SERVER['SERVER_NAME']."/".$link;
		$info = "Videók megtekintve: ".$_SERVER['SERVER_NAME']."/".$link;
		$hibainfo = "Videók: ".$link;
		
		$nyelv = (hun()) ? "hun" : "eng";
		if(UJUGYFELKEZELO===true){
			$nTopicID = (hun()) ? 270 : 0;
		}else{
			$nTopicID = (hun()) ? 172 : 0;
		}
		
		$this->mclusers->levelesemeny($email, "videok", "email", $nTopicID, $egyezes, $info, $nyelv, $hibainfo);
		redirect($link);
	}
	
	/* magyar videó oldalak */
	
	function kezdo(){
		$lapid = 716;
		$this->eloallit($lapid,' kezdő felhasználóknak');
		return;
	}
	
	function halado(){
		$lapid = 813;
		$this->eloallit($lapid,' haladó felhasználóknak');
		return;
	}
	
	function profi(){
		$lapid = 717;
		$this->eloallit($lapid,' profi felhasználóknak');
		return;
	}
	
	function workshop(){
		$lapid = 814;
		$this->eloallit($lapid,' workshop oktatóvideók');
		return;
	}
	
	function bemutato(){
		$lapid = 815;
		$this->eloallit($lapid,' bemutató videók');
		return;
	}
	
	/* End magyar videó oldalak */
	
	function tapasztalt(){
		$lapid = 715;
		$this->eloallit($lapid,' tapasztalt felhasználóknak');
		return;
	}
	
	/* angol videó oldalak */
	
	function beginner(){
		$lapid = 718;
		$this->eloallit($lapid,' for new users');
		return;
	}
	
	
	function familiar(){
		$lapid = 719;
		$this->eloallit($lapid," - Familiar");
		return;
	}
	
	function expert(){
		$lapid = 720;
		$this->eloallit($lapid," - Expert");
		return;
	}
	
	function workshops(){
		$lapid = 816;
		$this->eloallit($lapid,' - Workshops');
		return;
	}
	
	function presentations(){
		$lapid = 817;
		$this->eloallit($lapid,' - Interior design projects using ARCHLine.XP');
		return;
	}
	
	/* End angol videó oldalak */
	
	
	
	function strcsere($csoport,$videok){
		$csoport2 = $this->db->query("SELECT * FROM videogroups WHERE azon='{$csoport}'")->row();
		$ret = "";
		$ret .= "<div style=\"background: url('/public/img/welcome/2012/box_video.png') no-repeat; margin-left: -17px; width: 970px;\">\n";
		$ret .= "	<div id=\"vh{$csoport}\" title=\"The Second Video\" style=\"height: 350px; width: 425px; float: left; padding: 13px 20px 10px 12px; margin-top: 0px;\">\n";
				
		$ret .= "		<object width=\"425\" height=\"349\">\n";
		$ret .= "		<param name=\"movie\" value=\"http://www.youtube.com/v/{$videok[0]->youtubeid}?fs=1&amp;hl=hu_HU\"></param>\n";
		$ret .= "		<param name=\"allowFullScreen\" value=\"true\"></param>\n";
		$ret .= "		<param name=\"allowscriptaccess\" value=\"always\"></param>\n";
		$ret .= "		<param name=\"wmode\" value=\"opaque\"></param>\n";
		$ret .= "		<embed src=\"http://www.youtube.com/v/{$videok[0]->youtubeid}?fs=1&amp;hl=hu_HU\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"349\" allowscriptaccess=\"always\" allowfullscreen=\"true\" wmode=\"opaque\"></embed>\n";
		$ret .= "		</object>\n";
		$ret .= "	</div>\n";
		$ret .= "	<div id=\"videojobb\" style=\"height: 378px; width: 515px; margin-left: 450px;\">\n";
		$ret .= "		<div class=\"welboxtit\" style=\"padding-top: 10px;\"><strong>{$csoport2->cim}</strong></div>\n";
		$ret .= "		<div style=\"margin: 0px 5px 0px 5px;\">{$csoport2->leiras}</div>\n";
				
		$ret .= "		<div class=\"videoklistakeret scroll-pane\" style=\"width: 500px; height: 300px;\">\n";
				
			foreach($videok as $video){
		$ret .= "		<div style=\"height: 58px; overflow: hidden; cursor: pointer; padding: 5px;\" class=\"video\" rel=\"{$video->youtubeid}\" name=\"{$csoport}\">\n";
		
		if(!file_exists($video->kep)){
			$ret .= "			<img src=\"http://i1.ytimg.com/vi/".$video->youtubeid."/default.jpg\" style=\"float: left; width: 60px; height: 48px; margin-right: 5px;\" alt=\"{$video->cim}\" />\n";
		}
		else
			$ret .= "			<img src=\"/{$video->kep}\" style=\"float: left; width: 60px; height: 48px; margin-right: 5px;\" alt=\"{$video->cim}\" />\n";
		
		$ret .= "			<h3 style=\"margin: 0px 0px 4px 65px; font-weight: bold;\">{$video->cim}</h3>\n";
		$ret .= $video->leiras;
		$ret .= "		</div>\n";
		$ret .= "		<div class=\"clear\"></div>\n";
			}
				
				
		$ret .= "		</div>\n";
				
		$ret .= "	</div>\n";
		$ret .= "</div>";
		
		return $ret;
	}
	
	function eloallit($lapid,$title=""){
		$nyelv = hun() ? "hun" : "eng";
		//$videokvegyes = $this->db->query("SELECT * FROM videos WHERE sorszam > 0 AND nyelv='{$nyelv}' ORDER BY sorszam")->result();
		$videokvegyes = $this->db->query("SELECT * FROM videos WHERE sorszam > 0 ORDER BY sorszam")->result();
		
		$videok = array();
		foreach($videokvegyes as $video){
			$csoport = $video->csoport;
			if( !is_array($videok[$csoport]) )
				$videok[$csoport] = array();
			
			$videok[$csoport][] = $video;
		}
		
		$lap = $this->mpages->get_row($lapid);
		foreach($videok as $k=>$v){
			$csere = '#'.$k.'#';
			$lap->page_body = str_replace($csere,$this->strcsere($k,$videok[$k]),$lap->page_body);
		}
		
		$data['videok']      = $videok;
		$data['lap']         = $lap;
		$data['style']       = array( 'jquery.jscrollpane' );
		$data['javascript']  = array(
					'jquery.mousewheel.min',
					'jscrollpane/jquery.jscrollpane.min'
				);
		
		$data['title']    = hun() ? 'ARCHLine.XP Oktatóvideók '.$title : 'ARCHLine.XP videos '.$title;
        $data['tartalom'] = 'oktatovideok/index';
		
		$this->load->view('site',$data);
	}
	
}
?>