local p = {}
-- shallow copy di un oggetto table
local function table_shallow_copy(obj)
local copy = {}
if type(obj) == 'table' then
for key, val in pairs(obj) do
copy[key] = val
end
end
return copy
end
-- parametri posizionali: {{New Grove|edizione|nome|cognome|voce|volume|pagine|cid|wl}}
function p.citation(frame)
local pargspframe = frame:getParent().args
-- wl determina se inserire o meno un wikilink nel titolo dell'opera
local wl = pargspframe.args[8] or pargspframe.args['wl'] or Nil
wl = wl and wl ~= ''
-- sceglie edizione (per avere i campi precompilati)
local edition = pargspframe.args[1] or pargspframe.args['edizione'] or Nil
-- shallow copy dei parametri
local inner_args = table_shallow_copy(pframe.args)
-- conversione parametri posizionali:
-- il Modulo:Citazione e il Template:New Grove hanno un ordine diverso
-- per i parametri posizionali
pargsinner_args['nome'] = pargspframe.args[2] or pargspframe.args['nome']
pargsinner_args['cognome'] = pargspframe.args[3] or pargspframe.args['cognome']
pargsinner_args['voce'] = pargspframe.args[4] or pargspframe.args['voce']
pargsinner_args['volume'] = pargspframe.args[5] or pargspframe.args['volume']
pargsinner_args['pagine'] = pargspframe.args[6] or pargspframe.args['pagine']
pargsinner_args['cid'] = pargspframe.args[7] or pargspframe.args['cid']
-- New Grove ed. 1
if edition == "1" then
if wl then
pargsinner_args['titolo'] = "The New Grove Dictionary of Music and Musicians"
else
pargsinner_args['titolo'] = "[[Grove Dictionary of Music and Musicians|The New Grove Dictionary of Music and Musicians]]"
end
pargsinner_args['curatore'] = "Stanley Sadie"
pargsinner_args['edizione'] = "1ª ed."
pargsinner_args['editore'] = "MacMillian"
pargsinner_args['città'] = "Londra"
pargsinner_args['anno'] = "1980"
pargsinner_args['ISBN'] = "978-0333231111"
-- New Grove ed. 2
elseif edition == "2" then
if wl then
pargsinner_args['titolo'] = "The New Grove Dictionary of Music and Musicians"
else
pargsinner_args['titolo'] = "[[Grove Dictionary of Music and Musicians|The New Grove Dictionary of Music and Musicians]]"
end
pargsinner_args['curatore'] = "Stanley Sadie"
pargsinner_args['curatore2'] = "John Tyrrell"
pargsinner_args['edizione'] = "2ª ed."
pargsinner_args['editore'] = "Oxford University Press"
pargsinner_args['anno'] = "2001"
pargsinner_args['ISBN'] = "978-0195170672"
-- Grove Dictionary of Musical Instruments
elseif edition == "inst" then
pargsinner_args['titolo'] = "The New Grove Dictionary of Musical Instruments"
pargsinner_args['curatore'] = "Stanley Sadie"
pargsinner_args['editore'] = "MacMillian"
pargsinner_args['città'] = "Londra"
pargsinner_args['anno'] = "1984"
pargsinner_args['ISBN'] = "0943818052"
-- Grove Dictionary of Opera
elseif edition == "opera" then
if wl then
pargsinner_args['titolo'] = "[[New Grove Dictionary of Opera|The New Grove Dictionary of Opera]]"
else
pargsinner_args['titolo'] = "The New Grove Dictionary of Opera"
end
pargsinner_args['curatore'] = "Stanley Sadie"
pargsinner_args['edizione'] = "1ª ed."
pargsinner_args['editore'] = "MacMillian"
pargsinner_args['città'] = "Londra"
pargsinner_args['anno'] = "1992"
pargsinner_args['ISBN'] = "0333485521"
-- Grove Dictionary of American Music
elseif edition == "american" then
pargsinner_args['titolo'] = "The New Grove Dictionary of American Music"
pargsinner_args['curatore'] = "Stanley Sadie"
pargsinner_args['curatore'] = "Hugh Wiley Hitchcock"
pargsinner_args['editore'] = "MacMillian"
pargsinner_args['città'] = "Londra"
pargsinner_args['anno'] = "1986"
pargsinner_args['ISBN'] = "0333378792"
-- Grove Dictionary of Art ed. 1
elseif edition == "art1" then
pargsinner_args['titolo'] = "The Grove Dictionary of Art"
pargsinner_args['curatore'] = "Jane Turner"
pargsinner_args['edizione'] = "1ª ed."
pargsinner_args['editore'] = "Oxford University Press"
pargsinner_args['anno'] = "1996"
pargsinner_args['ISBN'] = "1884446000"
-- Grove Dictionary of Art ed. 2
elseif edition == "art2" then
pargsinner_args['titolo'] = "The Grove Dictionary of Art"
pargsinner_args['curatore'] = "Jane Turner"
pargsinner_args['edizione'] = "2ª ed."
pargsinner_args['editore'] = "Oxford University Press"
pargsinner_args['anno'] = "2003"
pargsinner_args['ISBN'] = "0195170687"
-- Grove Dictionary of Jazz ed. 1
elseif edition == "jazz1" then
pargsinner_args['titolo'] = "The New Grove Dictionary of Jazz"
pargsinner_args['curatore'] = "Barry Kernfeld"
pargsinner_args['edizione'] = "1ª ed."
pargsinner_args['editore'] = "MacMillian"
pargsinner_args['anno'] = "1988"
pargsinner_args['ISBN'] = "0312113579"
-- Grove Dictionary of Jazz ed. 2
elseif edition == "jazz2" then
pargsinner_args['titolo'] = "The New Grove Dictionary of Jazz"
pargsinner_args['curatore'] = "Barry Kernfeld"
pargsinner_args['edizione'] = "2ª ed."
pargsinner_args['editore'] = "Oxford University Press"
pargsinner_args['anno'] = "2003"
pargsinner_args['ISBN'] = "1561592846"
-- parametro edizione assente o invalido
local cite_object = {
cite_module = require("Modulo:Citazione"),
args = pargsinner_args,
frame = {
args = {}
|