<?php
class imprimir{

	var $url_template;
	var $name_template;
	
	function imprimir($url,$name){
		
		$this->url_template=$url;
		$this->name_template=$name;
		
	}

	function web(){		
		$print['template']=$_SESSION['select_template'];	
		
		if($_SESSION['npaso']!=1){								
				$content='<a href="index.php?step=less'.$_SESSION['back_extra'].'"><img src="img/general/left.png"align="left" border="0"></a>';
				$content.='<div class="centrar">';
		}
		$_SESSION['back_extra']='';
			$content.='<form name="form1" action="index.php'.$_SESSION['form_extra'].'" method="post">';
			$_SESSION['form_extra']='';
			$content.=$_SESSION['contenido'];
			$content.='</div>';
		if(($_SESSION['npaso']==count($GLOBALS['arrayStep']))||($_SESSION['npaso']==1)){								

//				$content.='<a href="index.php"><img src="img/general/right.png"align="right" border="0"></a>';
		}else{
				$content.='<a class="enlace" href="#" onclick="document.forms.form1.submit();return false">
					      <img src="img/general/right.png" align="right" class="go_left" border="0" alt="enviar"></a></form>';
		}

		$print['contenido']=$content;
		$template="step/struct/interface/index.html";	
		$print['url']=$this->url_template.$this->name_template;
	//------------------------------------------------------------------------------		
	//     Creacion del CSS 
	//------------------------------------------------------------------------------	
		$url1=$this->name_template."estilo/estilo.css";
		$url2=$_SESSION['css'];
		//$url3="../template/001/001.css";		
		if(!isset($_SESSION['js'])){
			$print['js']='';
		}else{
			$print['js']=$_SESSION['js'];
		}
		
		if(!isset($_SESSION['css_step'])){
			$url3='';
		}else{
			$url3=$_SESSION['css_step'];
		}		
		$print['css']=$this->url_template."_estilo.php?template_web=".$url1."&template=".$url2."&step=".$url3;
	//------------------------------------------------------------------------------		
		$template=$this->url_template.$this->name_template."index.html";	
		
		$imprimir=$this->template($template,$print);
		$_SESSION['contenido']='';
		
		return $imprimir;
	}

	function template($template,$config){
		$s=file_get_contents($template);
		foreach ($config as $i=>$v) {
			$s=str_replace("{".$i."}",$v,$s);
		}
		
		return $s;		
	}
}
/*
class imprimir{

	var $url_template;
	var $name_template;
	
	function imprimir($url,$name){
		
		$this->url_template=$url;
		$this->name_template=$name;
		
	}

	function web($datos){		
		$print['template']=$datos['template'];							
		$print['contenido']=$datos['contenido'];

		$template="step/struct/interface/index.html";	
		$print['url']=$this->url_template.$this->name_template;
	//------------------------------------------------------------------------------		
	//     Creacion del CSS 
	//------------------------------------------------------------------------------	
		$url1=$this->name_template."estilo/estilo.css";
		$url2="../step/struct/interface/estilo/estilo.css";
		//$url3="../template/001/001.css";		
		$print['css']=$this->url_template."_estilo.php?template_web=".$url1."&template=".$url2."&step=".$url3;
	//------------------------------------------------------------------------------		
		$template=$this->url_template.$this->name_template."index.html";	
		
		$imprimir=$this->template($template,$print);
		
		return $imprimir;
	}

	function template($template,$config){
		$s=file_get_contents($template);
		foreach ($config as $i=>$v) {
			$s=str_replace("{".$i."}",$v,$s);
		}
		
		return $s;		
	}
}*/
?>
