Différences entre les versions de « Module:Présentation »
Aller à la navigation
Aller à la recherche
(valeurs de retour par défaut) |
(bug résolu (normalement) : récursion infinie lorsque des pages hiérarchiques sont utilisées) |
||
Ligne 54 : | Ligne 54 : | ||
list[table.getn(list)+1] = title.fullText | list[table.getn(list)+1] = title.fullText | ||
elseif title.baseText ~= title.rootText then | elseif title.baseText ~= title.rootText then | ||
title = title.basePageTitle | title = title.basePageTitle.basePageTitle:subpageTitle( tostring(tonumber(title.basePageTitle.subpageText)+1) ) | ||
if title.exists then | |||
list[table.getn(list)+1] = title.fullText | |||
end | |||
else | else | ||
break | break |
Version du 10 avril 2015 à 18:43
--[[
]]
local presentation = {}
function presentation.total( frame )
local sequence = presentation._expandSequence( mw.title.getCurrentTitle() ) return table.getn( sequence )
end
function presentation.current( frame )
local sequence = presentation._expandSequence( mw.title.getCurrentTitle() ) for i,v in pairs( sequence ) do if v == mw.title.getCurrentTitle().fullText then return i end end return 0
end
function presentation.next( frame )
local sequence = presentation._expandSequence( mw.title.getCurrentTitle() ) for i,v in pairs( sequence ) do if v == mw.title.getCurrentTitle().fullText then return sequence[i+1] end end return
end
function presentation.previous( frame )
local sequence = presentation._expandSequence( mw.title.getCurrentTitle() ) for i,v in pairs( sequence ) do if v == mw.title.getCurrentTitle().fullText then return sequence[i-1] end end return
end
function presentation._expandSequence( title )
local list = {}; title = title.rootPageTitle; while true do if title:subPageTitle( '0' ).exists then title = title:subPageTitle( '0' ) list[table.getn(list)+1] = title.fullText elseif title:subPageTitle( '1' ).exists then title = title:subPageTitle( '1' ) list[table.getn(list)+1] = title.fullText elseif tonumber(title.subpageText) ~= nil and title.basePageTitle:subPageTitle( tostring(tonumber(title.subpageText)+1) ).exists then title = title.basePageTitle:subPageTitle( tostring(tonumber(title.subpageText)+1) ) list[table.getn(list)+1] = title.fullText elseif title.baseText ~= title.rootText then title = title.basePageTitle.basePageTitle:subpageTitle( tostring(tonumber(title.basePageTitle.subpageText)+1) ) if title.exists then list[table.getn(list)+1] = title.fullText end else break end end return list
end
return presentation