کاربر ناشناس
(درجا)
imported>Darafsh |
((درجا)) |
||
| خط ۲: | خط ۲: | ||
local mHatnote = require('Module:Hatnote') | local mHatnote = require('Module:Hatnote') | ||
local mFormatLink = require('Module:Format link') | |||
local yesno = require('Module:Yesno') | local yesno = require('Module:Yesno') | ||
local mTableTools -- lazily initialise | local mTableTools -- lazily initialise | ||
| خط ۱۱: | خط ۱۲: | ||
mTableTools = require('Module:TableTools') | mTableTools = require('Module:TableTools') | ||
mArguments = require('Module:Arguments') | mArguments = require('Module:Arguments') | ||
local args = mArguments.getArgs(frame, {wrappers = 'الگو:اصلی رده'}) | local args = mArguments.getArgs(frame, {wrappers = {'الگو:Cat main', 'الگو:اصلی رده'}}) | ||
local pages = mTableTools.compressSparseArray(args) | local pages = mTableTools.compressSparseArray(args) | ||
local options = { | local options = { | ||
article = args.article, | article = args.article or args['مقاله'], | ||
selfref = args.selfref | selfref = args.selfref or args['خودارجاع'] | ||
} | } | ||
return p._catMain(options, unpack(pages)) | return p._catMain(options, unpack(pages)) | ||
| خط ۲۴: | خط ۲۵: | ||
-- Get the links table. | -- Get the links table. | ||
local links = | local links = mFormatLink.formatPages({}, {...}) | ||
if not links[1] then | if not links[1] then | ||
local page = mw.title.getCurrentTitle().text | local page = mw.title.getCurrentTitle().text | ||
links[1] = | links[1] = mFormatLink._formatLink{link = page} | ||
end | end | ||
for i, link in ipairs(links) do | for i, link in ipairs(links) do | ||
links[i] = | links[i] = mw.ustring.format("'''%s'''", link) | ||
end | end | ||
-- Get the pagetype. | -- Get the pagetype. | ||
local pagetype | local pages = {...} | ||
if yesno(options.article) ~= false then | local pagetype | ||
pagetype = | |||
if options.article ~= nil then | |||
pagetype = yesno(options.article) ~= false and 'مقاله' or 'صفحه' | |||
elseif pages and pages[1] then | |||
local page = mw.ustring.gsub(pages[1], "|.*", "") | |||
pagetype = mw.title.new(page).namespace == 0 and "مقاله" or "صفحه" | |||
else | else | ||
pagetype = | pagetype = "مقاله" | ||
end | end | ||
| خط ۴۴: | خط ۵۰: | ||
local stringToFormat | local stringToFormat | ||
if #links > 1 then | if #links > 1 then | ||
stringToFormat = '%sهای اصلی این [[راهنما:رده|رده]] %s هستند.' | stringToFormat = '%sهای اصلی این [[راهنما:رده|رده]]، %s هستند.' | ||
else | else | ||
stringToFormat = '%sٔ اصلی این [[راهنما:رده|رده]] | stringToFormat = '%sٔ اصلی این [[راهنما:رده|رده]]، %s است.' | ||
end | end | ||
-- Get the text. | -- Get the text. | ||
local text = | local text = mw.ustring.format( | ||
stringToFormat, | stringToFormat, | ||
pagetype, | pagetype, | ||
| خط ۵۹: | خط ۶۵: | ||
local hnOptions = {} | local hnOptions = {} | ||
hnOptions.selfref = options.selfref | hnOptions.selfref = options.selfref | ||
return mHatnote._hatnote(text, hnOptions) | return mHatnote._hatnote(text, hnOptions) | ||