namespace Shaarli\Front\Controller\Admin;
use Shaarli\Languages;
+use Shaarli\Render\TemplatePage;
use Shaarli\Render\ThemeUtils;
use Shaarli\Thumbnailer;
use Slim\Http\Request;
class ConfigureController extends ShaarliAdminController
{
/**
- * GET /configure - Displays the configuration page
+ * GET /admin/configure - Displays the configuration page
*/
public function index(Request $request, Response $response): Response
{
$this->assignView('thumbnails_mode', $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE));
$this->assignView('pagetitle', t('Configure') .' - '. $this->container->conf->get('general.title', 'Shaarli'));
- return $response->write($this->render('configure'));
+ return $response->write($this->render(TemplatePage::CONFIGURE));
}
/**
- * POST /configure - Update Shaarli's configuration
+ * POST /admin/configure - Update Shaarli's configuration
*/
public function save(Request $request, Response $response): Response
{
if ($thumbnailsMode !== Thumbnailer::MODE_NONE
&& $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE)
) {
- $this->saveWarningMessage(t(
- 'You have enabled or changed thumbnails mode. '
- .'<a href="./?do=thumbs_update">Please synchronize them</a>.'
- ));
+ $this->saveWarningMessage(
+ t('You have enabled or changed thumbnails mode.') .
+ '<a href="'. $this->container->basePath .'/admin/thumbnails">' . t('Please synchronize them.') .'</a>'
+ );
}
$this->container->conf->set('thumbnails.mode', $thumbnailsMode);
$this->container->history->updateSettings();
$this->container->pageCacheManager->invalidateCaches();
} catch (Throwable $e) {
- // TODO: translation + stacktrace
- $this->saveErrorMessage('ERROR while writing config file after configuration update.');
+ $this->assignView('message', t('Error while writing config file after configuration update.'));
+
+ if ($this->container->conf->get('dev.debug', false)) {
+ $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString());
+ }
+
+ return $response->write($this->render('error'));
}
$this->saveSuccessMessage(t('Configuration was saved.'));
- return $response->withRedirect('./configure');
+ return $this->redirect($response, '/admin/configure');
}
}