Module:CRTModel: Difference between revisions

No edit summary
No edit summary
Line 192: Line 192:
addSectionRow(tbl, 'Standards')
addSectionRow(tbl, 'Standards')
addFullRow(tbl, standards_semantic, 'padding:0.2em 0.4em;', false)
addFullRow(tbl, standards_semantic, 'padding:0.2em 0.4em;', false)
end
-- Documents section
local documentsAskWikitext =
'{{#ask:\n' ..
' [[Category:Documents]]\n' ..
' [[Has related CRT model::' .. fullPageName .. ']]\n' ..
' |?Has document type\n' ..
' |?Has document URL\n' ..
' |format=list\n' ..
' |link=none\n' ..
'}}'
local documentsAskResult = frame:preprocess(documentsAskWikitext)
-- Build the upload link
local target = pageName .. " - document"
local uploadUrl = mw.uri.fullUrl(
"Special:FormEdit",
{
form = "Document",
target = target,
["Document[crt_model]"] = pageName
}
)
-- Check if there are any documents
local hasDocuments = documentsAskResult and trim(documentsAskResult) and not documentsAskResult:match('^%s*$')
-- Always show Documents section if there are documents OR if we want to show the upload link
addSectionRow(tbl, 'Documents')
if hasDocuments then
-- Parse the ask results and build bulleted list
local docListWikitext =
'{{#ask:\n' ..
' [[Category:Documents]]\n' ..
' [[Has related CRT model::' .. fullPageName .. ']]\n' ..
' |?Has document type=Type\n' ..
' |?Has document URL=URL\n' ..
' |format=ul\n' ..
' |template=Document link inline\n' ..
' |named args=yes\n' ..
' |searchlabel=\n' ..
'}}'
local docListHtml = frame:preprocess(docListWikitext)
-- Add the documents list plus upload link
local combinedHtml = docListHtml .. '\n* [' .. tostring(uploadUrl) .. ' Upload a document]'
addFullRow(tbl, combinedHtml, 'padding:0.2em 0.4em;', true)
else
-- Just show the upload link
local uploadLinkHtml = '* [' .. tostring(uploadUrl) .. ' Upload a document]'
addFullRow(tbl, uploadLinkHtml, 'padding:0.2em 0.4em;', true)
end
end


MediaWiki Appliance - Powered by TurnKey Linux