aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes/Document.php
blob: 9b9893aba641e1b958aed904406bb160ebbb25ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use BigPipe\BigPipe;
use BigPipe\Pagelet;

class Document {
	private $contentCallbacks = [];
	private $pagelets = [];

	public function addPagelet(Pagelet $Pagelet, callable $callback) {
		$this->pagelets[] = $Pagelet;

		$this->contentCallbacks[$Pagelet->getID()] = $callback;

		if(!BigPipe::enabled()) {
			$Pagelet->addHTML($callback($Pagelet));
		}
	}

	public function render($content_html, $sidebar_html) {
		require 'template/document.php';
		BigPipe::flushOutputBuffer();

		if(BigPipe::enabled()) {
			foreach($this->pagelets as $Pagelet) {
				$Pagelet->addHTML($this->contentCallbacks[$Pagelet->getID()]($Pagelet));
				$Pagelet->flush();
			}
		}

		BigPipe::completeResponse();
		echo "</body>\n</html>";
	}
}
?>