File: D:/HostingSpaces/SBogers10/lab.komma-mediadesign.nl/wwwroot/poc/lib/mvc/view.class.php
<?php
/**
* view.class.php
* Created by Komma Mediadesign.
* Author: mike
* Date: 3/19/13
*/
class View
{
/*
* @property array $_data
* This array holds the data which is set for the view.
* Data is set by a controller.
*/
private $_data = array();
/*
* Language
*/
protected $lang = array();
protected $urls = array();
public function __construct(){}
/*
* Sets the data for the view
*/
public function setData($name, $value)
{
if(!empty($name))
{
$this->_data[$name] = $value;
}
}
/*
* Set the language property
*/
public function setLang($lang, $urls)
{
$this->lang = $lang;
$this->urls = $urls;
}
/*
* Gets the data from the $_data array to use in the view
*/
public function getData($name, $echo = true)
{
$value = '';
if( ! empty($name) && isset($this->_data[$name]))
{
$value = $this->_data[$name];
}
if($echo)
{
echo $value;
return false;
}
return $value;
}
/*
* Renders the view
*/
public function render($name, $includes = TRUE)
{
$url = DOCUMENT_ROOT . 'app/views/' . $name . '.php';
if($includes) include DOCUMENT_ROOT . 'app/views/includes/v_header.php';
include $url;
if($includes) include DOCUMENT_ROOT . 'app/views/includes/v_footer.php';
}
}