jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/386114 )
Change subject: Add attributes parameter to ShowSearchHitTitle
..
Add attributes parameter to ShowSearchHitTitle
This would allow extensions to define custom attributes on title link,
such as put information in "title", change attributes depending on
specific search hit, etc.
Now Wikidata does the same by overriding LinkBegin, but this applies
to all links, not specifically to search result link.
Since ShowSearchHitTitle is always used with the link, I think it makes
sense to enable this specific customization.
Change-Id: I19f64e0909d92e32ddf6271f74c014e8b65d5014
---
M docs/hooks.txt
M includes/widget/search/FullSearchResultWidget.php
2 files changed, 4 insertions(+), 2 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
Thiemo Mättig (WMDE): Looks good to me, but someone else must approve
DCausse: Looks good to me, but someone else must approve
diff --git a/docs/hooks.txt b/docs/hooks.txt
index b7fe8c1..5740040 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -2947,6 +2947,7 @@
$terms: String of the search terms entered
$specialSearch: The SpecialSearch object
&$query: Array of query string parameters for the link representing the search
result.
+&$attributes: Array of title link attributes, can be modified by extension.
'SidebarBeforeOutput': Allows to edit sidebar just before it is output by
skins.
Warning: This hook is run on each display. You should consider to use
diff --git a/includes/widget/search/FullSearchResultWidget.php
b/includes/widget/search/FullSearchResultWidget.php
index 0d0fa12..4c98399 100644
--- a/includes/widget/search/FullSearchResultWidget.php
+++ b/includes/widget/search/FullSearchResultWidget.php
@@ -133,13 +133,14 @@
$title = clone $result->getTitle();
$query = [];
+ $attributes = [ 'data-serp-pos' => $position ];
Hooks::run( 'ShowSearchHitTitle',
- [ &$title, &$snippet, $result, $terms,
$this->specialPage, &$query ] );
+ [ &$title, &$snippet, $result, $terms,
$this->specialPage, &$query, &$attributes ] );
$link = $this->linkRenderer->makeLink(
$title,
$snippet,
- [ 'data-serp-pos' => $position ],
+ $attributes,
$query
);
--
To view, visit https://gerrit.wikimedia.org/r/386114
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I19f64e0909d92e32ddf6271f74c014e8b65d5014
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Smalyshev
Gerrit-Reviewer: Anomie
Gerrit-Reviewer: Chad
Gerrit-Reviewer: DCausse
Gerrit-Reviewer: Daniel Kinzler
Gerrit-Reviewer: EBernhardson
Gerrit-Reviewer: Florianschmidtwelzow
Gerrit-Reviewer: Legoktm
Gerrit-Reviewer: Smalyshev
Gerrit-Reviewer: Thiemo Mättig (WMDE)
Gerrit-Reviewer: jenkins-bot <>
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits