Module:Class/Book contribution




example
{"Has initial":"","Title":"De wereld in","Has sort label":"wereld in de","Title plain":"De wereld in","Has sort label by author":""}
{"Has initial":"","Title":"Onvoltooide engelen","Has sort label":"onvoltooide engelen","Title plain":"Onvoltooide engelen","Has sort label by author":""}

local p = {}
local mSlot = require("Module:Slot")
local mFormatForSorting = require("Module:Format for sorting")
--local mTitle = require("Module:Class/Title")
--local mPerson = require("Module:Class/Person")

--[[
-->{{#slottemplates:ws-page-props |{{{TitelID|}}} | @title-props }}<!--
-->{{#vardefine:@titel|{{#caprint:@title-props[Title][TitelGew]}} }}<!--
-->{{#vardefine:@sort title|{{Strip title for sorting|{{lc:{{#caprint:@title-props[Title][TitelBiblio]}}}} }} }}<!--
-->{{DISPLAYTITLE:{{#var:@titel|Geen titel}}}}<!--

|Has publication year={{#show:{{{BoekID|}}} |?Has publication year}}
|Has publication year (date)={{#show:{{{BoekID|}}} |?Has publication year (date)}}
|Title={{#var:@titel|Geen titel}}
|Title plain={{#var:@titel|Geen titel}}
|Has sort label={{#var:@sort title}}¶
|Has sort label by author={{#show:{{{TitelID|-}}}|?Has sort label by author=|link=none}}
|Has initial={{uc:{{#sub:{{#var:@sort title}}|0|1}}}}

]]--
	
p.set = function( frame )
	local titelid = frame.args.titelid or ""
	local boekid = frame.args.boekid or ""
	
	local titelGew = ""
	local titelBiblio = ""
	local labelForSort = ""
	local displayTitle = ""
	if titelid ~= "" then
		titelGew = mSlot.getValueFromTemplateData( "ws-page-props", titelid, "Title", "TitelGew" )
		titelBiblio = mSlot.getValueFromTemplateData( "ws-page-props", titelid, "Title", "TitelBiblio" )
		if titelGew == "" then
			displayTitle = "Geen titel"
		else
			displayTitle = titelGew
		end
		labelForSort = mFormatForSorting.flatten( mw.text.trim( titelBiblio ) )
	end
	
	local set = {
		["Title"] = displayTitle,
		["Title plain"] = displayTitle,
		["Has sort label"] = labelForSort,
		["Has sort label by author"] = "",
		["Has initial"] = ""
	}
	
	local debugmode = frame.args.debugmode or "false"
	if debugmode == "true" then
		return "<pre>" .. mw.text.jsonEncode( set ) .. "</pre>"
	end
	
	local setResult = nil
	if mw.smw then
		setResult = mw.smw.set( set )
	end
	
	mw.ext.displaytitle.set( displayTitle )

end

return p