<?php
require_once ('assets/domit/xml_domit_include.php');
require_once ('assets/ParamsProxy.php');
/**
* Showcases the functionality of the ParamsProxy class.
* The ParamsProxy class is a generic, plug & play solution for making some arbitrary
* PHP class easy configurable.
* @author Claudius Tiberiu Iacob <hide@address.com>.
* @license Creative Commons Attribution Share Alike - Claudius Tiberiu Iacob 2009
*/
class ParamsProxyDemo {
public function __construct () {
$this->makePageHeader ();
// Hook up this class to the proxy:
ParamsProxy::getInstance()->configure($this);
}
public function __destruct () {
$this->makePageFooter ();
}
// Provide setter functions to receive values via the configuration file:
public function setA ($newValue) {
$this->dump ('a', $newValue);
}
public function setB ($newValue) {
$this->dump ('b', $newValue);
}
public function setC ($newValue) {
$this->dump ('c', $newValue);
}
public function setD ($newValue) {
$this->dump ('d', $newValue);
}
private function dump ($name, $value) {
ob_start ();
var_dump ($value);
$var_dump_output = ob_get_clean();
$format =
'<p> </p>
<table border="1">
<tr>
<th>name</th>
<th>"$value"</th>
<th>var_dump($value)</th>
</tr>
<tr>
<td>%s</td>
<td>%s</td>
<td><pre>%s</pre></td>
</tr>
</table>';
echo (sprintf ($format, $name, "$value", $var_dump_output));
}
private function makePageHeader () {
echo
'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>ParamsProxyDemo</title>
</head>
<body>';
}
private function makePageFooter () {
echo
'</body>
</html>';
}
}
$ParamsProxyDemo = new ParamsProxyDemo();
?>