|
@@ -331,9 +331,18 @@ class Page extends Element {
|
|
*/
|
|
*/
|
|
public function __construct(Context $context, array $item) {
|
|
public function __construct(Context $context, array $item) {
|
|
parent::__construct('html');
|
|
parent::__construct('html');
|
|
|
|
+ $context->setMessage($item, LOG_DEBUG);
|
|
$this->context = $context;
|
|
$this->context = $context;
|
|
$this->initializeHead();
|
|
$this->initializeHead();
|
|
$this->initializeBody();
|
|
$this->initializeBody();
|
|
|
|
+ if (method_exists($this, 'build')) {
|
|
|
|
+ $this->build();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function __toString() {
|
|
|
|
+ $html = new Element('html', NULL, $this->getHead() . $this->getBody());
|
|
|
|
+ return (string) $html;
|
|
}
|
|
}
|
|
|
|
|
|
public function finalizeBody() {
|
|
public function finalizeBody() {
|
|
@@ -411,11 +420,6 @@ class Page extends Element {
|
|
$this->setHead(new Element('title', NULL, 'Memcache info'));
|
|
$this->setHead(new Element('title', NULL, 'Memcache info'));
|
|
}
|
|
}
|
|
|
|
|
|
- public function render() {
|
|
|
|
- $html = new Element('html', NULL, $this->getHead() . $this->getBody());
|
|
|
|
- return (string) $html;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public function setBody($fragment, $region = 'content') {
|
|
public function setBody($fragment, $region = 'content') {
|
|
if (!in_array($region, $this->getRegions())) {
|
|
if (!in_array($region, $this->getRegions())) {
|
|
$this->context->setMessage(strtr('Attempted to insert data in nonexistent region @region', array(
|
|
$this->context->setMessage(strtr('Attempted to insert data in nonexistent region @region', array(
|
|
@@ -436,32 +440,20 @@ class Page extends Element {
|
|
}
|
|
}
|
|
|
|
|
|
class Page_Main extends Page {
|
|
class Page_Main extends Page {
|
|
- function finalizeBody() {
|
|
|
|
- $hello = new Element('p', NULL, 'Hello world');
|
|
|
|
- $this->setBody($hello);
|
|
|
|
- parent::finalizeBody();
|
|
|
|
|
|
+ function build() {
|
|
|
|
+ $this->setBody(new Element('p', NULL, 'Hello world'));
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
class Page_Server_Flush extends Page {
|
|
class Page_Server_Flush extends Page {
|
|
- public function __construct(Context $context, $item) {
|
|
|
|
- parent::__construct($context, $item);
|
|
|
|
- $context->setMessage($item, LOG_DEBUG);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function finalizeBody() {
|
|
|
|
- $hello = new Element('p', NULL, 'Flush server');
|
|
|
|
- $this->setBody($hello);
|
|
|
|
- parent::finalizeBody();
|
|
|
|
|
|
+ function build() {
|
|
|
|
+ $this->setBody(new Element('p', NULL, 'Flush server'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
class Page_Slab_Overview extends Page {
|
|
class Page_Slab_Overview extends Page {
|
|
- function finalizeBody() {
|
|
|
|
- $hello = new Element('p', NULL, 'Slabs');
|
|
|
|
- $this->setBody($hello);
|
|
|
|
- parent::finalizeBody();
|
|
|
|
|
|
+ function build() {
|
|
|
|
+ $this->setBody(new Element('p', NULL, 'Slabs'));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -585,8 +577,7 @@ function main() {
|
|
$router = new Router($context);
|
|
$router = new Router($context);
|
|
$item = $router->getRoute();
|
|
$item = $router->getRoute();
|
|
$page = new $item['page class']($context, $item);
|
|
$page = new $item['page class']($context, $item);
|
|
- // echo '<pre>'; var_dump($page);
|
|
|
|
- echo $page->render();
|
|
|
|
|
|
+ echo $page;
|
|
|
|
|
|
$html = ob_get_clean();
|
|
$html = ob_get_clean();
|
|
if ($context->getTidy()) {
|
|
if ($context->getTidy()) {
|