<?php
class Compatibility extends Controller{
	
	function Compatibility(){
		parent::Controller();
	}
	
	function index(){
		
		/*$tmp = $this->uri->segments;
		$ttmp = explode('&',$tmp[1]);
		unset($ttmp[0]);
		$tp = explode('=',$ttmp[1]);
		if($tp[0]=="p")
			$arch_id = $tp[1];
		elseif($tp[0]=="lang")
			$lang = $tp[1];
		
		$tl = explode('=',$ttmp[2]);
		if($tl[0]=="p")
			$arch_id = $tl[1];
		elseif($tl[0]=="lang")
			$lang = $tl[1];*/
		
		if(isset($this->input->origget['lang']))
			$lang = $this->input->origget['lang'];
		if(isset($this->input->origget['p']))
			$arch_id = $this->input->origget['p'];
			
		
		$lang = mysql_real_escape_string($lang);
		$elemdesc = "";
		
		//print 'archid: '.$arch_id. " , lang: ".$lang;
		
		$page = $this->mpages->get_row(810);
		
		$cserek = $this->db->query("SELECT a_name, title, version FROM compatibility WHERE lang='eng'")->result();
		
		if($lang!='' && $lang!="eng"){
			foreach($cserek as $k=>$csere){
				$nyelvititle = $this->db->query("SELECT title FROM compatibility WHERE lang='{$lang}' AND a_name='{$csere->a_name}'")->row();
				if($nyelvititle->title){
					$cserek[$k]->title = $nyelvititle->title;
				}
			}
		}
		
		if($arch_id != ''){
			$a_name = mysql_real_escape_string($arch_id);
			$elem = $this->db->query("SELECT title, version FROM compatibility WHERE lang='{$lang}' AND a_name='{$a_name}'")->row();
			if(!$elem->title)
				$elem = $this->db->query("SELECT title, version FROM compatibility WHERE lang='eng' AND a_name='{$a_name}'")->row();
			if($elem->title){
				$page2 = $this->mpages->get_row(812);
				$page2->page_body = str_replace('#accessoryName#',$elem->title,$page2->page_body);
				$page2->page_body = str_replace('#minVersion#',$elem->version,$page2->page_body);
				$elemdesc = $page2->page_body;
			}
		}
		
		$page->page_body = str_replace('#elemleiras#',$elemdesc,$page->page_body);
		
		$data['tartalom'] = 'compatibility/index';
		$data['accessories'] = $cserek;
		$data['page'] = $page;
		
		$this->load->view('site',$data);
	}
	
	function details(){
		$arch_id = $_GET['archid'];
		$lang = $_GET['lang'];
		print "details";
	}
	
}
?>