پودمان:AlborzHealthcare: تفاوت میان نسخهها
ظاهر
صفحهای تازه حاوی «-------------------------------------------------------------------------------- -- Module:AlborzHealthcare -- Wiki Alborz Healthcare Information System -- Core Engine -- Version 1.0 -------------------------------------------------------------------------------- local p = {} -------------------------------------------------------------------------------- -- CLEAN ---------------------------------------------------------------------...» ایجاد کرد |
جزبدون خلاصۀ ویرایش |
||
| خط ۳: | خط ۳: | ||
-- Wiki Alborz Healthcare Information System | -- Wiki Alborz Healthcare Information System | ||
-- Core Engine | -- Core Engine | ||
-- Version 1. | -- Version 1.1 | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
local p = {} | local p = {} | ||
-------------------------------------------------------------------------------- | |||
-- LOAD DATA | |||
-------------------------------------------------------------------------------- | |||
local data = mw.loadData("Module:AlborzHealthcare/Data") | |||
| خط ۷۸: | خط ۸۴: | ||
label = label, | label = label, | ||
value = value | value = value | ||
| خط ۹۵: | خط ۱۰۰: | ||
local result = {} | local result = {} | ||
table.insert(result, | table.insert(result, | ||
'<table class="healthcare-infobox">' | '<table class="healthcare-infobox">' | ||
) | ) | ||
| خط ۱۱۰: | خط ۱۱۰: | ||
------------------------------------------------------------ | ------------------------------------------------------------ | ||
local title = args.name or mw.title.getCurrentTitle().text | local title = | ||
args.name or mw.title.getCurrentTitle().text | |||
| خط ۱۲۱: | خط ۱۲۲: | ||
) | ) | ||
| خط ۱۶۳: | خط ۱۶۳: | ||
end | end | ||
------------------------------------------------------------ | ------------------------------------------------------------ | ||
-- | -- GROUPS | ||
------------------------------------------------------------ | ------------------------------------------------------------ | ||
for _,group in ipairs(data.groups) do | |||
local fields = {} | |||
for _,field in ipairs(group.fields) do | |||
addField( | |||
fields, | |||
field[1], | |||
args[field[2]] | |||
) | |||
end | |||
if #fields > 0 then | |||
table.insert(result, | |||
'<tr class="healthcare-infobox-header">' .. | |||
'<th colspan="2">' .. | |||
group.title .. | |||
'</th></tr>' | |||
) | |||
for _,item in ipairs(fields) do | |||
table.insert(result, | |||
'<tr>' .. | |||
'<th class="healthcare-infobox-label">' .. | |||
item.label .. | |||
'</th>' .. | |||
'<td class="healthcare-infobox-value">' .. | |||
item.value .. | |||
'</td>' .. | |||
'</tr>' | |||
) | |||
end | |||
end | |||
end | |||
------------------------------------------------------------ | ------------------------------------------------------------ | ||
-- | -- CLOSE | ||
------------------------------------------------------------ | ------------------------------------------------------------ | ||
table.insert(result, | table.insert(result, | ||
| خط ۳۱۹: | خط ۲۴۹: | ||
end | end | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- PUBLIC | -- PUBLIC FUNCTIONS | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
| خط ۳۳۵: | خط ۲۶۴: | ||
function p.infobox(frame) | function p.infobox(frame) | ||
| خط ۳۴۷: | خط ۲۷۲: | ||
-------------------------------------------------------------------------------- | |||
-- EXPORT | |||
-------------------------------------------------------------------------------- | |||
return p | return p | ||
نسخهٔ ۴ اوت ۲۰۲۶، ساعت ۱۳:۳۰
توضیحات این پودمان میتواند در پودمان:AlborzHealthcare/توضیحات قرار گیرد.
--------------------------------------------------------------------------------
-- Module:AlborzHealthcare
-- Wiki Alborz Healthcare Information System
-- Core Engine
-- Version 1.1
--------------------------------------------------------------------------------
local p = {}
--------------------------------------------------------------------------------
-- LOAD DATA
--------------------------------------------------------------------------------
local data = mw.loadData("Module:AlborzHealthcare/Data")
--------------------------------------------------------------------------------
-- CLEAN
--------------------------------------------------------------------------------
local function clean(value)
if value == nil then
return nil
end
if type(value) == "string" then
value = mw.text.trim(value)
if value == "" then
return nil
end
end
return value
end
--------------------------------------------------------------------------------
-- GET ARGUMENTS
--------------------------------------------------------------------------------
local function getArgs(frame)
local args = {}
local source = frame:getParent() or frame
for k,v in pairs(source.args) do
local key = mw.text.trim(k)
local value = clean(v)
if value then
args[key] = value
end
end
return args
end
--------------------------------------------------------------------------------
-- ADD FIELD
--------------------------------------------------------------------------------
local function addField(result,label,value)
value = clean(value)
if value then
table.insert(result,{
label = label,
value = value
})
end
end
--------------------------------------------------------------------------------
-- BUILD INFOBOX
--------------------------------------------------------------------------------
local function build(args)
local result = {}
table.insert(result,
'<table class="healthcare-infobox">'
)
------------------------------------------------------------
-- TITLE
------------------------------------------------------------
local title =
args.name or mw.title.getCurrentTitle().text
table.insert(result,
'<tr class="healthcare-infobox-title">' ..
'<th colspan="2">' ..
title ..
'</th></tr>'
)
------------------------------------------------------------
-- IMAGE
------------------------------------------------------------
if args.image then
table.insert(result,
'<tr>' ..
'<td colspan="2" class="healthcare-infobox-image">' ..
'[[File:' ..
args.image ..
'|250px]]'
)
if args.caption then
table.insert(result,
'<div class="healthcare-infobox-caption">' ..
args.caption ..
'</div>'
)
end
table.insert(result,
'</td></tr>'
)
end
------------------------------------------------------------
-- GROUPS
------------------------------------------------------------
for _,group in ipairs(data.groups) do
local fields = {}
for _,field in ipairs(group.fields) do
addField(
fields,
field[1],
args[field[2]]
)
end
if #fields > 0 then
table.insert(result,
'<tr class="healthcare-infobox-header">' ..
'<th colspan="2">' ..
group.title ..
'</th></tr>'
)
for _,item in ipairs(fields) do
table.insert(result,
'<tr>' ..
'<th class="healthcare-infobox-label">' ..
item.label ..
'</th>' ..
'<td class="healthcare-infobox-value">' ..
item.value ..
'</td>' ..
'</tr>'
)
end
end
end
------------------------------------------------------------
-- CLOSE
------------------------------------------------------------
table.insert(result,
'</table>'
)
return table.concat(result,"\n")
end
--------------------------------------------------------------------------------
-- PUBLIC FUNCTIONS
--------------------------------------------------------------------------------
function p.main(frame)
local args = getArgs(frame)
return build(args)
end
function p.infobox(frame)
return p.main(frame)
end
--------------------------------------------------------------------------------
-- EXPORT
--------------------------------------------------------------------------------
return p