Munurin millum rættingarnar hjá "Module:Cycling race"

Content deleted Content added
Psemdel (kjak | íkøst)
update
Psemdel (kjak | íkøst)
copy from wikidata
Merki: Reverted
Linja 13:
local wikilang = contentLanguage:getCode()
local wikibase = mw.wikibase
 
local localframe -- Value may be given by functions which use frame functions like getReference
local arwiki_totemplate = mw.getCurrentFrame():getParent().args["totemplate"] or mw.getCurrentFrame().args["totemplate"]
arwiki_totemplate = (wiki == "ar" and arwiki_totemplate and arwiki_totemplate ~= "") or false
-- == Structure of the code ==
-- I) Constant
Line 50 ⟶ 48:
 
--== I) Classes declared as global ==
 
--dictionnaries
local teamCats=data.teamCats
local class_sort=data.class_sort
local class_dic=data.class_dic
local UCI_Circuits=data.UCI_Circuits
local stages=data.stages
local bg_color_table = data.bg_color_table
local NationalRoadCyclingChampionships=data.NationalRoadCyclingChampionships
local NationalITTCyclingChampionships=data.NationalITTCyclingChampionships
local womenNcRoadtable=data.womenNcRoadtable
local womenNcITTtable=data.womenNcITTtable
local menNcRoadtable=data.menNcRoadtable
local menNcITTtable=data.menNcITTtable
local amateurcat=data.amateurcat
local nationalcat=data.nationalcat
 
local available, translations = pcall(require, "Module:Cycling race/lang")
local available_list = available and type(translations.list) == "function"
local available_lang_priority = available == true and type(translations.lang_priority) == "table"
 
local textalign = "left"
local floattable = "left"
Line 84 ⟶ 61:
local standardtablecss=data.standardtablecss_part1..textalign..data.standardtablecss_part2
 
local lang_priority --for lang priority and fallback
if l10n["lang_priority"] then
lang_priority=l10n["lang_priority"]
else --default
lang_priority={}
table.insert(lang_priority,wikilang)
for _, lang in ipairs({'mul','en', 'fr', 'de','es','nl','it','da'}) do
if lang~=wikilang then
table.insert(lang_priority,lang)
end
end
end
 
--"country" means here, that there will be a separated column containing the country name
--otherwise a flag is typically added in another column, for instance before the rider name
local no_country_calendar={'ru','ar'}
local no_country_victories={'ru','ar','da'}
local no_country_classification={'es','da','no','ru','ar'}
 
--to avoid wrong display, or country names becoming very long,
--available_list==false --> country=false in the old code,
--should be implemented here
if not l10n["country_name_list"] then
table.insert(no_country_calendar, wiki)
table.insert(no_country_victories, wiki)
table.insert(no_country_classification, wiki)
end
 
--Note about WDlink_on
--On some wikipedia small wikidata flag are displayed after all data coming from wikidata
--to enable that set WDlink_on on true
 
local no_roll_startlist={'fr','da','no','ar','ru','de'}
local display_language_in_riderinfobox={'ru'}
Line 93 ⟶ 99:
local display_noweight_in_riderinfobox={'fr','pl'}
local display_noage_in_riderinfobox={'pl'}
local display_nonickname_in_riderinfobox={'pl'}
local display_cm_in_riderinfobox={'pl'}
 
local silver_theme_countries={'da', 'pl'}
 
local backgroundColor="#FFDF80"
Line 111 ⟶ 119:
 
--== II) Translation ==
local function translate(func_name_short, index, womenrace_boolw_race, title)
if index == nil then index=1 end -- for prologue
if index==1000 then --code for some custom function
return title
Line 118 ⟶ 125:
if func_name_short then
local func_name
if womenrace_boolw_race then
func_name=func_name_short.."_women_translate"
if l10n[func_name] and l10n[func_name][index] then
Line 130 ⟶ 137:
return "translation for "..func_name.." index ".. tostring(index).." not found"
else
return "error: no ('func_name found"')
end
end
end
 
local function plural(num)
local plural=false --latin language
local gen_singular=false --for slavic language
Line 161 ⟶ 168:
end
 
local function black_list( Label)
local black_list=l10n.black_list
--[[ List of Wikipedia articles with the same lemma as the non existing rider article. Those lemmas are printed
Line 169 ⟶ 176:
end
 
local function country_name_from_list(countryID)
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
if l10n["country_name_list"] and l10n["country_name_list"][countryID] then
local l10nDef = {["fr"]="étape", ["en"]="stage", ["ar"]="المرحلة", ["br"]="Tennad", ["ca"]="etapa", ["cs"]="etapa", ["de"]="Etappe", ["da"]="etape", ["eo"]="Etapo",
return l10n["country_name_list"][countryID]
["es"]="etapa", ["eu"]="Etapa", ["fi"]="Etappi", ["fo"]="teinur", ["hu"]="szakasz", ["it"]="Tappa", ["ja"]="ステージ", ["la"]="Statio", ["lb"]="Etapp",
end
["lv"]="Posms", ["mk"]="Етапа", ["nl"]="Etappe", ["no"]="etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa",
return nil
["sv"]="Etapp", ["ast"]="etapa" }
end
 
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local word1, word2
local word1
word2=l10nDef[wiki]
local word2=translate("func_prologue",2) --stage
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word = word2
 
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
Line 224 ⟶ 232:
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10n=l10n["type_of_stage_translate"]
local l10nDef = {
["ar"] = {plain = "مرحلة مستوية", hilly="مرحلة التلال", inter='مرحلة متوسطة', mount='مرحلة جبلية', time_prologue='مرحلة سباق زمني', time_team='مرحلة سباق الزمن للفرق', time_indiv='مرحلة سباق الزمن فردي', uphill='مرحلة تسلق الجبل زمني', rest='يوم راحة'},
["ast"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de mediu monte', mount='etapa de monte', time_prologue='prólogu', time_team='contrarreló per equipos', time_indiv='contrarreló individual', uphill='cronoescalada', rest='xornada de descansu'},
["fr"] = {plain = "étape de plaine", hilly="étape vallonnée", inter='étape de moyenne montagne', mount='étape de montagne', time_prologue='prologue', time_team='contre-la-montre par équipes', time_indiv='contre-la-montre individuel', uphill='contre-la-montre en côte', rest='étape de repos'},
["en"] = {plain = "plain stage", hilly="hilly stage", inter='intermediate stage', mount='mountain stage', time_prologue='time trial stage', time_team='team time trial stage', time_indiv='individual time trial stage', uphill='uphill time trial stage', rest='rest day'},
["br"] = {plain = "tennad plaen", hilly="tennad digompez", inter='tennad damveneziek', mount='tennad meneziek', time_prologue='prolog', time_team='ABEU a-skipailhoù', time_indiv='ABEU', uphill='', rest='devezh diskuizh'},
["ca"] = {plain = "etapa plana", hilly="etapa accidentada", inter='etapa de mitja muntanya', mount='etapa de muntanya', time_prologue='pròleg', time_team='contrarellotge per equips', time_indiv='contrarellotge individual', uphill='', rest='etapa de descans'},
["cs"] = {plain = "rovinatá etapa", hilly="", inter='kopcovitá etapa', mount='horská etapa', time_prologue='prolog', time_team='týmová časovka', time_indiv='individuální časovka', uphill='', rest=''},
["da"] = {plain = "flad etape", hilly="kuperet etape", inter='middel bjergetape', mount='bjergetape', time_prologue='prolog', time_team='holdtidskørsel', time_indiv='enkeltstart', uphill='bjergenkeltstart', rest='hviledag'},
["de"] = {plain = "Flachetappe", hilly="Hügelige Etappe", inter='Mittelschwere Etappe', mount='Hochgebirgsetappe', time_prologue='Prolog', time_team='Teamzeitfahren', time_indiv='Einzelzeitfahren', uphill='Bergzeitfahren', rest='Ruhetag'},
["eo"] = {plain = "ebena etapo", hilly="malebena etapo", inter='mezgranda montaro etapo', mount='montara etapo', time_prologue='prologo', time_team='teama kontraux-la-kronometro', time_indiv='individua kontraux-la-kronometro', uphill='malebena kontraux-la-kronometro', rest='ripoza etapo'},
["es"] = {plain = "etapa llana", hilly="etapa escarpada", inter='etapa de media montaña', mount='etapa de montaña', time_prologue='prólogo', time_team='contrarreloj por equipos', time_indiv='contrarreloj individual', uphill='cronoescalada', rest='jornada de descanso'},
["eu"] = {plain = "etapa laua", hilly="etapa gorabeheratsua", inter='bitarteko etapa', mount='mendiko etapa', time_prologue='aitzinetapa', time_team='taldekako erlojupekoa', time_indiv='banakako erlojupekoa', uphill='erlojupeko igoera', rest='atseden eguna'},
["fi"] = {plain = "Tasamaaetappi", hilly="Mäkietappi", inter='Keskivaikea vuorietappi', mount='Vuorietappi', time_prologue='', time_team='Joukkueaika-ajo', time_indiv='Henkilökohtainen aika-ajo', uphill='mäkiaika-ajo', rest='välipäivä'},
["fo"] = {plain = "Slætt", hilly="Slætt við brúgvasteinum", inter='Óslætt', mount='Fjallateinur', time_prologue='Forteinur', time_team='Liðsúkkling', time_indiv='Einkultstartur', uphill='', rest='Hvílidagur'},
["hu"] = {plain = "sík szakasz", hilly="dombos szakasz", inter='közepes hegyi szakasz', mount='hegyi szakasz', time_prologue='prolog', time_team='csapat időfutam', time_indiv='egyéni időfutam', uphill='hegyi időfutam', rest=''},
["ja"] = {plain = "平坦ステージ", hilly="丘陵ステージ", inter='中間ステージ', mount='山岳ステージ', time_prologue='タイムトライアルステージ', time_team='チームタイムトライアルステージ', time_indiv='個人タイムトライアルステージ', uphill='アップヒルタイムトライアルステージ', rest='休養日'},
["lb"] = {plain = "Flaach Etapp", hilly="Hiwweleg Etapp", inter='Mëttelschwéier Etapp', mount='Biergetapp', time_prologue='Prolog', time_team='Contre-la-montre (Ekipp)', time_indiv='Contre-la-montre (Eenzel)', uphill='Biergcourse', rest='Roudag'},
["lv"] = {plain = "līdzenuma posms", hilly="paugurains posms", inter='vidēju kalnu posms', mount='kalnu posms', time_prologue='individuālais brauciens', time_team='komandu brauciens', time_indiv='individuālais brauciens', uphill='individuālais brauciens kalnā', rest='atpūtas diena'},
["mk"] = {plain = "рамна етапа", hilly="ридеста етапа", inter='среднопланинска етапа', mount='планинска етапа', time_prologue='пролог', time_team='екипен хронометар', time_indiv='индивидуален хронометар', uphill='', rest='ден за одмор'},
["nl"] = {plain = "vlakke rit", hilly="heuvelrit", inter='heuvelrit', mount='bergrit', time_prologue='proloog', time_team='ploegentijdrit', time_indiv='individuele tijdrit', uphill='klimtijdrit', rest='rustdag'},
["no"] = {plain = "flat etappe", hilly="kupert etappe", inter='middels klatreetappe', mount='klatreetappe', time_prologue='prolog', time_team='lagtempo', time_indiv='temporitt', uphill='klatretempoetappe', rest='hviledag'},
["pl"] = {plain = "płaski", hilly="pagórkowaty", inter='górzysty', mount='górski', time_prologue='prolog', time_team='jazda drużynowa na czas', time_indiv='jazda indywidualna na czas', uphill='jazda indywidualna na czas pod górę', rest='dzień przerwy'},
["pt"] = {plain = "etapa plana", hilly="etapa escarpada", inter='média montanha', mount='alta montanha', time_prologue='prólogo', time_team='contrarrelógio por equipes', time_indiv='contrarrelógio individual', uphill='cronoescalada', rest='jornada de descanso'},
["ro"] = {plain = "etapă de plat", hilly="etapă valonată", inter='etapă intermediară', mount='etapă de munte', time_prologue='prolog', time_team='contratimp pe echipe', time_indiv='contratimp individual', uphill='', rest='zi de repaus'},
["ru"] = {plain = "равнинный", hilly="холмистый", inter='среднегорный', mount='горный', time_prologue='пролог', time_team='командная разделка', time_indiv='индивидуальная разделка', uphill='горная разделка', rest='день отдыха'},
["sv"] = {plain = "Flack etapp", hilly="", inter='Kuperat', mount='Bergsetapp', time_prologue='Prolog', time_team='Lagtempoetapp', time_indiv='Tempoetapp', uphill='', rest='Vilodag'},
}
local l10n = l10nDef[wiki]
if not l10n then l10n = l10nDef["en"] end -- default
 
local border
Line 270 ⟶ 249:
if x=='time trial stage' then
if noborder then border="" else border="|right" end
local stages2 = {
if typ=="Q2348250" then return "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_team.."]]" end
if typ== ["Q2266066Q2348250"] then return= "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_indivtime_team.."]]" end,
if typ== ["Q485321Q2266066"] then return= "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_prologuetime_indiv.."]]" end,
["Q485321"] = "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_prologue.."]]"
}
if stages2[typ] then
return stages2[typ]
end
end
end
 
local function typeofstagelogo(stageID, noborder)
local sType
p = mw.wikibase.getBestStatements(stageID, 'P31') -- P31 is 'instance of'
local stages = {
for _,t in pairs(p) do
["Q20646667"] = {"plain stage", nil},
["Q20646670"] = {"hilly stage", nil},
["Q20680270"] = {"intermediate stage", nil},
["Q20646668"] = {"mountain stage", nil},
["Q485321"] = {"time trial stage", "Q485321"}, -- prologue
["Q2266066"] = {"time trial stage", "Q2266066"}, -- individual time trial
["Q2348250"] = {"time trial stage", "Q2348250"}, -- team time trial
["Q20679712"] = {"uphill time trial stage", nil}
}
for _, t in pairs(p) do
if t.mainsnak.snaktype == 'value' then
local iOf = t.mainsnak.datavalue.value.id
if stages[iOf] then
if iOf == "Q20646667" then sType = typeofstage('plain stage', nil, noborder) break end
if iOf == "Q20646670" then sType = typeofstage('hillystages[iOf][1], stage'stages[iOf][2], nil,noborder) break end
break
if iOf == "Q20680270" then sType = typeofstage('intermediate stage', nil,noborder) break end
end
if iOf == "Q20646668" then sType = typeofstage('mountain stage',nil, noborder) break end
if iOf == "Q485321" then sType = typeofstage('time trial stage', "Q485321", noborder) break end -- prologue
if iOf == "Q2266066" then sType = typeofstage('time trial stage', "Q2266066", noborder) break end -- individual time trial
if iOf == "Q2348250" then sType = typeofstage('time trial stage', "Q2348250", noborder) break end -- team time trial
if iOf == "Q20679712" then sType = typeofstage('uphill time trial stage', nil, noborder) break end
end
end
Line 319 ⟶ 309:
local function getLabelFallback(itemID, fallback)
local label
if fallback==nil then --default
fallback=lang_priority
end
for _, lang in ipairs(fallback) do
label = mw.wikibase.getLabelByLang(itemID, lang)
Line 335 ⟶ 328:
end
return nil
end
 
local arwiki_totemplate = mw.getCurrentFrame():getParent().args["totemplate"] or mw.getCurrentFrame().args["totemplate"]
arwiki_totemplate = (wiki == "ar" and arwiki_totemplate and arwiki_totemplate ~= "") or false
 
local function get_lf(frame)
local lf = frame
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
lf = frame:getParent()
end
return lf
end
 
local function get_and_checkID(frame)
local lf = get_lf(frame)
local entityID = mw.text.trim(lf.args[1])
entityID= string.gsub(entityID, "%c", "") --probably redundant
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
return entityID, lf
end
 
Line 418 ⟶ 431:
--[[ Get a Wikidata statement for an entity and property valid at the given timevalue ]]
local function checktime(s,q, time)
local start, startPrecision, END, endPrecision, timePrecision
if not q or not time then
return s
end
local _, _, _, m, _ = string.find(time, "(%d+)%p(%d+)%p(%d+)")
if m=="00" then
timePrecision=9
end
if q.P580 and q.P580[1] and q.P580[1].snaktype == 'value' then -- P580 is start time
start = q.P580[1].datavalue.value.time
startPrecision = q.P580[1].datavalue.value.precision
if startPrecision == 9 or timePrecision==9 then -- precision is years
start = string.sub(start, 1, 5) -- Cut of everything after year
elseif startPrecision == 10 then -- precision is months
Line 439 ⟶ 456:
return s
end
if endPrecision == 9 or timePrecision==9 then -- precision 9 is 'years'
END = string.sub(END, 1, 6) .. '13' -- Set month to 13
elseif endPrecision == 10 then -- precision 10 is 'months'
Line 473 ⟶ 490:
local starttime, endtime
local month_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia",
"września", "października", "listopada", "grudnia"}
--local format = formats[wiki] or formats['']
if mode==nil then mode='long' end
Line 482 ⟶ 497:
if m=='00' then --manage the 30 November issue
if mode=='long' or mode=="verylong" then
starttime =lang:formatDate( "Y", sTime )
else
Line 489 ⟶ 504:
else
if y ~= y2 then
if mode=='long' or mode=="verylong" then
starttime = lang:formatDate( "j F Y", sTime )
else
Line 495 ⟶ 510:
end
elseif m ~= m2 then
if mode=='long' or mode=="verylong" then
starttime = lang:formatDate( "j F", sTime )
else
Line 557 ⟶ 572:
end
elseif wiki == "pl" then
if y ~= y2 then starttime = lang:formatDate( "j ", sTime ) .. month_pl[tonumber(lang:formatDate( "n", sTime ))] .. lang:formatDate( "xg Y", sTime )
elseif m ~= m2 then starttime = lang:formatDate( "j xg", sTime ) .. month_pl[tonumber(lang:formatDate( "n", sTime ))]
else starttime = lang:formatDate( "j", sTime )
end
Line 565 ⟶ 580:
if m2=='00' then --manage the 30 November issue
if mode=='long' or mode=="verylong" then
endtime= lang:formatDate( "Y", eTime )
else
Line 571 ⟶ 586:
end
else
if (mode=='long' and y ~= y2) or mode=="verylong" then
endtime = lang:formatDate("j F Y", eTime)
elseif y ~= y2 then --small
Line 581 ⟶ 596:
end
if wiki == "ar" then
if mode=='long' or mode=="verylong" or y ~= y2 then endtime = lang:formatDate( "d F Y", eTime )
elseif m ~= m2 then endtime = lang:formatDate( "d F Y", eTime )
else endtime = lang:formatDate( "d F Y", eTime )
Line 587 ⟶ 602:
elseif wiki == "br" then endtime = lang:formatDate( "j", eTime ) .." a viz ".. lang:formatDate( "F Y", eTime )
elseif wiki == "ca" or wiki == "es" or wiki == "ast" then
if mode=='long' or mode=="verylong" or y ~= y2 then
endtime = lang:formatDate( "j", eTime ) .." de "..
lang:formatDate( "F", eTime ) .." de ".. lang:formatDate( "Y", eTime )
Line 596 ⟶ 611:
elseif wiki == "cs" then endtime = lang:formatDate( "j. xg Y", eTime )
elseif wiki == "de" or wiki == "da" or wiki == "fi" or wiki == "fo" or wiki == "lb" or wiki == "no" then
if mode=='long' or mode=="verylong" or y ~= y2 then
endtime = lang:formatDate( "j. F Y", eTime )
else
Line 620 ⟶ 635:
else endtime = lang:formatDate( "j. F", eTime )
end
elseif wiki == "pl" then endtime = lang:formatDate( "j xg Y", eTime )
endtime = lang:formatDate( "j ", eTime ) .. month_pl[tonumber(lang:formatDate( "n", eTime ))] ..
lang:formatDate( " Y", eTime )
end
end
Line 637 ⟶ 650:
local lang = contentLanguage
local month_pl = {"stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia",
"września", "października", "listopada", "grudnia"}
 
--handle problems with lack of precision
local daycorrectdispDate =true date
local monthcorrect=true
 
if string.sub(date,107,118)=='00' then -- daycorrect=falselack of endmonth
dispDate= string.sub(date,1,6).."01-01"..string.sub(date,12)
if string.sub(date,7,8)=='00' then monthcorrect=false end
if mode == 'long' or mode == 'onlyyear' or mode == 'monthly' then
 
if mode == 'Yonlyyear' then
return string.sub(date,2,5) --only year, note: contentLanguage:formatDate("Y", date) returns the wrong year
end
 
if daycorrect and monthcorrect then
if wiki=="pl" then-- overcome declination issue
return lang:formatDate( "j ", date ) .. month_pl[tonumber(lang:formatDate( "n", date ))] ..
lang:formatDate( " Y", date )
else
mode = 'nodate'
return contentLanguage:formatDate(format[mode], date)
end
elseif string.sub(date,10,11)=='00' then -- lack of day
else
dispDate= string.sub(date,1,9).."01"..string.sub(date,12)
if daycorrect or (monthcorrect==false and daycorrect==false) then --no month
if mode == 'long' then
mode = 'monthly'
return string.sub(date,2,5) --only year, note: contentLanguage:formatDate("Y", date) returns the wrong year
elseif mode == 'small' then
else --otherwise we don't know
returnmode = '-onlymonth'
elseif mode == 'onlyday' then
end
mode = 'nodate'
else --month correct, but day incorrect
if mode=='onlyday' then
return '-'
else
local newdate=string.sub(date,1,9).."01"..string.sub(date,12)
if wiki=="pl" then
return month_pl[tonumber(lang:formatDate( "n", date ))] ..lang:formatDate( " Y", date )
else
return string.sub(contentLanguage:formatDate(format[mode], newdate), 3) --cut the day
end
end
end
end
if format[mode] == nil then mode = 'nodate' end
return contentLanguage:formatDate(format[mode], dispDate)
end
 
Line 690 ⟶ 685:
end
 
local function isdisqualified(p,q) --disqualification can use deprecated or P1534
local cancelled=""
local disqualified=false
Line 715 ⟶ 710:
local cyrillic = {mk = true, ru = true}
local strictLangBool= strictLang[wiki] or strict
local correcttime, best, name, nametemp
local wantedLanguages = {}
for i, lang in ipairs(lang_priority) do
if available_lang_priority then
wantedLanguages[lang] = i
for i, lang in ipairs(translations.lang_priority) do --from Module:Cycling_race/lang
wantedLanguages[lang] = i
end
end
--case one, one official name / period overloaded with other languages as qualifier
--for instance https://www.wikidata.org/wiki/Q195833
best = 999
for _, p1448 in statements(teamID, 'P1448') do
correcttime=true
Line 731 ⟶ 725:
end
if correcttime then
if available_lang_priority and p1448.qualifiers and p1448.qualifiers.P1448 then
local q = p1448.qualifiers.P1448
best = 999
Line 748 ⟶ 742:
lang=p1448.mainsnak.datavalue.value.language
if strictLangBool then
best = 999
if available_lang_priority and wantedLanguages[lang] and wantedLanguages[lang] < best then
best = wantedLanguages[lang]
name = p1448.mainsnak.datavalue.value.text
elseif strictLangBool then
if wiki==lang then
name = p1448.mainsnak.datavalue.value.text
end
elseif wantedLanguages[lang] and wantedLanguages[lang] < best then
best = wantedLanguages[lang]
name = p1448.mainsnak.datavalue.value.text
else
if cyrillic[lang]==nil then --don't display cyrillic for latin wiki
Line 765 ⟶ 758:
if name then
return name, true
elseif not strictLangBool and nametemp then
return nametemp, false
end
Line 787 ⟶ 780:
end
 
local function checksitelink(sitelink, label)
if sitelink==label then
return "[[" .. sitelink .."]]"
else
return "[[" .. sitelink .. "|" .. label.. "]]"
end
end
-- RiderID --> RiderLink
local function getRiderLink(riderID, startOfSeason) --startOfSeason optional
Linja 848:
 
if sitelink and officialname then --if there is an official name, then use it
return "[[" .. checksitelink(sitelink, .. "|" ..officialname.."]]"), correctlanguage
else
if officialname then return officialname end
Linja 859:
local c = p27[1].mainsnak.datavalue.value.id
if c=="Q159" or c=="Q184" or c=="Q212" or c=="Q232" then -- Q159, Q184, Q212, Q232 is Russia, Belarus, Ukraine, Kazakhstan
return "[[" .. checksitelink(sitelink .. "|" .., label .. "]]"), correctlanguage
end
end
Linja 865:
end
if wiki == 'ru' then
local label = revertfirstlast(mw.text.trim(string.gsub(sitelink, "%b()", ""), " "))
return "[[" .. checksitelink(sitelink .. "|" .., label.. "]]"), correctlanguage
else
return "[[" .. checksitelink(sitelink .. "|" .., mw.text.trim(string.gsub(sitelink, "%b()", "")), .." "]]")), correctlanguage
end
end
Linja 902:
link = make_IllWD2_link(riderID)
else
link = getLabelFallback(riderID, {'en', 'de', 'fr','es'})
if link then
link = string.gsub(link, "%b()", "")
Linja 911:
return link, correctlanguage
end
end
 
-- Get the countryID, return a single one, not a list
local function getCountryID(entityID, timeOfRace)
local countryID
if entityID then
local stm = getStatementForTime(entityID, 'P1532', timeOfRace) -- P1532 is country for sport
if stm == nil then
stm = getStatementForTime(entityID, 'P17', timeOfRace) -- P17 is country
end
if stm then countryID = stm.mainsnak.datavalue.value.id end
end
return countryID
end
 
--[[ Get the name of a country ]]
local function getCountryName(countryID)
local name = ''country_name_from_list(countryID)
if available_listname == nil then
name = translations.list(countryID)
end
if name == '' then
local label, lang = wikibase.getLabelWithLang(countryID)
--[[ Uses standard language fallback. Should not return nil, nil, as all countries have English labels. ]]
Line 928 ⟶ 939:
end
end
return name or ''
end
 
