aboutsummaryrefslogtreecommitdiffstats
path: root/include/classes
diff options
context:
space:
mode:
Diffstat (limited to 'include/classes')
-rw-r--r--include/classes/BigPipe/BigPipe.php4
-rw-r--r--include/classes/Document.php34
2 files changed, 34 insertions, 4 deletions
diff --git a/include/classes/BigPipe/BigPipe.php b/include/classes/BigPipe/BigPipe.php
index d84083e..737e860 100644
--- a/include/classes/BigPipe/BigPipe.php
+++ b/include/classes/BigPipe/BigPipe.php
@@ -89,10 +89,6 @@ class BigPipe {
}
}
}
-
- if(self::enabled()) {
- echo "<script>BigPipe.onLastPageletArrived();</script>\n";
- }
}
}
?> \ No newline at end of file
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