יחידה:אתר רשמי
ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:אתר רשמי/תיעוד
function extendedConcat(t, f_sep, m_sep, l_sep)
local concated = ''
local f_sep = f_sep or ''
local m_sep = m_sep or ''
local l_sep = l_sep or ''
for idx,val in ipairs(t) do
if idx == 1 then
concated = concated .. f_sep .. val
elseif next(t,idx) ~= nil then
concated = concated .. m_sep .. val
elseif next(t,idx) == nil then
concated = concated .. l_sep .. val
end
end
return concated
end
function formatWebsite(url, name, languages, countries)
local icon = '[[file:Green globe.svg|15px]]'
local urlTemplate = '[' .. url ..' אתר האינטרנט הרשמי] של'
local result = '* ' .. icon .. ' ' .. urlTemplate .. ' ' .. name
if next(languages) ~= nil then
local language = '<span dir="rtl" class="languageicon" style="font-size:0.95em; font-weight:bold; color:#555;">('..extendedConcat(languages, 'ב', ', ב', ' וב')..')</span>'
result = result .. ' ' .. language
elseif next(countries) ~= nil then
local country = '<span dir="rtl" style="font-size:0.95em; font-weight:bold; color:#555;">('..extendedConcat(countries, nil, ', ', ' ו')..')</span>'
result = result .. ' ' .. country
end
return result
end
function extractQualifier(claim, qualifier, ignoredValue)
local values = {}
if claim.qualifiers and claim.qualifiers[qualifier] then
for _,v in pairs(claim.qualifiers[qualifier]) do
if mw.wikibase.label(v.datavalue.value.id) ~= ignoredValue then
table.insert(values, mw.wikibase.label(v.datavalue.value.id))
end
end
end
return values
end
function isHebrewWebsite(claim)
if claim.qualifiers and claim.qualifiers['P407'] then
for _,v in pairs(claim.qualifiers['P407']) do
if mw.wikibase.label(v.datavalue.value.id) == 'עברית' then
return true
end
end
end
return false
end
-- generate websites from wikidata
function websites(frame)
local name = frame.args["שם"] or frame.args["name"]
local entityId = frame.args["entityId"]
local websiteProperty = 'P856'
local languageQualifier = 'P407'
local countryQualifier = 'P17'
if not name or name == '' then
name = mw.title.getCurrentTitle().text:gsub('%b()', '')
end
return nil
end
return {
formatWebsite = formatWebsite,
websites = websites
}