WARP uses the abstractions in WebFace to create a facility where multiple pages can share the same control mechanism. i.e. show_log1.php can use the,
index.php?WRP001X1_sortorder=0component of the GET request, while free_space.php can use,
&WRP002X2_disk=3
It does this, primarily, by replacing the Web_Ctrl feature to build custom links for each "applet". (Each, applet being the name for the various server-side files that handle application-specific functionality.)
The replacement code is small:
function getParameterValue($param) { $app =& $this->_appman->getCurrentApplet(); $full = $this->_appman->getParameter($app, $param); return $this->_appman->queryArgument($full); }This is because the work is done by the appletmanager, which keeps a list of all applets running in the system (and their IDs).
function getParameter(&$applet, $argName) { $idx = $this->getAppletIndex($applet); return $applet->getID($this).$idx."_".$argName; }This ensures a unique parameter ID for each applet. You can see this by studying the URL,
http://www.warpdemo.homelinux.net/index.php?WRP001X1_current=0& WRP003X3_current=1&MIN004A4_current=0&WRP004X5_sort=11&WRP004X5_mx=10& WRP004X5_opt=&WRP005X6_sort=11&WRP005X6_mx=10&WRP005X6_opt=& max=WRP003X&wintype=main&content=WRP003X&WRP003X3_cmd=nextIf we break it down, you'll see these system parameters:
Underneath, the directory structure keeps applets separate. The directories within WARP are: applets conf system warplib
function init(&$appMan) { // pickup any control parameters passed in $prm = $appMan->queryParameter($this, "on"); if ($prm != "") { X10::setStatus($prm, X10::$device_on); } }The other half of the equation involves creating a suitably configured link:
$html.= $appMan->getAppletLink($this, "on", "bedroom_light", "Switch Light On");For anything that isn't a command, but merely holds additional state there this:
function getRefreshParams(&$appMan) { return $appMan->getArgument($this, "current", $this->_which); }
<? include 'warp/warplib/appletmanager.inc'; include 'warp/applets/main/main.inc'; include 'warp/applets/top/top.inc'; include 'warp/applets/useragent/ua.inc'; include 'warp/applets/diskfree/df.inc'; include 'warp/applets/smbstatus/smbstatus.inc'; include 'warp/applets/static/static.inc'; include_once 'warp/system/master_standard.conf'; $appman = new Warp_Applet_Manager; $appman->init(); $appman->AddApplet(new Warp_Main_Applet()); $appman->AddApplet(new Warp_Disk_Space_Applet()); $appman->AddApplet(new Warp_UA_Applet()); $appman->AddApplet(new Warp_Top_Applet()); $appman->AddApplet(new Warp_SambaStatus_Applet()); $appman->AddApplet(new Warp_Static_Text_Applet()); echo $appman->renderPage(); ?>