$this->image
);
}
+
+ function widget($name, $params = [])
+ {
+ $path = stream_resolve_include_path("widget/$name.php");
+ if (!file_exists($path)) {
+ return '<strong class="warn"><em>'.$name.'</em> ontbreekt</strong>';
+ }
+
+ ob_start();
+ $Page = clone $this;
+ $Page->handler = $Page->handler . $Page->path; // .= with explicit getter
+ $Page->path = '';
+ $Place = $GLOBALS['Place'];
+ foreach ($params as $param) {
+ if ($set = strpos($param, '=')) {
+ $Place[ substr($param, 0, $set) ] = substr($param, $set + 1);
+ }
+ elseif (!empty($param)) {
+ $Page->path .= '/'.$param;
+ }
+ }
+ $Page->link .= $Page->path;
+ try {
+ include "widget/$name.php";
+ return ob_get_clean();
+ }
+ catch (Exception $e) {
+ return sprintf('<strong class="warn">%s</strong>',
+ "fout in <em>$name</em>: {$e->getMessage()}"
+ );
+ }
+ }
}
class PageSearch
)->fetch();
if (!$Issue) throw new Exception('Issuenummer niet gevonden');
- $replies = placeholder_include('reply'); # handle updates
+ $replies = $Page->widget('reply'); # handle updates
$Page->title .= ': '.htmlspecialchars($Issue->subject);
$Page->teaser = $Issue->body;
<?php
if ($Page->path and $User->admin('user')) {
$user = new User(strtolower("profile{$Page->path}"), FALSE);
- print placeholder_include('login/admin');
+ print $Page->widget('login/admin');
$Page->title = "Profiel <em>{$user->login}</em>";
print "<h2>{$Page->title}</h2>\n";
- print placeholder_include('login/edit');
+ print $Page->widget('login/edit');
return;
}
}
}
if ($replyform) {
- print placeholder_include('reply');
+ print $Page->widget('reply');
}
return;
}
}
print "<h2>$title</h2>\n\n";
- print placeholder_include('nieuws', [$match]);
+ print $Page->widget('nieuws', [$match]);
return;
}
exit;
}
-function placeholder_include($name, $params = [])
-{
- $path = stream_resolve_include_path("widget/$name.php");
- if (!file_exists($path)) {
- return '<strong class="warn"><em>'.$name.'</em> ontbreekt</strong>';
- }
-
- ob_start();
- $Page = clone $GLOBALS['Page'];
- $Page->handler = $Page->handler . $Page->path; // .= with explicit getter
- $Page->path = '';
- $Place = $GLOBALS['Place'];
- foreach ($params as $param) {
- if ($set = strpos($param, '=')) {
- $Place[ substr($param, 0, $set) ] = substr($param, $set + 1);
- }
- elseif (!empty($param)) {
- $Page->path .= '/'.$param;
- }
- }
- $Page->link .= $Page->path;
- try {
- include "widget/$name.php";
- return ob_get_clean();
- }
- catch (Exception $e) {
- return sprintf('<strong class="warn">%s</strong>',
- "fout in <em>$name</em>: {$e->getMessage()}"
- );
- }
-}
-
function getoutput($blocks = [])
{
$doc = ob_get_clean();