<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FWas_a_bee%2FgetLinkedName</id>
	<title>Module:Sandbox/Was a bee/getLinkedName - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FWas_a_bee%2FgetLinkedName"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Was_a_bee/getLinkedName&amp;action=history"/>
	<updated>2026-05-26T00:46:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Was_a_bee/getLinkedName&amp;diff=146385&amp;oldid=prev</id>
		<title>imported&gt;Was a bee at 21:25, 5 June 2018</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Was_a_bee/getLinkedName&amp;diff=146385&amp;oldid=prev"/>
		<updated>2018-06-05T21:25:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.rmvDisambigBracket ( text )&lt;br /&gt;
	text = string.gsub( text, &amp;#039;%s%(.+%)$&amp;#039;, &amp;#039;&amp;#039; )&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.getLinkedName( frame )&lt;br /&gt;
    local id = frame.args[1]&lt;br /&gt;
	local alias = frame.args[&amp;#039;alias&amp;#039;]&lt;br /&gt;
	&lt;br /&gt;
	if id == nil or id == &amp;#039;&amp;#039; then&lt;br /&gt;
		--If QID is not defined, using the QID of the item which is connected to the current page.&lt;br /&gt;
		id = mw.wikibase.getEntityIdForCurrentPage() &lt;br /&gt;
		if not id then&lt;br /&gt;
			return &amp;#039;No item passed as parameter&amp;#039; --If there is no connected wikidata page, abort.&lt;br /&gt;
		end&lt;br /&gt;
    end&lt;br /&gt;
	&lt;br /&gt;
	if tonumber(id) then --legacy format&lt;br /&gt;
		id = &amp;#039;Q&amp;#039;.. tostring(id)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
    local lang = mw.language.getContentLanguage().code&lt;br /&gt;
	local globalSiteId = lang .. &amp;#039;wiki&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local entity = mw.wikibase.getEntity( id )&lt;br /&gt;
	&lt;br /&gt;
	local content&lt;br /&gt;
	local currentText = nil&lt;br /&gt;
	local currentText_NoBracket = nil&lt;br /&gt;
	&lt;br /&gt;
	currentText = entity:getSitelink( globalSiteId )	&lt;br /&gt;
	if currentText ~= nil then&lt;br /&gt;
		if alias ~= nil and alias ~= &amp;#039;&amp;#039; then&lt;br /&gt;
			currentText_NoBracket = alias&lt;br /&gt;
		else&lt;br /&gt;
			currentText_NoBracket = p.rmvDisambigBracket(currentText)&lt;br /&gt;
		end&lt;br /&gt;
		content = &amp;#039;[[:&amp;#039; .. lang .. &amp;#039;:&amp;#039; .. currentText .. &amp;#039;|&amp;#039; .. currentText_NoBracket .. &amp;#039;]]&amp;#039;&lt;br /&gt;
		return content ---- 1. [[:en:Sitelink|Sitelink]] style &lt;br /&gt;
	else&lt;br /&gt;
		currentText = entity:getLabelWithLang(lang)&lt;br /&gt;
		if currentText ~= nil then&lt;br /&gt;
			content = &amp;#039;[[:&amp;#039; .. lang .. &amp;#039;:&amp;#039; .. currentText .. &amp;#039;|&amp;#039; .. currentText .. &amp;#039;]]&amp;#039;&lt;br /&gt;
			return content ---- 2. [[:en:Label|Label]] style&lt;br /&gt;
		else&lt;br /&gt;
			content = id .. &amp;#039; &amp;#039; .. &amp;#039;[[File:Blue pencil.svg|frameless|text-top|10px|link=https://www.wikidata.org/wiki/&amp;#039; .. id .. &amp;#039;]]&amp;#039;&lt;br /&gt;
			return content ---- 3. Q123456 style&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Was a bee</name></author>
	</entry>
</feed>