aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front
diff options
context:
space:
mode:
authorArthurHoaro <arthur.hoareau@wizacha.com>2020-07-23 16:41:32 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commit3ee8351e438f13ccf36062ce956e0b4a4d5f4a29 (patch)
tree5c5ea281a072e4dffe0b97c12269278c999710df /application/front
parentfabff3835da26e6c95cea56b2a01a03749dec7c8 (diff)
downloadShaarli-3ee8351e438f13ccf36062ce956e0b4a4d5f4a29.tar.gz
Shaarli-3ee8351e438f13ccf36062ce956e0b4a4d5f4a29.tar.zst
Shaarli-3ee8351e438f13ccf36062ce956e0b4a4d5f4a29.zip
Multiple small fixes
Diffstat (limited to 'application/front')
-rw-r--r--application/front/ShaarliMiddleware.php2
-rw-r--r--application/front/controller/admin/ConfigureController.php17
-rw-r--r--application/front/controller/visitor/InstallController.php13
-rw-r--r--application/front/controller/visitor/TagController.php2
4 files changed, 17 insertions, 17 deletions
diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php
index e9f5552d..fd978e99 100644
--- a/application/front/ShaarliMiddleware.php
+++ b/application/front/ShaarliMiddleware.php
@@ -56,7 +56,7 @@ class ShaarliMiddleware
56 } catch (ShaarliFrontException $e) { 56 } catch (ShaarliFrontException $e) {
57 // Possible functional error 57 // Possible functional error
58 $this->container->pageBuilder->reset(); 58 $this->container->pageBuilder->reset();
59 $this->container->pageBuilder->assign('message', $e->getMessage()); 59 $this->container->pageBuilder->assign('message', nl2br($e->getMessage()));
60 60
61 $response = $response->withStatus($e->getCode()); 61 $response = $response->withStatus($e->getCode());
62 62
diff --git a/application/front/controller/admin/ConfigureController.php b/application/front/controller/admin/ConfigureController.php
index 865fc2b0..e675fcca 100644
--- a/application/front/controller/admin/ConfigureController.php
+++ b/application/front/controller/admin/ConfigureController.php
@@ -98,10 +98,10 @@ class ConfigureController extends ShaarliAdminController
98 if ($thumbnailsMode !== Thumbnailer::MODE_NONE 98 if ($thumbnailsMode !== Thumbnailer::MODE_NONE
99 && $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) 99 && $thumbnailsMode !== $this->container->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE)
100 ) { 100 ) {
101 $this->saveWarningMessage(t( 101 $this->saveWarningMessage(
102 'You have enabled or changed thumbnails mode. ' 102 t('You have enabled or changed thumbnails mode.') .
103 .'<a href="'. $this->container->basePath .'/admin/thumbnails">Please synchronize them</a>.' 103 '<a href="'. $this->container->basePath .'/admin/thumbnails">' . t('Please synchronize them.') .'</a>'
104 )); 104 );
105 } 105 }
106 $this->container->conf->set('thumbnails.mode', $thumbnailsMode); 106 $this->container->conf->set('thumbnails.mode', $thumbnailsMode);
107 107
@@ -110,8 +110,13 @@ class ConfigureController extends ShaarliAdminController
110 $this->container->history->updateSettings(); 110 $this->container->history->updateSettings();
111 $this->container->pageCacheManager->invalidateCaches(); 111 $this->container->pageCacheManager->invalidateCaches();
112 } catch (Throwable $e) { 112 } catch (Throwable $e) {
113 // TODO: translation + stacktrace 113 $this->assignView('message', t('Error while writing config file after configuration update.'));
114 $this->saveErrorMessage('ERROR while writing config file after configuration update.'); 114
115 if ($this->container->conf->get('dev.debug', false)) {
116 $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString());
117 }
118
119 return $response->write($this->render('error'));
115 } 120 }
116 121
117 $this->saveSuccessMessage(t('Configuration was saved.')); 122 $this->saveSuccessMessage(t('Configuration was saved.'));
diff --git a/application/front/controller/visitor/InstallController.php b/application/front/controller/visitor/InstallController.php
index aa032860..94ebb4ae 100644
--- a/application/front/controller/visitor/InstallController.php
+++ b/application/front/controller/visitor/InstallController.php
@@ -128,13 +128,14 @@ class InstallController extends ShaarliVisitorController
128 $this->container->conf->get('credentials.salt') 128 $this->container->conf->get('credentials.salt')
129 ) 129 )
130 ); 130 );
131 $this->container->conf->set('general.header_link', $this->container->basePath);
131 132
132 try { 133 try {
133 // Everything is ok, let's create config file. 134 // Everything is ok, let's create config file.
134 $this->container->conf->write($this->container->loginManager->isLoggedIn()); 135 $this->container->conf->write($this->container->loginManager->isLoggedIn());
135 } catch (\Exception $e) { 136 } catch (\Exception $e) {
136 $this->assignView('message', $e->getMessage()); 137 $this->assignView('message', t('Error while writing config file after configuration update.'));
137 $this->assignView('stacktrace', $e->getTraceAsString()); 138 $this->assignView('stacktrace', $e->getMessage() . PHP_EOL . $e->getTraceAsString());
138 139
139 return $response->write($this->render('error')); 140 return $response->write($this->render('error'));
140 } 141 }
@@ -155,18 +156,14 @@ class InstallController extends ShaarliVisitorController
155 { 156 {
156 // Ensure Shaarli has proper access to its resources 157 // Ensure Shaarli has proper access to its resources
157 $errors = ApplicationUtils::checkResourcePermissions($this->container->conf); 158 $errors = ApplicationUtils::checkResourcePermissions($this->container->conf);
158
159 if (empty($errors)) { 159 if (empty($errors)) {
160 return true; 160 return true;
161 } 161 }
162 162
163 // FIXME! Do not insert HTML here. 163 $message = t('Insufficient permissions:') . PHP_EOL;
164 $message = '<p>'. t('Insufficient permissions:') .'</p><ul>';
165
166 foreach ($errors as $error) { 164 foreach ($errors as $error) {
167 $message .= '<li>'.$error.'</li>'; 165 $message .= PHP_EOL . $error;
168 } 166 }
169 $message .= '</ul>';
170 167
171 throw new ResourcePermissionException($message); 168 throw new ResourcePermissionException($message);
172 } 169 }
diff --git a/application/front/controller/visitor/TagController.php b/application/front/controller/visitor/TagController.php
index c176f43f..de4e7ea2 100644
--- a/application/front/controller/visitor/TagController.php
+++ b/application/front/controller/visitor/TagController.php
@@ -11,8 +11,6 @@ use Slim\Http\Response;
11 * Class TagController 11 * Class TagController
12 * 12 *
13 * Slim controller handle tags. 13 * Slim controller handle tags.
14 *
15 * TODO: check redirections with new helper
16 */ 14 */
17class TagController extends ShaarliVisitorController 15class TagController extends ShaarliVisitorController
18{ 16{