Moduł:Brudnopis/Paweł Ziemian/Wikidane/formatFile1

Z Wikipedii, wolnej encyklopedii

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Brudnopis/Paweł Ziemian/Wikidane/formatFile1/opis

return {

scope = "props",

format = function(props, options)
	mw.logObject(props, "props")
	mw.logObject(options, "options")
	if #props <= 0 then
		return
	end

	for k, v in ipairs(props) do
		mw.logObject(v, "v")
		local item = {}
		if (v.type == "statement") and ((v.rank == "normal") or (v.rank == "preferred")) then
			if v.mainsnak and (v.mainsnak.snaktype == "value") and (v.mainsnak.datatype == "commonsMedia") and v.mainsnak.datavalue and (v.mainsnak.datavalue.type == "string") then
				local value = v.mainsnak.datavalue.value
				if #value > 0 then
					local alt = mw.wikibase.label(v.mainsnak.property)
					local description = require("Moduł:Wikidane/format/qualifiers").TEXT1(v, nil, "P2096")
					local result = {}
					table.insert(result, "[[Plik:")
					table.insert(result, value)
					if options and options.format and (#options.format > 0) then
						table.insert(result, "|")
						table.insert(result, options.format)
						if mw.ustring.match(options.format, "^%s*alt%s*=") or mw.ustring.match(options.format, "|%s*alt%s*=") then
							alt = false
						end
					end
					if alt and (#alt > 0) then
						table.insert(result, "|alt=")
						table.insert(result, alt)
					end
					if description and (#description > 0) then
						table.insert(result, "|")
						table.insert(result, description)
					end
					
					table.insert(result,"]]")
					return table.concat(result)
				end
			end
		end
	end
end,
 
}