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/spire.komma-mediadesign.nl/wwwroot/mvc/models/m_siteTemplate.php
<?php

/**
 * Spire
 *
 * Created By: Komma Mediadesign
 * Author: Mike van der Sanden
 * January 2013
 *
 */


class SiteTemplate
{

    /*
     * @property mixed data
     */
    private $_data;

    public $shoppingCart;

    /*
     * @property array lang
     * Language property, set in Template, accessible from every file.
     */
    public $lang = array();

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->_data = array();

        /**
         * Generate shopping cart
         */
        $this->shoppingCart = new ShoppingCart();

    }



    /*

        SETTER / GETTER

    */


    /**
     * Sets data for later use by the view
     *
     * @access public
     * @param string $name
     * @param string $value
     * @return void
     */
    public function setData($name,$value)
    {
        $this->_data[$name] = $value;
    }

    /**
     * Retrieves data based on provided name for access by view
     *
     * @access public
     * @param string $name
     * @param bool $echo
     * @return mixed
     */
    public function getData($name, $echo=TRUE)
    {
        if(isset($this->_data[$name]))
        {
            if($echo)
            {
                echo $this->_data[$name];
            }
            else{
                return $this->_data[$name];
            }
        }
        return FALSE;
    }


    /*

        LOAD / REDIRECT

    */


    /**
     * Loads specified url
     *
     * @access public
     * @param string
     * @return void
     */
    public function load($url)
    {
		
		if(strpos($url, $_SERVER['DOCUMENT_ROOT']) === false) $url = $_SERVER['DOCUMENT_ROOT'].'/'.$url;
		$url = str_replace('//','/', $url);
		include $url;
    }

    /**
     * Redirects to specified url
     *
     * @access public
     * @params string
     * @return null
     */
    public function redirect($url)
    {
        header('location:'.$url);
        exit;
    }

    /**
     * Redirects to specified url
     *
     * @access public
     * @params string
     * @return null
     */
    public function notFound()
    {
        header("HTTP/1.0 404 Not Found");
        header('location:'.SITE_ROOT.'404');
        exit;
    }

    public function printr($data)
    {
        echo '<pre>';
        print_r($data);
        echo '</pre>';
    }


    /*

        Convert Data

    */


    /**
     * Converts string into url string.
     *
     * @access public
     * @param string
     * @return string
     */
    public function encodeUrl($input)
    {
        $output = trim($input);
        $output = str_replace(' ','-',$output);

        //remove these characters
        $forbidden = array("'", '"', '\\', '/', ';', ';', '|', '>', '<', '[', ']', '!','?', '@', '#', '$', '%', '^', '&', '*', '(', ')','+','=','{','}','`', '~', '.', ',',);
        foreach($forbidden as $key => $value){
            $output = str_replace($value, '', $output);
        }
        $output = strtolower($output);

        //mdash
        $output = str_replace('–','-',$output);

        $output = str_replace('--','',$output);
        $output = str_replace('---','',$output);

        return $output;
    }

    /**
     * Encodes string into a valid Database name
     *
     * @access public
     * @param string
     * @return string
     */
    public function encodeDbName($input)
    {
        $input = $this->encodeUrl($input);
        $words = explode('-',$input);

        $dbName = '';
        foreach($words as $key => $word)
        {
            if($key > 0)
            {
                $word = ucfirst($word);
            }
            $dbName .= $word;
        }
        return $dbName;
    }

    public function camelCase($label)
    {
        $label = str_replace('-',' ',$label);
        $label = str_replace('_',' ',$label);
        $words = explode(' ',$label);

        $output = '';
        foreach($words as $i => $word)
        {
            $word = strtolower($word);
            if($i != 0) $word = ucfirst($word);
            $output .= $word;
        }
        return $output;
    }
}