Modül:Koruma kutu: Revizyonlar arasındaki fark

Değişiklik özeti yok
Etiket: Geri alındı
Değişiklik özeti yok
Etiket: Geri alındı
41. satır: 41. satır:
end
end
end
end
error(string.format(
error(string.format('invalid %s: %s', dateType, tostring(dateString)), 4)
'invalid %s: %s',
dateType,
tostring(dateString)
), 4)
end
end


80. satır: 76. satır:
Protection.__index = Protection
Protection.__index = Protection


Protection.supportedActions = {
Protection.supportedActions = { edit = true, move = true, autoreview = true, upload = true }
edit = true,
Protection.bannerConfigFields = { 'text', 'explanation', 'tooltip', 'alt', 'link', 'image' }
move = true,
autoreview = true,
upload = true
}
 
Protection.bannerConfigFields = {
'text',
'explanation',
'tooltip',
'alt',
'link',
'image'
}


function Protection.new(args, cfg, title)
function Protection.new(args, cfg, title)
170. satır: 153. satır:


Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
function Protection:isTemporary()
function Protection:isTemporary()
return type(self.expiry) == 'number'
return type(self.expiry) == 'number'
end
end
-- (Burada makeProtectionCategory, isIncorrect, isTemplateProtectedNonTemplate, makeCategoryLinks metotları aynı kalabilir)


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
183. satır: 163. satır:
local Blurb = {}
local Blurb = {}
Blurb.__index = Blurb
Blurb.__index = Blurb
 
Blurb.bannerTextFields = { text=true, explanation=true, tooltip=true, alt=true, link=true }
Blurb.bannerTextFields = {
text = true,
explanation = true,
tooltip = true,
alt = true,
link = true
}


function Blurb.new(protectionObj, args, cfg)
function Blurb.new(protectionObj, args, cfg)
return setmetatable({
return setmetatable({ _cfg=cfg, _protectionObj=protectionObj, _args=args }, Blurb)
_cfg = cfg,
_protectionObj = protectionObj,
_args = args
}, Blurb)
end
end
-- (Blurb:_formatDate, _getExpandedMessage, _substituteParameters ve tüm _make* parametre metodları aynı kalabilir)


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- BannerTemplate, Banner ve Padlock sınıfları
-- BannerTemplate, Banner, Padlock
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


212. satır: 179. satır:
local obj = {}
local obj = {}
obj._cfg = cfg
obj._cfg = cfg
local imageFilename = protectionObj.bannerConfig.image
local imageFilename = protectionObj.bannerConfig.image
if imageFilename then
if imageFilename then
obj._imageFilename = imageFilename
obj._imageFilename = imageFilename
else
else
local action = protectionObj.action
local action, level, namespace, reason = protectionObj.action, protectionObj.level, protectionObj.title.namespace, protectionObj.reason
local level = protectionObj.level
if (namespace == 10 or namespace == 828 or (reason and obj._cfg.indefImageReasons[reason]))
local namespace = protectionObj.title.namespace
and action=='edit' and level=='sysop' and not protectionObj:isTemporary()
local reason = protectionObj.reason
if (
namespace == 10
or namespace == 828
or (reason and obj._cfg.indefImageReasons[reason])
) and action == 'edit' and level == 'sysop' and not protectionObj:isTemporary()
then
then
obj._imageFilename = obj._cfg.msg['image-filename-indef']
obj._imageFilename = obj._cfg.msg['image-filename-indef']
231. satır: 191. satır:
local images = obj._cfg.images
local images = obj._cfg.images
if images[action] then
if images[action] then
if images[action][level] then
obj._imageFilename = images[action][level] or images[action].default
obj._imageFilename = images[action][level]
elseif images[action].default then
obj._imageFilename = images[action].default
end
end
end
end
end
242. satır: 198. satır:
end
end


-- (Banner ve Padlock sınıfları aynı kalabilir)
local Banner = setmetatable({}, BannerTemplate)
Banner.__index = Banner
 
function Banner.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg)
obj.imageWidth = 40
obj.imageCaption = blurbObj:makeBannerText('alt')
obj._reasonText = blurbObj:makeBannerText('text')
obj._explanationText = blurbObj:makeBannerText('explanation')
obj._page = protectionObj.title.prefixedText
return setmetatable(obj, Banner)
end
 
