Module:Message box: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
m (fix brackets) |
(on second thoughts, I like this way of passing params to category handler better) |
||
Line 128: | Line 128: | ||
function box:setTitle(args) |
function box:setTitle(args) |
||
-- Get the title object and the namespace. |
-- Get the title object and the namespace. |
||
self.pageTitle = getTitleObject(args.page ~= '' and args.page) |
|||
self.title = pageTitle or mw.title.getCurrentTitle() |
self.title = self.pageTitle or mw.title.getCurrentTitle() |
||
self.demospace = args.demospace ~= '' and args.demospace or nil |
|||
self.nsid = demospace or self.title.namespace |
self.nsid = box.getNamespaceId(self.demospace) or self.title.namespace |
||
end |
end |
||
Line 383: | Line 383: | ||
-- Convert category tables to strings and pass them through [[Module:Category handler]]. |
-- Convert category tables to strings and pass them through [[Module:Category handler]]. |
||
local chpage, chdemospace |
|||
local currentTitle = mw.title.getCurrentTitle() |
|||
if self.title ~= currentTitle then |
|||
chpage = self.title.prefixedText |
|||
end |
|||
if self.nsid ~= currentTitle.namespace then |
|||
chdemospace = self.nsid |
|||
end |
|||
self.categories = categoryHandler{ |
self.categories = categoryHandler{ |
||
main = tconcat(self.mainCats or {}), |
main = tconcat(self.mainCats or {}), |
||
Line 396: | Line 388: | ||
all = tconcat(self.allCats or {}), |
all = tconcat(self.allCats or {}), |
||
nocat = args.nocat, |
nocat = args.nocat, |
||
demospace = |
demospace = self.demospace, |
||
page = |
page = self.pageTitle and pageTitle.prefixedText or nil |
||
} |
} |
||
end |
end |