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

De Wiki Seb35
Aller à la navigation Aller à la recherche
(cht’i bug)
 
(19 versions intermédiaires par le même utilisateur non affichées)
Ligne 6 : Ligne 6 :


function presentation.total( frame )
function presentation.total( frame )
     return table.getn( presentation._expandSequence( mw.title.getCurrentTitle() ) )
     local sequence = presentation._expandSequence( mw.title.getCurrentTitle() )
    return table.getn( sequence )
end
end
--[[function presention.test( frame )
    return mw.title.getCurrentTitle().fullText
end
function presention.test2( frame )
    return mw.title.getCurrentTitle().rootText
end
function presention.test3( frame )
    return mw.title.getCurrentTitle().subpageText
end]]


function presentation.current( frame )
function presentation.current( frame )
     for i,v in pairs( presentation._expandSequence( mw.title.getCurrentTitle() ) ) do
     local sequence = presentation._expandSequence( mw.title.getCurrentTitle() )
    for i, v in pairs( sequence ) do
         if v == mw.title.getCurrentTitle().fullText then
         if v == mw.title.getCurrentTitle().fullText then
             return i
             return i
         end
         end
     end
     end
    return 0
end
end


function presentation.next( frame )
function presentation.next( frame )
     local sequence = presentation._expandSequence( mw.title.getCurrentTitle() )
     local sequence = presentation._expandSequence( mw.title.getCurrentTitle() )
     for i,v in pairs( sequence ) do
     for i, v in pairs( sequence ) do
         if v == mw.title.getCurrentTitle().fullText then
         if v == mw.title.getCurrentTitle().fullText then
             return sequence[i+1]
             return sequence[i+1]
         end
         end
     end
     end
    if not mw.title.getCurrentTitle().isSubpage then
        return sequence[1]
    end
    return ''
end
end


function presentation.previous( frame )
function presentation.previous( frame )
     local sequence = presentation._expandSequence( mw.title.getCurrentTitle() )
     local sequence = presentation._expandSequence( mw.title.getCurrentTitle() )
     for i,v in pairs( sequence ) do
     for i, v in pairs( sequence ) do
         if v == mw.title.getCurrentTitle().fullText then
         if v == mw.title.getCurrentTitle().fullText then
             return sequence[i-1]
             return sequence[i-1]
         end
         end
     end
     end
    return ''
end
end


function presentation._expandSequence( title )
function presentation._expandSequence( title )
     local list = {};
     local list = {};
     local title = title.rootPageTitle;
     title = title.rootPageTitle;
     while true do
     while true do
         if title.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 ).exists then
         if title:subPageTitle( '0' ).exists then
             title = title.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 )
             title = title:subPageTitle( '0' )
            list[table.getn(list)] = title.fullText
         elseif title:subPageTitle( '1' ).exists then
         elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 ).exists then
             title = title:subPageTitle( '1' )
             title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 )
        elseif tonumber(title.subpageText) ~= nil then
             list[table.getn(list)] = title.fullText
             if not title.exists then
        elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/0' ).exists then
                if title.baseText == title.rootText then
            title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/0' )
                    break
            list[table.getn(list)] = title.fullText
                end
        elseif title.basePageTitle.basePagTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/1' ).exists then
                title = title.basePageTitle.basePageTitle:subPageTitle( tostring(tonumber(title.basePageTitle.subpageText)+1) )
             title = title.basePageTitle.basePageTitle.subPageTitle( tonumber(title.subpageText)+1 .. '/1' )
             else
             list[table.getn(list)] = title.fullText
                title = title.basePageTitle:subPageTitle( tostring(tonumber(title.subpageText)+1) )
             end
         else
         else
             break
             break
        end
        if title.exists then
            list[table.getn(list)+1] = title.fullText
         end
         end
     end
     end

Version actuelle datée du 23 avril 2015 à 17:48

--[[

]]

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
   if not mw.title.getCurrentTitle().isSubpage then
       return sequence[1]
   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