+sub cgitemplate ($$$;@) {
+ my $cgi=shift;
+ my $title=shift;
+ my $content=shift;
+ my %params=@_;
+
+ my $template=template("page.tmpl");
+
+ my $topurl = $config{url};
+ if (defined $cgi && ! $config{w3mmode} && ! $config{reverse_proxy}) {
+ $topurl = $cgi->url;
+ }
+
+ my $page="";
+ if (exists $params{page}) {
+ $page=delete $params{page};
+ $params{forcebaseurl}=urlto($page);
+ }
+ run_hooks(pagetemplate => sub {
+ shift->(
+ page => $page,
+ destpage => $page,
+ template => $template,
+ );
+ });
+ templateactions($template, "");
+
+ my $baseurl = baseurl();
+
+ $template->param(
+ dynamic => 1,
+ title => $title,
+ wikiname => $config{wikiname},
+ content => $content,
+ baseurl => $baseurl,
+ html5 => $config{html5},
+ %params,
+ );
+
+ return $template->output;
+}
+
+sub redirect ($$) {