User:Simant/Sandbox 3

{{#if:{{{era|}}}{{{captain|}}}{{{pilot|}}}{{{type|}}}{{{user|}}}{{{start|}}}{{{end|}}}{{{usage|}}}{{{series|}}}{{{manufacturer|}}}{{{operator|}}}|{{#vardefine:_Query_|{{User/query|era={{{era|}}}|captain={{{captain|}}}|pilot={{{pilot|}}}|type={{{type|}}}|usertype={{{user|}}}|start={{{start|}}}|end={{{end|}}}|usage={{{usage|}}}|series={{{series|}}}|manufacturer={{{manufacturer|}}}|operator={{{operator|}}}|ptype={{{ptype|}}}}}}} {{#vardefine:_pQuery_|{{User/pquery|era={{{era|}}}|captain={{{captain|}}}|pilot={{{pilot|}}}|type={{{type|}}}|usertype={{{user|}}}|start={{{start|}}}|end={{{end|}}}|usage={{{usage|}}}|series={{{series|}}}|manufacturer={{{manufacturer|}}}|operator={{{operator|}}}|ptype={{{ptype|}}}}}}}{{#arraydefine:_ParentItems_|{{#arraymap:{{#ask:{{#ask:{{#var:_Query_}}{{#var:_pQuery_}}|?Parent|sep=,,,|link=none|headers=hide|format=list|offset=000|limit=500|searchlabel=}}|,,,|_var_| {{#vardefine:a|{{#regex:_var_|/\s\([^\(]{1,255}\s\((Descendant{{!}}Variant)\)(,\s[^\(]{1,255}\s\((Descendant{{!}}Variant)\))*\)\z/}}}} {{#replace:_var_|{{#var:a}}}};{{#replace:{{#var:a}}|,|;}}|,}}}}{{#arraydefine:_TotalItems_|{{#ask:{{#var:_Query_}}|sep=,|link=none|offset=0|limit=500|searchlabel=}}}}{{#arraydefine:_LowerItems_|{{#arraymap:{{#arrayprint:_ParentItems_}}|,|!|{{#explode:!|;}}}}}}{{#arraydiff:_TopItems_|_TotalItems_|_LowerItems_}}{{#arraymap:{{#arrayprint:_TopItems_}}|,|_Layer0_|
 * _Layer0_ {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer1_|{{#arraymap:{{#sub:_Layer1_|{{#pos:_Layer1_|;}}}}|;|$parent$|{{#ifeq:_Layer0_|$parent$|
 * ;}} {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer2_|{{#arraymap:{{#sub:_Layer2_|{{#pos:_Layer2_|;}}}}|;|$parent$|{{#ifeq:{{#explode:_Layer1_|;}}|$parent$|
 * ;}} {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer3_|{{#arraymap:{{#sub:_Layer3_|{{#pos:_Layer3_|;}}}}|;|$parent$|{{#ifeq:{{#explode:_Layer2_|;}}|$parent$|
 * ;}} {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer4_|{{#arraymap:{{#sub:_Layer4_|{{#pos:_Layer4_|;}}}}|;|$parent$|{{#ifeq:{{#explode:_Layer3_|;}}|$parent$|
 * ;}} {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer5_|{{#arraymap:{{#sub:_Layer5_|{{#pos:_Layer5_|;}}}}|;|$parent$|{{#ifeq:{{#explode:_Layer4_|;}}|$parent$|
 * ;}} {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer6_|{{#arraymap:{{#sub:_Layer6_|{{#pos:_Layer6_|;}}}}|;|$parent$|{{#ifeq:{{#explode:_Layer5_|;}}|$parent$|
 * ;}} {{#arraymap:{{#arrayprint:_ParentItems_}}|,|_Layer7_|{{#arraymap:{{#sub:_Layer7_|{{#pos:_Layer7_|;}}}}|;|$parent$|{{#ifeq:{{#explode:_Layer6_|;}}|$parent$|
 * ;}}

}}|}}|}} }}|}}|}} }}|}}|}} }}|}}|}} }}|}}|}} }}|}}|}} }}|}}|}} }}
 * }}