Modul:Citation: Unterschied zwischen den Versionen

Aus skandinavien-wiki.net
Keine Bearbeitungszusammenfassung
(i18n ausgelagert)
Zeile 8: Zeile 8:
local cu = require( 'Module:Citation/utilities' )
local cu = require( 'Module:Citation/utilities' )
local cc = require( 'Module:Citation/COinS' )
local cc = require( 'Module:Citation/COinS' )
local ci = require( 'Module:Citation/i18n' )
local cx = require( 'Module:Check isxn' )
local cx = require( 'Module:Check isxn' )
local li = require( 'Module:LinkISBN' )
local li = require( 'Module:LinkISBN' )
Zeile 16: Zeile 17:
local ct = {}
local ct = {}


-- global variables
-- global variable
-- list of possible type values
local refTypes = {
book      = { 'book', 'Buch' },
map        = { 'map', 'Karte' },
collection = { 'collection', 'Sammelwerk' },
journal    = { 'journal', 'Zeitschrift' },
newspaper  = { 'newspaper', 'Zeitung' },
web        = { 'web', 'Web', 'Internet' }
}
 
-- list of possible status values
local urlStates = {
dead    = { 'dead', 'offline' },
live    = { 'live', 'online' },
usurped = { 'unfit', 'usurped', 'usurpiert' }
}
 
-- list of possible parameter
-- no index: possible parameter names
-- types: reference types for which parameter is valid
-- COinS: COinS key
-- COinS_id: COinS id
-- cleanup = true: complete cleanup
local params = {
type        = { 'type', 'Typ', cleanup = true },
author      = { 'Autor', COinS = 'rft.au', cleanup = true },
editor      = { 'Herausgeber', 'Hrsg', cleanup = true },
title      = { 'Titel', COinS = 'rft.title', cleanup = true },
chapter    = { 'Kapitel', types = 'book', COinS = 'rft.atitle', cleanup = true },
collection  = { 'Sammelwerk', types = 'collection', cleanup = true },
journal    = { 'Zeitschrift', 'Sammelwerk', types = 'journal', COinS = 'rft.jtitle', cleanup = true },
newspaper  = { 'Zeitung', 'Sammelwerk', types = 'newspaper', COinS = 'rft.jtitle', cleanup = true },
website    = { 'Website', 'Internet', 'Sammelwerk', types = 'web', cleanup = true },
abbr        = { 'Abk', types = { 'collection', 'journal', 'newspaper' }, cleanup = true },
url        = { 'Online', 'URL', types = { 'book', 'map', 'collection', 'journal', 'newspaper', 'web' }, cleanup = true },
articleUrl  = { 'Onlineaufsatz', 'Aufsatz-URL', types = { 'journal' }, cleanup = true },
siteUrl    = { 'Site-URL', 'Website-URL', types = { 'collection', 'newspaper', 'web' }, cleanup = true },
jstor      = { 'JSTOR', types = { 'journal', 'newspaper' }, cleanup = true },
KBytes      = { 'KBytes', 'kBytes', 'kbytes', cleanup = true },
MBytes      = { 'MBytes', 'Mbytes', cleanup = true },
accessDate  = { 'Zugriff', 'Abruf', cleanup = true },
scale      = { 'Maßstab', types = 'map', cleanup = true },
place      = { 'Ort', COinS = 'rft.place', cleanup = true },
publisher  = { 'Verlag', 'Verleger', types = { 'book', 'map', 'collection', 'web' }, COinS = 'rft.pub', cleanup = true },
date        = { 'Datum', 'Jahr', COinS = 'rft.date', cleanup = true },
edition    = { 'Auflage', types = { 'book', 'map', 'collection' }, COinS = 'rft.edition', cleanup = true },
volume      = { 'Band', types = { 'book', 'map', 'collection', 'journal', 'newspaper' }, COinS = 'rft.volume', cleanup = true },
issue      = { 'Ausgabe', 'Nummer', 'Heft', types = { 'journal', 'newspaper' }, COinS = 'rft.issue', cleanup = true },
pages      = { 'Seite', 'Seiten', types = { 'book', 'collection', 'journal', 'newspaper', 'web' }, COinS = 'rft.pages', cleanup = true },
columns    = { 'Spalten', types = { 'book', 'collection', 'journal', 'newspaper', 'web' }, cleanup = true },
extent      = { 'Umfang', 'Seitenanzahl', types = { 'book', 'collection', 'map' } },
series      = { 'Serie', 'Reihe', types = { 'book', 'collection', 'map' }, COinS = 'rft.series', cleanup = true },
series2    = { 'Serie2', 'Reihe2', types = { 'book', 'collection', 'map' }, cleanup = true },
series3    = { 'Serie3', 'Reihe3', types = { 'book', 'collection', 'map' }, cleanup = true },
isbn        = { 'ISBN', types = { 'book', 'collection', 'map', 'journal' }, COinS = 'rft.isbn', cleanup = true },
dnb        = { 'DNB', types = { 'book', 'collection', 'map' }, cleanup = true },
oclc        = { 'OCLC', types = { 'book', 'collection', 'map' }, COinS_id = 'info:oclcnum', cleanup = true },
issn        = { 'ISSN', COinS = 'rft.issn', cleanup = true },
eissn      = { 'EISSN', cleanup = true },
doi        = { 'DOI', COinS_id = 'info:doi', cleanup = true },
language    = { 'Sprache' },
comment    = { 'Kommentar', 'Zitat' },
ignoreError = { 'ignoreError', 'ignoreErrors', 'keinFehler', 'kein Fehler', cleanup = true },
urlStatus  = { 'URL-Status', cleanup = true },
archiveUrl  = { 'Archiv-URL', cleanup = true },
archiveDate = { 'Archiv-Datum', 'Archivdatum', cleanup = true },
format      = { 'Format', cleanup = true }
}
 
