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

Content deleted Content added
Psemdel (kjak | íkøst)
copy from wikidata
Merki: Reverted
Psemdel (kjak | íkøst)
Tak burtur versjón 383351 hjá Psemdel (kjak)
Merkir: Undo 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 48 ⟶ 50:
 
--== 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 61 ⟶ 84:
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 99 ⟶ 93:
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 119 ⟶ 111:
 
--== II) Translation ==
local function translate(func_name_short, index, w_racewomenrace_bool, title)
if index == nil then index=1 end -- for prologue
if index==1000 then --code for some custom function
return title
Line 125 ⟶ 118:
if func_name_short then
local func_name
if w_racewomenrace_bool then
func_name=func_name_short.."_women_translate"
if l10n[func_name] and l10n[func_name][index] then
Line 137 ⟶ 130:
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 168 ⟶ 161:
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 176 ⟶ 169:
end
 
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
local function country_name_from_list(countryID)
local l10nDef = {["fr"]="étape", ["en"]="stage", ["ar"]="المرحلة", ["br"]="Tennad", ["ca"]="etapa", ["cs"]="etapa", ["de"]="Etappe", ["da"]="etape", ["eo"]="Etapo",
if l10n["country_name_list"] and l10n["country_name_list"][countryID] then
["es"]="etapa", ["eu"]="Etapa", ["fi"]="Etappi", ["fo"]="teinur", ["hu"]="szakasz", ["it"]="Tappa", ["ja"]="ステージ", ["la"]="Statio", ["lb"]="Etapp",
return l10n["country_name_list"][countryID]
["lv"]="Posms", ["mk"]="Етапа", ["nl"]="Etappe", ["no"]="etappe", ["pl"]="Etap", ["pt"]="Etapa", ["ro"]="Etapa", ["ru"]="Этап", ["sk"]="Etapa",
end
["sv"]="Etapp", ["ast"]="etapa" }
return nil
end
 
local word1, word2
local function stageLink(x, a, b) -- x= 10a: a = 10, b = a. x = 5: a = 5, b = ""
word2=l10nDef[wiki]
local word1
if word2 == nil then word2=l10nDef["en"] end -- if no translation, show en translation
local word2=translate("func_prologue",2) --stage
local word = word2
 
