Butun axtardiqlarinizi tapmaq ucun buraya: DAXIL OLUN
  Mp4 Mp3 Axtar Yukle
  Video Axtar Yukle
  Shekil Axtar Yukle
  Informasiya Melumat Axtar
  Hazir Inshalar Toplusu
  AZERI CHAT + Tanishliq
  1-11 Sinif Derslikler Yukle
  Saglamliq Tibbi Melumat
  Whatsapp Plus Yukle(Yeni)

  • Ana səhifə
  • Təsadüfi
  • Yaxınlıqdakılar
  • Daxil ol
  • Nizamlamalar
İndi ianə et Əgər Vikipediya sizin üçün faydalıdırsa, bu gün ianə edin.

Modul:Lua banner

  • Modul
  • Müzakirə

Bu modulun sənədləşdirmə səhifəsi Modul:Lua banner/doc səhifəsində yaradıla bilər

-- This module implements the {{lua}} template.
local yesno = require('Module:Yesno')
local mList = require('Module:List')
local mTableTools = require('Module:TableTools')
local mMessageBox = require('Module:Message box')

local p = {}

function p.main(frame)
	local origArgs = frame:getParent().args
	local args = {}
	for k, v in pairs(origArgs) do
		v = v:match('^%s*(.-)%s*$')
		if v ~= '' then
			args[k] = v
		end
	end
	return p._main(args)
end

local function parseModuleFunctionPairs(positionalArgs)
	local results = {}
	for _, val in ipairs(positionalArgs) do
		if val:match('^[Mm]odul[ea]?:') then
			table.insert(results, { mod = val })
		elseif #results > 0 and not results[#results].func then
			results[#results].func = val
		end
	end
	return results
end

function p._main(args)
	local argList = mTableTools.compressSparseArray(args)
	local modules = parseModuleFunctionPairs(argList)
	local box = p.renderBox(modules)
	local trackingCategories = p.renderTrackingCategories(args, modules)
	return box .. trackingCategories
end

function p.renderBox(modules)
	local boxArgs = {}
	if #modules < 1 then
		boxArgs.text = '<strong class="error">Xəta: modullar göstərilməyib!</strong>'
	else
		local title = mw.title.getCurrentTitle()
		if title.subpageText == "doc" then
			title = title.basePageTitle
		end
		local isTemplate = (title.contentModel ~= "Scribunto")

		local function getPlainName(mod)
			return mw.ustring.gsub(mod, '^[Mm]odul[ea]?:', '')
		end

		local function makeModLink(mod)
			local plain = getPlainName(mod)
			return string.format('[[%s|%s]]', mod, plain)
		end

		local function makeFuncLink(mod, func)
			return string.format('[[%s#%s|<code>%s()</code>]]', mod, func, func)
		end

		local subject = isTemplate and "şablon" or "modul"

		local hasFunction = false
		for _, pair in ipairs(modules) do
			if pair.func then
				hasFunction = true
				break
			end
		end

		local phrase
		if not hasFunction then
			local plainNames = {}
			for i, pair in ipairs(modules) do
				plainNames[i] = string.format('[[%s|%s]]', pair.mod, getPlainName(pair.mod))
			end
			if #plainNames == 1 then
				phrase = plainNames[1] .. ' modulundan'
			elseif #plainNames == 2 then
				phrase = plainNames[1] .. ' və ' .. plainNames[2] .. ' modullarından'
			else
				for i = 1, #plainNames - 2 do
					plainNames[i] = plainNames[i] .. ','
				end
				phrase = table.concat(plainNames, ' ', 1, #plainNames - 1) ..
					' və ' .. plainNames[#plainNames] .. ' modullarından'
			end
		else
			local parts = {}
			for _, pair in ipairs(modules) do
				local modLink = makeModLink(pair.mod)
				if pair.func then
					table.insert(parts, string.format('%s modulunun %s funksiyasından', modLink, makeFuncLink(pair.mod, pair.func)))
				else
					table.insert(parts, string.format('%s modulundan', modLink))
				end
			end
			if #parts == 1 then
				phrase = parts[1]
			elseif #parts == 2 then
				phrase = parts[1] .. ' və ' .. parts[2]
			else
				for i = 1, #parts - 2 do
					parts[i] = parts[i] .. ','
				end
				phrase = table.concat(parts, ' ', 1, #parts - 1) .. ' və ' .. parts[#parts]
			end
		end

		boxArgs.text = string.format('Bu %s [[Lua]] əsaslı olub %s istifadə edir.', subject, phrase)
	end

	boxArgs.type = 'notice'
	boxArgs.small = true
	boxArgs.image = '[[Fayl:Lua-logo-nolabel.svg|30px|alt=|link=]]'
	return mMessageBox.main('mbox', boxArgs)
end

function p.renderTrackingCategories(args, modules, titleObj)
	if yesno(args.nocat) then
		return ''
	end

	local cats = {}

	if #modules < 1 then
		cats[#cats + 1] = 'Xətalar olan Lua şabonları'
	end

	titleObj = titleObj or mw.title.getCurrentTitle()
	local subpageBlacklist = {
		doc = true,
		sandbox = true,
		sandbox2 = true,
		testcases = true
	}
	if not subpageBlacklist[titleObj.subpageText] then
		local protCatName
		if titleObj.namespace == 10 then
			local category = args.category
			if not category then
				local categories = {
					['Module:String'] = 'Lua əsaslı şablonlar',
					['Module:Math'] = 'Lua əsaslı şablonlar',
					['Module:BaseConvert'] = 'Lua əsaslı şablonlar',
					['Module:Citation'] = 'Lua əsaslı istinad şablonları'
				}
				categories['Module:Citation/CS1'] = categories['Module:Citation']
				category = modules[1] and categories[modules[1].mod]
				category = category or 'Lua əsaslı şablonlar'
			end
			cats[#cats + 1] = category
			protCatName = "Mühafizə edilmiş Lua modulları istifadə edən şablonlar"
		elseif titleObj.namespace == 828 then
			protCatName = "Mühafizə edilmiş Lua modullarını istifadə edən modullar"
		end

		if not args.noprotcat and protCatName then
			local protLevels = {
				autoconfirmed = 1,
				extendedconfirmed = 2,
				sysop = 3
			}
			local currentProt
			if titleObj.id ~= 0 then
				currentProt = titleObj.protectionLevels["edit"][1]
			end
			if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end
			for _, pair in ipairs(modules) do
				local module = pair.mod
				if module ~= "WP:libraryUtil" then
					local moduleProt = mw.title.new(module).protectionLevels["edit"][1]
					if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end
					if moduleProt < currentProt then
						cats[#cats + 1] = protCatName
						break
					end
				end
			end
		end
	end

	for i, cat in ipairs(cats) do
		cats[i] = string.format('[[Category:%s]]', cat)
	end

	return table.concat(cats)
end

return p
Mənbə — "https://az.wikipedia.org/w/index.php?title=Modul:Lua_banner&oldid=8229027"
Informasiya Melumat Axtar