<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl">
	<id>https://bajkowscy.pl/mw22/index.php?action=history&amp;feed=atom&amp;title=Modu%C5%82%3APortal</id>
	<title>Moduł:Portal - Historia wersji</title>
	<link rel="self" type="application/atom+xml" href="https://bajkowscy.pl/mw22/index.php?action=history&amp;feed=atom&amp;title=Modu%C5%82%3APortal"/>
	<link rel="alternate" type="text/html" href="https://bajkowscy.pl/mw22/index.php?title=Modu%C5%82:Portal&amp;action=history"/>
	<updated>2026-04-20T22:02:43Z</updated>
	<subtitle>Historia wersji tej strony wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://bajkowscy.pl/mw22/index.php?title=Modu%C5%82:Portal&amp;diff=244&amp;oldid=prev</id>
		<title>Admin: 1 wersja</title>
		<link rel="alternate" type="text/html" href="https://bajkowscy.pl/mw22/index.php?title=Modu%C5%82:Portal&amp;diff=244&amp;oldid=prev"/>
		<updated>2016-06-21T08:37:39Z</updated>

		<summary type="html">&lt;p&gt;1 wersja&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nowa strona&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[==[ &lt;br /&gt;
Zobacz też [[Moduł:Portal/grafika]]&lt;br /&gt;
]==]&lt;br /&gt;
 &lt;br /&gt;
local p = {}&lt;br /&gt;
 &lt;br /&gt;
local function matchImagePage(s)&lt;br /&gt;
	-- Finds the appropriate image subpage given a lower-case&lt;br /&gt;
	-- portal name plus the first letter of that portal name.&lt;br /&gt;
	if type(s) ~= &amp;#039;string&amp;#039; or #s &amp;lt; 1 then return end&lt;br /&gt;
	local firstLetter = mw.ustring.sub(s, 1, 1)&lt;br /&gt;
	local imagePage&lt;br /&gt;
	imagePage = &amp;#039;Module:Portal/grafika&amp;#039;&lt;br /&gt;
	return mw.loadData(imagePage)[s]&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function getImageName(s)&lt;br /&gt;
	-- Gets the image name for a given string.&lt;br /&gt;
	if type(s) ~= &amp;#039;string&amp;#039; or #s &amp;lt; 1 then&lt;br /&gt;
		return &amp;#039;OpenEye icon.svg&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	s = mw.ustring.lower(s)&lt;br /&gt;
	return matchImagePage(s) or &amp;#039;OpenEye icon.svg&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
