Ir para o conteúdo

Módulo:Citation

De Wiki TokuDrive
Revisão de 05h42min de 4 de outubro de 2026 por Tavoraadmin (discussão | contribs) (Importando predefinição/módulo da Wikipédia em português para manter layout)
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)

local c = require('Módulo:Citação/CS1')

--[[--------------------------< c . c i t a t i o n >------------------------------------

Este é o método principal da predefinição {{#invoke:Citation|citation}}.

]]

c.citation = function(frame)

   local config, args, A = tratarArgumentos(frame)
   config.CitationClass = 
   config.usaVolume = true
   config.usaIssue = true
   config.TituloDispensavel = true
   local B
   local classe = 'citation'
   A.Mode = A.Mode:lower()
   if not is_set(A.Mode) or (A.Mode ~= 'mla' and A.Mode ~= 'cs1') then
       A.Mode = 'cs2'
   end
   local coins_chapter
   local coins_title
   if not is_set(A.Periodical) then
       config.usaContributor = true
       if not is_set(A.Title) and is_set(A.Chapter) then
           coins_chapter = A.Chapter
           coins_title = A.Title
           A.Title = A.Chapter
           A.Chapter = ""
           
           local TransTitle = A.TransTitle
           local Title = A.Title
       	if is_set(A.TitleLink) and is_set(A.Title) then
           	Title = "" .. Title .. ""
           end
           config.TituloFormatado = {}
           if (is_set(Title)) then
           	Title = kern_quotes (Title)

Title = wrap_style ('quoted-title', Title) config.TituloFormatado.Title = Title

           end
           if (is_set(TransTitle)) then
       	    TransTitle= wrap_style ('trans-quoted-title', TransTitle ) -- .. ", "

config.TituloFormatado.TransTitle = TransTitle

           end
       end
   elseif not is_set (A.Encyclopedia) then
       config.ChapterNaoSuportado = true
       local chap_param
       -- pega o nome do parâmetro de um destes peta-parâmetros relacionados a "chapter"
       if is_set (A.Chapter) then
           chap_param = A:ORIGIN ('Chapter')
       elseif is_set (A.TransChapter) then
           chap_param = A:ORIGIN ('TransChapter')
       elseif is_set (A.ChapterURL) then
           chap_param = A:ORIGIN ('ChapterURL')
       elseif is_set (A.ScriptChapter) then
           chap_param = A:ORIGIN ('ScriptChapter')
       else is_set (A.ChapterFormat)
           chap_param = A:ORIGIN ('ChapterFormat')
       end
       -- se foi encontrado algum...
       if is_set(chap_param) then
           -- ... adiciona mensagem de erro
           table.insert(z.message_tail, { set_error('chapter_ignored', {chap_param}, true)})
           -- e esvazia para evitar problemas com concatenações
           A.Chapter = 
           A.TransChapter = ;
           A.ChapterURL = ;
           A.ScriptChapter = ;
           A.ChapterFormat = ;
       end
       local TransTitle = A.TransTitle
       local Title = A.Title
   	if is_set(A.TitleLink) and is_set(A.Title) then
       	Title = "" .. Title .. ""
       end
       config.TituloFormatado = {}
       if (is_set(Title)) then
           Title = kern_quotes (Title)
           Title = wrap_style ('quoted-title', Title)
           config.TituloFormatado.Title = Title
       end
       if (is_set(TransTitle)) then
           TransTitle= wrap_style ('trans-quoted-title', TransTitle ) -- .. ", "
           config.TituloFormatado.TransTitle = TransTitle
       end
   else
       if is_set(A.Title) or is_set (A.ScriptTitle) then
           if not is_set(A.Chapter) then
   -- |encyclopedia e |title definidos, mapeia |title para |article e |encyclopedia para |title
               A.Chapter = A.Title
               A.ScriptChapter = A.ScriptTitle
               A.TransChapter = A.TransTitle
               A.ChapterURL = A.URL
               if not is_set (A.ChapterURL) and is_set (A.TitleLink) then
                   A.Chapter= '' .. A.Chapter .. ''
               end
               A.Title = A.Periodical
               A.ChapterFormat = A.Format
               A.Periodical =  -- redundante
               A.TransTitle = 
               A.URL = 
               A.Format = 
               A.TitleLink = 
               A.ScriptTitle = 
           elseif is_set(A.Title) then
               coins_chapter =  A.Title -- remapeia
               coins_title = A.Periodical
           end
       else -- |title não definido
           A.Title = A.Periodical -- mapeia |encyclopedia (alias) ao título
           A.Periodical =  -- redundante
       end
   end
   coins_chapter = make_coins_title (coins_chapter or A.Chapter, A.ScriptChapter)
   coins_title = make_coins_title (coins_title or A.Title, A.ScriptTitle)


   local sepc = set_style (A.Mode:lower())
   local use_lowercase = sepc == ','
   local page, pages = , 
   if in_array(A:ORIGIN('Periodical'), {'periódico', 'periodico', 'jornal', 'journal'}) then
       -- mla sempre usa os prefixos p ou pp
       if A.Mode:lower() ~= 'mla' then
           if is_set(A.Page) then
               page = substitute(cfg.messages['j-page(s)'], A.Page)
           elseif is_set(A.Pages) then
               page = substitute (cfg.messages['j-page(s)'], A.Pages)
           end
       else
           page, pages = format_pages (A.Page, A.Pages, sepc, A.NoPP, use_lowercase)
       end
   else
       page, pages = format_pages (A.Page, A.Pages, sepc, A.NoPP, use_lowercase)
   end


   local volume = A.Volume
   if in_array(A:ORIGIN('Periodical'), {'revista', 'magazine'}) then
       if is_set (volume) and is_set (A.Issue) then
           volume = wrap_msg ('vol-no', {sepc, volume, A.Issue}, use_lowercase);
       elseif is_set (volume) then
           volume = wrap_msg ('vol', {sepc, volume}, use_lowercase);
       elseif is_set (A.Issue) then
           volume = wrap_msg ('issue', {sepc, A.Issue}, use_lowercase);
       else
           volume = 
       end
   else
       volume = format_volume_issue (A.Volume, A.Issue, sepc)
   end
   local isbn, argIsbn = {ISBN = select_one(args, cfg.id_handlers.ISBN.parameters
       , 'redundant_parameters')}
   local issn, argIssn = {ISSN = select_one(args, cfg.id_handlers.ISSN.parameters
       , 'redundant_parameters')}
   coins_isbn = isbn.ISBN
   coins_issn = issn.ISSN
   isbn = build_id_list(isbn, {IdAccessLevels = extract_id_access_levels({argIsbn}
       , isbn), IgnoreISBN = A.IgnoreISBN})[1]
   issn = build_id_list(issn, {IdAccessLevels = extract_id_access_levels({argIssn}
       , issn)})[1]
   cfg.id_handlers.ISBN.parameters = {}
   cfg.id_handlers.ISSN.parameters = {}
   -- Função com o código abstraído
   A, B = citation0( config, args, A)
   if is_set(isbn) then
       A.Title = A.Title .. sepc .. ' ' .. isbn
       B.coins_table.ID_list.ISBN = coins_isbn
   end
   if is_set(issn) then
       A.Periodical = A.Periodical .. sepc .. ' ' .. issn
       B.coins_table.ID_list.ISSN = coins_issn
   end
   B.coins_table.Chapter = coins_chapter
   B.coins_table.Title = coins_title
   A.Page = page
   A.Pages = pages
   A.Volume = volume;
   if is_set(A.Periodical) then
       if is_set(A.Others) then
           A.Others = A.Others .. B.sepc .. " "
       end
       if 'mla' == A.Mode then
           B.tcommon = safe_join( {A.Periodical, A.Format, A.TitleType, A.Series, A.Language, A.Edition, B.Publisher, A.Agency, A.Volume}, B.sepc )
       else
           B.tcommon = safe_join( {A.Others, A.Title, A.TitleNote, A.Edition, B.Publisher, A.Periodical, A.Format, A.TitleType, A.Series,
               A.Language, A.Agency, A.Volume}, B.sepc )
       end
   else
       if is_set (B.Contributors) then -- quando citado prefácio, introdução, etc.
           -- autor e outros virão depois disto e antes de tcommon2
           B.tcommon = safe_join( {A.Title, A.TitleNote}, B.sepc )
           if 'mla' == A.Mode then
               B.tcommon2 = safe_join( {A.Periodical, A.Format, A.TitleType, A.Edition, B.Publisher, A.Series, A.Language, A.Volume, A.Agency}, B.sepc );
           else
               B.tcommon2 = safe_join( {A.Periodical, A.Format, A.TitleType, A.Edition, B.Publisher, A.Series, A.Language, A.Volume, A.Others, A.Agency}, B.sepc );
           end
       elseif 'mla' == A.Mode then
           B.tcommon = safe_join( {A.TitleNote, A.Periodical, A.Format, A.TitleType, A.Series, A.Language, A.Volume, B.Publisher, A.Agency}, B.sepc );
       else
           B.tcommon = safe_join( {A.Title, A.TitleNote, A.Periodical, A.Format, A.TitleType, A.Series, A.Language, A.Volume, A.Others, A.Edition, B.Publisher, A.Agency}, B.sepc );
       end
   end
   config.CitationClass = classe
   B.config = config
   return textoFinal(A, B)

end

return c