وحدة:Wikidata2 sub modules/P39
المظهر
| هذه الوحدة تعتمد على الوحدات الأخرى التالية: |
بسبب ظهور مشاكل التضمين في بعض الصفحات يعرض القالب 10 قيم فقط. ويمكن تحديد قيم أقل عبر الوسيط |limit=.
أمثلة
1
صفحة فاليري جيسكار ديستان (Q2124):
| مناصب | ||
|---|---|---|
| 21 يناير 1995 – 18 يناير 2003 | ||
| عضو مجلس النواب الأمريكي[1][2] | ||
| 5 يناير 1993 – 3 يناير 1995 | ||
| الانتخابات | انتخابات مجلس النواب الأمريكي 1992 | |
| الدائرة الإنتخابية | الدائرة الكونغرسية السابعة لتينيسي | |
| فترة برلمانية | الكونغرس الأمريكي الثالث بعد المائة | |
| عضو مجلس النواب الأمريكي[1][2] | ||
| 3 يناير 1991 – 3 يناير 1993 | ||
| الانتخابات | انتخابات مجلس النواب الأمريكي 1990 | |
| الدائرة الإنتخابية | الدائرة الكونغرسية السابعة لتينيسي | |
| فترة برلمانية | الكونغرس الأمريكي الثاني بعد المائة | |
| عضو مجلس النواب الأمريكي[1][2] | ||
| 3 يناير 1989 – 3 يناير 1991 | ||
| الدائرة الإنتخابية | الدائرة الكونغرسية السابعة لتينيسي | |
| فترة برلمانية | الكونغرس الأمريكي الـ101 | |
| عضو مجلس النواب الأمريكي[1][2] | ||
| 3 يناير 1987 – 3 يناير 1989 | ||
| الدائرة الإنتخابية | الدائرة الكونغرسية السابعة لتينيسي | |
| فترة برلمانية | الكونغرس الأمريكي الـ100 | |
| عضو مجلس النواب الأمريكي[1][2] | ||
| 3 يناير 1985 – 3 يناير 1987 | ||
| الدائرة الإنتخابية | الدائرة الكونغرسية السابعة لتينيسي | |
| فترة برلمانية | الكونغرس الأمريكي الـ99 | |
| عضو مجلس النواب الأمريكي[1][2] | ||
| 3 يناير 1983 – 3 يناير 1985 | ||
| الدائرة الإنتخابية | الدائرة الكونغرسية السابعة لتينيسي | |
| فترة برلمانية | الكونغرس الأمريكي الثامن والتسعون | |
{{ص.م/فتح}}
{{صندوق معلومات صاحب منصب/منصب ويكي بيانات|Q358726|noref=1}}
{{ص.م/غلق}}
مثال مع امكانية ظهور الخطأ
صفحة فاليري جيسكار ديستان (Q2124):
{{#invoke:Wikidata2|formatStatements|offset=5|entityId=Q358726|noref=1|claim-module=Wikidata2 sub modules/P39|sortbytime=inverted|limit=25|separator=|conjunction=|property=P39|claim-function=office3|rank=all}} ←
| |||||||||||||||||||||
مختبر
- ^ "Representative Don Sundquist (1936 - 2023). In Congress 1983 - 1995" (بالإنجليزية). United States Congress. Retrieved 2023-09-04.
- ^ Biographical Directory of the United States Congress (بالإنجليزية), United States Government Publishing Office, 1903, QID:Q1150348
local p = {}
local table_maker = require("Module:ص.م")
local sandbox = "ملعب"
local sandbox_added = ""
if nil ~= string.find(mw.getCurrentFrame():getTitle(), sandbox, 1, true) then
sandbox_added = "/" .. sandbox
end
local config = mw.loadData('Module:Wikidata2/config' .. sandbox_added)
local i18n = config.i18n
local p39_labels = {
from = "'''منذ''' ",
to = "'''حتى''' ",
electedin = "الانتخابات",
president = "الرئيس",
premier = "رئيس الوزراء",
P5054 = "مجلس الوزراء",
constituency = "الدائرة الإنتخابية",
P2937 = "فترة برلمانية",
jurisdiction = "الاختصاص",
employer = "في مكتب",
}
local function valid_value(x)
if x and x ~= nil and x ~= "" and x ~= i18n.no then return x end
return nil
end
local function valid_values(xs)
for _, x in pairs(xs) do
if valid_value(x) then
return x
end
end
return nil
end
local function notvalid_value(x)
if not x or x == nil or x == "" then return true end
return false
end
local function render_infobox(args)
local colspan = valid_value(args.colspan) or 2
local output = "</tr>"
local series_line = ""
if valid_value(args.series) then
-- remove form it
args.series = args.series:gsub(" ", "")
series_line = "(" .. args.series .. ")"
end
-- ص.م/عنوان فرعي
local head_title = (args.office_img or "") .. (args.office or "") .. " " .. series_line
local head_row = table_maker.SubTitle({
title = head_title,
showTitle = head_title,
bg_color = "E1E1E1",
txt_color = "000000",
colspan = colspan,
})
output = output .. head_row
-- ص.م/سطر
local term_content = ""
if valid_value(args.termstart) then
if valid_value(args.termend) then
term_content = args.termstart .. " – " .. args.termend
else
term_content = p39_labels.from .. args.termstart
end
else
if valid_value(args.termend) then
term_content = p39_labels.to .. args.termend
end
end
local date_line = table_maker.Line({
showLine = term_content,
content = term_content,
textAlign = "center",
bg_color = "f9f9f9",
txt_color = "000000",
colspan = colspan,
})
output = output .. date_line
-- أسطر مختلطة شرطية
local mixed_rows = {
{ label = p39_labels.electedin, param = args.electedin },
{ label = p39_labels.president, param = args.president },
{ label = p39_labels.premier, param = args.premier },
{ label = p39_labels.P5054, param = args.P5054 },
{ label = p39_labels.constituency, param = args.constituency },
{ label = p39_labels.P2937, param = args.P2937 },
{ label = p39_labels.jurisdiction, param = args.jurisdiction },
{ label = p39_labels.employer, param = valid_values({ args.of, args.employer }) }
}
for _, row in ipairs(mixed_rows) do
if valid_value(row.param) then
local mixed_row = table_maker.MixedLine({
title = row.label,
showLine = row.param,
content = row.param,
colspan = colspan,
bg_color = "f9f9f9"
})
output = output .. mixed_row
end
end
local before_after_row = table_maker.PrevNextLine1({
dprev = args.predecessor,
dnext = args.successor,
bg_color = "f9f9f9",
colspan = colspan,
right_arrow = "Fleche-defaut-droite-gris-32.png",
left_arrow = "Fleche-defaut-gauche-gris-32.png",
arrowSize = 8
})
output = output .. before_after_row
output = output .. "<tr>"
return output
end
local function result_table(s, office_img, personqid, entity_id, options, qualifiers)
local args = {
office = s,
office_img = office_img,
entityId = personqid,
q = entity_id,
colspan = valid_value(options.co) or valid_value(options.colspan),
termstart = qualifiers.start,
termend = qualifiers.finish,
constituency = qualifiers.constituency,
predecessor = qualifiers.before,
successor = qualifiers.after,
president = qualifiers.president,
premier = qualifiers.premier,
series = qualifiers.series,
electedin = qualifiers.electedin,
jurisdiction = qualifiers.P1001,
employer = qualifiers.P108,
of = qualifiers.P2389,
P2937 = qualifiers.P2937,
P5054 = qualifiers.p5054
}
local result1 = render_infobox(args)
return result1
end
local function get_office_img(qid)
local ca1 = formatStatements({
property = "P154",
otherproperty = "P41",
entityId = qid,
noref = 1,
rank = "all",
size = 25,
image = "image",
firstvalue = 1,
separator = "",
conjunction = ""
})
return ca1
end
local function get_female_label(office_id, personqid)
local gender = formatStatements({
property = 'P21',
entityId = personqid,
noref = 1,
rank = 'all',
firstvalue = 't',
formatting = 'raw'
})
if gender and (gender == 'Q6581072' or gender == 'Q1052281') then
local fem_label = formatStatements({
property = 'P2521',
entityId = office_id,
noref = 1,
langpref = i18n.local_lang,
formatting = 'text',
rank = "all"
})
return fem_label
end
return ""
end
local function get_qua(property, enbarten, modifytime, statement, options)
local ca = formatStatements(
{ property = property, illwd2 = 1, firstvalue = enbarten, modifytime = modifytime, noref = options.noref },
statement.qualifiers) or ""
if ca ~= "" then
return ca .. addTrackingCategory({ property = property, noicon = 1 })
end
return ca
end
local function process_qualifiers(statement, options)
return {
img = formatStatements({
property = "P94",
otherproperty = "P41",
noref = 1,
rank = "all",
size = 25,
image = "image",
firstvalue = 1,
separator = "",
conjunction = ""
}, statement.qualifiers),
P108 = get_qua("P108", "", "", statement, options),
P108_raw = formatStatements({
property = "P108",
noref = 1,
rank = "all",
firstvalue = 1,
formatting = 'raw'
}, statement.qualifiers),
start = get_qua("P580", 1, "longdate", statement, options),
finish = get_qua("P582", 1, "longdate", statement, options),
before = get_qua("P1365", 1, "", statement, options),
after = get_qua("P1366", 1, "", statement, options),
constituency = get_qua("P768", "", "", statement, options),
series = get_qua("P1545", 1, "", statement, options),
electedin = get_qua("P2715", "", "", statement, options),
P1001 = get_qua("P1001", "", "", statement, options),
P2389 = get_qua("P2389", "", "", statement, options),
president = get_qua("P325", "", "", statement, options),
premier = get_qua("P6", "", "", statement, options),
p5054 = get_qua("P5054", "", "", statement, options),
P2937 = get_qua("P2937", "", "", statement, options)
}
end
local function office_is_okay(qualifiers, statement)
if notvalid_value(statement.qualifiers.P108) and notvalid_value(statement.qualifiers.P2389) then
return true
end
if statement.qualifiers.P108 and valid_value(qualifiers.P108) then
return true
end
if statement.qualifiers.P2389 and valid_value(qualifiers.P2389) then
return true
end
return false
end
function p.office3(statement, options)
if valid_value(options.reff) then
options.noref = 1
end
local s_tab = formatSnak(statement.mainsnak, options)
local s = s_tab.value
local sqid = s_tab.item
if notvalid_value(s) then
return ""
end
local qualifiers = {}
if statement.qualifiers then
qualifiers = process_qualifiers(statement, options)
end
if not valid_values({ qualifiers.start, qualifiers.finish, qualifiers.constituency, qualifiers.before, qualifiers.after, qualifiers.electedin, qualifiers.P1001, qualifiers.president, qualifiers.P5054 }) then
return ""
end
if not office_is_okay(qualifiers, statement) then
return ""
end
local entity_id = statement.mainsnak.datavalue.value.id
local personqid = options.entityId or options.qid
local female_label = get_female_label(sqid, personqid)
local office_label = formatEntityId(entity_id, options).value
if valid_value(female_label) then
office_label = formatEntityId(entity_id, { female_label = female_label }).value
end
-- mw.log("s: ", s, "office_label: ", office_label)
if valid_value(office_label) then
s = office_label
end
if statement.references and valid_value(options.reff) then
options.numberofreferences = options.numberofreferences and options.numberofreferences or 3
s = s .. formatReferences(statement, options)
end
local office_img
if valid_value(qualifiers.img) then
office_img = qualifiers.img
else
office_img = get_office_img(entity_id)
end
local result = result_table(s, office_img, personqid, entity_id, options, qualifiers)
return result
end
return p