Browse Source

Fix author search link (#3315)

Before, when clicking on the author link, the search was done on the
main stream in the normal view. It's fine until the feed is not visible
in the main stream.
Now, the current context is used along with the search.

See #3314
Alexis Degrugillier 5 years ago
parent
commit
31cb07ac1a
3 changed files with 9 additions and 2 deletions
  1. 1 1
      app/views/index/normal.phtml
  2. 1 1
      app/views/index/reader.phtml
  3. 7 0
      lib/Minz/Request.php

+ 1 - 1
app/views/index/normal.phtml

@@ -88,7 +88,7 @@ $today = @strtotime('today');
 								echo $first ? _t('gen.short.by_author') . ' ' : '· ';
 								$first = false;
 					?>
-	<em><a href="<?= _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))) ?>"><?= $author ?></a></em>
+	<em><a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])) ?>"><?= $author ?></a></em>
 					<?php	endforeach; ?>
 					</div><?php endif; ?>
 				</div>

+ 1 - 1
app/views/index/reader.phtml

@@ -57,7 +57,7 @@ $content_width = FreshRSS_Context::$user_conf->content_width;
 							echo $first ? _t('gen.short.by_author') . ' ' : '· ';
 							$first = false;
 				?>
-<em><a href="<?= _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))) ?>"><?= $author ?></a></em>
+<em><a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(['search' => 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))])) ?>"><?= $author ?></a></em>
 				<?php
 						endforeach;
 						echo ' — ';

+ 7 - 0
lib/Minz/Request.php

@@ -71,6 +71,13 @@ class Minz_Request {
 			'params' => self::$params,
 		);
 	}
+	public static function modifiedCurrentRequest(array $extraParams = null) {
+		$currentRequest = self::currentRequest();
+		if (null !== $extraParams) {
+			$currentRequest['params'] = array_merge($currentRequest['params'], $extraParams);
+		}
+		return $currentRequest;
+	}
 
 	/**
 	 * Setteurs