function p._portal(portals, args)&lt;br /&gt;
	-- This function builds the portal box used by the {{portal}} template.&lt;br /&gt;
	local root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;infobox noprint plainlinks&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;cellpadding&amp;#039;, 4)&lt;br /&gt;
		:newline()&lt;br /&gt;
 &lt;br /&gt;
	-- If no portals have been specified, display an error and add the page to a tracking category.&lt;br /&gt;
	if not portals[1] then&lt;br /&gt;
		root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;font-size&amp;#039;, &amp;#039;90%&amp;#039;)&lt;br /&gt;
				:wikitext(&amp;#039;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;Nie podano żadnego portalu: proszę podać chociaż jeden portal&amp;lt;/strong&amp;gt;[[Kategoria:Szablony portali z błędami]]&amp;#039;)&lt;br /&gt;
			:done()&lt;br /&gt;
		:done()&lt;br /&gt;
		:newline()&lt;br /&gt;
	end&lt;br /&gt;
 &lt;br /&gt;
	-- Display the portals specified in the positional arguments.&lt;br /&gt;
	for _, portal in ipairs(portals) do&lt;br /&gt;
		local image = getImageName(portal)&lt;br /&gt;
 &lt;br /&gt;
		-- Generate the html for the image and the portal name.&lt;br /&gt;
		root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;vertical-align&amp;#039;, &amp;#039;middle&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;width&amp;#039;, &amp;#039;30px&amp;#039;)&lt;br /&gt;
				:wikitext(string.format(&amp;#039;[[Plik:%s|32x28px|alt=Ikona portalu|class=noviewer]]&amp;#039;, image))&lt;br /&gt;
			:done()&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;vertical-align&amp;#039;, &amp;#039;middle&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;text-align&amp;#039;, &amp;#039;center&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;line-height&amp;#039;, &amp;#039;normal&amp;#039;) &lt;br /&gt;
				:wikitext(string.format(&amp;#039;[[Portal:Portale|Portal]]: \&amp;#039;\&amp;#039;\&amp;#039;[[Portal:%s|%s]]\&amp;#039;\&amp;#039;\&amp;#039;&amp;#039;, portal, portal))&lt;br /&gt;
			:done()&lt;br /&gt;
		:done()&lt;br /&gt;
		:newline()&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
function p._image(portals)&lt;br /&gt;
 &lt;br /&gt;
	-- Wrapper function to allow getImageName() to be accessed through #invoke.&lt;br /&gt;
	return getImageName(portals[1])&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function getAllImageTables()&lt;br /&gt;
	local images = {}&lt;br /&gt;
	images[i] = mw.loadData(&amp;#039;Module:Portal/grafika&amp;#039;)&lt;br /&gt;
	return images&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
function p._displayAll(portals, args)&lt;br /&gt;
	-- This function displays all portals that have portal images. This function is for maintenance purposes and should not be used in&lt;br /&gt;
	-- articles, for two reasons: 1) there are over 1500 portals with portal images, and 2) the module doesn&amp;#039;t record how the portal&lt;br /&gt;
	-- names are capitalized, so the portal links may be broken.&lt;br /&gt;
	local lang = mw.language.getContentLanguage()&lt;br /&gt;
	local count = 1&lt;br /&gt;
	for _, imageTable in ipairs(getAllImageTables()) do&lt;br /&gt;
		for portal in pairs(imageTable) do&lt;br /&gt;
			portals[count] = lang:ucfirst(portal)&lt;br /&gt;
			count = count + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return p._portal(portals, args)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
function p._imageDupes()&lt;br /&gt;
	-- This function searches the image subpages to find duplicate images. If duplicate images exist, it is not necessarily a bad thing,&lt;br /&gt;
	-- as different portals might just happen to choose the same image.&lt;br /&gt;
	local exists, dupes = {}, {}&lt;br /&gt;
	for _, imageTable in ipairs(getAllImageTables()) do&lt;br /&gt;
		for portal, image in pairs(imageTable) do&lt;br /&gt;
			if not exists[image] then&lt;br /&gt;
				exists[image] = portal&lt;br /&gt;
			else&lt;br /&gt;
				table.insert(dupes, string.format(&amp;#039;The image &amp;quot;[[:File:%s|%s]]&amp;quot; is used for both portals &amp;quot;%s&amp;quot; and &amp;quot;%s&amp;quot;.&amp;#039;, image, image, exists[image], portal))&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if #dupes &amp;lt; 1 then&lt;br /&gt;
		return &amp;#039;No duplicate images found.&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;The following duplicate images were found:\n* &amp;#039; .. table.concat(dupes, &amp;#039;\n* &amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function processPortalArgs(args)&lt;br /&gt;
	-- This function processes a table of arguments and returns two tables: an array of portal names for processing by ipairs, and a table of&lt;br /&gt;
	-- the named arguments that specify style options, etc. We need to use ipairs because we want to list all the portals in the order&lt;br /&gt;
	-- they were passed to the template, but we also want to be able to deal with positional arguments passed explicitly, for example&lt;br /&gt;
	-- {{portal|2=Politics}}. The behaviour of ipairs is undefined if nil values are present, so we need to make sure they are all removed.&lt;br /&gt;
	args = type(args) == &amp;#039;table&amp;#039; and args or {}&lt;br /&gt;
	local portals = {}&lt;br /&gt;
	local namedArgs = {}&lt;br /&gt;
	for k, v in pairs(args) do&lt;br /&gt;
		if type(k) == &amp;#039;number&amp;#039; and type(v) == &amp;#039;string&amp;#039; then -- Make sure we have no non-string portal names.&lt;br /&gt;
			table.insert(portals, k)&lt;br /&gt;
		elseif type(k) ~= &amp;#039;number&amp;#039; then&lt;br /&gt;
			namedArgs[k] = v&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(portals)&lt;br /&gt;
	for i, v in ipairs(portals) do&lt;br /&gt;
		portals[i] = args[v]&lt;br /&gt;
	end&lt;br /&gt;
	return portals, namedArgs&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
local function makeWrapper(funcName)&lt;br /&gt;
	-- Processes external arguments and sends them to the other functions.&lt;br /&gt;
	return function (frame)&lt;br /&gt;
		-- If called via #invoke, use the args passed into the invoking&lt;br /&gt;
		-- template, or the args passed to #invoke if any exist. Otherwise&lt;br /&gt;
		-- assume args are being passed directly in from the debug console&lt;br /&gt;
		-- or from another Lua module.&lt;br /&gt;
		local origArgs&lt;br /&gt;
		if type(frame.getParent) == &amp;#039;function&amp;#039; then&lt;br /&gt;
			origArgs = frame:getParent().args&lt;br /&gt;
			for k, v in pairs(frame.args) do&lt;br /&gt;
				origArgs = frame.args&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			origArgs = frame&lt;br /&gt;
		end&lt;br /&gt;
		-- Trim whitespace and remove blank arguments.&lt;br /&gt;
		local args = {}&lt;br /&gt;
		for k, v in pairs(origArgs) do&lt;br /&gt;
			if type(v) == &amp;#039;string&amp;#039; then&lt;br /&gt;
				v = mw.text.trim(v)&lt;br /&gt;
			end&lt;br /&gt;
			if v ~= &amp;#039;&amp;#039; then&lt;br /&gt;
				args[k] = v&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return p[funcName](processPortalArgs(args)) -- passes two tables to func: an array of portal names, and a table of named arguments.&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
for _, funcName in ipairs{&amp;#039;portal&amp;#039;, &amp;#039;image&amp;#039;, &amp;#039;imageDupes&amp;#039;, &amp;#039;displayAll&amp;#039;} do&lt;br /&gt;
	p[funcName] = makeWrapper(&amp;#039;_&amp;#039; .. funcName)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>