<?php

namespace ThurData\Servers\KerioEmail\Core\UI\Traits;

use \ThurData\Servers\KerioEmail\Core\UI\Helpers\AppLayoutConstants;
use \ThurData\Servers\KerioEmail\Core\UI\Helpers\TemplateConstants;
use \ThurData\Servers\KerioEmail\Core\Helper;

/**
 * App Layouts related functions
 * View Trat
 *
 * @autor ThurData <info@thurdata.ch>
 */
trait AppLayouts
{
    protected $appLayout = AppLayoutConstants::NAVBAR_TOP;
    
    public function getAppLayout()
    {
        return $this->appLayout;
    }
    
    public function setAppLayout($layout)
    {
        if (in_array($layout, [
            AppLayoutConstants::NAVBAR_LEFT, 
            AppLayoutConstants::NAVBAR_LEFT_THIN,
            AppLayoutConstants::NAVBAR_RIGHT,
            AppLayoutConstants::NAVBAR_RIGHT_THIN,
            AppLayoutConstants::NAVBAR_TOP
        ]))
        {
            $this->appLayout = $layout;
        }
        
        return $this;
    }
    
    public function getAppLayoutTemplateDir()
    {
        return \ThurData\Servers\KerioEmail\Core\ModuleConstants::getTemplateDir() . DIRECTORY_SEPARATOR
        . (Helper\isAdmin() ? TemplateConstants::ADMIN_PATH : TemplateConstants::CLIENT_PATH . DIRECTORY_SEPARATOR) .
        TemplateConstants::MAIN_DIR . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR .'default' . DIRECTORY_SEPARATOR . 'appLayouts';
    }
}
