<?php
class Page extends Controller
{
	function Page()
	{
		parent::Controller();
	}
	
	function index()
	{
		redirect('');
	}
	
	function kapcsolat()
	{
		redirect('page/show/27');
	}
	
	function show()
	{
		$betoltlap = "site";
		
		$notitle = $this->uri->segment(4);
		if($notitle){
			$data['notitle']=true;
		}else{
			$data['notitle']=false;
		}
		
		$page_id = $this->uri->rsegment(3);
		// hibas korlevel link javitasara
		if( $page_id != "635" && substr($page_id,0,3) == "635" ){
			$this->load->model('mclusers');
			$email = str_replace("_",".",substr($page_id,3));
			$page_id = 635;
			
			
			$egyezes = "/page/show/635";
			$info = "Akció oldal megtekintve: archline.hu/page/show/635";
			$hibainfo = "Akció";
			
			$this->mclusers->levelesemeny($email, "events", "click", 138, $egyezes, $info, "hun", $hibainfo);
			
			redirect("page/show/635");
			
			$data['tartalom']='page/show';
			$data['csik']=array('home', $page->page_title);
			
			$data['page']=$page;
			
			$data['meta']['keyw'] .= ', '.$page->page_title;
			$data['title']='ARCHLine.XP ' . $page->page_title;
			
		//	$this->load->view($betoltlap,$data);
		}
		if(!$page_id || !is_numeric($page_id))
		{
			$page = $this->db->query("SELECT * FROM `cadline2`.`pages` WHERE page_url = '".$page_id."'")->result();
			if( count($page) != 1 )
				redirect('page');
			
			$page = $page[0];
			$data['tartalom']='page/show';
			$data['csik']=array('home', $page->page_title);
			
			switch($this->uri->segment(3)){
				case "partnerek":
					$data['style'] = array('style_2011');
					$data['notitle'] = true;
					$betoltlap = "site_new";
					break;
			}
			
			$data['page']=$page;
				
			$data['meta']['keyw'] = !hun() ? 'ARCHLine.XP, ARCHLine.XP 2011, Interior, Design, CAD, Architect, Architectural, Program, Software' : 'ARCHLine.XP, ARCHLine.XP 2011, Interior, Terv, Tervezés, CAD, Építész, Építészet, Belsőépítész, lakberendezés, program, szoftver';
			$data['meta']['keyw'] .= ', '.$page->page_title;
			$data['title']='ARCHLine.XP ' . $page->page_title;
			
			$this->load->view($betoltlap,$data);
		}
		else
		{
			$page=$this->mpages->get_row($page_id);
			if(!$page)
			{
				show_404();
			}
			else
			{
				$data['tartalom']='page/show';
				$data['csik']=array('home', $page->page_title);
				
				switch($this->uri->segment(3))
				{
					case 278:
					    $data['javascript'] = array('intkit/JavaScriptFlashGateway');
					    break;

                    case 279:
					    $data['javascript'] = array('intkit/JavaScriptFlashGateway');
					    break;
                        
                    case 437:
					    $data['javascript'] = array('intkit/JavaScriptFlashGateway');
					    break;
                        
                    case 436:
                        $data['javascript'] = array('intkit/JavaScriptFlashGateway');
					    break;
					case 92:
					case 556:
					case 818:
                        $data['javascript'] = array('fancybox/jquery-1.3.2.min','fancybox/jquery.easing.1.3','fancybox/jquery.fancybox-1.2.1.pack','fancybox/fancy');
                        $data['style'] = array('fancybox2');
					    break;
					case 590:
						redirect('webrender');
					    break;
					case 625:
						$data['style'] = array('style_2011');
						$data['notitle'] = true;
						$betoltlap = "site_new";
					    break;
					case 703:
						include('application/helpers/video.php');
						$videok1 = $this->db->query("SELECT * FROM videos WHERE csoport='OktatoiVizsgaFelkeszito_01' AND sorszam > 0 ORDER BY sorszam")->result();
						$csoport1 = $this->db->query("SELECT * FROM videogroups WHERE azon='OktatoiVizsgaFelkeszito_01'")->row();
						$videohtml1 = video_strcsere('OktatoiVizsgaFelkeszito_01',$csoport1,$videok1);
						
						$videok2 = $this->db->query("SELECT * FROM videos WHERE csoport='OktatoiVizsgaFelkeszito_02' AND sorszam > 0 ORDER BY sorszam")->result();
						$csoport2 = $this->db->query("SELECT * FROM videogroups WHERE azon='OktatoiVizsgaFelkeszito_02'")->row();
						$videohtml2 = video_strcsere('OktatoiVizsgaFelkeszito_02',$csoport2,$videok2);
						
						$videok3 = $this->db->query("SELECT * FROM videos WHERE csoport='OktatoiVizsgaFelkeszito_03' AND sorszam > 0 ORDER BY sorszam")->result();
						$csoport3 = $this->db->query("SELECT * FROM videogroups WHERE azon='OktatoiVizsgaFelkeszito_03'")->row();
						$videohtml3 = video_strcsere('OktatoiVizsgaFelkeszito_02',$csoport3,$videok3);
						
						$page->page_body = str_replace('#OktatoiVizsgaFelkeszito_01#',$videohtml1,$page->page_body);
						$page->page_body = str_replace('#OktatoiVizsgaFelkeszito_02#',$videohtml2,$page->page_body);
						$page->page_body = str_replace('#OktatoiVizsgaFelkeszito_03#',$videohtml3,$page->page_body);
						
						$data['style']      = array( 'jquery.jscrollpane' );
						$data['javascript'] = array(
									'jquery.mousewheel.min',
									'jscrollpane/jquery.jscrollpane.min',
									'video'
								);
						
						break;
				}
				
				if($page_id==433){
					Header("HTTP/1.1 301 Moved Permanently");
					Header("Location: /interior/lakberendezo_iskolak");
					exit;
				}
				
				$data['page']=$page;
				
				$data['meta']['keyw'] = !hun() ? 'ARCHLine.XP, ARCHLine.XP 2009, Interior, Design, CAD, Architect, Architectural' : 'ARCHLine.XP, ARCHLine.XP 2011, Interior, Terv, Tervezés, CAD, Építész, Építészet, Belsőépítész';
				$data['meta']['keyw'] .= ', '.$page->page_title;
				$data['title']='ARCHLine.XP ' . $page->page_title;
				
				$this->load->view($betoltlap,$data);
			}
		}
	}
}
?>