Modulenn:Auteur2Tpt-s-br
Documentation for this module may be created at Modulenn:Auteur2Tpt-s-br/doc
local p = {} -- The main Module:Author (version Module:Author3) form a header of authors pages in wikisource.
Auteur2Tpt = p
-- See documentations:
-- MediaWiki:Scribunto/Auteur2Tpt modules reference manual
-- MediaWiki:Scribunto/Auteur2Tpt modules
p.version = { -- Modules dependencies. Dependencias del módulo. Dépendances du module.
versionName = "Auteur2Tpt", versionNumber = "1.0.0(180724T06:00)", versionDate = "2018-07-24T06:00:00",
-- UTC version structure : main.fonction.task(yymmddThh:mm)
mainDescription = "Begin to use", functionDescription = "try Module.Auteur2Tpt", taskDescription = "First operative version",
sought = "Centralizer;Centralizer/I18N;Mathroman;TestRequire", -- Sought module and submodules versions
known = "Centralizer;Centralizer-s-fr;Central-14 * Centralizer/I18N;Central/I18N * Mathroman22;Mathroman34", -- Known module and submodules versions
}
p.Central_version = p.version.versionName
p.ModuleNS = mw.site.namespaces.Module.name .. ":"
local Interprojet = require( p.ModuleNS .. "Interprojet" )
local Centralizer = require(p.ModuleNS .. "Centralizer-s-fr") -- Module:ControlArgs control arguments, mixes translations and manage modules versions.
p.added_modes_views = "" -- Depends of modes.mode_name
p.i18n = {}
p.i18n.en = { -- en = English = English
-- To translate, referral languages are English and French.
-- To translate, do not translate parts like these: <b>%1</b> ; <b><b>%1</b> = <b>%2</b></b> (%3) ; <code>Q535</code> ; <br/> ; \n* ; _G.
["docfunc"] = "docfunc",
["docitem"] = "docitem",
["dockey"] = "dockey",
p_page_erroneous_author_template_i_cat = 'Pages Making a Wrong Call to the Author Template', -- explains next text
p_createLinkRow_file = '[[File:%1-logo.svg|12px|logo de %1]] ',
p_getEntity_Author_without_element_cat = 'Pages « Auteur » without element on Wikidata', -- explains next text
p_getEntity_utilisant_modele_cat = 'Pages using the Author template with a local name', -- explains next text
p_getEntity_using_Description_cat = 'Pages using the Author template with a local Description', -- explains next text
p_getEntity_using_image_local_cat = 'Pages using the Author template with a local image', -- explains next text
p_getEntity_template_local_date_cat = 'Pages using the Author template with a local date', -- explains next text
p_getEntity_template_datas_migrate_cat = 'Pages using the Author template with datas to migrate', -- explains next text
p_getEntity_template_pseudo_local_cat = 'Pages using the Author template with a local nickname', -- explains next text
p_getEntity_contain_name_author_need = 'The parameter "name" is mandatory and must contain the name of the author', -- explains next text
p_Authors_firstname_unknown_cat = 'Authors of first name unknown', -- explains next text
p_key_param_need_contain_sortkey = 'The "key" parameter is mandatory and must contain a sort key for the author', -- explains next text
p_Pages_template_local_key_cat = 'Pages using the Author template with a local key', -- explains next text
p_initial_name_parametre_contain_need = 'The "initial" parameter is mandatory and must contain the initial of the name of the author in uppercase capital', -- explains next text
p_nbsp_authors_args_initiale_cat = " [[:Category:Author-%1|Author %1]]",
-- "Catégorie:Auteurs-H", vue : "Auteurs H" -- explains next text
p_nbsp_authors_args_initiale_cat = ' [[:%1:%2-<b>%3</b>|%2 <b>%3</b>]]',
p_nbsp_authors_args_initiale_cat = ' %1-%2 | %1 %2 ',
-- local Authors_initiale_cat = events.add_cat( viewers.form9content("p_nbsp_authors_args_initiale_cat", p_Category, p_Authors, args.initiale) )
p_plainlinks_wikisource_IndexPages_link = "<span class='plainlinks'>[//fr.wikisource.org/wiki/Spécial:IndexPages?key=' .. mw.uri.encode(searchKey(args.cle)) .. ' Facsimiles]</span>", -- explains next text
p_plainlinks_wikisource_IndexPages_link = "<span class='plainlinks'>[//%1.%2.org/wiki/%3:IndexPages?key=<b>%4</b> %5]</span>",
-- local commonsCat = item:formatPropertyValues('P373').value -- explains next text
p_commonsCat_item_formatPropertyValues = "P373", -- explains next text
} -- p.i18n.en
p.i18n.es = { -- es = Spanish = español
-- Para traducir, los idiomas de referencia son inglés y francés.
-- Para traducir, no traduzca partes como estas: <b>%1</b> ; <b><b>%1</b> = <b>%2</b></b> (%3) ; <code>Q535</code> ; <br/> ; \n* ; _G.
["docfunc"] = "docfunc",
["docitem"] = "docitem",
["dockey"] = "dockey",
p_page_erroneous_author_template_i_cat = 'Páginas haciendo una llamada incorrecta a la plantilla del autor', -- explains next text
p_createLinkRow_file = '[[File:%1-logo.svg|12px|logo de %1]] ',
p_getEntity_Author_without_element_cat = 'Pages « Autor » sin elemento en Wikidata', -- explains next text
p_getEntity_utilisant_modele_cat = 'Páginas que usan la plantilla Autor con un nombre local', -- explains next text
p_getEntity_using_Description_cat = 'Páginas que usan la plantilla Autor con una descripción local', -- explains next text
p_getEntity_using_image_local_cat = 'Páginas que usan la plantilla Autor con una imagen local', -- explains next text
p_getEntity_template_local_date_cat = 'Páginas que usan la plantilla Autor con para migrar', -- explains next text
p_getEntity_template_datas_migrate_cat = 'páginas que usan la plantilla de autor con datos para migrar', -- explains next text
p_getEntity_template_pseudo_local_cat = 'Páginas que usan la plantilla Autor con un pseudo local', -- explains next text
p_getEntity_contain_name_author_need = 'El parámetro "nombre" es obligatorio y debe contener el nombre del autor', -- explains next text
p_Authors_firstname_unknown_cat = 'Autores del primer nombre desconocido', -- explains next text
p_key_param_need_contain_sortkey = 'El parámetro "clave" es obligatorio y debe contener una clave de clasificación para el autor', -- explains next text
p_Pages_template_local_key_cat = 'Páginas que usan la plantilla Autor con una clé locale', -- explains next text
p_initial_name_parametre_contain_need = 'El parámetro "inicial" es obligatorio y debe contener la inicial del nombre del autor en mayúscula', -- explains next text
p_nbsp_authors_args_initiale_cat = " [[:Categoría:Auteurs-' .. args.initiale .. '|Auteurs ' .. args.initiale .. ']]", -- explains next text
p_nbsp_authors_args_initiale_cat = " [[:%1:%2-<b>%3</b>|%2 <b>%3</b>]]",
p_plainlinks_wikisource_IndexPages_link = "<span class='plainlinks'>[//fr.wikisource.org/wiki/Spécial:IndexPages?key=' .. mw.uri.encode(searchKey(args.cle)) .. ' Fac-similés]</span>", -- explains next text
p_plainlinks_wikisource_IndexPages_link = "<span class='plainlinks'>[//%1.wikisource.org/wiki/%2:IndexPages?key=<b>%3</b> %4]</span>",
-- local commonsCat = item:formatPropertyValues('P373').value -- explains next text
p_commonsCat_item_formatPropertyValues = "P373", -- explains next text
} -- p.i18n.es
p.i18n.fr = { -- fr = French = Français
-- Pour traduire, les langues de référence sont l'anglais et le français.
-- Pour traduire, ne traduisez pas des parties comme celles-ci : %1 ; <b>%1</b> ; <b><b>%1</b> = ; <code>Q535</code> ; <br/> ; \n* ; _G.
["docfunc"] = "docfunc",
["docitem"] = "docitem",
["dockey"] = "dockey",
p_page_erroneous_author_template_i_cat = 'Pages faisant un appel erroné au modèle Auteur', -- explains next text
p_createLinkRow_file = '[[File:%1-logo.svg|12px|logo de %1]] ',
p_getEntity_Author_without_element_cat = 'Pages « Auteur » sans élément sur Wikidata', -- explains next text
p_getEntity_utilisant_modele_cat = 'Pages utilisant le modèle Auteur avec un nom local', -- explains next text
p_getEntity_using_Description_cat = 'Pages utilisant le modèle Auteur avec une Description locale', -- explains next text
p_getEntity_using_image_local_cat = 'Pages utilisant le modèle Auteur avec une image locale', -- explains next text
p_getEntity_template_local_date_cat = 'Pages utilisant le modèle Auteur avec une date locale', -- explains next text
p_getEntity_template_datas_migrate_cat = 'Pages utilisant le modèle Auteur avec des données à migrer', -- explains next text
p_getEntity_template_pseudo_local_cat = 'Pages utilisant le modèle Auteur avec un pseudo local', -- explains next text
p_getEntity_contain_name_author_need = "Le paramètre « nom » est obligatoire et doit contenir le nom de l’auteur", -- explains next text
p_Authors_firstname_unknown_cat = 'Catégorie:Auteurs de prénom inconnu', -- explains next text
p_key_param_need_contain_sortkey = "Le paramètre « cle » est obligatoire et doit contenir une clé de tri pour l’auteur", -- explains next text
p_Pages_template_local_key_cat = 'Pages utilisant le modèle Auteur avec une clé locale', -- explains next text
p_initial_name_parametre_contain_need = "Le paramètre « initiale » est obligatoire et doit contenir l’initiale du nom de l’auteur en majuscule non accentuée", -- explains next text
p_nbsp_authors_args_initiale_cat = "Auteurs-' .. args.initiale .. '|Auteurs ' .. args.initiale'", -- explains next text
p_nbsp_authors_args_initiale_cat = " [[:%1:%2-<b>%3</b>|%2 <b>%3</b>]]",
p_plainlinks_wikisource_IndexPages_link = "<span class='plainlinks'>[//fr.wikisource.org/wiki/Spécial:IndexPages?key=' .. mw.uri.encode(searchKey(args.cle)) .. ' Fac-similés]</span>", -- explains next text
p_plainlinks_wikisource_IndexPages_link = "<span class='plainlinks'>[//%1.wikisource.org/wiki/%2:IndexPages?key=<b>%3</b> %4]</span>",
-- local commonsCat = item:formatPropertyValues('P373').value -- explains next text
p_commonsCat_item_formatPropertyValues = "P373", -- explains next text
} -- p.i18n.fr
p.args_known = { -- Table of the definitions of all known arguments at module level. -- ric (p.box1)
-- Arguments in order without names, with their keyword for use as other arguments.
-- Arguments dans l'ordre, non nommés, avec leur keyword pour traitement comme les autres arguments.
["category"] = { ["typ"] = "ctr", ["need"] = 0, ["keyword"] = "category"},
["debug"] = { ["typ"] = "opt", ["need"] = 0, ["keyword"] = "debug"},
["c"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "c"},
["docfunc"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "docfunc"},
["docitem"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "docitem"},
["dockey"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "dockey"},
["itemid"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "itemid"},
["mode"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "mode"},
["options"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "options"},
["knownversions"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "knownversions"},
["soughtversions"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "soughtversions"},
["contentlang"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "contentlang"},
["pagelang"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "pagelang"},
["userlang"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "userlang"},
-- All arguments have a keyword identical to the registration name, except synonyms.
-- Tous les arguments ont un keyword identique au nom d'enregistrement, sauf les synonymes.
["image"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "image", ["prop"] = "P18", },
["country"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "country", ["prop"] = "P27", },
-- ["countryRANK"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "country", ["prop"] = "P27", ["RANK"] = "RANK_NORMAL", },
["birthyear"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "birthyear", ["prop"] = "P569", ["format"] = "year", },
["deathyear"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "deathyear", ["prop"] = "P570", ["format"] = "year", },
["lastname"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "lastname", ["prop"] = "P734", },
["lastname2"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "lastname", ["prop"] = "P734", ["syn"] = 2, },
["firstname"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "firstname", ["prop"] = "P735", },
["firstname2"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "firstname", ["prop"] = "P735", ["syn"] = 2, },
["initial"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "initial", ["prop"] = "P735", },
["title"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "label", ["prop"] = "P735", ["syn"] = 2, },
["personlang"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "personlang", ["prop"] = "P1412", },
["description"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "description",["prop"] = "description", },
["label"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "label" , ["prop"] = "label", ["default"] = "Aristote", },
["labelcontent"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "labelcontent",["prop"] = "labelcontent", },
["labelpage"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "labelpage", ["prop"] = "labelpage", },
["labeluser"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "labeluser", ["prop"] = "labeluser", },
["labelbylang"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "labelbylang",["prop"] = "labelbylang", },
["QITEM"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "QITEM", ["prop"] = "QITEM", },
["sitelink"] = { ["typ"] = "dat", ["need"] = 0, ["keyword"] = "sitelink", ["prop"] = "sitelink", },
["uri"] = { ["typ"] = "dat", ["need"] = 2, ["keyword"] = "uri", ["prop"] = "uri", },
["sex"] = {["keyword"] = "sex", ["typ"] = "dat", ["need"] = 0, ["prop"] = "P21",
["arg_values"] = "sex_values", ["key_values"] = "male;femelle", }, -- wiki_selectors
["region"] = {["keyword"] = "region", ["typ"] = "dat", ["need"] = 0,
["arg_values"] = "region_values", ["key_values"] = "other;china;india;century" }, -- wiki_selectors
["rights"] = {["keyword"] = "rights", ["typ"] = "dat", ["need"] = 2,
["arg_values"] = "rights_values", ["key_values"] = "no;none;ONU;none;cn;50;us;70;mpf", -- wiki_selectors
["delay_values"] = "0;0;0;0;50;50;70;70;95", ["arg_uses"] = "none;none;none;none;cn;cn;us;us;mpf" }, -- wiki_selectors
} -- #p.args_known = 29 on 2018-01-15
function errorMessage(text)
-- Return a html formated version of text stylized as an error.
local html = mw.html.create('div')
html:addClass('error')
:wikitext(text)
html:wikitext( events.add_cat( viewers.form9content("p_page_erroneous_author_template_i_cat") ), "" )
return tostring(html)
end
function createLinkRow(link, site)
-- Return some html stylised formated text of link
local html = mw.html.create('div')
html:tag('span')
:css({['color'] = '#232388', ['font-size'] = '140%', ['line-height'] = '150%'})
:wikitext('[[File:' .. site .. '-logo.svg|12px|logo de ' .. site .. ']] ')
html:wikitext(link)
return html
end
function categorization(baseName, parameter)
-- Return the categorisation wikitext for each element of parameter prefixed with baseName
if parameter == nil then
return ''
end
local wikitext = ''
for _,param in pairs(mw.text.split(parameter, '/', true)) do
wikitext = wikitext .. '[[Catégorie:' .. baseName .. ' ' .. param .. ']]'
end
return wikitext
end
function computeCenturyFromYear(year)
-- Return the corresponding century for the given year
if year >= 0 then
return math.ceil(year / 100)
else
return -math.ceil(-year / 100)
end
end
function getTextForCentury(century, withHtml)
-- Return a roman ordinal of century appended with a trailing text precising
-- if the date is before of after the calendar reference point.
local romanNumbers1 = {'', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X'}
local romanNumbers2 = {'', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'}
local text = romanNumbers2[math.floor(math.abs(century) / 10) + 1] .. romanNumbers1[math.floor(math.abs(century) % 10) + 1]
if withHtml then
text = text .. '<sup>e</sup>'
else
text = text .. 'e'
end
if century > 0 then
return text .. ' siècle'
else
return text .. ' siècle av. J.-C.'
end
end
function getTextForYear(year)
local text = math.abs(year)
if year < 0 then
text = text .. ' av. J.-C.'
end
return text
end
function getDateFromArgs(args, field, fieldUpper)
local struct = {
year = nil,
century = nil,
text = nil,
precision = 0
}
--extract year or century
local date = args['annee' .. fieldUpper]
if date == nil then
date = args[field]
end
if tonumber(date) ~= nil then
struct.year = tonumber(date)
if struct.year == 0 then
struct.text = errorMessage("Le calendrier grégorien ne possède pas d’année 0 !")
return struct
end
struct.century = computeCenturyFromYear(struct.year)
struct.precision = 9
elseif args['siecle' .. fieldUpper] ~= nil then
struct.century = tonumber(args['siecle' .. fieldUpper])
struct.precision = 7
end
--build text
if struct.year ~= nil then
struct.text = getTextForYear(struct.year)
elseif struct.century ~= nil then
struct.text = getTextForCentury(struct.century, true)
else
struct.text = date
end
if args['text' .. fieldUpper] ~= nil then
struct.precision = 0 --we don't know anything
struct.text = args['text' .. fieldUpper] .. ' ' .. struct.text
end
if args['incertitude' .. fieldUpper] ~= nil and struct.text ~= nil then
struct.precision = 0 --we don't know anything
struct.text = args['incertitude' .. fieldUpper] .. ' ' .. struct.text
end
return struct
end
function getDateFromTimeStatements(statements, field)
if #statements == 0 then
return {
precision = 0
}
end
local time = nil
for _, statement in pairs(statements) do
local newTime = getDateFromTimeStatement(statement, field)
if time == nil then
time = newTime
elseif time.year ~= newTime.year then --années contradictoires
mw.addWarning('Plusieurs années de ' .. field .. ' possibles sur Wikidata. Une manière simple de résoudre se problème est de mettre la date à afficher au rang "préféré".')
end
end
if time == nil then
return {
precision = 0
}
end
return time
end
function parseWbTime(value)
local _,_, year = string.find(value.time, '([%+%-]%d%d%d+)%-')
year = tonumber(year)
return {
year = year,
century = computeCenturyFromYear(year),
text = nil,
precision = value.precision
}
end
function getDateFromTimeStatement(statement, field)
local struct = {
year = nil,
century = nil,
text = nil,
precision = 0
}
local snak = statement.mainsnak
if snak.snaktype == 'novalue' then
return struct
end
if snak.snaktype == 'somevalue' then
struct.text = '??'
return struct
end
struct = parseWbTime(snak.datavalue.value)
local prefix = ''
if struct.precision == 8 then
prefix = 'vers '
end
--Extract circa
if statement.qualifiers ~= nil and statement.qualifiers.P1480 ~= nil then
for _,qualifier in pairs(statement.qualifiers.P1480) do
if qualifier.datavalue.value.id == 'Q5727902' then
prefix = 'circa '
struct.precision = 8 --TODO: hacky
end
end
end
--Use before and after if precision <= century
if statement.qualifiers ~= nil and struct.precision <= 7 then
if statement.qualifiers.P1319 ~= nil then
for _,qualifier in pairs(statement.qualifiers.P1319) do
struct = parseWbTime(qualifier.datavalue.value)
prefix = 'après '
struct.precision = 8 --TODO: hacky
end
elseif statement.qualifiers.P1326 ~= nil then
for _,qualifier in pairs(statement.qualifiers.P1326) do
struct = parseWbTime(qualifier.datavalue.value)
prefix = 'avant '
struct.precision = 8 --TODO: hacky
end
elseif statement.qualifiers.P1317 ~= nil then
for _,qualifier in pairs(statement.qualifiers.P1317) do
struct = parseWbTime(qualifier.datavalue.value)
prefix = 'floruit '
struct.precision = 8 --TODO: hacky
end
end
end
--Create text
if struct.precision >= 9 then
struct.text = prefix .. getTextForYear(struct.year)
elseif struct.precision == 8 then
struct.text = prefix .. getTextForYear(struct.year)
elseif struct.precision == 7 then
struct.text = prefix .. getTextForCentury(struct.century, true)
else
struct.text = errorMessage('La date de ' .. field .. ' a une précision trop faible sur Wikidata')
end
return struct
end
function formatDates(naissance, deces)
if naissance.text == nil and deces.text == nil then
return ''
end
local text = '('
if naissance.precision >= 9 then
text = text .. '<time datetime=' .. naissance.year .. ' class="bday" itemprop="birthDate">' .. naissance.text .. '</time> '
elseif naissance.text ~= nil then
text = text .. naissance.text .. ' '
end
text = text .. '–'
if deces.precision >= 9 then
text = text .. ' <time datetime=' .. deces.year .. ' class="dday" itemprop="deathDate">' .. deces.text .. '</time>'
elseif deces.text ~= nil then
text = text .. ' ' .. deces.text
end
return text .. ')'
end
function qidForProperty(item, property)
local statements = mw.wikibase.getBestStatements(item.id ,property)
if statements[1] ~= nil and statements[1].mainsnak.datavalue ~= nil then
return statements[1].mainsnak.datavalue.value.id
end
return nil
end
function searchKey(key)
-- normally the key does not contain any diacritic but it's a common misuse
-- of the clef = so handle at least the most usual diacritics, note than
-- prenom can be empty
local nom, prenom = string.match(key, '^([A-ZÉÈÀÇa-zéèàç-]*)[,]?[ ]*(.*)$')
return prenom .. ' ' .. 'intitle:' .. nom
end
datas.default_item = "Q34743" -- Rudyard Kipling
datas.default_name = "Rudyard Kipling" -- Rudyard Kipling
function p.box1(frame)
--create a clean table of parameters with blank parameters removed
local args = datas.prop
-- modes.frame = mw.getCurrentFrame()
for k,v in pairs(modes.frame:getParent().args) do
if v ~= '' then
args[k] = v
end
end
--Utilise Wikidata si paramètres non renseignés
local naissance = getDateFromArgs(args, 'naissance', 'Naissance')
local deces = getDateFromArgs(args, 'deces', 'Deces')
local sexe = nil
local html = mw.html.create( )
local main = html:tag('span')
:addClass('background') -- 115
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/Person')
:css({['background-color'] = '#F1F1DE', ['overflow'] = 'auto', ['border-radius'] = '0.7em', ['box-shadow'] = '0.2em 0.3em 0.2em #B7B7B7'})
local item = mw.wikibase.getEntity() or {}
if item == nil then
item = mw.wikibase.getEntity(datas.default_item) or {}
end
if item == nil then
item = {}
for k,v in pairs(args) do
if v then
item[k] = v
end
end
end
item.id = item.id or datas.default_item
args.nom = args.nom or datas.default_name
args.description = args.Description or datas.prop.description -- item.Descriptions.fr.value
if item == nil then
html:wikitext('Pages « Auteur » sans élément sur Wikidata]]')
events.add_cat( viewers.form9content("p_getEntity_Author_without_element_cat") )
else
if args.nom == nil then
args.nom = datas.default_name
events.add_err( viewers.form9content("p_getEntity_contain_name_author_need") )
else
end
if args.description ~= nil then
events.add_cat( "p_getEntity_using_Description_cat" )
elseif item.Descriptions ~= nil and item.Descriptions.fr ~= nil then
args.Descriptions = item.Descriptions.fr.value
if item.Descriptions.fr.language ~= 'fr' then
args.DescriptionLanguageCode = item.Descriptions.fr.language
end
end
if args.image == nil then
local statements = mw.wikibase.getBestStatements(item.id ,'P18') -- (item.id, 'P1324' ) ( 'Q16354758', 'P1324' )
if statements[1] ~= nil and statements[1].mainsnak.datavalue ~= nil then
args.image = statements[1].mainsnak.datavalue.value
end
else
events.add_cat( viewers.form9content("p_getEntity_using_image_local_cat") )
end
local naissanceWikidata = getDateFromTimeStatements(mw.wikibase.getBestStatements(item.id ,'P569'), 'naissance')
if naissance.text == nil then
naissance = naissanceWikidata
else
html:wikitext('Pages utilisant le modèle Auteur avec une date locale]]')
html:wikitext( events.add_cat( viewers.form9content("p_page_erroneous_author_template_i_cat") ), "" )
if naissanceWikidata.text == nil then
events.add_cat( viewers.form9content("p_getEntity_template_datas_migrate_cat") )
end
end
local decesWikidata = getDateFromTimeStatements(mw.wikibase.getBestStatements(item.id ,'P570'), 'deces')
if deces.text == nil then
deces = decesWikidata
else
html:wikitext('Pages utilisant le modèle Auteur avec une date locale]]')
if decesWikidata.text == nil then
events.add_cat( viewers.form9content("p_getEntity_template_datas_migrate_cat") )
end
end
if args.pseudo == nil then
args.pseudo = mw.wikibase.getBestStatements(item.id ,'P742' ).value
if args.pseudo == '' then
args.pseudo = nil
end
elseif args.pseudo ~= '-' then
events.add_cat( viewers.form9content("p_getEntity_template_pseudo_local_cat") )
end
--sexe
sexe = qidForProperty(item, 'P21')
end
--
if args.nom == nil then
args.nom = datas.default_name
events.add_err( viewers.form9user("p_getEntity_contain_name_author_need") )
events.add_cat( viewers.form9content("p_page_erroneous_author_template_i_cat") )
end
--sort key and initiale
local firstName = ''
local familyName = ''
if item ~= nil then
--first name
local firstNameStatements = mw.wikibase.getBestStatements(item.id ,'P735')
if firstNameStatements[1] ~= nil then
if firstNameStatements[1].mainsnak.type == 'value' then
local firstNameId = firstNameStatements[1].mainsnak.datavalue.value.id
firstName = mw.wikibase.label(firstNameId) or ''
--TODO check if the first name is not an initial
elseif firstNameStatements[1].mainsnak.type == 'somevalue' then
events.add_cat( viewers.form9content("p_Authors_firstname_unknown_cat") )
end
end
--family name
local familyNameId = qidForProperty(item, 'P734')
if familyNameId ~= nil then
familyName = mw.wikibase.label(familyNameId) or ''
end
end
if familyName == '' then
--We are in a simple case with first name and last name. TODO: bad hack, should be improved
if args.nom == nil then args.nom = datas.default_name end
local nameParts = mw.text.split(args.nom, ' ', true)
if #nameParts == 1 then
familyName = nameParts[1]
elseif #nameParts == 2 then
firstName = nameParts[1]
familyName = nameParts[2]
end
end
if args.cle == nil then
if familyName ~= '' then
local moduleClassement = require 'Module:Classement'
args.cle = moduleClassement.getSortKeyForName({args = {firstName, familyName}})
else
events.add_err( viewers.form9user("p_key_param_need_contain_sortkey") )
end
else
events.add_cat( viewers.form9content("p_Pages_template_local_key_cat") )
end
if args.initiale == nil then
if args.cle ~= nil then
args.initiale = string.sub(args.cle, 1, 1)
else
events.add_cat( viewers.form9content("p_initial_name_parametre_contain_need") )
end
else
events.add_cat( viewers.form9content("p_getEntity_template_datas_migrate_cat") )
end
local main = html:tag('div')
:addClass('vcard')
:attr('itemscope', '')
:attr('itemtype', 'http://schema.org/Person')
:css({['background-color'] = '#F1F1DE', ['overflow'] = 'auto', ['border-radius'] = '0.7em', ['box-shadow'] = '0.2em 0.3em 0.2em #B7B7B7'})
if item ~= nil and item.id ~= nil then
main:attr('itemid', 'http://www.wikidata.org/entity/' .. item.id)
end
--Image
local image = args.image
if image == nil then
local defaultImages = {'Silver - replace this image male.svg', 'Silver - replace this image female.svg'}
if sexe == 'Q6581097' then
image = defaultImages[1]
elseif sexe == 'Q6581072' then
image = defaultImages[2]
else
image = defaultImages[math.random(#defaultImages)]
end
end
-- main:tag('div') -- box1
main:tag('span')
:css({['float'] = 'right', ['margin'] = '1em'})
:wikitext('[[Fichier:' .. image .. '|140px|alt=' .. args.nom .. '|class=photo|itemprop=image]]')
--First row
local ns = mw.site.namespaces[14].canonicalName -- Category = 14
local Authors_initiale_cat = viewers.form9user( "[[:%1:%2|%3]]", ns, "Auteurs" .. "-" .. args.initiale, "Auteurs" .. " " .. args.initiale, ":")
local firstRow = main:tag('div')
--Categorie Auteur-X
firstRow:tag('div')
:css({['float'] = 'left', ['font-size'] = '115%', ['text-indent'] = '1em'})
:tag('span')
:css('color', '#aaaa66')
:wikitext('◄')
:done()
-- :wikitext(' [[:Catégorie:Auteurs-' .. args.initiale .. '|Auteurs ' .. args.initiale .. ']]')
:wikitext(' ' .. Authors_initiale_cat )
--Title
firstRow:tag('h1')
:addClass('fn')
:attr('itemprop', 'name')
:css({['text-align'] = 'center', ['font-size'] = '160%', ['font-weight'] = 'bold', ['border-bottom'] = 'none'})
:wikitext(args.nom)
--Second row
local secondRow = main:tag('div') --- w3schools
--Interwikis
local interwikis = secondRow:tag('div')
:css({['float'] = 'left', ['height'] = '50%', ['font-size'] = '75%', ['text-indent'] = '2em'})
:node(createLinkRow('<span class="plainlinks">[//fr.wikisource.org/wiki/Spécial:IndexPages?key=' .. mw.uri.encode(searchKey(args.cle)) .. ' Fac-similés]</span>', 'Wikisource'))
if item ~= nil and mw.wikibase.getSitelink('frwiki') ~= nil then
interwikis:node(createLinkRow('[[w:' .. mw.wikibase.getSitelink('frwiki') .. '|Biographie]]', 'Wikipedia'))
else
interwikis:node(createLinkRow('[[w:' .. args.nom .. '|<span style="color:#BA0000;">Biographie</span>]]', 'Wikipedia'))
end
if item ~= nil and mw.wikibase.getSitelink('frwikiquote') ~= nil then
interwikis:node(createLinkRow('[[q:' .. mw.wikibase.getSitelink('frwikiquote') .. '|Citations]]', 'Wikiquote'))
else
interwikis:node(createLinkRow('[[q:' .. args.nom .. '|<span style="color:#BA0000;">Citations</span>]]', 'Wikiquote'))
end
if item ~= nil then
local commonsCat = mw.wikibase.getSitelink('commonswiki') or 'commons'
if not commonsCat then
interwikis:node(createLinkRow('[[commons:Category:' .. commonsCat .. '|Médias]]', 'Commons'))
elseif mw.wikibase.getSitelink('commonswiki') ~= nil then
interwikis:node(createLinkRow('[[commons:' .. mw.wikibase.getSitelink('commonswiki') .. '|Médias]]', 'Commons'))
else
interwikis:node(createLinkRow('[[commons:' .. args.nom .. '|<span style="color:#BA0000;">Médias</span>]]', 'Commons'))
end
else
interwikis:node(createLinkRow('[[commons:' .. args.nom .. '|<span style="color:#BA0000;">Médias</span>]]', 'Commons'))
end
if item ~= nil and item.id ~= nil then
interwikis:node(createLinkRow('[[d:' .. item.id .. '|Données structurées]]', 'Wikidata'))
else
interwikis:node(createLinkRow('<span class="plainlinks">[//www.wikidata.org/w/index.php?title=Special:NewItem&site=frwikisource&page=' .. mw.uri.encode(mw.title.getCurrentTitle().fullText) .. '&label=' .. mw.uri.encode(args.nom) .. ' Données structurées</span>]</span>', 'Wikidata'))
end
-- Description
local fullDescription = secondRow:tag('div')
:css({['text-align'] = 'center', ['font-size'] = '110%', ['line-height'] = '110%', ['padding'] = '1em'})
local Description = fullDescription:tag('span')
:addClass('label')
:attr('itemprop', 'Description')
:wikitext(args.description or '')
if args.DescriptionLanguageCode ~= nil then
Description:attr('lang', item.description)
:css('font-style', 'italic')
html:wikitext('Pages utilisant le modèle Auteur sans Description française]]')
elseif args.description == nil then
html:wikitext('Pages utilisant le modèle Auteur sans Description française]]')
end
-- fullDescription
fullDescription:newline()
fullDescription:wikitext(formatDates(naissance, deces))
if args.pseudo ~= nil and args.pseudo ~= '-' then
fullDescription:tag('br')
fullDescription:wikitext('Pseudonyme : \'\'')
:tag('span')
:attr('itemprop', 'alternateName')
:css('font-style', 'italic')
:wikitext(args.pseudo)
end
--categories
html:wikitext('[[Catégorie:Auteurs]]' .. '[[Catégorie:Auteurs-' .. args.initiale .. ']]')
--genre
if args.genre ~= nil then
html:wikitext('Pages utilisant le modèle Auteur avec un genre local]]')
html:wikitext(categorization('', args.genre))
end
html:wikitext(categorization('', args.genre))
--langue
if item ~= nil then
for _, statement in pairs(mw.wikibase.getBestStatements(item.id ,'P1412')) do
if statement.mainsnak.datavalue ~= nil then
categoryName = 'Catégorie:Auteurs écrivant en ' .. mw.wikibase.label(statement.mainsnak.datavalue.value.id)
html:wikitext('[[' .. categoryName .. ']]')
if not mw.title.new( categoryName ).exists then
html:wikitext('Pages utilisant le modèle Auteur avec une catégorie de langue non créée]]')
end
end
end
end
if args.langue ~= nil then
html:wikitext('Pages utilisant le modèle Auteur avec une langue locale]]')
end
--nationalités
categoryForCountry = mw.loadData('Module:Auteur2/nationalités')
if item ~= nil then
for _, statement in pairs(mw.wikibase.getBestStatements(item.id ,'P27')) do
if statement.mainsnak.datavalue ~= nil then
countryId = statement.mainsnak.datavalue.value.id
if categoryForCountry[countryId] == nil then
html:wikitext('Pages utilisant le modèle Auteur avec une nationalité sans catégorie]]')
elseif categoryForCountry[countryId] then
html:wikitext('[[Category:' .. categoryForCountry[countryId] .. ']]')
end
end
end
end
if args.pays ~= nil then
html:wikitext('Pages utilisant le modèle Auteur avec une nationalité locale]]')
end
--occupation
categoryForOccupation = mw.loadData('Module:Auteur2/occupations')
if item ~= nil then
for _, statement in pairs(mw.wikibase.getBestStatements(item.id ,'P106')) do
if statement.mainsnak.datavalue ~= nil then
occupationId = statement.mainsnak.datavalue.value.id
if categoryForOccupation[occupationId] == nil then
events.add_cat( 'Pages utilisant le modèle Auteur avec une occupation sans catégorie' )
elseif categoryForOccupation[occupationId] then
events.add_cat( categoryForOccupation[occupationId] )
end
end
end
end
if args.metier ~= nil or args["métier"] ~= nil then
html:wikitext(categorization('', args.metier or args["métier"]))
html:wikitext('Pages utilisant le modèle Auteur avec une occupation locale]]')
end
--Prix
if args.prix ~= nil then
html:wikitext(categorization('Lauréats du', args.prix))
html:wikitext('Pages utilisant le modèle Auteur avec un prix local]]')
end
if item ~= nil then
for _, awardStatement in pairs(mw.wikibase.getBestStatements(item.id ,'P166')) do
if awardStatement.mainsnak.datavalue ~= nil then
distinctionItem = mw.wikibase.getEntity(awardStatement.mainsnak.datavalue.value.id)
for _, awardeeCatStatement in pairs(mw.wikibase.getBestStatements(item.id ,'P2517')) do
if awardeeCatStatement.mainsnak.datavalue ~= nil then
wikisourceCategory = mw.wikibase.sitelink(awardeeCatStatement.mainsnak.datavalue.value.id)
if wikisourceCategory then
html:wikitext('[[' .. wikisourceCategory .. ']]')
end
end
end
end
end
end
--categorie dates
if naissance.precision >= 9 and naissance.year > 1500 then
events.add_cat( "Naissance en " .. naissance.year )
end
if deces.precision >= 9 and deces.year > 1500 then
events.add_cat( "Décès en " .. deces.year )
end
local withoutEpoque = true
if naissance.century ~= nil and (naissance.precision < 9 or naissance.year <= naissance.century * 100 - 20) then
if 15 <= naissance.century then
events.add_cat( "Auteurs du " .. getTextForCentury(naissance.century, false) )
elseif 6 <= naissance.century and naissance.century <= 14 then
events.add_cat( "Auteurs du Moyen Âge" )
else
events.add_cat( "Auteurs de l’Antiquité" )
end
withoutEpoque = false
end
if deces.century ~= nil and (deces.precision < 9 or (deces.century - 1) * 100 + 5 <= deces.year) then
if 15 <= deces.century then
events.add_cat( "Auteurs du " .. getTextForCentury(deces.century, false) )
elseif 6 <= deces.century and deces.century <= 14 then
events.add_cat( "Auteurs du Moyen Âge" )
else
events.add_cat( "Auteurs de l’Antiquité" )
end
withoutEpoque = false
end
if withoutEpoque then
html:wikitext('[[Catégorie:Epoque inconnue]]')
end
if sexe == 'Q6581072' then
html:wikitext('[[Catégorie:Autrices]]')
end
-- droits
if args.droits == nil then
args.droits = '70'
end
droitsNumber = tonumber(args.droits)
if args.droits == 'mpf' then
if deces.precision >= 9 and tonumber(os.date("%Y")) <= deces.year + 95 then --TODO: guess 'mpf' from P166:Q3324507 in Wikidata?
html:wikitext(modes.frame:expandTemplate({title = 'Auteur Mort pour la France'}))
end
html:wikitext('[[Catégorie:Auteurs morts pour la France]]')
elseif args.droits == 'non' then
---- rien à faire
elseif droitsNumber ~= nil then
if deces.year ~= nil and tonumber(os.date("%Y")) <= deces.year + droitsNumber then --XX ans on vérifie le DP-EU
if naissance.year == nil or 1923 - naissance.year > 20 then
html:wikitext(modes.frame:expandTemplate({title = 'DP-EU-Auteur'}))
end
end
if args.droits ~= '70' then
html:wikitext('[[Catégorie:Droits d’auteur ' .. args.droits .. ' ans]]')
end
else
return errorMessage('Le paramètre droit contient une valeur non supportée. Valeurs possibles : 70/60/50 (durée du droit d\'auteur), "mpf" (mort pour la france). Par défaut: 70')
end
---- maintenance
if args.image == nil then
html:wikitext('Pages « Auteur » sans image]]')
end
if args.cle ~= nil then
html:wikitext(modes.frame:preprocess('{{DEFAULTSORT:' .. args.cle .. '}}') )
end
p.added_modes_views = "" -- Depends of modes.mode_name
local categ_list = events.categories_lister(":") -- Categorize categories, or view categories if c=":".
p.add_text_before = "\n* Add text before Auteur2Tpt"
p.html_in_div = '<div class="html_in_div">' .. tostring(html) .. '</div>'
return p.html_in_div .. '\n__NOTOC__'
end -- function p.box1(frame)
-- Main frame functions
function p.auteur(frame)
return p.box1(frame)
end
function p.interact_args_final(args_import, args_known)
local t = ""
local args_known = args_known or modes.args_known or p.args_known or {} -- optional value from p.args_known = { -- }
if type(args_import) ~= "table" then args_import = modes.args_import or {} end
local args_final = mw.clone(args_import) -- do not disturb original args_import
local a = args_import
local i = {} -- interact
local tit = nil
if not a.title then -- If title is undefined, enforce it.
if a.lastname and a.firstname then
tit = a.firstname .. " " .. a.lastname
end
i.title = a.label or modes.main_title or a.QITEM or a.itemid or a.title or tit
end
----
if a.docfunc then a.docfunc = mw.text.trim(a.docfunc) end -- dockey docitem args_known = { i18n.vi
if a.docitem then a.docitem = mw.text.trim(a.docitem) end -- dockey docitem args_known = { i18n.vi
if a.dockey then a.dockey = mw.text.trim(a.dockey) end -- dockey docitem args_known = { i18n.vi
if not a.QITEM then -- The Title can come from several arguments to insure it.
i.QITEM = a.label or modes.main_title or a.QITEM or a.itemid or a.title
i.QITEM = mw.text.trim(i.QITEM or "Q34743") -- Rudyard Kipling
else
a.QITEM = a.QITEM or datas.default_item
a.QITEM = mw.text.trim(a.QITEM)
end
---- if absent, synonym of basic arguments, syn = 2
if not a.firstname then i.firstname = (i.firstname2 or a.firstname2) end
if not a.lastname then i.lastname = (i.lastname2 or a.lastname2) end
if not a.firstname2 then i.firstname2 = (i.firstname or a.firstname) end
if not a.lastname2 then i.lastname2 = (i.lastname or a.lastname) end
----
if not a.initial then -- If initial is undefined, enforce it.
if a.lastname then
i.initial = string.sub( a.lastname, 1, 1 ) -- selector the first letter
i.initial = string.upper( i.initial or "*" )
end
end
local label = a.label or a.labeluser or a.labelpage or a.labelcontent or a.labelbylang
if label then i.label = label
else
events.add_err( viewers.form9user("versions_with_internal_error") , "" )
events.add_cat( viewers.form9content("versions_with_internal_error_cat") , "" )
end
----
if a.birth and not a.birthyear then
local tt, err = viewers.date_to_part(a.birth, viewers.form9user("modes_date_to_part_format"), "yyyy")
if tt then i.birthyear = tt else
events.add_err(err, viewers.form9user("birthyear"), "yyyy")
events.add_cat("modes_date_to_part_call_cat")
end
end
---- memorize interactions in modes.args_final and show errors or warnings
langs.init_content_page_user_lang()
local n = 0
for key, val in pairs(i) do
local argskwn = args_known[key]
if type(argskwn) == "table" then
args_final[key] = val -- = i[key]
args_final.src = "inter"
n = n + 1
if (args_final.need == 2) and not a[key] then --
---- need = 2 necessary from argument or module interaction
events.add_wng("modes_auto_val_warning_wng", langs.user_translations[key], val)
end
else
events.add_err("modes_unknown_auto_arg_err", langs.content_translations[key], val)
end
end
modes.args_final = args_final
return args_final, t
end -- args_final = p.interact_args_final(args_import)
p.formDocBox = Centralizer.formDocBox
-- Display the documentation in an infobox, similar to edit-boxs
-- Affichage de documentation dans un cadre (box), semblable aux boites d'edition
function p.formDocBox(args_final)
-- See p.options_for_modes = {} -- module options_for_modes
local res, props = "", datas.props
if type(args_final) ~= "table" then args_final = modes.args_final end -- optional arguments
langs.init_content_page_user_lang(modes.args_source.contentlang, modes.args_source.pagelang, modes.args_source.userlang)
local head_line = viewers.discreet_main_version() .. viewers.ta("content", langs.content_lang) .. viewers.ta("page", langs.page_lang) .. viewers.ta("user", langs.user_lang)
head_line = head_line .. " - [https://fr.wikisource.org/wiki/MediaWiki:Scribunto/Central_modules_reference_manual User manual]"
head_line = head_line .. " - [[phab:T135845|T135845 Convert]]"
head_line = head_line .. " - [[phab:T198107|T198107 Begin to use]]" .. "<br/>"
head_line = head_line .. viewers.styles_color_error("<b>" .. viewers.form9user("modes_delete_docbox_wng") .. "</b>" )
res = res .. "<center>" .. head_line .. "<br/></center>"
res = res .. drop_box.form(drop_box.new_title(), versions.form_support_desk_report() )
if modes.option("debug") then res = res .. "\n*" .. viewers.ta("modes.cat_view", modes.cat_view) .. viewers.ta("modes.template_options", modes.template_options) .. viewers.ta("modes.mode_options", modes.mode_options) end
local lnk = props.QITEM
if modes.option("docdata") then res = res .. "\n*" .. modes.generDoc(" docdef docline ", datas.args_wikidata, datas_link) end
res = res .. ", " .. viewers.form9user(" (%1 properties)", (datas.propss_count_all or "") ) -- datas_structured_data_txt
if modes.option("docview") then res = res .. "\n*" .. modes.generDoc("", args_final, "Arguments") end
if not modes.option("noerr")then res = res .. "\n*" .. events.errors_lister() end
local t = "" -- Formats events views
for key, evt in pairs(events.list_all_events) do
if evt.typ == "wng" then
evt.res, evt = events.form(evt)
if evt.res then t = t .. "<br>* " .. tostring(evt.res) end
end
end
---- display errors
for key, evt in pairs(events.list_all_events) do
if evt.typ == "err" then
evt.res, evt = events.form(evt)
if evt.res then t = t .. "<br>* " .. tostring(evt.res) end
end
end
---- display events, mainly categories
for key, evt in pairs(events.list_all_events) do
if evt.typ == "cat" then
evt.res, evt = events.form(evt)
if evt.res then t = t .. "<br>* " .. tostring(evt.res) end
end
end
t = t .. langs.main_i18n_languages_list() -- List available translations languages
res = res .. t
local result = "" -- "\n------ " -- This code interact with drop_box and debug the bug T20151215 2016-11-13 17:57.
result = result .. '<div class="CentralDocBox" style=" width=90%; border: 1px solid #AAAAAA; margin:1em; background-color:#F1F1F1; padding:0.3em; ">' .. res .. '</div>'
result = result .. "\n* " .. events.categories_lister(":")
return result
end -- function p.formDocBox(args_final)
p.options_for_modes = { -- module options_for_modes
read = " box1 catview ",
edit = " box1 docdef docline docsrc docdata catview docview : ",
doc = " nobox1 noerr nocatview ",
tests = " box1 catview docdef docline docsrc docdata docview : tests docGroup ",
}
function p.form_result(args_final, main_module) -- Formats all results of this module and its sub-modules.
local res = ""
local memo = viewers.init_configs("p.form_result") -- Initialize global configurations and save them before eventual changes.
main_module = main_module or versions.main_module
if type(args_final) ~= "table" then args_final = modes.args_final end -- optional arguments
res = res .. viewers.ta("modes.mode_name", modes.mode_name) .. viewers.ta("modes.options", modes.options)
if modes.option("box1") then res = res .. p.box1(props) end -- ric (p.box1)
if modes.option("box1") or modes.option("catview")
then res = res .. " catview = " .. events.categories_lister(":") end -- Display categories
events.gener_categories(args_final) -- Formats all categories without activate them
if modes.option("docview") or modes.option(":") or modes.option("tests") or (modes.args_final.mode == "edit") then
-- res = res .. drop_box.new("allwaysview", "versions_support_desk_title", versions.form_support_desk_report )
res = res .. "\n* datas.default_item = <b>" .. datas.default_item .. "</b>, datas.default_name = <b>" .. datas.default_name .. "</b>\n"
res = res .. p.formDocBox(modes.args_final)
end
modes.time3 = os.clock()
if modes.option("tests") then -- or (modes.args_final.mode == "tests") --
res = res .. viewers.doc_group("allwaysview") -- viewers.doc_group(selector, mask_sections) -- To enforce title of sections
-- res = res .. viewers.doc_page("allwaysview")
-- res = res .. viewers.doc_module("allwaysview")
-- res = res .. viewers.doc_internal("allwaysview")
res = res .. versions.running_times(false, "")
end
viewers.restore_configs(memo, "p.form_result") -- Restore global configurations after eventual changes.
return res
end -- res = res .. viewers.main_view(args_final, main_module) -- Formats all the result of this module
------------------------------------------------------------------------- try to debug on 2018-07-01T15:46:00 UTC
function Auteur2Tpt.init(frame, Central_version, mode_name, args_known, options_for_modes)
-- p.version.versionNumber = CentralI18N.version.versionNumber
local res = ""
modes.time1 = os.clock()
local args_known = args_known or modes.args_known or p.args_known or {} -- optional value from p.args_known = {...}
Central_version = Central_version or langs.Central_version or Centralizer.Central_version
options_for_modes = options_for_modes or modes.options_for_modes or p.options_for_modes
res = res .. Centralizer.init(frame, Central_version, mode_name, args_known, options_for_modes) --try Centralizer.init(...
-- res = res .. versions.init(frame, Central_version) -- for memo : inside Centralizer.init
modes.frame = mw.getCurrentFrame()
res = res .. "\n* datas.default_item = <b>" .. datas.default_item .. "</b>, datas.default_name = <b>" .. datas.default_name .. "</b>"
datas.prop, datas.props = datas.get_item(p.args_known, datas.default_item) -- Get datas from mw.wikibase for the page.
res = res .. modes.init_modes_translate_events(frame, Central_version, mode_name, modes.args_known, options_for_modes, QITEM or itemid)
modes.init_args_mode_options(mix, mode_name, modes.args_template) -- Import and mix args mode and options from template and invoke -- S170710mix
modes.args_import = modes.import_arguments(args_known, args_source, content_translations, args_wikidata) -- function modes.import_arguments()
modes.args_final = p.interact_args_final(modes.args_import) -- Interactions between arguments
modes.get_args(args_known) -- Interactions between arguments
langs.init_content_page_user_lang() -- function langs.init_content_page_user_lang()
return res
end -- function Auteur2Tpt.init(frame, Central_version, mode_name, args_known, options_for_modes, QITEM)
function Auteur2Tpt.read(frame) -- The read mode generates the normal result for read only users.
-- Helpers or admins can add options to include edit or tests or user language...
local res = ""
local t = Auteur2Tpt.init(frame, p.Central_version, "read", p.args_known, p.options_for_modes)
modes.args_final = p.interact_args_final(modes.args_import) -- Interactions between arguments
res = res .. p.form_result(modes.args_final) -- Generate wikitext, categories, and others
return res
end -- function Auteur2Tpt.read(frame)
function Auteur2Tpt.edit(frame) -- The edit mode verifies arguments, displays the edit panel with errors, warnings and categories.
local res = ""
local t = Auteur2Tpt.init(frame, p.Central_version, "edit", p.args_known, p.options_for_modes)
-- res = res .. t
modes.args_final = p.interact_args_final(modes.args_import) -- Interactions between argumensts
res = res .. p.form_result(modes.args_final) -- Generate wikitext, categories, and others
return res
end -- function Auteur2Tpt.edit(frame)
-- ["docfunc"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "docfunc"},
-- ["docitem"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "docitem"},
-- ["dockey"] = { ["typ"] = "config", ["need"] = 0, ["keyword"] = "dockey"},
function Auteur2Tpt.doc(frame) -- Formats a documentation or a test in a drop_box.
local res = ""
-- if 1 then return "\n* Auteur2Tpt.doc(frame)" end
local t = Auteur2Tpt.init(frame, p.Central_version, "doc", p.args_known, p.options_for_modes, "Q535") -- QITEM
langs.init_content_page_user_lang()
modes.change_itemid() -- default = "Q41568"
modes.args_final = p.interact_args_final(modes.args_import) -- Interactions between argumensts
-- {{Centralizer|doc|versions_support_desk_title}}
local docfunc = modes.args_final.docfunc or modes.args_final[3] or modes.args_import.docitem or modes.args_import[3]
local docitem = modes.args_final.docitem or modes.args_final[2] or modes.args_import.docitem or modes.args_import[2] or datas.default_item
local dockey = modes.args_final.dockey or modes.args_final[1] or modes.args_import.dockey or modes.args_import[1]
local QITEM = modes.args_final.QITEM or modes.args_final.docitem or docitem
QITEM = mw.text.trim(QITEM) -- clean spaces in each name
return res
end -- function Auteur2Tpt.doc(frame)
function p.form_tests_init(res, args_source)
-- Special init for the test mode
if type(res) ~= "string" then res = "\n* Mode test : " end
if type(args_source) ~= "table" then args_source = modes.args_source or {} end
if p.i18n and p.i18n.en then p.i18n.en.error_i18n_wanted_to_test_missing_translation = 'English error i18n wanted for tests missing translation' end
if p.i18n and p.i18n.es then p.i18n.es.error_i18n_deseada_para_probar_traduccion_faltan = 'Espagnol error i18n deseada para probar traducción faltan' end
if p.i18n and p.i18n.fr then p.i18n.fr.error_i18n_voulue_pour_test_de_traduction_manquante = 'Français erreur i18n voulue pour tests de traduction manquante' end
-- if not args_source.userlang then args_source.userlang = "en" end
-- if not args_source.contentlang then args_source.contentlang = "es" end
if not args_source.modeinvoke then args_source.modeinvoke = "catview" end
if not args_source.mode_invoke then args_source.mode_invoke = "catview" end
if not args_source.template_options then args_source.template_options = "catview" end
if not args_source.name then args_source.name = "Jack Smith" end
if not args_source.nom then args_source.nom = "Victor Hugo" end
if not args_source.region then args_source.region = "india" end
if not args_source["région"] then args_source["région"] = "chine" end
if not args_source.description then args_source.description = "Victor Hugo est très connu." end --
if not args_source.langue then args_source.langue = "français,japonais" end
if not args_source.occupation then args_source.occupation = "Académiciens,Personnalités politiques" end
modes.args_source = args_source
return res
end -- function p.form_tests_init(res, args_source)
function Auteur2Tpt.tests(frame)
local res = ""
local t = Auteur2Tpt.init(frame, p.Central_version, "tests", p.args_known, p.options_for_modes)
p.form_tests_init()
modes.args_final = p.interact_args_final(modes.args_import) -- Interactions between arguments
versions.main_versions = versions.main_versions or { versionName = "versionName", versionNumber = "0.0", }
if not versions.main_versions then versions.main_versions = p.version or versions.version end
modes.mode_name = "tests"
res = res .. p.form_result(modes.args_final) -- Generate wikitext, categories, and others
return res
end -- function Auteur2Tpt.tests(frame)
------------------------------------------------------------------------- try to debug on 2018-07-01T15:46:00 UTC
function viewers.doc_group(selector, mask_sections) -- Formats all or any documentations of tests and reports. -- snaks tst
local res = ""
Auteur2Tpt.tst = false -- To form documentations of only some tests and reports
Auteur2Tpt.tst = true -- To form all tests and reports. -- snaks tst
if Auteur2Tpt.tst then -- Select which tests to form.
res = res .. viewers.doc_page(selector, mask_sections)
res = res .. viewers.doc_module(selector, mask_sections)
res = res .. viewers.doc_internal(selector, mask_sections)
else
if mask_sections then
res = res .. viewers.doc_section(selector, "Tests of this page", "h2", mask_sections)
res = res .. drop_box.new(selector, "modes_args_known_report_title", modes.args_known_report)
res = res .. drop_box.new(selector, "activity_report_subtasks_title", activity.central_subtasks_report)
res = res .. drop_box.new(selector, "datas.get_item() Report datas from mw.wikibase **", datas.get_item_report)
else
res = res .. viewers.doc_page(selector, mask_sections)
res = res .. viewers.doc_module(selector, mask_sections)
res = res .. viewers.doc_internal(selector, mask_sections)
end
end
return res
end -- function viewers.doc_group(selector, mask_sections) item:
--{{Auteur2Tpt|doc|versions_support_desk_title}}
return p
-- To easy try a change in a module for the adequate page on 2018-06-29:
-- datas.i18n.it
-- Module:Auteur2 -- ws.Module:Tpt (Q535)
-- Module:Tests/Aristote -- ws.Module:Tests (Q868)
-- Utilisateur:Rical/Rudyard Kipling -- ws.Module:Centralizer (Q34743)
-- Utilisateur:Rical/Nelson Mandela -- ws.Module:Tests (Q8023)
-- Utilisateur:Rical/Nelson Mandela -- ws.Module:Centralizer-s-fr (Q8023)
-- Module:Centralizer-s-fr/Galilée -- ws.Module:Centralizer (Q307)
--
--
-- Tests pages on 2018-07-24 :
-- Patrom:TestsAuteur2Tpt -- s.br.Patrom:TestsAuteur2Tpt for tests in Breton
-- Patrom:Auteur2Tpt -- s.br.Patrom:Auteur2Tpt as templete in Breton
-- Modulenn:Auteur2Tpt-s-br -- s.br.Modulenn:Auteur2Tpt as module itself in Breton
--
-- Mô đun:Centralizer-w-vi -- w.vi.wikipedia.Mô đun:Centralizer-w-vi in Vietnamise
-- MediaWiki:Centralizer/Tests -- w.vi.wikipedia.Mô đun:Centralizer/Tests in Vietnamise
-- Módulo:Centralizer-w-es -- s.es.wikipedia.Módulo:Central-w-es in Spanish
-- Plantilla:Centralizer/Tests -- s.es.wikipedia.Módulo:Centralizer/Tests in Spanish
-- Modulenn:Centralizer-s-br -- s.br.wikisource.Modulenn:Centralizer-s-br in Breton
-- Patrom:TestsCentralizer -- s.br.wikisource.Patrom:CentralizerTests in Breton
-- Module:Centralizer-s-fr -- s.fr.wikisource.Module:Centralizer/Tests in French
-- Module:Centralizer/Tests -- s.fr.wikisource.Module:Centralizer/Tests in French