« Module:Version imprimable » : différence entre les versions

Contenu supprimé Contenu ajouté
mAucun résumé des modifications
Aucun résumé des modifications
Ligne 133 :
end
return chapter
end
 
 
function p.displays_footer(frame)
-- ébauche
if frame == nil then return '' end
if frame.args == nil then return '' end
if frame.args[1] == nil then return '' end
local BookName = frame.args[1]
if (BookName ~= nil and mw.text.trim(BookName) ~= '') then
title = mw.title.new(BookName)
if frame.args[2] ~= nil and frame.args[2] ~= '' then
BookName = frame.args[2]
else
if mw.ustring.find(BookName, sep .. TOC) ~= nil then BookName = mw.ustring.gsub(BookName, "^(.*)" .. sep .. TOC .. "$", "%1") end
end
if frame.args[3] ~= nil then OnlySubpages = false end
else
return Error
end
if (title == nil or title == '') then return Error end
text = title.getContent(title)
if (text == nil or text == '') then return Error end
 
-- Book subpages titles normalization to absolute names
local lines_ = mw.text.split(text, "\n")
local footer = {}
local previousChapter = '../'
local found = false
local chapter
 
for i,v in ipairs(lines_) do
chapter = p.subpage(BookName, v)
if chapter ~= nil then
ChapterTitle = mw.title.new(chapter)
if (ChapterTitle ~= nil and ChapterTitle.exists) then
PageName = mw.ustring.gsub(chapter, "[^"..sep.."]*"..sep.."*(.*)", "%1")
if (PageName ~= nil and PageName ~= '') then
if found == true then
table.insert(footer, previousChapter)
table.insert(footer, PageName)
break
elseif mw.text.trim(v) ~= currentPage then
found = true
elseif mw.text.trim(v) ~= '' then
previousChapter = p.subpage(BookName, v)
end
end
end
end
end
 
return table.concat(footer, "|")
end