2014-10-03 08:01:37 +00:00
|
|
|
<?php namespace Backend\Models;
|
|
|
|
|
|
2014-10-13 08:05:23 +00:00
|
|
|
use File;
|
2014-10-03 08:01:37 +00:00
|
|
|
use Lang;
|
|
|
|
|
use Model;
|
2014-10-13 08:05:23 +00:00
|
|
|
use Less_Parser;
|
2014-10-03 08:01:37 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Backend settings that affect all users
|
|
|
|
|
*
|
|
|
|
|
* @package october\backend
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
|
|
|
|
class BackendSettings extends Model
|
|
|
|
|
{
|
2014-10-13 08:05:23 +00:00
|
|
|
use \System\Traits\ViewMaker;
|
2014-10-03 08:01:37 +00:00
|
|
|
use \October\Rain\Database\Traits\Validation;
|
|
|
|
|
|
|
|
|
|
public $implement = ['System.Behaviors.SettingsModel'];
|
|
|
|
|
|
|
|
|
|
public $settingsCode = 'backend_settings';
|
|
|
|
|
|
|
|
|
|
public $settingsFields = 'fields.yaml';
|
|
|
|
|
|
|
|
|
|
public $attachOne = [
|
|
|
|
|
'logo' => ['System\Models\File']
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validation rules
|
|
|
|
|
*/
|
|
|
|
|
public $rules = [
|
|
|
|
|
'app_name' => 'required',
|
|
|
|
|
'app_motto' => 'required',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function initSettingsData()
|
|
|
|
|
{
|
|
|
|
|
$this->app_name = Lang::get('system::lang.app.name');
|
|
|
|
|
$this->app_motto = Lang::get('system::lang.app.motto');
|
2014-10-13 07:08:59 +00:00
|
|
|
|
|
|
|
|
// Carrot
|
2014-10-14 21:10:38 +00:00
|
|
|
$this->primary_color_dark = '#d35400';
|
|
|
|
|
|
|
|
|
|
// Pumpkin
|
|
|
|
|
$this->primary_color_light = '#e67e22';
|
2014-10-13 07:08:59 +00:00
|
|
|
|
|
|
|
|
// Midnight Blue
|
2014-10-14 21:10:38 +00:00
|
|
|
$this->secondary_color_dark = '#2b3e50';
|
|
|
|
|
|
|
|
|
|
// Wet Asphalt
|
|
|
|
|
$this->secondary_color_light = '#34495e';
|
2014-10-03 08:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getLogo()
|
|
|
|
|
{
|
|
|
|
|
$settings = self::instance();
|
|
|
|
|
if (!$settings->logo)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return $settings->logo->getPath();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-13 08:05:23 +00:00
|
|
|
public function renderCss()
|
|
|
|
|
{
|
|
|
|
|
$parser = new Less_Parser(['compress' => true]);
|
|
|
|
|
|
|
|
|
|
$parser->ModifyVars([
|
2014-10-14 21:10:38 +00:00
|
|
|
'logo-image' => "'".self::getLogo()."'",
|
|
|
|
|
'primary-color-light' => $this->primary_color_light,
|
|
|
|
|
'primary-color-dark' => $this->primary_color_dark,
|
|
|
|
|
'secondary-color-light' => $this->secondary_color_light,
|
|
|
|
|
'secondary-color-dark' => $this->secondary_color_dark,
|
2014-10-13 08:05:23 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$parser->parse(File::get(__DIR__.'/backendsettings/custom.less'));
|
|
|
|
|
|
|
|
|
|
$css = $parser->getCss();
|
|
|
|
|
return $css;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-03 08:01:37 +00:00
|
|
|
}
|