Explorar el Código

Fix slider views (#5469)

* Fix slider titles
And fix full-page view of category configuration.
FIx https://github.com/FreshRSS/FreshRSS/pull/5449#issuecomment-1590021947

* Fix user queries and user management
Implement https://github.com/FreshRSS/FreshRSS/pull/5469#issuecomment-1591957935
Alexandre Alapetite hace 2 años
padre
commit
228d7adfdb

+ 11 - 8
app/Controllers/configureController.php

@@ -323,12 +323,13 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
 		$this->view->feeds = $feed_dao->listFeeds();
 		$this->view->tags = $tag_dao->listTags() ?: [];
 
-		$id = Minz_Request::paramInt('id');
-		$this->view->displaySlider = false;
-		if ($id !== 0) {
-			$this->view->displaySlider = true;
+		if (Minz_Request::paramTernary('id') !== null) {
+			$id = Minz_Request::paramInt('id');
 			$this->view->query = $this->view->queries[$id];
 			$this->view->queryId = $id;
+			$this->view->displaySlider = true;
+		} else {
+			$this->view->displaySlider = false;
 		}
 
 		FreshRSS_View::prependTitle(_t('conf.query.title') . ' · ');
@@ -340,7 +341,9 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
 	 * applied to the selected query.
 	 */
 	public function queryAction(): void {
-		$this->view->_layout(null);
+		if (Minz_Request::paramBoolean('ajax')) {
+			$this->view->_layout(null);
+		}
 
 		$id = Minz_Request::paramInt('id');
 		if (Minz_Request::paramTernary('id') === null || empty(FreshRSS_Context::$user_conf->queries[$id])) {
@@ -369,22 +372,22 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
 			if (!empty($params['state']) && is_array($params['state'])) {
 				$queryParams['state'] = (int)(array_sum($params['state']));
 			}
-			$queryParams['url'] = Minz_Url::display(['params' => $params]);
 			$name = Minz_Request::paramString('name') ?: _t('conf.query.number', $id + 1);
 			if ('' === $name) {
 				$name = _t('conf.query.number', $id + 1);
 			}
 			$queryParams['name'] = $name;
+			$queryParams['url'] = Minz_Url::display(['params' => $queryParams]);
 
 			$queries = FreshRSS_Context::$user_conf->queries;
 			$queries[$id] = (new FreshRSS_UserQuery($queryParams, $feed_dao, $category_dao, $tag_dao))->toArray();
 			FreshRSS_Context::$user_conf->queries = $queries;
 			FreshRSS_Context::$user_conf->save();
 
-			Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries', 'params' => ['id' => $id] ]);
+			Minz_Request::good(_t('feedback.conf.updated'), [ 'c' => 'configure', 'a' => 'queries', 'params' => ['id' => (string)$id] ]);
 		}
 
-		FreshRSS_View::prependTitle(_t('conf.query.title') . ' · ' . $query->getName() . ' · ');
+		FreshRSS_View::prependTitle($query->getName() . ' · ' . _t('conf.query.title') . ' · ');
 	}
 
 	/**

+ 1 - 0
app/Controllers/extensionController.php

@@ -97,6 +97,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
 			return;
 		}
 
+		FreshRSS_View::prependTitle($ext->getName() . ' · ' . _t('admin.extensions.title') . ' · ');
 		$this->view->extension = $ext;
 		$this->view->extension->handleConfigureAction();
 	}

+ 6 - 2
app/Controllers/subscriptionController.php

@@ -107,7 +107,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
 		$feed = $this->view->feeds[$id];
 		$this->view->feed = $feed;
 
-		FreshRSS_View::prependTitle(_t('sub.title.feed_management') . ' · ' . $feed->name() . ' · ');
+		FreshRSS_View::prependTitle($feed->name() . ' · ' . _t('sub.title.feed_management') . ' · ');
 
 		if (Minz_Request::isPost()) {
 			$user = Minz_Request::paramString('http_user_feed' . $id);
@@ -283,7 +283,9 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
 	}
 
 	public function categoryAction(): void {
-		$this->view->_layout(null);
+		if (Minz_Request::paramBoolean('ajax')) {
+			$this->view->_layout(null);
+		}
 
 		$categoryDAO = FreshRSS_Factory::createCategoryDao();
 
@@ -295,6 +297,8 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
 		}
 		$this->view->category = $category;
 
+		FreshRSS_View::prependTitle($category->name() . ' · ' . _t('sub.title') . ' · ');
+
 		if (Minz_Request::isPost()) {
 			if (Minz_Request::paramBoolean('use_default_purge_options')) {
 				$category->_attributes('archiving', null);

+ 5 - 0
app/Controllers/userController.php

@@ -620,8 +620,13 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
 			Minz_Error::error(404);
 		}
 
+		if (Minz_Request::paramBoolean('ajax')) {
+			$this->view->_layout(null);
+		}
+
 		$this->view->username = $username;
 		$this->view->details = $this->retrieveUserDetails($username);
+		FreshRSS_View::prependTitle($username . ' · ' . _t('gen.menu.user_management') . ' · ');
 	}
 
 	/** @return array{'feed_count':int,'article_count':int,'database_size':int,'language':string,'mail_login':string,'enabled':bool,'is_admin':bool,'last_user_activity':string,'is_default':bool} */

+ 2 - 2
app/layout/aside_configure.phtml

@@ -47,7 +47,7 @@ function get_logout_url(): string {
 				<li class="item<?= Minz_Request::actionName() === 'shortcut' ? ' active' : '' ?>">
 					<a href="<?= _url('configure', 'shortcut') ?>"><?= _t('gen.menu.shortcuts') ?></a>
 				</li>
-				<li class="item<?= Minz_Request::actionName() === 'queries' ? ' active' : '' ?>">
+				<li class="item<?= in_array(Minz_Request::actionName(), ['queries', 'query'], true) ? ' active' : '' ?>">
 					<a href="<?= _url('configure', 'queries') ?>"><?= _t('gen.menu.queries') ?></a>
 				</li>
 				<li class="item<?= Minz_Request::controllerName() === 'extension' ? ' active' : '' ?>">
@@ -69,7 +69,7 @@ function get_logout_url(): string {
 				<li class="item<?= Minz_Request::actionName() === 'system' ? ' active' : '' ?>">
 					<a href="<?= _url('configure', 'system') ?>"><?= _t('gen.menu.system') ?></a>
 				</li>
-				<li class="item<?= Minz_Request::controllerName() === 'user' && Minz_Request::actionName() === 'manage' ? ' active' : '' ?>">
+				<li class="item<?= Minz_Request::controllerName() === 'user' && in_array(Minz_Request::actionName(), ['manage', 'details'], true) ? ' active' : '' ?>">
 					<a href="<?= _url('user', 'manage') ?>"><?= _t('gen.menu.user_management') ?></a>
 				</li>
 				<li class="item<?= Minz_Request::controllerName() === 'auth' ? ' active' : '' ?>">

+ 1 - 1
app/layout/aside_subscription.phtml

@@ -8,7 +8,7 @@
 					<a href="<?= _url('subscription', 'add') ?>"><?= _t('sub.menu.add') ?></a>
 				</li>
 
-				<li class="item<?= Minz_Request::controllerName() === 'subscription' && Minz_Request::actionName() === 'index' ? ' active' : '' ?>">
+				<li class="item<?= Minz_Request::controllerName() === 'subscription' && in_array(Minz_Request::actionName(), ['index', 'category', 'feed'], true) ? ' active' : '' ?>">
 					<a href="<?= _url('subscription', 'index') ?>"><?= _t('sub.menu.subscription_management') ?></a>
 				</li>
 

+ 4 - 1
app/views/configure/query.phtml

@@ -1,6 +1,9 @@
-<?php /** @var FreshRSS_View $this */ ?>
 <?php
+/** @var FreshRSS_View $this */
 
+if (!Minz_Request::paramBoolean('ajax')) {
+	$this->partial('aside_configure');
+}
 if ($this->query) {
 	$this->renderHelper('configure/query');
 }

+ 5 - 1
app/views/subscription/category.phtml

@@ -1,5 +1,9 @@
-<?php /** @var FreshRSS_View $this */ ?>
 <?php
+/** @var FreshRSS_View $this */
+
+if (!Minz_Request::paramBoolean('ajax')) {
+	$this->partial('aside_subscription');
+}
 if ($this->category) {
 	$this->renderHelper('category/update');
 }

+ 1 - 1
app/views/subscription/feed.phtml

@@ -1,5 +1,5 @@
-<?php /** @var FreshRSS_View $this */ ?>
 <?php
+/** @var FreshRSS_View $this */
 
 if (!Minz_Request::paramBoolean('ajax')) {
 	$this->partial('aside_subscription');

+ 3 - 0
app/views/user/details.phtml

@@ -1,5 +1,8 @@
 <?php
 	/** @var FreshRSS_View $this */
+	if (!Minz_Request::paramBoolean('ajax')) {
+		$this->partial('aside_configure');
+	}
 ?>
 
 <?php $isDefault = $this->details['is_default']; ?>

+ 4 - 1
lib/Minz/Url.php

@@ -92,7 +92,10 @@ class Minz_Url {
 			unset($url['params']['c']);
 			unset($url['params']['a']);
 			foreach ($url['params'] as $key => $param) {
-				$uri .= $separator . urlencode($key) . '=' . urlencode($param);
+				if (!is_string($key) || (!is_string($param) && !is_int($param))) {
+					continue;
+				}
+				$uri .= $separator . urlencode($key) . '=' . urlencode((string)$param);
 				$separator = $and;
 			}
 		}