Module:Common: Difference between revisions

From DataTrek
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:
       local Property = mw.wikibase.getEntity('P' .. PNumber)
       local Property = mw.wikibase.getEntity('P' .. PNumber)
      
      
       PDetails[#PDetails + 1] = 'P' .. PNumber
       PDetails[#PDetails + 1] = Property.id
       PDetails[#PDetails + 1] = Property.type
      PDetails[#PDetails + 1] = Property.datatype
       PDetails[#PDetails + 1] = Property.labels["it"].value
      
      
       --AllP[#AllP + 1] = 'P' .. PNumber
       --AllP[#AllP + 1] = 'P' .. PNumber

Revision as of 00:19, 10 June 2020

Documentation for this module may be created at Module:Common/doc

-- Keyword: wikitrek
local p = {}
function p.SiteAllP()
	local MaxP = 20
	local Separator = "|"
	local AllP = {}
	local PDetails = {}
	
	for PNumber = 1, MaxP, 1 do
      if mw.wikibase.entityExists('P' .. PNumber) then
      	local PDetails = {}
      	local Property = mw.wikibase.getEntity('P' .. PNumber)
      	
      	PDetails[#PDetails + 1] = Property.id
      	PDetails[#PDetails + 1] = Property.datatype
      	PDetails[#PDetails + 1] = Property.labels["it"].value
      	
      	--AllP[#AllP + 1] = 'P' .. PNumber
      	AllP[#AllP + 1] = table.concat(PDetails, Separator)
      end
    end
	
	return table.concat(AllP, "<br />" .. string.char(10))
end
return p