<?php

namespace ModulesGarden\Servers\OpenXchange\App\Libs;

use ModulesGarden\OpenXchangeAddon\Core\Models\ModuleSettings\Model;

class ThemeHelper
{
    public static function config()
    {
        $entries = [];
        $data = Model::pluck('value', 'setting');

        $colorSettings = [
            'mainColor', 'topbarBackground', 'topbarHover', 'linkHover', 'linkColor', 'listSelectedFocus',
            'listSelected', 'listHover'
        ];

        foreach($colorSettings as $setting)
        {
            if($data[$setting] == 'on' && !empty($data[$setting.'Picker']))
            {
                //$entries[] = ['key' => 'io.ox/dynamic-theme//'.$setting, 'value' => '#'.$data[$setting.'Picker']];
                $entries[$setting] = '#'.$data[$setting.'Picker'];
            }
        }

        $textSettings = [
            'logoUrlLight', 'logoUrlDark', 'logoWidth', 'logoHeight'
        ];

        foreach($textSettings as $setting)
        {
            if(!empty($data[$setting]))
            {
                //$entries[] = ['key' => 'io.ox/dynamic-theme//'.$setting, 'value' => $data[$setting]];
                $entries[$setting] = $data[$setting];
            }
        }

        return (object)$entries;
    }
}