if wiki=="ar" then return word2 .. " " .. ( a or "" ) , "#" .. word2 .. " " .. ( a or "" ) end
Line 232 ⟶ 224:
-- plain, hilly, inter, ... must be "" or "any text"
-- l10nDef[""] = {plain = "", hilly="", inter='', mount='', time_prologue='', time_team='', time_indiv='', uphill='', rest=''}
local l10nDef = {
local l10n=l10n["type_of_stage_translate"]
["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 249 ⟶ 270:
if x=='time trial stage' then
if noborder then border="" else border="|right" end
if typ=="Q2348250" then return "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_team.."]]" end
local stages2 = {
[if typ=="Q2348250Q2266066"] =then return "[[File:Team Time Trial Stage.svg"..border.."|20px|"..l10n.time_teamtime_indiv.."]]", end
[if typ=="Q2266066Q485321"] = then return "[[File:Time Trial.svg"..border.."|20px|"..l10n.time_indivtime_prologue.."]]", 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'
for _,t in pairs(p) do
local stages = {
["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 iOf == "Q20646667" then sType = typeofstage('plain stage', nil, noborder) break end
if stages[iOf] then
if iOf == "Q20646670" then sType = typeofstage(stages[iOf][1],'hilly stages[iOf][2]stage', nil,noborder) break end
if iOf == "Q20680270" then sType = typeofstage('intermediate stage', nil,noborder) break end
break
if iOf == "Q20646668" then sType = typeofstage('mountain stage',nil, noborder) break end
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 309 ⟶ 319:
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 328 ⟶ 335:
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 431 ⟶ 418:
--[[ 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 456 ⟶ 439:
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 490 ⟶ 473:
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 497 ⟶ 482:
if m=='00' then --manage the 30 November issue
if mode=='long' or mode=="verylong" then
starttime =lang:formatDate( "Y", sTime )
else
Line 504 ⟶ 489:
else
if y ~= y2 then
if mode=='long' or mode=="verylong" then
starttime = lang:formatDate( "j F Y", sTime )
else
Line 510 ⟶ 495:
end
elseif m ~= m2 then
if mode=='long' or mode=="verylong" then
starttime = lang:formatDate( "j F", sTime )
else
Line 572 ⟶ 557:
end
elseif wiki == "pl" then
if y ~= y2 then starttime = lang:formatDate( "j xg", sTime ) .. month_pl[tonumber(lang:formatDate( "n", sTime ))] .. lang:formatDate( " 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 580 ⟶ 565:
if m2=='00' then --manage the 30 November issue
if mode=='long' or mode=="verylong" then
endtime= lang:formatDate( "Y", eTime )
else
Line 586 ⟶ 571:
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 596 ⟶ 581:
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 602 ⟶ 587:
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 611 ⟶ 596:
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 635 ⟶ 620:
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 650 ⟶ 637:
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 dispDate daycorrect= datetrue
local monthcorrect=true
 
if string.sub(date,710,811)=='00' then -- lack ofdaycorrect=false monthend
if string.sub(date,7,8)=='00' then monthcorrect=false end
dispDate= string.sub(date,1,6).."01-01"..string.sub(date,12)
 
if mode == 'long' or mode == 'onlyyear' or mode == 'monthly' then
if mode == 'onlyyearY' 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
return contentLanguage:formatDate(format[mode], date)
mode = 'nodate'
end
else
elseif string.sub(date,10,11)=='00' then -- lack of day
if daycorrect or (monthcorrect==false and daycorrect==false) then --no month
dispDate= string.sub(date,1,9).."01"..string.sub(date,12)
if mode == 'long' then
return string.sub(date,2,5) --only year, note: contentLanguage:formatDate("Y", date) returns the wrong year
mode = 'monthly'
else --otherwise we don't know
elseif mode == 'small' then
mode = return 'onlymonth-'
end
elseif mode == 'onlyday' then
else --month correct, but day incorrect
mode = 'nodate'
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 685 ⟶ 690:
end
 
local function isdisqualified(p,q) --disqualification can use deprecated or P1534
local cancelled=""
local disqualified=false
Line 710 ⟶ 715:
local cyrillic = {mk = true, ru = true}
local strictLangBool= strictLang[wiki] or strict
local correcttime, best, name, nametemp
local wantedLanguages = {}
if available_lang_priority then
for i, lang in ipairs(lang_priority) do
for i, lang in ipairs(translations.lang_priority) do --from Module:Cycling_race/lang
wantedLanguages[lang] = i
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 725 ⟶ 731:
end
if correcttime then
if available_lang_priority and p1448.qualifiers and p1448.qualifiers.P1448 then
local q = p1448.qualifiers.P1448
best = 999
Line 742 ⟶ 748:
lang=p1448.mainsnak.datavalue.value.language
best = 999
if strictLangBool then
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 758 ⟶ 765:
if name then
return name, true
elseif not strictLangBool and nametemp then
return nametemp, false
end
Line 780 ⟶ 787:
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 name == nilavailable_list 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 939 ⟶ 928:
end
end
return name or ''
end
 
Line 957 ⟶ 946:
--[[ 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, forceParentlinkseason)
local name, sitelink, catIDparentID, countryID,catID p31
local national_team_boolean=false
local parentID = getParentID(teamID)
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
iflocal natureID = data.teamCats[p2094.mainsnak.datavalue.value.id] then
if teamCats[natureID] then
catID = p2094.mainsnak.datavalue.value.id
seasoncatID =true natureID
break
end
end
end
--check if season
-- Fallback with P31 (deprecated)
if season==false then --otherwise already clear
for _, pp31 in statements(teamID, 'P31') do
if checktime(p31, p31.qualifiers, timeOfRace) then
local natureID = p.mainsnak.datavalue.value.id
iflocal natureID =="Q53534649" thenp31.mainsnak.datavalue.value.id
if teamCats[natureID] then
season=true
catID = natureID
break
end
Line 983 ⟶ 973:
end
 
--look by the parent, then P31 is used for the category
if (not catID and parentID and season) then
parentID = getParentID(teamID)
p31 = getStatementForTime(parentID, 'P31', timeOfRace)
if parentID then
elseif not season then --it is the team look in the team directly
local p31 = getStatementForTime(teamIDparentID, 'P31', timeOfRace)
if p31 then catID = p31.mainsnak.datavalue.value.id end
end
end
if p31 and data.teamCats[p31.mainsnak.datavalue.value.id] then
catID = catID or 'Q53534649'
catID = p31.mainsnak.datavalue.value.id
end
-- Find country if needed
local countryID
if country or data.natTeamCats[catID] then
if country or catID == 'Q23726798' or catID == 'Q20738667' or catID == 'Q54555994' then
countryID = getCountryID(teamID, timeOfRace)
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] then== 'Q23726798' or catID == 'Q20738667'
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.002 ⟶ 1.000:
name = getCountryName(countryID)
end
if catID == 'Q20738667' then -- national cycling team U23
local t={Q20738667=34, Q54555994=35, Q99658502=36}
local s
if t[catID] then --add U23, U19, B, (note: why "B" and not B)
if wiki == 'fr' then s = ' espoirs'
name = name ..' '..translate("headoftableIII",t[catID])
elseif wiki == 'mk' then s = ' под 23 години'
end
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 notseason forceParentlink== true 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
parentID = getParentID(teamID)
sitelink = wikibase.getSitelink(parentID)
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.026 ⟶ 1.050:
end
if not name or (not isLocal and l10n["lang_priority"]available_lang_priority) then
local partName, partIsLocal = getOfficialName(teamID, timeOfRace)
if partName and (not name or partIsLocal) then
Line 1.053 ⟶ 1.077:
end
end
return sitelink, catID, countryID, national_team_boolean
end
 
Line 1.074 ⟶ 1.098:
end
 
local function getReference(lf,statement, outputLocal)
local function formatRefDate(date, precision)
if precision == 9 then -- Precision is year
Line 1.159 ⟶ 1.183:
refargs.name = refText
end
return lflocalframe: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.242 ⟶ 1.248:
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.264 ⟶ 1.274:
-- ClassID --> ClassLink
-- some WPs use a unique article for this case
local function classLinkFn(classIDclass, circuitID)
local link, label
if wiki~="fr" then --not used
Line 1.272 ⟶ 1.282:
end
 
if classIDclass=="Q18536594" then
if wiki=="fr" then
label="JO"
Line 1.279 ⟶ 1.289:
end
else
label = getLabelFallback(classIDclass, {wikilang, 'en', 'fr', 'de'})
end
 
Line 1.292 ⟶ 1.302:
end
if wiki == "ar" then-- right now Q22348500 has no link in "ar"
link = make_IllWD2_link(classIDclass , "", label)
end
return link
Line 1.298 ⟶ 1.308:
--[[ 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.342 ⟶ 1.353:
end
 
local function checkDis(q) --discipline
dis="road"
if q and q.P642 and q.P642[1] and q.P642[1].snaktype == 'value' then
local sport_id=nil
if q and q.P641 and q.P641P642[1].datavalue.value.id and== 'Q520611' or q.P641P642[1].snaktypedatavalue.value.id == 'valueQ1031445' 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 sport_id q.P642[1].datavalue.value.id == 'Q335638' then
onlyRoad=false
dis="cycloCross"
elseif sport_idq.P642[1].datavalue.value.id == 'Q221635' then
onlyRoad=false
dis="track"
Line 1.372 ⟶ 1.376:
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.381 ⟶ 1.385:
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.387 ⟶ 1.391:
end
end
return link, teamID, catID, countryID, national_team_boolean
end
 
Line 1.431 ⟶ 1.435:
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.447 ⟶ 1.451:
local function getCountryBool(no_country_list)
local country = true
for _, value in pairs(no_country_list) do -- get data if country should be printed in this wiki
if no_country_list then
for _,if value in== pairs(no_country_list)wiki do -- get data ifthen country should= befalse printed in this wikiend
if value == wiki then country = false end
end
end
return country
end
 
local function handle_error_messagetableA(s)
local error_message = ''
if s.error_messagewiki == "ar" and s.error_messageitem ~== 0"" 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)
Line 1.464 ⟶ 1.467:
error_message = ' [[File:Exclam icon.svg|12px|'.. error_message .. ']]'
end
return error_message
local table = mw.html.create('table')
end
 
local function tableA(s)
local error_message=handle_error_message(s)
 
local t = mw.html.create('table')
:addClass('sortable')
:attr('cellpadding', '0')
Line 1.477 ⟶ 1.475:
:css('padding', '3px')
local title =translate(s.header_function,s.header_1, s.w_racewomenrace_bool, 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 = ttable: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.489 ⟶ 1.487:
local country=getCountryBool(s.no_country)
 
local header = ttable: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.w_racewomenrace_bool))
end
end
Line 1.501 ⟶ 1.499:
local column = header:tag('th')
:cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap')
:wikitext(translate(s.header_function,k,s.w_racewomenrace_bool))
if s.data_sort_type[i] == 'unsortable' then
column:addClass('unsortable')
Line 1.508 ⟶ 1.506:
end
 
return ttable
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.536 ⟶ 1.541:
 
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.558 ⟶ 1.563:
:attr('colspan','3'):attr('align','center')
tCell:node(wdlink_span)
tCell:wikitext(translate("startlist",1,s.w_racewomenrace_bool or false))
local tRow=tCell:tag('tr')
 
Line 1.572 ⟶ 1.577:
{'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', '+19801937-0712-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.583 ⟶ 1.586:
{'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', '+19801946-0706-2919'},
{'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', '+19801889-0812-2912'},
{'OlympicFlag flagof Switzerland.svg', '+19801879-0701-19', '+1980-07-2901'}}, -- 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.607 ⟶ 1.603:
Q43 = {'TUR', {'Flag of Turkey.svg'}},
Q45 = {'POR', {'Flag of Portugal.svg', '+1911-06-30'}},
Q55 = {'NED', {'Flag of the Netherlands.svg', '+1980-07-291806'}},
{'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.616 ⟶ 1.610:
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', '+20201794-0705-1420'}},
Q145 = {'GBR', {'Flag of Francethe United Kingdom.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.662 ⟶ 1.651:
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.675 ⟶ 1.662:
Q334 = {'SGP', {'Flag of Singapore.svg'}},
Q347 = {'LIE', {'Flag of Liechtenstein.svg'}},
Q398 = {'BRN ', {'Flag of Bahrain.svg', '+2002-02-1714'}},
{'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.697 ⟶ 1.681:
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.718 ⟶ 1.701:
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.767 ⟶ 1.730:
Q8646 = {'HKG', {'Flag of Hong Kong.svg'}},
Q25228 = {'AIA', {'Flag of Anguilla.svg'}},
Q29999 = {'NED', {'Flag of the Netherlands.svg', '+1980-07-291690'}}, --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.826 ⟶ 1.786:
end
elseif not date then
local p41 = firstValuemw.wikibase.getBestStatements(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.840 ⟶ 1.800:
if arwiki_totemplate then
result = '{{flagicon image|' .. p41.mainsnak.datavalue.value .. '}}'
end
end
end
end
return result .. trackingCategory
Line 1.857 ⟶ 1.817:
--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
if available_list then
countryName=country_name_from_list(countryID)
if countryNametype(translations.list) == nil or blacklist[countryID]"function" then
countryName = translations.list(countryID)
end
end
if countryName == nil or countryName=='' or blacklist[countryID] then
countryName = mw.wikibase.getSitelink(countryID)
end
Line 1.878 ⟶ 1.842:
-- 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.947 ⟶ 1.988:
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 1.959 ⟶ 2.000:
end -- function end
 
--=== E) Other (winner, getkm) ===
local function isHuman(riderId)
local isHuman = false
Line 1.974 ⟶ 2.015:
end
 
local function isCountry(inputIDriderId)
local isCountry = false
if inputIDriderId then
local p31 = wikibase.getBestStatements(inputIDriderId, 'P31')
for _, iOf in pairs (p31) do
-- exception Hong-Kong and Taiwan
Line 1.989 ⟶ 2.030:
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.025 ⟶ 2.054:
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.061 ⟶ 2.083:
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.069 ⟶ 2.091:
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 propertyOfq.P642 and propertyOfq.P642[1].snaktype == 'value' then
for _, qpropq642 in pairs(propertyOfq.P642) do
wOf = qpropq642.datavalue.value.id -- P642 is 'of'
if not wOf then
-- Try P1346 (winner) instead
Line 2.093 ⟶ 2.107:
if winners[wOf] then
if wID then
local reference = ref and getReference(lf,winner)
local _, countryID
if isHuman(wID) then
Line 2.124 ⟶ 2.138:
countryID = getNationality(wID, timeOfRace,q)
else
countryIDlocal p17 = getCountryIDgetStatementForTime(wID, 'P17', timeOfRace) --P27 is country of citizenship
if p17 then
countryID = p17.mainsnak.datavalue.value.id
end
end
end
Line 2.166 ⟶ 2.183:
 
local function sortAndConcat(t_Body, resultTable)
table.sort(t_Body, function(a, b) return a['sortkey'1] < b['sortkey'1] end)
for _, m in ipairs(t_Body) do resultTable:node(m['body'2]) end
return resultTable
end
 
--------- Definition sub-functions for calendar and victory ------
local function getTimeOfRace(raceID, mandatory, p582_prio)
local timeOfRace = firstValue(raceID, 'P580', properties'time')
if timeOfRace==nil then
if p582_prio then --for case like UCI Europe Tour 2006 (Q1455600) where most of the competition is in the next year
timeOfRace = firstValue(raceID, 'P585', 'time') -- P585 is 'point in time'
properties={'P582','P585','P580'}
if timeOfRace==nil then
else
timeOfRace = firstValue(raceID, 'P582', 'time')
properties={'P580','P585','P582'}
if timeOfRace==nil then
end
local link = getSitelinkFallback(raceID, {'en', 'fr', 'de'})
if link then
for _, prop in ipairs(properties) do
local year = string.match(link, '%d%d%d%d')
timeOfRace= firstValue(raceID, prop, 'time')
if year then
if timeOfRace ~= nil then return timeOfRace end
timeOfRace = year .. '-01-01T00:00:00Z'
end
end
 
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
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
returntimeOfRace = '+1970-01-01T00:00:00Z'
end
return timeOfRace, '> Wikidata is missing data about start time (P580) or point in time (P582)'
if mandatory then
error('> Wikidata is missing data about start time (P580) or point in time (P582)')
end
return nil
end
 
local function get_formatted_datefn_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, style1'small')
if functionName==nil or functionName=='infobox' then --calendar, infobox
tempdate return= startTime .. ' – ' .. endTime, sTime, true--mettre year en option!
sortkeyDate = sTime
else --victory, general classification
else --victory, general classification
return endTime, eTime, true
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
returntempdate = funcDate(pTime, style2'small'), pTime, false
timeOfRace = pTime
sortkeyDate = pTime
end
end
local _, _, y, m, d = string.find(sortkeyDate or "", "(%d+)-(%d+)-(%d+)")
return nil
if y~= nil and m~= nil and d~=nil then
end
sortkey = y..m..d
 
elseif y~= nil and m~= nil then
local function fn_date(entityID, functionName) --to move as a general function
sortkey = y..m
local tempdate, timeOfRace, _ = get_formatted_date(entityID, functionName) --is there a reason why timeofrace cannot be sTime??
elseif y~= nil then
 
sortkey = y
local _, _, y, m, d = string.find(timeOfRace or "", "(%d+)-(%d+)-(%d+)")
localelse sortkey =(y or '')..(m or '')..(d or '0000')
end
if sortkey =='' then sortkey = '0000' end
 
local tCell = mw.html.create('td'):attr('data-sort-value',sortkey)
:cssText("style=text-align:right;padding:0 0.5em")
:wikitext(tempdate)
 
outTable["timeOfRace"]=timeOfRace
return timeOfRace, tostring(tCell), sortkey
outTable["tCell"]=tostring(tCell)
outTable["sortkey"]=sortkey
return outTable
end
 
local function fn_country(entityID, timeOfRace,countrycountrybool, 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
local listOfProperty={'P1532','P17'} -- P1512 is 'country for sport' to handle problems with Hong Kong etc.
if countryID then
local listOfID = {entityID, parentID}
country_flag=flag(countryID, timeOfRace)
country_str=country_flag
for _, thisID in ipairs(listOfID) do
country_name = getCountryName(countryID)
if country_namethisID~=''nil then
for _, prop in ipairs(listOfProperty) do
tCell:attr('data-sort-value',country_name)
if country~countryID == falsenil then --like "break"
for _, p1532 in statements(thisID, prop) do
country_str=country_str.." "..country_name
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 countryID == nil then outTable["flag"]="no flag" end
if country==false then
if countryname[1] then tCell:attr('data-sort-value',countryname[1]) end
tCell:wikitext(country_flag.." "..(raceCell or ''))
if countrybool==false then
country_name=''
tCell:wikitext((country[1] or '').." "..(raceCell or ''))
outTable["countryname"]=''
else
if country_strcountryname[1] then
outTable["countryname"]=countryname[1]
tCell:wikitext(country_str)
if country[1] then tCell:wikitext(country[1]) end
else
outTable["countryname"]=''
end
end
outTable["tCell"]=tCell
return country_flag, country_name, tCell
return outTable
end
 
Line 2.368 ⟶ 2.395:
prefix=''; postfix='' --general classification
listOfProperty={'P2561','P1448'}
--system with P3450 and P2094
--main race link is in the parent --can be improved
for _, p31 in statementsinstanceOf=firstValue(entityID, 'P31P3450', 'id') do
--else use P31
instanceOfTemp = p31.mainsnak.datavalue.value.id
if instanceOf==nil then
if instanceOfTemp ~= "Q27020041" and instanceOfTemp ~= 'Q88903067' and data.class_dic[instanceOfTemp]==nil then --but the main race
for _, p31 in statements(entityID, 'P31') do
instanceOf=instanceOfTemp
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.402 ⟶ 2.433:
 
if label==nil then
label=wikibase.label(instanceOf)
label=getLabelFallback(instanceOf,lang_priority) --the case of 'ar' should be handled in lang_priority
if wiki == 'ar' then arlabel = mw.wikibase.getLabelByLang(instanceOf, 'ar') end
if not label then
label = getLabelFallback(entityID,lang_priority {'en', 'fr', 'de'}) or ''
end
end
Line 2.439 ⟶ 2.471:
--affect the label
if label==nil then
label=getLabelFallbackwikibase.label(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.486 ⟶ 2.522:
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.493 ⟶ 2.529:
else --for instance Flèche wallonne
if q then
if q.P279P642 and q.P279P642[1].snaktype == 'value' and q.P279P642[1].datavalue.value.id then --fallback
displayedCircuitID = q.P279P642[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.530 ⟶ 2.564:
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.572 ⟶ 2.584:
end
end
return getPeriodSubSub(sTime, eTime, startTime,endTime,brackets)
end
 
local period
local function getPeriodSub_season(sTime, eTime, brackets)
local startTime, endTime
if sTime and eTime then
if startTime, ==endTime = getStartEndTime(sTime, eTime, 'small')then
period=startTime --only (1990)
else
period=startTime .. '-'..endTime
end
elseif sTime then
period=startTime .. '-'
startTime=funcDate(sTime, 'small')
elseif eTime then
period='-'..endTime
endTime=funcDate(eTime, 'small')
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)
return getPeriodSub(sTime, eTime, brackets)
if season then
end
return getPeriodSub_season(sTime, eTime, brackets), sTime
 
else
local function getClassCalendar_sub(entityID)
return getPeriodSub(sTime, eTime, brackets), sTime
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.605 ⟶ 2.635:
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 ifand classLink then
local period, sTime=getPeriod(p279.qualifiers, true)
local classStr = classLink .. " <small>"..period.."</small>"
table.insert(classTable, {sTime, classStr, circuitID})
end
Line 2.622 ⟶ 2.652:
if not str then str='' else str=str..'<br>' end
str=str..class[2]
if circuitLink=WPlinkpure(class[3] then)
circuitLink=WPlinkpure(class[3])
end
end
return str, circuitLink, #classTable
Line 2.631 ⟶ 2.659:
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=firstValuegetClassCalendar_sub(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.646 ⟶ 2.681:
Sitelink=getMainRaceLink(entityID,entity_type,stageID, functionName,timeOfRace)
else
Sitelink=getMainRaceLink(entityID,class_dic[classID],nil, functionName,timeOfRace)
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)
race_tCelloutTable["raceCell"]=tostring(tCell)
else
race_tCelloutTable["raceCell"]=Sitelink --already opened
end
Line 2.661 ⟶ 2.695:
local classLink=classLinkFn(classID,circuitID) --return '' worst case
 
class_tCelllocal 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 outTable
return parentID, race_tCell, class_tCell
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.682 ⟶ 2.718:
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.743 ⟶ 2.779:
local function calculateAge(birthDate, endDate) --test future
local eYear, eMonth, eDay
local longestcontractyears=10
if birthDate then
if not endDate then
Line 2.778 ⟶ 2.813:
if alreadyThisYear then
return eYear-tYear, tYear, eYear+longestcontractyears1
else
return eYear-tYear-1, tYear, eYear+longestcontractyears1
end
else
return 0, tYear, eYear+longestcontractyears1
end
end
Line 2.824 ⟶ 2.859:
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.856 ⟶ 2.892:
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.867 ⟶ 2.903:
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.876 ⟶ 2.912:
end
end
else --for team the checkthere is lighternothing to check
for num=1,#t.race do
numberOfEditions=num
if t.race[num]['future']==false then --in the past
lastRunEdition=num
if mandatory_prop==nil then
lastEditionDate=t.race[num]['raceDate']
numberOfEditions=num
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
 
ift.lastEditionYear=contentLanguage:formatDate("Y", lastEditionDate then)
t.lastEditionYear=funcDate(lastEditionDate,"onlyyear")
end
t.numberOfEditions=numberOfEditions
if not team then evaluateWinnerMax(t) end
Line 2.910 ⟶ 2.932:
if lastRunEdition then
t.lastWinner=lastWinner or '' --t.vainqueur[lastRunEdition]['link']
tsitelink = wikibase.lastID=getSitelink(t.race[lastRunEdition]['raceId'])
sitelink = wikibase.getSitelink(t.lastID)
if sitelink ~= nil then
t.lastLink = "[[" .. sitelink .. "]]"
Line 2.920 ⟶ 2.941:
if nextEdition then
tsitelink = wikibase.nextID=getSitelink(t.race[nextEdition]['raceId'])
sitelink = wikibase.getSitelink(t.nextID)
if sitelink ~= nil then
t.nextLink = "[[" .. sitelink .. "]]"
Line 2.930 ⟶ 2.950:
end
 
local function getPeriodicity(itemID, t)
local p = wikibase.getBestStatements(itemID, 'P2257')
if p[1] and p[1].mainsnak.snaktype == 'value' then
Line 2.960 ⟶ 2.980:
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<=#lang_prioritylangFallback do
lang=lang_prioritylangFallback[kk]
kk=kk+1
for _, prop in ipairs({PID}) do
Line 2.973 ⟶ 2.999:
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 2.985 ⟶ 3.011:
 
local function officialSite(itemID)
local urlp856 =firstValue wikibase.getBestStatements(itemID, 'P856')
if p856[1] and p856[1].mainsnak.snaktype == 'value' then
if url 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.004 ⟶ 3.061:
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
res=return m
elseif unit=='http://www.wikidata.org/entity/Q174728' then --cm
res=return 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.047 ⟶ 3.087:
end
 
local function formatNumbergetHeight(e, addUnit, transentityID)
local m
local text
local lang = contentLanguage
if e then
 
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
text = text .. ' ' .. getm(wiki)
if addUnit then
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 getHeight(entityID, in_cm)
local p = mw.wikibase.getBestStatements(entityID, 'P2048')
if in_cm then
return formatNumber(checkm(p, in_cm), true, 11)
else
return formatNumber(checkm(p, in_cm), true, 9)
end
end
 
local function getWeight(entityID)
local kg
local text
local lang = contentLanguage
local p = mw.wikibase.getBestStatements(entityID, 'P2067')
returnkg = formatNumber(checkkg(p), true, 10)
 
if kg then
text = lang:formatNum(kg)
if wiki == 'fo' then
text = string.gsub(text, "%.", ",")
end
text = text .. ' ' .. getKg(wiki)
end
return text
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
stagepstageID =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
local text
return formatNumber(km, addUnit, 8), km
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 l10nDef = {
local p =mw.wikibase.getBestStatements(raceID, 'P7297')
["en"] = " m",
return formatNumber(checkm(p), true, 9)
["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=checkkmh(p), unit, text, found, timeOfRace
local lang = contentLanguage
 
if p[1] and p[1].mainsnak.snaktype == 'value' then
if not kmh and kmdistance then --calculate speed
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.122 ⟶ 3.211:
 
if timeOfRace then
found=true
kmh=math.modf(1000*kmdistance/(timeOfRace/3600))/1000
end
end
end
if found then
return formatNumber(kmh, addUnit, 5)
-- 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 gp21 = firstValuemw.wikibase.getBestStatements(riderID, 'P21', 'id') -- P21 is gender
if p21[1] and p21[1].mainsnak.snaktype == 'value' then
if g == 'Q6581097' then gender = 'm' -- Male
local g = p21[1].mainsnak.datavalue.value.id
elseif g == 'Q6581072' then gender = 'f' -- Female
elseif if g == 'Q1052281Q6581097' then gender = 'tm' -- TransgenreMale
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.196 ⟶ 3.299:
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.209 ⟶ 3.311:
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[wikimw.site.server]
if not l10n then
l10n = ''
Line 3.230 ⟶ 3.332:
end
if inp == "0" then
this_label = translate("func_prologue",1)
else
this_label = stageLink(inp, a, b)
Line 3.312 ⟶ 3.414:
--== 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.403 ⟶ 3.494:
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.490 ⟶ 3.582:
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.496 ⟶ 3.588:
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:9375%')
: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 = wdLink(ID)wd_link .." [[" .. s .. "|" .. translation .. "]]"
else
link = "[[" .. s .. "|" .. translation .. "]] "..wdLink(ID)
end
tC:cssText('text-align:right; border-top:3px solid '..backgroundColor..'; font-size:9375%')
:wikitext(link)
end
Line 3.531 ⟶ 3.623:
 
--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.544 ⟶ 3.636:
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.551 ⟶ 3.643:
value=wikibase.getLabelByLang(ID, wiki)
elseif option == 'country' then
value=getCountryName(ID)
if display_flag then
value= flag(ID, sTime).." "..valuegetCountryName(ID)
endelse
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.601 ⟶ 3.694:
 
-- == 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.621 ⟶ 3.714:
end
if riderReason then
local label = string.gsub(getLabelFallbackwikibase.label(riderReason,lang_priority), "%b()", "") or getLabelFallback(riderReason,{'en', 'fr', 'de'})
riderRef = getReference(lf,p527, 1)
riderReason = ', ' .. label
end
Line 3.634 ⟶ 3.727:
for _, q in qualifiers(v, 'P39') do
stagiaire = q.value.id
local label = string.gsub(getLabelFallbackwikibase.label(stagiaire,lang_priority), "%b()", "") or getLabelFallback(stagiaire,{'en', 'fr', 'de'})
Sitelink = wikibase.getSitelink('Q2328847')
if Sitelink then
Line 3.706 ⟶ 3.799:
end
if not done then
names = tostring(c)..' '..tostring(a)..' '..tostring(b)
done = true
end
Line 3.734 ⟶ 3.827:
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.742 ⟶ 3.838:
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.756 ⟶ 3.852:
{"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.768 ⟶ 3.860:
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.787 ⟶ 3.879:
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(get_arg(frame.args['display_numbering',frame)]) then
display_numbering=true
table.insert(headers, 3)
Line 3.798 ⟶ 3.894:
--no_country modify the way the country is displayed
local no_country={}
if istrue(get_arg(frame.args['no_country',frame)]) or wiki == "ar" then
no_country={wiki}
end
Line 3.807 ⟶ 3.903:
 
local display_class=false
if istrue(get_arg(frame.args['display_class',frame)]) or wiki == "ar" then
display_class=true
table.insert(headers, 6)
Line 3.814 ⟶ 3.910:
table.insert(headers, 7) --winner
local only_winner=1
if istrue(get_arg(frame.args['podium',frame)]) or wiki == "ar" then
only_winner =0
table.insert(headers, 8) --second
Line 3.821 ⟶ 3.917:
local display_leader=false
if istrue(get_arg(frame.args['display_leader',frame)]) then
display_leader=true
table.insert(headers, 10)
end
local display_team =false
if istrue(get_arg(frame.args['display_team',frame)]) then
display_team =true
end
Line 3.835 ⟶ 3.931:
end
local w_racewomenrace_bool=isWomenrace(calendarID)
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 3.848 ⟶ 3.944:
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,
w_raceframe=w_raceframe,
womenrace_bool=womenrace_bool
lf=lf
}
return calendar_main(s, tableA(s))
Line 3.862 ⟶ 3.959:
----- based on WWTcalendar function -----
----- author: Mr. Ibrahem -----
local calendarID --determined later
localif lfwiki == get_lf("ar" then frame = frame:getParent() end
local UCI = data.UCIYearToQ
Line 3.870 ⟶ 3.967:
local header_1_number = 12
local tempdic, year, keyk, yeary
local tempdic1 = {
header_2 = {2, 3,5, 4, 7, 8, 9, 10},
Line 3.889 ⟶ 3.986:
 
for key, v in pairs(UCI) do
if not calendarID and frame.args[key] then
year = get_arg(key,frame) --with lf does not work
local year = frame.args[key]
if not calendarID and year then
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 3.911 ⟶ 4.007:
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(get_arg(frame.args['display_numbering',lf)]) then
tempdic.display_numbering=true
elseif get_arg(frame.args['display_numbering',lf)] and istrue(get_arg(frame.args['display_numbering',lf)]) == nil then
tempdic.display_numbering=false
end
local w_racewomenrace_bool=isWomenrace(calendarID)
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 3.936 ⟶ 4.028:
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,
w_raceframe=w_raceframe,
womenrace_bool=womenrace_bool
lf=lf
}
return calendar_main(s, tableA(s))
Line 3.947 ⟶ 4.040:
 
function calendar_main(s, resultTable)--Display the UCI women calendar of one year
localframe=s.frame
local lf = s.lf
local calendarID=s.item
local fn_racetable,fn_datetable, fn_countrytable
local t_Body ={}
local w_racewomenrace_bool=isWomenrace(calendarID)
 
local temp=firstValue(calendarID, s.property)
if not temp orthen s.error_message temp=="" then2 return '' 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 3.963 ⟶ 4.056:
local RaceID = p527.mainsnak.datavalue.value.id
---- Create a row ----
local timeOfRace, date_tCell, date_sortkeyfn_datetable = fn_date(RaceID)
local parentID, race_tCell, class_tCellfn_racetable= fn_race(RaceID,s.displayed_class,s.display_class,fn_datetable["timeOfRace"],nil,country)
 
if race_tCellfn_racetable["raceCell"]~=nil then --otherwise the class is not display
fn_countrytable=fn_country(RaceID,
local country_flag, country_name, country_tCell=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
fn_datetable["timeOfRace"],
--create the table
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(race_tCellfn_countrytable["tCell"]) end
if class_tCellcountry then tRow:node(class_tCell) end
tRow:node(fn_racetable["raceCell"])
local rider_tCell =fn_rider(lf,RaceID,timeOfRace,s.display_team,s.only_winner)
end
tRow:node(rider_tCell)
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
local leader_tCell=tRow:node(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 3.992 ⟶ 4.094:
function p.nationalchampionships(frame)
local calendarroadID, calendarITTID, year
if wiki == "ar" then
local lf=get_lf(frame)
frame = frame:getParent()
local listOfCalendar={data.NationalRoadCyclingChampionships,data.NationalITTCyclingChampionships}
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
if ((ii==1 and calendarroadID==nil) or (ii==2 and calendarITTID ==nil)) and frame.args[key] then
year = get_arg(key,frame) --with lf does not work
year = frame.args[key]
if ((ii==1 and calendarroadID==nil) or (ii==2 and calendarITTID ==nil)) and year then
year = string.gsub( year , "%c", "")
if v[year] then
if ii==1 then
Line 4.010 ⟶ 4.115:
end
local w_racewomenrace_bool=isWomenrace(calendarroadID)
local s = {
header_function = "calendar", -- translations are in function Calendar
Line 4.023 ⟶ 4.128:
year = year,
no_country = {}, --no sense here to hide the country
error_message = 0,
display_team = true,
display_countrylink = falsetrue, --too expensive
w_raceframe =w_race frame,
womenrace_bool=womenrace_bool
lf=lf
}
return nationalchampionships_main(s,tableA(s))
Line 4.032 ⟶ 4.138:
 
function nationalchampionships_main(s, resultTable)--Display the list of national champions for one year
localframe=s.frame
local lf = s.lf
local tableChamp, fn_countrytable, t_Body = {}, {}, {}
local timeOfRace ='+'..tostring(s.year).."-01-01T00:00:00Z"
local rider_tCelltRace, thereisawinner, parentID, parentParentID, sitelink
local country_flag, country_name, country_tCell
 
local temp=firstValue(s.calendarroadID, s.property)
if not temp orthen else s.error_message temp=="" then2 return '' end
s.error_message = 2
if wiki == "ar" then return "" end
end
 
local listOfCalendarID={s.calendarroadID, s.calendarITTID}
Line 4.051 ⟶ 4.153:
for _, p527 in statements(thisCalendarID, 'P527') do
thisID = p527.mainsnak.datavalue.value.id
country_flag, country_name, country_tCellfn_countrytable=fn_country(thisID,timeOfRace,s.country)
sortkey=string.gsub(fn_countrytable["countryname"], 'É', 'E') --case États Unis
if country_name == nil then country_name="country not found" end
 
sortkey=string.gsub(country_name, 'É', 'E') --case États Unis
--create the table
if tableChamp[sortkey]==nil then
tableChamp[sortkey]={}
tableChamp[sortkey]['countryname']=country_namefn_countrytable["countryname"] --raw
tableChamp[sortkey]['roadwinner']='<td></td>'
tableChamp[sortkey]['ITTwinner']='<td></td>'
Line 4.070 ⟶ 4.172:
end
tableChamp[sortkey]['sitelink']=sitelink
tableChamp[sortkey]['flag']=country_flagfn_countrytable["flag"]
end
--fill the table
rider_tCelltRace, 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.080 ⟶ 4.182:
if ii==1 then
tableChamp[sortkey]['roadwinner']=rider_tCelltRace
else
tableChamp[sortkey]['ITTwinner']=rider_tCelltRace
end
end
Line 4.099 ⟶ 4.201:
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.108 ⟶ 4.210:
--=== C) Victory ===
function p.victories(frame)
local tempID, lfIDtemp=get_and_checkID(frame).args[1]
local w_racewomenrace_bool=isWomenrace(tempIDIDtemp)
local s = {
Line 4.119 ⟶ 4.221:
country_column = 3,
data_sort_type = {'', 'unsortable', '', '', ''}, -- see https://meta.wikimedia.org/wiki/Help:Sorting
item = tempIDIDtemp,
property = 'P2522',
no_country = no_country_victories,
error_message = 0,
lf=lf,
frame=frame,
w_race=w_race
womenrace_bool=womenrace_bool
}
return victory_main(s ,tableA(s))
Line 4.129 ⟶ 4.232:
 
function victory_main(s, resultTable)
localframe=s.frame
local lf = s.lf
local _
_, _, s.item = string.find(s.item, "(%w+)")
 
local temp=firstValue(s.item, s.property,'id')
if not temp orthen else s.error_message temp=="" then2 return '' 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.146 ⟶ 4.249:
local tRow = mw.html.create('tr'):cssText( "line-height: 1.8em; padding: 5px;")
 
local timeOfRace, date_tCell, date_sortkeyfn_datetable = fn_date(RaceID, 'victory')
local parentID, race_tCell, class_tCellfn_racetable=fn_race(RaceID,nil ,true,fn_datetable["timeOfRace"], 'victory',country)--displayed_class=nil
if race_tCellfn_racetable["raceCell"]~= nil then --otherwise class not to be displayed
country_flag, country_name, country_tCellfn_countrytable=fn_country(RaceID, timeOfRace, country, race_tCell, parentID)
fn_datetable["timeOfRace"],
--Build the table
country,
tRow:node(date_tCell)
fn_racetable["raceCell"],
fn_racetable["parentID"]
)
tRow:node(fn_datetable["tCell"])
if country==true then
tRow:node(race_tCellfn_racetable["raceCell"]) --race site link is in fn_countrytable
end
tRow:node(country_tCellfn_countrytable["tCell"])
tRow:node(class_tCellfn_racetable["classCell"]) --class
local rider_tCell =tRow:node(fn_rider(lf,RaceID,fn_datetable["timeOfRace"],false,1))
t_Body[#t_Body + 1] = {fn_datetable["sortkey"], tRow}
tRow:node(rider_tCell)
table.insert(t_Body, {sortkey=date_sortkey, body=tRow})
end --no winner
end --end list of key
Line 4.169 ⟶ 4.276:
--== D) Stage infobox
function p.stageinfobox(frame)
local stageID, lfentityID = get_and_checkIDmw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
local w_race=isWomenrace(stageID)
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,w_racewomenrace_bool)}, -- course / not used
{ name = translate("stageinfobox",2,w_racewomenrace_bool)}, -- competition
{ name = translate("stageinfobox",3,w_racewomenrace_bool), name_plural = translate("infobox",4,w_racewomenrace_bool)}, -- stage type
{ name = translate("stageinfobox",4,w_racewomenrace_bool), name_plural = translate("infobox",7,w_racewomenrace_bool)}, -- date
{ name = translate("stageinfobox",6,w_racewomenrace_bool)}, -- distance
{ name = translate("stageinfobox",7,w_racewomenrace_bool), name_plural = translate("infobox",10,w_racewomenrace_bool)}, -- country
{ name = translate("stageinfobox",9,w_racewomenrace_bool)}, -- start place
{ name = translate("stageinfobox",10,w_racewomenrace_bool)}, -- endplace
{ name = translate("stageinfobox",11,w_racewomenrace_bool)}, -- participants at start
{ name = translate("stageinfobox",12,w_racewomenrace_bool)}, -- participants at end
{ name = translate("stageinfobox",13,w_racewomenrace_bool)}, -- speed
{ name = translate("stageinfobox",44,w_racewomenrace_bool)}, -- elevation
{ name = translate("infobox",32,w_racewomenrace_bool), special = true}, -- special 1
{ name = translate("infobox",33,w_racewomenrace_bool), 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_Oft_P642 = {
Q20882747={'results', 'first'},
Q20882748={'results', 'second'},
Line 4.229 ⟶ 4.346:
}
local localframe
getLocalContent(details, lf.args)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
getLocalContent(others, lf.args)
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
 
local timeOfRace
local temp = firstValue(stageIDentityID, 'P31','id')
icon = ''
if temp and temp ~= 'Q18131152' then
Line 4.241 ⟶ 4.365:
icon = " [[File:Cycling (road) pictogram.svg|35px]]"
end
details[3].content = typeofstagelogo(stageIDentityID, true).." "..WPlinkpure(temp)
end
local name = getLabelFallback(stageIDentityID, {wikilang, 'en', 'fr', 'de'}) or ''
if wiki == 'fr' and name ~= nil then
name= mw.ustring.gsub(name, "^(%d+)([re]+)", "%1<sup>%2</sup> ")
Line 4.250 ⟶ 4.374:
name= mw.ustring.gsub(name, "^(%a)",function (x) return mw.ustring.upper(x) end)
infoGetOthers(others, stageIDentityID)
 
--name
local race={}
if course==nil then
temp = firstValue(stageIDentityID, 'P1545')
if temp then
details[2].content =getStageLabel(temp)
raceId = firstValue(entityID, 'P361','id')
raceId = getParentID(stageID) --for instance Tour de France 2020
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.270 ⟶ 4.393:
 
-- This function give a format to dates when P585 (date) is used in a single day race
local pTime = firstValue(stageIDentityID, 'P585', 'time') -- P585 is 'point in time'
if pTime then
details[4].content = funcDate(pTime, 'long')
Line 4.277 ⟶ 4.400:
local kmdistance
if not details[5].content then details[5].content, kmdistance = getDistance(stageIDentityID, true) end -- distance
infoGetCountry(details,6, stageIDentityID, timeOfRace)
infoGetStartEnd(details,7, stageIDentityID, timeOfRace)
infoGetParticipants(details,9, stageIDentityID)
if not details[11].content then details[11].content = getSpeed(stageIDentityID, true, kmdistance, 'P2417') end --speed
if not details[12].content then
local elevation=getElevation(stageIDentityID)
if elevation ~= nil then details[12].content =elevation else details[12].content = nil end
end --Elevation
Line 4.329 ⟶ 4.452:
 
--Winner
for _, p1346 in statements(stageIDentityID, '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.343 ⟶ 4.466:
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, ..)
if q.P642 and q.P642[1].snaktype == 'value' then
propertyOf=nil
for _, vv in pairs(q.P642) do
if q.P2501 and q.P2501[1].snaktype == 'value' then
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_Oft_P642[qual] then
if qual=="Q21686770" and t_s['results']['winner_fighting'][1] ~= "" then
t_Oft_P642[qual][2] = 'winner_fighting2'
end
type_ofclas=t_Oft_P642[qual][1] --annex or gen
name_ofclas=t_Oft_P642[qual][2] --name of ranking
local v=t_s[type_ofclas][name_ofclas]
 
Line 4.382 ⟶ 4.498:
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({'results','gen'}listoftable) do
if ii==1 then
prop='P2417'
Line 4.393 ⟶ 4.510:
end
for _, p2417 in statements(stageIDentityID, prop) do
local q = p2417.qualifiers
if q.P1352 and q.P1352[1].snaktype == 'value' then
Line 4.419 ⟶ 4.536:
end
 
for _, thistable in ipairs(listoftable={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.432 ⟶ 4.551:
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,w_racewomenrace_bool))
 
-- ranking table, general and stage
Line 4.442 ⟶ 4.561:
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 '..backgroundColorLight..'#fff2cc; background-color:'..backgroundColor..'#FFE7A0; text-align:center')
:css('font-weight','bold')
:wikitext(translate("stageinfobox",thistable.header,w_racewomenrace_bool))
 
for key, value in ipairs(thistable.order) do --value is the name of the class
Line 4.457 ⟶ 4.576:
else
local lang = mw.language.getContentLanguage()
v['speed'] = '('.. lang:formatNum(v['speed'])..translate("unit",5,w_racewomenrace_bool)..')'
end
end
if v['points'] then
if v['points'] > 1 then
temp=translate("unit",7,w_racewomenrace_bool)
else
temp=translate("unit",6,w_racewomenrace_bool)
end
v['points'] = v['points']..temp
end
local title, k = string.gsub(translate("stageinfobox",v['translation'],w_racewomenrace_bool), " ", "&nbsp;")
if k > 0 then title = string.gsub(title, "&nbsp;", "<br>", 1) end --&#32;
Line 4.478 ⟶ 4.597:
tCell:attr('rowspan','2')
end
tCell:cssText("width:1%;background-color:"..backgroundColorLight.."#fff2cc;text-align:" ..
textalign .. ";padding:0 2px 0 2px;white-space:nowrap")
Line 4.484 ⟶ 4.603:
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'],w_racewomenrace_bool))
else
tCell:wikitext(number(v['genre'], key, wiki))
end
else
tempif jerseyWPID=='' then
if jerseyWPID~ temp='' then
else
temp="|link="..jerseyWPID
end
Line 4.547 ⟶ 4.667:
infoFillOthersMap(tab, others)
tab:node(getPreviousNextLine(stageIDentityID,true))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/stageinfobox", translate("stageinfobox",39,w_racewomenrace_bool), stageIDframe.args[1])
return tab
end
Line 4.554 ⟶ 4.674:
--== 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)
if not timeOfRace then return errorMessage end
local w_race=isWomenrace(raceID)
local womenrace_bool=isWomenrace(raceID)
local teamCats_lot = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
 
-- Part of the numbering is omitted for the convenience of possible subsequent editing.
local teamCats = { -- {c,d,e} c = singular team type, d = plural team type, e = print order of the team types
-- UCI professional men's teams
["Q6154783"] = {4,5,1}, -- WorldTeam
["Q20638319Q80425135"] = {64,75,2}, -- ProTeamUCI (2005-2014)Women’s WorldTeam
["Q78464255Q20638319"] = {6,7,3}, -- ProTeam (20202005-2014)
["Q382927Q78464255"] = {86,97,4}, -- UCI Professional Continental TeamProTeam (20052020-2019)
["Q1756006Q382927"] = {108,119,5}, -- UCI Professional Continental Team (2005-2019)
["Q20639847Q1756006"] = {1610,1711,6}, -- professionalUCI cyclingContinental teamTeam
["Q20653563Q20639847"] = {2016,2117,7}, -- Groupeprofessional Sportifcycling Iteam
["Q20653564Q20653563"] = {2220,2321,8}, -- Groupe Sportif III
["Q20653566Q20653564"] = {2422,2523,9}, -- Groupe Sportif IIIII
["Q20653566"] = {24,25,10}, -- Groupe Sportif III
-- UCI professional women's teams
["Q80425135Q2466826"] = {5728,5829,11}, -- UCI Women’s WorldTeamTeam
["Q130604574Q23726798"] = {5912,6013,12}, -- UCInational Women’scycling ProTeamteam
["Q119942457Q99658502"] = {3212,3313,13}, -- UCInational Women'scycling Continentalteam Team (2020-) "B"
["Q2466826Q20738667"] = {2812,2913,14}, -- UCInational Women’scycling Teamteam (-2019)U23
["Q119948768Q54555994"] = {5512,5613,15}, -- UCInational Women'scycling Elite-2team TeamU19
["Q28492441"] = {12,13,16}, -- national cycling team with sponsor name
-- other non-road UCI teams
["Q2466819Q20652655"] = {4518,4619,2117}, -- UCIamateur Trackcycling Teamteam
["Q39885628Q26849121"] = {4730,4831,2218}, -- UCIWomen's amateur Cyclocrosscycling Teamteam
["Q2466804Q20639848"] = {4914,5015,2319}, -- UCIclub and region MTBcycling Teamteam
["Q39885630Q20653570"] = {5114,5215,2420}, -- UCIclub and region BMXcycling 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.614 ⟶ 4.711:
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,
teamCats_lotteamCats[teamCat] and teamCats_lotteamCats[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 teamCats_lotteamCats
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.629 ⟶ 4.726:
local function getHeader(CatID, count)
local header, sitelink
if teamCats_lotteamCats[CatID] then
local done=false
if CatID=="Q2466826" then --name changed after 2020
Line 4.635 ⟶ 4.732:
if year and year>2019 then
if count == 1 then
header_label = translate("headoftableIII",32, w_racewomenrace_bool) -- singular name
else
header_label = translate("headoftableIII",33, w_racewomenrace_bool) -- plural name
end
done=true
Line 4.645 ⟶ 4.742:
if done==false then
if count == 1 then
header_label = translate("headoftableIII",teamCats_lotteamCats[CatID][1], w_racewomenrace_bool) -- singular name
else
header_label = translate("headoftableIII",teamCats_lotteamCats[CatID][2], w_racewomenrace_bool) -- plural name
end
end
Line 4.666 ⟶ 4.763:
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.728 ⟶ 4.825:
--== 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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item =tempID,
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=100000,1000 --unlimited the whole team must be displayed
lf=lf
}
return new_classification(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
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 = tempIDframe.args[1],
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(sframe, frames)
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 = tempIDframe.args[1],
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(sframe, frames)
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 = tempIDframe.args[1],
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 = get_argtonumber(2, frame,true.args[2]) == 0 and 0 or 1,
max_rank_displayed=10,
lf=lf
}
return new_classification(sframe, frames)
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 = tempIDframe.args[1],
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 = get_argtonumber(2, frame,true.args[2]) == 0 and 0 or 1,
max_rank_displayed=25,
lf=lf
}
return new_classification(sframe, frames)
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 = tempIDframe.args[1],
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 = get_argtonumber(2, frame,true.args[2]) == 0 and 0 or 1,
max_rank_displayed=25,
lf=lf
}
return new_classification(sframe, frames)
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 = tempIDframe.args[1],
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 =get_arg(2, tonumber(frame,true.args[2]) == 0 and 0 or 1,
max_rank_displayed=25,10
lf=lf
}
return new_classification(sframe, frames)
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 = tempIDframe.args[1],
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 = get_argtonumber(2, frame,true.args[2]) == 0 and 0 or 1,
max_rank_displayed=25,
lf=lf
}
return new_classification(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
end
 
function p.combinationclassification(frame)
local s = {
local tempID, lf=get_and_checkID(frame)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
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 = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
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(sframe, frames)
end
 
function p.custompointsclassification(frame)
local tempID, lf=get_and_checkID(frame)
 
local team_title
if frame.args[4] and string.find(frame.args[4],"{{{")==nil then team_title=string.gsub(frame.args[4], "%c", "") end
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 = {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=get_argstring.gsub(frame.args[3],frame) or"%c", ''""), --with lf does not work
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
property = get_argstring.gsub(frame.args[2],frame "%c", ""), -- 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(sframe, frames)
end
 
function p.customtimeclassification(frame)
local tempID, lf=get_and_checkID(frame)
 
local team_title
if frame.args[4] and string.find(frame.args[4],"{{{")==nil then team_title=string.gsub(frame.args[4], "%c", "") end
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 = {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=get_argstring.gsub(frame.args[3],frame) or"%c", ''""),
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
property = get_argstring.gsub(frame.args[2],frame "%c", ""), -- 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(sframe, frames)
end
 
function new_classification(frame, s)
 
local country = true
function p.customteamclassificationbypoints(frame)
for _, value in pairs(no_country_classification) do -- get data if country should be printed in this wiki
local tempID, lf=get_and_checkID(frame)
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 w_racewomenrace_bool=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.124 ⟶ 5.114:
]=]
 
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 get_arg('localframe.args.country',frame) ~= nil then -- switch country column on or off in the article
if get_arg('localframe.args.country',frame) == 'true' and l10n["country_name_list"] then country = true end
if get_arg('localframe.args.country',frame) == 'false' then country = false end
end
local tableHeader2_size = #s.header_2
local max_rank_displayed=s.max_rank_displayed
if localframe.args['max_rank_displayed'] and localframe.args['max_rank_displayed'] ~= '' then
for _, p31 in statements(raceID, 'P31') do
max_rank_displayed=tonumber(localframe.args['max_rank_displayed'])
if data.stages[p31.mainsnak.datavalue.value.id] then
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,w_racewomenrace_bool) 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,w_racewomenrace_bool) end --translation for team has index "3"
local tableBody = mw.html.create('table')
Line 5.168 ⟶ 5.156:
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,w_racewomenrace_bool)
end
local head =header:tag('th'):wikitext(header_text)
Line 5.204 ⟶ 5.192:
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,w_racewomenrace_bool)--"HD","NP","DQ"
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7,w_racewomenrace_bool)
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8,w_racewomenrace_bool)
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9,w_racewomenrace_bool)
else riderDNF=''
end
Line 5.240 ⟶ 5.228:
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.246 ⟶ 5.234:
if countryID then
flagLink = flag(countryID, timeOfRace)
if available_list and country then
if type(translations.list) == "function" then
countryName = getCountryName(countryID)
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.256 ⟶ 5.255:
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.281 ⟶ 5.280:
 
if not s.team_classification then
if countrynot teamLink then teamLink = '' end
if not available_list then
tCell:wikitext(riderLink .. jersey(h.jersey) )
tBody:tag('td')tCell:wikitext( flagLink .. ' '.. countryNameriderLink .. jersey(h.jersey))
if s.display_team~=false then
tBody:tag('td'):wikitext(teamLink)
end
else
if country == true then
tCell:wikitext(flagLink .. ' ' .. riderLink .. jersey(h.jersey))
tCell:wikitext(riderLink .. jersey(h.jersey) )
end
tBody:tag('td'):wikitext( flagLink ..' '.. countryName)
if s.display_team~=false then
else
tBody:tag('td'):cssText("text-align:".. textalign ..";padding:0 0.2em 0 0.2em")
tCell:wikitext(teamLinkflagLink 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.300 ⟶ 5.307:
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.323 ⟶ 5.330:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=translate("unit",7,w_racewomenrace_bool)
else
temp2=translate("unit",6,w_racewomenrace_bool)
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 5.356 ⟶ 5.363:
if type(h.value[1]) == "number" then
if h.value[1] > 1 then
temp2=translate("unit",7,w_racewomenrace_bool)
else
temp2=translate("unit",6,w_racewomenrace_bool)
end
tCell:tag('span'):cssText("font-size:80%"):wikitext(temp2)
Line 5.373 ⟶ 5.380:
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,w_racewomenrace_bool))
end
end
Line 5.379 ⟶ 5.386:
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.398 ⟶ 5.405:
:cssText("text-align:right")
tCell:tag('small')
:wikitext(race_reference(raceID,lf))
end
--general table style and last line
local tableStyle, tableNewline
if get_arg('localframe.args.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 get_arg('localframe.args.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 get_arg('localframe.args.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.433 ⟶ 5.440:
 
--=== G) Infobox ===
function p.infobox(frame) -- normal infobox
return infobox_main(frame,0)
end
 
function p.seasoninfoboxinfoboxseason(frame) -- season infobox
return infobox_main(frame,1)
end
 
function p.champinfoboxinfoboxChamp(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 = get_and_checkIDmw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
local w_race=isWomenrace(entityID)
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,w_racewomenrace_bool)}, -- course
{ name = translate("infobox",3,w_racewomenrace_bool), name_plural = translate("infobox",4,w_racewomenrace_bool)}, -- competition
{ name = translate("infobox",5,w_racewomenrace_bool)}, -- stages
{ name = translate("infobox",6,w_racewomenrace_bool), name_plural = translate("infobox",7,w_racewomenrace_bool)}, -- date
{ name = translate("infobox",8,w_racewomenrace_bool)}, -- distance
{ name = translate("infobox",9,w_racewomenrace_bool), name_plural = translate("infobox",10,w_racewomenrace_bool)}, -- country
{ name = translate("infobox",11,w_racewomenrace_bool)}, -- start place
{ name = translate("infobox",12,w_racewomenrace_bool)}, -- endplace
{ name = translate("infobox",13,w_racewomenrace_bool)}, -- teams
{ name = translate("infobox",14,w_racewomenrace_bool)}, -- participants at start
{ name = translate("infobox",15,w_racewomenrace_bool)}, -- participants at end
{ name = translate("infobox",16,w_racewomenrace_bool)}, -- speed
{ name = translate("infobox",43,w_racewomenrace_bool)}, -- elevation
{ name = translate("infobox",17,w_racewomenrace_bool)}, -- cost
{ name = translate("infobox",32,w_racewomenrace_bool), special = true}, -- special 1
{ name = translate("infobox",33,w_racewomenrace_bool), special = true}, -- special 2
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
elseif selector==1 then -- season infobox
details = {
{ name = translate("infobox",46,w_racewomenrace_bool)}, -- edition (1)
{ name = translate("infobox",3,w_racewomenrace_bool), name_plural = translate("infobox",4,w_racewomenrace_bool)}, -- competition (2)
{ name = translate("infobox",6,w_racewomenrace_bool), name_plural = translate("infobox",7,w_racewomenrace_bool)}, -- date (3)
{ name = translate("infobox",45,w_race), name_plural=translate("infobox",71,w_racewomenrace_bool)}, -- rasing (4)
{ name = translate("infobox",47,w_racewomenrace_bool), name_plural = translate("infobox",48,w_racewomenrace_bool)}, -- location (country) (5)
{ name = translate("infobox",49,w_racewomenrace_bool), name_plural = translate("infobox",50,w_racewomenrace_bool)}, -- organizer (6)
{ name = translate("infobox",63,w_racewomenrace_bool), name_plural = translate("infobox",63,w_racewomenrace_bool)}, -- team class (7)
{ name = translate("infobox",32,w_racewomenrace_bool), special = true}, -- special 1
{ name = translate("infobox",33,w_racewomenrace_bool), special = true}, -- special 2
{ name = translate("teaminfobox",13,w_race)}, -- official web site
}
else -- champ infobox
details = {
{ name = translate("infobox",46,w_racewomenrace_bool)}, -- edition (1)
{ name = translate("infobox",6,w_racewomenrace_bool), name_plural = translate("infobox",7,w_racewomenrace_bool)}, -- date (2)
{ name = translate("infobox",9,w_racewomenrace_bool), name_plural = translate("infobox",10,w_racewomenrace_bool)}, -- country (3)
{ name = translate("infobox",67,w_racewomenrace_bool), name_plural = translate("infobox",68,w_racewomenrace_bool)}, -- location (city) (4)
{ name = translate("infobox",61,w_racewomenrace_bool), name_plural = translate("infobox",62,w_racewomenrace_bool)}, -- arena / stadion (5)
{ name = translate("infobox",60,w_racewomenrace_bool)}, -- medals (6)
{ name = translate("infobox",13,w_racewomenrace_bool)}, -- team (7)
{ name = translate("infobox",49,w_racewomenrace_bool), name_plural = translate("infobox",50,w_racewomenrace_bool)}, -- organizer (8)
{ name = translate("infobox",32,w_racewomenrace_bool), special = true}, -- special 1
{ name = translate("infobox",33,w_racewomenrace_bool), 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,w_racewomenrace_bool), QID = 'Q20882667' }, -- first
{ name = translate("infobox",20,w_racewomenrace_bool), QID = 'Q20882668' }, -- second
{ name = translate("infobox",21,w_racewomenrace_bool), QID = 'Q20882669' }, -- third
{ name = translate("infobox",22,w_racewomenrace_bool), QID = 'Q20883007' }, -- points
{ name = translate("infobox",23,w_racewomenrace_bool), QID = 'Q20883212' }, -- mountains
{ name = translate("infobox",24,w_racewomenrace_bool), QID = 'Q20883328' }, -- sprints
{ name = translate("infobox",25,w_racewomenrace_bool), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",26,w_racewomenrace_bool), QID = 'Q101246973' }, -- supercombativity
{ name = translate("infobox",26,w_racewomenrace_bool), QID = 'Q20893983' }, -- combativity
{ name = translate("infobox",35,w_racewomenrace_bool), QID = 'Q27067359' }, -- volantes
{ name = translate("infobox",36,w_racewomenrace_bool), QID = 'Q27067170' }, -- regularity
{ name = translate("infobox",27,w_racewomenrace_bool), QID = 'Q20893979' }, -- combination
{ name = translate("infobox",38,w_racewomenrace_bool), QID = 'Q27907715' }, -- breakaway
{ name = translate("infobox",39,w_racewomenrace_bool), QID = 'Q27907747' }, -- azzurri
{ name = translate("infobox",40,w_racewomenrace_bool), QID = 'Q28092831' }, -- rookie
{ name = translate("infobox",28,w_racewomenrace_bool), QID = 'Q20882921' }, -- teams
{ name = translate("infobox",37,w_racewomenrace_bool), QID = 'Q27104269' }, -- teamspoints
{ name = translate("infobox",41,w_racewomenrace_bool), QID ='Q61976850' },-- amateur
{ name = translate("infobox",42,w_racewomenrace_bool), QID ='Q61976872' } --nationality
}
elseif selector==1 then -- season infobox
winners = {
{ name = translate("infobox",52,w_racewomenrace_bool), QID = 'Q20882667' }, -- individual (first)
{ name = translate("infobox",53,w_racewomenrace_bool), QID = 'Q20883139' }, -- youth
{ name = translate("infobox",54,w_racewomenrace_bool), QID = 'Q27104269' }, -- team (teamspoints)
{ name = translate("infobox",55,w_racewomenrace_bool), QID = 'Q98959152' }, -- team GS-I
{ name = translate("infobox",56,w_racewomenrace_bool), QID = 'Q98959153' }, -- team GS-II
{ name = translate("infobox",57,w_racewomenrace_bool), QID = 'Q98959155' }, -- team GS-III
{ name = translate("infobox",58,w_racewomenrace_bool), QID = 'Q72068715' }, -- country
{ name = translate("infobox",59,w_racewomenrace_bool), QID = 'Q72068724' } -- country U23
}
end -- Champ infobox has no winners
 
local localframe
getLocalContent(details, lf.args)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
getLocalContent(others, lf.args)
localframe = frame:getParent()
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
if selector==0 or selector==1 then
getLocalContent(winners, lflocalframe.args)
end
 
Line 5.551 ⟶ 5.573:
' [[File:Cycling (road) pictogram.svg|35px]]' or ''
 
local name = getLabelFallback(entityID, {wikilang, 'en', 'fr', 'de'}) or ''
infoGetOthers(others, entityID)
 
Line 5.576 ⟶ 5.598:
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.587 ⟶ 5.609:
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.630 ⟶ 5.651:
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
local sTime = firstValue(entityID, 'P580', 'time') -- P580 is 'start time'
details[index_date].content, timeOfRace, plural = get_formatted_date(entityID, 'infobox')
local eTime = firstValue(entityID, 'P582', 'time') -- P582 is 'end time'
if plural then
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.704 ⟶ 5.733:
if stages > 0 then
details[4].content = stages
if stages > 1 then
details[4].name = details[4].name_plural
end
end
end
Line 5.713 ⟶ 5.739:
end
if not details[6].content then -- organizer sitelink
listWPlink(details, 6, entityID,'P664P644',true) --org
end
if not details[7].content then -- organizer sitelink
Line 5.739 ⟶ 5.765:
end
if not details[8].content then -- organizer sitelink
listWPlink(details, 8, entityID,'P664P644',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.766 ⟶ 5.780:
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.784 ⟶ 5.798:
:cssText('border-bottom:5px solid white; background-color:'..backgroundColor..'; text-align:center')
:css('font-weight','bold')
:wikitext(translate("infobox",18,w_racewomenrace_bool))
tab:wikitext(winRows)
end
Line 5.799 ⟶ 5.813:
tab:node(getPreviousNextLine(entityID))
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/infobox", translate("infobox",34,w_racewomenrace_bool), entityID)
return tab
end
Line 5.805 ⟶ 5.819:
--=== 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.814 ⟶ 5.830:
},
vainqueur= {},
lastEditionMonth,
lastEditionYear,
numberOfEditions,
lastLink,
nextLink,
lastWinner,
maxWinner,
}
 
local entityID, lf = get_and_checkIDmw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
local w_race= isWomenrace(entityID)
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,w_racewomenrace_bool)}, -- sport
{ name = translate("raceinfobox",5,w_racewomenrace_bool)}, -- creation date
{ name = translate("raceinfobox",6,w_racewomenrace_bool)}, -- disparition date
{ name = translate("raceinfobox",7,w_racewomenrace_bool)}, -- number of editions
{ name = translate("raceinfobox",8,w_racewomenrace_bool)}, -- periodicity
{ name = translate("raceinfobox",9,w_racewomenrace_bool)}, -- type , name_plural = translate("infobox",10)
{ name = translate("raceinfobox",33,w_racewomenrace_bool), name_plural = translate("raceinfobox",34,w_racewomenrace_bool)}, --country
{ name = translate("raceinfobox",10,w_racewomenrace_bool), name_plural = translate("raceinfobox",11,w_racewomenrace_bool)}, -- place
{ name = translate("raceinfobox",12,w_racewomenrace_bool), name_plural = translate("raceinfobox",13,w_racewomenrace_bool)}, --org
{ name = translate("raceinfobox",27,w_racewomenrace_bool), name_plural = translate("raceinfobox",28,w_racewomenrace_bool)}, --race director
{ name = translate("raceinfobox",1514,w_race), name_plural = translate("raceinfobox",16,w_racewomenrace_bool)}, -- Catofficial web site
{ name = translate("raceinfobox",1715,w_racewomenrace_bool), name_plural = translate("raceinfobox",16,womenrace_bool)}, -- circuitCat
{ name = translate("raceinfobox",1417,w_racewomenrace_bool)}, -- official web sitecircuit
}
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)
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, class
Line 5.857 ⟶ 5.897:
local creation=firstValue(entityID, 'P571', 'time')
if not details[2].content and creation then
details[2].content = funcDate(creation, "onlyyearY" )
end
 
