QueryHandler
UT2003's WebAdmin has been build modular, you can add new pages by writing your own QueryHandler and insert it into the WebAdmin (this feature only works for UT2003 builds higher then 2136 or when using Evolution's fixed WebAdmin).
This document will describe how to write your own QueryHandler and how to add it to the WebAdmin.
Configuration
This is a bit tricky, to add an extra QueryHandler you must repeat the default QueryHandlers or else they won't be loaded.
To add a extra QueryHandler to the WebAdmin you have to add the following lines to the server configuration:
[xWebAdmin.UTServerAdmin] QueryHandlerClasses=class'xWebAdmin.xWebQueryCurrent' // one of the default QueryHandlers QueryHandlerClasses=class'xWebAdmin.xWebQueryDefaults' // one of the default QueryHandlers QueryHandlerClasses=class'xWebAdmin.xWebQueryAdmins' // one of the default QueryHandlers QueryHandlerClasses=class'MyPackage.MyQueryHandler' // your new QueryHandler
MyQueryHandler
To create a new QueryHandler you have to extend the class xWebQueryHandler
class MyQueryHandler extends xWebQueryHandler; var string SettingsPage; var string AboutPage; function bool Init() { Super.Init(); log("MyQueryHandler loaded"); return true; }
The method Init() is loaded when this page is loaded, if you need some things to be loaded or found you should do it here.
SettingsPage and AboutPage variables are use to identify the pages this query handler will handler. There's an additional variable defined in xWebQueryHandler, DefaultPage, this is the initial page the WebAdmin will link to the the links page.
function bool Query(WebRequest Request, WebResponse Response) { switch (Mid(Request.URI, 1)) { case DefaultPage: RequestDefault(Request, Response); return true; case SettingsPage: RequestSettings(Request, Response); return true; case AboutPage: RequestAbout(Request, Response); return true; } return false; }
The query event of the QueryHandler works about the same as for with the WebApplication with a few diffirences:
- It has a return value, if the page belongs to this query handler it should return true, otherwise return false
- You should not return a 404 error when you can't handle the page, the WebAdmin will to it for you.
The methods RequestDefault, RequestSettings and RequestAbout handle the request page. Check Creating A WebApplication on how to write such methods.
The DefaultPage is opened in a frame that can not scroll, so it's best that the DefaultPages creates another frameset with frames where it will open the actual pages. So you can create a menu like system on the left side like with the default WebAdmin pages
defaultproperties { DefaultPage="MyQueryHandler" SettingsPage="MyQueryHandler_Settings" AboutPage="MyQueryHandler_About" Title="MyQueryHandler" NeededPrivs="" }
These settings are pretty important. The above three settings define the names of the pages that this QueryHandler handles. It's very imporant that you use unique names for every page because you can obscure an other page if you use the same name.
The Title value is used as the title of the link that will be visible in the WebAdmin. NeededPrivs is a string with AdminControlIni privilege codes needed to use this page.
Your new QueryHandler will be visible in the QueryHandler links as seen above.