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
During the applets initialization, you have the opportunity to parse the GET arguments. Note that the Applet Manager does all the work!
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); }
The best location for these files are from the Minerva bundle, as this is the biggest project (to date) which uses them, and keeps the files up-to-date.