summaryrefslogtreecommitdiffstats
path: root/Server/Plugins/DumpInfo/Init.lua
blob: 8b328c8621fa68b6847b34d54e8ec63a93ddf786 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function Initialize(a_Plugin)
	a_Plugin:SetName("DumpInfo")
	a_Plugin:SetVersion(1)
	
	-- Check if the infodump file exists.
	if (not cFile:IsFile("Plugins/InfoDump.lua")) then
		LOGWARN("[DumpInfo] InfoDump.lua was not found.")
		return false
	end
	
	-- Add the webtab.
	a_Plugin:AddWebTab("DumpPlugin", HandleDumpPluginRequest)
	return true
end





function HandleDumpPluginRequest(a_Request)
	local Content = ""
	
	-- Check if it already was requested to dump a plugin.
	if (a_Request.PostParams["DumpInfo"] ~= nil) then
		local F = loadfile("Plugins/InfoDump.lua")
		F("Plugins/" .. a_Request.PostParams["DumpInfo"])
	end
	
	Content = Content .. [[
<table>
	<tr>
		<th colspan="2">DumpInfo</th>
	</tr>]]

	-- Loop through each plugin that is found.
	cPluginManager:Get():ForEachPlugin(
		function(a_Plugin)
			-- Check if there is a file called 'Info.lua'
			if (cFile:IsFile("Plugins/" .. a_Plugin:GetName() .. "/Info.lua")) then
				Content = Content .. "\n<tr>\n"
				Content = Content .. "\t<td>" .. a_Plugin:GetName() .. "</td>\n"
				Content = Content .. "\t<td><form method='POST'> <input type='hidden' value='" .. a_Plugin:GetName() .. "' name='DumpInfo'> <input type='submit' value='DumpInfo'></form></td>\n"
				Content = Content .. "</tr>\n"
			end
		end
	)
	
	Content = Content .. [[
</table>]]

	return Content
end