FANDOM


-- <pre>
-- infobox-related utils. it's iboxu (unlike lboxu)
 
local p = {}
 
function p.updated(frame)
    -- returns list of dates for mediawiki:pagename.* and mediawiki:pagename/*
    -- dpl-dependant
    -- format: date (code)
    -- 1: pagename: default: rootpagename; otherwise: root of {1}
    -- 2: format: #time-compatible date format; default: Y.m.d
    -- 3: uselang: language code; default: en
    -- 4: notrans: do not list translation page (i18n.json); default: false
    --5: order: dpl ordermethod; default: lastedit
    local args = frame.args
    local pagename = args['pagename'] or args[1] or args['1'] or mw.title.getCurrentTitle().rootText
    local fmt = args['format'] or args[2] or args['2'] or 'Y.m.d'
    local lang = args['uselang'] or args[3] or args['3'] or 'en'
    local trans = args['notrans'] or args[4] or args['4'] or ''
    local order = args['order'] or args[5] or args['5'] or 'lastedit'
    if #mw.text.trim(tostring(trans)) > 0 then
        trans = ''
    else
        trans = '(Custom\-)?'
    end
    pagename = mw.ustring.match(pagename, '[^/]*')-- rootpagename
    local timeq = '{{#time:' .. fmt .. '|%date%|' .. lang .. '}}'
    local dplq = '{{#dpl:suppresserrors=1|allowcachedresults=1|namespace=MediaWiki|titleregexp=^' .. trans .. pagename ..'(/+{{!}}\\.)|ordermethod=' .. order ..'|addeditdate=1|userdateformat=Ymdhis|mode=userformat|replaceintitle=(.*?/),|format=,%DATE%{{!}}%TITLE%,\\n}}'
    local dplo = frame:preprocess(dplq)
    local ret, page, upd, pos = '', '', '', 0
    for m in mw.ustring.gmatch(mw.text.trim(dplo), '[^\n]+') do
        pos = mw.ustring.find(m, '|') or 0
        if pos < 1 then-- wrong dpl output
            return ret
        end
        upd = mw.ustring.sub(m, 0, pos - 1)
        page = mw.ustring.sub(m, pos + 1)
        ret = ret .. mw.ustring.gsub(timeq, '%%date%%', upd) .. ' (' .. page .. ')<br>'
    end
    ret = mw.ustring.gsub(ret, '(.*)<br>$', '%1')-- strip last \n\n
    return frame:preprocess(ret)
end-- updated
 
function p.about(frame)
    return [[iboxu
returns list of dates for mediawiki:pagename.* and mediawiki:pagename/*
dpl-dependant
format: date (code)
1: pagename: default: rootpagename; otherwise: root of {1}
2: format: #time-compatible date format; default: Y.m.d
3: uselang: language code; default: en
4: notrans: do not list translation page (i18n.json); default: false
5: order: dpl ordermethod; default: lastedit
]]
end -- about
return p
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+