<?php

class WizardStepLanguageAndStyle extends WizardStep
{

    public function run() {
        
        if (isset($_POST["LanguageAndStyle"])) {

            $installationName = $_POST["LanguageAndStyle"]["installationName"];
            $language = $_POST["LanguageAndStyle"]["gui_language"];
            $style = $_POST["LanguageAndStyle"]["color_theme"];
            
            $this->setInstallationName($installationName);
            $this->setDefaultLanguage($language);
            $this->setColorTheme($style);
            
            $this->setStepIsDone(true);
            return;
        }
        
        // render the page,
        $this->wizardController->render("languageAndStyle");
    }
    
    private function setDefaultLanguage($language) 
    {
        Yii::app()->language = $language;
        Yii::app()->user->setState('language', $language);
        
        setCfg('GUI_LANGS', $language);
    }
    
    private function setColorTheme($theme)
    {
        setCfg('UI_THEME', $theme);
    }
    
    private function setInstallationName($name)
    {
        setCfg('PHONALISA_NAME', $name);
        setCfg('EMAIL_NAME', $name);
    }

}