Modul:Banner shell
Penampilan
Pendokumenan untuk modul ini boleh diciptakan di Modul:Banner shell/doc
local p = {}
local DuplicateBanners = function(text)
local capture = '<span class="wpb%-project">([%w%s]*)</span>'
local banners = {}
for project in text:gmatch(capture) do
if banners[project] == true then
return '[[Kategori:Laman menggunakan rangka sepanduk WikiProjek dengan penduaan templat sepanduk|' .. project .. ']]'
end
banners[project] = true
end
end
local ofinterest = function(collapsed)
local wikiprojects = '[[Wikipedia:WikiProjek|WikiProjek]]'
local text = ' merupakan tumpuan '
if collapsed then
text = text .. 'beberapa ' .. wikiprojects .. '.'
else
text = text .. '' .. wikiprojects .. ' seperti berikut:'
end
return text
end
p.main = function(frame)
local args = require('Module:Arguments').getArgs(frame,
{wrappers = {'Template:WikiProject banner shell'}
})
local classmask = require('Module:Class mask')
local readarticleclass = require('Module:WikiProject banner').readarticleclass
local yesno = require('Module:Yesno')
local class = classmask._main{args.class or ''}
local demo = not yesno(args.category or true, true)
local pagetype = demo and 'article' or require('Module:Pagetype')._main{
[1] = args.class,
defaultns = 'extended'
}
local out = {}
if yesno(args.blp) or yesno(args.living) then
table.insert(out,frame:expandTemplate{title = 'BLP'})
elseif yesno(args.blpo) then
table.insert(out,frame:expandTemplate{title = 'BLP others'})
end
if yesno(args.activepol) then
table.insert(out, frame:expandTemplate{title = 'Active politician'})
end
local banner_args = {
templatestyles = 'WikiProject banner shell/styles.css',
collapsed = args.collapsed,
size = '32',
class = 'wpbs',
image = 'WikiProject Council with transparent background.svg',
alt = 'WikiProject Council',
image_link = 'Wikipedia:Majlis WikiProjek'
}
local globalclass = false
if class == '' then -- check if class parameters is defined by any project banner
local articleclass = require('Modul:WikiProject banner').readarticleclass{
ignore_blank = true,
only_subtemplates = true
}
if articleclass == '' then -- no class parameters are defined by any project banner, so globally unassessed
globalclass = true
end
else -- global class defined, so display it
globalclass = true
end
if globalclass then
local icons = { -- map output of pagetype function to input of class icon function
['project page'] = 'project',
['user page'] = 'user',
['interface page'] = 'interface',
['help page'] = 'help',
['module'] = 'module',
['disambiguation page'] = 'disambig',
['page'] = 'na'
}
local icon_class = class=='NA' and (icons[pagetype] or pagetype) or class
local icon = require('Modul:Class')._icon{icon_class, size='35px'}
local header = '<td class="assess">'
.. icon
.. '</td><td class="banner-shell-header" style="text-align: left; font-weight: normal;">Laman '
.. (pagetype=='article' and pagetype or ('<b>'..pagetype..'</b>'))
.. ' ini '
if demo or class == '' then
header = header .. 'belum dinilai'
else
if args.class and class~='NA' then
header = header .. 'dinilai <span style="font-weight:bold;">kelas ' .. class .. '</span>'
else
header = header .. 'tidak memerlukan penilaian'
end
end
header = header .. " mengikut skala [[Wikipedia:Penilaian rencana|penilaian kandungan]] Wikipedia.<br>"
if args[1] then
header = header .. 'Laman ini' .. ofinterest(yesno(args.collapsed))
else
if not demo then
if mw.title.getCurrentTitle().isTalkPage then
header = header .. '[[Kategori:Rencana kelas ' .. (class=='' and 'belum dinilai' or (class .. '')) .. ']]'
end
end
end
header = header .. '</td>'
banner_args.header = header
end
if args.header then
banner_args.text = args.header
else
banner_args.text = 'Laman ' .. pagetype .. ofinterest(yesno(args.collapsed))
end
banner_args[1] = args[1] or ''
table.insert(out,frame:expandTemplate{title='Banner holder', args=banner_args})
if args[1] and args[1]~='' then
local duplicate_cat = DuplicateBanners(args[1])
if duplicate_cat and mw.title.getCurrentTitle().isTalkPage then
table.insert(out, duplicate_cat)
end
elseif mw.title.getCurrentTitle().isTalkPage then
table.insert(out,'[[Kategori:Laman menggunakan rangka sepanduk WikiProjek tanpa templat sepanduk]]')
end
if args.listas then
table.insert(out,frame:preprocess('{{DEFAULTSORT:' .. args.listas .. '}}'))
end
return table.concat(out)
end
return p