<?php
class View
{
private $_path;
private $_vars;
/**
* Constructeur de la classe
*
* @param unknown_type $path
*/
public function __construct ($path)
{
$this->_path = $this->createPath($path);
}
/**
* Admet une varriable cree a la volé
*
* @param string $key
* @param mix $val
*/
public function __set ($key, $val)
{
$this->_vars[$key] = $val;
}
/**
* Retourne la valeur cree par le __set() magique
*
* @param string $key
* @return mix
*/
public function __get ($key)
{
return $this->_vars[$key];
}
/**
* Netoie les valeurs en sortie
*
* @param string $var
* @return string
*/
public function escape ($var)
{
}
/**
* Cree le chemin d'accee des templates
*
* @param string $path
* @return string
*/
protected function createPath ($path)
{
$dir =
rtrim ($path,
"\\/" . DIRECTORY_SEPARATOR
) . DIRECTORY_SEPARATOR;
return $dir;
}
/**
* Cree le chemin d'acce complet
* ver le fichier
*
* @param string $file
* @return string
*/
protected function createContent ($file)
{
$full = $this->_path . $file;
return $this->_path . $file;
else throw new Exception("<b>{$file}</b> n'est pas present dans {$this->_path}");
}
/**
* Rendu d'un fichier
*
* @param mix $file
* @return string
*/
public function render ($file)
{
$content = $this->createContent ($file);
include ($content);
}
}