<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ro">
	<id>https://enciclopedia.md/index.php?action=history&amp;feed=atom&amp;title=Modul%3ANameAndImage</id>
	<title>Modul:NameAndImage - Revizia istoricului</title>
	<link rel="self" type="application/atom+xml" href="https://enciclopedia.md/index.php?action=history&amp;feed=atom&amp;title=Modul%3ANameAndImage"/>
	<link rel="alternate" type="text/html" href="https://enciclopedia.md/index.php?title=Modul:NameAndImage&amp;action=history"/>
	<updated>2026-04-21T23:16:53Z</updated>
	<subtitle>Istoricul versiunilor pentru această pagină din wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://enciclopedia.md/index.php?title=Modul:NameAndImage&amp;diff=356&amp;oldid=prev</id>
		<title>Sergiu: Pagină nouă: local getArgs = require(&#039;Modul:Arguments&#039;).getArgs local wikidata = require(&#039;Modul:Wikidata&#039;) local StringUtils = require(&#039;Modul:StringUtils&#039;) local DateUtils = require(&#039;Modul:DateUtils&#039;) local GregorianDate = require(&#039;Modul:GregorianDate&#039;) local join = require(&#039;Modul:Separated entries&#039;)._main local libUtils = require(&#039;libraryUtil&#039;) local p = {}  local maxSize = { [&#039;P94&#039;] = &#039;23x23&#039;, [&#039;P41&#039;] = &#039;23x23&#039;}  local function toWikidataTimestamp(timestamp) 	local ret = nil 	if timesta...</title>
		<link rel="alternate" type="text/html" href="https://enciclopedia.md/index.php?title=Modul:NameAndImage&amp;diff=356&amp;oldid=prev"/>
		<updated>2024-07-14T20:31:14Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: local getArgs = require(&amp;#039;Modul:Arguments&amp;#039;).getArgs local wikidata = require(&amp;#039;Modul:Wikidata&amp;#039;) local StringUtils = require(&amp;#039;Modul:StringUtils&amp;#039;) local DateUtils = require(&amp;#039;Modul:DateUtils&amp;#039;) local GregorianDate = require(&amp;#039;Modul:GregorianDate&amp;#039;) local join = require(&amp;#039;Modul:Separated entries&amp;#039;)._main local libUtils = require(&amp;#039;libraryUtil&amp;#039;) local p = {}  local maxSize = { [&amp;#039;P94&amp;#039;] = &amp;#039;23x23&amp;#039;, [&amp;#039;P41&amp;#039;] = &amp;#039;23x23&amp;#039;}  local function toWikidataTimestamp(timestamp) 	local ret = nil 	if timesta...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pagină nouă&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local getArgs = require(&amp;#039;Modul:Arguments&amp;#039;).getArgs&lt;br /&gt;
local wikidata = require(&amp;#039;Modul:Wikidata&amp;#039;)&lt;br /&gt;
local StringUtils = require(&amp;#039;Modul:StringUtils&amp;#039;)&lt;br /&gt;
local DateUtils = require(&amp;#039;Modul:DateUtils&amp;#039;)&lt;br /&gt;
local GregorianDate = require(&amp;#039;Modul:GregorianDate&amp;#039;)&lt;br /&gt;
local join = require(&amp;#039;Modul:Separated entries&amp;#039;)._main&lt;br /&gt;
local libUtils = require(&amp;#039;libraryUtil&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local maxSize = { [&amp;#039;P94&amp;#039;] = &amp;#039;23x23&amp;#039;, [&amp;#039;P41&amp;#039;] = &amp;#039;23x23&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
local function toWikidataTimestamp(timestamp)&lt;br /&gt;
	local ret = nil&lt;br /&gt;
	if timestamp then&lt;br /&gt;
		ret = timestamp&lt;br /&gt;
		if mw.ustring.gmatch(timestamp, &amp;#039;^%d+$&amp;#039;) then&lt;br /&gt;
			return &amp;#039;+&amp;#039; .. timestamp .. &amp;#039;-00-00&amp;#039;, 9&lt;br /&gt;
		end&lt;br /&gt;
		if mw.ustring.find(timestamp, &amp;#039;%d+&amp;#039;) == 1 then&lt;br /&gt;
			ret = &amp;#039;+&amp;#039; .. timestamp&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
p._imageFromOneOfProps = function(entityId, imagePropIds, timestamp)&lt;br /&gt;
	local imageName = nil&lt;br /&gt;
	local maxSizeOfImage = nil&lt;br /&gt;
	for _idx, eachPropId in pairs(imagePropIds) do&lt;br /&gt;
		local defaultImageName = wikidata.findOneValueNoRef(eachPropId, entityId)&lt;br /&gt;
		local specificImageName = nil&lt;br /&gt;
		local dataClaim = nil&lt;br /&gt;
		if timestamp then&lt;br /&gt;
			dataClaim = wikidata.findClaimForTimestamp(entityId, eachPropId, timestamp)&lt;br /&gt;
		else&lt;br /&gt;
			local bestDataClaims = wikidata.findBestClaimsForProperty(entityId, eachPropId)&lt;br /&gt;
			if bestDataClaims and 0 &amp;lt; #bestDataClaims then dataClaim = bestDataClaims[1] end&lt;br /&gt;
		end&lt;br /&gt;
		if dataClaim and &amp;#039;statement&amp;#039; == dataClaim.type and &amp;#039;value&amp;#039; == dataClaim.mainsnak.snaktype then specificImageName = dataClaim.mainsnak.datavalue.value end&lt;br /&gt;
&lt;br /&gt;
		if imageName == nil and (defaultImageName and mw.text.trim(defaultImageName) ~= &amp;#039;&amp;#039; or specificImageName and mw.text.trim(specificImageName) ~= &amp;#039;&amp;#039;) then&lt;br /&gt;
			imageName = mw.text.trim(specificImageName or defaultImageName)&lt;br /&gt;
			maxSizeOfImage = StringUtils.appendIfMissing({maxSize[imagePropId] or &amp;#039;23x23&amp;#039;, &amp;#039;px&amp;#039;})&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local imageLink = &amp;#039;&amp;#039;&lt;br /&gt;
	if imageName and mw.text.trim(imageName) ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		imageLink = &amp;#039;[[Fișier:&amp;#039; .. imageName .. &amp;#039;|&amp;#039; .. maxSizeOfImage .. &amp;#039;|border]]&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	return imageLink&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p._nameAndImageFromOneOfProps = function(entityId, imagePropIds, timestamp)&lt;br /&gt;
	libUtils.checkTypeForNamedArg(&amp;#039;_nameAndImageFromOneOfProps&amp;#039;, &amp;#039;entityId&amp;#039;, entityId, &amp;#039;string&amp;#039;, true)&lt;br /&gt;
	libUtils.checkTypeForNamedArg(&amp;#039;_nameAndImageFromOneOfProps&amp;#039;, &amp;#039;imagePropIds&amp;#039;, imagePropIds, &amp;#039;table&amp;#039;, false)&lt;br /&gt;
	libUtils.checkTypeForNamedArg(&amp;#039;_nameAndImageFromOneOfProps&amp;#039;, &amp;#039;timestamp&amp;#039;, timestamp, &amp;#039;table&amp;#039;, true)&lt;br /&gt;
&lt;br /&gt;
	local articleLink = wikidata.findLinkToItem(entityId, true, false, true)&lt;br /&gt;
&lt;br /&gt;
	local imageLink = p._imageFromOneOfProps(entityId, imagePropIds, timestamp)&lt;br /&gt;
	&lt;br /&gt;
	return mw.text.trim(join({imageLink, articleLink, separator = &amp;#039; &amp;#039;}))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p._nameAndImage = function(entityId, imagePropId, timestamp)&lt;br /&gt;
	if not entityId or entityId == &amp;#039;&amp;#039; then return &amp;#039;&amp;#039; end&lt;br /&gt;
	&lt;br /&gt;
	libUtils.checkTypeForNamedArg(&amp;#039;_nameAndImage&amp;#039;, &amp;#039;imagePropId&amp;#039;, imagePropId, &amp;#039;string&amp;#039;, false)&lt;br /&gt;
	libUtils.checkTypeForNamedArg(&amp;#039;_nameAndImage&amp;#039;, &amp;#039;entityId&amp;#039;, entityId, &amp;#039;string&amp;#039;, true)&lt;br /&gt;
	libUtils.checkTypeForNamedArg(&amp;#039;_nameAndImage&amp;#039;, &amp;#039;timestamp&amp;#039;, timestamp, &amp;#039;table&amp;#039;, true)&lt;br /&gt;
&lt;br /&gt;
	return p._nameAndImageFromOneOfProps(entityId, {imagePropId}, timestamp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.nameAndImage = function(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local entityId = args[1]&lt;br /&gt;
	local propId = args[2]&lt;br /&gt;
	local timestamp = args[3] or args[&amp;#039;timestamp&amp;#039;]&lt;br /&gt;
	local wdTimestamp, wdTimestampPrecision = toWikidataTimestamp(timestamp)&lt;br /&gt;
	if timestamp then timestamp = DateUtils.parseWikidataDate(wdTimestamp, wdTimestampPrecision) end&lt;br /&gt;
	return p._nameAndImage(entityId, propId, timestamp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.nameAndCoatOfArms = function(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local entityId = args[1]&lt;br /&gt;
	local timestamp = args[2] or args[&amp;#039;timestamp&amp;#039;]&lt;br /&gt;
	local wdTimestamp, wdTimestampPrecision = toWikidataTimestamp(timestamp)&lt;br /&gt;
	if timestamp then timestamp = DateUtils.parseWikidataDate(wdTimestamp, wdTimestampPrecision) end&lt;br /&gt;
	return p._nameAndImage(entityId, &amp;#039;P94&amp;#039;, timestamp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.nameAndFlag = function(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local entityId = args[1]&lt;br /&gt;
	local timestamp = args[2] or args[&amp;#039;timestamp&amp;#039;]&lt;br /&gt;
	local wdTimestamp, wdTimestampPrecision = toWikidataTimestamp(timestamp)&lt;br /&gt;
	if timestamp then timestamp = DateUtils.parseDate(wdTimestamp, wdTimestampPrecision) end&lt;br /&gt;
	return p._nameAndImage(entityId, &amp;#039;P41&amp;#039;, timestamp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p._nameAndFlagFromPropOfEntity = function(propId, entityId, timestamp)&lt;br /&gt;
	if not propId then return &amp;#039;&amp;#039; end&lt;br /&gt;
	local entity = entityId&lt;br /&gt;
	local claims = nil&lt;br /&gt;
	if type(entity) == &amp;#039;table&amp;#039; then&lt;br /&gt;
		claims = entity:getBestStatements(propId)&lt;br /&gt;
	else&lt;br /&gt;
		if not entity then entity = mw.wikibase.getEntityIdForCurrentPage() end&lt;br /&gt;
		if type(entity) == &amp;#039;number&amp;#039; then entity = &amp;#039;Q&amp;#039; .. tostring(entityId) end&lt;br /&gt;
		if not entity then return nil end&lt;br /&gt;
		claims = mw.wikibase.getBestStatements(entity, propId)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local countryIdsList = {}&lt;br /&gt;
	if claims and 0 &amp;lt; #claims then&lt;br /&gt;
		for _,eachClaim in ipairs(claims) do&lt;br /&gt;
			if eachClaim.mainsnak.snaktype == &amp;#039;value&amp;#039; then&lt;br /&gt;
				table.insert(countryIdsList, eachClaim.mainsnak.datavalue.value.id)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local countriesWithFlags = {}&lt;br /&gt;
	for _,eachCountryId in ipairs(countryIdsList) do&lt;br /&gt;
		table.insert(countriesWithFlags, p._nameAndImage(eachCountryId, &amp;#039;P41&amp;#039;, timestamp))&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(countriesWithFlags, tostring(mw.html.create(&amp;#039;br&amp;#039;)))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.nameAndFlagFromPropOfEntity = function(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local propId = args[&amp;#039;pid&amp;#039;] or args[1]&lt;br /&gt;
	local entityId = args[&amp;#039;qid&amp;#039;] or args[2]&lt;br /&gt;
	local timpestamp = args[&amp;#039;timestamp&amp;#039;] or args[3]&lt;br /&gt;
&lt;br /&gt;
	return p._nameAndFlagFromPropOfEntity(propId, entityId, timestamp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.flag = function(frame)&lt;br /&gt;
	local args = getArgs(frame)&lt;br /&gt;
	local entityId = args[1]&lt;br /&gt;
	local timestamp = args[2] or args[&amp;#039;timestamp&amp;#039;]&lt;br /&gt;
	if timestamp then&lt;br /&gt;
		local wdTimestamp, wdTimestampPrecision = toWikidataTimestamp(timestamp)&lt;br /&gt;
		timestamp = DateUtils.parseWikidataDate(wdTimestamp, wdTimestampPrecision)&lt;br /&gt;
	end&lt;br /&gt;
	return p._imageFromOneOfProps(entityId, {&amp;#039;P41&amp;#039;}, timestamp)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Sergiu</name></author>
	</entry>
</feed>