Différences entre les versions de « Module:Présentation »
Aller à la navigation
Aller à la recherche
(ajout de la possibilité du scénario /1/2, /1/3/1, …) |
(certains titres étaient oubliés dans la liste (cas 2e elseif,1er if)) |
||
Ligne 46 : | Ligne 46 : | ||
if title:subPageTitle( '0' ).exists then | if title:subPageTitle( '0' ).exists then | ||
title = title:subPageTitle( '0' ) | title = title:subPageTitle( '0' ) | ||
elseif title:subPageTitle( '1' ).exists then | elseif title:subPageTitle( '1' ).exists then | ||
title = title:subPageTitle( '1' ) | title = title:subPageTitle( '1' ) | ||
elseif tonumber(title.subpageText) ~= nil then | elseif tonumber(title.subpageText) ~= nil then | ||
if not title.exists then | if not title.exists then | ||
Ligne 58 : | Ligne 56 : | ||
else | else | ||
title = title.basePageTitle:subPageTitle( tostring(tonumber(title.subpageText)+1) ) | title = title.basePageTitle:subPageTitle( tostring(tonumber(title.subpageText)+1) ) | ||
end | end | ||
else | else | ||
break | break | ||
end | |||
if title.exists then | |||
list[table.getn(list)+1] = title.fullText | |||
end | end | ||
end | end |
Version du 20 avril 2015 à 20:19
--[[
]]
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' ) elseif title:subPageTitle( '1' ).exists then title = title:subPageTitle( '1' ) elseif tonumber(title.subpageText) ~= nil then if not title.exists then if title.baseText == title.rootText then break end title = title.basePageTitle.basePageTitle:subPageTitle( tostring(tonumber(title.basePageTitle.subpageText)+1) ) else title = title.basePageTitle:subPageTitle( tostring(tonumber(title.subpageText)+1) ) end else break end if title.exists then list[table.getn(list)+1] = title.fullText end end return list
end
return presentation