Aller au contenu

Module:Cite archive

Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 21 décembre 2017 à 09:22 et modifiée en dernier par Od1n (discuter | contributions) (inlinage test résultat Module:Biblio/Commun.indicationDeLangue() ; normalement empty string si pas de résultat, mais par sécurité on va aussi tester falsy (nil)). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.

 Documentation[voir] [modifier] [historique] [purger]

Utilisation

Fonctions exportables :

  • cite_archive(args) – affiche les références d'une source se trouvant dans un fonds d’archives. Voir {{Modèle:Cite archive}}.

Modules externes et autres éléments dont ce module a besoin pour fonctionner :

Exemples

Pour des exemples, voir {{Modèle:Cite archive}}.

local Cite_archive = { }

local Commun = require( 'Module:Biblio/Commun' )
local References = require( 'Module:Biblio/Références' )
local Outils = require( 'Module:Outils' )
local TableBuilder = require( 'Module:TableBuilder' )
local Langue = require( 'Module:Langue' )


Cite_archive.cite_archive = function ( frame )
	local args = Outils.extractArgs( frame )

	-- La table wiki va recevoir tout les petits bouts de texte, et sera concaténtée à la fin.
	-- Elle utilise la meta-table de TableBuilder, permettant d'utiliser les fonctions de la 
	-- librairy table comme des méthodes. minsert permet d'insérer plusieurs élément en une 
	-- seule fois en, ignorant les paramètre nil.
	local wiki = TableBuilder.new()
	
	-- validArg renvoie le premier paramètre non vide, ou nil s'ils sont tous vides.
	-- Seul les noms des paramètres doivent être transmis à la fonction.
	local validArg = function ( ... ) return Commun.validTextArg( args, ... ) or false end
	
	-- table servant à la catégorisation
	args.categ = {}
	
	-- paramètres valides, avec au minimum institution et fonds ou collection
	args.principal = validArg( 'pièce' , 'item', 'dossier' , 'file' , 'sous-série' , 'série' , 'sous-fonds' , 'fonds' , 'collection' , 'section' )
	args.est_item = validArg( 'pièce', 'item' , 'dossier' , 'file' )
	local institution = validArg( 'institution' )
	-- test existence des parametres obligatoires
	if institution and args.principal and validArg( 'fonds', 'collection' ) then
		-- initialisation de tous les libellés
		local section = validArg( 'section' )
		local collection = validArg( 'collection' )
		local fonds = validArg( 'fonds' )
		local sous_fonds = validArg( 'sous-fonds' )
		local serie = validArg( 'série' , 'series' )
		local sous_serie = validArg( 'sous-série' )
		local dossier = validArg( 'dossier' , 'file' )
		local box = validArg( 'boîte' , 'box' )
		local piece = validArg( 'pièce' , 'item' )
		local date = validArg( 'date', 'dates' )
		local type = validArg( 'support' , 'type' )
		local importance = validArg( 'importance' )
		local cote = validArg( 'cote' , 'item-id' )
		local isil = validArg( 'isil' )
		local lieu = validArg( 'ville', 'situation', 'location' )
		local repository = validArg( 'dépôt', 'repository' )
		if args.est_item then args['format électronique'] = args.format end
		args.format = false
		
		-- niveau soit level
		local intitule_plan_level = nul
		if section    then intitule_plan_level = 1 end
		if collection then intitule_plan_level = 3 end
		if fonds      then intitule_plan_level = 5 end
		if sous_fonds then intitule_plan_level = 6 end
		if serie      then intitule_plan_level = 7 end
		if sous_serie then intitule_plan_level = 8 end
		if dossier    then intitule_plan_level = 9 end
		if piece      then intitule_plan_level = 12 end
		
		-- teste intitulé contenant son propre label
		local position_col = nul
		if collection then position_col = string.find(collection,"Collection") end
		local position_fds = nul
		if fonds then position_fds = string.find(fonds,"Fonds") end
		if not position_fds and fonds then position_fds = string.find(fonds,"Fund") end
				
		-- span initial (id) et libellé
		local spanInitial, spanFinal = Commun.spanInitial ( args, validArg )
		wiki.minsert( spanInitial,  Commun.libelle( args ) )
			
		-- indication de langue
		local indicLangue, codeLangue = Commun.indicationDeLangue ( args, validArg )
		if indicLangue and indicLangue ~= '' then
			wiki.minsert( indicLangue, ' ' )
		end

		-- intitulé principal
		if args.est_item then
			-- objet d'archives de type dossier ou pièce
			-- liste des auteurs et de leur responsabilités (principale et secondaire)
			local auteur = validArg( 'nom1', 'nom', 'auteur1', 'auteur', 'auteurs', 'auteur institutionnel', 'last1', 'last', 'author1', 'author' )
			if auteur then
				if validArg( 'auteurs' ) then
					wiki.minsert( args.auteurs )
				else
					 wiki.minsert( Commun.responsabilitePrincipale( args, validArg ) )
				end
				wiki.minsert( Commun.responsabiliteSecondaire( args, validArg ), ', ' )
				args.categ.auteur = validArg( 'auteur', 'auteurs', 'author1', 'author', 1, 2, 3, 4 )
				args.categ.coauteur = validArg( 'coauteurs', 'coauteur', 'coauthors' )
			end
			-- langue
			if codeLangue then
				local dir = Langue.directionLangue( codeLangue )
				if dir == 'rtl' then dir = '" dir="rtl'
				else dir = nil
				end
				wiki.minsert( '<span lang="', codeLangue, dir, '">')
			end
			-- intitulé dossier ou pièce
			wiki.minsert( '« <cite style="font-style:normal;">', args.principal , '</cite> »', codeLangue and '</span>' )
		elseif validArg( 'collection' , 'section' , 'fonds' , 'sous-fonds' , 'série' , 'sous-série' ) then
			-- intitulé collection ou section ou fonds, sous-fonds, série ou sous-série
			if sous_serie then
				wiki.minsert( 'Sous-série : ', args.principal )
			elseif serie then
				wiki.minsert( 'Série : ', args.principal )
			elseif sous_fonds then
				wiki.minsert( 'Sous-fonds : ', args.principal )
			elseif fonds then
				if position_fds then wiki.minsert( args.principal ) else wiki.minsert( 'Fonds : ', args.principal ) end
			elseif collection then
				if position_col then wiki.minsert( args.principal ) else wiki.minsert( 'Collection : ', args.principal ) end
			elseif section then
				wiki.minsert( 'Section : ', args.principal )
			end
		end
		
		-- dates=date de l'objet d'archives
		if date then
			wiki.minsert( ' (', date , ')')
		end
		-- support=type et importance de l'objet d'archives
		if type or importance then
			if     type and not importance then wiki.minsert( ' [', type , ']' )
			elseif not type and importance then wiki.minsert( ' [', importance , ']' )
			else    wiki.minsert( ' [', type , ' ; ' , importance , ']' )
			end
		end
		-- fin de l'intitulé principal
		wiki.minsert( '. ')
		
		-- contexte de plan d'archivage
		local intitule_plan_start = nul
		if args.est_item or sous_fonds or fonds or collection then
			if section then
				wiki.minsert( 'Section : ', section )
				intitule_plan_start = 1
			end
		end
		if args.est_item then
			if section and not intitule_plan_start then
				wiki.minsert( 'Section : ', section )
				intitule_plan_start = 1
			end
			if collection then
				-- collection = Commun.fusionTexteLien( collection, args['collection-url'], args.categ )
				if intitule_plan_start then	
					if position_col then wiki.minsert( '; ', collection ) else wiki.minsert( '; Collection : ', collection ) end
				else
					if position_col then wiki.minsert( collection ) else wiki.minsert( 'Collection : ', collection ) end
				end
				intitule_plan_start = 3
			end
			if fonds then
				if intitule_plan_start then	
					if position_fds then wiki.minsert( '; ' , fonds ) else wiki.minsert( '; Fonds : ', fonds ) end
				else
					-- fonds = Commun.fusionTexteLien( fonds, args['collection-url'], args.categ )
					if position_fds then wiki.minsert( fonds ) else wiki.minsert( 'Fonds : ', fonds ) end
				end
				intitule_plan_start = 5
			end
		elseif collection and fonds then  -- 'fonds' déjà mentionné comme intitulé principal
			collection = Commun.fusionTexteLien( collection, args['collection-url'], args.categ )
			if intitule_plan_start then
				if position_col then wiki.minsert( '; ', collection ) else wiki.minsert( '; Collection : ', collection ) end
			else
				if position_col then wiki.minsert( collection ) else wiki.minsert( 'Collection : ', collection ) end
			end
			intitule_plan_start = 3
		elseif fonds and intitule_plan_level >= 6  and not args.est_item then   -- présence d'un sous-fonds
			-- fonds = Commun.fusionTexteLien( fonds, args['collection-url'], args.categ )
			if intitule_plan_start then	
				if position_fds then wiki.minsert( '; ' , fonds ) else wiki.minsert( '; Fonds : ', fonds ) end
			else
				if position_fds then wiki.minsert( fonds ) else wiki.minsert( 'Fonds : ', fonds ) end
			end
			intitule_plan_start = 5
		end
		if sous_fonds and intitule_plan_level > 6 then
			if intitule_plan_start then
				wiki.minsert( '; Sous-fonds : ', sous_fonds )
			else
				wiki.minsert( 'Sous-fonds : ', sous_fonds )
			end
			intitule_plan_start = 6
		end
		if serie and intitule_plan_level > 7 then
			if intitule_plan_start then
				wiki.minsert( '; Série : ', serie )
			else
				wiki.minsert( 'Série : ', serie )
			end
			intitule_plan_start = 7
		end
		if sous_serie and intitule_plan_level > 8 then
			if intitule_plan_start then
				wiki.minsert( '; Sous-série : ', sous_serie )
			else
				wiki.minsert( 'Sous-série : ', sous_serie )
			end
			intitule_plan_start = 8
		end
		if dossier and intitule_plan_level > 9 then
			if intitule_plan_start then
				wiki.minsert( '; Dossier : ', dossier )
			else
				wiki.minsert( 'Dossier : ', dossier )
			end
			intitule_plan_start = 9
		end
		if box then
			if intitule_plan_start then
				wiki.minsert( '; Boîte : ', box )
			end
			intitule_plan_start = 11
		end
		-- Cote, identifiant unique
		if cote then
			if intitule_plan_start then
				wiki.minsert( '; ' )
			else
				wiki.minsert( ' ' )
			end
			if isil then
				-- cote universelle = identifiant ISIL de l'institution + cote interne
				wiki.minsert( 'Cote : <small>[[ISO 15511|', isil , ']]</small> ' , cote )
			else
				wiki.minsert( 'Cote : ', cote )
			end
		end
		
		-- ville : dépôt, institution
		if lieu or repository or institution then
			if intitule_plan_start or cote then
				wiki.minsert( '. ' )
			end
			if lieu then
				wiki.minsert( '', lieu )
				if repository or institution then wiki.minsert( ' : ' ) end
			end
			if repository then
				wiki.minsert( '', repository )
				if institution then wiki.minsert( ', ' ) end
			end
			if institution then
				wiki.minsert( '', institution )
			end
			-- fin institution
			wiki.minsert( '.' )
		end
		
		-- lien vers l'article en ligne (isbn, issn, pmid, doi, lire en ligne, résumé...)
		wiki.minsert( References.affichageLiensExternes( args, validArg, true, false ) )
		-- "consulté le" n'est pas affiché, voir [[Discussion_modèle:Ouvrage/Archive_5#.C3.89volution_documentation]]

