HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/lab.komma-mediadesign.nl/wwwroot/lab/lib/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();

    /*
     * @property array $urls
     */
    protected $urls;

    public function __construct(){ }

    /*
     * Sets the data for the view
     *
     * @param string $name
     * @param mixed $value
     */
    public function setData($name, $value)
    {
        if(!empty($name))
        {
            $this->_data[$name] = $value;
        }
    }

    /*
     * Gets the data from the $_data array to use in the view
     *
     * @param string $name
     * @param mixed $value
     */
    public function getData($name, $echo = true)
    {
        $value = '';
        if(!empty($name))
        {
            if(isset($this->_data[$name]))
            {
                $value = $this->_data[$name];
            }
            else
            {
                return false;
            }
        }
        if($echo)
        {
            echo $value;
            return false;
        }
        return $value;
    }

    /*
     * Renders the view
     *
     * @param string $name - tells us which view to load.
     * @param boolean $includes - checks if we need to include the header and the footer
     */
    public function render($name, $includes = TRUE)
    {
        $url = DOCUMENT_ROOT . 'views/' . $name . '.php';

        if($includes) include DOCUMENT_ROOT . 'views/includes/v_header.php';
        include $url;
        if($includes) include DOCUMENT_ROOT . 'views/includes/v_footer.php';
    }
}