« Module:Infobox/Configs/Geographie » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (2 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 23 : | Ligne 23 : | ||
allowedValues = { | allowedValues = { | ||
['supercontinent'] = { | ['supercontinent'] = { | ||
display = ' | display = 'Supercontinent', | ||
category = 'Supercontinent' | category = 'Supercontinent' | ||
}, | }, | ||
| Ligne 30 : | Ligne 30 : | ||
category = 'Continent' | category = 'Continent' | ||
}, | }, | ||
[ | ["cours d'eau"] = { | ||
display = | display = "Cours deau", | ||
category = | category = "Cour d'eau" | ||
}, | }, | ||
['océan'] = { | ['océan'] = { | ||
| Ligne 47 : | Ligne 47 : | ||
}, | }, | ||
}, | }, | ||
errorMessage = | errorMessage = "Type de Géographie non reconnu. Types autorisés : Monde, Supercontinent,Continent,Région, Océan, Mer, Cours d'eau" | ||
}, | }, | ||
| Ligne 76 : | Ligne 76 : | ||
} | } | ||
} | } | ||
} | }, | ||
-- Catégorisation automatique selon le type | |||
categories = function(args, config, frame) | |||
local cats = {} | |||
local title = mw.title.getCurrentTitle() | |||
-- On ajoute les catégories uniquement dans le namespace principal (0) | |||
if title.namespace ~= 0 then | |||
return cats | |||
end | |||
-- Catégorie selon le type | |||
if args.type and config.typeField and config.typeField.allowedValues then | |||
local cleanType = mw.text.trim(mw.ustring.lower(args.type)) | |||
local typeDef = config.typeField.allowedValues[cleanType] | |||
if typeDef and typeDef.category then | |||
table.insert(cats, typeDef.category) | |||
end | |||
end | |||
return cats | |||
end | |||
} | } | ||
return config | return config | ||