Modul:PageTree: Unterschied zwischen den Versionen

3.487 Bytes hinzugefügt ,  vor 10 Jahren
2015-05-18
w>PerfektesChaos
(fix 3)
w>PerfektesChaos
(2015-05-18)
Zeile 1: Zeile 1:
--[=[ 2015-03-09
--[=[ 2015-05-18
Module:pageTree
Module:pageTree
]=]
]=]
Zeile 157: Zeile 157:
     -- Returns absolute page name, or false
     -- Returns absolute page name, or false
     local designs = {
     local designs = {
          autoconfirmed = "background:#FFFF00",
    autoconfirmed       = "background:#FFFF80",
          superprotect = "background:#FF0000;border:#FFFF00 9px solid",
    editeditorprotected = "background:#FFFF00;border:#FF0000 1px solid",
          sysop         = "background:#FFFF00;border:#FF0000 2px solid",
    superprotect       = "background:#FF0000;border:#FFFF00 9px solid",
          ["?????????"] = "border:#FF0000 5px solid;color:#FF0000" }
    sysop               = "background:#FFFF00;border:#FF0000 3px solid",
    ["?????????"]       = "border:#FF0000 5px solid;color:#FF0000" }
     local restrictions = mw.text.split( adopt, ":" )
     local restrictions = mw.text.split( adopt, ":" )
     local r = ""
     local r = ""
Zeile 495: Zeile 496:
     return r
     return r
end -- flag()
end -- flag()
local function flip( already, ahead, amount, above )
    -- Render subtree as expandable/collapsible list of entries
    --    already  -- number, of initially visible levels
    --    ahead    -- string, leading list syntax, either "#" or "*"
    --    amount  -- number, of leading elements
    --    above    -- table, with top element (not shown)
    --                .children -- will be shown
    -- Returns string with story
    local n = table.maxn( above.children )
    local r = ""
    if n > 0 then
        local live = ( already <= amount )
--      local span = "<span ></span>"
        local e, let, serial
        table.sort( above.children, firstly )
        for i = 1, n do
            e = Current.pages[ above.children[ i ] ]
            if e.list == false then
                let = Current.list
            elseif Current.hide then
                let = not fade( e.seed )
            else
                let = true
            end
            if let then
                if not e.less then
                    Current.item = Current.item + 1
                    serial      = string.format( "%s_%d",
                                                  Current.serial,
                                                  Current.item )
                    r = string.format( "%s\n<div %s %s %s>",
                                      r,
                                      "class='mw-collapsible'",
                                      "data-expandtext='[+]'",
                                      "data-collapsetext='[-]'" )
                end
                r = string.format( "%s\n%s%s",
                                  r,  ahead,  field( e, false ) )
                if not e.less then
                    r = string.format( "%s\n<div %s>\n%s\n%s",
                                      r,
--                                    span,
                                      "class='mw-collapsible-content'",
                                      flip( ahead,
                                            amount + 1,
                                            e,
                                            already ),
                                      "</div></div>" )
                end
            end
        end -- for i
    end
    return r
end -- flip()




Zeile 533: Zeile 591:
local function fluent()
local function fluent()
     -- Collect all .children; add .super where missing
     -- Collect all .children; add .super where missing
    local let = true
     local e
     local e
    local let = true
     for k, v in pairs( Current.pages ) do
     for k, v in pairs( Current.pages ) do
         if v.super == nil then
         if v.super == nil then
Zeile 565: Zeile 623:
     --    all    -- true if all grandchildren shall be shown
     --    all    -- true if all grandchildren shall be shown
     -- Returns string with story
     -- Returns string with story
    local let, lift
     local n = table.maxn( above.children )
     local n = table.maxn( above.children )
     local r = ""
     local r = ""
     if n > 0 then
     if n > 0 then
         local e
         local e, let, lift
         local start = "\n" .. string.rep( ahead, amount )
         local start = "\n" .. string.rep( ahead, amount )
         table.sort( above.children, firstly )
         table.sort( above.children, firstly )
Zeile 598: Zeile 655:
local function formatAll()
local function formatAll()
     -- Render as single list of entries
     -- Render as single list of entries
    local r
     local collect = { }
     local collect = { }
    local let
     local n      = 0
     local n      = 0
    local r, let
     for k, v in pairs( Current.pages ) do
     for k, v in pairs( Current.pages ) do
         let = true
         let = true
Zeile 647: Zeile 703:
     return r
     return r
end -- formatAll()
end -- formatAll()
local function formatExpand( ancestor, args )
    -- Render entire tree as collapsible list text
    --    ancestor  -- string, with name of root element, or false
    --    args      -- table, with control information
    -- Returns string with story, or false
    local init, r
    if type( ancestor ) == "string" then
        r = ancestor
    else
        r = true
    end
    r = Current.pages[ r ]
    if r then
        if type( Current.init ) == "number" then
            init = Current.init
            if Current.init < 1 then
                init = 1
            end
        else
            init = 1
        end
        if type( Current.serial ) ~= "string"
          or Current.serial == "" then
            Current.serial = "pageTree"
        end
        Current.item = 0
        r = flip( init,  flag( "#" ),  1,  r )
    else
        r = false
    end
    return r
end -- formatExpand()




Zeile 857: Zeile 948:
                         if Current.service == "path" then
                         if Current.service == "path" then
                             r = formatPath( segment )
                             r = formatPath( segment )
                        elseif Current.service == "expand" then
                            r = formatExpand( segment, args )
                         else
                         else
                             if args.limit == "1"  or
                             if args.limit == "1"  or
Zeile 938: Zeile 1.031:
function p.check( frame )
function p.check( frame )
     return  framed( frame, "check" )
     return  framed( frame, "check" )
end -- p.path
end -- p.check
 
function p.expand( frame )
    return  framed( frame, "expand" )
end -- p.expand


function p.path( frame )
function p.path( frame )
Anonymer Benutzer