--[[----- A VOIR, PARAMETRE 'page' NON IMPLEMENTE	
		  -- pages
		local page =  validArg( 'passage', 'pages', 'page', 'p.', 'pp.' )
		if page then
			if string.match ( page, '^[%dIVXL]' ) then
				wiki.minsert( ', ', Commun.page, page )
			else
				wiki.minsert( ', ', page )
			end
		end	
]]	
--[[--------	A VOIR, LIGNES COPIEES DE Module:Biblio/Article
		local patternPonct = '[,.;:!?]$'
		local ponctuation = wiki.concat():gsub( '%b<>', '' ):match( patternPonct )
	
		-- ajout des méthadonnées COinS (ContextObjects in Spans)
		wiki.minsert( Commun.COinS( args, validArg, 'article' ) )
]]
		-- fin du span (id) et de la description de l'ouvrage
		wiki.minsert( spanFinal )

		-- commentaire
		wiki.minsert( Commun.commentaire( args ) )

		-- ajout de catégories cachées
		if mw.title.getCurrentTitle().namespace == 0 then
			wiki.minsert(
				args.categ.coauteur and '[[Catégorie:Recension temporaire pour le modèle Cite archive|coauteur]]',
				args.categ.langue  and '[[Catégorie:Page du modèle Cite archive comportant une erreur|langue]]',
				args.categ.date and '[[Catégorie:Page du modèle Cite archive comportant une erreur|date]]',
				args.categ.lienExterne and '[[Catégorie:Page du modèle Cite archive comportant une erreur|externe]]'
			)
			if codeLangue then
				if Langue.directionLangue( codeLangue ) == 'rtl' then
					wiki.minsert( '[[Catégorie:Recension temporaire pour le modèle Cite archive|rtl]]' )
				end
			end
		end
	
