Deze module is nog in ontwikkeling (versie 0.0) en wordt getest.
De Module:Layout is bedoeld om snel, consistent en uitgebreid een pagina op te maken.
Er is een op de module afgestemde handleiding over deze onderwijswiki beschikbaar.
-- This submodule checks all the input passed to Module:Layout. -- If an input is invalid this submodule will default it to allow correct proceeding.-- Any mistake found will be reported to the user.-- This submodle will set call.pass to false to prevent the system to be launched.localsecurity={};localfrisk={};localreport={};-- This function checks the identity of the calling pages.-- Only passage is granted to a call by the correct interface template.functionsecurity.authentication(call)call.add_new_debug(call.message.DEBUG.INVOKER,tostring(call.invoker),report.debugging(call));if(call.invoker~=call.template)thencall.add_new_mistake(call.message.MISTAKE.NO_INTERFACE_TEMPLATE);call.add_debug(call.message.DEBUG.NO_INTERFACE_TEMPLATE);endreturncall;endfunctionsecurity.declaration(call)-- The functions from other modules that are used in this functionlocalarray=call.include("array");-- Loop over named parametersforkey,valueinpairs(call.named)do-- The parameter should be listed in the configuration setting hook.PARAMETERifnotarray.search(call.hook.PARAMETER,key)thencall.add_new_mistake(call.message.MISTAKE.WRONG.INVOKE_PARAMETER,key,key,value);endendreturncall;end-- This function frisks all the parameters that are added by the frame on their values.functionsecurity.frisk(call)-- The functions from other modules that are used in this functionlocalarray,frisk=call.include("array","frisk");localmistakes_before_value_check=#call.mistake;for_,parameterinipairs(call.hook.PARAMETER)do-- Protect the call object for being changed by the frisk so no other wiki-objects are infected accidentaly-- The frisks should only return the result not change anything it frisks.localcall_clone=array.copy(call);iffrisk[parameter](call_clone)thencall.add_new_mistake(frisk[parameter](call_clone));endendlocalvalue_mistake=#call.mistake-mistakes_before_value_check;ifvalue_mistake==0thencall.add_debug(call.message.DEBUG.VALUES_OK);endifvalue_mistake==1thencall.add_mistake(call.message.DEBUG.VALUE_MISTAKE);endifvalue_mistake>1thencall.add_mistake(call.message.DEBUG.VALUE_MISTAKES,value_mistake);endreturncall;end-- This function checks the original call to the template-- This call has the parameters named in the installed language in stead of the names used in this application.-- Be aware that we are not able to know if the template has been called multiple times in the page-- which one is the one we need. So we just check everyone.functionsecurity.scan(call)-- returns call object with security information-- The functions from other modules that are used in this functionlocalextract,array=call.include("extract","array");-- A strange thing can happen that a doc page is returning it's module content -- and if in it are strings containing template defintions it will produce unwanted results.-- if call.caller:inNamespace( "Module" ) and call.caller.subpageText ~= "doc" then return call; endcall.add_new_debug(call.message.DEBUG.CALLER,tostring(call.invoker),tostring(call.caller));localcaller_content=call.caller:getContent();localcalling_templates=extract.template(caller_content,call.message.TEMPLATENAME,call);localparameter_mistake={};forindex,valueinipairs(calling_templates)doforkey,vinpairs(value)do-- We only check the named arguments of the string because the unnamed parameters are free to use up to this point-- and see if they are hooked as valid parameters in the configuration of the language.-- Allow case-insensitive values for the parameters ifnottonumber(key)andnotarray.search(call.message.HOOK.PARAMETER,key,true)thenparameter_mistake[#parameter_mistake+1]=key;call.add_new_mistake(call.message.MISTAKE.WRONG.TEMPLATE_PARAMETER,key,key,v,table.concat(call.message.HOOK.PARAMETER,", "));endendend-- The mistakes are already stored. The debug reports only the number of mistakes found.if#parameter_mistake==0thencall.add_debug(call.message.DEBUG.PARAMETERS_OK);endif#parameter_mistake==1thencall.add_debug(call.message.DEBUG.PARAMETER_MISTAKE,parameter_mistake[1]);endif#parameter_mistake>1thencall.add_debug(call.message.DEBUG.PARAMETER_MISTAKES,#parameter_mistake,table.concat(parameter_mistake,", "));endreturncall;end-- Construct a template call as the module would have received it so the user can check if he used wrong named parametersfunctionreport.debugging(call)localcall_string="{{#invoke:Layout|main";-- loop over named parametersforkey,valueinpairs(call.named)docall_string=call_string.."|"..key.."="..value;end-- loop over unnamed parametersfor_,valueinipairs(call.unnamed)docall_string=call_string.."|"..value;endreturncall_string.."}}";endreturnsecurity;