Line 5.863 ⟶ 5.903:
local disparition=firstValue(entityID, 'P576', 'time')
if not details[3].content and disparition then
details[3].content = funcDate(disparition,"onlyyearY")
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,w_racewomenrace_bool) .. " "..tostring(tRace.lastEditionYear)..")"
end
--periodicity
Line 5.886 ⟶ 5.926:
end
if not details[8].content then
infoGetPlace(details,87, entityID, timeOfRace)
end
Line 5.897 ⟶ 5.937:
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[1112].content then
details[1112].content = classContent
if numberClass >1 then
details[1112].name = details[1112].name_plural
end
end
if not details[1213].content then
details[1213].content = circuitLink
end
--Official web site
if not details[13].content then
details[13].content = officialSite(entityID)
end
--Build the table
Line 5.924 ⟶ 5.963:
end
--picture at the top
infoFillOthersDetails(tab, others, nil,translate("raceinfobox",19,w_racewomenrace_bool),"260px")
if not listOfNamesAtBottom then
if listOfNames and #listOfNames>1 then
tab:node(addATitle(translate("raceinfobox",18,w_racewomenrace_bool)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 5.934 ⟶ 5.973:
end
infoFillOthersDetails(tab, nil, details,translate("raceinfobox",19,w_racewomenrace_bool),"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,w_racewomenrace_bool)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 5.947 ⟶ 5.986:
if (tRace.lastWinner and tRace.lastWinner~='') or
(tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addATitle(translate("raceinfobox",20,w_racewomenrace_bool)))
if (tRace.lastWinner and tRace.lastWinner~='') then
tab:node(addARow(translate("raceinfobox",21,w_racewomenrace_bool),tRace.lastWinner))
end
if (tRace.maxWinner and tRace.maxWinner~='') then
tab:node(addARow(translate("raceinfobox",22,w_racewomenrace_bool),tRace.maxWinner))
end
end
 
if tRace.nextLink or tRace.lastLink then
tab:node(addATitle(translate("raceinfobox",23,w_racewomenrace_bool)))
local outTable
 
Line 5.964 ⟶ 6.003:
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,w_racewomenrace_bool)..
":<br>'''"..
tRace.lastLink.."'''"
Line 5.975 ⟶ 6.014:
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,w_racewomenrace_bool)..
":<br>'''"..
tRace.nextLink.."'''"
Line 5.982 ⟶ 6.021:
end
end
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,w_racewomenrace_bool), entityID)
return tab
end
 