function Banner:__tostring()
makeMessageBox = makeMessageBox or require('Modül:İleti kutusu').main
local reasonText = self._reasonText or error('no reason text set', 2)
local explanationText = self._explanationText
local mbargs = {
page = self._page,
type = 'protection',
image = self:renderImage(),
text = string.format("'''%s'''%s", reasonText, explanationText and '<br />' .. explanationText or '')
}
return makeMessageBox('mbox', mbargs)
end
 
local Padlock = setmetatable({}, BannerTemplate)
Padlock.__index = Padlock
 
function Padlock.new(protectionObj, blurbObj, cfg)
local obj = BannerTemplate.new(protectionObj, cfg)
obj.imageWidth = 20
obj.imageCaption = blurbObj:makeBannerText('tooltip')
obj._imageAlt = blurbObj:makeBannerText('alt')
obj._imageLink = blurbObj:makeBannerText('link')
obj._indicatorName = cfg.padlockIndicatorNames[protectionObj.action] or cfg.padlockIndicatorNames.default or 'pp-default'
return setmetatable(obj, Padlock)
end
 
function Padlock:__tostring()
local frame = mw.getCurrentFrame()
return frame:extensionTag{name='nowiki'} .. frame:extensionTag{name='indicator', args={name=self._indicatorName}, content=self:renderImage()}
end


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
251. satır: 249. satır:


function p._exportClasses()
function p._exportClasses()
return {
return { Protection=Protection, Blurb=Blurb, BannerTemplate=BannerTemplate, Banner=Banner, Padlock=Padlock }
Protection = Protection,
Blurb = Blurb,
BannerTemplate = BannerTemplate,
Banner = Banner,
Padlock = Padlock,
}
end
end


263. satır: 255. satır:
args = args or {}
args = args or {}
cfg = cfg or require(CONFIG_MODULE)
cfg = cfg or require(CONFIG_MODULE)
local protectionObj = Protection.new(args, cfg, title)
local protectionObj = Protection.new(args, cfg, title)
local ret = {}
local ret = {}


if not yesno(args.catonly) and (protectionObj.action == 'edit' or
if not yesno(args.catonly) and (protectionObj.action=='edit' or args.demolevel or not getReachableNodes(cfg.hierarchy, protectionObj.level)[effectiveProtectionLevel('edit', protectionObj.title)]) then
args.demolevel or
not getReachableNodes(cfg.hierarchy, protectionObj.level)[effectiveProtectionLevel('edit', protectionObj.title)])
then
local blurbObj = Blurb.new(protectionObj, args, cfg)
local blurbObj = Blurb.new(protectionObj, args, cfg)
local parameter = args["küçük"] or args["small"]
local parameter = args["küçük"] or args["small"]
if protectionObj:shouldShowLock() then
if protectionObj:shouldShowLock() then
ret[#ret + 1] = tostring(
ret[#ret+1] = tostring((yesno(parameter) and Padlock or Banner).new(protectionObj, blurbObj, cfg))
(yesno(parameter) and Padlock or Banner)
.new(protectionObj, blurbObj, cfg)
)
end
end
end
end


if yesno(args.category) or yesno(args.kategori) ~= false then
if yesno(args.category) or yesno(args.kategori) ~= false then
ret[#ret + 1] = protectionObj:makeCategoryLinks()
ret[#ret+1] = protectionObj:makeCategoryLinks()
end
end
 
return table.concat(ret)
return table.concat(ret)
end
end


function p.main(frame, cfg)
function p.main(frame, cfg)
cfg = cfg or require(CONFIG_MODULE)
cfg = cfg or require(CONFIG_MODULE)
cfg.wrappers = cfg.wrappers or {} -- burada nil kontrolü
cfg.wrappers = cfg.wrappers or {}
 
local parent = frame.getParent and frame:getParent()
local parent = frame.getParent and frame:getParent()
local defaultArgs
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')] or {}
if parent then
defaultArgs = cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')] or {}
end
 
getArgs = getArgs or require('Modül:Bağımsız değişkenler').getArgs
getArgs = getArgs or require('Modül:Bağımsız değişkenler').getArgs
local userArgs = getArgs(frame, {
local userArgs = getArgs(frame, { parentOnly=defaultArgs, frameOnly=not defaultArgs })
parentOnly = defaultArgs,
frameOnly = not defaultArgs
})
 
local args = {}
local args = {}
for k, v in pairs(defaultArgs or {}) do
for k,v in pairs(defaultArgs or {}) do args[k]=v end
args[k] = v
for k,v in pairs(userArgs) do args[k]=v end
end
for k, v in pairs(userArgs) do
args[k] = v
end
 
return p._main(args, cfg)
return p._main(args, cfg)
end
end


return p
return p