-- list of formatter strings
local formatters = {
-- author
auAuthor = '%s: ',
auAuthorEditor = '%s ; %s',
auEditor = '%s (Hrsg.)',
-- title
tiAll = "%s. ",
tiChapter = "Kapitel ''%s''",
tiIn = 'In: ',
tiScale = 'Maßstab: %s. ',
tiSeries = '(%s)',
tiTitle = "''%s''",
tiVolume = "''%s''; Bd. %s",
-- publisher
puAll = '%s.',
puDateEdition = '%s (%d. Auflage)',
puPlaceDate = '%s, %s',
puPlacePub = '%s: %s',
-- additions
addColumns = 'Sp. %s',
addComment = ' %s',
addDelimiter1 = ', ',
addDelimiter2 = '; ',
addExtent = '%s Seiten',
addLanguage = ' (%s)',
addPages = 'S. %s',
-- periodical
prAbbr = ' (%s)',
prIssue = 'Nr. %s',
prPlace = ' <%s>',
prVolume = 'Bd. %s',
prVolIssue = '%s,%s',
prVolYear = '%s (%s)',
-- newspaper
nsVolume = 'Jg. %s',
-- database ids
dbDnb = '[[w:Deutsche Nationalbibliothek|DNB]] [http://d-nb.info/%s %s]',
dbDoi = '[[w:Digital Object Identifier|doi]]:%s',
dbOclc = '[[w:Online Computer Library Center|OCLC]] [https://worldcat.org/oclc/%s %s]',
dbIssn = '[[w:Internationale Standardnummer für fortlaufende Sammelwerke|ISSN]] [http://zdb-katalog.de/list.xhtml?t=iss%3D%22xx1xx%22&key=cql xx1xx]',
dbJstor = '[[w:JSTOR|JSTOR]] [https://www.jstor.org/stable/%s %s]',
-- web
wbAccess = 'abgerufen am %s',
wbKBytes = 'Dateigröße: %s KByte',
wbMBytes = 'Dateigröße: %s MByte',
-- archive
arArchived = 'Archiviert',
arOriginal = 'Original',
arArchive = ' %s vom %s.',
arArchiveDate = ' %s vom %s am %s.'
}
 
-- error categories and hints
local texts = {
decimalPoint  = ',',
noTitel      = '<span class="error">Fehlender Titel</span>',
noTitelUrl    = '<span class="error">Titel und URL fehlen</span>[[Category:Literatur: Titel und URL fehlen]]',
noURL        = '<span class="error">Ungültige URL</span>[[Category:Literatur: ungültige URL]]',
unknownParam  = '<span class="error">Ungültiger Parameter: %s</span>[[Category:Literatur: ungültige Parameter]]',
unknownParams = '<span class="error">Ungültige Parameter: %s</span>[[Category:Literatur: ungültige Parameter]]',
unknownTitle  = '[[Category:Literatur: fehlender Titel]]',
unknownPeriodical = '[[Category:Literatur: fehlender Titel eines Periodikums]]',
wrongDate    = '<span class="error">Ungültiges Datum</span>[[Category:Literatur: ungültiges Datum]]',
wrongIssn    = '<span class="error">Ungültige ISSN</span>[[Category:Seiten mit ISSN-Fehlern]]',
wrongPages    = '<span class="error">Ungültige Seiten</span>[[Category:Literatur: ungültige Seiten]]',
wrongType    = '<span class="error">Ungültiger Typ</span>[[Category:Literatur: ungültiger Typ]]',
wrongValue    = '<span class="error">Ungültiger Wert: %s</span>[[Category:Literatur: ungültiger Wert]]',
wrongValues  = '<span class="error">Ungültige Werte: %s</span>[[Category:Literatur: ungültiger Wert]]',
KBytesMBytes  = '<span class="error">KBytes und MBytes gleichzeitig</span>[[Category:Literatur: KBytes und MBytes gleichzeitig]]'
}
 
-- detcted date format y, y-m, y-m-d
-- detcted date format y, y-m, y-m-d
local dateFormat = ''
local dateFormat = ''
Zeile 168: Zeile 28:
local aType = frameArgs.type
local aType = frameArgs.type


for key, value in pairs( params ) do
for key, value in pairs( ci.params ) do
if not value.types or cu.inArray( value.types, aType ) then
if not value.types or cu.inArray( value.types, aType ) then
for key2, value2 in ipairs( value ) do
for key2, value2 in ipairs( value ) do
Zeile 179: Zeile 39:
end
end
-- no missing items
-- no missing items
for key, value in pairs( params ) do
for key, value in pairs( ci.params ) do
if not args[ key ] then
if not args[ key ] then
args[ key ] = ''
args[ key ] = ''
Zeile 191: Zeile 51:
end
end
if #wrongParams == 1 then
if #wrongParams == 1 then
cu.addErrorMsg( mw.ustring.format( texts.unknownParam, table.concat( wrongParams, ', ' ) ) )
cu.addErrorMsg( mw.ustring.format( ci.texts.unknownParam, table.concat( wrongParams, ', ' ) ) )
elseif #wrongParams > 0 then
elseif #wrongParams > 0 then
cu.addErrorMsg( mw.ustring.format( texts.unknownParams, table.concat( wrongParams, ', ' ) ) )
cu.addErrorMsg( mw.ustring.format( ci.texts.unknownParams, table.concat( wrongParams, ', ' ) ) )
end
end
return args
return args
Zeile 205: Zeile 65:


if aType == 'web' and not cu.isSet( args.title ) and not cu.isSet( args.url ) then
if aType == 'web' and not cu.isSet( args.title ) and not cu.isSet( args.url ) then
title = texts.noTitle
title = ci.texts.noTitle
cu.addErrorMsg( texts.noTitleUrl )
cu.addErrorMsg( ci.texts.noTitleUrl )
elseif not cu.isSet( args.title ) then
elseif not cu.isSet( args.title ) then
title = texts.noTitle
title = ci.texts.noTitle
cu.addErrorMsg( texts.unknownTitle )
cu.addErrorMsg( ci.texts.unknownTitle )
end
end


Zeile 217: Zeile 77:
if cu.isSet( args.KBytes ) and cu.isSet( args.MBytes ) then
if cu.isSet( args.KBytes ) and cu.isSet( args.MBytes ) then
args.MBytes = ''
args.MBytes = ''
cu.addErrorMsg( texts.KBytesMBytes )
cu.addErrorMsg( ci.texts.KBytesMBytes )
end
end


Zeile 242: Zeile 102:
else
else
args.date = ''
args.date = ''
cu.addErrorMsg( texts.wrongDate )
cu.addErrorMsg( ci.texts.wrongDate )
end
end
end
end
Zeile 251: Zeile 111:
not args[ value ]:match( '^20%d%d%-[01]?%d%-[0123]?%d$' ) then
not args[ value ]:match( '^20%d%d%-[01]?%d%-[0123]?%d$' ) then
args[ value ] = ''
args[ value ] = ''
cu.addErrorMsg( texts.wrongDate )
cu.addErrorMsg( ci.texts.wrongDate )
end
end
end
end
Zeile 258: Zeile 118:
if cu.isSet( args[ value ] ) and uc.isUrl( args[ value ] ) > 2 then
if cu.isSet( args[ value ] ) and uc.isUrl( args[ value ] ) > 2 then
args[ value ] = ''
args[ value ] = ''
cu.addErrorMsg( texts.noURL )
cu.addErrorMsg( ci.texts.noURL )
end
end
end
end
Zeile 268: Zeile 128:
args.url = args.articleUrl
args.url = args.articleUrl
end
end
args.urlStatus = cu.getKey( args.urlStatus, urlStates )
args.urlStatus = cu.getKey( args.urlStatus, ci.urlStatusTable )
if not cu.isSet( args.urlStatus ) and cu.isSet( args.archiveUrl ) then
if not cu.isSet( args.urlStatus ) and cu.isSet( args.archiveUrl ) then
args.urlStatus = 'dead'
args.urlStatus = 'dead'
Zeile 307: Zeile 167:


if #wrong == 1 then
if #wrong == 1 then
cu.addErrorMsg( mw.ustring.format( texts.wrongValue, wrong[ 1 ] ) )
cu.addErrorMsg( mw.ustring.format( ci.texts.wrongValue, wrong[ 1 ] ) )
elseif #wrong > 1 then
elseif #wrong > 1 then
cu.addErrorMsg( mw.ustring.format( texts.wrongValues, table.concat( wrong, ', ' ) ) )
cu.addErrorMsg( mw.ustring.format( ci.texts.wrongValues, table.concat( wrong, ', ' ) ) )
end
end
end
end
Zeile 316: Zeile 176:
local text = ''
local text = ''
if ignoreError ~= 'true' then
if ignoreError ~= 'true' then
text = texts.wrongIssn
text = ci.texts.wrongIssn
end
end
return formatters.dbIssn:gsub( 'xx1xx', issn )
return ci.formatters.dbIssn:gsub( 'xx1xx', issn )
.. cx.check_issn( { args = { [ 1 ] = issn, error = text } } )
.. cx.check_issn( { args = { [ 1 ] = issn, error = text } } )
end
end
Zeile 325: Zeile 185:
local function makeAuthor( author, editor )
local function makeAuthor( author, editor )
if cu.isSet( editor ) then
if cu.isSet( editor ) then
editor = mw.ustring.format( formatters.auEditor, editor )
editor = mw.ustring.format( ci.formatters.auEditor, editor )
end
end
if cu.isSet( author ) and cu.isSet( editor ) then
if cu.isSet( author ) and cu.isSet( editor ) then
author = mw.ustring.format( formatters.auAuthorEditor, author, editor )
author = mw.ustring.format( ci.formatters.auAuthorEditor, author, editor )
elseif not cu.isSet( author ) and cu.isSet( editor ) then
elseif not cu.isSet( author ) and cu.isSet( editor ) then
author = editor
author = editor
end
end
if cu.isSet( author ) then
if cu.isSet( author ) then
return mw.ustring.format( formatters.auAuthor, author )
return mw.ustring.format( ci.formatters.auAuthor, author )
else
else
return ''
return ''
Zeile 342: Zeile 202:
local function makeTitle( title, volume, url, scale )
local function makeTitle( title, volume, url, scale )
if not cu.isSet( title ) then
if not cu.isSet( title ) then
title = texts.noTitle
title = ci.texts.noTitle
cu.addErrorMsg( texts.unknownTitle )
cu.addErrorMsg( ci.texts.unknownTitle )
end
end
if cu.isSet( url ) then
if cu.isSet( url ) then
Zeile 351: Zeile 211:
if cu.isSet( volume ) then
if cu.isSet( volume ) then
title = mw.ustring.format( formatters.tiVolume, title, volume )
title = mw.ustring.format( ci.formatters.tiVolume, title, volume )
else
else
title = mw.ustring.format( formatters.tiTitle, title )
title = mw.ustring.format( ci.formatters.tiTitle, title )
end
end
title = mw.ustring.format( formatters.tiAll, title )
title = mw.ustring.format( ci.formatters.tiAll, title )
if cu.isSet( scale ) then
if cu.isSet( scale ) then
title = title .. mw.ustring.format( formatters.tiScale, scale )
title = title .. mw.ustring.format( ci.formatters.tiScale, scale )
end
end
return title
return title
Zeile 369: Zeile 229:
dateFormat = 'M Y'
dateFormat = 'M Y'
end
end
theDate = cu.getDate( args.date, dateFormat, texts.wrongDate )
theDate = cu.getDate( args.date, dateFormat, ci.texts.wrongDate )
end
end


Zeile 375: Zeile 235:


if cu.isSet( theDate ) and cu.isSet( args.edition ) then
if cu.isSet( theDate ) and cu.isSet( args.edition ) then
theDate = mw.ustring.format( formatters.puDateEdition, theDate, args.edition )
theDate = mw.ustring.format( ci.formatters.puDateEdition, theDate, args.edition )
end
end
if cu.isSet( args.place ) and cu.isSet( args.publisher ) then
if cu.isSet( args.place ) and cu.isSet( args.publisher ) then
published = mw.ustring.format( formatters.puPlacePub, args.place, args.publisher )
published = mw.ustring.format( ci.formatters.puPlacePub, args.place, args.publisher )
elseif cu.isSet( args.place ) then
elseif cu.isSet( args.place ) then
published = args.place
published = args.place
Zeile 387: Zeile 247:
published = theDate
published = theDate
elseif cu.isSet( theDate ) then
elseif cu.isSet( theDate ) then
published = mw.ustring.format( formatters.puPlaceDate, published, theDate )
published = mw.ustring.format( ci.formatters.puPlaceDate, published, theDate )
end
end
if cu.isSet( published ) then
if cu.isSet( published ) then
Zeile 399: Zeile 259:
for key, value in ipairs( { 'series', 'series2', 'series3' } ) do
for key, value in ipairs( { 'series', 'series2', 'series3' } ) do
if cu.isSet( args[ value ] ) then
if cu.isSet( args[ value ] ) then
table.insert( tab, mw.ustring.format( formatters.tiSeries, args[ value ] ) )
table.insert( tab, mw.ustring.format( ci.formatters.tiSeries, args[ value ] ) )
end
end
end
end
Zeile 409: Zeile 269:
li._linkISBNSet( { isbn = args.isbn, ignoreError = args.ignoreError } ) )
li._linkISBNSet( { isbn = args.isbn, ignoreError = args.ignoreError } ) )
elseif cu.isSet( args.dnb ) then
elseif cu.isSet( args.dnb ) then
table.insert( tab, mw.ustring.format( formatters.dbDnb, args.dnb, args.dnb ) )
table.insert( tab, mw.ustring.format( ci.formatters.dbDnb, args.dnb, args.dnb ) )
elseif cu.isSet( args.oclc ) then
elseif cu.isSet( args.oclc ) then
table.insert( tab, mw.ustring.format( formatters.dbOclc, args.oclc, args.oclc ) )
table.insert( tab, mw.ustring.format( ci.formatters.dbOclc, args.oclc, args.oclc ) )
end
end
if cu.isSet( args.issn ) then
if cu.isSet( args.issn ) then
Zeile 424: Zeile 284:
if cu.isSet( args.pages ) then
if cu.isSet( args.pages ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.addPages, args.pages:gsub( '-', '–' ) ) )
mw.ustring.format( ci.formatters.addPages, args.pages:gsub( '-', '–' ) ) )
end
end
if cu.isSet( args.columns ) then
if cu.isSet( args.columns ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.addColumns, args.columns:gsub( '-', '–' ) ) )
mw.ustring.format( ci.formatters.addColumns, args.columns:gsub( '-', '–' ) ) )
end
end
end
end
Zeile 435: Zeile 295:
if cu.isSet( args.extent ) then
if cu.isSet( args.extent ) then
if args.extent:match( '^%d+$' ) then
if args.extent:match( '^%d+$' ) then
args.extent = mw.ustring.format( formatters.addExtent, args.extent )
args.extent = mw.ustring.format( ci.formatters.addExtent, args.extent )
end
end
table.insert( tab, args.extent )
table.insert( tab, args.extent )
Zeile 441: Zeile 301:
if cu.isSet( args.doi ) then
if cu.isSet( args.doi ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.dbDoi, cu.makeDoiLink( args.doi ) ) )
mw.ustring.format( ci.formatters.dbDoi, cu.makeDoiLink( args.doi ) ) )
end
end
if cu.isSet( args.jstor ) then
if cu.isSet( args.jstor ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.dbJstor, args.jstor, args.jstor ) )
mw.ustring.format( ci.formatters.dbJstor, args.jstor, args.jstor ) )
end
end
end
end
Zeile 453: Zeile 313:
if cu.isSet( args.url ) or cu.isSet( args.articleUrl ) or cu.isSet( args.archiveUrl ) then
if cu.isSet( args.url ) or cu.isSet( args.articleUrl ) or cu.isSet( args.archiveUrl ) then
if cu.isSet( args.accessDate ) then
if cu.isSet( args.accessDate ) then
args.accessDate = cu.getDate( args.accessDate, 'j. F Y', texts.wrongDate )
args.accessDate = cu.getDate( args.accessDate, 'j. F Y', ci.texts.wrongDate )
if cu.isSet( args.accessDate ) then
if cu.isSet( args.accessDate ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.wbAccess, args.accessDate ) )
mw.ustring.format( ci.formatters.wbAccess, args.accessDate ) )
end
end
end
end
Zeile 477: Zeile 337:
if kb >= 1024 then
if kb >= 1024 then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.wbMBytes,
mw.ustring.format( ci.formatters.wbMBytes,
tostring( cu.round( kb / 1024, 3 ) ):gsub( '%.', texts.decimalPoint ) ) )
tostring( cu.round( kb / 1024, 3 ) ):gsub( '%.', ci.texts.decimalPoint ) ) )
else
else
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.wbKBytes, args.KBytes ) )
mw.ustring.format( ci.formatters.wbKBytes, args.KBytes ) )
end
end
elseif cu.isSet( args.MBytes ) then
elseif cu.isSet( args.MBytes ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.wbMBytes, args.MBytes ) )
mw.ustring.format( ci.formatters.wbMBytes, args.MBytes ) )
end
end
end
end
Zeile 491: Zeile 351:


local function makeArchived( args )
local function makeArchived( args )
local archived = formatters.arArchived
local archived = ci.formatters.arArchived
local original = formatters.arOriginal
local original = ci.formatters.arOriginal
if cu.isSet( args.archiveUrl ) then
if cu.isSet( args.archiveUrl ) then
archived = '[' .. args.archiveUrl .. ' ' .. archived .. ']'
archived = '[' .. args.archiveUrl .. ' ' .. archived .. ']'
Zeile 502: Zeile 362:
local day = '', result
local day = '', result
if cu.isSet( args.archiveDate ) then
if cu.isSet( args.archiveDate ) then
day = cu.getDate( args.date, 'l, j. F Y', texts.wrongDate )
day = cu.getDate( args.date, 'l, j. F Y', ci.texts.wrongDate )
end
end
if day ~= '' then
if day ~= '' then
result = mw.ustring.format( formatters.arArchiveDate, archived, original, day )
result = mw.ustring.format( ci.formatters.arArchiveDate, archived, original, day )
else
else
if cu.isSet( args.archiveDate ) then
if cu.isSet( args.archiveDate ) then
cu.addErrorMsg( texts.wrongDate )
cu.addErrorMsg( ci.texts.wrongDate )
end
end
result = mw.ustring.format( formatters.arArchive, archived, original )
result = mw.ustring.format( ci.formatters.arArchive, archived, original )
end
end
return result
return result
Zeile 517: Zeile 377:
local function makeLanguageComment( args, result )
local function makeLanguageComment( args, result )
if cu.isSet( args.language ) then
if cu.isSet( args.language ) then
result = result .. mw.ustring.format( formatters.addLanguage, args.language )
result = result .. mw.ustring.format( ci.formatters.addLanguage, args.language )
end
end
if result ~= '' then
if result ~= '' then
result = mw.ustring.format( formatters.puAll, result )
result = mw.ustring.format( ci.formatters.puAll, result )
end
end
if cu.isSet( args.archiveUrl ) or cu.isSet( args.originalUrl )  
if cu.isSet( args.archiveUrl ) or cu.isSet( args.originalUrl )  
Zeile 527: Zeile 387:
end
end
if cu.isSet( args.comment ) then
if cu.isSet( args.comment ) then
result = result .. mw.ustring.format( formatters.addComment, args.comment )
result = result .. mw.ustring.format( ci.formatters.addComment, args.comment )
end
end
return result
return result
Zeile 538: Zeile 398:
makeIsbn( args, result )
makeIsbn( args, result )
if cu.isSet( args.chapter ) then
if cu.isSet( args.chapter ) then
table.insert( result, mw.ustring.format( formatters.tiChapter, args.chapter ) )
table.insert( result, mw.ustring.format( ci.formatters.tiChapter, args.chapter ) )
end
end
makePages( args, result )
makePages( args, result )
if #result > 0 then
if #result > 0 then
result = { table.concat( result, formatters.addDelimiter1 ) }
result = { table.concat( result, ci.formatters.addDelimiter1 ) }
end
end


makeDoi( args, result )
makeDoi( args, result )
makeWebInfo( args, result )
makeWebInfo( args, result )
result = table.concat( result, formatters.addDelimiter2 )
result = table.concat( result, ci.formatters.addDelimiter2 )


return makeLanguageComment( args, result )
return makeLanguageComment( args, result )
Zeile 573: Zeile 433:
collection = makeTitle( args.collection, args.volume, args.siteUrl, '' )
collection = makeTitle( args.collection, args.volume, args.siteUrl, '' )


return author .. title .. formatters.tiIn .. editor .. collection
return author .. title .. ci.formatters.tiIn .. editor .. collection
.. makePublished( args )
.. makePublished( args )
end
end
Zeile 587: Zeile 447:
end
end
if title == '' then
if title == '' then
title = texts.noTitel
title = ci.texts.noTitel
cu.addErrorMsg( texts.unknownPeriodical )
cu.addErrorMsg( ci.texts.unknownPeriodical )
else
else
title = mw.ustring.format( formatters.tiTitle, title )
title = mw.ustring.format( ci.formatters.tiTitle, title )
end
end
if cu.isSet( args.siteUrl ) then
if cu.isSet( args.siteUrl ) then
Zeile 597: Zeile 457:
end
end
if cu.isSet( args.place ) then
if cu.isSet( args.place ) then
title = title .. mw.ustring.format( formatters.prPlace, args.place )
title = title .. mw.ustring.format( ci.formatters.prPlace, args.place )
end
end
if cu.isSet( args.abbr ) then
if cu.isSet( args.abbr ) then
title = title .. mw.ustring.format( formatters.prAbbr, args.abbr )
title = title .. mw.ustring.format( ci.formatters.prAbbr, args.abbr )
end
end
return title
return title
Zeile 608: Zeile 468:
local year = ''
local year = ''
if cu.isSet( args.date ) then
if cu.isSet( args.date ) then
year = cu.getDate( args.date, dateFormat, texts.wrongDate )
year = cu.getDate( args.date, dateFormat, ci.texts.wrongDate )
end
end
local volume = ''
local volume = ''
if cu.isSet( args.volume ) then
if cu.isSet( args.volume ) then
volume = mw.ustring.format( formatters.prVolume, args.volume )
volume = mw.ustring.format( ci.formatters.prVolume, args.volume )
if cu.isSet( args.issue ) then
if cu.isSet( args.issue ) then
volume = mw.ustring.format( formatters.prVolIssue, volume, args.issue )
volume = mw.ustring.format( ci.formatters.prVolIssue, volume, args.issue )
end
end
if year ~= '' then
if year ~= '' then
volume = mw.ustring.format( formatters.prVolYear, volume, year )
volume = mw.ustring.format( ci.formatters.prVolYear, volume, year )
end
end
else
else
if cu.isSet( args.issue ) then
if cu.isSet( args.issue ) then
volume = mw.ustring.format( formatters.prIssue, args.issue )
volume = mw.ustring.format( ci.formatters.prIssue, args.issue )
if year ~= '' then
if year ~= '' then
volume = mw.ustring.format( formatters.prVolYear, volume, year )
volume = mw.ustring.format( ci.formatters.prVolYear, volume, year )
end
end
else
else
Zeile 640: Zeile 500:
if cu.isSet( args.volume ) then
if cu.isSet( args.volume ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.nsVolume, args.volume ) )
mw.ustring.format( ci.formatters.nsVolume, args.volume ) )
end
end
if cu.isSet( args.issue ) then
if cu.isSet( args.issue ) then
table.insert( tab,
table.insert( tab,
mw.ustring.format( formatters.prIssue, args.issue ) )
mw.ustring.format( ci.formatters.prIssue, args.issue ) )
end
end


Zeile 651: Zeile 511:
if dateFormat == 'j. F Y' then
if dateFormat == 'j. F Y' then
-- following result can be ''
-- following result can be ''
day = cu.getDate( args.date, 'l, j. F Y', texts.wrongDate )
day = cu.getDate( args.date, 'l, j. F Y', ci.texts.wrongDate )
else
else
cu.addErrorMsg( texts.wrongDate )
cu.addErrorMsg( ci.texts.wrongDate )
end
end
end
end
Zeile 663: Zeile 523:
local function makePeriodical( args )
local function makePeriodical( args )
local result = { makeAuthor( args.author, '' )
local result = { makeAuthor( args.author, '' )
.. makeTitle( args.title, '', args.url, '' ) .. formatters.tiIn
.. makeTitle( args.title, '', args.url, '' ) .. ci.formatters.tiIn
.. makeJournalTitle( args ) }
.. makeJournalTitle( args ) }


Zeile 675: Zeile 535:
makeDoi( args, result )
makeDoi( args, result )
makeWebInfo( args, result )
makeWebInfo( args, result )
result = table.concat( result, formatters.addDelimiter1 )
result = table.concat( result, ci.formatters.addDelimiter1 )


return makeLanguageComment( args, result )
return makeLanguageComment( args, result )
Zeile 694: Zeile 554:
else
else
args.type = 'book'
args.type = 'book'
citation = texts.wrongType .. makeBook( args )
citation = ci.texts.wrongType .. makeBook( args )
end
end


Zeile 703: Zeile 563:
.. '<cite style="font-style: normal;" class="citation ' .. args.type
.. '<cite style="font-style: normal;" class="citation ' .. args.type
.. ' printNoLink">' .. citation .. '</cite>'
.. ' printNoLink">' .. citation .. '</cite>'
.. cc.makeCOinS( args, params )
.. cc.makeCOinS( args, ci.params )
end
end


Zeile 713: Zeile 573:
args.type = fType
args.type = fType
else
else
args.type = cu.getKey( cu.getArgValue( params, 'type', args ), refTypes )
args.type = cu.getKey( cu.getArgValue( ci.params, 'type', args ), ci.refTypes )
end
end
if not cu.isSet( args.type ) then
if not cu.isSet( args.type ) then
if cu.getArgValue( params, 'scale', args ) ~= '' then
if cu.getArgValue( ci.params, 'scale', args ) ~= '' then
args.type = 'map'
args.type = 'map'
elseif cu.getArgValue( params, 'collection', args ) ~= '' then
elseif cu.getArgValue( ci.params, 'collection', args ) ~= '' then
args.type = 'collection'
args.type = 'collection'
elseif cu.getArgValue( params, 'journal', args ) ~= '' then
elseif cu.getArgValue( ci.params, 'journal', args ) ~= '' then
args.type = 'journal'
args.type = 'journal'
elseif cu.getArgValue( params, 'newspaper', args ) ~= '' then
elseif cu.getArgValue( ci.params, 'newspaper', args ) ~= '' then
args.type = 'newspaper'
args.type = 'newspaper'
elseif cu.getArgValue( params, 'website', args ) ~= '' then
elseif cu.getArgValue( ci.params, 'website', args ) ~= '' then
args.type = 'web'
args.type = 'web'
else
else

Version vom 26. März 2020, 18:21 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Citation/doc erstellt werden

-- documentation
local citation = {
	suite  = 'Citation',
	serial = '2020-03-26',
}

-- module import
local cu = require( 'Module:Citation/utilities' )
local cc = require( 'Module:Citation/COinS' )
local ci = require( 'Module:Citation/i18n' )
local cx = require( 'Module:Check isxn' )
local li = require( 'Module:LinkISBN' )
local uc = require( 'Module:UrlCheck' )
local yn = require( 'Module:Yesno' )

-- module variable
local ct = {}

-- global variable
-- detcted date format y, y-m, y-m-d
local dateFormat = ''

-- check for valid arguments against params table
local function getValidArgs( frameArgs )
	local args = {}, key, key2, ok, value, value2
	local complete = {}
	local wrongParams = {}
	local aType = frameArgs.type

	for key, value in pairs( ci.params ) do
		if not value.types or cu.inArray( value.types, aType ) then
			for key2, value2 in ipairs( value ) do
				complete[ value2 ] = key
				args[ key ] = args[ key ] or
					cu.cleanupParameters( frameArgs[ value2 ], value.cleanup )
			end
			args[ key ] = args[ key ] or ''
		end
	end
	-- no missing items
	for key, value in pairs( ci.params ) do
		if not args[ key ] then
			args[ key ] = ''
		end
	end

	for key, value in pairs( frameArgs ) do
		if not complete[ key ] then
			table.insert( wrongParams, key )
		end
	end
	if #wrongParams == 1 then
		cu.addErrorMsg( mw.ustring.format( ci.texts.unknownParam, table.concat( wrongParams, ', ' ) ) )
	elseif #wrongParams > 0 then
		cu.addErrorMsg( mw.ustring.format( ci.texts.unknownParams, table.concat( wrongParams, ', ' ) ) )
	end
	return args
end

-- check parameter values
local function checkValues( args )
	local i, key, value
	local wrong = {}
	local aType = args.type

	if aType == 'web' and not cu.isSet( args.title ) and not cu.isSet( args.url ) then
		title = ci.texts.noTitle
		cu.addErrorMsg( ci.texts.noTitleUrl )
	elseif not cu.isSet( args.title ) then
		title = ci.texts.noTitle
		cu.addErrorMsg( ci.texts.unknownTitle )
	end

	args.pages = cu.cleanupPageNumbers( args.pages )
	args.columns = cu.cleanupPageNumbers( args.columns )

	if cu.isSet( args.KBytes ) and cu.isSet( args.MBytes ) then
		args.MBytes = ''
		cu.addErrorMsg( ci.texts.KBytesMBytes )
	end

	args.ignoreError = yn( args.ignoreError, false )
	if args.ignoreError then
		args.ignoreError = 'true'
	else
		args.ignoreError = 'false'
	end

	if cu.isSet( args.date ) then
		if args.date:match( '^[12]%d%d%d%-[01]?%d%-[0123]?%d$' ) then
			dateFormat = 'j. F Y'
		elseif args.date:match( '^[12]%d%d%d%-[01]?%d$' ) then
			dateFormat = 'M Y'
		elseif args.date:match( '^[12]%d%d%d$' ) then
			dateFormat = 'Y'
		else
			args.date = args.date:match( '%d+' ) or ''
			if cu.isSet( args.date ) then
				i = tonumber( args.date )
				if i >= 1000 and i < 2100 then
					dateFormat = 'Y'
				else
					args.date = ''
					cu.addErrorMsg( ci.texts.wrongDate )
				end
			end
		end
	end
	for key, value in ipairs( { 'accessDate', 'archiveDate' } ) do
		if cu.isSet( args[ value ] ) and
			not args[ value ]:match( '^20%d%d%-[01]?%d%-[0123]?%d$' ) then
			args[ value ] = ''
			cu.addErrorMsg( ci.texts.wrongDate )
		end
	end

	for key, value in ipairs( { 'url', 'articleUrl', 'archiveUrl' } ) do
		if cu.isSet( args[ value ] ) and uc.isUrl( args[ value ] ) > 2 then
			args[ value ] = ''
			cu.addErrorMsg( ci.texts.noURL )
		end
	end
	-- copying for historical reasons
	if aType == 'journal' then
		args.siteUrl = args.url
	end
	if aType == 'journal' then
		args.url = args.articleUrl
	end
	args.urlStatus = cu.getKey( args.urlStatus, ci.urlStatusTable )
	if not cu.isSet( args.urlStatus ) and cu.isSet( args.archiveUrl ) then
		args.urlStatus = 'dead'
	elseif not cu.isSet( args.urlStatus ) then
		args.urlStatus = 'live'
	end
	if args.urlStatus == 'dead' then
		args.originalUrl = args.url
		args.url = args.archiveUrl
		args.archiveUrl = ''
	elseif args.urlStatus == 'usurped' then
		args.url = args.archiveUrl
		args.archiveUrl = ''
	end

	for key, value in ipairs( { 'dnb', 'oclc', 'jstor', 'KBytes' } ) do
		if cu.isSet( args[ value ] ) and not args[ value ]:match( '^%d+$' ) then
			args[ value ] = ''
			table.insert( wrong, value )
		end
	end

	if cu.isSet( args.doi ) and not mw.ustring.match( args.doi, '^10%.%d+/.+$' ) then
		args.doi = ''
		table.insert( wrong, 'doi' )
	end

	if cu.isSet( args.edition ) then
		args.edition = args.edition:match( '%d+' ) or ''
		if args.edition == '1' then
			args.edition = ''
		end
	end

	if cu.isSet( args.type ) and args.type ~= 'map' then
		args.scale = ''
	end

	if #wrong == 1 then
		cu.addErrorMsg( mw.ustring.format( ci.texts.wrongValue, wrong[ 1 ] ) )
	elseif #wrong > 1 then
		cu.addErrorMsg( mw.ustring.format( ci.texts.wrongValues, table.concat( wrong, ', ' ) ) )
	end
end

local function makeIssnLink( issn, ignoreError )
	local text = ''
	if ignoreError ~= 'true' then
		text = ci.texts.wrongIssn
	end
	return ci.formatters.dbIssn:gsub( 'xx1xx', issn )
		.. cx.check_issn( { args = { [ 1 ] = issn, error = text } } )
end

-- make author part
local function makeAuthor( author, editor )
	if cu.isSet( editor ) then
		editor = mw.ustring.format( ci.formatters.auEditor, editor )
	end
	if cu.isSet( author ) and cu.isSet( editor ) then
		author = mw.ustring.format( ci.formatters.auAuthorEditor, author, editor )
	elseif not cu.isSet( author ) and cu.isSet( editor ) then
		author = editor
	end
	if cu.isSet( author ) then
		return mw.ustring.format( ci.formatters.auAuthor, author )
	else
		return ''
	end
end

-- make title part
local function makeTitle( title, volume, url, scale )
	if not cu.isSet( title ) then
		title = ci.texts.noTitle
		cu.addErrorMsg( ci.texts.unknownTitle )
	end
	if cu.isSet( url ) then
		title = title:gsub( '[%[%]]', '' )
		title = '[' .. url .. ' ' .. title .. ']'
	end
	
	if cu.isSet( volume ) then
		title = mw.ustring.format( ci.formatters.tiVolume, title, volume )
	else
		title = mw.ustring.format( ci.formatters.tiTitle, title )
	end
	title = mw.ustring.format( ci.formatters.tiAll, title )
	if cu.isSet( scale ) then
		title = title .. mw.ustring.format( ci.formatters.tiScale, scale )
	end
	return title
end

-- make publisher part for books
local function makePublisher( args, tab )
	local theDate = ''
	if cu.isSet( args.date ) then
		if cu.isSet( dateFormat ) and dateFormat ~= 'Y' then
			dateFormat = 'M Y'
		end
		theDate = cu.getDate( args.date, dateFormat, ci.texts.wrongDate )
	end

	local published = ''

	if cu.isSet( theDate ) and cu.isSet( args.edition ) then
		theDate = mw.ustring.format( ci.formatters.puDateEdition, theDate, args.edition )
	end
	if cu.isSet( args.place ) and cu.isSet( args.publisher ) then
		published = mw.ustring.format( ci.formatters.puPlacePub, args.place, args.publisher )
	elseif cu.isSet( args.place ) then
		published = args.place
	elseif cu.isSet( args.publisher ) then
		published = args.publisher
	end
	if not cu.isSet( published ) then
		published = theDate
	elseif cu.isSet( theDate ) then
		published = mw.ustring.format( ci.formatters.puPlaceDate, published, theDate )
	end
	if cu.isSet( published ) then
		table.insert( tab, published )
	end
end

-- make series part
local function makeSeries( args, tab )
	local key, value
	for key, value in ipairs( { 'series', 'series2', 'series3' } ) do
		if cu.isSet( args[ value ] ) then
			table.insert( tab, mw.ustring.format( ci.formatters.tiSeries, args[ value ] ) )
		end
	end
end

local function makeIsbn( args, tab )
	if cu.isSet( args.isbn ) then
		table.insert( tab,
			li._linkISBNSet( { isbn = args.isbn, ignoreError = args.ignoreError } ) )
	elseif cu.isSet( args.dnb ) then
		table.insert( tab, mw.ustring.format( ci.formatters.dbDnb, args.dnb, args.dnb ) )
	elseif cu.isSet( args.oclc ) then
		table.insert( tab, mw.ustring.format( ci.formatters.dbOclc, args.oclc, args.oclc ) )
	end
	if cu.isSet( args.issn ) then
		table.insert( tab, makeIssnLink( args.issn, args.ignoreError ) )
	end
	if cu.isSet( args.eissn ) then
		table.insert( tab, makeIssnLink( args.eissn, args.ignoreError ) )
	end
end

local function makePages( args, tab )
	if cu.isSet( args.pages ) then
		table.insert( tab,
			mw.ustring.format( ci.formatters.addPages, args.pages:gsub( '-', '–' ) ) )
	end
	if cu.isSet( args.columns ) then
		table.insert( tab,
			mw.ustring.format( ci.formatters.addColumns, args.columns:gsub( '-', '–' ) ) )
	end
end

local function makeDoi( args, tab )
	if cu.isSet( args.extent ) then
		if args.extent:match( '^%d+$' ) then
			args.extent = mw.ustring.format( ci.formatters.addExtent, args.extent )
		end
		table.insert( tab, args.extent )
	end
	if cu.isSet( args.doi ) then
		table.insert( tab,
			mw.ustring.format( ci.formatters.dbDoi, cu.makeDoiLink( args.doi ) ) )
	end
	if cu.isSet( args.jstor ) then
		table.insert( tab,
			mw.ustring.format( ci.formatters.dbJstor, args.jstor, args.jstor ) )
	end
end

local function makeWebInfo( args, tab )
	local kb, index, value
	if cu.isSet( args.url ) or cu.isSet( args.articleUrl ) or cu.isSet( args.archiveUrl ) then
		if cu.isSet( args.accessDate ) then
			args.accessDate = cu.getDate( args.accessDate, 'j. F Y', ci.texts.wrongDate )
			if cu.isSet( args.accessDate ) then
				table.insert( tab,
					mw.ustring.format( ci.formatters.wbAccess, args.accessDate ) )
			end
		end
		if cu.isSet( args.format ) then
			table.insert( tab, args.format:upper() )
		else
			for index, value in ipairs( { 'PDF' } ) do
				if cu.hasExtension( args.url, value ) then
					table.insert( tab, args.format )
					break
				end
				if cu.hasExtension( args.archiveUrl, value ) then
					table.insert( tab, args.format )
					break
				end
			end
		end
		if cu.isSet( args.KBytes ) then
			kb = tonumber( args.KBytes ) or 0
			if kb >= 1024 then
				table.insert( tab,
					mw.ustring.format( ci.formatters.wbMBytes,
						tostring( cu.round( kb / 1024, 3 ) ):gsub( '%.', ci.texts.decimalPoint ) ) )
			else
				table.insert( tab,
					mw.ustring.format( ci.formatters.wbKBytes, args.KBytes ) )
			end
		elseif cu.isSet( args.MBytes ) then
			table.insert( tab,
				mw.ustring.format( ci.formatters.wbMBytes, args.MBytes ) )
		end
	end
end

local function makeArchived( args )
	local archived = ci.formatters.arArchived
	local original = ci.formatters.arOriginal
	if cu.isSet( args.archiveUrl ) then
		archived = '[' .. args.archiveUrl .. ' ' .. archived .. ']'
	end
	if cu.isSet( args.originalUrl ) then
		original = '[' .. args.originalUrl .. ' ' .. original .. ']'
	end
	
	local day = '', result
	if cu.isSet( args.archiveDate ) then
		day = cu.getDate( args.date, 'l, j. F Y', ci.texts.wrongDate )
	end
	if day ~= '' then
		result = mw.ustring.format( ci.formatters.arArchiveDate, archived, original, day )
	else
		if cu.isSet( args.archiveDate ) then
			cu.addErrorMsg( ci.texts.wrongDate )
		end
		result = mw.ustring.format( ci.formatters.arArchive, archived, original )
	end
	return result
end

local function makeLanguageComment( args, result )
	if cu.isSet( args.language ) then
		result = result .. mw.ustring.format( ci.formatters.addLanguage, args.language )
	end
	if result ~= '' then
		result = mw.ustring.format( ci.formatters.puAll, result )
	end
	if cu.isSet( args.archiveUrl ) or cu.isSet( args.originalUrl ) 
		or args.urlStatus == 'usurped' then
		result = result .. makeArchived( args )
	end
	if cu.isSet( args.comment ) then
		result = result .. mw.ustring.format( ci.formatters.addComment, args.comment )
	end
	return result
end

local function makePublished( args )
	result = {}
	makePublisher( args, result )
	makeSeries( args, result )
	makeIsbn( args, result )
	if cu.isSet( args.chapter ) then
		table.insert( result, mw.ustring.format( ci.formatters.tiChapter, args.chapter ) )
	end
	makePages( args, result )
	if #result > 0 then
		result = { table.concat( result, ci.formatters.addDelimiter1 ) }
	end

	makeDoi( args, result )
	makeWebInfo( args, result )
	result = table.concat( result, ci.formatters.addDelimiter2 )

	return makeLanguageComment( args, result )
end

local function makeBook( args )
	local author, title
	
	if args.type == 'map' or args.type == 'book' then
		author = makeAuthor( args.author, args.editor )
		title = makeTitle( args.title, args.volume, args.url, args.scale )
	else
		author = makeAuthor( '', args.editor )
		title = makeTitle( args.collection, args.volume, args.url, args.scale )
	end
	return author .. title .. makePublished( args )
end

local function makeCollection( args )
	local author, collection, editor, title

	author = makeAuthor( args.author, '' )
	title = makeTitle( args.title, args.volume, args.url, '' )
	editor = makeAuthor( '', args.editor )
	collection = makeTitle( args.collection, args.volume, args.siteUrl, '' )

	return author .. title .. ci.formatters.tiIn .. editor .. collection
		.. makePublished( args )
end

local function makeJournalTitle( args )
	local title
	if args.type == 'journal' then
		title = args.journal
	elseif args.type == 'newspaper' then
		title = args.newspaper
	else
		title = args.website
	end
	if title == '' then
		title = ci.texts.noTitel
		cu.addErrorMsg( ci.texts.unknownPeriodical )
	else
		title = mw.ustring.format( ci.formatters.tiTitle, title )
	end
	if cu.isSet( args.siteUrl ) then
		title = title:gsub( '[%[%]]', '' )
		title = '[' .. args.siteUrl .. ' ' .. title .. ']'
	end
	if cu.isSet( args.place ) then
		title = title .. mw.ustring.format( ci.formatters.prPlace, args.place )
	end
	if cu.isSet( args.abbr ) then
		title = title .. mw.ustring.format( ci.formatters.prAbbr, args.abbr )
	end
	return title
end

local function makeJournalInfo( args, tab )
	local year = ''
	if cu.isSet( args.date ) then
		year = cu.getDate( args.date, dateFormat, ci.texts.wrongDate )
	end
	local volume = ''
	if cu.isSet( args.volume ) then
		volume = mw.ustring.format( ci.formatters.prVolume, args.volume )
		if cu.isSet( args.issue ) then
			volume = mw.ustring.format( ci.formatters.prVolIssue, volume, args.issue )
		end
		if year ~= '' then
			volume = mw.ustring.format( ci.formatters.prVolYear, volume, year )
		end
	else
		if cu.isSet( args.issue ) then
			volume = mw.ustring.format( ci.formatters.prIssue, args.issue )
			if year ~= '' then
				volume = mw.ustring.format( ci.formatters.prVolYear, volume, year )
			end
		else
			volume = year
		end
	end
	if volume ~= '' then
		table.insert( tab, volume )
	end
end

local function makeNewspaperInfo( args, tab )
	if cu.isSet( args.publisher ) then
		table.insert( tab, args.publisher )
	end
	if cu.isSet( args.volume ) then
		table.insert( tab,
			mw.ustring.format( ci.formatters.nsVolume, args.volume ) )
	end
	if cu.isSet( args.issue ) then
		table.insert( tab,
			mw.ustring.format( ci.formatters.prIssue, args.issue ) )
	end

	local day = ''
	if cu.isSet( args.date ) then
		if dateFormat == 'j. F Y' then
			-- following result can be ''
			day = cu.getDate( args.date, 'l, j. F Y', ci.texts.wrongDate )
		else
			cu.addErrorMsg( ci.texts.wrongDate )
		end
	end
	if day ~= '' then
		table.insert( tab, day )
	end
end

local function makePeriodical( args )
	local result = { makeAuthor( args.author, '' )
		.. makeTitle( args.title, '', args.url, '' ) .. ci.formatters.tiIn
		.. makeJournalTitle( args ) }

	makeIsbn( args, result )
	if args.type == 'journal' then
		makeJournalInfo( args, result )
	else -- newspaper and web
		makeNewspaperInfo( args, result )
	end
	makePages( args, result )
	makeDoi( args, result )
	makeWebInfo( args, result )
	result = table.concat( result, ci.formatters.addDelimiter1 )

	return makeLanguageComment( args, result )
end

local function makeCitation( frameArgs )
	local args, citation
	args = getValidArgs( frameArgs )
	checkValues( args )

	if args.type == 'map' or args.type == 'book' then
		citation = makeBook( args )
	elseif args.type == 'collection' then
		citation = makeCollection( args )
	elseif args.type == 'journal' or args.type == 'newspaper'
		or args.type == 'web' then
		citation = makePeriodical( args )
	else
		args.type = 'book'
		citation = ci.texts.wrongType .. makeBook( args )
	end

	citation = cu.finalCleanup( citation )
	cc.prepareForCOinS( args )

	return cu.getErrorMsgs()
		.. '<cite style="font-style: normal;" class="citation ' .. args.type
		.. ' printNoLink">' .. citation .. '</cite>'
		.. cc.makeCOinS( args, ci.params )
end

function ct.citation( frame )
	local fType = frame.args.type
	local args = frame:getParent().args

	if cu.isSet( fType ) then
		args.type = fType
	else
		args.type = cu.getKey( cu.getArgValue( ci.params, 'type', args ), ci.refTypes )
	end
	if not cu.isSet( args.type ) then
		if cu.getArgValue( ci.params, 'scale', args ) ~= '' then
			args.type = 'map'
		elseif cu.getArgValue( ci.params, 'collection', args ) ~= '' then
			args.type = 'collection'
		elseif cu.getArgValue( ci.params, 'journal', args ) ~= '' then
			args.type = 'journal'
		elseif cu.getArgValue( ci.params, 'newspaper', args ) ~= '' then
			args.type = 'newspaper'
		elseif cu.getArgValue( ci.params, 'website', args ) ~= '' then
			args.type = 'web'
		else
			args.type = 'book'
		end
	end
	return makeCitation( args )
end

return ct