<?php

define('DB_HOSTNAME', '127.0.0.1');
define('DB_DATABASE', 'nashvand_web');
define('DB_USERNAME', 'nashvand_mysqlweb');
define('DB_PASSWORD', 'N@shV@nd@y@r');

class constants
{
    private $engine;

    private $defaults = [
        ['const' => 'SYS_SKIN', 'value' => 'default'],
        ['const' => 'MAIN_NAME', 'value' => 'website'],
        ['const' => 'MAIN_SLOGAN', 'value' => 'website template'],
        ['const' => 'MAIN_TEL', 'value' => '(123) 456-7890'],
        ['const' => 'MAIN_FAX', 'value' => '(123) 555-7891'],
        ['const' => 'MAIN_PHYSICAL_ADDRESS', 'value' => 'Springville center X264, Park Ave S.01<br>Semarang 16425 Indonesia'],
        ['const' => 'MAIN_POSTAL_ADDRESS', 'value' => 'Springville center X264, Park Ave S.01<br>Semarang 16425 Indonesia'],
        ['const' => 'MAIN_EMAIL', 'value' => 'email@domainname.com'],
    ];

    function __construct($engine)
    {
        $this->engine = $engine;
        $this->defaults = json_decode(json_encode($this->defaults));
    }

    function set()
    {
        $data = $this->engine->database->tbl_const->all();
        foreach ($data as $item) {
            define($item->const, $item->value);
        }
        foreach ($this->defaults as $default) {
            defined($default->const) or define($default->const, $default->value);
        }
    }
}
