<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pt-BR">
	<id>https://dicionario.advogadocompleto.com/index.php?action=history&amp;feed=atom&amp;title=M%C3%B3dulo%3ATrainingPages</id>
	<title>Módulo:TrainingPages - Histórico de revisão</title>
	<link rel="self" type="application/atom+xml" href="https://dicionario.advogadocompleto.com/index.php?action=history&amp;feed=atom&amp;title=M%C3%B3dulo%3ATrainingPages"/>
	<link rel="alternate" type="text/html" href="https://dicionario.advogadocompleto.com/index.php?title=M%C3%B3dulo:TrainingPages&amp;action=history"/>
	<updated>2026-05-15T17:58:24Z</updated>
	<subtitle>Histórico de revisões para esta página neste wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://dicionario.advogadocompleto.com/index.php?title=M%C3%B3dulo:TrainingPages&amp;diff=140&amp;oldid=prev</id>
		<title>Itaymbere: Criou página com &#039;--The purpose of this module is to take a list of linked page, and use it to determine the next and previous page in the list as well as the total number of pages.   local p = {}   function anonymize(name) 	return mw.ustring.gsub(name,&quot;^&quot;..mw.site.siteName,&quot;Project&quot;) or name end  function out(name) 	return mw.ustring.gsub(name,&quot;^Project&quot;,mw.site.siteName) or name end  function keyize(pagename) 	-- there was a complaint about &quot;_&quot; breaking things.  Do all lookups with _ in...&#039;</title>
		<link rel="alternate" type="text/html" href="https://dicionario.advogadocompleto.com/index.php?title=M%C3%B3dulo:TrainingPages&amp;diff=140&amp;oldid=prev"/>
		<updated>2026-03-29T17:22:29Z</updated>

		<summary type="html">&lt;p&gt;Criou página com &amp;#039;--The purpose of this module is to take a list of linked page, and use it to determine the next and previous page in the list as well as the total number of pages.   local p = {}   function anonymize(name) 	return mw.ustring.gsub(name,&amp;quot;^&amp;quot;..mw.site.siteName,&amp;quot;Project&amp;quot;) or name end  function out(name) 	return mw.ustring.gsub(name,&amp;quot;^Project&amp;quot;,mw.site.siteName) or name end  function keyize(pagename) 	-- there was a complaint about &amp;quot;_&amp;quot; breaking things.  Do all lookups with _ in...&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--The purpose of this module is to take a list of linked page, and use it to determine the next and previous page in the list as well as the total number of pages.&lt;br /&gt;
 &lt;br /&gt;
local p = {}&lt;br /&gt;
 &lt;br /&gt;
