X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/772961fd4e9be46ad340cad1e55ee5f28cc5b968..7983570288ed2798470a552ec04f64aa646b664a:/article.inc.php diff --git a/article.inc.php b/article.inc.php index acd219d..b676dd0 100644 --- a/article.inc.php +++ b/article.inc.php @@ -170,6 +170,38 @@ class ArchiveArticle $this->image ); } + + function widget($name, $params = []) + { + $path = stream_resolve_include_path("widget/$name.php"); + if (!file_exists($path)) { + return ''.$name.' ontbreekt'; + } + + 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('%s', + "fout in $name: {$e->getMessage()}" + ); + } + } } class PageSearch