Line 946 ⟶ 957:
--[[ Get sitelink, categoryID and maybe country for a team.
Returns sitelink, team category ID, countryID (only countryID if country arg is true ]]
local function getTeamLinkCat(teamID, timeOfRace, country, seasonforceParentlink)
local name, sitelink, parentIDcatID, catIDcountryID, p31
local parentID = getParentID(teamID)
local national_team_boolean=false
local season=false
-- Find team category
--Hypothesis, it is a season, look in P2094
for _, p2094 in statements(teamID, 'P2094') do
if checktime(p2094, p2094.qualifiers, timeOfRace) then
local natureID =if data.teamCats[p2094.mainsnak.datavalue.value.id] then
catID = p2094.mainsnak.datavalue.value.id
if teamCats[natureID] then
catID season= natureIDtrue
break
end
end
end
--check if season
if season==false then --otherwise already clear
-- Fallback with P31 (deprecated)
for _, p31p in statements(teamID, 'P31') do
local natureID = p.mainsnak.datavalue.value.id
if checktime(p31, p31.qualifiers, timeOfRace) then
localif natureID =="Q53534649" p31.mainsnak.datavalue.value.idthen
season=true
if teamCats[natureID] then
catID = natureID
break
end
Line 973 ⟶ 983:
end
 
--look by the parent, then P31 is used for the category
if (not catID and parentID and season) then
p31 = getStatementForTime(parentID, 'P31', timeOfRace)
parentID = getParentID(teamID)
elseif not season then --it is the team look in the team directly
if parentID then
local p31 = getStatementForTime(parentIDteamID, 'P31', timeOfRace)
end
if p31 then catID = p31.mainsnak.datavalue.value.id end
if p31 and data.teamCats[p31.mainsnak.datavalue.value.id] then
end
catID = p31.mainsnak.datavalue.value.id
catID = catID or 'Q53534649'
end
-- Find country if needed
if country or data.natTeamCats[catID] then
local countryID
countryID = getCountryID(teamID, timeOfRace)
if country or catID == 'Q23726798' or catID == 'Q20738667' or catID == 'Q54555994' then
local stm = getStatementForTime(teamID, 'P1532', timeOfRace) -- P1532 is country for sport
if stm == nil then
stm = getStatementForTime(teamID, 'P17', timeOfRace) -- P17 is country
end
if stm then countryID = stm.mainsnak.datavalue.value.id end
end
if countryID and (data.natTeamCats[catID] == 'Q23726798' or catID == 'Q20738667'then
or catID == 'Q54660600' or catID == 'Q54555994' or catID == 'Q99658502') then
-- It is a national cycling team
national_team_boolean=true
if countryID=='Q145' then
name = getCountryName('Q23666')
Line 1.000 ⟶ 1.002:
name = getCountryName(countryID)
end
local t={Q20738667=34, Q54555994=35, Q99658502=36}
if catID == 'Q20738667' then -- national cycling team U23
if t[catID] then --add U23, U19, B, (note: why "B" and not B)
local s
name = name ..' '..translate("headoftableIII",t[catID])
if wiki == 'fr' then s = ' espoirs'
end
elseif wiki == 'mk' then s = ' под 23 години'
elseif wiki == 'ar' then s = ' تحت 23'
elseif wiki == 'es' then s = ' sub-23'
else s = ' U23'
end
name = name .. s
elseif catID == 'Q54555994' then -- national cycling team U19
local s
if wiki == 'fr' then s = ' juniors'
elseif wiki == 'mk' then s = ' под 19 години'
elseif wiki == 'ar' then s = ' تحت 19'
elseif wiki == 'es' then s = ' sub-19'
else s = ' U19'
end
name = name .. s
elseif catID == 'Q99658502' then -- national cycling team "B"
local s
if wiki == 'fr' then s = ' "B"'
elseif wiki == 'mk' then s = ' "B"'
elseif wiki == 'ar' then s = ' "ب"'
elseif wiki == 'es' then s = ' "B"'
else s = ' "B"'
end
name = name .. s
end
sitelink = getRawTeamLink(teamID)
else
-- It is not a national cycling team
local isLocal
if season and seasonnot == trueforceParentlink then
sitelink = wikibase.getSitelink(teamID)
name, isLocal = getOfficialName(teamID, timeOfRace,true) --problem here is that the label will be used if no official name, official name of the parent would actually be better...
if not sitelink and parentID then
sitelink = wikibase.getSitelink(parentID)
parentID = getParentID(teamID)
if parentID then sitelink = wikibase.getSitelink(parentID) end
end
else
parentID = getParentID(teamID)
if parentID then -- try parent team first
sitelink = wikibase.getSitelink(parentID)
Line 1.050 ⟶ 1.026:
end
if not name or (not isLocal and available_lang_priorityl10n["lang_priority"]) then
local partName, partIsLocal = getOfficialName(teamID, timeOfRace)
if partName and (not name or partIsLocal) then
Line 1.077 ⟶ 1.053:
end
end
return sitelink, catID, countryID, national_team_boolean
end
 
Line 1.098 ⟶ 1.074:
end
 
local function getReference(lf,statement, outputLocal)
local function formatRefDate(date, precision)
if precision == 9 then -- Precision is year
Line 1.183 ⟶ 1.159:
refargs.name = refText
end
return localframelf:extensionTag('ref', refText, refargs)
end
end
end
 
--Some wikipedia, like WP:ar, don't use model like
--{{#invoke:Cycling race/infobox|Q123}}
--But have the module included in another module
--{{#invoke:wikidata|Cycling race/infobox|...
--in this case frame does not refer to the arguments of /infobox but to the wanted ones
--read https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#frame-object
 
local function get_arg(index, lf, number)
if lf.args[index] then
if number then
return tonumber(lf.args[index])
else
return string.gsub(lf.args[index], "%c", "")
end
end
return nil
end
 
Line 1.248 ⟶ 1.242:
local function getPlaceLink(placeID,timeOfRace)
local sitelink = wikibase.getSitelink(placeID)
local name = country_name_from_list(placeID)
if name==nil then
 
if available_list then
name = translations.list(placeID) --return '' if nothing
end
if name==nil or name=='' then
name=getOfficialName(placeID, timeOfRace,nil,true) --name should be in the right language
end
Line 1.274 ⟶ 1.264:
-- ClassID --> ClassLink
-- some WPs use a unique article for this case
local function classLinkFn(classclassID, circuitID)
local link, label
if wiki~="fr" then --not used
Line 1.282 ⟶ 1.272:
end
 
if classclassID=="Q18536594" then
if wiki=="fr" then
label="JO"
Line 1.289 ⟶ 1.279:
end
else
label = getLabelFallback(class, {wikilang, 'en', 'fr', 'de'}classID)
end
 
Line 1.302 ⟶ 1.292:
end
if wiki == "ar" then-- right now Q22348500 has no link in "ar"
link = make_IllWD2_link(classclassID , "", label)
end
return link
Line 1.308 ⟶ 1.298:
--[[ Get local content to a infoboxe from template args ]]
local function getLocalContent(contents, args)
 
for _, content in pairs(contents) do
local name = content.name
if not name then error('translation missing in Module:Cycling race/l10n of your wikipedia') end
local nameNoShy = string.gsub(name, '&#173;', '') -- filter soft hyphen out
local nameNoShyLow, name_pluralNoShyLow
Line 1.353 ⟶ 1.342:
end
 
local function checkDis(q) --discipline
dis="road"
local sport_id=nil
if q and q.P642 and q.P642[1] and q.P642[1].snaktype == 'value' then
if q and q.P642P641 and q.P641[1].datavalue.value.id == 'Q520611' orand q.P642P641[1].datavalue.value.idsnaktype == 'Q1031445value' then
sport_id=q.P641[1].datavalue.value.id
elseif q and q.P642 and q.P642[1] and q.P642[1].snaktype == 'value' then --fallback
sport_id=q.P642[1].datavalue.value.id
end
if sport_id then
if sport_id == 'Q520611' or sport_id =='Q1031445' then
onlyRoad=false
dis="mountainBike"
elseif q.P642[1].datavalue.value.idsport_id == 'Q335638' then
onlyRoad=false
dis="cycloCross"
elseif q.P642[1].datavalue.value.idsport_id == 'Q221635' then
onlyRoad=false
dis="track"
Line 1.376 ⟶ 1.372:
if q and q.P54 and q.P54[1].snaktype == 'value' then -- P54 is member of sports team
teamID = q.P54[1].datavalue.value.id
link, catID, countryID, national_team_boolean = getTeamLinkCat(teamID, timeOfRace)
else
for _, s in statements(riderID, 'P54') do
Line 1.385 ⟶ 1.381:
if dis=='road' then --by default
teamID = p54.mainsnak.datavalue.value.id
link, catID, countryID, national_team_boolean = getTeamLinkCat(teamID, timeOfRace)
end
end
Line 1.391 ⟶ 1.387:
end
end
return link, teamID, catID, countryID, national_team_boolean
end
 
Line 1.435 ⟶ 1.431:
local link=''
local Sitelink = wikibase.getSitelink(Qnumber) -- link to WParticle
local Label = getLabelFallback(Qnumber, {wikilang, 'en', 'fr', 'de'}) or ''
 
if Sitelink ~= nil then link = "[[" .. Sitelink .. "|" .. mw.text.trim(string.gsub(Sitelink, "%b()", "")..' ') .. "]]"
Line 1.451 ⟶ 1.447:
local function getCountryBool(no_country_list)
local country = true
if no_country_list then
for _, value in pairs(no_country_list) do -- get data if country should be printed in this wiki
if value == wiki then country = false end
end
end
return country
end
 
local function tableAhandle_error_message(s)
local error_message = ''
if wiki == "ar"s.error_message and s.itemerror_message =~= "" or not s.item0 then return "" end
if s.error_message == 1 then
error_message = func_error_message( 1)
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
Line 1.467 ⟶ 1.464:
error_message = ' [[File:Exclam icon.svg|12px|'.. error_message .. ']]'
end
return error_message
end
local table = mw.html.create('table')
 
local function tableA(s)
local error_message=handle_error_message(s)
 
local t = mw.html.create('table')
:addClass('sortable')
:attr('cellpadding', '0')
Line 1.475 ⟶ 1.477:
:css('padding', '3px')
local title =translate(s.header_function,s.header_1, s.womenrace_boolw_race, s.title)
if s.header_1 == 19 and wiki == "ar" then title = title .. " " .. s.year end
local wd_link = mw.html.create('span'):cssText('float:left; margin: 0 5px'):wikitext(wdLink(s.item..'#'..s.property))
if arwiki_totemplate then wd_link = wdLink(s.item..'#'..s.property) end
local caption = tablet:tag('tr'):tag('th'):attr('colspan', tostring(#s.header_2 + 1))
:cssText('padding:2px; text-align:center; line-height: 1.8em;')
:css('background-color',backgroundColor)
Line 1.487 ⟶ 1.489:
local country=getCountryBool(s.no_country)
 
local header = tablet:tag('tr')
for i,k in ipairs(s.header_2) do
if i == s.country_column then
if available_list and country == true then
header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function,k,s.womenrace_boolw_race))
end
end
Line 1.499 ⟶ 1.501:
local column = header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function,k,s.womenrace_boolw_race))
if s.data_sort_type[i] == 'unsortable' then
column:addClass('unsortable')
Line 1.506 ⟶ 1.508:
end
 
return tablet
end
 
local function tableB(s) --for startlist
local error_message = ''handle_error_message(s)
if wiki == "ar" and s.item == "" or not s.item then return "" end
if s.error_message == 1 then
error_message = func_error_message( 1)
error_message = mw.ustring.gsub(error_message, "<1>", s.property)
error_message = mw.ustring.gsub(error_message, "<2>", mw.wikibase.label( s.item ))
error_message = mw.ustring.gsub(error_message, "<3>", s.item)
error_message = ' [[File:Exclam icon.svg|12px|'.. error_message .. ']]'
end
local roll = true
for _, value in pairs(s.no_roll_startlist) do -- get data if country should be printed in this wiki
Line 1.541 ⟶ 1.536:
 
local tSpan=tDiv:wikitext(tostring(wdlink_span))
tDiv:wikitext(translate("startlist",1,s.w_race or false))
tDiv = rollTable1:tag('div'):addClass("NavContent"):cssText("margin:0; background:white; display:block; text-align:left;")
Line 1.563 ⟶ 1.558:
:attr('colspan','3'):attr('align','center')
tCell:node(wdlink_span)
tCell:wikitext(translate("startlist",1,s.womenrace_boolw_race or false))
local tRow=tCell:tag('tr')
 
Line 1.577 ⟶ 1.572:
{'Flag of Japan (1870–1999).svg', '+1870-02-27', '+1999-08-12'}},
Q20 = {'NOR', {'Flag of Norway.svg', '+1821-07-13'}},
Q27 = {'IRL', {'Flag of Ireland.svg', '+19371980-1207-29'}},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Ireland.svg', '+1937-12-29', '+1980-07-19'}},
Q28 = {'HUN', {'Flag of Hungary.svg', '+1957-05-23'}},
Q29 = {'ESP', {'Flag of Spain.svg', '+1981-12-06'},
Line 1.586 ⟶ 1.583:
{'Flag of Spain (1785–1873, 1875–1931).svg', '+1874', '+1931-04-13'}},
Q30 = {'USA', {'Flag of the United States.svg', '+1960-07-04'}},
Q31 = {'BEL', {'Flag of Belgium (civil).svg'}, '+1980-07-29'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Belgium (civil).svg', '+1800', '+1980-07-19'}},
Q32 = {'LUX', {'Flag of Luxembourg.svg'}},
Q33 = {'FIN', {'Flag of Finland.svg', '+1918-05-29'}},
Q34 = {'SWE', {'Flag of Sweden.svg'}},
Q35 = {'DEN', {'Flag of Denmark.svg'}, '+1980-07-29'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Denmark.svg', '+1800', '+1980-07-19'}},
Q36 = {'POL', {'Flag of Poland.svg'}},
Q37 = {'LTU', {'Flag of Lithuania.svg', '+2004-09-01'},
{'Flag of Lithuania (1988-2004).svg', '+1990-03-11', '+2004-09-01'}},
Q38 = {'ITA', {'Flag of Italy.svg', '+19461980-0607-1929'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Italy.svg', '+1946-06-19', '+1980-07-19'},
{'Flag of Italy (1861–1946).svg', '+1861', '+1946-06-19'}},
Q39 = {'SUI', {'Flag of Switzerland.svg', '+18891980-1208-1229'},
{'FlagOlympic of Switzerlandflag.svg', '+18791980-0107-0119', '+1980-07-29'}}, -- OG-1980
{'Flag of Switzerland.svg', '+1879-01-01', '+1980-07-19'}},
Q40 = {'AUT', {'Flag of Austria.svg', '+1945-05-01'},
{'Flag of Austria.svg', '+1919-10-21', '+1938-03-13'}},
Line 1.603 ⟶ 1.607:
Q43 = {'TUR', {'Flag of Turkey.svg'}},
Q45 = {'POR', {'Flag of Portugal.svg', '+1911-06-30'}},
Q55 = {'NED', {'Flag of the Netherlands.svg', '+18061980-07-29'}},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of the Netherlands.svg', '+1806', '+1980-07-19'}},
Q77 = {'URU', {'Flag of Uruguay.svg'}},
Q96 = {'MEX', {'Flag of Mexico.svg', '+1968-09-16'},
Line 1.610 ⟶ 1.616:
Q115 = {'ETH', {'Flag of Ethiopia.svg', '+1996-10-31'}},
Q117 = {'GHA', {'Flag of Ghana.svg', '+1966-02-28'}},
Q142 = {'FRA', {'Flag of France (1794–1815, 1830–1974, 2020–present).svg', '+17942020-0507-2014'}},
Q145 = {'GBR', {'Flag of the United KingdomFrance.svg'}, '+1980-07-29', '+2020–07-14'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of France.svg', '+1794-05-20', '+1980-07-19'}},
Q145 = {'GBR', {'Flag of the United Kingdom (3-5).svg', '+1980-07-29'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of the United Kingdom (3-5).svg', '+1980-07-19'}},
Q148 = {'CHN', {"Flag of the People's Republic of China.svg", '+1985'}},
Q155 = {'BRA', {'Flag of Brazil.svg', '+1992-05-11'},
Line 1.651 ⟶ 1.662:
Q232 = {'KAZ', {'Flag of Kazakhstan.svg'}},
Q235 = {'MON', {'Flag of Monaco.svg'}},
Q238 = {'SMR', {'Flag of San Marino.svg'}, '+1980-07-29'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of San Marino.svg', '+1980-07-19'}},
Q241 = {'CUB', {'Flag of Cuba.svg'}},
Q244 = {'BAR', {'Flag of Barbados.svg'}},
Line 1.662 ⟶ 1.675:
Q334 = {'SGP', {'Flag of Singapore.svg'}},
Q347 = {'LIE', {'Flag of Liechtenstein.svg'}},
Q398 = {'BRN ', {'Flag of Bahrain.svg', '+2002-02-1417'}},
{'Flag of Bahrain (1972–2002).svg', '+1972-08-19', '+2002-02-16'}},
Q403 = {'SRB', {'Flag of Serbia.svg', '+2004-08-18'},
{'Flag of Serbia (1992–2004).svg', '+1992-04-27', '+2004-08-17'}},
Q408 = {'AUS', {'Flag of Australia.svg'}, '+1980-07-29'},
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of Australia.svg', '+1980-07-19'}},
Q414 = {'ARG', {'Flag of Argentina.svg'}},
Q419 = {'PER', {'Flag of Peru.svg', '+1950'},
Line 1.681 ⟶ 1.697:
Q750 = {'BOL', {'Flag of Bolivia.svg', '+1851-10-31'}},
Q754 = {'TTO', {'Flag of Trinidad and Tobago.svg'}},
Q769 = {'GRN', {'Flag of Grenada.svg'}},
Q774 = {'GUA', {'Flag of Guatemala.svg'}},
Q778 = {'BAH', {'Flag of the Bahamas.svg'}, '+1973-07-10'},
Line 1.701 ⟶ 1.718:
Q881 = {'VIE', {'Flag of Vietnam.svg', '+1976-02-07'}},
Q884 = {'KOR', {'Flag of South Korea.svg', '+1997-10'}},
Q889 = {'AFG', {'Flag of Afghanistan (2013–2021).svg','+2013-08-19'},
{'Flag of Afghanistan (2004-2021, Variant).svg', '+2004-10-09', '+2013-08-18'},
{'Flag of Afghanistan (2002–2004, variant with golden arms).svg', '+2002-06-27', '+2004-10-08'},
{'Flag of Afghanistan (2002–2004).svg', '+2002-01-28', '+2002-06-26'},
{'Flag of Afghanistan (2001–2002).svg', '+2001-11-13', '+2002-01-27'},
{'Flag of Afghanistan (1992–2001).svg', '+1992-12-07', '+2002-01-26'},
{'Flag of Afghanistan (1992).svg', '+1992-04-27', '+1992-12-06'},
{'Flag of Afghanistan (1987–1992).svg', '+1987-11-30', '+1992-04-26'},
{'Flag of Afghanistan (1980–1987).svg', '+1980-04-22', '+1987-11-29'},
{'Flag of Afghanistan (1978–1980).svg', '+1978-10-19', '+1980-04-21'},
{'Flag of Afghanistan (1978).svg', '+1978-04-27', '+1978-10-18'},
{'Flag of Afghanistan (1974–1978).svg', '+1974-05-9', '+19780-4-26'},
{'Flag of Afghanistan (1973–1974).svg', '+1973-03-17', '+1974-05-8'},
{'Flag of Afghanistan (1931–1973).svg', '+1930-03-27', '+1973-03-16'},
{'Flag of Afghanistan (1929–1931).svg', '+1929-01-1', '+1930-03-26'}},
Q902 = {'BAN ', {'Flag of Bangladesh.svg','+1972-01-17'},
{'Flag of Bangladesh (1971).svg', '+1971-03-06', '+1972-01-16'}},
Q916 = {'ANG', {'Flag of Angola.svg', '+1975-11-11'}},
Q917 = {'BHU ', {'Flag of Bhutan.svg','+1972-06-08'},
{'Flag of Bhutan (1956–1969).svg', '+1956-07-01', '+1972-06-07'},
{'Flag of Bhutan (1949–1956).svg', '+1949-01-01', '+1956-06-30'}},
Q921 = {'BRU', {'Flag of Brunei.svg', '+1959-09-29'}},
Q928 = {'PHI', {'Flag of the Philippines.svg', '+1998'}},
Line 1.730 ⟶ 1.767:
Q8646 = {'HKG', {'Flag of Hong Kong.svg'}},
Q25228 = {'AIA', {'Flag of Anguilla.svg'}},
Q29999 = {'NED', {'Flag of the Netherlands.svg', '+16901980-07-29'}}, --Kingdom of the Netherlands
{'Olympic flag.svg', '+1980-07-19', '+1980-07-29'}, -- OG-1980
{'Flag of the Netherlands.svg', '+1690', '+1980-07-19'}},
Q33946 = {'TCH', {'Flag of the Czech Republic.svg', '+1920'}}, -- Czechoslovakia (1918–1992)
Q36704 = {'YUG', {'Flag of Yugoslavia (1992–2003).svg', '+1992-04-27', '+2003-02-04'}, --Yugoslavia
{'Flag of Yugoslavia (1943–1992).svg', '+1946', '+1992-04-27'}},
Q41304 = {'GER', {'Flag of Germany (3-2 aspect ratio).svg', '+1918-11-09'}}, -- Weimar Republic
Q47588 = {'EU', {'Flag_of_the_Basque_Country.svg'}},
Q83286 = {'YUG', {'Flag of Yugoslavia (1943–1992).svg'}}, --Socialist Federal Republic of Yugoslavia
Q172579 = {'ITA', {'Flag of Italy (1861–1946).svg'}}, --Kingdom of Italy (1861-1946)
Line 1.786 ⟶ 1.826:
end
elseif not date then
local p41 = mw.wikibase.getBestStatementsfirstValue(countryID, "P41") -- P41 is flag image
if p41[1] and p41[1].mainsnak.snaktype == 'value' then
result = '[[File:' .. p41[1].mainsnak.datavalue.value .. '|border|' .. flagpxSize ..'|(Wikidata:' .. countryID .. ')]]'
if arwiki_totemplate then
result = '{{flagicon image|' .. p41[1].mainsnak.datavalue.value .. '}}'
end
end
Line 1.800 ⟶ 1.840:
if arwiki_totemplate then
result = '{{flagicon image|' .. p41.mainsnak.datavalue.value .. '}}'
end
end
end
end
return result .. trackingCategory
Line 1.817 ⟶ 1.857:
--get link, assumed for a country the label is equal to the link, where not correct in the blacklist
--if the black list becomes too long, we could create a second list for the sitelinks
countryName=country_name_from_list(countryID)
if available_list then
if type(translations.list)countryName == "function"nil or blacklist[countryID] then
countryName = translations.list(countryID)
end
end
if countryName == nil or countryName=='' or blacklist[countryID] then
countryName = mw.wikibase.getSitelink(countryID)
end
Line 1.842 ⟶ 1.878:
-- 6. item of the Wikipedia article of that jersey
 
local data = {
{'Q33881', 'montagne', '+1975', '+2500', 'Q25265958', 'Q927157'}, -- Tour de France
{'Q33881', 'leader', '+1919', '+2500', 'Q24257871', 'Q738903'},
{'Q33881', 'points', '+1953', '+1967', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'points', '+1968', '+1968', 'Q26919974', 'Q175399'}, -- Jersey red.svg
{'Q33881', 'points', '+1969', '+2500', 'Q24645209', 'Q175399'}, -- Jersey green.svg
{'Q33881', 'jeune', '+1975', '+2500', 'Q640430', 'Q2254180'}, -- Jersey white.svg
{'Q33881', 'winner_fighting', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'winner_fighting2', '+2003', '+2500', 'Q27644113', 'Q2094179'}, -- Jersey red number.svg
{'Q33881', 'equipe', '+2006', '+2500', 'Q27644112', 'Q1436680'}, -- Jersey yellow number.svg
 
{'Q33861', 'leader', '+1931', '+2500', 'Q24257763', 'Q1164275'}, -- Giro d'Italia, Jersey pink.svg
{'Q33861', 'points', '+1967', '+1968', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+1969', '+2009', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'points', '+2010', '+2016', 'Q26919974', 'Q641083'}, -- Jersey red.svg
{'Q33861', 'points', '+2017', '+2500', 'Q26945272', 'Q641083'}, -- Jersey violet.svg
{'Q33861', 'montagne', '+1974', '+2011', 'Q24645209', 'Q641060'}, -- Jersey green.svg
{'Q33861', 'montagne', '+2012', '+2500', 'Q24687409', 'Q641060'}, -- Jersey blue.svg
{'Q33861', 'jeune', '+1976', '+2500', 'Q640430', 'Q641662'}, -- Jersey white.svg
 
{'Q33937', 'leader', '+1935', '+1936', 'Q24258056', 'Q3278226'}, -- Vuelta a España, Jersey orange.svg
{'Q33937', 'leader', '+1941', '+1941', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1942', '+1942', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1945', '+1945', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'leader', '+1946', '+1950', 'Q26696171', 'Q640430'}, -- Jersey white.svg
{'Q33937', 'leader', '+1955', '+1976', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1977', '+1977', 'Q24258056', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'leader', '+1978', '+1998', 'Q24257871', 'Q738903'}, -- Jersey yellow.svg
{'Q33937', 'leader', '+1999', '+2009', 'Q24257991', 'Q27665179'}, -- Jersey gold.svg
{'Q33937', 'leader', '+2010', '+2500', 'Q24257872', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'points', '+1945', '+1986', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+1987', '+1989', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'points', '+1990', '+2009', 'Q24687409', 'Q2746711'}, -- Jersey blue.svg
{'Q33937', 'points', '+2010', '+2500', 'Q24645209', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1935', '+1985', 'Q27670182', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+1986', '+1986', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+1987', '+1987', 'Q27670178', 'Q2534046'}, -- Jersey red.svg
{'Q33937', 'montagne', '+1988', '+1989', 'Q27670105', 'Q27670115'}, -- Jersey blackdots.png
{'Q33937', 'montagne', '+1990', '+2005', 'Q27670182', 'Q11638007'}, -- Jersey green.svg
{'Q33937', 'montagne', '+2006', '+2008', 'Q27670174', 'Q3278226'}, -- Jersey orange.svg
{'Q33937', 'montagne', '+2009', '+2009', 'Q27670126', 'Q27670163'}, -- Jersey granate.svg
{'Q33937', 'montagne', '+2010', '+2500', 'Q25265959', 'Q27670167'}, -- Jersey bluedots.svg
{'Q33937', 'jeune', '+2019', '+2500', 'Q640430', 'Q60233927'}, -- Jersey white.svg
 
{'Q2091354', 'leader', '+2011', '+2500', 'Q24257871'}, -- Tour of Norway, Jersey yellow.svg
{'Q2091354', 'sprints', '+2011', '+2011', 'Q26806427'}, -- Jersey green.svg
{'Q2091354', 'points', '+2012', '+2017', 'Q24645209'}, -- Jersey green.svg
{'Q2091354', 'points', '+2018', '+2018', 'Q28820618'}, -- MaillotCyan.PNG
{'Q2091354', 'points', '+2019', '+2500', 'Q47945989'}, -- Jersey dark blue.svg
{'Q2091354', 'montagne', '+2011', '+2015', 'Q25265958'}, -- Jersey polkadot.svg
{'Q2091354', 'montagne', '+2016', '+2017', 'Q27670174'}, -- Jersey orange.svg
{'Q2091354', 'montagne', '+2018', '+2500', 'Q25265958'}, -- Jersey polkadot.svg
{'Q2091354', 'jeune', '+2011', '+2500', 'Q640430'}, -- Jersey white.svg
{'Q2091354', 'winner_fighting', '+2017', '+2017', 'Q29957114'}, -- MaillotCyan.PNG
{'Q128713', 'leader', '+2013', '+2017', 'Q24257871'}, -- Tour des Fjords, Jersey yellow.svg
{'Q128713', 'leader', '+2018', '+2018', 'Q29594434'}, -- MaillotCyan.PNG
{'Q128713', 'points', '+2013', '+2014', 'Q24645209'}, -- Jersey green.svg
{'Q128713', 'points', '+2015', '+2017', 'Q24687409'}, -- Jersey blue.svg
{'Q128713', 'points', '+2018', '+2018', 'Q25265938'}, -- Jersey violet.svg
{'Q128713', 'montagne', '+2013', '+2018', 'Q25265958'}, -- Jersey polkadot.svg
{'Q128713', 'jeune', '+2013', '+2018', 'Q640430'}, -- Jersey white.svg
{'Q128713', 'winner_fighting', '+2015', '+2015', 'Q30035038'}, -- Jersey green.svg
{'Q128713', 'winner_fighting', '+2016', '+2017', 'Q30035039'}, -- Jersey orange.svg
{'Q128961', 'leader', '+2013', '+2500', 'Q24687408'}, -- Arctic Race of Norway, Jersey blue.svg
{'Q128961', 'points', '+2013', '+2500', 'Q24645209'}, -- Jersey green.svg
{'Q128961', 'montagne', '+2013', '+2014', 'Q27670178'}, -- Jersey red.svg
{'Q128961', 'montagne', '+2015', '+2500', 'Q27670174'}, -- Jersey orange.svg
{'Q128961', 'jeune', '+2013', '+2500', 'Q640430'}, -- Jersey white.svg
{'Q128961', 'winner_fighting', '+2014', '+2500', 'Q27644113'}, -- Jersey red number.svg
{'Q17619325', 'leader', '+2014', '+2014', 'Q24257871'}, -- Ladies Tour of Norway, Jersey yellow.svg
{'Q17619325', 'leader', '+2015', '+2016', 'Q26945272'}, -- Jersey violet.svg
{'Q17619325', 'leader', '+2017', '+2500', 'Q24257871'}, -- Jersey yellow.svg
{'Q17619325', 'points', '+2014', '+2500', 'Q24645209'}, -- Jersey green.svg
{'Q17619325', 'montagne', '+2014', '+2500', 'Q25265958'}, -- Jersey polkadot.svg
{'Q17619325', 'jeune', '+2014', '+2500', 'Q640430'}, -- Jersey white.svg
{'Q17619325', 'winner_fighting', '+2016', '+2500', 'Q30035039'}, -- Jersey orange.svg
}
--timeOfRace = '+1968-07-01T00:00:00Z'
timeOfRace = string.match(timeOfRace, "+%d%d%d%d") or ''
for _, v in pairs(item) do
for _, value in pairs(data.stageinfobox_jersey) do
if v == value[1] then
if winner_classification == value[2] then
Line 1.988 ⟶ 1.947:
if p18[1] and p18[1].mainsnak.snaktype == 'value' then
jersey_string = jersey_string .. '[[File:' .. p18[1].mainsnak.datavalue.value .. '|20px'
jersey_name = getLabelFallback(v, {wikilang, 'en', 'fr'})
if jersey_name then
jersey_string = jersey_string .. '|' .. jersey_name
Line 2.000 ⟶ 1.959:
end -- function end
 
--=== E) Other (winner, getkm) ===
local function isHuman(riderId)
local isHuman = false
Line 2.015 ⟶ 1.974:
end
 
local function isCountry(riderIdinputID)
local isCountry = false
if riderIdinputID then
local p31 = wikibase.getBestStatements(riderIdinputID, 'P31')
for _, iOf in pairs (p31) do
-- exception Hong-Kong and Taiwan
Line 2.030 ⟶ 1.989:
end
 
local function isWomenrace(raceID) --for translation
for _, p2094 in statements(raceID, 'P2094') do
if p2094.mainsnak.datavalue.value.id == "Q1451845" then
return true
end
end
return false
end
 
local function isWomenteam(teamID, timeOfRace)
if isWomenrace(teamID) then --simplest way
return true
end
--else we can identify with teamCat
local _, catID= getTeamLinkCat(teamID, timeOfRace, false)
if data.womenCats[catID] then
return true
end
return false
Line 2.054 ⟶ 2.025:
end
end
end
end
if wiki=='eu' and (countryID=="Q142" or countryID=="Q29") then --look for people or location in the Basque Country, quite expensive function
local birth_place = firstValue(wID, 'P19','id') --birth place
if data.BasqueTown[birth_place] then
return "Q47588"
end
end
Line 2.083 ⟶ 2.061:
end
 
local function winner(lf,raceID, winners, timeOfRace, country, WDlink_on, team, ref, winnersId)
local p1346 = wikibase.getAllStatements(raceID, 'P1346') -- P1346 is 'winner'
for _, winner in pairs(p1346) do
Line 2.091 ⟶ 2.069:
if q then
local _, disqualified =isdisqualified(winner,q)
local propertyOf=nil
if q.P2501 and q.P2501[1].snaktype == 'value' then
propertyOf=q.P2501 --result
elseif q.P828 and q.P828[1].snaktype == 'value' then --cause, for cancellation
propertyOf=q.P828
elseif q.P642 and q.P642[1].snaktype == 'value' then
propertyOf=q.P642 --fallback
end
if q.P642propertyOf and q.P642propertyOf[1].snaktype == 'value' then
for _, q642qprop in pairs(q.P642propertyOf) do
wOf = q642qprop.datavalue.value.id -- P642 is 'of'
if not wOf then
-- Try P1346 (winner) instead
Line 2.107 ⟶ 2.093:
if winners[wOf] then
if wID then
local reference = ref and getReference(lf,winner)
local _, countryID
if isHuman(wID) then
Line 2.138 ⟶ 2.124:
countryID = getNationality(wID, timeOfRace,q)
else
local p17countryID = getStatementForTimegetCountryID(wID, 'P17', timeOfRace) --P27 is country of citizenship
if p17 then
countryID = p17.mainsnak.datavalue.value.id
end
end
end
Line 2.183 ⟶ 2.166:
 
local function sortAndConcat(t_Body, resultTable)
table.sort(t_Body, function(a, b) return a[1'sortkey'] < b[1'sortkey'] end)
for _, m in ipairs(t_Body) do resultTable:node(m[2'body']) end
return resultTable
end
 
--------- Definition sub-functions for calendar and victory ------
local function getTimeOfRace(raceID, mandatory, p582_prio)
local timeOfRace = firstValue(raceID, 'P580', 'time')properties
if p582_prio then --for case like UCI Europe Tour 2006 (Q1455600) where most of the competition is in the next year
if timeOfRace==nil then
properties={'P582','P585','P580'}
timeOfRace = firstValue(raceID, 'P585', 'time') -- P585 is 'point in time'
else
if timeOfRace==nil then
properties={'P580','P585','P582'}
timeOfRace = firstValue(raceID, 'P582', 'time')
end
if timeOfRace==nil then
local link = getSitelinkFallback(raceID, {'en', 'fr', 'de'})
for _, prop in ipairs(properties) do
if link then
timeOfRace= firstValue(raceID, prop, 'time')
local year = string.match(link, '%d%d%d%d')
if timeOfRace ~= nil then return timeOfRace end
if year then
end
timeOfRace = year .. '-01-01T00:00:00Z'
 
end
local link = getSitelinkFallback(raceID, {'en', 'fr', 'de','es'}) --language is not important here, it is just to get the year
end
if link then
end
local year = string.match(link, '%d%d%d%d')
if year then
return year .. '-01-01T00:00:00Z'
end
end
if timeOfRace == nil and wiki == "ar" then
timeOfRace =return '+1970-01-01T00:00:00Z'
end
if mandatory then
return timeOfRace, '> Wikidata is missing data about start time (P580) or point in time (P582)'
error('> Wikidata is missing data about start time (P580) or point in time (P582)')
end
return nil
end
 
local function fn_dateget_formatted_date(entityID, functionName) --to move as a general function
local tempdate, timeOfRace, sortkey, sortkeyDate
local outTable={}
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
local style1, style2
if functionName=="infobox" then
style1='verylong' --force to display the year
style2='long'
else
style1='small'
style2='small'
end
if sTime and eTime then
local startTime, endTime = getStartEndTime(sTime, eTime, 'small'style1)
if functionName==nil or functionName=='infobox' then --calendar, infobox
tempdate = return startTime .. ' – ' .. endTime, sTime, --mettre year en option!true
else --victory, general classification
sortkeyDate = sTime
return endTime, eTime, true
else --victory, general classification
tempdate =endTime
sortkeyDate =eTime
end
timeOfRace = eTime
else
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
tempdate =return funcDate(pTime, 'small'style2), pTime, false
timeOfRace = pTime
sortkeyDate = pTime
end
end
return nil
local _, _, y, m, d = string.find(sortkeyDate or "", "(%d+)-(%d+)-(%d+)")
end
if y~= nil and m~= nil and d~=nil then
 
sortkey = y..m..d
local function fn_date(entityID, functionName) --to move as a general function
elseif y~= nil and m~= nil then
local tempdate, timeOfRace, _ = get_formatted_date(entityID, functionName) --is there a reason why timeofrace cannot be sTime??
sortkey = y..m
 
elseif y~= nil then
local _, _, y, m, d = string.find(timeOfRace or "", "(%d+)-(%d+)-(%d+)")
sortkey = y
elselocal sortkey =(y or '')..(m or '')..(d or '0000')
if sortkey =='' then sortkey = '0000' end
end
 
local tCell = mw.html.create('td'):attr('data-sort-value',sortkey)
:cssText("style=text-align:right;padding:0 0.5em")
:wikitext(tempdate)
 
return timeOfRace, tostring(tCell), sortkey
outTable["timeOfRace"]=timeOfRace
outTable["tCell"]=tostring(tCell)
outTable["sortkey"]=sortkey
return outTable
end
 
local function fn_country(entityID, timeOfRace,countryboolcountry, raceCell, parentID)
-- This function gives countries where the race take place
-- parentID taken from fn_race, optional
local country_str, country_name, country_flag
 
local country, countryname, outTable= {}, {}, {}
local countryID
 
local cssCell="text-align:" .. textalign .. ";padding:0 0.5em"
local tCell= mw.html.create('td'):cssText(cssCell)
 
local countryID = getCountryID(entityID, timeOfRace)
if countryID==nil then countryID = getCountryID(parentID, timeOfRace) end
if countryID then
local listOfProperty={'P1532','P17'} -- P1512 is 'country for sport' to handle problems with Hong Kong etc.
country_flag=flag(countryID, timeOfRace)
local listOfID = {entityID, parentID}
country_str=country_flag
country_name = getCountryName(countryID)
for _, thisID in ipairs(listOfID) do
if thisIDcountry_name~=nil'' then
tCell:attr('data-sort-value',country_name)
for _, prop in ipairs(listOfProperty) do
if countryID =country~= nilfalse then --like "break"
country_str=country_str.." "..country_name
for _, p1532 in statements(thisID, prop) do
countryID = p1532.mainsnak.datavalue.value.id
countryname[#countryname + 1] = getCountryName(countryID)
if countrybool==false or not countryname[#countryname] then
country[#country + 1]=flag(countryID, timeOfRace)
else
country[#country + 1]=flag(countryID, timeOfRace).." "..countryname[#countryname]
end
outTable["flag"]=flag(countryID, timeOfRace)
end
end
end
end
else
country_flag="no flag"
end
 
if country==false then
if countryID == nil then outTable["flag"]="no flag" end
tCell:wikitext(country_flag.." "..(raceCell or ''))
if countryname[1] then tCell:attr('data-sort-value',countryname[1]) end
country_name=''
if countrybool==false then
tCell:wikitext((country[1] or '').." "..(raceCell or ''))
outTable["countryname"]=''
else
if countryname[1]country_str then
tCell:wikitext(country_str)
outTable["countryname"]=countryname[1]
if country[1] then tCell:wikitext(country[1]) end
else
outTable["countryname"]=''
end
end
return country_flag, country_name, tCell
outTable["tCell"]=tCell
return outTable
end
 
Line 2.395 ⟶ 2.368:
prefix=''; postfix='' --general classification
listOfProperty={'P2561','P1448'}
--main race link is in the parent --can be improved
--system with P3450 and P2094
instanceOf=firstValuefor _, p31 in statements(entityID, 'P3450', 'idP31') do
instanceOfTemp = p31.mainsnak.datavalue.value.id
--else use P31
if instanceOfTemp ~= "Q27020041" and instanceOfTemp ~= 'Q88903067' and data.class_dic[instanceOfTemp]==nil then --but the main race
if instanceOf==nil then
instanceOf=instanceOfTemp
for _, p31 in statements(entityID, 'P31') do
instanceOfTemp = p31.mainsnak.datavalue.value.id
if instanceOfTemp ~= "Q27020041" and class_dic[instanceOfTemp]==nil then --we don't want the class, but the main race
instanceOf=instanceOfTemp
end
end
end
 
--get information from the parent
if instanceOf then
Line 2.433 ⟶ 2.402:
 
if label==nil then
label=getLabelFallback(instanceOf,lang_priority) --the case of 'ar' should be handled in lang_priority
label=wikibase.label(instanceOf)
if wiki == 'ar' then arlabel = mw.wikibase.getLabelByLang(instanceOf, 'ar') end
if not label then
label = getLabelFallback(entityID, {'en', 'fr', 'de'}lang_priority) or ''
end
end
Line 2.471 ⟶ 2.439:
--affect the label
if label==nil then
label=wikibase.labelgetLabelFallback(entityID,lang_priority) or ''
if wiki == 'ar' then arlabel = mw.wikibase.getLabelByLang(entityID, 'ar') end
if not label then
label = getLabelFallback(entityID, {'en', 'fr', 'de'}) or ''
end
end
--look for link to the race if nothing
Line 2.522 ⟶ 2.486:
for _, p31 in statements(circuitID, 'P31') do --is it a UCI circuit?
parentCircuitID = p31.mainsnak.datavalue.value.id
if data.UCI_Circuits[parentCircuitID] then
displayedCircuitID=circuitID
end
Line 2.529 ⟶ 2.493:
else --for instance Flèche wallonne
if q then
if q.P642P279 and q.P642P279[1].snaktype == 'value' and q.P642P279[1].datavalue.value.id then --fallback
displayedCircuitID = q.P642P279[1].datavalue.value.id
elseif q.P642 and q.P642[1].snaktype == 'value' and q.P642[1].datavalue.value.id then --fallback
displayedCircuitID = q.P642[1].datavalue.value.id
end
end
Line 2.564 ⟶ 2.530:
end
 
local function getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
local period
if sTime and eTime then
if startTime==endTime then
period=startTime --only (1990)
else
period=startTime .. '-'..endTime
end
elseif sTime then
period=startTime .. '-'
elseif eTime then
period='-'..endTime
else
period=""
end
if brackets and period~="" then
period="("..period..")"
end
return period
end
local function getPeriodSub(sTime, eTime, brackets)
local startTime, endTime, y, m, y2, m2
Line 2.584 ⟶ 2.572:
end
end
return getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
end
 
local function getPeriodSub_season(sTime, eTime, brackets)
local period
local startTime, endTime
if sTime and eTime then
if startTime==, endTime then= getStartEndTime(sTime, eTime, 'small')
period=startTime --only (1990)
else
period=startTime .. '-'..endTime
end
elseif sTime then
startTime=funcDate(sTime, 'small')
period=startTime .. '-'
elseif eTime then
endTime=funcDate(eTime, 'small')
period='-'..endTime
else
period=""
end
return getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
if brackets and period~="" then
period="("..period..")"
end
return period, sTime
end
 
-- for display period with only year, for instance (2020-2021)
local function getPeriod(q, brackets,season)
local sTime, eTime = getStartEndfromQuali(q)
if season then
return getPeriodSub(sTime, eTime, brackets)
return getPeriodSub_season(sTime, eTime, brackets), sTime
end
else
 
return getPeriodSub(sTime, eTime, brackets), sTime
local function getClassCalendar_sub(entityID)
local classID=firstValue(entityID, 'P279', 'id')
if classID==nil then
for _, p31 in statements(entityID, 'P31') do
if class_dic[p31.mainsnak.datavalue.value.id]~=nil then
classID=p31.mainsnak.datavalue.value.id
break
end
end
end
return classID
end
 
Line 2.635 ⟶ 2.605:
local classID = p279.mainsnak.datavalue.value.id
 
if data.class_dic[classID]~=nil then
circuitID=classToCircuit(classID, entityID, false, p279.qualifiers)
classLink=classLinkFn(classID,circuitID)
if circuitID and if classLink then
local period, sTime=getPeriod(p279.qualifiers, true)
local classStr = classLink .. " <small>"..period.."</small>"
table.insert(classTable, {sTime, classStr, circuitID})
end
Line 2.652 ⟶ 2.622:
if not str then str='' else str=str..'<br>' end
str=str..class[2]
if class[3] then
circuitLink=WPlinkpure(class[3])
end
end
return str, circuitLink, #classTable
Line 2.659 ⟶ 2.631:
local function fn_race(entityID,displayed_class,display_class,timeOfRace, functionName,country)--return link to the race and class
--first function read from victory main
local Sitelink, entity_type, classID, stageID, race_tCell, class_tCell, parentID
local outTable={}
 
for _, p31 in statements(entityID, 'P31') do
if data.stages[p31.mainsnak.datavalue.value.id] then
entity_type = 'stage' --then the class is one stage above!
local parentID = getParentID(entityID)
classID=getClassCalendar_subfirstValue(parentID, 'P279', 'id')
outTable["parentID"] = parentID --as we read it here, no need to read it afterwards
stageID= entityID --everything slide from one rank
entityID = parentID
end
end
if classID==nil then
classID=getClassCalendar_sub(entityID)
end
--Now we have the class and know the type of race it is
Line 2.681 ⟶ 2.646:
Sitelink=getMainRaceLink(entityID,entity_type,stageID, functionName,timeOfRace)
else
classID=firstValue(entityID, 'P279', 'id')
Sitelink=getMainRaceLink(entityID,data.class_dic[classID],nil, functionName,timeOfRace)
end
if country~=false then
local tCell=mw.html.create('td'):cssText("text-align:".. textalign ..";padding:0 2.3em"):wikitext(Sitelink)
outTable["raceCell"]race_tCell=tostring(tCell)
else
outTable["raceCell"]race_tCell=Sitelink --already opened
end
Line 2.695 ⟶ 2.661:
local classLink=classLinkFn(classID,circuitID) --return '' worst case
 
local tCellclass_tCell=mw.html.create('td')
:attr('data-sort-value',data.class_sort[classID]) --sortkey
:cssText("text-align:center;padding:0 0.5em")
:wikitext(classLink)
outTable["classCell"]=tCell
end
return parentID, race_tCell, class_tCell
return outTable
end
 
local function fn_rider(lf,entityID,timeOfRace,display_team,only_winner,country)
local winners, countrytemp, result
local WDlink_on = (wiki == "mk" or wiki == "ja")
Line 2.718 ⟶ 2.682:
end
if country==nil then countrytemp=false else countrytemp=country end
winner(lf,entityID, winners, timeOfRace, countrytemp, WDlink_on, display_team, true)
local tCell=mw.html.create('td'):css("text-align:".. textalign ..";padding:0 0.5em")
Line 2.779 ⟶ 2.743:
local function calculateAge(birthDate, endDate) --test future
local eYear, eMonth, eDay
local longestcontractyears=10
if birthDate then
if not endDate then
Line 2.813 ⟶ 2.778:
if alreadyThisYear then
return eYear-tYear, tYear, eYear+1longestcontractyears
else
return eYear-tYear-1, tYear, eYear+1longestcontractyears
end
else
return 0, tYear, eYear+1longestcontractyears
end
end
Line 2.859 ⟶ 2.824:
end
 
local function listOfWinners(itemID,t, team,lf, mandatory_prop)
local winners = { Q20882667 = '',}-- Q20882667 is 'overall winner general classification'
local winnersId={ Q20882667 = '',}--to detect disqualification
local WDlink_on, sitelink
 
-- WDlink_on is used to decide if a Wikidata flag will be shown
if wiki == "mk" or wiki == "ja" or wiki == "ru" then WDlink_on = true else WDlink_on = false end
 
Line 2.892 ⟶ 2.856:
winners.Q20882667=''
winnersId.Q20882667=''
winner(lf,t.race[num]['raceId'], winners, t.race[num]['raceDate'], false, WDlink_on, nil, nil, winnersId )
if t.race[num]['future']==false then --in the past
if winnersId.Q20882667~="Q30108381" and winnersId.Q20882667~="Q54806642" then --cancelled
numberOfEditions=numberOfEditions+1
lastRunEdition=num
Line 2.903 ⟶ 2.867:
winnerId=winnersId.Q20882667
if winnerId~=nil and winnerId~='' and winnerId~='Q666' and winnerId~='Q30108381' and winnersId.Q20882667~="Q54806642" then --code for disqualification
if not t.vainqueur[winnerId] then
t.vainqueur[winnerId]={}
Line 2.912 ⟶ 2.876:
end
end
else --for team therethe check is nothing to checklighter
for num=1,#t.race do
if t.race[num]['future']==false then --in the past
numberOfEditions=num
if mandatory_prop==nil then
lastRunEdition=num
numberOfEditions=num
lastEditionDate=t.race[num]['raceDate']
lastRunEdition=num
lastEditionDate=t.race[num]['raceDate']
else
local ss = wikibase.getAllStatements(t.race[num]['raceId'], mandatory_prop)
if #ss >0 then
numberOfEditions=num
lastRunEdition=num
lastEditionDate=t.race[num]['raceDate']
end
end
end
end
end
 
local monthId=firstValue(itemID, 'P2922','id')
if monthId then
t.lastEditionMonth=getLabelFallback(monthId, {wikilang, 'en', 'fr', 'de'}) or ''
else
t.lastEditionMonth=contentLanguage:formatDate("M", lastEditionDate)
end
 
t.lastEditionYear=contentLanguage:formatDate("Y",if lastEditionDate) then
t.lastEditionYear=funcDate(lastEditionDate,"onlyyear")
end
t.numberOfEditions=numberOfEditions
if not team then evaluateWinnerMax(t) end
Line 2.932 ⟶ 2.910:
if lastRunEdition then
t.lastWinner=lastWinner or '' --t.vainqueur[lastRunEdition]['link']
sitelink = wikibaset.getSitelink(lastID=t.race[lastRunEdition]['raceId'])
sitelink = wikibase.getSitelink(t.lastID)
if sitelink ~= nil then
t.lastLink = "[[" .. sitelink .. "]]"
Line 2.941 ⟶ 2.920:
if nextEdition then
sitelink = wikibaset.getSitelink(nextID=t.race[nextEdition]['raceId'])
sitelink = wikibase.getSitelink(t.nextID)
if sitelink ~= nil then
t.nextLink = "[[" .. sitelink .. "]]"
Line 2.950 ⟶ 2.930:
end
 
local function getPeriodicity(itemID, t)
local p = wikibase.getBestStatements(itemID, 'P2257')
if p[1] and p[1].mainsnak.snaktype == 'value' then
Line 2.980 ⟶ 2.960:
end
 
local function getFormerNames(itemID, PID, season)
local listOfNames={}
local langFallback, officialname,language
 
if wiki=="mk" then
langFallback= {wiki} --only exact language
else
langFallback= {wiki, 'en','fr', 'de', 'es', 'nl', 'it'} --all languages, but tested one at a time
end
local kk=1
while #listOfNames == 0 and kk<=#langFallbacklang_priority do
lang=langFallbacklang_priority[kk]
kk=kk+1
for _, prop in ipairs({PID}) do
Line 2.999 ⟶ 2.973:
officialname = p1813.mainsnak.datavalue.value.text
if lang==language then --only exact language
local period, sTime=getPeriod(p1813.qualifiers, nil, season)
if not sTime then sTime="+1900-01-01T00:00:00Z" end --first
table.insert(listOfNames,{sTime, period, officialname, language})
Line 3.011 ⟶ 2.985:
 
local function officialSite(itemID)
local p856 url= wikibase.getBestStatementsfirstValue(itemID, 'P856')
if url then
if p856[1] and p856[1].mainsnak.snaktype == 'value' then
local url = p856[1].mainsnak.datavalue.value
return '['..url.." "..translate("raceinfobox",3)..']'
end
return nil
end
 
local function getKm(wiki)
local km
if wiki == "ar" then km = 'كم'
elseif wiki == "mk" then km = 'км'
elseif wiki == "ru" then km = 'км'
elseif wiki == "ja" then km = 'キロメートル'
else km = 'km' end
return km
end
 
local function getm(wiki)
local m
if wiki == "ar" then m = 'م'
elseif wiki == "mk" then m = 'м'
elseif wiki == "ru" then m = 'м'
elseif wiki == "ja" then m = ''
else m = 'm' end
return m
end
 
local function getKg(wiki)
local kg
if wiki == "ar" then kg = 'كجم'
elseif wiki == "mk" then kg = 'кг'
elseif wiki == "ru" then kg = 'кг'
elseif wiki == "ja" then kg = ''
else kg = 'kg' end
return kg
end
 
Line 3.061 ⟶ 3.004:
end
 
local function checkm(p, in_cm)
local m, unit, res
if p[1] and p[1].mainsnak.snaktype == 'value' then
m = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q11573' then
return res=m
elseif unit=='http://www.wikidata.org/entity/Q174728' then --cm
return res=m*0.01
end
if res then
if in_cm then
res=res*100
end
return res
end
end
return nil
end
 
local function checkkmh(p)
if p[1] and p[1].mainsnak.snaktype == 'value' then
kmh = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q180154' then -- Q180154 is 'kilometre per hour'
return kmh
end
end
Line 3.087 ⟶ 3.047:
end
 
local function getHeightformatNumber(entityIDe, addUnit, trans)
local m
local text
if e then
local lang = contentLanguage
text = contentLanguage:formatNum(e)
 
local p = mw.wikibase.getBestStatements(entityID, 'P2048')
m= checkm(p)
if m then
text = lang:formatNum(m)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
if addUnit then
text = text .. ' ' .. getm(wiki)
local t=translate("unit",trans)
if string.find( t," ")==1 then
text = text ..t
else
text = text .. ' ' ..t
end
end
end
return text
end
 
local function getWeight(entityID)
local kg
local text
local lang = contentLanguage
local p = mw.wikibase.getBestStatements(entityID, 'P2067')
kg = checkkg(p)
 
local function getHeight(entityID, in_cm)
if kg then
local p = mw.wikibase.getBestStatements(entityID, 'P2048')
text = lang:formatNum(kg)
if wiki == 'fo'in_cm then
return formatNumber(checkm(p, in_cm), true, 11)
text = string.gsub(text, "%.", ",")
else
end
return formatNumber(checkm(p, in_cm), true, 9)
text = text .. ' ' .. getKg(wiki)
end
end
return text
 
local function getWeight(entityID)
local p = mw.wikibase.getBestStatements(entityID, 'P2067')
return formatNumber(checkkg(p), true, 10)
end
 
local function getDistance(raceID, addUnit)
local km
local p = mw.wikibase.getBestStatements(raceID, 'P3157') -- P3157 is 'event distance'
local km =checkkm(p)
if not km then --for stage race we can sum the distances from each stage
local stagep, tempkm
for _, p527 in statements(raceID,'P527') do
stageID stagep= mw.wikibase.getBestStatements(p527.mainsnak.datavalue.value.id, 'P3157')
stagep=mw.wikibase.getBestStatements(stageID, 'P3157')
tempkm=checkkm(stagep)
if tempkm then
if not km then km=0 end
km=km+tempkm
else
km=km+tempkm
end
end
end
end
return formatNumber(km, addUnit, 8), km
local text
local lang = contentLanguage
if km then
-- The unit should always be km. Skip if it isn't.
text = lang:formatNum(km)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
if addUnit then
text = text .. ' ' .. getKm(wiki)
end
end
return text, km
end
 
local function getKmh(wiki)
local kmh
if wiki == "ar" then kmh = 'كم/س'
elseif wiki == "da" then kmh = 'km/t'
elseif wiki == "fo" then kmh = 'km/t'
elseif wiki == "nl" then kmh = 'km/u'
elseif wiki == "no" then kmh = 'km/t'
elseif wiki == "mk" then kmh = 'км/ч'
elseif wiki == "ru" then kmh = 'км/ч'
elseif wiki == "ja" then kmh = 'キロメートル毎時'
else kmh = 'km/h' end
return kmh
end
 
local function getElevation(raceID)
local p =mw.wikibase.getBestStatements(raceID, 'P7297')
local l10nDef = {
return formatNumber(checkm(p), true, 9)
["en"] = " m",
["ar"] = " م",
}
local l10n = l10nDef[wiki] or l10nDef["en"]
local temp = mw.wikibase.getBestStatements(raceID, 'P7297')
if temp[1] and temp[1].mainsnak.snaktype == 'value' then
local unit = temp[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q11573' then
return tonumber(temp[1].mainsnak.datavalue.value.amount) .. l10n
end
end
return nil
end
 
local function getSpeed(raceID, addUnit,kmdistance, property)
local timeOfRace
local p = mw.wikibase.getBestStatements(raceID, 'P2052') -- P2052 is 'speed'
local kmh, unit, text, found, timeOfRace=checkkmh(p)
 
local lang = contentLanguage
if not kmh and kmdistance then --calculate speed
if p[1] and p[1].mainsnak.snaktype == 'value' then
kmh = tonumber(p[1].mainsnak.datavalue.value.amount)
unit = p[1].mainsnak.datavalue.value.unit
if unit == 'http://www.wikidata.org/entity/Q180154' then -- Q180154 is 'kilometre per hour'
found=true
end
end
if not found and kmdistance then --calculate speed
local p2321= wikibase.getBestStatements(raceID, property) --winner supposed to be first of overall classification
if p2321 and p2321[1] and p2321[1].mainsnak.snaktype == 'value' then
Line 3.211 ⟶ 3.122:
 
if timeOfRace then
found=true
kmh=math.modf(1000*kmdistance/(timeOfRace/3600))/1000
end
end
end
return formatNumber(kmh, addUnit, 5)
if found then
-- The unit should always be km/h. Skip if it isn't.
text = lang:formatNum(kmh)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
if addUnit then
text = text .. ' ' .. getKmh(wiki)
end
end
return text
end
 
local function getGenderCode(riderID, default)
local gender=default -- default is for teams, n or f
local p21g = mw.wikibase.getBestStatementsfirstValue(riderID, 'P21', 'id') -- P21 is gender
if g == 'Q6581097' then gender = 'm' -- Male
if p21[1] and p21[1].mainsnak.snaktype == 'value' then
elseif g == 'Q6581072' then gender = 'f' -- Female
local g = p21[1].mainsnak.datavalue.value.id
if elseif g == 'Q6581097Q1052281' then gender = 'mt' -- MaleTransgenre
elseif g == 'Q6581072' then gender = 'f' -- Female
elseif g == 'Q1052281' then gender = 't' -- Transgenre
end
end
return gender or default -- default is for teams, n or f
end
 
Line 3.299 ⟶ 3.196:
end
 
local function func_error_message(x)
local l10nDef = {
["fr"] = {"La propriété <1> est manquante dans l'item <2> (<3>)"},
["en"] = {'Property <1> is missing in item "<2>" (<3>)'},
["ar"] = {'الخاصية <1> غير موجودة في العنصر "<2>" (<3>)'},
Line 3.311 ⟶ 3.209:
local function getMissingLabelTrackingCategory()
local l10nDef = {
["//cs.wikipedia.org"] = '[[Kategorie:Údržba:Doplnit štítek na Wikidatech]]',
["//lv.wikipedia.org"] = '[[Category:Vikidatos trūkst nosaukuma latviešu valodā]]',
["//he.wikipedia.org"] = '[[קטגוריה:ויקינתונים:ערכים חסרי תווית בעברית: קבוצת אופניים]]',
}
local l10n = l10nDef[mw.site.serverwiki]
if not l10n then
l10n = ''
Line 3.332 ⟶ 3.230:
end
if inp == "0" then
this_label = translate("func_prologue",1)
else
this_label = stageLink(inp, a, b)
Line 3.414 ⟶ 3.312:
--== Functions for infobox
-- functions for infoboxs
local function get_others_dic()
return {
{ name = translate("infobox",29,w_race)}, -- picture
{ name = translate("infobox",30,w_race)}, -- caption
{ name = translate("infobox",31,w_race)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,w_race)}, -- caption map
{ name = translate("infobox",30,w_race)}, -- caption sectional
}
end
 
local function infoGetOthers(others, entityID)
if not others[1].content then --picture
Line 3.494 ⟶ 3.403:
if width==nil then width= '320px' end
local tab = mw.html.create('table'):addClass('infobox')
if wiki == "eo" then
tab:cssText(standardtablecss):css('width','23em')
:addClass('infobox')
else
cellpadding=tostring(cellpadding or 4)
Line 3.582 ⟶ 3.490:
local function wdDoc(tab, s, translation, ID)
local tCell=tab:tag('tr'):tag('td')
local tC, link
local commons_cat=firstValue(ID, 'P373', 'id')
Line 3.588 ⟶ 3.496:
commons_cat=string.gsub(commons_cat, '%s', '_')
local icon="[[File:Commons-logo.svg|12px|link=https://commons.wikimedia.org/wiki/Category:"..commons_cat.."]]"
tC=tCell:cssText('text-align:left; border-top:3px solid '..backgroundColor..'; font-size:7593%')
:wikitext(icon):tag('td')
else
tC=tCell:attr('colspan','2')
end
local wd_link = wdLink(ID)
local link = "[[" .. s .. "|" .. translation .. "]] "..wd_link
if wiki == "ar" then
link = wd_linkwdLink(ID) .." [[" .. s .. "|" .. translation .. "]]"
else
link = "[[" .. s .. "|" .. translation .. "]] "..wdLink(ID)
end
tC:cssText('text-align:right; border-top:3px solid '..backgroundColor..'; font-size:7593%')
:wikitext(link)
end
Line 3.623 ⟶ 3.531:
 
--Display in a chronological order fields in a table
local function listWPlinkChrono(details, index, entityID, listOfProperty, option, initialYear, display_flag, comma,season)
local period, sTime, value, ID, temp
local list={}
Line 3.636 ⟶ 3.544:
ID=p.mainsnak.datavalue.value.id
if p.qualifiers then
period, sTime=getPeriod( p.qualifiers, true,season)
end
if not sTime then sTime="+"..initialYear.."-01-01T00:00:00Z" end --first
Line 3.643 ⟶ 3.551:
value=wikibase.getLabelByLang(ID, wiki)
elseif option == 'country' then
value=getCountryName(ID)
if display_flag then
value= flag(ID, sTime).." "..getCountryName(ID)value
else end
value=getCountryName(ID)
end
elseif option=='officialname' then
value=getOfficialName(ID, sTime,false) --official name is necessary because of continental team change in ProTeam
Line 3.694 ⟶ 3.601:
 
-- == Functions for team roster
local function getReason(riderReason, riderRef, p527,timeOfRace,riderEnd,lf) --reason for end
local listofproperty={'P1642','P1643','P1534'}
local outTable={}
Line 3.714 ⟶ 3.621:
end
if riderReason then
local label = string.gsub(wikibase.labelgetLabelFallback(riderReason,lang_priority), "%b()", "") or getLabelFallback(riderReason,{'en', 'fr', 'de'})
riderRef = getReference(lf,p527, 1)
riderReason = ', ' .. label
end
Line 3.727 ⟶ 3.634:
for _, q in qualifiers(v, 'P39') do
stagiaire = q.value.id
local label = string.gsub(wikibase.labelgetLabelFallback(stagiaire,lang_priority), "%b()", "") or getLabelFallback(stagiaire,{'en', 'fr', 'de'})
Sitelink = wikibase.getSitelink('Q2328847')
if Sitelink then
Line 3.799 ⟶ 3.706:
end
if not done then
names = tostring(c)..' '..tostring(a)..' '..tostring(b)
done = true
end
Line 3.827 ⟶ 3.734:
if wikiIsSlavic and correctlanguage then
local label = wikibase.getLabelByLang(riderID, wiki)
if not label then
label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findLastName(label,wiki)
else
local nametable = mw.text.split(label, ",")
if nametable[2] then --there is a coma so the lastname is first
Line 3.838 ⟶ 3.742:
end
end
else
local label = getLabelFallback(riderID, {'en', 'fr', 'de', 'es'})
return findLastName(label,wiki)
end
--all other cases
label = getLabelFallback(riderID)
return findLastName(label,wiki)
end
 
--== V) Main functions ==
--=== A) Function race reference ===
local function race_reference(raceID,lf)
-- Allow to display the reference below the classifications --
local bases={
Line 3.852 ⟶ 3.756:
{"Cycling Quotient", "P2648", "http://www.cqranking.com/men/asp/gen/race.asp?raceid="},
{"Cycling Archives", "P2330", "http://www.cyclingarchives.com/ritfiche.php?ritid="},
{"Cycling Quotient", "P2708", "http://www.cqranking.com/women/asp/gen/race.asp?raceid="},
-- cycling team
{"ProCyclingStats", "P2328", "http://www.procyclingstats.com/team/"},
{"Cycling Quotient", "P2649", ""}, --The entire link is indicated in full
{"Cycling Archives", "P2331", "http://www.cyclingarchives.com/ploegfiche.php?id="}
}
local links = {}
Line 3.860 ⟶ 3.768:
if p[1] and p[1].mainsnak.snaktype == 'value' then
if base[2]=="P2648" and p[1].mainsnak.datavalue.value=="1" then --code for general reference of results
ref=getReference(lf,p[1], 1)
if ref then table.insert(links, ref) end
else
Line 3.879 ⟶ 3.787:
function p.calendarcustom(frame)
local headers={2} --date
local calendarID, lf =get_and_checkID(frame)
 
if wiki == "ar" and string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
then frame = frame:getParent() end
 
if frame.args[1] ~= nil then calendarID = string.gsub(frame.args[1], "%c", "") end
 
local display_numbering=false --default
local country_column=2
if istrue(frame.args[get_arg('display_numbering'],frame)) then
display_numbering=true
table.insert(headers, 3)
Line 3.894 ⟶ 3.798:
--no_country modify the way the country is displayed
local no_country={}
if istrue(frame.args[get_arg('no_country'],frame)) or wiki == "ar" then
no_country={wiki}
end
Line 3.903 ⟶ 3.807:
 
local display_class=false
if istrue(frame.args[get_arg('display_class'],frame)) or wiki == "ar" then
display_class=true
table.insert(headers, 6)
Line 3.910 ⟶ 3.814:
table.insert(headers, 7) --winner
local only_winner=1
if istrue(frame.args[get_arg('podium'],frame)) or wiki == "ar" then
only_winner =0
table.insert(headers, 8) --second
Line 3.917 ⟶ 3.821:
local display_leader=false
if istrue(frame.args[get_arg('display_leader'],frame)) then
display_leader=true
table.insert(headers, 10)
end
local display_team =false
if istrue(frame.args[get_arg('display_team'],frame)) then
display_team =true
end
Line 3.931 ⟶ 3.835:
end
local womenrace_boolw_race=isWomenrace(calendarID)
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 3.944 ⟶ 3.848:
only_winner = only_winner,
display_numbering = display_numbering,
error_message = 0,
displayed_class =nil,
display_team=display_team,
display_class=display_class,
display_leader= display_leader,
framew_race=framew_race,
lf=lf
womenrace_bool=womenrace_bool
}
return calendar_main(s, tableA(s))
Line 3.959 ⟶ 3.862:
----- based on WWTcalendar function -----
----- author: Mr. Ibrahem -----
local calendarID --determined later
iflocal wikilf == "ar" then get_lf(frame = frame:getParent() end
local UCI = data.UCIYearToQ
Line 3.967 ⟶ 3.870:
local header_1_number = 12
local tempdic, year, keyk, yeary
local tempdic1 = {
header_2 = {2, 3,5, 4, 7, 8, 9, 10},
Line 3.986 ⟶ 3.889:
 
for key, v in pairs(UCI) do
year = get_arg(key,frame) --with lf does not work
if not calendarID and frame.args[key] then
if not calendarID and year then
local year = frame.args[key]
year = string.gsub(year , "%c", "")
if v[year] then
calendarID = v[year]
header_1_number = header_1_tab[key]
display_code = display_code_tab[key]
keyk=key
yeary=year
end
end
Line 4.007 ⟶ 3.911:
if display_code == 1 then
tempdic=tempdic1
if keyk=="UWT" and tonumber(yeary) > 2018 then
tempdic.display_leader=false --no more leader after 2018
tempdic.header_2 ={2, 3,5, 4, 7, 8, 9}
end
else
tempdic=tempdic2
end
if istrue(frame.args[get_arg('display_numbering'],lf)) then
tempdic.display_numbering=true
elseif frame.args[get_arg('display_numbering'],lf) and istrue(frame.args[get_arg('display_numbering'],lf)) == nil then
tempdic.display_numbering=false
end
local womenrace_boolw_race=isWomenrace(calendarID)
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 4.028 ⟶ 3.936:
only_winner = tempdic.only_winner,
display_numbering = tempdic.display_numbering,
error_message = 0,
displayed_class = nil, --all
display_team=tempdic.display_team,
display_class=tempdic.display_class,
display_leader=tempdic.display_leader,
framew_race=framew_race,
lf=lf
womenrace_bool=womenrace_bool
}
return calendar_main(s, tableA(s))
Line 4.040 ⟶ 3.947:
 
function calendar_main(s, resultTable)--Display the UCI women calendar of one year
local lf = s.lf
localframe=s.frame
local calendarID=s.item
local fn_racetable,fn_datetable, fn_countrytable
local t_Body ={}
local womenrace_boolw_race=isWomenrace(calendarID)
 
local temp=firstValue(calendarID, s.property)
if not temp then s.error_messageor temp=="" 2 return ''then end
s.error_message = 2
 
if wiki == "ar" then return "" end
end
local country=getCountryBool(s.no_country)
if available_list==false then country=false end --otherwise the display put no "country" column...
 
----- Begin of the main part of the code
Line 4.056 ⟶ 3.963:
local RaceID = p527.mainsnak.datavalue.value.id
---- Create a row ----
fn_datetablelocal timeOfRace, date_tCell, date_sortkey = fn_date(RaceID)
fn_racetablelocal parentID, race_tCell, class_tCell= fn_race(RaceID,s.displayed_class,s.display_class,fn_datetable["timeOfRace"],nil,country)
 
if fn_racetable["raceCell"]race_tCell~=nil then --otherwise the class is not display
local country_flag, country_name, country_tCell=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
fn_countrytable=fn_country(RaceID,
--create the table
fn_datetable["timeOfRace"],
country,
fn_racetable["raceCell"],
fn_racetable["parentID"]
)
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
tRow:node(date_tCell)
 
tRow:node(fn_datetable["tCell"])
if s.display_numbering == true then
tRow:tag('td'):cssText("text-align:center;padding:0 0.5em"):wikitext(tostring(kk))
end
tRow:node(country_tCell)
if country then tRow:node(fn_countrytable["tCell"]race_tCell) end
if countryclass_tCell then tRow:node(class_tCell) end
local rider_tCell =fn_rider(lf,RaceID,timeOfRace,s.display_team,s.only_winner)
tRow:node(fn_racetable["raceCell"])
tRow:node(rider_tCell)
end
if fn_racetable["classCell"] then tRow:node(fn_racetable["classCell"]) end --class
local tCell, _ =fn_rider(RaceID,fn_datetable["timeOfRace"],s.display_team,s.only_winner)
tRow:node(tCell)
if s.display_leader==true then
tRow:node(local leader_tCell=fn_rider(lf,RaceID,fn_datetable["timeOfRace"],s.display_team,3))
tRow:node(leader_tCell)
end
---- Add the row to the table
table.insert(t_Body[#t_Body + 1] =, {fn_datetable["sortkey"]=date_sortkey, body=tRow})
end
end
 
return sortAndConcat(t_Body, resultTable)
end
Line 4.094 ⟶ 3.992:
function p.nationalchampionships(frame)
local calendarroadID, calendarITTID, year
local lf=get_lf(frame)
if wiki == "ar" then
local listOfCalendar={data.NationalRoadCyclingChampionships,data.NationalITTCyclingChampionships}
frame = frame:getParent()
end
local listOfCalendar={NationalRoadCyclingChampionships,NationalITTCyclingChampionships}
 
for ii, thisCalendar in pairs(listOfCalendar) do --road/ITT
for key, v in pairs(thisCalendar) do --look for the key of the dictionnary, here women/men
year = get_arg(key,frame) --with lf does not work
if ((ii==1 and calendarroadID==nil) or (ii==2 and calendarITTID ==nil)) and frame.args[key] then
if ((ii==1 and calendarroadID==nil) or (ii==2 and calendarITTID ==nil)) and year then
year = frame.args[key]
year = string.gsub( year , "%c", "")
if v[year] then
if ii==1 then
Line 4.115 ⟶ 4.010:
end
local womenrace_boolw_race=isWomenrace(calendarroadID)
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 4.128 ⟶ 4.023:
year = year,
no_country = {}, --no sense here to hide the country
error_message = 0,
display_team = true,
display_countrylink = truefalse, --too expensive
frame w_race= framew_race,
lf=lf
womenrace_bool=womenrace_bool
}
return nationalchampionships_main(s,tableA(s))
Line 4.138 ⟶ 4.032:
 
function nationalchampionships_main(s, resultTable)--Display the list of national champions for one year
local lf = s.lf
localframe=s.frame
local tableChamp, fn_countrytable, t_Body = {}, {}, {}
local timeOfRace ='+'..tostring(s.year).."-01-01T00:00:00Z"
local tRacerider_tCell, thereisawinner, parentID, parentParentID, sitelink
local country_flag, country_name, country_tCell
 
local temp=firstValue(s.calendarroadID, s.property)
if not temp then else s.error_messageor temp=="" 2 return ''then end
s.error_message = 2
if wiki == "ar" then return "" end
end
 
local listOfCalendarID={s.calendarroadID, s.calendarITTID}
Line 4.153 ⟶ 4.051:
for _, p527 in statements(thisCalendarID, 'P527') do
thisID = p527.mainsnak.datavalue.value.id
fn_countrytablecountry_flag, country_name, country_tCell=fn_country(thisID,timeOfRace,s.country)
if country_name == nil then country_name="country not found" end
sortkey=string.gsub(fn_countrytable["countryname"], 'É', 'E') --case États Unis
sortkey=string.gsub(country_name, 'É', 'E') --case États Unis
 
--create the table
if tableChamp[sortkey]==nil then
tableChamp[sortkey]={}
tableChamp[sortkey]['countryname']=fn_countrytable["countryname"] --rawcountry_name
tableChamp[sortkey]['roadwinner']='<td></td>'
tableChamp[sortkey]['ITTwinner']='<td></td>'
Line 4.172 ⟶ 4.070:
end
tableChamp[sortkey]['sitelink']=sitelink
tableChamp[sortkey]['flag']=fn_countrytable["flag"]country_flag
end
--fill the table
tRacerider_tCell, thereisawinner=fn_rider(lf,thisID,timeOfRace,s.display_team,1,true)
if tableChamp[sortkey]['thereisawinner']~=true then --all other cases
tableChamp[sortkey]['thereisawinner']=thereisawinner
Line 4.182 ⟶ 4.080:
if ii==1 then
tableChamp[sortkey]['roadwinner']=tRacerider_tCell
else
tableChamp[sortkey]['ITTwinner']=tRacerider_tCell
end
end
Line 4.201 ⟶ 4.099:
tRow:node(thisRow['roadwinner'])
tRow:node(thisRow['ITTwinner'])
table.insert(t_Body[#t_Body + 1], {sortkey= {key, body=tRow})
end --no winner
end --end list of key
Line 4.210 ⟶ 4.108:
--=== C) Victory ===
function p.victories(frame)
local IDtemptempID, lf=get_and_checkID(frame.args[1])
local womenrace_boolw_race=isWomenrace(IDtemptempID)
local s = {
Line 4.221 ⟶ 4.119:
country_column = 3,
data_sort_type = {'', 'unsortable', '', '', ''}, -- see https://meta.wikimedia.org/wiki/Help:Sorting
item = IDtemptempID,
property = 'P2522',
no_country = no_country_victories,
lf=lf,
error_message = 0,
w_race=w_race
frame=frame,
womenrace_bool=womenrace_bool
}
return victory_main(s ,tableA(s))
Line 4.232 ⟶ 4.129:
 
function victory_main(s, resultTable)
local lf = s.lf
localframe=s.frame
local _
_, _, s.item = string.find(s.item, "(%w+)")
 
local temp=firstValue(s.item, s.property,'id')
if not temp then else s.error_messageor temp=="" 2 return ''then end
s.error_message = 2
if wiki == "ar" then return "" end
end
 
local country=getCountryBool(s.no_country)
if available_list==false then country=false end
 
local sortkey
local t_Body = {}
 
Line 4.249 ⟶ 4.146:
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
 
fn_datetablelocal timeOfRace, date_tCell, date_sortkey = fn_date(RaceID, 'victory')
fn_racetablelocal parentID, race_tCell, class_tCell=fn_race(RaceID,nil ,true,fn_datetable["timeOfRace"], 'victory',country)--displayed_class=nil
if fn_racetable["raceCell"]race_tCell~= nil then --otherwise class not to be displayed
fn_countrytablecountry_flag, country_name, country_tCell=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
--Build the table
fn_datetable["timeOfRace"],
tRow:node(date_tCell)
country,
fn_racetable["raceCell"],
fn_racetable["parentID"]
)
tRow:node(fn_datetable["tCell"])
if country==true then
tRow:node(fn_racetable["raceCell"]race_tCell) --race site link is in fn_countrytable
end
tRow:node(fn_countrytable["tCell"]country_tCell)
tRow:node(fn_racetable["classCell"]class_tCell) --class
tRow:node(local rider_tCell =fn_rider(lf,RaceID,fn_datetable["timeOfRace"],false,1))
tRow:node(rider_tCell)
t_Body[#t_Body + 1] = {fn_datetable["sortkey"], tRow}
table.insert(t_Body, {sortkey=date_sortkey, body=tRow})
end --no winner
end --end list of key
Line 4.276 ⟶ 4.169:
--== D) Stage infobox
function p.stageinfobox(frame)
local entityIDstageID, lf = mw.text.trimget_and_checkID(frame.args[1])
local w_race=isWomenrace(stageID)
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
local womenrace_bool=isWomenrace(entityID)
local details = {
{ name = translate("stageinfobox",2,womenrace_boolw_race)}, -- course / not used
{ name = translate("stageinfobox",2,womenrace_boolw_race)}, -- competition
{ name = translate("stageinfobox",3,womenrace_boolw_race), name_plural = translate("infobox",4,womenrace_boolw_race)}, -- stage type
{ name = translate("stageinfobox",4,womenrace_boolw_race), name_plural = translate("infobox",7,womenrace_boolw_race)}, -- date
{ name = translate("stageinfobox",6,womenrace_boolw_race)}, -- distance
{ name = translate("stageinfobox",7,womenrace_boolw_race), name_plural = translate("infobox",10,womenrace_boolw_race)}, -- country
{ name = translate("stageinfobox",9,womenrace_boolw_race)}, -- start place
{ name = translate("stageinfobox",10,womenrace_boolw_race)}, -- endplace
{ name = translate("stageinfobox",11,womenrace_boolw_race)}, -- participants at start
{ name = translate("stageinfobox",12,womenrace_boolw_race)}, -- participants at end
{ name = translate("stageinfobox",13,womenrace_boolw_race)}, -- speed
{ name = translate("stageinfobox",44,womenrace_boolw_race)}, -- elevation
{ name = translate("infobox",32,womenrace_boolw_race), special = true}, -- special 1
{ name = translate("infobox",33,womenrace_boolw_race), special = true}, -- special 2
}
local others = {
{ name = translate("infobox",29,womenrace_bool)}, -- picture
{ name = translate("infobox",30,womenrace_bool)}, -- caption
{ name = translate("infobox",31,womenrace_bool)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,womenrace_bool)}, -- caption map
{ name = translate("infobox",30,womenrace_bool)}, -- caption sectional
}
local others = get_others_dic()
--begin of the function
local t_P642t_Of = {
Q20882747={'results', 'first'},
Q20882748={'results', 'second'},
Line 4.346 ⟶ 4.229:
}
getLocalContent(details, lf.args)
local localframe
getLocalContent(others, lf.args)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
 
local timeOfRace
local temp = firstValue(entityIDstageID, 'P31','id')
icon = ''
if temp and temp ~= 'Q18131152' then
Line 4.365 ⟶ 4.241:
icon = " [[File:Cycling (road) pictogram.svg|35px]]"
end
details[3].content = typeofstagelogo(entityIDstageID, true).." "..WPlinkpure(temp)
end
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}stageID) or ''
if wiki == 'fr' and name ~= nil then
name= mw.ustring.gsub(name, "^(%d+)([re]+)", "%1<sup>%2</sup> ")
Line 4.374 ⟶ 4.250:
name= mw.ustring.gsub(name, "^(%a)",function (x) return mw.ustring.upper(x) end)
infoGetOthers(others, entityIDstageID)
 
--name
local race={}
if course==nil then
temp = firstValue(entityIDstageID, 'P1545')
if temp then
details[2].content =getStageLabel(temp)
raceId = getParentID(stageID) --for instance Tour de France 2020
raceId = firstValue(entityID, 'P361','id')
if raceId then
details[2].content = (details[2].content or '') .. '، '.. WPlinkpure(raceId)
for k, p31 in statements(raceId, 'P31') do --get Tour de France
if race==nil then race={} end
race[k] = p31.mainsnak.datavalue.value.id --for the jersey
end
Line 4.393 ⟶ 4.270:
 
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(entityIDstageID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[4].content = funcDate(pTime, 'long')
Line 4.400 ⟶ 4.277:
local kmdistance
if not details[5].content then details[5].content, kmdistance = getDistance(entityIDstageID, true) end -- distance
infoGetCountry(details,6, entityIDstageID, timeOfRace)
infoGetStartEnd(details,7, entityIDstageID, timeOfRace)
infoGetParticipants(details,9, entityIDstageID)
if not details[11].content then details[11].content = getSpeed(entityIDstageID, true, kmdistance, 'P2417') end --speed
if not details[12].content then
local elevation=getElevation(entityIDstageID)
if elevation ~= nil then details[12].content =elevation else details[12].content = nil end
end --Elevation
Line 4.452 ⟶ 4.329:
 
--Winner
for _, p1346 in statements(entityIDstageID, 'P1346') do
local id_speed, id_time, id_time_gap, id_points_a, id_points_b, type_ofclas, name_ofclas
local q = p1346.qualifiers
Line 4.466 ⟶ 4.343:
local riderLink,riderTeam = subwinner(riderId, timeOfRace, q) --sub function to avoid code in double
-- looks into race item if the winner has a P642 statement for showing the type of winner(points, mountain, ..)
propertyOf=nil
if q.P642 and q.P642[1].snaktype == 'value' then
if q.P2501 and q.P2501[1].snaktype == 'value' then
for _, vv in pairs(q.P642) do
propertyOf=q.P2501
elseif q.P642 and q.P642[1].snaktype == 'value' then --fallback
propertyOf=q.P642
end
 
if propertyOf and propertyOf[1].snaktype == 'value' then
for _, vv in pairs(propertyOf) do
local qual = vv.datavalue.value.id
if qual~=nil and deprecated~='deprecated' and t_P642t_Of[qual] then
if qual=="Q21686770" and t_s['results']['winner_fighting'][1] ~= "" then
t_P642t_Of[qual][2] = 'winner_fighting2'
end
type_ofclas=t_P642t_Of[qual][1] --annex or gen
name_ofclas=t_P642t_Of[qual][2] --name of ranking
local v=t_s[type_ofclas][name_ofclas]
 
Line 4.498 ⟶ 4.382:
end
local rank, deprecated, prop, order, thisorder
local listoftable = {'results','gen'}
 
-- look into P2417, stage classification, then p2321 gen classification
for ii, thistable in ipairs(listoftable{'results','gen'}) do
if ii==1 then
prop='P2417'
Line 4.510 ⟶ 4.393:
end
for _, p2417 in statements(entityIDstageID, prop) do
local q = p2417.qualifiers
if q.P1352 and q.P1352[1].snaktype == 'value' then
Line 4.536 ⟶ 4.419:
end
 
listoftable=for _, thistable in ipairs({t_s.results,t_s.gen,t_s.annex}) do
for _, thistable in ipairs(listoftable) do
for _, v in ipairs(thistable.order) do --order is the list of all classification names
if thistable[v]['link'] then
Line 4.551 ⟶ 4.432:
if t_s.annex.show == true and (wiki == 'no' or wiki == '..') then width= '340px' end
tab= infoInitTab(width, name, icon)
infoFillOthersDetails(tab, others, details,translate("stageinfobox",1,womenrace_boolw_race))
 
-- ranking table, general and stage
Line 4.561 ⟶ 4.442:
tTab=tCell:tag('table'):attr('cellpadding','0'):attr('cellspacing','0'):css('width','100%')
tCell=tTab:tag('tr'):tag('td'):attr('colspan','3')
:cssText('border-bottom:5px solid #fff2cc'..backgroundColorLight..'; background-color:#FFE7A0'..backgroundColor..'; text-align:center')
:css('font-weight','bold')
:wikitext(translate("stageinfobox",thistable.header,womenrace_boolw_race))
 
for key, value in ipairs(thistable.order) do --value is the name of the class
Line 4.576 ⟶ 4.457:
else
local lang = mw.language.getContentLanguage()
v['speed'] = '('.. lang:formatNum(v['speed'])..translate("unit",5,womenrace_boolw_race)..')'
end
end
if v['points'] then
if v['points'] > 1 then
temp=translate("unit",7,womenrace_boolw_race)
else
temp=translate("unit",6,womenrace_boolw_race)
end
v['points'] = v['points']..temp
end
local title, k = string.gsub(translate("stageinfobox",v['translation'],womenrace_boolw_race), " ", "&nbsp;")
if k > 0 then title = string.gsub(title, "&nbsp;", "<br>", 1) end --&#32;
Line 4.597 ⟶ 4.478:
tCell:attr('rowspan','2')
end
tCell:cssText("width:1%;background-color:#fff2cc"..backgroundColorLight..";text-align:" ..
textalign .. ";padding:0 2px 0 2px;white-space:nowrap")
Line 4.603 ⟶ 4.484:
if v['jersey'] == nil then
if (value_order=='results') and (value=='winner_fighting' or value=='winner_fighting2' or value=='cima_coppi' or value=='cima_pantanii') then
tCell:wikitext(translate("stageinfobox",v['translation'],womenrace_boolw_race))
else
tCell:wikitext(number(v['genre'], key, wiki))
end
else
temp=''
if jerseyWPID=~='' then
temp=''
else
temp="|link="..jerseyWPID
end
Line 4.667 ⟶ 4.547:
infoFillOthersMap(tab, others)
tab:node(getPreviousNextLine(entityIDstageID,true))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox", translate("stageinfobox",39,womenrace_boolw_race), frame.args[1]stageID)
return tab
end
Line 4.674 ⟶ 4.554:
--== E) List of teams
function p.listofteams(frame)
local raceID, lf = get_and_checkID(frame.args[1])
local teams = {} -- values will be {teamLink, teamCat, sortkey, index}
local WDlink_on = (wiki == "mk" or wiki == "ja")
 
local timeOfRace, errorMessage = getTimeOfRace(raceID, true)
local w_race=isWomenrace(raceID)
if not timeOfRace then return errorMessage end
local teamCats_lot = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
local womenrace_bool=isWomenrace(raceID)
-- Part of the numbering is omitted for the convenience of possible subsequent editing.
 
-- UCI professional men's teams
local teamCats = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
["Q6154783"] = {4,5,1}, -- WorldTeam
["Q80425135Q20638319"] = {46,57,2}, -- UCIProTeam Women’s WorldTeam(2005-2014)
["Q20638319Q78464255"] = {6,7,3}, -- ProTeam (20052020-2014)
["Q78464255Q382927"] = {68,79,4}, -- ProTeamUCI Professional Continental Team (20202005-2019)
["Q382927Q1756006"] = {810,911,5}, -- UCI Professional Continental Team (2005-2019)
["Q1756006Q20639847"] = {1016,1117,6}, -- UCIprofessional Continentalcycling Teamteam
["Q20639847Q20653563"] = {1620,1721,7}, -- professionalGroupe cyclingSportif team I
["Q20653563Q20653564"] = {2022,2123,8}, -- Groupe Sportif III
["Q20653564Q20653566"] = {2224,2325,9}, -- Groupe Sportif IIIII
-- UCI professional women's teams
["Q20653566"] = {24,25,10}, -- Groupe Sportif III
["Q2466826Q80425135"] = {2857,2958,11}, -- UCI Women’s TeamWorldTeam
["Q23726798Q130604574"] = {1259,1360,12}, -- nationalUCI cyclingWomen’s teamProTeam
["Q99658502Q119942457"] = {1232,1333,13}, -- nationalUCI cyclingWomen's teamContinental "B"Team (2020-)
["Q20738667Q2466826"] = {1228,1329,14}, -- nationalUCI cyclingWomen’s teamTeam U23(-2019)
["Q54555994Q119948768"] = {1255,1356,15}, -- nationalUCI cyclingWomen's teamElite-2 U19 Team
-- other non-road UCI teams
["Q28492441"] = {12,13,16}, -- national cycling team with sponsor name
["Q20652655Q2466819"] = {1845,1946,1721}, -- amateurUCI cyclingTrack teamTeam
["Q26849121Q39885628"] = {3047,3148,1822}, -- Women's amateurUCI cyclingCyclocross teamTeam
["Q20639848Q2466804"] = {1449,1550,1923}, -- club and regionUCI cyclingMTB teamTeam
["Q20653570Q39885630"] = {1451,1552,2024}, -- club and regionUCI cyclingBMX teamTeam
-- national teams (partially merged)
["Q54660600"] = {12,13,31}, -- national cycling team "any", without specifying additional parameters"
["Q23726798"] = {12,13,31}, -- national cycling team Elit
["Q99658502"] = {12,13,31}, -- national cycling team "B"
["Q20738667"] = {12,13,31}, -- national cycling team U23
["Q54555994"] = {12,13,31}, -- national cycling team U19
["Q26213387"] = {12,13,31}, -- olympic team
["Q46135307"] = {12,13,31}, -- nation at sport competition in multisport games
["Q28492441"] = {39,40,32}, -- national cycling team with sponsor name
["Q117280678"] = {37,38,33}, -- mixt cycling team
-- Below are two blocks with "non-professional" teams. They differ in the type of output - individually or all together. You can choose any manual setting.
-- amateur, club and region (not merged). Each type of team is output in a separate block
["Q114864716"] = {43,44,41}, -- DCU Elite Team
["Q20652655"] = {18,19,42}, -- amateur cycling team
["Q26849121"] = {30,31,43}, -- Women's amateur cycling team
["Q20639848"] = {14,15,44}, -- club cycling team
["Q20653570"] = {53,54,45}, -- region cycling team
-- amateur, club and region (merged). All types of team are displayed in a common block
-- ["Q114864716"] = {41,42,41}, -- DCU Elite Team
-- ["Q26849121"] = {41,42,41}, -- Women's amateur cycling team
-- ["Q20652655"] = {41,42,41}, -- amateur cycling team
-- ["Q20639848"] = {41,42,41}, -- club cycling team
-- ["Q20653570"] = {41,42,41}, -- region cycling team
}
 
Line 4.711 ⟶ 4.614:
if v.mainsnak.snaktype == 'value' then
no = no + 1
local teamLink, teamCat, countryID = getTeamLinkCat(v.mainsnak.datavalue.value.id, timeOfRace, true, true)
local flagImage = countryID and flag(countryID, timeOfRace) or ''
teams[#teams + 1] = {flagImage .. ' ' .. teamLink, teamCat,
teamCatsteamCats_lot[teamCat] and teamCatsteamCats_lot[teamCat][3] or 999, no}
end
end
 
table.sort(teams, function(a,b)
if a[3] < b[3] then return true end -- First sort key: Order from table teamCatsteamCats_lot
if a[3] > b[3] then return false end
return a[4] < b[4] -- Second key is the index to ensure stable sorting
Line 4.726 ⟶ 4.629:
local function getHeader(CatID, count)
local header, sitelink
if teamCatsteamCats_lot[CatID] then
local done=false
if CatID=="Q2466826" then --name changed after 2020
Line 4.732 ⟶ 4.635:
if year and year>2019 then
if count == 1 then
header_label = translate("headoftableIII",32, womenrace_boolw_race) -- singular name
else
header_label = translate("headoftableIII",33, womenrace_boolw_race) -- plural name
end
done=true
Line 4.742 ⟶ 4.645:
if done==false then
if count == 1 then
header_label = translate("headoftableIII",teamCatsteamCats_lot[CatID][1], womenrace_boolw_race) -- singular name
else
header_label = translate("headoftableIII",teamCatsteamCats_lot[CatID][2], womenrace_boolw_race) -- plural name
end
end
Line 4.763 ⟶ 4.666:
if not header then
-- Unknown team category. Get the label for the entity to display if possible
header = (CatID and getLabelFallback(CatID, {wikilang, 'en', 'fr', 'de'})) or 'Unknown team category'
tHeader:css('text-transform','capitalize')
end
Line 4.825 ⟶ 4.728:
--== F) Classifications
function p.UCIclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 19, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item =tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P3494', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_team=false,
max_rank_displayed=1000100000, --unlimited the whole team must be displayed
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.pointsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 10, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P3494', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.teamsclassificationbytime(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 14, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4}, -- translations 3, 2, 4 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P3497', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = 'strong', -- there is no background color for the first row, but the first row is formated strong
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.teamsclassificationbypoints(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 15, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 7}, -- translations 3, 2, 7 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P3496', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = 'strong', -- there is no background color for the first row, but the first row is formated strong
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.stageclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 8, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 4 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P2417', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = false, -- there is no background color for the first row
display_ref = tonumberget_arg(frame.args[2], frame,true) == 0 and 0 or 1,
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.generalclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 4 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P2321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_ref = tonumberget_arg(frame.args[2], frame,true) == 0 and 0 or 1,
max_rank_displayed=25,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.generalclassificationpoint(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P2321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
display_ref = tonumberget_arg(frame.args[2], frame,true) == 0 and 0 or 1,
max_rank_displayed=25,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.generalclassificationforttt(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 9, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P2321', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = false, -- there is no background color for the first row
display_ref = tonumberget_arg(frame.args[2], frame,true) == 0 and 0 or 1,
max_rank_displayed=1025,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.teamtimetrialclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 8, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {3, 2, 4, 5, 6}, -- translations 3, 2, 4, 5, 6 in function headoftableII are printed in this order in the lower part of the table header
item = frame.args[1]tempID,
property = 'P2417', -- property to use for this table
team_classification = true, -- it is a team classification table, its not a rider classification table
background = false, -- there is no background color for the first row
display_ref = tonumberget_arg(frame.args[2], frame,true) == 0 and 0 or 1,
max_rank_displayed=25,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.mountainsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 11, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4320', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.sprintsclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 12, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4322', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.intermediatesprintclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 20, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
property = 'P4958', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(s, frame)
end
 
function p.bestyoungclassificationbypoints(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4323', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.bestyoungclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 13, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4323', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.u23classification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 18, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4323', -- property to use for this table (same as best young classification)
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.combinationclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 16, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4324', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.combativeclassification(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_1 = 17, -- translation 10 in function headoftableII is printed in the upper part of the table header
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = 'P4321', -- property to use for this table
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.custompointsclassification(frame)
local tempID, lf=get_and_checkID(frame)
 
local team_title
local temp=get_arg(4,frame)
if frame.args[4] and string.find(frame.args[4],"{{{")==nil then team_title=string.gsub(frame.args[4], "%c", "") end
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {1, 2, 3, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=string.gsubget_arg(frame.args[3],frame) "%c",or "")'', --with lf does not work
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = string.gsubget_arg(frame.args[2], "%c", ""frame), -- property to use for this table
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
function p.customtimeclassification(frame)
local tempID, lf=get_and_checkID(frame)
 
local team_title
local temp=get_arg(4,frame)
if frame.args[4] and string.find(frame.args[4],"{{{")==nil then team_title=string.gsub(frame.args[4], "%c", "") end
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {1, 2, 3, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=string.gsubget_arg(frame.args[3],frame) "%c",or "")'',
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
property = string.gsubget_arg(frame.args[2], "%c", ""frame), -- property to use for this table
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = false, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(frames, sframe)
end
 
 
function new_classification(frame, s)
function p.customteamclassificationbypoints(frame)
local country = true
local tempID, lf=get_and_checkID(frame)
for _, value in pairs(no_country_classification) do -- get data if country should be printed in this wiki
 
if value == wiki then country = false end
local team_title
local temp=get_arg(4,frame)
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {3, 2, 7}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=get_arg(3,frame) or '', --with lf does not work
item = tempID,
property = get_arg(2,frame), -- property to use for this table
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = true, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(s, frame)
end
 
function p.customteamclassificationbytime(frame)
local tempID, lf=get_and_checkID(frame)
 
local team_title
local temp=get_arg(4,frame)
if temp and string.find(temp,"{{{")==nil then
team_title=temp
end
local s = {
header_function = "headoftableII", -- translations are in function headoftableII
header_2 = {3, 2, 4}, -- translations 1, 2, 3, 7 in function headoftableII are printed in this order in the lower part of the table header
header_1_text=get_arg(3,frame) or '', --with lf does not work
item = tempID,
property = get_arg(2,frame), -- property to use for this table
team_title=team_title, --for old races where there was no team, only bike brands
team_classification = true, -- it is not a team classification table, its a rider classification table
background = 'color', -- there is a background color for the first row
max_rank_displayed=10,
lf=lf
}
return new_classification(s, frame)
end
 
function new_classification(s, frame)
local country = getCountryBool(no_country_classification)
local lf = s.lf
local raceID = s.item
local womenrace_boolw_race=isWomenrace(raceID)
 
--[=[ It is possible to give the classification tables in the article commands to change the standard behaviour. They could look like this:
Line 5.114 ⟶ 5.124:
]=]
 
local timeOfRace, errorMessage = getTimeOfRace(raceID, true)
if not timeOfRace then return errorMessage end
 
local plus = ''
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
then localframe = frame:getParent() else localframe = frame end
if localframe.args[1] ~= nil then localframe.args[1] = string.gsub(localframe.args[1], "%c", "") end
 
if localframe.args.get_arg('country ',frame)~= nil then -- switch country column on or off in the article
if localframe.args.get_arg('country',frame) == 'true' and l10n["country_name_list"] then country = true end
if localframe.args.get_arg('country',frame) == 'false' then country = false end
end
local tableHeader2_size = #s.header_2
local max_rank_displayed=s.max_rank_displayed
for _, p31 in statements(raceID, 'P31') do
if localframe.args['max_rank_displayed'] and localframe.args['max_rank_displayed'] ~= '' then
if data.stages[p31.mainsnak.datavalue.value.id] then
max_rank_displayed=tonumber(localframe.args['max_rank_displayed'])
max_rank_displayed=10 --limit general ranking to 10 except for not stage
end
end
local temp=get_arg('max_rank_displayed',frame)
if temp and temp~='' and string.find(temp,"{{{")==nil then
max_rank_displayed=tonumber(temp)
end
 
if s.header_1_text ==nil then s.header_1_text=translate(s.header_function,s.header_1,womenrace_boolw_race) end --for custom title
local team_translation_index=3
if s.team_title == nil then s.team_title=translate(s.header_function,team_translation_index,womenrace_boolw_race) end --translation for team has index "3"
local tableBody = mw.html.create('table')
Line 5.156 ⟶ 5.168:
header= tableBody:tag('tr'):cssText("text-align:center;padding:2px 2px;white-space:nowrap")
for i, k in ipairs(s.header_2) do
if i ~= 2 or (country and available_list) then
local header_text
if k == team_translation_index then --for team
header_text=s.team_title
else
header_text=translate(s.header_function,k,womenrace_boolw_race)
end
local head =header:tag('th'):wikitext(header_text)
Line 5.192 ⟶ 5.204:
if q.P1534 and q.P1534[1].snaktype == 'value' then
local dnf=q.P1534[1].datavalue.value.id
if dnf=='Q1210380' then riderDNF =translate("startlist",6,womenrace_boolw_race)--"HD","NP","DQ"
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7,womenrace_boolw_race)
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8,womenrace_boolw_race)
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9,womenrace_boolw_race)
else riderDNF=''
end
Line 5.228 ⟶ 5.240:
teamLink, _, countryID = getTeamLinkCat(riderID, timeOfRace, true)
else
riderLink = getRiderLink(riderID,timeOfRace)..(getReference(lf,m) or '')
teamLink = getTeam(riderID, timeOfRace, q)
countryID = getNationality(riderID, timeOfRace,q)
Line 5.234 ⟶ 5.246:
if countryID then
flagLink = flag(countryID, timeOfRace)
if available_list and country then
countryName = getCountryName(countryID)
if type(translations.list) == "function" then
countryName = translations.list(countryID)
end
if countryName == '' then
local label, lang = mw.wikibase.getLabelWithLang(countryID)
--[[ Uses standard language fallback. Should not be nil, as all countries have English labels. ]]
if lang == wikilang then
countryName = label
else
countryName = label .. ' (' .. lang .. ')'
end
end
end
end
Line 5.255 ⟶ 5.256:
if h.jersey[1] then
for _, jersey in pairs(h.jersey) do
if data.bg_color_table[jersey] then
bg_color = data.bg_color_table[jersey]
break
end
Line 5.280 ⟶ 5.281:
 
if not s.team_classification then
if not teamLinkcountry then teamLink = '' end
tCell:wikitext(riderLink .. jersey(h.jersey) )
if not available_list then
tCelltBody:tag('td'):wikitext( flagLink .. ' '.. riderLink .. jersey(h.jersey)countryName)
if s.display_team~=false then
tBody:tag('td'):wikitext(teamLink)
end
else
tCell:wikitext(flagLink .. ' ' .. riderLink .. jersey(h.jersey))
if country == true then
end
tCell:wikitext(riderLink .. jersey(h.jersey) )
if s.display_team~=false then
tBody:tag('td'):wikitext( flagLink ..' '.. countryName)
tBody:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.2em 0 0.2em")
else
tCell:wikitext(flagLinkteamLink ..or ' ' .. riderLink .. jersey(h.jersey))
end
if s.display_team~=false then
tBody:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.2em 0 0.2em")
:wikitext(teamLink)
end
end
else --team
if available_list==true and country then
tCell:wikitext(teamLink .. jersey(h.jersey))
tBody:tag('td'):wikitext(flagLink .. ' ' .. countryName)
Line 5.307 ⟶ 5.300:
end
 
if s.header_2[4] == 4 then -- for table stageclassification, generalclassification, adds time and time gap
if riderDNF=='' then
if rank == 1 and h.value[2] then
Line 5.330 ⟶ 5.323:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=translate("unit",7,womenrace_boolw_race)
else
temp2=translate("unit",6,womenrace_boolw_race)
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 5.363 ⟶ 5.356:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=translate("unit",7,womenrace_boolw_race)
else
temp2=translate("unit",6,womenrace_boolw_race)
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 5.380 ⟶ 5.373:
if type(h.value[4]) == "number" then
tCell:wikitext(mw.ustring.format('%.3f', h.value[4]))
:tag('span'):cssText("font-size:80%"):wikitext(translate("unit",5,womenrace_boolw_race))
end
end
Line 5.386 ⟶ 5.379:
if rank~='' and rank<=max_rank_displayed then --else no display
if riderDNF=='' then
table.insert(t_Body[#t_Body + 1], {sortkey= {(type(rank) == 'number') and rank or 999, body=tostring(tBody)})
else --disqualified should be higher than not disqualified if the ranking was revided
table.insert(t_Body[#t_Body + 1], {sortkey= {(type(rank) == 'number') and rank-0.1 or 999, body=tostring(tBody)})
end
end
Line 5.405 ⟶ 5.398:
:cssText("text-align:right")
tCell:tag('small')
:wikitext(race_reference(raceID,lf))
end
--general table style and last line
local tableStyle, tableNewline
if localframe.args.get_arg('newline',frame) == 'false' then -- parameter newline in WP article is 'false'
tableStyle = "float:" .. floattable .. "; margin-right:0.5em; border:1px solid rgb(200,200,200)"
tableNewline = ''
end
if localframe.args.get_arg('newline',frame) == 'true' then -- parameter newline in WP article is 'true'
tableStyle = "border:1px solid rgb(200,200,200)"
tableNewline = '<br style="clear:left;">'
end
if localframe.args.get_arg('newline',frame) == nil then -- no second parameter, compatible to the old code
if s.property == 'P2417' then --stageclassification
tableStyle = "float:"..floattable.."; margin-right:0.5em; border:1px solid rgb(200,200,200)"
Line 5.440 ⟶ 5.433:
 
--=== G) Infobox ===
function p.infobox(frame) -- normal infobox
return infobox_main(frame,0)
end
 
function p.infoboxseasonseasoninfobox(frame) -- season infobox
return infobox_main(frame,1)
end
 
function p.infoboxChampchampinfobox(frame) -- champ infobox
return infobox_main(frame,2)
end
 
function infobox_main(frame, selector)
localframe = frame
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
 
-- If true, winners will the team of the cyclist
local team = true
local details, others, winners, plural
local entityID, lf = mw.text.trimget_and_checkID(frame.args[1])
local w_race=isWomenrace(entityID)
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error ('parameter must be a valid Wikidata item (ex: Q42)') end
local womenrace_bool=isWomenrace(entityID)
if selector==0 then -- normal infobox
details = {
{ name = translate("infobox",2,womenrace_boolw_race)}, -- course
{ name = translate("infobox",3,womenrace_boolw_race), name_plural = translate("infobox",4,womenrace_boolw_race)}, -- competition
{ name = translate("infobox",5,womenrace_boolw_race)}, -- stages
{ name = translate("infobox",6,womenrace_boolw_race), name_plural = translate("infobox",7,womenrace_boolw_race)}, -- date
{ name = translate("infobox",8,womenrace_boolw_race)}, -- distance
{ name = translate("infobox",9,womenrace_boolw_race), name_plural = translate("infobox",10,womenrace_boolw_race)}, -- country
{ name = translate("infobox",11,womenrace_boolw_race)}, -- start place
{ name = translate("infobox",12,womenrace_boolw_race)}, -- endplace
{ name = translate("infobox",13,womenrace_boolw_race)}, -- teams
{ name = translate("infobox",14,womenrace_boolw_race)}, -- participants at start
{ name = translate("infobox",15,womenrace_boolw_race)}, -- participants at end
{ name = translate("infobox",16,womenrace_boolw_race)}, -- speed
{ name = translate("infobox",43,womenrace_boolw_race)}, -- elevation
{ name = translate("infobox",17,womenrace_boolw_race)}, -- cost
{ name = translate("infobox",32,womenrace_boolw_race), special = true}, -- special 1
{ name = translate("infobox",33,womenrace_boolw_race), special = true}, -- special 2
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
elseif selector==1 then -- season infobox
details = {
{ name = translate("infobox",46,womenrace_boolw_race)}, -- edition (1)
{ name = translate("infobox",3,womenrace_boolw_race), name_plural = translate("infobox",4,womenrace_boolw_race)}, -- competition (2)
{ name = translate("infobox",6,womenrace_boolw_race), name_plural = translate("infobox",7,womenrace_boolw_race)}, -- date (3)
{ name = translate("infobox",45,womenrace_boolw_race), name_plural=translate("infobox",71,w_race)}, -- rasing (4)
{ name = translate("infobox",47,womenrace_boolw_race), name_plural = translate("infobox",48,womenrace_boolw_race)}, -- location (country) (5)
{ name = translate("infobox",49,womenrace_boolw_race), name_plural = translate("infobox",50,womenrace_boolw_race)}, -- organizer (6)
{ name = translate("infobox",63,womenrace_boolw_race), name_plural = translate("infobox",63,womenrace_boolw_race)}, -- team class (7)
{ name = translate("infobox",32,womenrace_boolw_race), special = true}, -- special 1
{ name = translate("infobox",33,womenrace_boolw_race), special = true}, -- special 2
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
else -- champ infobox
details = {
{ name = translate("infobox",46,womenrace_boolw_race)}, -- edition (1)
{ name = translate("infobox",6,womenrace_boolw_race), name_plural = translate("infobox",7,womenrace_boolw_race)}, -- date (2)
{ name = translate("infobox",9,womenrace_boolw_race), name_plural = translate("infobox",10,womenrace_boolw_race)}, -- country (3)
{ name = translate("infobox",67,womenrace_boolw_race), name_plural = translate("infobox",68,womenrace_boolw_race)}, -- location (city) (4)
{ name = translate("infobox",61,womenrace_boolw_race), name_plural = translate("infobox",62,womenrace_boolw_race)}, -- arena / stadion (5)
{ name = translate("infobox",60,womenrace_boolw_race)}, -- medals (6)
{ name = translate("infobox",13,womenrace_boolw_race)}, -- team (7)
{ name = translate("infobox",49,womenrace_boolw_race), name_plural = translate("infobox",50,womenrace_boolw_race)}, -- organizer (8)
{ name = translate("infobox",32,womenrace_boolw_race), special = true}, -- special 1
{ name = translate("infobox",33,womenrace_boolw_race), special = true}, -- special 2
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
end
others = get_others_dic()
others = { --same for 3 infobox
{ name = translate("infobox",29,womenrace_bool)}, -- picture
{ name = translate("infobox",30,womenrace_bool)}, -- caption
{ name = translate("infobox",31,womenrace_bool)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,womenrace_bool)}, -- caption map
{ name = translate("infobox",30,womenrace_bool)}, -- caption sectional
}
 
if selector==0 then -- normal infobox
winners = {
{ name = translate("infobox",19,womenrace_boolw_race), QID = 'Q20882667' }, -- first
{ name = translate("infobox",20,womenrace_boolw_race), QID = 'Q20882668' }, -- second
{ name = translate("infobox",21,womenrace_boolw_race), QID = 'Q20882669' }, -- third
{ name = translate("infobox",22,womenrace_boolw_race), QID = 'Q20883007' }, -- points
{ name = translate("infobox",23,womenrace_boolw_race), QID = 'Q20883212' }, -- mountains
{ name = translate("infobox",24,womenrace_boolw_race), QID = 'Q20883328' }, -- sprints
{ name = translate("infobox",25,womenrace_boolw_race), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",26,womenrace_boolw_race), QID = 'Q101246973' }, -- supercombativity
{ name = translate("infobox",26,womenrace_boolw_race), QID = 'Q20893983' }, -- combativity
{ name = translate("infobox",35,womenrace_boolw_race), QID = 'Q27067359' }, -- volantes
{ name = translate("infobox",36,womenrace_boolw_race), QID = 'Q27067170' }, -- regularity
{ name = translate("infobox",27,womenrace_boolw_race), QID = 'Q20893979' }, -- combination
{ name = translate("infobox",38,womenrace_boolw_race), QID = 'Q27907715' }, -- breakaway
{ name = translate("infobox",39,womenrace_boolw_race), QID = 'Q27907747' }, -- azzurri
{ name = translate("infobox",40,womenrace_boolw_race), QID = 'Q28092831' }, -- rookie
{ name = translate("infobox",28,womenrace_boolw_race), QID = 'Q20882921' }, -- teams
{ name = translate("infobox",37,womenrace_boolw_race), QID = 'Q27104269' }, -- teamspoints
{ name = translate("infobox",41,womenrace_boolw_race), QID ='Q61976850' },-- amateur
{ name = translate("infobox",42,womenrace_boolw_race), QID ='Q61976872' } --nationality
}
elseif selector==1 then -- season infobox
winners = {
{ name = translate("infobox",52,womenrace_boolw_race), QID = 'Q20882667' }, -- individual (first)
{ name = translate("infobox",53,womenrace_boolw_race), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",54,womenrace_boolw_race), QID = 'Q27104269' }, -- team (teamspoints)
{ name = translate("infobox",55,womenrace_boolw_race), QID = 'Q98959152' }, -- team GS-I
{ name = translate("infobox",56,womenrace_boolw_race), QID = 'Q98959153' }, -- team GS-II
{ name = translate("infobox",57,womenrace_boolw_race), QID = 'Q98959155' }, -- team GS-III
{ name = translate("infobox",58,womenrace_boolw_race), QID = 'Q72068715' }, -- country
{ name = translate("infobox",59,womenrace_boolw_race), QID = 'Q72068724' } -- country U23
}
end -- Champ infobox has no winners
 
getLocalContent(details, lf.args)
local localframe
getLocalContent(others, lf.args)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
if selector==0 or selector==1 then
getLocalContent(winners, localframelf.args)
end
 
Line 5.573 ⟶ 5.551:
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
 
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
infoGetOthers(others, entityID)
 
Line 5.598 ⟶ 5.576:
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf ~= "Q27020041" and data.class_dic[instanceOf] then
class = classLinkFn(instanceOf)
break
Line 5.609 ⟶ 5.587:
is_a = raceLink(season)
else
--normally there should be only a p31
for _, p31 in statements(entityID, 'P31') do -- P31 is 'instance of'
local instanceOf = p31.mainsnak.datavalue.value.id
if instanceOf ~= 'Q27968055' and instanceOf ~= 'Q27020041' and class_dic[instanceOf] == nil then -- Q27020041 is 'sports season'
is_a = raceLink(instanceOf)
break
Line 5.651 ⟶ 5.630:
end
end
 
local index_date, index_official_site
if selector==0 then
index_date=4
index_official_site=17
elseif selector==1 then
index_date=3
index_official_site=10
else
index_date=2
index_official_site=11
end
 
-- if selector==0 or selector==1 then
if not details[index_date].content then -- date
details[index_date].content, timeOfRace, plural = get_formatted_date(entityID, 'infobox')
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
if plural then
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
if sTime and eTime then
local startTime, endTime = getStartEndTime(sTime, eTime)
details[index_date].content = startTime .. ' – ' .. endTime
details[index_date].name = details[index_date].name_plural
timeOfRace = eTime
else
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(entityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[index_date].content = funcDate(pTime, 'long')
timeOfRace = pTime
end
end
end
-- end
--from this point the functions differ fundamentally
Line 5.733 ⟶ 5.704:
if stages > 0 then
details[4].content = stages
if stages > 1 then
details[4].name = details[4].name_plural
end
end
end
Line 5.739 ⟶ 5.713:
end
if not details[6].content then -- organizer sitelink
listWPlink(details, 6, entityID,'P644P664',true) --org
end
if not details[7].content then -- organizer sitelink
Line 5.765 ⟶ 5.739:
end
if not details[8].content then -- organizer sitelink
listWPlink(details, 8, entityID,'P644P664',true) --org
end
end
 
if not details[index_official_site].content then
details[index_official_site].content = officialSite(entityID)
end
 
tab = infoInitTab("300px", name, icon)
 
infoFillOthersDetails(tab, others, details,translate("infobox",1,womenrace_bool))
if selector==0 then -- normal infobox
infoFillOthersDetails(tab, others, details,translate("infobox",1,w_race))
elseif selector==1 then -- season infobox
infoFillOthersDetails(tab, others, details,translate("infobox",69,w_race))
else -- champ infobox
infoFillOthersDetails(tab, others, details,translate("infobox",70,w_race))
end
if selector==0 or selector==1 then --no winners for champ
Line 5.780 ⟶ 5.766:
end
end
winner(lf,entityID, win, timeOfRace, false, WDlink_on, team, true)
for _, v in pairs(winners) do
if not v.content then
Line 5.798 ⟶ 5.784:
:cssText('border-bottom:5px solid white; background-color:'..backgroundColor..'; text-align:center')
:css('font-weight','bold')
:wikitext(translate("infobox",18,womenrace_boolw_race))
tab:wikitext(winRows)
end
Line 5.813 ⟶ 5.799:
tab:node(getPreviousNextLine(entityID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/infobox", translate("infobox",34,womenrace_boolw_race), entityID)
return tab
end
Line 5.819 ⟶ 5.805:
--=== H) race infobox
function p.raceinfobox(frame)
localframe = frame
local lang = contentLanguage
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
Line 5.830 ⟶ 5.814:
},
vainqueur= {},
lastEditionMonth,
lastEditionYear,
numberOfEditions,
lastLink,
nextLink,
lastWinner,
maxWinner,
}
 
local entityID, lf = mw.text.trimget_and_checkID(frame.args[1])
local w_race= isWomenrace(entityID)
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
local womenrace_bool=isWomenrace(entityID)
local details = {
{ name = translate("raceinfobox",4,womenrace_boolw_race)}, -- sport
{ name = translate("raceinfobox",5,womenrace_boolw_race)}, -- creation date
{ name = translate("raceinfobox",6,womenrace_boolw_race)}, -- disparition date
{ name = translate("raceinfobox",7,womenrace_boolw_race)}, -- number of editions
{ name = translate("raceinfobox",8,womenrace_boolw_race)}, -- periodicity
{ name = translate("raceinfobox",9,womenrace_boolw_race)}, -- type , name_plural = translate("infobox",10)
{ name = translate("raceinfobox",33,womenrace_boolw_race), name_plural = translate("raceinfobox",34,womenrace_boolw_race)}, --country
{ name = translate("raceinfobox",10,womenrace_boolw_race), name_plural = translate("raceinfobox",11,womenrace_boolw_race)}, -- place
{ name = translate("raceinfobox",12,womenrace_boolw_race), name_plural = translate("raceinfobox",13,womenrace_boolw_race)}, --org
{ name = translate("raceinfobox",27,womenrace_boolw_race), name_plural = translate("raceinfobox",28,womenrace_boolw_race)}, --race director
{ name = translate("raceinfobox",1415,womenrace_boolw_race), name_plural = translate("raceinfobox",16,w_race)}, -- official web siteCat
{ name = translate("raceinfobox",1517,womenrace_bool), name_plural = translate("raceinfobox",16,womenrace_boolw_race)}, -- Catcircuit
{ name = translate("raceinfobox",1714,womenrace_boolw_race)}, -- circuitofficial web site
}
local others = {
{ name = translate("infobox",29,womenrace_bool)}, -- picture
{ name = translate("infobox",30,womenrace_bool)}, -- caption
{ name = translate("infobox",31,womenrace_bool)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,womenrace_bool)}, -- caption map
{ name = translate("infobox",30,womenrace_bool)}, -- caption sectional
}
local others = get_others_dic()
 
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
infoGetOthers(others, entityID)
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
local timeOfRace, class
Line 5.897 ⟶ 5.857:
local creation=firstValue(entityID, 'P571', 'time')
if not details[2].content and creation then
details[2].content = funcDate(creation, "Yonlyyear" )
end
 
Line 5.903 ⟶ 5.863:
local disparition=firstValue(entityID, 'P576', 'time')
if not details[3].content and disparition then
details[3].content = funcDate(disparition,"Yonlyyear")
end
--populate tRace
listOfWinners(entityID, tRace,nil,lf)
--number of editions
if not details[4].content and tRace.numberOfEditions and tRace.lastEditionYear then
details[4].content = tostring(tRace.numberOfEditions).." (" .. translate("raceinfobox",31,womenrace_boolw_race) .. " "..tostring(tRace.lastEditionYear)..")"
end
--periodicity
Line 5.926 ⟶ 5.886:
end
if not details[8].content then
infoGetPlace(details,78, entityID, timeOfRace)
end
Line 5.937 ⟶ 5.897:
end
if not details[11].content then
details[11].content = officialSite(entityID)
end
--Class and circuit
local classContent, circuitLink, numberClass= getClass(entityID)
if not details[1211].content then
details[1211].content = classContent
if numberClass >1 then
details[1211].name = details[1211].name_plural
end
end
if not details[1312].content then
details[1312].content = circuitLink
end
--Official web site
if not details[13].content then
details[13].content = officialSite(entityID)
end
--Build the table
Line 5.963 ⟶ 5.924:
end
--picture at the top
infoFillOthersDetails(tab, others, nil,translate("raceinfobox",19,womenrace_boolw_race),"260px")
if not listOfNamesAtBottom then
if listOfNames and #listOfNames>1 then
tab:node(addATitle(translate("raceinfobox",18,womenrace_boolw_race)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 5.973 ⟶ 5.934:
end
infoFillOthersDetails(tab, nil, details,translate("raceinfobox",19,womenrace_boolw_race),"260px")
 
if listOfNamesAtBottom then
if listOfNames and #listOfNames>0 then -- except for the ru-wiki, no one uses the display of official names at the bottom anyway
tab:node(addATitle(translate("raceinfobox",18,womenrace_boolw_race)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 5.986 ⟶ 5.947:
if (tRace.lastWinner and tRace.lastWinner~='') or
(tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addATitle(translate("raceinfobox",20,womenrace_boolw_race)))
if (tRace.lastWinner and tRace.lastWinner~='') then
tab:node(addARow(translate("raceinfobox",21,womenrace_boolw_race),tRace.lastWinner))
end
if (tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addARow(translate("raceinfobox",22,womenrace_boolw_race),tRace.maxWinner))
end
end
 
if tRace.nextLink or tRace.lastLink then
tab:node(addATitle(translate("raceinfobox",23,womenrace_boolw_race)))
local outTable
 
Line 6.003 ⟶ 5.964:
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local lastText="[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("raceinfobox",24,womenrace_boolw_race)..
":<br>'''"..
tRace.lastLink.."'''"
Line 6.014 ⟶ 5.975:
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local nextText = "[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("raceinfobox",25,womenrace_boolw_race)..
":<br>'''"..
tRace.nextLink.."'''"
Line 6.021 ⟶ 5.982:
end
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,womenrace_boolw_race), entityID)
return tab
end
 
--=== I) Team roster
function p.teamrosterlastteamroster(frame)
local teamID, lf = get_and_checkID(frame)
localframe=frame
local squadID
local tRace = {race={
if frame.args[1] then squadID = string.gsub(frame.args[1], "%c", "") end
raceId,
local flags, pays = {}, {}
raceDate,
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
future,
local riderPosition, riderReason, riderRef, errortext
},
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
vainqueur= {},
local labelMissing = false
}
local teamID, startOfSeason, stagiaire
listOfWinners(teamID, tRace,true,lf,"P527")
if get_arg(2,frame) ~= nil then
if mw.ustring.find(mw.ustring.lower(get_arg(2,frame)), "sort") or wiki == "lv" or wiki == "mk" or wiki == "ru" then
sort = true
else
sort = false
end
end
 
local slavicWikiss = {mk = true, ru = true}
sort=sort,
local wikiIsSlavic = slavicWikis[wiki]
seasonID=tRace.lastID,
local WDlink_on = wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he"
lf=lf,
local tableEndText = ''
year=tRace.lastEditionYear
}
 
if tRace.lastID then
return teamroster_main(s)
end
end
 
function p.teamroster(frame)
local seasonID, lf = get_and_checkID(frame)
local sort
--[[
Line 6.051 ⟶ 6.031:
change that in the code. In lv mkWiki and ruWiki sorting is standard, there is no need to switch sorting on in the article
]]
if get_arg(2,frame) ~= nil then
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
if mw.ustring.find(mw.ustring.lower(get_arg(2,frame)), "sort") or wiki == "lv" or wiki == "mk" or wiki == "ru" then
then localframe = frame:getParent() else localframe = frame end
sort = true
if localframe.args[2] ~= nil then
else
if mw.ustring.find(mw.ustring.lower(localframe.args[2]), "sort") then sort = true else sort = false end
sort = false
end
end
if wiki == "lv" or wiki == "mk" or wiki == "ru" then sort = true end
end
local s = {
sort=sort,
seasonID=seasonID,
lf=lf
}
return teamroster_main(s)
end
 
function teamroster_main(s)
local womenrace_bool=isWomenrace(squadID)
local tempflags, =pays firstValue(squadID,= 'P361'{}, 'id'){}
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
local riderPosition, riderReason, riderRef, errortext
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
local labelMissing = false
local teamID, stagiaire
 
local slavicWikis = {mk = true, ru = true}
local wikiIsSlavic = slavicWikis[wiki]
local WDlink_on = wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he"
local tableEndText = ''
 
local w_race=isWomenrace(s.seasonID)
local temp = firstValue(s.seasonID, 'P5138', 'id')
if temp then teamID = temp end
 
local startOfSeason = getTimeOfRace(s.seasonID, true)
temp = firstValue(squadID, 'P580', 'time')
if temp then
if not s.year then
startOfSeason = temp
label=getLabelFallback(s.seasonID)
else
local second_occurrence
local Sitelink=getSitelinkFallback(squadID,{'en', 'fr', 'de'})
local first_occurrence=string.find(label, "%d%d%d%d")
if Sitelink == nil then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
if first_occurrence~=nil then
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
second_occurrence=string.find(label, "%d%d%d%d",first_occurrence+1)
if second_occurrence~=nil then
s.year=string.match(label, "%d%d%d%d",first_occurrence+1) --case Tartu2024
else
s.year=string.match(label, "%d%d%d%d")
end
end
end
 
for _, p527 in statements(squadIDs.seasonID, 'P527') do
--re-init
riderName, riderBirthday, correctlanguage=nil, nil, nil
Line 6.099 ⟶ 6.108:
end
riderPosition=getPosition(riderPosition,p527)
riderReason, riderRef=getReason(riderReason,riderRef,p527, timeOfRace,enddate,s.lf)
 
local beginYear, beginMonth, beginDay, endYear, endMonth, endDay, beginDate, endDate, endDatefound, endDatetemp
Line 6.119 ⟶ 6.128:
if not endDate then endDatefound=false end
endDate, endYear, endMonth, endDay, _ = parseDate(endDate, beginYear, '12', '31', errortext,'')
riderReason, riderRef=getReason(riderReason,riderRef,v,timeOfRace,endDate,s.lf)
 
if (beginYear == startOfSeasonYear or endYear == startOfSeasonYear) and ((beginYear == startOfSeasonYear and (beginMonth ~= '01' or beginDay ~= '01')) or (endYear == startOfSeasonYear and (endMonth ~= '12' or endDay ~= '31'))) then
Line 6.197 ⟶ 6.206:
 
-- sorting names
-- if sort == true and #riderTablecorrect~=0 and #riderTablenotcorrect~=0 then -- It was
if #riderTablecorrect~=0 then
if sort == true and #riderTablecorrect==0 and #riderTablenotcorrect==0 then -- replaced with this to display the team roster in the ru-wiki
table.sort(riderTablecorrect, function(a,b) return a[1"sortkey"]<b[1"sortkey"] end)
end
table.sort(riderTablenotcorrect, function(a,b) return a[1]<b[1] end)
if #riderTablenotcorrect~=0 then
table.sort(riderTablenotcorrect, function(a,b) return a["sortkey"]<b["sortkey"] end)
end
end
 
--merge
for _, v in pairs (riderTablecorrect) do
Line 6.209 ⟶ 6.222:
table.insert(riderTable, v)
end
local wd_link = mw.html.create('span'):css('float','left'):wikitext(wdLink(frames.args[1]seasonID..'#P527'))
if arwiki_totemplate then wd_link = wdLink(frames.args[1]seasonID .. '#P527') end
local outTable = mw.html.create('table')
:addClass('sortable')
Line 6.219 ⟶ 6.232:
local th_colspan = 4
if wiki == "ar" then th_colspan = 5 end
local tRow=outTable:tag('tr'):css('line-height','1.8em')
:css('background-color',backgroundColor)
:tag('th'):attr('colspan', th_colspan):cssText('text-align:center;white-space:nowrap')
:wikitext(tostring(wd_link))
if s.year then
:wikitext(translate("getSquadTableColumn",7,womenrace_bool))
tRow:wikitext(translate("getSquadTableColumn",7,w_race).." "..s.year)
else
tRow:wikitext(translate("getSquadTableColumn",7,w_race))
end
local header = outTable:tag('tr')
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",1,womenrace_boolw_race))
local textalign = 'center'
if wiki=='ar' then textalign = 'right' end
header:tag('th'):cssText('text-align:'..textalign..';padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",2,womenrace_boolw_race))
if available_listl10n["country_name_list"] and wiki ~= 'lv' and wiki ~= 'ru' and wiki ~= 'da' then
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",6,womenrace_boolw_race))
end
if wiki == "ar" then
header:tag('th'):attr('colspan', 2):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",3,womenrace_boolw_race))
else
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",3,womenrace_boolw_race))
end
local temp
Line 6.243 ⟶ 6.260:
local tCell= tRow:tag('td'):cssText("padding:0 1em 0 0;white-space:nowrap")
 
if not available_listl10n["country_name_list"] or wiki == 'lv' or wiki == 'ar' or wiki == 'ru' or wiki == 'da' then temp=v['flags']..' ' else temp='' end
tCell:wikitext(temp..v['riderName']):attr('data-sort-value',v['sortkey'])
 
Line 6.250 ⟶ 6.267:
local note=''
if v['riderReason'] ~= nil then
note = ', [[#tr_'..i..frames.args[1]seasonID..'|'..translate("getSquadTableColumn",4,womenrace_boolw_race)..']]'
if wiki == "ar" then note = '، [[#tr_'..i..frames.args[1]seasonID..'|'..translate("getSquadTableColumn",4,womenrace_boolw_race)..']]' end
end
tCell:wikitext(' ('..(v['riderStart'] or '')..'–'..(v['riderEnd'] or '')
Line 6.257 ⟶ 6.274:
elseif v['riderReason'] then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
:wikitext('([[#tr_'..i..frames.args[1]seasonID..'|'..translate("getSquadTableColumn",4,womenrace_boolw_race)..']]'.. ')')
end
tCell=tRow:tag('td'):cssText("text-align:right;white-space:nowrap")
Line 6.263 ⟶ 6.280:
local _, _, beginYear, beginMonth, beginDay = string.find(startOfSeason,"(%d+)-(%d+)-0*(%d+)")
local _, _, endYear, endMonth, endDay = string.find(v['riderBirthday'] or '',"(%d+)-(%d+)-0*(%d+)")
tCell:wikitext(frames.lf:expandTemplate{ title = 'Template:Birth date and age2', args = { beginYear, beginMonth, beginDay, endYear, endMonth, endDay } })
else
tCell:wikitext(funcDate(v['riderBirthday'] or '', 'long'))
if l10n["country_name_list"] and wiki ~= 'ar' and wiki ~= 'ru' and wiki ~= 'da' then
if available_list then
tRow:tag('td'):wikitext(v['flags'].. ' '..v['pays'])
end
Line 6.279 ⟶ 6.296:
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
elseif wiki == "ar" then
else
tCell=tRow:tag('td'):cssText("padding:0 0.5em")
if wiki == "ar" then
else
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
else
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
end
if v['riderTeam'] then
Line 6.299 ⟶ 6.314:
local temp=(v['riderReason'] or '')..(v['errortext'] or '')
if iii == 1 then
tableEndText = tableEndText.. translate("getSquadTableColumn",5,womenrace_boolw_race)..': '.. v['riderName'].. temp
else
tableEndText = tableEndText.. '<span style="color:white">'.. translate("getSquadTableColumn",5,womenrace_boolw_race)..': </span>'.. riderName.. temp
end
iii = iii + 1
if riderRef ~= nil then tableEndText = tableEndText..
frames.lf:extensionTag{name='ref', content=v['riderRef'], args = {name='tr_'..iii..frames.args[1]seasonID}} end
tableEndText = tableEndText.. '<br>'
end
Line 6.311 ⟶ 6.326:
if labelMissing then outTable:wikitext(getMissingLabelTrackingCategory()) end
local ref=race_reference(s.seasonID,s.lf)
local UCIlink
if wikiref=="fr"'' then --fallback
local UCIlink
UCIlink="https://www.uci.org/fr/route/%C3%A9quipe"
if wiki=="fr" then
else
UCIlink="https://www.uci.org/roadfr/teamsroute/%C3%A9quipe"
else
UCIlink="https://www.uci.org/road/teams"
end
ref=translate("race_reference", 1,w_race).."["..UCIlink..' UCI]'
end
Line 6.326 ⟶ 6.345:
:attr('data-sort-value','zzz')
:cssText("text-align:right")
:tag('small'):wikitext(translate("race_reference", 1,womenrace_bool).."["..UCIlink..' UCI]'ref)
return tostring(outTable)..tableEndText
Line 6.333 ⟶ 6.352:
--== J) List of winners ==
function p.listofwinners(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
 
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team,
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
 
return listofwinners_main(frame, s)
return listofwinners_main(s)
end
 
function p.listofwinnersyoung(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20883139','Q72099969','Q72099972'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[4]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=tonumber(frame.args[5]), -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnersChamp(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local s = {
countryflag=false,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
winnersProperty=winnersProperty,
display_team = false,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
--listofwinnerssecondpart and so on can be coded with p.listofwinners
function p.listofwinnersnowiki(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q20882667','Q20882668','Q20882669'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return frame:extensionTag{ name = 'nowiki', content = listofwinners_main(frame, s)}
end
 
function p.listofwinnersteamofpoint(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q27104269','Q72065970','Q72065977'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnersGSI(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q98959152','Q98959192','Q98959196'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnersGSII(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q98959153','Q98959194','Q98959197'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnersGSIII(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q98959155','Q98959195','Q98959198'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnerscountry(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q72068715','Q72068718','Q72068721'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnerscountryU23(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty = {'Q72068724','Q72068725','Q72068729'}
local display_team = false -- display of a rider without a team
if tonumber(frame.args[5]) ==1 then display_team = true end -- display of the rider with the team
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team=display_team, -- since the answer is "args[4]"
display_team=istrue(get_arg(5,frame)), -- false= display of a rider without a team
winnersProperty=winnersProperty,
custom=false,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function p.listofwinnerscustom(frame)
local raceID, lf =get_and_checkID(frame)
local winnersProperty ={}
--general
if frame.args[5] ~= nil and tonumberistrue(get_arg('general',frame.args[5]) ==1) then table.insert( winnersProperty,'Q20882667') end
if istrue(get_arg('podium',frame)) then
--podium
if frame.args[6] ~= nil and tonumber(frame.args[6]) ==1 then
table.insert( winnersProperty,'Q20882668')
table.insert( winnersProperty,'Q20882669')
end
if istrue(get_arg('points',frame)) then table.insert( winnersProperty, 'Q20883007' ) end
--points
if frame.args[7] ~= nil and tonumberistrue(get_arg('mountain',frame.args[7]) ==1) then table.insert( winnersProperty, 'Q20883007Q20883212' ) end
if istrue(get_arg('sprints',frame)) then table.insert( winnersProperty, 'Q20883328' ) end
--mounstain
if frame.args[8] ~= nil and tonumberistrue(get_arg('youth',frame.args[8]) ==1) then table.insert( winnersProperty, 'Q20883212Q20883139' ) end
if istrue(get_arg('combativity',frame)) then table.insert( winnersProperty, 'Q101246973' ) table.insert( winnersProperty, 'Q20893983' ) end
-- sprints
if frame.args[9] ~= nil and tonumberistrue(get_arg('volante',frame.args[9]) ==1) then table.insert( winnersProperty, 'Q20883328Q27067359' ) end
if istrue(get_arg('regularity',frame)) then table.insert( winnersProperty, 'Q27067170' ) end
-- youth
if frame.args[10] ~= nil and tonumberistrue(get_arg('combination',frame.args[10]) ==1) then table.insert( winnersProperty, 'Q20883139Q20893979' ) end
if istrue(get_arg('breakaway',frame)) then table.insert( winnersProperty, 'Q27907715' ) end
-- supercombativity
if frame.args[11] ~= nil and tonumberistrue(get_arg('azzurri',frame.args[11]) ==1) then table.insert( winnersProperty, 'Q101246973Q27907747' ) end
if istrue(get_arg('rookie',frame)) then table.insert( winnersProperty, 'Q28092831' ) end
-- combativity
if frame.args[11] ~= nil and tonumberistrue(get_arg('teams',frame.args[11]) ==1) then table.insert( winnersProperty, 'Q20893983Q20882921' ) end
if istrue(get_arg('teamspoints',frame)) then table.insert( winnersProperty, 'Q27104269' ) end
-- volante
if frame.args[12] ~= nil and tonumberistrue(get_arg('amateur',frame.args[12]) ==1) then table.insert( winnersProperty, 'Q27067359Q61976850' ) end
if istrue(get_arg('nationality',frame)) then table.insert( winnersProperty, 'Q61976872' ) end
-- regularity
if frame.args[13] ~= nil and tonumberistrue(get_arg('country',frame.args[13]) ==1) then table.insert( winnersProperty, 'Q27067170Q72068715' ) end
if istrue(get_arg('countryU23',frame)) then table.insert( winnersProperty, 'Q72068724' ) end
-- combination
if frame.args[14] ~= nil and tonumber(frame.args[14]) ==1 then table.insert( winnersProperty, 'Q20893979' ) end
-- breakaway
if frame.args[15] ~= nil and tonumber(frame.args[15]) ==1 then table.insert( winnersProperty, 'Q27907715' ) end
-- azzurri
if frame.args[16] ~= nil and tonumber(frame.args[16]) ==1 then table.insert( winnersProperty, 'Q27907747' ) end
-- rookie
if frame.args[17] ~= nil and tonumber(frame.args[17]) ==1 then table.insert( winnersProperty, 'Q28092831' ) end
-- teams
if frame.args[18] ~= nil and tonumber(frame.args[18]) ==1 then table.insert( winnersProperty, 'Q20882921' ) end
-- teamspoints
if frame.args[19] ~= nil and tonumber(frame.args[19]) ==1 then table.insert( winnersProperty, 'Q27104269' ) end
-- amateur
if frame.args[20] ~= nil and tonumber(frame.args[20]) ==1 then table.insert( winnersProperty, 'Q61976850' ) end
--nationality
if frame.args[21] ~= nil and tonumber(frame.args[21]) ==1 then table.insert( winnersProperty, 'Q61976872' ) end
-- country
if frame.args[22] ~= nil and tonumber(frame.args[22]) ==1 then table.insert( winnersProperty, 'Q72068715' ) end
-- country U-23
if frame.args[23] ~= nil and tonumber(frame.args[23]) ==1 then table.insert( winnersProperty, 'Q72068724' ) end
local s = {
countryflag=true,
raceID=raceID,
beginyear=tonumber(frame.args[2]),
endyearbeginyear=tonumberget_arg(2,frame.args[3],true),
shapkaendyear=tonumberget_arg(3,frame.args[4],true),
shapka=get_arg(4,frame,true),
display_team = false,
winnersProperty=winnersProperty,
custom=true,
lf=lf
}
return listofwinners_main(frame, s)
end
 
function listofwinners_main(frame, s)
local lf=s.lf
local raceID=s.raceID
local rows = {}
frame.args[1] = string.gsub(frame.args[1], "%c", "")
local raceID = frame.args[1]
local WDlink_on = (wiki == "mk") or (wiki == "ja") or (wiki == "ru")
-- WDlink_on is used to decide if a Wikidata logo will be shown
local WPcontent = {
row ={},
Line 6.563 ⟶ 6.579:
local titletable
local womenrace_boolw_race=isWomenrace(raceID)
if s.custom then
titletable={
[ 'Q20882667' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner
[ 'Q20882668' ]=translate("listofwinners",3, womenrace_boolw_race), -- second
[ 'Q20882669' ]=translate("listofwinners",4, womenrace_boolw_race), -- third
[ 'Q20883007' ]=translate("listofwinners",5, womenrace_boolw_race), -- points
[ 'Q20883212' ]=translate("listofwinners",6, womenrace_boolw_race), -- mountains
[ 'Q20883328' ]=translate("listofwinners",7, womenrace_boolw_race), -- sprints
[ 'Q20883139' ]=translate("listofwinners",8, womenrace_boolw_race), -- youth
[ 'Q101246973' ]=translate("listofwinners",9, womenrace_boolw_race), -- supercombativity
[ 'Q20893983' ]=translate("listofwinners",9, womenrace_boolw_race), -- combativity
[ 'Q20893979' ]=translate("listofwinners",10, womenrace_boolw_race), -- combination
[ 'Q20882921' ]=translate("listofwinners",11, womenrace_boolw_race), -- teams
[ 'Q27067359' ]=translate("listofwinners",12, womenrace_boolw_race), -- volantes
[ 'Q27067170' ]=translate("listofwinners",13, womenrace_boolw_race), -- regularity
[ 'Q27104269' ]=translate("listofwinners",14, womenrace_boolw_race), -- teamspoints
[ 'Q27907715' ]=translate("listofwinners",15, womenrace_boolw_race), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",16, womenrace_boolw_race), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",17, womenrace_boolw_race), -- rookie
[ 'Q61976850' ]=translate("listofwinners",18, womenrace_boolw_race), -- amateur
[ 'Q61976872' ]=translate("listofwinners",19, womenrace_boolw_race), -- nationality
[ 'Q72068715' ]=translate("listofwinners",23, womenrace_boolw_race), -- winner country
[ 'Q72068724' ]=translate("listofwinners",24, womenrace_boolw_race), -- winner countryU23
}
else --main
titletable={
-- winner:
[ 'Q20882667' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner
[ 'Q20883007' ]=translate("listofwinners",2, womenrace_boolw_race), -- points
[ 'Q20883212' ]=translate("listofwinners",2, womenrace_boolw_race), -- mountains
[ 'Q20883328' ]=translate("listofwinners",2, womenrace_boolw_race), -- sprints
[ 'Q20883139' ]=translate("listofwinners",2, womenrace_boolw_race), -- youth (time or point)
[ 'Q101246973' ]=translate("listofwinners",2, womenrace_boolw_race), -- supercombativity
[ 'Q20893983' ]=translate("listofwinners",2, womenrace_boolw_race), -- combativity
[ 'Q20893979' ]=translate("listofwinners",2, womenrace_boolw_race), -- combination
[ 'Q20882921' ]=translate("listofwinners",2, womenrace_boolw_race), -- team (time)
[ 'Q27067359' ]=translate("listofwinners",2, womenrace_boolw_race), -- volantes
[ 'Q27067170' ]=translate("listofwinners",2, womenrace_boolw_race), -- regularity
[ 'Q27104269' ]=translate("listofwinners",2, womenrace_boolw_race), -- teampoints
[ 'Q27907715' ]=translate("listofwinners",2, womenrace_boolw_race), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",2, womenrace_boolw_race), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",2, womenrace_boolw_race), -- rookie
[ 'Q61976850' ]=translate("listofwinners",2, womenrace_boolw_race), -- amateur
[ 'Q61976872' ]=translate("listofwinners",2, womenrace_boolw_race), -- nationality
[ 'Q72068715' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner country
[ 'Q72068724' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner countryU23
[ 'Q98959152' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner team GS-I
[ 'Q98959153' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner team GS-II
[ 'Q98959155' ]=translate("listofwinners",2, womenrace_boolw_race), -- winner team GS-III
-- 2 place:
[ 'Q20882668' ]=translate("listofwinners",3, womenrace_boolw_race), -- second
[ 'Q72065970' ]=translate("listofwinners",3, womenrace_boolw_race), -- second teampoints
[ 'Q72099969' ]=translate("listofwinners",3, womenrace_boolw_race), -- youth (time or point)
[ 'Q72068718' ]=translate("listofwinners",3, womenrace_boolw_race), -- second country
[ 'Q72068725' ]=translate("listofwinners",3, womenrace_boolw_race), -- second countryU23
[ 'Q98959192' ]=translate("listofwinners",3, womenrace_boolw_race), -- second team GS-I
[ 'Q98959194' ]=translate("listofwinners",3, womenrace_boolw_race), -- second team GS-II
[ 'Q98959195' ]=translate("listofwinners",3, womenrace_boolw_race), -- second team GS-III
-- 3 place:
[ 'Q20882669' ]=translate("listofwinners",4, womenrace_boolw_race), -- third
[ 'Q72065977' ]=translate("listofwinners",4, womenrace_boolw_race), -- third teampoints
[ 'Q72099972' ]=translate("listofwinners",4, womenrace_boolw_race), -- youth (time or point)
[ 'Q72068721' ]=translate("listofwinners",4, womenrace_boolw_race), -- third country
[ 'Q72068729' ]=translate("listofwinners",4, womenrace_boolw_race), -- third countryU23
[ 'Q98959196' ]=translate("listofwinners",4, womenrace_boolw_race), -- third team GS-I
[ 'Q98959197' ]=translate("listofwinners",4, womenrace_boolw_race), -- third team GS-II
[ 'Q98959198' ]=translate("listofwinners",4, womenrace_boolw_race), -- third team GS-III
}
end
 
--localframe defined as global for references
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
if localframe.args[1] then
localframe.args[1] = string.gsub(localframe.args[1], "%c", "")
end
--[=[
It is possible to give the table listofwinners in the article commands. It could look like this:
Line 6.651 ⟶ 6.658:
"above row x" inserts a new row above row x into the table. Content is what is behind the ":".
]=]
if localframe.args[get_arg(2],lf) then
for num, _ in pairs(localframelf.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(localframe.args[get_arg(num],lf)), 'row') then
local _, _, kebeginYear, val = mw.ustring.find(localframe.args[get_arg(num],lf), "([^:]+)%s*:%s*(%C+)")
local _, _, key01, kebeginYear1, kebeginYear2 = mw.ustring.find(kebeginYear, "(%a+)%s*(%a+)%s*(%d+)")
kebeginYear2 = tonumber(kebeginYear2) kebeginYear1 = mw.ustring.lower(key01..kebeginYear1)
Line 6.668 ⟶ 6.675:
if part.rank ~= 'deprecated' and part.mainsnak.snaktype == 'value' then
local partID = part.mainsnak.datavalue.value.id
local timeOfRace=getTimeOfRace(partID,true,true) --original P585 and P580 inverted here
local year = timeOfRace and string.sub(timeOfRace, 2, 5) or '?'
local month = timeOfRace and string.sub(timeOfRace, 7, 8) or '01'
Line 6.691 ⟶ 6.698:
local temp=firstValue(partID, 'P1346','id')
if temp and temp=='Q30108381' or temp=='Q54806642' or temp=='Q23023872' then --race cancelled
local cancelledlabel = getLabelFallback('Q30108381', {wikilang, 'en', 'fr', 'de'}temp)
tCell=mw.html.create('td'):attr('colspan','4')
:cssText('text-align:center; font-style: italic')
Line 6.698 ⟶ 6.705:
tCellstr=tostring(tCell)
else
winner(lf,partID, winners, timeOfRace, not s.countryflag, WDlink_on,s.display_team,true)
for _, property in ipairs(s.winnersProperty) do
tCell=mw.html.create('td'):wikitext(winners[property])
Line 6.732 ⟶ 6.739:
tCell:wikitext(tostring(wd_link))
end
tCell:wikitext(translate("listofwinners",1,womenrace_boolw_race)) --year
for _, pp in ipairs(s.winnersProperty) do
tTitleRow:tag('th'):wikitext(titletable[pp])
Line 6.784 ⟶ 6.791:
 
--== K) List of stages
function check_basque_place(sPoint, sPointID)
local eu=false
--check if it is a town
local town=false
for _, p31 in statements(sPointID, 'P31') do
if p31.mainsnak.datavalue.value.id == "Q2074737" or p31.mainsnak.datavalue.value.id == "Q484170" then --Spanish and French towns
town=true
end
end
if not town then --if it not a town look for parent
for _, p131 in statements(sPointID, 'P131') do
if data.BasqueTown[p131.mainsnak.datavalue.value.id] then
eu=true
end
end
else
if data.BasqueTown[sPointID] then
eu=true
end
end
if eu then
sPoint = flag("Q47588", timeOfRace).." "..sPoint
end
return sPoint, eu
end
 
function p.listofstages(frame)
-- WDlink_on is used to decide if a Wikidata logo will be shown
local WDlink_on = wiki == "mk" or wiki == "ja"
local WPcontent = {}
local raceID, lf = get_and_checkID(frame.args[1])
local thereiselevation=false
local result, tableBody
local w_race=isWomenrace(raceID)
 
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
if localframe.args[1] then
localframe.args[1] = string.gsub(localframe.args[1], "%c", "")
end
local womenrace_bool=isWomenrace(raceID)
--[=[ It is possible to give the table listofstages in the article commands which overwrites data from Wikidata.
It could look like this:
Line 6.820 ⟶ 6.843:
end location are the same. The file data for the icon looks this way: [[File:Stage rest day.svg|any text]]
]=]
if localframe.args[get_arg(2],lf) then
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance
= 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
Line 6.826 ⟶ 6.849:
local key01, kebeginYear1, kebeginYear2
local key21, key22
for num, var in pairs(localframelf.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(var), WProw) then
_, _, kebeginYear, key2, val = mw.ustring.find(var, "([^:]+)%s*:?%s*([^:]*)%s*:%s*(%C+)")
Line 6.886 ⟶ 6.909:
local WDLink = WDlink_on and wdLink(stageID) or ''
local sitelink = mw.wikibase.getSitelink(stageID)
local timeOfRace =getTimeOfRace(stageID) or ''
local sPointID = firstValue(stageID, 'P1427', 'id')
local sPoint = (sPointID and getPlaceLink(sPointID, timeOfRace)) or ''
local eu=false
if wiki=="eu" and sPointID then
sPoint, eu=check_basque_place(sPoint, sPointID)
end
 
if sPointID and not onecountry and timeOfRacenot eu then
local startcountrystartcountryID= getStatementForTimegetCountryID(sPointID, 'P17',timeOfRace)
if startcountryID and firstcountryID ~= startcountryID then
if startcountry then
sPoint = flag(startcountryID, timeOfRace).." "..sPoint
local startcountryID = startcountry.mainsnak.datavalue.value.id
if firstcountryID ~= startcountryID then
local sflag = flag(startcountryID, timeOfRace)
sPoint = sflag.." "..sPoint
end
end
end
Line 6.905 ⟶ 6.928:
local dPoint = (dPointID and getPlaceLink(dPointID, timeOfRace)) or ''
 
eu=false
if dPointID and not onecountry and timeOfRace then
if wiki=="eu" and dPointID then
local dcountry= getStatementForTime(dPointID, 'P17',timeOfRace)
dPoint, eu=check_basque_place(dPoint, dPointID)
if dcountry then
end
local dcountryID = dcountry.mainsnak.datavalue.value.id
 
if firstcountryID ~= dcountryID then
if dPointID and not onecountry and not eu then
local dflag = flag(dcountryID, timeOfRace)
local dcountryID=getCountryID(dPointID, timeOfRace)
dPoint = dflag.." "..dPoint
if dcountryID and firstcountryID ~= dcountryID then
end
dPoint = flag(dcountryID, timeOfRace).." "..dPoint
end
end
Line 6.925 ⟶ 6.949:
Q20882667 = '', -- Q20882667 is 'overall winner' not supposed to be used
}
winner(lf,stageID, winners, timeOfRace, false, WDlink_on)
 
-- find the type of stage
Line 6.931 ⟶ 6.955:
local label, section_title
if sOrdinal == "0" then
label, section_title = translate("func_prologue",1), "#" .. translate("func_prologue",1)
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 6.943 ⟶ 6.967:
if winners['Q20882763']~='' then tempoverall=winners['Q20882763'] else tempoverall=winners['Q20882667'] end
rows[#rows + 1] = {
rank=tonumber(sNumber) or 0,
sortkey=sLetter, -- Sort keys
sLink=sLink,
sLink, sDate, WDLink, sPoint, dPoint, sType, sDistance, sElevation, winners['Q20882747'], tempoverall -- Content
sDate=sDate,
WDLink=WDLink,
sPoint=sPoint,
dPoint=dPoint,
sType=sType,
sDistance=sDistance,
sElevation=sElevation,
sSWin=winners['Q20882747'],
sGWin=tempoverall -- Content
}
end
Line 6.950 ⟶ 6.984:
 
table.sort(rows, function(a, b)
if a[1"rank"] ~= b[1"rank"] then return a[1"rank"] < b[1"rank"] end
return a[2"sortkey"] < b[2"sortkey"]
end)
local Id = ((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")
Line 6.963 ⟶ 6.997:
:css('text-align','center')
tRow:tag('th'):css('white-space','nowrap')
:wikitext(Id..translate("headoftable",1,womenrace_boolw_race))
tRow:tag('th'):wikitext(translate("headoftable",2,womenrace_boolw_race))
tRow:tag('th'):wikitext(translate("headoftable",3,womenrace_boolw_race))
tRow:tag('th'):css('color',backgroundColor):wikitext("type")
tRow:tag('th'):wikitext(translate("headoftable",4,womenrace_boolw_race))
if thereiselevation then
tRow:tag('th'):wikitext(translate("headoftable",7,womenrace_boolw_race))
end
tRow:tag('th'):wikitext(translate("headoftable",5,womenrace_boolw_race))
tRow:tag('th'):wikitext(translate("headoftable",6,womenrace_boolw_race))
local header = tostring(tRow)
for num, row in pairs(rows) do
local sPoint=row["sPoint"]
local sLink, sDate, WDLink, sPoint, dPoint, sType, sDistance, sElevation, sSWin, sGWin
local dPoint=row["dPoint"]
= row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12]
local sType=row["sType"]
 
local sDistance=row["sDistance"]
local WPc = WPcontent[num]
if WPc then
Line 6.988 ⟶ 7.024:
 
local tRow = tab:tag('tr')
local tCell= tRow:tag('td'):cssText('text-align:center; white-space:nowrap'):wikitext(row["sLink"])
tCell:tag('span'):css('white-space','nowrap'):wikitext("&nbsp;".. row["WDLink "])
tRow:tag('td'):css('white-space','nowrap'):cssText("text-align:right; padding-right:0px")
:wikitext(row["sDate"])
tCell=tRow:tag('td'):cssText("padding-right:0px"):wikitext( sPoint)
if dPoint ~= '' then
Line 6.999 ⟶ 7.035:
tRow:tag('td'):css('text-align','center'):wikitext( sDistance)
if thereiselevation then
tRow:tag('td'):css('text-align','center'):wikitext(row["sElevation"])
end
 
Line 7.005 ⟶ 7.041:
tRow:tag('td'):css('text-align',textalign):wikitext( WPc['stage winner'])
else
tRow:tag('td'):wikitext(row["sSWin"])
end
if WPc and WPc['general winner'] then
tRow:tag('td'):css('text-align',textalign):wikitext( WPc['general winner'])
else
tRow:tag('td'):wikitext(row["sGWin"])
end
if WPc and (WPc['date'] or WPc['text'] or WPc['icon (new row)']) then
Line 7.038 ⟶ 7.074:
 
function p.stagetitle(frame)
local stageID = get_and_checkID(frame)
-- WDlink_on is used to decide if a Wikidata logo will be shown
local stageID = frame.args[1]
-- from to
local psPointID = mw.wikibase.getBestStatementsfirstValue(stageID, 'P1427') -- P1427 is, 'start pointid')
local sPointID = p[1] and p[1].mainsnak.snaktype == 'value' and p[1].mainsnak.datavalue.value.id
local sPoint = sPointID and getPlaceLink(sPointID) or ''
 
p = mw.wikibase.getBestStatements(stageID, 'P1444') -- P1444 is 'destination point'
local dPointID = p[1] and p[1].mainsnak.snaktype ==firstValue(stageID, 'valueP1444', and p[1].mainsnak.datavalue.value.'id')
local dPoint = (dPointID and getPlaceLink(dPointID)) or ''
 
local sDistance = getDistance(stageID, true) or ''
local sType = typeofstagelogo(stageID) -- find the type of stage
local sType = typeofstagelogo(stageID)
tab=mw.html.create('table')
Line 7.062 ⟶ 7.095:
local road, ITT, result
local hcountry, hnotcountry = {},{}
local womenrace_boolw_race=nil --to be defined if needed
--the jersey for a stage race and the jersey from national championship should be differentiated
Line 7.071 ⟶ 7.104:
roadtemp=false
ITTtemp=false
if data.womenNcRoadtable[v] or data.menNcRoadtable[v] then
road = true
roadtemp=true
elseif data.womenNcITTtable[v] or data.menNcITTtable[v] then
ITT = true
ITTtemp=true
Line 7.114 ⟶ 7.147:
end
--avoid double display of jersey
result = "<small>("..translate("startlist",10,womenrace_boolw_race).." "..translate("startlist",12,womenrace_boolw_race).." "..translate("startlist",11,womenrace_boolw_race)..")</small>"
elseif road then
result = "<small>("..translate("startlist",10,womenrace_boolw_race)..")</small>"
elseif ITT then
result = "<small>("..translate("startlist",11,womenrace_boolw_race)..")</small>"
else
result = ""
Line 7.133 ⟶ 7.166:
local q = winner.qualifiers
if q then
if q.P642P2501 and q.P642P2501[1].snaktype == 'value' then
wOf = q.P2501[1].datavalue.value.id -- P642 is 'of'
elseif q.P642 and q.P642[1].snaktype == 'value' then --fallback
wOf = q.P642[1].datavalue.value.id -- P642 is 'of'
end
if q.P2912 and q.P2912[1].snaktype == 'value' then
thisjersey=q.P2912[1].datavalue.value.id
if data.bg_color_table[thisjersey] then
bg_color = data.bg_color_table[thisjersey]
end
end
Line 7.158 ⟶ 7.193:
local displaytypeofstage = true
local stageinfotable = {}
local raceID, lf = get_and_checkID(frame.args[1])
local womenrace_boolw_race=isWomenrace(raceID)
local sType
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
if localframe.args[1] then
localframe.args[1] = string.gsub(localframe.args[1], "%c", "")
end
 
--link for Grand Tour
local GTid={['Q33881']=true,['Q33861']=true,['Q33937']=true,['Q1526999']=true}
local thisGT
 
Line 7.181 ⟶ 7.207:
local Sitelink,overallname, pointsname, mountainname, youngname, teamname, combativityname, supercombativityname, combinedname
if thisGT then
if thisGT=='Q33881' then -- Tour de France
Sitelink = wikibase.getSitelink('Q2267539') -- General
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,womenrace_boolw_race).."]]" end
Sitelink = wikibase.getSitelink('Q175399') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,womenrace_boolw_race).."]]" end
Sitelink = wikibase.getSitelink('Q927157') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,womenrace_boolw_race).."]]" end
Sitelink = wikibase.getSitelink('Q641662Q2254180') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,womenrace_boolw_race).."]]" end
Sitelink = wikibase.getSitelink('Q1436680') -- Team by time
if Sitelink then teamname="[["..Sitelink .."|"..translate("infobox",28,womenrace_boolw_race).."]]" end
Sitelink = wikibase.getSitelink('Q2094179') -- Combativity award
if Sitelink then combativityname="[["..Sitelink .."|"..translate("infobox",26,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2094179') -- Combativity award
if Sitelink then supercombativityname="[["..Sitelink .."|"..translate("infobox",26,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q1835362') -- Combination
if Sitelink then combinedname="[["..Sitelink .."|"..translate("infobox",27,w_race).."]]" end
 
elseif thisGT=='Q33861' then -- Giro d'Italia
Sitelink = wikibase.getSitelink('Q2094179')
Sitelink = wikibase.getSitelink('Q1164275') -- General
if Sitelink then combativityname="[["..Sitelink .."|"..translate("infobox",26,womenrace_bool).."]]" end
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641083') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641060') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641662') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
 
elseif thisGT=='Q33937' then -- Vuelta a España
Sitelink = wikibase.getSitelink('Q2094179')
Sitelink = wikibase.getSitelink('Q2532554') -- General
if Sitelink then supercombativityname="[["..Sitelink .."|"..translate("infobox",26,womenrace_bool).."]]" end
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2241695') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q1118296') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q60233927') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2141595') -- Team by time
if Sitelink then teamname="[["..Sitelink .."|"..translate("infobox",28,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q20882672') -- Combativity award
if Sitelink then combativityname="[["..Sitelink .."|"..translate("infobox",26,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q2330008') -- Combination
if Sitelink then combinedname="[["..Sitelink .."|"..translate("infobox",27,w_race).."]]" end
 
else -- Giro d'Italia Women
 
Sitelink = wikibase.getSitelink('Q1835362Q3679692') -- General
if Sitelink then combinednameoverallname="[["..Sitelink .."|"..translate("infoboxheadoftableII",279,womenrace_boolw_race).."]]" end
Sitelink = wikibase.getSitelink('Q3679673') -- Point
elseif thisGT=='Q33861' then
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q1164275')
Sitelink = wikibase.getSitelink('Q3679712') -- Mountains
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,womenrace_bool).."]]" end
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641083')
Sitelink = wikibase.getSitelink('Q3679695') -- Young
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,womenrace_bool).."]]" end
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
Sitelink = wikibase.getSitelink('Q641060')
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q641662')
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,womenrace_bool).."]]" end
else
Sitelink = wikibase.getSitelink('Q2532554')
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q2241695')
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q1118296')
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q2330008')
if Sitelink then combinedname="[["..Sitelink .."|"..translate("infobox",27,womenrace_bool).."]]" end
end
end
 
local winners = {
{ name = translate("infobox",19,womenrace_boolw_race), QID = 'Q20882747'}, -- stage
{ name = overallname or translate("headoftableII",9,womenrace_boolw_race), QID = 'Q20882763' }, -- overall
{ name = pointsname or translate("infobox",22,womenrace_boolw_race), QID = 'Q20883008' }, -- points
{ name = mountainname or translate("infobox",23,womenrace_boolw_race), QID = 'Q20883213' }, -- mountains
{ name = translate("infobox",24,womenrace_boolw_race), QID= 'Q20883329' }, -- sprints
{ name = youngname or translate("infobox",25,womenrace_boolw_race), QID='Q20883140' }, -- youth
{ name = combativityname or translate("infobox",26,womenrace_boolw_race), QID= 'Q21686770' }, -- combativity
{ name = supercombativityname or translate("infobox",26,womenrace_boolw_race), QID= 'Q20893984' }, -- combativity
{ name = translate("infobox",35,womenrace_boolw_race), QID= 'Q27104688' }, -- volantes
{ name = translate("infobox",36,womenrace_boolw_race), QID= 'Q27104684' }, -- regularity
{ name = combinedname or translate("infobox",27,womenrace_boolw_race), QID='Q20965880' }, -- combination
{ name = translate("infobox",38,womenrace_boolw_race), QID='Q27907714' }, -- breakaway
{ name = translate("infobox",39,womenrace_boolw_race), QID='Q27907748' }, -- azzurri
{ name = translate("infobox",40,womenrace_boolw_race), QID='Q28096780'}, -- rookie
{ name = teamname or translate("infobox",28,womenrace_boolw_race), QID='Q20882922' }, -- teams
{ name = translate("infobox",37,womenrace_boolw_race), QID ='Q27104271' }, -- teamspoints
{ name = translate("infobox",41,womenrace_boolw_race), QID ='Q61976847' },-- amateur
{ name = translate("infobox",42,womenrace_boolw_race), QID ='Q61976871' } --nationality
}
 
Line 7.331 ⟶ 7.371:
local label, section_title
if sOrdinal == "0" then
label, section_title = translate("func_prologue",1), "#" .. translate("func_prologue",1)
else
label, section_title = stageLink(sOrdinal, sNumber, sLetter)
Line 7.346 ⟶ 7.386:
if ii==1 then jerseytable[v.QID]='' end
end
winner(lf,stageID, win, timeOfRace, false, WDlink_on, false, false) --fill win table
if ii<==12 then --only two first stagestages
jerseytable, bgcolortable=winnerjersey(stageID, jerseytable)
end
Line 7.368 ⟶ 7.408:
end
columntable[v.QID].used=true
if ii<==12 then --read the jersey in the two first stagestages of a race
if columntable[v.QID].jersey =jerseytable= '' or columntable[v.QID].jersey==nil then
columntable[v.QID].bg_colorjersey=bgcolortablejerseytable[v.QID]
columntable[v.QID].bg_color=bgcolortable[v.QID]
end
end
end
Line 7.389 ⟶ 7.431:
somewinner = false
jerseytable, bgcolortable=winnerjersey(raceID, jerseytable)
winner(lf,raceID, win, timeOfRace, false, WDlink_on, false, false)
for _, v in pairs(winnersgen) do
if win[v.QID] and win[v.QID] ~= '' then
Line 7.421 ⟶ 7.463:
end
end
table.insert(stageinfotable,{sLink=translate("listofstagesclassification",2,womenrace_boolw_race), sType=nil, somewinner=somewinner})
 
--build the table
Line 7.432 ⟶ 7.474:
tRow:tag('th'):css('white-space','nowrap')
:wikitext(((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")..
translate("headoftable",1,womenrace_boolw_race))
if displaytypeofstage==true then tRow:tag('th') end
Line 7.480 ⟶ 7.522:
tCell=tRow:tag('td')
if ii~=#stageinfotable and v.somewinner==true then
tCell:wikitext(translate("listofstagesclassification",1,womenrace_boolw_race)) --not attributed
elseif ii~=#stageinfotable then
--empty
elseif v.somewinner==true then --general row
tCell:cssText('border-top: 2px black solid')
:wikitext(translate("listofstagesclassification",1,womenrace_boolw_race)) --not attributed
else
tCell:cssText('border-top: 2px black solid') --empty
Line 7.498 ⟶ 7.540:
--M) Start list
function p.startlist(frame)
local tempID, lf=get_and_checkID(frame)
local IDtemp
local w_race=isWomenrace(tempID)
if frame.args[1] ~= nil then
IDtemp=string.gsub(frame.args[1], "%c", "")
end
local womenrace_bool=isWomenrace(IDtemp)
local s = {
header_function = "startlist",
header_1 = 1, -- translation 1 in function victories is printed in the upper part of the table header
header_2 = {2, 3,4,5},
item=IDtemptempID,
title="Start list",
data_sort_type={'unsortable', 'unsortable', 'unsortable'},
property ='P710',
no_roll_startlist=no_roll_startlist,
w_race=w_race,
womenrace_bool=womenrace_bool
lf=lf
}
 
Line 7.520 ⟶ 7.560:
 
function p.startlisttable(frame)
local tempID, lf=get_and_checkID(frame)
local IDtemp
local w_race=isWomenrace(tempID)
if frame.args[1] ~= nil then
IDtemp=string.gsub(frame.args[1], "%c", "")
end
local womenrace_bool=isWomenrace(IDtemp)
 
local s = {
Line 7.530 ⟶ 7.567:
header_1 = 1, -- translation 1 in function victories is printed in the upper part of the table header
header_2 = {2, 3,4,5},-- translations 2, 3, 4, 5, 6 in function victories are printed in this order
item=IDtemptempID,
title="Start list", -- in the lower part of the table header. The second value 3 in {4, 3} tells where the icon will go.
no_country ={'fr'},
Line 7.536 ⟶ 7.573:
property ='P710',
no_roll_startlist=no_roll_startlist,
w_race=w_race,
womenrace_bool=womenrace_bool
lf=lf
}
return startlisttable_main(s, tableA(s))
end
 
local function startlist_sub(p710, timeOfRace, WDlink_on, istable,womenrace_boolw_race)
--Return a table containing a row for the selected rider and their associated team, link, etc
local h, resultTable= {}, {}
local h = {}
local tBody = '' --row in our case
local riderID, riderTeamLink, riderTeamID, riderDossard, riderLink, riderRank
Line 7.565 ⟶ 7.604:
if q and q.P1534 and q.P1534[1].snaktype == 'value' then
local dnf=q.P1534[1].datavalue.value.id
if dnf=='Q1210380' then riderDNF =translate("startlist",6,womenrace_boolw_race)--"HD","NP","DQ"
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7,womenrace_boolw_race)
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8,womenrace_boolw_race)
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9,womenrace_boolw_race)
else riderDNF=''
end
Line 7.613 ⟶ 7.652:
end
riderTeamLink, riderTeamID, catID, countryID, national_team_boolean = getTeam(riderID, timeOfRace, q)
riderTeamID=seasonToTeamID(riderTeamID)
riderTeamCode= getTeamCode(riderID, timeOfRace, q)
--Custom display for national selection
if national_team_booleandata.natTeamCats[catID] and countryID then
if riderTeamCode and wikibase.getSitelink(countryID) then --for the refugee case
riderTeamCode='[['..wikibase.getSitelink(countryID)..'|'..riderTeamCode..']]'
Line 7.628 ⟶ 7.667:
riderLink =riderLink..jerseytemp
 
if riderTeamLink == nil then riderTeamLink ="" end
local sortkey = riderDossard == "" and 0 or tonumber(riderDossard)
 
Line 7.638 ⟶ 7.676:
if wiki == "ar" then td_css = "text-align:right;padding:0 0.5em" end
if istable then
tBody:tag('td'):cssText(td_css):wikitext(riderTeamLink or "")
end
tBody:tag('td'):cssText('text-align:'..textalign.. ';padding:0 0.5em;'..DSQ):wikitext(number(gender,riderRank,wiki)..riderDNF)
 
--table.insert(resultTable, )
return {sortkey=sortkey, riderTeamLink=riderTeamLink,riderTeamID=riderTeamID,riderTeamCode=riderTeamCode, tBodybody=tBody})
return resultTable
end
 
Line 7.652 ⟶ 7.690:
 
local timeOfRace=getTimeOfRace(s.item)
local womenrace_boolw_race=isWomenrace(s.item)
 
for _,p286 in statements(s.item, 'P286') do--look for DS
DSID = p286.mainsnak.datavalue.value.id
DSLink= getRiderLink(DSID, timeOfRace)
DSteamID=nil
q= p286.qualifiers
if q.P642P54 and q.P642P54[1].snaktype == 'value' then
DSteamID=q.P54[1].datavalue.value.id
elseif q.P642 and q.P642[1].snaktype == 'value' then --fallback
DSteamID=q.P642[1].datavalue.value.id
DSteamID=seasonToTeamID(DSteamID)
end
if DSteamID then DSteamID=seasonToTeamID(DSteamID) end
table.insert(DStable, {DSLink=DSLink, DSteamID=DSteamID})
end
 
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
subtable=table.insert(ridertable, startlist_sub(p710, timeOfRace, WDlink_on, false,womenrace_boolw_race))
ridertable[#ridertable + 1] = {
subtable[1].sortkey,
riderTeamLink=subtable[1].riderTeamLink,
riderTeamID=subtable[1].riderTeamID,
riderTeamCode=subtable[1].riderTeamCode,
tBody=subtable[1].tBody
}
end
table.sort(ridertable, function(a, b) --sort by team and then by bib and then by team
if a['sortkey'] ~= b['sortkey'] then --sort by bib
--sort
table.sort(ridertable, function(a, b) return a[1'sortkey'] < b[1'sortkey'] end)
else
 
return (a['riderTeamCode'] or 'a') < (b['riderTeamCode'] or 'a') --order does not matter for nil
end
end)
local thisTableRow, thisTeamTable, thisDS, insideTable, test
local tSubtitle, tTitle
Line 7.686 ⟶ 7.723:
tSubtitle:tag('td'):attr('width','30px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",2,womenrace_boolw_race))
tSubtitle:tag('td'):attr('width','200px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",3,womenrace_boolw_race))
tSubtitle:tag('td'):attr('width','85px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",4,womenrace_boolw_race))
else
tSubtitle=mw.html.create('tr')
tSubtitle:tag('td'):attr('width','30px'):wikitext(translate("startlist",2,womenrace_boolw_race))
tSubtitle:tag('td'):attr('width','250px'):wikitext(translate("startlist",3,womenrace_boolw_race))
tSubtitle:tag('td'):attr('width','35px'):wikitext(translate("startlist",4,womenrace_boolw_race))
end
 
Line 7.708 ⟶ 7.745:
else
for ii=1,#ridertable do
--new team
if ridertable[ii].riderTeamLink==nil then ridertable[ii].riderTeamLink=translate("startlist",13,womenrace_bool) end
if not (ii~=1 and ridertable[ii].riderTeamID and ridertable[ii].riderTeamID==ridertable[ii-1].riderTeamID) thenor testii=0 else test=1 endthen --teamridertable[ii].riderTeamID and change
--new team
if test==1 or ii==1 then
if thisDS and ii~=1 then
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5,womenrace_boolw_race).." "..thisDS)
thisDS=nil
end
Line 7.741 ⟶ 7.776:
:attr('align','center')
local tCell=tTitle:tag('th'):attr('colspan','3')
tCell:tag('big'):wikitext((ridertable[ii].riderTeamLink or translate("startlist",13,w_race)).."<br/>"..(ridertable[ii].riderTeamCode or "___"))
insideTable:node(tTitle)
Line 7.758 ⟶ 7.793:
end
end
--add the rider, also for old team
insideTable:node(ridertable[ii].tBody)
insideTable:node(ridertable[ii].body)
end
--last DS
Line 7.764 ⟶ 7.800:
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5,womenrace_boolw_race).." "..thisDS)
end
tag:node(thisTableRow)
Line 7.771 ⟶ 7.807:
end
end
 
local KeytoRiderRankingCode={
["women"]= 2,
['WWT']= 3,
['WWC']= 4,
["UWT"]= 5,
["europe"]= 6,
["asia"]= 7,
["oceania"]=8,
["america"]=9,
["africa"]= 10,
["WR"]= 11,
["WC"]= 12,
["UPT"]= 13, --WC is world calendar here
["UCImen"]= 14,
["WCmen"]= 15, --UCImen = UCI ranking 1984-2004, WC= World cup men
["Pernod"]= 16,
["Desgrange"]=17,
}
 
function startlisttable_main(s, resultTable)
Line 7.779 ⟶ 7.834:
 
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
localtable.insert(t_Body, subtable=startlist_sub(p710, timeOfRace, WDlink_on, true))
t_Body[#t_Body + 1] = {subtable[1].sortkey, tostring(subtable[1].tBody)}
end
 
return sortAndConcat(t_Body, resultTable)
end
Line 7.797 ⟶ 7.852:
 
function p.riderranking(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
item = tempID,
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
lf=lf
}
return riderranking_main(frame, s)
end
 
local function checkWorldTourTeam(itemID,year)
 
local thisdate='+'..tostring(year).."-07-01T00:00:00Z"
function riderranking_main(frame,s)
local catID
local thisCompetition, rank, thisyear, sitelink, q, gender, DSQ
local resultTable, listofcalendar, UCImaster, UCImasterlimist={},{},{},{}
local minmaxyear= {
minimum = 0, -- lots of jerseyID
maximum = 0 -- points, time, time_gap, speed
}
local calendarlistpresent={
["UCIwomen"]=false,
["UCImen"]=false
}
for _, s in statements(itemID, 'P54') do
local UCI = {}
p54 =checktime(s, s.qualifiers, thisdate) --present Team
--inverse the table
if p54 then
teamId= p54.mainsnak.datavalue.value.id
_, catID=getTeamLinkCat(teamId, thisdate)
if catID=="Q6154783" or catID=="Q20638319" then
return true
end
end
end
return false
end
 
local function ranking_legend()
local UCIlink, legend
if wiki=="fr" then
UCIlink="https://www.uci.org/fr/route/classements" --see also https://dataride.uci.org/iframe/Rankings/10/
legend= " Légende : nc = non classé"
else
UCIlink="https://www.uci.org/road/rankings"
legend=""
end
return UCIlink, legend
end
 
local function riderranking_sub(w_race)
local listofcalendar=data.listofmencalendar
if w_race then
listofcalendar=data.listofwomencalendar
end
 
local UCIQtoYear={}
for k,v in pairs(data.UCIYearToQ) do
UCIUCIQtoYear[k]={}
for kk, vv in pairs(v) do
UCIUCIQtoYear[k][vv]=kk --calendar/Q = year
end
end
return listofcalendar, UCIQtoYear
end
local UCImaster=data.UCImaster
 
function riderranking_main(s)
local lf=s.lf
local thisCompetition, rank, thisyear, sitelink, q, gender, DSQ
local calendarlistpresent={}
 
local gender=getGenderCode(s.item, 'm')
local womenrace_boolw_race=false
if gender=="f" then womenrace_boolw_race=true end
 
local minmaxyear= { minimum = 0, maximum = 0 }
UCImastername={
local listofcalendar, UCIQtoYear=riderranking_sub(w_race)
["women"]= translate("riderranking",2,womenrace_bool),
['WWT']= translate("riderranking",3,womenrace_bool),
['WWC']= translate("riderranking",4,womenrace_bool),
["UWT"]= translate("riderranking",5,womenrace_bool),
["europe"]= translate("riderranking",6,womenrace_bool),
["asia"]= translate("riderranking",7,womenrace_bool),
["oceania"]=translate("riderranking",8,womenrace_bool),
["america"]=translate("riderranking",9,womenrace_bool) ,
["africa"]= translate("riderranking",10,womenrace_bool),
["WR"]= translate("riderranking",11,womenrace_bool),
["WC"]= translate("riderranking",12,womenrace_bool),
["UPT"]= translate("riderranking",13,womenrace_bool), --WC is world calendar here
["UCImen"]= translate("riderranking",14,womenrace_bool),
["WCmen"]= translate("riderranking",15,womenrace_bool), --UCImen = UCI ranking 1984-2004, WC= World cup men
["Pernod"]= translate("riderranking",16,womenrace_bool),
["Desgrange"]=translate("riderranking",17,womenrace_bool),
}
 
local resultTable={}
UCImasterlimit={
["women"]= {b=1989, e=0}, --women=Calendrier international féminin UCI, begin/end 0 = no end
["WWT"]= {b=2016, e=0},
["WWC"]= {b=1998, e=2015},
["UWT"]= {b=2011, e=2018},
["europe"]= {b=2005, e=0},
["asia"]= {b=2005, e=0},
["oceania"]={b=2005, e=0},
["america"]={b=2005, e=0},
["africa"]= {b=2005, e=0},
["WR"]= {b=2016, e=0},
["WC"]= {b=2009, e=2010},
["UPT"]= {b=2005, e=2008},
["UCImen"]= {b=1984, e=2004},
["WCmen"]= {b=1989, e=2004},
["Pernod"]= {b=1959, e=1987},
["Desgrange"]= {b=1948, e=1958},
}
local listofwomencalendar={"women","WWC", "WWT"} --"women" is in fact UCIwomen
local listofmencalendar={"Desgrange","Pernod","UCImen","WCmen","UPT",
"WC","UWT","WR","europe","asia","america","oceania","africa","Pro"}
if gender=="f" then
listofcalendar=listofwomencalendar
else
listofcalendar=listofmencalendar
end
--init table
for ii=1900,2100,1 do
resultTable[tostring(ii)]={}
for _, calendar in pairs(listofcalendar) do
resultTable[tostring(ii)][calendar]={}
rank=nil,
sitelink=nil
}
end
end
Line 7.892 ⟶ 7.928:
for _, p1344 in statements(s.item, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
for _, calendar in pairs(listofcalendar) do
if UCIUCIQtoYear[calendar][thisCompetition] then
thisyear=UCIUCIQtoYear[calendar][thisCompetition]
minmaxyear=checkminmaxyear(minmaxyear,thisyear)
q = p1344.qualifiers
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
resultTable[thisyear][calendar]["rank"] = tostring(tonumber(q.P1352[1].datavalue.value.amount)) --without the tonumber, there can be +1 instead of 1
resultTable[thisyear][calendar]["DSQ"] = isdisqualified(p1344, q) or ""
else
rank= nil
end
if rank then
resultTable[thisyear][calendar]["rank"]=tostring(rank)
resultTable[thisyear][calendar]["DSQ"]=DSQ or ""
calendarlistpresent[calendar]=true
sitelink=mw.wikibase.getSitelink(thisCompetition)
Line 7.923 ⟶ 7.952:
local tRow= finalTable:tag('tr'):tag('th')
:css("background-color",backgroundColor)
:wikitext(wdLin..' '..translate("riderranking",1,womenrace_boolw_race)) --year
 
for ii=minmaxyear.minimum,minmaxyear.maximum,1 do
Line 7.935 ⟶ 7.964:
for _, calendar in pairs(listofcalendar) do
if calendarlistpresent[calendar] then
sitelink=mw.wikibase.getSitelink(data.UCImaster[calendar])
local tRow=finalTable:tag('tr')
local tCell = tRow:tag('th'):cssText("text-align:" .. textalign .. ";") -- left
local calendar_name=translate("riderranking",data.KeytoRiderRankingCode[calendar],w_race)
if sitelink then
tCell:wikitext('[['..sitelink..'|'..UCImastername[calendar]calendar_name..']]')
else
tCell:wikitext(UCImastername[calendar]calendar_name)
end
Line 7.947 ⟶ 7.977:
thisyear=tostring(yy)
color="white"
local impossible=false
if resultTable[ thisyear][calendar]["rank"] then
--we need to check the impossibility here, as it is impossible even if nothing is in P1344
if resultTable[thisyear][calendar]["rank"]=="1" then
if data.continental_calendar[calendar] then
color="gold"
--between 2005 and 2015 WorldTour team member cannot score by continental calendars.
elseif (2<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=3) then
if tonumber(thisyear)>=2005 and tonumber(thisyear)<=2015 then
color="YellowGreen"
if checkWorldTourTeam(s.item,thisyear) then
elseif (4<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=10) then
color impossible="silver"true
end
--between 2016 and 2018 no contradiction
--after 2019, it depends on the nationality
elseif tonumber(thisyear)>=2019 then
local countryID=getNationality(s.item,'+'..tostring(year).."-07-01T00:00:00Z")
if data.continental_calendar[calendar] and not data.continental_calendar[calendar][countryID] then
impossible=true
end
end
elseif calendar=="UWT" then
--non member of World Tour team cannot point in the WT
if tonumber(thisyear)>=2005 and tonumber(thisyear)<=2015 then
if not checkWorldTourTeam(s.item,thisyear) then
impossible=true
end
end
end
 
tCell=tRow:tag('td'):attr("bgcolor",color):cssText(if resultTable[ thisyear][calendar]["DSQrank"]) or impossible then
if impossible then
local rank=tonumber(resultTable[thisyear][calendar]["rank"])
tRow:tag('td'):css('background-color',backgroundColorLight)
rank=number(gender,rank,wiki)
if resultTable[thisyear][calendar]["sitelink"] then
tCell:wikitext('[['..resultTable[thisyear][calendar]["sitelink"]..'|'..rank..']]')
else
if resultTable[thisyear][calendar]["rank"]=="1" then
tCell:wikitext(rank)
color="gold"
elseif (2<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=3) then
color="YellowGreen"
elseif (4<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=10) then
color="silver"
end
 
tCell=tRow:tag('td'):attr("bgcolor",color):cssText(resultTable[thisyear][calendar]["DSQ"])
local rank=tonumber(resultTable[thisyear][calendar]["rank"])
rank=number(gender,rank,wiki)
if resultTable[thisyear][calendar]["sitelink"] then
tCell:wikitext('[['..resultTable[thisyear][calendar]["sitelink"]..'|'..rank..']]')
else
tCell:wikitext(rank)
end
end
--this ranking exist for this year, but the rider is not ranked
elseif yy>=UCImasterlimitdata.UCIcalendarstartend[calendar].b and
(UCImasterlimitdata.UCIcalendarstartend[calendar].e==0 or yy<=UCImasterlimitdata.UCIcalendarstartend[calendar].e) then
if wiki=="fr" then
tRow:tag('td'):wikitext(' nc ')
Line 7.979 ⟶ 8.038:
end
end
 
local UCIlink, legend
if wiki=="fr" then
UCIlink="https://www.uci.org/fr/route/classements"
legend= " Légende : nc = non classé"
else
UCIlink="https://www.uci.org/road/rankings"
legend=""
end
local tableyearsize=minmaxyear.maximum-minmaxyear.minimum+2
local UCIlink, legend=ranking_legend()
finalTable:tag('tr'):tag('td'):addClass("navigation-only")
Line 8.001 ⟶ 8.052:
:wikitext(legend)
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1,womenrace_boolw_race).."["..UCIlink..' UCI]')
 
return finalTable
end
end
 
function p.teamranking(frame)
local tempID, lf=get_and_checkID(frame)
local calendar_key=get_arg(2,frame)
if not calendar_key or calendar_key == "" then return "" end
local w_race=false
if calendar_key=="women" or calendar_key=="WWT" or calendar_key=="WWC" then
w_race=true
end
 
local s = {
header_function = "riderranking",
header_1 = data.KeytoRiderRankingCode[calendar_key] or 1,
header_2 = {1, 18, 19},
property="P527",
data_sort_type = {'unsortable', 'unsortable', 'unsortable'},
item = tempID,
calendar_key=calendar_key,
lf=lf,
w_race=w_race
}
return teamranking_main(s,tableA(s))
end
 
local function get_teamranking(seasonID, w_race, UCIQtoYear,listofcalendar, tTable,gender)
--fill resultTable
local done, thisyear, q, done, rider, riderLink, countryID, rank, thisdate, teamrank
for _, p1344 in statements(seasonID, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
 
for _, calendar in pairs(listofcalendar) do
if UCIQtoYear[calendar][thisCompetition] then
thisyear=UCIQtoYear[calendar][thisCompetition]
thisdate='+'..tostring(thisyear).."-07-01T00:00:00Z"
rank=nil
if tTable[calendar] then
tTable[calendar][thisyear]={}
else
error("tTable badly initialized")
end
q = p1344.qualifiers
done=false
--get team rank
local suffix=""
if calendar== "UCImen" then --case of GSI (Q20653563), GSII (Q20653564) and GSIII (Q20653566)
propertyOf_id=nil
if q and q.P279 and q.P279[1].snaktype == 'value' then
propertyOf_id=q.P279[1].datavalue.value.id
elseif q and q.P642 and q.P642[1].snaktype == 'value' then
propertyOf_id=q.P642[1].datavalue.value.id
end
if propertyOf_id=="Q20653564" then
suffix=" (GSII)"
elseif propertyOf_id=="Q20653566" then
suffix=" (GSIII)"
end
end
 
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
teamrank= tonumber(q.P1352[1].datavalue.value.amount)
tTable[calendar][thisyear]["teamrank"]=number(gender,teamrank,wiki)..suffix
done=true
end
--get best rider rank
if q and q.P1545 and q.P1545[1].snaktype == 'value' then --participant
rank = tostring(tonumber(q.P1545[1].datavalue.value))
done=true
end
--get best rider
if q and q.P710 and q.P710[1].snaktype == 'value' then --participant
rider = q.P710[1].datavalue.value.id
riderLink = getRiderLink(rider, thisdate)
countryID = getNationality(rider, thisdate)
if countryID then
riderLink = flag(countryID, thisdate) .. ' ' .. riderLink
end
if rank then
rank=number(gender,tonumber(rank),wiki)
riderLink=riderLink.." ("..rank..")"
end
tTable[calendar][thisyear]["rider"]=riderLink
done=true
end
 
sitelink=mw.wikibase.getSitelink(thisCompetition)
tTable[calendar][thisyear]["sitelink"]=sitelink
end
end
end
return tTable
end
 
function teamranking_main(s, resultTable)
local lf=s.lf
local t_Body = {}
local gender="m"
if s.w_race then gender="f" end
 
--init, reverse UCIQtoYear
local UCIQtoYear={}
UCIQtoYear[s.calendar_key]={}
if data.UCIYearToQ[s.calendar_key] then
local v=data.UCIYearToQ[s.calendar_key]
for kk, vv in pairs(v) do
UCIQtoYear[s.calendar_key][vv]=kk
end
end
 
local tTable={}
tTable[s.calendar_key]={}
for ii, p527 in statements(s.item, "P527") do
tTable=get_teamranking(p527.mainsnak.datavalue.value.id, w_race,
UCIQtoYear,{s.calendar_key}, tTable,gender)
end
local t=tTable[s.calendar_key]
if t then
for thisyear, v in pairs(t) do
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 0.5em;")
local tCell=tRow:tag('td'):css("text-align",textalign)
if v["sitelink"] then
tCell:wikitext('[['..v["sitelink"]..'|'..thisyear..']]')
else
tCell:wikitext(thisyear)
end
if v["teamrank"] then
tRow:tag('td'):wikitext(v["teamrank"]):css("text-align","center")
else
tRow:tag('td'):wikitext(" - "):css("text-align","center")
end
if v["rider"] then
tRow:tag('td'):wikitext(v["rider"])
else
tRow:tag('td'):wikitext(" - ")
end
table.insert(t_Body, {sortkey=thisyear, body=tRow})
end
end
resultTable=sortAndConcat(t_Body, resultTable)
local UCIlink, _=ranking_legend()
local tRow=resultTable:tag('tr')
tRow:tag('td'):addClass("navigation-only")
:attr('colspan',tostring(3))
:cssText("border-top: 2px "..backgroundColor.." solid; font-size: 80%;")
tRow=resultTable:tag('tr')
local tCell=tRow:tag('td'):attr('colspan',tostring(3)):tag('small')
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1,w_race).."["..UCIlink..' UCI]')
return resultTable
end
 
 
Line 8.050 ⟶ 8.259:
local riderteam={}
local stagiaire
--initially initialYear is the birthyear of the rider
--end year is now +10 years, or the death date
--let's reduce the range (note: it may be slightly over-engineered, maybe it can be deleted and just assume 10 years in the future is sufficient)
local today=os.date("*t")
local t1=tonumber(today['year'])
local t2=math.min(finalYear, tonumber(today['year']))
local t_initialYear=t1
local t_finalYear=t2
 
for ii, p54 in statements(itemID, PID) do --itemID loaded in presentTeam
local q = p54.qualifiers
if q then
local sTime, eTime=getStartEndfromQuali(q)
--min/max
if sTime then
y=tonumber(string.sub(sTime, 2, 5))
if y < t_initialYear then
t_initialYear=y
end
if y>t_finalYear then
t_finalYear=y
end
end
if eTime then
y=tonumber(string.sub(eTime, 2, 5))
if y < t_initialYear then
t_initialYear=y
end
if y>t_finalYear then
t_finalYear=y
end
end
end
end
if t_initialYear~=t1 then initialYear=t_initialYear end
if t_finalYear~=t2 then finalYear=t_finalYear end
 
for ii, p54 in statements(itemID, PID) do --itemID loaded in presentTeam
Line 8.071 ⟶ 8.317:
end
end
return riderteam, initialYear, finalYear
end
 
Line 8.107 ⟶ 8.353:
 
if managedTeam then
cat=data.nationalcat
else
cat=data.amateurcat
end
 
Line 8.336 ⟶ 8.582:
 
local function listOfManagedTeamTable(itemID, initialYear,finalYear)
local managedTeamRider, initialYear, finalYear = listofTeam(itemID, initialYear,finalYear,'P6087')--raw list of team
if not managedTeamRider then
return nil, nil
Line 8.349 ⟶ 8.595:
 
local function listOfTeamTable(itemID, initialYear,finalYear)
local teamRider, initialYear, finalYear = listofTeam(itemID, initialYear,finalYear,'P54')--raw list of team
if not teamRider then
return nil, nil
Line 8.365 ⟶ 8.611:
end
 
local function getBirthDeathDate(entityID, display_age)
local birthDate=firstValue(entityID, 'P569', 'time')
local deathDate=firstValue(entityID, 'P570', 'time')
Line 8.371 ⟶ 8.617:
local gender=getGenderCode(entityID, 'm')
local womenrace_boolw_race=false
if gender=="f" then womenrace_boolw_race=true end
 
if birthDate then
Line 8.384 ⟶ 8.630:
local ans
if gen_singular then
ans=translate("riderinfobox",48,womenrace_boolw_race)
elseif gen_plural then
ans=translate("riderinfobox",49,womenrace_boolw_race)
else
ans=translate("riderinfobox",50,womenrace_boolw_race)
end
 
Line 8.412 ⟶ 8.658:
local ans
if gen_singular then
ans=translate("riderinfobox",48,womenrace_boolw_race)
elseif gen_plural then
ans=translate("riderinfobox",49,womenrace_boolw_race)
else
ans=translate("riderinfobox",50,womenrace_boolw_race)
end
if display_age==false then
Line 8.453 ⟶ 8.699:
teamLinkRoad=teamLink
elseif dis=='mountainBike' then
row=teamLink..' (VTT'..translate("riderinfobox",56,w_race)..')'
elseif dis=='cycloCross' then
row=teamLink..' (cyclo-cross'..translate("riderinfobox",57,w_race)..')'
else
row=teamLink..' (piste'..translate("riderinfobox",58,w_race)..')'
end
if row then
Line 8.500 ⟶ 8.746:
 
--for wikidata input
local function teamTable(tab, teamAmateur, title_singular, title_plural)
if teamAmateur and #teamAmateur>0 then
if #teamAmateur==1 then
Line 8.515 ⟶ 8.761:
end
if v['stagiaire'] then
local stagiaire = string.gsub(wikibase.labelgetLabelFallback('Q2328847',lang_priority), "%b()", "") or getLabelFallback('Q2328847',{'en', 'fr', 'de'})
nametemp=nametemp..' ('..stagiaire..')'
end
Line 8.524 ⟶ 8.770:
 
--for local data
local function localTeamTable(tab, names, periods, title_singular, title_plural)
if names then
names = mw.text.split(names, '<br />')
Line 8.541 ⟶ 8.787:
 
function p.riderinfobox(frame)
local frame = frame
local lang = contentLanguage
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
local entityID, lf = get_and_checkID(frame)
 
local localframe
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
localframe = frame:getParent()
else
localframe = frame
end
local entityID = mw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
local gender=getGenderCode(entityID, 'm')
local womenrace_boolw_race=false
if gender=="f" then womenrace_boolw_race=true end
 
local details = {
{ name = translate("riderinfobox",1,womenrace_boolw_race), name_plural =translate("riderinfobox",2,womenrace_boolw_race)}, -- birth name
{ name = translate("riderinfobox",3,womenrace_boolw_race), name_plural =translate("riderinfobox",4,womenrace_boolw_race)}, -- nick name
{ name = translate("riderinfobox",5,womenrace_boolw_race), name_plural =translate("riderinfobox",6,womenrace_boolw_race)}, -- official name
{ name = translate("riderinfobox",7,womenrace_boolw_race), name_plural =translate("riderinfobox",8,womenrace_boolw_race)}, -- official name
{ name = translate("riderinfobox",9,womenrace_boolw_race) }, -- birth translate("riderinfobox",9)
{ name = translate("riderinfobox",10,womenrace_boolw_race)}, -- death
{ name = translate("riderinfobox",11,womenrace_boolw_race), name_plural =translate("riderinfobox",12,womenrace_boolw_race)}, -- country
{ name = translate("riderinfobox",13,womenrace_boolw_race), name_plural =translate("riderinfobox",14,womenrace_boolw_race)}, -- present team
{ name = translate("riderinfobox",15,womenrace_boolw_race), name_plural =translate("riderinfobox",16,womenrace_boolw_race)}, -- speciality
{ name = translate("riderinfobox",17,womenrace_boolw_race) }, -- lateralisation
{ name = translate("riderinfobox",18,womenrace_boolw_race) }, -- blood group
{ name = translate("riderinfobox",19,womenrace_boolw_race) }, -- height
{ name = translate("riderinfobox",20,womenrace_boolw_race) }, -- weight
{ name = translate("riderinfobox",21,womenrace_boolw_race), name_plural =translate("riderinfobox",22,womenrace_boolw_race)}, -- awards
}
local teams = {
{ name = translate("riderinfobox",23,womenrace_boolw_race), name_plural =translate("riderinfobox",24,womenrace_boolw_race)}, -- directed teams
{ name = translate("riderinfobox",25,womenrace_boolw_race)}, -- directed years
{ name = translate("riderinfobox",26,womenrace_boolw_race), name_plural =translate("riderinfobox",27,womenrace_boolw_race)}, -- amateur names
{ name = translate("riderinfobox",28,womenrace_boolw_race)}, -- amateur periods
{ name = translate("riderinfobox",29,womenrace_boolw_race), name_plural =translate("riderinfobox",30,womenrace_boolw_race)}, -- nonUCI names
{ name = translate("riderinfobox",31,womenrace_boolw_race)}, -- nonUCI periods
{ name = translate("riderinfobox",32,womenrace_boolw_race), name_plural =translate("riderinfobox",33,womenrace_boolw_race)}, -- pro names
{ name = translate("riderinfobox",34,womenrace_boolw_race)}, -- pro periods
{ name = translate("riderinfobox",35,womenrace_boolw_race), name_plural =translate("riderinfobox",36,womenrace_boolw_race)}, -- UCI names
{ name = translate("riderinfobox",37,womenrace_boolw_race)}, -- UCI periods
{ name = translate("riderinfobox",52,womenrace_boolw_race), name_plural =translate("riderinfobox",53,womenrace_boolw_race)}, -- national selections
{ name = translate("riderinfobox",54,womenrace_boolw_race)}, -- national selection years
}
 
--separated to have a title
local subtitle = {
{ name = translate("riderinfobox",51,womenrace_boolw_race)}, -- insertion of a sub-title
}
--separated to have a title
local victories = {
{ name = translate("riderinfobox",38,womenrace_boolw_race)}, -- main victories
}
--separated to have a title
local medals = {
{ name = translate("riderinfobox",47,womenrace_boolw_race)}, -- main victories
}
local others = get_others_dic()
 
local othersname = { getLabelFallback(entityID) or ''
{ name = translate("infobox",29,womenrace_bool)}, -- picture
{ name = translate("infobox",30,womenrace_bool)}, -- caption
{ name = translate("infobox",31,womenrace_bool)}, -- map
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,womenrace_bool)}, -- caption map
{ name = translate("infobox",30,womenrace_bool)}, -- caption sectional
}
 
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
 
local display_birthnameastitle=false
Line 8.624 ⟶ 8.848:
if value == wiki then display_birthnameastitle=true end
end
getLocalContent(subtitle, localframelf.args)
if not subtitle[1].content and display_birthnameastitle then
Line 8.643 ⟶ 8.867:
infoGetOthers(others, entityID)
 
getLocalContent(details, localframelf.args)
getLocalContent(teams, localframelf.args)
getLocalContent(others, localframelf.args)
getLocalContent(victories, localframelf.args)
getLocalContent(medals, localframelf.args)
 
local listOfBirthNames, listOfNickNames, listOfOfficialNames, listOfShortNames
Line 8.662 ⟶ 8.886:
if value == wiki then display_age=false end
end
local display_nickname=true
for _, value in pairs(display_nonickname_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_nickname=false end
end
 
local display_cm=false
for _, value in pairs(display_cm_in_riderinfobox) do -- get data if country should be printed in this wiki
if value == wiki then display_cm=true end
end
-- getSomeNames(details, entityID, 'P1477', 1, display_language) --birthname
--less prio than P1477
if display_nickname then
getSomeNames(details, entityID, 'P1559', 1, display_language) --birthname, bis
getSomeNames(details, entityID, 'P1449P1559', 21, display_language) --nickbirthname, namebis
getSomeNames(details, entityID, 'P1449', 2, display_language) --nick name
end
getSomeNames(details, entityID, 'P1448', 3, display_language) --official name
getSomeNames(details, entityID, 'P1813', 4, display_language) --short name
if display_nickname then
getSomeNames(details, entityID, 'P1813', 4, display_language) --short name
end
 
local birth, death, initialYear, finalYear=getBirthDeathDate(entityID, display_age)
Line 8.705 ⟶ 8.944:
--height
if not details[12].content then
details[12].content=getHeight(entityID, display_cm)
end
 
Line 8.727 ⟶ 8.966:
local proWD=true
local managedWD=true
 
local teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack=listOfTeamTable(entityID, initialYear, finalYear)
local nationalTeam, managedTeam=listOfManagedTeamTable(entityID, initialYear, finalYear)
Line 8.778 ⟶ 9.018:
end
 
infoFillOthersDetails(tab, others, details,translate("riderinfobox",55,womenrace_boolw_race),"260px")
if amateurWD then
teamTable(tab, teamAmateur, translate("riderinfobox",26,womenrace_boolw_race), translate("riderinfobox",27,womenrace_boolw_race))
else
localTeamTable(tab,amateurTeam_names, amateurTeam_periods, translate("riderinfobox",26,womenrace_boolw_race), translate("riderinfobox",27,womenrace_boolw_race))
localTeamTable(tab,nonUCITeam_names, nonUCITeam_periods, translate("riderinfobox",29,womenrace_boolw_race), translate("riderinfobox",30,womenrace_boolw_race))
end
if proWD then
teamTable(tab, teamPro, translate("riderinfobox",45,womenrace_boolw_race),translate("riderinfobox",46,womenrace_boolw_race))
teamTable(tab, teamMountainBike, translate("riderinfobox",39,womenrace_boolw_race), translate("riderinfobox",40,womenrace_boolw_race))
teamTable(tab, teamCycloCross, translate("riderinfobox",41,womenrace_boolw_race), translate("riderinfobox",42,womenrace_boolw_race))
teamTable(tab, teamTrack, translate("riderinfobox",43,womenrace_boolw_race), translate("riderinfobox",44,womenrace_boolw_race))
else
localTeamTable(tab,proTeam_names, proTeam_periods,translate("riderinfobox",45,womenrace_boolw_race), translate("riderinfobox",46,womenrace_boolw_race))
localTeamTable(tab,UCITeam_names, UCITeam_periods, translate("riderinfobox",35,womenrace_boolw_race), translate("riderinfobox",36,womenrace_boolw_race))
end
 
--managed teams
if managedWD then
teamTable(tab, nationalTeam, translate("riderinfobox",52,womenrace_boolw_race), translate("riderinfobox",53,womenrace_boolw_race))
teamTable(tab, managedTeam, translate("riderinfobox",23,womenrace_boolw_race), translate("riderinfobox",24,womenrace_boolw_race))
else
localTeamTable(tab,managedTeam_names, managedTeam_periods,translate("riderinfobox",23,womenrace_boolw_race), translate("riderinfobox",24,womenrace_boolw_race))
end
if victories[1].content then
tab:node(addATitle(translate("riderinfobox",38,womenrace_boolw_race)))
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
Line 8.812 ⟶ 9.052:
if medals[1].content then
tab:node(addATitle(translate("riderinfobox",47,womenrace_boolw_race)))
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
:wikitext(medals[1].content)
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/riderinfobox", translate("raceinfobox",26,womenrace_boolw_race), entityID)
return tab
end
 
--=== P) Team infobox
local function get_rider_number(entityID, details, index)
if not details[index].content then
local riders = #wikibase.getAllStatements(entityID, 'P527') -- P527 is 'has part'
if riders > 0 then
local stagiaire = string.gsub(getLabelFallback('Q2328847'), "%b()", "")
local nb_stagiaires=0
for ii, p527 in statements(entityID, 'P527') do
local q = p527.qualifiers
if q and q.P39 and q.P39[1] and q.P39[1].snaktype == 'value' and
q.P39[1].datavalue.value=='Q2328847'then
nb_stagiaires=nb_stagiaires+1
end
end
if nb_stagiaires>0 then
details[index].content = riders ..' ('.. tostring(nb_stagiaires).." "..stagiaire..')'
else
details[index].content = riders
end
end
end
end
 
function p.teamseasoninfobox(frame)
local WDlink_on = (wiki == "mk" or wiki == "ja")
local seasonID, lf = get_and_checkID(frame)
local w_race=isWomenteam(seasonID)
local gender="m"
if w_race then gender="f" end
 
local details = {
{ name = translate("teaminfobox",2,w_race)}, -- sport
{ name = translate("headoftableII",3,w_race)}, -- team
{ name = translate("teaminfobox",3,w_race), name_plural = translate("teaminfobox",4,w_race)}, -- type
{ name = translate("teaminfobox",5,w_race), name_plural = translate("teaminfobox",6,w_race)}, -- UCI-cod
{ name = translate("teaminfobox",7,w_race), name_plural = translate("teaminfobox",8,w_race)}, -- сountry
{ name = translate("getSquadTableColumn",7,w_race)}, --team size
{ name = translate("teaminfobox",13,w_race)}, -- official web site
{ name = translate("teaminfobox",27,w_race), name_plural = translate("teaminfobox",28,w_race)}, --sponsor
{ name = translate("teaminfobox",24,w_race), name_plural = translate("teaminfobox",25,w_race) }, -- bike
{ name = translate("teaminfobox",26,w_race)}, -- budget
}
 
local managers ={
{ name = translate("teaminfobox",14,w_race), name_plural = translate("teaminfobox",15,w_race)}, -- manager --country
{ name = translate("teaminfobox",16,w_race), name_plural = translate("teaminfobox",17,w_race)}, -- sports director
}
 
local others=get_others_dic()
 
infoGetOthers(others, seasonID)
getLocalContent(details, lf.args)
getLocalContent(others, lf.args)
local sport_id=firstValue(seasonID, 'P641', 'id')
local icon = (sport_id == "Q3609") and -- P641 is 'sport', Q3609 is 'road bicycle racing'
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
local name = getLabelFallback(seasonID) or ''
local listOfNames=getFormerNames(seasonID, 'P1448',true)
--1st ist sport
if not details[1].content and sport_id then
details[1].content = WPlinkpure(sport_id)
end
local timeOfRace=getTimeOfRace(seasonID)
local initialYear
if timeOfRace then
initialYear=string.sub(timeOfRace,2,5)
else
error("no timeOfRace found for "..seasonID)
end
local sitelink, catID, _=getTeamLinkCat(seasonID, timeOfRace, nil, true)
--team
if not details[2].content then
details[2].content=sitelink
end
 
--type
listWPlinkChrono(details, 3, seasonID, {'P2094'}, 'rider', initialYear, nil, nil, true)
if not details[3].content then --fallback
if catID then
details[3].content=getRiderLink(catID, timeOfRace) --it is not a rider, but it gives the correct result
end
end
listWPlinkChrono(details, 4, seasonID, {'P1998'}, 'UCIcode', initialYear, nil, true,true)
 
local display_flag=true
listWPlinkChrono(details, 5, seasonID, {'P1532','P17'}, 'country', initialYear, display_flag,nil,true)
 
-- number of riders
get_rider_number(seasonID, details, 6)
 
-- official site
if not details[7].content then
details[7].content = officialSite(seasonID)
end
--Sponsor
listWPlinkChrono(details, 8, seasonID, {'P859'}, 'rider', initialYear, nil, nil, true)
--bike
listWPlinkChrono(details, 9, seasonID, {'P1876'}, 'rider', initialYear, nil, nil, true)
 
--budget
if not details[10].content then
p=firstValue(seasonID,'P2769')
if p and p.mainsnak.snaktype == 'value' then
local amount=p.mainsnak.datavalue.value.amount
local unit=p.mainsnak.datavalue.value.unit
details[10].content=dispmoney(amount, unit)
end
end
local listofcalendar, UCIQtoYear=riderranking_sub(w_race)
 
local tTable={} --no need for year, it is clear
for _, calendar in pairs(listofcalendar) do
tTable[calendar]={}
end
--not over-writable presently
tTable=get_teamranking(seasonID, w_race, UCIQtoYear,listofcalendar, tTable,gender)
 
--Staff, there can be several
-- manager
listWPlinkChrono(managers, 1, seasonID, {'P505'}, 'rider', initialYear, nil, nil, true)
 
-- sports director
listWPlinkChrono(managers, 2, seasonID, {'P286'}, 'rider', initialYear, nil, nil, true)
--Build the table
tab = infoInitTab("300px", name, icon, 2)
infoFillOthersDetails(tab, others, details, translate("teaminfobox",1,w_race))
--in case there are several names
if listOfNames and #listOfNames>1 then --Always display a list of names
tab:node(addATitle(translate("teaminfobox",19,w_race)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
end
end
if managers[1].content or managers[2].content then
tab:node(addATitle(translate("teaminfobox",18,w_race)))
for _, row in ipairs(managers) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
end
end
--Palmares
tab:node(addATitle(translate("raceinfobox",20,w_race)))
local wins = #wikibase.getAllStatements(seasonID, 'P2522')
if wins then
tab:node(addARow(translate("victories",2,w_race),tostring(wins)))
end
 
for calendar, v_calendar in pairs(tTable) do
if v_calendar[initialYear] then
local v=v_calendar[initialYear]
local calendar_name=translate("riderranking",KeytoRiderRankingCode[calendar],w_race)
if v["sitelink"] then
tab:node(addATitle('[['..v["sitelink"]..'|'..calendar_name..']]'))
else
tab:node(addATitle(calendar_name))
end
if v["teamrank"] then
tab:node(addARow(translate("riderranking",20,w_race),v["teamrank"]))
end
if v["rider"] then
tab:node(addARow(translate("riderranking",21,w_race),v["rider"]))
end
end
end
 
-- an empty line with a title under the form in the form of an image or third-party template
if get_arg('jersey',lf) then -- if the jersey is not specified, then the JERSEY header is not displayed
tab:node(addATitle(translate("teaminfobox",20,w_race)))
local outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','3'):css('text-align','center')
tCell:wikitext(get_arg('jersey',lf)) -- adding a form via "argument 2" by an image or an extraneous template
tab:node(outTable)
end
 
-- adding a link to articles about the last and current seasons (the same as for the race)
tab:node(getPreviousNextLine(seasonID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,w_race), seasonID)
return tab
end
 
function p.teaminfobox(frame)
localframe = frame
local lang = contentLanguage
-- If true, winners will have Wikidata logos with link to Wikidata
local WDlink_on = (wiki == "mk" or wiki == "ja")
local entityID, lf = mw.text.trimget_and_checkID(frame.args[1])
local w_race=isWomenrace(entityID)
if type(entityID) ~= 'string' then error('parameter must be a string') end
if not entityID:match('Q%d+') then error('parameter must be a valid Wikidata item (ex: Q42)') end
local womenrace_bool=isWomenrace(entityID)
local tRace = {race={
Line 8.838 ⟶ 9.263:
future,
},
lastEditionMonth,
lastEditionYear,
numberOfEditions,
lastLink,
nextLink,
}
local details = {
{ name = translate("teaminfobox",2,womenrace_boolw_race)}, -- sport
{ name = translate("teaminfobox",3,womenrace_boolw_race), name_plural = translate("teaminfobox",4,womenrace_boolw_race)}, -- type
{ name = translate("teaminfobox",5,womenrace_boolw_race), name_plural = translate("teaminfobox",6,womenrace_boolw_race)}, -- UCI-cod
{ name = translate("teaminfobox",7,womenrace_boolw_race), name_plural = translate("teaminfobox",8,womenrace_boolw_race)}, -- сountry
{ name = translate("teaminfobox",9,womenrace_boolw_race)}, -- creation date
{ name = translate("teaminfobox",10,womenrace_boolw_race)}, -- disparition date
{ name = translate("teaminfobox",11,womenrace_boolw_race)}, -- number of season
{ name = translate("teaminfobox",13,womenrace_boolw_race)}, -- official web site
{ name = translate("teaminfobox",2427,womenrace_boolw_race), name_plural = translate("teaminfobox",2528,womenrace_boolw_race) }, -- bikesponsor
{ name = translate("teaminfobox",2624,womenrace_boolw_race), name_plural = translate("teaminfobox",25,w_race) }, -- budgetbike
{ name = translate("teaminfobox",26,w_race)}, -- budget
}
local others = {get_others_dic()
local managers ={
{ name = translate("infobox",29,womenrace_bool)}, -- picture
{ name = translate("infoboxteaminfobox",3014,womenrace_boolw_race), name_plural = translate("teaminfobox",15,w_race)}, -- captionmanager --country
{ name = translate("infoboxteaminfobox",3116,womenrace_boolw_race), name_plural = translate("teaminfobox",17,w_race)}, -- mapsports director
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,womenrace_bool)}, -- caption map
{ name = translate("infobox",30,womenrace_bool)}, -- caption sectional
}
local managersmanagers_season ={
{ name = translate("teaminfobox",14,womenrace_boolw_race), name_plural = translate("teaminfobox",15,womenrace_boolw_race)}, -- manager --country
{ name = translate("teaminfobox",16,womenrace_boolw_race), name_plural = translate("teaminfobox",17,womenrace_boolw_race)}, -- sports director
}
local details_season = {
{ name = translate("getSquadTableColumn",7,w_race)}, --team size
{ name = translate("victories",2,w_race)} --number of victories
}
 
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}lang_priority) or ''
infoGetOthers(others, entityID)
getLocalContent(details, lf.args)
local localframe
getLocalContent(others, lf.args)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
getLocalContent(managers, lf.args)
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
getLocalContent(managers, localframe.args)
local listOfNames=getFormerNames(entityID, 'P1448')
Line 8.911 ⟶ 9.328:
--creation date
if not details[5].content and creation then
details[5].content = funcDate(creation, "Yonlyyear" )
end
 
Line 8.917 ⟶ 9.334:
local disparition=firstValue(entityID, 'P576', 'time')
if not details[6].content and disparition then
details[6].content = funcDate(disparition,"Yonlyyear")
end
 
--populate tRace
listOfWinners(entityID, tRace,true,lf)
-- number of season
if not details[7].content and tRace.numberOfEditions and tRace.lastEditionYear then
details[7].content = tostring(tRace.numberOfEditions).." (" .. translate("teaminfobox",12,womenrace_boolw_race) .. " "..tostring(tRace.lastEditionYear)..")"
end
 
Line 8.933 ⟶ 9.350:
end
--9 is bike (no Wikidata input)sponsor
listWPlinkChrono(details, 9, entityID, {'P859'}, 'rider', initialYear)
--10 budget
listWPlinkChrono(details, 10, entityID, {'P2769'}, 'money', initialYear)
--10 is bike
listWPlinkChrono(details, 10, entityID, {'P1876'}, 'rider', initialYear)
--11 budget
listWPlinkChrono(details, 11, entityID, {'P2769'}, 'money', initialYear)
 
-- manager
Line 8.953 ⟶ 9.374:
end
--picture at the top
infoFillOthersDetails(tab, others, details, translate("teaminfobox",1,womenrace_boolw_race),"260px")
 
if managers[1].content or managers[2].content then
tab:node(addATitle(translate("teaminfobox",18,womenrace_boolw_race)))
for _, row in ipairs(managers) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
Line 8.963 ⟶ 9.384:
if listOfNames and #listOfNames>0 then --Always display a list of names
tab:node(addATitle(translate("teaminfobox",19,womenrace_boolw_race)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 8.970 ⟶ 9.391:
 
-- an empty line with a title under the form in the form of an image or third-party template
if frame.args[get_arg(2],lf) then -- if the jersey is not specified, then the JERSEY header is not displayed
tab:node(addATitle(translate("teaminfobox",20,womenrace_boolw_race)))
local outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','3'):css('text-align','center')
tCell:wikitext(frame.args[get_arg(2],lf)) -- adding a form via "argument 2" by an image or an extraneous template
tab:node(outTable)
end
 
-- adding a link to articles about the last and current seasons (the same as for the race)
if tRace.nextLink or tRace.lastLinklastID then
-- manager
tab:node(addATitle(translate("teaminfobox",21,womenrace_bool)))
listWPlinkChrono(managers_season, 1, tRace.lastID, {'P505'}, 'rider', tRace.lastEditionYear, nil, nil, true)
local outTable
-- sports director
listWPlinkChrono(managers_season, 2, tRace.lastID, {'P286'}, 'rider', tRace.lastEditionYear, nil, nil, true)
get_rider_number(tRace.lastID, details_season, 1)
 
local wins = #wikibase.getAllStatements(tRace.lastID, 'P2522')
local today=os.date("*t")
if wins and tonumber(tRace.lastEditionYear)==tonumber(today['year']) then --display only if the season if for this year
details_season[2].content=tostring(wins)
end
infoFillOthersDetails(tab, nil, managers_season, translate("teaminfobox",21,w_race),"260px")
infoFillOthersDetails(tab, nil, details_season, nil,"260px")
local outTable
if tRace.lastLink then
outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local lastText="[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("teaminfobox",22,womenrace_boolw_race)..
":<br>'''"..
tRace.lastLink.."'''"
Line 8.998 ⟶ 9.433:
local tCell=outTable:tag('td'):attr('colspan','2'):css('text-align','center')
local nextText = "[[File:Crystal Clear app kworldclock.png|left|37px]]"..
translate("teaminfobox",23,womenrace_boolw_race)..
":<br>'''"..
tRace.nextLink.."'''"
Line 9.006 ⟶ 9.441:
end
 
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,womenrace_boolw_race), entityID)
return tab
end
 
--== teamriderCompetitionranking
function p.teamriderCompetitionranking(frame)
local tempID, lf=get_and_checkID(frame)
local calendarID
local timeOfRace=getTimeOfRace(tempID)
local initialYear
if timeOfRace then
year=string.sub(timeOfRace,2,5)
end
 
local header_1_tab = {["UWT"]=13 ,["europe"]=14 ,["asia"]=15,["america"]=16 ,["africa"]=17 ,["oceania"]=18, ["WWT"]=11, ["women"]=1, ["Pro"]=22}
local header_1_number = 12
local key=get_arg(2,frame)
if key and year then
calendarID=data.UCIYearToQ[key][year]
header_1_number = header_1_tab[key]
end
local w_race=isWomenteam(calendarID)
if not calendarID or calendarID == "" then return "" end
 
local s = {
header_function = "calendar",
header_1 =header_1_number,
header_2 = {2, 3, 5, 4, 24, 23},
data_sort_type = {'', '','', 'unsortable', '', ''},
property="P1344",
calendarID=calendarID,
item = tempID, --should be called item for tableA
lf=lf,
w_race=w_race
}
return teamriderCompetitionranking_main(s,tableA(s))
end
 
local function get_competition_bestrider(RaceID, seasonID, gender)
local riderLink, rank, disqualified, cancelled, q
local bold=false
 
for _, p1344 in statements(seasonID, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
if thisCompetition and thisCompetition==RaceID then
q = p1344.qualifiers
if q then
if q and q.P1352 and q.P1352[1].snaktype == 'value' then --rank
rank= tonumber(q.P1352[1].datavalue.value.amount)
if rank==1 then
bold=true
end
rank=number(gender,rank,wiki)
end
--get best rider
if q and q.P710 and q.P710[1].snaktype == 'value' then --participant
rider = q.P710[1].datavalue.value.id
riderLink = getRiderLink(rider, thisdate)
countryID = getNationality(rider, thisdate)
if countryID then
riderLink = flag(countryID, thisdate) .. ' ' .. riderLink
end
end
_,disqualified=isdisqualified(p1344, q)
if riderLink and disqualified==true then
riderLink='<s>'..riderLink..'</s>'
end
end
end
end
return riderLink, rank, bold
end
 
function teamriderCompetitionranking_main(s, resultTable)--Display the UCI women calendar of one year
local best_rider, rank
local lf = s.lf
local calendarID=s.calendarID
local seasonID= s.item
local t_Body ={}
local w_race=s.w_race
local gender="m"
if w_race then gender="f" end
 
local temp=firstValue(calendarID, s.property)
if not temp or temp=="" then
s.error_message = 2
if wiki == "ar" then return "" end
end
local country=getCountryBool(s.no_country)
 
----- Begin of the main part of the code
local ind=0
for _, p527 in statements(calendarID, 'P527') do
local RaceID = p527.mainsnak.datavalue.value.id
local temp=firstValue(RaceID, 'P1346','id')
local cancelled=false
if temp and temp=='Q30108381' or temp=='Q54806642' or temp=='Q23023872' then --race cancelled
cancelled=true
else
ind=ind+1
end
if not cancelled then
---- Create a row ----
local timeOfRace, date_tCell, date_sortkey = fn_date(RaceID)
local future=compareDate(timeOfRace)
local parentID, race_tCell, _= fn_race(RaceID,nil,false,timeOfRace,nil,country)
if race_tCell~=nil then --otherwise the class is not display
local country_flag, country_name, country_tCell=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
--create the table
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
tRow:node(date_tCell)
tRow:tag('td'):cssText("text-align:center;padding:0 0.5em"):wikitext(tostring(ind)) --correct only if the races are sorted correctly in wikidata
tRow:node(country_tCell)
if country then tRow:node(race_tCell) end
--logic to get the best rider||ranking
riderLink, rank, bold=get_competition_bestrider(RaceID, seasonID, gender)
local tCell=tRow:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.5em")
if riderLink then
tCell:wikitext(riderLink)
elseif future then
tCell:wikitext("")
else
tCell:wikitext(" - ")
end
tCell=tRow:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.5em")
if bold then
tCell:cssText("font-weight:bold;")
end
if rank then
tCell:wikitext(rank)
elseif future then
tCell:wikitext("")
else
tCell:wikitext(" - ")
end
---- Add the row to the table
table.insert(t_Body, {sortkey=date_sortkey, body=tRow})
end
end
end
return sortAndConcat(t_Body, resultTable)
end
 
Line 9.055 ⟶ 9.634:
end
elseif function_name=='getTeamLinkCat' then
temp=getTeamLinkCat(argu[2],argu[3],toboolean(argu[4]),toboolean(argu[5]))
if temp then return temp else return 'nil' end
elseif function_name=='getTeamLinkCat2' then
temp, temp2=getTeamLinkCat(argu[2],argu[3],toboolean(argu[4]))
if temp2 then return temp2 else return 'nil' end
elseif function_name=='getPlaceLink' then
if argu[3]=="nil" then arg3=nil else arg3=argu[3] end
Line 9.095 ⟶ 9.677:
elseif function_name=='isWomenrace' then
return tostring(isWomenrace(argu[2]))
elseif function_name=='isWomenteam' then
return tostring(isWomenteam(argu[2]))
elseif function_name=='commaStage' then
temp =commaStage(argu[2],argu[3])
Line 9.181 ⟶ 9.765:
elseif function_name=='getNationality' then
return getNationality(argu[2], argu[3])
elseif function_name=='getClassCalendar_subgetCountryID' then
return getClassCalendar_subgetCountryID(argu[2], argu[3])
elseif function_name=='get_formatted_date1' then
if argu[3]=="nil" then arg3=nil else arg3=argu[3] end
temp, temp2= get_formatted_date(argu[2], arg3)
if temp then return temp end
elseif function_name=='get_formatted_date2' then
if argu[3]=="nil" then arg3=nil else arg3=argu[3] end
temp, temp2= get_formatted_date(argu[2], arg3)
if temp2 then return temp2 end
elseif function_name=="getSpeed" then
if argu[4]=="nil" then arg4=nil else arg4=tonumber(argu[4]) end
return tostring(getSpeed(argu[2], toboolean(argu[3]),arg4, argu[5]))
elseif function_name=="formatNumber" then
return formatNumber(tonumber(argu[2]), toboolean(argu[3]),tonumber(argu[4]))
end
end
 
Line 9.192 ⟶ 9.788:
 
if function_name=='class_dic' then
return tostring(data.class_dic[argu[2]])
elseif function_name=="class_sort" then
return tostring(data.class_sort[argu[2]])
elseif function_name=='bg_color_table' then
local temp = data.bg_color_table[argu[2]]
temp=string.gsub(temp,'#',"")
return temp