<?php

namespace SCF\Core;

use Smarty;
use AltoRouter;


class Templates extends Smarty
{

    private $_auth;

    private $_acl;

    private $_lang;

    private $_router;

    private $_user;

    private $_settings;

    /**
     * Templates constructor.
     * @param System $settings
     * @param Authentication $auth
     * @param AclManager $acl
     * @param AltoRouter $router
     * @param Languages $lang
     * @param UserManager $user
     */
    public function __construct(System $settings, Authentication $auth, AclManager $acl, AltoRouter $router, Languages $lang, UserManager $user)
    {
        parent::__construct();


        $this->_settings = $settings;
        $this->_auth = $auth;

        if($this->_auth->isLogin()) {
            $this->_user = $user;
            $this->_acl = $acl;
        }

        $this->_router = $router;
        $this->_lang = $lang;


        $this->setTemplateDir(ROOTDIR . DS . APP . '/templates/SmartAdmin/');
        $this->setCompileDir(ROOTDIR . DS . APP . '/Caches/templates_c/');
        $this->setConfigDir(ROOTDIR . DS . APP . '/Caches/configs/');
        $this->setCacheDir(ROOTDIR . DS . APP . '/Caches/cache/');


        $this->assign('path', ROOTDIR . DS . APP);
        $this->assign('auth', $this->_auth);
        $this->assign('lang', $this->_lang);
        $this->assign('settings', $this->_settings);


        if($this->_auth->isLogin()) {
            $this->assign('user', $this->_user);
            $this->assign('acl', $this->_acl);
        }
    }
}