Module:Developer

From Eli's Software Encyclopedia

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

local utils = require('Module:Utils')

local p = {}

function p.semanticStore(frame)
	
	local titleObj  = mw.title.getCurrentTitle()
	local args      = frame:getParent().args or {}
	
	-- Get and normalize parameter values
	local title     = args['name'] or args['Name'] or args['title'] or titleObj.text
	local logo		= args['logo'] or args['Logo'] or ''
	local logoFilename = ''
	if logo ~= '' then
		logoFilename = frame:preprocess('{{PAGENAME:' .. logo .. '}}')
	end
	local image		= args['image'] or args['photo'] or args['Photo'] or ''
	local imageFilename, imageAlt, imageCaption = '', '', ''
	if image ~= '' then
		local fn, alt = utils.parseFileLink(image)
		if fn then
    		imageFilename = fn
        	imageAlt  = alt or args['caption'] or args['Caption'] or ''
        else
        	imageFilename = frame:preprocess('{{PAGENAME:' .. image .. '}}')
    	end
		imageCaption = args['caption'] or args['Caption'] or ''
	end
	local address = args['address'] or args['Address'] or ''
	local country = args['country'] or args['Country'] or ''
	local founded = args['founded'] or args['Founded'] or ''
	local defunct = args['defunct'] or args['Defunct'] or ''
	local acquiredBy = args['acquiredby'] or args['Acquired by'] or ''
	local labelOf = args['labelof'] or args['Label of'] or ''
	local phone = args['phone'] or args['Phone'] or ''
	local fax = args['fax'] or args['Fax'] or ''
	local website = args['website'] or args['Website'] or ''
	local websiteUrl = utils.getUrlFromLink(website) or ''
	
	-- Set properties
    local data = {
    	'Has Title=' .. title,
    	'Has Logo=' .. logoFilename,
    	'Has Image=' .. imageFilename,
    	'Has Image Caption=' .. imageCaption,
    	'Address=' .. address,
    	'Country=' .. country,
    	'Foundation Date=' .. founded,
    	'Defunct Info=' .. defunct,
    	'Acquired By=' .. acquiredBy,
    	'Label=' .. labelOf,
    	'Phone=' .. phone,
    	'Fax=' .. fax,
    	'Website URL=' .. websiteUrl
	}
	mw.smw.set( data )
	
end

return p