Différences entre les versions de « Module:Présentation »

De Wiki Seb35
Aller à la navigation Aller à la recherche
(return)
(fix bug)
Ligne 39 : Ligne 39 :
     local title = title.rootPageTitle;
     local title = title.rootPageTitle;
     while true do
     while true do
         if title.basePageTitle.subPageTitle( title.subpageText+1 ).exists then
         if title.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 ).exists then
             title = title.basePageTitle.subPageTitle( title.subpageText+1 )
             title = title.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 )
             list[table.getn(list)] = title.fullText
             list[table.getn(list)] = title.fullText
         elseif title.basePageTitle.basePagTitle.subPageTitle( title.subpageText+1 ).exists then
         elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 ).exists then
             title = title.basePageTitle.basePageTitle.subPageTitle( title.subpageText+1 )
             title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 )
             list[table.getn(list)] = title.fullText
             list[table.getn(list)] = title.fullText
         elseif title.basePageTitle.basePagTitle.subPageTitle( title.subpageText+1 .. '/0' ).exists then
         elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/0' ).exists then
             title = title.basePageTitle.basePageTitle.subPageTitle( title.subpageText+1 .. '/0' )
             title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/0' )
             list[table.getn(list)] = title.fullText
             list[table.getn(list)] = title.fullText
         elseif title.basePageTitle.basePagTitle.subPageTitle( title.subpageText+1 .. '/1' ).exists then
         elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/1' ).exists then
             title = title.basePageTitle.basePageTitle.subPageTitle( title.subpageText+1 .. '/1' )
             title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/1' )
             list[table.getn(list)] = title.fullText
             list[table.getn(list)] = title.fullText
         else
         else

Version du 10 avril 2015 à 16:02

--[[

]]

local presentation = {}

function presentation.total( frame )

   return table.getn( presentation._expandSequence( mw.title.getCurrentTitle() ) )

end

function presentation.current( frame )

   for i,v in pairs( presentation._expandSequence( mw.title.getCurrentTitle() ) ) do
       if v == mw.title.getCurrentTitle().fullText then
           return i
       end
   end

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

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

end

function presentation._expandSequence( title )

   local list = {};
   local title = title.rootPageTitle;
   while true do
       if title.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 ).exists then
           title = title.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 )
           list[table.getn(list)] = title.fullText
       elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 ).exists then
           title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 )
           list[table.getn(list)] = title.fullText
       elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/0' ).exists then
           title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/0' )
           list[table.getn(list)] = title.fullText
       elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/1' ).exists then
           title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/1' )
           list[table.getn(list)] = title.fullText
       else
           break
       end
   end
   return list

end

return presentation