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/SBogers59/ferrumbv.nl/wwwroot/lib/mvc/controller.class.php
<?php
/**
 * controller.class.php
 * Created by Komma Mediadesign.
 * Author: mike
 * Date: 3/19/13
 */

class Controller {

    /*
     * @property View
     * Contains a view object.
     */
    protected $View;

    /*
     * @property Model
     * Contains a model object.
     */
    protected $Model;


    /*
     * Language
     */
    protected $lang = array();
    protected $urls = array();

    public function __construct()
    {
        // Set language and url for conversion
        $Translator = new Translator(URL_LANG);
        $this->lang = $Translator->get();
        $this->urls = $Translator->getUrls();

    }

    /*
     * LoadModel checks if the requested file exists.
     * If so, it includes it in this template and creates a new Model;
     */
    public function loadModel($name)
    {
        $path = DOCUMENT_ROOT . 'app/models/m_' . strtolower($name) . '.class.php';
        if(file_exists($path))
        {
            if( ! class_exists($name . '_Model'))
            {
                require_once $path;
            }
            $modelName = ucfirst($name) . '_Model';

            // Create model
            $this->Model = new $modelName;

            // Make language available for model
            $this->Model->setLang($this->lang,$this->urls);
        }
    }

    /*
     * Initialise
     */
    public function init($name)
    {
        // Create new view
        $this->View = new View();

        // Set language for the view
        $this->View->setLang($this->lang,$this->urls);

        // Body Id
        $this->View->setData('body_id',strtolower($name));

        // Set menu
        $Menu = new Menu();
        $mainMenu = $Menu->createMain();
        $this->View->setData('main_menu',$mainMenu);
    }

}