File: D:/HostingSpaces/SBogers68/resortouddorpduin.nl/wwwroot/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($input, $includes = TRUE)
{
// Include header
if($includes) include DOCUMENT_ROOT . 'app/views'. LANG_ROOT .'includes/v_header.php';
// Include views
if(is_array($input))
{
foreach($input as $name)
{
include DOCUMENT_ROOT . 'app/views'. LANG_ROOT . $name . '.php';
};
}
else
{
//echo DOCUMENT_ROOT . 'app/views/' . $input . '.php';
//exit;
include DOCUMENT_ROOT . 'app/views'. LANG_ROOT . $input . '.php';
}
// Include footer
if($includes) include DOCUMENT_ROOT . 'app/views'. LANG_ROOT .'includes/v_footer.php';
if(LANG_ROOT == '/nl/' && $includes) include DOCUMENT_ROOT . 'app/views'. LANG_ROOT .'includes/v_popup.php';
if($includes) include DOCUMENT_ROOT . 'app/views'. LANG_ROOT .'includes/v_cookie.php';
}
}