--=== I) Team roster
function p.lastteamrosterteamroster(frame)
localframe=frame
local teamID, lf = get_and_checkID(frame)
local squadID
if frame.args[1] then squadID = string.gsub(frame.args[1], "%c", "") end
local tRace = {race={
local flags, pays = {}, {}
raceId,
local riderName, riderBirthday,riderTeam, timeTeam, correctlanguage,riderStart, riderEnd
raceDate,
local riderPosition, riderReason, riderRef, errortext
future,
local riderReasonTable, riderTablecorrect, riderTablenotcorrect, riderTable = {}, {}, {}, {}
},
local labelMissing = false
vainqueur= {},
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 sslavicWikis = {mk = true, ru = true}
local wikiIsSlavic = slavicWikis[wiki]
sort=sort,
local WDlink_on = wiki == "mk" or wiki == "ja" or wiki == "ru" or wiki == "he"
seasonID=tRace.lastID,
local tableEndText = ''
lf=lf,
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.031 ⟶ 6.051:
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 string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name
if get_arg(2,frame) ~= nil then
then localframe = frame:getParent() else localframe = frame end
if mw.ustring.find(mw.ustring.lower(get_arg(2,frame)), "sort") or wiki == "lv" or wiki == "mk" or wiki == "ru" then
if localframe.args[2] ~= nil then
sort = true
if mw.ustring.find(mw.ustring.lower(localframe.args[2]), "sort") then sort = true else sort = false end
else
end
sort = false
if wiki == "lv" or wiki == "mk" or wiki == "ru" then sort = true end
end
end
local s = {
sort=sort,
seasonID=seasonID,
lf=lf
}
return teamroster_main(s)
end
 
local womenrace_bool=isWomenrace(squadID)
function teamroster_main(s)
local flags, paystemp = {}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
 
temp = firstValue(squadID, 'P580', 'time')
local startOfSeason = getTimeOfRace(s.seasonID, true)
if temp then
startOfSeason = temp
if not s.year then
else
label=getLabelFallback(s.seasonID)
local Sitelink=getSitelinkFallback(squadID,{'en', 'fr', 'de'})
local second_occurrence
if Sitelink == nil then return '> Wikidata is missing data about the start time (P580) and end time (P582) of the season'
local first_occurrence=string.find(label, "%d%d%d%d")
else startOfSeason = '+'..string.match(Sitelink, '%d%d%d%d' ) ..'-01-01T00:00:00Z'
if first_occurrence~=nil then
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(s.seasonIDsquadID, 'P527') do
--re-init
riderName, riderBirthday, correctlanguage=nil, nil, nil
Line 6.108 ⟶ 6.099:
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.128 ⟶ 6.119:
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.206 ⟶ 6.197:
 
-- sorting names
-- if sort == true and #riderTablecorrect~=0 and #riderTablenotcorrect~=0 then -- It was
if sort == true and #riderTablecorrect==0 and #riderTablenotcorrect==0 then -- replaced with this to display the team roster in the ru-wiki
if #riderTablecorrect~=0 then
table.sort(riderTablecorrect, function(a,b) return a["sortkey"1]<b["sortkey"1] end)
table.sort(riderTablenotcorrect, function(a,b) return a[1]<b[1] end)
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.222 ⟶ 6.209:
table.insert(riderTable, v)
end
local wd_link = mw.html.create('span'):css('float','left'):wikitext(wdLink(sframe.seasonIDargs[1]..'#P527'))
if arwiki_totemplate then wd_link = wdLink(sframe.seasonIDargs[1] .. '#P527') end
local outTable = mw.html.create('table')
:addClass('sortable')
Line 6.232 ⟶ 6.219:
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))
:wikitext(translate("getSquadTableColumn",7,womenrace_bool))
if s.year then
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,w_racewomenrace_bool))
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,w_racewomenrace_bool))
if l10n["country_name_list"]available_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,w_racewomenrace_bool))
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,w_racewomenrace_bool))
else
header:tag('th'):cssText('text-align:center;padding:2px 20px 2px 2px;white-space:nowrap'):wikitext(translate("getSquadTableColumn",3,w_racewomenrace_bool))
end
local temp
Line 6.260 ⟶ 6.243:
local tCell= tRow:tag('td'):cssText("padding:0 1em 0 0;white-space:nowrap")
 