else
	-- ERREURS
		if not args.principal then
			wiki.minsert( Outils.erreur( '[[Modèle:Cite archive|{{Cite archive}}]] : paramètre « <code>fonds</code> » ou « <code>collection</code> » manquant' ) )
		end
		if not institution then
			wiki.minsert( Outils.erreur( '[[Modèle:Cite archive|{{Cite archive}}]] : paramètre « <code>institution</code> » manquant' ) )
		end
	end
	return wiki.concat()
end

return Cite_archive

--[[
HISTORY OF CHANGES = HISTORIQUE DES MODIFICATIONS

18 mai 2017		sur la base de w:en:Module:Cite archive, ajouts des paramètres en français, p.e. args.series = pframe.args.series or pframe.args['série']
				modification des séparateurs ',' remplacé par ';' entre les niveaux de description 
19 mai 2017		ajout du nouveau paramètre 'language'='langue' et traitement comme pour le modèle Ouvrage (inclusion de Module:Biblio/Commun et Module:Outils) - OK
                choix concernant les url : 
                	* 'item-url'='url'='présentation en ligne', à afficher en fin de ligne (comme pour Ouvrage)   -   21.5.2017 OK
                	* NEW 'lire en ligne'='url texte'='texte', à afficher en fin de ligne (comme pour Ouvrage)   -   21.5.2017 OK
                	* 'collection-url' est conservé, concerne la notice descriptive du fonds soit collection (ajout ='fonds-url'), 
                	  le lien est placé sur le texte de la collection si elle existe, sinon du fonds   -   21.5.2017 NON OK
				choix concernant le paramètre 'collection' :      -   21.5.2017 OK
					* remplacé en français par 'fonds'
					* mais comme les deux peuvent exister et être distincts :
						* si 'intitulé' est non vide, alors : "« intitulé » (dates). Collection, Fonds, ISIL-Cote. Lieu : Institution"
						* si 'intitulé' est vide, alors : "Collection (dates). Fonds, ISIL-Cote. Lieu : Institution" 
					* si 'collection' est vide :
						* si 'intitulé' est vide : "Fonds (dates). ISIL-Cote. Lieu : Institution"   (CAS STANDARD REFERENCE FONDS)
						* si 'intitulé' est non vide , alors : "« intitulé » (dates). Fonds, ISIL-Cote. Lieu : Institution"  (CAS STANDARD REFERENCE DOSSIER/PIECE)
					* si 'fonds' est vide (référence traduite de l'anglais), alors : "Collection (dates). ISIL-Cote. Lieu : Institution"
				choix concernant la 'cote' :     -   21.5.2017 OK
					* elle est mentionnée sous la forme "Cote : [cote]"
					* si ISIL (NEW paramètre 'isil') est renseigné: "ISIL Cote : [isil] [cote]"
20 mai 2017		TOUT REPRIS sur une autre base : plus tôt que de copier le contenu du module en anglais, copie d'un exemple en français (Module:Biblio/Article) et adaptation
21 mai 2017		ajout progressif des divers paramètres
1 juin 2017		renonce à 'intitulé' (remplace par 'dossier' ou 'pièce')
2 juin 2017		présentation, révision, nettoyages
8 juin 2017     non affichage du titre "Collection" si le paramètre contient ce même mot, idem avec "Fonds"
                traitement du nouveau paramètre "sous-série"
                traitement du nouveau paramètre "sous-fonds"
--]]