2013-12-23 03:25:54 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use PicoFarad\Router;
|
|
|
|
use PicoFarad\Response;
|
|
|
|
use PicoFarad\Request;
|
|
|
|
use PicoFarad\Session;
|
2014-03-17 02:56:43 +01:00
|
|
|
use PicoFarad\Template;
|
2014-02-08 20:13:14 +01:00
|
|
|
use PicoDb\Database;
|
2013-12-23 03:25:54 +01:00
|
|
|
|
|
|
|
// Re-generate tokens
|
|
|
|
Router\get_action('generate-tokens', function() {
|
|
|
|
|
|
|
|
Model\Config\new_tokens();
|
|
|
|
Response\redirect('?action=config#api');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Optimize the database manually
|
|
|
|
Router\get_action('optimize-db', function() {
|
|
|
|
|
2014-02-08 20:13:14 +01:00
|
|
|
Database::get('db')->getConnection()->exec('VACUUM');
|
2013-12-23 03:25:54 +01:00
|
|
|
Response\redirect('?action=config');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Download the compressed database
|
|
|
|
Router\get_action('download-db', function() {
|
|
|
|
|
|
|
|
Response\force_download('db.sqlite.gz');
|
|
|
|
Response\binary(gzencode(file_get_contents(DB_FILENAME)));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Display preferences page
|
|
|
|
Router\get_action('config', function() {
|
|
|
|
|
|
|
|
Response\html(Template\layout('config', array(
|
|
|
|
'errors' => array(),
|
|
|
|
'values' => Model\Config\get_all(),
|
|
|
|
'db_size' => filesize(DB_FILENAME),
|
|
|
|
'languages' => Model\Config\get_languages(),
|
2014-02-26 01:03:46 +01:00
|
|
|
'timezones' => Model\Config\get_timezones(),
|
2013-12-23 03:25:54 +01:00
|
|
|
'autoflush_options' => Model\Config\get_autoflush_options(),
|
|
|
|
'paging_options' => Model\Config\get_paging_options(),
|
|
|
|
'theme_options' => Model\Config\get_themes(),
|
|
|
|
'sorting_options' => Model\Config\get_sorting_directions(),
|
2013-12-23 19:33:16 +01:00
|
|
|
'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(),
|
2013-12-23 03:25:54 +01:00
|
|
|
'menu' => 'config',
|
|
|
|
'title' => t('Preferences')
|
|
|
|
)));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Update preferences
|
|
|
|
Router\post_action('config', function() {
|
|
|
|
|
|
|
|
$values = Request\values() + array('nocontent' => 0);
|
|
|
|
list($valid, $errors) = Model\Config\validate_modification($values);
|
|
|
|
|
|
|
|
if ($valid) {
|
|
|
|
|
|
|
|
if (Model\Config\save($values)) {
|
|
|
|
Session\flash(t('Your preferences are updated.'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Session\flash_error(t('Unable to update your preferences.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
Response\redirect('?action=config');
|
|
|
|
}
|
|
|
|
|
|
|
|
Response\html(Template\layout('config', array(
|
|
|
|
'errors' => $errors,
|
2014-02-08 20:13:14 +01:00
|
|
|
'values' => Model\Config\get_all(),
|
2013-12-23 03:25:54 +01:00
|
|
|
'db_size' => filesize(DB_FILENAME),
|
|
|
|
'languages' => Model\Config\get_languages(),
|
2014-02-26 01:03:46 +01:00
|
|
|
'timezones' => Model\Config\get_timezones(),
|
2013-12-23 03:25:54 +01:00
|
|
|
'autoflush_options' => Model\Config\get_autoflush_options(),
|
|
|
|
'paging_options' => Model\Config\get_paging_options(),
|
|
|
|
'theme_options' => Model\Config\get_themes(),
|
|
|
|
'sorting_options' => Model\Config\get_sorting_directions(),
|
2014-02-08 20:13:14 +01:00
|
|
|
'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(),
|
2013-12-23 03:25:54 +01:00
|
|
|
'menu' => 'config',
|
|
|
|
'title' => t('Preferences')
|
|
|
|
)));
|
|
|
|
});
|