Die Dokumentation für dieses Modul kann unter Modul:Contract/Doku erstellt werden
require( 'strict' ) local Contract = {} local metatable = {} local methodtable = {} metatable.__index = methodtable --- Needed Extensions local infobox = require( 'Module:InfoboxNeue' ) local common = require( 'Module:Common' ) local localized = require( 'Module:Localized' ) local TNT = require( 'Module:Translate' ):new() --- Save properties to the smw store function methodtable.setSemanticProperties( self ) self.smwData[ 'Name' ] = self.args[ 'Name' ] or nil; self.smwData[ 'Titel' ] = self.args[ 'Name' ] or nil; self.smwData[ 'Auftraggeber' ] = self.args[ 'Auftraggeber' ] or self.args[ 'Contractor' ] or nil; self.smwData[ 'Auftragstyp' ] = self.args[ 'Auftragstyp' ] or self.args[ 'Type' ] or nil; self.smwData[ 'Auftragsklasse' ] = self.args[ 'Auftragsklasse' ] or self.args[ 'Class' ] or nil; self.smwData[ 'Verfügbarkeit' ] = self.args[ 'Verfügbarkeit' ] or self.args[ 'Availability' ] or nil; self.smwData[ 'Bezahlung' ] = self.args[ 'Bezahlung' ] or self.args[ 'Payment' ] or nil; if not mw.title.getCurrentTitle().isSubpage then local result = mw.smw.set( self.smwData ) common.checkSmwResult( result ) end end --- Adds the main category function methodtable.setMainCategory( self ) table.insert( self.categories, '[[Category:Auftrag]]' ) end --- Extracts args and sets up the module function methodtable.init( self, frame ) self.args = require( 'Module:Arguments' ).getArgs( frame ) self:setSemanticProperties() if self.smwData[ 'Auftragsgeber' ] ~= nil then table.insert( self.categories, '[[Category:' .. self.smwData[ 'Auftragsgeber' ] .. ']]' ) end self:setMainCategory() end function Contract.main( frame ) local instance = Contract:new() instance:init( frame ) local box = infobox:new() box:renderImage( common.getImage( { instance.args[ 'image' ] } ) ) box:renderHeader( instance.smwData[ 'Name' ] or localized.getMainTitle() ) box:renderSection( { col = 2, content = { box:renderItem( TNT.format( 'Module:Contract/i18n.json', 'lbl_from' ), instance.smwData[ 'Auftraggeber' ] or '-' ), box:renderItem( TNT.format( 'Module:Contract/i18n.json', 'lbl_availability' ), instance.smwData[ 'Verfügbarkeit' ] or '-' ), box:renderItem( TNT.format( 'Module:Contract/i18n.json', 'lbl_type' ), instance.smwData[ 'Auftragstyp' ] or '-' ), box:renderItem( TNT.format( 'Module:Contract/i18n.json', 'lbl_class' ), instance.smwData[ 'Auftragsklasse' ] or '-' ), box:renderItem( TNT.format( 'Module:Contract/i18n.json', 'lbl_payment' ), instance.smwData[ 'Bezahlung' ] or '-' ), } } ) if instance.args[ 'Editlink' ] ~= nil then box:renderFooterButton( { label = 'Mission Bearbeiten', type = 'link', content = instance.args[ 'Editlink' ] } ) end return tostring( box ) .. tostring( table.concat( instance.categories, '' ) ) end --- New Instance function Contract.new( self ) local instance = { args = {}, smwData = { [ 'Name' ] = nil, [ 'Auftraggeber' ] = nil, [ 'Auftragstyp' ] = nil, [ 'Auftragsklasse' ] = nil, [ 'Availability' ] = nil, [ 'Bezahlung' ] = nil, }, categories = {}, } setmetatable( instance, metatable ) return instance end return Contract