Przejdź do zawartości

Moduł:ZalaczTresc

Z Wikiźródeł, wolnej biblioteki

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:ZalaczTresc/opis

function czysc( frame )
	local args = frame.args
	local tresc = ""
	local od_naglowek = 4
	for k,v in pairs(args) do
		if tonumber(k)~=nil and (v ~= '' and v ~= nil) then
			if string.find( v, '/') ~= nil then
				od_naglowek = string.find( v, '/') + 1
			end
			tresc = tresc .. '\n' .. string.rep( '=', tonumber(string.sub(v,2,2)) ) .. string.sub(v, od_naglowek ) .. string.rep( '=', tonumber(string.sub(v,2,2)) ) .. '\n'
			tresc = tresc .. string.gsub(string.gsub( frame:expandTemplate{ title = ':' .. string.sub(v,4), args = {} }, '<div id="Template_law".*</div></div>' , '' ), '%[%[Kategoria:.*%]%]' , '' )
		end
	end
	return tresc
end

function z_sekcja(frame)
	local args = frame.args
	local tresc = ""
	local od_sekcja = 0	
	for k,v in pairs(args) do
		if tonumber(k)~=nil and (v ~= '' and v ~= nil) then
			if string.find( v, '#') ~= nil then
				od_sekcja = string.find( v, '#')
			end
			local strona_nazwa = string.sub( v, 1, od_sekcja - 1 )
			local nazwa_s = string.sub( v, od_sekcja + 1, string.len(v) )
			local slowo_r
			local strona_raw_p = mw.title.makeTitle( 'Strona', strona_nazwa )
			if strona_raw_p.exists then
				slowo_r = strona_raw_p:getContent()
			end
			local wynik = string.gsub( slowo_r, '.*<[sS][eE][cC][tT][iI][oO][nN][^>]-begin[^>]-"' .. nazwa_s .. '".-/>(.-)<[sS][eE][cC][tT][iI][oO][nN][^>]-end[^>]-"' .. nazwa_s .. '".-/>.*','%1')
			tresc = tresc .. ' ' .. frame:preprocess{ text = wynik }
	
		end
	end	
	return string.sub( tresc, 2, string.len(tresc) )
end


local p = {}
function p.zalacz( frame )
    return  czysc( frame:getParent() )
end

function p.sekcja(frame)
    return  z_sekcja( frame:getParent() )
end
 

return p