aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes/Document.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/classes/Document.php')
-rw-r--r--include/classes/Document.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/classes/Document.php b/include/classes/Document.php
new file mode 100644
index 0000000..9b9893a
--- /dev/null
+++ b/include/classes/Document.php
@@ -0,0 +1,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>";
+ }
+}
+?> \ No newline at end of file