function anonymize(name)&lt;br /&gt;
	return mw.ustring.gsub(name,&amp;quot;^&amp;quot;..mw.site.siteName,&amp;quot;Project&amp;quot;) or name&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function out(name)&lt;br /&gt;
	return mw.ustring.gsub(name,&amp;quot;^Project&amp;quot;,mw.site.siteName) or name&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function keyize(pagename)&lt;br /&gt;
	-- there was a complaint about &amp;quot;_&amp;quot; breaking things.  Do all lookups with _ in place of any space.&lt;br /&gt;
	-- also spaces in the index file (non-module) were causing trouble&lt;br /&gt;
	pagename = mw.text.trim(pagename)&lt;br /&gt;
	pagename = mw.ustring.gsub(pagename, &amp;quot; &amp;quot;, &amp;quot;_&amp;quot;)&lt;br /&gt;
	pagename = mw.uri.decode(pagename)&lt;br /&gt;
	pagename = anonymize(pagename)&lt;br /&gt;
	return pagename&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame,displacement,varstoreturn)&lt;br /&gt;
	local parent=frame.getParent(frame)&lt;br /&gt;
	local currentpage,indexmodule,defaultpage,noerr&lt;br /&gt;
	---- args in the #invoke itself trump args in the parent frame&lt;br /&gt;
	currentpage = frame.args.page and mw.text.trim(frame.args.page)&lt;br /&gt;
	defaultpage = frame.args.defaultpage and mw.text.trim(frame.args.defaultpage)&lt;br /&gt;
	indexmodule = frame.args.index and mw.text.trim(frame.args.index)&lt;br /&gt;
	displacement = displacement or frame.args.displacement -- can be passed from the other function names at the end&lt;br /&gt;
	noerr=frame.args.noerr -- used as boolean&lt;br /&gt;
	anonymizereturn = frame.args.anonymize -- used as boolean&lt;br /&gt;
	---- args in the parent frame come next&lt;br /&gt;
	if parent then&lt;br /&gt;
		currentpage=currentpage or (parent.args.page and mw.text.trim(parent.args.page))&lt;br /&gt;
		indexmodule=indexmodule or (parent.args.index and mw.text.trim(parent.args.index)) -- index is a module return{&amp;#039;page1&amp;#039;,&amp;#039;page2&amp;#039;, ...}&lt;br /&gt;
		defaultpage=defaultpage or (parent.args.defaultpage and mw.text.trim(parent.args.defaultpage))&lt;br /&gt;
		noerr=noerr or parent.args.noerr&lt;br /&gt;
		anonymizereturn = anonymizereturn or parent.args.anonymize&lt;br /&gt;
	end&lt;br /&gt;
	---- default values if parameters aren&amp;#039;t provided&lt;br /&gt;
	defaultpage=defaultpage or &amp;quot;&amp;quot; -- don&amp;#039;t know where to send people by default&lt;br /&gt;
	if not(indexmodule) then&lt;br /&gt;
		return &amp;quot;[[Module:TrainingPages]] error:no index parameter specified&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	if not(currentpage) then&lt;br /&gt;
		local pp=mw.title.getCurrentTitle()&lt;br /&gt;
		if not pp then&lt;br /&gt;
			if noerr then&lt;br /&gt;
				return &amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;&lt;br /&gt;
			else return &amp;quot;[[Module:TrainingPages]] error:failed to access getCurrentTitle&amp;quot; -- this shouldn&amp;#039;t happen anyway, I don&amp;#039;t think....&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		currentpage=pp.fullText&lt;br /&gt;
	end&lt;br /&gt;
	currentpage=anonymize(currentpage) --- convert &amp;quot;Wikipedia:, &amp;quot;Meta:&amp;quot; etc. into &amp;quot;Project:&lt;br /&gt;
	local index={}&lt;br /&gt;
	if mw.ustring.sub(indexmodule,1,6)==&amp;quot;Module&amp;quot; then&lt;br /&gt;
		---- get a table of the pages in order from indexmodule&lt;br /&gt;
		index=mw.loadData(indexmodule)&lt;br /&gt;
	else pp=mw.title.new(indexmodule)&lt;br /&gt;
		if not pp then&lt;br /&gt;
			if noerr then&lt;br /&gt;
				return &amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;&lt;br /&gt;
			else return &amp;quot;[[Module:TrainingPages]] error (&amp;#039;&amp;#039;index&amp;#039;&amp;#039; parameter): failed to access mw.title.new(&amp;quot;..tostring(indexmodule)..&amp;quot;) to load the index file&amp;quot;,false,false,true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		local textindex=pp.getContent(pp)&lt;br /&gt;
		if not textindex then&lt;br /&gt;
			if noerr then&lt;br /&gt;
				return &amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;&lt;br /&gt;
			else return &amp;quot;[[Module:TrainingPages]] error (&amp;#039;&amp;#039;index&amp;#039;&amp;#039; parameter):failed to access mw.title.new(&amp;quot;..indexmodule..&amp;quot;):getContent() to load the index data&amp;quot;,false,false,true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		prowl=mw.ustring.gmatch(textindex,&amp;quot;%[%[(.-)[%]|]&amp;quot;) -- first half of any wikilink&lt;br /&gt;
		index={}&lt;br /&gt;
		repeat&lt;br /&gt;
			link=prowl()&lt;br /&gt;
			if not(link) then break end&lt;br /&gt;
			link = mw.text.trim(link)&lt;br /&gt;
			if link~=&amp;quot;&amp;quot; then table.insert(index,link) end&lt;br /&gt;
		until false&lt;br /&gt;
	end&lt;br /&gt;
	displacement = displacement or 0 -- assume a null parameter is just display the same&lt;br /&gt;
	---- set up the reverse lookup in lookup.&lt;br /&gt;
	---- it would be faster to set this up in the indexmodule&lt;br /&gt;
	---- but we don&amp;#039;t want inconsistencies from user input!&lt;br /&gt;
	local lookup={}&lt;br /&gt;
	local i=0&lt;br /&gt;
	repeat&lt;br /&gt;
		i=i+1&lt;br /&gt;
		local j=index[i]&lt;br /&gt;
		if j then lookup[keyize(j)]=i else break end -- lookup[&amp;quot;page name&amp;quot;] =&amp;gt; page number&lt;br /&gt;
	until false&lt;br /&gt;
	--- get the page to return&lt;br /&gt;
	local returnpage,currentpagenumber&lt;br /&gt;
	if tonumber(currentpage) then&lt;br /&gt;
		currentpagenumber=tonumber(currentpage)&lt;br /&gt;
		returnpage=index[currentpagenumber+displacement] or defaultpage&lt;br /&gt;
	elseif (lookup[keyize(currentpage)]) then&lt;br /&gt;
		currentpagenumber=lookup[keyize(currentpage)]&lt;br /&gt;
		returnpage=index[currentpagenumber+displacement] or defaultpage&lt;br /&gt;
	else returnpage=defaultpage&lt;br /&gt;
	end&lt;br /&gt;
	if anonymizereturn then&lt;br /&gt;
		returnpage=anonymize(returnpage)&lt;br /&gt;
	else&lt;br /&gt;
		returnpage=out(returnpage)&lt;br /&gt;
	end&lt;br /&gt;
	if returnpage then returnpage = mw.text.trim(returnpage) end&lt;br /&gt;
	if not(varstoreturn) then return tostring(returnpage) else return tostring(returnpage),currentpagenumber,#index end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Return the next page in the index&lt;br /&gt;
-- Used like if on a page that is part of the index:&lt;br /&gt;
--{{#invoke:TrainingPages| next_page | index=Project:Training/For students/Editing module index }}&lt;br /&gt;
-- Used like this to find the next page after a specified page:&lt;br /&gt;
--{{#invoke:TrainingPages| next_page | index=Project:Training/For students/Editing module index | currentpage=Project:Training/For students/My sandbox }}&lt;br /&gt;
&lt;br /&gt;
function p.next_page(frame)&lt;br /&gt;
	local returnpage,pagenumber,totalpages,errcode=p.main(frame,1,true)&lt;br /&gt;
	return returnpage&lt;br /&gt;
end&lt;br /&gt;
p.next = p.next_page&lt;br /&gt;
 &lt;br /&gt;
-- Same as above, but returns the previous page&lt;br /&gt;
function p.last_page(frame)&lt;br /&gt;
	local returnpage,pagenumber,totalpages,errcode=p.main(frame,-1,true)&lt;br /&gt;
	return returnpage&lt;br /&gt;
end&lt;br /&gt;
p.last = p.last_page&lt;br /&gt;
 &lt;br /&gt;
function p.page_number(frame)&lt;br /&gt;
	local returnpage,pagenumber,totalpages,errcode=p.main(frame,0,true)&lt;br /&gt;
	if errcode then return returnpage else return pagenumber end&lt;br /&gt;
end&lt;br /&gt;
p.page = p.page_number&lt;br /&gt;
&lt;br /&gt;
function p.total_pages(frame)&lt;br /&gt;
	local returnpage,pagenumber,totalpages,errcode=p.main(frame,0,true)&lt;br /&gt;
	if errcode then return returnpage else return totalpages end&lt;br /&gt;
end&lt;br /&gt;
p.total = p.total_pages&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Itaymbere</name></author>
	</entry>
</feed>