Quellcode durchsuchen

Improve notifications: notificationName (#7287)

* notificationID

* 3 first examples

* fix

* notificationID -> notificationName

* Update lib/Minz/Request.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
maTh vor 1 Jahr
Ursprung
Commit
1e8ef4bb72

+ 1 - 1
app/Controllers/configureController.php

@@ -75,7 +75,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
 			Minz_Translate::reset(FreshRSS_Context::userConf()->language);
 			Minz_Translate::reset(FreshRSS_Context::userConf()->language);
 			invalidateHttpCache();
 			invalidateHttpCache();
 
 
-			Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'display' ]);
+			Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'display' ], 'displayAction');
 		}
 		}
 
 
 		$this->view->themes = FreshRSS_Themes::get();
 		$this->view->themes = FreshRSS_Themes::get();

+ 2 - 1
app/Controllers/entryController.php

@@ -189,7 +189,8 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {
 					'c' => 'index',
 					'c' => 'index',
 					'a' => 'index',
 					'a' => 'index',
 					'params' => $params,
 					'params' => $params,
-				]
+				],
+				'readAction'
 			);
 			);
 		}
 		}
 	}
 	}

+ 1 - 1
app/Controllers/feedController.php

@@ -918,7 +918,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
 			// Redirect to the main page with correct notification.
 			// Redirect to the main page with correct notification.
 			Minz_Request::good(_t('feedback.sub.feed.actualized', $feed->name()), [
 			Minz_Request::good(_t('feedback.sub.feed.actualized', $feed->name()), [
 				'params' => ['get' => 'f_' . $id]
 				'params' => ['get' => 'f_' . $id]
-			]);
+			], 'actualizeAction');
 		} elseif ($nbUpdatedFeeds >= 1) {
 		} elseif ($nbUpdatedFeeds >= 1) {
 			Minz_Request::good(_t('feedback.sub.feed.n_actualized', $nbUpdatedFeeds), []);
 			Minz_Request::good(_t('feedback.sub.feed.n_actualized', $nbUpdatedFeeds), []);
 		} else {
 		} else {

+ 3 - 1
app/layout/layout.phtml

@@ -84,14 +84,16 @@
 <?php
 <?php
 	$msg = '';
 	$msg = '';
 	$status = 'closed';
 	$status = 'closed';
+	$notificationName = '';
 	$notif = Minz_Request::getNotification();
 	$notif = Minz_Request::getNotification();
 	if (!empty($notif)) {
 	if (!empty($notif)) {
 		$msg = $notif['content'];
 		$msg = $notif['content'];
 		$status = $notif['type'];
 		$status = $notif['type'];
+		$notificationName = $notif['notificationName'];
 		invalidateHttpCache();
 		invalidateHttpCache();
 	}
 	}
 ?>
 ?>
-<div role="dialog" id="notification" class="notification <?= $status ?>" aria-describedby="dialogMsg">
+<div role="dialog" id="notification" class="notification <?= $status ?> <?= $notificationName ?>" aria-describedby="dialogMsg">
 	<span class="msg" id="dialogMsg"><?= $msg ?></span>
 	<span class="msg" id="dialogMsg"><?= $msg ?></span>
 	<button class="close" title="<?= _t('gen.action.close') ?>"><?= _i('close') ?></button>
 	<button class="close" title="<?= _t('gen.action.close') ?>"><?= _i('close') ?></button>
 </div>
 </div>

+ 12 - 12
lib/Minz/Request.php

@@ -385,33 +385,33 @@ class Minz_Request {
 		return $_GET['rid'];
 		return $_GET['rid'];
 	}
 	}
 
 
-	private static function setNotification(string $type, string $content): void {
+	private static function setNotification(string $type, string $content, string $notificationName = ''): void {
 		Minz_Session::lock();
 		Minz_Session::lock();
 		$requests = Minz_Session::paramArray('requests');
 		$requests = Minz_Session::paramArray('requests');
 		$requests[self::requestId()] = [
 		$requests[self::requestId()] = [
 				'time' => time(),
 				'time' => time(),
-				'notification' => [ 'type' => $type, 'content' => $content ],
+				'notification' => [ 'type' => $type, 'content' => $content, 'notificationName' => $notificationName ],
 			];
 			];
 		Minz_Session::_param('requests', $requests);
 		Minz_Session::_param('requests', $requests);
 		Minz_Session::unlock();
 		Minz_Session::unlock();
 	}
 	}
 
 
-	public static function setGoodNotification(string $content): void {
-		self::setNotification('good', $content);
+	public static function setGoodNotification(string $content, string $notificationName = ''): void {
+		self::setNotification('good', $content, $notificationName);
 	}
 	}
 
 
-	public static function setBadNotification(string $content): void {
-		self::setNotification('bad', $content);
+	public static function setBadNotification(string $content, string $notificationName = ''): void {
+		self::setNotification('bad', $content, $notificationName);
 	}
 	}
 
 
 	/**
 	/**
 	 * @param $pop true (default) to remove the notification, false to keep it.
 	 * @param $pop true (default) to remove the notification, false to keep it.
-	 * @return array{type:string,content:string}|null
+	 * @return array{type:string,content:string,notificationName:string}|null
 	 */
 	 */
 	public static function getNotification(bool $pop = true): ?array {
 	public static function getNotification(bool $pop = true): ?array {
 		$notif = null;
 		$notif = null;
 		Minz_Session::lock();
 		Minz_Session::lock();
-		/** @var array<string,array{time:int,notification:array{type:string,content:string}}> */
+		/** @var array<string,array{time:int,notification:array{type:string,content:string,notificationName:string}}> */
 		$requests = Minz_Session::paramArray('requests');
 		$requests = Minz_Session::paramArray('requests');
 		if (!empty($requests)) {
 		if (!empty($requests)) {
 			//Delete abandoned notifications
 			//Delete abandoned notifications
@@ -461,8 +461,8 @@ class Minz_Request {
 	 * @param string $msg notification content
 	 * @param string $msg notification content
 	 * @param array{c?:string,a?:string,params?:array<string,mixed>} $url url array to where we should be forwarded
 	 * @param array{c?:string,a?:string,params?:array<string,mixed>} $url url array to where we should be forwarded
 	 */
 	 */
-	public static function good(string $msg, array $url = []): void {
-		Minz_Request::setGoodNotification($msg);
+	public static function good(string $msg, array $url = [], string $notificationName = ''): void {
+		Minz_Request::setGoodNotification($msg, $notificationName);
 		Minz_Request::forward($url, true);
 		Minz_Request::forward($url, true);
 	}
 	}
 
 
@@ -471,8 +471,8 @@ class Minz_Request {
 	 * @param string $msg notification content
 	 * @param string $msg notification content
 	 * @param array{c?:string,a?:string,params?:array<string,mixed>} $url url array to where we should be forwarded
 	 * @param array{c?:string,a?:string,params?:array<string,mixed>} $url url array to where we should be forwarded
 	 */
 	 */
-	public static function bad(string $msg, array $url = []): void {
-		Minz_Request::setBadNotification($msg);
+	public static function bad(string $msg, array $url = [], string $notificationName = ''): void {
+		Minz_Request::setBadNotification($msg, $notificationName);
 		Minz_Request::forward($url, true);
 		Minz_Request::forward($url, true);
 	}
 	}