mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 21:16:23 +05:30
Improved autosaving feature
Autosaving now can be disabled in the config menu and only saves when the content field is not empty.
This commit is contained in:
parent
912418984b
commit
96d5145395
13 changed files with 162 additions and 31 deletions
|
|
@ -1774,6 +1774,76 @@ post('/admin/config/reading', function () {
|
|||
}
|
||||
});
|
||||
|
||||
// Show Config page
|
||||
get('/admin/config/writing', function () {
|
||||
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$role = user('role', $user);
|
||||
|
||||
if (login()) {
|
||||
config('views.root', 'system/admin/views');
|
||||
if ($role === 'admin') {
|
||||
render('config-writing', array(
|
||||
'title' => generate_title('is_default', i18n('Config')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_admin-config',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'admin-config',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Config')
|
||||
));
|
||||
} else {
|
||||
render('denied', array(
|
||||
'title' => generate_title('is_default', i18n('Config')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_admin-config',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'denied',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Config')
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Submitted Config page data
|
||||
post('/admin/config/writing', function () {
|
||||
|
||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
if (login() && $proper) {
|
||||
$new_config = array();
|
||||
$new_Keys = array();
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$role = user('role', $user);
|
||||
if ($role === 'admin') {
|
||||
foreach ($_POST as $name => $value) {
|
||||
if (substr($name, 0, 8) == "-config-") {
|
||||
$name = str_replace("_", ".", substr($name, 8));
|
||||
if(!is_null(config($name))) {
|
||||
$new_config[$name] = $value;
|
||||
} else {
|
||||
$new_Keys[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
save_config($new_config, $new_Keys);
|
||||
$redir = site_url() . 'admin/config/writing';
|
||||
header("location: $redir");
|
||||
} else {
|
||||
$redir = site_url();
|
||||
header("location: $redir");
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Show Config page
|
||||
get('/admin/config/widget', function () {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue