Module:Biblio/Commun

De Lagny-sur-Marne Wiki
Aller à la navigation Aller à la recherche

-- Les fonctions du module Util sont des éléments nécessaire au modules Ouvrage, Article, ...

local Commun = {}


local Date = require( 'Module:Date' ) local Outils = require( 'Module:Outils' ) local TableBuilder = require( 'Module:TableBuilder' ) local Langue -- = require( 'Module:Langue' ) ne sera chargé que si nécessaire

local validTextArg = Outils.validTextArg local abr = Outils.abr -- fonction abréviation discréte

-- extractArgs permet de récupérer les arguement du modèle, -- ou la table transmise à la fonction par une autre fonction d'un module local extractArgs = Outils.extractArgs


-- Abréviation utiles Commun.chap = abr{ 'chap.', 'chapitre(s)', nbsp='+' } Commun.coll = abr{ 'coll.', 'collection', nbsp='+' } Commun.ed = abr{ 'éd.', 'édition', nbsp='-' } Commun.nbp = abr{ 'p.', 'pages', nbsp='-' } Commun.numero = abr{ 'no', 'numéro', nbsp='+' } Commun.page = abr{ 'p.', 'page(s)', nbsp='+' } Commun.plume = [=[ Ouvrage utilisé pour la rédaction de l'article]=] Commun.premiere = abr{ '1re', 'première' } Commun.reimpr = abr{ 'réimpr.', 'réimpression', nbsp='+' } Commun.tome = abr{ 't.', 'tome', nbsp='+' } Commun.vol = abr{ 'vol.', 'volume', nbsp='+' }


function Commun.detailEdition( ref ) return '[détail de l’édition]' end

function Commun.detailEditions( ref ) return '[détail des éditions]' end


-- affiche le texte en nombre romain majuscule. function Commun.romain( texte )

   local a = ''
   local b = ''
   return a, texte, b

end


-- voir Modèle:Module biblio/span initial function Commun.spanInitial( args, validArg ) validArg = validArg or function ( ... ) return validTextArg( args, ... ) end local idTab = { validArg( 'id' ) }

if #idTab == 0 then local auteur = validArg( 'nom1', 'nom', 'auteur1', 'auteur', 'last1', 'last', 'author1', 'author' ) if auteur then table.insert( idTab, mw.uri.anchorEncode( auteur ) ) for i = 2, 4 do auteur = validArg( 'nom' .. i, 'auteur' .. i, 'last' .. i, 'author' .. i ) if auteur then table.insert( idTab, mw.uri.anchorEncode( auteur ) ) else break end end end local annee = validArg( 'année', 'year' ) if annee then table.insert( idTab, mw.uri.anchorEncode( annee ) ) end end

local id if #idTab > 0 then table.insert( idTab, 1, ' id="' ) table.insert( idTab, '"' ) id = table.concat( idTab ) end

return '' end

-- voir Modèle:Module biblio/libellé function Commun.libelle( args ) local lib = args['libellé'] or if lib ~= then lib = '[', lib, '] ' end return lib end

-- voir Modèle:Commentaire biblio function Commun.commentaire( args ) if Outils.trim( args.commentaire ) then

local a = '

' local b = '

'

return a, args.commentaire, b end return end

-- voir Modèle:Module biblio/indication de langue function Commun.indicationDeLangue( args, validArg ) local lang = validArg( 'langue', 'lang', 'lien langue', 'language' ) if lang then Langue = require( 'Module:Langue' ) local codeLangue = Langue.codeLangue2( lang ) if codeLangue == then return , nil, true elseif codeLangue ~= 'fr' then return Langue.indicationDeLangue{ , codeLangue }, codeLangue end end return end


-- voir Modèle:Module biblio/responsabilité principale function Commun.responsabilitePrincipale( args, validArg, autolien ) validArg = validArg or function ( ... ) return validTextArg( args, ... ) end

local nom = validArg( 'nom1', 'nom', 'auteur1', 'auteur', 'last1', 'last', 'author1', 'author' ) if nom == nil then return end

-- préparation des variables local listeRresponsables = { } -- contiendra un élément pour chaque nom local directeur = abr { 'dir.', 'directeur de publication' } autolien = autolien or not validArg( 'nolien' ) local prenom, dir, responsable, lien , precision, resp local i = 1

-- boucle sur chaque nom, assemble toutes les caractéristique et ajoute l'ensemble à la liste. while nom do if i == 1 then prenom = validArg( 'prénom1', 'prénom', 'first1', 'first' ) dir = validArg( 'directeur1', 'directeur' ) lien = validArg( 'lien auteur1', 'lien auteur', 'authorlink' ) or ( autolien and validArg( 'nom' ) and ( ( args['prénom'] or ) .. ' ' .. args.nom ) ) else prenom = validArg( 'prénom' .. i, 'first' .. i ) dir = validArg( 'directeur' .. i ) lien = validArg( 'lien auteur' .. i ) end if prenom then prenom = prenom .. ' ' else prenom = end

resp = args['responsabilité' .. i] if dir then if resp then precision = ' (' .. directeur .. ' et ' .. resp .. ')' else precision = ' (' .. directeur .. ')' end elseif resp then precision = ' (' .. resp .. ')' else precision = end

if lien then responsable = '' .. prenom .. nom .. '' .. precision else responsable = prenom .. nom .. precision end

table.insert( listeRresponsables, responsable )

i = i + 1 nom = validArg( 'nom' .. i, 'last' .. i, 'auteur' .. i, 'author' .. i ) end

if validArg( 'et al.', 'et alii' ) then local et_al = " " .. abr { "et al.", "et alii (et d’autres)" } .. "" return table.concat( listeRresponsables, ', ' ) .. et_al else return mw.text.listToText( listeRresponsables ) end end


-- voir Module biblio/responsabilité secondaire function Commun.responsabiliteSecondaire( args, validArg ) validArg = validArg or function ( ... ) return validTextArg( args, ... ) end local liste = { }

-- fonction qui teste l'existence d'un paramètre et insérere dans liste une abréviation discrète suivi de ce paramètre local function insertAbr( arg, abrev, texte ) if arg then table.insert( liste, abr{ abrev, texte, nbsp='+' } .. arg ) end end

-- ajout des différents responsables local trad = validArg( 'traducteur', 'trad', 'traduction' ) insertAbr( trad, 'trad.', 'traduction' ) insertAbr( validArg( 'préface' ), 'préf.', 'préface' ) insertAbr( validArg( 'postface' ), 'post.', 'postface' ) insertAbr( validArg( 'illustrateur' ), 'ill.', 'illustrations' ) insertAbr( validArg( 'photographe' ), 'photogr.', 'photographies' ) if validArg( 'champ libre' ) then table.insert( liste, args['champ libre'] ) end

-- concaténation de l'ensemble local texte = table.concat( liste, ', ') if texte ~= then return ' (' .. texte .. ')' else return end end

-- émule le modèle:Inscription date Commun.inscriptionDate = Date.inscriptionDate


-- voir Modèle:COinS bibliographique -- NISO Z39.88 -- http://www.openurl.info/registry function Commun.COinS( args, validArg, genre ) validArg = validArg or function ( ... ) return validTextArg( args, ... ) end if validArg( 'COinS', 'coins', 'COins' ) == 'non' then return '' -- retour systématique d'un span qui pourra donc être systématiquement fermé. end

local liste = { }

-- la fonction insert liste ajoute à la table 'liste' un couple 'nom Coins normalisé' - 'donnée' -- Si istexte = true, le deuxième élément de tab est considéré comme du texte, -- sinon comme le nom d'un paramètre. local function insertList( key, value, prefix ) prefix = prefix or if type( value ) == 'string' and value ~= then table.insert( liste, key .. '=' .. mw.uri.encode( prefix .. value ) ) end end

-- norme du COinS insertList( 'ctx_ver', 'Z39.88-2004' )

-- genre, titre et sous-titre if genre == 'article' then insertList( 'rft_val_fmt', 'info:ofi/fmt:kev:mtx:journal' ) insertList( 'rft.genre', 'article' ) insertList( 'rft.atitle', Outils.texteLien( args.titre ) ) insertList( 'rft.jtitle', Outils.texteLien( validArg( 'périodique', 'revue', 'journal' ) ) ) insertList( 'rft.issue', validArg( 'numéro', 'no', 'issue' ) ) else -- genre = ouvrage ou chaitre insertList( 'rft_val_fmt','info:ofi/fmt:kev:mtx:book' ) if genre == 'chapitre' then insertList( 'rft.genre', 'bookitem' ) else insertList( 'rft.genre', 'book' ) end insertList( 'rft.btitle', Outils.texteLien( args.titre ) ) insertList( 'rft.atitle', Outils.texteLien( validArg( 'titre chapitre', 'titreChap' ) ) )

-- donnée sur l'éditeur insertList( 'rft.place', validArg( 'lieu' ) ) insertList( 'rft.pub', Outils.texteLien( validArg( 'éditeur', 'édition' ) ) ) insertList( 'rft.edition', args["numéro d'édition"] ) end insertList( 'rft.stitle', args['sous-titre'] )

-- Premier auteur, séparé en noms et prénoms local nom = Outils.texteLien( validArg( 'nom1', 'nom', 'last1', 'last' ) ) if nom then insertList( 'rft.aulast', nom ) insertList( 'rft.aufirst', validArg( 'prénom1', 'prénom', 'first1', 'first' ) ) else local auteur = Outils.texteLien( validArg( 'auteur', 'auteur1' ) ) if auteur then -- séparation de auteurs au niveau des deux premiers espaces local a1, a2, a3 = mw.ustring.match( auteur, '^([^ ]+) ?([^ ]*) ?(.-)$' ) if Outils.notEmpty( a3 ) then if mw.ustring.len( a2 ) == 2 and mw.ustring.sub( a2, -1 ) == "." then -- a1 est le prénom, a2 et a3 le nom insertList( 'rft.aufirst', a1 .. ' ' .. a2 ) insertList( 'rft.aulast', a3 ) else -- a1 le prénom, a2 l'initiale du deuxième prénom ou du nom maternel (US) insertList( 'rft.aufirst', a1 ) insertList( 'rft.aulast', a2 .. ' ' .. a3 ) end elseif Outils.notEmpty( a2 ) then -- a1 prénom, a2 nom insertList( 'rft.aufirst', a1 ) insertList( 'rft.aulast', a2 ) else insertList( 'rft.aulast', a1 ) end end end

-- les autres auteurs, la norme ne prévoi pas de séparation. for i = 2, 20 do local nom_i = Outils.texteLien( validArg( 'nom' .. i ) ) if nom_i then local prenom_i = validArg( 'prénom' .. i ) if prenom_i then insertList( 'rft.au', nom_i .. ', ' .. prenom_i ) else insertList( 'rft.au', nom_i ) end else local auteur_i = Outils.texteLien( validArg( 'auteur' .. i ) ) if auteur_i then insertList( 'rft.au', auteur_i ) else break end end end

-- date local datePub = Date.dateISO( args ) if datePub then insertList( 'rft.date', datePub ) else insertList( 'rft.date', args.date ) end

-- doonées physique de la publication insertList( 'rft.volume', validArg( 'volume', 'vol' ) ) insertList( 'rft.pages', validArg( 'passage', 'page' ) ) insertList( 'rft.spage', args['page début chapitre'] ) insertList( 'rft.tpages', args['pages totales'] )


-- références internationales insertList( 'rft.isbn', args.isbn ) insertList( 'rft.issn', args.issn ) insertList( 'rft_id', args.doi, 'info:doi/' ) insertList( 'rft_id', args.pmid, 'info:pmid/' ) insertList( 'rft_id', args.oclc, 'info:oclcnum/' ) insertList( 'rft_id', args.url )

-- referer : page Wikipedia ou se trouve cette référence insertList( 'rfr_id', 'fr.wikipedia.org:' .. mw.title.getCurrentTitle().fullText, 'info:sid/' )

return '' end

return Commun