Frio: add login background color admin option

This commit is contained in:
fabrixxm 2018-01-17 16:33:27 +01:00
parent 2c8bbea65d
commit fc8e8feec1
5 changed files with 34 additions and 17 deletions

View file

@ -34,8 +34,8 @@ function home_content(App $a) {
$customhome = False;
$defaultheader = '<h1>'.((x($a->config,'sitename')) ? sprintf(t("Welcome to %s"), $a->config['sitename']) : "").'</h1>';
$homefilepath = $a->basepath . '/home.html';
$cssfilepath = $a->basepath . '/home.css';
$homefilepath = $a->basepath . "/home.html";
$cssfilepath = $a->basepath . "/home.css";
if (file_exists($homefilepath)) {
$customhome = $homefilepath;
if (file_exists($cssfilepath)) {

View file

@ -40,6 +40,7 @@ function theme_admin_post(App $a) {
Config::set('frio', 'background_image', $_POST["frio_background_image"]);
Config::set('frio', 'bg_image_option', $_POST["frio_bg_image_option"]);
Config::set('frio', 'login_bg_image', $_POST["frio_login_bg_image"]);
Config::set('frio', 'login_bg_color', $_POST["frio_login_bg_color"]);
Config::set('frio', 'css_modified', time());
}
}
@ -77,6 +78,7 @@ function theme_admin(App $a) {
$arr["background_image"] = Config::get('frio', 'background_image');
$arr["bg_image_option"] = Config::get('frio', 'bg_image_option');
$arr["login_bg_image"] = Config::get('frio', 'login_bg_image');
$arr["login_bg_color"] = Config::get('frio', 'login_bg_color');
return frio_form($arr);
}
@ -123,6 +125,10 @@ function frio_form($arr) {
if ( array_key_exists("login_bg_image", $arr ) && !array_key_exists("login_bg_image", $disable ) ) {
$ctx['$login_bg_image'] = ['frio_login_bg_image', t('Login page background image'), $arr['login_bg_image'], $background_image_help];
}
if ( array_key_exists("login_bg_color", $arr ) && !array_key_exists("login_bg_color", $disable ) ) {
$ctx['$login_bg_color'] = ['frio_login_bg_color', t('Login page background color'), $arr['login_bg_color'], t('Leave background image and color empty for theme defaults')];
}
$o .= replace_macros($t, $ctx);

View file

@ -3018,6 +3018,7 @@ section .profile-match-wrapper {
.mod-home.is-not-singleuser,
.mod-login {
background-color: $login_bg_color;
background-image: linear-gradient(to right, rgba(0,0,0, 0.7) , rgba(0,0,0, 0.4)), url($login_bg_image);
background-size: cover;
background-attachment: fixed;
@ -3034,29 +3035,29 @@ section .profile-match-wrapper {
}
.mod-home.is-not-singleuser .login-content,
.mod-login .login-content {
color: #eee;
margin-top: 2.5%;
color: #eee;
margin-top: 2.5%;
}
.mod-home.is-not-singleuser .login-form > #login-form label,
.mod-login #content #login-form label {
color: #eee;
color: #eee;
}
.mod-home.is-not-singleuser .login-panel-content,
.mod-login .login-panel-content {
background-color: rgba(255,255,255,.85);
background-color: rgba(255,255,255,.85);
}
/* Medium devices (desktops, 992px and up) */
@media (min-width: 992px) {
.mod-home.is-not-singleuser #content,
.mod-home.is-not-singleuser #content,
.mod-login #content {
margin-top: 100px!important;
}
margin-top: 100px!important;
}
.mod-home.is-not-singleuser .login-form > #login-form,
.mod-home.is-not-singleuser .login-form > #login-form,
.mod-login #content #login-form {
background-color: #fff;
padding: 1em;
@ -3064,10 +3065,10 @@ section .profile-match-wrapper {
margin-top: 4em;
}
.mod-home.is-not-singleuser .login-form > #login-form label,
.mod-login #content #login-form label {
color: #444;
}
.mod-home.is-not-singleuser .login-form > #login-form label,
.mod-login #content #login-form label {
color: #444;
}
.mod-home.is-not-singleuser .login-form > #login-form::before,
.mod-login #content #login-form::before {
@ -3093,7 +3094,7 @@ section .profile-match-wrapper {
top: -10%;
left: 10%;
z-index: -1;
}
}
}

View file

@ -47,6 +47,7 @@ if ($a->module !== 'install') {
$background_image = Config::get("frio", "background_image");
$bg_image_option = Config::get("frio", "bg_image_option");
$login_bg_image = Config::get("frio", "login_bg_image");
$login_bg_color = Config::get("frio", "login_bg_color");
$modified = Config::get("frio", "css_modified");
// There is maybe the case that the user did never modify the theme settings.
@ -101,9 +102,16 @@ $link_color = (empty($link_color) ? "#6fdbe8" : $link_color);
$bgcolor = (empty($bgcolor) ? "#ededed" : $bgcolor);
// The background image can not be empty. So we use a dummy jpg if no image was set.
$background_image = (empty($background_image) ? 'img/none.jpg' : $background_image);
$login_bg_image = (empty($login_bg_image) ? 'img/login_bg.jpg' : $login_bg_image);
$modified = (empty($modified) ? time() :$modified);
// set a default login bg image if no custom image and no custom bg color are set.
if (empty($login_bg_image) && empty($login_bg_color)) {
$login_bg_image = (empty($login_bg_image) ? 'img/login_bg.jpg' : $login_bg_image);
}
$login_bg_color = (empty($login_bg_color) ? "#ededed" : $login_bg_color);
$contentbg_transp = ((isset($contentbg_transp) && $contentbg_transp != "") ? $contentbg_transp : 100);
// Calculate some colors in dependance of existing colors.
@ -181,6 +189,7 @@ $options = [
'$background_image' => $background_image,
'$background_size_img' => $background_size_img,
'$login_bg_image' => $login_bg_image,
'$login_bg_color' => $login_bg_color
];
$css_tpl = file_get_contents('view/theme/frio/css/style.css');

View file

@ -31,10 +31,11 @@
</div>
{{if $login_bg_image}}{{include file="field_fileinput.tpl" field=$login_bg_image}}{{/if}}
{{if $login_bg_color}}{{include file="field_colorinput.tpl" field=$login_bg_color}}{{/if}}
<script type="text/javascript">
$(document).ready(function() {
$("#frio_nav_bg, #frio_nav_icon_color, #frio_background_color, #frio_link_color").colorpicker({format: 'hex', align: 'left'});
$("#frio_nav_bg, #frio_nav_icon_color, #frio_background_color, #frio_link_color, #frio_login_bg_color").colorpicker({format: 'hex', align: 'left'});
// show image options when user user starts to type the address of the image
$("#id_frio_background_image").keyup(function(){