Module:Wdtablerow/listed buildings explained

--This module is invoked from Template:English Heritage listed building row/Leeds Universitylocal getArgs = require('Module:Arguments').getArgslocal wd = require('Module:Wd')local p = local qid= local label_tlocal label_textlocal location_plocal location_textlocal completed_yearlocal completed_textlocal source_circumstancelocal earliest_datelocal latest_datelocal range_start_datelocal has_creatorlocal has_architectlocal architect_textlocal image_textlocal commons_cat_textlocal return_text

function p.main(frame)

local row_header_text='|-style=\"text-align: center;\"\n!scope=\"row\" | ' --sets up row style sets 1st cell as header row local args = getArgs(frame) --assign passed parameters qid= (args.qid or args[1] or ) local o_name= (args.name or args[2] or ) --local name local o_location= (args.location or args[3] or ) --local location local entry_notes= (args.notes or args[4] or ) -- freetext notes local image_title=(args.image or args[5] or ) -- local image --label if o_name

then label_t=wd._label --use wd label else label_t=o_name --overwrite name with local value end local site_link = mw.wikibase.sitelink(qid) --check if there is a sitelink if site_link then --if there is make the link = the sitelink but piped with the label/overwrite name label_text=''..label_t..'' else label_text=label_t end local wd_link='('..wd._label..')' --whatever the label add a WikiData link underneath and enclose in brackets --location if wd._property ~= then location_p='P276' --use P276 if present else location_p='P131' --fallback if P276 isn't present end if o_location~= then location_text=o_location --overwrite with local value else location_text=wd._property -- use wd location end --image if image_title~= then image_text=image_title --overwrite WD value if filename is passed. No error checking i.e. is filename valid as yet. else image_text=wd._property --otherwise use WD image end if image_text~= then --add markup only if an image file is named image_text = '' --add wiki markup end --non-overwriteable parameters --completion year completed_year=wd._property --determine in P571 (inception) is present if completed_year~= then completed_year='P571' --if it is make the value equal inception else completed_year='P580' --else make it equal start year end completed_text=wd._property --set return value to whichever --check for qualifiers source_circumstance=wd._qualifier --check for circa etc qualifier to completion date earliest_date=wd._qualifier --check for the earliest and latest date qualifiers latest_date=wd._qualifier if source_circumstance~= then completed_text='data-sort-value=\"'..completed_text..'\"|'..source_circumstance..' '..completed_text --if there is a qualifier use it as a prefix to the date but keep the date as the sort-value end if earliest_date~= and latest_date~= then --only proceed if both are present completed_text='data-sort-value=\"'..completed_text..'\"|'..earliest_date..' - '..latest_date --if there is a range use it as the date but keep the completed date as the sort-value end --architect or creator has_creator=wd._property --get P170 if it exists has_architect= wd._property --get P84 if it exists if has_architect~= and has_creator

then --if no creator then architect_text=wd._properties --use P84 architect. Note properties to catch multiple uses elseif has_architect

and has_creator~= then architect_text=wd._property --use P170 creator elseif has_architect

and has_creator

then --if no creator then architect_text= --use an empty string if neither are present end --heritage designation and date local heritage_text=wd._property --heritage designation local heritage_date_text=wd._qualifier --and date of listing local heritage_type=wd._property --decides cell shading based on listing grade local cell_shading= if heritage_type

'Q15700818' then --Grade I cell_shading='style=\"background: #FFC0CB;\"|' elseif heritage_type

'Q15700831' then --Grade II* cell_shading='style=\"background: #87CEEB;\"| ' elseif heritage_type

'Q15700834' then --Grade II cell_shading='style=\"background: #ACE1AF;\"| ' else cell_shading= end if entry_notes~= then entry_notes = 'style=\"text-align: left;\" |'..entry_notes end local gbmapping_text=frame:expandTemplate --gb map local coord_text=wd._property --and co-ords local list_number_text=frame:expandTemplate --NHLE number local commons_cat_name=wd._property if commons_cat_name

then --commons category commons_cat_text= --ignore non-existent or unlinked in WD categories else commons_cat_text=''..commons_cat_name..'' end --return cell values to page return_text=row_header_text..label_text..'
'..wd_link..'\n|' --includes code to create new line and make first cell row header ..location_text..'\n|' ..completed_text..'\n|' ..architect_text..'\n|' ..cell_shading..heritage_text..'
('..heritage_date_text..')\n|' ..entry_notes..'\n|' ..gbmapping_text..'
'..coord_text..'\n|' ..image_text..'\n|' ..list_number_text..'\n|' ..commons_cat_text return return_text

endreturn p