if not l10n["country_name_list"]available_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.267 ⟶ 6.250:
local note=''
if v['riderReason'] ~= nil then
note = ', [[#tr_'..i..sframe.seasonIDargs[1]..'|'..translate("getSquadTableColumn",4,w_racewomenrace_bool)..']]'
if wiki == "ar" then note = '، [[#tr_'..i..sframe.seasonIDargs[1]..'|'..translate("getSquadTableColumn",4,w_racewomenrace_bool)..']]' end
end
tCell:wikitext(' ('..(v['riderStart'] or '')..'–'..(v['riderEnd'] or '')
Line 6.274 ⟶ 6.257:
elseif v['riderReason'] then
tCell:tag('span'):cssText("font-size:80%; color:#686868")
:wikitext('([[#tr_'..i..sframe.seasonIDargs[1]..'|'..translate("getSquadTableColumn",4,w_racewomenrace_bool)..']]'.. ')')
end
tCell=tRow:tag('td'):cssText("text-align:right;white-space:nowrap")
Line 6.280 ⟶ 6.263:
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(s.lfframe:expandTemplate{ title = 'Template:Birth date and age2', args = { beginYear, beginMonth, beginDay, endYear, endMonth, endDay } })
else
tCell:wikitext(funcDate(v['riderBirthday'] or '', 'long'))
if available_list then
if l10n["country_name_list"] and wiki ~= 'ar' and wiki ~= 'ru' and wiki ~= 'da' then
tRow:tag('td'):wikitext(v['flags'].. ' '..v['pays'])
end
Line 6.296 ⟶ 6.279:
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
else
elseif wiki == "ar" then
if wiki == "ar" then
tCell=tRow:tag('td'):cssText("padding:0 0.5em")
tCell=tRow:tag('td'):cssText("padding:0 0.5em")
else
else
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
tCell=tRow:tag('td'):cssText("padding:0 0.5em; text-align:left")
end
end
if v['riderTeam'] then
Line 6.314 ⟶ 6.299:
local temp=(v['riderReason'] or '')..(v['errortext'] or '')
if iii == 1 then
tableEndText = tableEndText.. translate("getSquadTableColumn",5,w_racewomenrace_bool)..': '.. v['riderName'].. temp
else
tableEndText = tableEndText.. '<span style="color:white">'.. translate("getSquadTableColumn",5,w_racewomenrace_bool)..': </span>'.. riderName.. temp
end
iii = iii + 1
if riderRef ~= nil then tableEndText = tableEndText..
s.lfframe:extensionTag{name='ref', content=v['riderRef'], args = {name='tr_'..iii..sframe.seasonIDargs[1]}} end
tableEndText = tableEndText.. '<br>'
end
Line 6.326 ⟶ 6.311:
if labelMissing then outTable:wikitext(getMissingLabelTrackingCategory()) end
local UCIlink
local ref=race_reference(s.seasonID,s.lf)
if refwiki==''"fr" then --fallback
UCIlink="https://www.uci.org/fr/route/%C3%A9quipe"
local UCIlink
else
if wiki=="fr" then
UCIlink="https://www.uci.org/frroad/route/%C3%A9quipeteams"
else
UCIlink="https://www.uci.org/road/teams"
end
ref=translate("race_reference", 1,w_race).."["..UCIlink..' UCI]'
end
Line 6.345 ⟶ 6.326:
:attr('data-sort-value','zzz')
:cssText("text-align:right")
:tag('small'):wikitext(reftranslate("race_reference", 1,womenrace_bool).."["..UCIlink..' UCI]')
return tostring(outTable)..tableEndText
Line 6.352 ⟶ 6.333:
--== 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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team,
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=tonumber(frame.args[5]), -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
display_team=display_team, -- since the answer is "args[4]"
shapka=get_arg(4,frame,true),
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 istrueframe.args[5] ~= nil and tonumber(get_arg('general',frame.args[5])) ==1 then table.insert( winnersProperty,'Q20882667') end
--podium
if istrue(get_arg('podium',frame)) then
if frame.args[6] ~= nil and tonumber(frame.args[6]) ==1 then
table.insert( winnersProperty,'Q20882668')
table.insert( winnersProperty,'Q20882669')
end
--points
if istrue(get_arg('points',frame)) then table.insert( winnersProperty, 'Q20883007' ) end
if istrueframe.args[7] ~= nil and tonumber(get_arg('mountain',frame.args[7])) ==1 then table.insert( winnersProperty, 'Q20883212Q20883007' ) end
--mounstain
if istrue(get_arg('sprints',frame)) then table.insert( winnersProperty, 'Q20883328' ) end
if istrueframe.args[8] ~= nil and tonumber(get_arg('youth',frame.args[8])) ==1 then table.insert( winnersProperty, 'Q20883139Q20883212' ) end
-- sprints
if istrue(get_arg('combativity',frame)) then table.insert( winnersProperty, 'Q101246973' ) table.insert( winnersProperty, 'Q20893983' ) end
if istrueframe.args[9] ~= nil and tonumber(get_arg('volante',frame.args[9])) ==1 then table.insert( winnersProperty, 'Q27067359Q20883328' ) end
-- youth
if istrue(get_arg('regularity',frame)) then table.insert( winnersProperty, 'Q27067170' ) end
if istrueframe.args[10] ~= nil and tonumber(get_arg('combination',frame.args[10])) ==1 then table.insert( winnersProperty, 'Q20893979Q20883139' ) end
-- supercombativity
if istrue(get_arg('breakaway',frame)) then table.insert( winnersProperty, 'Q27907715' ) end
if istrueframe.args[11] ~= nil and tonumber(get_arg('azzurri',frame.args[11])) ==1 then table.insert( winnersProperty, 'Q27907747Q101246973' ) end
-- combativity
if istrue(get_arg('rookie',frame)) then table.insert( winnersProperty, 'Q28092831' ) end
if istrueframe.args[11] ~= nil and tonumber(get_arg('teams',frame).args[11]) ==1 then table.insert( winnersProperty, 'Q20882921Q20893983' ) end
-- volante
if istrue(get_arg('teamspoints',frame)) then table.insert( winnersProperty, 'Q27104269' ) end
if istrueframe.args[12] ~= nil and tonumber(get_arg('amateur',frame.args[12])) ==1 then table.insert( winnersProperty, 'Q61976850Q27067359' ) end
-- regularity
if istrue(get_arg('nationality',frame)) then table.insert( winnersProperty, 'Q61976872' ) end
if istrueframe.args[13] ~= nil and tonumber(get_arg('country',frame.args[13])) ==1 then table.insert( winnersProperty, 'Q72068715Q27067170' ) end
-- combination
if istrue(get_arg('countryU23',frame)) then table.insert( winnersProperty, 'Q72068724' ) end
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,
beginyear=tonumber(frame.args[2]),
raceID=raceID,
beginyearendyear=get_argtonumber(2,frame,true.args[3]),
endyearshapka=get_argtonumber(3,frame,true.args[4]),
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.579 ⟶ 6.563:
local titletable
local w_racewomenrace_bool=isWomenrace(raceID)
if s.custom then
titletable={
[ 'Q20882667' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner
[ 'Q20882668' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second
[ 'Q20882669' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third
[ 'Q20883007' ]=translate("listofwinners",5, w_racewomenrace_bool), -- points
[ 'Q20883212' ]=translate("listofwinners",6, w_racewomenrace_bool), -- mountains
[ 'Q20883328' ]=translate("listofwinners",7, w_racewomenrace_bool), -- sprints
[ 'Q20883139' ]=translate("listofwinners",8, w_racewomenrace_bool), -- youth
[ 'Q101246973' ]=translate("listofwinners",9, w_racewomenrace_bool), -- supercombativity
[ 'Q20893983' ]=translate("listofwinners",9, w_racewomenrace_bool), -- combativity
[ 'Q20893979' ]=translate("listofwinners",10, w_racewomenrace_bool), -- combination
[ 'Q20882921' ]=translate("listofwinners",11, w_racewomenrace_bool), -- teams
[ 'Q27067359' ]=translate("listofwinners",12, w_racewomenrace_bool), -- volantes
[ 'Q27067170' ]=translate("listofwinners",13, w_racewomenrace_bool), -- regularity
[ 'Q27104269' ]=translate("listofwinners",14, w_racewomenrace_bool), -- teamspoints
[ 'Q27907715' ]=translate("listofwinners",15, w_racewomenrace_bool), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",16, w_racewomenrace_bool), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",17, w_racewomenrace_bool), -- rookie
[ 'Q61976850' ]=translate("listofwinners",18, w_racewomenrace_bool), -- amateur
[ 'Q61976872' ]=translate("listofwinners",19, w_racewomenrace_bool), -- nationality
[ 'Q72068715' ]=translate("listofwinners",23, w_racewomenrace_bool), -- winner country
[ 'Q72068724' ]=translate("listofwinners",24, w_racewomenrace_bool), -- winner countryU23
}
else --main
titletable={
-- winner:
[ 'Q20882667' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner
[ 'Q20883007' ]=translate("listofwinners",2, w_racewomenrace_bool), -- points
[ 'Q20883212' ]=translate("listofwinners",2, w_racewomenrace_bool), -- mountains
[ 'Q20883328' ]=translate("listofwinners",2, w_racewomenrace_bool), -- sprints
[ 'Q20883139' ]=translate("listofwinners",2, w_racewomenrace_bool), -- youth (time or point)
[ 'Q101246973' ]=translate("listofwinners",2, w_racewomenrace_bool), -- supercombativity
[ 'Q20893983' ]=translate("listofwinners",2, w_racewomenrace_bool), -- combativity
[ 'Q20893979' ]=translate("listofwinners",2, w_racewomenrace_bool), -- combination
[ 'Q20882921' ]=translate("listofwinners",2, w_racewomenrace_bool), -- team (time)
[ 'Q27067359' ]=translate("listofwinners",2, w_racewomenrace_bool), -- volantes
[ 'Q27067170' ]=translate("listofwinners",2, w_racewomenrace_bool), -- regularity
[ 'Q27104269' ]=translate("listofwinners",2, w_racewomenrace_bool), -- teampoints
[ 'Q27907715' ]=translate("listofwinners",2, w_racewomenrace_bool), -- breakaway
[ 'Q27907747' ]=translate("listofwinners",2, w_racewomenrace_bool), -- azzurri
[ 'Q28092831' ]=translate("listofwinners",2, w_racewomenrace_bool), -- rookie
[ 'Q61976850' ]=translate("listofwinners",2, w_racewomenrace_bool), -- amateur
[ 'Q61976872' ]=translate("listofwinners",2, w_racewomenrace_bool), -- nationality
[ 'Q72068715' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner country
[ 'Q72068724' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner countryU23
[ 'Q98959152' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner team GS-I
[ 'Q98959153' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner team GS-II
[ 'Q98959155' ]=translate("listofwinners",2, w_racewomenrace_bool), -- winner team GS-III
-- 2 place:
[ 'Q20882668' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second
[ 'Q72065970' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second teampoints
[ 'Q72099969' ]=translate("listofwinners",3, w_racewomenrace_bool), -- youth (time or point)
[ 'Q72068718' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second country
[ 'Q72068725' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second countryU23
[ 'Q98959192' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second team GS-I
[ 'Q98959194' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second team GS-II
[ 'Q98959195' ]=translate("listofwinners",3, w_racewomenrace_bool), -- second team GS-III
-- 3 place:
[ 'Q20882669' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third
[ 'Q72065977' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third teampoints
[ 'Q72099972' ]=translate("listofwinners",4, w_racewomenrace_bool), -- youth (time or point)
[ 'Q72068721' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third country
[ 'Q72068729' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third countryU23
[ 'Q98959196' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third team GS-I
[ 'Q98959197' ]=translate("listofwinners",4, w_racewomenrace_bool), -- third team GS-II
[ 'Q98959198' ]=translate("listofwinners",4, w_racewomenrace_bool), -- 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.658 ⟶ 6.651:
"above row x" inserts a new row above row x into the table. Content is what is behind the ":".
]=]
if get_arg(localframe.args[2,lf)] then
for num, _ in pairs(lflocalframe.args) do
if num > 1 and mw.ustring.find(mw.ustring.lower(get_arg(localframe.args[num,lf)]), 'row') then
local _, _, kebeginYear, val = mw.ustring.find(get_arg(localframe.args[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.675 ⟶ 6.668:
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.698 ⟶ 6.691:
local temp=firstValue(partID, 'P1346','id')
if temp and temp=='Q30108381' or temp=='Q54806642' or temp=='Q23023872' then --race cancelled
local cancelledlabel = getLabelFallback(temp'Q30108381', {wikilang, 'en', 'fr', 'de'})
tCell=mw.html.create('td'):attr('colspan','4')
:cssText('text-align:center; font-style: italic')
Line 6.705 ⟶ 6.698:
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.739 ⟶ 6.732:
tCell:wikitext(tostring(wd_link))
end
tCell:wikitext(translate("listofwinners",1,w_racewomenrace_bool)) --year
for _, pp in ipairs(s.winnersProperty) do
tTitleRow:tag('th'):wikitext(titletable[pp])
Line 6.791 ⟶ 6.784:
 
--== 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.843 ⟶ 6.820:
end location are the same. The file data for the icon looks this way: [[File:Stage rest day.svg|any text]]
]=]
if get_arg(localframe.args[2,lf)] then
local WProw, WPnew_row, WPcourse, WPtext, WPdate, WPwinner, WPicon, WPdistance
= 'row', 'afterrow', 'location', 'text', 'date', 'winner', 'icon', 'distance'
Line 6.849 ⟶ 6.826:
local key01, kebeginYear1, kebeginYear2
local key21, key22
for num, var in pairs(lflocalframe.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.909 ⟶ 6.886:
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 not eutimeOfRace then
local startcountryIDstartcountry=getCountryID getStatementForTime(sPointID, 'P17',timeOfRace)
if startcountry then
if startcountryID and firstcountryID ~= startcountryID then
local startcountryID = startcountry.mainsnak.datavalue.value.id
sPoint = flag(startcountryID, timeOfRace).." "..sPoint
if firstcountryID ~= startcountryID then
local sflag = flag(startcountryID, timeOfRace)
sPoint = sflag.." "..sPoint
end
end
end
Line 6.928 ⟶ 6.905:
local dPoint = (dPointID and getPlaceLink(dPointID, timeOfRace)) or ''
 
if dPointID and not onecountry and timeOfRace then
eu=false
local dcountry= getStatementForTime(dPointID, 'P17',timeOfRace)
if wiki=="eu" and dPointID then
if dcountry then
dPoint, eu=check_basque_place(dPoint, dPointID)
local dcountryID = dcountry.mainsnak.datavalue.value.id
end
if firstcountryID ~= dcountryID then
 
local dflag = flag(dcountryID, timeOfRace)
if dPointID and not onecountry and not eu then
dPoint = dflag.." "..dPoint
local dcountryID=getCountryID(dPointID, timeOfRace)
end
if dcountryID and firstcountryID ~= dcountryID then
dPoint = flag(dcountryID, timeOfRace).." "..dPoint
end
end
Line 6.949 ⟶ 6.925:
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.955 ⟶ 6.931:
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.967 ⟶ 6.943:
if winners['Q20882763']~='' then tempoverall=winners['Q20882763'] else tempoverall=winners['Q20882667'] end
rows[#rows + 1] = {
rank=tonumber(sNumber) or 0, sLetter, -- Sort keys
sLink, sDate, WDLink, sPoint, dPoint, sType, sDistance, sElevation, winners['Q20882747'], tempoverall -- Content
sortkey=sLetter, -- Sort keys
sLink=sLink,
sDate=sDate,
WDLink=WDLink,
sPoint=sPoint,
dPoint=dPoint,
sType=sType,
sDistance=sDistance,
sElevation=sElevation,
sSWin=winners['Q20882747'],
sGWin=tempoverall -- Content
}
end
Line 6.984 ⟶ 6.950:
 
table.sort(rows, function(a, b)
if a["rank"1] ~= b["rank"1] then return a["rank"1] < b["rank"1] end
return a["sortkey"2] < b["sortkey"2]
end)
local Id = ((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")
Line 6.997 ⟶ 6.963:
:css('text-align','center')
tRow:tag('th'):css('white-space','nowrap')
:wikitext(Id..translate("headoftable",1,w_racewomenrace_bool))
tRow:tag('th'):wikitext(translate("headoftable",2,w_racewomenrace_bool))
tRow:tag('th'):wikitext(translate("headoftable",3,w_racewomenrace_bool))
tRow:tag('th'):css('color',backgroundColor):wikitext("type")
tRow:tag('th'):wikitext(translate("headoftable",4,w_racewomenrace_bool))
if thereiselevation then
tRow:tag('th'):wikitext(translate("headoftable",7,w_racewomenrace_bool))
end
tRow:tag('th'):wikitext(translate("headoftable",5,w_racewomenrace_bool))
tRow:tag('th'):wikitext(translate("headoftable",6,w_racewomenrace_bool))
local header = tostring(tRow)
for num, row in pairs(rows) do
local sLink, sDate, WDLink, sPoint, dPoint, sType, sDistance, sElevation, sSWin, sGWin
local sPoint=row["sPoint"]
= row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12]
local dPoint=row["dPoint"]
 
local sType=row["sType"]
local sDistance=row["sDistance"]
local WPc = WPcontent[num]
if WPc then
Line 7.024 ⟶ 6.988:
 
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 7.035 ⟶ 6.999:
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.041 ⟶ 7.005:
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.074 ⟶ 7.038:
 
function p.stagetitle(frame)
-- WDlink_on is used to decide if a Wikidata logo will be shown
local stageID = get_and_checkID(frame)
local stageID = frame.args[1]
-- from to
local sPointIDp = firstValuemw.wikibase.getBestStatements(stageID, 'P1427',) -- P1427 is 'idstart point')
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 = firstValue(stageID,p[1] and p[1].mainsnak.snaktype == 'P1444value', '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.095 ⟶ 7.062:
local road, ITT, result
local hcountry, hnotcountry = {},{}
local w_racewomenrace_bool=nil --to be defined if needed
--the jersey for a stage race and the jersey from national championship should be differentiated
Line 7.104 ⟶ 7.071:
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.147 ⟶ 7.114:
end
--avoid double display of jersey
result = "<small>("..translate("startlist",10,w_racewomenrace_bool).." "..translate("startlist",12,w_racewomenrace_bool).." "..translate("startlist",11,w_racewomenrace_bool)..")</small>"
elseif road then
result = "<small>("..translate("startlist",10,w_racewomenrace_bool)..")</small>"
elseif ITT then
result = "<small>("..translate("startlist",11,w_racewomenrace_bool)..")</small>"
else
result = ""
Line 7.166 ⟶ 7.133:
local q = winner.qualifiers
if q then
if q.P2501P642 and q.P2501P642[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.193 ⟶ 7.158:
local displaytypeofstage = true
local stageinfotable = {}
local raceID, lf = get_and_checkID(frame).args[1]
local w_racewomenrace_bool=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.207 ⟶ 7.181:
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,w_racewomenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q175399') -- Point
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_racewomenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q927157') -- Mountains
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_racewomenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q2254180Q641662') -- Young
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_racewomenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q1436680') -- Team by time
if Sitelink then teamname="[["..Sitelink .."|"..translate("infobox",28,w_racewomenrace_bool).."]]" 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
 
Sitelink = wikibase.getSitelink('Q2094179')
elseif thisGT=='Q33861' then -- Giro d'Italia
if Sitelink then combativityname="[["..Sitelink .."|"..translate("infobox",26,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q1164275') -- General
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
 
Sitelink = wikibase.getSitelink('Q2094179')
elseif thisGT=='Q33937' then -- Vuelta a España
if Sitelink then supercombativityname="[["..Sitelink .."|"..translate("infobox",26,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q2532554') -- General
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('Q3679692Q1835362') -- General
if Sitelink then overallnamecombinedname="[["..Sitelink .."|"..translate("headoftableIIinfobox",927,w_racewomenrace_bool).."]]" end
elseif thisGT=='Q33861' then
Sitelink = wikibase.getSitelink('Q3679673') -- Point
Sitelink = wikibase.getSitelink('Q1164275')
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,w_race).."]]" end
if Sitelink then overallname="[["..Sitelink .."|"..translate("headoftableII",9,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q3679712') -- Mountains
Sitelink = wikibase.getSitelink('Q641083')
if Sitelink then mountainname="[["..Sitelink .."|"..translate("infobox",23,w_race).."]]" end
if Sitelink then pointsname="[["..Sitelink .."|"..translate("infobox",22,womenrace_bool).."]]" end
Sitelink = wikibase.getSitelink('Q3679695') -- Young
Sitelink = wikibase.getSitelink('Q641060')
if Sitelink then youngname="[["..Sitelink .."|"..translate("infobox",25,w_race).."]]" end
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,w_racewomenrace_bool), QID = 'Q20882747'}, -- stage
{ name = overallname or translate("headoftableII",9,w_racewomenrace_bool), QID = 'Q20882763' }, -- overall
{ name = pointsname or translate("infobox",22,w_racewomenrace_bool), QID = 'Q20883008' }, -- points
{ name = mountainname or translate("infobox",23,w_racewomenrace_bool), QID = 'Q20883213' }, -- mountains
{ name = translate("infobox",24,w_racewomenrace_bool), QID= 'Q20883329' }, -- sprints
{ name = youngname or translate("infobox",25,w_racewomenrace_bool), QID='Q20883140' }, -- youth
{ name = combativityname or translate("infobox",26,w_racewomenrace_bool), QID= 'Q21686770' }, -- combativity
{ name = supercombativityname or translate("infobox",26,w_racewomenrace_bool), QID= 'Q20893984' }, -- combativity
{ name = translate("infobox",35,w_racewomenrace_bool), QID= 'Q27104688' }, -- volantes
{ name = translate("infobox",36,w_racewomenrace_bool), QID= 'Q27104684' }, -- regularity
{ name = combinedname or translate("infobox",27,w_racewomenrace_bool), QID='Q20965880' }, -- combination
{ name = translate("infobox",38,w_racewomenrace_bool), QID='Q27907714' }, -- breakaway
{ name = translate("infobox",39,w_racewomenrace_bool), QID='Q27907748' }, -- azzurri
{ name = translate("infobox",40,w_racewomenrace_bool), QID='Q28096780'}, -- rookie
{ name = teamname or translate("infobox",28,w_racewomenrace_bool), QID='Q20882922' }, -- teams
{ name = translate("infobox",37,w_racewomenrace_bool), QID ='Q27104271' }, -- teamspoints
{ name = translate("infobox",41,w_racewomenrace_bool), QID ='Q61976847' },-- amateur
{ name = translate("infobox",42,w_racewomenrace_bool), QID ='Q61976871' } --nationality
}
 
Line 7.371 ⟶ 7.331:
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.386 ⟶ 7.346:
if ii==1 then jerseytable[v.QID]='' end
end
winner(lf,stageID, win, timeOfRace, false, WDlink_on, false, false) --fill win table
if ii<=2=1 then --only two first stagesstage
jerseytable, bgcolortable=winnerjersey(stageID, jerseytable)
end
Line 7.408 ⟶ 7.368:
end
columntable[v.QID].used=true
if ii<=2=1 then --read the jersey in the two first stagesstage of a race
if columntable[v.QID].jersey == '' or columntablejerseytable[v.QID].jersey==nil then
columntable[v.QID].jerseybg_color=jerseytablebgcolortable[v.QID]
columntable[v.QID].bg_color=bgcolortable[v.QID]
end
end
end
Line 7.431 ⟶ 7.389:
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.463 ⟶ 7.421:
end
end
table.insert(stageinfotable,{sLink=translate("listofstagesclassification",2,w_racewomenrace_bool), sType=nil, somewinner=somewinner})
 
--build the table
Line 7.474 ⟶ 7.432:
tRow:tag('th'):css('white-space','nowrap')
:wikitext(((not WDlink_on and wdLink(string.gsub(raceID, '%s', '') .. "#P527")) or "")..
translate("headoftable",1,w_racewomenrace_bool))
if displaytypeofstage==true then tRow:tag('th') end
Line 7.522 ⟶ 7.480:
tCell=tRow:tag('td')
if ii~=#stageinfotable and v.somewinner==true then
tCell:wikitext(translate("listofstagesclassification",1,w_racewomenrace_bool)) --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,w_racewomenrace_bool)) --not attributed
else
tCell:cssText('border-top: 2px black solid') --empty
Line 7.540 ⟶ 7.498:
--M) Start list
function p.startlist(frame)
local IDtemp
local tempID, lf=get_and_checkID(frame)
if frame.args[1] ~= nil then
local w_race=isWomenrace(tempID)
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=tempIDIDtemp,
title="Start list",
data_sort_type={'unsortable', 'unsortable', 'unsortable'},
property ='P710',
no_roll_startlist=no_roll_startlist,
womenrace_bool=womenrace_bool
w_race=w_race,
lf=lf
}
 
Line 7.560 ⟶ 7.520:
 
function p.startlisttable(frame)
local IDtemp
local tempID, lf=get_and_checkID(frame)
if frame.args[1] ~= nil then
local w_race=isWomenrace(tempID)
IDtemp=string.gsub(frame.args[1], "%c", "")
end
local womenrace_bool=isWomenrace(IDtemp)
 
local s = {
Line 7.567 ⟶ 7.530:
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=tempIDIDtemp,
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.573 ⟶ 7.536:
property ='P710',
no_roll_startlist=no_roll_startlist,
womenrace_bool=womenrace_bool
w_race=w_race,
lf=lf
}
return startlisttable_main(s, tableA(s))
end
 
local function startlist_sub(p710, timeOfRace, WDlink_on, istable,w_racewomenrace_bool)
local h, resultTable= {}, {}
--Return a table containing a row for the selected rider and their associated team, link, etc
local h = {}
local tBody = '' --row in our case
local riderID, riderTeamLink, riderTeamID, riderDossard, riderLink, riderRank
Line 7.604 ⟶ 7.565:
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,w_racewomenrace_bool)--"HD","NP","DQ"
elseif dnf=='Q54881674' or dnf=='Q7113430' then riderDNF =translate("startlist",7,w_racewomenrace_bool)
elseif dnf=='Q1210382' then riderDNF =translate("startlist",8,w_racewomenrace_bool)
elseif dnf=='Q1229261' then riderDNF =translate("startlist",9,w_racewomenrace_bool)
else riderDNF=''
end
Line 7.652 ⟶ 7.613:
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 data.natTeamCats[catID]national_team_boolean and countryID then
if riderTeamCode and wikibase.getSitelink(countryID) then --for the refugee case
riderTeamCode='[['..wikibase.getSitelink(countryID)..'|'..riderTeamCode..']]'
Line 7.667 ⟶ 7.628:
riderLink =riderLink..jerseytemp
 
if riderTeamLink == nil then riderTeamLink ="" end
local sortkey = riderDossard == "" and 0 or tonumber(riderDossard)
 
Line 7.676 ⟶ 7.638:
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, {sortkey=sortkey, riderTeamLink=riderTeamLink,riderTeamID=riderTeamID,riderTeamCode=riderTeamCode, tBody=tBody})
--table.insert(resultTable, )
return resultTable
return {sortkey=sortkey, riderTeamLink=riderTeamLink,riderTeamID=riderTeamID,riderTeamCode=riderTeamCode, body=tBody}
end
 
Line 7.690 ⟶ 7.652:
 
local timeOfRace=getTimeOfRace(s.item)
local w_racewomenrace_bool=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.P54P642 and q.P54P642[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
table.insert(ridertable, subtable=startlist_sub(p710, timeOfRace, WDlink_on, false,w_race)womenrace_bool)
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
--sort
if a['sortkey'] ~= b['sortkey'] then --sort by bib
table.sort(ridertable, function(a, b) return a['sortkey'1] < b['sortkey'1] 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.723 ⟶ 7.686:
tSubtitle:tag('td'):attr('width','30px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",2,w_racewomenrace_bool))
tSubtitle:tag('td'):attr('width','200px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",3,w_racewomenrace_bool))
tSubtitle:tag('td'):attr('width','85px')
:css("align:right;text-align:right")
:wikitext(translate("startlist",4,w_racewomenrace_bool))
else
tSubtitle=mw.html.create('tr')
tSubtitle:tag('td'):attr('width','30px'):wikitext(translate("startlist",2,w_racewomenrace_bool))
tSubtitle:tag('td'):attr('width','250px'):wikitext(translate("startlist",3,w_racewomenrace_bool))
tSubtitle:tag('td'):attr('width','35px'):wikitext(translate("startlist",4,w_racewomenrace_bool))
end
 
Line 7.745 ⟶ 7.708:
else
for ii=1,#ridertable do
if ridertable[ii].riderTeamLink==nil then ridertable[ii].riderTeamLink=translate("startlist",13,womenrace_bool) end
--new team
if not (ii~=1 and ridertable[ii].riderTeamID and ridertable[ii].riderTeamID==ridertable[ii-1].riderTeamID) orthen iitest=0 else test=1 then end--ridertable[ii].riderTeamID andteam 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,w_racewomenrace_bool).." "..thisDS)
thisDS=nil
end
Line 7.776 ⟶ 7.741:
: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.793 ⟶ 7.758:
end
end
insideTable:node(ridertable[ii].tBody)
--add the rider, also for old team
insideTable:node(ridertable[ii].body)
end
--last DS
Line 7.800 ⟶ 7.764:
tDS=insideTable:tag('tr')
tDS:tag('td'):attr('colspan','3'):attr('align','center')
:wikitext(translate("startlist",5,w_racewomenrace_bool).." "..thisDS)
end
tag:node(thisTableRow)
Line 7.807 ⟶ 7.771:
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.834 ⟶ 7.779:
 
for _, p710 in statements(s.item, 'P710') do -- P710 is participants
table.insert(t_Body,local 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.852 ⟶ 7.797:
 
function p.riderranking(frame)
local tempID, lf=get_and_checkID(frame)
local s = {
item = string.gsub(frame.args[1] or frame:getParent().args[1], "%c", ""),
item = tempID,
lf=lf
}
return riderranking_main(frame, s)
end
 
 
local function checkWorldTourTeam(itemID,year)
function riderranking_main(frame,s)
local thisdate='+'..tostring(year).."-07-01T00:00:00Z"
local thisCompetition, rank, thisyear, sitelink, q, gender, DSQ
local catID
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
}
local UCI = {}
for _, s in statements(itemID, 'P54') do
--inverse the table
p54 =checktime(s, s.qualifiers, thisdate) --present Team
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
UCIQtoYearUCI[k]={}
for kk, vv in pairs(v) do
UCIQtoYearUCI[k][vv]=kk --calendar/Q = year
end
end
return listofcalendar, UCIQtoYear
local UCImaster=data.UCImaster
end
 
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 w_racewomenrace_bool=false
if gender=="f" then w_racewomenrace_bool=true end
 
UCImastername={
local minmaxyear= { minimum = 0, maximum = 0 }
["women"]= translate("riderranking",2,womenrace_bool),
local listofcalendar, UCIQtoYear=riderranking_sub(w_race)
['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),
}
 
UCImasterlimit={
local resultTable={}
["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.928 ⟶ 7.892:
for _, p1344 in statements(s.item, 'P1344') do
thisCompetition = p1344.mainsnak.datavalue.value.id
for _, calendar in pairs(listofcalendar) do
if UCIQtoYearUCI[calendar][thisCompetition] then
thisyear=UCIQtoYearUCI[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.952 ⟶ 7.923:
local tRow= finalTable:tag('tr'):tag('th')
:css("background-color",backgroundColor)
:wikitext(wdLin..' '..translate("riderranking",1,w_racewomenrace_bool)) --year
 
for ii=minmaxyear.minimum,minmaxyear.maximum,1 do
Line 7.964 ⟶ 7.935:
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..'|'..calendar_nameUCImastername[calendar]..']]')
else
tCell:wikitext(calendar_nameUCImastername[calendar])
end
Line 7.977 ⟶ 7.947:
thisyear=tostring(yy)
color="white"
if resultTable[ thisyear][calendar]["rank"] then
local impossible=false
if resultTable[thisyear][calendar]["rank"]=="1" then
--we need to check the impossibility here, as it is impossible even if nothing is in P1344
color="gold"
if data.continental_calendar[calendar] then
elseif (2<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=3) then
--between 2005 and 2015 WorldTour team member cannot score by continental calendars.
color="YellowGreen"
if tonumber(thisyear)>=2005 and tonumber(thisyear)<=2015 then
elseif (4<=tonumber(resultTable[thisyear][calendar]["rank"])) and (tonumber(resultTable[thisyear][calendar]["rank"])<=10) then
if checkWorldTourTeam(s.item,thisyear) then
impossiblecolor=true"silver"
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
 
if tCell=tRow:tag('td'):attr("bgcolor",color):cssText(resultTable[ thisyear][calendar]["rankDSQ"] or impossible then)
local rank=tonumber(resultTable[thisyear][calendar]["rank"])
if impossible then
rank=number(gender,rank,wiki)
tRow:tag('td'):css('background-color',backgroundColorLight)
if resultTable[thisyear][calendar]["sitelink"] then
tCell:wikitext('[['..resultTable[thisyear][calendar]["sitelink"]..'|'..rank..']]')
else
tCell:wikitext(rank)
if resultTable[thisyear][calendar]["rank"]=="1" then
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>=data.UCIcalendarstartendUCImasterlimit[calendar].b and
(data.UCIcalendarstartendUCImasterlimit[calendar].e==0 or yy<=data.UCIcalendarstartendUCImasterlimit[calendar].e) then
if wiki=="fr" then
tRow:tag('td'):wikitext(' nc ')
Line 8.038 ⟶ 7.979:
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.052 ⟶ 8.001:
:wikitext(legend)
tCell:tag('span'):css("float","right")
:wikitext(translate("race_reference", 1,w_racewomenrace_bool).."["..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.259 ⟶ 8.050:
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.317 ⟶ 8.071:
end
end
return riderteam, initialYear, finalYear
end
 
Line 8.353 ⟶ 8.107:
 
if managedTeam then
cat=data.nationalcat
else
cat=data.amateurcat
end
 
Line 8.582 ⟶ 8.336:
 
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.595 ⟶ 8.349:
 
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.611 ⟶ 8.365:
end
 
local function getBirthDeathDate(entityID, display_age)
local birthDate=firstValue(entityID, 'P569', 'time')
local deathDate=firstValue(entityID, 'P570', 'time')
Line 8.617 ⟶ 8.371:
local gender=getGenderCode(entityID, 'm')
local w_racewomenrace_bool=false
if gender=="f" then w_racewomenrace_bool=true end
 
if birthDate then
Line 8.630 ⟶ 8.384:
local ans
if gen_singular then
ans=translate("riderinfobox",48,w_racewomenrace_bool)
elseif gen_plural then
ans=translate("riderinfobox",49,w_racewomenrace_bool)
else
ans=translate("riderinfobox",50,w_racewomenrace_bool)
end
 
Line 8.658 ⟶ 8.412:
local ans
if gen_singular then
ans=translate("riderinfobox",48,w_racewomenrace_bool)
elseif gen_plural then
ans=translate("riderinfobox",49,w_racewomenrace_bool)
else
ans=translate("riderinfobox",50,w_racewomenrace_bool)
end
if display_age==false then
Line 8.699 ⟶ 8.453:
teamLinkRoad=teamLink
elseif dis=='mountainBike' then
row=teamLink..' ('..translate("riderinfobox",56,w_race)..'VTT)'
elseif dis=='cycloCross' then
row=teamLink..' ('..translate("riderinfobox",57,w_race)..'cyclo-cross)'
else
row=teamLink..' ('..translate("riderinfobox",58,w_race)..'piste)'
end
if row then
Line 8.746 ⟶ 8.500:
 
--for wikidata input
local function teamTable(tab, teamAmateur, title_singular, title_plural)
if teamAmateur and #teamAmateur>0 then
if #teamAmateur==1 then
Line 8.761 ⟶ 8.515:
end
if v['stagiaire'] then
local stagiaire = string.gsub(getLabelFallbackwikibase.label('Q2328847',lang_priority), "%b()", "") or getLabelFallback('Q2328847',{'en', 'fr', 'de'})
nametemp=nametemp..' ('..stagiaire..')'
end
Line 8.770 ⟶ 8.524:
 
--for local data
local function localTeamTable(tab, names, periods, title_singular, title_plural)
if names then
names = mw.text.split(names, '<br />')
Line 8.787 ⟶ 8.541:
 
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 w_racewomenrace_bool=false
if gender=="f" then w_racewomenrace_bool=true end
 
local details = {
{ name = translate("riderinfobox",1,w_racewomenrace_bool), name_plural =translate("riderinfobox",2,w_racewomenrace_bool)}, -- birth name
{ name = translate("riderinfobox",3,w_racewomenrace_bool), name_plural =translate("riderinfobox",4,w_racewomenrace_bool)}, -- nick name
{ name = translate("riderinfobox",5,w_racewomenrace_bool), name_plural =translate("riderinfobox",6,w_racewomenrace_bool)}, -- official name
{ name = translate("riderinfobox",7,w_racewomenrace_bool), name_plural =translate("riderinfobox",8,w_racewomenrace_bool)}, -- official name
{ name = translate("riderinfobox",9,w_racewomenrace_bool) }, -- birth translate("riderinfobox",9)
{ name = translate("riderinfobox",10,w_racewomenrace_bool)}, -- death
{ name = translate("riderinfobox",11,w_racewomenrace_bool), name_plural =translate("riderinfobox",12,w_racewomenrace_bool)}, -- country
{ name = translate("riderinfobox",13,w_racewomenrace_bool), name_plural =translate("riderinfobox",14,w_racewomenrace_bool)}, -- present team
{ name = translate("riderinfobox",15,w_racewomenrace_bool), name_plural =translate("riderinfobox",16,w_racewomenrace_bool)}, -- speciality
{ name = translate("riderinfobox",17,w_racewomenrace_bool) }, -- lateralisation
{ name = translate("riderinfobox",18,w_racewomenrace_bool) }, -- blood group
{ name = translate("riderinfobox",19,w_racewomenrace_bool) }, -- height
{ name = translate("riderinfobox",20,w_racewomenrace_bool) }, -- weight
{ name = translate("riderinfobox",21,w_racewomenrace_bool), name_plural =translate("riderinfobox",22,w_racewomenrace_bool)}, -- awards
}
local teams = {
{ name = translate("riderinfobox",23,w_racewomenrace_bool), name_plural =translate("riderinfobox",24,w_racewomenrace_bool)}, -- directed teams
{ name = translate("riderinfobox",25,w_racewomenrace_bool)}, -- directed years
{ name = translate("riderinfobox",26,w_racewomenrace_bool), name_plural =translate("riderinfobox",27,w_racewomenrace_bool)}, -- amateur names
{ name = translate("riderinfobox",28,w_racewomenrace_bool)}, -- amateur periods
{ name = translate("riderinfobox",29,w_racewomenrace_bool), name_plural =translate("riderinfobox",30,w_racewomenrace_bool)}, -- nonUCI names
{ name = translate("riderinfobox",31,w_racewomenrace_bool)}, -- nonUCI periods
{ name = translate("riderinfobox",32,w_racewomenrace_bool), name_plural =translate("riderinfobox",33,w_racewomenrace_bool)}, -- pro names
{ name = translate("riderinfobox",34,w_racewomenrace_bool)}, -- pro periods
{ name = translate("riderinfobox",35,w_racewomenrace_bool), name_plural =translate("riderinfobox",36,w_racewomenrace_bool)}, -- UCI names
{ name = translate("riderinfobox",37,w_racewomenrace_bool)}, -- UCI periods
{ name = translate("riderinfobox",52,w_racewomenrace_bool), name_plural =translate("riderinfobox",53,w_racewomenrace_bool)}, -- national selections
{ name = translate("riderinfobox",54,w_racewomenrace_bool)}, -- national selection years
}
 
--separated to have a title
local subtitle = {
{ name = translate("riderinfobox",51,w_racewomenrace_bool)}, -- insertion of a sub-title
}
--separated to have a title
local victories = {
{ name = translate("riderinfobox",38,w_racewomenrace_bool)}, -- main victories
}
--separated to have a title
local medals = {
{ name = translate("riderinfobox",47,w_racewomenrace_bool)}, -- main victories
}
local others = get_others_dic()
 
local nameothers = 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.848 ⟶ 8.624:
if value == wiki then display_birthnameastitle=true end
end
getLocalContent(subtitle, lflocalframe.args)
if not subtitle[1].content and display_birthnameastitle then
Line 8.867 ⟶ 8.643:
infoGetOthers(others, entityID)
 
getLocalContent(details, lflocalframe.args)
getLocalContent(teams, lflocalframe.args)
getLocalContent(others, lflocalframe.args)
getLocalContent(victories, lflocalframe.args)
getLocalContent(medals, lflocalframe.args)
 
local listOfBirthNames, listOfNickNames, listOfOfficialNames, listOfShortNames
Line 8.886 ⟶ 8.662:
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
getSomeNames(details, entityID, 'P1559', 1, display_language) --birthname, bis
if display_nickname then
getSomeNames(details, entityID, 'P1559P1449', 12, display_language) --birthname,nick bisname
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.944 ⟶ 8.705:
--height
if not details[12].content then
details[12].content=getHeight(entityID, display_cm)
end
 
Line 8.966 ⟶ 8.727:
local proWD=true
local managedWD=true
 
local teamAmateur,teamPro, teamMountainBike, teamCycloCross, teamTrack=listOfTeamTable(entityID, initialYear, finalYear)
local nationalTeam, managedTeam=listOfManagedTeamTable(entityID, initialYear, finalYear)
Line 9.018 ⟶ 8.778:
end
 
infoFillOthersDetails(tab, others, details,translate("riderinfobox",55,w_racewomenrace_bool),"260px")
if amateurWD then
teamTable(tab, teamAmateur, translate("riderinfobox",26,w_racewomenrace_bool), translate("riderinfobox",27,w_racewomenrace_bool))
else
localTeamTable(tab,amateurTeam_names, amateurTeam_periods, translate("riderinfobox",26,w_racewomenrace_bool), translate("riderinfobox",27,w_racewomenrace_bool))
localTeamTable(tab,nonUCITeam_names, nonUCITeam_periods, translate("riderinfobox",29,w_racewomenrace_bool), translate("riderinfobox",30,w_racewomenrace_bool))
end
if proWD then
teamTable(tab, teamPro, translate("riderinfobox",45,w_racewomenrace_bool),translate("riderinfobox",46,w_racewomenrace_bool))
teamTable(tab, teamMountainBike, translate("riderinfobox",39,w_racewomenrace_bool), translate("riderinfobox",40,w_racewomenrace_bool))
teamTable(tab, teamCycloCross, translate("riderinfobox",41,w_racewomenrace_bool), translate("riderinfobox",42,w_racewomenrace_bool))
teamTable(tab, teamTrack, translate("riderinfobox",43,w_racewomenrace_bool), translate("riderinfobox",44,w_racewomenrace_bool))
else
localTeamTable(tab,proTeam_names, proTeam_periods,translate("riderinfobox",45,w_racewomenrace_bool), translate("riderinfobox",46,w_racewomenrace_bool))
localTeamTable(tab,UCITeam_names, UCITeam_periods, translate("riderinfobox",35,w_racewomenrace_bool), translate("riderinfobox",36,w_racewomenrace_bool))
end
 
--managed teams
if managedWD then
teamTable(tab, nationalTeam, translate("riderinfobox",52,w_racewomenrace_bool), translate("riderinfobox",53,w_racewomenrace_bool))
teamTable(tab, managedTeam, translate("riderinfobox",23,w_racewomenrace_bool), translate("riderinfobox",24,w_racewomenrace_bool))
else
localTeamTable(tab,managedTeam_names, managedTeam_periods,translate("riderinfobox",23,w_racewomenrace_bool), translate("riderinfobox",24,w_racewomenrace_bool))
end
if victories[1].content then
tab:node(addATitle(translate("riderinfobox",38,w_racewomenrace_bool)))
tab:tag('tr'):tag('td')
:css('vertical-align','top'):attr('colspan','2')
Line 9.052 ⟶ 8.812:
if medals[1].content then
tab:node(addATitle(translate("riderinfobox",47,w_racewomenrace_bool)))
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,w_racewomenrace_bool), 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 = get_and_checkIDmw.text.trim(frame.args[1])
if type(entityID) ~= 'string' then error('parameter must be a string') end
local w_race=isWomenrace(entityID)
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 9.263 ⟶ 8.838:
future,
},
lastEditionMonth,
lastEditionYear,
numberOfEditions,
lastLink,
nextLink,
}
local details = {
{ name = translate("teaminfobox",2,w_racewomenrace_bool)}, -- sport
{ name = translate("teaminfobox",3,w_racewomenrace_bool), name_plural = translate("teaminfobox",4,w_racewomenrace_bool)}, -- type
{ name = translate("teaminfobox",5,w_racewomenrace_bool), name_plural = translate("teaminfobox",6,w_racewomenrace_bool)}, -- UCI-cod
{ name = translate("teaminfobox",7,w_racewomenrace_bool), name_plural = translate("teaminfobox",8,w_racewomenrace_bool)}, -- сountry
{ name = translate("teaminfobox",9,w_racewomenrace_bool)}, -- creation date
{ name = translate("teaminfobox",10,w_racewomenrace_bool)}, -- disparition date
{ name = translate("teaminfobox",11,w_racewomenrace_bool)}, -- number of season
{ name = translate("teaminfobox",13,w_racewomenrace_bool)}, -- official web site
{ name = translate("teaminfobox",2724,w_racewomenrace_bool), name_plural = translate("teaminfobox",2825,w_racewomenrace_bool) }, --sponsor bike
{ name = translate("teaminfobox",2426,w_racewomenrace_bool), name_plural = translate("teaminfobox",25,w_race) }, -- bikebudget
{ name = translate("teaminfobox",26,w_race)}, -- budget
}
local others =get_others_dic() {
{ name = translate("infobox",29,womenrace_bool)}, -- picture
local managers ={
{ name = translate("teaminfoboxinfobox",1430,w_race), name_plural = translate("teaminfobox",15,w_racewomenrace_bool)}, -- manager --countrycaption
{ name = translate("teaminfoboxinfobox",1631,w_race), name_plural = translate("teaminfobox",17,w_racewomenrace_bool)}, -- sports directormap
{ name = 'sectional'}, -- sectional
{ name = translate("infobox",30,womenrace_bool)}, -- caption map
{ name = translate("infobox",30,womenrace_bool)}, -- caption sectional
}
local managers_seasonmanagers ={
{ name = translate("teaminfobox",14,w_racewomenrace_bool), name_plural = translate("teaminfobox",15,w_racewomenrace_bool)}, -- manager --country
{ name = translate("teaminfobox",16,w_racewomenrace_bool), name_plural = translate("teaminfobox",17,w_racewomenrace_bool)}, -- 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, lang_priority'en', 'fr', 'de'}) or ''
infoGetOthers(others, entityID)
local localframe
getLocalContent(details, lf.args)
if string.match(frame:getParent():getTitle(), '%P+') == mw.site.namespaces.Template.name then
getLocalContent(others, lf.args)
localframe = frame:getParent()
getLocalContent(managers, lf.args)
else
localframe = frame
end
getLocalContent(details, localframe.args)
getLocalContent(others, localframe.args)
getLocalContent(managers, localframe.args)
local listOfNames=getFormerNames(entityID, 'P1448')
Line 9.328 ⟶ 8.911:
--creation date
if not details[5].content and creation then
details[5].content = funcDate(creation, "onlyyearY" )
end
 
Line 9.334 ⟶ 8.917:
local disparition=firstValue(entityID, 'P576', 'time')
if not details[6].content and disparition then
details[6].content = funcDate(disparition,"onlyyearY")
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,w_racewomenrace_bool) .. " "..tostring(tRace.lastEditionYear)..")"
end
 
Line 9.350 ⟶ 8.933:
end
--9 is sponsorbike (no Wikidata input)
--10 budget
listWPlinkChrono(details, 9, entityID, {'P859'}, 'rider', initialYear)
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 9.374 ⟶ 8.953:
end
--picture at the top
infoFillOthersDetails(tab, others, details, translate("teaminfobox",1,w_racewomenrace_bool),"260px")
 
if managers[1].content or managers[2].content then
tab:node(addATitle(translate("teaminfobox",18,w_racewomenrace_bool)))
for _, row in ipairs(managers) do
tab:node(addARow(row.name, row.content)) --node check itself if nil
Line 9.384 ⟶ 8.963:
if listOfNames and #listOfNames>0 then --Always display a list of names
tab:node(addATitle(translate("teaminfobox",19,w_racewomenrace_bool)))
for _, v in pairs(listOfNames) do
tab:node(addARow(v[2],v[3])) --period, name
Line 9.391 ⟶ 8.970:
 
-- an empty line with a title under the form in the form of an image or third-party template
if get_arg(frame.args[2,lf)] then -- if the jersey is not specified, then the JERSEY header is not displayed
tab:node(addATitle(translate("teaminfobox",20,w_racewomenrace_bool)))
local outTable = mw.html.create('tr')
local tCell=outTable:tag('td'):attr('colspan','3'):css('text-align','center')
tCell:wikitext(get_arg(frame.args[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.lastIDnextLink or tRace.lastLink then
tab:node(addATitle(translate("teaminfobox",21,womenrace_bool)))
-- manager
local outTable
listWPlinkChrono(managers_season, 1, tRace.lastID, {'P505'}, 'rider', tRace.lastEditionYear, nil, nil, true)
-- 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,w_racewomenrace_bool)..
":<br>'''"..
tRace.lastLink.."'''"
Line 9.433 ⟶ 8.998:
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,w_racewomenrace_bool)..
":<br>'''"..
tRace.nextLink.."'''"
Line 9.441 ⟶ 9.006:
end
 
wdDoc(tab, "d:Wikidata:WikiProject Cycling/Documentation/raceinfobox", translate("raceinfobox",26,w_racewomenrace_bool), 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.634 ⟶ 9.055:
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.677 ⟶ 9.095:
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.765 ⟶ 9.181:
elseif function_name=='getNationality' then
return getNationality(argu[2], argu[3])
elseif function_name=='getCountryIDgetClassCalendar_sub' then
return getCountryIDgetClassCalendar_sub(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.788 ⟶ 9.192:
 
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